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

Variants, step 1b: POST /api/v1/feed/tells with variants: 2 starts two builder runs in one group #1679

opened this

Merged 49d 10h ago, live in production

POST /api/v1/feed/tells now accepts variants, and a tell with variants: n starts n builder runs in one fresh group. The pull each run opens carries that group. The new tests pass and tsc is clean.

Notes

opened this

POST /api/v1/feed/tells now accepts variants, and a tell with variants: n starts n builder runs in one fresh group. The pull each run opens carries that group. The new tests pass and tsc is clean. I didn't run the full gate or the whole bun test suite here.

Two tests in test/asks*.test.ts ("acting on many asks at once": the one-request card with undo link, and the muted-repository card) fail. They fail the same way on an untouched checkout, and I didn't touch src/web/studio/asks.ts. I also ran crew-direction, offline and the feed tests, which pass.

  • Validation: variants must be an integer from 1 to 4. Absent means 1. 0, 9, "2", 2.5, null and true get a 400 invalid_variants saying "1 to 4". Validation (parseVariants) lives in src/actions/tell.ts.
  • Several issues, not one: n > 1 opens n issues, one per variant, because a run's branch is derived from its issue. Several runs on one issue would share a branch and collide, and the dispatcher allows one active run per issue and agent. Each issue's body ends with "Variant k of n.".
  • Response: for n > 1 the 201 adds issues (the issue numbers) and variantGroup. A plain tell answers as before and leaves the group null.
  • How the group travels: assignIssue puts it in the issue.assigned event. The dispatcher passes it to queueAgentRun, which stores it on the run. The runner hands it to openPull, and from there it reaches core/pulls.ts and the pull's variant_group. Runs now expose variantGroup.
  • Tests: they are in test/pull-variants.test.ts, the file from step 1a. They cover a plain tell having no group, the six bad values returning 400 with nothing opened, variants: 2 giving two runs in one group on two issues, and openPull with a group producing a pull that carries it.

Left out:

  • The tests don't run a real agent to open a variant pull. The run-to-pull hand-off is covered by the run storing the group and openPull honouring it, not end to end.
  • The MCP tell tool and the studio box don't take variants; only the feed route does.
  • Asks grouping and counting are unchanged; the deck that chooses among siblings is #1410.

To try it, send POST /api/v1/feed/tells with {"app":"owner/name","text":"…","variants":2} and an rw token. Each returned issue's run has the same variantGroup.

Closes #1644

commented

POST /api/v1/feed/tells now takes variants (an integer 1–4; absent means 1). With n > 1 it opens n issues, one run each, all in one fresh variant_group, and the pull each run opens carries that group. A plain tell leaves the group null. I pushed e15ca67f. tsc is clean and test/pull-variants.test.ts plus test/asks*.test.ts give 48 pass, 0 fail.

Review feedback:

  • Pull hand-off test: I replaced the hand-written openPull test with one where the run itself opens the pull. It uses a fake agent binary that commits and pushes, with concurrency: 1. The test sends variants: 2, waits for two open pulls, and checks that both carry the returned variantGroup and sit on different head branches. It also checks that every run carries that group. With the openPull spread in src/crew/runner.ts removed, it fails; I restored the line afterwards.
  • Dropped assignments: a 201 for n > 1 now returns assigned, the issue numbers a builder actually took, next to issues. A caller can tell when fewer runs started than issues exist.
  • Rebase: the branch is merged with main (0.7.107) rather than rebased, because force pushes are refused. The two asks* failures are gone.

Behaviour:

  • Bad values: 0, 9, "2", 2.5, null and true get a 400 invalid_variants.
  • One issue per variant: a run's branch comes from its issue, so n runs on one issue would collide. Each issue's body ends with "Variant k of n.".
  • Response: for n > 1 the 201 carries issues, assigned and variantGroup. A plain tell answers as before.

Left out:

  • Other doors: MCP tell and the studio box don't take variants.
  • Asks: src/web/studio/asks.ts is untouched; sibling pulls count as ordinary pulls until #1410.

To try it, send {"app":"owner/name","text":"…","variants":2} with an rw token, then look at the two pulls' variantGroup and variantSiblings.

commented

A variant run that the forge queues again now keeps its group, and docs/FEED.md documents variants. tsc --noEmit is clean and test/pull-variants.test.ts passes (7 tests). I did not run the rest of bun test.

Group recovery. queueAgentRun in src/crew/dispatch.ts now falls back to the group of the issue's earlier runs when none is passed. The lookup is a new variantGroupOf() in src/core/runs.ts, read inside the same write transaction that creates the run.

  • Paths covered: requeue, resumeLater, the startup sweep, and the feedback and check_failed runs all go through queueAgentRun. All of them keep the group without any change to their own code.
  • Pull: the runner already reads run.variantGroup when it opens the pull, so a re-queued run's pull stays in the group.
  • Why not pass run.variantGroup through each path: one lookup in one place covers every caller, including any added later.

Test. A new test in test/pull-variants.test.ts starts a two-variant tell and cancels one run. It then queues the issue again twice, once with the again pause or restart options and once plain as the sweep does. Both new runs carry the original group. I did not run a real pause or restart through the dispatcher. The test calls queueAgentRun the way those paths do, and the pull side rests on the existing end-to-end test.

Docs. The docs/FEED.md entry for POST /api/v1/feed/tells now states the 1–4 range, that anything else is a 400 that opens nothing, and that the group survives re-queues. It also lists the extra issues, assigned and variantGroup fields in the 201, which a plain tell does not have.

Left out. MCP, the studio box and the terminal still don't take variants, as the issue scoped.

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs