Skip to content

CI: scan mod tests assert codes, not sentences (#1089) - #1560

Merged
Mikola Lysenko (mikolalysenko) merged 4 commits into
mainfrom
agent/fix-ci-scan-mod-envelope-asserts
Oct 15, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 4 commits into
mainfrom
agent/fix-ci-scan-mod-envelope-asserts

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code:claude-opus-5-5

Refs #1089 (child 5, scan_mod slice). This is the last covgap file in child 5; with #1556 (scan_hosted, merged) child 5 is done.

What changes

  • tests/covgap_commands_scan_mod.rs (3,160 lines, 58 tests, its own test binary) moves into the scan suite binary as four modules:
    • scan/scan_failure_paths.rs (24 tests): the --json contracts. They check exit code, status, error.code, event actions and errorCodes, warnings[] codes, the mock API's request log and disk state. Messages are read only for what they must name (a flag, a purl, a file). It has 0 .contains("…") asserts of 4+ words; the old file had 37.
    • New JSON twins replace human-only checks: total detail-fetch failure (patch_details_failed), partial failure (one patch_details_failed warning naming the purl, the resolved package still verified), vendor-owned purls (one skipped event coded vendored, no download), report-only --prune, --sync / --mode agent --prune apply-and-collect (pruned manifest, swept blob, gc), and hosted_wiring_retained.
    • The scan exits 1 in human output but 0 with --json when every patch query returns nothing #1062 human/JSON parity tests compare exit codes and JSON codes. The human warning line they also checked lives in the render file.
    • scan/scan_render.rs (35 tests): human output, one check per message family (17 sentence asserts), keeping each human run's disk-state checks. Duplicate checks were collapsed: the GC singular/plural/agent-prune tests are one table-driven test, and the two partial-failure warnings are one test over both shapes. The two bun.lockb human halves are also one test.
    • scan/scan_tty.rs (4 tests, unix): scan on a real terminal, moved unchanged apart from the shared fixture helpers and dropping the PTY runner's unused typeahead path.
    • scan/scan_fixture.rs: shared mocks, project writers and runners. It merges the four copies of the 500 detail mock and the one/two-patch API mounts, and removes the never-delayed _delayed variants.
  • The mode_fold in-process tests are removed. cli_parse_scan.rs::mode_hosted_with_sync_errors already covers them, and they mutated process env inside the shared scan binary. That test now also requires the error to name the mode (--mode vendored cannot be used with --sync), so the cli_name() coverage stays.
  • scripts/ci-test-durations.json folds the old target's 1.81 s into scan. The doc pointer in docs/testing/bun-compatibility.md is updated.
  • No production change.

Observed while writing the twins (not changed here): with a paid-only catalog and no paid access, the human arm skips the by-package detail fetch, but the --json arm still makes it.

CI cost

No workflow change. A lean PR run stays at about 28 Linux jobs, ~8 min (~110 job-min) before and after. The test shards link one fewer integration-test binary (scan absorbs it).

Test evidence

  • cargo fmt --all -- --check: clean.
  • cargo clippy --locked --workspace --all-features -- -D warnings (the CI command): clean. cargo clippy -p socket-patch-cli --all-features --test scan -- -D warnings reports nothing in the four new files. The 19 remaining hits in that target (prebuilt_common, hosted_yarn_classic_sha1.rs, module-loaded-twice) are the same count as on main.
  • cargo test -p socket-patch-cli --all-features --test scan: 204 passed. --test cli_parse_scan: 48 passed.
  • python3 -m pytest scripts/tests -q: 342 passed, 6 skipped.
  • The moved code includes cfg(unix) tests, so one full-scope ci.yml run was dispatched on cffeede: https://github.com/SocketDev/socket-patch/actions/runs/38675513037

/code-review high

Fixed in cffeede: duplicate mode_fold tests mutating env (removed, coverage moved into cli_parse_scan.rs). The vendored-skip twin now requires the skipped/vendored event. The retained-wiring render check reads the warning line itself. The global-scope envelope now checks invariants. The private warning helper was dropped for vlt_hosted_common::warning_detail, the PTY runner shares the fixture's api_args, and the dead typeahead parameter is gone.
Not fixed, and why:

Merge note

#1556 merged first. Its conflicts (the scan/main.rs module list, the scan line of ci-test-durations.json, now 12.35 s, and the bun-compatibility.md sentence) are resolved in the merge of main. The merged scan binary runs 244 tests, all passing.

🤖 Generated with Claude Code

https://claude.ai/code/session_011Y5j5rYtzb1JgiDLSWLQY9


Note

Low Risk
Test-only reorganization and stricter assertions; runtime CLI behavior is unchanged.

Overview
Refactors the monolithic covgap_commands_scan_mod integration binary into modules under the existing scan test target, aligned with #1089’s goal of pinning envelope codes and structure instead of long English strings.

scan_fixture.rs centralizes wiremock mounts, hermetic runners, and project seeds. scan_failure_paths.rs holds --json contracts (exit codes, error.code, events, warnings, API/disk oracles). scan_render.rs (referenced in the suite) keeps human-terminal checks with fewer duplicate sentence asserts. scan_tty.rs (unix) keeps PTY behavior tests. Several former human-only scenarios gain JSON twins (detail-fetch failures, vendored skips, report-only prune, sync GC, hosted wiring retained, etc.).

Removes in-process mode_fold tests that mutated env inside the shared binary; cli_parse_scan::mode_hosted_with_sync_errors now requires errors to name the conflicting mode via cli_name(). Docs and ci-test-durations.json drop the old target and fold its time into scan. No production code changes.

Reviewed by Cursor Bugbot for commit 883f3e7. Configure here.


Generated by Claude Code

Assisted-by: Claude Code:claude-opus-5-5
Copy edits to scan's terminal output no longer break dozens of
unrelated tests, and each scan path now has a --json test that checks
its exit code, error code, events, warning codes and files on disk.

covgap_commands_scan_mod.rs (58 tests, its own test binary) moves into
the scan suite binary as four modules:
- scan_failure_paths.rs: the --json contracts, with no 4+-word
  sentence asserts. New twins cover the total and partial detail-fetch
  failures, vendor-owned purls, report-only --prune, the --sync GC and
  the retained hosted wiring warning.
- scan_render.rs: the human output, one check per message family,
  keeping each human run's disk-state checks.
- scan_tty.rs: scan on a real terminal (unix only).
- scan_fixture.rs: shared mocks, project writers and runners. Four
  copies of the 500 detail mock and the two patch-API mounts are merged.

Refs #1089

Assisted-by: Claude Code:claude-opus-5-5
- Drop the moved mode_fold tests: cli_parse_scan.rs already runs
  resolve_mode_flags on --mode hosted/vendored --sync, and they mutated
  process env inside the shared scan binary. cli_parse_scan.rs now also
  requires the error to name the mode.
- The vendored-skip JSON test requires the one skipped event coded
  vendored, and the human retained-wiring check reads the warning line.
- The global-scope usage error checks the envelope invariants.
- Reuse vlt_hosted_common::warning_detail, share the mock-API flags
  between the subprocess and PTY runners, and drop the PTY runner's
  unused typeahead path.

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review October 15, 2026 03:18
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

…-envelope-asserts

# Conflicts:
#	crates/socket-patch-cli/tests/scan/main.rs
#	docs/testing/bun-compatibility.md
#	scripts/ci-test-durations.json
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

bugbot run


Generated by Claude Code

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 883f3e7. Configure here.

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Oct 15, 2026
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

Ready for review — head 883f3e7 (main merge on top of cffeede).

Slack announcement not sent this run (Slack send unavailable); next run will retry.


Generated by Claude Code

Merged via the queue into main with commit 45a3455 Oct 15, 2026
54 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the agent/fix-ci-scan-mod-envelope-asserts branch October 15, 2026 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-perf CI / merge-queue performance finding (profiler routine) Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants