Skip to content

Raise traverse-mcp line coverage from 86% to 98.55%#623

Open
enricopiovesan wants to merge 1 commit into
mainfrom
claude/issue-617-mcp-coverage
Open

Raise traverse-mcp line coverage from 86% to 98.55%#623
enricopiovesan wants to merge 1 commit into
mainfrom
claude/issue-617-mcp-coverage

Conversation

@enricopiovesan

Copy link
Copy Markdown
Collaborator

Summary

  • Quality: Enforce coverage gate for traverse-cli and traverse-mcp (constitution 100% core logic) #594 added traverse-mcp to the coverage gate with a measured phased floor (86.07%) so it couldn't regress while a larger test tranche was completed. This closes most of that gap.
  • lib.rs 74.6%→99.9%: not_found/map_runtime_error/lifecycle_name exercised directly and exhaustively (every RuntimeErrorCode and Lifecycle variant), McpToolRegistry Default/Debug, observe_execution, and get_capability/get_event/get_workflow's not-found paths.
  • stdio_server.rs 74.6%→94.2%: StdioAuthConfig's Debug impl and from_env (refactored into an injectable from_env_var core, since mutating env vars from a test is unsafe and this workspace forbids unsafe entirely); describe_entrypoint/describe_content_group/entrypoint_artifacts/validate_runtime_request's validation branches driven directly or via crafted stdio commands; run_stdio_server's own body via simulate_startup_failure (which returns before ever reading real stdin, so it's safe to call directly); every write_json_line call site's io_error branch, exercised with a writer that fails on the Nth \n-terminated envelope so each branch can be targeted individually; malformed-JSON and invalid-UTF8 command lines; unsupported commands; and several free helper functions called directly.
  • main.rs 0%→75%: extracted a testable run(args) core from main, covering the usage/unsupported-command/simulated-failure branches.
  • Converted several test-only Err(e) => panic!(...) match arms into single-line .expect()/.expect_err() calls: those arms are unreachable in a passing test and llvm-cov's line coverage counts the never-taken arm as a separate missed line.
  • ci/coverage-targets.txt's traverse-mcp threshold moves from 86 to 98 (measured 98.55%, kept a small margin for tooling variance, matching the convention of the original phased floors).
  • Remaining gap (98.55%→100%) is registry-bundle-load failure paths with no test injection point, one genuinely unreachable executor match arm, and a get_capability double-lookup branch that doesn't appear reachable through the public registry API — filed as #622 per the Definition of Done.

Governing Spec

  • 015-capability-discovery-mcp
  • 042-mcp-library-surface

Project Item

Closes #617

Validation

  • cargo test --workspace — all tests pass (47 new/updated traverse-mcp tests).
  • cargo clippy --workspace --all-targets -- -D warnings — clean.
  • cargo fmt --check — clean.
  • bash scripts/ci/coverage_gate.sh (with LLVM_COV/LLVM_PROFDATA pointed at brew llvm) — passes; traverse-mcp measured at 98.55%, threshold set to 98.
  • bash scripts/ci/spec_alignment_check.sh — passes locally against this branch.

#594 added traverse-mcp to the coverage gate with a measured phased
floor (86.07%) so it couldn't regress while a larger test tranche was
completed. This closes most of that gap:

- lib.rs 74.6%->99.9%: not_found/map_runtime_error/lifecycle_name
  exercised directly and exhaustively (every RuntimeErrorCode and
  Lifecycle variant), McpToolRegistry Default/Debug, observe_execution,
  and get_capability/get_event/get_workflow's not-found paths.
- stdio_server.rs 74.6%->94.2%: StdioAuthConfig's Debug impl and
  from_env (refactored into an injectable from_env_var core, since
  mutating env vars from a test is unsafe and this workspace forbids
  unsafe entirely); describe_entrypoint/describe_content_group/
  entrypoint_artifacts/validate_runtime_request's validation branches
  driven directly or via crafted stdio commands; run_stdio_server's
  own body via simulate_startup_failure (which returns before ever
  reading real stdin, so it's safe to call directly); every
  write_json_line call site's io_error branch, exercised with a
  writer that fails on the Nth `\n`-terminated envelope so each
  branch can be targeted individually without depending on how many
  raw write() calls the JSON body itself takes; malformed-JSON and
  invalid-UTF8 command lines; unsupported commands; and the handful of
  free helper functions (derive_composability_metadata,
  parse_workflow_ref, load_runtime_request, provenance_source_label,
  execute_validate_team_readiness's branches) called directly.
- main.rs 0%->75%: extracted a testable `run(args)` core from `main`,
  covering the usage/unsupported-command/simulated-failure branches.

Also converted several test-only "Err(e) => panic!(...)" match arms
into single-line `.expect()`/`.expect_err()` calls across lib.rs and
stdio_server.rs: those error arms are unreachable in a passing test,
and llvm-cov's line coverage counts the never-taken arm as a separate
missed line since it spans its own source line(s), unlike a single
`.expect()` call.

ci/coverage-targets.txt's traverse-mcp threshold moves from 86 to 98
(kept a small margin below the measured 98.55% for tooling variance,
following the same convention as the original phased floors).

Remaining gap (98.55% -> 100%) is registry-bundle-load failure paths
(McpDiscoveryCatalog::load_canonical, CanonicalExecutionContext::
load_canonical, build_capability_registration all read from a fixed
repo-relative canonical bundle path with no injection point for
testing failure), one genuinely unreachable executor match arm given
the current canonical bundle's capability set, and a get_capability
double-lookup branch in tools/capabilities.rs whose failure mode isn't
reachable through the public registry API. Filed as a follow-up
issue per #617's Definition of Done.

Closes #617

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.

Quality: Raise traverse-mcp coverage gate to 100%

1 participant