Skip to content

refactor(schema): declare event durability at definition level - #35172

Merged
kitlangton merged 5 commits into
v2from
event-foundations
Jul 3, 2026
Merged

kitlangton merged 5 commits into
v2from
event-foundations

Conversation

@kitlangton

@kitlangton kitlangton commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Part of the V2 event audit (#35021, first slice of #35014).

What

  • Adds explicit Event.durable(...) / Event.ephemeral(...) definition constructors; every event definition in packages/schema now declares its durability at the definition site.
  • Removes the implicit Event.define entirely (no durable config ⇒ silently ephemeral was exactly the failure mode this refactor exists to prevent). Core test call sites converted to the explicit constructors.
  • DurableDefinitions and the V1 durable/live manifest split are now derived by filtering definition metadata instead of hand-maintained inventory lists; hand-counted manifest tests replaced with derivation-based membership assertions.
  • Wire envelope now encodes classification: durable events require durable: { aggregateID, seq, version }, ephemeral events omit the field entirely (previously durable? was optional on every event type). Definition is a discriminated DurableDefinition | EphemeralDefinition union, so payload types narrow. Runtime already guaranteed this — every durable publish/replay/commit path attaches the position before any envelope-schema encode; verified no path validates earlier.

Not in this PR

Zero behavior change by design: no event renames, no payload changes, no migrations. Durable membership before/after is identical (38 durable / 65 ephemeral, membership diffed empty in both directions). The rename sweep, payload strips, stored envelope created, and the reset migration follow in the next PR.

Test-only fallout: event fixtures in packages/sdk-next and two packages/opencode test files (stream-v2 transport, message-updater) gained required durable envelopes / narrowing — no V1 production code touched.

Verification

  • Full-repo bun turbo typecheck (35 packages) green.
  • packages/schema event/manifest tests; packages/core event, session-log, session-prompt, tool-progress, and session-create tests; packages/sdk-next embedded tests; packages/opencode stream-v2 transport + message-updater tests.
  • Generated trees regenerated via bun run generate (packages/client) and packages/sdk/js/script/build.ts; no hand edits. Generated diff shape confirmed: no durable? remains anywhere.
  • Grep-proof: no Event.define call sites remain.

Add explicit durable and ephemeral event definition constructors.

Derive durable inventories from definition metadata while preserving classifications.

Regenerate client and legacy SDK outputs and document the schema refactor.
@kitlangton
kitlangton force-pushed the event-foundations branch from 3788ab9 to 7acb392 Compare July 3, 2026 16:25
@kitlangton
kitlangton merged commit de476aa into v2 Jul 3, 2026
7 checks passed
@kitlangton
kitlangton deleted the event-foundations branch July 3, 2026 16:35
jinhuang712 pushed a commit to jinhuang712/opencode that referenced this pull request Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant