gabriel / musehub public
feat patch mwp-1 task/mwp-1-generation-authority #6 / 11
AI Agent gabriel · 26 days ago · Jun 29, 2026 · Diff

feat(mwp-1): Phase 3 — repair_corrupt_commit_generations for pre-existing RC-1 artefacts

Adds repair_corrupt_commit_generations(session) -> dict: - Queries musehub_commit_graph WHERE generation=0 AND cardinality(parent_ids)>0 to find all rows corrupted by the old RC-1 bug (both call sites pre-Phase-2). - Fetches external parent gens from the graph as walk anchors. - Falls back to _resolve_generation_with_backfill for any external parent not found in the graph at all. - Topologically sorts (Kahn's) the corrupt set and recomputes bottom-up. - Bulk-upserts corrected rows (only updates generation column). - Idempotent: second call finds zero corrupt rows and returns immediately. - Returns {total_corrupt, repaired}.

Test results — all 10 GREEN: MWP1_10 GREEN: 4-commit scenario (C1=root, C2/C3/C4 corrupt) repair produces C1=0, C2=1, C3=2, C4=3 MWP1_11 GREEN: first call fixes C2,C3 → second call is a no-op (0 corrupt)

musehub#106 muse#58

sha256:667089b438359d91efd6337e44c0bcb653deaf6ad3937861c5d2707457ff0aae sha
+4 ~3 symbols
sha256:027303c68152aff6d998d771414da7128f8ae00e27c05cb01887124556ad04ea snapshot
+4
symbols added
~3
symbols modified
0
dead code introduced
Semantic Changes 7 symbols
+ repair_corrupt_commit_generations function async_function repair_corrupt_commit_generations L1272–1408
~ tests/test_mwp1_generation_authority.py .py 3 symbols added, 3 symbols modified
+ repair_corrupt_commit_generations import import repair_corrupt_commit_generations L49–49
+ test_mwp1_10_repair_corrects_corrupt_rows function async_function test_mwp1_10_repair_corrects_corrupt_rows L628–669
+ test_mwp1_11_repair_is_idempotent function async_function test_mwp1_11_repair_is_idempotent L678–717

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:667089b438359d91efd6337e44c0bcb653deaf6ad3937861c5d2707457ff0aae --body "your comment"