feat: canonical module path, public extension API, and embeddable bootstrap#457
feat: canonical module path, public extension API, and embeddable bootstrap#457SantiagoDePolonia wants to merge 9 commits into
Conversation
Makes GoModel importable as a Go module (library embedding, separate binaries built on top of the gateway). Pure mechanical rename: go.mod, all import paths, and version ldflags in Makefile, Dockerfile, and goreleaser config. No behavior change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds the gomodel ext package: a registry where external modules building custom gateway binaries register raw-JSON request rewriters, Echo middleware, extra routes, and auth-skip paths. Core will consume an immutable snapshot at server construction; an empty registry adds zero request overhead. No wiring yet — no behavior change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Wires the ext registry into the server: request rewriters run on the raw JSON body of POST /v1/chat/completions, /v1/messages, and /v1/responses after authentication and before workflow resolution, so body rewrites (including the model field) affect routing, failover, guardrails, budgets, and caching. Rewriter errors fail closed; audit logs keep the original client body. Extension middleware registers before gateway auth, extension routes after core routes, and extension public paths join the auth skip list. Nothing is registered when no extensions exist, so the default build is unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Moves the CLI parsing, logging setup, health/ready probes, default provider registrations, and start/shutdown lifecycle from cmd/gomodel into the importable run package. run.Run(ctx, run.Options) executes the full gateway lifecycle and accepts an ext.Registry, a product name, and a swagger-docs callback, so external modules can build custom gateway binaries; run.ExitCode maps errors to process exit codes. cmd/gomodel becomes a thin wrapper with identical CLI behavior; the swagger build-tag pair stays in cmd and is passed in as a callback. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Lets embedders register extensions and validate product licensing once the process is committed to serving, keeping --version and the --health/--ready probe modes silent (Docker healthchecks run the binary every few seconds). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Every rewriter that changes a request body now appends a request_revisions entry to the audit entry: sequence, rewriter name, body sizes, an optional rewriter-provided change summary (new ext.Result.Detail field), and the rewritten body when body logging is enabled. RequestBody stays the original client request, so the original plus the revision chain reconstruct the full transformation history the same way provider attempts are tracked. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Audit entries with request_revisions now render one 'Rewritten' tab per revision between the Request and Response tabs: a 'What changed' summary (rewriter, byte sizes, and the rewriter-provided detail) plus the rewritten body when body logging captured it, with an explanatory notice when it didn't. The Request tab keeps showing the original client body. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Resolves import-block conflicts from the module rename and applies the canonical module path to the newly added tagging package; server.Config keeps both the upstream Tagging field and the extension fields. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Too many files changed for review. ( Bypass the limit by tagging |
|
Important Review skippedToo many files! This PR contains 456 files, which is 306 over the limit of 150. To get a review, narrow the scope: Upgrade to a paid plan to raise the limit. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (456)
You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
What this does
Makes GoModel embeddable as a Go module and gives it a small, feature-neutral extension surface, so separate binaries can be built on top of the gateway (the open-source binary itself becomes a thin wrapper over the same API).
1. Canonical module path (
build:)Renames the module from
gomodeltogithub.com/ENTERPILOT/GoModel— a pure mechanical rename of go.mod, all import paths, and version ldflags (Makefile, Dockerfile, goreleaser). This is what allows anyone torequire github.com/ENTERPILOT/GoModelas a dependency. No behavior change.2. Public
extpackage (feat:)A registry where external modules register:
POST /v1/chat/completions,/v1/messages,/v1/responses(subroutes excluded) after auth and before workflow resolution, so body rewrites (includingmodel) affect routing, failover, guardrails, budgets, and caching. Fail-closed error semantics rendered in each endpoint's native error dialect.An empty registry adds zero request overhead (the middleware isn't even registered), so the default build is unchanged.
3. Public
runpackage (refactor:)Extracts CLI parsing, logging setup, health/ready probes, provider registration, and the start/shutdown lifecycle from
cmd/gomodelinto an importablerun.Run(ctx, run.Options), with aSetuphook that fires only when the process actually serves (keeps--versionand Docker healthcheck probes silent).cmd/gomodelkeeps byte-identical CLI behavior.4. Audit request-revision chain (
feat:)Audit entries record an ingress rewrite trail:
request_bodystays the original client request, and a newrequest_revisionsarray captures one entry per rewriter that changed the body (name, sizes, optional rewriter detail, rewritten body when body logging is on) — mirroring the existing provider-attempts pattern. The dashboard's audit detail view renders these as "Rewritten" tabs between Request and Response.Docs
docs/extensions.mddocuments the rewriter contract, embedding recipe, cross-module ldflags versioning, and Prometheus/config guidance.Testing
make test-e2e), dashboard JS tests (386),TestHotPathPerfGuard, and golangci-lint all green.extregistry semantics, request-rewrite middleware (per-endpoint gating, chaining, fail-closed envelopes per dialect, >64KB/>1MB bodies, audit-keeps-original assertions for streaming and buffered paths), revision recording with and without body logging,runpackage CLI behavior.main(labelling system, hot-path perf, failover fix);taggingpackage included in the rename,server.Configcarries bothTaggingand the extension fields.🤖 Generated with Claude Code