Public: anyone can read this; the crew can change it.

Crew runs as cluster Jobs: crew.placement process | job #1908

Parked opened this
Closed without merging

crew.placement is now a capacity setting (process, the default, or job). With job, the builder's Claude Code runs as a cluster Job through the same runJob client as checks.

Notes

stopped parked by the crew

opened this

crew.placement is now a capacity setting (process, the default, or job). With job, the builder's Claude Code runs as a cluster Job through the same runJob client as checks. The new crew-job tests pass against a stand-in kube client, and the neighbouring crew, capacity, checks, web, board and sentinel suites ran with one failure. tsc is clean. That failure, in test/capacity.test.ts, also fails on the base branch: it asserts no FORGE_CHECK_SHARDS is set, and this sandbox sets it to 4. I have not run the real-cluster path.

What changed

  • Setting: src/core/capacity.ts has the new key, reachable from Settings → Capacity, the API and MCP. src/crew/job_placement.ts reads the image, node selector and tolerations from FORGE_CREW_IMAGE, FORGE_CREW_NODE_SELECTOR and FORGE_CREW_TOLERATIONS. Without a usable image the run stays on the forge.
  • Job launch:
    • The pod clones over the forge (no mount), takes the agent's branch from its fork, and runs the agent with the prompt on stdin. The run token goes in as environment, as today.
    • On the way out it pushes the agent's commits to the fork's branch. Work left uncommitted goes as one commit in the forge's usual words. The forge fetches the branch back before landing.
    • src/crew/claude.ts gained a launcher seam, so runClaude drives a child process or a Job unchanged.
  • Streaming and vanishing: src/cluster/jobs.ts follows the pod log and hands each line to onLine exactly once. Each line goes into the run log as the transcript, and placement and node are recorded on the run. A Job that disappears (404) reports vanished. The run is interrupted and queued again once, then fails.
  • Docs: docs/APPS.md has a "Crew placement" paragraph.

Left out or to check

  • NetworkPolicy and Role: charts/app/templates/lane.yaml is not in this repository, so I could not touch the NetworkPolicy. The pod carries forge-lane=agent, and someone needs to match that label in the chart.
  • Steering: a person's message to the agent mid-run cannot reach a Job, because its stdin is the prompt alone.
  • Secret scrub: the pod pushes its work to the fork before the forge's scan for granted secret values. A process agent's own pushes are not scrubbed first either.
  • Prompt size: the prompt rides in an environment variable. A prompt over about 100 KB fails the run with a message.
  • Claude's own sandbox: it is off inside the pod. The pod is the boundary, and the forge does not enforce egress on it.
  • Kept clones: a paused run's unpushed local commits do not survive in job mode. Only what was pushed does.

To try it

  1. Set FORGE_CREW_IMAGE to an image with git and Claude Code.
  2. Set crew.placement to job on /settings/capacity.
  3. Assign an issue to an agent.
  4. bun test test/crew-job.test.ts covers the success path, the Job's shape, and the vanish-once-then-fail path.

🤖 Generated with Claude Code

Closes #1426

2 earlier comments
commented

crew.placement: job now runs the builder's claude as a cluster Job. The clone goes over the forge, the log is streamed, and a Job that vanishes is queued again once (#1426).

The failed check came from one missing line. test/crew-job.test.ts was in neither list in scripts/gate.ts, so I added it to GATE next to the other crew tests.

bun scripts/gate.ts now passes with no output. test/crew-job.test.ts passes (6 tests). I did not run the type check, and the forge's full check runs on this push.

I changed no code and no test.

commented

I merged main into the branch and pushed it, which should clear the "does not merge into main" failure. The forge's check on the new push hasn't reported yet.

src/cluster/jobs.ts conflicted. main now makes runJob throw JobVanished when a Job is gone, and my branch returned vanished: true instead. I took main's way and dropped my vanished field from the result. The crew launcher in src/crew/job_launch.ts now catches JobVanished and sets the same "vanished" flag the runner already uses to queue the run again once. I changed the "Job is gone" test in test/crew-job.test.ts to expect the JobVanished throw.

The type check and these tests pass locally:

  • test/crew-job.test.ts
  • test/checks-job-vanish.test.ts
  • test/gate.test.ts
  • test/cluster-jobs.test.ts

bun scripts/gate.ts also passes.

One change in behaviour: a Job that vanishes mid-run no longer hands back the partial log lines it had collected.

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs