Skip to content

feat(compaction): explicit native protocol capabilities for Responses gateways - #6759

Closed
fliaping wants to merge 9 commits into
lidge-jun:devfrom
fliaping:feat/native-compact-gateway
Closed

fliaping wants to merge 9 commits into
lidge-jun:devfrom
fliaping:feat/native-compact-gateway

Conversation

@fliaping

@fliaping fliaping commented Oct 8, 2026 •

Copy link
Copy Markdown

Summary

  • Add independent opt-ins for native Responses v2 compaction_trigger (supportsNativeCompactionTrigger) and v1 /responses/compact (supportsNativeCompactEndpoint) on custom openai-responses providers. Custom gateways keep portable summaries by default. Neither flag implies ciphertext replay (decodesNativeCompactionBlobs), OpenAI identity, or permission to forward caller credentials.
  • Custom native v1 reuses the normal Responses URL/header construction (src/adapters/openai-responses/transport.ts) for key/local/forward routes, plus ordinary replay sanitization: explicit plaintext/metadata preservation, null-channel omission, drop-reasoning and strict adjacency policy. Generic OAuth providers stay on routed compaction with their existing credential selection, refresh and dispatch fence; native v2 remains independent.
  • A successful native v1 replacement history is validated (nativeCompactResponseSchema) before serving/replay provenance is committed. Failed, empty or malformed HTTP 200 bodies keep the prior identity. Cross-provider overrides and the v1 fallback stay portable.
  • Gateway sends always carry only the gateway transport's headers, and Codex pool recovery (401 refresh replay, quota and transient alternate accounts) plus pool outcome recording skip gateway sends. Before this, those branches relied on the router pinning the only pool-mode provider (openai) to the canonical URL; the boundary now holds locally (tests/responses/native-compaction-gateway-credentials.test.ts).
  • Provider, configuration and protocol docs and the owning structure/ notes are updated.

Original contribution by @fliaping (61afaab15); maintainer follow-ups through b93c76f93; this push merges current dev and adds the gateway recovery guard.

Verification

Head ae286e2ca60e0c66d133acb9c089eca2cc6eac50, merged with dev 7640a942b350 (0 behind at push). Normal fast-forward push to the contributor branch; no rebase or force push. Merge conflicts were only in docs, structure/ and test-layout files and were resolved by keeping both sides.

  • OCX_TEST_NO_QUEUE=1 OPENCODEX_HOME=$(mktemp -d) CODEX_HOME=$(mktemp -d) bun scripts/test.ts --parallel=1 over 27 files (all native-compaction-*, responses-compaction* incl. -http-isolation, responses-pool-401-refresh, compact-transient-alternate, responses-compact-handoff-admission, responses-canonical-only-top-level-fields, responses-opaque-blob-recovery, opaque-blob-wrapped-rejection, openai-responses-passthrough, reasoning-replay identity/robustness/scope-source, deepseek-reasoning-replay, test-layout, test-layout-tooling, file-size-ratchet, core-lab-boundary): 952 pass / 0 fail.
  • New gateway credential regression: 0 pass / 2 fail before the guard (the gateway received a refreshed stored Codex bearer on 401 and a stored account bearer on 429 when a gateway row was given a pool account mode), 2 pass / 0 fail after.
  • bun run typecheck, bun run structure:check, bun run privacy:scan: exit 0.
  • Independent gpt-6.1-sol (high) security review of the full diff at ae286e2ca: PASS, no P0–P3 findings, covering credential forwarding on every compact send path, OAuth exclusion, editor field policy, and replay/provenance binding.
  • Not run locally, because about 20 concurrent worktrees share this machine: the full bun run test, bun run test:changed (its import graph selects ~1.8k files for this change), and the docs-site build (it last passed at b93c76f93; this push only merges one docs sentence). Cross-platform CI on the exact head: https://github.com/lidge-jun/opencodex/actions/runs/38714586378

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.

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.

@coderabbitai

coderabbitai Bot commented Oct 8, 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

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

@github-actions github-actions Bot added the intake: hygiene-blocked Deterministic PR hygiene checks failed label Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

⚠️ Deterministic hygiene checks failed.

  • unsponsored_surface — This changes an authentication, workflow, release-automation, or dependency surface. MAINTAINERS.md requires security review for these; ask a maintainer to apply maintainer-sponsored once they have reviewed it. Paths: src/server/auth-cors.ts.

@github-actions github-actions Bot added the enhancement New feature or request label Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • hygiene: unsponsored_surface.

What to do

  • Fix unsponsored_surface — This changes an authentication, workflow, release-automation, or dependency surface. MAINTAINERS.md requires security review for these; ask a maintainer to apply maintainer-sponsored once they have reviewed it. Paths: src/server/auth-cors.ts.
  • 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.

This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.
@fliaping Tick the boxes once required local validation has passed with commands, results, and any full-suite exception documented, your branch is on the latest dev commit, and every correct Codex and CodeRabbit finding is resolved.

@fliaping

fliaping commented Oct 8, 2026 •

Copy link
Copy Markdown
Author

@lidge-jun This draft is blocked by unsponsored_surface on src/server/auth-cors.ts. Could a maintainer review the security boundary and, if satisfied, apply maintainer-sponsored? That file adds the two new capability fields at the existing editor policy level beside decodesNativeCompactionBlobs; it does not grant canonical identity or caller credential forwarding. The shared transport and compact-v1 metadata/replay handling were also independently reviewed, with no remaining security or logic findings after the regression fixes. Head: 61afaab15b5302dc10a954725bd2e14c69cee34e. Local focused validation and the full-suite resource exception are documented in the description. Required upstream CI has not passed, and CodeRabbit skipped this draft; I am keeping it in draft rather than marking it ready or applying an approval label myself. Live sub2api evidence supports v2 generation plus replay only; its native v1 endpoint is explicitly documented as unsupported in that deployment.

@Ingwannu Both failed checks (hygiene and enforce-target) report the same unsponsored_surface requirement, not a compile/test failure. Could either maintainer perform the required security review and apply maintainer-sponsored if approved? The fork author cannot submit a formal reviewer request (GitHub returned a permission error), so this comment is the review request. The label should trigger both gates to reevaluate; no source or workflow changes are needed to hide or bypass the requirement.

@Ingwannu

Copy link
Copy Markdown
Owner

For the explicit review request: I confirmed head 61afaab15b5302dc10a954725bd2e14c69cee34e and the current unsponsored_surface hold. The schema/editor mapping and the transport/replay contract require their own explicit boundary review; author-reported or model-reported validation is not that sign-off. I have not completed that review in this pass and am not adding maintainer-sponsored as a gate workaround.

Cross-platform CI 37765275217 and React Doctor 37765275223 remain action_required, not compile/test failures or passing execution. Keep Draft and retain the documented v2-generation/replay versus unsupported native-v1 distinction. No workflow execution, scan or sponsorship label was authorized here.

A custom native v1 compact send used whatever headers the pool recovery
branches handed it. The 401 refresh replay and the quota/transient
alternate-account sends materialize stored ChatGPT credentials, so a
gateway row that ever carried a Codex account mode would receive them.
Today the router pins the only pool-mode row to the canonical URL; this
makes the gateway boundary hold locally instead of depending on that pin.

Gateway sends now always use the gateway transport's headers, and pool
recovery and pool outcome recording skip gateway transport.
lidge-jun added a commit that referenced this pull request Oct 16, 2026
Unify native v2 capability gating between retention and dispatch when carrying #6603 with #6759. Cover canonical and gateway native routes with the same wire/archive regression.

Co-authored-by: panyuanyuan <panyuanyuan@hetao101.com>
Co-authored-by: fliaping <269832017@qq.com>
@lidge-jun

Copy link
Copy Markdown
Owner

Being carried into #7217 with your authorship preserved; this PR will be closed when the bundle lands.

lidge-jun added a commit that referenced this pull request Oct 16, 2026
#6759, #6930, #6603, #6758) (#7217)

Carried from #6759, #6930, #6603, #6758 (one commit per source PR, original authors preserved). Retention across account/model switches is opt-in and defaults off.

Remote validation (hosted GitHub Actions unreliable; local tests not run by maintainer rule): union candidate codex/prr-integ-8 = dev c03eafd + #7224 + #7223 + #7225 + #7217 + #6454 + #6594 plus a Gentle Shell import-cycle fix (integ-9 e1f289c: typecheck + full suite on mini (Windows) and lidge (Linux), compared with the same host's dev runs) and a test-only Windows path-escaping fix for the reasoning-retention routing test (integ-10 0d4cba7, tree a2b309a: that file re-run on both hosts).

Co-authored-by: fliaping <269832017@qq.com>
Co-authored-by: panyuanyuan <panyuanyuan@hetao101.com>
Co-authored-by: yuanyuanlove <yuanyuanlove@users.noreply.github.com>
@lidge-jun

Copy link
Copy Markdown
Owner

Landed on dev in 65ef8b3 via #7217 (your change is its own commit in that bundle, and the squash keeps your authorship as Co-authored-by). Thank you!

@lidge-jun lidge-jun closed this Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request intake: hygiene-blocked Deterministic PR hygiene checks failed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants