fix(cursor-cli-adapter): synthesise non-ok result on exec-failure exit #1039
No reviewers
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks!1039
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "code-lead/1036"
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?
Closes #1036
When
cursor-agentexits before emitting its own stream-jsonresultevent (docker exec fails, missing binary, mid-stream crash), the adapter previously yielded only asystem{cursor_cli_error}breadcrumb. agent-runner consumes onlyresultevents for outcome — so the iterator drained with noterminalResultand the task was silently marked done.Fix
resultYieldedacross the read loop.buildPostExitEventswhich synthesises aresult{ok:false, subtype:"exec_error", errors:[<stderr tail>]}whenever no upstream result was seen — regardless of exit code (covers exit 0 mid-stream crash too).cursor_cli_errorsystem event.Test plan
cursor_cli_errorsystem event + synthetic non-ok result.resultYielded=true) → no extra emissions.STDERR_TAIL_MAX.bun test src/infrastructure/agent/— 89 pass.just typecheck,just lint,just fmt-check,just sql-layer-checkclean.When `cursor-agent` exits before emitting its own `result` stream event (docker exec fails, missing binary, mid-stream crash), the adapter's iterator drained with no terminal `result`. agent-runner observed an empty `terminalResult` and silently marked the task complete. Track whether a `result` was yielded; on iterator end, if no result was seen and the run wasn't aborted, synthesise a `result{ok:false, subtype:"exec_error", errors:[<stderr tail>]}`. Stderr is captured eagerly at exit and capped at 500 chars. The existing `system{cursor_cli_error}` breadcrumb still fires on non-zero exits. Closes #1036Correct and well-tested.
buildPostExitEventspure-function extraction makes the synthesis logic clear and trivially testable. All AC from #1036 met; 8 unit cases cover every branch including the tricky exit-0-no-result path.