Skip to content

P5 O10: the endpoint follows a recovery whose first state is a sibling of its head - #317

Merged
SSFSKIM merged 8 commits into
masterfrom
p5-o10-recovery-sibling
Oct 29, 2026
Merged

SSFSKIM merged 8 commits into
masterfrom
p5-o10-recovery-sibling

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 29, 2026

Copy link
Copy Markdown
Owner

P5 O10 follow-up: the endpoint now follows an org recovery whose first state is a sibling of its head. This closes the endpoint half of P5 Decision Log 126's residue, the same defect O8 fixed app-side in #314 (740f0c4).

The defect

The endpoint's hub sync read only GET /machine/org/state?since=<held head> (the old src/endpoint/org-sync.ts, line 100). When an admin delivers a state straight to a machine, the hub's head sits below the endpoint's. The hub then accepts a recovery from its own head and serves the recovered line's first state at the endpoint's head version: a sibling with the same version and a different hash. ?since=<head> never serves that state or its base, so the endpoint refused the recovery as a fork.

The fix (src/endpoint/org-sync.ts)

Only which states the sync reads has changed. #adopt and #rewind verify as before (verifySuccessor, verifyRewind, the base hash against hashes[fromVersion-1]), and head and window still commit in one rename.

  • A sync reads at most MAX_PAGES pages, the same ceiling as before. Every state it reads goes into one pool, deduplicated by version and hash, and #adopt judges the pool as a whole.
  • When the first page after the head serves a transition from below the head that passes verifyRewind against it, half of the remaining pages (rounded up) go to the recovery. The forward read gets the rest, plus whatever the recovery leaves unused.
  • Bases are probed newest first, two pages each. A probe reads from fromVersion when the window holds the base, and from fromVersion - 1 when the base has aged out.
  • Once #rewind finds a rewind in the pool, its line is read on up to the head's version. Whatever has been read when the pages run out is adopted, and the next sync continues from there.
  • A sibling with no valid recovery behind it still reads fork. The head, the status and org.json stay byte-identical, and the same fork line is logged.

Files outside src/endpoint/ and test/endpoint/:

  • vitest.config.ts: one line, registering the new Miniflare suite.
  • test/org/signer.local.test.ts: a comment only. It used to say the endpoint could never follow such a recovery.
  • The O10 spec: one Surprises entry and one Decision Log entry.

Validation Evidence

  • Miniflare (test/endpoint/org-recovery.local.test.ts, new):
    • A recovery whose first state is a sibling at the endpoint's head version: the endpoint ends on the recovered line. On 287b2e6a0 this failed with "no the recovered line adopted within 5000 ms"; with the fix it passes.
    • A bare sibling still reads as a fork.
    • Result: 2/2.
  • Unit (test/endpoint/org-sync.test.ts): 24/24. Each regression below was written to fail first, and the raw outputs are in the executor's evidence.
    • the sibling recovery and its continuation;
    • the fork guards;
    • forward progress when the re-read hits the cap (round 1);
    • the request bound against a hostile hub that answers more: true (round 2: 13 requests before the fix, at most 4 after);
    • starvation of the recovery by a forward read that fills the budget (round 3);
    • a rewind whose first state arrived in another base's pages (round 3).
  • Neighbouring suites, run one at a time: test/org/signer.local 8/8, hub-link.local 10/10, enroll 7/7, provision 22/22.
  • eslint exits 0. tsc -p exits 0 on node, web and e2e.
  • Gate: ci-gate --gates static,unit,probes,e2e:desk-web-hub --class1a pool --runner macos --lane hosted --label o10-recsib4 on head fe886426e. GREEN, run 40790637898; desk-web-hub 39 passed, no flaky: line, no coverage warning.
    • An earlier head, 40ffd4e67, was red in a single test, src/mawsd/cli-prompt.test.ts's ^C case (run 40788949682). This branch doesn't touch that file, and the case passed on the next head. It is logged as a possible pty flake.
  • Review: reviewer-high ran four rounds.
    1. A stall when the re-read hit MAX_PAGES.
    2. Request amplification: N transitions cost N × MAX_PAGES.
    3. Starvation of the recovery, and a crash in the probe-keyed map.
    4. Correct. Its 14 independent probes covered competing hashes, held and aged-out bases, and partial prefixes, and none admitted an incompatible chain.

Residue

  • A pending genuine recovery transition with nothing signed under it costs up to two of the recovery's pages on every sync, until a newer transition is accepted. O8's app has the same property.
  • A device's handshake pages (OrgView.advance, M1's h2/h3) still can't carry a recovery whose first state is a sibling of the endpoint's head. The endpoint now follows one from the hub or by delivery. This was out of this change's scope.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)

…ibling of its head, reading the hub again from under the recovery's base (a sibling with no recovery behind it still reads fork)

The hub sync read `?since=<head>` only, so a recovery's first state at or below the head's version (the hub never
had the head: an admin delivered it straight to the machines) never reached `#rewind`, and the hub's head was
judged against the endpoint's alone, as a fork. `sync` now reads the chain again from `fromVersion - 1` of the
lowest transition that passes `verifyRewind` against the head (O8's `rereadFrom`, src/main/org/held.ts), so the
page carries the base too once it has aged out of the window. What is accepted is unchanged: `#adopt` and
`#rewind` verify as before, and commit the head and the window in one rename.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…fter the head rather than replace it, and a transition nothing is signed under costs its base and first state, not the history

reviewer-high's P2: the re-read from a recovery's base replaced the read after the head, so a genuine transition
that passed `verifyRewind` but authorized nothing the hub served, read again past MAX_PAGES, dropped the forward
successors already fetched, and every later sync repeated the capped re-read. Now each passing transition's base
and first state are read (a page or two) and judged by `#rewind`; only when it finds a rewind is the recovered line
read on, up to the head's version, and whatever is read under the head is adopted beside the read after it.
Acceptance is unchanged. `EndpointOrg` takes a `maxPages` seam for the suite.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…view fix

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…S), a probe of a recovery's base reads two pages at most, and what was read when the budget runs out is adopted

reviewer-high's round-2 P2: each qualifying base began its own read with a fresh MAX_PAGES allowance, and `until`
only said where to stop, so a hub answering `more: true` with an old state cost N genuine transitions N x 1000
requests. The read after the head, the probes and the recovered line's read now draw on one budget, the read after
the head first, so a sync costs at most what it did before the recovery fix.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…s whole, and a recovery from below the head has half the sync's pages left after the first, so neither the read after the head nor the recovery starves the other

reviewer-high's round-3 P2s, both from the budget running out: a read after the head that took every page left a
recovery's first state unread (an honest hub, the endpoint at the superseded head for good), and a rewind found in an
earlier base's pages had no probe of its own to read on from (`probes.get` undefined, a TypeError). Now every state
read goes into one pool, deduplicated by version and hash; the bases are probed newest first, two pages each, within
the recovery's share, each from its base's version when the window holds the base; the line of a rewind `#rewind`
finds in the pool is read on from the pool's own run of it; and what either share leaves goes to the other.
Verification is unchanged and a sync still reads at most MAX_PAGES pages.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…d-budget sync

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T00:05:35.181152Z fe88642 PR opened
ℹ️ 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.

@SSFSKIM
SSFSKIM merged commit ea90b9e into master Oct 29, 2026
SSFSKIM added a commit that referenced this pull request Oct 29, 2026
…316's root lines recorded

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
SSFSKIM added a commit that referenced this pull request Oct 29, 2026
…dpoint fixes, desk-hub eyJ fix) into p5-o3-c at M5's start

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
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