Skip to content

test(coverage): lock noema src coverage at 100% - #48

Merged
seonghobae merged 2 commits into
mainfrom
claude/contextualwisdomlab-audit-governance-5gowdn
Aug 3, 2026
Merged

test(coverage): lock noema src coverage at 100%#48
seonghobae merged 2 commits into
mainfrom
claude/contextualwisdomlab-audit-governance-5gowdn

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Bring the entire configured coverage scope (src/**/*.ts) to 100% and lock it in with a Vitest threshold gate. The implementation is additive: new and expanded tests, coverage thresholds, and a changelog entry. Runtime behavior under src/ is unchanged.

Coverage: before → after

Metric Before After
Statements 88.21% (307/348) 100% (348/348)
Branches 80.53% (182/226) 100% (226/226)
Functions 95.55% (43/45) 100% (45/45)
Lines 89.72% (297/331) 100% (331/331)

What changed

  • vitest.config.ts: enforce 100% statements, branches, functions, and lines over the existing src/**/*.ts scope.
  • test/worker-exchange-replay.test.ts: exercise exact workflow-ref trust, trusted trace IDs, malformed token payloads, and single-use replay outcomes.
  • test/worker-defensive-rate-limit.test.ts and test/worker-defensive-replay.test.ts: verify unexpected dependency failures remain fail-closed.
  • test/oidc-replay.test.ts and test/distributed-rate-limit.test.ts: cover malformed decisions, transport errors, claim mismatches, and internal Durable Object request validation.
  • CHANGELOG.md: record the enforced source-coverage contract.

The branch has been synchronized with current main, including the patched undici@7.29.0 lockfile and Node.js >=22 runtime contract.

Verification

  • npx vitest run --coverage
  • npm run typecheck
  • npm test
  • npm run security:scan
  • repository CI, reviewer CI, and security workflows

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@seonghobae, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 42 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cac5996e-cd66-4be8-aaa2-be35e501b09e

📥 Commits

Reviewing files that changed from the base of the PR and between 0f976da and 2fbde50.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • test/distributed-rate-limit.test.ts
  • test/oidc-replay.test.ts
  • test/worker-defensive-rate-limit.test.ts
  • test/worker-defensive-replay.test.ts
  • test/worker-exchange-replay.test.ts
  • vitest.config.ts
📝 Walkthrough

Walkthrough

분산 rate limiter와 OIDC replay guard의 잘못된 입력 및 예외 처리 테스트를 추가했습니다. Worker의 503 fail-closed 응답과 토큰 교환 replay 검증을 확장했습니다. Vitest에 모든 커버리지 기준 100%를 설정했습니다.

Changes

방어적 인증 및 제한 검증

Layer / File(s) Summary
분산 rate limiter 검증
test/distributed-rate-limit.test.ts
비객체 응답, 비정상 상태, 원시 예외를 503으로 처리하는 동작을 검증합니다. Durable Object의 잘못된 payload와 요청 형식은 400 또는 415로 거부합니다.
OIDC replay 결정 검증
test/oidc-replay.test.ts
잘못된 결정 응답, 만료 시각 불일치, 비충돌 거부 응답 및 Durable Object 예외를 OidcReplayUnavailable로 처리하는 동작을 검증합니다.
Worker 방어적 오류 응답
test/worker-defensive-rate-limit.test.ts, test/worker-defensive-replay.test.ts
원시 예외 발생 시 Worker가 503, retry-after: 1, 관련 오류 코드 및 일반화된 메시지를 반환하는지 검증합니다.
Exchange replay 흐름
test/worker-exchange-replay.test.ts, vitest.config.ts
토큰 단일 사용, 재사용 토큰 거부, replay claim 검증, trace ID, workflow 설정 및 fail-closed 응답을 검증합니다. 모든 커버리지 기준을 100%로 설정합니다.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

🚥 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 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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 src 범위의 커버리지를 100%로 고정하는 주요 변경 사항을 정확하고 간결하게 설명합니다.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/contextualwisdomlab-audit-governance-5gowdn

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 3, 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.

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

🧹 Nitpick comments (1)
test/distributed-rate-limit.test.ts (1)

494-521: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

단일 테스트에서 4개의 독립된 검증 케이스를 검증합니다.

이 테스트는 nonObject, nonInteger, malformed, noBody 4개의 서로 다른 요청을 만들고, 마지막에 expect 문 4개를 순서대로 실행합니다. toBe는 실패 시 즉시 예외를 던지므로, 첫 번째 assert(nonObject.status)가 실패하면 나머지 3개 assert는 실행되지 않습니다. 이 경우 회귀 발생 시 실패 원인을 파악하기 어렵습니다.

각 검증 케이스를 별도의 it 블록으로 분리하면, 어떤 입력 검증이 실패했는지 테스트 실행 결과에서 바로 확인할 수 있습니다.

♻️ 제안: 검증 케이스별로 테스트 분리
-  it("rejects non-object, non-integer, and content-type-less limiter payloads", async () => {
-    const limiter = new NoemaRateLimiter(fakeDurableObjectState().state);
-
-    const nonObject = await limiter.fetch(new Request("https://noema-rate-limit.internal/check", {
-      method: "POST",
-      headers: { "content-type": "application/json" },
-      body: JSON.stringify(123),
-    }));
-    const nonInteger = await limiter.fetch(new Request("https://noema-rate-limit.internal/check", {
-      method: "POST",
-      headers: { "content-type": "application/json" },
-      body: JSON.stringify({ limit: 2.5 }),
-    }));
-    const malformed = await limiter.fetch(new Request("https://noema-rate-limit.internal/check", {
-      method: "POST",
-      headers: { "content-type": "application/json" },
-      body: "not-json",
-    }));
-    const noBody = await limiter.fetch(new Request("https://noema-rate-limit.internal/check", {
-      method: "POST",
-    }));
-
-    expect(nonObject.status).toBe(400);
-    expect(nonInteger.status).toBe(400);
-    expect(malformed.status).toBe(400);
-    expect(noBody.status).toBe(415);
-  });
+  it("rejects a non-object limiter payload", async () => {
+    const limiter = new NoemaRateLimiter(fakeDurableObjectState().state);
+    const response = await limiter.fetch(new Request("https://noema-rate-limit.internal/check", {
+      method: "POST",
+      headers: { "content-type": "application/json" },
+      body: JSON.stringify(123),
+    }));
+    expect(response.status).toBe(400);
+  });
+
+  it("rejects a non-integer limit", async () => {
+    const limiter = new NoemaRateLimiter(fakeDurableObjectState().state);
+    const response = await limiter.fetch(new Request("https://noema-rate-limit.internal/check", {
+      method: "POST",
+      headers: { "content-type": "application/json" },
+      body: JSON.stringify({ limit: 2.5 }),
+    }));
+    expect(response.status).toBe(400);
+  });
+
+  it("rejects malformed JSON", async () => {
+    const limiter = new NoemaRateLimiter(fakeDurableObjectState().state);
+    const response = await limiter.fetch(new Request("https://noema-rate-limit.internal/check", {
+      method: "POST",
+      headers: { "content-type": "application/json" },
+      body: "not-json",
+    }));
+    expect(response.status).toBe(400);
+  });
+
+  it("rejects a request without content-type", async () => {
+    const limiter = new NoemaRateLimiter(fakeDurableObjectState().state);
+    const response = await limiter.fetch(new Request("https://noema-rate-limit.internal/check", {
+      method: "POST",
+    }));
+    expect(response.status).toBe(415);
+  });
🤖 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 `@test/distributed-rate-limit.test.ts` around lines 494 - 521, Split the
combined test around NoemaRateLimiter into four independent it blocks, one each
for the nonObject, nonInteger, malformed, and noBody request cases. Keep each
request setup and its corresponding status assertion together, preserving the
expected 400 responses for the first three cases and 415 for the
content-type-less case.
🤖 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.

Nitpick comments:
In `@test/distributed-rate-limit.test.ts`:
- Around line 494-521: Split the combined test around NoemaRateLimiter into four
independent it blocks, one each for the nonObject, nonInteger, malformed, and
noBody request cases. Keep each request setup and its corresponding status
assertion together, preserving the expected 400 responses for the first three
cases and 415 for the content-type-less case.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a5621028-c44f-4425-918f-f47019718f34

📥 Commits

Reviewing files that changed from the base of the PR and between 4e5c70e and 0f976da.

📒 Files selected for processing (6)
  • test/distributed-rate-limit.test.ts
  • test/oidc-replay.test.ts
  • test/worker-defensive-rate-limit.test.ts
  • test/worker-defensive-replay.test.ts
  • test/worker-exchange-replay.test.ts
  • vitest.config.ts

Rebase the coverage gate and fail-closed regression suite onto the current main branch, preserving the GitHub API egress trust boundary and its tests.
@seonghobae
seonghobae force-pushed the claude/contextualwisdomlab-audit-governance-5gowdn branch from 8a5c082 to 9678ff3 Compare August 3, 2026 21:23
@seonghobae
seonghobae merged commit ba577fd into main Aug 3, 2026
16 checks passed
@seonghobae
seonghobae deleted the claude/contextualwisdomlab-audit-governance-5gowdn branch August 3, 2026 21:26
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.

1 participant