Repository navigation
CONTRACT: feat(ui-server): same-account chat deletion for owner logins (#4138) - #4168
Merged
Merged
Conversation
#4138) A chat two owner logins used by voice refused deletion to both of them: resolveChat aggregated exact principal IDs across the dialogue owner, voice epochs and typed-creation binding and refused more than one. Under the maintainer's option B ruling, any currently authorized owner login may delete a chat whose every deletion-relevant ownership record proves that same owner account. - resolveChat returns every ownership record with its stored durable account; chatOwnedBy requires each one to be the caller's account via sameAccount, at the catalog preflight and again in the commit transaction. Missing, corrupt, contradictory or mixed-account evidence refuses that chat alone. - Migration 091 adds principal_account to conversation_epochs and chat_session_owners, written from the principal's own row and backfilled only where a principal row still proves it, so evidence outlives pruning. - The lifecycle, receipt and retry key stay with the initiating login; no record's attribution is rewritten. Provisional chats accept one safety collection per login of one generation. A stale provisional target is reported to the owner account rather than the exact principal. - Decision record amended, HTTP admission semantics and contract index updated, minor changeset added; existing tests that used a second owner login as a foreign caller now use a different account. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
Independent reviewReviewed head 08c3d18 against base 9f9147f. Reviewer: agent. 2 findings: 0 fixed, 0 filed, 0 rejected, 2 without a disposition. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4168,
"head": "08c3d18cf3241126d9627e38eaec6b982d759704",
"base": "9f9147f0ec7d335a82c30e07c7c442e21832949a",
"reviewer": "agent",
"outcome": "findings",
"findings": [
{
"summary": "packages/ui-server/src/ws/chat-lifecycle.ts:120: When a provisional dialogue owner exists, resolveChat skips its safety collections entirely. A collection with corrupt or mixed-account evidence therefore does not prevent retirement. Reproduced with a corrupt principal_account: retirement succeeded, violating the requirement that every relevant ownership record prove the account."
},
{
"summary": "packages/ui-server/src/ws/chat-lifecycle.ts:198: Commit authorization checks expiry against input.at, the timestamp captured before asynchronous catalog/writer waits. A login expiring during that wait still retires the chat because both authorization checks use the old time. Reproduced successful retirement with expires_at before the current time but after input.at; commit must check current time."
}
]
} |
…the current clock (#4138) Review of 08c3d18 found two holes in same-account deletion admission: - resolveChat consulted a history owner's unbound safety collections only when no dialogue owner existed. With a provisional dialogue owner, or under a session chat's history owner, a collection with corrupt or another account's evidence did not stop retirement. Every branch now records each unbound collection under every history owner and alias. - The catalog preflight and the commit transaction checked the caller's expiry against input.at, stamped before the catalog and writer waits, so a login that expired in between still retired the chat. Both now check the current clock; input.at stays only as the recorded retirement time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
Independent reviewReviewed head 08c3d18 against base 9f9147f. Reviewer: agent. 2 findings: 2 fixed, 0 filed, 0 rejected, 0 without a disposition. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4168,
"head": "08c3d18cf3241126d9627e38eaec6b982d759704",
"base": "9f9147f0ec7d335a82c30e07c7c442e21832949a",
"reviewer": "agent",
"outcome": "findings",
"findings": [
{
"summary": "packages/ui-server/src/ws/chat-lifecycle.ts:120: When a provisional dialogue owner exists, resolveChat skips its safety collections entirely. A collection with corrupt or mixed-account evidence therefore does not prevent retirement. Reproduced with a corrupt principal_account: retirement succeeded, violating the requirement that every relevant ownership record prove the account.",
"disposition": "fixed",
"commit": "d2a53cd63bb03723c6a2adac09fc8d2a5d9a0ab8"
},
{
"summary": "packages/ui-server/src/ws/chat-lifecycle.ts:198: Commit authorization checks expiry against input.at, the timestamp captured before asynchronous catalog/writer waits. A login expiring during that wait still retires the chat because both authorization checks use the old time. Reproduced successful retirement with expires_at before the current time but after input.at; commit must check current time.",
"disposition": "fixed",
"commit": "d2a53cd63bb03723c6a2adac09fc8d2a5d9a0ab8"
}
]
} |
…ypechecker (#4138) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 of 7 tasks
Owner
Author
Independent reviewReviewed head 26fbb98 against base 9f9147f. Reviewer: agent. No findings. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4168,
"head": "26fbb985596e7df6f57c4ab3bc181469059e9e1d",
"base": "9f9147f0ec7d335a82c30e07c7c442e21832949a",
"reviewer": "agent",
"outcome": "no-findings",
"findings": []
} |
This was referenced Nov 17, 2026
schlessera
marked this pull request as ready for review
November 17, 2026 16:16
This was referenced Nov 17, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4138. Part of #3234.
What
Any currently authorized owner login may now explicitly delete a chat when every deletion-relevant ownership record proves that same owner account (maintainer ruling, option B). Before this,
resolveChataggregated exact principal IDs across the dialogue owner, voice epochs and typed-creation binding and refused more than one, so a chat two owner logins used by voice could be deleted by neither.resolveChatnow returns every ownership record (owners: AccountRecord[]) with the durable account stored beside it.chatOwnedByrequires each record to be the caller's account through the existingsameAccount(current principal row, or storedprincipal_account; corrupt, contradictory, missing or mixed-account evidence matches nobody). It is checked at the catalog preflight and again inside the commit transaction.authorizedOwnerstill re-reads the caller's own row at both points, so stored evidence never authorizes a caller.principal_accounttoconversation_epochsandchat_session_owners. The writers (saveConversationEpoch,upsertSession) fill it from the principal's own row once and never rewrite it. Legacy rows are backfilled only where a principal row still proves an owner login, and unknowns stay NULL. This builds on ui-server: a chat whose starting owner login was pruned can never be continued #3962's column (089) and ui-server: an owner continuing a chat by voice from another device is refused as a dialogue ownership mismatch #3963's per-conversation login (090); there is no second ownership store.chatRetirementstay bound to it. No record's original principal is rewritten. A stale provisional target is reported asstaleto the owner account (previously only to the exact principal), so it is still never revealed to another account.ownsuses the samechatOwnedBy. Its policy was already account-scoped (sameAccounton the single principal); now a chat whose records name two logins of the account is no longer "unknown", and pruned records keep their stored evidence.chat_retiredstill goes to the initiating login's capable connections (documented); every reader already refuses a retired chat.Docs/contract (
CONTRACT:commit): dated amendment and rejected alternatives indocs/decisions/chat-history-deletion.md; admission semantics indocs/http-api.md; index entry indocs/integration-contract.md; wire note and plan cross-references; minor changeset. The pending #3963 changeset's "exact-principal chat deletion is unchanged" now points at this rule. No request, receipt, refusal or frame shape changes.Tests that changed meaning: several existing deletion tests used a second owner login ("Penelope tablet", passkey) as the "foreign" caller. Under the ruling every owner login is the one owner account, so those fixtures now use a proxy-ambient principal for the other person and a
secondowner login for the same-account cases. PositionalINSERT INTO chat_session_owners VALUES(...)in 16 test files now name their columns, because the table gained a column.Proof
Real SQLite with the real write worker, through actual catalog admission and commit (
tests/dialogue-account-ownership.test.ts,chat-lifecycle.test.ts,chat-deletion.test.ts,chat-session-owner.test.ts):unauthorized.unauthorized.owner; agent, ambient, system and unknown epochs; an unknown principal with a corrupt account) each refuse asunavailable, retire nothing, rewrite nothing, and leave an unrelated chat of the account deletable.unauthorized; a foreign epoch or corrupted evidence landing between preflight and commit givesunavailable; busy givesbusy.partial. The other login cannot read or retry it, and restart reconciliation finishes it under the initiator.Failing-first
The admission files (
chat-lifecycle.ts,session-catalog.ts,app.ts) were reverted toorigin/main, keeping the migration and writers, andtests/dialogue-account-ownership.test.tswas run: 28 pass, 5 fail, each on the claimed assertion.DELETION_ADMITS_THE_ACCOUNTS_LOGINfailed for ship, home and a third login, andDELETION_DURABLE_EVIDENCE_OUTLIVES_PRUNINGfailed for revoked and expired. Every refusal case already passed on base (the old code refused everything). After restoring the files, all pass.Mutations (each applied, run, restored)
chatOwnedByignores accounts (owners.length > 0)DELETION_UNPROVEN_OWNERSHIP_REFUSES×12,FOREIGN_REFUSAL_LEAKS_NOTHING,STALE_NEVER_REVEALS_ANOTHER_ACCOUNTDELETION_DURABLE_EVIDENCE_OUTLIVES_PRUNING×2, corrupt-evidence cases ×3PROVISIONAL_RECORDS_EACH_LOGIN×3DELETION_UNPROVEN_OWNERSHIP_REFUSES×12,PROVISIONAL_MIXED_ACCOUNT_REFUSES×2,FOREIGN_REFUSAL_LEAKS_NOTHINGDELETION_OPERATION_IS_THE_CALLERS,SECOND_LOGIN_PARTIAL_IS_HONEST(6 fail)DELETION_RECORDS_CARRY_DURABLE_ACCOUNTS×3,DELETION_DURABLE_EVIDENCE_OUTLIVES_PRUNING×2CREATION_BINDING_STORES_ITS_ACCOUNTSTALE_FOR_THE_ACCOUNTS_OTHER_LOGINUPGRADE_EPOCH_ACCOUNTSLocal runs
chat-session-ownerfix (which flipped exactly as predicted and is now updated, 2/2 pass). The other 25 failures are ingovernance-policy.test.tsandhttp-supported-mounts.test.tsand fail identically (25) on a cleanorigin/mainworktree: sandbox environment failures.ui-backend-claudeandui-backend-pitests/provider-history.test.ts) fail on a cleanorigin/mainworktree in this sandbox, because the native runtimes cannot spawn here. This change touches no provider-facing path, and hosted proof covers both.bun run typecheck: exit 0.Review round 1 (record at
08c3d18cf, both findings fixed ind2a53cd63bb03723c6a2adac09fc8d2a5d9a0ab8)resolveChatnow records every unbound collection (session_id IS NULL) under every history owner and alias, in every branch. Grepping for the same class found it under a session chat's history owner too, and that case is fixed and tested. Alias owner rows are deleted on adoption, so they are not another skipped source.UNBOUND_COLLECTION_EVIDENCE_REFUSESfailed for {provisional dialogue owner, session history owner} × {corrupt, another account's}, 4 tests.UNBOUND_COLLECTION_OF_THE_ACCOUNT_RETIRES).Date.now()toauthorizedOwner;input.atstays only as the recorded time.EXPIRY_CHECKED_AT_COMMIT_BY_CURRENT_TIME(held writer, expiry lands after the preflight) andEXPIRY_CHECKED_AT_PREFLIGHT_BY_CURRENT_TIMEboth retired before the fix.input.at):EXPIRY_CHECKED_AT_COMMIT_BY_CURRENT_TIMEfails.input.at):EXPIRED_CALLER_NEVER_REACHES_BUSYfails.principalValidalready readsDate.now()after each await, and safety reviews read the clock inside their transaction. Reference-grant creation stampsnowbefore awaiting the writer; that is outside this issue and filed as ui-server: reference-grant creation checks login expiry against a time stamped before the writer wait #4169.Also:
26fbb98makes two test fixturesas const. The earlier typecheck predated those tests; the 8 GBbun run typechecknow exits 0.origin/mainwas merged inf51773e4f(clean; 5 unrelated files). The affected deletion/safety files pass 210/0. Decision record, changeset and moved citations are updated with the fix.Collisions (
bun scripts/collisions.ts --json --pr 4168, head26fbb985596e7df6f57c4ab3bc181469059e9e1d)docs/http-api.md,packages/ui-server/src/app.ts).docs/http-api.md,docs/plans/chat-history-deletion.md,app.ts; it also addsmigrations/091_reference_authority_fences.sql. Migrations are tracked by file name, so the two091_*files coexist in either landing order), test(experiments): assert synchronous Git revision refusal #4036, fix(ci): read a pull request's complete file list for a moved base's overlap (#4114) #4151, chore(ci): shard an oversized determinism selection by reviewed weight (#4117) #4157, chore(ci): partition archived runs by UTC day #4166, fix(backends): write edit_file's new_string literally (#2486) #4167. (chore(ci): refresh the reviewed unit weights and read the complete changed-file list in pr-status (#4140, #4114) #4155 no longer collides at this head.)check:pr receipt
{"version":1,"kind":"brain-check-pr-receipt","head":"26fbb985596e7df6f57c4ab3bc181469059e9e1d","base":"origin/main","mode":"focused","startedAt":"2026-11-17T10:00:30.791Z","finishedAt":"2026-11-17T10:02:06.295Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":22297.702263},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":150.54491699999926},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":124.03690699999424},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":29.810262999999395},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":72876.904884}]}🤖 Generated with Claude Code