Skip to content

Coverage audit: 39 bug fixes + test extension to 98.2% line coverage - #236

Open
Mikola Lysenko (mikolalysenko) wants to merge 3 commits into
mainfrom
test/coverage-audit-2026-09
Open

Coverage audit: 39 bug fixes + test extension to 98.2% line coverage#236
Mikola Lysenko (mikolalysenko) wants to merge 3 commits into
mainfrom
test/coverage-audit-2026-09

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Full audit of CLI test coverage at d5e1815, executed as a multi-agent pipeline: measure → audit every uncovered range → fix confirmed bugs → implement test plans → adversarial review → targeted mop-up.

Coverage (host, default features): 94.18% → 98.47% lines (94.73% → 98.26% regions; 6,441 → 2,138 missed lines). Tests: 5,220 → 6,762 (full workspace, green, also green under instrumentation). Baseline was cross-checked against CI's merged docker-e2e lcov for the same commit (docker legs added only 18 lines beyond host coverage, so host numbers are authoritative).

Commit 1 — fix: 39 adversarially-confirmed bugs (0b7714b)

120 bugs were claimed by per-file auditors over never-executed code; 39 survived 3-reviewer refutation panels, and every fix landed with a failing repro test first. Classes:

  • Orphaned vendor-artifact husks on failure paths (npm, composer, pnpm-legacy, gem, + bun/pnpm-v9 twins found in review) — missing done_failure_unstage
  • keep_artifact / --preserve-state contract violations (bun, gem, pnpm-legacy): empty-wiring refusals fired despite documented skip; legacy revert helpers missed already-converged liveness checks
  • Missing drift-keep gates in the pypi revert family — vendored wheel dirs deleted while a drift-skipped lock still referenced them
  • Wired-rebuild safety: gem/nuget/composer/pypi rebuild failures deleted the live artifact dir the wired lock still points at; pypi in-sync rebuild now honors the wired sha256/wheel-path pin (fail-closed on unreadable state.json)
  • NuGet packageSourceMapping: nuget.org seed suppressed by a whole-file substring probe → socket-only exclusive mapping (NU1100 for every other package); insert_nuget_source could drop the source while mapping+ledger were still recorded; open-tag/single-quote tolerance now consistent between the redirect and nuget_feed twins
  • scan --prune: RevertOutcome::kept_artifact was ignored (drift-kept entries pruned, artifacts destroyed); corrupt vendor ledger silently defeated every vendored prune safeguard; apply output now reports keptVendoredEntries + remediation hint (CLI_CONTRACT.md updated; dry preview documented as drift-blind)
  • CLI envelopes: get --json printed two JSON documents on engine hard errors; apply --silent exited 1 with zero output when patch sources were unavailable; rollback --ecosystems replayed other ecosystems' leftover hosted edits; scan hosted --dry-run previewed against vendored wiring; repair --vendor pre-delete destroyed healthy soft-reconstructed artifacts
  • Parsers/safety: zip-entry cap gated on declared size (unbounded read_to_end); registry_fetch 128MB cap enforced only after full read; pnpm-workspace flow-sequence packages: [a, b] parsed to zero members (pre-existing RED tests un-ignored); cargo config inline-table crates-io invisible to remove/read; uv dependency-groups/empty-overrides/direct-URL defects; takeover alias-collision edits stranded or mis-claimed (now scope-aware)

Commit 2 — test: coverage extension + review findings (4a29cc1)

  • ~1,100 new tests: inline #[cfg(test)] additions plus 30 new per-module covgap_* integration suites
  • A 46-reviewer adversarial pass over the full diff confirmed 42 findings (3-vote panels), all applied: fix residuals (uv convergence carve-outs, fail-open pin guard, golang gate strengthening, multi-line flow sequences, fetch-stage silent-mode envelope), the bun/pnpm-v9 twins above, and test hygiene (root guards on all chmod tests, SOCKET_*/VIRTUAL_ENV scrubs, telemetry disabled in spawned-CLI suites — one suite was POSTing to production, hermetic Gemfile.lock fixtures, cfg gates, vacuous tests repaired or deleted)

Commit 3 — test: final mop-up (9e45492)

165 targeted tests over the 14 worst remaining files (fresh post-fix line numbers); 129 remaining ranges formally classified untestable with per-range reasons (match-exhaustiveness arms proven dead by construction, assertion-failure format args inside test modules, interactive-only/platform-gated paths). Two prior skips overturned where a stable approach existed.

Known residuals (flagged, deliberately not fixed here)

  • vendor/maven_repo.rs wired-leg rebuild failure has the same remove-live-feed-dir shape fixed for gem/nuget/composer — needs its own pass
  • requirements.txt extras (pkg[extra]==v) line matching is a recorded TS-parity residual; this PR adds the entry-not-found warning only (same shape as PR fix(hosted): never redirect bundled npm entries; warn on misses #189 for npm)
  • NuGet config output bytes change for previously-broken configs — if the TS implementation shares the seed/insert defects it needs the matching fix for byte parity
  • scan --prune dry preview remains drift-blind (backends return before wiring replay on dry runs); documented in CLI_CONTRACT.md rather than half-mirrored

Note on CI: hosted-e2e, e2e (windows, safety_cargo), and release-readiness are red on main (traitobject unpublish + npm wrapper lock, PR #234 territory) — failures there are pre-existing and unrelated.

🤖 Generated with Claude Code


Note

Medium Risk
Changes affect prune/GC, rollback hosted replay, vendor repair, and lockfile migration paths where incorrect behavior can delete or orphan committed patch/vendor state; mitigated by extensive new tests and fail-closed guards.

Overview
This PR tightens socket-patch-cli behavior around garbage collection, diagnostics, and vendor/hosted migrations, and adds a large unit/integration test expansion (the diff is mostly tests pinning contracts).

scan --prune / GC now surfaces drift-kept vendored entries as keptVendoredEntries in apply JSON (plus a human remediation line), documents the preview vs wet difference in CLI_CONTRACT.md, and aborts manifest prune/blob sweep when the manifest is missing or corrupt instead of treating it as empty. Corrupt vendor ledgers no longer drop vendored packages from discovery: scan falls back to manifest + live .socket/vendor/<eco>/<uuid> dirs so prune cannot delete still-vendored state.

User-visible CLI fixes: fetch/apply staging prints hard errors under --silent (only --json suppresses stderr); get --json avoids emitting a second JSON document when the download engine already returned an error envelope; rollback with --ecosystems no longer replays record-less hosted redirect edits for other ecosystems; hosted scan --dry-run previews vendored→hosted takeover through the same revert path and counts those purls as redirected instead of failing against still-vendored locks; repair --vendor moves aside uuid dirs before rebuild and restores them when dispatch fails (instead of leaving ENOENT on wired locks).

Smaller changes: format_patch_option for interactive get selection; overlay_dir copy fallback when hardlink fails (cross-filesystem temps).

Reviewed by Cursor Bugbot for commit 9e45492. Configure here.

…mand flows

Full-coverage audit of never-executed code paths (host+docker lcov at
d5e1815) surfaced 120 suspected bugs; 39 survived 3-reviewer adversarial
refutation panels and every one reproduced with a failing test before its
fix. Classes:

- orphaned vendor-artifact husks on failure paths (npm_common, npm_lock,
  composer_lock, pnpm_lock_legacy, gem): missing done_failure_unstage
  twins of the fixed cargo shape
- keep_artifact / --preserve-state contract violations (bun_lock, gem,
  pnpm_lock_legacy): empty-wiring revert refusal fired despite documented
  skip; legacy revert helpers missed already-converged liveness checks
- drift-keep gates missing in pypi revert family (pipenv/poetry/pdm):
  vendored wheel dir deleted while a drift-skipped lock still references it
- wired-rebuild safety: gem/nuget_feed/composer/pypi rebuild failures
  deleted the live artifact dir the wired lock still points at; pypi
  in-sync rebuild now honors the wired sha256/wheel-path pin
- NuGet packageSourceMapping: nuget.org seed suppressed by whole-file
  substring probe -> socket-only exclusive mapping (NU1100 for every
  other package); insert_nuget_source replacen could drop the source
  while mapping+ledger were still recorded
- scan --prune: RevertOutcome::kept_artifact ignored (drift-kept entries
  pruned + artifacts destroyed); corrupt vendor ledger silently defeated
  every vendored prune safeguard
- redirect: requirements.txt rewriter silently dropped unparseable granted
  deps (entry-not-found parity warning added); pnpm-trust removal lacked
  the duplicate-occurrence guard; remove_fragment_once newline-eat merged
  the following line; takeover alias-keyed edits stranded/mis-claimed
- registry_fetch: 128MB cap enforced only after full read; composer flat
  zip layouts refused; vendor/mod zip-entry cap gated on declared size
  (unbounded read_to_end)
- get --json double JSON document on engine hard error; rollback
  --ecosystems replayed other ecosystems' leftover hosted edits; scan
  hosted --dry-run previewed against vendored wiring; apply --silent
  exited 1 mutely when patch sources unavailable; repair --vendor
  pre-delete destroyed healthy soft-reconstructed artifacts
- pnpm-workspace.yaml flow-sequence packages parsed as zero members
  (pre-existing RED tests un-ignored); authed batch 404 no longer an
  empty success; cargo config inline-table crates-io entries now visible
  to remove/read; uv: dependency-groups-only deps refused up front, empty
  overrides array no longer renders malformed, direct-URL requires-dist
  fails closed; golang missing-target precheck no longer fails healthy
  wired re-runs

5311 tests green (196 binaries, full workspace).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Implements the audited test plans for every uncovered-but-testable range
found by the full-coverage audit at d5e1815 (936 worthwhile ranges across
92 files): inline #[cfg(test)] additions plus 30 new per-module covgap_*
integration suites (conflict-free placement; shared suites untouched).

An adversarial review pass (46 reviewers + 3-vote refutation panels over
the full diff) confirmed 42 findings, all applied:
- fix residuals: uv revert convergence carve-outs (drift-keep gate no
  longer keeps converged reverts forever), requirements-flavor
  vendor_revert_residual_reference keep signal, fail-closed in-sync
  rebuild pin guard (corrupt/missing state.json now refuses instead of
  rebuilding blind), redirect nuget open-tag/single-quote tolerance
  matching the nuget_feed twin, scan --prune now reports
  keptVendoredEntries + remediation hint (dry preview documented as
  drift-blind), takeover scope-aware name probe, golang hot-path gate
  strengthened to full redirect_in_sync equivalence, multi-line
  pnpm-workspace flow sequences, fetch-stage online-failure silent-mode
  envelope
- unfixed twins found by review: bun_lock + pnpm v9 post-pack failure
  paths ported to done_failure_unstage (a new test had enshrined the
  husk behavior; now asserts the fixed contract)
- test hygiene: geteuid()==0 root guards on all new chmod-based tests,
  SOCKET_*/VIRTUAL_ENV scrubs in spawned-CLI harnesses, telemetry
  disabled in covgap_commands_vex (was POSTing to production), hermetic
  Gemfile.lock fixtures replacing real bundle probes, cfg(unix)/path-
  separator gates, vacuous tests repaired or deleted

6,597 tests green (196 binaries, full workspace). Coverage (host,
default features): 94.18% → 98.2%+ lines; 72-77% of the 5,720
never-executed production lines from the baseline audit now covered;
the remainder is classified defensive/unreachable/interactive-only/
platform-gated in the audit record.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…maining files

Re-triage of the 923 missed lines remaining after the main waves, with
fresh post-fix line numbers. Each of the 14 files' uncovered ranges was
either covered by a stable test or formally classified untestable with a
per-range reason (129 declared: match-exhaustiveness arms proven dead by
construction, assertion-failure format args inside test modules,
interactive-only and platform-gated paths). Two prior-wave skips were
overturned where a stable approach existed (pnpm-v9 packages-key
diagnosis, yarn-berry compressionLevel:0).

6,762 tests green (full workspace).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review September 2, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant