Skip to content

Emit neutral JSON schema artifact (db/event_schema.json)#161

Merged
tylercschneider merged 6 commits into
mainfrom
feat/json-schema-artifact
Jul 1, 2026
Merged

Emit neutral JSON schema artifact (db/event_schema.json)#161
tylercschneider merged 6 commits into
mainfrom
feat/json-schema-artifact

Conversation

@tylercschneider

Copy link
Copy Markdown
Collaborator

Summary

Adds a parallel, neutral JSON artifact — db/event_schema.json — generated from the same compiled schema as db/event_schema.rb, so BI/data consumers can read every event's shape and version without running Ruby or evaluating the executable schema file.

Purely additive: the Ruby artifact format, the boot/runtime path, the DSL, and the helper signatures are all unchanged. The JSON is written during the same schema dump.

What changed

  • Schema#to_h — plain-data hash parallel to to_ruby: event_name, event_version, event_type, process_type, subject, domain, required_inputs, optional_inputs, payload_fields (each name/from/attr/required), and fingerprint.
  • EventSchemaJsonWriter — serializes a full compiled EventSchema (all events, all versions) to JSON, one object per event+version, sorted [event_name, event_version] like EventSchemaWriter. Output is byte-identical on unchanged re-dump.
  • EventSchemaDumper.dump! takes an optional json_path: and writes the JSON when given.
  • event_engine:schema:dump rake task writes db/event_schema.json next to db/event_schema.rb.
  • README documents the JSON contract.

Testing

  • New unit tests for to_h, the JSON writer (ordering + determinism), and the dumper wiring.
  • bundle exec rake test — 162 runs, 0 failures.

Out of scope (per the issue)

Making JSON canonical at runtime, drift-guard coverage of the JSON file, RBS generation, and conforming to a formal JSON Schema meta-schema — each a separate task.

Closes #157. Part of the #152 plan.

🤖 Generated with Claude Code

tylercschneider and others added 6 commits July 1, 2026 14:30
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tylercschneider tylercschneider merged commit fe62196 into main Jul 1, 2026
3 checks passed
@tylercschneider tylercschneider deleted the feat/json-schema-artifact branch July 1, 2026 18:41
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.

Emit a neutral JSON schema artifact (db/event_schema.json) alongside the Ruby schema file

1 participant