effects

package
v2.10.3 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 16 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 effects checks the claims an agent makes about the world ("pushed", "restarted the service", "it is live at …") by probing the effect itself.

A pilot on real sessions showed that the false completions a human catches are mostly effect claims that were only proxy-verified: a test ran, and then the agent said "pushed". Extract finds those claims in the agent's final message, deterministically and without a model. Probe (probe.go) then looks at the machine with read-only commands. The package never changes state.

Index

Constants

View Source
const (
	ModeOff     = "off"
	ModeShow    = "show"
	ModeEnforce = "enforce"
)

The values of projects.effect_checks (docs/effect-checks.md).

Variables

This section is empty.

Functions

func MessageHash

func MessageHash(message string) string

MessageHash identifies a message for the dedupe. It is a digest, not the text, so the table never stores a second copy of the agent's message.

func ModeOf

func ModeOf(v string) string

ModeOf reads a project's effect_checks value. Anything that is not "off" or "enforce" is "show", the default, so an unexpected value never silences the checks.

Types

type Claim

type Claim struct {
	Kind Kind
	// Target is what the claim is about: a unit name, URL, port, path, commit
	// or remote ref. It is empty when the sentence names none.
	Target string
	// Sentence is the sentence the claim was found in, for evidence.
	Sentence string
}

Claim is one completion claim found in a message.

func Extract

func Extract(message string) []Claim

Extract returns every completion claim in the message, in sentence order. The same claim may appear more than once; Evaluate de-duplicates.

type Facts

type Facts struct {
	Since              time.Time
	LastCheck          *store.SessionCheck
	CurrentFingerprint string
}

Facts is what the probes may compare against: when the turn began, the most recent test run in the session, and the fingerprint of the tree now.

type Kind

type Kind string

Kind names what a completion claim asserts.

const (
	KindPushed        Kind = "pushed"
	KindCommitted     Kind = "committed"
	KindTestsPass     Kind = "tests_pass"
	KindRestarted     Kind = "restarted"
	KindURLOK         Kind = "url_ok"
	KindPortListening Kind = "port_listening"
	KindFileExists    Kind = "file_exists"
)

type Notifier

type Notifier interface {
	Notify(title, body, urlPath string, extra *sinks.Extra)
}

Notifier is the phone-push side; *sinks.Notifier satisfies it.

type Result

type Result struct {
	Claim   Claim
	Verdict Verdict
}

Result pairs a claim with the verdict of its probe.

func Evaluate

func Evaluate(ctx context.Context, ex executor.Executor, dir, message string, facts Facts) []Result

Evaluate extracts the claims in message, drops repeats of the same kind and target, and probes each one in order.

type SessionSender

type SessionSender interface {
	SendNotice(ctx context.Context, id int64, text string) error
}

SessionSender is how a machine-originated message reaches a session; *sessions.Manager satisfies it (its SendNotice).

type Status

type Status string

Status is the outcome of probing one claim.

const (
	// StatusVerified means the probe observed the claimed effect.
	StatusVerified Status = "verified"
	// StatusContradicted means the probe observed the opposite.
	StatusContradicted Status = "contradicted"
	// StatusUnknown means the probe could not decide: no evidence either way.
	StatusUnknown Status = "unknown"
)

type Verdict

type Verdict struct {
	Status   Status
	Evidence string
}

Verdict is what Probe concluded and the observation behind it.

func Probe

func Probe(ctx context.Context, ex executor.Executor, dir string, c Claim, f Facts) Verdict

Probe checks one claim against the machine behind ex. dir is the project directory the agent worked in. Every command it runs is read-only.

type Watcher

type Watcher struct {
	DB       *store.DB
	Reg      *executor.Registry
	Bus      *bus.Bus
	Notifier Notifier
	Sessions SessionSender
	Log      *slog.Logger
	// CheckTimeout bounds how long a claim about tests waits for a running
	// check. checks.DefaultTimeout is used when unset.
	CheckTimeout time.Duration
	// contains filtered or unexported fields
}

Watcher evaluates the completion claims in each agent turn's final message. It is a subscriber on the hook path, so HandleHookEvent does no probing: it only decides whether a turn is worth checking and starts a goroutine. The evaluation then runs without holding the agent's HTTP hook response.

func New

func New(db *store.DB, reg *executor.Registry, b *bus.Bus, notifier Notifier, sessions SessionSender, timeout time.Duration, log *slog.Logger) *Watcher

New builds a Watcher.

func (*Watcher) HandleHookEvent

func (w *Watcher) HandleHookEvent(sess *store.Session, event string, body []byte, state string, changed bool)

HandleHookEvent is the events.OnHookEvent subscriber. It returns at once. A UserPromptSubmit starts a new turn, so its time becomes the Since fact that restart claims are compared against. A Stop, or codex's AgentTurnComplete, with a last message that makes a claim starts one evaluation in the background.

Jump to

Keyboard shortcuts

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