predict

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package predict infers where a developer was working and what they were about to do next. The evidence is deterministic (recent commits, the current dirty working tree, the subsystems those touch, active objectives); the synthesis is a single model call. This is the seed of the expectations → deviations layer: a prediction is an expectation about the next step.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fingerprint

func Fingerprint(ctx context.Context, root string, ev Evidence) string

Fingerprint hashes ALL the state a prediction depends on, so the cache invalidates the moment any of it changes. That's HEAD + the dirty files/diff AND the episodic evidence: objectives and the focus projection (current/open/paused threads). Without the latter, a clean tree that abandoned a plan, added an objective, or opened a thread kept serving the pre-session cached prediction until some FILE changed — stale against fresh memory.

func Head(ctx context.Context, root string) string

Head returns the current HEAD SHA (empty outside a repo).

func StoreCached

func StoreCached(ctx context.Context, st store.Store, root, fingerprint, text string)

StoreCached persists a freshly synthesized prediction.

func UserPrompt

func UserPrompt(ev Evidence) (user string)

Prompt builds the (system, user) messages for the synthesis call. UserPrompt serializes the evidence into the user message. The system prompt is the gateway's (mode "predict") — the CLI ships facts, not doctrine.

Types

type Evidence

type Evidence struct {
	Commits    []gitlog.Commit
	DirtyFiles []string
	Diff       string // current working-tree diff (truncated, redacted)
	Subsystems []string
	Objectives []string
	Focus      focus.State // where you left off — current/open/paused/done, from the episodic log + objectives
}

Evidence is the deterministic signal the prediction is built from.

func Gather

func Gather(ctx context.Context, st store.Store, root, excludeSessionID string) (Evidence, error)

Gather collects the evidence for a prediction (no model call). excludeSessionID is the current live session, if any — its episodic signal is skipped so a fresh session doesn't shadow the prior meaningful one ("where you left off" must point at the LAST distinct session). Pass "" from standalone CLI where there is none.

type Prediction

type Prediction struct {
	Text        string    `json:"text"`
	HeadSHA     string    `json:"head_sha"`
	Fingerprint string    `json:"fingerprint"`
	GeneratedAt time.Time `json:"generated_at"`
}

Prediction is a cached synthesis, stored in current_state. Unlike the overview (keyed by HEAD alone), a prediction also depends on the UNCOMMITTED working tree — so it's keyed by HEAD plus a fingerprint of the dirty files + diff. Within an unchanged (commit, working-tree) state, repeat `predict` calls are free.

func LoadCached

func LoadCached(ctx context.Context, st store.Store, root string, fingerprint string) (Prediction, bool)

LoadCached returns the cached prediction and whether it matches the current (HEAD, working-tree) state — i.e. can be served without a model call.

Jump to

Keyboard shortcuts

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