Repository navigation
test(coverage): closure matrix YAML + lint (#1186) - #1191
Conversation
Add docs/plans/test-closure-matrix.yaml as the executable per-domain test-closure matrix (rows of domain × target_files × representative_tests × gate × known_gaps) plus the devtools verify-closure-matrix lint that fails when declared paths drift from the realized tree. The lint is wired into devtools verify under the §10 manifest+lint pattern so closure-matrix drift fails locally before a PR is opened. The legacy qualitative catalog at docs/plans/test-coverage-domains.yaml is retained as free-text notes and pointed back to from the new matrix. Closes #1186 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughThis PR delivers the test-closure matrix as a tracked artifact. A new YAML file documents per-domain coverage mappings (target files, representative tests, gate classification, and known gaps), a new ChangesTest Closure Matrix Definition and Verification
Sequence DiagramsequenceDiagram
participant Developer
participant CLI as devtools verify
participant Verifier as verify-closure-matrix
participant Matrix as test-closure-matrix.yaml
participant Tree as Repository Tree
Developer->>CLI: devtools verify --quick
CLI->>Verifier: spawn verify-closure-matrix step
Verifier->>Matrix: load YAML
Matrix-->>Verifier: matrix rows
loop Validate each row
Verifier->>Tree: confirm domain target_files exist
Tree-->>Verifier: file/dir status
Verifier->>Tree: confirm representative_tests path exist
Tree-->>Verifier: file status
Verifier->>Verifier: check gate constraints (known_gaps, required tests)
end
Verifier->>CLI: report blocking=true/false + error count
CLI->>Developer: exit 0 (clean) or 1 (blocking)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
## Summary The `devtools` CLI shell wrapper required `POLYLOGUE_REPO_ROOT` and dispatched against it unconditionally. The devshell exports that variable once at entry and it is then inherited by every subshell — including ones cd'd into a worktree — so `devtools verify --quick` run from a worktree silently validated the *main checkout*. This PR makes the wrapper worktree-aware and audits the other CLI wrappers (`polylogue`, `polylogued`, `polylogue-mcp`) for the same anti-pattern. ## Problem - Observed during PR #1191 implementation, filed as #1193: agent ran `devtools verify --quick` from an isolated worktree, got false-positive green, and the pre-push hook (which also calls `devtools verify --quick`) had the same blind spot. - #1209 is the audit companion: ensure no installed wrapper in this flake bakes a developer-specific path or inherits the wrong root from env. ## Solution - Move the wrapper body to `nix/devtools-wrapper.sh` so the same shell script is read into the Nix `writeShellScriptBin` (via `builtins.readFile`) and exercised by unit tests directly — no Nix build required for the regression test. - New resolution order in the wrapper: 1. `git rev-parse --show-toplevel` from the caller's cwd, validated by the presence of `devtools/__main__.py`. This is the normal path and makes the wrapper worktree-aware. 2. `POLYLOGUE_REPO_ROOT`, only when set and pointing at a real checkout. Documented fallback for tarball / non-git extraction cases. 3. Loud error otherwise. No silent dispatch to a stale or wrong path. - Audit of the other wrappers: - `polylogue`, `polylogued`, `polylogue-mcp` are Python console-script entry points (`[project.scripts]` in `pyproject.toml`) — no path baking, they import the installed package. - `flake.nix` `postFixup` wraps them with `wrapProgram` that only scrubs PYTHON* env vars — no path pin. - `nix/module.nix` (NixOS module) sets only `POLYLOGUE_CONFIG`; no checkout path. - No `/realm/project/polylogue` literal exists anywhere in `flake.nix` or `nix/` (only in a docstring example and test fixtures, both unrelated to the install surface). - The static side of the audit is enforced by `test_repo_wrapper_script_has_no_hardcoded_paths`, which keeps the script free of `/realm/project/polylogue` and free of any "POLYLOGUE_REPO_ROOT is not set" hard requirement. The `POLYLOGUE_REPO_ROOT="$PWD"` export in the devshell `shellHook` is retained because it still serves as the documented fallback for tooling that wants an explicit hint; it is no longer load-bearing for `devtools` worktree dispatch. ## Verification ``` $ python -m pytest tests/unit/devtools/test_cli_wrapper.py 6 passed in 8.41s $ python -m devtools verify --quick ... "exit_code": 0 ``` The new tests cover: cwd resolution, cwd-wins-over-env (the #1193 scenario), env-fallback outside git, invalid env-var ignored, no-checkout error path, and the static no-hardcoded-paths guard. Closes #1209 Closes #1193
Summary
Adds
docs/plans/test-closure-matrix.yamlas the executable per-domain test-closure matrix the #997 close-out promised, plus a newdevtools verify-closure-matrixlint that fails when reality drifts from the manifest. Wired intodevtools verifyso closure-matrix drift fails locally before a PR is opened.Problem
#997 left the closure matrix as a known follow-up: the existing
docs/plans/test-coverage-domains.yamldocuments qualitative coverage notes but is not consumed by any verification gate, and it does not carry the four-column closure shape (target files × representative tests × gate × known gaps) the AC asked for. #1186 tracks the missing artifact and lint.Solution
docs/plans/test-closure-matrix.yaml— 31 rows covering the substrate, derived read models, surfaces, and verification rings. Each row carries:domain(stable dotted identifier, e.g.storage.blob_store,sources.parsers.codex)target_files(production paths underpolylogue/, file or directory form)representative_tests(test file paths orpath::Class::testnodeids)gate∈required/optional/absentknown_gaps(free-text bullets; required forabsentrows)deprecated_pointerback-reference sotest-coverage-domains.yamlstays as the free-text companion catalog.devtools/verify_closure_matrix.py— new lint that checks every declared path exists on disk, gate is one of the legal values,absentrows carry at least oneknown_gapsbullet,required/optionalrows list at least one representative test, and domain values are unique. Outputs human/JSON forms in the same shape asdevtools verify-file-budgets.devtools/command_catalog.py— registersverify-closure-matrixunder theverificationcategory sodevtools --list-commands, the help surfaces, and the rendered devtools reference all pick it up.devtools/verify.py— addsverify-closure-matrixto the defaultbuild_verify_steps()chain (runs in bothdevtools verifyanddevtools verify --quick).devtools/render_quality_reference.py— generates a new "Closure Matrix" section indocs/test-quality-workflows.mdexplaining the schema, the gate semantics, and the lint behavior so future test additions update the matrix.tests/unit/devtools/test_verify_closure_matrix.py— 8 cases: committed matrix passes, missing target/test paths fail, gate validation,absent-without-gaps fails,required-without-tests fails, duplicate domains fail, and pytest nodeid form is accepted.Pattern follows the existing manifest+lint pairs (
verify-file-budgets,verify-test-ownership,verify-topology) per the §10 evidence-driven structural specifications pattern; the matrix is the executable backstop for the qualitativetest-coverage-domains.yaml.The eight domains called out in the #997 close-out (codex events, browser capture, site/rendering, blob store, CLI insights, auth, schema migration, Claude-AI/Gemini parsers) are all present as dedicated rows with their representative tests and any remaining gaps spelled out.
Verification
Closes #1186
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Tests