From 6693089bb32fa6566e9c2e0a6ea89b87424f1879 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Fri, 20 Nov 2026 15:03:49 +0000 Subject: [PATCH 01/46] CONTRACT: feat(ui-server): enforce prospective exact-origin trust (#3609) --- .changeset/exact-origin-trust.md | 7 ++ api-report/ui-sdk.txt | 51 ++++++++ api-report/ui-server.txt | 20 +++- docs/decisions/governed-writable-workers.md | 8 +- docs/http-api.md | 4 +- docs/integration-contract/http.md | 23 +++- docs/integration-contract/package-api.md | 23 +++- docs/integration-contract/wire.md | 11 ++ docs/plans/reviewable-session-safety.md | 2 +- docs/supported-inputs.md | 12 +- .../src/components/chat/safety-indicator.tsx | 16 +-- packages/ui-react/src/lib/safety-client.ts | 6 +- .../tests/browser/safety-review.layout.tsx | 16 +++ packages/ui-react/tests/safety-client.test.ts | 5 +- packages/ui-sdk/src/safety.ts | 4 +- packages/ui-sdk/src/server/egress-proxy.ts | 25 +++- packages/ui-server/src/app.ts | 5 +- packages/ui-server/src/brain/origin-trust.ts | 20 ++++ .../ui-server/src/brain/trust-settings.ts | 20 +++- packages/ui-server/src/brain/turn-egress.ts | 46 +++++-- packages/ui-server/src/governance/events.ts | 2 +- .../ui-server/src/governance/occurrence.ts | 5 +- .../src/governance/safety-history.ts | 26 ++-- .../src/governance/safety-reviews.ts | 5 +- .../ui-server/src/governance/safety-store.ts | 9 +- .../ui-server/src/governance/session-taint.ts | 4 +- .../ui-server/src/routes/session-safety.ts | 4 +- packages/ui-server/src/ws/connection.ts | 2 +- packages/ui-server/src/ws/handlers/safety.ts | 2 +- packages/ui-server/src/ws/host.ts | 7 +- .../src/ws/session-run/backend-entry.ts | 1 + packages/ui-server/tests/origin-trust.test.ts | 113 ++++++++++++++++++ .../tests/safety-entry-correlation.test.ts | 19 +++ .../ui-server/tests/trust-settings.test.ts | 16 +++ 34 files changed, 455 insertions(+), 84 deletions(-) create mode 100644 .changeset/exact-origin-trust.md create mode 100644 packages/ui-server/src/brain/origin-trust.ts create mode 100644 packages/ui-server/tests/origin-trust.test.ts diff --git a/.changeset/exact-origin-trust.md b/.changeset/exact-origin-trust.md new file mode 100644 index 0000000000..d3d1dd304a --- /dev/null +++ b/.changeset/exact-origin-trust.md @@ -0,0 +1,7 @@ +--- +"@schlessera/brain-ui-server": minor +"@schlessera/brain-ui-sdk": minor +"@schlessera/brain-ui-react": minor +--- + +Enforce prospective exact-origin and explicit-tunnel source trust with separate restricted-recipient permission. This pre-1.0 semantic break lets qualified future inputs avoid unresolved triggers while retaining their historical rule, policy hash and revision. Removing a rule fences active admissions and interrupts trusted input streams; repository trust remains unavailable. Existing triggers, independent controls and provider history are preserved. diff --git a/api-report/ui-sdk.txt b/api-report/ui-sdk.txt index a993b8e283..4636cbb51f 100644 --- a/api-report/ui-sdk.txt +++ b/api-report/ui-sdk.txt @@ -16270,6 +16270,7 @@ signatures (every public export and the types it is made of) }>; }, z.core.$strict>, z.ZodObject<{ cursor: z.ZodOptional>; + includeAdmissions: z.ZodOptional>; includeEntries: z.ZodOptional>; limit: z.ZodOptional; requestId: z.ZodString; @@ -16436,6 +16437,7 @@ signatures (every public export and the types it is made of) clientSafetyReadSchema (packages/ui-sdk/src/safety.ts) const clientSafetyReadSchema: z.ZodObject<{ cursor: z.ZodOptional>; + includeAdmissions: z.ZodOptional>; includeEntries: z.ZodOptional>; limit: z.ZodOptional; requestId: z.ZodString; @@ -21301,6 +21303,13 @@ signatures (every public export and the types it is made of) unresolvedCount: z.ZodNumber; }, z.core.$strict>; records: z.ZodArray; + policyHash: z.ZodNullable; + ruleId: z.ZodOptional; + trustRevision: z.ZodString; + trusted: z.ZodBoolean; + }, z.core.$strict>>; bindingId: z.ZodString; detailPruned: z.ZodBoolean; detector: z.ZodNullable; @@ -21447,6 +21456,13 @@ signatures (every public export and the types it is made of) }, z.core.$strict>; safetyRecordSchema (packages/ui-sdk/src/safety.ts) const safetyRecordSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ + admission: z.ZodOptional; + policyHash: z.ZodNullable; + ruleId: z.ZodOptional; + trustRevision: z.ZodString; + trusted: z.ZodBoolean; + }, z.core.$strict>>; bindingId: z.ZodString; detailPruned: z.ZodBoolean; detector: z.ZodNullable; @@ -21944,6 +21960,13 @@ signatures (every public export and the types it is made of) unresolvedCount: z.ZodNumber; }, z.core.$strict>; records: z.ZodArray; + policyHash: z.ZodNullable; + ruleId: z.ZodOptional; + trustRevision: z.ZodString; + trusted: z.ZodBoolean; + }, z.core.$strict>>; bindingId: z.ZodString; detailPruned: z.ZodBoolean; detector: z.ZodNullable; @@ -26855,6 +26878,13 @@ signatures (every public export and the types it is made of) unresolvedCount: z.ZodNumber; }, z.core.$strict>; records: z.ZodArray; + policyHash: z.ZodNullable; + ruleId: z.ZodOptional; + trustRevision: z.ZodString; + trusted: z.ZodBoolean; + }, z.core.$strict>>; bindingId: z.ZodString; detailPruned: z.ZodBoolean; detector: z.ZodNullable; @@ -27013,6 +27043,13 @@ signatures (every public export and the types it is made of) unresolvedCount: z.ZodNumber; }, z.core.$strict>; records: z.ZodArray; + policyHash: z.ZodNullable; + ruleId: z.ZodOptional; + trustRevision: z.ZodString; + trusted: z.ZodBoolean; + }, z.core.$strict>>; bindingId: z.ZodString; detailPruned: z.ZodBoolean; detector: z.ZodNullable; @@ -27692,6 +27729,13 @@ signatures (every public export and the types it is made of) unresolvedCount: z.ZodNumber; }, z.core.$strict>; records: z.ZodArray; + policyHash: z.ZodNullable; + ruleId: z.ZodOptional; + trustRevision: z.ZodString; + trusted: z.ZodBoolean; + }, z.core.$strict>>; bindingId: z.ZodString; detailPruned: z.ZodBoolean; detector: z.ZodNullable; @@ -27866,6 +27910,13 @@ signatures (every public export and the types it is made of) unresolvedCount: z.ZodNumber; }, z.core.$strict>; records: z.ZodArray; + policyHash: z.ZodNullable; + ruleId: z.ZodOptional; + trustRevision: z.ZodString; + trusted: z.ZodBoolean; + }, z.core.$strict>>; bindingId: z.ZodString; detailPruned: z.ZodBoolean; detector: z.ZodNullable; diff --git a/api-report/ui-server.txt b/api-report/ui-server.txt index f0ea66c3d4..69278ea5aa 100644 --- a/api-report/ui-server.txt +++ b/api-report/ui-server.txt @@ -693,6 +693,14 @@ signatures (every public export and the types it is made of) port: z.ZodNumber; provider: z.ZodOptional>; reason: z.ZodOptional; + recipientAdmission: z.ZodOptional>; + standingRecipient: z.ZodOptional>; + trustedSource: z.ZodOptional>; }, z.core.$strict>; version: number; }; @@ -1073,11 +1081,17 @@ signatures (every public export and the types it is made of) payload: z.ZodObject<{ detail: z.ZodNullable; occurrence: z.ZodOptional; - trustRevision: z.ZodLiteral<"0">; + trustRevision: z.ZodString; trusted: z.ZodLiteral; - }, z.core.$strict>>; + }, z.core.$strict>, z.ZodObject<{ + collectionRevision: z.ZodString; + policyHash: z.ZodString; + ruleId: z.ZodString; + trustRevision: z.ZodString; + trusted: z.ZodLiteral; + }, z.core.$strict>], "trusted">>; detector: z.ZodEnum<{ attachment_input: "attachment_input"; compute_input: "compute_input"; diff --git a/docs/decisions/governed-writable-workers.md b/docs/decisions/governed-writable-workers.md index 08e7d87cc5..7423a02c1d 100644 --- a/docs/decisions/governed-writable-workers.md +++ b/docs/decisions/governed-writable-workers.md @@ -2544,7 +2544,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:86-216`). The note says egress is +`packages/ui-server/src/brain/turn-egress.ts:88-218`). 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 @@ -4150,7 +4150,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:62-84`). +(`createOutwardCalls`, `packages/ui-server/src/brain/turn-egress.ts:64-86`). A background process left by an earlier call can still connect inside such a window; the proxy records it either way. @@ -4344,7 +4344,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:86-242`). Hosts without managed +`packages/ui-server/src/brain/turn-egress.ts:88-244`). Hosts without managed native storage have no proxy, so the Bash classifier remains their shell rule and nothing narrows their egress. @@ -4392,7 +4392,7 @@ through the turn's tool-permission card (`toolName: "Network"`, `kind: (`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:41-46`). +(`taintedDestinationDescription`, `packages/ui-server/src/brain/turn-egress.ts:43-48`). 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 diff --git a/docs/http-api.md b/docs/http-api.md index 57ab56feb5..e616a90223 100644 --- a/docs/http-api.md +++ b/docs/http-api.md @@ -158,10 +158,10 @@ client code has a gap. Source owners are listed after the table. | GET | `/api/journal/configuration-coverage` | S | Read the brain's current untraced configuration-input set | Latest complete inventoried turn only; explicit `unknown`, never an empty list. | | GET | `/api/agent-policy` | I | Read shared admission policy and reported enforcing limits | Read-only Devices & agents facts; no editor or duplicate policy cache. | | GET | `/api/policy-proposals/:turnId/:requestId` | I | Read one principal-owned policy request receipt | Same-request reconciliation only; never writes or reactivates approval. | -| GET | `/api/trust-settings` | I | Read trust policy data and publication availability | Paired Security settings transport (#3608); live password-mode human owners only; runtime trust remains disabled. | +| GET | `/api/trust-settings` | I | Read trust policy data and publication availability | Paired Security settings transport (#3608); live password-mode human owners only; exact origin/tunnel enforcement is advertised independently from unavailable repository enforcement. | | GET | `/api/trust-settings/:request` | I | Read one owner-bound trust publication receipt and review | Same-request reconciliation only; never republishes or resolves a taint trigger. | | POST | `/api/trust-settings/prepare` | I | Prepare one exact-base trust change | Paired Security settings transport; same-origin JSON and live owner authority; repository create/edit independently verifies host metadata. | -| POST | `/api/trust-settings/commit` | I | Publish the exact owner-reviewed trust change | Shared descriptor-bound publisher; bounded durable receipt; saved policy does not imply runtime enforcement. | +| POST | `/api/trust-settings/commit` | I | Publish the exact owner-reviewed trust change | Shared descriptor-bound publisher; bounded durable receipt; enforced origin/tunnel publication joins live admission fences, while repository publication remains unavailable. | | GET | `/api/sessions/:id/safety` | S | Read bounded revisioned host safety evidence | Authenticated principal of the history owner's account (#3952); immutable records, snapshot aggregate/high-water, scoped cursor, explicit coverage/unavailable, no mutation (#3604). | | POST | `/api/sessions/:id/safety/reviews/prepare` | S | Prepare review of one finalized safety occurrence | Live password-mode human owner, exact Origin and bounded JSON; host-issued body/brain/principal/generation-bound handle (#3603). | | POST | `/api/sessions/:id/safety/reviews/:requestId/commit` | S | Commit or read back one individual safe verdict | Live owner rechecked on the acquired FULL transaction and final response; immutable receipt plus fresh aggregate, no bulk clear or standing rule (#3603). | diff --git a/docs/integration-contract/http.md b/docs/integration-contract/http.md index a27ea82c45..345570ba16 100644 --- a/docs/integration-contract/http.md +++ b/docs/integration-contract/http.md @@ -460,8 +460,7 @@ The version 1 governance taint payload optionally adds strict host occurrence metadata; the source enum adds `legacy_unknown`. Every input/output/path/mark signal is independent, including later signals from the same source. Exact host-key retries deduplicate; changed identity/payload retries refuse. Admission -records `trusted: false`, the admitted policy hash (or `null`) and trust revision -`"0"`. Runtime source trust remains disabled. Verified proxy provenance records +records the host admission decision. Unmatched input retains `trusted:false`, the admitted policy hash (or `null`) and current trust revision. Since #3609, verified exact-origin/tunnel matches retain `trusted:true`, `ruleId`, exact trust policy hash, `trustRevision` and `collectionRevision`; these immutable facts survive rule removal and detail pruning. Trusted admissions remain inspectable and do not contribute unresolved triggers. Unknown or independent signals stay restrictive. Verified proxy provenance records only the actual web origin or opaque tunnel authority; worker tool arguments never establish transport or repository provenance. The proxy's optional `connectionId` relates its admission and receipt, without guessing a tool call. @@ -1310,3 +1309,23 @@ Authenticated `GET /api/status` adds `journalCleanup`: `retained` contains `retrying: true` at the time it was recorded. The historical cause survives recovery and restart; it does not assert a currently blocked turn. Current charges remain separate in `retained`. No field changes public `/health`. + + +### Prospective origin enforcement (breaking before 1.0, #3609) + +The composed host enables incoming-source and explicit restricted-recipient +rules for verified exact web origins and explicitly selected opaque tunnel +authorities. Repository enforcement stays unavailable pending its independent +read qualification. A CONNECT authority never asserts HTTPS or a Git path. +Redirects and concurrent traffic receive independent decisions; scheme, port +and subdomain cannot borrow another selector's permission. + +Standing recipient permission bypasses only the taint-network card. Source-only +trust grants no recipient permission after unrelated input restricts a chat. +Egress evidence retains `trustedSource` and/or `standingRecipient` markers; a standing recipient decision also records `recipientAdmission` with its rule ID, exact policy hash, trust revision and collection revision. Connections covered by either standing capability do not create a legacy +hostname grant; existing unrelated legacy grants retain their original scope. +Deny/allowlists, byte ceilings, provider credentials and outward-action approval +remain independent. Removing a standing capability affects future admissions; +source streams stop on a trust revision change before subsequent input bytes. +Approval and recording waits recheck live authority and recipient permission at +final dispatch. No earlier trigger, verdict or provider message is rewritten. diff --git a/docs/integration-contract/package-api.md b/docs/integration-contract/package-api.md index 3e829dc991..bf2b26ce4c 100644 --- a/docs/integration-contract/package-api.md +++ b/docs/integration-contract/package-api.md @@ -5584,7 +5584,7 @@ capability, HTTP endpoint, history DTO or provider conversation changes here. The optional owner-only `/api/trust-settings` HTTP surface is a policy-publication building block. `GET /api/trust-settings` reads the current trust-only revision, exact policy hash, `origins`, `repositories`, repository-identity availability, -and disabled runtime enforcement capabilities. +and independently advertised runtime enforcement capabilities. The composed host enables origin/recipient enforcement; repository enforcement remains unavailable. `POST /api/trust-settings/prepare` accepts strict version-1 JSON with `expectedTrustRevision`, `expectedPolicyHash` and exactly one `change`: `{action:create|edit,rule}` or `{action:remove,ruleId}`. The host issues the @@ -5633,12 +5633,10 @@ only read the original outcome; changed data conflicts. Expired handles can never create operations. Prepared/readback text survives stale-base refusal. The receipt stages are `prepared|file_published|committed|partial|unknown|refused`; -`committed` is an internal publication-completion stage, never proof of live -runtime enforcement. Current responses use `partial` for saved policy because -`enforcement:unavailable` remains truthful until the admission implementation. +`committed` with `enforcement:enforced` reports a qualified origin/tunnel publication only after the live revision and active input fences have updated. Repository publication and hosts without origin enforcement continue to return `partial` with `enforcement:unavailable`. `currentRule:present|removed|changed|unknown` is refreshed on reads, independently of historical publication proof. Readback loads the durable operation and policy -projection within the same brain lock after any in-progress commit finishes. No removal receipt claims an enforcing fence. +projection within the same brain lock after any in-progress commit finishes. An enforced origin removal has already fenced later active-turn admission and interrupted affected source streams. No agent turn, provider message or ordinary governance snapshot is changed. The journal awaits asynchronous metadata and publication before releasing its Settings observation window. It records intervening changes with their ordinary attribution before @@ -5649,7 +5647,7 @@ The live trust projection retains last-valid rules on invalid policy, reports an error, and increments its decimal uint64 revision only for trust-list changes. Exhausted revisions refuse both new reviews and publication of retained reviews before any protected policy write; request revisions above uint64 also refuse. -It is supplied for future admission integration; runtime capabilities remain off. +The composed host shares its live trust revision with proxy and backend admission; ordinary turn budgets, commands and profiles retain their admitted snapshots. The HTTP boundary admits at most 32 concurrent requests per principal and 256 for the served brain, including lock waiters; excess requests return retryable @@ -5952,3 +5950,16 @@ for every interactive session, so a new session's retained append contains the bullet. A session retained earlier keeps its append byte for byte. The same-commit API report records the additive types. See [the MCP component](mcp.md#raw-connections-to-githubs-api-0450-3799). + + +### Historical origin admission evidence (#3609) + +Safety occurrence DTOs add optional `admission` with `trusted`, `policyHash` +and `trustRevision`; a true decision also carries `ruleId` and +`collectionRevision`. It is host-owned historical evidence, never client +permission or a human verdict. Older payloads without it retain conservative +interpretation. The aggregate excludes trusted admissions from unresolved +counts while keeping unrelated occurrences, coverage gaps and recording failures +restrictive. Pruning preserves these minimal admission facts. The UI names +historical source trust separately and offers no safe-verdict action for it. +Provider history remains byte-identical as an earlier prefix. diff --git a/docs/integration-contract/wire.md b/docs/integration-contract/wire.md index f855f99514..339d26628d 100644 --- a/docs/integration-contract/wire.md +++ b/docs/integration-contract/wire.md @@ -3349,3 +3349,14 @@ These sidecars never change provider messages, tools or system prefixes. The host-only verdict store remains separate; this slice changes no effective-taint admission semantics or Settings policy. The semantic G6 break remains governed by the prior maintainer ruling in the session-safety ADR. + + +### Historical admission evidence (additive, #3609) + +A server advertising `sessionSafetyAdmissionEvidence:true` accepts optional +`includeAdmissions:true` on `safety_read`. Only opted-in snapshot pages and +their subscriptions include occurrence `admission` evidence. Cursor continuation +pins this choice alongside entry correlation; changing it requires a fresh +snapshot. Older readers retain their strict record shape and conservative +interpretation. New clients omit the field when the server capability is absent. +HTTP readers explicitly opt in with `admissions=1`; repeated/invalid query values are refused. This affects host UI sidecars only; it never changes provider history. diff --git a/docs/plans/reviewable-session-safety.md b/docs/plans/reviewable-session-safety.md index 5f57f1cc9e..4958e5467f 100644 --- a/docs/plans/reviewable-session-safety.md +++ b/docs/plans/reviewable-session-safety.md @@ -36,7 +36,7 @@ public design or its fixtures. Fictional examples use the Odysseus world. never prove finalized delivery or complete coverage. - The turn proxy records each admitted non-provider connection and terminal exposure observation (`prepareTurnEgress`, - `packages/ui-server/src/brain/turn-egress.ts:86-295`). Relay admissions join + `packages/ui-server/src/brain/turn-egress.ts:88-297`). Relay admissions join this proxy's submitted terminal observations and its own announced session binding before reading fresh safety (`settleTurnSessionBinding`, `packages/ui-server/src/ws/bridge-session-binding.ts:14-28`), without excluding diff --git a/docs/supported-inputs.md b/docs/supported-inputs.md index 9301decc05..ddec487720 100644 --- a/docs/supported-inputs.md +++ b/docs/supported-inputs.md @@ -110,11 +110,13 @@ repeated hyphens; repository tokens are 1–100 ASCII alphanumeric/`_.-` bytes, excluding `.` and `..`. Stable provider IDs are nonzero decimal strings of at most 20 digits. A parsed worker remote never proves provider identity. -These are policy data and pure candidate matching only. All runtime origin, -recipient and repository rule capabilities remain **disabled**, with an -explicit reason in the internal availability facts. There is no new Settings -writer, transport, admission exemption, historical reclassification or safe -verdict. Incoming-only rules cannot authorize a restricted destination; repo +Schema parsing and pure candidate matching alone enable no runtime authority. +The data-only availability defaults remain disabled. Since #3609, the composed +host independently advertises qualified exact-origin/tunnel source and recipient +enforcement; repository enforcement remains disabled. See the +[admission contract](integration-contract/http.md#prospective-origin-enforcement-breaking-before-10-3609) +and [owner Settings publication](integration-contract/package-api.md#human-trust-settings-publication). +No rule retrospectively reclassifies a trigger or supplies a safe verdict. Incoming-only rules cannot authorize a restricted destination; repo rules cannot authorize a generic host, outward write or private acquisition. The existing `taint.egress.allow` list is not populated from these entries. diff --git a/packages/ui-react/src/components/chat/safety-indicator.tsx b/packages/ui-react/src/components/chat/safety-indicator.tsx index a417af5bc4..60c38ef34a 100644 --- a/packages/ui-react/src/components/chat/safety-indicator.tsx +++ b/packages/ui-react/src/components/chat/safety-indicator.tsx @@ -70,9 +70,10 @@ function SafetyIndicator({entries:currentEntries}:{entries:SafetyEvidence[]}) { const entries=allowed?(currentEntries.length?currentEntries:open||readStatus!=="ready"?held.current.entries:[]):[]; useEffect(()=>{if(!allowed)setOpen(false);},[allowed]); useEffect(()=>{setOpen(false);},[scope,auth]); - const unresolved=entries.filter(e=>!e.decision).length,unknown=entries.some(e=>e.occurrence.detailPruned||e.occurrence.source==="legacy_unknown"); - const name=unresolved?`Safety restrictions: ${unresolved} unresolved trigger${unresolved===1?"":"s"}`:`Marked safe by you${entries.length>1?`: ${entries.length} triggers`:""}: show details`; - const reason=unresolved?`${sources[entries[0]!.occurrence.source]} · Only this trigger can be reviewed`:"Human decision retained; content remains in the model context"; + const unresolved=entries.filter(e=>!e.decision&&!e.occurrence.admission?.trusted).length,unknown=entries.some(e=>e.occurrence.detailPruned||e.occurrence.source==="legacy_unknown"); + const trusted=entries.some(e=>e.occurrence.admission?.trusted); + const name=unresolved?`Safety restrictions: ${unresolved} unresolved trigger${unresolved===1?"":"s"}`:`${trusted?"Trusted at admission":"Marked safe by you"}${entries.length>1?`: ${entries.length} triggers`:""}: show details`; + const reason=unresolved?`${sources[entries[0]!.occurrence.source]} · Only this trigger can be reviewed`:trusted?"Historical source trust retained; current rules may differ":"Human decision retained; content remains in the model context"; useLayoutEffect(()=>{ if(!open)return; const place=()=>{const r=trigger.current?.getBoundingClientRect();if(r)setPosition({left:Math.max(12,Math.min(r.left,innerWidth-Math.min(384,innerWidth-24)-12)),top:Math.max(12,Math.min(r.bottom+4,innerHeight-Math.min(520,innerHeight*.65)-12))});}; @@ -108,18 +109,19 @@ function SafetyTrigger({entry}:{entry:SafetyEvidence}) { useEffect(()=>{if(state.status!=="ready"||!state.capabilities?.review||auth!=="active")setReview(false);},[state.status,state.capabilities?.review,auth]); const r=entry.occurrence,session=state.identity&&"sessionId" in state.identity?state.identity:null; const readable=state.status==="ready"&&!!session,owner=state.capabilities?.review===true&&auth==="active"; - const canReview=readable&&owner&&entry.exposure==="finalized"&&!entry.decision&&!state.projection?.pendingCount&&!state.projection?.reasons.includes("recording_failed"); + const canReview=readable&&owner&&entry.exposure==="finalized"&&!entry.decision&&!r.admission?.trusted&&!state.projection?.pendingCount&&!state.projection?.reasons.includes("recording_failed"); const busy=progress?.stage==="pending",unknown=progress?.stage==="unknown"; const provenance=r.provenance?.kind==="web_origin"?`${r.provenance.origin.scheme}://${r.provenance.origin.host}:${r.provenance.origin.port}`: r.provenance?.kind==="tunnel_authority"?`${r.provenance.authority.host}:${r.provenance.authority.port}`:"Source provenance unavailable"; return
-

{entry.decision?"Marked safe by you":"Safety restrictions enabled"}

+

{r.admission?.trusted?"Trusted at admission":entry.decision?"Marked safe by you":"Safety restrictions enabled"}

{sources[r.source]} ·

{r.summary}

{provenance}

+ {r.admission?.trusted&&

Source rule {r.admission.ruleId} · trust revision {r.admission.trustRevision}. This historical decision grants no current recipient permission.

} {r.detailPruned&&

Some source detail has expired. The trigger and any decision remain recorded.

} {entry.decision&&

Marked safe by you ·

} - {!entry.decision&&entry.exposure!=="finalized"&&

{entry.exposure==="open"?"Input is still arriving. Mark as safe is unavailable until delivery is finalized.":"Delivery could not be confirmed. This trigger cannot be marked safe."}

} - {!owner&&!entry.decision&&

Only the authenticated owner can mark this trigger safe.

} + {!r.admission?.trusted&&!entry.decision&&entry.exposure!=="finalized"&&

{entry.exposure==="open"?"Input is still arriving. Mark as safe is unavailable until delivery is finalized.":"Delivery could not be confirmed. This trigger cannot be marked safe."}

} + {!r.admission?.trusted&&!owner&&!entry.decision&&

Only the authenticated owner can mark this trigger safe.

} {!readable&&

Current evidence is unavailable or incomplete. Read it again before reviewing.

} {canReview&&!review&&!progress&&