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
mikolalysenko commentedon Oct 14, 2026
[agent] Claiming child 1 of this issue (the #1090 scope:
remove/covgap_commands_remove.rsmoves ontotests/common/envelope.rsand asserts codes instead of sentences; shared root cause: CLI tests pin English sentences instead of the --json codes). Branch: agent/fix-ci-remove-envelope-asserts. Claim-ID: 2026-10-14T12:51:41Z-7afacbGenerated by Claude Code
mikolalysenko commentedon Oct 14, 2026
[agent] Child 1 draft PR: #1535
Generated by Claude Code
60 remaining items
mikolalysenko commentedon Oct 15, 2026
[agent] #1568 is ready for review. It removes the last two top-level covgap binaries:
covgap_utils_socket_cli_config.rsfolds intocli_config_fallback.rs.coverage_fix_scan_hosted_dryrun_vendored.rsbecomesscan/hosted_dryrun_vendored.rsand uses the scan suite's shared helpers.Head 777911b is green (86 checks) and Bugbot is clean. Still to do: the
update/andscan/covgap files, plus the core crate'scovgap_*files.Generated by Claude Code
mikolalysenko commentedon Oct 15, 2026
[agent] Claiming the
update/slice of this issue:update/covgap_commands_update.rs,update/covgap_update_download.rsandupdate/covgap_update_swap.rsget command-named homes. The--jsontests assert codes, events and disk state throughcommon::envelope, and the human/PTY output keeps one check per message family inupdate/update_render.rs. Shared root cause: CLI tests pin English sentences instead of the --json codes. Branch: agent/fix-ci-update-envelope-asserts. Claim-ID: 2026-10-15T15:51:11Z-31a633Generated by Claude Code
mikolalysenko commentedon Oct 15, 2026
[agent]
updateslice draft PR (child 6): #1580Generated by Claude Code
Update tests assert codes, not sentences
Tighten update JSON checks from review
mikolalysenko commentedon Oct 15, 2026
[agent] #1580 (
updateslice of child 6) is ready for review. The threeupdate/covgap_*files are nowupdate/update_json_contracts.rs(--jsoncodes, events, details and disk state throughcommon::envelope),update/update_render.rs(human and PTY wording, one check per message family) and adownload_failedtest inself_update_failures_e2e.rs. Head 9dd5b35 is green (86 checks) and Bugbot is clean. Still to do: thescan/covgap files (covgap_commands_scan_vendor_flow.rs,covgap_ecosystem_dispatch.rs,covgap_commands_fetch_stage.rs,coverage_fix_scan_discovery_corrupt_ledger.rs) and the core crate'scovgap_*files.Generated by Claude Code
mikolalysenko commentedon Oct 15, 2026
[agent] Claiming the
scan/slice of this issue:scan/covgap_commands_fetch_stage.rs,scan/covgap_commands_scan_vendor_flow.rs,scan/covgap_ecosystem_dispatch.rsandscan/coverage_fix_scan_discovery_corrupt_ledger.rsget command-named homes, with--jsonbehaviour asserted throughcommon::envelopeand human wording kept to one check per message family. Shared root cause: CLI tests pin English sentences instead of the --json codes. Branch: agent/fix-ci-scan-envelope-asserts. Claim-ID: 2026-10-15T16:50:49Z-a4ac23Generated by Claude Code
mikolalysenko commentedon Oct 15, 2026
[agent]
updateslice of child 6 merged in #1580. The update suite has no covgap files left:update/update_json_contracts.rschecks--jsoncodes, events and disk state,update/update_render.rsholds the human and PTY wording, and thedownload_failedtest lives inself_update_failures_e2e.rs. Remaining covgap files:scan/covgap_commands_scan_vendor_flow.rs,scan/covgap_ecosystem_dispatch.rs,scan/covgap_commands_fetch_stage.rs,scan/coverage_fix_scan_discovery_corrupt_ledger.rs, and the core crate'scovgap_*files.Generated by Claude Code
mikolalysenko commentedon Oct 15, 2026
[agent]
scanslice draft PR (child 6): #1583Generated by Claude Code
CI: fold review fixes into the apply staging tests
mikolalysenko commentedon Oct 15, 2026
[agent] Claiming the core-crate slice of this issue:
crates/socket-patch-core/tests/covgap_{api_blob_fetcher,crawlers_composer_crawler,crawlers_npm_crawler,patch_apply,update_state}.rsget named homes in their existing companion suites (sharing those suites' helpers instead of mirrored copies), which also drops four test binaries. Shared root cause: coverage-gap files kept as a test category with duplicated helpers. Branch: agent/fix-ci-core-covgap-homes. Claim-ID: 2026-10-15T17:51:03Z-c905e3Generated by Claude Code
mikolalysenko commentedon Oct 15, 2026
[agent] Core-crate slice draft PR (child 6): #1585
Generated by Claude Code
CI: core covgap tests join their suites
CI: share npm/composer test fixtures
mikolalysenko commentedon Oct 15, 2026
[agent] Core-crate slice of child 6 is ready in #1585: the five
crates/socket-patch-core/tests/covgap_*.rsfiles moved into their companion suites, which removes four test binaries. CI on 709b391 is green, including a full-scope Windows/macOS run, and Bugbot found no issues. After #1585 and #1583 merge, nocovgap_*orcoverage_fix_*file is left in the repo.Generated by Claude Code