Skip to content

fix(rules): regenerate templates for any package providing them, not just type:rules#182

Open
mellanon wants to merge 1 commit into
mainfrom
fix/a-181-template-regen-gate
Open

fix(rules): regenerate templates for any package providing them, not just type:rules#182
mellanon wants to merge 1 commit into
mainfrom
fix/a-181-template-regen-gate

Conversation

@mellanon
Copy link
Copy Markdown
Collaborator

Summary

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. arc upgrade compass --force was 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 the case "rules": branch of the artifact-type switch, 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 on type === "rules".

Fix

Mirrors the type-agnostic provides.files pass added for #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 — hoisted template generation out of case "rules": into a type-agnostic provides.templates pass that runs for every artifact type after the switch (right beside the provides.files pass). case "rules": becomes a documented break.
  • upgrade.ts — dropped the manifest.type === "rules" condition from both gate sites; they now fire on manifest.provides?.templates?.length alone.

Test

test/commands/rules.test.ts — new case: upgrade --force regenerates templates for a non-rules package that provides templates. Installs a type: component package that declares provides.templates[], drifts a section file with no version bump, runs upgradePackage(..., { force: true }), asserts the consumer's CLAUDE.md regenerated. Pre-fix this test fails (stale output); post-fix it passes. createMockRulesRepo gains a type option.

Risk

Low. Packages without provides.templates are unaffected — the inner if (templates.length) guard is unchanged. Packages with provides.templates but a non-rules type were already declaring the contract; this honours it. No public signature changes.

Validation

  • Full suite: 956 pass / 0 fail / 3 skip (959 across 63 files)
  • bunx tsc --noEmit clean

Test plan

  • bun test full suite green
  • bunx tsc --noEmit clean
  • Post-merge: arc upgrade compass --force from a consumer repo with agents-md.yaml regenerates CLAUDE.md (verifies the real compass case end-to-end)
  • Then update compass/sops/claude-md-adoption.md §Known issues per compass#64 acceptance criteria

Closes #181

🤖 Generated with Claude Code

…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>
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.

arc upgrade should regenerate templates for non-"rules" packages too

1 participant