Skip to content

ui-server: the boot alias check fails when the journal scrub quarantines an object mid-walk #4487

Closed

Description

@schlessera

Found by the native measurement of the landed epic #4278 on a boat.dev VM, large tree, Pi backend. The journal scrub comes from #4323.

In progress: PR #4490 (fixes this issue together with #4486, per the maintainer decision below).

Context

Two things now run at the same time while the host boots:

  • The alias check. At boot, createApp records governed availability (activity.runtime.recordGoverned(boundary.status()), packages/ui-server/src/app.ts:1003). That runs operationalStateRefusal (packages/ui-server/src/brain/operational-state.ts:141-156), which walks every private state path, the turn journal root included, looking for inode aliases inside the brain. The walk (hasBrainAlias, operational-state.ts:40-105: collect, :51-67, and walk, :80-97) lists a directory and then runs lstatSync on each entry. It throws when an entry disappears in between.
  • The journal scrub. It is new in the epic (scrub, packages/ui-server/src/brain/turn-journal.ts:613-632). The journal starts maintenance as soon as it is ready (:648-655 → maintain, :633-647 → scrub), and the scrub moves unreferenced objects into <journal>/quarantine/ from the write worker.

A rename that lands during the walk makes lstatSync throw ENOENT, and boot fails at HOSTED_PROBE_PREREQUISITE. A host whose journal has unreferenced objects can then fail to start, at random, which breaks the proportionate containment rule. governed() runs the same walk on every status() and admission preparation (governedAvailability, packages/ui-server/src/brain/host-boundary.ts:222-229; :455; :587-607), and the scrub repeats every idleObservationMs. Status and admission can probably hit the same race later, but no run has shown that yet.

Evidence on 98f8d3ac6 (its product code is identical to 356fa7d76), harness with the receipt proof skipped (see #4486): prove-native-host.ts --backend=pi --app-uid=1000 --tree=large --observation-timing.

  • After the epic: 3 of 3 runs fail at boot in about 5 s. main before the epic (7e861bdb3) passes 3 of 3 on the same VM.
  • Diagnostic trace: the walk was in the journal objects root. Object e13abef4… was renamed to quarantine/ by journal-scrub.run → journal-accounting.write → db/write-worker-thread.ts. The walk's ENOENT followed the rename by 8.8 ms.
  • Why the large tree: its 30,000 generated journal objects have no database row, so the scrub has plenty to quarantine at boot.

Rulings (maintainer, 2026-11-23; the latest governs)

  1. Fix ui-server: one workspaces/ folder with a broken .git refuses every writable workspace turn #4486 and ui-server: the boot alias check fails when the journal scrub quarantines an object mid-walk #4487 together in one PR against main, with failing-first tests for each, an independent review and one confirm lease. The blocked large-tree native cells get rerun on the fix.
  2. (Amends an earlier same-day ruling that allowed a diagnostic boot.) A persistent private_state_unverified check refuses boot, as main does. The refusal names its cause, OperationalStateAliasVerificationUnavailable, with the underlying error. The bounded retry stays: it fixes the actual race. A later check that cannot finish at admission refuses that turn with the named cause. No diagnostic boot, no per-call checkpoint guard and no strict-turn fallback for uncertainty. A host that boots with no brain-reading surface at all is a separate issue.

Scope

The private-state alias check in operational-state.ts, its callers at boot, status and admission, and the turn refusal it produces.

Exclusions: scrub scheduling; scan correctness under a rename that raises no error (#4494); trees above the entry/depth bounds (#4499); the alias-check diagnostic's recording gaps (#4495); refusal error identity in chat/retry and journal paths (#4497); cron's smaller layout (#4498).

Acceptance criteria

  • The alias walk survives an entry that is renamed or removed while it runs. It retries or rescans, so an object moved into quarantine is still checked, and it never turns a transient vanished entry into a boot failure.
  • If the walk still can't finish after the bounded retry, boot is refused with an error named OperationalStateAliasVerificationUnavailable that keeps the original scan error as cause (ruling 2). After boot, an incomplete check at status or admission refuses that governed or strict turn with the named cause, and the next verified check admits turns again without a restart. A confirmed exposure on any path still refuses as OperationalStateInBrainError, taking precedence over another path's incomplete scan.
  • A unit test that renames a private-state entry between readdir and lstat (using an injected hook or a controlled fixture) fails on 356fa7d76 and passes with the fix.
  • The large-tree Pi native proof boots and passes journal begin on a boat.dev-class VM (a planned end-stage run by the orchestrator, not on a shared host; it does not block coding).

Verification

Failing-first and mutation receipts for the targeted unit tests (bun run test <file>), recorded in the PR; then the native proof command above on the qualified VM.

Contract impact

The boot refusal name and the PRIVATE_STATE_UNVERIFIED turn refusal are documented in docs/integration-contract/http.md in the same commit, with a CONTRACT: prefix (additive).

2026-11-23 triage at main 356fa7d: folded the amended boot-refusal ruling into the criteria (replacing "do not throw out of createApp"), repaired the walk/operationalStateRefusal citations, added scope, exclusions, verification and contract impact.

Activity

  1. added this to the 0.45.0 milestone on Nov 23, 2026
  2. added
    area: ui-server
    priority: p1
    on Nov 23, 2026
  3. schlessera commented on Nov 23, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-11-23): fix #4486 and #4487 together in one PR against main, with failing-first tests for each, an independent review and one confirm lease. The blocked large-tree native cells get rerun on the fix.

  4. schlessera commented on Nov 23, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-11-23): when the private-state alias check cannot finish (private_state_unverified), the host still boots, and status, diagnostics and settings stay available. Every turn that reads the brain, governed or strict, is refused with the named cause until a later check verifies; recovery is automatic. A confirmed exposure still refuses boot. This replaces the strict-turn fallback in #4490 (review finding F106), so an unknown never becomes clean.

  5. schlessera commented on Nov 23, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-11-23, amends the earlier ruling): a persistent private_state_unverified check refuses boot, as main does. The refusal names its cause, OperationalStateAliasVerificationUnavailable with the underlying error. The bounded retry stays: it fixes the actual race, the journal scrub renaming an object mid-walk. A later check that cannot finish at admission refuses that turn with the named cause. Diagnostic boot, and the per-call checkpoint guard behind it, are removed from #4490. The round-2 review showed the read gate could not be proven complete: file routes, voice, chat attachments and MCP reads all read the brain directly. A host that boots with no brain-reading surface at all is a separate issue.

  6. added
    type: fix
    agent-ready
    and removed on Nov 23, 2026
  7. schlessera commented on Nov 23, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-11-23): F145 is fixed in #4490.

    The round-3 head (c1f7103a1) walks private state three times per warm turn on the normal successful path:

    • once through assertReadable() before the checkpoint;
    • once through the direct operationalStateRefusal call in prepare();
    • once through governed().

    main before the fix walked it once. On the large native tree one walk costs about 95 ms, so the extra walks add about 200 ms per warm turn. The fix reuses the verdict within one synchronous preparation step, so a warm turn walks private state once again. Checks that span asynchronous boundaries stay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: ui-serverpriority: p1type: fix

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions