Repository navigation
feat(provider): ship LLM provider adapters as opt-in Go modules (#362) - #378
Merged
Merged
Conversation
The engine module ships port.LLMProvider and mockllm, but the real adapters lived in the root module's internal/adapter/, unimportable — so an engine embedder had to re-derive wire-format logic that has exactly one correct answer (Anthropic prompt-cache breakpoint placement, message ordering, stream assembly, usage accounting). Getting it wrong is silent and costly: misplaced cache breakpoints turn every turn of a long tool-calling loop into a full-transcript reprocess at full input price. forced on every engine importer — but that argued against the *engine module*, not against shipping them. Ship them as a provider/ subtree of opt-in Go submodules, so the dependency is opt-in by import (Jeremy's mechanism): - provider/anthropic — native Anthropic Messages adapter (zero couplings) - provider/openai — OpenAI Responses adapter - provider/openaichat — OpenAI Chat Completions adapter - provider/ssefilter — the shared SSE keepalive filter (openai + openaichat) Each carries its own go.mod (require engine + its SDK; openai/openaichat also require provider/ssefilter), so a consumer go gets exactly one provider and inherits only that SDK + the engine's tiny closure. llmresilience / providercatalog / openrouter / openaicompat stay root-side (a harness decorator and stdlib-only leaves, not wire-format providers). The engine module is untouched. Registration: go.work use, root go.mod require+replace, Taskfile second passes, ci.yml per-module jobs + a provider-standalone GOWORK=off gate (scoped to ssefilter + anthropic — openai/openaichat defer until provider/ssefilter is tagged), perf.yml cache keys, dependabot, depguard rules, release.yml tag-grammar doc (provider/<name>/v*). New ADR 0093 records the decision. The ~30 internal/adapter/... doc citations across the frozen ADRs + living docs are repointed to provider/<name>/ (docs/lint gate), and AGENTS.md / user-docs are updated. Co-Authored-By: Juan Antonio Osorio <[email protected]>
JAORMX
force-pushed
the
feat/362-provider-module
branch
from
August 4, 2026 22:03
205fa56 to
dea2099
Compare
The provider-standalone job's run blocks did 'cd provider/ssefilter && ...' then 'cd provider/anthropic && ...' on separate lines of the SAME shell — the first cd persisted, so the second resolved to provider/ssefilter/provider/ anthropic and failed. Wrap each in a subshell. Same gate logic; scoped to ssefilter + anthropic until provider/ssefilter is tagged (ADR 0093). Co-Authored-By: Juan Antonio Osorio <[email protected]>
…lms.txt The build/test/lint/vet/vuln provider jobs each ran several 'cd provider/X && ...' lines in ONE shell — the first cd persisted, so every later line resolved under provider/ssefilter/provider/... and failed. Subshell each (the same fix as the standalone gate). Also regenerate llms.txt now that the scratch PLAN-362.md is gone (159 docs / 0 orphans). Co-Authored-By: Juan Antonio Osorio <[email protected]>
…po fetch wall anthropic/openai/openaichat each require another mecatl module (engine, and provider/ssefilter for the openai-go family). mecatl is a private/INTERNAL repo, so a GOWORK=off build must fetch that dep from the origin — proxy.golang.org can't serve a private module, and the job checks out with persist-credentials: false, so the fetch 401s (git ls-remote exit 128). The earlier 'deferred until ssefilter is tagged' framing was wrong: even anthropic (engine is a published v0.8.0 tag) cannot fetch it privately. Scope the provider-standalone gate to ssefilter (the only self-contained provider) and defer the rest until the repo is public or git credentials + GOPRIVATE are wired; correct ADR 0093 to record the real reason. Co-Authored-By: Juan Antonio Osorio <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Ships the real LLM provider adapters (OpenAI + Anthropic) out of the box as opt-in Go submodules under
provider/, so engine importers get a workingport.LLMProviderby import instead of re-deriving wire-format logic.Closes #362.
Why
engine/shipsport.LLMProviderandmockllm, but the real adapters lived in the root module'sinternal/adapter/— unimportable. Anyone embedding the engine had to write their own, re-deriving details that have exactly one correct answer and fail silently when wrong. The sharpest example is Anthropic prompt-cache breakpoint placement: place them wrong and every turn of a long tool-calling loop reprocesses the accumulated transcript at full input price — quadratic cost growth on precisely the sessions this engine exists to run. Nothing fails; you find out from a bill.#269 carved the adapters out of the engine module so heavy SDK deps aren't forced on every engine importer. That was right — but it argued against the engine module, not against shipping them. mecatl is already multi-module; a third makes the dependency opt-in by import. Nobody who doesn't want the SDK pays for it.
How — a
provider/subtree of opt-in submodulesprovider/anthropicanthropic-sdk-goprovider/openaiopenai-go/v3+provider/ssefilterprovider/openaichatopenai-go/v3+provider/ssefilterprovider/ssefilteropenai-go/v3/optiononlygo.mod; a consumergo gets exactly one provider and inherits only that SDK + the engine's tiny closure. The engine module is untouched (ADR 0036's tiny-closure promise holds).git mv) — no logic change, no second copy to drift.llmresilience/providercatalog/openrouter/openaicompatstay root-side — a harness decorator and stdlib-only leaves, not wire-format providers.provider/<name>/vX.Y.Z(same asengine/v*); thev*release trigger does not fire on these.The one design decision — version pinning + the private-repo standalone wall
Each provider
go.modrequires the engine at the publishedv0.8.0(noreplace— a committedreplacebreaks downstreamgo get), resolved to the local tree viago.workfor dev.Consequence: the
GOWORK=offstandalone hygiene gate (provider-standaloneCI job +test:provider-standalone) can only coverprovider/ssefilter— the sole self-contained provider (no mecatl-module dependency).anthropic/openai/openaichateachrequireanother mecatl module, and mecatl is a private/INTERNAL repo, so aGOWORK=offbuild must fetch that dep from the origin —proxy.golang.orgcan't serve a private module and the job checks out withpersist-credentials: false, so the fetch 401s. They're covered by the workspace (GOWORK=on) build/test; their standalone proof is deferred until the repo is public or git credentials +GOPRIVATEare wired. Recorded in ADR 0093 and tracked in #379.Verification
provider-standalone(GOWORK=off) — ssefilter ✓ (anthropic/openai/openaichat deferred per above)task lint— 0 issues across all 6 modules;task test— root + engine + all 4 providers + both standalone gatestask api:check,go test ./docs/lint/,task docs,task site:build,go run ./cmd/mecademo— all greenPanel review (spec / standards / software-architect / devops): architecture verdict "sound, ship it". Findings fixed in this PR: 4 stale
internal/adapter/...Go-comment backpaths; the multi-linecdsubshell bug across the provider CI jobs; the private-repo standalone fetch wall.Docs
New ADR 0093 (
docs/adr/0093-provider-modules.md). The ~30internal/adapter/...citations across the frozen ADRs + living docs are repointed toprovider/<name>/(thedocs/lintanti-drift gate). AGENTS.md,docs/architecture*.md, anduser-docs/(embed-engine, extension-points) updated;llms.txtregenerated.Follow-ups (not in this PR)
provider/ssefiltertag).0092-no-project-trust-pinADR (onfeat/359) to 0091 — the existing0090collision means 0092 was taken; this ADR is 0093. Flagged, not touched here.