Skip to content

Use query types everywhere and lint against copies - #362

Merged
byronwall merged 2 commits into
claude/doc-detail-one-typefrom
claude/cleanup-batch-2-5e0a9a
Nov 28, 2026
Merged

byronwall merged 2 commits into
claude/doc-detail-one-typefrom
claude/cleanup-batch-2-5e0a9a

Conversation

@byronwall

@byronwall byronwall commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

The AI, embeddings, UMAP and chat code now uses the types that the queries export, and the research code declares Topic once. CI lint fails if someone copies a query module's type again or casts a fetch* result.

User impact: None. All 20 changed source files compile to the same JavaScript as the base.

Why

A local copy of a query's type keeps compiling after the query changes, as long as the fields stay assignable. A cast hides even the cases that do not. This is cleanup batch 2: move every caller, delete the copies, and add the check in one PR.

  • Removed all 8 casts. The vn/no-query-result-cast exceptions list (6 files) is gone.
  • Deleted the copies of Prompt, UmapRunSummary, UmapRunDetail, UmapPoint, the UMAP points result, EmbeddingRunDetail, DocSectionItem, PromptDetail, PromptRunDetail, RunStatus, ChatThreadStatus and the dashboard prompt type. DashboardRun is now a Pick of PromptRunItem.
  • Topic moved the other way: it is declared once in research.activity.ts, and the MCP layer imports it. The MCP file already imports that service, so the reverse import would make a cycle.
  • No cast hid a type error. Type-check passed after the casts came out.
  • New lint rule vn/no-query-type-redeclare: no file may declare a type name that a *.queries.ts module exports.

Proof

duplicate-type finding on all of app/ (srcly#483, unreleased):

Base (#361) This branch
duplicate-type findings 3 0
Declarations of Prompt, UmapRunSummary, Topic (srcly refs) 2 each 1 each
fetch* casts 8 0
Files excepted from the cast rule 6 0

The final lint config on the base source and on this branch:

base    $ oxlint src   exit 1
        8 vn(no-query-result-cast) errors
        6 vn(no-query-type-redeclare) errors: RunStatus, UmapPoint (2 files),
          Prompt, UmapRunSummary, ChatThreadStatus
branch  $ oxlint src   exit 0

No behavior change, checked by compiling each changed src file at both commits with esbuild:

20 of 20 changed source files emit identical JavaScript

Checks:

  • pnpm type-check and pnpm lint pass. pnpm test: 924 passed, 86 skipped.
  • A one-off browser check on an isolated audit database, with seeded rows, passed 14 of 14 with no page errors: /ai, a prompt, a run, an embedding run and its sections, a UMAP run, and a chat thread.
  • E2E (route-hydration-smoke, no-page-flash, note-safety-gaps, canvas-note-panel, homepage, research-board, research-editing, research-map), with --workers 1, after the rebase onto Drop write-only values and the casts that hid types #364: 45 of 47 pass.
  • The 2 that fail are in canvas-note-panel: "unsaved edits ask before the panel closes" and "a save in flight blocks closing until it finishes". Both also failed on the base before the rebase (3b320b53).
  • The rebase had one conflict, in routes/embeddings/[id].tsx: Drop write-only values and the casts that hid types #364 and this branch each deleted local types there. The result keeps both sets of deletions. The checks above were all rerun after it.

Limits

  • PromptsManagerModal has no importer, so its change was not seen in a browser. It looks like dead code; this PR does not delete it.
  • The new rule matches by name, and only for *.queries.ts exports. A renamed copy passes (this PR found SectionItem by reading), and so does a copy of a type from another module, such as Topic.
  • services/umap.service.ts fetchUmapPoints and fetchUmapPointsForRun share the query key umap-points. Not changed here.

Stack: type cleanup, layer 2 of 2

This slice: the remaining query-type copies and casts, and the check against new copies.
Why it is its own layer: #361 proved the method on DocDetail and can merge alone.
Full story: #361

🤖 Generated with Claude Code

@byronwall
byronwall added this pull request to stack #363 November 28, 2026 04:08
@byronwall byronwall changed the title claude/cleanup batch 2 5e0a9a Use query types everywhere and lint against copies Nov 28, 2026
@byronwall
byronwall removed this pull request from stack #363 November 28, 2026 05:46
@byronwall
byronwall added this pull request to stack #366 November 28, 2026 05:47
byronwall and others added 2 commits November 28, 2026 01:02
Delete the local copies of the types that query modules export, and the 8
casts of fetch* results that hid them.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Add vn/no-query-type-redeclare and drop the six exceptions from
vn/no-query-result-cast.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@byronwall
byronwall force-pushed the claude/cleanup-batch-2-5e0a9a branch from 9833b70 to 87fbd53 Compare November 28, 2026 06:07
@byronwall
byronwall marked this pull request as ready for review November 28, 2026 06:07
@byronwall

Copy link
Copy Markdown
Owner Author

Code review (medium, inline, by the session that wrote the change) before merge: nothing blocking.

  • Older bug, not changed here: fetchUmapPoints and fetchUmapPointsForRun share the query key umap-points but return different shapes. Not reproduced. A separate task covers it.
  • Nit, left as is: vn/no-query-type-redeclare reads only export type and export interface lines in *.queries.ts, so a type exported through export type { Foo } is not protected.

🤖 Generated with Claude Code

@byronwall
byronwall merged commit 44ddb64 into main Nov 28, 2026
5 of 7 checks 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.

1 participant