feat: optionally require service registration before set_service_price#75
Merged
mikewheeleer merged 1 commit intoJun 24, 2026
Conversation
Closes Agentpay-Org#11. set_service_price accepted a price for any service_id, even phantom/unregistered/disabled ones, letting prices drift apart from the registry. Couple it to the existing RequireServiceRegistration flag: when strict mode is on, pricing an unregistered service is rejected with ServiceNotRegistered (Agentpay-Org#7); a disabled service is always rejected with ServiceDisabled (Agentpay-Org#12), mirroring record_usage. Default (flag off) keeps the prior behaviour. Emit price_set(service_id, price) after validation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #11.
Problem
set_service_priceaccepted a price for anyservice_id— even one never registered, with no metadata, or disabled. This let prices accumulate for phantom services and let the registry and pricing tables drift apart.Change
Couple pricing to registration via the existing
RequireServiceRegistrationflag (the same onerecord_usagehonours):service_idis allowed — fully backward compatible.ServiceNotRegistered(Add contract upgradeability via update_current_contract_wasm #7).ServiceDisabled(Add a paginated query entrypoint to enumerate an agent's active services #12), mirroringrecord_usage's gate.price_set(service_id, price_stroops)— after every validation passes.No new error codes (reuses #7 / #12); error codes stay append-only.
Tests
test_set_price_lax_allows_unregistered_service(default behaviour)test_set_price_strict_allows_registered_servicetest_set_price_strict_rejects_unregistered_service→#7test_set_price_rejects_disabled_service→#12test_set_price_flag_toggled_mid_life→#7cargo fmt --all -- --check,cargo build,cargo testall green — 56 passed; 0 failed.Security notes
No behaviour change when the flag is off. With it on, prices can only attach to real, enabled services.