← Back to Pull requests

test(cli): a fault contract generated from the parser tree for every path parameter #1336

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 27, 2026 03:08 UTC
Author

Summary

Reviewers keep finding two things by hand: a wrong exit code or a traceback where a message belongs, and a path or link that leaves its root. This adds a contract test, generated from the parser, that raises both before review.

Closes #1294

Changes

  • tests/cli_faults.py builds the faults; tests/test_cli_fault_contract.py generates cases from build_parser(): every path parameter of every command gets a missing file, a directory, an unreadable file, a dangling link, a link out of the root, .., an absolute path, an empty file, invalid UTF-8 and an unwritable parent.

  • Each case must exit with the code docs/quickstart.md gives a bad input, print no Traceback, leave nothing behind, and make no model call before an unreadable path is refused.

  • A case counts only when it reaches its parameter: each parameter is also run once with a good value, and a case the command answers in the same words is skipped as not reached, never passed.

  • A parameter is a path by its help, metavar, type, name or default, so one with an empty help is still covered.

  • A readable file also gets four content values: JSON cut short (must be refused as malformed, exit 2), and a JSON list, null and a JSON string, which a command may accept or refuse but must not crash on.

  • Known failures are rows in tests/data/cli_fault_allowlist.txt. A row that no longer fails, is not reached, or names no case fails the test, so the list only shrinks. The same file lists the commands none of whose path parameters is reached, each with what refuses first; these are limits of the harness, not defects.

  • Names kept by hand (NOT_PATHS, FILLERS, CENTRAL, DOCUMENTED) live in tests/cli_faults.py; test_every_hand_kept_name_is_still_in_the_parser fails on the PR that renames one.
  • Tests only; no product code changes.

    What the allowlist holds

    1. Traceback on an unreadable input: catalog check --root and --upstream, catalog provenance --upstream, skill check --root, eval tasks list --tasks-root, the batch dir of repo compare, repo hits sheet and repo report, the subject file of subjects run.
    2. Traceback on eval native-import when the log is missing, a directory, a dangling link or unreadable.
    3. Unreadable directory accepted with exit 0: eval inspect.
    4. catalog check --tasks-subdir accepts a missing path, a file, .., an absolute path and a link out of --root.
    5. catalog list --intents is read only with --domain, so a bad file passes; an empty --intents or --registry file reads as an empty registry.
    6. Output left after a refusal: catalog eval writes report.md and then exits 2; repo hits judge leaves _eval/lock on a bad --labels.
    7. skill novelty analyze and skill novelty atoms make a model call before refusing an unusable --out-dir or --out; skill shorten exits 0 on an unusable --out.
    8. skill novelty probe raises KeyError: 'atoms' on an --atoms file holding {}.
    9. eval judge wording --answers crashes on a JSON list with no usable answer.

    Each is a defect to fix in its own PR; fixing one fails its row here, naming the row to delete.

    Risk

  • Test-only. It adds about 20 seconds to a run on four workers.

  • A new command whose cases are all refused before its path is read fails test_the_harness_reaches_a_path_parameter_of_every_command, with the refusal in the message; its author adds a filler or one unreached row.

  • Interpreter: Path.exists() raises PermissionError under an unreadable directory before Python 3.14 and returns False from 3.14 on. Rows whose reason starts python <3.14: or python >=3.14: apply on those versions only. Expect a few rows to move when a new Python joins the matrix.

  • Silent gaps: a parameter that is not reached, on a command with another reached parameter, is only a skip; a parameter that names a path by none of help, metavar, type, name or default is not seen.
  • Testing

  • tests/test_cli_fault_contract.py on Python 3.11, 3.13 and 3.14 before the rebase onto current main, and on 3.14 after it: passes on each (the interpreter rows above are what differ). Also passes in shuffled order under -n auto with three seeds and in one process.

  • Removing an allowlist row fails its case; a stale row, a row for a case that is not reached and a row naming no case all fail; removing an unreached row fails the reach test; a name planted in FILLERS that no command has fails the names test.

  • make ci-local CI_LOCAL_ARGS='--offline --jobs static,typecheck': 0 failed, 17 passed, 3 skipped.
  • Open questions

    None. Three readings were settled from the docs:
    1. catalog check --tasks-subdir should refuse a directory outside --root and a missing one given on the command line: its help places it under --root, and the exit-code table lists repo scan --manifest ../x.yaml under exit 2. The default subdirectory may still be absent.
    2. An empty intents or registry file named on the command line should be refused: the exit-code table gives exit 2 to "evaluate --custom-questions on an empty or non-JSON file".
    3. report summary exiting 0 on a missing input is intended: its docstring says "Exit 0 once written", and the missing input becomes a not_run row. The contract accepts 0 and 2 for it.

    Revert

    Revert the commit. It adds four test files (the helpers, the contract, a test of the helpers and the allowlist) and touches nothing else; nothing is stored.

    Checklist

  • Tests added/updated and pytest passes

  • ruff, mypy, and schema checks pass

  • Docs updated (or N/A) — see the docs-drift checklist in CONTRIBUTING.md

  • Self-reviewed per "Before opening a PR" in AGENTS.md

  • Each new raise/exit and test names the doc, contract or issue it traces to

  • No ad-hoc run artifacts committed

  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml)
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: vchamarthi Review duration: 5204m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.52) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #1336"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 29.7% · Safe to merge
    29.7%
    Repository