Skip to content

fix: preserve Pi session affinity through native Chat - #3880

Merged
lidge-jun merged 8 commits into
devfrom
codex/260907-a-affinity
Sep 7, 2026
Merged

fix: preserve Pi session affinity through native Chat#3880
lidge-jun merged 8 commits into
devfrom
codex/260907-a-affinity

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Summary

Carries #3858 with original commit provenance. Pi configuration opts into affinity; native Chat, bridged Chat and Responses preserve the same canonical Go identity. Operator override precedes the Codex lane, which precedes fallback client metadata. Independent fixed vectors and distinct mixed-header fixtures pin hashing and precedence.

The source PR's checked local-CI boxes and stale blocked-readiness prose are not used as verification. This carry records actual remote evidence and explicit local NOT RUN. English and all7translated Pi guides now include the flag and cache-retention caveat; the M-owned providers.md hunk is supplied separately, including the Pi cacheRetention:none qualification; this layer does not modify that file.

Closes #3857.

Co-authored-by: makesomethingshit 246213378+makesomethingshit@users.noreply.github.com

Verification

  • Local tests/typecheck/build/install/docs build: NOT RUN, by explicit maintainer instruction.
  • git diff --check: PASS. All10Acommits compare = in git range-diff after rebasing onto ddee5e8b4e0535f3d99306b55f6ac4fb61c2d0ea; no conflicts.
  • Expected cumulative merge tree equals top tree d4f0958225bb6bc64c707fbc9b9568fb567f9b9e.
  • Required lane gate: PASS (16/16 jobs). Current remote evidence: CI34113638182, workflow_dispatch lane=all, exact top c84cc3b3e076b6c49cf93a6ca267f6303a698f5b.
  • Explicit updated user/maintainer lane gate: Linux4 + macOS2 + gates/storage/api/keyring/npm/docker (16 jobs) must pass. Windows6 full-suite shards and macOS control are deferred to the final release-train head; they are not claimed passed. Windows keyring/npm smoke jobs remain required. The full-run aggregate is not this lane's acceptance gate under this instruction.
  • Lower-layer product CI: NOT RUN separately, as authorized; current top evidence certifies the cumulative tree. Prior runs are superseded/cancelled; no passing claim relies on a cancelled run.
  • Independent current-head source/security review: PASS, A blockers=0; details below. Published A review findings are resolved.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed; the M-owned providers.md hunk is supplied separately.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Manual chain

Manual dependent PRs, native stack: null; integrate bottom-up through the main session only.

Order Source / carry Head branch Base Head SHA
1 #3862#3879 codex/260907-a-reasoning dev d8b18b1ecb013f46585c9e6dadac0b95caa49836
2 #3858#3880 codex/260907-a-affinity codex/260907-a-reasoning feb1855df91e5db351699d959d88d7e6c21c0f93
3 #3769 residual → #3881 codex/260907-a-compact codex/260907-a-affinity c84cc3b3e076b6c49cf93a6ca267f6303a698f5b

Maintainer integration is reserved for the main session under MAINTAINERS.md; this is not self-approval. This lane does not merge. Refresh dev, heads/bases, review threads, required gates and expected tree before integration; cascade and reverify if dev advances. The revised platform gate above is an explicit user decision for this lane, with deferred platform verification at final train head.

Independent review

Independent gpt-6-astra high explorer Avicenna: source/security PASS. Reviewed d8b18b1ecb013f46585c9e6dadac0b95caa49836..feb1855df91e5db351699d959d88d7e6c21c0f93. All14affinity files unchanged; same patch ID after cascade. B quota opt-in/canonical checks and outbound TLS/address admission do not replace the Go affinity destination guard. A blockers0.

This is an A-scoped source/security review, not blanket approval of the new base. Local tests/typecheck/build/install: NOT RUN.

VERDICT: PASS

Landing readiness

LANDABLE under the explicit updated lane policy. Exact-head Linux4, macOS2, gates, storage policy, API usage, all3keyring, all3npm-global and Docker jobs are SUCCESS. PR gates enforce-target/hygiene/label are SUCCESS, review findings resolved, and native stack is null. Final fetch confirmed dev ddee5e8b4e0535f3d99306b55f6ac4fb61c2d0ea; expected cumulative merge tree equals tested top tree d4f0958225bb6bc64c707fbc9b9568fb567f9b9e. Windows6/macOScontrol and full aggregate are not claimed green; deferred under user policy. No merge performed.


Maintainer integration decision (MAINTAINERS.md, dev-only admin integration): @lidge-jun integrates lane A's manual chain (#3879#3880#3881) into dev bottom-up. Chain-top evidence at head c84cc3b3e: Cross-platform CI run 34113638182 — Linux test 1/4–4/4, macOS 1/2, 2/2, gates, storage policy, api usage, keyring ×3, npm-global ×3, docker smoke = success. Windows shards and macos control were cancelled by maintainer policy: they run once on the final release-train head. Prospective merge tree of origin/dev@ddee5e8b4 + top = d4f095822 = tested tree. Independent source/security reviews PASS per PR body; review threads resolved. Local suites NOT RUN. This is maintainer integration, not self-approval.

@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner September 7, 2026 09:33
@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (2)
  • ^dev$
  • ^preview$

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: dbbd829a-e4ca-46f6-aaf0-7414051d16ca

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 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 Completed 2026-09-07T09:39:01.676779Z a7220a7 PR opened
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a7220a7104

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/clients/config-export.ts
@github-actions github-actions Bot added the bug Something isn't working label Sep 7, 2026
@lidge-jun
lidge-jun force-pushed the codex/260907-a-affinity branch from a7220a7 to 5a462d3 Compare September 7, 2026 09:49
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@lidge-jun

Copy link
Copy Markdown
Owner Author

리뷰 · 우선순위 65 / 80

이 PR은 체인 두 번째입니다. base는 codex/260907-a-reasoning(#3879), head는 codex/260907-a-affinity입니다. 원본은 #3858이고, Pi가 보낸 세션 친화성(session affinity)을 native Chat 경로에서도 OpenCode Go까지 같은 신원으로 유지하게 만듭니다. #3857을 닫는 방향입니다.

지금 dev(그리고 #3879만 올라간 상태)에서는 Responses 쪽 resolveOpenCodeGoTransport가 Codex 레인/세션을 해시해 Go에 넘기지만, native Chat(/v1/chat/completions)은 그 연결이 약합니다. Pi가 x-opencode-session을 줘도 Chat 인그레스에서 Go 쪽으로 안정적인 X-OpenCode-Session(ocx_… 해시)이 안 나가거나, 대화마다 갈라지지 않을 수 있습니다.

이 PR은 세 곳을 맞춥니다. 첫째, src/clients/config-export.ts에서 Pi export만 compat.sendSessionAffinityHeaders: true를 켭니다. Prime Agent는 같은 models.json 계약이지만 세션 헤더 opt-in은 하지 않도록 테스트를 바꿨습니다. 둘째, src/server/chat-completions.ts에서 라우트 직후 resolveOpenCodeGoTransport를 호출하고, 내부 브리지 헤더에 x-opencode-session을 실어 줍니다. 셋째, src/server/responses/core.ts도 세션 레인 ID가 없을 때 x-opencode-session으로 떨어지게 합니다.

우선순위는 운영자 override → Codex 레인 → 클라이언트 fallback으로 테스트에 고정되어 있습니다. 악성/무관 destination으로 affinity 헤더가 새지 않는 테스트도 있습니다. 현재 dev 대비 의미는 분명합니다. Pi ↔ OpenCode Go 캐시/어피니티가 native Chat에서도 Responses와 같은 규칙으로 동작해야 긴 세션이 깨지지 않습니다.

types.ts/config.ts 대분할과 충돌하지 않습니다. 다만 base가 #3879이므로 #3879가 먼저 들어가야 하고, 원본 #3858은 캐리 합류 후 landed-via로 닫는 편이 맞습니다. 라인·경로 관찰에서 큰 버그는 보이지 않습니다.

src/clients/config-export.ts (buildPiClientConfig / buildPiContribution) - Pi에만 affinity compat를 켜고 Prime은 제외한 분리가 명확합니다. export 기본값 인자가 false이고 contribution/EXPORT_CLIENTS.build만 true를 넘깁니다.
src/server/chat-completions.ts (route 직후 Go transport 해석) - sessionLaneIdFromRequest(req.headers) ?? normalizeLogConversationId(x-opencode-session) 패턴이 Responses core와 같습니다. FORWARD_HEADERS 앞에 x-opencode-session을 넣는 주석(내부 메타, Go resolver가 해시)도 일관됩니다.
tests/providers/opencode-go-session-header.test.ts - native Chat 안정 해시, 대화 분리, renamed provider 운영자 헤더, Pi 헤더만 있는 경우, 고정 SHA-256 벡터, override 우선순위, evil destination 미전송까지 한 파일에 모여 있습니다. 체인이 쌓인 뒤 원격 lane=all 증거가 이 레이어까지 커버하는지 확인이 필요합니다.
tests/clients/prime-client.test.ts / tests/config/client-config-export.test.ts - Prime은 affinity 없이 Pi 모델 계약만 공유하고, Pi 바이트 스냅샷에 compat 블록이 들어간 점이 고정됩니다.

메인테이너의 판단이 필요한 지점

너의 추천
#3879가 dev에 들어간 뒤 이 PR을 합치세요. #3858은 리베이스하지 말고 캐리 merge 후 landed-via로 닫으세요. 그다음 #3881로 이어가세요.

이 댓글은 grok-bot이 작성했습니다

Ingwannu and others added 8 commits September 7, 2026 19:51
…p ci]

(cherry picked from commit 9bcb774)

Co-authored-by: Ingwannu <186453546+Ingwannu@users.noreply.github.com>
Co-authored-by: Ingwannu <186453546+Ingwannu@users.noreply.github.com>
…opies [skip ci]

Thread live budgets through bridge and outbound callers, keep abnormal bridge cleanup on the typed overflow path, and retain only the constructed request body after serialization. Sync the authorized adapter and reference locale contracts.

Co-authored-by: Ingwannu <186453546+Ingwannu@users.noreply.github.com>
… ci]

(cherry picked from commit fbb214f)

Co-authored-by: makesomethingshit <246213378+makesomethingshit@users.noreply.github.com>
(cherry picked from commit 7e45a95f70689dfe1eb313c4af9aecbf2c44cdb6)
…kip ci]

(cherry picked from commit 9f15a7c)

Co-authored-by: makesomethingshit <246213378+makesomethingshit@users.noreply.github.com>
(cherry picked from commit 65908008e52c5dca2eb1130d1c0cff0e0732873d)
(cherry picked from commit 23d8693)

Co-authored-by: makesomethingshit <246213378+makesomethingshit@users.noreply.github.com>
(cherry picked from commit 1e65ffd4bc9ba8befdf6e3546643b428106f4650)
Co-authored-by: makesomethingshit <246213378+makesomethingshit@users.noreply.github.com>
Co-authored-by: makesomethingshit <246213378+makesomethingshit@users.noreply.github.com>
@lidge-jun
lidge-jun force-pushed the codex/260907-a-reasoning branch from f6359b8 to d8b18b1 Compare September 7, 2026 10:51
@lidge-jun
lidge-jun force-pushed the codex/260907-a-affinity branch from 075444c to feb1855 Compare September 7, 2026 10:51
@lidge-jun
lidge-jun changed the base branch from codex/260907-a-reasoning to dev September 7, 2026 11:03
@lidge-jun
lidge-jun merged commit dac7e28 into dev Sep 7, 2026
15 of 19 checks passed
@lidge-jun
lidge-jun deleted the codex/260907-a-affinity branch September 7, 2026 11:03
cb8010d6 pushed a commit to cb8010d6/opencodex that referenced this pull request Sep 7, 2026
…pat flag [skip ci]

Docs hunk from the lidge-jun#3858 carry (lidge-jun#3880) that lane A handed off because
guides/providers.md is owned by the main lane in this train.

Co-authored-by: makesomethingshit <246213378+makesomethingshit@users.noreply.github.com>
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.

3 participants