oracle

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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. Until the provider adapter intent (itd-2609081951381895) implements Connections, NoConnections is the only implementation, so every row resolves to the harness.

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 and the provider allowlist wait on the implement loop's state file and the API adapter, and are the spec's remainder; until the adapter implements Connections, every step resolves to the harness.

Index

Constants

View Source
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.

View Source
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).

View Source
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 Ceiling

func Ceiling(agent string) (int, bool)

Ceiling returns the agent contract's fan-out ceiling; ok is false for a name outside the roster.

func ModelReported

func ModelReported(payload []byte) string

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.

func Roster

func Roster() []string

Roster returns every agent the proposal names, sorted: the runtime roster a table's rows are checked against.

Types

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 Connection

type Connection struct {
	Name     string
	Defaults Settings
}

Connection is one provider connection configured on this machine, with the sampling settings it sends by default.

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 FlagRoute

type FlagRoute struct {
	Agent      string
	Row        Row
	Connection string
	Text       string
}

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

func Load(r layered.Roots) (*Layered, error)

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

func (l *Layered) Accepted() bool

Accepted reports whether a routing table exists at the repository or the machine layer, the condition under which any row applies.

func (*Layered) Apply

func (l *Layered) Apply(routes []FlagRoute) error

Apply places parsed routes in the flag layer, where they win over every accepted table for this invocation.

func (*Layered) Board

func (l *Layered) Board() ([]BoardRow, error)

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.

func (*Layered) Rows

func (l *Layered) Rows(agent string) ([]LayerRow, error)

Rows returns every layer's row for agent, highest precedence first, with the bundled proposal last. Whether the bundled row applies is Resolve's answer (it does only once a table is accepted); Rows lists it regardless, so the board can show what an acceptance would change.

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 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"`
}

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".

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 Table

type Table map[string]Row

Table maps an agent's name to its row.

func Proposal

func Proposal() Table

Proposal returns the bundled table: one row per agent, its tier and its fan-out at the contract ceiling. The map is a copy.

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"
)

func ParseTier

func ParseTier(s string) (Tier, error)

ParseTier admits exactly a member of the vocabulary, spelled as it is.

func Tiers

func Tiers() []Tier

Tiers returns the closed tier vocabulary.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL