Repository navigation
Description
Context
#3952 binds a chat's safety history to the account: another owner login continues a chat, because sameAccount (packages/ui-server/src/middleware/account-partition.ts) treats two owner principals as one account. It decides that from the principals rows of both principals.
Principal rows do not last. prunePrincipals deletes a non-ambient principal 30 days after it expires or is revoked (packages/ui-server/src/db/principals.ts:410-421), and an owner login expires after SESSION_TTL_SECONDS, 30 days (packages/ui-server/src/middleware/auth.ts:57). Once the login that started a chat is pruned, its safety_sessions.principal_id names a principal nobody can vouch for. sameAccount treats it as unknown, so every later turn in that chat is refused with Safety principal mismatch, by every login, for good. #3952's test a chat's rows keep the principal that wrote them, and an owner login whose row is gone is unknown pins that refusal.
So a chat stays continuable for roughly 30 to 60 days after the login that started it, depending on when in that login's life the chat began. That is far longer than before #3952 (only until the starting login expired), but it is not "the owner can always continue their chat".
Refusing is the right default: an unknown principal must never become the owner. The question is how to keep the fact that the principal was an owner login.
Decision
Selected — maintainer (2026-11-11): option A. Store durable account ownership with the safety history.
Capture the server-verified account ownership when safety history is written, so a later login of the same owner can continue that history after the originating login row is pruned. Preserve the originating principal IDs as attribution. The durable ownership evidence is not a credential and never restores an expired or revoked login's authority.
This keeps the existing principal-retention policy. Option B (retaining login metadata or tombstones) and option C (making old chats permanently unavailable by policy) were not selected.
Legacy records without durable account evidence may rely only on their still-resolvable original principal. Ownership proof already deleted cannot be recovered or guessed. Missing or contradictory evidence remains refused within the affected scope; it never becomes ownership of the current caller.
Scope
The safety binding checks that use sameAccount: beginSafetyCollection (packages/ui-server/src/governance/safety-store.ts:194), bindSafetyCollection (safety-store.ts:261), SafetyHistory.authorize (packages/ui-server/src/governance/safety-history.ts:43), safetyReviewTarget (packages/ui-server/src/governance/safety-reviews.ts:63) and the safety_decision_identity trigger (packages/ui-server/migrations/087_safety_account_partition.sql:13). Apply the same ownership evidence to admission, binding, reads, inherited/forked history and review-decision identity checks; do not leave one path dependent on a pruned login.
Out of scope
- Voice/dialogue ownership and chat deletion, which compare exact principals by their own rules.
- Changing which principals are one account.
Acceptance criteria
- New safety history captures server-derived, durable account ownership separately from immutable principal attribution. It is not supplied or overridden by a client or model.
- With two owner logins, write history under the first, expire or revoke and prune that login using the real cleanup path, and continue with the still-authorized second login. Admission, collection binding, history reads and safety-review decisions remain usable and refer to the same history and taint.
- Preserve ui-server: an owner continuing a chat from another device is refused as a safety principal mismatch #3952's account equivalence: owner logins share their history; different accounts, agent/system principals and distinct ambient identities do not gain cross-principal access. No current-auth-mode guess may reinterpret historical ownership.
- Legacy history with a resolvable principal keeps its existing access rules. A missing original principal with no durable evidence remains unknown and refused. Corrupt or conflicting evidence is also refused. Any legacy enrichment requires verified evidence; there is no owner-by-default backfill.
- Original
principal_idattribution, safety records, verdicts, coverage/gap facts and history generations are preserved; an ownership metadata migration does not rewrite taint history or make incomplete history clean. - Principal cleanup keeps its existing retention policy. Durable historical ownership does not authenticate a pruned, expired or revoked principal; the caller still needs current authorization.
- A refusal is contained to the uncertain turn/history, with the existing durable diagnostic and recovery rules. An unrelated chat remains usable.
- Provider-facing history stays append-only and receives no new ownership metadata.
Verification
Keyless tests in packages/ui-server/tests, extending safety-account-partition.test.ts, must exercise the real principal-pruning path and all ownership consumers above. Cover same-owner continuation, foreign/unknown/corrupt identity refusal, legacy evidence, unchanged attribution/taint, revocation and unrelated-chat containment. Record a failing-first receipt and restored mutations that (1) remove durable ownership and break continuation after pruning and (2) admit a foreign/unknown account and break the refusal assertion. Run the provider-history guard because these checks are on the turn path.
Contract impact
Internal operational schema and ownership evidence; no new CLI/MCP shape, principal authority or account-equivalence rule is selected. Preserve #3952's public behavior and its additive contract note. Any necessary change to a documented machine surface must update its relevant integration-contract component in the same CONTRACT: commit.
2026-11-11: folded the maintainer's option A ruling into the specification and finalized acceptance/verification; implementation remains open.
The durable decision record is tracked separately in #3978; implementation of this issue does not wait on that documentation task.
Activity
schlessera commentedon Nov 11, 2026
Decision (maintainer, 2026-11-11): Option A — store durable account ownership with the safety history.
Capture ownership from verified server-side identity when history is written, separately from the original principal attribution. A currently authorized owner login can then continue the same history after the originating login is pruned, without extending login retention or authority. Unknown/foreign identities remain refused; already-deleted ownership proof cannot be reconstructed. Legacy rows without durable evidence retain only their evidence-backed access.
The issue body now specifies the chosen branch, the affected admission/binding/read/review paths, and keyless pruning, isolation, attribution and mutation proof. There is no release commitment. Remove
needs: decisionand addagent-ready; no otherneeds:prerequisite remains.The durable decision record is tracked separately in #3978; implementation of this issue does not wait on that documentation task.
schlessera commentedon Nov 17, 2026
Claimed for implementation. Claim token:
claim-b5cea2a3. Branch:fix/3962-durable-safety-ownership.closure-only overlap with open drafts (#3056, #3059, #3069, #3581, #3622, #4002, #4036, #4102, #4106, #4112, #4113, #4115, #4118); no path collisions
fix(ui-server): refuse a verdict on a dialogue owner with no stored a…
CONTRACT: fix(ui-server): keep a chat's safety history with its accou…
schlessera commentedon Nov 17, 2026
Merged in #4128 as
16dfb9cacthrough the integration lease (orchestrator merge queue for 0.45.0). Candidate confirmation passed on the exact head; the squash's own main run carries the post-merge heavy categories.CONTRACT: fix(ui-server): let another owner login continue a chat's r…