Skip to content

ui-server: worktree journal observer can retain a checkpoint aborted before its pool lease is recorded #3528

Closed

Description

@schlessera

Context

Found while fixing #3521. The native journal observer adds a checkpoint id to its retained set before it calls the manager (checkpoint, packages/ui-server/src/brain/native-journal-observer.ts:291-302, after #3521). If the manager refuses the call before it records a lease, the release that follows is refused too. The id then stays retained, and close() throws "native checkpoint(s) remain retained after shutdown".

#3521 closes the window for the brain's own journal: the observer now checks the signal in the same synchronous step that hands the id to the native lease owner, and that owner checks the signal before anything else.

The worktree journal has more waits before its lease is recorded:

  • referenceWorktreeJournalManager().checkpoint awaits ledger.record(...) before pool.poolCheckpoint(...) (packages/ui-server/src/brain/reference-worktree-journal.ts:28-33).
  • The lease owner's poolCheckpoint awaits settleRelease(from, signal) with the caller's signal before poolCheckpointIntent (packages/ui-server/src/brain/native-brain-leases.ts:176-186).

An abort during either wait refuses the checkpoint before a pool lease exists. poolRelease then refuses the id ("no recorded app lease"), so the worktree observer keeps it and its close() throws.

This has not been seen in CI.

Scope

Correct ownership handoff for worktree observation checkpoints refused before the pool lease is recorded. Cover both the ledger wait and the lease owner's release-settlement wait; preserve recovery ownership once a lease actually exists.

Out of scope

Acceptance criteria

  • A deterministic test aborts a worktree journal observation during each of the two waits above, and shows the observer's close() resolving with no retained checkpoint.
  • No change weakens the "remain retained after shutdown" refusal or lets poolRelease delete a root that has no recorded lease.

Verification

  • Run bun run test packages/ui-server/tests/native-journal-observer.test.ts packages/ui-server/tests/reference-worktree-journal.test.ts packages/ui-server/tests/native-brain-leases.test.ts and the new deterministic regression cases.
  • For each wait, record the intended failing assertion before the fix and restored passing result. Prove post-lease failure still retains retryable cleanup ownership, and unleased arbitrary roots remain undeletable.
  • Run the normal affected preflight before a PR. No keys or network are needed.

Triage evidence — 2026-11-04

Inspected main 53b862123d7b8e4c9d039859fabdc9fc6ad4cd36. The source pointers above still identify the claimed waits (referenceWorktreeJournalManager, packages/ui-server/src/brain/reference-worktree-journal.ts:26-30; poolCheckpoint, packages/ui-server/src/brain/native-brain-leases.ts:176-180). The observer retains the ID before the call (checkpoint, packages/ui-server/src/brain/native-journal-observer.ts:291-302).

A bounded keyless runtime check used the actual observer and worktree manager, a deferred ledger record, and a pool double that rejects an already-aborted checkpoint before recording a lease and refuses release without a lease. Steps: start observer.initialize(signal); wait until record enters; abort; resolve record; await initialization rejection; call observer.close(). Initialization rejected with the supplied abort reason; close rejected with 1 native checkpoint(s) remain retained after shutdown and no recorded app lease. The pool never recorded a lease and received two refused release attempts. This demonstrates the ledger-wait path with a controlled pool double, not a native Btrfs reproduction or proof of the second wait. The implementation must supply both regression cases above.

Contract impact

None expected.

Activity

  1. added this to the 0.45.0 milestone on Nov 3, 2026
  2. added
    type: fixSomething is broken and must behave the way it is documented.
    area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.
    priority: p2Wanted, not scheduled. Pulled in when a milestone has room.
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    on Nov 3, 2026
  3. self-assigned this
    on Nov 15, 2026
  4. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation. Claim token: claim-1a9bda1e. Branch: fix/3528-worktree-checkpoint-abort.

    Path collision: #4050 also edits native-brain-leases.ts (adds turn-tree methods; different region). Closure-only reports otherwise.

  5. schlessera commented on Nov 16, 2026

    @schlessera
    OwnerAuthor

    Merged in #4060 as 85497b398 through the integration lease (orchestrator merge queue for 0.45.0). Candidate confirmation passed on the exact head; the squash's own main run carries the post-merge heavy categories.

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

Metadata

Metadata

Assignees

Labels

agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.priority: p2Wanted, not scheduled. Pulled in when a milestone has room.type: fixSomething is broken and must behave the way it is documented.

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions