Skip to content

fix: enforce idempotency TTL store conformance - #1385

Merged
kang-heewon merged 3 commits into
trunkfrom
fix/1370-validate-idempotency-ttl
Jul 24, 2026
Merged

fix: enforce idempotency TTL store conformance#1385
kang-heewon merged 3 commits into
trunkfrom
fix/1370-validate-idempotency-ttl

Conversation

@kang-heewon

@kang-heewon kang-heewon commented Jul 12, 2026

Copy link
Copy Markdown
Member

Fixes #1370.

Summary

  • Enforces invalid TTL rejection before reserve, commit, and fail state changes in the portable idempotency store conformance suite.
  • Covers zero, negative, NaN, infinity, fractional, and Date-overflow TTLs on every transition.
  • Locks omitted TTLs as the explicit non-expiring behavior across reserve, commit, and fail.
  • Preserves the runtime validation, public Problem API, generated docs, registry, and snapshots already merged to trunk by fix: reject invalid idempotency TTLs and secure generated appsย #1449 instead of reintroducing a competing implementation.

Verification

  • pnpm --filter=@croco/idempotency-core test โ€” 68/68 tests passed.
  • pnpm typecheck --filter=@croco/idempotency-core โ€” 4/4 tasks passed.
  • pnpm lint --filter=@croco/idempotency-core โ€” 2/2 tasks passed.
  • pnpm static-misuse:check โ€” all rules passed.
  • pnpm check โ€” repository profile passed 21/22 gates, with one non-applicable gate.
  • Pre-push gates for the current head โ€” tests 226/226 and typecheck 225/225 passed.
  • Full Oxfmt check across 2,681 files and git diff --check โ€” passed.

Self-review gates

  • Correctness and regression: PASS. Every invalid numeric class rejects before reserve creation or commit/fail mutation, while omitted TTLs remain non-expiring on all transitions.
  • API, security, compatibility, and release: PASS. The rebase keeps fix: reject invalid idempotency TTLs and secure generated appsย #1449's current public API and generated contracts unchanged; the remaining package behavior has a patch changeset.
  • Maintainability and minimality: PASS. The rebased diff is limited to the conformance suite, its case registry test, package guidance, the required static-misuse locator updates, and one changeset.

Rebase accounting

The original PR commit db7c526 was rebased onto b65ed66. Its runtime/API/generated-artifact changes were already represented on trunk by 62885fe (#1449); the PR-only conformance and README changes were retained as 9153ff2. Repository policy support is in e83fa0b, and the review-requested invalid TTL matrix is in 94f6639.

Residual risk

No known validation gap remains for the numeric TTL classes defined by the contract.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • โ–ถ๏ธ Resume reviews
  • ๐Ÿ” Trigger review
๐Ÿ“ Walkthrough

Walkthrough

idempotency store conformance suite๊ฐ€ reserve, commit, fail์˜ ์ž˜๋ชป๋œ TTL๊ณผ ์ƒ๋žต๋œ TTL ๋™์ž‘์„ ๊ฒ€์ฆํ•˜๋„๋ก ํ™•์žฅ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. README์™€ changeset์—๋Š” TTL ์œ ํšจ์„ฑ ๋ฐ InvalidIdempotencyTtlProblem์ด ๋ฌธ์„œํ™”๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

Changes

Idempotency TTL conformance

Layer / File(s) Summary
TTL ์ฝ˜ํฌ๋จผ์Šค ๊ฒ€์ฆ ๋ฐ ๊ณ„์•ฝ ๋ฌธ์„œ
packages/idempotency-core/src/libs/conformance.ts, packages/idempotency-core/src/tests/IdempotencyConformance.spec.ts, packages/idempotency-core/README.md, .changeset/9c4317b7.md
reserve, commit, fail์—์„œ ์ž˜๋ชป๋œ TTL์„ InvalidIdempotencyTtlProblem์œผ๋กœ ๊ฑฐ๋ถ€ํ•˜๊ณ  ๊ธฐ์กด reservation์„ ์œ ์ง€ํ•˜๋Š” ์ผ€์ด์Šค๋ฅผ ์ถ”๊ฐ€ํ–ˆ์Šต๋‹ˆ๋‹ค. ์ƒ๋žต๋œ TTL์˜ expiresAt: null ๋™์ž‘๊ณผ ๊ด€๋ จ ๊ณต๊ฐœ ๋ฌธ์„œ ๋ฐ patch changeset๋„ ์ถ”๊ฐ€ํ–ˆ์Šต๋‹ˆ๋‹ค.

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

๐Ÿšฅ Pre-merge checks | โœ… 4 | โŒ 1

โŒ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage โš ๏ธ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
โœ… Passed checks (4 passed)
Check name Status Explanation
Linked Issues check โœ… Passed ๋น„์ •์ƒ TTL ๊ฑฐ๋ถ€, reserve/commit/fail์˜ ๋™์ผํ•œ ๊ฒ€์ฆ, omitted TTL์˜ ๋น„๋งŒ๋ฃŒ ๋™์ž‘์ด ์š”๊ตฌ์‚ฌํ•ญ๊ณผ ์ผ์น˜ํ•ฉ๋‹ˆ๋‹ค.
Out of Scope Changes check โœ… Passed ๋ณ€๊ฒฝ์€ ๋ฌธ์„œ, conformance ํ…Œ์ŠคํŠธ, ๋ณ€๊ฒฝ๊ธฐ๋ก์— ํ•œ์ •๋˜์–ด ์žˆ์–ด ๋งํฌ๋œ ์š”๊ตฌ์‚ฌํ•ญ ๋ฒ”์œ„๋ฅผ ๋ฒ—์–ด๋‚œ ํ•ญ๋ชฉ์ด ๋ณด์ด์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
Description Check โœ… Passed Check skipped - CodeRabbitโ€™s high-level summary is enabled.
Title check โœ… Passed ์ œ๋ชฉ์ด idempotency TTL ๊ฒ€์ฆ๊ณผ ์Šคํ† ์–ด conformance ๊ฐ•์ œ๋ฅผ ์ •ํ™•ํžˆ ์š”์•ฝํ•˜๋ฉฐ ๋ณ€๊ฒฝ ๋‚ด์šฉ๊ณผ ์ž˜ ๋งž์Šต๋‹ˆ๋‹ค.
โœจ Finishing Touches
๐Ÿ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
๐Ÿงช Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1370-validate-idempotency-ttl

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.

@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown

๐Ÿ“Š Benchmark Results

โœ… All benchmarks passed

Benchmark p75 Threshold Baseline vs Baseline Status Notes
CrocoApp constructor 9.0ฮผs 30.0ms 8.2ฮผs +10.1% โœ… -
CrocoApp lambdaHandler (10 controllers) 283.6ฮผs 50.0ms 258.4ฮผs +9.7% โœ… -
Lambda cold-start simulation 428.1ฮผs 80.0ms 418.1ฮผs +2.4% โœ… -
Lambda cold-start with headers 401.5ฮผs 80.0ms 369.7ฮผs +8.6% โœ… -
Lambda cold-start with binary body 380.2ฮผs 80.0ms 339.1ฮผs +12.1% โœ… -
Lambda cold-start with query params 316.6ฮผs 80.0ms 301.3ฮผs +5.1% โœ… -
Lambda cold-start with authorizer context 318.3ฮผs 80.0ms 299.8ฮผs +6.2% โœ… -
Lambda cold-start realistic scenario 319.7ฮผs 80.0ms 299.2ฮผs +6.9% โœ… -
EventBusConfig.start (10 handlers) 1.9ฮผs 10.0ms 1.4ฮผs +32.4% โŒ -
EventPublisher.publishNow single event 2.0ฮผs 2.0ms 1.7ฮผs +17.9% โœ… -
DefaultHandlerResolver.resolve ร— 10 0.1ฮผs 5.0ms 0.1ฮผs -16.2% โœ… -
Container.get singleton (cold) 71.5ฮผs 5.0ms 70.3ฮผs +1.7% โœ… -
Container.register ร— 50 components 3.6ms 10.0ms 3.2ms +11.4% โœ… -
Container.validate (50 components) 4.1ms 20.0ms 3.4ms +21.7% โŒ -
Container.get singleton (warm) 1.9ฮผs 500.0ฮผs 1.6ฮผs +15.9% โœ… -
TelemetryRuntime.init (lambda preset) 2.4ฮผs 200.0ms 1.1ms -99.8% โœ… -
lambdaPreset config creation 1.6ฮผs 2.0ms 1.4ฮผs +10.9% โœ… -

Updated: 2026-07-24T12:42:41.206Z ยท Commit: f7ab85f

@kang-heewon
kang-heewon force-pushed the fix/1370-validate-idempotency-ttl branch 2 times, most recently from 10784fd to bfbbd9e Compare July 13, 2026 05:34
@kang-heewon

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
โœ… Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@kang-heewon
kang-heewon force-pushed the fix/1370-validate-idempotency-ttl branch from bfbbd9e to 7871103 Compare July 13, 2026 06:44
@kang-heewon

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
โœ… Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@kang-heewon
kang-heewon force-pushed the fix/1370-validate-idempotency-ttl branch from 7871103 to 9920b76 Compare July 13, 2026 07:47
@kang-heewon

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
โœ… Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@kang-heewon
kang-heewon force-pushed the fix/1370-validate-idempotency-ttl branch from 9920b76 to 08cb6f1 Compare July 13, 2026 08:32
@kang-heewon

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
โœ… Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@kang-heewon
kang-heewon force-pushed the fix/1370-validate-idempotency-ttl branch 2 times, most recently from bfa53f0 to fe45159 Compare July 13, 2026 11:13

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

๐Ÿค– Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/idempotency-core/src/libs/conformance.ts`:
- Around line 158-259: Expand the TTL validation conformance cases around the
existing reserve, commit, and fail tests to cover representative invalid values
beyond zero, including negative, NaN/non-finite, fractional, and out-of-range
TTLs. Use separate createConformanceKey values and preserve the current
assertions that invalid inputs reject before changing reservation state.
๐Ÿช„ Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

โ„น๏ธ Review info
โš™๏ธ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d19f54cc-f232-43ac-a079-9a700da010d9

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between 08cb6f1 and fe45159.

โ›” Files ignored due to path filters (1)
  • packages/problems-core/src/generated/problem-code-registry.ts is excluded by !**/generated/**
๐Ÿ“’ Files selected for processing (17)
  • .changeset/valid-idempotency-ttl.md
  • docs/problem-code-registry.json
  • packages/docs/src/content/docs/api/idempotency-core/src/classes/InvalidIdempotencyTtlProblem.md
  • packages/docs/src/content/docs/api/idempotency-core/src/type-aliases/IdempotencyTtlOperation.md
  • packages/docs/src/content/docs/api/idempotency-core/src/type-aliases/InvalidIdempotencyTtlReason.md
  • packages/docs/src/content/docs/api/idempotency-core/src/variables/IDEMPOTENCY_DIAGNOSTIC_CODES.md
  • packages/docs/src/content/docs/en/reference/problem-recovery-cookbook.md
  • packages/idempotency-core/README.md
  • packages/idempotency-core/src/index.ts
  • packages/idempotency-core/src/libs/InMemoryIdempotencyStore.ts
  • packages/idempotency-core/src/libs/conformance.ts
  • packages/idempotency-core/src/libs/problems/IdempotencyProblems.ts
  • packages/idempotency-core/src/tests/IdempotencyConformance.spec.ts
  • packages/idempotency-core/src/tests/InMemoryIdempotencyStore.spec.ts
  • public-api-surface.snapshot.json
  • scripts/static-misuse-raw-error-allowlist.json
  • tsconfig/contract-strict.baseline.json

Comment thread packages/idempotency-core/src/libs/conformance.ts
@kang-heewon
kang-heewon force-pushed the fix/1370-validate-idempotency-ttl branch from fe45159 to db7c526 Compare July 13, 2026 12:10
@kang-heewon
kang-heewon force-pushed the fix/1370-validate-idempotency-ttl branch from db7c526 to 05ccd9b Compare July 24, 2026 12:22
@kang-heewon kang-heewon changed the title fix: reject invalid idempotency TTL values fix: enforce idempotency TTL store conformance Jul 24, 2026
@kang-heewon
kang-heewon force-pushed the fix/1370-validate-idempotency-ttl branch from 05ccd9b to a9b56c3 Compare July 24, 2026 12:23

@coderabbitai coderabbitai 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.

โ™ป๏ธ Duplicate comments (1)
packages/idempotency-core/src/libs/conformance.ts (1)

158-225: ๐ŸŽฏ Functional Correctness | ๐ŸŸ  Major | โšก Quick win

๊ธฐ์กด TTL ๋Œ€ํ‘œ๊ฐ’ ํ™•์žฅ ์ง€์ ์ด ์—ฌ์ „ํžˆ ์œ ํšจํ•ฉ๋‹ˆ๋‹ค.

ํ˜„์žฌ ์„ธ transition์€ ttlMs: 0๋งŒ ๊ฒ€์ฆํ•ฉ๋‹ˆ๋‹ค. ๊ณ„์•ฝ์— ๋ช…์‹œ๋œ ์Œ์ˆ˜, NaN/๋ฌดํ•œ๋Œ€, ์†Œ์ˆ˜, Date ๋ฒ”์œ„ ์ดˆ๊ณผ ๊ฐ’๋„ reserveยทcommitยทfail๋งˆ๋‹ค ๊ฒ€์ฆํ•ด์•ผ ์„œ๋“œํŒŒํ‹ฐ ์ €์žฅ์†Œ๊ฐ€ ์ „์ฒด invalid TTL ๊ณ„์•ฝ์„ ์šฐํšŒํ•˜์ง€ ๋ชปํ•ฉ๋‹ˆ๋‹ค. ์ถ”๊ฐ€ํ•œ case ์ด๋ฆ„์— ๋งž์ถฐ IdempotencyConformance.spec.ts์˜ ๊ธฐ๋Œ€ ๋ชฉ๋ก๋„ ํ•จ๊ป˜ ๊ฐฑ์‹ ํ•˜์„ธ์š”.

๐Ÿค– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/idempotency-core/src/libs/conformance.ts` around lines 158 - 225,
Expand the invalid-TTL conformance cases for reserve, commit, and fail beyond
zero to cover negative, NaN/infinite, fractional, and Date-range-overflow
values. Ensure each case asserts rejection with InvalidIdempotencyTtlProblem
before any state change, preserving reservation state for commit and fail.
Update the expected case-name list in IdempotencyConformance.spec.ts to include
all newly added cases.
๐Ÿค– Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@packages/idempotency-core/src/libs/conformance.ts`:
- Around line 158-225: Expand the invalid-TTL conformance cases for reserve,
commit, and fail beyond zero to cover negative, NaN/infinite, fractional, and
Date-range-overflow values. Ensure each case asserts rejection with
InvalidIdempotencyTtlProblem before any state change, preserving reservation
state for commit and fail. Update the expected case-name list in
IdempotencyConformance.spec.ts to include all newly added cases.

โ„น๏ธ Review info
โš™๏ธ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ce76b105-c874-4fb6-a0bf-8e88285b7e10

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between fe45159 and 05ccd9b.

๐Ÿ“’ Files selected for processing (4)
  • .changeset/9c4317b7.md
  • packages/idempotency-core/README.md
  • packages/idempotency-core/src/libs/conformance.ts
  • packages/idempotency-core/src/tests/IdempotencyConformance.spec.ts

@kang-heewon
kang-heewon force-pushed the fix/1370-validate-idempotency-ttl branch from a9b56c3 to e83fa0b Compare July 24, 2026 12:34
@kang-heewon
kang-heewon merged commit 0aa0bf1 into trunk Jul 24, 2026
9 checks passed
@kang-heewon
kang-heewon deleted the fix/1370-validate-idempotency-ttl branch July 24, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[idempotency-core] Reject invalid TTL values before creating expired or immortal records

1 participant