Skip to content

The guardrails stopped at the config schema - #95

Merged
blakebauman merged 1 commit into
mainfrom
feat/toolkit-lockstep-guards
Aug 26, 2026
Merged

blakebauman merged 1 commit into
mainfrom
feat/toolkit-lockstep-guards

Conversation

@blakebauman

Copy link
Copy Markdown
Member

The .claude/ hooks encode two of this repo's lockstep surfaces — config.go ↔ schema, and the conformance pin — and leave the rest to CI or to nothing. This closes the gap for five more, blocks two classes of edit that cannot merge or cannot be undone, and brings /preflight back in line with what CI actually runs.

Found by auditing the toolkit against the repo surface it covers: 8 CI jobs, 20 make targets, 18 packages, the deploy tree, and the last 35 commits.

What was unguarded

Surface What enforced it before What happens now
metrics.go ↔ dashboard + both alert files observability_pack_test.go, at test time Named at the edit, with the test to run
Chart.yaml version vs appVersion The release workflow's chart job, after the tag Named at the edit, with what each line does
Console pin (CONSOLE_COMMIT) /console-sync, if invoked Named at the edit, as a supply-chain change
Writes under gateway/console/** CI's console job, on a red PR Blocked at the write
-3104x ↔ README's Errors table Nothing Diffed on edit, silent unless they diverge
Discarding a dirty tree Nothing Prompts, naming the paths at risk

The error-code row is the one I'd call the real find: CLAUDE.md says "README 'Errors' is the canonical table — this list moves with it," and grep 31040 gateway/*_test.go is empty. It is the only lockstep here held up by discipline alone.

The part that needs review

bash-guard.sh asks rather than blocks, and that is a judgement call. git reset --hard, checkout --/., restore, clean -f, and stash now surface a prompt naming how many uncommitted paths are at risk. session-start.sh has always warned that a dirty tree may be another session's in-flight work; nothing stood between that warning and a reset taking it. But bench-profiler stash-bisects deliberately, so a block would break a documented workflow. If you would rather it block on reset --hard specifically and only ask on the rest, say so.

git checkout <path> still passes. Matching it would prompt on every git checkout feat/branch, which is the more common command by a wide margin. git restore is caught, and that is the form that discards without ambiguity.

make console-check is now pre-allowed and it re-vendors as a side effect (sync-console.sh, then diff). It needs network and leaves the tree modified if the pin has drifted. That is exactly what it is supposed to do, but it is the one allowlisted command that writes.

Verification

Each hook exercised against its decision matrix, not just read:

  • bash-guard.sh — 14 commands. checkout -b, checkout main, stash pop, stash list, status, diff pass through untouched; the five destructive forms return ask; the pre-existing force-push, --no-verify, and tag guards still fire. (The force-push guard blocked one of my own test harnesses, which was a reassuring way to find it working.)
  • pre-edit-guard.sh — 4 paths. Blocks gateway/console/assets/index.js and console_source.go; allows console.go and console_test.go.
  • post-edit.sh — 9 paths, one per case plus two that must stay silent.
  • Error-code check — silent with code and README in sync; fires precisely against a simulated -31046 mint, and names both sets in the message.
  • bash -n clean on all five hooks, all executable, settings.json valid and all five registered.

Two portability fixes fell out of that testing: grep here is ugrep, which reads --include as a filename (replaced with plain globs, which also stops it recursing into the vendored console tree), and bash mis-parses a nested case pattern's ) inside command substitution.

No Go changed, so make check is unaffected — but CI will confirm.

Checklist

  • make check passes — no Go, no config, no deploy files touched
  • New behavior is covered by tests — hooks are shell; each is exercised against its decision matrix above
  • Proxy-path changes: none
  • Wire-behavior changes: none
  • README updated — .claude/README.md and CLAUDE.md's tooling paragraph both describe the new hooks
  • Pin bumps: none

The .claude/ hooks encode two of this repo's lockstep surfaces — config.go
↔ schema, and the conformance pin — and leave the rest to CI or to nothing.
An added metric fails observability_pack_test.go with no warning at the
edit; a chart change forgets which of Chart.yaml's two version lines does
what; a minted error code drifts from README's Errors table, which is
canonical and has no test behind it at all.

Two guards, four reminders, and the settings to stop paying for the review
agents:

- pre-edit-guard.sh (new, PreToolUse Edit|Write) blocks writes to
  gateway/console/** and gateway/console_source.go. CONTRIBUTING says an
  edit there cannot merge and CI's console job makes that true; learning it
  from a red PR is a round trip for a rule that is knowable at the write.

- bash-guard.sh asks before git reset --hard, checkout --/., restore,
  clean -f, and stash, naming how many uncommitted paths are at risk.
  SessionStart already warns that a dirty tree may be another session's
  in-flight work, and nothing stood between that warning and a reset taking
  it. It asks rather than blocks because bench-profiler stash-bisects on
  purpose.

- post-edit.sh grows from three lockstep cases to seven: metrics.go and the
  observability pack it is checked against in both directions, the Helm
  chart (version is an immutable OCI tag, appVersion is what a default
  install actually deploys), and the console pin as a supply-chain change
  rather than a version bump. Each message names the test that will fail.

- The same hook now diffs the -3104x codes minted under gateway/ against
  README's Errors table, and stays silent unless they actually diverge.

- settings.json goes from 18 allowed commands to 49. The consequential one
  is read-only git: all four review agents work from the working diff, and
  git diff prompted on every call.

- /preflight now matches CI's eight jobs. It was missing vuln,
  console-check, and a local image build — the last of which exists because
  a builder base skew shipped past two green merges and failed after the
  tag was pushed, with the binaries and chart already published.

Two portability fixes fell out of testing the error-code check: grep here
is ugrep, which reads --include as a filename, and bash mis-parses a nested
case pattern's ) inside command substitution.

Verified by exercising each hook against its decision matrix — 14 bash-guard
commands, 9 post-edit paths, 4 pre-edit paths, and the error-code check both
in sync (silent) and against a simulated -31046 mint. No Go changed.
@blakebauman
blakebauman merged commit 1e3ead6 into main Aug 26, 2026
8 checks passed
@blakebauman
blakebauman deleted the feat/toolkit-lockstep-guards branch August 26, 2026 05:23
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