Skip to content

feat(id-worlds): durable per-world journal positions on lease entries (#13711) - #13829

Open
dezren39 wants to merge 1 commit into
mainfrom
xaltha/13711-journal-position
Open

dezren39 wants to merge 1 commit into
mainfrom
xaltha/13711-journal-position

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Summary

Refs #13711 (prerequisite for #7572 failover barrier). Lease entries
now carry a durable, monotonic per-world journal position, stamped
by the append authority and recorded in the lease history, so a
checkpoint carries every covered position and a successor replaying
the journal reports its watermark through it.

  • JournalEntry lease variants (LeaseGranted, LeaseRenewed,
    LeaseHandedOff, LeaseRevoked, LeaseWriteRejected) gain
    position: u64 (#[serde(default)] — 0 means unstamped, a
    lease entry written before positions existed).
  • WriteLeaseTransition / LeaseWriteRejection gain position;
    WriteLease::last_position() is the replay watermark.
  • WorldCore exposes lease_position_watermark() and
    next_lease_position(); the actor handoff stamps the next
    position before its durable append (a failed append drops the
    uncommitted lease, so the counter — derived from history — never
    advances past a durable record).
  • Replay refuses a stamped position that does not advance past the
    highest stamped position already seen.
  • Journal version 16 for stamped positions (entries and checkpoints
    whose lease history carries one); unstamped entries keep version 7
    and restore unchanged.

Scope note (decide-and-proceed): positions cover lease entries only,
per the issue's request ("every journal entry that changes lease
state (and ideally all entries)"). Per-entry positions for all
entries remain the JournalRecord envelope follow-up (design #2819).
A checkpoint records the last covered lease position through the
lease history it carries (its max is the watermark); no redundant
Checkpoint.position field was added.

Evidence

  • Property test (lease_positions_are_strictly_increasing_across_appends_and_compaction, proptest over the lease state machine — handoff/renew/revoke/grant sequences): history positions are exactly 1..=n after restore and after compaction + restore; watermark is n.
  • Oracle test (lease_position_watermark_reports_the_grant_position_after_replay): grant at position 3 reports watermark 3, before and after compaction; bootstrap reports 0.
  • Legacy test: unstamped entries restore under a version-7 header with watermark 0. Non-monotonic test: a stamped position that does not advance is refused at restore.
  • Live-path test: two actor handoffs stamp positions 1 and 2; the successor restored from that journal reports watermark 2.

Remote verification (narrowest commands, GitHub-hosted runner via
the fleet-command.yml fallback — fleet queue dispatch itself is
blocked by #13185 TLS defect):

cd pkgs/id && cargo test -p id-worlds --lib lease && cargo test -p id-worlds --lib handoff && cargo test -p id-worlds --lib notify_events_require

— fleet run 45278328401 (first dispatch, pre-fix): compile failure — JOURNAL_VERSION_LEASE_POSITION was not re-exported from crate::world and the proptest moved expected twice. Fixed by adding the constant to the world/mod.rs re-export list and cloning expected at its first use (amended commit 7cb3750, pushed with an explicit --force-with-lease value after verifying the remote was still at the pre-amend commit).

— fleet run 45279480155 (re-dispatch after the fix): success — cargo test -p id-worlds --lib lease: 42 passed, 0 failed; --lib handoff: 22 passed, 0 failed; --lib notify_events_require: 1 passed, 0 failed. All four new tests ran and passed by name: lease_positions_are_strictly_increasing_across_appends_and_compaction, lease_position_watermark_reports_the_grant_position_after_replay, unstamped_lease_entries_still_restore_at_version_7, lease_positions_that_do_not_advance_are_refused. Log: https://github.com/developing-today/fleet/actions/runs/45279480155

No new test file, so no test-suite-registry row is needed (tests
added to existing id-worlds test modules).

Merge Danger

Medium-low. The journal format gains an optional field on five
variants plus a new header version; old journals parse unchanged
(position defaults to 0) and old binaries refuse v16 journals at
the header check. Replay now enforces stamped-position monotonicity
(legacy zeros pass through). Revertible: dropping the fields
restores the v15 format, but any journal that already stamped
positions would then lose them at its next checkpoint.

{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-23T22:39:21Z",
    "session_id": null,
    "lane": null,
    "host": "htch-runtime",
    "worktree": "/home/hatch/workspace/github-work/code-13711",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/hatch/workspace/github-work/code-13711",
      "repo": "developing-today/code",
      "branch": "xaltha/13711-journal-position",
      "sha": "7cb3750e4ca19a41df6aee089bac88c2a93e4366"
    },
    "auth_subject": "xaltha",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

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

…#13711)

Lease entries (LeaseGranted/Renewed/HandedOff/Revoked/WriteRejected)
now carry a durable monotonic per-world journal position, stamped by
the append authority and recorded in the lease history, so a
checkpoint carries every covered position and a successor replaying
the journal reports its watermark through it. Positions start at 1;
0 means unstamped (pre-positions entry) and restores as before.

- JournalEntry lease variants gain position (serde default 0);
  stamped positions require journal version 16, unstamped keep 7.
- WriteLeaseTransition/LeaseWriteRejection gain position;
  WriteLease::last_position is the replay watermark.
- WorldCore exposes lease_position_watermark and
  next_lease_position; the actor handoff stamps the next position
  before its durable append.
- Replay refuses a stamped position that does not advance past the
  highest stamped position already seen.
- Property test: positions strictly increase across appends and
  survive compaction; oracle test: grant at P reports watermark P;
  legacy and non-monotonic cases covered.

Scope note: positions cover lease entries only, per the issue's
request; per-entry positions for all entries remain the
JournalRecord envelope follow-up (design #2819).
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 28 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4b87487e-73bb-4217-b18b-9eb57cd14a48
Commits

Reviewing files that changed from the base of the PR and between 5730675 and 7cb3750.

Files selected for processing: 7

  • pkgs/id/crates/id-worlds/src/world/actor.rs
  • pkgs/id/crates/id-worlds/src/world/core.rs
  • pkgs/id/crates/id-worlds/src/world/core/operations.rs
  • pkgs/id/crates/id-worlds/src/world/journal.rs
  • pkgs/id/crates/id-worlds/src/world/mod.rs
  • pkgs/id/crates/id-worlds/src/world/tests.rs
  • pkgs/id/crates/id-worlds/src/world_store.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@dezren39

Copy link
Copy Markdown
Member Author

Batch B disposition (oc-code-08, task 21623): not merged this run. Verification needs the laptop shell route, which is down from this lane (bridge hello shell leg: broker connection refused). Rebase of this conflicting branch would need a force push, which this batch excludes, so the next step is a merge-main-in commit once verification is reachable. Named blocker: the PR's own verification (Rust/Fleet dispatch or mdBook build) cannot be run from this lane right now, so it is not merged unverified. Resume when a shell route to the laptop answers.

This branch has not been deployed

No deployments
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