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
6 changes: 6 additions & 0 deletions .changeset/managed-reference-wire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@schlessera/brain-ui-sdk": patch
"@schlessera/brain-ui-server": minor
---

Add a host-owned bounded GitHub acquisition wire with live repository-grant and independent API credential-recipient checks. Managed acquisition records never grant contacted-host authority. Keep repository trust disabled until immutable source and read provenance are qualified.
1 change: 1 addition & 0 deletions api-report/ui-sdk.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,7 @@ export "./internal" (./src/internal.ts)
createWorkerFileObserver
denyWorkerCommand
describeClient
egressAddressRefusal
egressBootstrapEntry
envMaskedPaths
execWrapperSpawnOptions
Expand Down
1 change: 1 addition & 0 deletions api-report/ui-server.txt
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ signatures (every public export and the types it is made of)
durationMs: z.ZodNumber;
host: z.ZodString;
inference: z.ZodOptional<z.ZodLiteral<true>>;
managedReference: z.ZodOptional<z.ZodLiteral<true>>;
method: z.ZodString;
outcome: z.ZodEnum<{
cancelled: "cancelled";
Expand Down
44 changes: 42 additions & 2 deletions docs/decisions/reference-source-acquisition.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ the previous root, so a refresh fetches only new objects. Then
2. The **network transport** fetches one ref into it. It is the only worker
that may hold a credential: the granted host variable, delivered through a
fixed credential helper, with one allowed protocol and no redirects
(`fetch({ repository, ref, token, root, signal })`, `packages/ui-server/src/brain/reference-transport.ts:145-163`).
(`async fetch({ repository, ref, token, root, signal, wire })`, `packages/ui-server/src/brain/reference-transport.ts:169-190`).
3. A separate **checkout worker** has no credential and no network. It checks
out the commit and evaluates the repository's attributes. No filter or
hook is configured, so none runs
(`async checkout({ root, commit, signal })`, `packages/ui-server/src/brain/reference-transport.ts:164-174`).
(`async checkout({ root, commit, signal })`, `packages/ui-server/src/brain/reference-transport.ts:191-200`).
4. The live grant is read again, the root is sealed, the grant is read
again, and only then is the root published.

Expand All @@ -105,6 +105,46 @@ A failure or cancellation releases the staging root through the pool, and only
after the worker has exited. The pool keeps its reservation charged until
reclamation is observed.

## Fixed GitHub wire and identity authority (#3613)

The concrete access owner (`createGitHubReferenceAccess`,
`packages/ui-server/src/brain/github-reference-access.ts:12-129`) uses the
fixed transport (`createGitHubReferenceWire`,
`packages/ui-server/src/brain/github-reference-wire.ts:19-254`).

The host-only GitHub access service binds one canonical repository and short
branch/tag to a bounded acquisition. Anonymous metadata precedes a private
attempt. Only an existing live grant for the actual brain/principal, with
explicit permission for `https://api.github.com`, permits a credentialed
metadata retry. Every use retains the selected grant identity and credential
selector: replacement, revocation, a changed covering grant, changed credential
or lost API permission refuses the operation. Public acquisition stays
anonymous even when the host holds a credential and the principal has a grant.
Owner identity uses its own anonymous `/users/<owner>` operation, without a
Git channel or credentialed mode. Parsed identity data carries no trust or
approved-owner-boundary claim.

The fixed wire shares one operation allowance across metadata, Git discovery,
authentication and fetch, and charges the real turn counter. It counts TLS
framing and both directions. Before forwarding each chunk it rechecks live
authority, final egress admission and the remaining allowance. An inbound chunk
can already have crossed the socket when it exceeds that allowance: it is
refused, the residual turn allowance is consumed, every channel closes and
separate observed socket counts retain the overrun. This does not promise
zero physical-network overshoot. Metadata bodies have a separate 65536-byte
ceiling and never redirect. All DNS answers must be public; connection uses a
checked address with system TLS verification of the fixed host.

Separate random capabilities bind Git/API and anonymous/credentialed channels.
Only the host's fixed Git argv receives a Git proxy capability; callers of the
access service receive neither that capability nor the credential. An invalid
revision is refused before metadata dispatch, fetch needs that acquisition's
resolved full ref, and commit movement refuses before checkout. Failed final
identity revalidation ends the acquisition. Cancellation, turn stop and a
finite deadline close its sockets; a late successful command cannot outlive
the wire. This wire establishes neither sealed-root provenance nor qualified
immutable-read evidence and enables no repository trust rule by itself.

## Admission

At most `BRAIN_UI_REFERENCE_ACQUISITIONS` (default two) acquisitions or
Expand Down
2 changes: 1 addition & 1 deletion docs/http-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1726,7 +1726,7 @@ read by any authenticated principal.
| Kind | Version | Fields | Meaning |
| --- | --- | --- | --- |
| `safety_admission_expired` | 1 | `toolUseId`, `evidenceRevision`, `trustRevision`, `authorityEpoch`, `reason` | A waiting or claimed safety-bound approval was withdrawn before dispatch. The server commits this terminal fact before settling the backend wait or publishing the coordinator's `expired` result. Revisions describe the card's original host snapshot; `reason` is `safety_changed`, `turn_ended` or `grant_storage_failed`. Storage failure stops the turn with an explicit failed terminal outcome, without claiming durable withdrawal. This grants no replay and changes no historical approval. |
| `egress_connection` | 1 | `connectionId` (optional), `host`, `port`, `method`, `path` (optional), `bytes`, `accounting`, `durationMs`, `outcome`, `inference` (optional), `provider` (optional, #3246), `reason` (optional) | A completed, denied, failed or cancelled proxy connection. HTTP has a path and conservative wire accounting; opaque CONNECT has no path or plaintext claim. Only the concrete inference relay sets `inference: true`, and only a validated provider-relay operation sets `provider: true`; a record never carries both. Neither relay's record makes its host a contacted one for a tainted session's worker traffic. Headers, query strings and content are absent. |
| `egress_connection` | 1 | `connectionId` (optional), `host`, `port`, `method`, `path` (optional), `bytes`, `accounting`, `durationMs`, `outcome`, `inference` (optional), `provider` (optional, #3246), `managedReference` (optional, #3613), `reason` (optional) | A completed, denied, failed or cancelled proxy connection. HTTP has a path and conservative wire accounting; opaque CONNECT has no path or plaintext claim. Only the concrete inference relay sets `inference: true`, only a validated provider-relay operation sets `provider: true`, and only the fixed host GitHub acquisition wire sets `managedReference: true`. Each operation supplies its own exclusive tag. These host records grant no contacted-host authority to a tainted session's worker traffic. Managed acquisition retains ordinary recipient restrictions and claims no model-content delivery or repository trust. Headers, query strings and content are absent. |
| `steering_change` | 1 | `path`, `sequence`, `beforeHash`, `afterHash`, `taintSourceEventId`, `overlappingTurnIds`, `tainted` (optional) | One observed steering change, attributed to its turn. Hashes identify retained regular-file versions or are `null`; the source is the current unresolved taint event or `null`. New observations may carry `tainted: true` for effective restriction, including unknown coverage without an attributable source. Historical rows retain their original attribution. Shared windows remain shared, not exclusive writer claims. |
| `policy_change` | 1 | `requestId`, `baseHash`, `proposedHash`, `sections`, `outcome` | Explicit user-approved policy publication. Actor is `user`; outcome is `updated`; hashes identify the exact reviewed and written bytes. |
| `scratch_overage` | 1 | `bytes`, `pinnedFiles`, `pinnedBytes`, `overageBytes` | Scratch remains above its cap after a prune that preserved retained links. Counts are remaining bytes and pinned files/bytes; `overageBytes` is the excess. A background pass has actor `server` and no session or turn; unbound retention applies. |
Expand Down
12 changes: 12 additions & 0 deletions docs/integration-contract/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,18 @@ unbound safety evidence has no eviction TTL. Revision exhaustion refuses before
wrap. These foundations supply the later verdict slice's projection without
publishing a mutation surface.

<a id="managed-reference-acquisition-additive-3613"></a>

**Managed reference acquisition audit (additive, #3613).** Version 1
`egress_connection` may carry `managedReference: true` for the host's fixed
GitHub acquisition wire. Worker headers cannot select this tag. Its TLS bytes
share the turn's existing byte counter, and its recipient retains ordinary
egress policy and restricted-recipient checks. These records never add the
destination to the session's contacted hosts, in memory or after reload.
Acquisition alone has delivered no source content to the model and records no
input occurrence; an immutable read needs its own independently bound evidence.
No repository trust capability or worker-facing authenticated relay is added.

<a id="shell-taint-behind-the-egress-proxy-breaking-3429"></a>

**Shell taint behind the egress proxy (breaking before 1.0, #3429).** On a
Expand Down
11 changes: 11 additions & 0 deletions docs/integration-contract/package-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ A backend that never calls it, and every call it reports nothing for, keeps
the observation after each result. This is first-party implementation sharing
under the internal-entry classification below and requires a patch changeset.

## Managed GitHub acquisition wire (internal #3613)

The internal turn proxy has a first-party `managedReference(target,
signal)` operation for fixed GitHub HTTPS acquisition and a `remainingBytes()`
counter. It retains ordinary G6 recipient narrowing, final admission fences
and byte accounting; it cannot grant a contacted-host allowance. No worker
header selects it. The internal entry also exports the existing
`egressAddressRefusal` validator so the fixed acquisition wire validates every
DNS address before connecting to a checked IP. These are implementation
sharing, with no supported public transport extension seam (#3613).

## Prepared ordinary inference transport (internal #1665)

The existing `WorkerSandbox` input adds optional `@internal egress`, a concrete host-created
Expand Down
2 changes: 1 addition & 1 deletion docs/plans/reviewable-session-safety.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public design or its fixtures. Fictional examples use the Odysseus world.
([reference-source grants](../decisions/reference-source-grants.md)). Its
fixed Git transport separates network acquisition from credential-free,
network-free checkout (`createReferenceTransport`,
`packages/ui-server/src/brain/reference-transport.ts:97-176`).
`packages/ui-server/src/brain/reference-transport.ts:106-203`).
- The Security and Devices & agents surfaces already exist; policy facts are
currently read-only (`AgentPolicyGroup`,
`packages/ui-react/src/components/settings/agent-policy-group.tsx:8-51`).
Expand Down
6 changes: 6 additions & 0 deletions docs/process/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ as true for local fixtures. Loopback alone reports false and correctly pauses
share upload before the ownership assertions (#2401). Keep browser egress
guards and the test preload enabled.

An inherited `/sys/class/net` mount may still list the parent's interfaces
after entering a fresh network namespace. Audit the current namespace through
`ip -j link show` and its IPv4/IPv6 route queries; do not infer its interfaces
from that inherited sysfs view. The managed Git wire fixture requires only
loopback, empty main routes and all setup capabilities dropped before Git runs.

Setup needs `unshare --keep-caps`, but retaining those capabilities for tests
makes bubblewrap refuse with `Unexpected capabilities but not setuid`.
The launcher drops inherited, ambient and bounding capabilities through
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-sdk/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export { execWrapperSpawnOptions, workerExecHelpers } from "./server/exec-wrappe
export { assertScratchMask, assertScratchMaskAsync } from "./server/bridge-tools/mask.js";
export { startInferenceRelay, ANTHROPIC_INFERENCE_ROUTES, INFERENCE_PLACEHOLDER, WORKER_INFERENCE_SOCKET } from "./server/inference-relay.js";
export type { InferenceRelay, InferenceRelayEvent } from "./server/inference-relay.js";
export { startEgressProxy, egressBootstrapEntry, EgressAdmissionRefused, WORKER_EGRESS_DIR, WORKER_EGRESS_TRANSPORT_ENV } from "./server/egress-proxy.js";
export { startEgressProxy, egressAddressRefusal, egressBootstrapEntry, EgressAdmissionRefused, WORKER_EGRESS_DIR, WORKER_EGRESS_TRANSPORT_ENV } from "./server/egress-proxy.js";
export { startProviderRelay, parseCliProviderOrigins, relayedProviderKeys, heldCustomProviderKeys, PROVIDER_RELAY_KEYS_NAME, providerUsage, FIRST_PARTY_PROVIDER_RECIPIENTS, PROVIDER_RELAY_SOCKET_NAME, WORKER_PROVIDER_RELAY_SOCKET, MAX_PROVIDER_REQUEST_BYTES, type ProviderRelay, type ProviderRelayOptions, type ProviderRelayReceipt, type ProviderRelayRefusal, type ProviderUsage, type ProviderOperation } from "./server/provider-relay.js";
export { hostProviderCredential, hostComputeCredential } from "./config/env.js";
export type { EgressDestinationPolicy, EgressRecord, EgressRefusal } from "./server/egress-proxy.js";
Expand Down
Loading
Loading