Skip to content

fix: Stream completion-stable canonical apply_patch input - #7506

Merged
lidge-jun merged 1 commit into
lidge-jun:devfrom
Platinum-Scripts:perf/canonical-apply-patch-streaming
Oct 28, 2026
Merged

lidge-jun merged 1 commit into
lidge-jun:devfrom
Platinum-Scripts:perf/canonical-apply-patch-streaming

Conversation

@Platinum-Scripts

@Platinum-Scripts Platinum-Scripts commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Routed apply_patch input on the native Responses compatibility path stays buffered until completion even after the exact canonical opening marker has arrived. The same guard covers patch delimiters that completion may repair, so a valid canonical patch appears silent while its body is generated.

Stream only completion-stable prefixes once the canonical LF/CRLF opening is resolved. Hold ambiguous/decorated openings and potentially rewritable closing decorations; keep exec/helper retarget buffering unchanged. Validate published progress against repaired authoritative input before executable completion. A malformed wrapper that would rewrite the published prefix fails through the existing failed-terminal path and releases retained state.

Valid completion bytes, tool identities, execution timing and tool-result replay are unchanged. This improves visible delivery of already-generated input; it does not claim faster provider decoding.

This draft replaced #7460 to move the contribution head to Platinum-Scripts.

Verification

Author validation (earlier heads):

  • Required Bun1.4.3 runner before rebasing: OCX_TEST_RUNNER_BUN=... bun run test:changed — 31,233 passed, 37 skipped, 0 failed across 1,346 selected files, 695,961 assertions. Full 2,515-file suite was not run; the import-graph selection covers the changed runtime modules, with explicit eager-relay and malformed-wrapper regressions.
  • Shipped Bun1.4.2 affected suites — 212 passed, 0 failed; typecheck passed.
  • Independent adversarial verification — 111 passed / 175,007 assertions, including every prefix/split, LF/CRLF, decorations, future suffixes, malformed/duplicate wrappers, namespaces, no-operation bodies and multiple closing markers.
  • The real eager relay emits one response.failed, with no executable input.done/item.done/completed, when repaired input disagrees with an already-published prefix.
  • Actual OpenCodex source → verified local TLS → actual proxy executor → gated fake provider: canonical apply_patch via the existing grammar compatibility wrapper reaches the client before provider completion, then replays the exact real tool result on turn two. The baseline first-input gate times out. This is a local protocol test, not a live-provider TTFT benchmark.
  • Rebased onto current dev1202598; the first current-head test:changed run had 31,730 passes, 37 skips and one 5-second timeout in the compaction-override suite. That entire file then passed in isolation (73 tests, 740 assertions). The broad rerun without concurrent builds passed: 31,731 passed, 37 skipped, zero failed across 1,361 files (672,877 assertions, 280.6 seconds). The earlier timeout remains disclosed. Typecheck/privacy scan pass. Structure check passes after keeping the mapped wire document within its existing line budget. No gate limits or suppressions changed.

Maintainer carry (2026-10-28): the branch was 227 commits behind dev and conflicted in structure/transports/inventory.md. It was rebased onto current dev as one commit (e637125ee, original authorship kept); the inventory keeps dev's two new rows and takes this change's "Responses custom-tool preview" wording. The diff is unchanged otherwise (9 files, +278/-19). NOT RUN locally on the rebased head: the focused apply-patch/custom-tool/eager-relay files and typecheck (the shared test lock was held by another run); PR CI on this head (gates, typecheck, test changed) is the validation of record.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed (structure/transports/).
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults (no auth or credential surface).

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • 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

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

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

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • review readiness checklist open (0/4 boxes ticked).

What to do

  • Tick all four boxes in the PR description once you're done (currently 0/4).

Review readiness checklist

  • ⬜ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ⬜ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ⬜ I resolved all correct Codex and CodeRabbit findings.
  • ⬜ My PR is ready for review.

0/4 boxes ticked.

Automatic draft conversion failed. Please convert this pull request to a draft manually until every box above is ticked.

Hygiene

✅ Deterministic PR hygiene checks passed.

@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer triage (2026-10-28, against dev e1976da):

The canonical apply_patch progress improvement is still needed: dev continues buffering this case at src/server/responses-custom-tool-repair.ts:323. The contribution includes focused prefix, completion-consistency and eager-relay regressions.

The remaining work is small enough for a maintainer carry:

  1. Reconcile the transport inventory row at structure/transports/inventory.md:37, preserving current dev entries and the new streaming contract.
  2. Reformat the description to include Summary, Verification and Checklist, and consolidate the duplicate readiness lists.
  3. Validate the resulting head with Bun 1.4.4 through bun scripts/test.ts tests/responses/apply-patch-envelope.test.ts tests/responses/responses-custom-tool-stream-consistency.test.ts tests/server/relay-eager.test.ts, plus typecheck and the relevant structure/size checks. Document any full-suite exception.

No additional feature work is requested from you. A maintainer can carry these integration fixes with your authorship credit preserved, then obtain current-head PR CI. The later failed workflow records have no executed jobs, so their cause remains unestablished; the earlier green run alone does not establish readiness.

Rebased onto current dev as one commit (lidge-jun#7506); the transport inventory
row keeps dev's new rows and takes this change's preview wording.

Co-authored-by: JUN <243035832+lidge-jun@users.noreply.github.com>
@lidge-jun
lidge-jun force-pushed the perf/canonical-apply-patch-streaming branch from 0d286e5 to e637125 Compare October 28, 2026 03:06
@lidge-jun
lidge-jun marked this pull request as ready for review October 28, 2026 03:09
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-28T03:36:54.883106Z
We couldn’t complete this review. Comment @codex review to try again.
e637125 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions
github-actions Bot marked this pull request as draft October 28, 2026 03:34
@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration into dev (MAINTAINERS.md, "Review and merge policy"). This is maintainer integration, not an approving review.

  • Exact head e637125eee12f3e2c1231744d2408cf2bc68e3e6: the contribution rebased onto dev as one commit after a conflict in structure/transports/inventory.md (dev's new rows kept, this change's preview wording taken). No conflict with current dev.
  • Exact-head PR CI: Cross-platform CI 40624780037 (gates, test changed, structure gate, docker smoke, npm-global, storage policy, api usage, ci), Catalog async contracts 40624779952, enforce-target: all success.
  • Review: canonical apply_patch input now streams completion-stable prefixes once the canonical opening is resolved; ambiguous openings and rewritable closing decorations stay buffered, and a wrapper that would rewrite an already-published prefix fails through the existing failed-terminal path. Exec/helper retarget buffering, completion bytes and tool-result replay are unchanged. NOT RUN locally on the rebased head: focused files and typecheck (shared test lock); test changed on this head covers the import-connected suites.

Thank you @Platinum-Scripts.

@lidge-jun
lidge-jun marked this pull request as ready for review October 28, 2026 03:35
@lidge-jun
lidge-jun merged commit 6f0d5eb into lidge-jun:dev Oct 28, 2026
30 of 33 checks passed
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