Documentation
¶
Index ¶
- func Build(entries []config.PluginEntry, opts ...pipeline.Option) (*pipeline.Pipeline, error)
- func BuildWithDeps(entries []config.PluginEntry, deps Deps, opts ...pipeline.Option) (*pipeline.Pipeline, error)
- func BuildWithSPIFFE(entries []config.PluginEntry, p *spiffe.Provider, opts ...pipeline.Option) (*pipeline.Pipeline, error)
- func CollectStats(p *pipeline.Pipeline) []*auth.Stats
- func PricingConsumerPlugins() []string
- func RegisterPlugin(name string, factory PluginFactory)
- func RegisteredPlugins() []string
- func SPIFFEConsumerPlugins() []string
- func UnregisterPlugin(name string) bool
- func WarmCatalog()
- type AccountingConsumer
- type CatalogEntry
- type Deps
- type LocalInstallConsumer
- type PluginFactory
- type StatsSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
Build constructs a pipeline from an ordered list of plugin entries. For every plugin that implements pipeline.Configurable, Build calls Configure with the entry's Config bytes (nil when omitted). Passing config to a plugin that doesn't implement Configurable is rejected so stale or misplaced config blocks fail at startup instead of being silently ignored.
Unknown plugin names fail fast with an error that lists every currently-registered plugin — typo-catching diagnostic.
Injects nothing. A thin wrapper over BuildWithDeps, which is the single implementation; see there for the Configure and injection contract.
func BuildWithDeps ¶
func BuildWithDeps(entries []config.PluginEntry, deps Deps, opts ...pipeline.Option) (*pipeline.Pipeline, error)
BuildWithDeps constructs a pipeline from an ordered list of plugin entries, injecting each supplied dependency into the plugins that consume it.
For every plugin implementing pipeline.Configurable, Configure is called with the entry's Config bytes (nil when omitted). Passing config to a plugin that does not implement Configurable is rejected, so stale or misplaced config blocks fail at startup instead of being silently ignored. Unknown plugin names fail fast with an error listing every registered plugin.
Dependencies are injected BEFORE Configure runs, so configuration code can use them. That ordering is the contract, not an implementation detail: a plugin's Configure may build rate- or identity-dependent state, and an injection landing afterwards would be silently too late.
A nil dependency is NOT injected, rather than injected as nil. Handing a plugin a typed-nil interface would make its own `!= nil` guard true while every call through it panicked.
This is the single builder. Build and BuildWithSPIFFE delegate here; before this they were two copies of the same forty lines, differing only in one injection.
func BuildWithSPIFFE ¶
func BuildWithSPIFFE(entries []config.PluginEntry, p *spiffe.Provider, opts ...pipeline.Option) (*pipeline.Pipeline, error)
BuildWithSPIFFE is Build plus dependency injection of the framework SPIFFE Provider. Every plugin satisfying spiffe.ProviderConsumer receives p via SetSPIFFEProvider before its Configure is invoked, so configuration code can use the provider's sources directly.
Pass nil for p in builds that don't need SPIFFE; in that case the behavior is equivalent to Build for non-consuming plugins, and consumer plugins are NOT called (their SetSPIFFEProvider is skipped).
Plugins that don't implement ProviderConsumer are unaffected.
A thin wrapper over BuildWithDeps. It survives as a named entry point because four binaries call it; new dependencies go through Deps rather than growing a third builder.
func CollectStats ¶
CollectStats walks a pipeline and returns every *auth.Stats exposed by a StatsSource-implementing plugin. Order matches plugin declaration order in the pipeline, which keeps the aggregated output deterministic.
Returns nil (not an empty slice) when no plugins implement StatsSource, so callers can pass the result straight to auth.MergeStats without guarding against zero-length.
func PricingConsumerPlugins ¶
func PricingConsumerPlugins() []string
PricingConsumerPlugins lists the registered plugins whose instances implement pricing.ResolverConsumer — the plugins BuildWithDeps would inject the Registry into.
Callers that gate Registry construction on actual need use this to assert their need-detection covers every consumer; a new consumer slipping past the predicate would otherwise silently receive no resolver and report its traffic as unpriced, which looks identical to having no rates configured.
Probes by constructing each plugin and type-asserting, which is safe because PluginFactory is contractually a cheap, side-effect-free constructor. Mirrors SPIFFEConsumerPlugins; if a factory ever gains construction-time side effects, both switch to a static capability tag instead of a live probe.
func RegisterPlugin ¶
func RegisterPlugin(name string, factory PluginFactory)
RegisterPlugin adds a plugin factory under name. Intended to be called from package init() functions of plugin implementations:
func init() {
plugins.RegisterPlugin("rate-limiter", func() pipeline.Plugin {
return &RateLimiter{}
})
}
This is the stdlib pattern (database/sql.Register, image codec registration, log/slog handler registration): plugins live in their own package and advertise themselves by side-effect import:
import _ "github.com/acme/rossoctl-rate-limiter/ratelimit"
Double-registration under the same name panics. Silent last-write- wins would let a version mismatch or deployment bug poison the registry in ways that only surface as mysterious runtime behaviour; failing loud at process start is strictly safer.
Empty name or nil factory also panics — both are programmer errors, not recoverable conditions.
func RegisteredPlugins ¶
func RegisteredPlugins() []string
RegisteredPlugins returns the names of every registered plugin in sorted order. Intended for diagnostic surfaces (/config, CLI --help, Build's "unknown plugin" error message) and for tests that assert a plugin is visible to the builder.
func SPIFFEConsumerPlugins ¶
func SPIFFEConsumerPlugins() []string
SPIFFEConsumerPlugins returns the sorted names of registered plugins whose instances implement spiffe.ProviderConsumer — i.e. the plugins BuildWithSPIFFE would inject the Provider into. Callers that gate Provider construction on actual need (see cmd/cortex's spiffeProviderNeeded) use this to assert their need-detection covers every consumer; a new consumer that slips past the predicate would otherwise silently receive a nil Provider.
This probes by constructing each plugin and type-asserting. That is safe because PluginFactory is contractually a cheap, side-effect-free constructor (see PluginFactory: no construction args; deps + goroutines are created in Configure/Init, not the factory). If a factory ever gains construction-time side effects, switch this to a static capability tag instead of a live probe.
func UnregisterPlugin ¶
UnregisterPlugin removes a plugin factory from the registry. Intended for test isolation: a test registers a fake plugin, runs, and uses t.Cleanup to unregister so parallel tests aren't poisoned by the leftover entry.
Do not call from production code. The registry is intended to be written exactly once per plugin per process, at init() time; runtime deregistration has no valid use case in a running authbridge binary and would make the /config endpoint lie about pipeline composition.
Returns true when the name was registered (and is now removed), false when it wasn't. Callers ignoring the return value are common and correct — Cleanup doesn't care.
func WarmCatalog ¶
func WarmCatalog()
WarmCatalog triggers Catalog() at boot so any plugin whose factory violates the constructor contract (panics, allocates goroutines / connections / file handles) surfaces during startup rather than silently caching a faulty throwaway instance on the first /v1/plugins request. Cheap insurance — the result is already memoized, so calling this at boot moves "first call" out of the request hot path.
Intended for the binary's main() to invoke once after all plugin init() registrations have run (typically right before sessionapi.New).
Types ¶
type AccountingConsumer ¶
type AccountingConsumer interface {
SetAccounting(*accounting.Host)
}
AccountingConsumer is implemented by plugins that read the accountant's figures: the inference parser, which asks for a request's Result when it settles the cost; context-guru, which hands it its keep-alive pings; and session-budget, which counts those pings (Host.AddPingListener).
type CatalogEntry ¶
type CatalogEntry struct {
Name string
Capabilities pipeline.PluginCapabilities
Fields []pipeline.FieldSchema
}
CatalogEntry pairs a registered plugin's name with the capabilities it advertises and the field-level schema of its config (if it implements pipeline.SchemaProvider). Surfaces in `agentop`'s catalog pane, in the /v1/plugins endpoint, and in `agentop edit`'s template renderer so operators can see what plugins exist, what each one needs, and what each field means without reading source.
Fields is nil for plugins without a config (or that don't implement SchemaProvider) — the wire format omits the field via `omitempty`, so existing consumers that don't know about field schemas keep working.
func Catalog ¶
func Catalog() []CatalogEntry
Catalog returns a sorted snapshot of every registered plugin's capabilities. The result is computed on first call and cached; subsequent calls return the cached slice (do not mutate it).
First-call mechanics: each registered factory is invoked once with no config; the resulting instance's Capabilities() is the static type-level metadata that the rest of the framework also reads.
CONSTRUCTOR CONTRACT: factories called from Catalog MUST NOT allocate goroutines, network connections, file handles, or other resources that need explicit teardown. Allocate the plugin struct and nothing more — heavy work belongs in Init() (after Configure()), where the framework owns the lifecycle. The throwaway instance Catalog constructs is never Shutdown'd; anything it leaks is process-wide.
The godoc on PluginCapabilities documents the parallel constraint that Capabilities() must be instance-state-independent (so the cached snapshot from one instance describes every instance the factory produces).
type Deps ¶
type Deps struct {
// SPIFFE is injected into plugins implementing spiffe.ProviderConsumer.
SPIFFE *spiffe.Provider
// Pricing is injected into plugins implementing pricing.ResolverConsumer.
// Long-lived: the reloader rebuilds pipelines but the resolver is swapped in
// place, so a plugin from any build sees current rates. See pricing.Registry.
Pricing *pricing.Registry
// Store is injected into plugins implementing storage.StoreConsumer: the process's
// state that outlives it. Long-lived like Pricing: every build gets the same one,
// so state a plugin saves survives a reload as well as a restart.
Store storage.Store
// History is injected into plugins implementing session.HistoryConsumer: the
// session archive's events, for a process that keeps one.
History session.History
// Listener says which listener-dependent capabilities the listener this pipeline
// serves can honor; a plugin declaring one it cannot is refused. The zero value
// honors none of them, so a build that names no listener admits no such plugin.
Listener pipeline.ListenerSupport
// LocalInstall is true for a laptop proxy started from ~/.cortex, and is
// injected into plugins implementing LocalInstallConsumer. Only cmd/cortex sets
// it. The zero value is false, so a binary that has not decided is treated as a
// shared deployment, where a plugin that runs the user's own programs must not.
LocalInstall bool
// Accounting is the process's accountant host, nil when accounting is off. Set it on the
// OUTBOUND build only: inference requests leave through that chain. With it set, the
// pipeline is built with pipeline.WithAccountant, and it is injected into plugins
// implementing AccountingConsumer. Long-lived like Pricing: every build a reload makes gets
// the same Host, so its Tracker state survives the reload.
Accounting *accounting.Host
}
Deps are the process-wide dependencies a pipeline build can inject into plugins.
Plugin factories take no construction arguments (see PluginFactory), so anything shared across the process has to arrive this way. A struct rather than a growing parameter list: BuildWithSPIFFE existed because SPIFFE needed injecting, and adding pricing the same way would have meant a third near-identical builder.
Every field is optional. A zero Deps builds exactly what Build always did for every plugin that declares no listener-dependent capability (see pipeline.ListenerSupport).
type LocalInstallConsumer ¶
type LocalInstallConsumer interface {
SetLocalInstall(bool)
}
LocalInstallConsumer is implemented by plugins that behave differently on a local install. BuildWithDeps tells every such plugin, before Configure, whether this is one — false included, since false is the safe answer and must not depend on a plugin's zero value.
type PluginFactory ¶
PluginFactory returns a fresh plugin instance. Plugins take no construction arguments — they receive their configuration through pipeline.Configurable.Configure during Build, and any external dependencies (JWKS cache, HTTP client, etc.) are built from that local config inside Configure.
type StatsSource ¶
StatsSource is an optional interface a plugin implements when it maintains observability counters worth exposing on the /stats endpoint. Lives in the plugins package (rather than pipeline) because auth.Stats is the shared counter type and the pipeline package has no reason to depend on auth.
Plugins that don't report stats don't implement this interface; the host skips them during aggregation.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package all registers the bundled plugins for every binary that imports it.
|
Package all registers the bundled plugins for every binary that imports it. |
|
Package contextguru is an outbound AuthBridge plugin that compacts an agent's LLM request context before it is forwarded upstream, using the embedded github.com/rossoctl/context-guru engine.
|
Package contextguru is an outbound AuthBridge plugin that compacts an agent's LLM request context before it is forwarded upstream, using the embedded github.com/rossoctl/context-guru engine. |
|
Package cpex bridges AuthBridge requests through the CPEX (Context Plugin Execution) framework so operators can drive policy with CPEX's APL (Attribute Policy Language) DSL — or any of CPEX's built-in plugins (JWT identity, OAuth delegation, the Cedar, CEL and OPA decision points) — without writing Go code.
|
Package cpex bridges AuthBridge requests through the CPEX (Context Plugin Execution) framework so operators can drive policy with CPEX's APL (Attribute Policy Language) DSL — or any of CPEX's built-in plugins (JWT identity, OAuth delegation, the Cedar, CEL and OPA decision points) — without writing Go code. |
|
Package evolve connects Cortex to altk-evolve, a service that learns guidelines from agent trajectories (https://github.com/AgentToolkit/altk-evolve), using only the tools a stock `evolve-mcp --transport sse` server exposes.
|
Package evolve connects Cortex to altk-evolve, a service that learns guidelines from agent trajectories (https://github.com/AgentToolkit/altk-evolve), using only the tools a stock `evolve-mcp --transport sse` server exposes. |
|
Package ibac implements an Intent-Based Access Control plugin for authbridge.
|
Package ibac implements an Intent-Based Access Control plugin for authbridge. |
|
Package inferencerouter is the inference-router plugin: it sends a coding agent's new sessions to the inference server chosen for that agent, and keeps every session on the server it started on.
|
Package inferencerouter is the inference-router plugin: it sends a coding agent's new sessions to the inference server chosen for that agent, and keeps every session on the server it started on. |
|
routerconfig
Package routerconfig is the inference-router plugin's configuration: its shape, its validation, and the host rules the plugin routes by.
|
Package routerconfig is the inference-router plugin's configuration: its shape, its validation, and the host rules the plugin routes by. |
|
internal
|
|
|
hostmatch
Package hostmatch matches a request host against the bypass_hosts globs that ibac, sparc, cpex and lineage share.
|
Package hostmatch matches a request host against the bypass_hosts globs that ibac, sparc, cpex and lineage share. |
|
validation
Package validation provides JWT verification with JWKS-based key resolution.
|
Package validation provides JWT verification with JWKS-based key resolution. |
|
Package lineage provides the lineage-telemetry authbridge plugin.
|
Package lineage provides the lineage-telemetry authbridge plugin. |
|
Package litellm_budgettrack provides a pipeline plugin that tracks per-request cost and enforces a daily spending budget, rejecting requests with HTTP 429 when the budget is exceeded.
|
Package litellm_budgettrack provides a pipeline plugin that tracks per-request cost and enforces a daily spending budget, rejecting requests with HTTP 429 when the budget is exceeded. |
|
Package plugintesting exposes stub plugin adapters for listener tests that need to inject pre-built *auth.Auth instances (for example, with a mock verifier or a mock exchanger) without going through the real plugins' Configure path.
|
Package plugintesting exposes stub plugin adapters for listener tests that need to inject pre-built *auth.Auth instances (for example, with a mock verifier or a mock exchanger) without going through the real plugins' Configure path. |
|
Package script is the script plugin: it runs every executable file in a folder as a pipeline step, so a user can customize Cortex with a small Python or shell script instead of a Go plugin and a rebuild.
|
Package script is the script plugin: it runs every executable file in a folder as a pipeline step, so a user can customize Cortex with a small Python or shell script instead of a Go plugin and a rebuild. |
|
catalog
Package catalog is the script plugins Cortex ships: each folder under entries/ is one entry, which installed is one slot.
|
Package catalog is the script plugins Cortex ships: each folder under entries/ is one entry, which installed is one slot. |
|
internal/worker
Package worker runs one script as a long-lived child process and exchanges line-delimited JSON with it: one object per line on the child's stdin, one per line back on its stdout.
|
Package worker runs one script as a long-lived child process and exchanges line-delimited JSON with it: one object per line on the child's stdin, one per line back on its stdout. |
|
Package sessionbudget enforces per-session lifetime budgets on tokens, inference calls, and wall-clock duration.
|
Package sessionbudget enforces per-session lifetime budgets on tokens, inference calls, and wall-clock duration. |
|
Package sparc implements a pre-tool reflection plugin for authbridge.
|
Package sparc implements a pre-tool reflection plugin for authbridge. |
|
Package staticinject implements the static-inject outbound AuthBridge plugin: it swaps a placeholder credential on the outbound Authorization header for a real static credential, so a model-influenced workload never holds the real secret.
|
Package staticinject implements the static-inject outbound AuthBridge plugin: it swaps a placeholder credential on the outbound Authorization header for a real static credential, so a model-influenced workload never holds the real secret. |
|
client
Package client provides an HTTP client for the Token Broker service.
|
Package client provides an HTTP client for the Token Broker service. |
|
cache
Package cache provides a SHA-256 keyed token cache with TTL-based eviction.
|
Package cache provides a SHA-256 keyed token cache with TTL-based eviction. |
|
exchange
Package exchange implements RFC 8693 OAuth 2.0 Token Exchange and client credentials grant.
|
Package exchange implements RFC 8693 OAuth 2.0 Token Exchange and client credentials grant. |
|
Package tokenexchangeaiac is an outbound token-exchange plugin that needs no routes.
|
Package tokenexchangeaiac is an outbound token-exchange plugin that needs no routes. |
|
Package toolprune removes unused tool definitions from outbound inference requests.
|
Package toolprune removes unused tool definitions from outbound inference requests. |