Skip to content

fix(kiro): gate request diagnostics behind the debug check (carry #3837) - #3867

Merged
lidge-jun merged 3 commits into
devfrom
codex/rt-m3-3837
Sep 7, 2026
Merged

fix(kiro): gate request diagnostics behind the debug check (carry #3837)#3867
lidge-jun merged 3 commits into
devfrom
codex/rt-m3-3837

Conversation

@lidge-jun

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

Copy link
Copy Markdown
Owner

Summary

Carries #3837 by @luvs01: Kiro request diagnostic payloads are no longer encoded when debug is off. Adds the test-isolation fix requested in the maintainer review (discussion_r3945935220): the test now snapshots and restores OCX_DEBUG, OCX_DEBUG_FRAMES and the runtime debug override, so an inherited OCX_DEBUG=1 cannot make the encoder-spy assertion fail.

(carried/reimplemented from #3837; Co-authored-by trailer in the commit)

Verification

  • Regression: tests/providers/kiro/kiro-stream.test.ts encoder-spy test with isolated debug settings runs in the chain-top CI.
  • Local checks NOT RUN by maintainer instruction.

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.

Manual review chain (integrate bottom-up; stack: null, no native stack)

Layer Branch Base Source
1 codex/rt-m1-3532 dev #3532 (Ingwannu)
2 codex/rt-m2-3840 layer 1 #3840 (chilung-cgu)
3 codex/rt-m3-3837 layer 2 #3837 (luvs01) + test isolation fix
4 codex/rt-m4-3843 layer 3 #3843 (luvs01) + same-delta fix
5 codex/rt-m5-3845 layer 4 #3845 (luvs01)
6 codex/rt-m6-2033 layer 5 #2033 (louis-tepe) reimplemented — chain top

Verification policy (maintainer instruction, this train): local test suite / typecheck / build were NOT RUN; branches pushed with --no-verify. Lower layers carry [skip ci]; the full Cross-platform CI (lane=all, Windows shards included) runs once at the chain top head and is the exact-head evidence for the cumulative tree.

Layer 3 of 6. Review this PR's diff only.


Maintainer integration decision (MAINTAINERS.md, dev-only admin integration): @lidge-jun integrates this manual chain into dev bottom-up. Exact chain-top evidence: Cross-platform CI run 34106345180 at head 6eadb1658 (lane=all: Linux 4/4, macOS 2/2 + control, Windows 6/6, gates, storage policy, api usage, keyring ×3, npm-global ×3, docker smoke, aggregate ci = success). Tested tree 7621cac89 equals the prospective merge tree of origin/dev@ece556a6e + chain top. Independent chain review PASS; #3845 security review PASS (see #3869). Local suites NOT RUN by maintainer instruction. This is maintainer integration, not self-approval. Lower-layer PR runs are skipped/cancelled by design ([skip ci]); they are not passing evidence on their own.

t and others added 3 commits September 7, 2026 18:17
… [skip ci]

Carries PR #3840 (head 9a21452, 5 commits squashed onto current dev):
gpt-6-astra, Grok and MAI models on GitHub Copilot default to the Responses
wire instead of Chat Completions, which returned unsupported_api_for_model.
Docs scope the per-wire model lists and the discovery fallback test covers
legacy overrides.

(carried from #3840)

Co-authored-by: chilung-cgu <215337896+chilung-cgu@users.noreply.github.com>
`debugProviderDiagnostic` already returns early when provider debug is off,
but its argument object is built by the caller first. The Kiro request path
therefore ran `new TextEncoder().encode(body).length` over the entire
serialized request body on every request, including when diagnostics were
disabled, and then discarded the result inside the callee.

Wrap the diagnostic call in `isDebugEnabled()` so the details are only
constructed when they can actually be emitted. `src/adapters/openai-chat.ts`
already guards its diagnostics the same way.

The regression asserts that building a request performs no `TextEncoder`
encode over the serialized payload while diagnostics are off; it fails
without the guard and passes with it.

(cherry picked from commit d5d711a)

Co-authored-by: luvs01 <27862058+luvs01@users.noreply.github.com>
…ate reads [skip ci]

Resolves the maintainer objection on #3837 (discussion_r3945935220): the
shared setup cleared only OCX_DEBUG_FRAMES, so an inherited OCX_DEBUG=1 or a
runtime debug override made the encoder-spy test fail legitimately. Snapshot
OCX_DEBUG, OCX_DEBUG_FRAMES and the runtime override in beforeEach, clear
them, and restore the exact previous values in afterEach.

Co-authored-by: luvs01 <27862058+luvs01@users.noreply.github.com>
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner September 7, 2026 09:24
@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: 128068f7-e680-4133-9f2a-4bfc483ea16d

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:27:57.410741Z 6061dcc 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.

@github-actions github-actions Bot added the bug Something isn't working label Sep 7, 2026
@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

리뷰 · 우선순위 54 / 80

이 PR은 기여자 #3837(luvs01)을 메인테이너 릴리스 트레인 레이어 3(codex/rt-m3-3837, base codex/rt-m2-3840)으로 옮긴 캐리입니다. 지금 dev HEAD는 ece556a6e(2.47.0 + #3854 code-mode host contract)이고, Kiro 어댑터의 요청 진단 경로는 그대로입니다. 문제는 단순합니다. debugProviderDiagnostic 안에서는 이미 isDebugEnabled()로 일찍 빠져나가지만, 호출자가 넘기는 인자 객체는 그 전에 먼저 만들어집니다. 그래서 Kiro 요청마다 JSON.stringify로 만든 body 전체에 new TextEncoder().encode(body).length를 돌린 뒤, 디버그가 꺼져 있으면 그 결과를 바로 버립니다. 큰 conversationState 페이로드에서는 매 요청 CPU 낭비가 됩니다. src/adapters/openai-chat.ts의 request 진단은 이미 if (isDebugEnabled())로 감싸져 있고, 이 PR은 Kiro request 진단도 같은 모양으로 맞춥니다.

추가로 원본 #3837 리뷰에서 지적된 테스트 고립도 고쳤습니다. 예전에 공유 setup이 OCX_DEBUG_FRAMES만 지웠기 때문에, CI나 로컬에 OCX_DEBUG=1이 남아 있거나 런타임 debug override가 켜져 있으면 encoder-spy 단언이 정당하게 실패할 수 있었습니다. 지금은 beforeEach에서 OCX_DEBUG, OCX_DEBUG_FRAMES, getDebugSettings().runtimeOverride.debug를 스냅샷하고 비운 뒤, afterEach에서 정확히 되돌립니다. 회귀 테스트는 buildRequest 동안 TextEncoder.prototype.encode 호출 중 conversationState 문자열이 섞인 게 없어야 한다고 확인합니다. 디버그 꺼진 기본 경로에서 body 재인코딩이 안 일어난다는 걸 직접 잠그는 좋은 테스트입니다.

현재 devsrc/adapters/kiro.ts를 보면 request 진단만 비싼 bodyBytes 재인코딩을 합니다. 같은 파일의 context_usage / attempt_complete 진단은 인자 자체가 작고, debugProviderDiagnostic 내부 early-return으로도 충분합니다. 그래서 이번 스코프가 request만 가드한 선택은 맞습니다. 트레인 설명대로 로컬 suite는 돌리지 않았고, 체인 top에서 Cross-platform CI가 누적 증거를 본다고 하니, 이 레이어 diff만 보면 merge 후보로 충분합니다. types/config 분할에 걸려 무효화될 PR도 아닙니다.

src/adapters/kiro.ts isDebugEnabled 가드 - 호출 전에 객체 리터럴이 평가되지 않게 막아, 디버그 off에서 TextEncoder body 재인코딩이 사라짐. openai-chat request 패턴과 일치.

tests/providers/kiro/kiro-stream.test.ts encoder-spy - conversationState가 encode 인자로 들어가면 실패. 가드가 빠지면 깨지고, 있으면 통과하는 회귀.

테스트 고립 - OCX_DEBUG / OCX_DEBUG_FRAMES / runtime override를 스냅샷·복원. 상속된 디버그 환경 때문에 spy 단언이 깨지던 #3837 리뷰 반대를 해소.

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

  • 이 캐리가 머지된 뒤 원본 #3837을 바로 landed-via-maintainer로 닫을지, 트레인 전체(레이어 6)가 dev에 들어간 뒤에 일괄 닫을지
  • context_usage / attempt_complete도 바깥에서 isDebugEnabled()로 맞춰 일관성을 살릴지(비용은 작아서 필수는 아님)
  • 체인 top CI만 믿는 정책이 이 레이어에도 그대로 적용되는지(로컬 미실행은 이미 PR에 명시됨)

너의 추천
릴리스 트레인 레이어 3으로 그대로 머지하세요. diff는 작고, openai-chat과 같은 가드이며, 테스트 고립까지 들어 있습니다. 이 PR이 랜딩되면 원본 #3837에는 Landed via #3867 at <commit> 코멘트를 남기고 landed-via-maintainer 라벨을 붙인 뒤 completed/superseded로 닫으세요. 같은 웨이브의 상위 레이어(#3868/#3869/#3870 등)는 각자 diff만 보면 됩니다.

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

@lidge-jun
lidge-jun changed the base branch from codex/rt-m2-3840 to dev September 7, 2026 10:10
@lidge-jun
lidge-jun merged commit 0ef7d29 into dev Sep 7, 2026
8 of 9 checks passed
@lidge-jun
lidge-jun deleted the codex/rt-m3-3837 branch September 7, 2026 10:10
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