Skip to content

feat(response): response-schema linking — generic/annotation/OpenAPI (5.5)#38

Merged
officialCodeWork merged 1 commit into
developmentfrom
build/phase-5/step-5.5-response-schema
Jul 15, 2026
Merged

feat(response): response-schema linking — generic/annotation/OpenAPI (5.5)#38
officialCodeWork merged 1 commit into
developmentfrom
build/phase-5/step-5.5-response-schema

Conversation

@officialCodeWork

Copy link
Copy Markdown
Owner

What

TRACKER step 5.5 — Response-schema linking (failure mode F4). Data sources now carry the shape they return, recovered from three sources.

  • Core: DataSourceNode.responseType?: ResponseType { name, fields: {name,type}[], source } — one level of fields. Lineage-graph + context-bundle JSON schemas regenerated; both drift gates green.
  • Parser (response.ts):
    • responseFromCall — a call's generic argument (axios.get<User[]>, useQuery<T>), else the annotation on the nearest enclosing typed variable whose initializer holds the call (const data: Invoice[] = await fetch(…).then(r => r.json())). Stops at function boundaries; reads property signatures only (methods skipped).
    • loadOpenApi / linkOpenApiResponses — a post-pass that fills sources the code left untyped from an OpenAPI 3 JSON spec, matching ${METHOD} ${endpoint} with {id}:id normalization and $ref resolution.
  • Surfaces: openapi scan option + CLI scan --openapi <file>; bundle lineage dataSources carry responseType; trace prints it (→ User[] { id: number, … } (generic)).

Accept

f4-typed-responses fixture exercises all three: /api/usersUser[] (generic), /api/invoicesInvoice[] (annotation), /api/ordersOrder[] (OpenAPI). New GoldenResponse type + responses check kind; a control asserts /api/orders stays untyped when no spec is supplied.

Verification

  • 6 packages build/typecheck clean; both schema drift gates green
  • unit tests: 181 pass (parser 118 incl. new response.test.ts with 5 tests, core 46, agent-sdk 14, vision 3)
  • eval: 265 pass · 0 fail · 0 xfail — precision/recall 1.000, poison 0.000, gate OK

🤖 Generated with Claude Code

…(5.5)

DataSourceNode gains an optional ResponseType { name, fields, source }
(one level of fields); lineage-graph and context-bundle schemas
regenerated, drift gates green.

New response.ts parser module:
- responseFromCall: recovers the type from a call's generic argument
  (axios.get<User[]>, useQuery<T>) or, failing that, the annotation on
  the nearest enclosing typed variable whose initializer holds the call
  (const data: Invoice[] = await fetch(...).then(r => r.json())). Stops at
  function boundaries; reads property signatures only (methods skipped).
- loadOpenApi / linkOpenApiResponses: post-pass filling untyped sources
  from an OpenAPI 3 JSON spec, matching `${METHOD} ${endpoint}` with
  {id}->:id normalization and $ref resolution.

Exposed via the `openapi` scan option and CLI `scan --openapi`. Bundle
lineage dataSources carry responseType; `trace` prints it.

New f4-typed-responses fixture + GoldenResponse / `responses` check kind
covering all three sources. 5 parser unit tests incl. bundle-level.
eval 265/0/0, gate OK.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@officialCodeWork
officialCodeWork merged commit aea7ed7 into development Jul 15, 2026
1 check passed
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.

2 participants