enforcement-gate-migration
Use when re-pointing a gate onto a new evidence store.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 4
- Forks
- 1
01 前言 Front Matter
- name
- enforcement-gate-migration
- author
- Steadfaste Fleet curator
- license
- MIT
- version
- 1.0.0
- category
- devops
- metadata
- { "hermes": { "tags": [ "governance", "gate", "enforcement", "migration", "fail-closed", "adversarial-review" ], "related_skills": [ "loop-governance", "change-checklist", "shell-scripting", "postgres-schema-design" ] } }
- platforms
- [ "linux", "macos" ]
- description
- Use when re-pointing a gate onto a new evidence store.
02 资源文件 2
03 SKILL.md 正文
Enforcement Gate Migration
Moving a gate or checker off an evidence source it does not own, onto one it does — and getting a change like that through adversarial review.
When to Use
- A gate reads a store owned by another system (another tool's DB, another agent's artifact) and you are moving it onto HC-owned evidence.
- Adding or altering a pre-commit / CI gate, or the checker behind one.
- A complex gate change whose close-out keeps returning FINDINGS.
Procedure (order matters)
- Write the evidence first, prove it live, THEN flip the gate. The order is writer -> checker -> gate re-point. Flipping the gate before anything writes the new store refuses every commit fleet-wide, which is an outage dressed up as enforcement.
- Prove the writer's TRIGGER exists in that harness BEFORE you write it. A
writer keyed on another harness's vocabulary is unreachable dead code that looks
wired: the hook registers, the guard reports
hook registered ✅, and NOTHING is ever recorded. Establish the harness's real mechanism by driving its OWN installed package — its exported tool factories, and the instruction its own system prompt emits — never from a skill, a doc, or the other harness's tool name. Record the mechanism the harness actually performs, under its TRUE tool name: a row claiming a load that never happened is worse than a missing one, because the store is evidence. Recipe:references/multi-harness-evidence-writer.md. - Key the writer to the identity the gate already uses — and ASK for it. Resolve the session from the governance lock rather than inventing a second key: a harness and a subprocess must agree on what "this session" means, or the gate asks a question nothing can answer. Ask the SHARED implementation (a read-only verb over the same predicate the gate consumes) instead of reading the state file or an env var yourself — a second derivation drifts, and the drift is invisible until a commit is refused. Resolve the id the lock WILL carry when none exists yet: capabilities are often loaded BEFORE the lock is opened, so requiring a lock silently drops the ordinary case.
- Build the checker as a small program with an explicit exit-code contract.
See
templates/fail-closed-checker.py. Codes:0verified,1refused,3cannot verify (store missing / unreachable / raising). - The gate delegates and fails closed. If the verifier is missing, refuse and name the fix. A gate that passes when it cannot verify is not a gate.
- Register the checker and any migration in the deploy map. An unregistered file is never deployed, and a repo that applies cleanly proves nothing about any other host — the runner discovers migrations by file.
- Prove it on the DEPLOYED path. The hook that actually runs is whatever
core.hooksPathpoints at, usually a symlink to a deployed copy — not the repo source you just edited. - Delete any transitional bridge once the writer is live, and pin its absence. A bridge that outlives its window quietly becomes the authoritative source again.
Rules
- Never fall back to the incumbent source. A fallback keeps it load-bearing, contradicts the point of the migration, and hides a failure of your own recording instead of surfacing it.
- No run-time override of the evidence lookup — no env var, no flag that redirects which store the gate reads. A caller who can set the environment can point the gate at a stub that answers "yes" for anything, which is a bigger hole than the one being closed. Make test branches reachable by STAGING a copy of the checker in a scratch tree and controlling what its lookup finds there.
- Fail closed on an unreachable store, and say which component is missing so the fix is not a mystery. Deleting or weakening a check to clear a block is a bypass.
- Derive count assertions from the directory, never hardcode them. A battery check asserting a literal row count goes stale the moment the next migration ships, and that staleness is what hides a migration that cannot apply.
- Static review cannot see schema or wiring faults. Apply the migration on a scratch database; a type mismatch, a bad path, or an unregistered file all pass reading and fail only at run time.
- A transitional bridge must use evidence you already own. Bridging to another system's artifact reintroduces exactly the coupling being removed.
- Escape LIKE metacharacters in the interpolated VALUE, never in the pattern. A
capability/skill name containing
_or%over-matches when interpolated raw into a LIKE pattern (a_bmatchesaxb), and the gate's answer is a permission — an over-match reports evidence that was never recorded. But escaping the WHOLE pattern escapes your own intentional%wildcards and turns the predicate into a literal match that can never succeed, silently zeroing every branch. Escape backslash, then%, then_, on the value only, and SQL-quote the assembled pattern afterwards. - Never require a stored value to sit at a fixed position in JSON text. A pattern
anchored to a closing quote matches the one payload shape you have in hand and fails
the moment the writer stores an extra key or the tool's own input
(
{"path": ..., "limit": ...}). Anchor on the discriminating segment and leave the tail open. Same rule for matching the thing's OWN location: a bare filename match lets an unrelated artifact satisfy the question. - One predicate per real mechanism, none of them laundered into another. Two OR'd branches are correct; writing an event under a name the harness never emits is not — the store would assert something that did not happen.
Closing Out Under Adversarial Review
An enforcement change touches always-review paths, so the review is part of the procedure, not an afterthought.
- Evidence must live IN THE REPO as a runnable test. Results pasted into a closing note are rejected as unverifiable self-report, and correctly so — a claim only the author can see is not verification. Put the reproduction in the diff: a test that drives the real writer, the real store, and the real checker.
- Do not write for the reviewer. No "how to verify" instructions, no self-verdicts ("ACCEPTED", "resolved"), no outcome counts, no pointers to the test that ought to convince it. State what changed and what the code does; let the material stand.
- Never suppress a HIGH finding. An inline ignore or a widened
exceptis the tempting shortcut and the wrong one — fix the cause (e.g. guard memoized module globals with a lock once a file becomes threaded). - Pin the verdict to the material; the reviewer is a sampling model. A stored verdict is reusable only for the exact material it judged (note + diff combined), so the same material cannot be judged CLEAN and then FINDINGS on consecutive attempts. If a close is re-judged every attempt, check the verdict is actually being STORED: the review row is UNIQUE per cycle, so a re-review written as a plain insert is swallowed as an idempotent no-op and the fresh verdict is SILENTLY DISCARDED — leaving the original FINDINGS frozen forever, which is the very gap re-review exists to close. A fix that is never stored looks exactly like a fix that did not work.
- Re-judge only when the material moved, and only through the explicit re-review action; the ordinary close must honour the stored verdict. A verdict with no or mismatched material fingerprint is not reused, so a CLEAN cannot be carried over a later, unreviewed change.
- One lock per logical change. The lock's description is frozen at
begin_change, while the reviewed diff is measured from the lock onward. Stack a second, unrelated change under the same lock and the reviewer receives a diff that does not match the stated task — a scope finding you cannot resolve, because editing the lock by hand is itself the bypass. Close the cycle, then open a new one with an accurate description. - Findings are sometimes factually wrong. Measure before changing working code to appease one, and report the measurement. Never fabricate a probe to match the finding's framed premise — run the real form.
rereview_changemay be missing from the MCP tool list while the generic CLI reaches it. A CLI subprocess has no harness session, so it cannot resolve the governance lock by itself — pass the lock's session id explicitly.- Exercise the gate's REAL question, not a convenience override. A verification that passes a session/skill/flag override the gate itself never sets proves a path the gate does not use: the first cut of a harness writer was "verified" with an explicit session argument while the gate derives its session from the lock, so the guard passed and the real path stayed broken for every commit. Run the checker the way the gate invokes it — no extra arguments — and show red/green on that form. Prove the guard DISCRIMINATES too: point it at the PRE-FIX revision and require it to fail on the case that names the defect.
Pitfalls
- Backticks in a shell-quoted string are command substitution. In
git commit -m "..."they are executed and their output spliced in (usually empty), so the sentence silently loses words while the command exits 0. Single-quote the message and read it back withgit log -1 --pretty=%B. - A multi-line edit is safer as a script file than an inline heredoc. Write the surgery to a file, make it refuse to run twice, and anchor on markers rather than line numbers; then run it. Quoting cannot corrupt what is not on the command line.
- Check what the gate actually runs before changing it. Run the checker the way the gate calls it — same interpreter, same arguments — and confirm red/green on the same binary; a checker that only ever says yes proves nothing.
- A test stub must match the interpreter the code uses. A shell stub for a Python-invoked verifier fails to parse, and every case "passes" for the wrong reason.
- Deploying enforcement code does not make it live. Long-lived processes hold the module they imported: the governance MCP server and the gateway both keep the old copy until restarted, so a fixed close-out path still behaves as before for MCP calls while the CLI — which imports fresh per invocation — already runs it. Exercise new code through the CLI, and state plainly which process still needs a restart rather than reporting the fix as live.
- Don't name a live database path in a shell command. A lifecycle guard scans the scripts a command references and will try to read a path it finds there; if that path is a SQLite file the command is refused outright. Run the edit from a script file, or refer to the path without quoting it into the command line.
Related
references/multi-harness-evidence-writer.md— writing evidence for one gate across harnesses with different mechanisms (probe recipe, predicates, identity, fixture cleanup)templates/fail-closed-checker.py— starter checker with the exit-code contractloop-governance— the review mechanism the close-out section works withinpostgres-schema-design— migration-runner and scratch-DB battery patterns
04 同仓库更多 Skills
macbook-linux-maintenance
Legacy MacBook Linux fixes: GPU wedge, reboot hang, thermal.
governance-regression-triage
Triage a host's governance issues: what changed.
enforcement-immutability
Use when enforcement files lose their immutable flag.
steadfaste-fleet-repo-deploy
Use when committing to the steadfaste-fleet repo.
steadfaste-fleet-maintenance
Maintain an installed Steadfaste Fleet instance — update both the upstream Hermes Agent and the fleet repo layer, merge diverged histories, sync skills safely, and troubleshoot common issues. Covers the dual-update workflow (hermes update + fleet-update.sh), encrypted brain data backup, mycortex import, and recovery techniques.
fleet-preflight
DEPRECATED alias — merged into survey-before-action (2026-08-20). Load survey-before-action instead; its "Repo-Specific Pre-Flight" section covers git search, Hermes boundary, and deployment verification.