Skip to content

ui-server: the first provider-policy turn after server start is refused for an active peer's folder plan #2832

Closed

Description

@schlessera

Context

The first provider-policy turn after the hosted server starts is often refused at admission with:

An active peer did not retain the requested provider folders; finish that peer and retry admission

The same message, sent again a second or two later, is admitted.

Observed on the native hosted fixture (UID 1000, Btrfs loop store, offline fake providers) with a policy of providers: [{ paths: [me/**], allow: [google] }, { types: [private], allow: [google] }] and the recipient proven as anthropic. In 3 of 5 server starts with that policy, for both backends, the first turn was refused; every refusal was the first provider-policy turn after start, and no later turn was refused (≈45 later admissions). One refusal came after the harness had waited until no host worker process had run for 2 s, so the peer is not simply a worker that is still running.

The refusal is (An active peer did not retain, packages/ui-server/src/brain/writer-gate.ts:201), inside (assertPeerFolderPlans(paths) {, packages/ui-server/src/brain/writer-gate.ts:181): some other row in writer_gate for the brain has a folder plan that does not retain the requested provider-folder roots. Admission calls it at (hold.assertPeerFolderPlans(folderPaths), packages/ui-server/src/brain/governed-turn.ts:204), after acquiring its own shared hold (const hold = await gate.acquire, packages/ui-server/src/brain/governed-turn.ts:116) and after the first-pass maintenance qualification (const availability = await options.execution.boundary.prepare, packages/ui-server/src/brain/governed-turn.ts:122, which probes a maintenance worker in async prepare(signal, preparedView), packages/ui-server/src/brain/host-boundary.ts:517).

Which peer holds the gate is not identified. Candidates to check first: a host gate row left by boot-time work (status checks, maintenance qualification), and host commands acquiring the gate through (if (gate) return gate.acquire(mode, purpose, { signal }), packages/ui-server/src/brain/host-boundary.ts:462) without a folder plan that retains provider folders.

To a user this reads as a policy failure on the first message after a restart, and the message tells them to finish a peer they cannot see.

Scope

  • Identify the peer that holds the gate during the first provider-policy admission after start.
  • Make that admission succeed without a client retry: either the peer's plan retains the provider folders, or admission waits for (rather than refuses) a peer that is known to finish, within a bound.
  • Keep the guarantee the check exists for: a provider-folder turn never runs beside a peer that could write into a folder it hides.

Out of scope

  • Changing which folders a policy masks, or the recipient proof.
  • Peers that genuinely hold an incompatible plan for a long time: those may still refuse, with the existing message.

Acceptance criteria

  • On the native hosted fixture, the first provider-policy turn after server start is admitted in 10 of 10 starts, for both Claude and pi, with no retry.
  • A test reproduces the refusal on the tree before the fix (a server start followed immediately by a provider-policy turn) and passes after it.
  • A peer whose plan does not retain the requested folders and stays active still refuses admission, proven by a test that fails if admission ignores it.
  • The PR names the peer.

Verification

Reproduction: run the native hosted proof (bun scripts/prove-native-host.ts --backend=claude --app-uid=1000, and the pi cell, under the exclusive native fixture lock) with a test that writes the policy above plus a brain.config.ts taxonomy defining private: { dir: "vault" }, creates me/ and vault/ documents, starts the app, and sends one chat turn as soon as the app reports ready. Record whether the first chat_message gets session_info or this error, and dump writer_gate from ui.db at the refusal.

Then bun run test packages/ui-server.

Contract impact

None.

The follow-up #2836 separately owns cross-process/restart persistence of type-selector plans; its intended longer-lived writer fix is not a prerequisite for identifying and correcting this first-start peer. Retain the current refusal for a genuinely incompatible live peer, cancellation and a bounded wait if that is the supported correction. The active claim remains with its current worker.

2026-10-24 triage at main 77f35ef1ba34e4fab7092ada5362ae799852ea24: Verified current gate refusal, admission and host-boundary anchors and reviewed the retained 3/5 startup occurrence plus active worker claim. The bounded diagnose-and-fix brief is complete with an incompatible-peer negative control. Preserve existing G2 parent, p1 and assignment; no client retry, selected peer cause or merged repair is invented.

Activity

  1. added this to the 0.44.0 milestone on Oct 24, 2026
  2. added
    type: fix
    area: ui-server
    priority: p1
    on Oct 24, 2026
  3. self-assigned this
    on Oct 24, 2026
  4. schlessera commented on Oct 24, 2026

    @schlessera
    OwnerAuthor

    Claim bk044-2832-7f3a: working this on branch fix/2832-first-policy-turn-peer-plan-044 from current main. Draft PR to follow.

  5. added
    agent-ready
    on Oct 24, 2026
  6. schlessera commented on Oct 24, 2026

    @schlessera
    OwnerAuthor

    2026-10-24 triage at main 77f35ef1ba34e4fab7092ada5362ae799852ea24: Verified current gate refusal, admission and host-boundary anchors and reviewed the retained 3/5 startup occurrence plus active worker claim. The bounded diagnose-and-fix brief is complete with an incompatible-peer negative control. Preserve existing G2 parent, p1 and assignment; no client retry, selected peer cause or merged repair is invented.

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

Metadata

Metadata

Assignees

Labels

agent-readyarea: ui-serverpriority: p1type: fix

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions