Repository navigation
refactor(policy): consolidate doctor test fixtures - #118173
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 2, 2026, 4:18 PM ET / 20:18 UTC. ClawSweeper reviewWhat this changesConsolidates repeated temporary policy/config-file setup and doctor-registration ceremony into file-local helpers across three Policy doctor test modules. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 4 items remain Keep this PR open for normal protected-label review. The branch is a focused test-fixture refactor with no observed production, configuration, dependency, or workflow change; its selected modules preserve 43, 42, and 45 test declarations respectively, and no discrete patch defect was found. The available validation is test-only and not inspectable as an artifact, so real after-fix proof remains the only contributor action before merge. Priority: P3 Review scores
Verification
How this fits togetherThe Policy plugin registers doctor checks that inspect workspace configuration and policy files for conformance. These test modules create isolated temporary workspaces, register those checks, and assert the findings and repair behavior exposed by the doctor command. flowchart LR
A[Policy test cases] --> B[File-local fixture helpers]
B --> C[Temporary workspace files]
C --> D[Policy doctor registration]
D --> E[Doctor check catalog]
E --> F[Findings and repair assertions]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -747. Total -747 across 3 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the file-local fixture approach, then attach a redacted focused-suite terminal transcript or Testbox artifact for the exact head before protected-label review completes. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR reports test-fixture duplication rather than a user-visible failure. The affected registration and fixture lifecycle are directly inspectable in source, but no bug reproduction is claimed. Is this the best way to solve the issue? Yes, with medium confidence: file-local helpers preserve the single mocked Vitest module graph while retaining raw-string fixtures, JSON formatting arguments, and existing doctor-registration boundaries. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3a2337ece4f9. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Pre-merge proof for exact reviewed head
Both rank-up moves are addressed by the linked, inspectable exact-head CI/gate evidence and preserved focused/security-suite proof. No actionable findings remain. |
|
Merged via squash.
|
* origin/main: feat(gateway): track event-loop degradation persistence and add concurrency benchmark (#118193) fix(config): preserve secret ownership when configuration rows move (#118149) fix(cron): deliver failure alerts after persistence (#118200) chore(lint): clear 172 lint:all baseline violations in five batches (#118098) perf(gateway): remove streaming hot-path rescans (#118192) test(gateway): use in-memory task registry (#118191) test(macos): fix three races in the bounded process suites (#118196) refactor(migrate-hermes): consolidate test fixtures (#118182) test(android): share Wear transport fixtures (#118177) test(ui): deduplicate control UI e2e setup (#118180) fix(plugins): unblock prerelease validation (#118103) test(cli): reduce redundant process launches (#118141) test(gateway): compact terminal observer fixtures (#118179) fix(agents): make requested threads sidebar-visible (#118073) test(plugins): canonicalize native resolver fixtures (#118174) test: deduplicate agent runner fixtures (#118176) refactor(policy): consolidate doctor test fixtures (#118173) fix(plugins): remove disabled channel plugin configuration on uninstall (#118127) refactor(matrix): consolidate monitor test fixtures (#118175)
* origin/main: feat(gateway): track event-loop degradation persistence and add concurrency benchmark (openclaw#118193) fix(config): preserve secret ownership when configuration rows move (openclaw#118149) fix(cron): deliver failure alerts after persistence (openclaw#118200) chore(lint): clear 172 lint:all baseline violations in five batches (openclaw#118098) perf(gateway): remove streaming hot-path rescans (openclaw#118192) test(gateway): use in-memory task registry (openclaw#118191) test(macos): fix three races in the bounded process suites (openclaw#118196) refactor(migrate-hermes): consolidate test fixtures (openclaw#118182) test(android): share Wear transport fixtures (openclaw#118177) test(ui): deduplicate control UI e2e setup (openclaw#118180) fix(plugins): unblock prerelease validation (openclaw#118103) test(cli): reduce redundant process launches (openclaw#118141) test(gateway): compact terminal observer fixtures (openclaw#118179) fix(agents): make requested threads sidebar-visible (openclaw#118073) test(plugins): canonicalize native resolver fixtures (openclaw#118174) test: deduplicate agent runner fixtures (openclaw#118176) refactor(policy): consolidate doctor test fixtures (openclaw#118173) fix(plugins): remove disabled channel plugin configuration on uninstall (openclaw#118127) refactor(matrix): consolidate monitor test fixtures (openclaw#118175)
What Problem This Solves
Policy doctor coverage had accumulated hundreds of repeated lines for temporary config and policy files, doctor registration, and check execution. That repetition made the security-sensitive cases harder to compare and maintain even though the underlying behavior was identical.
Why This Change Was Made
This consolidates the repeated setup into file-local fixture helpers owned by the three existing Policy doctor test modules. The helpers preserve sequential config-before-policy writes, raw malformed fixtures, pretty-printed JSON bytes, and the existing registration/check boundaries; no production, config, schema, default, API, or i18n surface changes.
Architecturally, the test fixture layer owns the duplication. The canonical fix removes duplicate config/policy writes and registration/check ceremony while leaving the Policy doctor implementation and all assertions at their current owners.
User Impact
No runtime behavior changes. Maintainers get the same 300-case Policy doctor safety net with 747 fewer test-support lines and clearer case-specific inputs and expectations.
Evidence
expect(...)call sites before and after.node scripts/run-vitest.mjs extensions/policy/src/doctor/register.test.ts --reporter=verbose— 300/300 passed.extensions/policysuite plus every MCP- and security-named test across core, plugins, UI, and E2E — all 30 Vitest shards passed.pnpm check:changedpassed, including formatting, extension production/test typechecks, lint, dead-code, plugin-boundary, database-first, and import-cycle checks.The dependency contract was checked directly in sibling Codex source: MCP server configuration and transport shapes in
../codex/codex-rs/config/src/mcp_types.rs:124-225,324-480; authentication state and persistence in../codex/codex-rs/protocol/src/auth.rs:6-55and../codex/codex-rs/login/src/auth/manager.rs:248-458; model/catalog behavior in../codex/codex-rs/app-server-protocol/src/protocol/v2/model.rs:40-135,../codex/codex-rs/app-server/src/request_processors/catalog_processor.rs:159-305, and../codex/codex-rs/model-provider-info/src/lib.rs:86-285,332-507; MCP lifecycle behavior in../codex/codex-rs/core/src/session/mcp.rs:89-218,581-635and../codex/codex-rs/core/src/session/session.rs:721-755,1241-1270.