Documentation
¶
Overview ¶
Package oracle is the model-tier routing of itd-2609170822093401: which tier of model each host-delegated agent deserves, how many agents a step may run at once, and, at run time, whether a configured provider takes the step or the harness does.
The table has one row per agent (a tier from a closed set, a fan-out bound, provider settings) and four layers, resolved through the shared layered configuration resolver (internal/core/layered): an invocation --route over the repository's .abcd/config/oracle-routing.json over the machine's ~/.abcd/oracle-routing.json over the bundled proposal. Nothing is applied until a table is accepted: with neither file present every agent resolves to the harness at host-decides, and the bundled proposal is what an accepted table falls back to for an agent it has no row for.
The resolver never writes, never reaches a network and never prints. It takes the machine's connections as a value (Connections), so a test hands it a provider that is "reachable" without a socket. The provider adapter (itd-2609081951381895, config.go) implements Connections from the machine's provider blocks, each connection carrying its allowlist and the settings its adapter accepts; the delegating verbs still hand every resolution NoConnections, so every row resolves to the harness until provider dispatch lands (spc-2609251028149555).
Staged, loudly (the loud-staging rule): spc-2609180535002478 lands the types, the proposal and its roster test, the store readers, the --route parser, Resolve, the bare board's oracle lines, the request block and receipt every delegating verb carries (Route.Request, Route.Receipt), and the ahoy consent step that writes an accepted table. Escalating a tier after a failed fix round, the allowlist check inside Resolve and dispatching a step to a provider are spc-2609251028149555's; until they land, every step resolves to the harness.
Index ¶
- Constants
- func BundledDenylist() []string
- func Ceiling(agent string) (int, bool)
- func KeyHomes() []string
- func ModelReported(payload []byte) string
- func RenderRequestSection(rr RequestRouting) string
- func Roster() []string
- type APIConfig
- func (c *APIConfig) Admit(provider, model string) error
- func (c *APIConfig) Call(ctx context.Context, creds credential.Source, req CallRequest, ...) ([]byte, CallRecord, error)
- func (c *APIConfig) Connections() Connections
- func (c *APIConfig) Denylist() []DenyEntry
- func (c *APIConfig) Judgement(kind string) (Target, bool)
- func (c *APIConfig) Provider(name string) (Provider, bool)
- func (c *APIConfig) Providers() []Provider
- func (c *APIConfig) Role(agent string) (Target, bool)
- func (c *APIConfig) Routes() []PointedRoute
- type BoardLayer
- type BoardRow
- type CallRecord
- type CallRequest
- type ConnectRequest
- type ConnectResult
- type Connection
- type Connections
- type DenyEntry
- type FlagRoute
- type LayerRow
- type Layered
- type NoConnections
- type PointedRoute
- type Provider
- type ReceiptRoute
- type RequestRouting
- type Route
- type Row
- type Settings
- type Table
- type Target
- type Tier
Constants ¶
const ( // MaxProviders bounds the provider blocks one machine declares. MaxProviders = 16 // MaxModels bounds one provider's allowlist. MaxModels = 64 // MaxDenylist bounds the entries one layer adds to the denylist. MaxDenylist = 64 )
Bounds on what the configuration may carry.
const ( // KeyHomeExternal is a setup outside abcd (an environment variable or an // existing tool's configuration); abcd would store only its name. KeyHomeExternal = "external" // KeyHomeABCD is abcd-only: the owner-only ~/.abcd/credentials.json. KeyHomeABCD = "abcd" // KeyHomeKeychain is the platform keychain. KeyHomeKeychain = "keychain" // KeyHomeNone is a server that takes no key (a local one). KeyHomeNone = "none" )
The homes a provider's key may live in (the intent's Decision 4).
const ( // MaxSettingBytes bounds one setting's value, as JSON. MaxSettingBytes = 256 // MaxSettings bounds how many settings one row or one --route carries. MaxSettings = 16 // MaxRouteBytes bounds one --route's text, which a receipt carries verbatim. MaxRouteBytes = 1024 // MaxModelBytes bounds the model a payload reports, in a receipt. MaxModelBytes = 200 )
Bounds on what a routing file or a --route may carry, enforced where the value is read (review-tier1 F6): everything that reaches a request block or a receipt has already passed them, so the receipt records settings as sent, whole, and never a truncation of them.
const AdapterExplanation = "An aggregator (OpenRouter, for one) serves many vendors' models behind one " +
"OpenAI-compatible address and one key, and a local OpenAI-compatible server is reached the same way. " +
"abcd would use one for decision models and cheap judgements pointed at it by name, and never for a frontier " +
"model, which the vendor denylist keeps on the host. Everything works without one: with no provider configured, " +
"every delegated step runs on the host."
AdapterExplanation is what the adapter is, what abcd would use it for and what works without it (criterion 6), in the words every surface uses: the ahoy gap, `abcd ahoy --providers` and the plugin page.
const CredentialStoreIntent = "itd-2609221017023290"
CredentialStoreIntent is the intent that builds the external and keychain homes, named by every deferral.
const Harness = "harness"
Harness is the connection name of the harness leg: the host's own sub-agent dispatch, which owns model choice, credentials and execution (adr-25).
const KeyHomesProse = "Where the key lives is your choice of three. The platform keychain is the safest home, " + "because the secret stays in the operating system's own store rather than in a file. A setup outside abcd " + "keeps it with a tool you already use, and abcd stores only its name. The abcd-only home keeps it in " + "~/.abcd/credentials.json, readable by you alone. This version stores a key in the abcd-only home; the other " + "two arrive with the credential store (" + CredentialStoreIntent + "). The key never enters the harness's " + "settings or the repository."
KeyHomesProse is the prose above the choice of the key's home (criterion 8): the keychain is recommended here, in the prose, and never as a marked option.
const RouteSyntax = "<agent>=<tier>[@<connection>][?k=v,...]"
RouteSyntax is the --route flag's grammar, as every refusal names it.
Variables ¶
This section is empty.
Functions ¶
func BundledDenylist ¶ added in v0.11.1
func BundledDenylist() []string
BundledDenylist returns the denylist abcd ships. The slice is a copy.
func Ceiling ¶
Ceiling returns the agent contract's fan-out ceiling; ok is false for a name outside the roster.
func KeyHomes ¶ added in v0.11.1
func KeyHomes() []string
KeyHomes returns the homes in the order the setup offers them.
func ModelReported ¶
ModelReported returns the model a payload names: its top-level "model" string, else a reading's "instrument.model". A payload that names none, or is not a JSON object, reports "". The value is untrusted, so it is bounded to MaxModelBytes and its hidden runes are percent-encoded: recorded, never able to reorder or escape the receipt it lands in.
func RenderRequestSection ¶
func RenderRequestSection(rr RequestRouting) string
RenderRequestSection renders the routing section a request document carries, as indented key: value lines under "routing:". Every value is sanitised: the document is read by the host, and a value a file or a flag supplied must not carry a terminal escape or a reordering rune into it.
Types ¶
type APIConfig ¶ added in v0.11.1
type APIConfig struct {
// Diagnostics are the non-fatal reports the read produced, one line each,
// for a front door to print on stderr: a route naming a provider this
// machine has not configured, and a role outside the roster.
Diagnostics []string
// contains filtered or unexported fields
}
APIConfig is the adapter configuration one invocation read.
func LoadAPI ¶ added in v0.11.1
LoadAPI reads the provider configuration through the layered resolver and validates all of it. A fault is an error naming the file and the key; none falls through to a default.
func (*APIConfig) Admit ¶ added in v0.11.1
Admit is the refusal adr-2609221009491186 names: it returns nil only when provider is configured, model is on its list, and no denylist entry matches the model. It is consulted when the configuration is read and again by any dispatch, so a route never reaches a provider on a stale answer.
func (*APIConfig) Call ¶ added in v0.11.1
func (c *APIConfig) Call(ctx context.Context, creds credential.Source, req CallRequest, opts ...openaiapi.Option) ([]byte, CallRecord, error)
Call sends req through its target's provider and returns the answer the contract admitted and the call's record. It refuses before any call a target the configuration does not admit (Admit, again, so a target built anywhere but the read is held to the same rule) and a named key that resolves to nothing, because an unauthenticated call is never made. An answer whose reported model the denylist refuses is discarded: the provider substituted a frontier model, and the refusal names what it reported.
func (*APIConfig) Connections ¶ added in v0.11.1
func (c *APIConfig) Connections() Connections
Connections returns the machine's provider connections, the implementation of Connections this configuration backs. A provider claims no tier: it is reached by a role or a judgement type pointed at it, or by a --route naming it, never by a tier alone, so Serves answers false for every tier and the tier-only steps stay on the harness. Named returns the provider's connection carrying its allowlist and the settings the adapter accepts.
func (*APIConfig) Denylist ¶ added in v0.11.1
Denylist returns the denylist in force: the bundled entries, then the machine's, then the repository's.
func (*APIConfig) Judgement ¶ added in v0.11.1
Judgement returns where a judgement type is pointed, if it is.
func (*APIConfig) Providers ¶ added in v0.11.1
Providers returns the configured providers, sorted by name.
func (*APIConfig) Routes ¶ added in v0.11.1
func (c *APIConfig) Routes() []PointedRoute
Routes returns every role and judgement type pointed at a provider, roles first, each family sorted by name.
type BoardLayer ¶
type BoardLayer struct {
Layer string `json:"layer"`
Origin string `json:"origin"`
Tier Tier `json:"tier"`
FanOut int `json:"fan_out"`
}
BoardLayer is one layer's row for an agent, as the bare board shows it.
type BoardRow ¶
type BoardRow struct {
Agent string `json:"agent"`
Winner string `json:"winner"`
Layers []BoardLayer `json:"layers"`
}
BoardRow is one agent's routing on the bare board: every layer holding a row, highest precedence first, and the layer whose row applies.
type CallRecord ¶ added in v0.11.1
type CallRecord struct {
Provider string `json:"provider"`
ModelAsked string `json:"model_asked"`
ModelReported string `json:"model_reported"`
}
CallRecord is the per-call record the run record carries (criterion 5, adr-2609221009491186 Decision 5): the provider, the model asked for and the model the provider reported, side by side, so a substitution is visible. It never carries a key, a key's name or the brief.
type CallRequest ¶ added in v0.11.1
type CallRequest struct {
Target Target
Brief openaiapi.Brief
Settings Settings
// Contract is the output contract the host sub-agent's payload is judged
// by; nil admits any answer.
Contract func([]byte) error
}
CallRequest is one call: where it goes, the brief, the settings as sent and the output contract the answer is judged by.
type ConnectRequest ¶ added in v0.11.1
type ConnectRequest struct {
// Roots are where the configuration in force is read: the denylist a
// model is held to, and the provider blocks a name must not repeat. The
// writes land under Roots.Home alone.
Roots layered.Roots
Provider string
BaseURL string
// Models is the first allowlist; the verification call asks for the first.
Models []string
// Home is where the key lives: one of KeyHomes.
Home string
// KeyName is the credential's name; "" names it after the provider.
KeyName string
// Key is the value, for the abcd home. It is never echoed.
Key string
// Timeout bounds the verification call; 0 keeps the adapter's default.
Timeout time.Duration
}
ConnectRequest is one provider's setup.
type ConnectResult ¶ added in v0.11.1
type ConnectResult struct {
Provider string `json:"provider"`
BaseURL string `json:"base_url"`
Models []string `json:"models"`
KeyHome string `json:"key_home"`
KeyName string `json:"key_name,omitempty"`
// Verified is the verification call's record.
Verified CallRecord `json:"verified"`
// Wrote names each file written, in the tilde form.
Wrote []string `json:"wrote"`
}
ConnectResult is what the setup did. It never carries the key.
func Connect ¶ added in v0.11.1
func Connect(ctx context.Context, req ConnectRequest) (ConnectResult, error)
Connect verifies the connection with one call and, only when it succeeds, writes the key and the provider block. Every fault the configuration read would refuse is refused first, before the call.
type Connection ¶
type Connection struct {
Name string
Defaults Settings
// Models is the provider's allowlist (adr-2609221009491186): the only
// models it may serve, every one already cleared against the vendor
// denylist when the configuration was read. nil on a connection no
// provider block backs.
Models []string
// Accepts is the settings the connection's adapter accepts; a setting
// outside it is refused before a step runs, never dropped
// (spc-2609251028149555, AC 8). nil on a connection no adapter backs.
Accepts []string
}
Connection is one provider connection configured on this machine, with the sampling settings it sends by default.
func (Connection) Accepted ¶ added in v0.11.1
func (c Connection) Accepted(key string) bool
Accepted reports whether the connection's adapter accepts setting key.
func (Connection) Admits ¶ added in v0.11.1
func (c Connection) Admits(model string) bool
Admits reports whether model is on the connection's allowlist.
type Connections ¶
type Connections interface {
// Serves returns a configured connection that is reachable and can serve
// the tier, if there is one.
Serves(t Tier) (Connection, bool)
// Named returns the configured connection of that name, if there is one.
Named(name string) (Connection, bool)
}
Connections is the machine's configured provider connections. The provider adapter intent (itd-2609081951381895) implements it; this package only consumes it, so it never configures, probes or reaches a provider itself.
type DenyEntry ¶ added in v0.11.1
DenyEntry is one denylist entry and the layer that added it.
type FlagRoute ¶
FlagRoute is one parsed --route: a row for one agent for this invocation alone, the connection it names (if any), and the flag text verbatim.
func ParseRoutes ¶
func ParseRoutes(texts, dispatched []string, conns Connections) ([]FlagRoute, error)
ParseRoutes parses every --route value and refuses, before any step runs, a value that is malformed, names an agent this invocation does not dispatch (one outside the roster included), names a tier outside the vocabulary, names a connection not configured on this machine, carries a malformed setting, or repeats an agent. dispatched is the set of agents this invocation dispatches, which for every delegating verb is one agent, so a second --route naming another agent is refused rather than merged (the 2026-09-25 ruling on AC 7 in .abcd/work/DECISIONS.md).
type LayerRow ¶
type LayerRow struct {
Layer layered.Layer
Origin string
Row Row
// Connection is the connection a --route named (flag layer only).
Connection string
}
LayerRow is one layer's row for an agent, as a board renders it.
type Layered ¶
type Layered struct {
// Diagnostics are the non-fatal reports a read produced, one line each,
// for the front door to print on stderr before any step runs: an orphan
// row (named, skipped, the rest apply) and a fan-out clamped to the
// contract ceiling.
Diagnostics []string
// contains filtered or unexported fields
}
Layered is the routing table's four layers for one invocation.
func Load ¶
Load reads the repository and machine routing files through the layered resolver and validates every row in them. A malformed file or row is an error naming the file; an orphan row and a clamped fan-out are Diagnostics.
func (*Layered) Accepted ¶
Accepted reports whether a routing table exists at the repository or the machine layer, the condition under which any row applies.
func (*Layered) Apply ¶
Apply places parsed routes in the flag layer, where they win over every accepted table for this invocation.
func (*Layered) Board ¶
Board returns one row per agent in the roster, or nil when nothing is accepted (the board is then unchanged: every step runs through the harness at host-decides, which is what the board already implies). The winner is Resolve's own Source, so the board and a step can never disagree.
type NoConnections ¶
type NoConnections struct{}
NoConnections is a machine with no provider configured, and the only implementation until the adapter intent lands: every step goes to the harness, whatever its row says.
func (NoConnections) Named ¶
func (NoConnections) Named(string) (Connection, bool)
Named reports that no connection of any name is configured.
func (NoConnections) Serves ¶
func (NoConnections) Serves(Tier) (Connection, bool)
Serves reports that nothing serves any tier.
type PointedRoute ¶ added in v0.11.1
type PointedRoute struct {
Kind string `json:"kind"`
Name string `json:"name"`
Target Target `json:"target"`
}
PointedRoute is one role or judgement type and its target, for a board.
type Provider ¶ added in v0.11.1
type Provider struct {
Name string `json:"name"`
BaseURL string `json:"base_url"`
Key string `json:"key,omitempty"`
Models []string `json:"models"`
Origin string `json:"origin"`
}
Provider is one configured provider block.
type ReceiptRoute ¶
type ReceiptRoute struct {
Agent string `json:"agent"`
TierAsked Tier `json:"tier_asked"`
ConnectionTried string `json:"connection_tried"`
ConnectionUsed string `json:"connection_used"`
FallbackReason string `json:"fallback_reason"`
Override string `json:"override"`
SettingsSent Settings `json:"settings_sent"`
// ModelReported is the payload's own model field, "" when it names none
// (requiring it is itd-2609180517121254's).
ModelReported string `json:"model_reported"`
// ProviderCall is the call through a provider adapter that produced the
// payload: the provider, the model asked for and the model the provider
// reported (itd-2609081951381895 criterion 5). null on the harness leg.
ProviderCall *CallRecord `json:"provider_call"`
}
ReceiptRoute is the receipt's route block (AC 4, 5, 7, 8): what was asked, which connection was tried and which used, why a step fell back, the override verbatim, the settings as sent, and the model the payload reported, side by side. Every field is always present, so a reader tells "none" from "not recorded".
func (ReceiptRoute) WithCall ¶ added in v0.11.1
func (rr ReceiptRoute) WithCall(c CallRecord) ReceiptRoute
WithCall returns the receipt carrying the provider call that produced its payload.
type RequestRouting ¶
type RequestRouting struct {
Agent string `json:"agent"`
Tier Tier `json:"tier"`
FanOut int `json:"fan_out"`
// Source is the deciding layer: flag, repo, machine, bundled, or none.
Source string `json:"source"`
// Origin names that layer's file, the flag text, "bundled" or "none".
Origin string `json:"origin"`
// Override is the --route text verbatim when one governed the step.
Override string `json:"override,omitempty"`
// Connection is the leg: a provider connection's name, or harness.
Connection string `json:"connection"`
// Fallback is why a tier that asked for a provider went to the harness.
Fallback string `json:"fallback,omitempty"`
}
RequestRouting is the request block's routing section for the one agent a step dispatches: the tier and fan-out bound the host is asked to honour, the layer that decided them, and the leg the step goes to (AC 1, AC 4).
type Route ¶
type Route struct {
Agent string
// Row is the winning row, the flag's overrides applied and the fan-out
// clamped to the contract ceiling.
Row Row
// Source is the layer the row came from: flag, repo, machine, bundled, or
// none when nothing is accepted.
Source layered.Layer
// Origin names that layer's file, the flag text, "bundled" or "none".
Origin string
// Override is the --route text verbatim when a flag governed the step, so
// a measurement run is never mistaken for accepted routing.
Override string
// ConnectionTried is the provider connection the step was offered to; ""
// when none was (host-decides, or no connection serves the tier).
ConnectionTried string
// ConnectionUsed is the provider connection that takes the step, or
// Harness.
ConnectionUsed string
// Fallback is why a step whose tier asked for a provider went to the
// harness; "" when it did not fall back. The front door prints it on
// stderr before the step runs.
Fallback string
// SettingsSent is the provider leg's settings: the connection's defaults,
// then the row's, then the flag's. nil on the harness leg.
SettingsSent Settings
}
Route is one agent's resolved routing for one step: what the request block carries and what the receipt records.
func Resolve ¶
func Resolve(agent string, l *Layered, conns Connections) (Route, error)
Resolve returns agent's route: the flag's row over the repository's over the machine's over the bundled proposal (the last only once a table is accepted), resolved against conns. It consults conns only for a tier that asks for a provider or a connection a --route named.
func (Route) Receipt ¶
func (r Route) Receipt(model string) ReceiptRoute
Receipt returns the route's receipt block, with the model the payload reported (ModelReported's answer).
func (Route) Request ¶
func (r Route) Request() RequestRouting
Request returns the route's request-block section.
type Row ¶
type Row struct {
Tier Tier `json:"tier"`
// FanOut is the most agents one step may run at once, itself included. It
// may tighten the agent contract's ceiling and never raise it; 0 in a file
// means "not stated", which resolves to the ceiling.
FanOut int `json:"fan_out,omitempty"`
Settings Settings `json:"settings,omitempty"`
}
Row is one agent's routing row.
type Settings ¶
type Settings map[string]json.RawMessage
Settings are provider sampling settings (temperature, seed, and whatever else a provider accepts), each a JSON scalar kept as its raw bytes so a number reaches the provider and the receipt exactly as written. Which keys a provider accepts is its adapter's judgement (itd-2609081951381895), never this package's: a key is shape-checked here and passed through.
type Target ¶ added in v0.11.1
type Target struct {
Provider string `json:"provider"`
Model string `json:"model"`
// Origin names the file the route came from.
Origin string `json:"origin"`
}
Target is where a role or a judgement type is pointed: a configured provider and a model on its list.
type Tier ¶
type Tier string
Tier is a model tier: a class of model that survives model churn, not a model name.
const ( // Local: a model on this machine, for material that must not leave it. Local Tier = "local" // Economy: a cheap cloud model, for plumbing no human reads as a verdict. Economy Tier = "economy" // Frontier: the strongest model, for verdicts a human reads and acts on. Frontier Tier = "frontier" // HostDecides: no tier asked; the harness picks. The floor every step // stands on when nothing is accepted. HostDecides Tier = "host-decides" )