Skip to content

fix(snapshot): do not report a refused memory merge as merged - #28135

Merged
KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
rohnkum:fix/snapshot-merge-memory-tick
Nov 11, 2026
Merged

KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
rohnkum:fix/snapshot-merge-memory-tick

Conversation

@rohnkum

@rohnkum rohnkum commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

A merge-mode restore whose bundle carries a corrupt or unreadable memory.db reports success over a merge that imported nothing. _merge_memory refuses the source (integrity check failed, or unreadable), prints … skipping merge, and returns. Then kirocrew restore --mode merge prints ✅ memory and ✅ Merge complete., and the dashboard import (apply_import_zip) adds memory (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 TestCorruptSourceDB pins.

What changed

  • src/kiro_crew/snapshot_merge.py: _merge_memory now returns bool. It returns False when the source is refused (failed integrity check or unreadable) and True after the merge.
  • src/kiro_crew/snapshot_merge_driver.py: the restore driver prints ✅ memory only when _merge_memory returned True, like the crons branch.
  • src/kiro_crew/portability.py: the dashboard import appends memory (merged) only on success. A refusal is named in items and listed in refused_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_tick restores a bundle whose memory.db is corrupt into a home with a live memory.db. It asserts the skip warning is printed and the ✅ memory tick is not, and that rc stays 0.
  • test_import_merge_reports_a_refused_memory_merge drives apply_import_zip with _merge_memory refusing. It asserts the summary does not say memory (merged) and lists memory in refused_merges.
  • The snapshot and portability test files (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

@rohnkum
rohnkum requested review from a team and KiroCrewCaptain as code owners November 2, 2026 12:43
@rohnkum
rohnkum requested a review from chenmingwei23 November 2, 2026 12:43
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 2, 2026
@rohnkum
rohnkum force-pushed the fix/snapshot-merge-memory-tick branch from 4b55045 to 25cbd75 Compare November 6, 2026 17:28
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 6, 2026
@rohnkum
rohnkum force-pushed the fix/snapshot-merge-memory-tick branch from 25cbd75 to 5b599a9 Compare November 8, 2026 06:34
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 585edc9acca53272f8a1b4c70dfdc6a93d3c82a2 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision 585edc9acca53272f8a1b4c70dfdc6a93d3c82a2 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 585edc9acca53272f8a1b4c70dfdc6a93d3c82a2 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. _merge_memory has two callers (grepped _merge_memory\( in src/), and both now gate their success report on its return value.

What this change ships

Inventory (3 items) — 3 justified

Intent: someone restoring or importing a bundle with a corrupt memory.db is told the memory merge was refused instead of seeing a false success. FIX.

  1. kirocrew restore --mode merge no longer shows ✅ memory when the source memory DB is refused — justified
  2. The dashboard import lists a refused memory merge as skipped and adds it to refused_merges instead of reporting memory (merged) — justified
  3. _merge_memory now tells its callers whether it merged anything (returns bool) — justified

[FIRST-PRINCIPLES-REVIEWED] 585edc9

Description read

[DESCRIPTION-READ] 396977a7c039cf2bf63701c5e6bbd3c763217e111762d18a0808d423ed8c2266

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 585edc9acca53272f8a1b4c70dfdc6a93d3c82a2 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 585edc9

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 585edc9acca53272f8a1b4c70dfdc6a93d3c82a2 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 585edc9

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 8, 2026
@rohnkum
rohnkum force-pushed the fix/snapshot-merge-memory-tick branch from 5b599a9 to 8393030 Compare November 9, 2026 13:59
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 9, 2026
@rohnkum
rohnkum force-pushed the fix/snapshot-merge-memory-tick branch from 8393030 to 645f007 Compare November 9, 2026 17:28
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 9, 2026
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 9, 2026
@rohnkum
rohnkum force-pushed the fix/snapshot-merge-memory-tick branch from 645f007 to ec0bcaf Compare November 10, 2026 17:24
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 10, 2026
@rohnkum
rohnkum force-pushed the fix/snapshot-merge-memory-tick branch from ec0bcaf to c217f01 Compare November 10, 2026 22:40
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 10, 2026
@KiroCrewCaptain

KiroCrewCaptain commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: 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. _merge_memory now returns False on both refusal paths: an unreadable source, and a failed integrity check. It returns True once the merge commits, and an exception is still raised as before. The function has two production callers, snapshot_merge_driver._do_merge and portability.apply_import_zip, and both are updated. The restore driver now sets memory_ok from the return value, so a refused merge prints no ✅ memory. The dashboard import now names the refusal in items and adds memory to refused_merges. The dashboard handler (dashboard/handlers/portability.py:618) reads refused_merges and logs the import as partial, the same as a refused crons merge. Other callers in the tests and facade only call or re-export the function and ignore its result, so the new bool return breaks nothing. The test at test_snapshot_merge_core_files_pinned.py:115 that asserts ✅ memory covers the copy path, which this PR does not touch. Both new tests would fail on main: the CLI test checks for a tick that main prints, and the portability test checks for memory (merged), which main appends unconditionally. The restore exit code stays 0, as t

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 585edc9acc · 77 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

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
@rohnkum
rohnkum force-pushed the fix/snapshot-merge-memory-tick branch from c217f01 to 585edc9 Compare November 11, 2026 16:17
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 11, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 11, 2026 19:43

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 True at snapshot_merge.py:257 became return False, no test would fail. One assertion would cover it: add "memory (merged)" in summary["items"] to test_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.

@KiroCrewCaptain
KiroCrewCaptain merged commit 2377fd0 into kirodotdev:main Nov 11, 2026
102 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(snapshot): a refused memory merge is reported as merged ("✅ memory", "memory (merged)")

2 participants