Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.

refactor(api): migrate clean-shape ingestion types to openapi.ts source-of-truth - #793

Merged
shiba4life merged 1 commit into
mainfrom
phase-4a/migrate-clean-types
May 1, 2026
Merged

refactor(api): migrate clean-shape ingestion types to openapi.ts source-of-truth#793
shiba4life merged 1 commit into
mainfrom
phase-4a/migrate-clean-types

Conversation

@shiba4life

Copy link
Copy Markdown
Collaborator

Summary

Phase 4a of gbrain `projects/api-typegen-unification`. Six hand-written TypeScript interfaces in `ingestionClient.ts` collapse into one-line aliases over `openapi.ts`:

```ts
export type Role = components["schemas"]["Role"];
export type VisionBackend = components["schemas"]["VisionBackend"];
export type OllamaGenerationParams = components["schemas"]["OllamaGenerationParams"];
export type OllamaConfig = components["schemas"]["OllamaConfig"];
export type AnthropicConfig = components["schemas"]["AnthropicConfig"];
export type IngestionStatus = components["schemas"]["IngestionStatus"];
```

The drift check from #790 now mechanically prevents these from desyncing.

Scope

Bounded to types where the hand-written shape exactly matches the OpenAPI spec (verified line-by-line). Three classes of types stay hand-written for follow-up PRs:

  • `IngestionConfig` — conflates Rust `IngestionConfig` and `SavedConfig`; naive migration would lose the `query` field
  • `UseCaseOverride` — openapi.ts uses `T | null` (Rust `Option` with `skip_serializing_if`) vs hand-written `T?`; close but TypeScript distinguishes
  • Several other invented/partial shapes that need openapi.ts to grow first (Phase 3 cross-repo)

Test plan

  • `npm run typecheck` clean
  • 655 vitest tests pass
  • `npm run lint` — no new errors
  • CI green

🤖 Generated with Claude Code

…ce-of-truth

Phase 4a of gbrain projects/api-typegen-unification. Replaces hand-written
TypeScript interfaces in `ingestionClient.ts` with type aliases over
`components["schemas"][...]` from `openapi.ts` for the six types where the
hand-written shape matches the OpenAPI spec exactly:

- `Role` (literal union of 7 strings)
- `VisionBackend` (literal union)
- `OllamaGenerationParams` (8 number fields, identical layout)
- `OllamaConfig` (model/base_url/vision_model?/ocr_model?/generation_params?)
- `AnthropicConfig` (api_key/model/base_url)
- `IngestionStatus` (enabled/configured/provider/model/auto_execute_mutations)

The drift check shipped in #790 now mechanically prevents these from
desyncing — a backend change to any of the underlying Rust structs forces
a regenerated `openapi.ts`, which immediately propagates to every consumer
of the alias.

Deferred to follow-up PRs (each requires per-interface analysis):

- `IngestionConfig` — the hand-written interface conflates Rust's
  `IngestionConfig` (no `query`) with `SavedConfig` (has `query`). Naive
  migration would break runtime behavior; needs a careful split between
  the request and saved-config shapes.
- `UseCaseOverride` — openapi.ts uses `T | null` for skip_serializing_if
  options; hand-written uses `T?`. Functionally close but TypeScript
  treats them as distinct (null vs undefined). Needs callsite review.
- `MutationResponse`, `QueryResponse`, `ResetDatabaseResponse`,
  `SystemKeyResponse`, `OrgInviteBundle` — invented or partial shapes
  that don't yet match openapi.ts (Phase 1 fixed the most egregious;
  remaining ones get migrated as openapi.ts coverage expands via Phase 3
  cross-repo work).

Verification: `npm run typecheck` clean, 655 vitest tests pass, lint
unchanged from main.
@shiba4life
shiba4life enabled auto-merge May 1, 2026 20:13
@shiba4life
shiba4life added this pull request to the merge queue May 1, 2026
Merged via the queue into main with commit 5cdc3e3 May 1, 2026
16 checks passed
@shiba4life
shiba4life deleted the phase-4a/migrate-clean-types branch May 1, 2026 20:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant