Repository navigation
fix(snapshot): do not report a refused memory merge as merged - #28135
Conversation
4b55045 to
25cbd75
Compare
25cbd75 to
5b599a9
Compare
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: it fixes the root cause, since the helper now returns whether it did the merge. Both callers are updated, and both now report a refusal the way crons already does. [DESIGN-REVIEWED] 585edc9 Description read[DESCRIPTION-READ] c5c6957114448702847caf2f72e0a3ac288e96a3f4f9b4cb42ea1fec7b89dbb3 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 |
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. What this change shipsInventory (3 items) — 3 justifiedIntent: someone restoring or importing a bundle with a corrupt
[FIRST-PRINCIPLES-REVIEWED] 585edc9 Description read[DESCRIPTION-READ] 396977a7c039cf2bf63701c5e6bbd3c763217e111762d18a0808d423ed8c2266 That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
5b599a9 to
8393030
Compare
8393030 to
645f007
Compare
645f007 to
ec0bcaf
Compare
ec0bcaf to
c217f01
Compare
Code change approver recommendation: ApproveWhy: the decider estimates a 10% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes. This is a narrow fix and it is correct. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
A restore --mode merge printed '✅ memory' and 'Merge complete' after _merge_memory refused a corrupt or unreadable source memory.db and imported nothing, and the dashboard import reported 'memory (merged)' over the same refusal. _merge_memory now returns whether it merged. The restore driver prints the memory tick only when it did, and the dashboard import names the refusal and lists it in refused_merges, the way both already handle a refused crons merge. Closes kirodotdev#28129
c217f01 to
585edc9
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved. We checked this on head 585edc9. _merge_memory now returns False on both refusal paths and True only after the commit. Both production callers now check that result. The CLI driver no longer prints ✅ memory for a refused merge. apply_import_zip records memory (skipped: ...) and adds the item to refused_merges. We reverted each fix separately, and each time the matching new test failed. The new tests are deterministic and use only tmp_path and monkeypatch.
Well done: the fix copies the existing crons pattern. So the audit log (partial) and the Portability tab's skipped-item filter pick up the refusal with no handler or UI change.
Optional:
- No test checks the success side of the new bool. If
return Trueat snapshot_merge.py:257 becamereturn False, no test would fail. One assertion would cover it: add"memory (merged)" in summary["items"]totest_import_merge_memory_db. The crons tests already check both sides this way. - The Memory bullet in snapshot-and-restore.md could say how a refused memory merge is reported, the same way the Notifications bullet does.
Problem / Motivation
A merge-mode restore whose bundle carries a corrupt or unreadable
memory.dbreports success over a merge that imported nothing._merge_memoryrefuses the source (integrity check failed, or unreadable), prints… skipping merge, and returns. Thenkirocrew restore --mode mergeprints✅ memoryand✅ Merge complete., and the dashboard import (apply_import_zip) addsmemory (merged)to its summary without flagging the refusal.Goal: report a refused memory merge as refused, in both the restore command and the dashboard import, the same way a refused crons merge is already reported.
Why it matters
The person restoring sees a success tick, and the dashboard API caller gets a clean import, while no memory row came back. They have no reason to look for the warning line above the tick. The crons branch was fixed for exactly this reason in #8315; memory was left out.
Not a goal
When a source database is refused does not change, and neither does the merge itself or the restore's exit code: rc 0 on a refused source DB stays, as
TestCorruptSourceDBpins.What changed
src/kiro_crew/snapshot_merge.py:_merge_memorynow returnsbool. It returnsFalsewhen the source is refused (failed integrity check or unreadable) andTrueafter the merge.src/kiro_crew/snapshot_merge_driver.py: the restore driver prints✅ memoryonly when_merge_memoryreturnedTrue, like the crons branch.src/kiro_crew/portability.py: the dashboard import appendsmemory (merged)only on success. A refusal is named initemsand listed inrefused_merges, matching the crons branch just below it.Tests
Proof: PROVEN test/test_portability.py::TestImportMerge::test_import_merge_reports_a_refused_memory_merge, test/test_snapshot.py::TestCorruptSourceDB::test_refused_memory_merge_prints_no_success_tick (head 585edc9)
test_refused_memory_merge_prints_no_success_tickrestores a bundle whosememory.dbis corrupt into a home with a livememory.db. It asserts the skip warning is printed and the✅ memorytick is not, and that rc stays 0.test_import_merge_reports_a_refused_memory_mergedrivesapply_import_zipwith_merge_memoryrefusing. It asserts the summary does not saymemory (merged)and listsmemoryinrefused_merges.test_snapshot*.py,test_portability*.py): 198 passed, 5 skipped.Sibling sweep
Sibling: src/kiro_crew/portability.py -- changed here
The dashboard import's memory merge branch reported
memory (merged)over the same refusal, so it now checks the same return value.Pattern harvest
Rule candidate: review-prompt
Pattern: a helper that can refuse its work prints the refusal and returns None, so each caller reports success anyway. A function that can skip its work must return whether it did, and every caller must gate its success message on that value.
Closes #28129