Skip to content

feat(delegate): worker+auditor orchestration loop (piece #4 of 4) - #358

Merged
jobordu merged 1 commit into
mainfrom
nf/quick-delegate-loop-piece4
Jul 8, 2026
Merged

jobordu merged 1 commit into
mainfrom
nf/quick-delegate-loop-piece4

Conversation

@jobordu

@jobordu jobordu commented Jul 8, 2026

Copy link
Copy Markdown

What (piece #4 of 4 — completes the primitive)

Ties pieces #1–3 into one delegated step:

  1. Worker (resumable session) implements the step goal, editing files.
  2. Capture + persist the worker session id (store, Error: Cannot find module './conformance-schema.cjs' #2).
  3. Auditor (fresh, independent, read-only) reviews the git diff (Add Windows support with CI/CD testing #3).
  4. Decide — APPROVE → accept; REVISE → send the issues back to the same worker session and re-audit (up to maxRevisions); BLOCK → stop.

API (bin/delegate-loop.cjs)

  • pure: decideNext(verdict, revisions, max), buildRevisePrompt(issues, goal)
  • impure: gitDiff(cwd), runDelegatedStep(...) — every subprocess/IO dep is injectable → the whole loop is unit-tested without a live model.
  • CLI: node bin/delegate-loop.cjs --task-key X --goal "…" --worker codex --auditor claude --cwd .

Proven end-to-end with REAL models

Gave a codex worker a buggy sum.js (return a - b). The loop ran worker → auditor(REVISE) → worker RESUMED with the issues → auditor(APPROVE) → accepted. Final file: return a + b; the independent claude auditor's own words: "correctly changes add to return a + b with no unrelated changes or regressions." — i.e. the revise cycle itself fired live.

Tests

12 unit tests (decide logic, revise-resumes-the-same-session, exhausted-at-cap, block, worker-error-skips-audit), gated in test:ci.

The delegation primitive is now complete

Pieces #1–4 give a runnable, tested long-running cross-LLM worker+auditor loop. The last mile — wiring it into nf:quick --delegate / nf:solve remediation — is a follow-up skill integration.

🤖 Generated with Claude Code

Ties pieces #1-3 into one delegated step:
  1. WORKER (resumable session) implements the step goal, editing files.
  2. Capture + persist the worker session id (store).
  3. AUDITOR (fresh, independent, read-only) reviews the git diff.
  4. DECIDE — APPROVE -> accept; REVISE -> send the issues back to the SAME worker
     session and re-audit (up to maxRevisions); BLOCK -> stop.

bin/delegate-loop.cjs:
- decideNext(verdict, revisions, max) / buildRevisePrompt(issues, goal) — PURE.
- gitDiff(cwd) — unified diff of the working tree (IMPURE).
- runDelegatedStep(...) — the worker<->auditor cycle for one step; every subprocess/IO
  dependency is injectable, so the whole loop is unit-tested without a live model.
- CLI entrypoint: node bin/delegate-loop.cjs --task-key X --goal "..." --worker codex
  --auditor claude --cwd .

Proven end-to-end with REAL models: gave a codex worker a buggy sum.js (return a - b);
the loop ran worker -> auditor(REVISE) -> worker RESUMED with the issues -> auditor
(APPROVE) -> accepted. Final file: return a + b; independent claude auditor: "correctly
changes add to return a + b with no unrelated changes or regressions." 12 unit tests
(decide logic, revise-resumes-same-session, exhausted, block, worker-error), gated in
test:ci.

Task #49. Completes the worker+auditor delegation primitive; skill wiring
(nf:quick --delegate / nf:solve) is the remaining last-mile integration.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 8, 2026 10:05
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@jobordu, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 8 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5c8115a5-b09c-418d-9468-1f4b3593dc11

📥 Commits

Reviewing files that changed from the base of the PR and between 6894fa7 and ac81ba7.

📒 Files selected for processing (3)
  • bin/delegate-loop.cjs
  • bin/delegate-loop.test.cjs
  • package.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch nf/quick-delegate-loop-piece4

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI 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.

Pull request overview

Completes the delegation “primitive” by adding a worker→auditor orchestration loop that can iterate revisions using the same worker session, plus unit tests and CI wiring so the loop can be tested without calling real models.

Changes:

  • Add bin/delegate-loop.cjs implementing decideNext, buildRevisePrompt, gitDiff, and runDelegatedStep, plus a small CLI wrapper.
  • Add bin/delegate-loop.test.cjs covering accept/block/revise/exhausted paths and “resume same session” behavior with injected fakes.
  • Include the new test in the test:ci script.

Reviewed changes

Copilot reviewed 1 out of 3 changed files in this pull request and generated no comments.

File Description
package.json Adds bin/delegate-loop.test.cjs to CI test run.
bin/delegate-loop.cjs New worker+auditor orchestration loop and CLI entrypoint.
bin/delegate-loop.test.cjs New unit tests for decision logic and revision/resume behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jobordu
jobordu merged commit de86fbb into main Jul 8, 2026
17 checks passed
@jobordu
jobordu deleted the nf/quick-delegate-loop-piece4 branch July 8, 2026 10:15
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.

2 participants