fix(rules): regenerate templates for any package providing them, not just type:rules#182
Open
mellanon wants to merge 1 commit into
Open
fix(rules): regenerate templates for any package providing them, not just type:rules#182mellanon wants to merge 1 commit into
mellanon wants to merge 1 commit into
Conversation
…just type:rules `arc install` and `arc upgrade` only ran template generation (generateRules) when the package's primary type was "rules". A package that legitimately ships templates alongside other artefacts — compass is a governance-overlay that owns CLAUDE.md generation — never had its templates regenerated, so `arc upgrade compass --force` was a silent no-op for every consumer repo. Fix mirrors the type-agnostic provides.files pass (issue #84): the presence of provides.templates[] is itself the signal that a package owns rules-file generation; the primary type does not gate it. - artifact-installer.ts: hoist template generation out of the `case "rules"` switch branch into a type-agnostic provides.templates pass that runs for every artifact type after the type switch. - upgrade.ts: drop the `manifest.type === "rules"` condition from both regeneration gate sites (the version-match-no-force branch and the full upgrade pipeline). - rules.test.ts: new test — upgrade --force regenerates a non-rules (component) package's templates when section content drifts. Extends createMockRulesRepo with a `type` option. Drop unused import. Full suite: 956 pass / 0 fail. tsc clean. Closes #181 Co-Authored-By: Claude Opus 4.7 <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
arc installandarc upgradeonly ran template generation (generateRules) when the package's primarytypewas"rules". A package that legitimately ships templates alongside other artefacts — compass is agovernance-overlaythat ownsCLAUDE.mdgeneration — never had its templates regenerated.arc upgrade compass --forcewas a silent no-op for every consumer repo (cortex, halden, …).Surfaced while dogfooding compass-CLAUDE.md adoption on
mellanon/halden#95.Root cause
Two gate sites, both keyed on
manifest.type === "rules":src/lib/artifact-installer.ts— template generation lived inside thecase "rules":branch of the artifact-typeswitch, so no other type reached it.src/commands/upgrade.ts— both regeneration sites (the version-match-no-force branch and the full upgrade pipeline) were&&-gated ontype === "rules".Fix
Mirrors the type-agnostic
provides.filespass added for #84 — the presence ofprovides.templates[]is itself the signal that a package owns rules-file generation; the primarytypedoes not gate it.artifact-installer.ts— hoisted template generation out ofcase "rules":into a type-agnosticprovides.templatespass that runs for every artifact type after theswitch(right beside theprovides.filespass).case "rules":becomes a documentedbreak.upgrade.ts— dropped themanifest.type === "rules"condition from both gate sites; they now fire onmanifest.provides?.templates?.lengthalone.Test
test/commands/rules.test.ts— new case:upgrade --force regenerates templates for a non-rules package that provides templates. Installs atype: componentpackage that declaresprovides.templates[], drifts a section file with no version bump, runsupgradePackage(..., { force: true }), asserts the consumer'sCLAUDE.mdregenerated. Pre-fix this test fails (stale output); post-fix it passes.createMockRulesRepogains atypeoption.Risk
Low. Packages without
provides.templatesare unaffected — the innerif (templates.length)guard is unchanged. Packages withprovides.templatesbut a non-rules type were already declaring the contract; this honours it. No public signature changes.Validation
bunx tsc --noEmitcleanTest plan
bun testfull suite greenbunx tsc --noEmitcleanarc upgrade compass --forcefrom a consumer repo withagents-md.yamlregeneratesCLAUDE.md(verifies the real compass case end-to-end)compass/sops/claude-md-adoption.md§Known issues per compass#64 acceptance criteriaCloses #181
🤖 Generated with Claude Code