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

feat(mwp-1): Phase 2 — authoritative generation backfill via _resolve_generation_with_backfill

Adds _resolve_generation_with_backfill(session, pids, *, inline_gen, db_gen): - Walks musehub_commits.parent_ids toward roots for any pid whose generation is not in inline_gen or db_gen. - Stops at the first commit already in musehub_commit_graph (bounded walk). - Computes generations bottom-up in topological order (Kahn's algorithm). - Upserts all newly computed rows into musehub_commit_graph. - Raises ValueError([MWP1] integrity error) if any pid is absent from musehub_commits (fast-forward push invariant violated). - Returns max(gen for pid in pids); caller adds +1.

Both call sites now await this function instead of silently writing 0: - wire_push_unpack_mpack step 9b (line ~935) - _build_commit_graph_from_raw (line ~1340)

Test results — all 8 GREEN: MWP1_01 GREEN (was RED: _build_commit_graph_from_raw backfills correctly) MWP1_02 GREEN (root guard untouched) MWP1_03 GREEN (was RED: push-path backfills C3 then sets C4=3) MWP1_04 GREEN (seam: backfill warning still fires, root case clean) MWP1_05 GREEN (seam: push-path backfill warning fires) MWP1_07 GREEN (chain C1..C5 all get correct generations after one push) MWP1_08 GREEN (absent parent raises ValueError with [MWP1] integrity error) MWP1_09 GREEN (1000-commit chain backfills to C999=999, stops at C0 anchor)

musehub#106 muse#58

sha256:e7097592983d62d4acf97d03e05f44d6f96541aecd65b141fe7f525d0cb088cc sha
+5 ~5 symbols
sha256:6bf9797a8435b38361a423f2f8d999d8e3610e63d1167ae2e12bf3c6b2dfefe3 snapshot
+5
symbols added
~5
symbols modified
0
dead code introduced
Semantic Changes 10 symbols
~ musehub/services/musehub_wire_push.py .py 1 symbol added, 2 symbols modified
+ _resolve_generation_with_backfill function async_function _resolve_generation_with_backfill L1143–1269
~ tests/test_mwp1_generation_authority.py .py 4 symbols added, 3 symbols modified
+ _resolve_generation_with_backfill import import _resolve_generation_with_backfill L49–49
+ test_mwp1_07_backfill_resolves_chain_of_depth_n function async_function test_mwp1_07_backfill_resolves_chain_of_depth_n L492–525
+ test_mwp1_08_absent_parent_raises_integrity_error function async_function test_mwp1_08_absent_parent_raises_integrity_error L534–558
+ test_mwp1_09_stress_1000_commit_chain function async_function test_mwp1_09_stress_1000_commit_chain L567–618

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:e7097592983d62d4acf97d03e05f44d6f96541aecd65b141fe7f525d0cb088cc --body "your comment"