Skip to content

feat(id): phase 5 client/operations surface + gated enablement for region-seam handoff (#3904) - #9175

Merged
dezren39 merged 2 commits into
mainfrom
queue/5867-3904-phase5-client-ops
Nov 14, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/5867-3904-phase5-client-ops

Conversation

@dezren39

@dezren39 dezren39 commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Implements #3870 phase 5 (issue #3904) — client/operations surface + gated enablement for region-seam handoff, per design #2818 §8 packet 5. The hard gate is now satisfied: phase 4 issue #3903 closed via PR #9000 (merged 7904547).

Phases 1-4 built the journal, source fence, import primitive, and the Coordinator state machine, but the coordinator was wired to no client surface: no feature gate, no routing decision, no observability. This PR adds world::handoff_operations:

  • Feature gate, disabled by default. HandoffOperations::new starts with handoffs off; begin_handoff refuses with OpsError::HandoffsDisabled and journals nothing. Enablement is an explicit operator act (set_enabled). Turning the gate off strands nothing: in-flight handoffs keep status/routing answers and can still complete.
  • Fail-closed client routing. route_operation is the single decision for a client operation: while an entity is in transit, reads AND writes return the typed, retryable EntityInTransit status (design §4 — no entity snapshot projection exists, commands are never queued/replayed). A started handoff with no export yet still serves at the source.
  • Stale-route response. A client presenting a route that disagrees with the owner map (e.g. the old source route after completion) gets typed StaleRoute carrying the new owner epoch and region-map epoch, retryable through the coordinator. The fenced source never serves again; epochs are monotonic.
  • Age/reason observability. ops_snapshot(now) returns per-handoff age, time since last journaled progress, stage, machine-readable reason (awaiting_source_export / awaiting_destination_import / awaiting_coordinator_completion / stuck_no_progress_over_threshold), in-transit count, and the stuck count (60s threshold, STUCK_THRESHOLD_MS) that alerting keys off. Stuck remains an alert classification only — no completion, rollback, or re-route.
  • Coordinator::tracked_entities() added so the surface can enumerate the owner map without the map leaving the coordinator.

Acceptance suite (in-module tests): drives a full crossing with duplicate export delivery — no completion without a matching durable import, no write served at the source after export, exactly one completion/owner transition for repeated receipts, journal replay reproducing the post-completion routing — plus gate-default-off, fail-closed reads+writes, stuck boundary at exactly 60s, unknown-entity refusal, and gate-off-mid-flight.

Tests: cargo test -p id-worlds — 756 passed, 0 failed (7 new). Clippy clean for the new module.

Task 5867 (queue repo-health-code-pilot), lane code-c.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • New Features
    • Added handoff routing that identifies entities in transit and flags outdated client routes with the current region and owner version.
    • Handoff operations can be enabled or disabled; handoffs are disabled by default, while routing and status checks remain available.
    • Added operation snapshots showing active handoffs, their progress and age, and which have stalled.

…gion-seam handoff (#3904)

HandoffOperations over the phase-4 Coordinator: feature gate disabled by default (begin_handoff refuses and journals nothing while off), fail-closed routing for reads and writes while in transit with the typed EntityInTransit status, typed StaleRoute response carrying the new owner epoch, and an ops snapshot exposing per-handoff age/reason plus the stuck count for alerting. Coordinator gains tracked_entities() for enumeration. Acceptance suite drives a full crossing with duplicate receipt delivery and journal replay: no completion without a matching durable import, no write served at the source after export, exactly one completion/owner transition, replay reproduces routing. Handoffs remain disabled by default; enablement is an explicit operator act.
@dezren39
dezren39 requested a review from a team as a code owner November 13, 2026 02:25
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The change adds a handoff operations API that wraps Coordinator. It gates handoff starts, routes reads and writes according to transit and ownership state, and reports active handoffs in snapshots. The world module re-exports the new types.

Changes: Handoff operations

Layer / File(s) Summary
Define routing and operations contracts
pkgs/id/crates/id-worlds/src/world/coordinator.rs, pkgs/id/crates/id-worlds/src/world/handoff_operations.rs, pkgs/id/crates/id-worlds/src/world/mod.rs
Coordinator::tracked_entities returns sorted entity references. The world module declares the operations module and re-exports its routing, operations, and snapshot types.
Implement handoff operations
pkgs/id/crates/id-worlds/src/world/handoff_operations.rs
HandoffOperations gates handoff starts and provides transit-status lookup, operation routing, and snapshots with handoff age and stuck status.
Validate routing, handoff progression, and recovery
pkgs/id/crates/id-worlds/src/world/handoff_operations.rs
Tests cover gate behavior, routing decisions, snapshots, handoff progression, generated operation sequences, and journal-prefix recovery.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant HandoffOperations
  participant Coordinator
  Client->>HandoffOperations: route_operation(entity_ref, presented route)
  HandoffOperations->>Coordinator: inspect transit and owner state
  Coordinator-->>HandoffOperations: transit or current owner state
  HandoffOperations-->>Client: RouteDecision
Loading
Merge Risk: Moderate · up to ca168

The new handoff operations feature works as described, but its acceptance tests use operations the project lints deny, without the required exemption. The repository's Clippy check will fail. Add the lint allowance to the test module before merging; production behavior is not affected.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Clippy (1.99.1)

Clippy execution timed out

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-14T06:22:16.255598Z
We couldn’t complete this review. Comment @codex review to try again.
ca16812 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c3230b4e6f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dezren39

Copy link
Copy Markdown
Member Author

🤖 Agent note · picked up

…ng (#9793)

Extend the generated model to the phase-5 operations surface: proptest sequences drive gate toggles, begin_handoff, receipt observation, completion, cancellation and crash recovery through HandoffOperations, checking routing (both kinds; absent/correct/stale presented routes), the unknown-entity refusal, and the full ops_snapshot against an explicit model oracle after every transition. A deterministic companion test checks journal-prefix recovery against the same oracle. Dispositions the Codex P1 on PR #9175 (discussion r4558973564).
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@dezren39
dezren39 merged commit db524b4 into main Nov 14, 2026
1 check failed
@dezren39
dezren39 deleted the queue/5867-3904-phase5-client-ops branch November 14, 2026 06:28
@dezren39 dezren39 removed status/in-progress Queue worker lifecycle state queue/claimed Queue worker lifecycle state work/assigned Queue worker lifecycle state labels Nov 14, 2026
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