Skip to content

ui-server: boot a brain-less diagnostic host while private-state isolation is unverified #4500

Open

Description

@schlessera

Part of #4426. Follow-up to the amended ruling on #4487.

Context

When the private-state alias check cannot finish, the host refuses boot. The owner then loses status, diagnostics and settings, and can't see why from the UI. A first attempt in PR #4490 booted the full host and tried to gate each brain reader instead. Review showed the gate could not be proven complete: file routes, the graph index, voice orientation, chat attachments, the MCP bridge and boot steps all read the brain directly. createApp (packages/ui-server/src/app.ts) is one function of about 1,600 lines with about 70 uses of config.brainPath. Auth, status and settings are built after steps that touch the brain.

Ruling (maintainer, 2026-11-23)

Option 3: no brain-kit host runs in this state. The embedder reports the refusal itself, for example as a static page or a log line, and the owner repairs the layout and restarts. brain-kit does not split createApp, does not add a diagnostic listener, and opens no app database while its own isolation is unverified. The owner-facing rendering belongs to the hosting template, filed as a template task.

Scope

Make the refusal that createApp already throws a documented embedder contract. The error is named OperationalStateInBrainError and its status is attached (assertOperationalStateOutsideBrain, packages/ui-server/src/brain/operational-state.ts:159-166; called at packages/ui-server/src/app.ts:427-433). Its reasons are private_state_in_brain and database_in_brain, plus private_state_unverified once #4487 / PR #4490 lands.

  • Document the shape (error name, status.available, status.reason, status.detail) and its reasons for embedders in docs/integration-contract.md.
  • Pin it with tests: each reason rejects createApp before any listener starts or ui.db is opened, and the attached status matches the documented shape.
  • The detail text stays owner-actionable and never carries secrets.

Out of scope

  • Splitting createApp, a diagnostic listener, or any brain-kit route in this state (ruled out).
  • Rendering in the hosting template (template task).
  • Recovering without a restart.

Acceptance criteria

  • docs/integration-contract.md documents the refusal's error name, its status fields and every reason, as an additive contract entry.
  • A test per reason proves that createApp rejects with that shape, and that no HTTP listener is created and no ui.db file is opened before the rejection.
  • A mutation that drops the attached status fails the named test on its assertion.

Verification

bun run test packages/ui-server/tests
bun run typecheck
bun run lint

Contract impact

  • Additive integration-contract entry, so the commit is prefixed CONTRACT:.
  • Changeset for @schlessera/brain-ui-server.

Blocked by #4487

Decision record

The ruling on #4487 (2026-11-23, amended) says only that a host booting with no brain-reading surface is a separate issue. It doesn't choose how. The approach in Scope above is a proposal, not a ruling.

Question: how should a host whose private-state alias check cannot finish show its owner why, without any surface that reads the brain?

Pointers at main 356fa7d76: createApp (packages/ui-server/src/app.ts:373, file of 1,592 lines, 68 uses of config.brainPath); the boot refusal (assertOperationalStateOutsideBrain, packages/ui-server/src/app.ts:427-433, and packages/ui-server/src/brain/operational-state.ts:159-166), which already attaches its status to the thrown error "so an embedder can show the same diagnostic even though a refused app has no HTTP listener"; route mounting from createHealthRoutes (app.ts:1135) onward.

Options:

  1. Split createApp into a part that never receives the brain path and a part that does, with a fetch and WebSocket handover (the Scope above). Consequence: complete by construction, but it is the largest refactor of the host's assembly, and every later route must be placed on the right side.
  2. A separate diagnostic listener built before createApp from route factories that take no brain path (auth, status, a settings subset), replaced by the full app once a check verifies. Consequence: no split of createApp, but two assemblies of auth and status to keep consistent.
  3. No brain-kit host at all in that state. The embedder (the hosting template) reports the refusal's attached status itself, for example as a static page or log line; the owner repairs and restarts. Consequence: smallest change, no settings, and recovery needs a restart.

Each must settle whether opening or writing the app database is allowed while its own isolation (database_in_brain) is unverified: a settings write could land inside the brain if the database aliases into it.

Recommendation (not a ruling): option 3 first, as the smallest outcome under a p3 priority; option 2 only if a driving use case needs settings in this state.

Ruled 2026-11-23: option 3. Previous completion note: a dated maintainer ruling on this issue, folded into Scope and the acceptance criteria; then needs: decision comes off. The owner-facing design (see the design prompt in the comments) follows the ruling and keeps needs: design until approved.

2026-11-23 triage at main 356fa7d: the issue had needs: design but no prompt, and its central choice is architectural, so needs: decision was added with the question and options above; a design prompt for the owner-facing state is posted as a comment.

2026-11-23 triage at main 356fa7d76: folded the option 3 ruling into the body and rescoped the issue to the embedder contract. Removed needs: decision and needs: design: no brain-kit surface remains to design, and the template rendering carries its own design.

Activity

  1. added
    type: feat
    area: ui-server
    priority: p3
    needs: design
    on Nov 23, 2026
  2. schlessera commented on Nov 23, 2026

    @schlessera
    OwnerAuthor

    Needs design: the owner's view of a host that can't verify private-state isolation (prompt 2026-11-23, main 356fa7d76). Settled: a confirmed exposure refuses boot; a persistent private_state_unverified also refuses boot with OperationalStateAliasVerificationUnavailable (amended ruling on #4487); no surface in this state may read the brain. Open, in order: the architecture (needs: decision in the body), then what the owner sees and may do in that state, which code can't decide. Run this prompt after the ruling and pass the chosen option in.

    Paste to Claude:

    Design the owner-facing diagnostic state for brain-kit issue https://github.com/schlessera/brain-kit/issues/4500, under epic #4426.
    
    Read first:
    - #4500's body, including the "Decision needed" section and the maintainer's ruling on it (the chosen option: split createApp, a separate diagnostic listener, or embedder-only reporting). Design for the chosen option only.
    - #4487's comments: the 2026-11-23 decision and its amendment (persistent unverified check refuses boot; bounded retry; admission refusal with the named cause; diagnostic boot removed from PR #4490 because file routes, voice, chat attachments and MCP read the brain directly).
    - PR #4490's body, the "Guard checklist: alias verification" (H1-H6): the refusal error, `status`, `operationalState.lastFailure` and `runtime.operationalStateLastFailure`.
    - Source at main 356fa7d76: `assertOperationalStateOutsideBrain` and `operationalStateRefusal` (packages/ui-server/src/brain/operational-state.ts:141-166) and their detail text; the boot refusal in `createApp` (packages/ui-server/src/app.ts:427-433); `createHealthRoutes`/`createStatusRoutes` (packages/ui-server/src/routes/health.ts, mounted at app.ts:1135 and :1180); the settings panel (packages/ui-react/src/components/settings/settings-panel.tsx) and its tabs.
    - docs/decisions/proportionate-containment.md (the rule and its checklist), docs/decisions/design-kit.md D34/D36/D37, and the example-corpus decision (Odysseus world, 2026-07-12) for any sample text.
    
    Problem:
    When the alias check can't finish, the owner today gets no UI: the host refuses boot, so the PWA can't load or say why. The detail text tells an operator to stop the server, move state and restart, but the owner on a phone never sees it.
    
    Settled:
    - No route, WebSocket handler or boot step in this state reads a path under the brain.
    - A confirmed exposure keeps refusing; recovery from unverified is automatic when a later check verifies (in-app or by restart, per the ruling).
    - Status names the cause. No strict-turn fallback; no chat, files, graph, voice or attachments in this state.
    - Unresolved here: whether the app database may be opened or written while `database_in_brain` is itself unverified.
    
    Design:
    1. What the PWA shows on load in this state: the first screen, the cause in owner language, and the operator steps, using the existing detail text as the source.
    2. Which settings, if any, stay available. Go through each tab in settings-panel.tsx and say whether it reads the brain (persona Markdown, skills and module settings do) or only the app database, and whether a write is safe while database isolation is unknown. Accept "no settings" as an outcome.
    3. Sign-in in this state: is passkey sign-in needed before showing the cause, and what does an unauthenticated visitor see, without leaking paths?
    4. The transition when a check verifies (or after a restart): what the open PWA does, what happens to a stale tab, and what it shows when the check finds an exposure instead.
    5. Phone-width and desktop layout, focus on arrival, both themes, long path text.
    
    Requirements to hold:
    - Proportionate containment: restrict the narrowest uncertain thing, record the cause durably and visibly, recover automatically when no judgment is needed.
    - No real paths, hostnames or personal data in mocks; use Odysseus fixtures.
    - Don't add routes that read the brain, and don't reopen the #4487 rulings.
    
    Deliverable:
    A proposal with exact copy, the route/handler list allowed in this state with what each reads, the state and transition rules, ASCII mocks at 320px and desktop, and browser-test criteria. If the ruling chose embedder-only reporting, deliver the exact refusal text and the fields the embedder must show instead of PWA mocks. The maintainer reviews the proposal.
    
  3. added
    needs: decision
    on Nov 23, 2026
  4. schlessera commented on Nov 23, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-11-23): option 3. No brain-kit host runs while private-state isolation is unverified. The embedder reports the attached refusal status, and the owner repairs and restarts. This issue is rescoped to documenting and pinning that refusal as an embedder contract. The template rendering is filed separately, and the design prompt above applies to it.

  5. added
    area: docs
    blocked
    agent-ready
    contract
    and removed
    needs: decision
    needs: design
    on Nov 23, 2026
  6. schlessera commented on Nov 23, 2026

    @schlessera
    OwnerAuthor

    Unblocked: #4487 is closed, so scripts/sync-project.ts is removing the blocked label.

  7. removed
    blocked
    on Nov 23, 2026
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: docsarea: ui-servercontractpriority: p3type: feat

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions