Skip to content

Commit f37d8cd

Browse files
committed
ci: ignore stale queued runs in commit review capacity
1 parent beb5064 commit f37d8cd

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎.github/workflows/commit-review.yml‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,22 +169,23 @@ jobs:
169169
{
170170
for run_status in in_progress pending queued waiting requested; do
171171
gh api "repos/${{ github.repository }}/actions/runs?per_page=100&status=${run_status}" \
172-
--jq '.workflow_runs[] | {databaseId:.id, workflowName:.name, displayTitle:.display_title, status:.status}' 2>/dev/null \
172+
--jq '.workflow_runs[] | {databaseId:.id, workflowName:.name, displayTitle:.display_title, status:.status, createdAt:.created_at, updatedAt:.updated_at}' 2>/dev/null \
173173
|| true
174174
done
175175
} | jq -s 'unique_by(.databaseId)'
176176
}
177177
ACTIVE_RUNS_JSON="$(active_runs_json)"
178+
STALE_QUEUED_CUTOFF="$(date -u -d '6 hours ago' '+%Y-%m-%dT%H:%M:%SZ')"
178179
active_run_count() {
179180
printf '%s' "$ACTIVE_RUNS_JSON" \
180-
| WORKFLOW_NAME="$1" jq '[.[] | select(.workflowName == env.WORKFLOW_NAME) | select(.status == "in_progress" or .status == "pending" or .status == "queued" or .status == "waiting" or .status == "requested")] | length' 2>/dev/null \
181+
| 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 \
181182
|| printf '0'
182183
}
183184
active_sweep_background_workers() {
184185
local runs total id title status active_shards
185186
total=0
186187
runs="$(printf '%s' "$ACTIVE_RUNS_JSON" \
187-
| jq -r '.[] | select(.workflowName == "ClawSweeper") | select(.status == "in_progress" or .status == "pending" or .status == "queued" or .status == "waiting" or .status == "requested") | select(.displayTitle == "Review ClawSweeper items" or .displayTitle == "Review hot ClawSweeper items") | [.databaseId, .displayTitle, .status] | @tsv' 2>/dev/null || true)"
188+
| STALE_QUEUED_CUTOFF="$STALE_QUEUED_CUTOFF" jq -r '.[] | select(.workflowName == "ClawSweeper") | select(.status == "in_progress" or ((.status == "pending" or .status == "queued" or .status == "waiting" or .status == "requested") and ((.updatedAt // .createdAt // "") >= env.STALE_QUEUED_CUTOFF))) | select(.displayTitle == "Review ClawSweeper items" or .displayTitle == "Review hot ClawSweeper items") | [.databaseId, .displayTitle, .status] | @tsv' 2>/dev/null || true)"
188189
while IFS=$'\t' read -r id title status; do
189190
if [ -z "$id" ]; then
190191
continue
@@ -214,7 +215,7 @@ jobs:
214215
}
215216
active_sweep_exact_count() {
216217
printf '%s' "$ACTIVE_RUNS_JSON" \
217-
| jq '[.[] | select(.workflowName == "ClawSweeper") | select(.status == "in_progress" or .status == "pending" or .status == "queued" or .status == "waiting" or .status == "requested") | select(.displayTitle | startswith("Review event item "))] | length' 2>/dev/null \
218+
| STALE_QUEUED_CUTOFF="$STALE_QUEUED_CUTOFF" jq '[.[] | select(.workflowName == "ClawSweeper") | select((.status == "in_progress" or ((.status == "pending" or .status == "queued" or .status == "waiting" or .status == "requested") and ((.updatedAt // .createdAt // "") >= env.STALE_QUEUED_CUTOFF))) and (.displayTitle | startswith("Review event item ")))] | length' 2>/dev/null \
218219
|| printf '0'
219220
}
220221
if [ -z "$PAGE_SIZE" ]; then

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ checkpoint, and status-only commits are intentionally omitted.
5858
### Fixed
5959

6060
- Skipped open-but-locked repair apply targets before close or merge mutations and converted GitHub locked-conversation write denials into terminal skipped records. Thanks @AsishKumarDalal.
61+
- Kept stale queued workflow ghosts out of commit-review capacity probes after GitHub refuses to cancel old queued runs.
6162
- Required OpenClaw config-surface changes to pause automerge for maintainer review instead of emitting pass markers, with durable config-surface report metadata. Thanks @osolmaz.
6263
- Disabled automatic push-triggered commit review while keeping manual commit-review workflow dispatch available.
6364
- Treated target `AGENTS.md` files as optional repository-authored review policy

‎test/clawsweeper.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12651,6 +12651,9 @@ test("review capacity probes use REST actions run listing", () => {
1265112651
assert.match(block, /status=\$\{run_status\}/);
1265212652
assert.match(block, /workflowName:\.name/);
1265312653
assert.match(block, /displayTitle:\.display_title/);
12654+
assert.match(block, /createdAt:\.created_at/);
12655+
assert.match(block, /updatedAt:\.updated_at/);
12656+
assert.match(block, /STALE_QUEUED_CUTOFF/);
1265412657
assert.doesNotMatch(block, /gh run list/);
1265512658
}
1265612659
});
@@ -12676,6 +12679,8 @@ test("background review capacity reserves expanding matrices and caps broad manu
1267612679
assert.match(modeBlock, /Capping broad background review shards/);
1267712680
assert.match(commitBlock, /limit review_shards\.hot_intake_default/);
1267812681
assert.match(commitBlock, /limit review_shards\.normal_default/);
12682+
assert.match(commitBlock, /STALE_QUEUED_CUTOFF/);
12683+
assert.match(commitBlock, /updatedAt:\.updated_at/);
1267912684
});
1268012685

1268112686
test("sweep event reviews and target fanout avoid storm amplification", () => {

0 commit comments

Comments
 (0)