Repository navigation
Description
Problem / Motivation
A failproofai policy can be silently dead — configured, displayed as fine, and never firing — purely because of a name mismatch, and today nothing anywhere tells the user. I found three places where this happens:
-
Unknown names in
enabledPoliciesare dropped silently.registerBuiltinPolicies(src/hooks/builtin-policies.ts) builds anenabledSetfrom the config and registers only catalog entries that match. A misspelled, renamed, or stale name (hand-edited config, a project-level.failproofai/policies-config.jsonchecked into a repo, a policy renamed in a newer release) matches nothing and disappears without a log line or warning. Thefailproofai policiesscreen can't show it either: it iterates over known policies, so the dead name never appears in any row. -
Policy
match.toolNamesare never checked for reachability. Pack manifest validation (src/hooks/pack-manifest.ts) verifies thatmatch.toolNamesis a list of non-empty strings, but not that any of those names can ever occur. The same applies to custom policies validated at load time. At runtime,canonicalizeToolNamepasses unknown names through unchanged and policy lookup is an exact string match, so atoolNamesentry that is off by one character matches no tool call, ever, with zero signal. -
There is an in-repo inconsistency that makes this more surprising: the
policiesscreen does warn about unknownpolicyParamskeys — an attention line (Unknown policyParams key "…", possibly a typo.) plus apolicy_params_validation_warningtelemetry event. Unknown policy names and tool names — which disable enforcement entirely, a much more severe outcome than a stray params key — get no equivalent treatment.
This failure mode is not hypothetical. Tool-name drift has bitten repeatedly: #690 (Copilot task/web_search unmapped, so Task-class policies silently stopped applying) and the follow-up mapping PRs #693, #792, #844 each fixed one instance by hand after the fact. Those PRs fix individual mappings; nothing detects the next drift, typo, or stale config name when it happens.
The user-visible consequence: someone believes a guard (e.g. a file-protection or secret-sanitizing policy) is active in their agent sessions when it has never fired once.
Relation to #537 (scope boundary)
#537 already argues, persuasively, that silent failures should become visible warnings — its motivating example is block-env-files silently going dead for several releases because of Copilot version drift. I read #537 as being about the CLI version-detection layer: detecting that the harness/CLI version changed so name mappings and behaviours can be re-validated.
This proposal is the neighbouring but distinct name layer: names written in user configuration and policy definitions (enabledPolicies entries, match.toolNames in custom and pack policies) that can never resolve against the names the runtime actually knows. Same philosophy, different mechanism, no version detection involved. I'm filing it separately so the scope stays reviewable, but if you'd rather track it as a sub-item of #537, I'm happy to fold it in — please say so.
Proposed Solution
Add a "can this name ever match?" check at configuration/display time, reusing the existing attention-line + telemetry pattern from the policyParams warning:
enabledPoliciesnames: whenfailproofai policiesruns (and/or when configuration is loaded), any enabled name that resolves to no registered policy — builtin, pack, or custom — produces an attention line naming it, e.g.Unknown enabled policy "block-env-file", possibly a typo — it will never run., plus a telemetry event analogous topolicy_params_validation_warning.match.toolNamesin custom and pack policies: validate entries against the known tool-name universe (the canonical names produced by the per-CLI tool maps, union the tool names referenced by builtin policy matches). Entries outside that universe produce a low-confidence warning at validation time: the name may never match any tool.- Deliberate exemptions and wording: MCP tool names (e.g.
mcp__*/ server-defined names) are user-defined by design and must not warn. Because new harness tools appear over time, warnings should be phrased as "may never match" rather than errors, and should never block loading or enforcement.
Scope and non-goals:
- Warnings only — no change to which policies run, no change to the evaluation hot path, no new runtime interception behaviour.
- No CLI version detection (that's Version-aware CLI detection: know *which* agent version we're guarding, not just *whether* one exists #537's layer).
- No attempt to auto-correct or suggest the "right" name in v1 (a later nicety if wanted).
If the direction looks reasonable, I'm willing to implement it, with unit tests in __tests__/hooks/ covering: an unknown enabled policy name warns; an unknown toolNames entry warns; MCP-style names and all currently valid builtin/pack configurations produce no warning; and the existing test suite stays green.
Alternatives Considered
- Runtime counting of unmatched tool names (detect drift as it happens in live sessions): more powerful, but it touches the hook hot path and needs its own storage/telemetry design. I'd suggest it as a possible second phase rather than the first step.
- Failing hard on unknown names at load time: rejected — a checked-in project config with one stale name would break everyone's setup, and legitimate not-yet-known names (new harness tools, MCP) would false-positive. A warning matches the repo's existing
possibly a typoprecedent. - Doing nothing and relying on mapping PRs: the
COPILOT_TOOL_MAPis missingtaskandweb_search—Taskpolicies silently never fire on Copilot #690 series shows this pattern recurs; each instance is currently found by accident.
Additional Context
- Code pointers (current
main): silent drop inregisterBuiltinPoliciesinsrc/hooks/builtin-policies.ts; shape-onlytoolNamesvalidation insrc/hooks/pack-manifest.ts; pass-through incanonicalizeToolName(src/hooks/tool-name-canonicalize.ts) and exact-match lookup ingetPoliciesForEvent(src/hooks/policy-registry.ts); the warning pattern to align with is inlistHooksinsrc/hooks/manager.ts(attention line ~"possibly a typo" and thepolicy_params_validation_warningevent). - There is currently no "known tool names" set anywhere in the codebase to validate against; building that universe from the existing tool maps is part of the proposed change.
Questions where I'd like a maintainer call before writing code:
- Which surfaces should warn — the
failproofai policiesscreen only, or also at config-load time (which would surface in more flows but risks repeating the warning)? - Should the tool-name side (
match.toolNames) be in scope for the same change, or would you prefer policy names (enabledPolicies) first and tool names as a follow-up? - Wording/confidence: is the "possibly a typo / may never match" low-confidence phrasing and a
policy_params_validation_warning-style telemetry event the right conventions to reuse here?
Activity