Full spec: docs/hardening-roadmap-2026-04-16.md#h-6
Description
Two places cast JSON directly to typed objects after minimal validation: intake-context.ts:110 casts after only checking conversationHistory is an array; checkpoint.ts likely similar. A corrupted or version-drifted file passes the check then fails cryptically deeper in a phase.
Current State
packages/intake/src/intake-context.ts:110 uses return parsed as unknown as IntakeContext.
packages/core/src/checkpoint.ts — needs audit.
Suggested Fix
Verification
Automation Hints
scope: packages/intake/src, packages/core/src/checkpoint.ts
do-not-touch: adapters, output
approach: add-validation
risk: low
max-files-changed: 5
blocked-by: #9
bail-if: intake tests fail
Priority
Medium
Full spec:
docs/hardening-roadmap-2026-04-16.md#h-6Description
Two places cast JSON directly to typed objects after minimal validation:
intake-context.ts:110casts after only checkingconversationHistoryis an array;checkpoint.tslikely similar. A corrupted or version-drifted file passes the check then fails cryptically deeper in a phase.Current State
packages/intake/src/intake-context.ts:110usesreturn parsed as unknown as IntakeContext.packages/core/src/checkpoint.ts— needs audit.Suggested Fix
IntakeContextSchemainpackages/intake/src/schemas.ts.deserializeContextbody withIntakeContextSchema.parse(JSON.parse(json)).CheckpointSchemain@sourcerer/core; use it inloadCheckpoint.version: 1field to checkpoint file; reject mismatched versions with clear upgrade message.Verification
pnpm buildpassespnpm testpassespnpm typecheckcleancannot read property X of undefined)Automation Hints
scope: packages/intake/src, packages/core/src/checkpoint.ts
do-not-touch: adapters, output
approach: add-validation
risk: low
max-files-changed: 5
blocked-by: #9
bail-if: intake tests fail
Priority
Medium