Skip to content

feat(batch): per-stage agent routing and stacked PR grouping - #94

Closed
joctaTorres wants to merge 1 commit into
mainfrom
apply-batch
Closed

joctaTorres wants to merge 1 commit into
mainfrom
apply-batch

Conversation

@joctaTorres

Copy link
Copy Markdown
Owner

Summary

Delivers the per-stage-agents-and-prs batch — three vertical-slice phases that let a batch drive different coding agents per lifecycle stage and open pull requests in configurable groupings.

Phase 1 — per-stage agent routing

The agent setting accepts a scalar or a partial {propose, apply, verify} stage-map at both project-config and manifest scope. Resolution merges nearest-wins per stage (mapped → scalar → default) and the engine resolves the adapter per transition. Invalid stage keys, non-string values, and unknown agent names are rejected before any spawn.

Phase 2 — whole-batch PR opening

prGrouping: whole-batch spawns a dedicated instruction-following PR agent at batch completion that commits accumulated work (repo git-log style, semantic by default) and opens one PR via the self-contained pr-open workflow. Adds pr as a fourth routable stage. No forge-specific code in ratchet; idempotent on rerun via per-group run-state; failures surface as reported step failures; doctor warns when grouping is active but no git remote is configured.

Phase 3 — stacked PR grouping modes

per-phase / per-change open one stacked PR per unit (group 0 → batch base, group N → group N-1's branch). The engine spawns one PR agent per detected boundary with the resolved stacked base injected as instruction data, keyed per group so a resumed loop never double-opens; batch apply surfaces and routes the per-boundary PR steps.

Config

batch:
  agent:
    propose: claude
    apply: opencode
    verify: opencode
    pr: claude
  prGrouping: per-phase   # off (default) | whole-batch | per-phase | per-change

Also settable via ratchet batch config --set <key=value> (scalars) and inspectable with ratchet batch config <name> --json.

Verification

  • Full suite green: 199 files / 2678 tests
  • Line coverage 95.51% (≥ 95 gate)
  • Typecheck clean
  • Phase-3 e2e proof test/cli-e2e/batch-pr-grouping-modes.test.ts → exit 0 (4/4); phase hard-gate proof-of-work passed

Docs (README + docs/) document the settings, the stacked-base rule, and carry vertical Mermaid overviews.

🤖 Generated with Claude Code

Let a batch drive different coding agents per lifecycle stage and open
pull requests in configurable groupings, across three phases:

- per-stage-agent-routing: the `agent` setting accepts a scalar or a
  partial `{propose, apply, verify}` stage-map at project-config and
  manifest scope; resolution merges nearest-wins per stage (mapped ->
  scalar -> default) and the engine resolves the adapter per transition.
  Invalid stage keys, non-string values, and unknown agent names are
  rejected before any spawn.

- whole-batch-pr-opening: `prGrouping: whole-batch` spawns a dedicated
  instruction-following PR agent at batch completion that commits the
  accumulated work (repo git-log style, semantic by default) and opens
  one PR via the self-contained pr-open workflow. Adds `pr` as a fourth
  routable stage. No forge-specific code in ratchet; idempotent on rerun
  via per-group run-state; failures surface as reported step failures;
  doctor warns when grouping is active but no git remote is configured.

- stacked-pr-grouping-modes: `per-phase` / `per-change` open one stacked
  PR per unit (group 0 -> batch base, group N -> group N-1's branch).
  The engine spawns one PR agent per detected boundary with the resolved
  stacked base injected as instruction data, keyed per group so a resumed
  loop never double-opens; `batch apply` surfaces and routes the
  per-boundary PR steps.

Docs (README + docs/) document the settings, the stacked-base rule, and
carry vertical Mermaid overviews. Full suite green; line coverage 95.51%.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
ratchet 503ca6b Commit Preview URL

Branch Preview URL
Jul 05 2026, 04:00 PM

@joctaTorres

Copy link
Copy Markdown
Owner Author

closed in favor of #95

@joctaTorres joctaTorres closed this Jul 7, 2026
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