Skip to content

chore: add row types to mission/store.ts + assertion budget test (AC-491)#592

Merged
jayscambler merged 2 commits intomainfrom
chore/reduce-ts-type-assertions
Mar 31, 2026
Merged

chore: add row types to mission/store.ts + assertion budget test (AC-491)#592
jayscambler merged 2 commits intomainfrom
chore/reduce-ts-type-assertions

Conversation

@jayscambler
Copy link
Copy Markdown
Contributor

Summary

Added typed SQLite row interfaces and mapper functions to mission/store.ts, reducing inline type assertions from 45 to 31. Added a budget test to prevent regression.

Problem

mission/store.ts had 45 type assertions (as string, as number) because better-sqlite3 returns unknown for row values. Each query result was manually cast field-by-field.

Changes

Row types added to mission/store.ts

  • MissionRow, StepRow, SubgoalRow, VerificationRow — typed interfaces for SQLite query results
  • missionFromRow(), stepFromRow(), subgoalFromRow() — mapper functions replacing inline casts

Budget test (type-assertions.test.ts)

3 contract tests to prevent assertion count regression:

  1. Total codebase assertions ≤ 520
  2. mission/store.ts ≤ 35
  3. storage/index.ts ≤ 25

Verification

  • tsc --noEmit — zero errors
  • vitest run tests/type-assertions.test.ts — 3 passed

Issue

Partially resolves AC-491

…491)

Added typed row interfaces (MissionRow, StepRow, SubgoalRow, VerificationRow)
and mapper functions (missionFromRow, stepFromRow, subgoalFromRow) to
mission/store.ts, replacing inline 'as string'/'as number' casts.

mission/store.ts: 45 → 31 assertions (31% reduction)

TDD: Added type-assertions.test.ts with 3 budget tests:
- Total assertion count stays under 520 (baseline enforcement)
- mission/store.ts stays under 35 assertions
- storage/index.ts stays under 25 assertions

2 files changed, 148 insertions, 24 deletions
@linear
Copy link
Copy Markdown

linear bot commented Mar 31, 2026

@jayscambler jayscambler merged commit 30e0846 into main Mar 31, 2026
4 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