Full spec: docs/hardening-roadmap-2026-04-16.md#h-8
Description
handlers.ts:124 builds a budget-estimate SearchConfig with { ...({} as SearchConfig), maxCandidates: candidates.length } as SearchConfig — every other required field is undefined. Adapters happen to tolerate this but it's a landmine.
Current State
- Unsafe cast at
apps/cli/src/handlers.ts:124.
DataSource.estimateCost accepts full SearchConfig for both enrichment and search paths.
Suggested Fix
Verification
Automation Hints
scope: packages/core/src/pipeline-types.ts, apps/cli/src/handlers.ts, packages/adapters/*/src
do-not-touch: packages/scoring, packages/output
approach: refactor-types
risk: low
max-files-changed: 8
blocked-by: none
bail-if: adapter tests fail
Priority
Low
Full spec:
docs/hardening-roadmap-2026-04-16.md#h-8Description
handlers.ts:124builds a budget-estimate SearchConfig with{ ...({} as SearchConfig), maxCandidates: candidates.length } as SearchConfig— every other required field isundefined. Adapters happen to tolerate this but it's a landmine.Current State
apps/cli/src/handlers.ts:124.DataSource.estimateCostaccepts fullSearchConfigfor both enrichment and search paths.Suggested Fix
EnrichmentCostInputtype:{ maxCandidates: number }.DataSource.estimateCostsignature — acceptEnrichmentCostInputfor enrichment,SearchConfigfor search (or unify via discriminated union).Verification
pnpm buildpassespnpm testpassespnpm typecheckcleanas SearchConfigcasts remain inhandlers.tsestimateCostsignature precisely typed per call siteAutomation Hints
scope: packages/core/src/pipeline-types.ts, apps/cli/src/handlers.ts, packages/adapters/*/src
do-not-touch: packages/scoring, packages/output
approach: refactor-types
risk: low
max-files-changed: 8
blocked-by: none
bail-if: adapter tests fail
Priority
Low