Skip to content

[H-8 / Phase 3] [LOW] Fix malformed SearchConfig in budget gate #14

@matthewod11-stack

Description

@matthewod11-stack

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

  • Introduce minimal explicit EnrichmentCostInput type: { maxCandidates: number }.
  • Change DataSource.estimateCost signature — accept EnrichmentCostInput for enrichment, SearchConfig for search (or unify via discriminated union).
  • Delete the unsafe cast.

Verification

  • pnpm build passes
  • pnpm test passes
  • pnpm typecheck clean
  • No as SearchConfig casts remain in handlers.ts
  • estimateCost signature precisely typed per call site

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech-debtEligible for automated overnight fixing

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions