Skip to content

Worker-pool controller: queue client, worker, backlog, local review gate (phases 1,3,7)#1

Merged
Eyalm321 merged 6 commits into
mainfrom
feat/worker-pool-controller
Jun 15, 2026
Merged

Worker-pool controller: queue client, worker, backlog, local review gate (phases 1,3,7)#1
Eyalm321 merged 6 commits into
mainfrom
feat/worker-pool-controller

Conversation

@Eyalm321

Copy link
Copy Markdown
Owner

The worker-pool controller (phases 1, 3, 7) + a local subscription review gate. Branches off main (2451931); main untouched.

Included

  • Phase 1 — worktree-per-worker controller (src/worker-pool/): per task → git worktree addopen_pane worker → mint subtree-scoped token → dispatch → poll → teardown, with a concurrency cap and --dry-run.
  • Phase 3queue-client.ts repoints dispatch onto the Rust queue's HTTP routes; kinds.ts carries a strict zod RawTaskSchema byte-matching the Rust wire shape (camelCase / epoch-ms / flattened lease), pinned by a vendored task-wire.golden.json contract test.
  • Phase 7 — backlog generator (src/backlog/): TODO/FIXME scan + list sources → enqueue, with a --dry-run CLI.
  • Real worker bodyworker.ts runs a real agent via claude -p (Claude Code subscription) behind an injectable runner.
  • Local review gatereview.ts: after a worker succeeds, the controller reviews the diff with claude -p (subscription) and only merges on approve; block → nack review-blocked → failed. Fail-closed on missing/unauth claude, timeout, or unparseable output. Toggle via --no-review / HP_REVIEW.

Verification

  • tsc + vitest green (144 tests).
  • Live gate smoke with a real claude -p: a clean diff → approve (risk 3), a diff that guts a security test + exfiltrates a token → block (risk 10).

Notes

  • Everything runs on the Claude Code subscription — no ANTHROPIC_API_KEY, no metered API call anywhere.
  • The "failing-test" backlog source is an injectable seam (not yet wired to a real test-output parser).

🤖 Generated with Claude Code

Eyalm321 and others added 6 commits June 14, 2026 17:29
Worktree-per-worker pool over existing hyperpanes control primitives only
(no core/Rust changes): a plain control-API client reusing this repo's
ControlClient. Per task: git worktree add an isolated checkout, open_pane a
worker cwd'd there, mint a pane-scoped token handed over a short-lived
handshake file, dispatch on the message bus, poll liveness (explicit
DONE/FAIL else pane 'exited', never activity:'idle'), collect RESULT.md,
tear down pane-first-then-directory. Bounded concurrency, failure/cleanup
matrix, meta-based orphan reconciliation, and a --dry-run planner.

- kinds.ts: canonical Task schema (doc 05), zod loader, pure helpers
- git.ts: git worktree add/remove/prune/list wrapper
- controller.ts: planTask + lifecycle + bounded pool + reconcile
- worker.ts: handshake → scoped client → bus task → mock work → DONE
- cli.ts: arg parsing, --dry-run smoke path, sample backlog
- kinds.test.ts: unit tests for the pure planning logic

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Worker: replace the mock RESULT.md with a real agent run gated behind an
injectable AgentRunner. The default spawnAgentRunner shells out to a
configurable command (default 'claude --permission-mode acceptEdits -p
<prompt>', overridable via HP_WORKER_AGENT_CMD) in the task worktree, captures
stdout/exit code with a wall-clock timeout, and returns a structured outcome
(success on exit 0, failed/timeout otherwise) so the controller can ack/nack.
runTask is pure of process/exit concerns and unit-tested with a FAKE runner
(success + timeout + failed paths) that never spawns claude. main() is now
guarded by an entry-point check so importing the module in tests is side-effect
free.

Backlog (phase 7): new src/backlog/ generator that produces canonical Tasks
(kinds.ts shape) and enqueues them via the existing QueueClient.enqueue route.
Sources: a TODO/FIXME code scan (git grep, scanner injectable) and an explicit
list/JSON input, with a failing-test source seam ready to drop in. --dry-run
prints the Tasks without POSTing; a CLI entry (dist/backlog/cli.js) wires the
flags. Vitest covers dry-run, task shape, dedupe, and enqueue.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a runtime RawTaskSchema in kinds.ts (Task is now inferred from it) so the
queue wire shape is validated, not just type-asserted, and pin it against the
Rust-derived golden fixture.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Eyalm321 Eyalm321 merged commit 2addc64 into main Jun 15, 2026
2 checks passed
@Eyalm321 Eyalm321 deleted the feat/worker-pool-controller branch June 15, 2026 09:30
Eyalm321 added a commit that referenced this pull request Jun 15, 2026
Patch bump 0.1.6 -> 0.1.7. Ships the worker-pool controller (src/worker-pool/,
src/backlog/) merged in #1.

Co-authored-by: Eyalm321 <eyal@sunsationsusa.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.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