Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .changeset/live-effective-safety.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
"@schlessera/brain-ui-sdk": minor
"@schlessera/brain-ui-server": minor
"@schlessera/brain-backend-claude": minor
"@schlessera/brain-backend-pi": minor
---

Breaking before 1.0: revalidate effective safety at dispatch after waits, restore later policy allowances only after complete individual review, and attribute new journal changes to current evidence while preserving historical facts.

Fence parallel Claude hook waits and direct host approvals, and retain claimed-card ownership through grant persistence with explicit terminal receipts.

Fence host publication after application/policy locks and related effect waits, while preserving principal epochs, completed per-use approvals and frozen ordinary policy.

Wait for initial session identity binding before capturing an approval card's safety snapshot; recheck recorder health and authority after that bounded wait.

Let inference and provider relay admission join their own turn proxy's submitted terminal records before reading fresh safety state. Keep that wait cancellable and continue refusing independent pending input, recorder loss and revoked authority.

Keep pending approvals stable across unrelated sessions by scoping host admission revisions to canonical safety evidence. Continue withdrawing on same-cursor history adoption, exposure appends, provisional pending input and shared recorder loss; preserve brain-wide history/review cursors and existing capacity limits.
8 changes: 7 additions & 1 deletion api-report/ui-sdk.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,8 @@ export "./client" (./src/client/index.ts)
export "./internal" (./src/internal.ts)
AGENT_INFERENCE_CREDENTIAL_ENV
ANTHROPIC_INFERENCE_ROUTES
type AdmissionSafety
type AdmissionSafetySnapshot
BRAIN_INTERACTION_GUIDANCE
BRAIN_SCRATCH_DIR
BRAIN_WORKSPACES_DIR
Expand Down Expand Up @@ -1230,6 +1232,7 @@ export "./internal" (./src/internal.ts)
RTK_WORKER_ENV
type RemovalRun
type Reservation
STALE_SAFETY_ADMISSION
SUBPROCESS_ENV
type SessionPromptFacts
type SessionRetirement
Expand Down Expand Up @@ -1289,6 +1292,7 @@ export "./internal" (./src/internal.ts)
claudeMaskFilename
claudeReportedMaskPath
combineRemovalOutcomes
commitOutwardPlan
compileWorkerCommandPolicy
conversationOrientation
createLimitTracker
Expand Down Expand Up @@ -1375,6 +1379,8 @@ export "./internal" (./src/internal.ts)
rewriteWorkerRtk
runMaintenanceWorker
runMaintenanceWorkerSync
safetyAdmissionRefusal
sameSafetyAdmission
sessionPromptContext
sessionPromptContextLocation
sessionReplay
Expand Down Expand Up @@ -17908,7 +17914,7 @@ signatures (every public export and the types it is made of)
registerToolRenderers (packages/ui-sdk/src/client/renderers.ts)
export function registerToolRenderers(pack: RendererPack): void;
requestToolPermission (packages/ui-sdk/src/server/permission-gate.ts)
export function requestToolPermission(bridge: Pick<BackendBridge, "requestPermission" | "activity" | "checkpointPermission"> | null | undefined, request: PermissionRequest, options?: RequestToolPermissionOptions): Promise<PermissionDecision>;
export function requestToolPermission(bridge: Pick<BackendBridge, "requestPermission" | "activity" | "checkpointPermission" | "admissionSafety"> | null | undefined, request: PermissionRequest, options?: RequestToolPermissionOptions): Promise<PermissionDecision>;
resolutionEffectSchema (packages/ui-sdk/src/schemas.ts)
const resolutionEffectSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
approvedBy: z.ZodOptional<z.ZodString>;
Expand Down
15 changes: 15 additions & 0 deletions api-report/ui-server.txt
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,20 @@ signatures (every public export and the types it is made of)
}, z.core.$strict>;
version: number;
};
readonly safety_admission_expired: {
payload: z.ZodObject<{
authorityEpoch: z.ZodString;
evidenceRevision: z.ZodString;
reason: z.ZodEnum<{
grant_storage_failed: "grant_storage_failed";
safety_changed: "safety_changed";
turn_ended: "turn_ended";
}>;
toolUseId: z.ZodString;
trustRevision: z.ZodString;
}, z.core.$strict>;
version: number;
};
readonly scope_cap: {
payload: z.ZodObject<{
cap: z.ZodEnum<{
Expand Down Expand Up @@ -1017,6 +1031,7 @@ signatures (every public export and the types it is made of)
path: z.ZodString;
sequence: z.ZodNumber;
taintSourceEventId: z.ZodNullable<z.ZodNumber>;
tainted: z.ZodOptional<z.ZodLiteral<true>>;
}, z.core.$strict>;
version: number;
};
Expand Down
2 changes: 1 addition & 1 deletion docs/decisions/apify-capability.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ egress, outward rules and recipient restrictions, but no discovery or Actor gran
fields (`GovernancePolicySchema`, `packages/common/src/governance-policy.ts:101-130`).
Name-based permission admission cannot distinguish different Actors supplied to
one execution tool (`decideToolPermission`,
`packages/ui-sdk/src/server/permission-gate.ts:62-92`). Provider accounting is
`packages/ui-sdk/src/server/permission-gate.ts:63-93`). Provider accounting is
already attributed and settled on the host (`observeProvider`,
`packages/ui-server/src/brain/turn-budgets.ts:223-237`).

Expand Down
8 changes: 4 additions & 4 deletions docs/decisions/async-collaboration.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ requires one enforcement mechanism with different named memberships for voice
and unattended work. Keep that requirement when implementing availability
control. Existing mandatory backend conformance supports safe rejection of an
unsupported restricted request; silently ignoring it is forbidden. The current
optional inputs are (`enforceAllowedTools?: boolean`, `packages/ui-sdk/src/server/backend.ts:636`) and (`noGrantSurface?: boolean`, `packages/ui-sdk/src/server/backend.ts:660`). These are permission primitives,
optional inputs are (`enforceAllowedTools?: boolean`, `packages/ui-sdk/src/server/backend.ts:642`) and (`noGrantSurface?: boolean`, `packages/ui-sdk/src/server/backend.ts:666`). These are permission primitives,
not a claim of filesystem or network containment.

The ordinary Claude assembly loads project settings and appends bridge tools
Expand All @@ -85,7 +85,7 @@ is historical. Preserve subscription billing and the selected runtime identity.
Pi disables built-in tools but currently loads resources and extensions
(`createSessionResources`, `packages/ui-backend-pi/src/session-resources.ts:29-149`)
and gates extension calls (`createPermissionGate`,
`packages/ui-backend-pi/src/permission-gate.ts:102-131`). Removing four curated
`packages/ui-backend-pi/src/permission-gate.ts:103-134`). Removing four curated
tools cannot prove that extensions, MCP, scratch writers or in-process code have
no egress or write access. Both first-party runtimes owe executable evidence;
the plan's earlier “pi is easy” claim is not a containment result.
Expand Down Expand Up @@ -203,8 +203,8 @@ code atomically creates the Action and blocks its Queue item, then denies the
permission and unwinds the turn. Already completed side effects are not undone
by an abort. Attempt staging and cleanup therefore need idempotent recovery,
with filesystem compensation outside SQLite transactions. Ordinary permission
parking still exists (`requestPermission: (req) => {`,
`packages/ui-server/src/ws/bridge-capabilities/permissions.ts:17-123`); it is not a durable Action store.
parking still exists (`const requestPermission`,
`packages/ui-server/src/ws/bridge-capabilities/permissions.ts:19-188`); it is not a durable Action store.

Resolution validates the stored effect again, checks current authority, records
one resolution and applies the guarded state transition in one transaction.
Expand Down
8 changes: 4 additions & 4 deletions docs/decisions/backend-authoring-toolkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ by the package-wide inventory in [the public export boundary](public-export-boun
sharing a server entry point with the toolkit does not classify them implicitly.

The public permission implementation is the gate (`decideToolPermission`,
`packages/ui-sdk/src/server/permission-gate.ts:62-96`), request construction
(`createToolPermissionRequest`, `packages/ui-sdk/src/server/permission-gate.ts:205-219`),
bridge operation (`requestToolPermission`, `packages/ui-sdk/src/server/permission-gate.ts:254-292`)
`packages/ui-sdk/src/server/permission-gate.ts:63-97`), request construction
(`createToolPermissionRequest`, `packages/ui-sdk/src/server/permission-gate.ts:206-220`),
bridge operation (`requestToolPermission`, `packages/ui-sdk/src/server/permission-gate.ts:255-298`)
and edited-input check (`checkEditedApproval`,
`packages/ui-sdk/src/server/permission-gate.ts:148-180`). Pattern compilation is
`packages/ui-sdk/src/server/permission-gate.ts:149-181`). Pattern compilation is
shared (`compileConfirmPatterns`, `packages/ui-sdk/src/server/confirm-patterns.ts:97-134`).

## Mask fallback containment
Expand Down
2 changes: 1 addition & 1 deletion docs/decisions/claude-2.1.287-compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ The backend builds the actual turn options and production permission handlers
The explicit ask lives in
(`enforcementHookFor`, `packages/ui-backend-claude/src/permission-hooks.ts:289-330`)
and is registered under enforcement in
(`...(enforced ?`, `packages/ui-backend-claude/src/permission-hooks.ts:665-668`).
(`...(enforced ?`, `packages/ui-backend-claude/src/permission-hooks.ts:715-718`).

`scripts/measure-claude-enforcement.ts` runs `createClaudeBackend().startTurn()`
and forwards to the SDK resolved from that backend. Its query wrapper only
Expand Down
48 changes: 30 additions & 18 deletions docs/decisions/governed-writable-workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ still holds.
**Voice.** Ruling 1 makes voice `governed` too. Voice keeps its narrower
membership (`VOICE_ALLOWED_TOOLS`, `packages/ui-backend-claude/src/tool-policy.ts:120`):
no Bash, no raw `Write`/`Edit`, no archive, and approval returns false
(`const apply = createBrainApplication`, `packages/ui-server/src/ws/bridge-capabilities/application.ts:24-37`).
(`const apply = createBrainApplication`, `packages/ui-server/src/ws/bridge-capabilities/application.ts:25-38`).
A voice turn therefore writes only through curated capture and update, now
with a journal behind it. The writable mount gives voice no tool it lacked.
Pi still refuses voice turns.
Expand Down Expand Up @@ -1398,7 +1398,7 @@ classification:
`Write`/`Edit`/`NotebookEdit` disallow is lifted
(`disallowedTools`, `packages/ui-backend-claude/src/sdk-options.ts:405`). In
pi, the direct tools and a `bash` whose working directory is the brain root
return (`export function bashTool`, `packages/ui-backend-pi/src/file-tools.ts:151`).
return (`export function bashTool`, `packages/ui-backend-pi/src/file-tools.ts:152`).
- **Approvals do not change.** Confirmation patterns and destructive-operation
approvals still run in the permission hooks. The journal adds the ability to
undo; it removes no approval.
Expand Down Expand Up @@ -1466,7 +1466,7 @@ from worker transcripts, and no extension of the observed-shell guarantee.

**Where the next request waited.** The bridge never awaits an observation: it
starts one per result and carries on
(`void host.journal?.toolEnded`, `packages/ui-server/src/ws/bridge-capabilities/emission.ts:256`).
(`void host.journal?.toolEnded`, `packages/ui-server/src/ws/bridge-capabilities/emission.ts:272`).
The wait is the observation's hold. `held` takes it synchronously, before it
queues the capture
(`function held<T>`, `packages/ui-server/src/brain/turn-journal.ts:240-261`),
Expand Down Expand Up @@ -2249,7 +2249,7 @@ reports which applies as `governed.egress`. Making the relay work without
managed storage is follow-up work. Each connection is recorded as a governance event, and a recording
failure ends the turn. Without a governance recorder the policy still applies
and only the records are absent (`prepareTurnEgress`,
`packages/ui-server/src/brain/turn-egress.ts:82-190`). The note says egress is
`packages/ui-server/src/brain/turn-egress.ts:83-203`). The note says egress is
recorded only when the backend actually routed the worker through the proxy.
API-key Claude profiles (2026-10-22) and pi turns (2026-10-23) are routed
too. A pi turn whose credential the relay cannot carry is refused rather than
Expand Down Expand Up @@ -3845,7 +3845,7 @@ outward host skips the card only while every classified call in progress is a
visible read, or an approved outward action that names that host. A GitHub
write names the GitHub API hosts, and a push or HTTP write names its target's
host. Any unknown or opaque call in progress withholds the exception
(`createOutwardCalls`, `packages/ui-server/src/brain/turn-egress.ts:58-80`).
(`createOutwardCalls`, `packages/ui-server/src/brain/turn-egress.ts:59-81`).
A background process left by an earlier call can still connect inside such a
window; the proxy records it either way.

Expand All @@ -3859,7 +3859,7 @@ listen on other ports: `gmail.googleapis.com`, `graph.microsoft.com`,
`smtp.sendgrid.net`, `api.mailgun.net`, `api.eu.mailgun.net`,
`smtp.mailgun.org`, `smtp.eu.mailgun.org`, `api.postmarkapp.com`,
`smtp.postmarkapp.com`, `api.resend.com` and `smtp.resend.com`
(`MAIL_SUBMISSION_PORTS`, `packages/ui-server/src/brain/turn-egress.ts:18-21`).
(`MAIL_SUBMISSION_PORTS`, `packages/ui-server/src/brain/turn-egress.ts:19-22`).
Microsoft Graph and Exchange Online carry more than mail, so their reads by
an opaque script also wait on the card. The coordinator chose this list for
#1665; the maintainer may override it.
Expand Down Expand Up @@ -3895,6 +3895,18 @@ HTTP endpoint or review capability is enabled here. Live admission integration
remains a separate slice; this changes neither existing provider prefixes nor
the independent outward/credential/egress controls below.

**Live admission supersession — 2026-11-06 (#3602).** Effective evidence is
re-read after asynchronous approval, lock, index and recording waits at the
last host-controlled dispatch point. Only complete coverage and zero unresolved
committed evidence can restore normal policy. Standing allowances are recomputed;
completed per-use approvals retain their exact scope. Stale cards receive a
durable terminal withdrawal, without replay. New journal attribution reads the
current unresolved source; all prior journal/egress/approval facts and provider
prefixes remain unchanged. Live trust input accepts only a host revision and
notification; publication and source matching remain separate work. Ordinary
admitted governance, credentials, provider routing, outward and voice controls
remain independently enforced.

A session becomes **tainted** the first time a turn ingests content it did not
author:

Expand Down Expand Up @@ -3948,7 +3960,7 @@ every signal. A write that fails stops the turn rather than leaving its
outward rules loose. Binding, duplicate checks and the write share a SQLite transaction
(`recordFirstTaint`, `packages/ui-server/src/governance/session-taint.ts:21-27`).
The hosted server runs that transaction on its write worker
(`insertGovernanceEvent`, `packages/ui-server/src/governance/events.ts:367`;
(`insertGovernanceEvent`, `packages/ui-server/src/governance/events.ts:376`;
[#2850](https://github.com/schlessera/brain-kit/issues/2850)). A taint counts
for admission from the moment it is submitted, and a connection's first byte
waits for its taint's commit.
Expand All @@ -3973,7 +3985,7 @@ charges only after admission); otherwise it is refused and recorded as an
`egress_denial` with reason `taint_allowlist` (an interactive turn asks first
since 2026-11-03, see [below](#tainted-destinations-ask)). The taint list
narrows and never widens: deny and `allowlist` mode still apply first (`prepareTurnEgress`,
`packages/ui-server/src/brain/turn-egress.ts:82-215`). Hosts without managed
`packages/ui-server/src/brain/turn-egress.ts:83-229`). Hosts without managed
native storage have no proxy, so the Bash classifier remains their shell rule
and nothing narrows their egress.

Expand Down Expand Up @@ -4018,18 +4030,18 @@ turn's connection passes deny, `allowlist` mode and the byte ceiling but
matches neither `taint.egress.allow` nor a contacted host, the proxy asks
through the turn's tool-permission card (`toolName: "Network"`, `kind:
"command"`, never remembered as a tool grant) before refusing
(`const narrowing`, `packages/ui-sdk/src/server/egress-proxy.ts:192-197`). The
(`const narrowing`, `packages/ui-sdk/src/server/egress-proxy.ts:198-203`). The
card names the destination, the session's first taint source and the
consequence of allowing it
(`taintedDestinationDescription`, `packages/ui-server/src/brain/turn-egress.ts:37-42`).
(`taintedDestinationDescription`, `packages/ui-server/src/brain/turn-egress.ts:38-43`).
Concurrent connections to the same host share one card. An allowed
connection's admission adds its host to the turn's contacted hosts, and its
charged `egress_connection` record carries the host into the session's later
turns, so it is not asked for again; a different host still asks
(`const approveTainted`, `packages/ui-server/src/brain/turn-egress.ts:164-175`).
(`const approveTainted`, `packages/ui-server/src/brain/turn-egress.ts:167-178`).
A decline refuses: the record stays an `egress_denial` with reason
`taint_allowlist`, and the 403 carries a short reason the tool can print (`function describeRefusal`,
`packages/ui-sdk/src/server/egress-proxy.ts:83-99`). Stopping the turn while the
`packages/ui-sdk/src/server/egress-proxy.ts:88-104`). Stopping the turn while the
card is pending cancels the connection, and a late allow admits nothing. Voice turns, which have no
grant surface, and autonomous turns, which have no turn proxy, refuse without
a card as before; deny and `allowlist` mode still refuse first. Maintainer
Expand All @@ -4049,8 +4061,8 @@ with a status text and a body that name it: the deny list, `allowlist` mode,
the byte ceiling, an unapproved outward host, or a tainted session's host
outside its allow-list, with the session's first taint source and what the
user can do (`function describeRefusal`,
`packages/ui-sdk/src/server/egress-proxy.ts:83-99`; the source wording,
`cause: () =>`, `packages/ui-server/src/brain/turn-egress.ts:181`). The status
`packages/ui-sdk/src/server/egress-proxy.ts:88-104`; the source wording,
`cause: () =>`, `packages/ui-server/src/brain/turn-egress.ts:194`). The status
line carries the reason because `curl -v`, `git` and `egress-connect` print
only that line for a refused CONNECT. The provider relay passes the proxy's
reason through as the refusal body's `error.message` and an additive
Expand Down Expand Up @@ -4151,19 +4163,19 @@ authorization, the byte ceilings, budget admission, cancellation and
accounting. It keeps its own `egress_connection` record, which carries
`provider: true` and never `inference: true`. The exemption belongs to the operation, never to a
hostname. Only the relay's validated routes reach the proxy's provider
admission (`relayed`, `packages/ui-sdk/src/server/egress-proxy.ts:322`), and
admission (`relayed`, `packages/ui-sdk/src/server/egress-proxy.ts:338`), and
worker HTTP and `CONNECT` traffic cannot claim it, even to a provider's host
(`narrowed`, `packages/ui-sdk/src/server/egress-proxy.ts:190`). Turn egress
(`narrowed`, `packages/ui-sdk/src/server/egress-proxy.ts:196`). Turn egress
records neither a taint nor a contacted host for the operation
(`admitted`, `packages/ui-server/src/brain/turn-egress.ts:151-154`). So in a
(`admitted`, `packages/ui-server/src/brain/turn-egress.ts:154-157`). So in a
tainted session, the worker's own traffic stays narrowed away from the
provider's host.

A later turn rebuilds its contacted hosts from the session's earlier
`egress_connection` records, and a provider record there would look like a
worker's. So the maintainer added the optional `provider: true` tag, mirroring
`inference: true`, on the record of every validated provider-relay operation
(`finish`, `packages/ui-sdk/src/server/egress-proxy.ts:153-160`). The rebuild
(`finish`, `packages/ui-sdk/src/server/egress-proxy.ts:159-166`). The rebuild
excludes those records (`contactedHosts`,
`packages/ui-server/src/governance/session-taint.ts:34-40`), so a provider
request never gives the worker's own `CONNECT` a contacted-host pass, in the
Expand Down
Loading
Loading