Repository navigation
fix(chat): re-check app ownership in resume's reserved window - #17110
Conversation
3ddd53a to
30eab77
Compare
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] aecc55f Description read[DESCRIPTION-READ] ca0a45caeb0394b5bed389609a20c3a8fe8edcd20b7a714bce94f14f2c73e099 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check that a resume after a finished delete really should answer 200. The old docstring said "A finished delete is still refused by the existence re-check", and What this change shipsInventory (7 items) — 5 justifiedIntent: stop an app's resume from opening or closing a transcript that a different app recreated during the reopen window. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] aecc55f Description read[DESCRIPTION-READ] 00832a128aedbf624c1cf4df215204a7c81807ff7040f5af94f300b9385cc407 That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
30eab77 to
2d2ef83
Compare
Reds on 30eab77, all outside this diff (
|
2d2ef83 to
89bc630
Compare
A closed session's resume clears `closed` after the slot is built, in an awaited worker call, and re-reads the metadata line after it. Those re-reads checked existence, the delete-in-flight marker and `created_at`, but not transcript ownership. On a line with no `created_at`, an app resume could publish a transcript another app deleted and recreated inside that window, and the rollback could write `closed` onto the other app's line. `_identity_refusal` now re-asserts `app_owns_transcript_meta` on every re-read and answers the app's uniform 404, and the marker restore treats a line the app does not own as not this resume's transcript. Tests pin the reserved tail's in-flight arm and the window's release after a finished, raising or cancelled delete.
89bc630 to
aecc55f
Compare
|
Reviewed, not approving (crew-pr-reviewer). This changes an app-ownership authorization check in |
bolichen97
left a comment
There was a problem hiding this comment.
Reviewed on behalf of the maintainers (sweep 2026-10-06): full diff read, callers verified against current main, readiness passed, required checks green, no blocking review threads. Security half: extends the existing app-ownership check into the post-await race window, gated on request_app, uniform 404 for apps, no effect on dashboard users or an app's own transcript. Bypass-closing class. Approving and merging.
Follow-up to #16435.
Problem / Motivation
Goal: An app's resume of a closed session never publishes, or writes
closedonto, a transcript another app owns, and the reserved window's delete check is pinned by a test.Since #16435 every resume of a closed session, app callers included, clears
closedinside a reserved window after the slot is built. The re-reads after that window's awaits check existence, the delete-in-flight marker andcreated_at, but not ownership. On a line with nocreated_at, a delete and same-key recreate under another app inside the window passes all of them: the app resume answers 200 and publishes the other app's transcript. The marker restore decides "same transcript" bycreated_attoo, so a refusal there could putclosedon the other app's line. Separately, no test fails when the tail's own in-flight check is removed.Why it matters
App isolation is a boundary: one app must not open or alter a transcript another app owns. The late barrier before construction already enforces that; the window after it is the gap. The missing test means a later edit could drop the tail's in-flight check and leave a deleted conversation open as a tab with CI green.
Not a goal
_lastchecks identity, notclosed). That predates fix(resume): refuse to publish a slot while its session's delete is in flight #16435.created_at.What changed (motivation → approach → change)
An app resume could adopt another app's transcript because ownership was checked once, before the awaits that let a delete and recreate land. The fix re-asks the same question wherever the window already re-reads the line.
_identity_refusalinchat_api/resume.pyapp_owns_transcript_metaon every re-read, audits the denial, and answers the app's uniform 404._restore_closed_marker_claim_history_deletedocstring inhandlers/sessions.pyresume_conflict, the code resume answers.docs/system-specs/modules/history.mdstates the ownership re-check.Backwards compatibility
Compatible: the only new refusal is an app resume of a transcript that app no longer owns, which the pre-construction barrier already refuses with the same 404. Dashboard resumes and app resumes of their own transcripts behave as before.
Removes nothing: no key, route, field or public function is removed or renamed.
Tests
test_slot_ownership_checkpoint.py::...::test_resume_rechecks_app_ownership_after_the_reopen_write: parksclear_closed, deletes the legacy-shaped transcript and recreates it under another app, and expects 404, no slot, and the other app's line untouched. Fails on origin/main 6f70008 with status 200. Removing only the restore guard fails it on "the rollback closed another app's transcript".test_resume_refuses_an_in_flight_delete.py::test_a_delete_opening_during_the_reopen_write_refuses_the_resume: opens the delete window insideclear_closed, after construction, and expects 409resume_conflict, no slot, no leaked construction mark, andclosedrestored. Fails when the tail's in-flight term is replaced withFalse.test_a_finished_delete_releases_its_window,test_a_delete_that_raises_releases_its_window,test_a_cancelled_delete_releases_its_window: the window closes after each.test_a_resume_after_the_delete_finished_still_refuses_and_one_before_it_publishesis renamedtest_a_skipped_delete_leaves_nothing_that_refuses_a_later_resume, which is what it covers.Run:
test_resume_refuses_an_in_flight_delete.py,test_session_control_revive.py,test_slot_ownership_checkpoint.py,test_remove_slot_for_history_key.py,test_resume_publishes_hydrated_slot.py(431 passed; withtest_dashboard_chat.py, 1321 passed on the head rebased onto e281eca),test/test_history*.pyandtest/test_sessions_*.py(1026 passed); black, isort, flake8 and mypy on the changed files;check_comment_history.py,docs_lint.pyandcheck_feature_map.pyagainst origin/main.Manual verification
N/A: the change is server-side ordering inside one request, and the tests force each interleaving deterministically.
Related Issues
Closes #17105
Pattern harvest
Rule candidate: review-prompt
Pattern: a check done once before an await is not re-asserted on the re-reads after it, so a guard the pre-await barrier enforces is missing from the window it was meant to cover.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)