Skip to content

fix(scripts): make patch_mentor_suite a safe, idempotent re-run - #262

Open
npbuilds wants to merge 1 commit into
mainfrom
claude/reconcile-patch-mentor-suite
Open

fix(scripts): make patch_mentor_suite a safe, idempotent re-run#262
npbuilds wants to merge 1 commit into
mainfrom
claude/reconcile-patch-mentor-suite

Conversation

@npbuilds

Copy link
Copy Markdown
Owner

Summary

Follow-up to #259, which surfaced that scripts/patch_mentor_suite.py was no longer safe to re-run: it unconditionally rewrote all 43 mentor/career depends_on lists 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 ref reproduces 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, sort
  • derive_referenced_by() — full authoritative reverse-index rebuild, replacing additive-only mirroring that let stale referrers survive
  • Dry-run by default, --apply to write — and per-modification change reporting instead of a blind rewrite
  • Drop the dead design ref from narrative-architecture (warned on every run)
  • New scripts/test_patch_mentor_suite.py (registry matches canonical DEPS, parent overrides hold, all targets resolve, no mutual pairs), registered in ci.yml so future drift fails CI

Verification

  • Dry-run: 0 modifications; --apply: byte-identical registry (empty git diff)
  • New tests 4/4, test_wire_investing_graph.py 3/3
  • sync-registry.py in sync; wire-all-domains.py 0 modifications
  • recalibrate_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 it

Independent of #259 (that PR touches registry.json + the investing generator; this one touches only the mentor script, its new test, and ci.yml) — they merge in either order.

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant