Finish the declaration collapse: three shapes left, and a false rule that survives in two comments #181

Closed
opened 2026-09-18 10:16:11 +02:00 by lz · 0 comments
Owner

Follow-ups deliberately left out of #180 to keep that diff surgical. Each is pre-existing duplication rather than something that PR orphaned.

1. SessionKind is still written twice — and it is now load-bearing

lib/server/db/schema.ts:19 and inline at lib/api/types.ts:141. It is the parameter type of sessionBasePath, the helper #180 introduced, so it is the one shape that got more important while staying duplicated.

Contrast WORKER_STATUSES / SESSION_STATUSES (types.ts:11,17), which the repo already derives from one array and which schema.ts aliases. Low risk today — the dangerous direction is caught, since toDTO assigns row.kind into the DTO — but this is the shape a finishing pass should take first.

2. PreviewStatus / PreviewSource / PreviewScheme

db/schema.ts:99-101 and api/types.ts:168-170. Same asymmetry: rowToDTO assigns schema→canonical, so widening the schema union fails to compile, but the reverse is unguarded. One-line fix — import them in schema.ts alongside the three siblings already imported there.

3. The false rule, in two places

Both of these state a constraint that does not exist:

  • lib/api/mcp-dto-parity.test.ts:7-10 — "neither can import the other ($lib/api/types is reachable from the browser, $server is not)"
  • lib/server/db/schema.ts:2-3 — "Server-only modules can import a client-safe type, not vice versa"

Both halves are false. #180 demonstrates server → client-safe five times over (sessions/attention.ts, workers/service.ts, sessions/service.ts, previews/service.ts, terminal/upgrade.ts), and the reverse was already shipped on main: eleven client modules and .svelte components import type from $lib/server/artifacts/types, which is why ArtifactDTO is declared once while everything else is declared twice.

The accurate rule is narrower: a runtime value from $lib/server cannot reach client code, but import type is erased before Vite's illegal-import check sees it, and server → client-safe is unrestricted in both forms.

Do not delete mcp-dto-parity.test.ts. Unlike the two parity tests #180 removed, its duplication is live and the two declarations are structurally unrelated, so the mutual-assignability assertion still fails on real drift. Only the stated reason is wrong. Fix both docblocks together — fixing one would leave the other looking authoritative.

Once the comments are accurate, whether McpStatusDTO / CimdClientDTO stay duplicated becomes a live choice rather than an assumed constraint.

4. app.css is the last unguarded rename anchor for the attention vocabulary

sessionMark's return value is used directly as a CSS class name (app.css:318,323,361, .status-dot.needs-you). A rename that correctly updates worker/plugins/nexus/hooks/hooks.json and the four typecheck-red literal sites in lib/attention.ts still leaves that rule dead, and the needs-you ping silently stops animating.

Pre-existing — the parity test #180 deleted never checked CSS either — but it is now the only anchor nothing checks. A cheap guard: assert that every member of ATTENTION_STATES appears as a .status-dot.<state> selector in app.css.

Not in scope

The MountSpec / token-scope / McpStatusDTO duplication that AGENTS.md facts #22 and #24 name as deliberate stays deliberate. This issue is about making the stated reasons true, not about collapsing those.

Follow-ups deliberately left out of #180 to keep that diff surgical. Each is pre-existing duplication rather than something that PR orphaned. ## 1. `SessionKind` is still written twice — and it is now load-bearing `lib/server/db/schema.ts:19` and inline at `lib/api/types.ts:141`. It is the parameter type of `sessionBasePath`, the helper #180 introduced, so it is the one shape that got *more* important while staying duplicated. Contrast `WORKER_STATUSES` / `SESSION_STATUSES` (`types.ts:11,17`), which the repo already derives from one array and which `schema.ts` aliases. Low risk today — the dangerous direction is caught, since `toDTO` assigns `row.kind` into the DTO — but this is the shape a finishing pass should take first. ## 2. `PreviewStatus` / `PreviewSource` / `PreviewScheme` `db/schema.ts:99-101` and `api/types.ts:168-170`. Same asymmetry: `rowToDTO` assigns schema→canonical, so widening the schema union fails to compile, but the reverse is unguarded. One-line fix — import them in `schema.ts` alongside the three siblings already imported there. ## 3. The false rule, in two places Both of these state a constraint that does not exist: - **`lib/api/mcp-dto-parity.test.ts:7-10`** — *"neither can import the other (`$lib/api/types` is reachable from the browser, `$server` is not)"* - **`lib/server/db/schema.ts:2-3`** — *"Server-only modules can import a client-safe type, not vice versa"* Both halves are false. #180 demonstrates server → client-safe five times over (`sessions/attention.ts`, `workers/service.ts`, `sessions/service.ts`, `previews/service.ts`, `terminal/upgrade.ts`), and the reverse was already shipped on main: eleven client modules and `.svelte` components `import type` from `$lib/server/artifacts/types`, which is why `ArtifactDTO` is declared once while everything else is declared twice. The accurate rule is narrower: a **runtime value** from `$lib/server` cannot reach client code, but `import type` is erased before Vite's illegal-import check sees it, and server → client-safe is unrestricted in both forms. **Do not delete `mcp-dto-parity.test.ts`.** Unlike the two parity tests #180 removed, its duplication is live and the two declarations are structurally unrelated, so the mutual-assignability assertion still fails on real drift. Only the stated *reason* is wrong. Fix both docblocks together — fixing one would leave the other looking authoritative. Once the comments are accurate, whether `McpStatusDTO` / `CimdClientDTO` stay duplicated becomes a live choice rather than an assumed constraint. ## 4. `app.css` is the last unguarded rename anchor for the attention vocabulary `sessionMark`'s return value is used directly as a CSS class name (`app.css:318,323,361`, `.status-dot.needs-you`). A rename that correctly updates `worker/plugins/nexus/hooks/hooks.json` and the four typecheck-red literal sites in `lib/attention.ts` still leaves that rule dead, and the needs-you ping silently stops animating. Pre-existing — the parity test #180 deleted never checked CSS either — but it is now the only anchor nothing checks. A cheap guard: assert that every member of `ATTENTION_STATES` appears as a `.status-dot.<state>` selector in `app.css`. ## Not in scope The `MountSpec` / token-scope / `McpStatusDTO` duplication that AGENTS.md facts #22 and #24 name as deliberate stays deliberate. This issue is about making the *stated reasons* true, not about collapsing those.
lz added this to the MCP support (#140) milestone 2026-09-21 16:38:32 +02:00
lz closed this issue 2026-09-21 19:10:02 +02:00
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lz/agent-nexus#181
No description provided.