Skip to content

feat(loop): cross-repo auto mode with work-source and drain-complete - #115

Merged
androidand merged 19 commits into
devfrom
loop-wip-reconcile
Oct 3, 2026
Merged

androidand merged 19 commits into
devfrom
loop-wip-reconcile

Conversation

@androidand

Copy link
Copy Markdown
Owner

Adds cross-repo auto mode (runAuto) with a work-source that discovers repos under a root, per-repo gate options, capacity-bounded concurrency, an environmental guard for consecutive halts, and a claim lifecycle.

  • packages/opencode/src/loop/spec-queue/work-source.ts: repo discovery and claim lifecycle
  • packages/opencode/src/loop/loop.ts: runAuto, autoDirectory and autoRepos fields
  • packages/opencode/src/cli/cmd/loop.ts: --auto, --repos, --directory flags
  • packages/opencode/src/loop/crew/route.ts: routing decision function
  • packages/sdk/js/src/v2/gen: regenerated SDK types
  • tests: auto-mode, work-source, cross-repo-config, crew/route

Rebased onto origin/dev (899266b). Typechecks clean in a proper environment; the worktree symlink to the main repo causes an unrelated PluginInput type error only there.

- 5 tests covering disk fallback, synced repo exclusion, empty dir,
  missing openspec dir, and sibling discovery
- Fix querySpecsync to handle specsync returning null (not []) for
  empty results
- Add fs.existsSync check in runAuto loop; items with missing repos
  are recorded as 'skipped' with cause 'repo not found'
- Exclude skipped outcomes from ChangeOutcome[] (type only allows
  completed|quarantined)
- Add test verifying a resolvable item starts a run and completes
- Add capacity() helper that probes local providers via parentCapacity,
  returning max(1, free) to bound concurrent item processing
- Replace sequential for loop with worker pool bounded by capacity
- Add runningRepos per-repo exclusivity guard (one run per repo at a time)
- Add tests: 'concurrency follows the fleet' and 'one working tree, one run'
- Track haltsThisPass per pass in processItem
- Accumulate consecutiveHalts across passes when no gate passes
- Reset consecutiveHalts when a gate passes or a pass has no halts
- Stop run with stalled status when consecutiveHalts >= 3
- Report suspected environmental cause in the run report
- Add tests: one bad item among five, three identically broken items

All 257 loop tests pass, typecheck clean.
- Add claimedItems set to track which items have been claimed
- Claim items via claimChange before running gates
- Release claims in finally block via releaseChange
- Gate loop checks status at each iteration, so cancelled runs
  break out and release claims
- Add test: cancel stops the run and releases claims

All 258 loop tests pass, typecheck clean.
- Add mode === 'auto' to fenced condition
- Previously auto runs were only fenced when policy was 'scoped'
- Add test: authority ceiling is inherited and not widened

All 259 loop tests pass, typecheck clean.
- Report generation in runAuto builds a multi-line report from outcomes
- Each item listed with repo, change, and outcome (completed/HALTED/SKIPPED)
- Environmental guard report also includes aggregated outcomes
- Add test: aggregated report covers all items

All 260 loop tests pass, typecheck clean.
- Added everFoundItems flag to track whether any items were ever found
- If no items found and no outcomes exist, run ends with 'nothing found'
  report instead of 'drained'
- Add test: distinguishes drained from found nothing

All 261 loop tests pass, typecheck clean.
- Added --auto flag to opencode loop with documentation
- Documents that auto is fenced with QueueDenyRules
- Documents where work comes from (work source: specsync or local openspec)
- runAuto already uses getWorkItems which uses the work source

All 261 loop tests pass, typecheck clean.
- Added test: two-repository fixture drains to completion
- Creates two fixture repos with changes, runs auto mode
- Verifies both complete and report mentions both changes

All 262 loop tests pass, typecheck clean.
- Added test: halt path end-to-end
- Creates two fixture repos: one halts, other completes
- Verifies report names both changes

All 263 loop tests pass, typecheck clean.
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@androidand
androidand merged commit 8b93575 into dev Oct 3, 2026
3 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant