Repository navigation
Description
Part of #1344.
Context
Core asserts row types instead of checking them: 124 single-line .get()/.all() ... as T casts in 32 files under packages/core/src at main d79eeed0a (the same count #1367 records). No as any remains on a core database read.
When this was filed, briefing read rows as any[] inside the command (packages/core/src/cli/commands/briefing.ts:220-295 at 572dd6d28). #1353 / PR #3293 (squash 003576188) moved that SQL out of the CLI, so the as any[] reads became typed but unchecked as T casts in packages/core/src/lib/briefing-reads.ts:
focusLinkedDocuments,packages/core/src/lib/briefing-reads.ts:18-28(as FocusLinkedDocument[])upcomingDeadlines,packages/core/src/lib/briefing-reads.ts:39-47(as DeadlineRow[])overdueReviewRows,packages/core/src/lib/briefing-reads.ts:57-65(as OverdueReviewRow[])documentUpdated,packages/core/src/lib/briefing-reads.ts:68-71(as { updated: string | null } | null)
Hygiene's shared silent-edit query has the same shape (silentEdits, packages/core/src/lib/hygiene.ts:416-427, as SilentEdit[]). CLI commands no longer hold SQL. The largest remaining groups are packages/core/src/lib/db.ts (21), search-engine.ts (12), indexer/persist.ts (9) and stats.ts (8).
Blocked by #1367
Scope
- Apply the row-read convention core, ui-server: choose how SQLite rows are validated at read time #1367 decides across core, starting with the briefing reads and
silentEditsabove, then the remaining uncheckedas Trow casts. - Where core, ui-server: choose how SQLite rows are validated at read time #1367's decision record grants a documented hot-path exemption, follow it and name the exemption at the call site.
Out of scope
- Supported query result shapes.
- ui-server's row casts (core, ui-server: choose how SQLite rows are validated at read time #1367 counts 191; they are not this issue).
- Choosing or changing the convention itself (core, ui-server: choose how SQLite rows are validated at read time #1367).
Acceptance criteria
- Every core database read in the briefing reads and
silentEditsfollows the core, ui-server: choose how SQLite rows are validated at read time #1367 convention; none is a bareas Tcast. - No
as anyand no unchecked.get()/.all() ... as Trow cast remains inpackages/core/src, except at a call site that names a hot-path exemption from core, ui-server: choose how SQLite rows are validated at read time #1367's decision record. - A test feeds a skewed row (missing column) to a migrated read and gets a typed failure.
Verification
bun run test ./packages/core
git grep -n -E '\.(all|get)\([^)]*\) as ' -- packages/core/srcThe grep's remaining hits are each an exemption the decision record names. Keep a failing-first receipt for the skewed-row test.
Contract impact
None. A malformed row in a disposable index fails typed instead of flowing on; supported result shapes are unchanged.
2026-10-09: sequenced against the other code-quality issues to avoid overlapping edits; see the epic's planned-order comment.
2026-10-09 triage at main 572dd6d285a2daaa27a6dea9c84d3d170425a001: verified the cited database-read casts and complete migration brief. #1367 owns the measured convention deliverable; migration follows that output rather than choosing a competing convention. #1353 must first move CLI SQL into its shared library owner. Added agent-ready while preserving blocked; implementation remains unpickable until the declared outputs are delivered. No migration or runtime proof is claimed by this triage.
2026-11-10 triage at main d79eeed0a: #1353 is closed as completed through PR #3293 (squash 003576188, on main), so its Blocked by line moved here as history. The briefing citation was re-anchored to briefing-reads.ts by named anchor, and the scope now names the unchecked as T casts the move left, since no as any row read remains. #1367 is still open, so blocked stays.
Activity
schlessera commentedon Nov 10, 2026
2026-11-10 triage at main
d79eeed0a: the body is re-anchored. #1353 / PR #3293 (squash003576188) moved briefing'sas any[]reads out ofbriefing.tsintopackages/core/src/lib/briefing-reads.ts. There they became uncheckedas Tcasts (focusLinkedDocuments,upcomingDeadlines,overdueReviewRows,documentUpdated), and hygiene'ssilentEditshas the same shape. Noas anyrow read remains in core, so the scope and acceptance criteria now target the 124 unchecked.get()/.all() ... as Tcasts in core, starting with those reads, with #1367's documented exemptions allowed. ui-server's casts are out of scope. #1353 is satisfied and moved to history. #1367 is still open, soblockedstays, and so doespriority: p3(#1367 is p3, which meets the blocker rule). Labels are unchanged.