Repository navigation
feat(nix): guardrails capability module — the org's semantic gates - #1495
Merged
Merged
Conversation
devkit shipped 26 hooks to consumers and every one of them was syntactic: formatting, whitespace, YAML validity, typos, commit-message shape. Useful, and not one of them can tell you the code does what it says. Every semantic gate the org relies on lived in a PERSONAL repo that devkit and filesender both depended on. These 15 gates are now devkit's. Vendored from gerchowl/guardrails under Apache-2.0 — the same licence and holder as devkit, deliberately, so the copies need no separate attribution block. The upstream repo had no licence at all until gerchowl/guardrails#50; vendoring before that would have shipped all-rights-reserved files from the repo that enforces licence policy. PACKAGES ONLY, NO CONTRACT CHANGE. The obvious design is for this module to contribute hook ENTRIES too, and #1488 originally proposed exactly that as a v2 contract field. It was wrong and #1492 settled why: .pre-commit-config.yaml is read by the runner from a bare git tree, by CI containers that never enter `nix develop`, and by humans reading a diff — its lifecycle is the SCAFFOLD's, not the shell's. Flake-side entries would be silently discarded for every consumer that owns a committed config, which is all of them. It is closed at the tool level too: neither prek nor pre-commit has include/extends, one `repo:` stanza cannot pull a hook set, and prek's workspace mode scopes each sub-config to its own directory tree. So the module does the one thing v1 already allows — puts the gates on PATH — and hook entries stay a scaffold concern. THE CANARY IS THE POINT. checks.guardrails-canary feeds every gate a known-bad fixture and asserts it fires, plus a known-good one and asserts it stays quiet, running upstream's own harness against the PACKAGED scripts rather than a copy. Four of this org's eight recorded gate failures were "listed in the config, did not run" — a check that reads YAML would have caught none of them. "Protected" has to mean the gate rejected a known-bad input, because that is the only claim config drift cannot counterfeit. It earned itself immediately: it caught that the share/ copies the fixtures execute are unwrapped, so their runtime dependencies were not on PATH in the sandbox. One passthru list now feeds both the wrapper and the check, so a dependency added to one cannot be forgotten in the other. Also here: one real shellcheck ERROR fixed in the vendored tree (a malformed `disable=` directive that silently disabled nothing), three typos false positives whitelisted rather than edited into the scripts, and upstream's `templates/` deliberately not vendored — devkit IS the scaffolding system, and a second unreferenced one would just drift. KNOWN WART, deliberately not fixed here: the shellcheck exclude is shared between the runner config and the scaffold copy, because portableFor's `includeAll` selects WHICH hooks render, not per-artifact fields. So a consumer's .pre-commit-config.yaml now carries `^assets/guardrails/`, which means nothing in their repo. It is a dead regex, not a behaviour change. Fixing it properly means a `runnerYaml` override in hooks.nix and a drift-gate update — worth doing, not worth bundling into this. Refs: #1488, #1492
gerchowl
marked this pull request as ready for review
August 13, 2026 09:47
This was referenced Aug 13, 2026
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.
Implements #1488 with the layer decision from #1492. Closes the guardrails half of #1400.
What lands
devkit shipped 26 hooks to consumers and every one was syntactic — formatting, whitespace, YAML validity, typos, commit-message shape. Useful, and not one of them can tell you the code does what it says. Every semantic gate the org relies on lived in
gerchowl/guardrails, a personal repo that both devkit consumers and filesender depended on.Those 15 gates are now devkit's:
no-fake-impl·no-hardcoded·no-commented-code·no-debug-leftovers·no-raw-trace-fields·derived-docs·duplication·ci-shim·protect-trunk·protect-trunk-push·adr-matrix·numerical-obligation·no-conflict-markers·perf-budget·perf-recordplus the
guardrailsCLI, theguardrails-traceper-hook JSONL wrapper, and the freshness/stale/ledger tools — 25 executables, matching upstream exactly.Packages only — no contract change
#1488 originally proposed a v2
hooksfield. That was wrong, and #1492 settled why with four independent reviews..pre-commit-config.yamlis read by the runner from a bare git working tree, by CI containers that never enternix develop, and by humans reading a PR diff. Its lifecycle is the scaffold's, not the shell's. Every consumer today owns a committed config, and the generated path refuses to overwrite it — so flake-contributed entries would be silently discarded, or discarded with a warning on every shell entry.It is closed at the tool level too, independently confirmed: neither prek nor pre-commit has
include/extends(pre-commit#1203: "multiple configs / inclusion is not going to be implemented, sorry"), onerepo:stanza cannot pull a hook set, and prek's workspace mode scopes each sub-config to its own directory tree.So the module does the one thing v1 already allows: puts the gates on PATH. Hook entries stay a scaffold concern.
The canary is the point
checks.guardrails-canaryfeeds every gate a known-bad fixture and asserts it fires, and a known-good one and asserts it stays quiet — running upstream's own harness against the packaged scripts, not a copy.Four of this org's eight recorded gate failures were "listed in the config, did not run". A check that reads YAML would have caught none of them. "Protected" has to mean the gate rejected a known-bad input, because that is the only claim config drift cannot counterfeit.
It earned itself during this PR: it caught that the
share/copies the fixtures execute are unwrapped, so their runtime dependencies were absent in the sandbox. Onepassthrulist now feeds both the wrapper and the check, so a dependency added to one cannot be forgotten in the other.Verified
nix flake checkgreen, including the newguardrails-canaryandguardrails-shellchecknix/hooks.nixgerchowl/filesendermigrated off the flake input ontomodules = [ "guardrails" ]. Six lock nodes removed. All 21guardrails-oksource annotations, theGUARDRAILS_*env vars and every hook id unchanged. Itsjust precommit(both stages +nix flake check) and 77 tests greenDecisions worth reviewing
guardrails-okis an annotation living in consumer source (21 sites in one repo). Renaming to match devkit would break every consumer's source for no gain — devkit already shipsruffandtyposunder upstream ids.crates/tunables→ Rust pack and a decision ontools/).-S warning, every gate has a fixture, and the absentset -eis correct (these gatesgrep;-ewould abort on the quiet path). New gates go in Python; port only the stateful ones.style-severity shellcheck hook, withchecks.guardrails-shellcheckenforcing error+warning instead. Rewriting 3,000 lines of working, fixture-covered shell for SC2181 is the trade this repo already declined.Known wart
The shellcheck exclude is shared between the runner config and the scaffold copy, because
portableFor'sincludeAllselects which hooks render, not per-artifact fields. Consumers get a dead^assets/guardrails/regex — no behaviour change. Fixing it properly means arunnerYamloverride plus a drift-gate update; worth doing, not worth bundling here.Also in this PR
One real shellcheck error fixed in the vendored tree — a malformed
# shellcheck disable=SC2254 -- reasondirective that parsed as garbage and therefore disabled nothing. Threetyposfalse positives whitelisted rather than edited into the scripts ([Ss]tatus:, anfnd()helper, and the real word "mis-attributes"). Upstream'stemplates/deliberately not vendored — devkit is the scaffolding system.Blocked on nothing:
gerchowl/guardrailsis now Apache-2.0 (gerchowl/guardrails#50), same holder as devkit, so the vendored copies need no separate attribution.