indexer: add JSON schema and validate-schema script for events.ndjson - #241
Open
divinemike019 wants to merge 1 commit into
Open
indexer: add JSON schema and validate-schema script for events.ndjson#241divinemike019 wants to merge 1 commit into
divinemike019 wants to merge 1 commit into
Conversation
- Add indexer/events.schema.json (JSON Schema draft 2020-12) documenting all seven event record types emitted by the splitter contract: split_created, split_paid, split_updated, split_closed, control_transferred, deposited, distributed, plus an undecoded fallback. - Add indexer/validate-schema.mjs that reads events.ndjson line by line, validates each record against the schema with AJV, and exits 0/1. - Add ajv@^8.17.1 and ajv-formats@^3.0.1 as devDependencies and a validate-schema npm script to indexer/package.json. - Update indexer/README.md with an Event schema section and a Validating a log file subsection. Closes tributary-protocol#174
Contributor
|
@divinemike019 KINDLY RESOLVE CONFLICTS |
Spagero763
enabled auto-merge (squash)
July 30, 2026 03:50
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 #174
The event record format was undocumented. This PR adds a formal JSON Schema for
events.ndjsonand a validation script so any log file can be machine-checked against it.Changes
indexer/events.schema.json— JSON Schema draft 2020-12 describing all seven event record types emitted by the splitter contract (split_created,split_paid,split_updated,split_closed,control_transferred,deposited,distributed) plus anundecodedfallback. Common envelope fields (ledger,txHash,id,at,type) are required on every record; thetypeconstant selects the matchingoneOfbranch with its additional required fields.indexer/validate-schema.mjs— readsevents.ndjson(or a path given as the first argument) line by line, validates each JSON record against the schema using AJV, and exits0on success or1with per-line error details on failure. Run withnpm run validate-schema.indexer/package.json— addsajv@^8.17.1andajv-formats@^3.0.1as dev dependencies and avalidate-schemascript.indexer/README.md— adds an Event schema section that tables all event types and their fields, and a Validating a log file subsection with usage instructions.Testing
validate-schema.mjs: 8 representative records (one per type) all pass; a record missing a required field correctly exits 1 with a descriptive error.cargo fmt --all,cargo clippy --all-targets -- -D warnings, andcargo testall pass (30/30 tests). No Rust code was changed.