fix(providers): parse Kiro meteringEvent credits and preserve in usage ledger - #5951
codingbooo wants to merge 1 commit into
Conversation
|
✅ Deterministic PR hygiene checks passed. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: lidge-jun/opencodex/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (19)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughKiro metering events now contribute provider-reported credits to request usage. The adapter parses credit readings, usage merging adds readings across attempts, and normalization persists valid values separately from token estimates and USD costs. ChangesKiro credit metering
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix · Severity of issue fixed: Medium Sequence Diagram(s)sequenceDiagram
participant parseKiroEvent
participant KiroStream
participant OcxUsage
participant UsageLog
parseKiroEvent->>KiroStream: parsed metering event
KiroStream->>OcxUsage: providerCredits from credit-unit reading
OcxUsage->>UsageLog: normalized usage for persistence
Merge Risk: ⚪ Minimal · up to No actionable merge-blocking risk is established; the change is mergeable after normal checks. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to The new credit accounting path is validated and remains separate from token and dollar accounting, but it is not yet clear whether a credit charge survives every interrupted request. That uncertainty matters for the integrity of usage records. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation Issue [ Resolution Add support for Full details: Docstring CoverageExplanation Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 13 files. (6 skipped: 6 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
✅ READY
Review readiness checklist
✅ 4/4 boxes ticked. This pull request is already Ready for Review. |
리뷰 · 우선순위 54 / 80Kiro는 답변 스트림 끝에 "이번 요청에 크레딧을 이만큼 썼다"는 이 PR은 그 쪽지를 읽어서 한 응답 안에서 쪽지가 여러 번 오면 마지막 숫자가 이긴다. 답이 비어서 한 번 더 부르거나, 시도가 나뉘어 합쳐질 때는 크레딧을 더한다.
PR 본문 - 게이트가 읽는 아래쪽 체크리스트 네 칸은 비어 있다. 위에 따로 둔 목록만 체크되어 있어서 이 PR은 아직 DRAFT다. 메인테이너의 판단이 필요한 지점 이슈 예시는 대시보드와 토큰 합계( 한 응답은 마지막 스냅샷, 이어진 요청끼리는 합산. 이 규칙을 그대로 둘지 정하면 된다. 너의 추천 장부에 크레딧을 남기는 방향은 이슈의 핵심과 맞다. 머지 전에 게이트가 보는 체크리스트 네 칸을 채워서 DRAFT를 풀어라. 잘못된 크레딧 문단은 추론 절에서 빼서 제목을 따로 달아라. 이슈 #5948은 "기록에 숫자가 남는다"까지는 이 PR로 닫아도 된다. 화면의 비용 칸까지 바꾸려면 다음 작업으로 남겨라. 이 댓글은 grok-bot이 작성했습니다 |
) Six focused fixes from the assigned bug batch remain as separate attributed commits. | PR | Change | Author | | --- | --- | --- | | #5969 | Preserve Meta Muse tool-choice semantics and reject unsupported selectors before dispatch. | shawnkim | | #5944 | Remove unsupported hosted web-search declarations for Xiaomi MiMo destinations. | codingbo | | #5938 | Restart the Windows service child after unexpected exits, including exit 0, while reserving the intentional stay-out code. | codingbo | | #5935 | Reject Claude message-thread state on translated routes so the client resends full history. | kaladinhonor | | #5939 | Rewrite standalone `\\0` escapes in Meta tool-schema patterns to equivalent `\\x00`. | boblob6969 | | #5951 | Preserve Kiro-reported credits across stream attempts and in the usage ledger. | codingbo | A separate integration commit keeps upstream-controlled Kiro event-type text out of opt-in debug logs. The Kiro stream retains the previously landed bounded HTTP-error text when combined with credit metering. Left out: #5977. Independent security review found that its local read capability authenticates the request but not the HTTP response. A substituted listener could return a shape-valid forged `protected` verdict. A correct server proof bound to the nonce, endpoint, and body is outside this batch. Both its source commit and status-validation follow-up were reverted in new commits; its test and layout entries are gone. The source PR remains open. Co-authored-by: shawnkim <shawnkim@markncompany.co.kr> Co-authored-by: codingbo <cnsdbo@163.com> Co-authored-by: kaladinhonor <266145786+kaladinhonor@users.noreply.github.com> Co-authored-by: boblob6969 <boblob6969@icloud.com>
|
Thanks! This landed on |
Summary
Fixes #5948 by parsing the Kiro stream's
meteringEventframe (andinitial-response), preserving the reported credit charge in the usage ledger (providerCredits), and emitting diagnostic events for unknown event types when provider debug is enabled.Changes
src/adapters/kiro-events.ts)::event-type=meteringEventand extractunitandusage(oramount).:event-type=initial-responsecarryingconversationId.debugProviderDiagnosticwhen provider debug is enabled, without logging sensitive payload bodies.src/adapters/kiro/stream.ts,src/types/request.ts,src/server/request-log.ts,src/usage/log.ts):providerCreditson the request log / usage records.tests/providers/kiro/kiro-metering-events.test.tsandtests/providers/kiro/kiro-metering-usage.test.ts(12 tests passing).Validation
bun x tsc --noEmit: 0 errorsbun test tests/providers/kiro/kiro-metering-events.test.ts tests/providers/kiro/kiro-metering-usage.test.ts: 12 passed, 0 failedbun test tests/server/server-kiro-completion-e2e.test.ts: passedReview readiness checklist
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.
Summary by CodeRabbit