Skip to content

fix(replay): preserve terminal refusals across link and native transports - #8843

Draft
luvs01 wants to merge 7 commits into
lidge-jun:devfrom
luvs01:fix/link-replay-refusal
Draft

luvs01 wants to merge 7 commits into
lidge-jun:devfrom
luvs01:fix/link-replay-refusal

Conversation

@luvs01

@luvs01 luvs01 commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

A Link failure after dispatch could become a generic gateway error, allowing retries, key rotation or a combo hop to send the same request again. Native POST response-header deadlines had the same problem after the upstream had received the body.

  • Separate proven-unsent Link failures from ambiguous post-dispatch failures. Preserve terminal replay refusals through response formatting, native Responses/Chat/Messages, key retries and combo routing.
  • Honor an explicit x-should-retry: false before waiting for or classifying the body, including delayed HTTP bodies. Keep proxy-owned quota attribution separate from that general no-retry instruction.
  • Stop automatic replay when the proxy's own POST header deadline caused the fetch rejection. Preserve caller cancellation, proven connection refusal, GET/HEAD behavior and ordinary HTTP authentication/quota policy.
  • Document the historical replay-refusal code's deadline meaning and use a fixed message that does not falsely assert a connection reset.
  • Add wire, helper and opt-in native TCP regressions. This fixes replay safety; it does not introduce a standalone Home-first Remote Link mode.

Verification

Final local integration: 723d34c2a6706cc054d3af6a32c1a899aaab6728, with dev commit 3ef14ad572f3682b01143018c5efb6cc1f3180f6. The merge had no conflicts or manual production changes. Three additional regressions cover composition with offline wait.

Bun 1.4.4, repository-root runner, official preload and semantic test lock, one worker. Commands used the prefix bun --no-env-file --no-install scripts/test.ts and suffix --parallel=1 --timeout 30000 --no-env-file --no-install:

Files / additional selection Result
./tests/responses/responses-offline-resend.test.ts ./tests/responses/responses-combo-unavailable-cause.test.ts ./tests/server/fetch-header-timeout.test.ts 42 passed
./tests/lib/upstream-retry.test.ts ./tests/providers/upstream-transient-retry.test.ts 153 passed
./tests/server/replay-refusal-parity.test.ts --test-name-pattern 'serialized relay|ordinary quota|no-retry quota' 9 passed
./tests/test-layout.test.ts ./tests/test-layout-tooling.test.ts ./tests/ci-workflows/file-size-ratchet.test.ts --test-name-pattern 'membership oracle|tests/ layout|file-size ratchet' 15 passed
./tests/server/native-remote-local-fallback.test.ts, in the explicit credential-free proof environment 18 passed

Total: 237 passed / 0 failed / 1,416 assertions, with no timeout in the final integration runs. bun check --no-script --noEmit checked 2,554 files; bun run structure:check and bun run privacy:scan passed.

The native proof uses actual handlers/adapters and loopback TCP. It observed:

  • healthy Home: one Home dispatch, no local dispatch;
  • connection refusal before dispatch: one local dispatch;
  • post-body reset/header deadline: one Home dispatch, no local dispatch;
  • native Responses/Chat/Messages with retries and key pools enabled: a header deadline makes one Home dispatch, no backup-key or local dispatch;
  • caller cancellation, real HTTP 401/quota, cooldown recovery and two-turn tool continuity under their distinct policies.

The 18-case proof is opt-in (OCX_NATIVE_PROOF_CREDENTIAL_FREE=1 plus an isolated OCX_NATIVE_PROOF_ROOT and process-local homes/TEMP/cache, with credential variables absent). Its preflight checks the repository preload, guard and path containment before importing the product graph; every case drained owned work. Default CI skips this proof; three new helper regressions in the existing test file run normally. Tool continuity may reconstruct the prefix rather than forward the original response ID.

The original header-timeout case failed before the fix; disabling the new refusal branch also made the focused regression fail, then restoring it returned the helper file to green. Independent review covered the runtime change at 2c5072e59c7826e3928b44ef265657ec0080229c; the subsequent merge required no manual production edits, retained the reviewed header-deadline helper bytes, and received the integration checks above.

Full/import-connected local validation was not completed because the broader selection exceeded the shared Windows host's execution budget. This uses the documented resource exception; the final focused coverage above is the local claim, with broader coverage left to automatic PR CI. Official SDK execution, documentation build and real two-device Link enrollment/operation were not run. Hosted CI remains a separate posted-head check.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

The security checkbox records implementation review; explicit maintainer security review remains required before merge.

…playable refusal, not home_unreachable

A post-dispatch transport failure or a post-resolve abort cannot prove the turn never reached Home. Labelling them home_unreachable authorized a second dispatch of a possibly-running turn via GOAT local fallback or a combo hop. Answer the shared replay-refusal contract instead (429, x-should-retry: false, upstream_reset_replay_refused / upstream_closed_before_response, in-process markers). Clean refusals keep home_unreachable: preflight failures, credential-free auth deadlines, and refused connections with an untouched body.
…and sync refusal docs

Post-dispatch failures that leave the upstream response undeliverable
(response headers/body over the relay limit) now settle as a
non-replayable 429 upstream_response_refused instead of a retryable 502
that would re-dispatch an already-run turn. A refused connection stays
home_unreachable whenever the request provably never left the relay,
regardless of body consumption, while the resendable check only gates
the relay-internal resend. Docs and the refusal-code contract list the
new code in en/es.
@coderabbitai

coderabbitai Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Nov 16, 2026

This branch has not been deployed

No deployments
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.

1 participant