review: classify inspector timeout from the wait error, not a late ctx re-sample

main

Commit

dipree2mo ago

Reading agentCtx.Err() after Wait() returns has a tiny window: if an inspector completes naturally just before its deadline, the deadline can fire in the gap before the read and the agent context reports DeadlineExceeded, falsely flagging a timeout.

Classify from waitErr instead, which the Process contract sets to the context cause only when the process was actually killed by it (templateProcess returns ctx.Err() only when cmd.Wait errored). A natural completion returns nil regardless of a deadline firing a moment later, so errors.Is(waitErr, context.DeadlineExceeded) is the atomic, race-free signal in both Run and RunMulti. Drops the now-unused agent-ctx param from the RunMulti goroutine.

Adds TestRun_NaturalCompletionPastDeadlineIsNotTimeout (process finishes cleanly after the deadline elapses -> Succeeded, not a timeout); 'go test -race' on the package is clean.

Entire-Checkpoint: eaf38faaf53d

Checkpoints

Checkout the hand off doc that I just added.

PiOpus 4.8
View session
Checkpoint 1