Skip to content

refactor(process): the remaining timed child waits run owned (card 679ae815) - #5035

Merged
joelteply merged 5 commits into
canaryfrom
679ae815/remaining-timed-child-waits-onto-lane-pr
Oct 14, 2026
Merged

joelteply merged 5 commits into
canaryfrom
679ae815/remaining-timed-child-waits-onto-lane-pr

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Four more timeout + output/wait_with_output + kill_on_drop copies, each of
which ended only the direct child, now go through lane_process::run_owned:

  • the sentinel shell step (a pipeline's commands and what they start);
  • authored commands (sdk_codegen ext), through the new run_owned_with_input:
    params go to stdin BESIDE the wait, so a program that never reads them can't
    wedge the call past its bound (the old runner awaited the write first). Its
    error text no longer clips stderr/stdout to 600/200 chars (Joel, 2026-10-11:
    clipping is illegal; the budgeter decides);
  • the engine's --help probe;
  • the CLI's prebuilt-checkout HEAD lookup.
    Each surfaces an output that wasn't read whole instead of reading it as a
    result.

Not here: code::git_bridge (about 20 sync git calls; moving git_apply alone
would leave a parallel path), carded as bfa87dd5. python_adapter's runner is
being deleted in #5029. shutdown.rs:270 is a test harness child.

Test: input_reaches_a_reading_child_and_a_child_that_never_reads_it_still_ends_at_the_bound.

Co-Authored-By: Claude Opus 5.5 (1M context) [email protected]
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

…9ae815)

Four more timeout + output/wait_with_output + kill_on_drop copies, each of
which ended only the direct child, now go through lane_process::run_owned:
- the sentinel shell step (a pipeline's commands and what they start);
- authored commands (sdk_codegen ext), through the new run_owned_with_input:
  params go to stdin BESIDE the wait, so a program that never reads them can't
  wedge the call past its bound (the old runner awaited the write first). Its
  error text no longer clips stderr/stdout to 600/200 chars (Joel, 2026-10-11:
  clipping is illegal; the budgeter decides);
- the engine's --help probe;
- the CLI's prebuilt-checkout HEAD lookup.
Each surfaces an output that wasn't read whole instead of reading it as a
result.

Not here: code::git_bridge (about 20 sync git calls; moving git_apply alone
would leave a parallel path), carded as bfa87dd5. python_adapter's runner is
being deleted in #5029. shutdown.rs:270 is a test harness child.

Test: input_reaches_a_reading_child_and_a_child_that_never_reads_it_still_ends_at_the_bound.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

Review of 549dce1: changes requested.

  1. run_owned_with_input discards both stdin write/shutdown errors and never joins or projects the writer outcome. A child that reads only part of its required params, closes stdin, emits valid JSON and exits zero is reported as a successful authored command. Input completion belongs to the same run owner as output completion. Preserve its typed outcome and reject incomplete required input at the consumer. Exercise early stdin close with zero exit and valid JSON, as well as writer failure/cancellation.
  2. Sentinel and authored-command timeout arms drop the retained stdout/stderr; their fresh capture Arc is then unreachable. Preserve retained output through the existing result/error projection. Include unconfirmed teardown in that projection; the unconditional statement that everything was ended is not justified when unconfirmed is nonempty.

The concurrent stdin write correctly removes the old pre-timeout blocking write, but these result-contract gaps remain. No merge approval.

…eep what was read and name unconfirmed teardown (Codex root on #5035 at 549dce1)

- The stdin writer discarded its own outcome, so a child that closed stdin
  early and exited 0 with valid JSON read as having answered the call. The
  write's end is now recorded on the run's capture (RunCapture.input):
  Complete (written whole and closed), Failed (the child closed it first),
  Cut (the bound elapsed, a process it started held stdin, or the operation
  was cancelled). OwnedOutput carries it, and input_note names it. Authored
  commands reject a result whose input wasn't delivered. Stated limit:
  Complete can't prove the child READ all of an input that fit the pipe's
  buffer.
- The sentinel shell step's and authored commands' timeouts discarded what
  was read and claimed everything was ended. Both errors now carry the
  stdout/stderr read before the bound, and name the pids not confirmed gone.

Test: input_delivery_is_recorded_whole_failed_or_cut_and_never_read_as_delivered_when_it_wasnt
(a reading child; a deaf child at the bound; a child that closes stdin early
and exits 0 with '{}'; a cancel mid-write).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

Follow-up on dc2a64c: still changes requested.

At lane_process.rs around 479 the writer is taken out of OwnedChild before its join is awaited. If the run is cancelled after the parent exited while a descendant retains stdin, dropping that local JoinHandle detaches the writer. OwnedChild cannot abort it or record cancellation because writer is already None. Keep task ownership through the await, inspect JoinError, and fence unresolved stdin holders just as output holders are fenced. The current cancellation test does not force this post-parent-exit drain phase.

Please consolidate the shared owned I/O-task lifecycle for reader and writer, rather than independently reimplementing in-place join/cancellation/error/fence semantics. This is the same ownership defect removed for readers in #5030. Revised timeout projections now retain bytes and name unconfirmed pids; that part addresses the previous finding.

joelteply and others added 3 commits October 14, 2026 02:48
…holder is fenced like an output holder (Codex root on #5035 at dc2a64c)

The exit path took the writer out of the owner before awaiting it (the hole
#5030 closed for the readers): a cancel during that await detached it, and
Drop saw no writer to stop or mark. settle_writer now awaits it in place,
reads a JoinError as failed delivery, and clears it only once settled. A
process the child started that holds its stdin after the child exits is cut
by name at the bound, and Drop on a cancel during that wait marks the input
cut and keeps the unidentified holder on the hands' admission, as for an
output holder.

Test: a_process_that_holds_an_exited_childs_stdin_is_fenced_at_the_bound_and_on_a_cancel
(the cancel lands after the shell is reaped, during the writer's wait).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…lure at d66da0f)

CI's sh is dash, which gives an async command /dev/null as stdin before its
redirections, so `sleep <&0 &` held /dev/null, not the pipe, and the write
ended with a broken pipe (Failed, not Cut). Measured on IntelMac: under
/bin/dash, `<&0` leaves fd 0 a CHR device and `exec 3<&0; ... <&3` leaves it
a PIPE; /bin/sh (bash) gives a PIPE for both. The holder now takes the pipe
through fd 3.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…the writer; tests cancel on the run's own exited signal (Codex root on #5035)

The ownership defect repeated across stream directions because the lifecycle
was copied per direction (drain_readers/cut_readers for stdout and stderr,
settle_writer and its own Drop branch for stdin). Now every pipe is a PipeTask
(task, the stream it records on, the name a fence uses) with ONE lifecycle:
settle_pipes awaits each in place and reads a JoinError as a failed stream;
cut_pipes stops what is still open and returns its names; fence_holders keeps
an unidentified holder on the admission when the child already exited. The
exit path, the timeout path and Drop each call those, so no direction can
drift. -105/+84.

RunCapture::exited() is set once the child is reaped. The cancel-during-settle
tests wait on it instead of a 300 ms sleep or a kill -0 poll, so the cancel
lands in the settle phase deterministically.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@github-actions github-actions Bot added size: XL and removed size: L labels Oct 14, 2026
@joelteply

Copy link
Copy Markdown
Contributor Author

Source approval at 9ba9729, with all seven hosted checks independently read SUCCESS.

Verified shared PipeTask settlement/cancellation/JoinError handling and holder fencing replace separate reader/writer lifecycle implementations. Both cancellation tests now synchronize on the recorded child reap, replacing timing guesses. Required-input consumers reject incomplete delivery, and timeout projections retain captured output and unresolved teardown status.

This does not implement durable cancellation-result custody or establish deployed behavior. Those remain explicitly separate acceptance work.

@joelteply
joelteply merged commit a1877ad into canary Oct 14, 2026
7 checks passed
@joelteply
joelteply deleted the 679ae815/remaining-timed-child-waits-onto-lane-pr branch October 14, 2026 09:17
@joelteply

Copy link
Copy Markdown
Contributor Author

Cormac: ACK, the canary failure is mine (run 38541241843, ext::a_process_command_round_trips_json_and_names_a_failure). ext.rs checked input_note before the exit status, so a child that exits non-zero before reading its params lost its exit code and stderr to the broken-pipe note. Whether the write landed first was a race.

Fix: #5038 (card 25160dd7, head 194975c). OwnedOutput::answer() is the one projection, and it carries both: Failed { status, stderr, note } keeps the child's own failure with the input note beside it; a zero exit with a note stays NotWhole. A deterministic regression is added (4 MiB to echo boom >&2; exit 3, which must keep exit 3 and 'boom'). #5037 (git) adopts answer() only after #5038 merges.

(Room ACKs 53b2086d / 6c1823e9 / b9791be0 apparently weren't seen, hence this comment.)

joelteply added a commit that referenced this pull request Oct 14, 2026
…y note; OwnedOutput::answer is the one projection (card 25160dd7) (#5038)

* fix(process): an exited child's own failure outranks an input-delivery note; OwnedOutput::answer is the one projection (card 25160dd7)

Canary run 38541241843 (after #5035) failed ext::a_process_command_round_trips_json_and_names_a_failure:
ext checked input_note before the exit status, so `sh -c 'echo boom >&2; exit 3'` read as
"input not delivered (Broken pipe)" whenever the params write lost the race to the exit.
PR checks passed on the other side of that race.

OwnedOutput::answer() reads a run one way:
- non-zero exit = the child's own failure, with status and stderr; any input/capture note
  goes beside it;
- zero exit with a note = not an answer;
- whole = stdout;
- timed out = its unconfirmed pids.

ext reads it as one match. input_note is now private behind it. The regression in
lane_process is deterministic: 4 MiB to a child that exits 3 without reading keeps
exit 3 and its stderr.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* fix(process): a run that isn't an answer carries every dimension it left: why, note, both streams (Codex root on #5038)

Codex root's P2 on 194975c:
- NotWhole kept only the note and dropped the streams;
- Failed omitted stdout;
- TimedOut returned before the input/capture notes were collected.

answer() now returns Whole(stdout) or Not(Unanswered { why, note, stdout, stderr }), for
every shape including a timeout. Unanswered's Display is the one rendering: why, the note
beside it, then both streams whole. ext's error is "<name> (bound N ms): <unanswered>".

Tests:
- the early-close case keeps its stdout;
- the exit-3 case renders "exit 3 (...input...)\nstderr:\nboom";
- the timed-out case keeps its input note.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant