goalflow

package
v0.1.7 Latest Latest
Warning

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

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

Documentation

Overview

Package goalflow binds the neutral Goal policy to bounded Coding evidence. It owns neither a work driver nor a scheduler; Runtime supplies both admission and explicit notification delivery.

Index

Constants

View Source
const (
	MaxRecords       = 32
	MaxResultBytes   = 4096
	MaxEvidenceBytes = 192 << 10
	MaxGaps          = 16
)

Evidence payload bounds are independent of provider context limits.

Variables

This section is empty.

Functions

func Bound

func Bound(text string, maximum int) string

Bound caps UTF-8 text without cutting a code point.

func CanonicalArguments

func CanonicalArguments(data ai.JSON) ai.JSON

CanonicalArguments normalizes object ordering for evidence identity.

func DecodeStrict

func DecodeStrict(data ai.JSON, value any) error

DecodeStrict rejects unknown fields, trailing values and oversized payloads.

func Digest

func Digest(text string) string

Digest identifies the complete observed result, before truncation.

func Encode

func Encode(value any) (ai.JSON, error)

Encode enforces the persisted policy payload bound.

func PartsText

func PartsText(parts []ai.Part) string

PartsText extracts the textual channel from an actual tool result.

func ValidUsage

func ValidUsage(usage ai.Usage) bool

ValidUsage rejects impossible observed token counters.

Types

type Controller

type Controller struct {
	Evaluator goal.Evaluator
	Verifier  *Verifier
	// FailedUsage journals observed usage of a failed Decision separately. The
	// generic runtime intentionally commits usage only on successful Decisions.
	FailedUsage func(ai.Usage) error
	KnownFailed func() ai.Usage
	Invalidated func() bool
	Phase       func(string) error
}

Controller decorates the SDK Goal policy with Coding's gates, independent evidence audit, and substantive progress classification.

func (*Controller) Decide

Decide preserves Coding gates around the neutral SDK Goal policy.

type Evidence

type Evidence struct {
	InteractionID string   `json:"interaction_id"`
	AttemptID     string   `json:"attempt_id"`
	Records       []Record `json:"records"`
	Claim         string   `json:"claim,omitempty"`
	Gate          string   `json:"gate,omitempty"`
	Background    bool     `json:"background,omitempty"`
	Stopped       bool     `json:"stopped,omitempty"`
	Truncated     bool     `json:"truncated,omitempty"`
}

Evidence is persisted at the Work/Decision boundary. Claims cannot substitute for Records. Gate and Background defer assessment without invoking a model.

func Merge

func Merge(previous, next Evidence) Evidence

Merge retains a bounded latest-result ledger. Evicted essential evidence cannot authorize completion: truncation is sticky until explicit invalidation.

func (Evidence) Fingerprint

func (e Evidence) Fingerprint() string

Fingerprint deliberately excludes conversation text, identity, and repeated identical calls. Only substantive tool evidence advances this marker.

type Record

type Record struct {
	ID        string  `json:"id"`
	RunID     string  `json:"run_id,omitempty"`
	CallID    string  `json:"call_id"`
	EntryID   string  `json:"entry_id"`
	Tool      string  `json:"tool"`
	Arguments ai.JSON `json:"arguments"`
	Body      string  `json:"body"`
	Digest    string  `json:"digest"`
	Substance string  `json:"substance,omitempty"`
	OK        bool    `json:"ok"`
	Truncated bool    `json:"truncated"`
}

Record is an actual committed tool result, not an assistant claim. Digest covers the complete result even when the bounded body is truncated.

type State

type State struct {
	Version     int      `json:"version"`
	Goal        ai.JSON  `json:"goal"`
	Evidence    Evidence `json:"evidence"`
	Digest      string   `json:"digest,omitempty"`
	EmptyRounds int      `json:"empty_rounds"`
	Gaps        []string `json:"gaps,omitempty"`
	References  []string `json:"references,omitempty"`
}

State is the Coding wrapper around the unchanged SDK Goal State V1.

func Decode

func Decode(data ai.JSON) (State, error)

Decode validates persisted Coding Goal wrapper state.

func Prepare

func Prepare(condition string) (State, ai.JSON, error)

Prepare wraps the unchanged SDK Goal State V1.

type Verdict

type Verdict struct {
	Verified   bool     `json:"verified"`
	Reason     string   `json:"reason"`
	Gaps       []string `json:"gaps"`
	References []string `json:"references"`
}

Verdict is intentionally not the generic Review result: an empty list of findings can never authorize Goal completion.

type Verifier

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

Verifier audits captured evidence with a bounded read-only workspace catalog.

func NewVerifier

func NewVerifier(ctx context.Context, model ai.LanguageModel, tree *workspace.Tree) (*Verifier, error)

NewVerifier constructs an isolated verifier without shell, MCP or delegation.

func (*Verifier) Verify

func (v *Verifier) Verify(
	ctx context.Context, condition string, evidence Evidence, limits continuation.Limits, accounting continuation.Accounting,
) (Verdict, ai.Usage, error)

Verify performs bounded reads followed by one strict completion verdict.

Jump to

Keyboard shortcuts

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