Skip to content

fix(lab): preserve CL-03 live transport failure classes - #1710

Merged
lidge-jun merged 3 commits into
devfrom
agent/cl03-live-timeout-classification
Aug 15, 2026
Merged

fix(lab): preserve CL-03 live transport failure classes#1710
lidge-jun merged 3 commits into
devfrom
agent/cl03-live-timeout-classification

Conversation

@Wibias

@Wibias Wibias commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Preserve separate CL-03 first-byte and response-inactivity deadlines in pinned HTTP.
  • Convert first-byte stalls, body inactivity, and output-byte ceiling failures into typed transport errors.
  • Keep the legacy idleTimeoutMs request/response timeout path for existing pinned HTTP consumers.
  • Add focused loopback regressions for all three failure modes.

Root cause

The pinned HTTP layer emitted generic Error objects for first-byte stalls, response inactivity, and output-cap overruns. The Lab sender only translated the connect-timeout error, and it read response.text() outside that translation block.

As a result, runLiveScenario() treated realistic provider stalls and oversized responses as harness_failure / execution_error, instead of the timeout and resource-limit blockers defined by the CL-03 live authority.

Body failures also need to cross the already-resolved Response boundary. The pinned transport now errors the response body stream before tearing down the request, so inactivity and byte-limit failures remain observable by response.text() and retain their typed classification.

Compatibility

Existing image transport callers still rely on idleTimeoutMs being installed through ClientRequest.setTimeout() and IncomingMessage.setTimeout(). The new split deadlines are only used when firstByteTimeoutMs or inactivityTimeoutMs is supplied, so legacy callers keep their existing timeout behaviour.

Impact

Live-route evidence could record the wrong failure class for normal provider or network stalls and oversized responses. That makes an environmental or bounded-resource failure look like a Lab infrastructure fault.

Validation

Added tests/lab-live-pinned-timeouts.test.ts covering:

  • delayed response headers -> first_byte_timeout
  • stalled response body -> inactivity_timeout
  • response over the byte ceiling -> output_byte_limit

The existing tests/images/pinned-https-get.test.ts suite also exercises the legacy idleTimeoutMs request/response timeout contract. CI exposed that compatibility path had been dropped in the first commit, so the follow-up commit restores it without changing the new Lab-specific deadline path.

A second CI run exposed that post-header body failures were being sent through the pre-header promise rejection helper after the Response had already resolved. The latest commit separates body-stream failure state and signals the stream error before transport teardown.

The branch starts from current dev, is three commits ahead, and has no unrelated file changes.

Local Bun execution is not available in this ChatGPT environment, so GitHub CI is the executable validation source for this PR.

Follow-up to #1352.

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling and classification of connection, first-byte, inactivity, and excessive-response failures.
    • Responses continue to include their status, approved headers, and body when requests succeed.
    • Added clearer transport error codes for timeout and output-limit conditions.
  • Improvements

    • Added separate controls for first-byte and inactivity timeouts.
    • Retained the existing idle timeout setting for compatibility.
    • Added coverage for timeout and excessive-response scenarios.

@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f279ff83-83a4-486f-b355-3aabc644969a

📥 Commits

Reviewing files that changed from the base of the PR and between d9655f3 and c715534.

📒 Files selected for processing (1)
  • src/lib/pinned-http.ts

📝 Walkthrough

Walkthrough

The pinned HTTP client now separates first-byte and inactivity timeouts, emits typed timeout and output-limit errors, and preserves legacy idle-timeout fallback. The live sender maps these errors to transport results. Loopback tests verify the new classifications.

Changes

Pinned HTTP timeout handling

Layer / File(s) Summary
Timeout contracts and resolution
src/lib/pinned-http.ts
PinnedHttpErrorCode now includes first_byte_timeout, inactivity_timeout, and output_byte_limit. Request options add separate timeout values and retain deprecated idleTimeoutMs fallback.
Request timeout lifecycle
src/lib/pinned-http.ts
The request starts and clears first-byte and connection timers at socket and response events. Body reads use the inactivity timeout. Timeout and output-limit failures use typed PinnedHttpError values.
Sender mapping and live validation
src/lib/lab-live-pinned-sender.ts, tests/lab-live-pinned-timeouts.test.ts
The sender reads the body inside the guarded HTTP operation and maps the new pinned HTTP errors to TransportError codes. Loopback tests verify first-byte, inactivity, and output-limit classifications.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: 🔵 Low · up to c7155

The PR correctly classifies live transport failures, but response timeout cleanup may leave stale timeout behavior on reused connections. The change is mergeable with explicit owner follow-up to reset and remove the timeout on all terminal paths.

Sequence Diagram(s)

sequenceDiagram
  participant LabLivePinnedSender
  participant pinnedHttpPost
  participant LoopbackHTTPServer
  LabLivePinnedSender->>pinnedHttpPost: Send request with separate timeout limits
  pinnedHttpPost->>LoopbackHTTPServer: Establish pinned HTTP request
  LoopbackHTTPServer-->>pinnedHttpPost: Send headers or response body bytes
  pinnedHttpPost-->>LabLivePinnedSender: Return response or typed timeout/output-limit error
  LabLivePinnedSender-->>LabLivePinnedSender: Map PinnedHttpError to TransportError
Loading

Suggested reviewers: ingwannu, lidge-jun, if2007

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: preserving CL-03 live transport failure classifications in the lab pinned HTTP transport.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/cl03-live-timeout-classification

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the bug Something isn't working label Aug 14, 2026
coderabbitai[bot]

This comment was marked as resolved.

@Wibias
Wibias marked this pull request as ready for review August 14, 2026 22:21
@lidge-jun
lidge-jun merged commit 0827bc6 into dev Aug 15, 2026
37 checks passed
@Wibias
Wibias deleted the agent/cl03-live-timeout-classification branch August 15, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants