Repository navigation
scan exits 1 in human output but 0 with --json when every patch query returns nothing #1062
Description
[agent] Filed by the October 7 architecture audit campaign (core). Register: arch-audit register.
Kind: bug. Source: audit B54 (Part 2.2 / C11 drift), register C70.
Problem: run_scan's human arm treats Ok(discovered) with fetched == 0 as a fetch failure and exits 1 (scan/mod.rs#L2734). The JSON arms (agent apply, vendored run_vendor_json_path, report-only) accept the same result and exit 0 with an empty block. discover_selected returns Err only when every query fails. The vendored --dry-run GC preview and the hosted prune argument (args.prune || args.sync vs the policy-gated prune) also differ between the arms.
Symptoms: earlier bugs from the same fork: #424 (fixed), #732 (fixed), #744 (open). Impact: a CI job using scan --json and a developer running scan against the same API state get different exit codes and different previews; every fix has to land twice.
Proposed change: move the fetched == 0 rule (and the prune flag) into discover_selected/one shared decision, so both arms read it; delete the arm-local checks.
Size and scope: commands/scan/mod.rs, vendor_flow.rs, hosted.rs; under 100 lines. The full split is #843/#844 (C11).
Acceptance criteria:
- A parity test runs each mode × {json, human} over one fixture where every successful query returns no patches, and compares exit codes and actions.
- Existing scan suites stay green.
Dependencies: none; eases #844.
Generated by Claude Code
Activity
mikolalysenko commentedon Oct 7, 2026
[agent] Triage: priority:p3 (general CLI). Not a duplicate of #744 (a different scan human/JSON fork). No open PR references it.
Generated by Claude Code
mikolalysenko commentedon Oct 9, 2026
[agent] I re-checked this on main @
f3c6313. It still holds, and the code has moved, so here are fresh permalinks.Ok(discovered)withfetched == 0into exit 1 for agent, vendored and report-only runs:scan/mod.rs#L2794-L2798.``discovered.fetched, so the JSON arms still accept the same result and exit 0.Generated by Claude Code
mikolalysenko commentedon Oct 9, 2026
v5 release blocker (P1). A successful scan with no applicable patches must have the same exit code and actions in human and JSON mode. This is basic first-run/CI UX.
This follows the maintainer's release scope: one normally completing CLI instance, prioritizing valid-lockfile patch/install behavior, compatibility, and actionable CLI UX.
mikolalysenko commentedon Oct 9, 2026
[agent] Claiming for v5 blocker burn-down (shared root cause: scan's human arm applies its own
fetched == 0exit rule that the JSON arms don't). Branch: agent/v5-scan-empty-fetch-parity. Claim-ID: 2026-10-09T16:27:48Z-989b90Generated by Claude Code
mikolalysenko commentedon Oct 9, 2026
[agent] Draft PR: #1298
Generated by Claude Code
Make scan exit alike in human and JSON output
Read scan's unified dry-run GC key in the #1062 prune preview test
Move scan and get --json onto the shared envelope
Document the scan/get envelope and add shape and parity tests