feat(check): guard against consumers shadowing common recipes #24
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/PC-17-check-justfile-shadow-guard"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Every consumer sets
set allow-duplicate-recipes := truebecausedefaultmust be defined locally, which also means a local copy of a common-owned recipe silently wins over the imported one with no warning. That is how five repos ended up with forkedpre-commitrecipes that never receivedcheck-tree-ownership.docswas the only repo with a guard against it, as a local recipe with a hardcoded four-name list.Lift that guard into
common.justascheck-justfile, keeping the namedocsalready uses so that repo deletes its copy rather than renaming anything. It resolves the root justfile fromjust --dump --dump-format json(just also acceptsJustfileand.justfile, which the hardcodedopen --raw justfileindocswould miss), extracts recipe names with a textual scan, intersects them with the protected list, and exits 1 naming every offender. The scan has to be textual: the dump flattens imports and records no defining file per recipe, so an imported recipe and a local one are indistinguishable in it.The protected list is narrow by design: only the recipes where forking silently opts the repo out of a guarantee every repo shares.
check-justfileprotects itself so the guard cannot be neutered by shadowing it.defaultis deliberately absent, because PC-12 requires every consumer to define its own, and so arecheck,test,run,build,dev-clean*,dev-logs,ensure-env, and the*-docker*recipes, which consumers legitimately diverge on.extra_protected_recipesappends to the list; nothing shrinks it, since a guard a repo can switch off is decoration.Wired in two places: as a dependency of
pre-commit-composeandpre-commit-dockerso it fails at commit time, and as a step afterjust --summaryin bothjustfile.ymlandcheck.ymlbecause a hook is bypassable with--no-verify. PC-16's reasoning that the parse guard cannot live in a recipe does not apply here: by the time shadowing matters, the file parses.#PC-17