Repository navigation
Description
Problem or Motivation
A record alone does not tell what to fix. This plan ranked 1,737 errors by hand: 759 of 1,285 other-tool records (59%) follow a gh command form, and the top rows are a wrong group name (630), missing gh flags (--json 138, --search 53, --comments 42, --head and --base 41), missing commands (pr comment 42, pr status 27) and names of commands that exist under another name (roadmap show 25, openspec validate 20). No command repeats this ranking for a window, so the owner cannot see missing flags, features or aliases without a new manual study.
Tracker #4833, child 3. The owner asked on 2026-11-11 to fix the devops gh issue name and to record such errors for a later analysis of missing flags, features and aliases. The counts come from a study of Claude Code, Kilo, Antigravity and Loki records from 2026-09-23 to 2026-11-11.
Proposed Solution & Architectural Design
Add devops telemetry usage-errors with --since (default 7d), --until, --caller agent|person|ci|mcp|all, --source ledger|loki (default ledger), --limit and the house --format. It groups the records by kind, command path and name, and prints count, distinct days, callers, first and last date, Click's suggestion and one proposal class from fixed rules: alias_candidate (Click found a close declared name; an alias needs the owner's exception), flag_candidate (unknown option with no close name), feature_candidate (unknown command with no close name), help_candidate (missing or bad parameter), hinted (the hint table covers it) and resolved (the typed path resolves today through core/command_resolver.py). A row is a proposal only at 5 or more errors on 3 or more days; two settings hold these defaults. --source loki reads the cli_usage_error records through the existing Loki client with one topk query, and --dry-run lists that query and sends 0 requests. Register the dry-run class and the MCP mirror as for other commands (#3296). No model call.
Target Subsystem
SDLC, Git & PR Governance (CLI telemetry: a new devops telemetry usage-errors command).
Existing Tool Considered
The command reads the ledger of the capture child, the existing Loki client and core/command_resolver.py, and prints with the house --format. The study found no open tool that ranks Click usage errors and proposes a fix class. #2346 reads agent transcripts on one host for recurring problems of all kinds; this command reads the records of the CLI itself, so it needs no transcript and also covers the cluster Jobs.
Acceptance Criteria
On a fixture ledger of 40 lines, the table and the --format json output match a snapshot, rank by count and hold each proposal class at least once. A record outside the window does not count. An empty or missing ledger prints one line and exits 0. --source loki --dry-run prints 1 query and sends 0 requests. The command finishes in less than 2 s on a 4 MiB ledger.
Dependencies
Merge first: #4839.
Source: #4833
Alternatives check of 2026-11-27: partly.
Tool: getsentry/sentry (https://github.com/getsentry/sentry), NOASSERTION, last activity 2026-11-27, maintained.
Reason: Searches found no open tool that ranks Click usage errors into fix classes. Sentry, already in use, groups and counts error events with first and last seen dates, but lacks Click-specific proposal classes, ledger and Loki reading, and the house table.
Covers:
- Groups repeated error events into issues by fingerprint or tag
- Counts events per group with first and last seen dates
- Filters and breaks down events by tags such as caller
- Self-hosted ingest of custom error events through SDKs
Lacks:
- No Click suggestion or proposal class such as alias or flag
- No local JSONL ledger read, including rotated backups
- No proposal threshold on count and distinct days
- No LogQL dry-run query preview
- No house --format table of ranked rows
Proposed design
Problem statement
The CLI records each usage error, but no command ranks the records. The owner cannot see missing flags, features or aliases without a manual study. This item adds devops telemetry usage-errors. The command groups the records over a window and assigns one proposal class to each group.
Acceptance criteria
Requirement: Command surface
devops telemetry usage-errors SHALL accept --since, --until, --caller, --source, --limit, --dry-run and the house --format, with --since defaulting to 7d, --until to now, --caller to all, --source to ledger and --limit to 30.
Scenario: Default options
- WHEN The operator runs
devops telemetry usage-errorswith no options on the fixture ledger. - THEN The command reads the last 7 days up to now, includes every caller from the ledger, and prints at most 30 table rows.
Requirement: Row fields
Each output row SHALL hold count, distinct_days, callers, first_date, last_date, suggestion, proposal_class and is_proposal.
Scenario: JSON row
- WHEN The command prints one group with
--format json. - THEN The row holds the eight fields, and
callersis a list.
Requirement: Grouping and ranking
The command SHALL group records by kind, command_path and name, and SHALL rank the groups by count in descending order.
Scenario: Rank by count
- WHEN The fixture ledger holds 40 lines with repeated and single errors.
- THEN The table and the
--format jsonoutput match the snapshot, and each group with a higher count comes first.
Requirement: Proposal classes
The command SHALL assign exactly one class from alias_candidate, flag_candidate, feature_candidate, help_candidate, hinted and resolved to each group.
Scenario: Each class appears
- WHEN The fixture ledger holds at least one record for each proposal class.
- THEN The output holds each class at least once, and no group holds two classes.
Requirement: Proposal threshold
The command SHALL set is_proposal true only when a group holds at least 5 errors on at least 3 distinct days.
Scenario: Below threshold
- WHEN One group holds 4 errors on 4 days and another group holds 5 errors on 2 days.
- THEN Both rows hold
is_proposalfalse, and both stay in the table with their counts.
Requirement: Window filter
The command SHALL exclude every record whose timestamp is outside --since and --until.
Scenario: Record outside the window
- WHEN The ledger holds one record dated before
--since. - THEN The record counts in no group and in no total.
Requirement: Caller filter
The command SHALL filter records by --caller with the values agent, person, ci, mcp and all.
Scenario: Agent only
- WHEN The operator passes
--caller agent. - THEN Only records with caller
agentcount.
Requirement: Rotated ledger files
The command SHALL read usage-errors.jsonl and each rotated backup of it in the user data root.
Scenario: Record in a rotated file
- WHEN The fixture ledger holds a record in a rotated backup within the window.
- THEN The record counts in its group.
Requirement: Row limit
The command SHALL print at most --limit rows, with a default of 30.
Scenario: Limit
- WHEN The operator passes
--limit 2on a fixture ledger with three groups. - THEN The command prints the two groups with the highest counts.
Requirement: Empty ledger
The command SHALL print one line and exit 0 when the ledger is empty or missing.
Scenario: Missing ledger
- WHEN The ledger file does not exist.
- THEN The command prints one line and exits 0.
Requirement: Loki source
The command SHALL read cli_usage_error lines for the window through one execute_loki_query log query and SHALL aggregate them locally, applying --until and --caller to the returned entries.
Scenario: Loki aggregation
- WHEN The fake Loki client returns two
cli_usage_errorlines with different callers. - THEN The command groups the two lines, applies the caller filter, and sends one query.
Requirement: Loki dry run
--source loki --dry-run SHALL print exactly one LogQL query and send 0 requests.
Scenario: Dry run
- WHEN The operator runs
devops telemetry usage-errors --source loki --dry-run. - THEN The command prints one query, and the Loki client receives 0 requests.
Requirement: Dry-run class and MCP row
The command SHALL declare the request-plan dry-run class and SHALL join CONST_MCP_EXPOSURE_TABLE as a read-only tool with JSON output.
Scenario: Registration
- WHEN
uv run pytest tests/invariants/test_dry_run_class_ratchet.py tests/ai/mcp/test_mcp_exposure_table.pyruns. - THEN Both tests pass, and the table holds
telemetry usage-errorsas a read-only tool with JSON output.
Requirement: No model call
The command SHALL make no model call.
Scenario: No model call
- WHEN A test replaces the AI client factory with one that fails, and runs the command on the fixture ledger.
- THEN The command exits 0, and the factory is not called.
Requirement: Ledger performance
The command SHALL finish in less than 2 seconds on a 4 MiB ledger.
Scenario: 4 MiB ledger
- WHEN The test writes a 4 MiB fixture ledger and runs the command.
- THEN The command exits in less than 2 seconds.
Existing Tool Considered
The alternatives check in the issue body records in-use for getsentry/sentry (https://github.com/getsentry/sentry). The repository already uses this tool. The check holds the Covers: and Lacks: lists. The command builds the Click-specific part that Sentry lacks: local ledger or Loki grouping, six proposal classes, the house --format table and a dry-run query preview. Written cost: about 30k output tokens to build, about 4k tokens a month to keep and fix, and 2 days elapsed.
Key questions
- Which dependencies does this item have?: None. The usage-error ledger is in
src/devops_cli/telemetry/usage_errors.py, and the hint table is insrc/devops_cli/core/usage_hints.yaml, at the refined commit. [sources: src/devops_cli/telemetry/usage_errors.py:87, src/devops_cli/core/usage_hints.yaml:1, tests/core/test_usage_hints.py] - Which record fields group the usage errors?: Group by
kind,command_pathandname. A record with nonamegroups under its command path. The record also holdssuggestion,caller,agent_toolandversion. [sources: src/devops_cli/telemetry/usage_errors.py:87, src/devops_cli/telemetry/usage_errors.py:97, src/devops_cli/telemetry/usage_errors.py:104, docs/TELEMETRY.md:249] - Which proposal class does each record kind get, and which class wins?:
resolvedwins whenresolve_devops_argvreports no finding for the typed path.hintedwins whensrc/devops_cli/core/usage_hints.yamlcovers the typed name.alias_candidatewins for a record with asuggestion.flag_candidatewins forunknown_optionwith no suggestion.feature_candidatewins forunknown_commandwith no suggestion.help_candidatewins formissing_argument,missing_option,extra_argument,bad_valueandoption_usage. A group takes the most frequentsuggestionof its records. (best practice) [sources: src/devops_cli/telemetry/usage_errors.py:65, src/devops_cli/core/command_resolver.py:85, src/devops_cli/core/usage_hints.yaml:1]- Chosen: resolved, hinted, alias, flag, feature, help. A resolved path needs no fix, the hint is an existing answer, and Click's close declared name is the next strongest signal.
- Rejected: flag before alias. A close declared name is a stronger signal than a missing option.
- Rejected: passthrough before alias. The pass-through class needs the registry of feat(cli): add the tool pass-through registry and its ADR #6597 and is tracked by feat(telemetry): propose pass-through entries from usage errors #6598, not this item.
- Where do the two threshold settings live, and what are their defaults?:
TelemetryConfiggetsusage_errors_min_countwith default 5 andusage_errors_min_dayswith default 3, besideusage_ledger. (best practice) [sources: src/devops_cli/config/settings.py:602]- Chosen: Two fields in TelemetryConfig. The body asks for two settings. The
usage_*prefix matchesusage_ledger. - Rejected: Hard-coded constants. The body asks for two settings.
- Rejected: Command flags only. A flag changes one run, not the project default.
- Chosen: Two fields in TelemetryConfig. The body asks for two settings. The
- How does the command expose the proposal mark in a row?: Each row holds
is_proposal. It is true only when the group holds at leastusage_errors_min_counterrors on at leastusage_errors_min_daysdistinct days. A group below the threshold stays in the table with its count. (best practice) [sources: src/devops_cli/telemetry/usage_errors.py:92, src/devops_cli/config/settings.py:602]- Chosen: A boolean is_proposal on each row. The threshold needs a field that a test can read. The group stays in the table below the threshold.
- Rejected: Drop a row below the threshold. The body says the group stays in the table with its count.
- Rejected: A separate proposal list. The table and the JSON row would disagree.
- How does
--source lokiread the records?: One LogQL log query throughexecute_loki_queryreads thecli_usage_errorlines for the--sincewindow with a source limit high enough for the window. The command aggregates them locally.execute_loki_querysendssinceandlimitonly, so the command applies--untiland--callerto the returned entries. A metrictopkthroughquery_loki_metricsis rejected: it returns counts only and cannot filldistinct_days,callers,first_dateorlast_date.--dry-runprints the one query and sends 0 requests. (best practice) [sources: src/devops_cli/k8s/logql.py:323, src/devops_cli/k8s/logql.py:391, tests/ai/mcp/test_k8s_logql.py]- Chosen: One log query through execute_loki_query with local aggregation. It returns the lines that hold every row field, and one dry-run query sends no request.
- Rejected: One LogQL topk metric query through query_loki_metrics. A metric vector holds counts only, not distinct days, callers, first date or last date.
- Rejected: One query per kind. It sends several requests and breaks the dry-run count.
- Rejected: A local scrape of Loki. It adds a second client and a new dependency.
- Which ledger files does the command read?: The current
usage-errors.jsonland each rotated backup of it in the user data root. The 7-day window can cross a rotation. (best practice) [sources: src/devops_cli/telemetry/usage_errors.py:250, docs/TELEMETRY.md:249, tests/telemetry/test_usage_errors.py]- Chosen: The current file and each rotated backup. The 7-day window can cross a rotation, and the 4 MiB target covers the rotated files.
- Rejected: The current file only. It drops records that a rotation moved to a backup.
- Rejected: The newest file only. The window can cross a rotation, so the newest file is not enough.
- Which caller values does the command accept?:
agent,person,ci,mcpandall. The record already holdscallerwith these values. [sources: src/devops_cli/telemetry/usage_errors.py:78, docs/TELEMETRY.md:249] - Which default does
--limittake?: 30 rows, the default of the project's listing commands such asdevops pr list. (best practice) [sources: src/devops_cli/config/defaults.py:603, src/devops_cli/commands/pr.py:241]- Chosen: 30 rows. It matches the listing commands and shows the lower-count classes.
- Rejected: No limit. It prints every group of a 4 MiB ledger and hides the proposal rows.
- Rejected: 10 rows. It hides the lower-count proposal classes of the study.
- How does the command meet the 2-second target on a 4 MiB ledger?: It streams the ledger line by line and keeps only the groups of the window. The memory stays bounded. (best practice) [sources: src/devops_cli/telemetry/usage_errors.py:261, docs/TELEMETRY.md:249]
- Chosen: Stream and aggregate. The ledger is one JSON line for each record, and the window limits the groups.
- Rejected: Load the whole ledger. It holds every line in memory and misses the target on a large file.
- Rejected: Read only the newest file. The window can cross the rotated files.
- How is the command registered for dry run and MCP?: It declares the
request-plandry-run class. It joinsCONST_MCP_EXPOSURE_TABLEas a read-only tool with JSON output. (best practice) [sources: src/devops_cli/config/constants.py:302, tests/invariants/test_dry_run_class_ratchet.py, tests/ai/mcp/test_mcp_exposure_table.py]- Chosen: Request-plan class and a read-only MCP row. The command reads the ledger, or Loki for one query, and the telemetry group already has read-only rows.
- Rejected: No dry-run class. The dry-run ratchet refuses a command with no class.
- Rejected: No MCP row. The body asks for the MCP mirror as for other commands.
- Where do the grouping and the command live?: The grouping and the class rules go in a new module
src/devops_cli/telemetry/usage_error_report.py. The command joins thetelemetrygroup insrc/devops_cli/commands/telemetry.py. The writer moduleusage_errors.pystays as it is. (best practice) [sources: src/devops_cli/telemetry/usage_errors.py:1, src/devops_cli/commands/telemetry.py:62]- Chosen: A new report module. The writer runs on each usage error and stays small. The report is a read-only concern with its own tests.
- Rejected: Extend usage_errors.py. It mixes the writer on the error path with a report that reads a 4 MiB file.
- Rejected: Put the rules in the command module. A second caller cannot import the command module without the CLI.
- Does the command propose pass-through entries in this item?: No. The six classes of this item are the scope. The
passthrough_candidateclass, its precedence afterhinted, the never-wrapped list and the API-route field go to feat(telemetry): propose pass-through entries from usage errors #6598 under feat(cli): track gh-parity names and usage-error capture #4833. feat(telemetry): propose pass-through entries from usage errors #6598 needs feat(cli): add the tool pass-through registry and its ADR #6597, the registry item of feat(cli): tool commands pass unknown arguments to the tool #5223. This item does not wait for feat(telemetry): propose pass-through entries from usage errors #6598. (best practice) [sources: src/devops_cli/telemetry/usage_errors.py:65, src/devops_cli/core/command_resolver.py:56]- Chosen: Six classes now and pass-through in feat(telemetry): propose pass-through entries from usage errors #6598. The registry of feat(cli): tool commands pass unknown arguments to the tool #5223 is not in the tree. The owner moved the pass-through scope to feat(telemetry): propose pass-through entries from usage errors #6598.
- Rejected: Hard-code the tool groups and the never-wrapped list. The two lists drift from the registry.
- Rejected: Treat every unknown command as a feature. It hides the pass-through entries of the deferred part.
- Can the command name the API route field of an unknown option?: No. The record holds the command path and the typed name only. No argument value reaches the ledger, so the endpoint is not available. The part goes to feat(telemetry): propose pass-through entries from usage errors #6598. [sources: src/devops_cli/telemetry/usage_errors.py:87, src/devops_cli/telemetry/usage_errors.py:97]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(telemetry)scope of the title gives the scope.It improves the owner's ability to fix CLI errors but is not blocking and depends on #4839.It turns 1,737 raw error records into ranked proposals, saving the owner a manual study each cycle.It adds one command with six options, rule-based classification, a Loki query path, and a dry-run, but reuses the existing ledger and resolver.Both find recurring problems in CLI usage, but #2346 reads agent transcripts while this command reads the CLI's own error ledger.devops-cli-service commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
The command gives the owner visibility of missing flags, features and aliases, but it blocks no other work.The ranking shows the owner which errors to fix, and the fixes reach users through other items.The work adds one command with grouping rules, two sources, a dry run and snapshot tests.#4839 records each CLI usage error by name and kind; the candidate reads those records, ranks them and proposes fixes.dan-petty commentedon Nov 12, 2026
Link from #5164 (job grades for each agentic workflow). 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".
#5180 ranks the refused and failing tool calls of the agentic runs (the counter of #5179) and proposes safe tool changes. It reuses the grouping, the proposal rules, the thresholds and the house
--formatof this item, so build them as one module that both sources call. The scope of this item does not change.dan-petty commentedon Nov 12, 2026
Scope change for #5219 (the self-improvement section of the project review):
loop.candidatesof the section. The LogQL usage row of feat(roadmap): read project review facts through a catalog #4692 reads through it.devops-signalline (sourceusage_error, withpathandname) for each proposal row, so the issue that a proposal becomes names its signal.#5219 does not wait for this item. This item adds its own rows to section
self_improvementin its own pull request.dan-petty commentedon Nov 12, 2026
Re-scope (owner direction of 2026-11-12). The title stays.
New scope
After #5223, a pass-through command gives its options to the tool, so devops records no usage error for them. The ranking changes as follows:
passthrough_candidate: an unknown command under a group whose registry entries (core/passthrough.py) name a tool. An example isdevops openspec validatebefore feat(openspec): openspec validate, list and show run openspec #5227. The proposal is a pass-through entry, not a new flag.hintedcomes beforepassthrough_candidate. A command that the registry lists as never wrapped (pr merge,auth,secret set,repo delete,release) never getspassthrough_candidate. The ranking reads that list from the registry, so the two lists stay the same.flag_candidatenever names a pass-through command.k8s,kustomize,tf,uv,test,pipeline,docker sign|verify, the single-tool rows ofdevops ci, and the root aliaseslint,formatandtui.Acceptance Criteria (additions)
devops openspec validate, when no such command exists, getspassthrough_candidate.devops pr mergegetshinted, notpassthrough_candidate.flag_candidate.Dependencies
Merge first: #5223 (the registry) and #4860 (the hint table). Open the pull request after the pull request of #5228 merges.
9 remaining items
devops-cli-service commentedon Nov 25, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
devops-cli-service commentedon Nov 27, 2026
The result in the alternatives block of the issue body changed. Before this check:
in-use, tool https://github.com/getsentry/sentry. A person decides what the new result means for the item.Searches (7)
Tools considered:
Searches run:
Sources:
chore(main): release 0.237.0 (#7611)
devops-cli-service commentedon Nov 28, 2026
Released in v0.237.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.237.0
devops-cli-service commentedon Nov 28, 2026
Live since 2026-11-28 18:38 UTC