Refactor: Collapse authbridge-lite into a build-tag variant of authbridge-proxy#621
Conversation
…nt of authbridge-proxy authbridge-lite differed from authbridge-proxy only in its compiled-in plugin set (same HTTP listeners, same pure-Go CGO_ENABLED=0 build), and it had drifted: its doc comments claimed an auth-only/size-optimized build while it imported the opa plugin, pulling in the full OPA/Rego Go SDK. Measured, the lite image (43.6 MB) was the same size as proxy (43.7 MB) — the size goal was negated. Generalize the existing exclude_plugin_* build-tag pattern to every plugin in cmd/authbridge-proxy (one plugins_<name>.go per plugin gated by //go:build !exclude_plugin_<name>); jwt-validation and token-exchange stay always-compiled. Delete cmd/authbridge-lite, and build the authbridge-lite image from the proxy Dockerfile with the exclude tags so only jwt-validation + token-exchange compile in. The image name is preserved for consumers (build.yaml repoints it at the proxy Dockerfile with a GO_BUILD_TAGS build-arg). Result: lite binary 14.7 MB vs full 27.8 MB (0 open-policy-agent symbols vs 7,475); lite image 29.7 MB vs 43.7 MB. go build/vet/test pass with and without the lite tags; a PR-time CI step compiles the lite tag set. The lite image now runs the authbridge-proxy binary (logs as authbridge-proxy); abctl is unaffected (keys on the container name). Refs rossoctl#620, rossoctl/rossoctl#1458 Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
📝 WalkthroughWalkthroughauthbridge-lite is now built as a proxy image variant from ChangesAuthBridge lite build-variant refactor
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 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 @.github/workflows/ci.yaml:
- Around line 107-109: The lite variant job in the CI workflow only runs the
tagged build and never exercises the same excluded-plugin tag set with tests.
Update the authbridge-proxy lite-variant step in the workflow so it also runs a
tagged go test for the same exclude_plugin_* tags, ideally alongside the
existing build step, using the same tag list in the go test invocation to cover
lite-only regressions.
In `@authbridge/cmd/authbridge-proxy/plugins_tokenbroker.go`:
- Around line 1-5: The tokenbroker plugin import in plugins_tokenbroker.go is
being made opt-out, which breaks lite builds that are supposed to keep
token-exchange enabled. Make the import in the plugins_tokenbroker.go entrypoint
unconditional by removing the build guard, and update the lite tag sets in
build.yaml, ci.yaml, and local-build-and-test.sh to stop adding
exclude_plugin_tokenbroker so the token-exchange plugin stays included alongside
jwt-validation.
In `@authbridge/docs/framework-architecture.md`:
- Around line 665-667: The architecture note overstates TLS wiring ownership by
saying only cmd/authbridge-proxy wires it up. Reword this in
framework-architecture.md to refer to the proxy-family entrypoints and
explicitly include authbridge-cpex/main.go as a documented duplicate of
authbridge-proxy/main.go pending Run() extraction, while keeping
authbridge-envoy excluded from this wiring.
In `@CLAUDE.md`:
- Around line 128-133: Update the stale contributor-doc wording so it matches
the new build-variant layout throughout this section. In the intro near the Go
module notes, replace the old “Three mode-specific binaries, one Dockerfile per
binary” framing with language that describes image variants built from the thin
`authbridge/cmd/authbridge-{proxy,envoy}/` binaries and the shared
`authbridge/authlib/` library. Also fix the “Gotchas and Known Issues” entry
that still references the old single-module path `authbridge/proxy-init/go.mod`,
and point it to the current workspace/module structure using
`authbridge/go.work` and `authbridge/authlib/` instead.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 07daf794-5ff9-4482-806e-4e7b5f717610
⛔ Files ignored due to path filters (2)
authbridge/cmd/authbridge-lite/go.sumis excluded by!**/*.sumauthbridge/go.workis excluded by!**/*.work
📒 Files selected for processing (25)
.github/dependabot.yml.github/workflows/build.yaml.github/workflows/ci.yamlCLAUDE.mdMakefileREADME.mdauthbridge/CLAUDE.mdauthbridge/README.mdauthbridge/cmd/README.mdauthbridge/cmd/authbridge-envoy/main.goauthbridge/cmd/authbridge-lite/Dockerfileauthbridge/cmd/authbridge-lite/entrypoint.shauthbridge/cmd/authbridge-lite/go.modauthbridge/cmd/authbridge-lite/main.goauthbridge/cmd/authbridge-proxy/main.goauthbridge/cmd/authbridge-proxy/plugins_a2aparser.goauthbridge/cmd/authbridge-proxy/plugins_inferenceparser.goauthbridge/cmd/authbridge-proxy/plugins_mcpparser.goauthbridge/cmd/authbridge-proxy/plugins_opa.goauthbridge/cmd/authbridge-proxy/plugins_sparc.goauthbridge/cmd/authbridge-proxy/plugins_tokenbroker.goauthbridge/demos/README.mdauthbridge/docs/framework-architecture.mdauthbridge/docs/plugin-reference.mdlocal-build-and-test.sh
💤 Files with no reviewable changes (6)
- Makefile
- authbridge/cmd/authbridge-lite/Dockerfile
- authbridge/cmd/authbridge-lite/main.go
- authbridge/cmd/authbridge-lite/go.mod
- .github/dependabot.yml
- authbridge/cmd/authbridge-lite/entrypoint.sh
| | `authbridge-lite` _(image: proxy + `exclude_plugin_*`)_ | proxy-sidecar | HTTP forward + reverse proxies | auth-only (jwt-validation + token-exchange; OPA + parsers dropped) | | ||
|
|
||
| **Go modules:** | ||
| - `authbridge/authlib/` — pure library: validation, exchange, cache, bypass, spiffe, routing, auth, config, all listener implementations, all plugins. | ||
| - `authbridge/cmd/authbridge-{proxy,envoy,lite}/` — thin main packages that import authlib and start the listeners they need. | ||
| - `authbridge/cmd/authbridge-{proxy,envoy}/` — thin main packages that import authlib and start the listeners they need. (The `authbridge-lite` image is `authbridge-proxy` built with `exclude_plugin_*` tags.) | ||
| - `authbridge/go.work` — workspace linking authlib + the binaries for local development. |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
This doc still mixes the old layout with the new build-variant model.
The updated table/module text now treats authbridge-lite as an image variant, but the section intro above still says “Three mode-specific binaries, one Dockerfile per binary,” and the later “Gotchas and Known Issues” note still says the repo has a single Go module at authbridge/proxy-init/go.mod. Please update those stale lines too so the contributor docs describe one consistent structure.
🤖 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 `@CLAUDE.md` around lines 128 - 133, Update the stale contributor-doc wording
so it matches the new build-variant layout throughout this section. In the intro
near the Go module notes, replace the old “Three mode-specific binaries, one
Dockerfile per binary” framing with language that describes image variants built
from the thin `authbridge/cmd/authbridge-{proxy,envoy}/` binaries and the shared
`authbridge/authlib/` library. Also fix the “Gotchas and Known Issues” entry
that still references the old single-module path `authbridge/proxy-init/go.mod`,
and point it to the current workspace/module structure using
`authbridge/go.work` and `authbridge/authlib/` instead.
There was a problem hiding this comment.
Partially addressed in 2d4a677. Fixed the stale "lite is a binary" lines I'd missed: CLAUDE.md:122 ("Three mode-specific binaries…" → two + lite build variant), authbridge/CLAUDE.md (the ### AuthBridge Binaries (cmd/authbridge-{proxy,envoy,lite}/) heading and the Go-module list), and authbridge/cmd/README.md ("Three…/All three binaries").
The quoted "single Go module at authbridge/proxy-init/go.mod" gotcha line wasn't found in CLAUDE.md or authbridge/CLAUDE.md as written, so there was nothing to change there — the module/workspace layout is already described via authbridge/go.work + authbridge/authlib/.
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Current occurrences of authbridge/proxy-init/go.mod =="
rg -n -C2 'authbridge/proxy-init/go\.mod|single Go module|One Go module' CLAUDE.md authbridge/CLAUDE.md || true
echo
echo "== Current AuthBridge Binaries heading/snippet in CLAUDE.md =="
sed -n '118,150p' CLAUDE.md
echo
echo "== Current Gotchas snippet in CLAUDE.md =="
sed -n '250,290p' CLAUDE.md
echo
echo "== Current matching text in authbridge/CLAUDE.md =="
rg -n -C2 'authbridge/proxy-init/go\.mod|single Go module|One Go module|AuthBridge Binaries' authbridge/CLAUDE.md || trueLength of output: 5863
@huang195, thanks for the update — I rechecked the current branch.
The stale “lite is a binary” wording does look fixed, including the CLAUDE.md binaries section and the authbridge/CLAUDE.md heading.
There is still one remaining stale line in the root doc, though: CLAUDE.md Line 307 currently says:
1. **One Go module:** The repo has a single Go module at `authbridge/proxy-init/go.mod` (Go 1.25).So the “single Go module” part of my original comment is still applicable, but only for CLAUDE.md Line 307. Updating that line to reflect the current workspace/module layout (authbridge/go.work, authbridge/authlib/, and the cmd modules) should fully resolve this thread.
🧠 Learnings used
Learnt from: mrsabath
Repo: kagenti/kagenti-extensions PR: 466
File: authbridge/demos/weather-agent/demo-ui-advanced.md:0-0
Timestamp: 2026-06-03T14:52:08.855Z
Learning: When reviewing GitHub-flavored Markdown (GFM) tables, if a table cell needs to contain a literal pipe character (`|`), it must be escaped as `\|` so GitHub doesn’t treat it as a column delimiter. Do not flag occurrences of `\|` inside GFM table cells as an error, since GitHub renders `\|` as a plain `|` in the table output (and users copying from the rendered table will get the intended command/value).
…le too Extend the build-tag treatment to the last two always-compiled plugins so *every* plugin in cmd/authbridge-proxy can be dropped via -tags exclude_plugin_<name>. main.go now imports no plugin package at all: its lone coupling (tokenexchange.SpiffeIdentity) is replaced by a local constant for the shared identity.type=spiffe config convention, which is what let token-exchange be excluded without breaking the SPIFFE-provider gate. The authbridge-lite tag set is unchanged (it still excludes all but jwt-validation + token-exchange); this only adds composability. Verified: go build/vet/test pass with no tags, with the lite tag set, and with all nine plugins excluded. Refs rossoctl#620, rossoctl/rossoctl#1458 Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
…ix stale lite-as-binary docs - ci.yaml: the lite-variant PR step now runs `go test -race -cover` with the exclude tags too (not just `go build`), guarding lite-only regressions; the tag list is split across lines to stay under the 150-char yamllint cap. - Docs/comments: reframe the remaining "three binaries / lite binary" references (CLAUDE.md, authbridge/CLAUDE.md, authbridge/cmd/README.md, authlib/sessionapi/catalog_adapter.go) as two binaries (proxy, envoy) plus the lite build variant of the proxy binary. Addresses the CodeRabbit review on rossoctl#621. Two of its findings were checked and intentionally not changed: excluding token-broker is correct (token-broker != token-exchange — distinct plugins; lite keeps token-exchange), and the "only authbridge-proxy wires TLS" wording is accurate on main (authbridge-cpex is from an unmerged PR, not present here). Refs rossoctl#620, rossoctl/rossoctl#1458 Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
…xchange main.go deliberately does not import the token-exchange plugin package (so token-exchange stays build-tag excludable), which traded compiler-linkage of the identity.type=spiffe value for a duplicated "spiffe" literal. Add a test-time assertion that spiffeIdentityType == tokenexchange.SpiffeIdentity — a test file may import the package unconditionally without pulling it into the tag-gated production binary — so the two can't silently drift. Refs kagenti#620, kagenti/kagenti#1458 Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
pdettori
left a comment
There was a problem hiding this comment.
Clean refactoring that collapses authbridge-lite from a separate binary into a build-tag variant of authbridge-proxy. The plugin architecture is well-designed — each plugin gets its own plugins_<name>.go file gated by //go:build !exclude_plugin_<name>, making arbitrary plugin subsets composable at build time. The drift-guard test is a smart way to preserve correctness without reintroducing import coupling.
All CI checks pass. Capability change is clearly documented. Measurements verify the 32% image size reduction (29.7 MB vs 43.7 MB). CodeRabbit findings already addressed in follow-up commits.
Summary
authbridge-litewas a separatecmd/binary that differed fromauthbridge-proxyin only one dimension — its compiled-in plugin set (same HTTP listeners, same pure-GoCGO_ENABLED=0build, same Alpine base). It had drifted: its doc comments described an auth-only / size-optimized build, but it imported theopaplugin, pulling in the full OPA/Rego Go SDK (open-policy-agent/opa v1.4.2). Measured, theauthbridge-liteimage (43.6 MB) was essentially the same size asauthbridge-proxy(43.7 MB) — the size goal was negated.This collapses lite into a build variant of the proxy binary, using the build-tag mechanism the repo already had (
//go:build !exclude_plugin_ibac).Changes
cmd/authbridge-proxyis now build-tag excludable — oneplugins_<name>.goper plugin, gated by//go:build !exclude_plugin_<name>(generalizing the pre-existingplugins_ibac.go).main.goimports no plugin package directly: the lone coupling (tokenexchange.SpiffeIdentity) is replaced by a local constant for the sharedidentity.type=spiffeconvention, with a test-time assertion guarding against drift.cmd/authbridge-lite/.authbridge-liteimage fromcmd/authbridge-proxy/DockerfilewithGO_BUILD_TAGS=exclude_plugin_*(onlyjwt-validation + token-exchange). Image name preserved for consumers.build.yamlrepoints the lite matrix entry at the proxy Dockerfile + wires a per-entrybuild-args;ci.yamldrops the deleted lite module and adds a PR-time step that builds and tests the lite tag set.go.work,.github/dependabot.yml,Makefile,local-build-and-test.sh; docs reframed (lite = a build variant, not a separate binary).The old
authbridge-litebinary compiled in four plugins —jwt-validation,opa,token-broker,token-exchange. The newauthbridge-liteimage keeps onlyjwt-validation+token-exchange(OPA, token-broker, and parsers dropped). The image name is unchanged, so any lite deployment whose config references theopaauthz gate or thetoken-brokerplugin will now fail fast at boot with "unknown plugin" (loud, not silent). This is intentional — lite is the auth-core footprint — but operators using lite with OPA/token-broker should switch to the fullauthbridgeimage.Verification (measured, linux/arm64)
open-policy-agentsymbols in the lite binary (the full binary has 7,475).go build/go vet/go test -race -coverpass with no tags, with the lite tag set, and with all nine plugins excluded (provingmain.gois plugin-free).GO_BUILD_TAGSbuild-arg → 0 OPA symbols inside.Notes / risk
authbridge-liteimage now runs theauthbridge-proxybinary, so it logs asauthbridge-proxy.abctlis unaffected (it keys on the operator-assigned container name, not the binary/image name). Operator/observability configs keying on theauthbridge-liteprocess or log name should be checked. (Verified theopendatahub-io/agents-operatorinjector references lite only by image name and sets nocommandoverride — it's a drop-in.)cmd/authbridge-envoy(no-liteconsumer; trivial follow-up); build-taggingtlsbridge/SPIFFE out ofmain.go.Closes #620
Part of rossoctl/rossoctl#1458
Assisted-By: Claude Code