Skip to content

fix(upgrade): regenerate built-in SKILL.md when bundled template drifts (PROP-337 v1)#121

Open
JKHeadley wants to merge 1 commit intomainfrom
fix/prop-337-template-regeneration
Open

fix(upgrade): regenerate built-in SKILL.md when bundled template drifts (PROP-337 v1)#121
JKHeadley wants to merge 1 commit intomainfrom
fix/prop-337-template-regeneration

Conversation

@JKHeadley
Copy link
Copy Markdown
Owner

Summary

Closes Portal-tracked PROP-337 — chronic for 21 cycles. The non-destructive migrateBuiltinSkills only writes SKILL.md files that don't already exist; when the inline template in installBuiltinSkills is updated in a new release, existing installs never see the new content. The fix lives only in fresh installs, which is exactly the drift gap PROP-337 names.

This adds BuiltinSkillRegenerator and a new migrateBuiltinSkillRegeneration step in PostUpdateMigrator that:

  • Renders the bundled template into a tempdir by invoking installBuiltinSkills (no refactor of the 1187-line function needed).
  • Records the SHA-256 of each installed skill in .instar/state/builtin-skill-fingerprints.json.
  • On each migrator run, compares on-disk hash against fingerprint+bundled hash:
    • missing → install
    • on-disk == bundled → in sync (refresh fingerprint)
    • on-disk == fp → safe regenerate, update fingerprint
    • else → user-customized, preserve, seed fp on first observe
  • Custom skills are never enumerated, so they're untouchable.

Hooks already overwrite unconditionally (verified) so they're out of scope for this PROP — the gap was SKILL.md drift only.

Test plan

  • 7 new unit tests cover install, idempotency, regenerate-on-template-bump, preserve-user-customizations, first-observe seeding, and dry-run.
  • All 71 existing PostUpdateMigrator tests still pass.
  • Pre-push smoke tier passes in CI.
  • Manual verification on next release: existing install picks up an updated bundled SKILL.md without losing user customizations.

Cross-repo close-out

Portal-side upstream-prop-watcher is registered against this branch (commit 33c0c353, file src/core/BuiltinSkillRegenerator.ts). Once this PR merges to main, the next cycle-escalator run auto-flips PROP-337 to COMPLETED in Portal's evolution queue — closing the cross-repo loop the chronic detector kept reopening.

🤖 Generated with Claude Code

…ts (PROP-337 v1)

The non-destructive `migrateBuiltinSkills` only writes SKILL.md files
that don't already exist. When the inline template in
`installBuiltinSkills` is updated in a new release, existing installs
never see the new content — the fix lives only in fresh installs.

This adds `BuiltinSkillRegenerator` and a new
`migrateBuiltinSkillRegeneration` step that:

  - Renders the bundled template into a tempdir by invoking
    `installBuiltinSkills` (no refactor of the 1187-line function
    needed).
  - Records the SHA-256 of each installed skill in
    `.instar/state/builtin-skill-fingerprints.json`.
  - On each migrator run, compares on-disk hash against
    fingerprint+bundled hash:
      missing            -> install
      on-disk == bundled -> in sync (refresh fingerprint)
      on-disk == fp      -> safe regenerate, update fingerprint
      else               -> user-customized, preserve, seed fp on
                            first observe
  - Custom skills are never enumerated, so they're untouchable.

7 unit tests cover install, idempotency, regenerate-on-template-bump,
preserve-user-customizations, first-observe seeding, and dry-run.
All 71 existing PostUpdateMigrator tests still pass.

PROP-337 — was chronic for 21 cycles. Citation: "Upgrade process does
not regenerate on-disk gate/skill files". v1 covers SKILL.md drift;
hooks already overwrite unconditionally so they're not in scope.

Co-Authored-By: Claude Opus 4.7 (1M context) <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