Repository navigation
test(cli): scope module resets to mocked policy cases - #134364
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 2:20 PM ET / 18:20 UTC. ClawSweeper reviewWhat this changesThe PR scopes Vitest module resets and mock cleanup to the two CLI policy tests that temporarily mock a policy dependency. Merge readinessNo blocking findings. The two module-mock tests now establish and clean up their own mutable Vitest state, while the other cases retain immutable imported resolvers; this is a focused, behavior-neutral test cleanup. This maintainer-authored PR should remain open for normal landing review. Priority: P3 Review scores
Verification
How this fits togetherCLI startup first derives a command-path policy, then turns it into startup behavior such as config validation and plugin loading. The affected tests mock a catalog or policy dependency only to verify exceptional resolver branches. flowchart LR
Input[CLI arguments] --> Path[Command-path policy]
Catalog[Command catalog] --> Path
Path --> Startup[Startup policy]
Startup --> Behavior[CLI bootstrap behavior]
TestMocks[Scoped test mocks] --> Path
TestMocks --> Startup
Before merge
Agent review detailsSecurityNone. PR surfaceTests +3. Total +3 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep cleanup ownership local to the two tests that install module mocks, preserving their clean setup and guaranteed teardown without resetting unrelated cases. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR refactors test-state lifetime rather than reporting a user-facing runtime defect. The changed tests are structurally source-verifiable, but this read-only review did not execute them. Is this the best way to solve the issue? Yes. Cleanup now belongs to the only two tests that mutate module mocking state; the alternative suite-wide hook resets unaffected non-mocked cases in a non-isolated runner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 127ae428ece0. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Maintainer landing review is complete. I read the full latest ClawSweeper review (18:20 UTC): no actionable findings or Rank-up moves remain. The two mutable mock lifecycles own their setup and finally cleanup; all 58 focused policy/startup/execution/path-matcher tests passed before and after, full changed checks passed, and Codex autoreview is clean. Exact-head CI and Workflow Sanity are green. Production +0/-0; tests +50/-47. Proceeding through the native landing gates under the requested test-maintenance batch. |
|
Merged through the native landing workflow: prepared head eaff5dd became e2c92fce4d8b. The automatic completion comment hit GitHub's API quota after the merge. After the reset, native read-only reconciliation confirmed the accepted merge, and the current comment list contained no completion marker or duplicate landing comment. This records completion without repeating the merge. |
What problem does this PR solve?
CLI policy tests reset the module cache after every case, although only two cases install module mocks. The remaining cases use immutable imports and fresh policy inputs.
Why this approach?
Move reset/unmock ownership into those two cases. Each begins with a clean module cache, keeps its query-qualified fresh import, and restores the mock and cache in finally. This reduces 48 resets to four and 48 unmock calls to two without changing test inputs or outcomes.
User impact
Test-only cleanup; production +0/-0, tests +50/-47. All 48 changed-file cases and 123 assertion sites remain, including deep catalog overrides and suppressed-output guards.
Evidence
All 58 policy/startup/path-matching tests pass before and after through the default runner routes. Full changed-file checks and Codex autoreview pass after formatting. The original mock introduction, later query-qualified import change and runner cleanup were checked. Reset counts are structural; no elapsed-time improvement is claimed.
node scripts/run-vitest.mjs src/cli/command-path-policy.test.ts src/cli/command-startup-policy.test.ts src/cli/command-execution-startup.test.ts src/cli/command-path-matches.test.ts