Skip to content

fix: expose Croco operations status plane - #817

Merged
kang-heewon merged 1 commit into
trunkfrom
fix/716-operations-plane
Jun 16, 2026
Merged

fix: expose Croco operations status plane#817
kang-heewon merged 1 commit into
trunkfrom
fix/716-operations-plane

Conversation

@kang-heewon

@kang-heewon kang-heewon commented Jun 16, 2026

Copy link
Copy Markdown
Member

Fixes #716.

Summary

Croco apps now expose the canonical operations surface expected by the issue: /diagnostics alongside the legacy diagnostics path, /metrics with safe framework counters, and runtime metadata in the default diagnostics collector.

The CLI now includes croco ops status <url> with pretty and --json output for health, readiness, diagnostics, and metrics probes. The diagnostics token is only sent to /diagnostics, and degraded or unhealthy summaries return a non-zero exit code for smoke/CI usage.

Verification

  • pnpm --filter @croco/cli exec vitest run src/tests/opsStatus.spec.ts
  • pnpm --filter @croco/transports-http exec vitest run src/tests/OperationalEndpoints.spec.ts src/tests/HealthCheck.spec.ts
  • pnpm typecheck --filter=@croco/transports-http --filter=@croco/cli
  • pnpm check
  • pnpm test --filter=@croco/diagnostics-core --filter=@croco/health-core --filter=@croco/transports-http --filter=@croco/cli
  • pnpm changeset-required:check -- --base origin/trunk --head HEAD
  • git diff --check origin/trunk...HEAD
  • Pre-push hook: full pnpm test passed 197/197 tasks
  • Pre-push hook: full pnpm typecheck passed 196/196 tasks

Self-review gates

  • Correctness/regression: PASS. /diagnostics, legacy /health/diagnostics, /metrics, runtime diagnostics metadata, CLI healthy/degraded/unhealthy summaries, diagnostics token scoping, and non-zero degraded exits are covered by focused tests. Existing diagnostics duplicate-provider, timeout, redaction, recent-error, and readiness tests remain green through the related package matrix.
  • API/security/compatibility/release: PASS. The legacy diagnostics endpoint and constants remain available, the canonical diagnostics and metrics constants/types are exported, /metrics exposes only counts, diagnostics tokens are scoped to the diagnostics request, no dependency or lockfile change is introduced, and a patch changeset covers @croco/transports-http and @croco/cli.
  • Maintainability/minimality: PASS. The HTTP change reuses the existing diagnostics collector/policy and health registry, the CLI command is isolated under the existing citty command pattern, and the registry exposes only a count helper needed by metrics.

Independent review

  • Review found no HIGH/CRITICAL blockers. Addressed the actionable findings by scoping --token to /diagnostics, renaming the metrics endpoint-list count to standardEndpointPathCount, and making degraded CLI status non-zero.

Risk

Low. Diagnostics exposure remains controlled by the existing diagnostics policy; the new /metrics route is always available but only returns timestamp, standard endpoint-path count, and registered health-check count.

Summary by CodeRabbit

릴리스 노트

  • New Features

    • croco ops status 명령을 통해 런타임 상태를 확인할 수 있습니다.
    • 새로운 operational endpoints(health, ready, diagnostics, metrics)가 노출됩니다.
    • 상태 보고서를 JSON 또는 사람이 읽을 수 있는 형식으로 출력할 수 있습니다.
  • Tests

    • Ops status 명령 동작 검증을 위한 테스트 추가
    • Operational endpoints 기능 테스트 추가

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

More reviews will be available in 12 minutes and 19 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

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.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8eecf45a-f266-45bb-ae73-003f4be79345

📥 Commits

Reviewing files that changed from the base of the PR and between 6d7710c and 8b3cd2a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (16)
  • .changeset/ops-status-plane.md
  • packages/cli/package.json
  • packages/cli/src/bin/croco.ts
  • packages/cli/src/commands/ops.ts
  • packages/cli/src/index.ts
  • packages/cli/src/tests/opsStatus.spec.ts
  • packages/docs/src/content/docs/api/transports-http/src/classes/HealthCheckRegistry.md
  • packages/docs/src/content/docs/api/transports-http/src/type-aliases/OperationalMetricsResponse.md
  • packages/docs/src/content/docs/api/transports-http/src/variables/METRICS_ENDPOINT_PATH.md
  • packages/docs/src/content/docs/api/transports-http/src/variables/OPERATIONAL_ENDPOINT_PATHS.md
  • packages/docs/src/content/docs/api/transports-http/src/variables/STANDARD_DIAGNOSTICS_ENDPOINT_PATH.md
  • packages/transports-http/src/index.ts
  • 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/OperationalEndpoints.spec.ts
📝 Walkthrough

Walkthrough

transports-http에 표준 진단 경로(/diagnostics), 메트릭 엔드포인트(/metrics), RuntimeDiagnosticsProvider, OperationalMetricsResponse 타입 및 getRegisteredCheckCount 메서드를 추가한다. CrocoApp에 새 라우트를 등록하고, CLI에 croco ops status 명령을 구현해 4개 운영 엔드포인트를 병렬 조회 후 JSON 또는 사람 가독 형식으로 출력한다.

Changes

Operations Status Plane

Layer / File(s) Summary
운영 엔드포인트 상수·타입·런타임 프로바이더
packages/transports-http/src/libs/operationalEndpoints.ts, packages/transports-http/src/libs/HealthCheckRegistry.ts
STANDARD_DIAGNOSTICS_ENDPOINT_PATH, METRICS_ENDPOINT_PATH, OPERATIONAL_ENDPOINT_PATHS 상수와 OperationalMetricsResponse 타입, createOperationalMetricsResponse 함수, RuntimeDiagnosticsProvider 클래스를 추가한다. HealthCheckRegistrygetRegisteredCheckCount() 메서드를 추가한다.
HTTP 라우트 등록 및 공개 API 확장
packages/transports-http/src/libs/CrocoApp.ts, packages/transports-http/src/index.ts
registerSystemRoutes()에 표준/레거시 두 진단 경로와 /metrics 라우트를 등록한다. 새 상수·타입을 패키지 진입점에서 재내보낸다.
CLI ops status 명령 전체 구현
packages/cli/src/commands/ops.ts
OpsEndpointName, OpsEndpointSnapshot, OpsStatusReport 등 타입과 opsStatus·ops 커맨드를 정의한다. runOpsStatus가 4개 엔드포인트를 병렬 호출하고, AbortController로 타임아웃을 강제하며, diagnostics 전용 토큰 헤더를 주입한다. 스냅샷에서 healthy/degraded/unhealthy 요약을 계산하고 formatOpsStatusReport·getOpsStatusExitCode로 출력 및 종료 코드를 결정한다.
CLI 진입점 연결 및 공개 API 노출
packages/cli/src/bin/croco.ts, packages/cli/src/index.ts, .changeset/ops-status-plane.md
ops 모듈을 CLI subCommands에 등록하고, ops 관련 함수·타입을 패키지 진입점에서 전부 재내보낸다. patch 릴리스 changeset을 추가한다.
테스트
packages/transports-http/src/tests/OperationalEndpoints.spec.ts, packages/cli/src/tests/opsStatus.spec.ts
canonical/legacy 진단 경로 동등성, /metrics 최소 응답, RuntimeDiagnosticsProvider 메타데이터 포함 여부를 검증하는 테스트를 추가한다. healthy/degraded/unhealthy 시나리오, 토큰 헤더 주입 여부, 커맨드 등록, 종료 코드 매핑 테스트를 추가한다.

Sequence Diagrams

sequenceDiagram
  participant User
  participant opsStatus커맨드
  participant runOpsStatus
  participant fetchOperationalEndpoint
  participant CrocoApp서버

  rect rgba(70, 130, 180, 0.5)
    Note over User,opsStatus커맨드: croco ops status <url>
    User->>opsStatus커맨드: 실행 (--json, --token 옵션)
    opsStatus커맨드->>runOpsStatus: target URL, RunOpsStatusOptions
  end

  rect rgba(60, 179, 113, 0.5)
    Note over runOpsStatus,CrocoApp서버: 4개 엔드포인트 병렬 조회
    runOpsStatus->>fetchOperationalEndpoint: Promise.all [/health, /ready, /diagnostics, /metrics]
    fetchOperationalEndpoint->>CrocoApp서버: GET /health
    fetchOperationalEndpoint->>CrocoApp서버: GET /ready
    fetchOperationalEndpoint->>CrocoApp서버: GET /diagnostics (X-Diagnostics-Token 헤더)
    fetchOperationalEndpoint->>CrocoApp서버: GET /metrics
    CrocoApp서버-->>fetchOperationalEndpoint: OpsEndpointSnapshot 배열
  end

  rect rgba(255, 140, 0, 0.5)
    Note over runOpsStatus,opsStatus커맨드: 요약 계산 및 출력
    fetchOperationalEndpoint-->>runOpsStatus: OpsEndpointSnapshot[]
    runOpsStatus-->>opsStatus커맨드: OpsStatusReport (summary, endpoints)
    opsStatus커맨드->>User: JSON 또는 포맷된 텍스트 출력
    opsStatus커맨드->>opsStatus커맨드: process.exitCode = 0(healthy) 또는 1(그 외)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목은 운영(operations) 상태 평면(status plane)을 노출하는 변경사항을 간결하고 명확하게 요약합니다.
Linked Issues check ✅ Passed PR은 #716의 모든 핵심 목표를 충족합니다: 4개 표준 엔드포인트(/health, /ready, /diagnostics, /metrics), 진단 정책, CLI 뷰어(croco ops status), 런타임 메타데이터, 타임아웃 처리 및 하위 호환성 유지.
Out of Scope Changes check ✅ Passed 모든 변경사항이 #716의 운영 평면 표준화 목표와 일치합니다. 엔드포인트 추가, CLI 명령, 진단 정책, 런타임 메타데이터 제공 등 범위 내 변경입니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/716-operations-plane

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 and usage tips.

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

📊 Benchmark Results

❌ Some benchmarks failed

Gate failures

  • CrocoApp lambdaHandler (10 controllers): p75 40.5μs exceeds baseline 33.3μs by more than 20%
  • Lambda cold-start simulation: p75 171.0μs exceeds baseline 70.2μs by more than 20%
  • Lambda cold-start with headers: p75 107.5μs exceeds baseline 66.7μs by more than 20%
  • Lambda cold-start with binary body: p75 105.8μs exceeds baseline 63.2μs by more than 20%
  • Lambda cold-start with query params: p75 95.4μs exceeds baseline 63.9μs by more than 20%
  • Lambda cold-start with authorizer context: p75 99.0μs exceeds baseline 59.8μs by more than 20%
  • Lambda cold-start realistic scenario: p75 98.7μs exceeds baseline 60.2μs by more than 20%
  • EventBusConfig.start (10 handlers): p75 1.6μs exceeds baseline 0.9μs by more than 20%
  • EventPublisher.publishNow single event: p75 1.8μs exceeds baseline 1.1μs by more than 20%
  • DefaultHandlerResolver.resolve × 10: p75 0.1μs exceeds baseline 0.0μs by more than 20%
  • Container.get singleton (cold): p75 1.1μs exceeds baseline 0.6μs by more than 20%
  • Container.get singleton (warm): p75 0.4μs exceeds baseline 0.3μs by more than 20%
  • lambdaPreset config creation: p75 1.4μs exceeds baseline 1.0μs by more than 20%
Benchmark p75 Threshold Baseline vs Baseline Status Notes
CrocoApp constructor 3.2μs 30.0ms 3.4μs -6.2% -
CrocoApp lambdaHandler (10 controllers) 40.5μs 50.0ms 33.3μs +21.6% -
Lambda cold-start simulation 171.0μs 80.0ms 70.2μs +143.7% -
Lambda cold-start with headers 107.5μs 80.0ms 66.7μs +61.1% -
Lambda cold-start with binary body 105.8μs 80.0ms 63.2μs +67.4% -
Lambda cold-start with query params 95.4μs 80.0ms 63.9μs +49.3% -
Lambda cold-start with authorizer context 99.0μs 80.0ms 59.8μs +65.5% -
Lambda cold-start realistic scenario 98.7μs 80.0ms 60.2μs +64.1% -
EventBusConfig.start (10 handlers) 1.6μs 10.0ms 0.9μs +86.6% -
EventPublisher.publishNow single event 1.8μs 2.0ms 1.1μs +63.8% -
DefaultHandlerResolver.resolve × 10 0.1μs 5.0ms 0.0μs +64.3% -
Container.get singleton (cold) 1.1μs 5.0ms 0.6μs +75.4% -
Container.register × 50 components 12.0μs 10.0ms 12.1μs -1.0% -
Container.validate (50 components) 29.6μs 20.0ms 29.7μs -0.1% -
Container.get singleton (warm) 0.4μs 500.0μs 0.3μs +34.2% -
TelemetryRuntime.init (lambda preset) 1.0ms 200.0ms 69.3ms -98.5% -
lambdaPreset config creation 1.4μs 2.0ms 1.0μs +40.6% -

Updated: 2026-06-16T12:35:42.304Z · Commit: e566ff3

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

🤖 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/cli/src/commands/ops.ts`:
- Around line 148-166: The functions parseTimeoutMs and parseTargetUrl are
throwing raw Error objects which violates the project's RFC 7807-based exception
handling rules. Replace both Error throws with appropriate Problem subclasses:
in parseTimeoutMs when the parsed timeout is not finite or is non-positive, and
in parseTargetUrl when the URL constructor throws an exception. Use the
project's standard Problem subclasses instead of new Error for consistent error
handling across CLI validations.

In `@packages/cli/src/index.ts`:
- Around line 30-42: The export block from the ops commands module mixes runtime
exports and type exports together, violating the file's organization convention.
Separate the type exports (type OpsEndpointName, type OpsEndpointSnapshot, type
OpsStatusFetch, type OpsStatusReport, type OpsStatusSummary, type
RunOpsStatusOptions) from the runtime exports (formatOpsStatusReport,
getOpsStatusExitCode, ops, opsStatus, runOpsStatus). Keep the runtime exports in
their current location and move all the type exports to a dedicated types
section at the end of the file, following the established pattern of grouping
exports by category with types collected at the end.

In `@packages/cli/src/tests/opsStatus.spec.ts`:
- Around line 1-10: The test file is missing the required DI container isolation
hook. Add `beforeEach` to your vitest imports at the top of the file, import the
DI Container (likely from a dependency injection module), and add a `beforeEach`
hook inside the describe block for "ops status" that calls `Container.reset()`
before each test. This ensures proper test isolation by resetting the dependency
injection container between test runs as required by the coding guidelines for
test files.

In `@packages/transports-http/src/tests/OperationalEndpoints.spec.ts`:
- Around line 9-12: Separate type imports from value imports following the
mandatory coding guideline. In
packages/transports-http/src/tests/OperationalEndpoints.spec.ts (lines 9-12),
move DiagnosticsEndpointOptions from the regular import statement into a
separate import type statement. In packages/cli/src/tests/opsStatus.spec.ts
(lines 2-8), move OpsStatusFetch from the regular import statement into a
separate import type statement. Ensure all type-only symbols use import type
syntax while keeping value imports in regular import statements.
🪄 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: a8b1241f-22ce-49a7-afad-13c0a5ea9a02

📥 Commits

Reviewing files that changed from the base of the PR and between 6148ed3 and 6d7710c.

📒 Files selected for processing (10)
  • .changeset/ops-status-plane.md
  • packages/cli/src/bin/croco.ts
  • packages/cli/src/commands/ops.ts
  • packages/cli/src/index.ts
  • packages/cli/src/tests/opsStatus.spec.ts
  • packages/transports-http/src/index.ts
  • 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/OperationalEndpoints.spec.ts

Comment thread packages/cli/src/commands/ops.ts
Comment thread packages/cli/src/index.ts
Comment thread packages/cli/src/tests/opsStatus.spec.ts Outdated
Comment thread packages/transports-http/src/tests/OperationalEndpoints.spec.ts Outdated
@kang-heewon
kang-heewon force-pushed the fix/716-operations-plane branch from 6d7710c to 1b44764 Compare June 16, 2026 12:05
@kang-heewon
kang-heewon force-pushed the fix/716-operations-plane branch from 1b44764 to 8b3cd2a Compare June 16, 2026 12:31
@kang-heewon
kang-heewon merged commit f40eb63 into trunk Jun 16, 2026
8 checks passed
@kang-heewon
kang-heewon deleted the fix/716-operations-plane branch June 16, 2026 12:50
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.

Croco Operations Plane

1 participant