Skip to content

fix(runtime): atomically repair terminal Run projections - #461

Open
AsperforMias wants to merge 1 commit into
langgenius:mainfrom
AsperforMias:fix/runtime-atomic-terminal-projections
Open

fix(runtime): atomically repair terminal Run projections#461
AsperforMias wants to merge 1 commit into
langgenius:mainfrom
AsperforMias:fix/runtime-atomic-terminal-projections

Conversation

@AsperforMias

Copy link
Copy Markdown
Collaborator

Closes #416

Summary

  • Atomically persist a current Run status transition and its Session lifecycle projection in one D1 batch, retaining the status-sequence compare-and-swap guard.
  • Reconcile terminal Runs after a Driver is lost or stopped when a terminal runtime event or the Session projection is missing; recovery uses deterministic source event IDs and is idempotent.
  • Make the SQLite D1 test double serialize concurrent batches so its transaction semantics match D1.

Why

A Driver can persist a terminal session_run update and then be lost before the matching Session projection and terminal event are durably visible. That can leave a Session stuck in RUNNING or omit the terminal receipt. This closes #416 without requiring a schema migration or Driver change.

Verification

  • Commands:
  • Manual steps:
    • Exercised injected rollback and concurrent-transition cases; verified terminal-event recovery is idempotent and does not overwrite a newer Run.
  • Not run:
    • Cloudflare/production deployment and credentialed live-provider E2E; neither is needed for this persistence-only change.

Impact

  • User/API/contract changes: no public API or contract change. Terminal Run effects become durable and eventually repairable after Driver loss.
  • Generated files / GraphQL / DB / lockfile: none. No schema or migration change.
  • Env or config changes: none.
  • Risk and rollback: limited to runtime Session Run persistence and maintenance reconciliation. A revert restores the prior behavior; no data rewrite is involved.

Review

  • Closest review areas: session_run status CAS, Session lifecycle projection, runtime maintenance, session-event idempotency, and D1 batch semantics.
  • Known trade-offs: reconciliation is bounded by the maintenance batch limit and deliberately only repairs durable terminal evidence after the Driver is absent, failed, or stopped.

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.

fix(runtime): atomically finalize Run projections and repair missing terminal events

1 participant