Skip to content

fix: scope per-target state hydration - #938

Merged
steipete merged 1 commit into
mainfrom
fix/scoped-review-hydration
Jul 29, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/scoped-review-hydration

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • scope canonical record hydration to the target repository for 18 per-target or batch-selected workflow call sites
  • retain Worker repository discovery for the seven fleet-wide or pre-target-resolution lanes that need it
  • skip the unrelated full ledger/v1 and assets R2 download at all 25 workflow setup-state callers
  • lock the scope split into workflow-shape tests and document the operational fix in the changelog

Root cause

An empty records-repo-slugs input makes both snapshot-cache preparation and hydrate-state discover every repository in the canonical Worker store. materializeWorkerRecords then hydrates each discovered slug sequentially. After #937 raised exact-review concurrency, every exact-item publication run repeated that roughly 120-slug sequence through the same Worker/DO path.

Live evidence matched the code path: a queue snapshot showed 30 exact-item runs simultaneously in progress and no exact-item completion among the latest 100 runs. In https://github.com/openclaw/clawsweeper/actions/runs/30449281061 the actual review completed in 70 seconds, then setup-state remained in progress from 11:54 UTC onward.

Setup-state classification

Class Call sites Records behavior Blob behavior
Target-scoped commit review commit-review.yml: plan, review, publish target slug skip
Selected exact-review batch exact-review-batch-publish.yml: publish sorted unique slugs from the claimed batch skip
Target-scoped repair/support proof nudges; cluster intake; comment router; commit-finding intake; conflict self-heal; issue-implementation intake; spam scanner target slug skip
Target-scoped sweep exact event review apply/publish; plan; review publish; failed-review retry; apply proof; apply existing target slug skip
Pre-target repair repair cluster worker plan/execute; repair result publisher discovery because the repository is resolved from the hydrated job or downloaded result artifact skip
Fleet repair finalize open PRs; repair self-heal discovery skip
Fleet sweep target fanout/coverage; audit dashboard discovery skip

The slug derivation mirrors canonical record storage: trim/lowercase the owner/name, then replace the slash or other non-[a-z0-9_.-] separators with -. Batch publication calls the shared normalizeRepo + slugForRepo helpers directly.

Expected impact

Exact-item setup drops from roughly 120 serial repository hydrations to one, a 99.2% reduction per run. At 33 concurrent reviews that changes the hot path from roughly 3,960 slug hydration sequences to 33, while also eliminating the full R2 ledger/assets tree download. Once the existing DO backlog drains, per-review hydration should return to seconds rather than 60-90+ minutes.

Proof

  • node --test test/state-writer-workflow.test.ts test/sweep-workflow.test.ts test/clawsweeper.test.ts test/review-reliability-workflow.test.ts test/repair/exact-review-batch-workflow.test.ts test/repair/gitcrawl-store.test.ts test/repair/repair-cluster-worker-containment.test.ts — 188 passed
  • pnpm run check — formatting, all TypeScript builds, all lint targets, and coverage thresholds passed; the macOS run reached 2,755 passes and hit five unrelated Linux containment harness failures because Apple libc does not export capset
  • $HOME/.claude/skills/autoreview/scripts/autoreview --mode local — clean, no accepted/actionable findings

This PR intentionally does not change Worker serialization or the full-fleet discovery contract; it removes unnecessary callers from that path.

@steipete
steipete requested a review from a team as a code owner July 29, 2026 12:33
@steipete
steipete merged commit e27b574 into main Jul 29, 2026
13 checks passed
@steipete
steipete deleted the fix/scoped-review-hydration branch July 29, 2026 12:39
azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant