Skip to content

Add backend prefix registry#25

Merged
matdev83 merged 5 commits into
mainfrom
chore/local-backend-prefix-registry
Jun 23, 2026
Merged

Add backend prefix registry#25
matdev83 merged 5 commits into
mainfrom
chore/local-backend-prefix-registry

Conversation

@matdev83

Copy link
Copy Markdown
Owner

Summary

  • add backend prefix registration to model inventory wiring
  • enforce prefix ownership by backend connector kind before model discovery
  • reject backend-qualified canonical model IDs from fresh discovery and cached snapshots
  • add Ollama backend/reference support and route selector fallback wiring from local changes

Tests

  • go test -parallel=8 ./internal/core/modelregistry/... ./internal/infra/runtimebundle/... ./internal/pluginreg/... ./internal/plugins/backends/... ./pkg/lipsdk/...

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@matdev83, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 19 minutes and 23 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d36c4cf8-4bd6-4db6-9a39-2458df16b0b8

📥 Commits

Reviewing files that changed from the base of the PR and between 67a330b and 82f102a.

📒 Files selected for processing (11)
  • internal/infra/modelcatalog/modelsdev/normalize_test.go
  • internal/pluginreg/backend_prefix_inventory_test.go
  • internal/plugins/backends/bedrock/prefix_test.go
  • internal/plugins/backends/ollama/integration_test.go
  • internal/plugins/backends/ollama/inventory.go
  • internal/plugins/backends/ollama/inventory_test.go
  • internal/plugins/backends/ollama/version.go
  • internal/plugins/backends/ollama/version_test.go
  • internal/plugins/frontends/routeselect/routeselect.go
  • internal/plugins/frontends/routeselect/routeselect_test.go
  • scripts/ollama-text-smoke.ps1
📝 Walkthrough

Walkthrough

Introduces two new Ollama backend plugins (ollama, ollama-cloud) with full inventory discovery, capability probing, semver-based responses gating, and model-name resolution logic. Adds a BackendPrefixes field to the Backend struct and enforces prefix uniqueness/canonical-ID rules in the model registry. Updates all existing backend plugins to populate BackendPrefixes. Adds a routeselect helper enabling frontends to derive the route selector from the request body model field. Fixes a sub-millisecond TPS divide-by-zero in attempt accounting.

Changes

Ollama backend plugin, BackendPrefixes contract, frontend route-select, and minor fixes

Layer / File(s) Summary
BackendPrefixes struct field and registry prefix validation
internal/core/execbackend/backend.go, internal/core/modelregistry/registry.go, internal/core/modelregistry/runtime.go, internal/infra/runtimebundle/build.go, docs/capability-catalogs.md, docs/plugin-authoring.md
Adds BackendPrefixes []string to Backend and BackendInventory; exports ErrMissingBackendPrefix/ErrDuplicateBackendPrefix; implements validateInventoryPrefixes, prefix normalization, and canonical-prefix-qualifier rejection in Build and publishSnapshot; propagates registeredPrefixes into newRegistryFromBackendModels; updates docs with new authoring constraints.
Model registry prefix validation tests
internal/core/modelregistry/prefix_test.go, internal/core/modelregistry/registry_test.go, internal/core/modelregistry/runtime_test.go
Adds five targeted Build tests covering duplicate-same-kind allowance, cross-kind duplicate rejection (verifying LoadModels not called), missing prefix rejection, qualified canonical-ID rejection, and slash-canonical allowance with a prefixCountingProvider stub. Updates all existing registry/runtime test BackendInventory literals to include BackendPrefixes; adds TestRuntime_StartIgnoresCacheWithQualifiedCanonicalID.
BackendPrefixes wired into all existing backend plugins
internal/plugins/backends/acp/plugin.go, internal/plugins/backends/anthropic/plugin.go, internal/plugins/backends/bedrock/plugin.go, internal/plugins/backends/gemini/plugin.go, internal/plugins/backends/localstub/plugin.go, internal/plugins/backends/openaicompat/backend.go, internal/plugins/backends/openailegacy/plugin.go, internal/plugins/backends/openairesponses/plugin.go, internal/plugins/backends/bedrock/prefix_test.go, internal/infra/runtimebundle/*_test.go, internal/archtest/backend_lifecycle_contract_test.go
Sets BackendPrefixes: []string{ID} on both success and error-path backends in all existing plugins; updates all runtimebundle test helpers to include BackendPrefixes in stub backends; adds bedrock/prefix_test.go; expands lifecycle contract delegation map for ollama/ollama-cloud.
Ollama backend core: config, version, caps, mode, payload mutation
internal/plugins/backends/ollama/doc.go, internal/plugins/backends/ollama/config.go, internal/plugins/backends/ollama/version.go, internal/plugins/backends/ollama/caps.go, internal/plugins/backends/ollama/mode.go, internal/plugins/backends/ollama/payload_mutate.go, internal/plugins/backends/ollama/*_test.go
New ollama package: exports ID/CloudID; defines DiscoveryConfig/Config with ApplyDefaults and discovery-flag helpers; adds Semver, ParseSemver, VersionSupportsResponses, NativeRootFromBaseURL; adds CapsFromOllamaCapabilities/defaultModelCaps; adds local/cloud mode constants and discovery predicate helpers; adds requestOptions for max_tokens remapping; fully tested.
Ollama model and flavor resolution
internal/plugins/backends/ollama/resolve.go, internal/plugins/backends/ollama/resolve_test.go
Implements resolveModelForMode/resolveModel closures, modelFromCall (Primary.Model or Extensions fallback), upstreamModelID (prefix stripping, cloud-suffix enforcement), ensureCloudSuffix, and resolveFlavor; tests cover local prefix stripping and cloud suffix appending.
Ollama inventory provider and modelsdev ParseModelIDs
internal/plugins/backends/ollama/inventory.go, internal/plugins/backends/ollama/inventory_test.go, internal/infra/modelcatalog/modelsdev/normalize.go, internal/infra/modelcatalog/modelsdev/normalize_test.go
inventory.go implements LoadModels orchestration (local+cloud discovery, dedup, catalog mapping, capability probing), canonical-ID derivation with keyword→vendor fallback, capability caching, ProbeCapsForNative, fetchCaps (POST /api/show), and getJSON. ParseModelIDs added to modelsdev for catalog ID lookup. 14 inventory tests cover mode isolation, catalog mapping, error cases, and timeout enforcement.
Ollama plugin.go: backend construction, transport caps, and responses gating
internal/plugins/backends/ollama/plugin.go
Exports New/NewCloud delegating to newBackend; newBackend resolves responses availability via version probe, builds inventory provider, constructs openaicompat backend with request options/model/flavor resolvers, wires ResolveCaps (hosted/probed/default), wraps Open to block responses when disabled and rewrite primary model.
Ollama plugin integration tests and reference backend emulator
internal/plugins/backends/ollama/integration_test.go, internal/refbackend/ollama/server.go, internal/refbackend/ollama/doc.go, internal/refbackend/ollama/backend_test.go
18 integration tests cover auth, chat/responses streaming, payload mutation, transport caps negotiation, cloud model suffix handling, inventory cloud-suffix stripping, and ResolveCaps probing. refbackend/ollama/server.go implements a configurable in-process Ollama emulator with auth/hook/forced-error/streaming support; 14 handler tests validate all endpoints.
Ollama backends wired into standard bundle and config files
internal/pluginreg/standard_table.go, internal/pluginreg/backends_install.go, pkg/lipsdk/standard_bundle.go, internal/pluginreg/*_test.go, config/**/*.yaml, cmd/lipstd/testdata/**/*.json, internal/stdhttp/testdata/*.yaml, pkg/lipsdk/standard_bundle_ollama_test.go
Registers backendOllama/backendOllamaCloud in StandardBackendBundle with CredentialNone; adds YAML config structs and parseOllamaBackendConfig; adds ollama/ollama-cloud to StandardDistributionRequirements; all config/example/testdata YAML and golden JSON files gain disabled ollama entries; pluginreg tests verify prefix contract and inventory.
Frontend model-body route selection via routeselect
internal/plugins/frontends/routeselect/routeselect.go, internal/plugins/frontends/routeselect/routeselect_test.go, internal/plugins/frontends/anthropic/handler.go, internal/plugins/frontends/gemini/handler.go, internal/plugins/frontends/openailegacy/handler.go, internal/plugins/frontends/openairesponses/handler.go, internal/plugins/frontends/*/integration_test.go
New routeselect package provides InlineOrDefault (known-prefix map check) and FromModelOrDefault (JSON body model extraction); all four frontend handlers replace immediate DefaultRouteSelector fallback with routeselect calls after body read; integration tests verify body-model selector propagation and unknown-prefix fallback for each frontend.
Sub-millisecond TPS fix in attempt accounting
internal/core/runtime/attempt_accounting.go, internal/core/runtime/attempt_accounting_test.go
Changes CompletionTPSMilli guard to check out.CompletionDurationMillis > 0 instead of recomputing duration, preventing divide-by-zero for sub-millisecond completions; new test verifies both fields are 0 for a 500µs completion.
Ollama smoke test PowerShell script
scripts/ollama-text-smoke.ps1
End-to-end smoke script: allocates a free port, queries Ollama for the first model, runs direct preflight checks, generates a YAML config, starts lipstd, polls /healthz, sends proxied chat/image requests, asserts response content, and cleans up.

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

  • matdev83/go-llm-interactive-proxy#20: Introduced the openaicompat shared backend adapter that this PR extends with BackendPrefixes wiring and uses as the foundation for the new Ollama plugin.
  • matdev83/go-llm-interactive-proxy#23: Introduced the core model inventory registry/runtime contract that this PR extends with BackendPrefixes, prefix-uniqueness validation, and qualified canonical-ID rejection.
🚥 Pre-merge checks | ✅ 5 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.37% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Context Propagation ⚠️ Warning Data race in inventory_test.go: counter variables (cloudHits, localHits) are incremented in httptest.Server goroutines and read without synchronization, violating Go's memory model. Replace int counters with atomic.Int32 in ollama inventory tests and synchronize accesses, or use mutexes to protect counter increments and reads.
No Accidental Public Api Break ⚠️ Warning PR adds required BackendPrefixes field to exported BackendInventory struct; callers must populate it or modelregistry.Build() fails with ErrMissingBackendPrefix. This is a breaking API chan... Document the breaking change in PR description and/or migration guide explaining that SDK users must populate BackendInventory.BackendPrefixes when calling modelregistry.Build(), typically with values matching backend factory IDs.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add backend prefix registry' is a clear and descriptive summary of the main technical change - adding a prefix registry system for backends. It directly relates to the primary objective of implementing backend prefix registration into model inventory wiring.
Description check ✅ Passed The PR description is directly related to the changeset, detailing the addition of backend prefix registration, enforcement mechanisms, rejection of qualified canonical IDs, and Ollama backend support. It includes specific test commands that validate the changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
No Secrets ✅ Passed No hardcoded credentials, API keys, tokens, private keys, passwords, or production secrets found. All credential values are clearly-marked test fixtures (dummy credential "ollama", test value "my-s...

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 12

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/infra/modelcatalog/modelsdev/normalize_test.go`:
- Around line 46-59: Add a new table-driven test function
TestParseModelIDs_EdgeCases that tests the error handling paths of the
modelsdev.ParseModelIDs function. Create a test with multiple cases that verify
behavior for empty payloads (should error), null root JSON (should error), empty
objects (should return empty slice), and providers missing the models field.
Each test case should check whether an error is returned based on the wantErr
flag to ensure all edge cases handled by the implementation are properly
verified.

In `@internal/infra/modelcatalog/modelsdev/normalize.go`:
- Around line 73-112: The ParseModelIDs function duplicates approximately 90% of
the payload validation and provider iteration logic already present in
ParseSnapshot. Extract a shared helper function (for example, decodeProviderMap)
that handles the common logic of validating empty/null payloads, unmarshaling
the root map, iterating through providers, and decoding wireProvider/wireModel
structures. This helper should accept a callback function to handle provider and
model processing differently for each caller. Update both ParseModelIDs and
ParseSnapshot to use this shared helper, passing their respective callback logic
to handle building the ID list and catalog facts map respectively.

In `@internal/pluginreg/backend_prefix_inventory_test.go`:
- Around line 20-22: Remove the conditional block that skips the "bedrock"
backend in the inventory test loop. The if statement checking if id equals
"bedrock" and the corresponding continue statement are outdated and should be
deleted entirely. Bedrock now properly implements BackendPrefixes in its
NewWithContext factory method, making it compatible with this test. The existing
test configuration with region us-east-1 is sufficient to construct a backend
with populated prefixes, so bedrock should participate in the inventory test
alongside other backends.

In `@internal/plugins/backends/bedrock/prefix_test.go`:
- Around line 11-14: The test code creates and immediately cancels a context
before passing it to NewWithContext to intentionally trigger the error path
during backend construction. Add a clarifying comment above the
context.WithCancel and cancel() calls that explains this test strategy,
specifically noting that the canceled context is used to verify that
BackendPrefixes is properly set even when newRuntimeClient fails due to the
canceled context.

In `@internal/plugins/backends/ollama/inventory_test.go`:
- Around line 30-34: The cloudHits and localHits variables are accessed from
multiple goroutines (HTTP handler callbacks and the test goroutine) without
synchronization, causing a data race. Replace the plain int declarations for
cloudHits and localHits with atomic.Int64 types, then update all increment
operations from cloudHits++ to cloudHits.Add(1), and all read operations where
cloudHits or localHits are used in assertions to use the .Load() method instead
of direct access. Apply this pattern consistently across all occurrences at the
declaration point (around line 30), the cloudHits assertions (lines 84-88), the
localHits assertions (lines 125-128), and the subsequent assertions (lines
180-183).

In `@internal/plugins/backends/ollama/inventory.go`:
- Around line 296-314: The probeCapabilities function creates a new capsByID map
and replaces p.capsByID entirely, which can discard concurrent capability
updates from ProbeCapsForNative. Instead of replacing the entire map at the end
of probeCapabilities (where p.capsByID = capsByID is assigned), merge the newly
probed capabilities into the existing p.capsByID map while holding the p.capsMu
lock. Iterate through the capsByID map built from the probed models and assign
each capability to the existing p.capsByID map rather than doing a wholesale
replacement, ensuring that any capabilities written by ProbeCapsForNative
concurrently are preserved.

In `@internal/plugins/backends/ollama/version_test.go`:
- Around line 9-24: The test function TestNativeRootFromBaseURL currently only
tests lowercase /v1 paths but does not cover the uppercase /V1 variant. To
verify that NativeRootFromBaseURL correctly handles case-insensitive path
matching, add one or more test cases to the tests slice that include uppercase
/V1 suffixes (e.g., http://localhost:11434/V1 and http://localhost:11434/V1/)
with their corresponding expected root URLs to ensure the function works
correctly with all case variants.

In `@internal/plugins/backends/ollama/version.go`:
- Around line 34-35: The check for `len(parts) == 0` in the version parsing
logic is unreachable dead code because strings.Split always returns at least one
element even for empty strings, and empty strings are already handled earlier in
the function. Remove the entire `if len(parts) == 0` condition block that
returns the error, as this case cannot occur.
- Around line 17-23: In the NativeRootFromBaseURL function, the code checks for
a /v1 suffix using a lowercased version of the string but then attempts to trim
the suffix from the original uncased string, which will fail for uppercase or
mixed-case variants like /V1. Fix this by trimming based on the string length
instead of the literal suffix string, so that the original casing is properly
removed. When the lowercased version has the /v1 suffix, use string slicing to
remove the last 3 characters from the original string u before returning it.

In `@internal/plugins/frontends/routeselect/routeselect.go`:
- Around line 1-44: Add package-level documentation at the beginning of the
routeselect package file explaining the purpose and the route selector concept.
Add doc comments above the InlineOrDefault function describing what it does, its
parameters (model and defaultRoute), and what it returns. Add doc comments above
the FromModelOrDefault function describing what it does, its parameters (body
and defaultRoute), and what it returns. Ensure all doc comments follow Go
conventions by starting with the function/package name.
- Around line 8-21: The inlineRoutePrefixes map includes the "stub" prefix but
there is no corresponding backend plugin registered with that ID; "stub" only
appears in test mocks. Either remove "stub" from the inlineRoutePrefixes map if
it is not needed for production functionality, or add a clear comment above the
map entry explaining why it is included for test purposes. Additionally,
consider whether the entire inlineRoutePrefixes map should be derived from
registered backend IDs at runtime or protected by an archtest to prevent future
sync issues when new backends are added or removed.

In `@scripts/ollama-text-smoke.ps1`:
- Line 283: In the if condition that checks script:proc.ExitCode, reorder the
null comparison to follow PowerShell style guidelines. Change the current
comparison `$script:proc.ExitCode -ne $null` to place `$null` on the left side
as `$null -ne $script:proc.ExitCode`. This idiomatic comparison order prevents
accidental assignment operators and improves code readability according to
PowerShell best practices.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: dbfa79b3-fc5f-40ab-83f7-c51f0d1e28a4

📥 Commits

Reviewing files that changed from the base of the PR and between 5e9ac14 and 67a330b.

📒 Files selected for processing (75)
  • cmd/lipstd/testdata/dogfood-local-stub/inventory.golden.json
  • cmd/lipstd/testdata/dogfood-local-stub/routes.golden.json
  • config/config.yaml
  • config/examples/anthropic-stub.yaml
  • config/examples/dogfood-local-stub.yaml
  • config/examples/gemini-stub.yaml
  • config/examples/openai-legacy-stub.yaml
  • config/examples/openai-responses-stub.yaml
  • docs/capability-catalogs.md
  • docs/plugin-authoring.md
  • internal/archtest/backend_lifecycle_contract_test.go
  • internal/core/execbackend/backend.go
  • internal/core/modelregistry/prefix_test.go
  • internal/core/modelregistry/registry.go
  • internal/core/modelregistry/registry_test.go
  • internal/core/modelregistry/runtime.go
  • internal/core/modelregistry/runtime_test.go
  • internal/core/runtime/attempt_accounting.go
  • internal/core/runtime/attempt_accounting_test.go
  • internal/infra/modelcatalog/modelsdev/normalize.go
  • internal/infra/modelcatalog/modelsdev/normalize_test.go
  • internal/infra/runtimebundle/build.go
  • internal/infra/runtimebundle/dual_backend_test.go
  • internal/infra/runtimebundle/exclusive_registry_test.go
  • internal/infra/runtimebundle/modelregistry_build_test.go
  • internal/infra/runtimebundle/security_policy_test.go
  • internal/infra/runtimebundle/token_accounting_build_test.go
  • internal/pluginreg/backend_prefix_inventory_test.go
  • internal/pluginreg/backends_install.go
  • internal/pluginreg/ollama_build_test.go
  • internal/pluginreg/spec_bundle_standard_inventory_test.go
  • internal/pluginreg/standard_table.go
  • internal/plugins/backends/acp/plugin.go
  • internal/plugins/backends/anthropic/plugin.go
  • internal/plugins/backends/bedrock/plugin.go
  • internal/plugins/backends/bedrock/prefix_test.go
  • internal/plugins/backends/gemini/plugin.go
  • internal/plugins/backends/localstub/plugin.go
  • internal/plugins/backends/ollama/caps.go
  • internal/plugins/backends/ollama/caps_test.go
  • internal/plugins/backends/ollama/config.go
  • internal/plugins/backends/ollama/config_test.go
  • internal/plugins/backends/ollama/doc.go
  • internal/plugins/backends/ollama/integration_test.go
  • internal/plugins/backends/ollama/inventory.go
  • internal/plugins/backends/ollama/inventory_test.go
  • internal/plugins/backends/ollama/mode.go
  • internal/plugins/backends/ollama/mode_test.go
  • internal/plugins/backends/ollama/payload_mutate.go
  • internal/plugins/backends/ollama/payload_mutate_test.go
  • internal/plugins/backends/ollama/plugin.go
  • internal/plugins/backends/ollama/resolve.go
  • internal/plugins/backends/ollama/resolve_test.go
  • internal/plugins/backends/ollama/version.go
  • internal/plugins/backends/ollama/version_test.go
  • internal/plugins/backends/openaicompat/backend.go
  • internal/plugins/backends/openailegacy/plugin.go
  • internal/plugins/backends/openairesponses/plugin.go
  • internal/plugins/frontends/anthropic/handler.go
  • internal/plugins/frontends/anthropic/integration_test.go
  • internal/plugins/frontends/gemini/handler.go
  • internal/plugins/frontends/gemini/integration_test.go
  • internal/plugins/frontends/openailegacy/handler.go
  • internal/plugins/frontends/openailegacy/integration_test.go
  • internal/plugins/frontends/openairesponses/handler.go
  • internal/plugins/frontends/openairesponses/integration_test.go
  • internal/plugins/frontends/routeselect/routeselect.go
  • internal/plugins/frontends/routeselect/routeselect_test.go
  • internal/refbackend/ollama/backend_test.go
  • internal/refbackend/ollama/doc.go
  • internal/refbackend/ollama/server.go
  • internal/stdhttp/testdata/dogfood_gemini_dual_stub_failover.yaml
  • pkg/lipsdk/standard_bundle.go
  • pkg/lipsdk/standard_bundle_ollama_test.go
  • scripts/ollama-text-smoke.ps1
💤 Files with no reviewable changes (1)
  • internal/infra/runtimebundle/dual_backend_test.go
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: qa
🧰 Additional context used
📓 Path-based instructions (13)
internal/plugins/backends/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

Provider SDKs may only be imported in backend plugin adapters

Files:

  • internal/plugins/backends/ollama/payload_mutate.go
  • internal/plugins/backends/ollama/doc.go
  • internal/plugins/backends/ollama/mode_test.go
  • internal/plugins/backends/ollama/mode.go
  • internal/plugins/backends/localstub/plugin.go
  • internal/plugins/backends/ollama/caps.go
  • internal/plugins/backends/ollama/config_test.go
  • internal/plugins/backends/acp/plugin.go
  • internal/plugins/backends/ollama/payload_mutate_test.go
  • internal/plugins/backends/bedrock/prefix_test.go
  • internal/plugins/backends/ollama/caps_test.go
  • internal/plugins/backends/anthropic/plugin.go
  • internal/plugins/backends/ollama/config.go
  • internal/plugins/backends/gemini/plugin.go
  • internal/plugins/backends/openairesponses/plugin.go
  • internal/plugins/backends/openaicompat/backend.go
  • internal/plugins/backends/openailegacy/plugin.go
  • internal/plugins/backends/ollama/resolve.go
  • internal/plugins/backends/ollama/version_test.go
  • internal/plugins/backends/ollama/version.go
  • internal/plugins/backends/bedrock/plugin.go
  • internal/plugins/backends/ollama/resolve_test.go
  • internal/plugins/backends/ollama/plugin.go
  • internal/plugins/backends/ollama/integration_test.go
  • internal/plugins/backends/ollama/inventory_test.go
  • internal/plugins/backends/ollama/inventory.go
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*.go: Use small interfaces defined where they are consumed
Every I/O boundary takes context.Context
Do not use Java-style interface prefixes; use idiomatic Go names such as Store, Router, Clock
Avoid any unless unavoidable at a protocol boundary
Wrap errors with %w and preserve classification metadata
Avoid circular imports by design
Prefer the standard library unless a dependency clearly reduces complexity
Use small interfaces defined where they are consumed
Slices in JSON and returned values should use explicit empty initialization (s := []T{} or make) to prevent null in JSON
Establish explicit ownership for goroutines, channels, buffers, and cancellation
Do not use Go's native plugin package in v1
Add package docs where the boundary is non-obvious
Line length ~120+ characters; break at semantic boundaries. Single long lines preferred for embedded JSON/SSE to preserve stream integrity

For server, CLI, worker, or network code, check that context.Context is propagated correctly, cancellation is respected, and new goroutines cannot leak indefinitely

Files:

  • internal/plugins/backends/ollama/payload_mutate.go
  • internal/plugins/backends/ollama/doc.go
  • internal/plugins/backends/ollama/mode_test.go
  • internal/plugins/backends/ollama/mode.go
  • internal/plugins/frontends/gemini/integration_test.go
  • pkg/lipsdk/standard_bundle.go
  • internal/pluginreg/spec_bundle_standard_inventory_test.go
  • internal/plugins/frontends/routeselect/routeselect.go
  • internal/plugins/backends/localstub/plugin.go
  • internal/core/runtime/attempt_accounting.go
  • internal/plugins/frontends/anthropic/integration_test.go
  • internal/infra/runtimebundle/exclusive_registry_test.go
  • internal/plugins/backends/ollama/caps.go
  • internal/infra/modelcatalog/modelsdev/normalize_test.go
  • pkg/lipsdk/standard_bundle_ollama_test.go
  • internal/refbackend/ollama/doc.go
  • internal/plugins/frontends/openairesponses/integration_test.go
  • internal/plugins/backends/ollama/config_test.go
  • internal/plugins/backends/acp/plugin.go
  • internal/plugins/backends/ollama/payload_mutate_test.go
  • internal/plugins/backends/bedrock/prefix_test.go
  • internal/archtest/backend_lifecycle_contract_test.go
  • internal/infra/modelcatalog/modelsdev/normalize.go
  • internal/plugins/backends/ollama/caps_test.go
  • internal/core/modelregistry/runtime.go
  • internal/plugins/frontends/routeselect/routeselect_test.go
  • internal/plugins/backends/anthropic/plugin.go
  • internal/plugins/backends/ollama/config.go
  • internal/plugins/backends/gemini/plugin.go
  • internal/plugins/backends/openairesponses/plugin.go
  • internal/pluginreg/backend_prefix_inventory_test.go
  • internal/pluginreg/ollama_build_test.go
  • internal/plugins/backends/openaicompat/backend.go
  • internal/infra/runtimebundle/security_policy_test.go
  • internal/core/runtime/attempt_accounting_test.go
  • internal/plugins/backends/openailegacy/plugin.go
  • internal/plugins/backends/ollama/resolve.go
  • internal/plugins/backends/ollama/version_test.go
  • internal/plugins/backends/ollama/version.go
  • internal/plugins/frontends/gemini/handler.go
  • internal/infra/runtimebundle/build.go
  • internal/plugins/frontends/openairesponses/handler.go
  • internal/pluginreg/standard_table.go
  • internal/core/modelregistry/prefix_test.go
  • internal/plugins/frontends/openailegacy/integration_test.go
  • internal/plugins/frontends/anthropic/handler.go
  • internal/core/execbackend/backend.go
  • internal/infra/runtimebundle/token_accounting_build_test.go
  • internal/plugins/frontends/openailegacy/handler.go
  • internal/plugins/backends/bedrock/plugin.go
  • internal/plugins/backends/ollama/resolve_test.go
  • internal/plugins/backends/ollama/plugin.go
  • internal/refbackend/ollama/server.go
  • internal/core/modelregistry/registry.go
  • internal/core/modelregistry/registry_test.go
  • internal/core/modelregistry/runtime_test.go
  • internal/infra/runtimebundle/modelregistry_build_test.go
  • internal/pluginreg/backends_install.go
  • internal/plugins/backends/ollama/integration_test.go
  • internal/refbackend/ollama/backend_test.go
  • internal/plugins/backends/ollama/inventory_test.go
  • internal/plugins/backends/ollama/inventory.go

⚙️ CodeRabbit configuration file

**/*.go: Review as production Go code. Prioritize correctness, race conditions, goroutine leaks, context cancellation, timeout handling, error wrapping, nil-pointer risks, resource cleanup, defer placement, API compatibility, interface design, dependency boundaries, and testability. Avoid generic style comments when gofmt/golangci-lint already covers the issue.

Files:

  • internal/plugins/backends/ollama/payload_mutate.go
  • internal/plugins/backends/ollama/doc.go
  • internal/plugins/backends/ollama/mode_test.go
  • internal/plugins/backends/ollama/mode.go
  • internal/plugins/frontends/gemini/integration_test.go
  • pkg/lipsdk/standard_bundle.go
  • internal/pluginreg/spec_bundle_standard_inventory_test.go
  • internal/plugins/frontends/routeselect/routeselect.go
  • internal/plugins/backends/localstub/plugin.go
  • internal/core/runtime/attempt_accounting.go
  • internal/plugins/frontends/anthropic/integration_test.go
  • internal/infra/runtimebundle/exclusive_registry_test.go
  • internal/plugins/backends/ollama/caps.go
  • internal/infra/modelcatalog/modelsdev/normalize_test.go
  • pkg/lipsdk/standard_bundle_ollama_test.go
  • internal/refbackend/ollama/doc.go
  • internal/plugins/frontends/openairesponses/integration_test.go
  • internal/plugins/backends/ollama/config_test.go
  • internal/plugins/backends/acp/plugin.go
  • internal/plugins/backends/ollama/payload_mutate_test.go
  • internal/plugins/backends/bedrock/prefix_test.go
  • internal/archtest/backend_lifecycle_contract_test.go
  • internal/infra/modelcatalog/modelsdev/normalize.go
  • internal/plugins/backends/ollama/caps_test.go
  • internal/core/modelregistry/runtime.go
  • internal/plugins/frontends/routeselect/routeselect_test.go
  • internal/plugins/backends/anthropic/plugin.go
  • internal/plugins/backends/ollama/config.go
  • internal/plugins/backends/gemini/plugin.go
  • internal/plugins/backends/openairesponses/plugin.go
  • internal/pluginreg/backend_prefix_inventory_test.go
  • internal/pluginreg/ollama_build_test.go
  • internal/plugins/backends/openaicompat/backend.go
  • internal/infra/runtimebundle/security_policy_test.go
  • internal/core/runtime/attempt_accounting_test.go
  • internal/plugins/backends/openailegacy/plugin.go
  • internal/plugins/backends/ollama/resolve.go
  • internal/plugins/backends/ollama/version_test.go
  • internal/plugins/backends/ollama/version.go
  • internal/plugins/frontends/gemini/handler.go
  • internal/infra/runtimebundle/build.go
  • internal/plugins/frontends/openairesponses/handler.go
  • internal/pluginreg/standard_table.go
  • internal/core/modelregistry/prefix_test.go
  • internal/plugins/frontends/openailegacy/integration_test.go
  • internal/plugins/frontends/anthropic/handler.go
  • internal/core/execbackend/backend.go
  • internal/infra/runtimebundle/token_accounting_build_test.go
  • internal/plugins/frontends/openailegacy/handler.go
  • internal/plugins/backends/bedrock/plugin.go
  • internal/plugins/backends/ollama/resolve_test.go
  • internal/plugins/backends/ollama/plugin.go
  • internal/refbackend/ollama/server.go
  • internal/core/modelregistry/registry.go
  • internal/core/modelregistry/registry_test.go
  • internal/core/modelregistry/runtime_test.go
  • internal/infra/runtimebundle/modelregistry_build_test.go
  • internal/pluginreg/backends_install.go
  • internal/plugins/backends/ollama/integration_test.go
  • internal/refbackend/ollama/backend_test.go
  • internal/plugins/backends/ollama/inventory_test.go
  • internal/plugins/backends/ollama/inventory.go
internal/plugins/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

internal/plugins/**/*.go: Keep provider-specific payload types inside adapters and plugins
No pairwise protocol translators; only protocol <-> canonical adapters

Files:

  • internal/plugins/backends/ollama/payload_mutate.go
  • internal/plugins/backends/ollama/doc.go
  • internal/plugins/backends/ollama/mode_test.go
  • internal/plugins/backends/ollama/mode.go
  • internal/plugins/frontends/gemini/integration_test.go
  • internal/plugins/frontends/routeselect/routeselect.go
  • internal/plugins/backends/localstub/plugin.go
  • internal/plugins/frontends/anthropic/integration_test.go
  • internal/plugins/backends/ollama/caps.go
  • internal/plugins/frontends/openairesponses/integration_test.go
  • internal/plugins/backends/ollama/config_test.go
  • internal/plugins/backends/acp/plugin.go
  • internal/plugins/backends/ollama/payload_mutate_test.go
  • internal/plugins/backends/bedrock/prefix_test.go
  • internal/plugins/backends/ollama/caps_test.go
  • internal/plugins/frontends/routeselect/routeselect_test.go
  • internal/plugins/backends/anthropic/plugin.go
  • internal/plugins/backends/ollama/config.go
  • internal/plugins/backends/gemini/plugin.go
  • internal/plugins/backends/openairesponses/plugin.go
  • internal/plugins/backends/openaicompat/backend.go
  • internal/plugins/backends/openailegacy/plugin.go
  • internal/plugins/backends/ollama/resolve.go
  • internal/plugins/backends/ollama/version_test.go
  • internal/plugins/backends/ollama/version.go
  • internal/plugins/frontends/gemini/handler.go
  • internal/plugins/frontends/openairesponses/handler.go
  • internal/plugins/frontends/openailegacy/integration_test.go
  • internal/plugins/frontends/anthropic/handler.go
  • internal/plugins/frontends/openailegacy/handler.go
  • internal/plugins/backends/bedrock/plugin.go
  • internal/plugins/backends/ollama/resolve_test.go
  • internal/plugins/backends/ollama/plugin.go
  • internal/plugins/backends/ollama/integration_test.go
  • internal/plugins/backends/ollama/inventory_test.go
  • internal/plugins/backends/ollama/inventory.go
internal/**

⚙️ CodeRabbit configuration file

internal/**: Focus on package boundaries, hidden coupling, unexported API design, concurrency safety, deterministic behavior, and whether logic belongs in this internal package.

Files:

  • internal/plugins/backends/ollama/payload_mutate.go
  • internal/plugins/backends/ollama/doc.go
  • internal/plugins/backends/ollama/mode_test.go
  • internal/plugins/backends/ollama/mode.go
  • internal/plugins/frontends/gemini/integration_test.go
  • internal/stdhttp/testdata/dogfood_gemini_dual_stub_failover.yaml
  • internal/pluginreg/spec_bundle_standard_inventory_test.go
  • internal/plugins/frontends/routeselect/routeselect.go
  • internal/plugins/backends/localstub/plugin.go
  • internal/core/runtime/attempt_accounting.go
  • internal/plugins/frontends/anthropic/integration_test.go
  • internal/infra/runtimebundle/exclusive_registry_test.go
  • internal/plugins/backends/ollama/caps.go
  • internal/infra/modelcatalog/modelsdev/normalize_test.go
  • internal/refbackend/ollama/doc.go
  • internal/plugins/frontends/openairesponses/integration_test.go
  • internal/plugins/backends/ollama/config_test.go
  • internal/plugins/backends/acp/plugin.go
  • internal/plugins/backends/ollama/payload_mutate_test.go
  • internal/plugins/backends/bedrock/prefix_test.go
  • internal/archtest/backend_lifecycle_contract_test.go
  • internal/infra/modelcatalog/modelsdev/normalize.go
  • internal/plugins/backends/ollama/caps_test.go
  • internal/core/modelregistry/runtime.go
  • internal/plugins/frontends/routeselect/routeselect_test.go
  • internal/plugins/backends/anthropic/plugin.go
  • internal/plugins/backends/ollama/config.go
  • internal/plugins/backends/gemini/plugin.go
  • internal/plugins/backends/openairesponses/plugin.go
  • internal/pluginreg/backend_prefix_inventory_test.go
  • internal/pluginreg/ollama_build_test.go
  • internal/plugins/backends/openaicompat/backend.go
  • internal/infra/runtimebundle/security_policy_test.go
  • internal/core/runtime/attempt_accounting_test.go
  • internal/plugins/backends/openailegacy/plugin.go
  • internal/plugins/backends/ollama/resolve.go
  • internal/plugins/backends/ollama/version_test.go
  • internal/plugins/backends/ollama/version.go
  • internal/plugins/frontends/gemini/handler.go
  • internal/infra/runtimebundle/build.go
  • internal/plugins/frontends/openairesponses/handler.go
  • internal/pluginreg/standard_table.go
  • internal/core/modelregistry/prefix_test.go
  • internal/plugins/frontends/openailegacy/integration_test.go
  • internal/plugins/frontends/anthropic/handler.go
  • internal/core/execbackend/backend.go
  • internal/infra/runtimebundle/token_accounting_build_test.go
  • internal/plugins/frontends/openailegacy/handler.go
  • internal/plugins/backends/bedrock/plugin.go
  • internal/plugins/backends/ollama/resolve_test.go
  • internal/plugins/backends/ollama/plugin.go
  • internal/refbackend/ollama/server.go
  • internal/core/modelregistry/registry.go
  • internal/core/modelregistry/registry_test.go
  • internal/core/modelregistry/runtime_test.go
  • internal/infra/runtimebundle/modelregistry_build_test.go
  • internal/pluginreg/backends_install.go
  • internal/plugins/backends/ollama/integration_test.go
  • internal/refbackend/ollama/backend_test.go
  • internal/plugins/backends/ollama/inventory_test.go
  • internal/plugins/backends/ollama/inventory.go
**/*_test.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*_test.go: Prefer testdata/ for very large wire dumps and protocol fixtures instead of megastrings in test code
Keep tests near the package they validate unless a cross-package integration test is required
Tests are behavior contracts, not implementation snapshots

Files:

  • internal/plugins/backends/ollama/mode_test.go
  • internal/plugins/frontends/gemini/integration_test.go
  • internal/pluginreg/spec_bundle_standard_inventory_test.go
  • internal/plugins/frontends/anthropic/integration_test.go
  • internal/infra/runtimebundle/exclusive_registry_test.go
  • internal/infra/modelcatalog/modelsdev/normalize_test.go
  • pkg/lipsdk/standard_bundle_ollama_test.go
  • internal/plugins/frontends/openairesponses/integration_test.go
  • internal/plugins/backends/ollama/config_test.go
  • internal/plugins/backends/ollama/payload_mutate_test.go
  • internal/plugins/backends/bedrock/prefix_test.go
  • internal/archtest/backend_lifecycle_contract_test.go
  • internal/plugins/backends/ollama/caps_test.go
  • internal/plugins/frontends/routeselect/routeselect_test.go
  • internal/pluginreg/backend_prefix_inventory_test.go
  • internal/pluginreg/ollama_build_test.go
  • internal/infra/runtimebundle/security_policy_test.go
  • internal/core/runtime/attempt_accounting_test.go
  • internal/plugins/backends/ollama/version_test.go
  • internal/core/modelregistry/prefix_test.go
  • internal/plugins/frontends/openailegacy/integration_test.go
  • internal/infra/runtimebundle/token_accounting_build_test.go
  • internal/plugins/backends/ollama/resolve_test.go
  • internal/core/modelregistry/registry_test.go
  • internal/core/modelregistry/runtime_test.go
  • internal/infra/runtimebundle/modelregistry_build_test.go
  • internal/plugins/backends/ollama/integration_test.go
  • internal/refbackend/ollama/backend_test.go
  • internal/plugins/backends/ollama/inventory_test.go

⚙️ CodeRabbit configuration file

**/*_test.go: Review tests for meaningful assertions, table-driven coverage, race-prone tests, t.Parallel misuse, nondeterminism, leaked goroutines, real network or filesystem dependencies, fragile sleeps, and missing edge cases. Prefer testing observable behavior over implementation details.

Files:

  • internal/plugins/backends/ollama/mode_test.go
  • internal/plugins/frontends/gemini/integration_test.go
  • internal/pluginreg/spec_bundle_standard_inventory_test.go
  • internal/plugins/frontends/anthropic/integration_test.go
  • internal/infra/runtimebundle/exclusive_registry_test.go
  • internal/infra/modelcatalog/modelsdev/normalize_test.go
  • pkg/lipsdk/standard_bundle_ollama_test.go
  • internal/plugins/frontends/openairesponses/integration_test.go
  • internal/plugins/backends/ollama/config_test.go
  • internal/plugins/backends/ollama/payload_mutate_test.go
  • internal/plugins/backends/bedrock/prefix_test.go
  • internal/archtest/backend_lifecycle_contract_test.go
  • internal/plugins/backends/ollama/caps_test.go
  • internal/plugins/frontends/routeselect/routeselect_test.go
  • internal/pluginreg/backend_prefix_inventory_test.go
  • internal/pluginreg/ollama_build_test.go
  • internal/infra/runtimebundle/security_policy_test.go
  • internal/core/runtime/attempt_accounting_test.go
  • internal/plugins/backends/ollama/version_test.go
  • internal/core/modelregistry/prefix_test.go
  • internal/plugins/frontends/openailegacy/integration_test.go
  • internal/infra/runtimebundle/token_accounting_build_test.go
  • internal/plugins/backends/ollama/resolve_test.go
  • internal/core/modelregistry/registry_test.go
  • internal/core/modelregistry/runtime_test.go
  • internal/infra/runtimebundle/modelregistry_build_test.go
  • internal/plugins/backends/ollama/integration_test.go
  • internal/refbackend/ollama/backend_test.go
  • internal/plugins/backends/ollama/inventory_test.go
internal/plugins/frontends/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

internal/plugins/frontends/**/*.go: Do not add go (goroutine) in request handlers, frontend encoders, or per-call hot paths; prefer long-lived workers and stream-scoped pumps
Frontends are responsible for mapping internal errors to protocol-specific error shapes

Files:

  • internal/plugins/frontends/gemini/integration_test.go
  • internal/plugins/frontends/routeselect/routeselect.go
  • internal/plugins/frontends/anthropic/integration_test.go
  • internal/plugins/frontends/openairesponses/integration_test.go
  • internal/plugins/frontends/routeselect/routeselect_test.go
  • internal/plugins/frontends/gemini/handler.go
  • internal/plugins/frontends/openairesponses/handler.go
  • internal/plugins/frontends/openailegacy/integration_test.go
  • internal/plugins/frontends/anthropic/handler.go
  • internal/plugins/frontends/openailegacy/handler.go
cmd/**

⚙️ CodeRabbit configuration file

cmd/**: Focus on CLI/service entrypoint behavior: signal handling, graceful shutdown, context propagation, configuration parsing, environment variables, logging setup, exit codes, and backwards compatibility of flags or command output.

Files:

  • cmd/lipstd/testdata/dogfood-local-stub/inventory.golden.json
  • cmd/lipstd/testdata/dogfood-local-stub/routes.golden.json
pkg/lipsdk/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

Public contracts in pkg/lipapi and pkg/lipsdk must be versionable, documented, and minimal

Files:

  • pkg/lipsdk/standard_bundle.go
  • pkg/lipsdk/standard_bundle_ollama_test.go
pkg/**/*.go

📄 CodeRabbit inference engine (Custom checks)

For changes under pkg/** or exported Go identifiers, warn if the PR changes exported types, function signatures, error behavior, JSON fields, CLI flags, config keys, or documented behavior without clearly explaining the compatibility impact

Files:

  • pkg/lipsdk/standard_bundle.go
  • pkg/lipsdk/standard_bundle_ollama_test.go
pkg/**

⚙️ CodeRabbit configuration file

pkg/**: Treat exported identifiers as public API. Flag breaking changes, ambiguous contracts, missing error semantics, poor interface boundaries, and changes that make downstream usage harder.

Files:

  • pkg/lipsdk/standard_bundle.go
  • pkg/lipsdk/standard_bundle_ollama_test.go
internal/core/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

internal/core/**/*.go: Core packages must not import official provider SDKs
Core packages must not import concrete plugins
Return errors, do not panic in request paths
Keep core files small and cohesive
Do not mix frontend codec logic, routing policy, and backend invocation in one package
Prefer explicit construction and registration over DI containers, reflection, or global registries
No package-level mutable global state in core code
Capability mismatches must fail explicitly; never silently drop required semantics
Advanced request/response mutation belongs behind hook interfaces, not inside core business logic
Narrow interfaces, small files, simple control flow (keep the core boring)

Files:

  • internal/core/runtime/attempt_accounting.go
  • internal/core/modelregistry/runtime.go
  • internal/core/runtime/attempt_accounting_test.go
  • internal/core/modelregistry/prefix_test.go
  • internal/core/execbackend/backend.go
  • internal/core/modelregistry/registry.go
  • internal/core/modelregistry/registry_test.go
  • internal/core/modelregistry/runtime_test.go
internal/core/runtime/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

internal/core/runtime/**/*.go: No transparent retry or failover after the first downstream content event is emitted
Streaming is the primary path; non-streaming is collected from the streaming path
Preserve ordering guarantees for canonical event streams

Files:

  • internal/core/runtime/attempt_accounting.go
  • internal/core/runtime/attempt_accounting_test.go
internal/core/**/*_test.go

📄 CodeRabbit inference engine (AGENTS.md)

internal/core/**/*_test.go: Add regression tests for every bug fix in routing, translation, or streaming behavior
Decoder and selector parsers should gain fuzz tests when practical

Files:

  • internal/core/runtime/attempt_accounting_test.go
  • internal/core/modelregistry/prefix_test.go
  • internal/core/modelregistry/registry_test.go
  • internal/core/modelregistry/runtime_test.go
🪛 PSScriptAnalyzer (1.25.0)
scripts/ollama-text-smoke.ps1

[warning] 283-283: $null should be on the left side of equality comparisons.

Suggested fix: Use $null on the left hand side for safe comparison with $null.

(PSPossibleIncorrectComparisonWithNull)


[warning] 9-9: The parameter 'StartupTimeoutSeconds' has been declared but not used.

(PSReviewUnusedParameter)


[warning] 10-10: The parameter 'RequestTimeoutSeconds' has been declared but not used.

(PSReviewUnusedParameter)


[warning] 22-22: Function 'New-FreeLoopbackAddress' has verb that could change system state. Therefore, the function has to support 'ShouldProcess'.

(PSUseShouldProcessForStateChangingFunctions)

🔇 Additional comments (100)
internal/core/runtime/attempt_accounting.go (1)

94-96: LGTM!

internal/core/runtime/attempt_accounting_test.go (1)

54-70: LGTM!

internal/plugins/backends/ollama/doc.go (1)

1-8: LGTM!

internal/pluginreg/standard_table.go (2)

14-14: LGTM!


178-183: LGTM!

pkg/lipsdk/standard_bundle.go (1)

19-20: LGTM!

pkg/lipsdk/standard_bundle_ollama_test.go (1)

1-21: LGTM!

internal/pluginreg/ollama_build_test.go (5)

17-29: LGTM!


31-49: LGTM!


51-104: LGTM!


106-124: LGTM!


126-171: LGTM!

internal/pluginreg/spec_bundle_standard_inventory_test.go (1)

37-38: LGTM!

config/config.yaml (1)

279-300: LGTM!

config/examples/anthropic-stub.yaml (1)

63-68: LGTM!

internal/plugins/backends/ollama/config.go (4)

10-39: LGTM!


41-58: LGTM!


60-85: LGTM!


87-92: LGTM!

internal/plugins/backends/ollama/mode.go (4)

5-10: LGTM!


12-23: LGTM!


25-36: LGTM!


38-54: LGTM!

internal/plugins/backends/ollama/payload_mutate.go (1)

8-17: LGTM!

internal/plugins/backends/ollama/config_test.go (3)

10-20: LGTM!


22-52: LGTM!


54-61: LGTM!

internal/plugins/backends/ollama/mode_test.go (2)

5-58: LGTM!


60-113: LGTM!

internal/plugins/backends/ollama/payload_mutate_test.go (3)

9-16: LGTM!


18-28: LGTM!


30-40: LGTM!

internal/refbackend/ollama/backend_test.go (6)

14-40: LGTM!


42-80: LGTM!


82-122: LGTM!


124-143: LGTM!


145-164: LGTM!


166-404: LGTM!

scripts/ollama-text-smoke.ps1 (6)

1-21: LGTM!


22-31: LGTM!


33-83: LGTM!


85-102: LGTM!


104-140: LGTM!


142-282: LGTM!

Also applies to: 284-287

internal/plugins/backends/ollama/plugin.go (1)

24-183: LGTM!

internal/plugins/backends/ollama/integration_test.go (1)

1-670: LGTM!

config/examples/openai-responses-stub.yaml (1)

64-69: LGTM!

internal/stdhttp/testdata/dogfood_gemini_dual_stub_failover.yaml (1)

62-67: LGTM!

cmd/lipstd/testdata/dogfood-local-stub/inventory.golden.json (1)

65-74: LGTM!

internal/plugins/backends/ollama/caps.go (1)

7-26: LGTM!

internal/plugins/backends/ollama/caps_test.go (1)

10-45: LGTM!

internal/plugins/backends/ollama/resolve.go (1)

12-98: LGTM!

internal/plugins/backends/ollama/resolve_test.go (1)

10-64: LGTM!

internal/plugins/backends/ollama/inventory.go (4)

63-135: LGTM!


137-198: LGTM!


200-294: LGTM!


316-448: LGTM!

cmd/lipstd/testdata/dogfood-local-stub/routes.golden.json (1)

44-53: LGTM!

internal/plugins/backends/ollama/inventory_test.go (1)

520-577: LGTM!

Also applies to: 579-627

internal/refbackend/ollama/doc.go (1)

1-4: LGTM!

internal/refbackend/ollama/server.go (1)

1-333: LGTM!

internal/pluginreg/backends_install.go (1)

363-435: LGTM!

config/examples/dogfood-local-stub.yaml (1)

66-71: LGTM!

config/examples/gemini-stub.yaml (1)

63-68: LGTM!

config/examples/openai-legacy-stub.yaml (1)

63-68: LGTM!

internal/core/execbackend/backend.go (1)

27-30: LGTM!

internal/core/modelregistry/registry.go (3)

16-29: LGTM!


57-60: LGTM!

Also applies to: 96-98, 121-121


150-213: LGTM!

Also applies to: 227-229

internal/core/modelregistry/runtime.go (1)

200-204: LGTM!

internal/infra/runtimebundle/build.go (1)

126-130: LGTM!

docs/plugin-authoring.md (1)

64-69: LGTM!

internal/plugins/backends/openairesponses/plugin.go (1)

52-53: LGTM!

Also applies to: 125-127

internal/infra/runtimebundle/modelregistry_build_test.go (2)

34-35: LGTM!

Also applies to: 58-59, 109-111, 153-155, 189-191, 216-218, 257-259


295-298: LGTM!

Also applies to: 381-385

docs/capability-catalogs.md (1)

23-27: LGTM!

internal/core/modelregistry/prefix_test.go (1)

1-151: LGTM!

internal/core/modelregistry/registry_test.go (1)

19-29: LGTM!

Also applies to: 59-72, 91-94, 110-112, 142-144, 181-214

internal/plugins/backends/bedrock/plugin.go (1)

61-63: LGTM!

Also applies to: 74-76

internal/plugins/frontends/openailegacy/handler.go (1)

110-112: LGTM!

internal/plugins/frontends/openairesponses/handler.go (1)

154-156: LGTM!

internal/core/modelregistry/runtime_test.go (1)

32-35: LGTM!

Also applies to: 74-77, 96-135, 147-150, 180-183, 225-228, 264-267, 296-299, 335-338, 377-380, 408-411, 446-449

internal/plugins/backends/acp/plugin.go (1)

55-57: LGTM!

Also applies to: 74-75

internal/plugins/backends/anthropic/plugin.go (1)

62-62: LGTM!

Also applies to: 122-124

internal/infra/runtimebundle/security_policy_test.go (1)

26-28: LGTM!

Also applies to: 48-50

internal/plugins/frontends/anthropic/integration_test.go (1)

395-428: LGTM!

internal/plugins/frontends/gemini/integration_test.go (1)

381-416: LGTM!

internal/plugins/frontends/openailegacy/integration_test.go (1)

371-405: LGTM!

Also applies to: 407-440

internal/plugins/frontends/openairesponses/integration_test.go (1)

398-431: LGTM!

internal/plugins/backends/gemini/plugin.go (1)

58-59: LGTM!

Also applies to: 121-123

internal/plugins/backends/localstub/plugin.go (1)

33-34: LGTM!

internal/plugins/backends/openaicompat/backend.go (1)

48-58: LGTM!

Also applies to: 124-129

internal/infra/runtimebundle/exclusive_registry_test.go (1)

30-32: LGTM!

internal/plugins/backends/openailegacy/plugin.go (2)

51-109: LGTM!


123-135: LGTM!

internal/infra/runtimebundle/token_accounting_build_test.go (1)

26-28: LGTM!

Also applies to: 114-116, 159-161, 217-219, 257-259

internal/archtest/backend_lifecycle_contract_test.go (1)

14-19: LGTM!

internal/plugins/frontends/routeselect/routeselect_test.go (1)

7-117: LGTM!

internal/plugins/frontends/anthropic/handler.go (1)

15-15: LGTM!

Also applies to: 99-116

internal/plugins/frontends/gemini/handler.go (1)

15-15: LGTM!

Also applies to: 111-113

Comment thread internal/infra/modelcatalog/modelsdev/normalize_test.go
Comment on lines +73 to +112
// ParseModelIDs decodes a models.dev-style provider map and returns sorted canonical provider/model IDs.
func ParseModelIDs(raw []byte) ([]string, error) {
if len(raw) == 0 {
return nil, errors.New("modelsdev: empty payload")
}
var root map[string]json.RawMessage
if err := json.Unmarshal(raw, &root); err != nil {
return nil, fmt.Errorf("modelsdev: decode root: %w", err)
}
if root == nil {
return nil, errors.New("modelsdev: unsupported schema: null root")
}
ids := []string{}
for providerKey, providerRaw := range root {
providerKey = strings.TrimSpace(providerKey)
if providerKey == "" {
continue
}
var wp wireProvider
if err := json.Unmarshal(providerRaw, &wp); err != nil {
return nil, fmt.Errorf("modelsdev: provider %q: %w", providerKey, err)
}
if len(wp.Models) == 0 || string(wp.Models) == "null" {
continue
}
var models []wireModel
if err := json.Unmarshal(wp.Models, &models); err != nil {
return nil, fmt.Errorf("modelsdev: provider %q models: %w", providerKey, err)
}
for _, wm := range models {
mid := strings.TrimSpace(wm.ID)
if mid != "" {
ids = append(ids, providerKey+"/"+mid)
}
}
}
slices.Sort(ids)
return ids, nil
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider extracting shared JSON decoding logic.

ParseModelIDs duplicates ~90% of the provider map decoding logic from ParseSnapshot (lines 21-71). Both functions:

  • Validate empty/null payload identically (lines 23-32 vs 75-84)
  • Decode and iterate providers identically (lines 35-50 vs 86-101)
  • Only differ in what they build (catalog facts map vs ID list)

Extracting a shared helper (e.g., func iterateProviders(raw []byte, fn func(providerKey string, model wireModel))) would reduce duplication and make schema changes easier to maintain.

♻️ Example refactoring approach
// Shared helper
func decodeProviderMap(raw []byte, fn func(providerKey, modelID string)) error {
	// Common validation and iteration logic
	// ...
	for _, wm := range models {
		mid := strings.TrimSpace(wm.ID)
		if mid != "" {
			fn(providerKey, mid)
		}
	}
	return nil
}

// ParseModelIDs becomes:
func ParseModelIDs(raw []byte) ([]string, error) {
	var ids []string
	err := decodeProviderMap(raw, func(pk, mid string) {
		ids = append(ids, pk+"/"+mid)
	})
	if err != nil {
		return nil, err
	}
	slices.Sort(ids)
	return ids, nil
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/infra/modelcatalog/modelsdev/normalize.go` around lines 73 - 112,
The ParseModelIDs function duplicates approximately 90% of the payload
validation and provider iteration logic already present in ParseSnapshot.
Extract a shared helper function (for example, decodeProviderMap) that handles
the common logic of validating empty/null payloads, unmarshaling the root map,
iterating through providers, and decoding wireProvider/wireModel structures.
This helper should accept a callback function to handle provider and model
processing differently for each caller. Update both ParseModelIDs and
ParseSnapshot to use this shared helper, passing their respective callback logic
to handle building the ID list and catalog facts map respectively.

Comment thread internal/pluginreg/backend_prefix_inventory_test.go Outdated
Comment thread internal/plugins/backends/bedrock/prefix_test.go
Comment thread internal/plugins/backends/ollama/inventory_test.go Outdated
Comment thread internal/plugins/backends/ollama/version.go
Comment thread internal/plugins/backends/ollama/version.go Outdated
Comment thread internal/plugins/frontends/routeselect/routeselect.go
Comment thread internal/plugins/frontends/routeselect/routeselect.go
Comment thread scripts/ollama-text-smoke.ps1 Outdated
@matdev83 matdev83 merged commit dfe20b2 into main Jun 23, 2026
2 checks passed
@matdev83 matdev83 deleted the chore/local-backend-prefix-registry branch June 23, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant