← all branches

feat/one-api

needs attentionviewing older commit
85b9018 · incrementalPR #326reviewed 2026-07-21 23:51 UTC0H · 1M · 6L · 4I
The branch
Purpose
Establish the One-API program as a ratified architectural direction — one canonical contract tree where audience is metadata on a route, not a separate mount.
Goal
Land SSOT rules + W1 groundwork (route inventory, id registry, RouteMeta machinery) plus three P0 security gates making the unified surface enforceable.
Sub-goals
  • SG-1: one-api.md SSOT rule (decision, wire grammar, nesting rules, shipped wire examples, canonical contract form, wave plan)
  • SG-2: classify-routes.ts → route-inventory.json: 250 routes classified
  • SG-3: shared-kernel = sole 55-entity PublicIdPrefix registry
  • SG-4: ADRs 016/018/020 distilled into rules; docs/ADRs/ retired
  • SG-5: RouteMeta type/builder/schema/scope-helpers; all 48 public-v1 routes stamped
  • SG-6 (BAT-274): withMetaGate enforcement point at public mount
  • SG-7 (BAT-273): catalog write exports gated isPlatformAdmin
  • SG-8 (BAT-275): two-org IDOR harness over all 48 routes
The changes (whole branch)
What
Consolidates session knowledge about withMetaGate, scope grammar, catalog admin gate, realtime/event plane, and convergence migration hazards into permanent rule files. Also drops unused zone variable in IDOR test seed (lint).
Why
Captures in-session decisions as permanent SSOT rules so future implementors building W3–W5 capabilities work from a complete knowledge base rather than reconstructing decisions from session context.
Areas
.claude/rules+904apps/platform/src/__tests__+11
Blast
Docs-only + one test lint fix. 3 files, +92/-5. No production code changed. Rules auto-load in future sessions touching api/ and public-v1/.
public-api auth docs
CI· no CI status available via gh api tokenCodeRabbit· no .coderabbit.yaml

Findings · 11

security3

medium

'service' RouteAuthKind is unresolvable — silent W2 trap

apps/platform/src/api/utils/public-v1-meta-gate.ts:104

Gate maps actorType to kind as machine|session only. RouteMetaSchema accepts auth:['service'], so when W2 service keys land and a route stamps auth:['service'], the gate silently returns FORBIDDEN_ACTOR for all callers. Fix before W2: add 'service' to the actorType discriminator, or document that service routes must also include 'machine' until the gate is extended.

low

OPTIONS handler bypasses rate limiting

apps/platform/src/app/api/v1/[...ts-rest]/route.ts

All HTTP methods pass through withRateLimit before dispatch; OPTIONS calls baseHandler directly. Real impact minimal (CORS preflight is method-matched against POST so gate returns UNAUTHORIZED on OPTIONS) but inconsistent surface.

info

Org-claim GUC gap correctly documented; no W3 merge gate exists yet

.claude/rules/one-api.md

Convergence hazard #3 accurately identifies stale JWT membership claims as an auth gap on converged public routes. No blocker for this PR (no converged routes yet), but W3 capability PRs should each require a stale-membership test before deleting the internal twin.

conventions2

low

Scope grammar conflates grant vocabulary with required-scope vocabulary

.claude/rules/api-patterns.md

The new bullet lists 5 grant forms including {cap}:* but RouteMetaSchema.scopes restricts required scopes to {cap}:{read|write} only. Add one sentence distinguishing grant forms from route requirement forms to prevent future implementers from stamping {cap}:* as a required scope.

low

withPublicApiAuth attribution inverts causal direction

.claude/rules/api-patterns.md

Docs frame withPublicApiAuth as the enforcement mechanism; in reality withMetaGate enforces scopes, withPublicApiAuth is a handler wrapper that short-circuits. Risk: future implementers may believe adding withPublicApiAuth alone is sufficient for scope enforcement.

tests2

low

Pricing zone row not cleaned up in afterAll

apps/platform/src/__tests__/integration/public-v1-idor.test.ts

Pre-existing gap (not introduced by this diff). Repeated runs accumulate stale rows in shared integration DB.

info

No explicit 'fails-closed' test for withMetaGate unknown route key

apps/platform/src/__tests__/integration/public-v1-idor.test.ts

Docs claim withMetaGate fails closed on unknown keys. IDOR harness fires all known routes but not a fabricated unknown key. A one-line synthetic test would pin this behavioral claim.

improvement4

low

Route-metadata-gate bullet is a 230-word paragraph — hard to scan

.claude/rules/api-patterns.md

Encodes a 4-step decision tree, stash/reuse optimization, AuthContext shape, and CI hook all in one dense run-on. Sub-list would aid future readers scanning for specific facts.

low

Missing convergence hazard — error surface divergence

.claude/rules/one-api.md

3 documented hazards (casing, pagination, auth mechanism) miss a fourth: internal routes emit raw ZodError trees and undeclared 5xx bodies; when converged those become public leaks or contract violations.

info

Realtime table Gate column is heterogeneous

.claude/rules/one-api.md

Gate column mixes a system name, a design property, and a technical detail across rows — not a consistent column. Consider 3-column table (Plane/Transport/Audience) with gate info in the bullet rules below.

info

Test comment could be more specific

apps/platform/src/__tests__/integration/public-v1-idor.test.ts:149

'referential completeness of the CFE graph' is opaque. 'Required by the CFE schema FK chain but not used as a probe target' is more concrete.

History · 47 commits

  1. 82bb5b9blockedincremental5H · 5M · 4L2026-08-12 01:48
  2. 90aa3d5needs attentionincremental1H · 5M · 3L2026-08-11 19:37
  3. 29d19a0needs attentionincremental1H · 5M · 9L2026-08-11 17:41
  4. 9bd8a0cneeds attentionfull0H · 5M · 9L2026-08-11 02:14
  5. 62ec3f7needs attentionincremental2H · 5M · 6L2026-08-10 22:51
  6. f93bca9needs attentionincremental2H · 5M · 8L2026-08-10 17:51
  7. 052db6fneeds attentionincremental1H · 3M · 4L2026-08-09 21:13
  8. 45699caneeds attentionincremental0H · 7M · 11L2026-08-09 17:44
  9. b843d8aneeds attentionincremental1H · 7M · 9L2026-08-09 04:05
  10. e1757b8needs attentionincremental0H · 3M · 6L2026-08-05 02:11
  11. 7a762faneeds attentionincremental2H · 5M · 5L2026-08-05 01:25
  12. 3300a60needs attentionincremental2H · 4M · 7L2026-08-04 19:06
  13. 0c8a7f5needs attentionincremental0H · 4M · 9L2026-08-04 18:15
  14. 345f42eneeds attentionincremental2H · 6M · 9L2026-08-04 17:28
  15. 8338a9aneeds attentionincremental5H · 14M · 14L2026-08-04 00:33
  16. 41be4c3needs attentionincremental0H · 5M · 7L2026-08-03 23:49
  17. 5ed593dneeds attentionincremental1H · 6M · 6L2026-08-03 21:32
  18. b333e25needs attentionincremental4H · 9M · 8L2026-08-03 21:00
  19. 5642cccneeds attentionincremental2H · 3M · 2L2026-08-03 20:17
  20. 73b0b39needs attentionincremental3H · 10M · 13L2026-07-31 18:29
  21. b19852eneeds attentionincremental0H · 1M · 5L2026-07-29 05:04
  22. 3845205needs attentionincremental3H · 6M · 4L2026-07-29 04:47
  23. eb8eb50needs attentionincremental0H · 1M · 2L2026-07-29 03:03
  24. f4720a3needs attentionincremental6H · 8M · 7L2026-07-29 02:54
  25. f8d341ablockedincremental2H · 2M · 5L2026-07-29 00:00
  26. a7f1a64needs attentionincremental2H · 8M · 8L2026-07-28 18:41
  27. 738b60bblockedincremental3H · 6M · 5L2026-07-28 00:46
  28. 2c248b6needs attentionincremental8H · 12M · 8L2026-07-27 23:23
  29. 1346cc0needs attentionincremental2H · 8M · 6L2026-07-27 20:15
  30. 0716018needs attentionincremental2H · 11M · 12L2026-07-27 19:22
  31. 215cd2dneeds attentionincremental3H · 6M · 5L2026-07-27 17:04
  32. ec46958needs attentionincremental0H · 3M · 5L2026-07-27 16:51
  33. de7b337blockedincremental4H · 9M · 14L2026-07-27 06:36
  34. b1bb9c0needs attentionincremental1H · 2M · 4L2026-07-27 05:09
  35. 4701d11needs attentionincremental0H · 4M · 3L2026-07-27 04:44
  36. e1626c4needs attentionincremental3H · 9M · 10L2026-07-27 03:21
  37. 195f198needs attentionincremental3H · 3M · 3L2026-07-25 01:22
  38. 42c7358safeincremental0H · 0M · 0L2026-07-22 20:46
  39. 85b9018needs attentionincremental0H · 1M · 6L2026-07-21 23:51current
  40. a7b2a9aneeds attentionincremental0H · 9M · 12L2026-07-21 18:49
  41. c2ee0daneeds attentionincremental4H · 7M · 7L2026-07-21 02:17
  42. e8ffa5eneeds attentionincremental4H · 7M · 5L2026-07-21 01:33
  43. a2d2a54needs attentionincremental2H · 7M · 3L2026-07-21 00:51
  44. 576fbd6needs attentionfull1H · 6M · 7L2026-07-21 00:35
  45. d3465e8needs attentionincremental1H · 7M · 10L2026-07-21 00:23
  46. dc794a7needs attentionincremental0H · 5M · 5L2026-07-20 23:46
  47. 9082773needs attentionfull1H · 3M · 3L2026-07-20 23:13