Skip to content

backends: detect unqualified Pi extension configuration before turn admission #3658

Closed

Description

@schlessera

Out of scope

Do not qualify or exempt third-party extensions, weaken input-safety collection, auto-clear recorder failures, rewrite provider history, or add a live-provider/network test. Restoring web, MCP or subagent capability belongs to the controlled-execution work (#1863 for web; the MCP and subagent issues under the same parent epic). This issue only stops a known-unsupported configuration from reaching a turn.

Context

At 4ff63be8581dcfd72ed7ef3220347409a912a542 (anchors re-verified at 1619741f2), Pi's probeRuntime checks only SDK version compatibility (packages/ui-backend-pi/src/module.ts:161-163). Its environment factory constructs the backend without an explicit extension-loading choice (packages/ui-backend-pi/src/module.ts:190-202), and the hosted environment has no setting for one (agent: block, packages/ui-server/src/config/env.ts:1189-1203).

The backend defaults extension discovery on (loadExtensions: options.loadExtensions ?? true, packages/ui-backend-pi/src/backend.ts:115; worker entry packages/ui-backend-pi/src/worker-entry.ts:148), while documenting that any loaded extension or loading error is unsupported for managed input collection (packages/ui-backend-pi/src/backend-options.ts:119-127). The incompatibility is discovered only when the native session loads resources (load, packages/ui-backend-pi/src/native-session-runtime.ts:44-54; unqualifiedResources, packages/ui-backend-pi/src/native-session-runtime.ts:132-136).

The collector's explicit unavailable path calls the failure recorder (packages/ui-server/src/governance/safety-collector.ts:17-26,34). Subsequent collections then refuse until explicit stopped-producer recovery. This preserves the safety boundary, but version-only readiness does not reveal the unusable configuration before a user submits a turn. A boot-time throw from probeRuntime would refuse the whole server, Claude included (probeBackendRuntimes, packages/ui-server/src/agent/backend.ts:394-411), so it is not an acceptable readiness signal on its own.

Decision (maintainer, 2026-11-08)

Curated tools by default. Pi's extension discovery defaults to off for both the package option and the hosted environment. Installed extensions are found by static inspection (settings package lists and extension directories, read as data, never imported or executed) and reported as inactive. An explicit opt-in re-enables discovery; with that opt-in and any unqualified extension present, Pi is reported as not ready for managed turns, while other backends (Claude) remain usable. This changes a documented default, so it ships in a minor under the pre-1.0 breaking rule with this ruling as its authority.

Scope

  • Flip the loadExtensions default to false (CreatePiBackendOptions, the worker entry, and the hosted factory), keeping true as an explicit opt-in.
  • Add one documented hosted setting that selects the opt-in (for example BRAIN_UI_PI_EXTENSIONS=discover; default curated), parsed with the other agent: settings and passed through the Pi module factory.
  • Add a static inspection of the extension resources Pi would load (global/project settings packages, global and project extension directories) that never executes extension code and makes no provider request.
  • Report the result before admission: inactive installed extensions in the startup log and the session brief/catalog disclosure; with the opt-in and any finding, Pi is marked not ready and its turns are refused at admission with an actionable message that names the setting, without engaging the input-safety collector's failure path and without refusing server boot.
  • Document the setting, the default change and the migration in the Pi README, the ui-server environment table, docs/supported-inputs.md and the integration contract.

Acceptance criteria

  • With default configuration and a keyless fixture that has a prepared local Pi extension, a Pi turn runs on curated tools and succeeds; the extension is reported inactive by name; its code never ran (sentinel side effect absent).
  • With the opt-in and the same fixture, Pi is reported not ready before any turn, a submitted Pi turn is refused at admission with a message naming the setting, the safety failure recorder is not called, and a Claude turn in the same server still runs.
  • Readiness/configuration inspection does not execute unqualified extension code on the host or make provider requests, proven by an extension whose import would write a sentinel.
  • The extension-free curated tool mode retains skills and context-file loading.
  • Actual recording failures still require supported recovery and retain historical gaps and occurrences (existing collector/recovery tests stay green, unchanged in meaning).
  • The setting, default change and migration are documented; the contract index and changeset carry CONTRACT: and the breaking note.
  • Named mutations (restore the old default; make inspection import the extension; skip the admission refusal) each fail their intended test, recorded in the PR.

Verification

bun run test packages/ui-backend-pi packages/ui-server
bun run typecheck
bun run lint
bun run check:pr --base origin/main

Keyless, offline fixtures with fictional Odysseus content. Existing collector and recovery tests provide evidence of failure-latch behavior.

Contract impact

Changes a documented package-option default and adds a documented environment setting: CONTRACT: prefix, integration contract and docs/supported-inputs.md updated in the same commit, contract and breaking labels, minor changeset naming the default change. Fail-closed semantics are unchanged for every configuration that still loads an extension.

2026-11-08: scoped from "needs scoping" after the maintainer's ruling above. Original context retained; anchors re-verified at 1619741f2; boot-refusal limitation added; acceptance criteria made checkable.

Activity

  1. added
    type: fix
    area: backends
    priority: p2
    contract
    breaking
    agent-ready
    on Nov 6, 2026
  2. schlessera commented on Nov 8, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-11-08): curated tools by default. Pi's extension discovery defaults to off in the package option and the hosted environment. Installed extensions are found by static inspection and reported inactive. An explicit opt-in turns discovery back on, and with any unqualified extension present Pi is then marked not ready for managed turns without refusing server boot, so Claude stays usable. The body now carries the scope and checkable acceptance criteria. Labels: priority: p2 (sorted with the sibling controlled-execution work), contract and breaking (a documented default changes), agent-ready.

  3. self-assigned this
    on Nov 8, 2026
  4. schlessera commented on Nov 8, 2026

    @schlessera
    OwnerAuthor

    Claiming #3658 for implementation on fix/3658-pi-curated-default from main 1619741f2. Claim token: pi-curated-3658-20261108-f9666cab. No open PR or branch references this issue. Collision inspection reports path overlap on packages/ui-server/src/config/env.ts with drafts #3393 and #3458, plus shared import closures; neither is an ownership transfer. Parent epic: #3669.

  5. schlessera commented on Nov 8, 2026

    @schlessera
    OwnerAuthor

    Progress, 2026-11-08: implementation is in draft PR #3673, head 56d0bcf5. Local preflight, lint, typecheck, build, focused tests and five mutation receipts pass. Package-suite failures match origin/main exactly; they come from this host's lack of user namespaces. Hosted native proof is still pending, including the new inactive-extension real-worker scenario and the provider-history guards. Requests to dispatch draft heavy feedback were refused by a GitHub API rate limit for 15 minutes, so none is running yet. Found while implementing and filed as #3672: the test network guard does not stop a spawned npm from reaching the registry.

  6. 4 remaining items

  7. added this to the 0.45.0 milestone on Nov 8, 2026
  8. schlessera commented on Nov 8, 2026

    @schlessera
    OwnerAuthor

    Completed by PR #3673, squash 13f21dbc on main (verified as an ancestor of origin/main). The tested candidate was head dd1b276b on base 4c62d4db. Candidate run 42518312917 passed every selected category: unit, runtime, runtime_host, browser, layout, endurance, pack, verify, captures and changeset, plus the proof aggregate. That includes the new real-worker inactive-extension scenario and the provider-history guards. The automatic main run on the squash was still in progress at closure. PR and issue milestone 0.45.0 were read back. Releasing claim pi-curated-3658-20261108-f9666cab. Restoring web, MCP and subagent capability continues under #3669.

  9. removed their assignment
    on Nov 8, 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: backendsbreakingcontractpriority: p2type: fix

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions