cognition

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: Apache-2.0 Imports: 25 Imported by: 1 module, 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 cognition implements graph-native model execution over the repository's provider-neutral continuation API.

A TextModel samples an immutable trajectory snapshot when an explicit generation trigger is admitted. It emits prepared data only: this package neither appends to the canonical trajectory nor grants speech or tool execution authority. Those decisions remain visible graph topology.

Index

Constants

View Source
const (
	// ProviderRegistryService contains deployment-selected continuation
	// providers. Provider selection is a node value, not topology syntax.
	ProviderRegistryService = "cognition.continuation.providers"
	// MediaResolverService optionally resolves media handles referenced by a
	// sampled trajectory for multimodal continuation adapters.
	MediaResolverService = "cognition.media.resolver"
)

Variables

This section is empty.

Functions

func CancelType

func CancelType() element.Type

func ContextType

func ContextType() element.Type

Public type helpers let graph-boundary adapters construct exact envelopes without exporting mutable package-level Type values.

func Descriptors

func Descriptors() []element.Descriptor

func FactoryRegistrations

func FactoryRegistrations() ([]graphruntime.FactoryRegistration, error)

func GenerateType

func GenerateType() element.Type

func OutcomeType

func OutcomeType() element.Type

func PreparedTextType

func PreparedTextType() element.Type

func ProviderResolutionType

func ProviderResolutionType() element.Type

func RegisterDescriptors

func RegisterDescriptors(catalog *resolve.Catalog) error

func RegisterFactories

func RegisterFactories(registry *graphruntime.Registry) error

func ResultType

func ResultType() element.Type

func TextModelDescriptor

func TextModelDescriptor() element.Descriptor

TextModelDescriptor makes state sampling, activation, cancellation, and all terminal/data paths independently inspectable. MaxConcurrency is one per node; parallel fast and deliberative work is expressed by separate nodes.

func ToolProposalType

func ToolProposalType() element.Type

Types

type Cancel

type Cancel struct {
	RunID  string `json:"run_id,omitempty"`
	Reason string `json:"reason,omitempty"`
}

Cancel is an addressed control request. RunID may be omitted when the envelope's RunID or cancellation scope supplies the address.

type Generate

type Generate struct {
	Invocation continuation.Invocation `json:"invocation"`
	// SpokeOver records that policy deliberately authorized this run while the
	// user was still speaking. It is carried through prepared text into speech
	// provenance; it does not itself grant playback authority.
	SpokeOver bool `json:"spoke_over,omitempty"`
	// ExpectedContextVersion distinguishes an unconstrained trigger (nil)
	// from one explicitly bound to the empty trajectory (pointer to zero).
	ExpectedContextVersion *uint64 `json:"expected_context_version,omitempty"`
	// ExpectedContextItemID optionally binds the version to the exact State
	// envelope that released the policy trigger. This prevents two independently
	// wired state sources from satisfying the same numeric version with different
	// prefixes. A generation policy should set both fields from one sampled edge.
	ExpectedContextItemID string `json:"expected_context_item_id,omitempty"`
	// CommittedContext is the compact, commit-bound identity of an immutable
	// trajectory prefix. When present, both legacy expected-context fields are
	// required to agree exactly with it. This lets a model reconstruct that
	// prefix from a later append-only State value without accepting an unrelated
	// or replayed activation.
	CommittedContext *stateelements.CommittedContext `json:"committed_context,omitempty"`
}

Generate opens one model run. Invocation is the established provider-neutral request contract. ExpectedContextVersion is optional but lets a policy bind a trigger to one exact sampled prefix instead of accepting a newer state.

func (Generate) InspectionCause

func (Generate) InspectionCause() element.InspectionCauseKind

InspectionCause records the explicit activation policy that opened the model run; result and stream payloads below identify the run itself.

type Outcome

type Outcome struct {
	Kind              OutcomeKind `json:"kind"`
	Operation         string      `json:"operation"`
	RunID             string      `json:"run_id,omitempty"`
	ProviderReference string      `json:"provider_reference,omitempty"`
	ContextVersion    uint64      `json:"context_version,omitempty"`
	Code              string      `json:"code,omitempty"`
	Message           string      `json:"message,omitempty"`
	StartedNS         uint64      `json:"started_ns,omitempty"`
	FinishedNS        uint64      `json:"finished_ns,omitempty"`
	DurationNS        uint64      `json:"duration_ns,omitempty"`
}

Outcome is the closed terminal control result for generation and interrupt requests. Latency is empirical runtime evidence, not part of port typing.

func (Outcome) InspectionCause

func (Outcome) InspectionCause() element.InspectionCauseKind

type OutcomeKind

type OutcomeKind string
const (
	OutcomeSucceeded OutcomeKind = "succeeded"
	OutcomeCanceled  OutcomeKind = "canceled"
	OutcomeRefused   OutcomeKind = "refused"
	OutcomeFailed    OutcomeKind = "failed"
	OutcomeIgnored   OutcomeKind = "ignored"
)

type PreparedOutput

type PreparedOutput struct {
	Kind     PreparedOutputKind `json:"kind"`
	Text     string             `json:"text,omitempty"`
	Proposal *ToolProposal      `json:"proposal,omitempty"`
}

PreparedOutput retains provider order for a later, explicit trajectory commit adapter. Adjacent text deltas of the same kind are coalesced.

type PreparedOutputKind

type PreparedOutputKind string

PreparedOutputKind identifies one ordered, uncommitted model-output segment.

const (
	PreparedReasoning PreparedOutputKind = "reasoning"
	PreparedAssistant PreparedOutputKind = "assistant"
	PreparedTool      PreparedOutputKind = "tool_proposal"
)

type PreparedTextDelta

type PreparedTextDelta struct {
	Boundary    TextBoundary `json:"boundary"`
	Text        string       `json:"text,omitempty"`
	Index       uint64       `json:"index"`
	Interrupted bool         `json:"interrupted,omitempty"`
	SpokeOver   bool         `json:"spoke_over,omitempty"`
}

PreparedTextDelta is prepared model output. The distinct port payload type prevents a generic committed-text sink from accepting it without an explicit policy/commit element.

func (PreparedTextDelta) InspectionCause

func (PreparedTextDelta) InspectionCause() element.InspectionCauseKind

type ProviderFactory

type ProviderFactory func() (continuation.Provider, error)

type ProviderRegistry

type ProviderRegistry struct {
	// contains filtered or unexported fields
}

ProviderRegistry is immutable-by-registration deployment state. Multiple TextModel nodes may independently select distinct symbolic providers.

func NewProviderRegistry

func NewProviderRegistry() *ProviderRegistry

func (*ProviderRegistry) Register

func (registry *ProviderRegistry) Register(
	reference string, descriptor continuation.Descriptor, factory ProviderFactory,
) error

type ProviderResolution

type ProviderResolution struct {
	Reference        string                  `json:"reference"`
	Descriptor       continuation.Descriptor `json:"descriptor"`
	DescriptorDigest string                  `json:"descriptor_digest"`
	RegistryRevision uint64                  `json:"registry_revision"`
}

ProviderResolution is live startup evidence. DescriptorDigest covers the exact descriptor returned by the created provider instance; RegistryRevision identifies the deployment service revision from which it was resolved.

type Result

type Result struct {
	RunID             string                  `json:"run_id"`
	ProviderReference string                  `json:"provider_reference"`
	Descriptor        continuation.Descriptor `json:"descriptor"`
	ContextVersion    uint64                  `json:"context_version"`
	ContextTailID     string                  `json:"context_tail_id,omitempty"`
	// ContextPrefix binds the immutable input independently of later appends.
	// It is provenance for retaining speech history, never fresh action authority.
	ContextPrefix trajectory.PrefixIdentity `json:"context_prefix,omitzero"`
	Invocation    continuation.Invocation   `json:"invocation"`
	Outputs       []PreparedOutput          `json:"outputs,omitempty"`
	AssistantText string                    `json:"assistant_text,omitempty"`
	ReasoningText string                    `json:"reasoning_text,omitempty"`
	// ReasoningRetained attests that every textual reasoning delta emitted by
	// the provider is present in Outputs and ReasoningText. False is the
	// fail-closed default: an opaque native provider state can then contain
	// model-authored text that no downstream content boundary was able to
	// inspect.
	ReasoningRetained bool                    `json:"reasoning_retained,omitempty"`
	ToolProposals     []ToolProposal          `json:"tool_proposals,omitempty"`
	Completion        continuation.Completion `json:"completion"`
	Interrupted       bool                    `json:"interrupted,omitempty"`
}

Result is the complete prepared artifact for one accepted run. It includes enough provenance for a separate compare-and-append adapter and deliberately contains no claim that anything was committed, spoken, or executed.

func (Result) InspectionCause

func (Result) InspectionCause() element.InspectionCauseKind

type TextBoundary

type TextBoundary string

TextBoundary frames a prepared text stream. An end is emitted after every opened stream, including failed or canceled runs, so stream-aware arbiters can always release the run.

const (
	TextBegin TextBoundary = "begin"
	TextChunk TextBoundary = "delta"
	TextEnd   TextBoundary = "end"
)

type TextModelConfig

type TextModelConfig struct {
	Provider         string `json:"provider"`
	RetainReasoning  bool   `json:"retain_reasoning,omitempty"`
	MaxOutputBytes   int    `json:"max_output_bytes,omitempty"`
	MaxEvents        int    `json:"max_events,omitempty"`
	MaxToolProposals int    `json:"max_tool_proposals,omitempty"`
}

TextModelConfig selects one symbolic deployment registration. Endpoint, credential, model, and adapter settings belong to that provider deployment, not to graph topology.

type ToolProposal

type ToolProposal struct {
	Call              trajectory.ToolCall        `json:"call"`
	Declared          bool                       `json:"declared"`
	ProviderAuthority continuation.ToolAuthority `json:"provider_authority"`
}

ToolProposal is structured model output without execution authority. Even a legacy provider descriptor that says "execute" produces only this type; authorization and dispatch require explicit downstream elements.

func (ToolProposal) InspectionCause

func (ToolProposal) InspectionCause() element.InspectionCauseKind

Jump to

Keyboard shortcuts

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