Skip to content

refactor(policy): split doctor evaluator modules - #106313

Merged
steipete merged 3 commits into
mainfrom
codex/refactor-policy-doctor-register
Jul 13, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/refactor-policy-doctor-register

Conversation

@steipete

@steipete steipete commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes #106295

What Problem This Solves

extensions/policy/src/doctor/register.ts had grown to roughly 5,600 lines and mixed registration, evaluation orchestration, policy-shape parsing, scoped-policy handling, evidence checks, sandbox checks, and runtime/file helpers. Routine maintenance required navigating one oversized module with many unrelated responsibilities.

Why This Change Was Made

Split the implementation into focused owner modules while retaining register.ts as the stable registration and public-export facade. Runtime shapes, policy shapes, metadata, access findings, ingress findings, agent-workspace findings, evaluation, and scope orchestration now have explicit owners. Every changed production TypeScript file is at most 498 lines, with no compatibility barrel or duplicate implementation path.

A declaration-normalization comparison preserves all 213 original declaration bodies with no missing, extra, or mismatched declarations. Registration order, finding order, cache ownership, repair hooks, and public exports remain unchanged.

No config, protocol, storage, SDK, dependency, or user-visible behavior changes.

AI-assisted: yes (Codex). Fresh final-head autoreview reported no accepted/actionable findings at 0.98 confidence.

User Impact

No user-visible behavior change. Policy-doctor maintenance now happens in smaller, focused files with clearer dependency boundaries.

Evidence

  • Exact head 72abe2f92a344d3a4d61a2a8799dcee0180bb350 on Blacksmith Testbox tbx_01kxe4v31bfjd8vbkec5zkkhyz: corepack pnpm test extensions/policy — 6 files, 344 tests passed.
  • Same exact head/Testbox: corepack pnpm tsgo:extensions, corepack pnpm tsgo:extensions:test, corepack pnpm lint:extensions, corepack pnpm check:import-cycles, and full-PR corepack pnpm check:loc --base HEAD~3 --head HEAD — passed; 0 runtime value cycles and 34 production files checked by the LOC ratchet.
  • Mechanical declaration comparison: 213/213 declaration bodies preserved after normalization, with no missing, extra, or mismatched declarations.
  • Real doctor --lint --only policy/policy-jsonc-missing --json comparison on Testbox tbx_01kxe2r09q81ny0jvxqavm5t9w: base/head output byte-identical, SHA-256 61f6feed447705651f542361e2e7fa93e5af66566f0d35547b79651f294efb00; subsequent splits are declaration-equivalent extractions.
  • Hosted exact-head LOC and dependency gates passed. Remaining hosted gates are handled by the repo-native landing workflow.

@steipete steipete self-assigned this Jul 13, 2026
@steipete

steipete commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 72abe2f92a344d3a4d61a2a8799dcee0180bb350:

  • Blacksmith Testbox tbx_01kxe4v31bfjd8vbkec5zkkhyz: corepack pnpm test extensions/policy — 6 files, 344 tests passed.
  • Same exact head/Testbox: extension production and test type checks, extension lint, import-cycle check, and full-PR LOC ratchet passed. The ratchet checked 34 changed production files; the largest changed policy-doctor module is 498 lines.
  • Declaration-normalization comparison: 213/213 original declaration bodies preserved; no missing, extra, or mismatched declarations.
  • Real policy-doctor CLI comparison on Testbox tbx_01kxe2r09q81ny0jvxqavm5t9w: base/head JSON output byte-identical, SHA-256 61f6feed447705651f542361e2e7fa93e5af66566f0d35547b79651f294efb00. Later file splits preserve those declaration bodies exactly after normalization.
  • Fresh final-head autoreview: no accepted/actionable findings, 0.98 confidence.
  • Hosted exact-head LOC and dependency gates: passed. Repo-native prepare/merge gates remain authoritative.

No config, protocol, storage, SDK, dependency, or user-visible behavior change. No changelog entry: internal refactor.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 13, 2026
@clawsweeper

clawsweeper Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 13, 2026, 8:25 AM ET / 12:25 UTC.

Summary
The branch extracts policy-doctor parsing, scope, runtime, shape-validation, finding, and evaluation logic into focused modules while retaining register.ts as the registration and export facade.

PR surface: Source +236. Total +236 across 15 files.

Reproducibility: not applicable. This PR is a behavior-preserving structural refactor rather than a report of broken runtime behavior.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: migration/backfill/repair: extensions/policy/src/doctor/access-findings.ts, migration/backfill/repair: extensions/policy/src/doctor/access-shapes.ts, migration/backfill/repair: extensions/policy/src/doctor/data-auth-findings.ts, migration/backfill/repair: extensions/policy/src/doctor/exec-approval-findings.ts, migration/backfill/repair: extensions/policy/src/doctor/exec-approval-rules.ts, migration/backfill/repair: extensions/policy/src/doctor/policy-constants.ts, and 34 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #106295
Summary: This PR is the explicit implementation candidate for the paired refactor issue and no separate competing root cause is established.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🦞 diamond lobster
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted terminal or linked-artifact proof comparing representative real openclaw doctor --lint findings on the base and rebased branch; redact private paths, endpoints, credentials, and other identifying data.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The Testbox tests and static checks are strong supplemental evidence, but an external PR still needs redacted after-change output from a representative real openclaw doctor --lint run; after adding it, updating the PR body should trigger review, or a maintainer can request @clawsweeper re-review. 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.

Risk before merge

  • [P1] The branch is behind current main, so the declaration-equivalence and import-cycle results do not prove the eventual three-way merge result remains a mechanical extraction.
  • [P1] The submitted evidence exercises tests and static gates but does not show a representative real openclaw doctor --lint invocation producing equivalent findings before and after the refactor.

Maintainer options:

  1. Decide the mitigation before merge
    Land the extraction only after rebasing onto current main, preserving the facade, export, evaluation-order, cache, and hook-registration invariants, and demonstrating equivalent findings through a representative real doctor invocation.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] A maintainer should review the refreshed merge result after a current-main rebase and require representative real doctor output; there is no narrow code defect for an automated repair worker.

Security
Cleared: The extraction adds no dependency, workflow, permission, secret-handling, download, package-resolution, or other concrete supply-chain or security-boundary change.

Review details

Best possible solution:

Land the extraction only after rebasing onto current main, preserving the facade, export, evaluation-order, cache, and hook-registration invariants, and demonstrating equivalent findings through a representative real doctor invocation.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR is a behavior-preserving structural refactor rather than a report of broken runtime behavior.

Is this the best way to solve the issue?

Yes, conceptually: retaining one registration/export facade while extracting cohesive evaluator owners is the narrowest maintainable solution, provided current-main equivalence and real doctor behavior are confirmed.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 35fb5ee81ac6.

Label changes

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦞 diamond lobster.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The Testbox tests and static checks are strong supplemental evidence, but an external PR still needs redacted after-change output from a representative real openclaw doctor --lint run; after adding it, updating the PR body should trigger review, or a maintainer can request @clawsweeper re-review. 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.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: 📣 needs proof.

Label justifications:

  • P3: This is a maintenance-only module extraction with no intended user-visible behavior change or urgent runtime impact.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦞 diamond lobster.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The Testbox tests and static checks are strong supplemental evidence, but an external PR still needs redacted after-change output from a representative real openclaw doctor --lint run; after adding it, updating the PR body should trigger review, or a maintainer can request @clawsweeper re-review. 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

PR surface:

Source +236. Total +236 across 15 files.

View PR surface stats
Area Files Added Removed Net
Source 15 5791 5555 +236
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 15 5791 5555 +236

What I checked:

Likely related people:

  • steipete: The paired maintainer-labeled issue is assigned to this account, the account prepared the focused extraction, and the supplied repository history shows continuing ownership of policy and structural refactor work; routing confidence is limited because independent line-level history could not be established in this review environment. (role: adjacent owner and refactor driver; confidence: medium; commits: 2b6e45896ea7; files: extensions/policy/src/doctor/register.ts, extensions/policy/src/doctor/evaluation.ts, extensions/policy/src/doctor/policy-shape.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-13T12:11:05.354Z sha 2b6e458 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 13, 2026
@steipete
steipete force-pushed the codex/refactor-policy-doctor-register branch 2 times, most recently from 8cf482c to ac45cac Compare July 13, 2026 16:19
@steipete
steipete force-pushed the codex/refactor-policy-doctor-register branch from ac45cac to 72abe2f Compare July 13, 2026 16:26
@steipete
steipete merged commit d8fb5b4 into main Jul 13, 2026
103 checks passed
@steipete
steipete deleted the codex/refactor-policy-doctor-register branch July 13, 2026 16:35
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 14, 2026
* refactor(policy): split doctor evaluator modules

* refactor(policy): split runtime shape owners

* refactor(policy): split doctor policy domains
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: policy maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor policy doctor registration into focused modules

1 participant