Skip to content

feat(usage): group refusals by the reason they hit, not only by gate - #996

Open
sandstream wants to merge 3 commits into
mainfrom
claude/web-kit-status-sync-p6fg9a-usage-walls
Open

sandstream wants to merge 3 commits into
mainfrom
claude/web-kit-status-sync-p6fg9a-usage-walls

Conversation

@sandstream

Copy link
Copy Markdown
Owner

Owner decision from kit-research read-where-agents-fail-vs-kit: yes.

Stacked on #993 (it contains that branch). Merge #993 first; this diff then shrinks to its own change.

Why

A post on failed Microsoft 365 connections found that 19 of 23 failures hit one wall, an admin approval nobody had given. kit's kit usage counted refusals per gate only. In the scratch project of kit-research agent-platform-2027-vs-kit, all four gate-fs refusals had one reason, an unsigned scope, which one kit profile sign by the scope's owner clears. The report did not show that.

What

src/refusal-reasons.ts reduces each refusal's reason to its shape and groups by gate and shape:

Reason as logged Shape
write to [REDACTED]/.claude/settings.json denied — no verified scope/RoE (unsigned, tampered, or missing); … write to <path> denied — no verified scope/RoE (…); …
plaintext secret (kv-secret, keyed-secret, url-query-token) written to .env plaintext secret (…) written to .env
host(s) outside the signed egress scope: evil.example, files.example.org host(…) outside the signed egress scope: <host>
cannot reduce to a triage target: indirect-bin:$pm — run `kit triage` manually … cannot reduce to a triage target: <target> — run <…> manually …

The substitutions are fixed rules: quoted values, URLs, paths that start a word, scheme:value targets, host names (file names with a known extension are kept), parentheses and numbers. Only the first line of a reason is used, capped at 160 characters. No model reads the text.

The Floor tab, on that scratch log:

by reason
   4  gate-env · plaintext secret (…) written to .env
   4  gate-fs · write to <path> denied — no verified scope/Ro…
   2  gate-bash · cannot reduce to a triage target: <target> …

--markdown adds a Reason | Gate | Count table, up to six rows. --json carries floor.byReason.

Verification

  • src/refusal-reasons.test.ts: the four reason shapes above, the line and length limits, and grouping four refusals that differ only in path into one.
  • src/usage-markdown.test.ts: the table renders.
  • node scripts/prepush.mjs: build, format, lint, tests of the changed files, self-audit pass. kit review and the new-source-file check fail locally for container reasons. Semgrep did not run (not installed here).
  • The complexity warnings on cmdUsage, coverageFromRuns and keysFromConfigAndRun predate this change and are in the baseline.
  • No protected path. Harness-neutral: the audit log is the same for every harness.

Generated by Claude Code

Every kit check with the gates wired logs two refusals from its own
negative controls. kit#980 marked them; the Floor tab still counted
them, so a repository nobody was refused in showed 2 refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
Refusals that differ only in a path, host, package, quoted value or
number fall into one group, so the wall most refusals hit is the first
line. Deterministic substitutions; no model reads the reasons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

This branch has not been deployed

No deployments
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.

2 participants