Skip to content

feat: Drizzle schema + zod companions for uncertainty engine (#98)#114

Open
ssilvius wants to merge 2 commits intomainfrom
feat/98-uncertainty-schema
Open

feat: Drizzle schema + zod companions for uncertainty engine (#98)#114
ssilvius wants to merge 2 commits intomainfrom
feat/98-uncertainty-schema

Conversation

@ssilvius
Copy link
Copy Markdown
Contributor

Closes #98.

Two schema files matching the 0002_uncertainty_engine.sql migration column-for-column:

  • uncertainty.ts -- Drizzle table definitions with index declarations mirroring the migration
  • uncertainty.zod.ts -- insert/select schemas via drizzle-zod; state and outcome_label constrained as enums, all confidence/correctness/brier columns bounded 0-1 via shared unitInterval constant

The calibration snapshot insert and select overrides share a single calibrationSnapshotOverrides object -- no duplication. TypeScript inferred types exported for all four shapes.

ssilvius and others added 2 commits April 28, 2026 00:01
Two schema files matching the 0002_uncertainty_engine.sql migration exactly:
- uncertainty_prediction: full emit/witness lifecycle with state enum
  (emitted | witnessed | orphaned | retired) and 0-1 bounds on
  claimedConfidence and outcomeCorrectness
- uncertainty_calibration_snapshot: materialized reliability per cohort
  with 0-1 bounds on all confidence/correctness/brier columns

Both tables get index declarations mirroring the migration. State and
outcome_label are constrained via zod enums; drizzle-zod bridges the
Drizzle table types to insert/select schemas and inferred TypeScript types.

Closes #98.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…stant

Eliminates the duplicated 7-field override object between insert and select
schemas for uncertainty_calibration_snapshot, and collapses the repeated
z.number().min(0).max(1) pattern to a named unitInterval constant.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

Uncertainty engine: Drizzle schema + zod companions

1 participant