Skip to content

test: guard cost report agent coverage#57

Merged
moose-lab merged 1 commit into
mainfrom
codex/cost-agent-coverage-guardrail
Jun 18, 2026
Merged

test: guard cost report agent coverage#57
moose-lab merged 1 commit into
mainfrom
codex/cost-agent-coverage-guardrail

Conversation

@moose-lab

Copy link
Copy Markdown
Owner

Audit conclusion

Summary

  • add explicit Cost Report provider and Local CLI agent coverage metadata
  • mark Claude and Codex as supported with their historical source path and cache strategy
  • mark the remaining Local CLI agents as intentionally unsupported for Cost Report until a durable usage source is implemented
  • add guardrail tests so future agents/providers cannot be added without updating cost coverage

Verification

  • TZ=Asia/Shanghai node --test --import tsx --test-reporter spec src/core/tests/cost-tracker.test.ts
  • git diff --check
  • bun run typecheck
  • TZ=Asia/Shanghai bun run test
  • pre-commit quality gate: git diff --cached --check && bun run typecheck && TZ=Asia/Shanghai bun run test

@claude

claude Bot commented Jun 18, 2026

Copy link
Copy Markdown

Claude finished @moose-lab's task in 1m 40s —— View job


PR Review

  • Gather context
  • Read changed files
  • Review diff
  • Post findings

Findings

  • [should-fix] cost-tracker.test.ts:98-102.filter((coverage) => coverage.supported) has no type predicate, so TypeScript does not narrow the union before .map((coverage) => coverage.provider). property only exists on the supported: true branch; accessing it on the bare union type is a type error. Fix: .filter((coverage): coverage is Extract<CostReportAgentCoverage, { supported: true }> => coverage.supported). If this compiles today it is likely because __tests__ files are excluded from tsconfig.json — but the latent unsoundness is worth closing.

  • [nit] cost-tracker.ts:26-71 — The key type of COST_REPORT_AGENT_COVERAGE is inferred as string. Typing it as Record<(typeof LOCAL_CLI_AGENT_DEFINITIONS)[number]['id'], CostReportAgentCoverage> would give compile-time enforcement (not just test-time) that every agent ID is covered. The test guardrail already handles this at runtime, so not a blocker.

  • [nit] cost-tracker.ts:31,37 — The cacheStrategy strings are long prose. They document intent well, but there is no machine-readable enum distinguishing "mtime cache", "incremental", etc. If the strings are ever queried programmatically (e.g., for a UI badge), a structured field would be better. No action needed now.

Verdict: APPROVE

The overall design is sound: deriving CostProvider from the as const array, using a discriminated union for coverage, and the three guardrail tests together enforce that the coverage map stays in sync with LOCAL_CLI_AGENT_DEFINITIONS and that COST_REPORT_PROVIDERS matches what is actually supported. The only issue worth addressing before merge is the missing type predicate in the third test.

@moose-lab moose-lab merged commit 19929d8 into main Jun 18, 2026
4 checks passed
@moose-lab moose-lab deleted the codex/cost-agent-coverage-guardrail branch June 18, 2026 04: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.

1 participant