model

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package model is CSF's contract with a brain: an agent loop over a large model behind an inference provider or API. The brain is external; CSF ships this contract and a deterministic stub (ipc/model/stub), and each provider lives in its own subpackage, ipc/model/<provider>, because reaching a model crosses a process or network boundary.

Given context, a brain proposes actions. A language model's proposal is not permission to execute it: admission, checks and execution belong to the caller.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoProposal = errors.New("brain proposed no action")

ErrNoProposal reports that a brain answered without proposing any action.

Functions

func AddressKey

func AddressKey(provider string, tier ipc.Tier, parts ...string) string

AddressKey builds an address key from the provider, the tier and the provider's own identifying parts, so two providers or two tiers can never produce the same key for the same session identifier.

Types

type AmbiguousProposalError

type AmbiguousProposalError struct {
	Provider string
	Count    int
}

AmbiguousProposalError reports more proposed actions than the caller can admit for one decision.

func (*AmbiguousProposalError) Error

func (failure *AmbiguousProposalError) Error() string

type HostTier

type HostTier struct{}

HostTier marks an address whose session runs in another process on the same machine, reached through an ipc capability (a unix socket, or loopback through ipc/net).

func (HostTier) Tier

func (HostTier) Tier() ipc.Tier

Tier is ipc.TierHost.

type IAgentAddress

type IAgentAddress interface {
	// Provider names the provider that owns this address type.
	Provider() string
	// Key identifies the session uniquely across providers and tiers. It is
	// the address's stable identity in registries, inboxes and logs.
	Key() string
	// Tier is how far a message to this address travels from the runtime
	// that holds the inbox.
	Tier() ipc.Tier
	// contains filtered or unexported methods
}

IAgentAddress is where one agent's live conversation session receives messages. Each provider declares its own address types beside its brain, under ipc/model/<provider>, because what identifies a session is the provider's to say: a Claude Code session is a session identifier plus the local socket it is reached on, a Copilot session is a session identifier reached through the Copilot provider.

The tier is part of the address's TYPE, not a field: every address type embeds exactly one of InProcessTier, HostTier or NetworkTier, and the interface is closed by an unexported method only those three markers carry. That makes it a sealed sum type over the three tiers: an address that a caller built as in-process cannot be routed through a socket, because no value of its type answers any other tier.

type IBrain

type IBrain[Context any, Action any] interface {
	// Propose returns the actions the brain proposes for decision. A proposal
	// is never permission to execute it.
	Propose(ctx context.Context, decision Context) (*Proposal[Action], error)
}

IBrain is an agent loop over a large model behind an inference provider. Context is the information supplied for one decision; Action is what the brain may propose. Both are type parameters, so a caller never holds an untyped value at this boundary.

type InProcessTier

type InProcessTier struct{}

InProcessTier marks an address whose session runs in the same runtime: a direct call or a channel reaches it, with no capability.

func (InProcessTier) Tier

func (InProcessTier) Tier() ipc.Tier

Tier is ipc.TierInProcess.

type NetworkTier

type NetworkTier struct{}

NetworkTier marks an address whose session runs on another machine, reached through ipc/net.

func (NetworkTier) Tier

func (NetworkTier) Tier() ipc.Tier

Tier is ipc.TierNetwork.

type Proposal

type Proposal[Action any] struct {
	// Provider names the inference provider that produced the proposal.
	Provider string
	// Actions are the proposed actions in the order the brain gave them.
	Actions []Action
}

Proposal is a brain's answer for one decision. It is data, not an authorization: the caller decides whether any action is admitted.

func (*Proposal[Action]) Only

func (proposal *Proposal[Action]) Only() (Action, error)

Only returns the single action of a proposal that must contain exactly one.

Directories

Path Synopsis
Package claudecode is the Claude Code provider: a Claude Code session is an agent loop in its own process on the operator's machine.
Package claudecode is the Claude Code provider: a Claude Code session is an agent loop in its own process on the operator's machine.
Package copilot is the first inference provider behind CSF's brain contract: the GitHub Copilot agent loop, reached through the existing Copilot adapter's generated Workbench client (services/copilot-adapter/gen/api).
Package copilot is the first inference provider behind CSF's brain contract: the GitHub Copilot agent loop, reached through the existing Copilot adapter's generated Workbench client (services/copilot-adapter/gen/api).
Package stub is the brain that needs no model: it answers every decision with the same canned proposal, so the harness runs and its specs pass with no inference provider, network or credential at all.
Package stub is the brain that needs no model: it answers every decision with the same canned proposal, so the harness runs and its specs pass with no inference provider, network or credential at all.

Jump to

Keyboard shortcuts

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