Skip to content

fix(doctor): stop printing remediation hints for flags that do not exist - #198

Open
TAJD wants to merge 4 commits into
mainfrom
fix/impossible-remediation-hints
Open

fix(doctor): stop printing remediation hints for flags that do not exist#198
TAJD wants to merge 4 commits into
mainfrom
fix/impossible-remediation-hints

Conversation

@TAJD

@TAJD TAJD commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Closes CD-301 (the code half).

The bug

cofferdam doctor printed two remediation hints telling the user to run commands that exit 2.

Hint Reality
skipped — N files exceeds scan limit; pass --paths to scope doctor takes no positional args and no --paths. Usage is doctor [OPTIONS]; options are --pretty, --robot, --help.
run cofferdam doctor from a narrower directory or add --paths First half correct, second impossible.
see `cofferdam explain --list` explain requires <CHECK_ID> and defines no --list. Running it gives error: unexpected argument '--list' found, exit 2.

A remediation hint is read at the exact moment the user is already stuck. One naming a flag that was never implemented is worse than no hint, because it costs a second failed command before the user stops trusting the output.

docs/doctor.md repeated both verbatim, so the binary and the docs were consistently wrong together — which is why neither caught the other.

The fix

Both hints are now named constants (SCAN_LIMIT_HINT, STALE_ID_HINT) carrying accurate advice: run doctor from a subdirectory, and reach the catalog via cofferdam explain <CHECK_ID> or the checks index.

A test asserts neither hint names a CLI flag. That pins the invariant instead of restating it in a comment — the previous strings would fail it.

Also corrected docs/suppression.md, which recommended --ignore-path. No subcommand defines that flag; the real mechanisms are cofferdam.toml's exclude and .cofferdamignore.

How it was found

Per CD-299, I diffed every --flag named in the hand-written docs against cofferdam <subcommand> --help for all 13 subcommands. The generated reference/cli.md had to be excluded from the comparison — it is produced from clap and therefore always agrees with the binary, which is exactly why it hides drift in the pages humans write.

The same sweep found seven shipped-but-undocumented flags (check --no-cache, --cache-dir, --hide-baselined, --time-checks, init --force, watch --debounce, gen-docs --out). Those are documentation-only and are tracked on CD-301 for the docs branch; --no-cache matters most, since cofferdam's own CLAUDE.md requires it for real-repo validation and no public page mentions it.

Verification

  • cargo test -p cofferdam-cli — 21 passed
  • cargo clippy --all-targets -- -D warnings — clean
  • cargo fmt --all -- --check — clean
  • cofferdam gen-docs --check — exit 0

🤖 Generated with Claude Code

https://claude.ai/code/session_019afugU2bTYCtXn6Vy9dn1v

TAJD and others added 3 commits August 9, 2026 07:20
`cofferdam doctor` told users to run two commands that exit 2.

- The suppression scan-limit warning said "pass --paths to scope" and "add
  --paths". `doctor` takes no positional args and no --paths; its only options
  are --pretty, --robot and --help.
- The stale-directive warning said "see `cofferdam explain --list`". `explain`
  requires a <CHECK_ID> argument and defines no --list, so that command fails
  with "unexpected argument".

A remediation hint is read at the moment the user is already stuck. One that
names a flag that was never implemented costs more than no hint at all.

Both hints are now named constants with a test asserting they reference no CLI
flag, so the invariant is pinned rather than restated in prose.

docs/doctor.md repeated both errors verbatim and is corrected to match.
docs/suppression.md recommended `--ignore-path`, which no subcommand defines;
it now points at cofferdam.toml's `exclude` and .cofferdamignore, the two
mechanisms that exist.

Found by diffing every flag named in the hand-written docs against the output of
`cofferdam <subcommand> --help`, per CD-299. CD-301 has the full sweep, including
seven shipped-but-undocumented flags handled separately.

Verified: cargo test -p cofferdam-cli (21 passed), clippy -D warnings clean,
cargo fmt --check clean, gen-docs --check exits 0.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019afugU2bTYCtXn6Vy9dn1v
`ProjectConfig` has no `exclude` field and no `[ignore]` table; discovery
exclusion is `.cofferdamignore` / `.gitignore` only. The previous commit
replaced one impossible flag with an impossible config key.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019afugU2bTYCtXn6Vy9dn1v
…s not exist

`UnsupportedSchemaVersion` told the user to run `cofferdam invariants
migrate`. There is no `cofferdam invariants` subcommand — the clap enum
has 20 variants and none of them is `Invariants`. Same defect as the two
doctor hints in the previous commit, and worse placed: this message is
read at the moment a spec has already been rejected and the build has
stopped.

Currently unreachable, since MIN_SUPPORTED equals CURRENT so no declared
version can fall below the minimum. It arms itself at the first MAJOR
bump, which is exactly when a wrong hint costs the most.

Adds a regression test over both schema-version variants.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019afugU2bTYCtXn6Vy9dn1v
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

Criterion benchmark comparison (PR head vs base branch)

�[1m�[92m   Compiling�[0m cofferdam-core v0.4.1 (/home/runner/work/cofferdam/cofferdam/crates/cofferdam-core)
�[1m�[92m   Compiling�[0m cofferdam-html v0.4.1 (/home/runner/work/cofferdam/cofferdam/crates/cofferdam-html)
�[1m�[92m   Compiling�[0m cofferdam-rust v0.4.1 (/home/runner/work/cofferdam/cofferdam/crates/cofferdam-rust)
�[1m�[92m   Compiling�[0m cofferdam-graph v0.4.1 (/home/runner/work/cofferdam/cofferdam/crates/cofferdam-graph)
�[1m�[92m   Compiling�[0m cofferdam-engine v0.4.1 (/home/runner/work/cofferdam/cofferdam/crates/cofferdam-engine)
�[1m�[92m   Compiling�[0m cofferdam-checks v0.4.1 (/home/runner/work/cofferdam/cofferdam/crates/cofferdam-checks)
�[1m�[92m    Finished�[0m `bench` profile [optimized] target(s) in 49.93s
�[1m�[92m     Running�[0m benches/engine_bench.rs (target/release/deps/engine_bench-ca23a59a1638a55e)
Gnuplot not found, using plotters backend
Benchmarking full_run_no_cache
Benchmarking full_run_no_cache: Warming up for 3.0000 s
Benchmarking full_run_no_cache: Collecting 20 samples in estimated 6.9376 s (420 iterations)
Benchmarking full_run_no_cache: Analyzing
full_run_no_cache       time:   [16.351 ms 16.590 ms 17.106 ms]
                        change: [-1.7297% +2.1280% +5.3864%] (p = 0.29 > 0.05)
                        No change in performance detected.
Found 3 outliers among 20 measurements (15.00%)
  1 (5.00%) low severe
  2 (10.00%) high severe

Benchmarking single_file_edit_incremental
Benchmarking single_file_edit_incremental: Warming up for 3.0000 s

Warning: Unable to complete 20 samples in 5.0s. You may wish to increase target time to 9.5s, enable flat sampling, or reduce sample count to 10.
Benchmarking single_file_edit_incremental: Collecting 20 samples in estimated 9.5497 s (210 iterations)
Benchmarking single_file_edit_incremental: Analyzing
single_file_edit_incremental
                        time:   [7.4737 ms 7.5199 ms 7.5684 ms]
                        change: [+1.0162% +1.8909% +2.7561%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 3 outliers among 20 measurements (15.00%)
  1 (5.00%) low mild
  1 (5.00%) high mild
  1 (5.00%) high severe


… future work

`Consistency.UnusedSuppression` and `Consistency.BroadSuppression` both
ship in consistency.rs, but the page described the first as "a future
check (separate bead)" in two places. Name them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019afugU2bTYCtXn6Vy9dn1v
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

Criterion benchmark comparison (PR head vs base branch)

�[1m�[92m   Compiling�[0m cofferdam-core v0.4.1 (/home/runner/work/cofferdam/cofferdam/crates/cofferdam-core)
�[1m�[92m   Compiling�[0m cofferdam-graph v0.4.1 (/home/runner/work/cofferdam/cofferdam/crates/cofferdam-graph)
�[1m�[92m   Compiling�[0m cofferdam-html v0.4.1 (/home/runner/work/cofferdam/cofferdam/crates/cofferdam-html)
�[1m�[92m   Compiling�[0m cofferdam-rust v0.4.1 (/home/runner/work/cofferdam/cofferdam/crates/cofferdam-rust)
�[1m�[92m   Compiling�[0m cofferdam-checks v0.4.1 (/home/runner/work/cofferdam/cofferdam/crates/cofferdam-checks)
�[1m�[92m   Compiling�[0m cofferdam-engine v0.4.1 (/home/runner/work/cofferdam/cofferdam/crates/cofferdam-engine)
�[1m�[92m    Finished�[0m `bench` profile [optimized] target(s) in 52.32s
�[1m�[92m     Running�[0m benches/engine_bench.rs (target/release/deps/engine_bench-ca23a59a1638a55e)
Gnuplot not found, using plotters backend
Benchmarking full_run_no_cache
Benchmarking full_run_no_cache: Warming up for 3.0000 s
Benchmarking full_run_no_cache: Collecting 20 samples in estimated 7.0930 s (420 iterations)
Benchmarking full_run_no_cache: Analyzing
full_run_no_cache       time:   [16.366 ms 16.601 ms 17.019 ms]
                        change: [-2.7816% +0.1567% +2.4752%] (p = 0.92 > 0.05)
                        No change in performance detected.
Found 2 outliers among 20 measurements (10.00%)
  1 (5.00%) high mild
  1 (5.00%) high severe

Benchmarking single_file_edit_incremental
Benchmarking single_file_edit_incremental: Warming up for 3.0000 s

Warning: Unable to complete 20 samples in 5.0s. You may wish to increase target time to 9.4s, enable flat sampling, or reduce sample count to 10.
Benchmarking single_file_edit_incremental: Collecting 20 samples in estimated 9.3524 s (210 iterations)
Benchmarking single_file_edit_incremental: Analyzing
single_file_edit_incremental
                        time:   [7.4544 ms 7.5023 ms 7.5398 ms]
                        change: [-0.8878% +0.2973% +1.3073%] (p = 0.63 > 0.05)
                        No change in performance detected.
Found 1 outliers among 20 measurements (5.00%)
  1 (5.00%) low mild


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