Pre-Phase-7: per-source LLM routing seam (#7)

↗ view on GitHub · Archibald312 · 2026-05-15 · c549ff21

* Pre-Phase-7: per-source LLM routing seam

Defer original Phase 7 (local inference / Ollama / vLLM) to post-launch
and land the per-source LLM routing surface ahead of Phase 7 connectors,
so that connectors and the eventual local-inference adapter plug into the
same decision point without touching dispatch sites. See decisions.md
(2026-05-15) and the renumbered build plan in CLAUDE.md.

- model_preference (nullable) columns on projects + documents
- backend/src/lib/llm/routing.ts: resolveModelRouting() with doc → project
  → request precedence, conflicts and unknown-model rejections captured
  for audit
- streamChatWithTools accepts optional routing context, dispatches with
  the resolved model, and records the policy into the existing
  audit_log.routing_policy_applied jsonb column
- main chat path wired to pass project + document IDs
- 8 unit tests covering precedence, conflicts, rejections, and db errors

Backend tsc --noEmit clean; Vitest 73/73 passing.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* lint: const documentPrefs in routing resolver

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Repository Archibald312/GordonOSS
Author Archibald312 <129438073+Archibald312@users.noreply.github.com>
Authored
Parents d523a644
Stats 9 files changed , +452 , -16
Part of Pre-Phase-7 - Per-source LLM routing seam

Capture this commit into my fork

Download a Markdown prompt that tells Claude how to port this exact commit into your working tree. Run it via claude -p < capture-commit-c549ff21.md from inside the repo you want the change in.

⬇ Download capture-commit-c549ff21.md