fix(cli): auto-start the runtime for non-watch run and tasks run - #690
Open
EnmaJim wants to merge 1 commit into
Open
fix(cli): auto-start the runtime for non-watch run and tasks run#690EnmaJim wants to merge 1 commit into
EnmaJim wants to merge 1 commit into
Conversation
…resharpe#682) The runtime precondition and the auto-start were both nested inside the --watch branch, so the default path spawned the detached task runner with no runtime and exited 0. The runner then parked every task in needs-input with a runtime-endpoint-not-available note -- in a log file the caller never sees, and only after an integration branch had been created and pushed. --no-auto-runtime was bound but unreachable without --watch; it now refuses synchronously with exit 1, before Initialize-WorkflowRun, so a refused run leaves nothing behind. Start-DotbotRuntimeDetached brings the runtime up in a process of its own by spawning dotbot serve and waiting for the connection file, which Start-DotbotRuntime writes only once the listener is accepting. Start-DotbotRuntime hosts the listener in-process and records its own PID, so it cannot serve a CLI that exits immediately after spawning a detached runner. The result carries no listener handle, so a caller can never tear down a runtime it does not own. A runtime auto-started this way deliberately outlives the command; --watch still hosts its own in-process and tears it down on exit. dotbot tasks run takes the same path, and its exit code now propagates through bin/dotbot.ps1 -- exit inside an ampersand-invoked script only ends that script, so every tasks run failure previously reported success to the shell. --poll-interval-ms also consumed the token that followed it even when that token was another flag, so --poll-interval-ms --watch silently dropped --watch and took the very path above.
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.
Linked issue
Closes #682
Summary of changes
dotbot run <workflow>kept its runtime precondition and auto-start nested insideif ($Watch), so the default (detached) path launched the task runner with no runtime,printed
✓ Workflow '<name>' started.and exited 0. The runner then parked every task inneeds-inputwith "Dotbot runtime endpoint not available" — asynchronously, afterminting a run and pushing an integration branch — leaving callers and CI no way to detect
the failure. The runtime is now settled on both paths before any run is minted, with
--no-auto-runtimeas the synchronous, non-zero opt-out.Changes
src/cli/workflow-run.ps1: hoist the runtime check out ofif ($Watch)so--no-auto-runtimerefuses with exit 1 on every path, and auto-start a detached runtimefor non-watch runs. Both happen before
Initialize-WorkflowRun, so a runtime that cannotstart leaves no run, no tasks and no integration branch behind.
--watchstill hosts itsruntime in-process and tears it down on exit.
src/runtime/.../Private/Lifecycle.psm1: addStart-DotbotRuntimeDetached, which spawnsdotbot serveas a child and waits for.control/runtime.json(written only once thelistener accepts).
Start-DotbotRuntimehosts in-process and records its own$PID, soit cannot serve a CLI that exits right after spawning a detached runner. The result
carries no
listenerhandle — a caller can never stop a runtime it does not own. Exportedfrom
Dotbot.Runtime.psd1.src/cli/tasks-run.ps1: apply the same auto-start before launching the task runner.bin/dotbot.ps1: propagatetasks runexit codes (exitinside a&-invoked script onlyends that script, so every
tasks runfailure previously reported success); and stop--poll-interval-msfrom consuming the following token when it is another flag, which made--poll-interval-ms --watchcast[int]"--watch"and silently drop--watchinto thebroken detached path.
tests/Test-ProcessDispatch.ps1: cover the--poll-interval-msparser guard and theruntime precondition end to end.
CHANGELOG.md: Added / Changed / Fixed entries.Testing notes
pwsh -File tests/Run-Tests.ps1(orpwsh -File tests/Test-ProcessDispatch.ps1for thetargeted suite). New assertions:
--watchstill binds after a valueless--poll-interval-ms;--poll-interval-ms 500 --watchstill parses both; anddotbot run smoke-test --no-auto-runtimewithout a live runtime exits 1, says the runtimeis not running, and mints zero
WorkflowRundirectories.dotbot run <workflow>without--watchnever starts the runtime and fails asynchronously #682: in a freshdotbot initproject with nodotbot go/serverunning,
dotbot run smoke-test(no--watch) now prints› Starting headless runtime...,completes the task, and writes
.bot/.control/smoke-test.json.dotbot run smoke-test --no-auto-runtimeexits non-zero immediately and leaves.bot/workspace/tasks/workflow-runsempty (no pushed integration branch — see A failed task discards commits the agent already made; every run leaves an unreapable branch #683).--watchis unchanged: runtime is hosted in-process and stopped on exit.dotbot runtime-statusafter a non-watch run should report the auto-started runtime's PID —it deliberately outlives the command.
Checklist