Repository navigation
Description
Outcome
Data read from SQLite or from an upstream SDK transcript is checked at the boundary by a schema or a typed mapper, so a schema skew or upstream shape change fails loudly at the read instead of silently producing wrong values deeper in.
Why now
Found by the 2026-10-09 code-quality review of main @ 0c69e0cb. Core has 124 and ui-server 191 .get()/.all() ... as T casts; every one asserts a row type the checker cannot verify. ui-server's activity code has 18 as any (for example packages/ui-server/src/activity/query.ts, packages/ui-server/src/activity/store.ts), core's briefing read as any[] (then in packages/core/src/cli/commands/briefing.ts), and the Claude backend reads SDK transcript JSON through 12 anys (packages/ui-backend-claude/src/history.ts). The backend contract test drives a scripted query cast as unknown as typeof query (packages/ui-backend-claude/tests/backend-contract.test.ts:33-53), so an upstream transcript change would not be caught.
Shared context
brain.dbis disposable and schema-versioned (SCHEMA_VERSION,packages/core/src/lib/db.ts:21); skew is real when an old index meets new code.- Current source at main
3aadc8df5: refactor(core): move raw SQL out of CLI commands and keep one silent-edit query #3293 moved briefing's SQL out of the CLI command intopackages/core/src/lib/briefing-reads.ts(focusLinkedDocuments,packages/core/src/lib/briefing-reads.ts:18;upcomingDeadlines,:39;overdueReviewRows,:57). Itsas any[]reads are now uncheckedas Trow casts, which this epic still covers. Lines containingas anyremain inpackages/ui-server/src/activity/query.ts(4),packages/ui-server/src/activity/store.ts(8) andpackages/ui-backend-claude/src/history.ts(7). - zod is already the runtime-validation library across the repo.
- Hot paths (search, indexing) read many rows; validation cost must be measured there.
Constraints and non-goals
- No change to the database schema or to supported query result shapes (docs: retire direct brain.db SQL guarantees after query migration #701 owns those).
- No new dependency.
Breakdown
Native child #1367 owns the mechanism decision (zod per row versus typed mappers and any measured hot-path exemption); it is a scoped investigation deliverable, not a reason to mark this epic ready. Then #1368 owns core rows, #1369 server rows and #1370 Claude transcript parsing. Already-attached #2518 owns Pi server-to-worker messages and transcript resume probes. Preserve each child’s actual prerequisites; parent membership alone is not a blocker.
Definition of done
Each package has a documented row-reading convention, as any is gone from the listed files, and a test feeds a skewed row or transcript and asserts a typed failure.
2026-10-24 continued triage at main dc5d3c73282c29a3f0098306d398743ee18ec791: Refreshed the observed row-cast, scripted-query and SCHEMA_VERSION anchors and reconciled the breakdown with all five native children, including #2518. Historical review counts retain their review SHA. The mechanism decision belongs to #1367; no schema, query result or epic readiness changed.
2026-10-25 triage at main ab746a434c4ada11734ffea4e208d1d6211f1aca: Verified moved current-source anchors and refreshed navigation. Historical failed receipts, existing rulings and unresolved prerequisites are unchanged; this is not a new runtime qualification.
2026-11-10 triage at main 3aadc8df5: recorded that #3293 replaced briefing's as any[] reads with typed as T casts in briefing-reads.ts; the review paragraph keeps its review SHA. All five children remain open; the definition of done is unchanged.
Activity
schlessera commentedon Oct 24, 2026
2026-10-24 triage at main
dc5d3c73282c29a3f0098306d398743ee18ec791: Refreshed the observed row-cast, scripted-query and SCHEMA_VERSION anchors and reconciled the breakdown with all five native children, including #2518. Historical review counts retain their review SHA. The mechanism decision belongs to #1367; no schema, query result or epic readiness changed.schlessera commentedon Oct 25, 2026
2026-10-25 triage at main
ab746a434c4ada11734ffea4e208d1d6211f1aca: Verified moved current-source anchors and refreshed navigation. Historical failed receipts, existing rulings and unresolved prerequisites are unchanged; this is not a new runtime qualification.schlessera commentedon Nov 10, 2026
2026-11-10 triage at main
3aadc8df5: #3293 (merged 2026-11-03) moved briefing's SQL out ofpackages/core/src/cli/commands/briefing.tsintopackages/core/src/lib/briefing-reads.ts. The oldas any[]reads are now uncheckedas Trow casts (focusLinkedDocuments,packages/core/src/lib/briefing-reads.ts:18), so they are still in this epic's scope. I recorded this under Shared context. The review paragraph keeps its 2026-10-09 SHA, and the stale briefing line citation is gone. Lines containingas anyremain in ui-server'sactivity/query.ts(4) andactivity/store.ts(8), and in the Claude backend'shistory.ts(7). All five children remain open. The definition of done is unchanged.