Skip to content

fix: make HTTP readiness use readiness indicators - #1361

Merged
kang-heewon merged 2 commits into
trunkfrom
fix/1312-readiness-indicators
Jul 11, 2026
Merged

fix: make HTTP readiness use readiness indicators#1361
kang-heewon merged 2 commits into
trunkfrom
fix/1312-readiness-indicators

Conversation

@kang-heewon

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

Copy link
Copy Markdown
Member

Fixes #1312.

Summary

  • Makes /ready and /health/ready execute explicitly registered readiness indicators and map the aggregate result to 200 or 503.
  • Keeps generic health registrations, liveness, and health-check metrics independent through separate registry namespaces.
  • Reuses health-core timeout, abort, and failure aggregation while sanitizing readiness details at the HTTP boundary.
  • Publishes the additive readiness APIs, generated reference updates, package guidance, and patch changesets.

Verification

  • pnpm check — passed.
  • pnpm typecheck — 224/224 tasks passed.
  • pnpm test — 225/225 tasks passed.
  • Pre-push test and typecheck gates passed again: 225/225 and 224/224 tasks.
  • Focused readiness matrix passed twice: 50 health-core and 76 HTTP assertions.
  • Generated docs build passed: 3,572 pages.
  • Public API snapshots matched all 110 packages; problem registry matched all 417 codes.
  • Strict-contract baseline matched with 609 unchanged diagnostics and zero drift.
  • git diff --check — passed.

Self-review gates

  • Correctness and regression: PASS. Empty, all-up, down, thrown, timeout, abort, both aliases, duplicate namespaces, isolation, liveness, and metrics behavior are covered.
  • API, security, compatibility, and release: PASS. Readiness details redact sensitive keys, omit stack/cause, bound diagnostic text, and include additive patch changesets and generated docs.
  • Maintainability and minimality: PASS. Existing aggregation and redaction paths are reused; no dependency, fallback, draining policy, or Kubernetes-specific behavior was added.

Review and QA

  • Independent code review: APPROVE, no actionable findings.
  • Independent architecture review: CLEAR, no blockers.
  • Adversarial QA: PASS across the readiness failure matrix in two consecutive runs.

Migration

Applications that previously used generic register() calls as implicit readiness inputs must register those indicators explicitly with registerReadiness().

Residual risk

Readiness and generic health registration are intentionally independent. Existing applications receive an empty, healthy readiness aggregate until they opt indicators into the readiness registry.

Summary by CodeRabbit

  • 새로운 기능

    • 독립적인 readiness 체크 등록 및 결과 조회를 지원합니다.
    • /ready/health/ready가 readiness 전용 체크만 실행합니다.
    • readiness 실패 응답에서 민감 정보가 자동으로 마스킹되고 오류 메시지가 제한됩니다.
  • 버그 수정

    • 일반 health 체크와 readiness 체크가 서로 영향을 주지 않도록 개선했습니다.
    • readiness 체크의 오류, 타임아웃 및 중단 처리를 일관되게 개선했습니다.
  • 문서

    • readiness API, 응답 계약, 마이그레이션 안내 및 문제 해결 문서를 보강했습니다.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 2 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: ASSERTIVE

Plan: Pro

Run ID: f67a9112-3001-4333-af77-946f9e67b655

📥 Commits

Reviewing files that changed from the base of the PR and between 148b734 and db275e1.

📒 Files selected for processing (3)
  • packages/health-core/README.md
  • packages/health-core/src/tests/HealthCheckService.spec.ts
  • packages/transports-http/src/libs/CrocoApp.ts
📝 Walkthrough

Walkthrough

Health-core now aggregates readiness indicators independently, the HTTP registry exposes readiness registration and checks, and readiness routes return sanitized detailed results. Tests and documentation cover isolation, failures, timeouts, redaction, aliases, and empty readiness registrations.

Changes

Readiness HTTP contract

Layer / File(s) Summary
Health-core readiness aggregation
packages/health-core/src/libs/HealthCheckService.ts, packages/health-core/src/tests/*, packages/health-core/README.md, packages/docs/src/content/docs/api/health-core/*
Readiness indicators support registration, detailed aggregation, readiness status checks, timeout handling, and independent generic health results.
HTTP registry and response sanitization
packages/transports-http/src/libs/HealthCheckRegistry.ts, packages/transports-http/src/libs/operationalEndpoints.ts, packages/transports-http/src/libs/CrocoApp.ts
The HTTP registry separates health and readiness checks, and readiness routes sanitize sensitive details and select 200 or 503 from readiness status.
HTTP readiness validation
packages/transports-http/src/tests/HealthCheck.spec.ts, packages/transports-http/src/tests/OperationalEndpoints.spec.ts
Tests cover both readiness aliases, empty and failing results, timeout and abort behavior, duplicate names, health isolation, redaction, and message truncation.
Readiness contract documentation and metadata
packages/transports-http/README.md, packages/docs/src/content/docs/api/transports-http/*, docs/troubleshooting/diagnostics.md, docs/problem-code-registry.json, packages/docs/src/content/docs/en/reference/problem-recovery-cookbook.md, .changeset/*, scripts/*, tsconfig/*
Public readiness, diagnostics, redaction, API, release, and source-location documentation and metadata are updated.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant CrocoApp
  participant HealthCheckRegistry
  participant HealthCheckService
  Client->>CrocoApp: GET /ready or /health/ready
  CrocoApp->>HealthCheckRegistry: checkReadiness()
  HealthCheckRegistry->>HealthCheckService: checkReadiness()
  HealthCheckService-->>HealthCheckRegistry: Detailed readiness result
  HealthCheckRegistry-->>CrocoApp: Registry readiness result
  CrocoApp->>CrocoApp: Sanitize details
  CrocoApp-->>Client: HTTP 200 or 503 response
Loading

Possibly related PRs

  • croco-dev/framework#833: Modifies the shared operational endpoint redaction logic used by readiness and diagnostics responses.
🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목이 HTTP readiness가 readiness indicators를 사용하도록 바꾸는 핵심 변경을 정확히 요약합니다.
Linked Issues check ✅ Passed readiness 집계/등록, /ready 및 /health/ready 라우팅, 503·sanitize, 독립성, 빈 등록/타임아웃/중복 동작이 모두 반영되었습니다.
Out of Scope Changes check ✅ Passed 변경된 문서, 변경집합, 기준/allowlist 메타데이터는 readiness 변경과 연동된 주변 산출물로 보이며 뚜렷한 범위 이탈은 없습니다.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1312-readiness-indicators

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 11, 2026

Copy link
Copy Markdown

📊 Benchmark Results

✅ All benchmarks passed

Benchmark p75 Threshold Baseline vs Baseline Status Notes
CrocoApp constructor 9.6μs 30.0ms 8.2μs +17.4% -
CrocoApp lambdaHandler (10 controllers) 266.9μs 50.0ms 258.4μs +3.3% -
Lambda cold-start simulation 421.0μs 80.0ms 418.1μs +0.7% -
Lambda cold-start with headers 408.3μs 80.0ms 369.7μs +10.4% -
Lambda cold-start with binary body 350.1μs 80.0ms 339.1μs +3.2% -
Lambda cold-start with query params 284.9μs 80.0ms 301.3μs -5.4% -
Lambda cold-start with authorizer context 288.7μs 80.0ms 299.8μs -3.7% -
Lambda cold-start realistic scenario 286.1μs 80.0ms 299.2μs -4.4% -
EventBusConfig.start (10 handlers) 1.6μs 10.0ms 1.4μs +14.0% -
EventPublisher.publishNow single event 1.9μs 2.0ms 1.7μs +13.1% -
DefaultHandlerResolver.resolve × 10 0.1μs 5.0ms 0.1μs +0.0% -
Container.get singleton (cold) 59.4μs 5.0ms 70.3μs -15.4% -
Container.register × 50 components 3.1ms 10.0ms 3.2ms -4.3% -
Container.validate (50 components) 3.5ms 20.0ms 3.4ms +2.3% -
Container.get singleton (warm) 1.6μs 500.0μs 1.6μs -2.5% -
TelemetryRuntime.init (lambda preset) 2.0μs 200.0ms 1.1ms -99.8% -
lambdaPreset config creation 1.4μs 2.0ms 1.4μs -4.2% -

Updated: 2026-07-11T19:24:25.231Z · Commit: 620efcb

@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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/transports-http/src/libs/CrocoApp.ts (1)

405-419: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

/health/ready/ready 핸들러 로직 중복 - 공통 함수로 추출 권장.

두 라우트가 checkReadiness() + sanitizeReadinessResult() + 상태 코드 결정 로직을 완전히 동일하게 반복하고 있습니다. 두 alias가 항상 동일하게 동작해야 한다는 PR 목표를 고려하면, 공통 핸들러로 추출해 향후 한쪽만 변경되어 어긋나는 위험을 줄이는 것이 좋습니다.

♻️ 중복 제거 제안
+    const readinessHandler = async (c: Context) => {
+      const result = sanitizeReadinessResult(await this.healthCheckRegistry.checkReadiness());
+      return c.json(result, result.status === "up" ? 200 : 503);
+    };
+
-    this.hono.get("/health/ready", async (c) => {
-      const result = sanitizeReadinessResult(await this.healthCheckRegistry.checkReadiness());
-      return c.json(result, result.status === "up" ? 200 : 503);
-    });
-
-    this.hono.get("/ready", async (c) => {
-      const result = sanitizeReadinessResult(await this.healthCheckRegistry.checkReadiness());
-      return c.json(result, result.status === "up" ? 200 : 503);
-    });
+    this.hono.get("/health/ready", readinessHandler);
+    this.hono.get("/ready", readinessHandler);
🤖 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/transports-http/src/libs/CrocoApp.ts` around lines 405 - 419,
Extract the duplicated readiness logic from registerSystemRoutes into a shared
handler that performs checkReadiness, sanitizeReadinessResult, and status-code
selection, then register both /health/ready and /ready with that handler so the
aliases remain behaviorally identical.
🤖 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/health-core/README.md`:
- Around line 235-242: Update the README integration example to use the
readiness-capable indicator classes already defined in the document, or add
complete definitions for DatabaseReadinessIndicator and RedisReadinessIndicator
before they are instantiated. Ensure the example is self-contained and every
referenced class implements the readiness contract expected by
healthService.registerReadiness.

In `@packages/health-core/src/tests/HealthCheckService.spec.ts`:
- Around line 421-454: Restore real timers after the fake-timer test by adding
an afterEach cleanup that calls vi.useRealTimers(). Scope the cleanup
appropriately for the tests in HealthCheckService.spec.ts so subsequent tests
are unaffected.

---

Outside diff comments:
In `@packages/transports-http/src/libs/CrocoApp.ts`:
- Around line 405-419: Extract the duplicated readiness logic from
registerSystemRoutes into a shared handler that performs checkReadiness,
sanitizeReadinessResult, and status-code selection, then register both
/health/ready and /ready with that handler so the aliases remain behaviorally
identical.
🪄 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: 4b037039-c26f-46e4-a219-e8741c92c883

📥 Commits

Reviewing files that changed from the base of the PR and between 0590a47 and 148b734.

⛔ Files ignored due to path filters (1)
  • packages/problems-core/src/generated/problem-code-registry.ts is excluded by !**/generated/**
📒 Files selected for processing (18)
  • .changeset/readiness-indicator-http.md
  • docs/problem-code-registry.json
  • docs/troubleshooting/diagnostics.md
  • packages/docs/src/content/docs/api/health-core/src/classes/HealthCheckService.md
  • packages/docs/src/content/docs/api/problems-core/src/variables/CROCO_PROBLEM_CODE_REGISTRY.md
  • packages/docs/src/content/docs/api/transports-http/src/classes/HealthCheckRegistry.md
  • packages/docs/src/content/docs/en/reference/problem-recovery-cookbook.md
  • packages/health-core/README.md
  • packages/health-core/src/libs/HealthCheckService.ts
  • packages/health-core/src/tests/HealthCheckService.spec.ts
  • packages/transports-http/README.md
  • packages/transports-http/src/libs/CrocoApp.ts
  • packages/transports-http/src/libs/HealthCheckRegistry.ts
  • packages/transports-http/src/libs/operationalEndpoints.ts
  • packages/transports-http/src/tests/HealthCheck.spec.ts
  • packages/transports-http/src/tests/OperationalEndpoints.spec.ts
  • scripts/static-misuse-empty-catch-allowlist.json
  • tsconfig/contract-strict.baseline.json

Comment thread packages/health-core/README.md Outdated
Comment thread packages/health-core/src/tests/HealthCheckService.spec.ts
@kang-heewon

Copy link
Copy Markdown
Member Author

Addressed the out-of-diff alias-handler request in db275e1: /health/ready and /ready now share one typed readiness handler, keeping aggregation, sanitization, and status selection identical. Focused HTTP tests pass 38/38; full pre-push test and typecheck gates pass 225/225 and 224/224 tasks.

@kang-heewon
kang-heewon merged commit f2798d2 into trunk Jul 11, 2026
9 checks passed
@kang-heewon
kang-heewon deleted the fix/1312-readiness-indicators branch July 11, 2026 20:32
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.

[health] Route HTTP readiness endpoints through readiness indicators

1 participant