Repository navigation
fix(kiro): release leases granted across request cancellation - #6377
Conversation
…ssion A capacity waiter can be granted between the holders cancellation cleanup and the lease install. Re-check the cancellation state after acquisition and release the grant so the request stops at the client-cancelled response instead of occupying the account slot until expiry.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (2)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 (7)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughKiro Responses requests now track cancellation in the account-load holder and pass the request signal to lease acquisition. The transport releases leases when cancellation is detected. Tests cover cancellation during credential refresh and a queued lease grant. ChangesKiro lease cancellation
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant Client
participant handleResponses
participant KiroAccountLoadQueue
participant requestTransport
Client->>handleResponses: abort request
handleResponses->>handleResponses: mark account load cancelled and release lease
KiroAccountLoadQueue-->>requestTransport: grant queued lease
requestTransport->>requestTransport: detect cancellation and release lease
requestTransport-->>Client: return client-cancelled response
Merge Risk: ⚪ Minimal · up to The change releases leases when cancellation wins and prevents cancelled queued requests from dispatching. No actionable merge-blocking risk is established; merge after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change strengthens cancellation handling and prevents late leases from enabling unwanted request work. No new security weakness was identified in the reviewed paths, but live-provider behavior and deployment-wide effects remain unvalidated. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 5 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 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 |
|
✅ Deterministic PR hygiene checks passed. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Ingwannu
left a comment
There was a problem hiding this comment.
Scoped cancellation/resource-lifecycle review at badac2a. The persistent cancelled bit and post-await signal checks prevent the original holder cleanup from losing a subsequently granted lease; the observed real handoff test does not depend on a timing sleep. My isolated Bun 1.4.0 run of tests/providers/kiro/kiro-leased-responses.test.ts --test-name-pattern "^a lease granted as the request aborts is released instead of sending$" passed 1 test / 8 assertions (19 filtered) under CPUQuota=75%, MemoryMax=1536M with fresh homes. It proves grant-before-abort, 499, zero remaining lease, and no adapter/refresh/catalog/fetch work in that fixture. I did not run the broad transport suite or the separate credential-recovery case, and this is not live-provider or security signoff. The current-head hosted CI is successful, but src/server/responses/core.ts is owner-only in current CODEOWNERS; owner approval and the stated auth boundary review remain required. No sponsorship, merge, scan or service operation was performed.
|
Maintainer integration record (MAINTAINERS.md, dev-only) — draft by release lane L2
|
Summary
A request abort could clear the active Kiro lease while later admission or credential recovery installed a replacement lease. Keep cancellation visible for the entire request, pass the abort signal into lease acquisition, and release any lease granted across the abort race before it can be installed or used. The focused regression observes the queued waiter, grants its lease, confirms that grant happened, and then aborts; it no longer relies on a sleep to hit the race.
Source history is preserved through commit
90186f5bc3a2769238553b04ae8692ca6cf1c969. The local validation below used the integration withdevat0328373fb88fe0d019b29ae278e153d7fed4bcc7.Verification
Current upstream integration:
a6114b62ed1b65dede802359ccd373d913979b24; published HEADbadac2a859a8bc781605448f314f4f116be18db9. The source history througheae91d906560a8105e41fcdb307adcd076f7e964is retained without rewriting authors or commits. The PR-specific change was checked again after this integration; typecheck, structure, privacy and file-size gates passed. Cross-platform CI succeeded for this exact HEAD; its checkout tree matches the published HEAD tree. Skipped jobs remain skipped.Windows, Bun 1.4.0, isolated test temporary directory:
bun test tests/providers/kiro/kiro-leased-responses.test.ts --test-name-pattern "a lease granted as the request aborts is released instead of sending": 1 passed, 19 filtered, 0 failed, 8 assertions. The test supplies synthetic credentials, rejects credential refresh and adapter creation, makes catalog refresh a no-op, and makes any fetch throw. It asserts zero transport/refresh/fetch calls, a 499 result, and no remaining lease.bun node_modules/typescript/bin/tsc --noEmit: passed.bun scripts/structure-ssot.ts: passed.bun scripts/privacy-scan.ts: passed.bun scripts/file-size-ratchet.ts: passed.git diff --cached --check 0328373fb88fe0d019b29ae278e153d7fed4bcc7: passed.The full local suite,
test:changed, and broad Kiro transport suites were not run under the focused-validation exception. The single regression deliberately blocks native transport, SOCKS, catalog network work, provider adapters, and real credentials. Live transport coverage remains outstanding. Exact-HEAD CI succeeded; results from another HEAD are not its verification.Checklist
badac2a859a8bc781605448f314f4f116be18db9, known correct findings are addressed, and exact-HEAD CI is complete; author review readiness is confirmed.Independent maintainer approval, explicit security review, and any required
maintainer-sponsoreddecision remain pending before merge. These are separate from author review readiness; no approval or sponsorship is claimed.Summary by CodeRabbit