Repository navigation
Commit 9854fe3
* Add abortable clone and storage preparation that run in process groups (#51 item 5)
createTaskCloneAsync and prepareTaskFilesystemsAsync take an AbortSignal and
run every Git or Docker call as the leader of its own process group
(runInProcessGroup in agents/process-group.ts). Each group is reported through
onProcessGroup in the same turn as the spawn, so F can save it before anything
else runs. On abort or at the deadline the group gets SIGTERM, then SIGKILL
after 5 s, and the call settles only once the leader and every other member
of its group have exited. An aborted clone removes its partial directory; an
aborted allocation removes what it created with uncancelled cleanup.
The clone and allocation are now step generators shared by both variants:
the synchronous helpers keep their API and behaviour, and long file walks
pause regularly so the asynchronous variants keep the event loop free.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Kill a group the caller cannot record; never throw from group signals; report early aborts as cancelled
runInProcessGroup ran onProcessGroup unguarded, so a throwing callback left
the child running and unwatched. It now kills the group at once and settles
only after it exits, with EUNRECORDED and the callback's error as the cause.
signalGroup no longer throws (only ESRCH means gone), so a group member that
cannot be signalled cannot crash the runner from a timer or hang the drain.
An allocation ID check whose client was stopped or never started now reports
why (for example cancelled) instead of a generic message. The real-Docker
abort test checks groups with process.kill, which the kill utility cannot
stand in for.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Catch an abort raised during onProcessGroup; settle on the leader's exit, not its pipes
An abort raised inside the onProcessGroup callback came before the listener
existed and was never seen, so the child ran to its deadline. The helper now
checks the signal right after attaching the listener.
Settlement waited for 'close', which also needs every holder of the output
pipes; a process that left the group with setsid but kept the pipe survived
the group kill and hung the call forever. It now settles from the leader's
exit: drain the group, wait up to 1 s for the pipes, then destroy them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Clear the SIGKILL timer once the group is empty; release the pipe wait; document settlement bounds
The grace-period SIGKILL timer was cleared only after the up-to-1-second pipe
wait, so a sub-second grace could fire it at an ID the group no longer held.
It is now cleared as soon as the drain ends. The pipe-wait timer is cleared
when the pipes close, so a finished call never keeps the process alive. The
lifecycle doc now states the EGROUPALIVE and 1-second pipe bounds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Pause while reading a large directory; start the deadline before the group is recorded
The object audit and link check counted only paths taken off the queue, so
reading one huge directory held the event loop (and an abort) for all of it.
They now count every entry read too, and pause every 1,000 either way. The
process deadline was armed only after onProcessGroup returned, so a slow
durable write let the child run past timeoutMs; it is now armed at the spawn.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Add review rules from #73: reread whole functions, verify stated claims, independent review
Copilot found three issues on #73 that several author self-reviews missed: a
pause cadence claimed in comments but broken by an inner directory loop, and
a deadline armed only after a synchronous callback. New review-readiness
rules require rereading every changed function in each pass, verifying every
behavioural claim with a failing-if-false test, and an independent review for
concurrency, process and cleanup code. Two new required race cases cover
synchronous lifecycle hooks and descendants that hold output pipes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Count a Git call as a yield in the clone walk-pause test
The two object checks run before and after the clone call, which is awaited
and so yields the event loop. The test counted reads across that boundary as
one run and failed at 1,001 on Linux's object layout. It now resets the run at
each Git spawn; it still fails at 2,506 on the pre-fix clone code.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Report synchronous spawn failures as outcomes; stop nothing once the leader has exited
spawn throws, rather than emitting 'error', for spawn failures such as ENOMEM
or E2BIG. The throw rejected runInProcessGroup, so the step drivers skipped
the generators' cleanup: an allocation left its volumes, stayed live and kept
its claim. It is now reported as an outcome. stop() no longer runs after the
leader exits, so output read during the pipe wait cannot signal a drained,
possibly reused group ID or re-arm the SIGKILL timer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Report output held open past the group as an error, not a success
When a process outside the group held the pipes past the 1 s wait, the call
returned the leader's exit status with output that may be incomplete. It now
settles with ESTDIOHELD and keeps what was read. Before deciding, it gives I/O
one more event-loop turn, since after a long block the timer can fire before
output that is already waiting is read.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Document ESTDIOHELD and synchronous spawn failures in the lifecycle bounds
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Settle truncated output as ENOBUFS; report every post-abort failure as a cancel
Output crossing the limit after the leader exited was dropped while the call
still reported success; any crossing now settles as ENOBUFS. An abort landing
between two Git or Docker calls made the next call refuse to start, so the
clone or allocation rejected with a plain error instead of an AbortError; both
now rethrow any failure after the signal aborted as an AbortError with the
original as its cause (an unsettled cleanup stays an AggregateError).
Found by an independent review agent after the author's passes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Reject deadlines longer than a Node timer; make the between-calls abort tests deterministic
setTimeout treats delays above 2^31-1 ms as 1 ms, so a larger timeoutMs made
the async allocation time out at once while the sync one worked. Both now
refuse it up front, and runInProcessGroup reports it as not started.
The between-calls abort tests aborted one turn after a child's exit, which in
about a quarter of runs landed during the next call instead. They now wrap
runInProcessGroup and abort after one call settles and before the next is
requested, and assert that exactly one call was refused before it started.
Found by a second independent review agent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 90d8cec commit 9854fe3
11 files changed
Lines changed: 1029 additions & 96 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
48 | 53 | | |
49 | 54 | | |
50 | 55 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
| |||
0 commit comments