Skip to content

feat(events): version contract event schemas, add catalogue, and shape tests - #88

Open
ranjeet150 wants to merge 1 commit into
FinesseStudioLab:mainfrom
ranjeet150:feat/version-event-schema
Open

ranjeet150 wants to merge 1 commit into
FinesseStudioLab:mainfrom
ranjeet150:feat/version-event-schema

Conversation

@ranjeet150

@ranjeet150 ranjeet150 commented Sep 27, 2026 •

Copy link
Copy Markdown

Summary of Changes

Events are a public interface. Once an indexer, export pipeline, or partner consumes them, altering a topic or reordering a data payload silently breaks downstream consumers without compile-time warnings.

This PR implements event schema versioning, documents the complete catalogue, establishes evolution and compatibility policies, and adds exact shape assertion regression tests.

Key Changes

  1. Schema Versioning Across All Events:

    • Defined pub const EVENT_SCHEMA_VERSION: u32 = 1; in audit-registry, payment-router, and usage-meter.
    • Added #[topic] pub version: u32 as the leading topic across every event topic tuple:
      • audit-registry: CallerAllowed, CallerRevoked, AttestationRecorded, AttestationSuperseded
      • payment-router: EscrowOpened, PartialReleased, Claimed, Disputed, DisputeResolved, EscrowClosed, SettlementFailed, SettlementRecovered, DeadLettered
      • usage-meter: RegistrySet, PolicySet, UsageRecorded
    • Updated all event emission sites to supply version: EVENT_SCHEMA_VERSION.
  2. Event Catalogue & Compatibility Specification:

    • Created docs/event-catalogue.md containing the complete catalogue: event name, emitting entrypoint, topic tuple, and detailed data payload layout with types and field descriptions.
    • Documented the schema evolution and compatibility policy: additive changes only within a version, version increment on breaking changes, dual-emission during migration windows, and test shape enforcement.
    • Linked catalogue documentation in README.md.
  3. Automated Generator Script:

    • Added scripts/generate_event_catalogue.py to parse #[contractevent] definitions from Rust code and verify or regenerate documentation with --check flag for CI integration.
  4. Exact Shape Assertion Regression Tests:

    • Added dedicated test_event_shapes_and_versioning suites in each crate (audit-registry/src/test.rs, payment-router/src/test.rs, usage-meter/src/test.rs).
    • Asserts exact event XDR shape, contract address, topics layout, and payload fields across all 16 contract events.

Closes #78

…e tests

- Add EVENT_SCHEMA_VERSION = 1 to audit-registry, payment-router, and usage-meter
- Include schema version in every event topic tuple:
  * audit-registry: CallerAllowed, CallerRevoked, AttestationRecorded, AttestationSuperseded
  * payment-router: EscrowOpened, PartialReleased, Claimed, Disputed, DisputeResolved, EscrowClosed, SettlementFailed, SettlementRecovered, DeadLettered
  * usage-meter: RegistrySet, PolicySet, UsageRecorded
- Document full event catalogue and schema compatibility policy in docs/event-catalogue.md
- Add generator script scripts/generate_event_catalogue.py with CI verification flag (--check)
- Add exact event shape and topic regression tests across all three contract test suites
- Link event catalogue in README.md

Closes FinesseStudioLab#78
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Version the contract event schema before integrators depend on it

1 participant