Repository navigation
Tracking: assert stable codes instead of human sentences in CLI tests, and fold the covgap suites #1089
Description
[agent] Filed by the scheduled architecture audit routine (CLI and core). Register: discussion #560 register.
Kind: tracking. Source: Part 8.1; recommendations 8.5 G and H (register C32). Measured on main @ 05ecc6e.
Problem
CLI tests pin whole English sentences rather than behavior:
-
About 478 single-line
.contains("…")assertions incrates/socket-patch-cli/testsmatch a phrase of four or more words, across 114 files (the review counted 328 by a stricter rule). Multi-line assertions add to that. -
245 of them are in the 27
covgap_*/coverage_fix_*files: 26,086 lines and 391 tests. -
The heaviest files:
File Sentence assertions covgap_commands_scan_mod.rs46 covgap_commands_rollback.rs33 apply/covgap_commands_apply.rs30 covgap_commands_vendor.rs28 remove/covgap_commands_remove.rs27 covgap_commands_scan_hosted.rs21 covgap_commands_get.rs21 -
Many covgap tests come in
_json/_humantwins that drive the same code path twice. An example isremove_corrupt_vendor_ledger_fails_closed_jsonand…_human(covgap_commands_remove.rs#L332-L405). -
The repo has no snapshot tooling.
Impact:
- A copy edit touches dozens of test files. The output-polish PR Consolidated terminal UI and CLI-wide output polish #248 touched 65 files, and the shared remedy/UI-text work in Break command-module cycles and share remedy and UI text #1043 meets the same cost.
- Sentence assertions also hide whether the behavior (exit,
errorCode, events) is covered at all.
Target design
- Behavior is asserted through
--json:status,error.code/errorCode,events[].action/codeandsummarycounts, through shared helpers intests/common(assert_error_code(&out, "…"),event_codes(&out)). - Human output is asserted only in one render suite per command, keyed by message family. These use a few
instasnapshots if a maintainer accepts the dev-dependency, or exact-match fixtures otherwise. - Covgap twins collapse: where a
_jsontest covers a path, its_humantwin is deleted or reduced to the one render check that the render suite doesn't already have. - Covgap files are renamed into their command's suite once their tests assert behavior, so that "covgap" stops being a test category.
Children (one file family per PR, each deleting what it replaces)
- Child 1: Assert error codes instead of sentences in remove's covgap suite and add shared JSON assertion helpers #1090,
remove/covgap_commands_remove.rs, plus the sharedtests/commonassertion helpers. - Child 2:
covgap_commands_vendor.rsandrepair/covgap_commands_repair*.rs. - Child 3:
apply/covgap_commands_apply.rsand thecoverage_fix_*_silent_mute_exit.rspair. - Child 4:
covgap_commands_rollback.rs, after Decide: one shape for the--jsontop-levelerror(scan and get emit both a string and a {code, message} object) #704/Make every --json top-level error a {code, message} object (#704) #1027 givesrollback --jsona{code, message}error. - Child 5:
covgap_commands_scan_mod.rs,covgap_commands_scan_hosted.rsandcovgap_commands_get.rs, after Decide: one shape for the--jsontop-levelerror(scan and get emit both a string and a {code, message} object) #704 (bothscanandgetstill emit a bare-stringerror). - Child 6: the render suites (optional
insta) and the remaining non-covgap files (cli/output_modes_e2e.rs,cli/interactive_prompts_e2e.rs, …).
Acceptance criteria
- Every child keeps the covered production lines covered: the coverage job's line count for the touched command module doesn't drop.
- The count of 4+-word
.contains("…")assertions incrates/socket-patch-cli/testsfalls by every child's share, ending below 60, all of them in render suites. - No
covgap_*/coverage_fix_*file names remain.
Dependencies
- Children 4 and 5 are blocked by Decide: one shape for the
--jsontop-levelerror(scan and get emit both a string and a {code, message} object) #704 (Make every --json top-level error a {code, message} object (#704) #1027). - This is independent of C31 (test binary count, Tracking: build one RunCtx in main and stop mirroring CLI flags into the process environment #793), but the folded files reduce the binary count too.
Consolidated work — backlog review, 2026-10-08
The following standalone issues are now tracked here. Their closure consolidates scheduling; it does not mean their implementation is complete. Original reports and discussion remain linked below.
#1090: Assert error codes instead of sentences in remove's covgap suite and add shared JSON assertion helpers
- Track the remaining scope from Assert error codes instead of sentences in remove's covgap suite and add shared JSON assertion helpers #1090 in this issue. Explicit remove-test child of the stable-error-code test tracker; keep it as a checklist step.
Preserved scope and acceptance criteria from #1090
Proposed change
-
Add
tests/common/envelope.rswith:parse_envelope(stdout);assert_error_code(&Value, &str);event_codes(&Value) -> Vec<(action, code)>;event_purls(&Value, action).
Delete this file's private copies.
-
Rewrite each sentence assertion as the equivalent
--jsonassertion: the error code, event action/code, summary count, or the file bytes on disk. -
Delete each
_humantwin whose_jsonsibling covers the path. Where the human rendering is the point (the prompt text at L1854-L1862), keep one assertion per message family. -
Rename the file into the
removesuite (for exampleremove/remove_failure_paths.rs) when done.
Size and scope
- About −400/+250 test lines and no production change.
- Out of scope: other covgap files (later children of Tracking: assert stable codes instead of human sentences in CLI tests, and fold the covgap suites #1089) and any message wording change.
Acceptance criteria
- At most 3 sentence (4+-word)
.containsassertions remain in the file, each in a render-focused test. -
cargo test -p socket-patch-cli --test remove(or the renamed target) is green, as are the whole CLI tests. - Coverage of
commands/remove.rsis not lower than onmain(coverage job). -
tests/common/envelope.rsis used by this file and documented for the next children.
Activity
audit-core: file C34 decision (#1088, with C74), C32 tracking (#1089, #…
mikolalysenko commentedon Oct 7, 2026
[agent] Triaged:
priority:p3(test-suite refactor, cross-cutting CLI). Tracking issue; work proceeds through its children (#1090 first). Children 4 and 5 wait on #704 / #1027.Generated by Claude Code
mikolalysenko commentedon Oct 9, 2026
[agent] Claiming this issue for the architecture refactor routine (highest leverage: child 1's shared
tests/common/envelope.rshelpers, collapsing ~25 private--jsonenvelope helper copies —parse_envelope,events,find_event, event/warning code collectors — in ~22 test files no open PR changes;remove/covgap_commands_remove.rsmigrates once #1258 frees it). Branch: arch-refactor/1089-envelope-helpers. Claim-ID: 2026-10-09T12:56:47Z-6bbceeGenerated by Claude Code
mikolalysenko commentedon Oct 9, 2026
[agent] Draft PR: #1272.
Generated by Claude Code
mikolalysenko commentedon Oct 12, 2026
[agent] Janitor: releasing the stale claim
Claim-ID: 2026-10-09T12:56:47Z-6bbcee. #1272 merged a slice 2026-10-09 15:17Z; no open PR for the rest of this issue, and the claimer has been silent since 2026-10-09T13:02:30Z (more than 48h). Removingagent:claimedso another fixer can pick up what remains.Generated by Claude Code