Skip to content

refactor: extract scheduler policy - #383

Merged
steipete merged 2 commits into
openclaw:mainfrom
brokemac79:codex/extract-stable-units
Jul 4, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
brokemac79:codex/extract-stable-units

Conversation

@brokemac79

@brokemac79 brokemac79 commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Scheduler policy lived inside the large CLI module, coupling pure candidate-selection decisions to orchestration and making behavior-preserving scheduler changes harder to review and test.

Why This Change Was Made

Extract the stable scheduler policy into src/scheduler-policy.ts. The CLI still owns GitHub I/O and orchestration; the new module owns pure capacity, ordering, floor-backfill, and partition decisions. Runtime exports are limited to production callers, while tests exercise the pure helpers directly.

User Impact

No intended scheduling behavior change. The scheduler keeps the same selection order, capacity rules, floor backfill, and shard partitioning with a smaller owner boundary.

Evidence

  • Rebased on current main at d20cf36edb6bbcd499e2e1980e88e8ecc77e7f1b.
  • Deterministic equivalence harness: 5,000 randomized inputs / 30,000 assertions against the pre-extraction implementation.
  • Focused scheduler suite: 12/12 passing.
  • pnpm run build, full pnpm run lint, pnpm run format:check, and git diff --check: passing.
  • Whole-branch autoreview: clean at 0.88 confidence.
  • Live read-only plan against openclaw/openclaw: 22 shards, 66 selected items, 93 due backlog, 22 active Codex targets; saturated-capacity decision preserved.
  • Production diff: 351-line policy module replaces 335 lines in the CLI; net +31 production lines, with no second runtime path or compatibility facade.

@clawsweeper

clawsweeper Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 4, 2026, 12:24 AM ET / 04:24 UTC.

Summary
This PR extracts scheduler policy helpers and types from src/clawsweeper.ts into src/scheduler-policy.ts and updates the focused scheduler tests to import the new module directly.

Reproducibility: not applicable. This PR is a refactor rather than a bug report. The relevant confidence check is behavior equivalence, and the PR body provides tests plus a live scheduler plan result.

Review metrics: 2 noteworthy metrics.

  • Files changed: 3 files affected. The diff is narrow but centered on scheduler automation and its focused test coverage.
  • Production extraction: 1 new module, 1 CLI integration changed. The production change moves scheduler policy out of the large CLI without adding a second runtime path.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

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

Rank-up moves:

  • none.

Risk before merge

  • [P1] This code controls review planning, candidate ranking, floor backfill, hot-intake ordering, and saturated-scan stopping; behavior drift would affect ClawSweeper automation after merge.

Maintainer options:

  1. Merge after scheduler-owner review (recommended)
    Maintainers can accept the automation risk if the moved code, focused tests, equivalence evidence, and live plan result are enough proof for this refactor.
  2. Ask for broader equivalence proof
    If maintainers want more confidence, request before/after scheduler plan output that covers non-saturated, saturated, hot-intake, and floor-backfill paths before merge.
  3. Pause the module split
    If the scheduler boundary is not worth changing now, pause or close this PR and revisit during the next scheduler behavior change.

Next step before merge

  • [P2] There is no narrow automated repair target; maintainer review should decide whether the scheduler automation risk is acceptable before merge.

Security
Cleared: The diff moves TypeScript scheduler code and tests; it does not change dependencies, workflows, secrets, permissions, install scripts, or package execution paths.

Review details

Best possible solution:

Land the extraction after scheduler/automation review confirms the module boundary preserves selection behavior and the proof is enough for this core scheduling path.

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

Not applicable; this PR is a refactor rather than a bug report. The relevant confidence check is behavior equivalence, and the PR body provides tests plus a live scheduler plan result.

Is this the best way to solve the issue?

Yes; extracting pure scheduler helpers while keeping orchestration in the CLI is a narrow maintainability path. The remaining decision is whether maintainers accept the scheduler automation risk before merge.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P3: This is an internal refactor with no intended user-visible behavior change.
  • merge-risk: 🚨 automation: The moved policy controls automated review selection and scheduling decisions, where subtle drift could affect ClawSweeper automation.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes an after-extraction live read-only scheduler plan result plus focused tests/checks for this non-visual CLI refactor.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes an after-extraction live read-only scheduler plan result plus focused tests/checks for this non-visual CLI refactor.
Evidence reviewed

What I checked:

  • Repository policy read: AGENTS.md was read fully; its narrow, evidence-backed, automation-safe guidance applies because this PR touches ClawSweeper scheduling automation. (AGENTS.md:1, d20cf36edb6b)
  • PR diff scope: The PR changes three files: the CLI scheduler integration, a new scheduler policy module, and the focused scheduler test. (675a899bc773)
  • Scheduler module added: The new module owns scheduler item/review types, cadence checks, priority, bucket selection, candidate ordering, floor backfill, hot-intake ordering, and saturated-plan stopping. (src/scheduler-policy.ts:1, 675a899bc773)
  • CLI imports extracted policy: The PR head imports the scheduler helpers from ./scheduler-policy.js while leaving the CLI orchestration in src/clawsweeper.ts. (src/clawsweeper.ts:53, 675a899bc773)
  • Focused tests updated: The scheduler policy test imports the new module and keeps local adapters for candidate selection and floor backfill assertions. (test/scheduler-policy.test.ts:4, 675a899bc773)
  • Current main behavior source: Current main still has the scheduler policy inline in src/clawsweeper.ts, including cadence, selection, backfill, and saturated-scan helpers that the PR extracts. (src/clawsweeper.ts:5292, d20cf36edb6b)

Likely related people:

  • steipete: GitHub commit metadata and git history show prior scheduler fairness and saturated-plan work, and this PR includes a follow-up commit by this person removing runtime-only test helper exports. (role: scheduler behavior owner and recent PR committer; confidence: high; commits: 3ac50a858db3, 34154292b7b2, 675a899bc773; files: src/clawsweeper.ts, src/scheduler-policy.ts)
  • RomneyDa: GitHub commit metadata shows the focused scheduler policy test file was introduced by the scheduler/review-comment test split. (role: focused test area contributor; confidence: high; commits: 929e605da559; files: test/scheduler-policy.test.ts)
  • brokemac79: Current-main history shows recent adjacent work in src/clawsweeper.ts around apply queue automation before this PR. (role: recent adjacent automation contributor; confidence: medium; commits: 5bdf6f31c904; files: src/clawsweeper.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.

@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. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Jul 1, 2026
@brokemac79

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. 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. and removed 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. labels Jul 1, 2026
@steipete steipete self-assigned this Jul 4, 2026
@steipete
steipete force-pushed the codex/extract-stable-units branch from 2ce2445 to 675a899 Compare July 4, 2026 04:15
@steipete

steipete commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Land-ready maintainer proof for 675a899bc773098039f4c2485a075f03f3e33a71:

  • Rebased on current main (d20cf36edb6bbcd499e2e1980e88e8ecc77e7f1b).
  • Removed test-only compatibility exports from the production CLI and imported the pure scheduler helpers directly in the focused tests.
  • Deterministic equivalence harness: 5,000 randomized inputs and 30,000 before/after assertions, all equivalent.
  • node --test test/scheduler-policy.test.ts: 12/12 passing.
  • pnpm run build, full pnpm run lint, pnpm run format:check, and git diff --check: passing.
  • Whole-branch autoreview: no actionable findings (0.88 confidence).
  • Live read-only plan: 22 shards, 66 selected items, 93 due backlog, 22 active Codex targets; saturated-capacity decision preserved.
  • Exact-head CI: CI 28694618678 and CodeQL 28694618690 are green.

No known proof gaps remain for this behavior-preserving extraction.

@steipete
steipete merged commit e95da70 into openclaw:main Jul 4, 2026
8 checks passed
azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
* refactor: extract scheduler policy

* refactor(scheduler): keep test helpers out of runtime

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. proof: sufficient Contributor real behavior proof is sufficient. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants