Repository navigation
Description
Problem
In pkgs/id, WorldCore::restore validates a journal checkpoint's events with a plain + 1 — the one sequence-consecutiveness check in the file that does not use the checked/saturating arithmetic every sibling check uses — so a checkpoint whose penultimate event carries sequence u64::MAX behaves differently in each build profile, and neither behaviour is the intended rejection:
- Debug / test builds (overflow checks on —
pkgs/id/Cargo.toml's[profile.dev]/[profile.test]set nooverflow-checksoverride, so the default applies): the check panics with "attempt to add with overflow" instead of returning restore'sjournal checkpoint events are out of ordererror. - Release builds (overflow checks off):
u64::MAX + 1wraps to0, so a checkpoint whose events run[…, u64::MAX, 0]passes the consecutiveness gate as if MAX → 0 were a valid step (the trailing checkevents.last().sequence == sequencethen anchors the checkpoint at sequence 0).
Evidence (verified this run, main 51dee687)
-
pkgs/id/src/world/core.rs:380-384(theJournalEntry::Checkpointarm ofrestore,core.rs:138; reached from journal load atworld_store.rs:380):ensure!( events.last().is_none_or(|last| last.sequence == sequence) && events .windows(2) .all(|pair| pair[1].sequence == pair[0].sequence + 1), "journal checkpoint events are out of order" );
-
WorldEvent.sequenceisu64(pkgs/id/src/world/mod.rs:319). -
Every sibling sequence check in the same file uses saturating or checked arithmetic:
core.rs:335andcore.rs:1038usesaturating_add(1)for the same "next sequence" comparison;core.rs:220,:885,:1027,:1148usechecked_add(1). Line 383's plain+ 1is the lone exception. -
Laptop probe (verbatim predicate, source md5
607e68c2in both copies;~/git/fleet/probe-2026-11-01-laneA-ckptseq/on the laptop):rustc -C overflow-checks=on:[1,2,3] → true,[1,3] → false,[MAX-1,MAX] → true, and the[MAX,0]case panics —attempt to add with overflow, exit 101.rustc -O -C overflow-checks=off:[MAX,0] → true(wrap accepted as consecutive),[MAX,5] → false.
Why it matters
restore is the integrity gate for a world's journal on load: its ensure! checks are what stand between a damaged or crafted journal file and the world state rebuilt from it. A gate that panics in one profile and silently accepts a wrapped sequence in another is neither — the panic turns a corrupt-checkpoint error into a crash of the loading process, and the wrap-accept lets a checkpoint claim a sequence chain no writer can produce (writers advance via the saturating/checked paths). The fix is also the file's own established convention, so this is a consistency defect, not a design question.
Acceptance criteria
- The checkpoint consecutiveness check uses checked arithmetic (e.g.
pair[0].sequence.checked_add(1) == Some(pair[1].sequence), or the file'ssaturating_add(1)convention — either makes MAX → anything non-consecutive): a checkpoint with a penultimateu64::MAXsequence is rejected with the existing "journal checkpoint events are out of order" error in both debug and release profiles, with no panic. - A regression test restores a checkpoint whose events are
[…, u64::MAX, 0](checkpointsequence0) and asserts the out-of-order error; ordinary consecutive checkpoints (including[MAX-1, MAX]as the final pair) still restore. - No other restore validation changes behaviour; existing
world/world_storerestore tests pass.
Distinct from #2396 (CLI --seconds/--timeout-secs added to an Instant — different site, different input path).
Activity
developing-today commentedon Nov 1, 2026
CODE-1517
dezren39 commentedon Nov 1, 2026
🤖 Agent note · filed
+ 1where every sibling sequence check uses saturating/checked arithmetic — a penultimate u64::MAX sequence panics in debug/test builds and wraps to an accepted MAX → 0 step in release.dezren39 commentedon Nov 1, 2026
🤖 Agent note · adopted as Phase 2 of design #4000
source/design-architect. Existing queued triage packet stands.50 remaining items
dezren39 commentedon Nov 2, 2026
agent-note:v1
event: parked
task: 6202 (repo-health-code-pilot, repo-worker-code; OpenChamber scheduled lane ec118cad-0fd3-4652-91c4-27432f2f2efd)
state: parked for 30 minutes
blocker: PR #4498 remains OPEN and Drew-authored; this lane did not modify, test by editing, or merge it. Current rollup has no affected pkgs/id check (only unrelated basic guard success; CodeRabbit neutral/skipped).
resume: Revalidate issue/PR ownership and checks. Resume only after explicit reassignment / PR no longer Drew-owned, or an independent unowned verification path exists; then obtain targeted pkgs/id test evidence and required PR-tier coverage.
links: issue #3736 · PR #4498 · branch queue/6202-3736-checked-restore at 4b2a1b7
dezren39 commentedon Nov 2, 2026
🤖 Agent note · parked
queue/6202-3736-checked-restore//home/user/git/fleet/6202dezren39 commentedon Nov 2, 2026
🤖 Agent note · parked
dezren39 commentedon Nov 2, 2026
🤖 Agent note · picked up
queue/6202-3736-checked-restorebranch for task 6202 and neither issue id(world): restore's checkpoint consecutiveness check uses plain + 1 — a penultimate u64::MAX sequence panics in debug/test builds and wraps to an accepted MAX → 0 step in release #3736 nor PR fix(id): reject wrapped checkpoint sequences #4498 carries any hard-stop label (held,user/owned,do-not-merge,do-not-auto-edit); authordezren39is the fleet token account. Codex review on head4b2a1b7completed with no findings; guard check SUCCESS; PR is MERGEABLE/CLEAN.references.rscompile failure was in a file unchanged from base — checking whether it is pre-existing / already fixed on current main), then merge under the standing criteria.dezren39 commentedon Nov 2, 2026
🤖 Agent note · done
f2c62597c); issue id(world): restore's checkpoint consecutiveness check uses plain + 1 — a penultimate u64::MAX sequence panics in debug/test builds and wraps to an accepted MAX → 0 step in release #3736 closed by the merge. The earlierreferences.rscompile failure was pre-existing at the PR's old base883980a7c(file unchanged by the PR) and is already fixed on current main; after mergingorigin/maininto the branch, the focused regression testworld::tests::tests::restore_checkpoint_sequence_does_not_wrap_at_u64_maxpasses and all 160world::tests pass on the laptop under fleet-build-lock. Codex review on final heada87a633b5completed with no findings.basic: OpenCode metered-provider guardcheck is currently QUEUED fleet-wide (verified on PR fix(acp-adapter): reconcile pending prompts when the event stream reconnects (#4617) #4632, PR fix(id): five lib tests failing on main — fence span, tags socket close, archive references, two hosting-blind routing tests #4631, PR fix(acp): scope streamed-text offsets per session #4629, PR id(world): per-world total memory budget — contract + restore enforcement (#557 slice 1) #4628, PR id: session.checkpoint event kind — session header + segment checkpoint (#3794) #4627) — an infra backlog unrelated to this change; it was SUCCESS on this PR's prior head.