Repository navigation
perf(web): a web start builds its plan once - #127
Merged
Merged
Conversation
POST /api/runs built the plan to price its pacing, then the worker's Orchestrator built the same plan again before emitting it, about 1.6 s of wasted CPU for REP-004 at high intensity. The preview's plan is now handed to the worker through RunManager.start(plan=...) and Orchestrator.run(plan=...). Building is pure and seeded, so the emitted events are unchanged. tests/test_web_single_plan_build.py counts build_plan calls across a real start; against the unfixed code it counted 2 for the default vendor and for a non-default one, and 1 with the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HbjsVBv8HQSQkAds6W5Y1v
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This closes the last open engineering item in
tasks/todo.md, "Plan-twice cost in the web start path".POST /api/runsbuilt the plan to price its pacing, then the worker'sOrchestrator.runbuilt the same plan again before emitting it. That is about 1.6 s of CPU on the start path for REP-004 at high intensity.Now
_previewbuilds the plan once and hands it toRunManager.start(plan=...), and the worker emits it through a new keywordOrchestrator.run(plan=...). Building is pure and seeded and nothing mutates a plan during a run (_markcopies the extension dict), so the emitted events do not change. The CLI and menu never built twice and are untouched. Twoplan or buildchecks becameplan is None, becauseScenarioPlandefines__len__and an empty plan is falsy.Verification
tests/test_web_single_plan_build.pycountsOrchestrator.build_plancalls across a real start that runs todone. It is parametrized overfortigate(the configured default) andpaloalto(the per-vendor orchestrator path). Positive control: against the unfixedorchestrator.py,runner.pyandserver.py, both cases fail withthe plan was built 2 times for one start. With the fix, both pass./api/planpriced count equals the run'sevent_countand the manifest'splanned_event_count(REP-004 low, seed 7). This test is not a guard of the fix; it passes on both trees.test_web_api.py'sbusystub mirrorsRunManager.start's signature, so it gainedplan=None.mypy replicant tools experiments/typesafe/run.pyare clean.Documentation impact
tasks/todo.mditem struck through with a dated note. No operator, API, safety or runbook contract describes the internal build count, and the HTTP API is unchanged.)CHANGELOG.mdrecords the change.Scope boundary
This change moves no request or response field, no manifest field and no pacing, and it does not touch the send path, the eps cap or the send lock. I did not measure wall-clock savings; the claim is the build count.
Generated by Claude Code