Repository navigation
Description
Part of #5164 (child 14).
Problem or Motivation
The owner wrote on 2026-11-12, word for word:
can we make the tools a bit more flexible to support common use cases? That should be part of the project self-improvement loop
Facts on 2026-11-12 (Loki, implement runner Jobs, 24 hours):
- Two runner pods (the implement attempts on test(warnings): Turn all warnings into errors with reasoned exceptions #1878 and refactor(ai): rank the benchmark with numpy and pytrec-eval #1928) logged 10 refused calls of
run_command: programuv4 times,git2 times, andother:<digest>4 times. The runner logs show the same 3 patterns in both runs:uv run python -c ...(inline Python, twice in each run),git status && git log ...(a chain of two allowed read-only commands, once in each run), and programs outside the allowlist. logged_program(roadmap/implement/implement_tool_log.py) writes a program that is not in_KNOWN_PROGRAMSasother:and an HMAC digest with a key of the process. The key changes in each run, so the same program gives a different digest in each run. No count across runs can show which tool the model wanted.- Refusal hints exist (
roadmap/implement/implement_shell_refusal.py,IMPLEMENT_SHELL_REPLACEMENTS). The model still repeatspython -cin each run, so the hint does not fit that case. - The self-improvement loop (
docs/SELF_IMPROVEMENT.md) learns from review verdicts. feat(telemetry): rank CLI usage errors and propose fixes #4840 ranksdevopsusage errors (cli_usage_error, feat(telemetry): record each CLI usage error by name and kind #4973) and proposes a fix class, at 5 or more errors on 3 or more days. No part of the loop ranks refused or failing tool calls.
Proposed Solution & Architectural Design
- Safe category of a refused call. The runner logs, and the counter of feat(roadmap): count tool call errors by class for each workflow #5179 counts, a refusal key with no command text: the tool, the program (the name when it is in a widened list of common developer programs, else
other), and the refusal reason (program_not_allowed,inline_codesuch as-cor-e,chainsuch as&&,;or a pipe,argument_refused,path_refused,interactive). The digest stays only in the line of one run, for a drill-down. - Ranking.
devops telemetry tool-refusalsreuses the grouping, the thresholds and the house--formatof feat(telemetry): rank CLI usage errors and propose fixes #4840. It ranks refusal keys and tool error classes (feat(roadmap): count tool call errors by class for each workflow #5179) by count, distinct days, distinct items and workflows. It gives one proposal class from fixed rules:allowlist_candidate: an allowed-program chain or a program that is safe to allow.narrow_tool_candidate: a use case that needs a new narrow tool (for example a short Python snippet in the same sandbox and limits).split_candidate: a chain of allowed read-only commands that the runner can run as separate calls.hint_candidate: a refusal that repeats after its hint, so the hint does not fit.resolved: the key has had no refusal since a change merged.
- Minimum data. A key is a proposal only at 10 or more refusals on 3 or more days in 3 or more items, after 14 days of data from feat(roadmap): count tool call errors by class for each workflow #5179. A few hours of data give no proposal (the owner rule for CLI usage errors).
- Proposal to change. A proposal becomes one issue through the fingerprint module (feat(roadmap): file, update and close finding issues by fingerprint #5153), with the evidence (counts, days, items, the grade of each workflow). Each change to the shell allowlist gets its own security review before a build (owner decision 5 of the generalization plan, feat(roadmap): track one project profile for all repositories #4627). No proposal changes the allowlist by itself.
- Trial. After a change merges, the release compare (feat(roadmap): find a success or efficiency change after a release #5175) checks the result: the refusal rate of the key falls, and the success and first-pass ratios of the workflow do not fall. A worse result reverts the change by a pull request.
- First candidates for the loop to rank (each needs its own security look): run a chain of allowed read-only commands as separate calls, or allow
&&between allowlisted read-only programs; a narrow way to run a short Python snippet in the same sandbox (a test run already runs repository code, so measure whatpython -cadds); widen the known-program list of the log. docs/SELF_IMPROVEMENT.mdgets a section on tool refusals in the loop.
Target Subsystem
SDLC, Git & PR Governance (src/devops_cli/roadmap/implement/, the CLI telemetry commands) and Security & Vulnerability Scanners (the shell allowlist review).
Existing Tool Considered
#4840 builds the ranking and the proposal rules for CLI usage errors; this item reuses them for tool refusals. The pydantic-ai tool wrappers give no ranking. No open tool ranks the refused commands of an agent sandbox. Custom code: the refusal key (about 80 lines) and the ranking source (about 150 lines). Cost: about 300,000 tokens, 7 hours elapsed, then 14 days of data before the first proposal.
Acceptance Criteria
- A refused
uv run python -c ...call gives the keyrun_command,uv,inline_code, and the log holds no word of the command after the program. - A refused
git status && git logcall gives the keyrun_command,git,chain. - An unknown program gives
otherin the key, and two runs give the same key. - On a fixture of 14 days, a key with 12 refusals on 4 days in 3 items gives one proposal row with its class. A key with 12 refusals on 1 day gives none.
--dry-runsends 0 requests.
Dependencies
- chore(roadmap): hold incremental stage and implement work #6521 (hold: incremental work on the stage, implement and fix-checks jobs waits for the re-architecture)
#5179 (the tool error counter), #4840 (the ranking rules), #5153 (the fingerprint module), #5175 (the release compare).
Alternatives check of 2026-11-19: in-use.
The repository already uses this tool.
Tool: grafana/loki (https://github.com/grafana/loki), AGPL-3.0, last activity 2026-11-19, maintained.
Reason: Searches found only log and agent-observability stacks plus a research architecture; Loki, which the project runs, counts and groups refusal lines by labels, but no open tool ranks refusal keys by the data minimum or drafts allowlist proposals.
Covers:
- Counts refusal lines by label across runs
- Groups log lines by parsed program and reason fields
- Keeps the multi-day history the ranking reads
Lacks:
- Refusal key of gate, program, source and rule
- Proposal classes with the data minimum per key
- Draft allowlist entry with match and not_match examples
- Filing proposal issues with a devops-signal line
Proposed design
Problem statement
The implement step refuses no tool call since #6527: it runs the stock harness Shell with no allowed command, no denied command and no refusal wrapper, so the refusal key, the refusal reasons and the shell allowlist that this item was to rank and widen no longer exist. What a step still leaves is the line of each tool call in the Job log (the tool, the program, the outcome and a masked retry reason), and no part of the self-improvement loop ranks those failing calls across runs; the per-process other:<digest> of the log also stops a count from crossing runs. Build devops telemetry tool-errors to rank the failing tool calls by tool, program and tool error class, apply the #4840 data minimum, and file one proposal issue (a hint or a narrow tool) through the fingerprint module, without changing any control. The trial of a merged change waits on #5175 and is deferred.
Acceptance criteria
Requirement: Command registration
devops telemetry tool-errors SHALL be a registered command of the telemetry group.
Scenario: Help output
- WHEN A test runs
uv run devops telemetry tool-errors --help. - THEN The command exits 0 and prints the
--formatand--dry-runoptions.
Requirement: Grouping by tool error key
The command SHALL group the tool lines of the implement step by tool, program or other, and tool error class.
Scenario: Two lines share one key
- WHEN A fixture holds two lines with the same tool, program and class, and a third line with a different class.
- THEN The output holds two rows, and the shared row holds count 2.
Requirement: Stable program name
The key SHALL hold the name of a program in the runner tool table and other for any other program, the same in every run.
Scenario: Unknown program across two runs
- WHEN A fixture holds one line for
gitand one line forother:1a2b3c4d5e6ffrom another run. - THEN The output holds program
gitand programother, and the two runs give the same key.
Requirement: Tool error class of a failing call
The command SHALL give the class exit_status with the status, timeout, retry or repeat from the record that #5179 writes.
Scenario: One call of each class
- WHEN A fixture holds a
run_commandthat ended with[exit code: 1], one that ran past its wait, one retry and one repeated failed call. - THEN The output holds four rows with the classes
exit_statuswith status 1,timeout,retryandrepeat.
Requirement: Masked reason evidence
The command SHALL use the masked text of a retry reason and SHALL NOT read an unmasked command.
Scenario: Retry with a masked reason
- WHEN A fixture holds a retry line with a masked reason and no unmasked command.
- THEN The retry row holds the masked reason and no command text.
Requirement: Data minimum
The command SHALL give one proposal row at 10 or more tool errors on 3 or more days in 3 or more items after 14 days of data.
Scenario: 14-day fixture meets the minimum
- WHEN A 14-day fixture holds one key with 12 errors on 4 days in 3 items.
- THEN The output holds one proposal row for the key with its class.
Requirement: One day gives no proposal
The command SHALL NOT give a proposal row for a key with 12 tool errors on 1 day.
Scenario: One day of errors
- WHEN A fixture holds a key with 12 errors on 1 day in 3 items.
- THEN The output holds no proposal row for the key.
Requirement: Proposal classes
The command SHALL give hint_candidate for a key that repeats after the hint that addresses it, narrow_tool_candidate for a use case that needs a tool the step lacks, and resolved for a key with no error since a change merges.
Scenario: One key of each class
- WHEN A 14-day fixture holds a key that repeats after its hint, a key whose masked shape is a command form that the step has no tool for, and a key with a merge date and no error after it.
- THEN The output holds one
hint_candidaterow, onenarrow_tool_candidaterow and oneresolvedrow.
Requirement: Ranking order
The command SHALL rank rows by count, then distinct days, then distinct items, then distinct workflows.
Scenario: Higher count ranks first
- WHEN A 14-day fixture holds one key with 12 errors on 4 days in 3 items and one key with 10 errors on 3 days in 3 items.
- THEN The output lists the 12-error row before the 10-error row.
Requirement: Dry run sends no request
devops telemetry tool-errors --dry-run SHALL send 0 requests.
Scenario: Dry run with a fixture
- WHEN The command runs with
--dry-runon a fixture and a request spy. - THEN The request spy records 0 requests, and the command prints each LogQL query that a run would send.
Requirement: House format
devops telemetry tool-errors SHALL use the --format of #4840.
Scenario: JSON format
- WHEN The command runs with
--format jsonon a fixture. - THEN The output is valid JSON with one object for each ranked key.
Requirement: Proposal issue evidence and signal
Each proposal issue SHALL hold the count, distinct days, distinct items, the grade of each workflow, and a devops-signal line with source tool_error, the tool, the program and the class.
Scenario: Filed proposal issue body
- WHEN The command files one proposal issue from a fixture with a workflow grade.
- THEN The issue body holds the count, distinct days, distinct items, the workflow grade, and a
devops-signalline with sourcetool_error, the tool, the program and the class.
Requirement: Proposal fingerprint
The command SHALL file one proposal issue through the fingerprint module of #5153.
Scenario: Second run files no duplicate
- WHEN The command runs twice on the same fixture.
- THEN The fingerprint module receives one proposal, and the command files one issue.
Requirement: Known class share
The command SHALL report the share of tool lines with a known error class and SHALL NOT rank a line with no error.
Scenario: Line with no error
- WHEN A fixture holds one retry line and one line of a call that returned.
- THEN The output reports 1 of 2 lines with a known class and holds one ranked row.
Requirement: No control change
A proposal SHALL NOT change a shell control, a setting or the code of the project; the command SHALL file one issue.
Scenario: Proposal generation
- WHEN The command runs on a fixture that meets the minimum, with a proposal writer spy and a digest of the source tree.
- THEN The proposal writer records 1 call, and the source tree digest is the same after the run.
Requirement: Self-improvement document
docs/SELF_IMPROVEMENT.md SHALL have a section that names devops telemetry tool-errors in the loop.
Scenario: Docs row
- WHEN
uv run devops ci --check --only docsruns. - THEN The docs row exits 0 and reports no broken link and no stale generated page for
docs/SELF_IMPROVEMENT.md.
Existing Tool Considered
Grafana Loki (https://github.com/grafana/loki), AGPL-3.0 and maintained, is the tool that the alternatives check of 2026-11-19 records as in-use: the project runs it, and it counts and groups the tool lines of the Job pods across runs and keeps the multi-day history that the ranking reads. The Lacks: list of the block of that check in the issue body names what it does not do, and this item adds exactly that. The command reads Loki through the same LogQL metric instant queries as devops roadmap eval grades, with --dry-run printing each query and sending no request (docs/roadmap/job-success.md:68), and the test uses LokiFake (tests/support/fakes/loki.py:295).
Key questions
- Which refusal reasons have a known class?: None: no code produces a refusal reason at this commit. Since refactor(roadmap): run implement on stock Coder with a real shell #6527 the implement step runs the stock harness
Shellwithallowed_commands=[],denied_commands=[],denied_operators=[]and no refusal wrapper, so every program of the runner image runs, andimplement_shell_policy.pyandimplement_shell_refusal.pyare deleted. The tool log records an outcome (ok,refusedfor a repeated failed call,retry,failed) and a masked retry reason, and no gate, program-and-rule refusal key. [sources: src/devops_cli/roadmap/implement/implement_shell.py:59, docs/ROADMAP_WORKFLOW.md:314, src/devops_cli/roadmap/implement/implement_tool_log.py:100] - Which key and proposal classes does the ranking use?: The key is
(tool, program or other, class), where the class is the tool error class of feat(roadmap): count tool call errors by class for each workflow #5179 (exit_statuswith the status,timeout,retry,repeat). The proposal classes arehint_candidate(a key repeats after the hint that addresses it),narrow_tool_candidate(the masked shape is a command form that the step has no tool for, such as a chain or a heredoc) andresolved(no error since a change merged).allowlist_candidateandsplit_candidateare gone, because the step has no allowlist to widen and no chain refusal to split. (best practice) [sources: src/devops_cli/roadmap/implement/implement_tool_log.py:434, src/devops_cli/roadmap/implement/implement_tool_log.py:100, docs/ROADMAP_WORKFLOW.md:314]- Chosen: Reuse the tool call line with the feat(roadmap): count tool call errors by class for each workflow #5179 classes and three proposal classes. One key keeps the log, the counter and the ranking on the same data, and each class names a change that exists now.
- Rejected: Keep the refusal key and the five classes of the issue. No refusal exists since refactor(roadmap): run implement on stock Coder with a real shell #6527, so every count is 0 and no draft allowlist entry has a target.
- Rejected: Build a new key in this item. It splits the data and makes the two counts disagree.
- Where does the command read the tool lines?: From Loki, with LogQL metric instant queries over the streams of the Job pods, as
devops roadmap eval gradesreads the result lines:--dry-runprints each query and sends no request, and the test serves the queries withLokiFake. The trace is no source, because it stays in the job record and not in a store that a command can count. (best practice) [sources: docs/roadmap/job-success.md:68, tests/support/fakes/loki.py:295, src/devops_cli/roadmap/implement/implement_trace.py:1]- Chosen: Read Loki with LogQL instant queries. The Job log is the only evidence of a step, Loki keeps it for days, and the house reader already counts and groups such lines.
- Rejected: Read a local ledger under the user data root. A Job pod discards its checkout and its local files, so no ledger survives the run.
- Rejected: Read the implement trace. The trace stays in the job record of one run and holds no store to count across runs.
- How does the key name a program that is not in the common list?: The key holds the clear name for a program in the fixed runner tool table and
otherfor any other program. The HMAC digest of the process stays only in the line of one run, for a drill-down, so the same program gives the same key in every run. (best practice) [sources: src/devops_cli/roadmap/implement/implement_tool_log.py:84, src/devops_cli/roadmap/implement/implement_tool_log.py:158]- Chosen: Runner tool name plus
other. The same program gives the same key across runs, and the digest still names it inside one run. - Rejected: Keep the per-process digest in the key. The key changes in each run and no count can cross runs.
- Chosen: Runner tool name plus
- What data minimum makes a proposal?: A key needs 10 or more errors on 3 or more days in 3 or more items, after 14 days of data. The tests use 12 errors on 4 days in 3 items, and 12 errors on 1 day gives no proposal. This is the owner rule of feat(telemetry): rank CLI usage errors and propose fixes #4840 for CLI usage errors, reused here. (best practice) [sources: docs/guidelines/agentic-jobs.md:208, docs/guidelines/agentic-jobs.md:230]
- Chosen: Reuse the feat(telemetry): rank CLI usage errors and propose fixes #4840 data minimum. A few hours of data give no proposal, and a key must repeat across days and items.
- Rejected: Propose from a few hours of data. It ranks noise and can propose a tool change from one run.
- How does the ranking use command text?: The ranking reads the masked text that the log keeps (the masked retry reason and the masked command shape) and never an unmasked command. The key holds no command text; the masked shape only decides between
hint_candidateandnarrow_tool_candidate. (best practice) [sources: src/devops_cli/roadmap/implement/implement_tool_log.py:196, src/devops_cli/roadmap/implement/implement_tool_log.py:283, docs/TELEMETRY.md:254]- Chosen: Use the masked text only. The kept masked text is the evidence, and the house telemetry rule keeps a command line and an argument value out of a record.
- Rejected: Store the full command for ranking. It puts private command text in the log and breaks the masking rule.
- Does the command change a shell control?: No. The step has no allowlist, no denied command and no refusal wrapper since refactor(roadmap): run implement on stock Coder with a real shell #6527, so the command files one issue with the evidence and writes no code and no setting. A security control gets no tuning pass from a ranking rule. (best practice) [sources: docs/guidelines/agentic-jobs.md:237, src/devops_cli/roadmap/implement/implement_shell.py:59]
- Chosen: File one proposal issue. The command proposes a hint or a tool, and a person decides the change in the issue.
- Rejected: Change the shell directly. There is no allowlist to change, and a ranking rule must not widen a control.
- What is the command called?:
devops telemetry tool-errors, a new command of the existing telemetry group.tool-refusalswould name data that no longer exists. (best practice) [sources: docs/ROADMAP_WORKFLOW.md:314, docs/CLI_REFERENCE.md:408]- Chosen:
devops telemetry tool-errors. The name states the data that the command ranks. - Rejected: Keep
devops telemetry tool-refusals. The step refuses nothing, so the name promises a key and a class that no run writes.
- Chosen:
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 12, 2026
Both are children of #5164 and work on tool-call telemetry; #5179 counts errors by class while the candidate ranks refusals and generates proposal issues for safe tool changes.dan-petty commentedon Nov 12, 2026
The command gate plan (tracker #5199) changes the scope of this item.
What moves out: #5201 now makes the refusal key (gate, program or other, source, entry or rule id) and the wider known-program list. This item keeps the ranking and the proposals.
New scope:
allowlist_candidate: all shadow answers are continue, 0 flags, and a person-labelled sample with 0 dangerous.blocklist_candidate: at least 3 flags, or one person label "dangerous".narrow_entry_candidate: flags in the audit point.parse_candidateandhint_candidate.eval_cases.jsonof feat(roadmap): score the command gate on labelled commands and fit its cut #5207.Dependencies: #5179 (after its update) and #5206.
Acceptance to add:
allowlist_candidate. Its draft entry passes the load check and has no**after a network or write program.allowlist_candidate.blocklist_candidate.dan-petty commentedon Nov 12, 2026
Scope change for #5219 (the self-improvement section of the project review):
devops-signalline (sourcetool_refusal, withtool,programandreason) in each proposal issue that this item files, so the review can measure the effect of each tool change.self_improvement.#5219 does not wait for this item. This item adds its own rows to the section in its own pull request.
dan-petty commentedon Nov 13, 2026
New evidence of 2026-11-13 (review of failing jobs): 50 of 71 refusals cannot be explained or ranked from the log today.
Tool call: run_command, program git, refused.holds no operator and no reason, so it looks like a ban ofgit. In fact 322 of 339gitcalls passed, and the refusals were for&&and|.program other:<digest>refusals in 10 runs with 16 different digests. The per-process HMAC (src/devops_cli/roadmap/implement/implement_tool_log.py, near lines 170-181 and 498-502) hides common harmless words.Scope points for the refusal key of this item:
operatorwith its symbol,not_allowed,replacement,inline_code) and the exit status of an allowed call.sed,awk,echo,mkdir,rm,cp,mv,sort,diff,xargs,bash,sh,env,timeout,printf,jq,which,openspec,devops. All other words keep the digest, so no private name goes in clear text.#5452 fixes the hint text for the two largest classes (
python -cwith;, and chains of allowed programs) now. This ranking then shows if the new hints work.Measure: the share of refusals with a known class goes to 100%.
dan-petty commentedon Nov 13, 2026
New counts of refused runner calls, from the start-context review of the roadmap jobs (2026-11-13). Loki,
job="devops/runner", names and counts only.Since the
run_commandprompt (2026-11-12 04:00Z to 2026-11-13 16:00Z, n = 10 runs): 47 refused calls. By program: unknown program (logged asother) 19,uv18,git9,openspec1.The 7 days before (45 runs, 35 of them before the new prompt): 212 refused calls in 43 of 45 runs (median 4, max 15):
uv run python -cwith;or a new line&&,;,||), mostlygit status && git logat the start24 of the 79
python -crefusals came again with the same cause in the same streak.limit_reachedoccurred 16 times in 7 days. The share of these stops that refusals caused is not known; #5460 adds the limit class.Proposals for this item:
python -cwith;or a new line. It names the correct form: write a script file and run it. No alias of the wrong form.sed,awk,echo). Each row names the tool that does the job (edit_file,read_file,grep).other. Names only.Measure: refusals for each run by cause, same-cause streaks, and
limit_reachedby limit class. The baseline since 2026-11-12 has n = 10; extend the window until n is at least 30 runs.devops-cli-service commentedon Nov 17, 2026
Refine cannot set this item to Ready at 8ccd95a while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.
The next refine round also looks at the item again when a commit on the default branch changes one of these files:
src/devops_cli/roadmap/implement/implement_tool_log.py.devops-cli-service commentedon Nov 19, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (9)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Nov 19, 2026
Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.
dan-petty commentedon Nov 20, 2026
Frozen on 2026-11-20. The stage, implement and fix-checks jobs grade under 60%, so the owner rule asks for a re-architecture before more fixes inside the current design (tracker #6519). This item is incremental work on those jobs, so its Dependencies section now names #6521 first. Stage and implement leave this item while #6521 is open. When the experiments of #6519 decide, a person closes #6521 (this item can then continue) or closes this item as not planned.
devops-cli-service commentedon Nov 21, 2026
Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.