Skip to content

fix: exit session-construction failures by diagnostic class - #1031

Merged
e54-bot merged 2 commits into
mainfrom
fix/1028-session-exit-class
Oct 29, 2026
Merged

e54-bot merged 2 commits into
mainfrom
fix/1028-session-exit-class

Conversation

@e54-bot

@e54-bot e54-bot commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1028 — session-construction diagnostics now drive CLI exits by their declared Diagnostic.class instead of a hardcoded usage exit.

  • session/registry.rs: lint-rule-error splits by RuleRegistryError kind — Io (missing/unreadable --rule-file) is Usage → exit 2; Rule/Catalog/DuplicateId (invalid content) stays SourceError → exit 1, per the owner decision's first option since the registry distinguishes the two.
  • lint_package.rs: activate_pinned declares each LintPackageError with its existing exit_class() — the taxonomy lint package already reports. Without this, honoring Diagnostic.class would have regressed bad package pins (lint-package-source, a usage error) from exit 2 to exit 1 through lint/serve.
  • session.rs (new): session::refuse reports a construction diagnostic and returns diagnostic.class.exit_code(); run_configured and run_lookup use it, and serve::run exits by the class directly. No wrapper pins a fixed exit anymore.
  • cli.rs: check and lookup accept repeatable --rule-file wired into SessionConfig.lint_rule_paths, matching lint/serve — required so all three surfaces reach the construction boundary the same way.
  • Tests: lint-rule-error rows restored and pinned in check_failures.rs (missing → Usage, invalid → SourceError) and lookup_failures.rs; new tests/session_exits.rs drives missing and invalid rule files through check, lookup, and serve and asserts exits 2 and 1.

main.rs/tests/cli.rs were already over the repository size-guard limit, so the shared refusal path lives in src/session.rs and the new test in tests/session_exits.rs; main.rs nets −6 lines vs HEAD.

Verification

  • cargo fmt --all -- --check — clean
  • cargo clippy --workspace --all-targets --all-features -- -D warnings — clean
  • cargo test --workspace --all-targets --all-features </dev/null — 74 test binaries pass, 0 failures (12 mock_provider tests ignored; they require the LPP_MOCK_PROVIDER pin)
  • git diff --check — clean
  • Focused: cargo test -p wright-cli --test session_exits, -p wright-driver --test check_failures, --test lookup_failures — all pass
  • Mutation check (acceptance criterion): temporarily re-hardcoded run_configured's construction exit to exit::USAGE → session_construction_exits_follow_the_diagnostic_class failed as required; reverted.

Unverified

  • The mutation check was applied to run_configured only; run_lookup and serve::run use the same class-derived path and are covered by the same test, but were not individually mutated.

The check, lookup, and serve wrappers hardcoded exit 2 for every
CompilerSession::new / ToolService::new failure, so the process exit
disagreed with Diagnostic.class whenever a construction diagnostic
carried anything but Usage.

CompilerSession::new now classifies lint-rule-error by failure kind: a
missing or unreadable --rule-file path (RuleRegistryError::Io) is Usage,
while invalid rule content stays SourceError. activate_pinned declares
each package failure with the LintPackageError exit class that
`lint package` already reports, so a bad pin keeps exit 2 at the
session boundary. check and lookup accept --rule-file like lint and
serve, and the failure tables pin lint-rule-error on both classes. A
CLI test drives missing and invalid rule files through check, lookup,
and serve.

Fixes #1028
Remove the explanatory headers and local comments that restate the class-to-exit mapping. Code and assertions are unchanged.
@e54-bot

e54-bot commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator Author

Round-1 finding fixed in f951bb5: the newly added narrating comments are removed; code and assertions are unchanged. fmt, clippy -D warnings, and the three affected test targets pass. Ready for follow-up review.

@e54-bot
e54-bot merged commit f3b958e into main Oct 29, 2026
36 checks passed
@e54-bot
e54-bot deleted the fix/1028-session-exit-class branch October 29, 2026 08:15
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Make Workshop Great Again Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Session-construction diagnostics: declared class and CLI exit class disagree

2 participants