Skip to content

refactor(policy): consolidate doctor test fixtures - #118173

Merged
steipete merged 1 commit into
mainfrom
codex/goal100k-policy-doctor-fixture-wave19-2d45
Aug 2, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/goal100k-policy-doctor-fixture-wave19-2d45

Conversation

@steipete

@steipete steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

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

  • Exact parity census: 131 test declarations and 235 expect(...) call sites before and after.
  • Local focused proof: node scripts/run-vitest.mjs extensions/policy/src/doctor/register.test.ts --reporter=verbose — 300/300 passed.
  • Blacksmith Testbox broad proof: the complete extensions/policy suite plus every MCP- and security-named test across core, plugins, UI, and E2E — all 30 Vitest shards passed.
  • Blacksmith Testbox changed gate: pnpm check:changed passed, including formatting, extension production/test typechecks, lint, dead-code, plugin-boundary, database-first, and import-cycle checks.
  • Diff: +668/-1,415, net -747 test LOC; production delta 0.
  • Collision audit: exhaustive open-PR census and all >100-file tails found zero matches for the three changed paths.

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-55 and ../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-635 and ../codex/codex-rs/core/src/session/session.rs:721-755,1241-1270.

@steipete
steipete marked this pull request as ready for review August 2, 2026 20:13
@steipete steipete self-assigned this Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 2, 2026, 4:18 PM ET / 20:18 UTC.

ClawSweeper review

What this changes

Consolidates 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
Reviewed head: d2e3c6354880c1b246335315ebc92c11367247d6

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch appears focused and structurally sound, but real after-fix proof is limited to unlinked test/CI claims.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR body describes test and CI execution, but supplies no inspectable after-fix terminal artifact, linked run, recording, or redacted runtime log; the available evidence is test-only. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body describes test and CI execution, but supplies no inspectable after-fix terminal artifact, linked run, recording, or redacted runtime log; the available evidence is test-only. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Focused test-only change: The branch adds file-local fixture helpers that write an empty OpenClaw config and a supplied raw or JSON-stringified policy fixture; the changed helper is confined to a test module.
Existing registration owner remains unchanged: The production registration entry point constructs the Policy doctor checks once and registers each check; the PR does not touch this runtime owner.
Selected-suite declaration parity: The three changed modules contain the same 43, 42, and 45 it/test declarations at the PR base, PR head, and current main, respectively.
Findings None None.
Security None None.

How this fits together

The 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]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body describes test and CI execution, but supplies no inspectable after-fix terminal artifact, linked run, recording, or redacted runtime log; the available evidence is test-only. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The PR body reports focused and broad test runs, but it contains no inspectable terminal output, linked Testbox artifact, or redacted log demonstrating the refactored suite after the change.
  • Resolve merge risk (P1) - The local checkout could not retrieve missing promisor objects or GitHub discussion because network/DNS access was unavailable; review confidence is therefore limited to the inspected PR-head source and local history.
  • Complete next step (P2) - No mechanical repair is identified; protected-label review and contributor-supplied real proof are the remaining merge prerequisites.
Agent review details

Security

None.

PR surface

Source -747. Total -747 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 3 668 1415 -747
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 668 1415 -747

Review metrics

None.

Stored data model

Persistent data-model change detected: migration/backfill/repair: extensions/policy/src/doctor/register.base.test-utils.ts, migration/backfill/repair: extensions/policy/src/doctor/register.gateway-data-and-approvals.test-utils.ts, migration/backfill/repair: extensions/policy/src/doctor/register.models-and-mcp.test-utils.ts, serialized state: extensions/policy/src/doctor/register.base.test-utils.ts, serialized state: extensions/policy/src/doctor/register.gateway-data-and-approvals.test-utils.ts, serialized state: extensions/policy/src/doctor/register.models-and-mcp.test-utils.ts, and 3 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    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.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best 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.

Labels

Label changes:

  • add P3: This is a test-maintenance cleanup with no observed runtime or user-facing behavior change.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.

Label justifications:

  • P3: This is a test-maintenance cleanup with no observed runtime or user-facing behavior change.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

Likely related people:

  • Shakker: The current registerPolicyDoctorChecks implementation and shared test lifecycle trace to the commit that introduced these paths. (role: introduced current doctor registration and test-harness path; confidence: high; commits: c0104d567582; files: extensions/policy/src/doctor/register.ts, extensions/policy/src/doctor/register.test-harness.ts)
  • Peter Steinberger: Recent history for the affected Policy test modules includes prior test-suite splitting and Policy refactors, in addition to the current fixture-consolidation commit. (role: recent test-suite refactor contributor; confidence: medium; commits: 507038c456ce, f81f9d8570c3, d2e3c6354880; files: extensions/policy/src/doctor/register.models-and-mcp.test-utils.ts, extensions/policy/src/doctor/register.base.test-utils.ts, extensions/policy/src/doctor/register.gateway-data-and-approvals.test-utils.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach a redacted terminal transcript or linked Testbox artifact showing the focused Policy doctor suite on this exact head.
  • Let the in-progress exact-head checks complete and refresh the PR evidence if they expose a fixture regression.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Pre-merge proof for exact reviewed head d2e3c6354880c1b246335315ebc92c11367247d6:

  • Required hosted openclaw/ci-gate succeeded; complete exact-head CI run 30765129591 succeeded.
  • Focused proof: node scripts/run-vitest.mjs extensions/policy/src/doctor/register.test.ts --reporter=verbose — 300/300 passed; remote full Policy/MCP/security proof — 30/30 Vitest shards passed; remote pnpm check:changed passed.
  • Independent AST parity: 131 declarations, 201 expanded cases, 235 ordered assertions, all lifecycle hooks, and all 68 registered checks unchanged.
  • ClawSweeper's production/persistent-data classification is a false positive: all three changed .test-utils.ts modules are imported only by register.test.ts; production delta is 0, and no runtime, persisted state, migration, configuration, or operator behavior changes. A real product-setup demonstration is not applicable to this test-fixture-only refactor.

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.

@steipete
steipete merged commit 9187cfb into main Aug 2, 2026
147 of 150 checks passed
@steipete
steipete deleted the codex/goal100k-policy-doctor-fixture-wave19-2d45 branch August 2, 2026 20:25
@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 2, 2026
* 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)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 3, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 3, 2026
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant