Skip to content

fix(scheduler): count active runs by workflow path - #393

Merged
steipete merged 2 commits into
mainfrom
codex/fix-sweep-capacity-accounting
Jul 3, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/fix-sweep-capacity-accounting

Conversation

@steipete

@steipete steipete commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • identify active sweep, commit-review, and repair runs by stable workflow file path
  • keep dynamic run names only as display titles
  • use the REST run payload for backstop detection, with regression coverage for every affected planner

Why

Live verification after #392 exposed that GitHub's REST name field now follows the dynamic run-name. The scheduler still compared it with the workflow's static name, so a normal 89-shard wave was not counted before a hot planner allocated its lane. The excess hot run was cancelled immediately.

Validation

  • pnpm run format
  • pnpm run check:limits
  • pnpm run build:all
  • node --test test/sweep-workflow.test.ts (37/37)
  • isolated Codex process tests (24/24)
  • autoreview: clean, no actionable findings

The complete local check passed 551/559 tests; its eight failures were Codex-process 10-second timeouts under the live 89-worker load. All eight passed when rerun in their two isolated test files.

Live failure evidence: https://github.com/openclaw/clawsweeper/actions/runs/28682959017

Live verification plan

The scheduled workflow executes from main, so the after-fix overlap proof is necessarily post-merge. On the exact green head, observe the next natural broad overlap and verify the planner counts active workflow-path runs and admits no more than the remaining 128-worker budget. Cancel the new wave immediately if that invariant fails.

After-merge proof

Verified on merged main commit 1343d8ec0cef4a5088be01084937fe4396cf9571.

  • Before the controlled normal overlap, 9 exact workers and 52 background shards were active.
  • The normal run requested 89 shards and logged Capping broad background review shards from 89 to scheduler allowance 1 after counting all overlapping fixed-head planners by workflow path.
  • The run created exactly 1 shard; three adjacent fixed-head normal planners also created 1 shard each.
  • A follow-up live count found 10 exact workers and 50 active background shards. Including the unchanged 24 fixed reserves, observed active use plus reserves was 84 of the unchanged 128-worker maximum; pending planners remained separately reserved and were therefore capped to one shard.

Proof run: https://github.com/openclaw/clawsweeper/actions/runs/28684426284

@steipete
steipete requested a review from a team as a code owner July 3, 2026 21:11
@clawsweeper

clawsweeper Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 3, 2026, 5:24 PM ET / 21:24 UTC.

Summary
This PR changes sweep and commit-review workflow active-run accounting and review backstop detection from dynamic workflow names to stable workflow file paths, with regression coverage in sweep workflow tests.

Reproducibility: yes. at source/API level: current main compares REST .name with static workflow names, while live run payloads show dynamic names and stable .path. I did not rerun a full overloaded 89-shard wave.

Review metrics: 3 noteworthy metrics.

  • Workflow files: 2 modified. Both live scheduler workflows calculate active capacity before dispatching review or commit-review work.
  • Scheduler surfaces: 3 planners/backstops touched. The sweep planner, commit-review planner, and review backstop all rely on the same active-run identity choice.
  • Regression tests: 1 added, 2 expanded. The test changes assert path-based run detection across the affected workflow blocks.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof 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 live Actions or terminal proof showing workflow-path accounting prevents the overlapping planner over-allocation.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body has local validation and before-fix Actions evidence, but no after-fix run proof; add redacted Actions logs, terminal output, screenshots, recordings, or linked artifacts that show the fixed accounting, redact private details such as IPs, API keys, phone numbers, and non-public endpoints, then update the PR body for automatic re-review or ask a maintainer to comment @clawsweeper re-review.

Risk before merge

  • [P1] The diff changes live workflow capacity accounting; if path filtering or backstop detection is wrong, ClawSweeper can still over-dispatch, under-dispatch, or cancel live review work despite green unit tests.
  • [P1] The PR body includes local validation and before-fix live failure evidence, but not after-fix live Actions proof showing the repaired scheduler accounting under an overlapping wave.

Maintainer options:

  1. Require live scheduler proof (recommended)
    Before merge, have the latest head demonstrate with redacted Actions logs, terminal output, or linked artifacts that overlapping sweep capacity is counted by workflow path and does not allocate an extra lane.
  2. Accept operator risk
    A maintainer can intentionally merge after reviewing current Actions behavior, Codex quota headroom, and the before-fix failure evidence.
  3. Pause until proof is practical
    If the repaired path cannot be exercised safely before merge, keep the PR open until the operator proof can be collected.

Next step before merge

  • [P1] Human/operator review remains because after-fix live scheduler proof cannot be supplied by an automated code repair.

Security
Cleared: No concrete security or supply-chain concern was found; the diff reuses existing GitHub CLI/API calls and does not add permissions, actions, dependencies, or secret handling.

Review details

Best possible solution:

Land the path-based active-run accounting with its focused tests after redacted live Actions proof shows the fixed scheduler behavior under the affected overlap path.

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

Yes at source/API level: current main compares REST .name with static workflow names, while live run payloads show dynamic names and stable .path. I did not rerun a full overloaded 89-shard wave.

Is this the best way to solve the issue?

Yes for the code path: comparing the REST workflow file path is the narrow stable identifier, and the PR covers the affected planners and tests. The merge decision still needs live after-fix proof because this is scheduler admission logic.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P1: This addresses a live scheduler regression where active review waves can be missed and hot ClawSweeper work can be cancelled immediately.
  • merge-risk: 🚨 automation: The PR changes live workflow admission and capacity accounting, so a mismatch can over-dispatch or under-dispatch ClawSweeper automation despite green unit tests.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body has local validation and before-fix Actions evidence, but no after-fix run proof; add redacted Actions logs, terminal output, screenshots, recordings, or linked artifacts that show the fixed accounting, redact private details such as IPs, API keys, phone numbers, and non-public endpoints, then update the PR body for automatic re-review or ask a maintainer to comment @clawsweeper re-review.
Evidence reviewed

What I checked:

  • Repository policy read and applied: AGENTS.md was read fully; its conservative workflow-review and automation-safety guidance applies to this scheduler PR. (AGENTS.md:1, 56431d2dedf3)
  • Current main still uses name-based run accounting: Current main collects REST .name into workflowName and compares it with static workflow names in the sweep scheduler, so the reported dynamic run-name problem is not already fixed on main. (.github/workflows/sweep.yml:964, 56431d2dedf3)
  • Current commit-review planner has the same name-based path: Current main's commit-review planner also reads .name as workflowName and uses static name comparisons when calculating active workers. (.github/workflows/commit-review.yml:174, 56431d2dedf3)
  • Live REST payload confirms the mismatch: Live Actions runs from this repository show name following the dynamic run title, such as Review event item openclaw/openclaw#99653, while path remains .github/workflows/sweep.yml.
  • PR head switches sweep accounting to workflow paths: The latest PR head collects .path as workflowPath and counts sweep, commit-review, and repair workflows by file path in the sweep planner. (.github/workflows/sweep.yml:964, 79d6913e7e4f)
  • PR head updates commit-review accounting: The latest PR head applies the same workflowPath accounting to commit-review page-size planning. (.github/workflows/commit-review.yml:174, 79d6913e7e4f)

Likely related people:

  • steipete: Authored and merged the recent capacity-refill change in [codex] refill 128-worker review capacity #392 that this PR directly follows up on, including edits to the sweep capacity accounting surface. (role: recent area contributor; confidence: high; commits: 56431d2dedf3; files: .github/workflows/sweep.yml, test/sweep-workflow.test.ts)
  • RomneyDa: PR 324 introduced the split workflow files and the active-run accounting blocks that current main still uses. (role: introduced behavior; confidence: medium; commits: 6035f230849b; files: .github/workflows/sweep.yml, .github/workflows/commit-review.yml, test/sweep-workflow.test.ts)
  • vincentkoc: Recent merged CI fanout and GitHub API pressure work touched the same workflow scheduling and capacity surface before the latest refill. (role: recent adjacent contributor; confidence: medium; commits: 1566ad6a0a5b, f69d9debf487; files: .github/workflows/sweep.yml, .github/workflows/commit-review.yml, docs/limits.md)
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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 220e340fd6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

active_run_count() {
printf '%s' "$ACTIVE_RUNS_JSON" \
| WORKFLOW_NAME="$1" STALE_QUEUED_CUTOFF="$STALE_QUEUED_CUTOFF" jq '[.[] | select(.workflowName == env.WORKFLOW_NAME) | select(.status == "in_progress" or ((.status == "pending" or .status == "queued" or .status == "waiting" or .status == "requested") and ((.updatedAt // .createdAt // "") >= env.STALE_QUEUED_CUTOFF)))] | length' 2>/dev/null \
| WORKFLOW_PATH="$1" STALE_QUEUED_CUTOFF="$STALE_QUEUED_CUTOFF" jq '[.[] | select(.workflowPath == env.WORKFLOW_PATH) | select(.status == "in_progress" or ((.status == "pending" or .status == "queued" or .status == "waiting" or .status == "requested") and ((.updatedAt // .createdAt // "") >= env.STALE_QUEUED_CUTOFF)))] | length' 2>/dev/null \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Normalize workflow run paths before comparing

When GitHub returns the documented REST workflow-run path with a ref suffix like .github/workflows/build.yml@main, this exact equality rejects every active run even when it is the intended workflow. In active sweep/repair/commit-review environments, the scheduler (and the same exact comparisons added below and in commit-review.yml) will still count zero active workers/backstops and can over-allocate until waves are cancelled; strip the @... suffix or query the workflow-specific endpoint before comparing.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 Urgent regression or broken agent/channel workflow affecting real users now. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Jul 3, 2026
@steipete
steipete merged commit 1343d8e into main Jul 3, 2026
7 checks passed
@steipete
steipete deleted the codex/fix-sweep-capacity-accounting branch July 3, 2026 21:29
azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
fix(scheduler): count active runs by workflow path
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. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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.

1 participant