Repository navigation
feat(chat): pin a merged fork's reopen to the transcript it was merged from - #34274
Conversation
95481ea to
20e5d8c
Compare
20e5d8c to
ac6786e
Compare
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
…d from A merge card records the fork transcript's persisted created_at as mergedFrom.createdAt. Resume now accepts it as an optional expected_created_at and answers 409 resume_identity_mismatch when the transcript it would return is a different one, on both the live-slot and the hydrate paths. Callers that omit it are unchanged. The live-slot check lives in a new chat_api owner, resume_identity, so resume.py stays under the line cap. The parent-turn outcome tests move from test_chat_merge_back_merge.py into test_chat_merge_back_merge_turn_outcome.py for the same reason. Part of kirodotdev#3816.
ac6786e to
e114ec7
Compare
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns: the transcript's existing [DESIGN-REVIEWED] e114ec7 Description read[DESCRIPTION-READ] 84431869f8358784a14d026a952e994e9089341ba75c4398210aa53942ecda54 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 |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The new request field and the new card field have no reader in this tree yet. Both can be withdrawn without breaking anyone, so this is a note. Notes
Inventory (8 items) — 6 justifiedIntent: let someone reopen a merged fork from its merge card and get the exact fork, or be told it is gone. This is an ADDITION (the backend half of #15957).
[FIRST-PRINCIPLES-REVIEWED] e114ec7 Description read[DESCRIPTION-READ] 963d93ecc8dd2ade797138417cb6335e2c490b92c6307360302a888d7ab9cf8d That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
|
This adds a new concept, so it needs a design sign-off from a maintainer before it can merge. A maintainer will post the decision here. To propose a design, follow the request-for-change process in CONTRIBUTING.md (docs/request-for-change/). Review result on e114ec7: no blocking findings. The review read the full source diff and checked these points:
One thing done well: the live-slot tests set Context for the maintainer: #17165, the backend half of merge-back by the same author, is already on main. This PR extends it to the card and to resume, and #15957 is stacked on it. Optional:
|
bolichen97
left a comment
There was a problem hiding this comment.
Approving at e114ec7. Thank you.
- A merge card now records the fork transcript's persisted
created_atasmergedFrom.createdAt(chat_merge_back.py, fromfork._disk_meta_created_at).slot_buffers.pyreads it back bounded byMERGED_FROM_MAX_CREATED_AT_CHARS. A card written before this has nocreatedAtand still counts, so an older merge is not repeated. - The resume route takes an optional
expected_created_at. A caller that omits it gets exactly main's behavior. A supplied one is checked before any slot is returned or published: an empty, non-string or over-long value answers 400invalid_expected_created_at, and a transcript or live slot whose identity differs answers 409resume_identity_mismatch. So a merge card's link opens the fork it came from and never a different chat that took the key. _pinned_live_outcome(resume_identity.py) compares against the identity of the transcript the slot holds (_disk_meta_created_at, else the disk line), notslot.created_at, which is only the constructor's clock.- For an app caller, the pin is judged only after
_app_resume_refusaladmits the app, so a missing key and another owner's session both answer the same 404, and the pin cannot be used to tell them apart. - The new 400 and 409 apply only to the new optional field, so nothing main allows is refused. No regex.
All 94 checks on this head are green.
Problem / Motivation
Goal: Reopening a merged fork from its merge card opens the exact fork that was merged, or says that fork is gone.
A merge card links back to the fork it came from by slot key. A key can be reused: the fork can be deleted and a new chat made under the same name, or a workflow slot can hold another transcript under it. Clicking the card's link would then open the wrong conversation, and nothing tells the user.
This is the backend half of #15957's "merged from" link, which needs a transcript identity it can check.
Why it matters
Without an identity check the dashboard cannot safely show the "merged from" link at all, so on main a merge card never links back to its fork.
Not a goal
expected_created_atdoes.What changed (motivation → approach → change)
A transcript's persisted
created_atis its identity: a chat made later on the same key gets a new one. So the card records it, and a reopen hands it back for checking.chat_merge_back.pywrites the fork'screated_atintomergedFrom.createdAt.sanitize_merged_frominslot_buffers.pykeeps it (at mostMERGED_FROM_MAX_CREATED_AT_CHARS) and reads a card written before the field existed as an empty identity, so earlier merges keep countingPOST /api/chat/slots/{slot}/resumetakes an optionalexpected_created_at(a non-empty string within that bound, else 400invalid_expected_created_at). When the transcript it would return is another one, it answers 409resume_identity_mismatchThe check runs on both resume paths. A live slot's answer goes through
_pinned_live_outcome, which reads the identity of the transcript the slot holds, not the slot's construction stamp. A hydrated resume compares the metadata line it already reads. For an app caller the pin is judged only after_app_resume_refusaladmits it, so a missing key and another owner's key both stay the same 404._pinned_live_outcomelives in a new owner,chat_api/resume_identity.py, composed into thechat_handlersfacade likeresume_window, which keepsresume.pyunder the 2,000-line cap. For the same cap the parent-turn outcome tests move unchanged fromtest_chat_merge_back_merge.pyintotest_chat_merge_back_merge_turn_outcome.py. The dashboard module spec documents the field and the new owner.Backwards compatibility
Compatible:
expected_created_atis optional and a resume without it behaves as on main. A merge card main wrote, with nocreatedAt, still parses and counts.Removes nothing: the diff adds an optional request field, an optional card field and a refusal that only a caller sending the new field can get.
Tests
test_dashboard_chat_history.py(TestResumeExpectedIdentity,TestPinnedResumeOfALiveSlotBoundToAnOlderTranscript): a matching pin resumes, a mismatched or invalid one is refused, a live slot is judged by the transcript it holds, an app caller gets the same 404 for a missing and a foreign key, and an AST check fails if any live-slot probe in_resume_slot_from_history_notedreturns without the pin.test_chat_merge_back.py: the card recordscreatedAt;sanitize_merged_fromrefuses a present non-string or over-long one and reads a missing one as"".test_members_dm_thread_resume_and_reservation.py,test_slot_ownership_checkpoint.py: the pin on crewmate threads and app-owned slots.test_chat_handlers_composition_contract.py: the facade surface with the new owner and parameter.createdAtto card fixtures.Manual verification
N/A: the only caller that sends
expected_created_atis #15957's dashboard link, and the route behaviour is covered end to end against a real conversation log.Related Issues
Part of #3816. #15957 builds on this.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)