Skip to content

fix: retain modeled wait-path obligations - #243

Open
patrickleet wants to merge 9 commits into
fix/live-ownership-handofffrom
fix/live-root-index-handoff
Open

fix: retain modeled wait-path obligations#243
patrickleet wants to merge 9 commits into
fix/live-ownership-handofffrom
fix/live-root-index-handoff

Conversation

@patrickleet

@patrickleet patrickleet commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

This change makes causal projection evidence identify the semantic projection program that authored it. Modeled wait-path receipts retain their event-derived obligations, and query/live responses use the persisted program identity when they emit observations.

When a cell commits a terminal succeeded receipt before an asynchronous projection has written its proof, status evaluation checks the retained obligations instead of dropping them. The public command state remains succeeded; exact matching observations are exposed only after durable proof exists. A proof with a different semantic program identity remains pending.

The JavaScript command runtime now treats a terminal succeeded status with the complete exact observations as delivered for receipt.projected, while keeping the accepted optimistic layer until a canonical query or live frame confirms read-model membership. This keeps @load operations valid without forcing every operation to become @live or issuing an unconditional refetch.

Why this matters

An aggregate command can be durably accepted before its asynchronous projection is visible. The client must keep its optimistic layer until the exact causal observation arrives, but a physical projector name is not enough to distinguish two program revisions sharing the same owner and topology.

The durable projection change and observation rows now carry the versioned program identity present at commit time. The identity is preserved through SQLite, PostgreSQL, in-memory, replay, and live-wire paths. A nullable program_id migration is intentional: pre-migration rows remain readable, but unversioned history cannot mint modeled causal proof or be relabeled by a new active deployment. A valid prior program identity remains distinct from a replacement program, including after a cold restart and during fan-out.

This preserves the existing strict causation, model, scope, revision, and incarnation checks. Atomic/direct projections, unselected projections, and legacy physical-name evidence retain their existing paths. The change does not claim queue delivery, projector completion, or record-clock ordering from a command receipt.

Verification

  • npm test — 388 passed, 0 failed
  • npm run check — passed
  • node --test tests/replica-command-runtime.test.mjs — 73 passed, 0 failed
  • cargo test --features graphql,sqlite --lib — 1,019 passed, 0 failed
  • cargo test --no-default-features --features graphql,sqlite --test graphql_query_protocol -- --nocapture — 17 passed, 0 failed
  • cargo check --features graphql,postgres — passed
  • graphql_succeeded_status_evaluates_retained_projection_evidence — passed; exercises the SQLite ledger, GraphQL commandStatus, ordered modeled projector, pending proof, matching proof, and mismatched semantic program identity
  • wire_snapshot_preserves_persisted_modeled_identity_and_receipt_scope — passed; exercises SQLite commit, persisted identity, wire_live_metadata, and public observation token equality
  • wait_path_observation_proof_requires_the_persisted_semantic_program_identity — passed; covers matching, missing, wrong-program, wrong-causation, wrong-model, cold-restart, and replacement identities

No application UI copy or behavior was changed; the JavaScript README documents the delivery-versus-canonical-retirement boundary.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 502bfc98-8e7a-49c4-a721-ec3e82d91b2f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 69b05402-f22c-4bc0-8b75-a8c94dc51839

📥 Commits

Reviewing files that changed from the base of the PR and between 856e3be and 4d08f12.

📒 Files selected for processing (37)
  • distributed_cli/src/contracts/tests.rs
  • js/tests/replica-command-runtime.test.mjs
  • migrations/inventory.json
  • migrations/postgres/0007_projection_program_identity.sql
  • migrations/sqlite/0007_projection_program_identity.sql
  • src/command/direct_projection.rs
  • src/command_ledger/tests.rs
  • src/graphql/projection_delta/runtime.rs
  • src/graphql/projection_delta/tests.rs
  • src/graphql/protocol/tests.rs
  • src/graphql/query_protocol.rs
  • src/graphql/surface/tests.rs
  • src/in_memory_repo/projection_protocol/direct_projection.rs
  • src/in_memory_repo/projection_protocol/rebuild.rs
  • src/in_memory_repo/projection_protocol/state.rs
  • src/in_memory_repo/projection_protocol/state_impl.rs
  • src/in_memory_repo/projection_protocol/store_impl.rs
  • src/in_memory_repo/projection_protocol/tests.rs
  • src/microsvc/projector/runtime.rs
  • src/microsvc/service/causal.rs
  • src/projection/catalog.rs
  • src/projection_protocol/store/identity.rs
  • src/projection_protocol/store/mod.rs
  • src/projection_protocol/store/query.rs
  • src/projection_protocol/store/replay.rs
  • src/projection_protocol/store/tests.rs
  • src/projection_protocol/workspace.rs
  • src/sqlx_repo/projection_protocol/helpers.rs
  • src/sqlx_repo/projection_protocol/mod.rs
  • src/sqlx_repo/projection_protocol/reads.rs
  • src/sqlx_repo/projection_protocol/rebuild.rs
  • src/sqlx_repo/projection_protocol/store_impl.rs
  • src/sqlx_repo/projection_protocol/tests.rs
  • src/sqlx_repo/projection_protocol/writes.rs
  • src/sqlx_repo/repo/backend.rs
  • tests/postgres_repository/main.rs
  • tests/sqlite_repository/main.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change adds semantic projection program identity to projection ownership, persisted changes, observations, replay data, query protocol mapping, causal proof, wait-path handling, and command-runtime tests. It also adds migration version 7 and validates identity across restarts and fan-out models.

Changes

Semantic projection identity

Layer / File(s) Summary
Identity contracts and query mapping
src/projection_protocol/..., src/graphql/query_protocol.rs, src/graphql/surface/tests.rs, src/microsvc/projector/runtime.rs
Projection ownership and workspaces carry optional program identities. Modeled query runtimes map each output model to its semantic program ID.
Repository persistence and replay
migrations/..., src/in_memory_repo/projection_protocol/..., src/sqlx_repo/projection_protocol/..., src/projection_protocol/store/replay.rs, src/projection_protocol/store/query.rs
Migration 7 adds nullable identity columns. In-memory and SQLx paths write, read, decode, and replay program identities.
Causal proof and wait-path behavior
src/graphql/projection_delta/runtime.rs, src/graphql/query_protocol.rs, src/microsvc/service/causal.rs, src/graphql/projection_delta/tests.rs
Modeled observations require the persisted semantic identity. Wait-path obligations remain pending until matching evidence exists.
Command runtime validation
js/tests/replica-command-runtime.test.mjs
Command-runtime helpers support configurable models. Tests reject mismatched causal frames and retire overlays only after exact live observations.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CommandRuntime
  participant QueryProtocol
  participant ProjectionRepository
  participant CausalService
  CommandRuntime->>QueryProtocol: request projection observation
  QueryProtocol->>ProjectionRepository: read persisted program identity
  ProjectionRepository-->>QueryProtocol: return change and observation data
  QueryProtocol->>CausalService: provide matching causal evidence
  CausalService-->>CommandRuntime: retire overlay and seal receipt
Loading

Merge Risk: ⚪ Minimal · up to 4d08f

No actionable merge-blocking risk was identified in the semantic projection identity changes.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.23% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 87 functions across 34 files. (3 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes a central change: retaining modeled wait-path obligations. It is concise, specific, and consistent with the pull request objectives.
Full details: Docstring Coverage

Explanation

Docstring coverage is 40.23% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 87 functions across 34 files. (3 skipped: 3 unsupported.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/live-root-index-handoff

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@patrickleet

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

1 participant