feat(runs): the AI planner plans manual runs (phase 3) #49
No reviewers
Labels
No labels
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
priority
critical
priority
high
priority
low
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Beanstalk!49
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean:feat/runs-planner"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Manual runs (#48) all run the default plan, so a BigBean's words about what to test are kept but never used. This lets the AI planner plan a run the way it plans a PR, and lets a BigBean plan a run again with new words.
Builds on #48 and should merge after it. This branch is stacked on #48's commit, so until #48 merges the diff here shows both: the change of this PR is its last commit,
feat(runs): the AI planner plans manual runs, ....What changed
The planner reads a run (
planner.gather_run). A run has no PR, so the model reads:MAX_DIFF);.farm/test.tomlat the candidate, as a hint;gather_issues, as for a PR).Each of these goes in its own nonce-fenced data block under the same system rules, plus one short paragraph that says this is a manual run ("PR" means the candidate, "main" the baseline). The requester's
instructionstake the place of the maintainer's instructions.New Forge calls:
compare(base, head)(the commits oldest first, the changed paths including a rename's old path, and whether the list is complete) andcompare_diff(base, head, limit), which reads the web route/{repo}/compare/{a}...{b}.diffbecause the API has no compare diff. I checked both against git.magicbean.dev with read-only GETs. The fake Forgejo has them too.Submitting (
runs.submit) stores the run asplanningwith no plan and startsplanner.spawn_runin the background. Its tasks are keyed("plan-run", id), so they can't collide with a commit's. With AI planning off it uses the default plan at once, as before. A failed or refused AI plan, or any unexpected error, falls back to the default plan with the targets asked for, so a run never staysplanning.resume_pendingrestarts runs that a restart leftplanning. A planning run counts toward the requester's 5 live runs, because it has no jobs yet.Targets asked for are enforced, not just suggested. The model is told they are the maintainer's choice, and the plan's
[[target]]list is then replaced with them (planner.fixed_targets, which keeps the model'smin_reportsfor a target with the same name). I chose this over a hint because the client and the API show the targets that were asked for. If the model could widen or narrow them, the run would quietly test hardware the BigBean didn't choose, and a hint has no way to catch that.POST /api/v1/runs/{id}/plan{"instructions": "..."}(any BigBean, like cancel) plans the run again, as@Beanstalk plandoes for a PR. It starts a new round (runs.round), and the old round's queued and running jobs are cancelled with the reasonre-planned by <login>. With no body, the run is planned again with its own words. A cancelled run is opened again. An old round's planning that is still running finds itself superseded, because the round is claimed asplanner.claimclaims a commit's.API (additive only): the run gains
roundandplan: {state: planning|ready, source, summary, model}. No new run or job states. While the run is being planned, itsstateisqueuedwithjobs: [](it isn't finished, sofarm_run.pykeeps waiting).targetsare the plan's, or the ones asked for while planning. Errors are unchanged: always JSON{"error"}, with 401/403/404/400.The run page shows the plan like a PR's page: the model (or "default"), a
planning…chip, the plan's summary, "In plain words", "Asked for", the source and round, and any error. The/runscards showplanning.Nothing about a run goes to Forgejo. The planner only reads from it.
devserverplans its second seeded run with a canned stand-in model, so the page can be seen with a plan.Docs: protocol.md (the endpoint and the new fields), using.md and architecture.md.
Tests
tests/test_runs_planner.py, using the fake model from the planner's tests:resume_pendingpicks up a run that was left planning;compare_docparsing.compare_diffweb route inside the coordinator (I only checked it by hand with curl).Screenshots
From the dev server (made-up data; the plan is the canned stand-in's). Before: the run page in #48, which showed "Plan (default)" and "Kept for the planner".
After, desktop:
After, 390 px:
A run is planned as a PR's head is, from what it has instead of a PR: the compare between its baseline and its candidate (commit messages, changed files, the diff), the requester's words as the maintainer's instructions, the saves at the baseline, .farm/test.toml at the candidate and the issues the words or commits name, in the same untrusted data blocks. The targets asked for replace the plan's. A failed plan, or AI planning off, gives the default plan with those targets. POST /api/v1/runs/{id}/plan (BigBeans) plans a run again with new words or its own: a new round, the old jobs cancelled. The API's run gains round and plan {state, source, summary, model}; a run being planned is queued. The run's page shows the plan as a PR's page does. Assisted-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <[email protected]>Folded into #48: manual runs land as one pull request, and this phase is now a commit on its branch.
Pull request closed