Skip to content

test(kiro): read cooldown after verdict observation - #5993

Merged
lidge-jun merged 1 commit into
devfrom
codex/fix-kiro-pool-rank-state
Sep 26, 2026
Merged

lidge-jun merged 1 commit into
devfrom
codex/fix-kiro-pool-rank-state

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

The Kiro cooldown tests captured now before recording an exhaustion verdict. The usage-evidence guard introduced on dev correctly rejects a verdict with observedAt > now, so a millisecond tick during a multi-file Bun run turned the test's own new verdict into null. The production freshness rule is unchanged. The tests now read the clock after writing the verdict, compare the in-window reset against that read time, and force a 2 ms boundary in one case so the ordering cannot silently regress.

Verification

  • Red on untouched origin/dev: bun test tests/providers/kiro/kiro-usage-restart.test.ts tests/providers/kiro/kiro-pool-rank.test.ts produced 30 pass / 1 fail. With the explicit 2 ms boundary and old read ordering, the same command reliably failed the distant-reset assertion (86400000 expected, null received).
  • Green after the fix: the same two-file command passed 31/31; bun test tests/providers/kiro/kiro-account-state-disk.test.ts tests/providers/kiro/kiro-pool-rank.test.ts passed 43/43.
  • bun test tests/test-layout.test.ts tests/test-layout-tooling.test.ts tests/ci-workflows/file-size-ratchet.test.ts — 27 passed.
  • bun x tsc --noEmit, bun run structure:check, bun run privacy:scan, and git diff --check — passed.
  • The full local suite was not run under the merge-train scope. The same two cooldown assertions failed in hosted runs on unrelated PR heads, confirming this test-order defect is already on dev.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. This is a test-only correction; the runtime contract is unchanged.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. No runtime or credential path changes.

Summary by CodeRabbit

  • Tests
    • Updated timing checks for cooldown expiration scenarios, including distant, imminent, and exact reset times. Comparisons now account for the time remaining until a reset, improving the reliability of these checks.

The #5967 identity/freshness guard rightly rejects a verdict whose observedAt is later than the supplied read clock. Cooldown tests captured that clock before seeding the verdict, so a millisecond tick in a multi-file run made them read their own fixture as future evidence. Capture the read time after the seed, and compare the in-window reset against that read time.

Red: usage-restart plus pool-rank failed the distant-reset assertion with a forced 2ms boundary. Green: the same two-file run passes all 31 tests; account-state-disk plus pool-rank passes 43.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner September 26, 2026 18:09
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 26, 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-26T18:11:15.620767Z 93ff334 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

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). label Sep 26, 2026
@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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 configuration

Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 49634f8b-f413-46e3-9434-e7a697da5977

📥 Commits

Reviewing files that changed from the base of the PR and between a846dea and 93ff334.

📒 Files selected for processing (1)
  • tests/providers/kiro/kiro-pool-rank.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

The exhaustion-cooldown tests seed verdicts before capturing comparison times. The distant-reset case adds a brief wait, and the exact-reset assertion uses the calculated remaining time.

Changes

Kiro cooldown test timing

Layer / File(s) Summary
Seed verdicts before comparison
tests/providers/kiro/kiro-pool-rank.test.ts
The tests capture comparison times after seeding exhaustion verdicts. The distant-reset case adds a 2 ms wait, and the exact-reset assertion compares against the remaining time to reset.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 93ff3

This PR adjusts only Kiro cooldown tests, aligning their fixtures and expectations with the evidence-time guard. No actionable merge-blocking risk remains.

Architecture Summary

Architecture risk: 🔵 Low · up to 93ff3

The change affects 1 system.

Changed systems: tests

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — tests (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in tests/providers/kiro/kiro-pool-rank.test.ts: The distant-reset test now waits 2 ms and records the reset relative to the verdict-write time, then checks cooldown from a later read time. The imminent-reset and exact-reset tests now seed exhaustion before capturing now; the exact-reset expectation uses resetAt - now instead of a fixed hour.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: updating Kiro cooldown tests to read the cooldown after observing the exhaustion verdict.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@lidge-jun

Copy link
Copy Markdown
Owner Author

리뷰 · 우선순위 28 / 80

이 PR은 키로 계정을 고르는 동작을 바꾸지 않습니다. 쿨다운 테스트만 고칩니다. 바탕은 dev입니다. types.ts와 config.ts를 나누는 변경은 아닙니다.

한도를 다 썼다는 기록을 남기면, 그 기록을 본 시각도 같이 적힙니다. 쿨다운을 계산할 때 본 시각이 읽기 시각보다 뒤면 그 기록은 버립니다. 아직 오지 않은 시각을 믿지 않으려는 규칙이고, #5967에서 들어온 검사입니다. 이 규칙은 이번 PR에서 그대로입니다.

테스트는 시계를 먼저 적어 두고 그다음에 기록을 썼습니다. 기록을 쓰는 사이에 시간이 1밀리초만 흘러도, 방금 쓴 기록이 미래가 됩니다. 그러면 하루로 줄여야 할 쿨다운이 빈 값(null)이 됩니다. 파일을 여러 개 같이 돌릴 때 그 실패가 납니다. 본문은 관계없는 PR 헤드의 호스티드 실행에서도 같은 실패가 났다고 적습니다.

고친 뒤의 순서는 기록을 먼저 쓰고, 시계는 그 뒤에 읽습니다. 한 시간 안쪽 리셋은 "정확히 한 시간" 대신 resetAt - now를 기대합니다. 쓰는 동안 몇 밀리초가 지나도 기대값이 함수 계산과 같습니다.

tests/providers/kiro/kiro-pool-rank.test.ts:134 - await Bun.sleep(2)가 기록을 쓰기 전에 있습니다. 133행 주석은 기록을 쓰기 전에 밀리초가 넘어갈 수 있다고 말합니다. 잠은 그 사이에 있지 않습니다. const now를 seedExhausted보다 위로 옮겨도, 잠 뒤에만 두면 시계가 같은 밀리초에 머물 때는 다시 통과합니다. 틀린 순서를 매번 실패시키지는 못합니다. 142행과 148행 테스트는 잠 없이 순서만 바꿨고, 그 순서가 실제 수정입니다.

메인테이너의 판단이 필요한 지점
2밀리초 잠을 설명용으로 남길지입니다. 주석이 말하는 회귀 잠금은 지금 배치가 하지 않습니다.

너의 추천
시계를 기록 뒤로 옮긴 것과 resetAt - now 비교는 맞습니다. 그 상태로 머지해도 됩니다. 잠과 133행 주석은 빼는 편이 낫습니다. 제품 코드는 이 PR에서 안 바뀝니다. 닫을 중복 PR은 없습니다.

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

@lidge-jun
lidge-jun merged commit 177c647 into dev Sep 26, 2026
33 of 34 checks passed
@lidge-jun
lidge-jun deleted the codex/fix-kiro-pool-rank-state branch September 26, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant