Repository navigation
fix(guardrails): slot enables, startup reports resolved posture (#159) - #163
Merged
Merged
Conversation
The guardrails enable model was split across two unrelated surfaces — the ON/OFF gate (cfg.GuardrailsModel != "") and the model-picker `guardrail` slot (which superseded the gate VALUE but could not open the gate). A bound slot with no `--guardrails-model` left the checker silently OFF (the "armed but unloaded" footgun for a security control), and the build-time `guardrails ACTIVE` line logged the gate value, not the resolved checker model a slot had superseded. This aligns guardrails with the router's "configure = enable" model (ADR 0042) and adds one always-present startup posture line: - guardrailsConfigured now ORs in a bound `guardrail` slot (explicit or via the `cheap`-tier fallthrough). The kill-switch still wins. - A single pure resolver `resolveGuardrailsCheckerModel` is the source of truth for the resolved model + provenance (srcGate/srcSlot/ srcSlotSupersedingGate), shared by buildGuardrailsChecker and the new posture line so they can never disagree. - `normalizeGuardrailsModel` is now validate-only; the old ACTIVE emit is replaced by `logGuardrailsPosture` — exactly one INFO per Build carrying the RESOLVED model + provenance + mode + rules + maxChecks, and an explicit OFF line (no more inferring OFF from silence). - `--help` / the `--guardrails=on` error name BOTH enable paths. Byte-identical OFF-by-default: hook wiring unchanged (buildGuardrailsHooks returns `inner` unchanged); the only delta for a configure-nothing operator is one explicit `guardrails: OFF` line. Co-Authored-By: mecatl <[email protected]>
Review iteration 2 (panel + QA): - logGuardrailsPosture now branches on resolveGuardrailsCheckerModel's `configured` return (the same truth buildGuardrailsChecker uses), not on guardrailsConfigured. A bound-but-UNRESOLVABLE slot (selectorForSlot non-empty but resolveSlotModel fail-softs to "") previously reported `guardrails: ON, checker= (via ), ...` while buildGuardrailsChecker returned nil (OFF) — the exact posture↔checker divergence the refactor claimed to eliminate. The posture line and the live checker now share one truth; the false-ON for a security control is gone. - highestSeverityGuardrailMode normalizes an empty/unknown mode to "block" (the adapter's CompileRule safe default) instead of returning the raw unrecognised token. - Tests: bound-but-unresolvable-slot OFF regression case; direct table tests for highestSeverityGuardrailMode (9 cases) and guardrailsPostureLine (7 cases, incl. the usedDefaults=true + maxChecks>0 branch). - mecatequi --guardrails-model help no longer names the unregistered --model-slot flag (says "via a bound `guardrail` model slot"). - usage.md notes a trusted project's allowlisted guardrail slot binding enables the checker (operator-tier-only RULES gate untouched). Co-Authored-By: mecatl <[email protected]>
Adds a live e2e spec proving issue #159's slot-only enable against the real OpenRouter backend: a mecated spawned with `--model-slot guardrail=cheap` + `--model-alias cheap=<checker>` (NO --guardrails-model) must (A) emit the build-once `guardrails: ON` startup line naming the RESOLVED slot model with `via slot \`guardrail\`` provenance (must-fix #1 + #2), and (B) run the checker on a WebSearch tool call (observed by the default advisory set) through a real PreToolUse/PostToolUse verdict round-trip on the slot model and complete cleanly. The offline twin pins the gate + posture branches; this adds what only a live provider can show. Env MECATL_E2E_GUARDRAIL_MODEL (default openai/gpt-4.1-mini); FlakeAttempts(2), local-target only. Co-Authored-By: mecatl <[email protected]>
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.
Summary
Closes #159 — the guardrails enable UX overhaul.
Aligns the guardrails enable model with the router's "configure = enable" posture (ADR 0042): a bound
guardrailmodel slot now enables guardrails (it no longer only routes an already-enabled checker). The build-timeguardrails ACTIVEline — which reported the gate value, not the resolved checker model a slot may supersede — is replaced by one always-presentguardrails: ON|OFF …posture line carrying the resolved model + provenance.Problems fixed
guardrailslot with no--guardrails-modelleft guardrails silently OFF (the "armed but unloaded" footgun for a security control). The slot now co-enables.guardrails: OFFline.--helpnow discloses the slot-supersedes-gate precedence.--guardrails=onerror names both enable paths.Changes
internal/app/guardrails.go—guardrailsConfiguredORs in a bound slot; new pureresolveGuardrailsCheckerModel(single source of truth for resolved model + provenance, shared by the live checker and the posture line);buildGuardrailsCheckerrewired onto it.internal/app/build.go—normalizeGuardrailsModelis validate-only (ACTIVE emit removed); newlogGuardrailsPosture(one build-once INFO per Build, all states) +guardrailsPostureLinepure helper.cmd/mecated/main.go,cmd/mecatequi/flags.go,cmd/mecademo/main.go— help text +--guardrails=onerror name both enable paths.docs/adr/0046-guardrails-slot-enable.md— new ADR (supersedes the enable-model clause of 0021).docs/usage.md,docs/architecture/providers.md,docs/design/PRODUCTION-READINESS.md— stale-proofed.Review
Ran the dev-pipeline panel (spec + standards + secure-code + software-architect + QA). One cross-confirmed ship-blocker (posture↔checker divergence on a bound-but-unresolvable slot) was fixed in iteration 2 by branching the ON line on the resolver's
configuredreturn. Test gaps closed.task lint && task test && task docsgreen;go run ./cmd/mecademoprints exactly oneguardrails: OFFline.Backward compatibility
Byte-identical OFF-by-default: hook wiring unchanged (
buildGuardrailsHooksreturnsinnerunchanged). The only delta for a configure-nothing operator is one explicitguardrails: OFFline. The kill-switch (--guardrails=off) still wins absolutely. Operator-tier-only RULES enforcement untouched.Live e2e
This is a composition-layer UX change (config gate + a startup log line); the offline suite +
task lint/task test/task docsare the faithful gates. Requesting thee2e-livelabel for a live OpenRouter run per the operator's ask, to confirm no live-provider regression.