docs: structured events index across contracts#592
Open
obswrld wants to merge 1 commit into
Open
Conversation
- Add docs/EVENTS_INDEX.md: canonical index of every event emitted by settlement, revenue_pool, and vault, defining the target topic shape (Topic1=contract, Topic2=action, Topic3=subject), documenting current state, and defining a backwards-compat migration ladder (Stage 0: current 2-topic shape -> Stage 1: dual-publish -> Stage 2: cutover) - Add scripts/check-event-shape.sh: CI grep gate that fails if any events().publish() call site uses a raw inline Symbol::new(...) topic literal instead of a centralized events::event_*() constructor - Fix settlement contract: force_credit_developer and upgrade were using inline Symbol::new literals instead of centralized constructors; added event_developer_force_credited() and event_upgraded() to events.rs with matching byte-identity snapshot tests, updated call sites in lib.rs - Fix vault contract: prune_request_ids was using an inline Symbol::new literal instead of a centralized constructor; added event_request_id_pruned() to events.rs with a matching snapshot test, updated call site in lib.rs - Verified scripts/check-event-shape.sh passes cleanly (0 violations) after fixes, and correctly fails when a violation is reintroduced (manually tested and reverted) Note: contracts/settlement and contracts/vault have pre-existing compile errors on main unrelated to this change (missing types referenced by an admin broadcast function, argument mismatches in unrelated withdraw_developer_balance test calls, missing Box imports in test_invariant.rs). Verified via git stash comparison that these exist on main independent of this branch. Not fixed here as they are out of scope for this issue. Closes CalloraOrg#487
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.
Summary
Closes #487
Defines a stable topic structure for events across
settlement,revenue_pool, andvault, documents every emitted event, adds a CI gate enforcing event-shape discipline, and defines a backwards-compatibility ladder for migrating events toward the target shape over time.Changes
docs/EVENTS_INDEX.md(new)scripts/check-event-shape.sh(new)events().publish()call site uses a raw inlineSymbol::new(...)topic literal instead of a centralizedevents::event_*()constructorDrift fixes found and fixed via the new gate
While building the gate, it surfaced two real violations already in the codebase:
contracts/settlement:force_credit_developerandupgradeused inlineSymbol::new(&env, "developer_force_credited")/"upgraded"instead of centralized constructors. Addedevent_developer_force_credited()andevent_upgraded()toevents.rswith matching byte-identity snapshot tests; updated call sites.contracts/vault:prune_request_idsused an inlineSymbol::new(&env, "request_id_pruned"). Addedevent_request_id_pruned()toevents.rswith a matching snapshot test; updated call site.Pre-existing build issue (out of scope)
contracts/settlementandcontracts/vaulthave pre-existing compile errors onmain, unrelated to this change:Severity/String/AdminBroadcasttypes referenced by an admin broadcast functionwithdraw_developer_balancetest callsBoximports intest_invariant.rsVerified via
git stashcomparison that these exist onmainindependently of this branch. Not fixed here as out of scope for this issue — flagging for maintainer awareness since they blockcargo testfor the whole crate.Acceptance Criteria
docs/EVENTS_INDEX.md)scripts/check-event-shape.sh, tested pass + fail cases)event_*()constructors required, no inline literals)