Skip to content

Bug sweep 5: plan run / plan x fixes - #380

Merged
scott-cotton merged 8 commits into
scott/bug-sweepfrom
scott/bug-sweep-5
Oct 2, 2026
Merged

scott-cotton merged 8 commits into
scott/bug-sweepfrom
scott/bug-sweep-5

Conversation

@scott-cotton

Copy link
Copy Markdown
Member

Fifth batch of CLI bug-sweep fixes (ENG-1248), for plans. Stacked on #376. It is independent of #377, #378 and #379, and merges cleanly with each. There is one commit per fix; review only the 5 commits here.

Commits

  • fix(plan): resume live plan logs: plan run --attach and plan x logs -f opened the live stream once and discarded its errors. That caused three problems:

    • A stream requested before dispatch got a 404 (execution not yet dispatched to a runner) and the run showed no logs.
    • After the server's 5-minute idle cut (planexecution/logproxy.go, e.g. a silent step), all later logs were lost.
    • --attach cancelled the stream as soon as a terminal phase was seen, dropping trailing lines.

    The new planexec.FollowLiveLogs reconnects from the last cursor on a 404 before the execution finishes, on 5xx, and on connection/SSE errors. It stops when the stream ends or the execution is finished (the runner no longer holds live logs). --attach now gives the stream up to 10s after the execution finishes to deliver the rest.

  • fix(plan): don't truncate --output-dir exports: the export used go-openapi's 30s default request timeout, which covers the whole streamed body. Large or slow outputs were truncated, the remaining outputs skipped, and the run still exited 0 with only a warning. Downloads now have no request timeout (the command's context bounds them) and are written atomically. A failed export makes plan run exit non-zero after the result is reported.

  • fix(plan): allow compile/recompile to take longer than 30s: the server compiles synchronously with an LLM, bounded only by the request context. After 30s the CLI hit its deadline, the server cancelled the compile, and no plan was created. The timeout is now 5 minutes.

  • fix(planexec): dedup step outputs: plan outputs were keyed by <step>/<plan output name> instead of <step>/<StepRef.OutputName>. plan x outputs and get-output --all listed referenced step outputs twice when the names differed, and hid unrelated step outputs that happened to share the plan output's name.

  • fix(plan): send --param values of string-typed params as strings: python_version=3.10 was sent as a JSON number and reached the plan as 3.1. If the plan declares the param's JSON Schema type: string, the value is now sent as given. Untyped params keep the existing JSON inference, so an untyped 3.10 is still sent as a number; plan authors can type the param to avoid that.

Testing

  • FollowLiveLogs is tested against a fake server: 404 before dispatch, then a stream cut by an SSE error, then a resume, checking the output and the cursors sent. A separate test checks that it stops with the error once the execution is finished. There are also tests for export (partial failure, no leftover files), output dedup (fails without the fix) and string-schema params.
  • go vet ./... and go test ./... pass; -race passes for plan and planexec.
  • Not yet run against a real plan execution.

Refs ENG-1248.

🤖 Generated with Claude Code

scott-cotton and others added 5 commits September 29, 2026 11:13
`plan run --attach` and `plan x logs -f` opened the live log stream
once and discarded stream errors, so:
- a stream requested before the execution was dispatched got a 404 and
  the run showed no logs at all;
- after the server's 5 minute idle cut (a silent step), all later logs
  were lost (`x logs -f` ended with "log stream timed out");
- `--attach` cancelled the stream as soon as a terminal phase was seen,
  dropping trailing lines.

Add planexec.FollowLiveLogs, which reconnects from the last cursor on
404-before-finish, 5xx and connection/SSE errors, and stops when the
stream ends or the execution is finished. --attach now gives the
stream up to 10s after the execution finishes to deliver the rest.

Refs ENG-1248.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ort fails

exportOutputs used the go-openapi default 30s request timeout, which
bounds the whole streamed body, so large or slow outputs were truncated
on disk, the remaining outputs skipped, and only a warning printed with
exit 0. Downloads now have no request timeout (bounded by the command's
context), are written atomically (no partial files), and a failed
export makes `plan run` exit non-zero after reporting the result.

Refs ENG-1248.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
compile and recompile used the go-openapi default 30s request timeout
against a synchronous server-side LLM compile, so slower compiles
failed with a deadline error and the server cancelled the compile (no
plan created). Use a 5 minute timeout.

Refs ENG-1248.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fers to

collectAllOutputs keyed plan outputs by <step>/<plan output name>, but
a plan output refers to <step>/<StepRef.OutputName>, which may differ.
So a step output referenced under another name was listed twice by
`plan x outputs` and `get-output --all`, and an unrelated step output
sharing the plan output's name was hidden.

Refs ENG-1248.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Numeric-looking --param values were sent as JSON numbers, so e.g.
python_version=3.10 reached the plan as 3.1 (after the server's JSON
round-trip). When the plan declares the param's JSON Schema type as
"string", the value is now sent as given. Untyped params keep the
existing JSON inference.

Refs ENG-1248.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: medium. Approved based on skipped Bugbot and Security Agent signals (neither check was present) and no applicable approval policy requiring human review. No reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

@davixcky davixcky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I couldn't exercise plan run / plan x live because the staging plan-execution endpoints were hanging on both main and this branch. So this is based on review and the tests. Build, vet and -race all pass, and the dedup, string-param and export tests fail with their fixes reverted.

Non-blocking, but 1 and 2 are the same "logs lost" class this PR fixes, so they might be worth doing here:

  1. FollowLiveLogs stops for good on a clean end-of-stream before the execution finishes (internal/command/planexec/livelogs.go:46). The server's stream handler returns without sending EOF when its context is cancelled on shutdown. So a control-plane rollout during x logs -f exits 0 mid-run, and --attach drops the rest. Maybe check the phase on a clean end, and reconnect if the execution isn't finished.
  2. Non-APIError errors retry forever without checking the phase (livelogs.go:60). A 403 or 404 with an HTML body, from a proxy or a wrong api_url, retries every 2s silently, even after the execution has finished.
  3. get-output --all can overwrite files. Plan outputs that reference a step are written to <dir>/<step>/<name>, so a same-named step output overwrites them.
  4. Quoted values for string-typed params now keep their quotes (--param 'v="3.10"' is sent as "3.10", quotes included). Also, type: ["string","null"] isn't treated as a string.
  5. The export error is printed twice, because cobra prints the returned error as well. Also, writeFileAtomic uses a fixed 0644 that ignores the umask; #379 has the same.

scott-cotton and others added 2 commits October 1, 2026 16:58
Brings in origin/main via the updated base.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in the --attach and locald address fixes from #376's review.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in origin/main via the updated base.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scott-cotton
scott-cotton merged commit 129c6f3 into scott/bug-sweep Oct 2, 2026
1 check passed
@scott-cotton
scott-cotton deleted the scott/bug-sweep-5 branch October 2, 2026 10:03
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.

2 participants