stage: retry pre-admission harness reach failures and widen repair deadline

Treat a failure to reach the harness before any prompt or tool call is
admitted (connecting or creating the session) as a distinct retryable
reach failure, so a transport blip at the first stage no longer ends a
mutating run; keep post-admission readback/poll/agent failures retried
only on an explicit read-only stage and never replay admitted tool work.
Preserve the true cause when the context is already done (join ctx.Err
with the typed transport error) and report a sanitized unknown provider
error name/status instead of a blanket summary.

Make the isolated format-repair deadline proportional to the stage
timeout (floored, capped and clamped to remaining minus a margin) so a
slow-but-repairable result is recovered without ever extending the stage
deadline; the bounded ladder, value guard, deny-all formatter session,
cumulative usage accounting and no-tool-replay rule are unchanged.

Update docs/model-results.md, docs/pipeline-performance-review.md and the
packaged skill references; add stage, opencode and server fixtures.
This commit is contained in:
2026-10-17 14:51:09 +01:00
parent 5adc961f88
commit 7b72b8f20f
15 changed files with 563 additions and 63 deletions
@@ -80,7 +80,10 @@ specific authorization.
Retained model-stage failures now carry a fixed sanitized category. A strictly
invalid final result (a duplicate nested field, or malformed/ambiguous JSON with a
byte offset) is labeled `FINAL RESULT VALIDATION`; request, V2 active-session poll
and final-readback failures are labeled `HARNESS TRANSPORT`. A validation failure
and final-readback failures are labeled `HARNESS TRANSPORT`. A pre-admission
request failure replays nothing and is retried for any stage; a post-admission
failure is retried only on an explicit read-only stage (see the 2026-10-17 section
below). A validation failure
preserves the admitted session, transcript and evidence and performs no second tool
execution. Confirmed ordinary-endpoint failures on 2026-10-11: an all-history
readback of exactly 262144 bytes of incomplete JSON (`invalid agent messages`), a
@@ -100,8 +103,9 @@ Source-level, mocked `internal/stage` regression coverage (not live-provider
evidence and not a deployment): malformed final-result recovery now tries a
deterministic local pass first (append missing closers, drop one trailing comma,
or insert the single comma/colon the parser expected), then at most one deny-all
formatter request whose deadline is derived from the payload size and the
attempt's remaining budget rather than a fixed 30-second constant. Every path
formatter request whose deadline is derived from the payload size, the stage
timeout and the attempt's remaining budget rather than a fixed 30-second
constant. Every path
records `repaired`, `partial` or `unrecoverable` in `format_repairs`; a `partial`
or `unrecoverable` payload is never returned as a completed result, and an
ambiguous payload (an unescaped quote/colon inside a string value) is never
@@ -112,6 +116,26 @@ unchanged. The run-55 `ui_reviewer` payload was retrieved read-only with
ambiguous error class, so it is reported unrecoverable rather than repaired. This
does not update or restart any running server.
## Harness transport reach retry and repair deadline: 2026-10-17
Source-level, mocked `internal/stage`, `internal/opencode` and `internal/server`
regression coverage (not live-provider evidence and not a deployment): the
harness transport path now distinguishes a pre-admission reach failure
(connecting or creating the session) from a post-admission readback/poll/agent
failure under the one `HARNESS TRANSPORT` category. A pre-admission reach failure
replays nothing, so it is retried within `retries` for any stage with a fresh
session and no replayed prompt; a post-admission failure is retried only on an
explicit read-only stage, and an `edit`/`shell`/legacy stage still never replays
admitted work. A context that expires during a request keeps both the sanitized
transport detail (operation/status/exit) and
`errors.Is(err, context.DeadlineExceeded)`; a bare attempt-boundary deadline is
not treated as a reach failure and stays terminal for a mutating stage. An
unrecognized provider execution-error name is reported as a bounded, sanitized
identifier plus any HTTP status. The isolated formatter deadline is now
proportional to the stage timeout (floored, capped, and clamped to
`remaining - margin` so it can never extend the stage/attempt deadline). These are
mocked fixtures; a deployed server is not updated by this change.
## Failure-handling source changes: 2026-10-15
Source-level, mocked `internal/stage` and `internal/server` regression coverage