Repository navigation
Description
Summary
The guardrails feature (issue #27, the modelhook adapter) has an operator-facing configuration UX that is unintuitive and, in one case, actively misleading. An operator can believe they have a guardrail model wired (models.slots.guardrail: quick configured) while guardrails are in fact OFF, with no startup feedback. Separately, when guardrails ARE on, the startup line logs the wrong model. This issue proposes a UX overhaul that makes the slot alone enable guardrails (aligning with the subagent router's "configure = enable" model, ADR 0042) and adds a single always-present startup posture line that reports the resolved checker model and the guard state.
Background — the current mechanics
The guardrails enable model is split across two unrelated config surfaces:
-
The ON/OFF gate —
guardrailsConfigured(cfg)(internal/app/guardrails.go:219-224):func guardrailsConfigured(cfg Config) bool { if cfg.GuardrailsDisabled { return false } // --guardrails=off kill-switch return cfg.GuardrailsModel != "" // --guardrails-model OR guardrails.model YAML }
A non-empty
guardrails.model(YAML) or--guardrails-model(flag) turns it ON. The gate value is a raw scalar that must be non-empty; it has no tier fallthrough. -
The model-picker slot —
buildGuardrailsChecker(internal/app/guardrails.go:232-263) resolves the actual checker model via:if gm, ok := resolveSlotModel(cfg, slotGuardrail, parentModel); ok { resolved = gm // SLOT supersedes } else { resolved, _ = lookupModelAlias(cfg, sel) // else resolve guardrails.model through aliases }
The
guardrailslot (internal/app/slots.go:57) has a default-tier fallthrough tocheap(internal/app/slots.go:118), but it has no bearing on the gate. A bound slot with noguardrails:block and no--guardrails-modelleaves guardrails OFF.
So the gate and the slot are separate surfaces with different semantics, and the slot supersedes the gate value once the gate is open — but does not itself open the gate.
Problems
1. The startup guardrails ACTIVE line logs the WRONG model (must-fix)
normalizeGuardrailsModel emits guardrails ACTIVE … model=<sel> where sel is cfg.GuardrailsModel — the gate value (internal/app/build.go:2571,2576). But buildGuardrailsChecker then resolves the actual checker model via resolveSlotModel(cfg, slotGuardrail, …), which supersedes that gate value (internal/app/guardrails.go:242-243).
So an operator with guardrails.model: heavy + models.slots.guardrail: quick sees guardrails ACTIVE model=heavy in the log while the checker actually runs on quick. For a security control, the one line an operator trusts to tell them "what is my checker running on" states a value that is not the running value. During false-positive triage or an incident, this sends the operator to the wrong model.
Severity: must-fix.
2. The "slot bound but guardrails OFF" trap is silent (must-fix)
guardrailsConfigured ignores the slot entirely. An operator with models.slots.guardrail: quick configured and no guardrails: block / no --guardrails-model flag has guardrails OFF, with no startup message saying so. The only slot-related signal is the generic model slot ACTIVE line from logSlotConfigFacts (internal/app/slots.go:591), which says only "this internal lightweight call runs on the slot model" — it does NOT say "…but guardrails are OFF, so this slot is inert." logSlotConfigFacts cannot know, because it is slot-layer and unaware of the guardrail gate.
This is a footgun: a bound slot for a security control that does nothing reads as "armed" when it is "unloaded." The operator only discovers the gap when an exfiltration slips through.
Severity: must-fix.
3. No startup line when guardrails are OFF
When guardrails are ON, the operator gets guardrails ACTIVE … model=<sel> rules=<n>. When OFF (the default), there is no line at all — normalizeGuardrailsModel returns early (internal/app/build.go:2556-2557) and buildGuardrailsHooks returns inner unchanged (internal/app/guardrails.go:125-127). So an operator starting mecated cannot tell from the log whether guardrails are: OFF (no model), ON-advisory-default, ON-with-rules, or kill-switched. They must infer OFF from the absence of the ACTIVE line.
For a security control, "absence of a line means off" is a weak signal — the line may have been missed or scrolled past. This violates the "no silently-disabled features" stance.
Severity: should-fix (must-fix in combination with #2).
4. The slot-supersedes-gate precedence is undocumented in --help
The gate (guardrails.model) and the model-picker (models.slots.guardrail) are separate surfaces whose interaction (slot supersedes gate value but not gate state) is explained only in docs/usage.md:1218-1220 and the --model-slot flag's long doc (cmd/mecated/main.go:358 text) — NOT in the --guardrails-model flag help (cmd/mecated/main.go:1167) or the --guardrails kill-switch help (:1168). An operator reading mecated --help and landing on --guardrails-model has no idea a slot can override their chosen model.
An operator who sets guardrails.model: heavy (a deliberate choice of checker) and separately binds guardrail: quick (perhaps inherited from a cheap: tier binding set for compaction) gets a checker on quick with no warning. For a security control, "I picked X but got Y" is dangerous, not merely surprising.
Severity: should-fix.
5. The enable ceremony diverges from the documented sibling (the router)
The subagent model router was deliberately moved to a "configure = enable" model (ADR 0042, superseding ADR 0031's enable flag) — binding the models.router: taxonomy turns it ON, with --subagent-model-router=false as the kill-switch (cmd/mecated/main.go:1165). Guardrails is the explicit precedent cited for that model ("the guardrails-parity enable model," cmd/mecated/main.go:265), yet guardrails itself does NOT follow it: binding the guardrail slot does not enable the checker; only the separate guardrails.model / --guardrails-model scalar does.
So the two "housekeeping" features the docs present as peers have opposite enable semantics for the slot. An operator who learned the pattern from the router ("I bind a slot, it's enabled") will mis-apply it to guardrails and get an inert checker (problem #2). The "precedent" is named but not honoured, which is worse than no precedent — it actively misleads.
Severity: should-fix.
6. --guardrails=on errors at startup
The --guardrails flag only documents off as meaningful, but an operator scanning --help for "how do I turn on guardrails" may try --guardrails=on, which fails startup (cmd/mecated/main.go:1306) — a reasonable guess that errors rather than enabling. The kill-switch flag help never states the positive enable path.
Severity: nice-to-have.
Proposed UX
A. The slot alone enables guardrails (aligning with the router)
Make binding the guardrail model slot enable guardrails, mirroring the subagent router's "configure = enable" model (ADR 0042). The operator's existing config just works:
# ~/.config/mecatl/settings.yaml
models:
aliases:
quick: deepseek/deepseek-v4-flash
slots:
guardrail: quick # ← binding the slot ENABLES guardrails on this modelNo separate guardrails: block needed for the common (advisory-default) case. --guardrails=off remains the kill-switch.
For operators who want custom rules / block mode / fail-closed, the guardrails: block still exists, but model: becomes optional (the slot supplies it):
guardrails:
# model: omitted — inherited from the guardrail slot
rules:
- match: "Bash"
phases: [pre]
mode: block
fail-closed: trueResolution precedence for the checker model (unchanged):
models.slots.guardrail(the slot) — if bound and resolvable, it wins.- else
guardrails.model(the gate value), resolved throughlookupModelAlias.
The gate (guardrailsConfigured) becomes: !GuardrailsDisabled && (GuardrailsModel != "" || guardrailSlotBound). The slot-bound check uses selectorForSlot(cfg, slotGuardrail) != "" (the same helper buildGuardrailsChecker already uses).
B. One always-present startup posture line
Every mecated start prints one guardrails line, regardless of state. The model reported is always the resolved one, with provenance:
Off, no slot, no model (today's silent default → now explicit):
guardrails: OFF (no checker model configured; bind the `guardrail` model slot or set --guardrails-model to enable)
Off via kill-switch:
guardrails: OFF (kill-switch active via --guardrails=off)
On via slot, advisory defaults:
guardrails: ON, checker=deepseek/deepseek-v4-flash (via slot `guardrail`), mode=advisory, rules=3 (default set: WebSearch, WebFetch, mcp__*)
On via slot, superseding a differing gate value (disclosed supersession):
guardrails: ON, checker=deepseek/deepseek-v4-flash (via slot `guardrail`, supersedes gate value `heavy`), mode=advisory, rules=3 (default set)
On via gate, no slot:
guardrails: ON, checker=z-ai/glm-5.2 (via --guardrails-model), mode=block, rules=2
On with custom rules:
guardrails: ON, checker=deepseek/deepseek-v4-flash (via slot `guardrail`), mode=block, rules=1 (Bash/pre), maxChecks=200
This is a Build-time INFO (like logSlotConfigFacts), so the "loop emits exactly three lines" invariant is unaffected.
C. --help text
--guardrails-model string GUARDRAILS (issue #27): model id or alias of a tool-less checker
that inspects OUTBOUND tool-call args (PreToolUse, data exfil) and
INBOUND tool results (PostToolUse, prompt injection). Empty (default)
leaves the checker model to the `guardrail` model slot (binding that
slot ENABLES guardrails). A configured `guardrail` slot SUPERSEDES
this value. Operator-tier only — a project repo cannot configure or
weaken a checker. The rule list + cost knobs live in the user-global
settings.yaml `guardrails:` subtree.
--guardrails string GUARDRAILS kill-switch only. Pass `--guardrails=off` to force the
checker OFF regardless of --guardrails-model / the guardrail slot /
the YAML config. To ENABLE guardrails, bind the `guardrail` model
slot (--model-slot guardrail=…) or set --guardrails-model. Any
value other than "off" is a startup error.
What this removes
- The inert-slot footgun — a bound slot now means "on," matching the router and the operator's mental model. No more "armed but unloaded."
- The misreported model — the startup line always names the resolved model, so triage/incident response goes to the right place.
- The silent OFF — every start states the posture explicitly; "off" is a present signal, not an absence.
- The undocumented precedence —
--helpand the supersession INFO line both disclose that the slot wins over the gate value. - The
--guardrails=ondead end — the help now redirects to the actual enable path.
What this preserves
- OFF-by-default for operators who configure nothing (no slot, no flag) — the byte-identical guarantee holds; the only addition is one explicit OFF line.
- The
guardrails:block for custom rules / block mode / fail-closed / cost knobs — unchanged, just withmodel:now optional. - Operator-tier-only enforcement — project-tier
guardrails:blocks still ignored with WARN. - The kill-switch —
--guardrails=offstill forces off regardless. - The resolution precedence (slot supersedes gate value) — unchanged; just disclosed.
Files involved
internal/app/guardrails.go—guardrailsConfigured(gate),buildGuardrailsChecker(resolution),buildGuardrailsHooks(wiring)internal/app/build.go—normalizeGuardrailsModel(~line 2555-2576, the startup ACTIVE line + the misreported model)internal/app/slots.go—slotGuardrail,slotDefaultTier,resolveSlotModel,selectorForSlot,logSlotConfigFactscmd/mecated/main.go—--guardrails-model(:1167),--guardrails(:1168), kill-switch parsing (:1295-1306)internal/adapter/permconfig/resolve.go—OperatorGuardrails(operator-tier-only enforcement)docs/usage.md— guardrails section (:1008-1039), router comparison (:1233-1235)
Considerations / open questions
- Backward compatibility: operators currently relying on
guardrails.model:with no slot are unaffected (the gate value still works). Operators with aguardrailslot bound and guardrails intentionally OFF (via no gate) would see guardrails turn ON after this change — but that combination is the footgun this issue exists to fix, so the behavior change IS the fix. The kill-switch (--guardrails=off) covers any operator who wants the old behavior. - The sibling
ask-reviewerslot has the same gate/slot split (gated by--subagent-ask-reviewer,internal/app/build.go:4086-4090) and the same inert-slot trap. This issue scopes to guardrails (the highest-stakes one, a security control), but the same treatment could apply toask-reviewerfor consistency. - The
compactionslot has no gate at all (always on) — no change needed.
Acknowledgement
UX consultation performed via the ux-reviewer specialist agent against the current codebase (no changes made). Findings verified against internal/app/guardrails.go, internal/app/build.go, internal/app/slots.go, and cmd/mecated/main.go.
Activity
test(e2e): guardrails slot-enable live scenario (#159)
fix(guardrails): slot enables, startup reports resolved posture (#159)