Archibald312 builds the routing dial before turning it

GordonOSS lands a per-source model-routing layer ahead of the connectors that will need it - and pins the rules with tests before anyone can break them.

infrastructurecompliance

Most forks bolt on model routing once they have a mess of connectors to untangle. Archibald312 did it the other way around: build the decision layer first, with nullable preference fields on projects and documents, then let future connectors and a deferred local-inference adapter plug into the same spot. Precedence is explicit - document beats project beats request - and when those conflict, the system flags it rather than quietly picking one.

Every routing decision gets written to the audit log with a structured reason, reusing instrumentation an earlier phase already put in place. Unknown models are rejected loudly. Existing behaviour is untouched if no preferences are set, so the change is genuinely additive. The test coverage is heavier than the feature size warrants, which is the tell that this is meant to be load-bearing.

So what Worth a look for anyone building a legal-AI product who expects to route different matter types or document classes to different models - this is the cleanest version of that seam in the fork ecosystem so far.

View this fork on GitHub →

Spotted something wrong? Or know the PR text has fresher detail than the writeup above?

Commits in this thread

1 commit from Archibald312/GordonOSS, oldest first. Source extracted verbatim from the harvested git log.

SHA Subject Author Date
c549ff21 Pre-Phase-7: per-source LLM routing seam (#7) Archibald312 2026-05-15 ↗ GitHub
commit body
* 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>

Capture this thread into my fork

Download a single Markdown prompt that tells Claude how to port every commit above into your working tree — adapting paths and structure to match your repo. Run it via claude -p < capture-thread-426.md from inside the repo you want the changes in.

⬇ Download capture-thread-426.md