Skip to content

[tech-debt] Reshape Route union to encode routing decisions rather than routing diagnoses #37

Description

@dean0x

Finding

Files: src/router.ts:5–8, src/server.ts:598–630, src/agent-scan.ts, src/doctor.ts

decideRoute returns three Route kinds that server.ts folds into a single dispatch: ambiguous, unknown_provider, and anthropic all forward to Anthropic and set route = "anthropic". The union now encodes routing diagnoses rather than actual routing decisions. Any second consumer of decideRoute must re-implement the same fold, and the two redundant route = "anthropic" assignments at :615 and :627 (already initialised at :499) are a symptom of this.

Why Deferred

The reshape would churn doctor's taxonomy. doctor's exit code is a real CI gate (PF-006), so changing the severity discriminator between ambiguous and unknown_provider requires its own careful pass to avoid breaking the gate.

Suggested Approach

Consider replacing the three-variant union with { kind: "anthropic", diagnostic?: "ambiguous" | "unknown_provider" } so the dispatch decision and the diagnostic label are one value. server.ts dispatches on kind; doctor and logs consume diagnostic. The redundant route = "anthropic" assignments at :615/:627 become dead code and can be deleted.

Separately evaluate whether ambiguous and unknown_provider should have different doctor severities now that server.ts treats them identically.

Provenance

Deferred from code review 2026-08-19_2015 on wave/passthrough-hardening (PR #33), issue I-057 in the review ledger.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech-debtPre-existing or deferred technical debt items

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions