fix(scripts): make patch_mentor_suite a safe, idempotent re-run - #262
Open
npbuilds wants to merge 1 commit into
Open
fix(scripts): make patch_mentor_suite a safe, idempotent re-run#262npbuilds wants to merge 1 commit into
npbuilds wants to merge 1 commit into
Conversation
The script's DEPS table predated the parent-strip convention: every list still included the skill's own parent (directors -> "mentor", leaves -> their director) — the Parent-Echo anti-pattern (STYLE_GUIDE #7) that the cycle cleanups removed from the registry. Rerunning it therefore rewrote all 43 mentor/career depends_on lists, re-adding deliberately-removed edges. Its own NOTE comment documented the hazard. Root-cause fix instead of rewriting the table: canonicalize at apply time exactly like wire-investing-graph.py (resolve against registry, strip the skill's parent, sort). Verified the hypothesis before changing anything — parent-strip + sort + dropping the one dead ref reproduces the committed registry with zero mismatches across all 43 entries, so the declaration table itself was never wrong, only its application. Changes: - desired_dependencies(): parent-stripped, sorted, resolved-only edges - derive_referenced_by(): full authoritative reverse-index rebuild, replacing the old additive-only mirroring that let stale referrers survive - dry-run by default, --apply to write (matches the wire scripts); reports each modification instead of unconditionally rewriting - drop dead "design" ref from narrative-architecture (warned every run) - remove the stale drift NOTE; document the parent-inclusive convention - new scripts/test_patch_mentor_suite.py (registry matches canonical DEPS, parent overrides hold, all targets resolve, no mutual pairs), wired into ci.yml Verified: dry-run reports 0 modifications; --apply writes a byte-identical registry; new tests 4/4; wire-investing tests 3/3; sync-registry in sync; wire-all-domains 0 modifications. recalibrate --dry-run shows only the known ambient freshness drift (faction-design -3, within CI's 5pt tolerance), untouched here on purpose. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #259, which surfaced that
scripts/patch_mentor_suite.pywas no longer safe to re-run: it unconditionally rewrote all 43 mentor/careerdepends_onlists from a DEPS table that had drifted from the registry, re-adding edges the cycle cleanups (3cd9717, 7082150) deliberately removed. Its own NOTE comment documented the hazard.Root cause
The DEPS table predates the parent-strip convention — every list still includes the skill's own parent (directors →
mentor, leaves → their director), i.e. the Parent-Echo anti-pattern (STYLE_GUIDE #7). The table's content was never wrong; only its application was. Verified before changing anything:parent-strip + sort + drop one dead refreproduces the committed registry with zero mismatches across all 43 entries.Fix
Align the script with
wire-investing-graph.py's conventions instead of hand-rewriting the table:desired_dependencies()— canonicalize at apply time: resolve against registry, strip the skill's own parent, sortderive_referenced_by()— full authoritative reverse-index rebuild, replacing additive-only mirroring that let stale referrers survive--applyto write — and per-modification change reporting instead of a blind rewritedesignref fromnarrative-architecture(warned on every run)scripts/test_patch_mentor_suite.py(registry matches canonical DEPS, parent overrides hold, all targets resolve, no mutual pairs), registered inci.ymlso future drift fails CIVerification
--apply: byte-identical registry (empty git diff)test_wire_investing_graph.py3/3sync-registry.pyin sync;wire-all-domains.py0 modificationsrecalibrate_scores.py --dry-run: only the known ambient freshness drift (faction-design −3, within CI's 5 pt day-boundary tolerance) — deliberately untouched here; the daily maint bot owns itIndependent of #259 (that PR touches
registry.json+ the investing generator; this one touches only the mentor script, its new test, andci.yml) — they merge in either order.🤖 Generated with Claude Code