{"modulePath":"github.com/memcode-ai/memcode","version":"v0.56.16","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package predict\n\nPackage 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.\n\n## Functions\n\n```go\nfunc Fingerprint(ctx context.Context, root string, ev Evidence) string\n```\nFingerprint 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.\n\n```go\nfunc Head(ctx context.Context, root string) string\n```\nHead returns the current HEAD SHA (empty outside a repo).\n\n```go\nfunc StoreCached(ctx context.Context, st store.Store, root, fingerprint, text string)\n```\nStoreCached persists a freshly synthesized prediction.\n\n```go\nfunc UserPrompt(ev Evidence) (user string)\n```\nPrompt 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.\n\n## Types\n\n```go\ntype Evidence struct {\n\tCommits    []gitlog.Commit\n\tDirtyFiles []string\n\tDiff       string // current working-tree diff (truncated, redacted)\n\tSubsystems []string\n\tObjectives []string\n\tFocus      focus.State // where you left off — current/open/paused/done, from the episodic log + objectives\n}\n```\nEvidence is the deterministic signal the prediction is built from.\n\n```go\nfunc Gather(ctx context.Context, st store.Store, root, excludeSessionID string) (Evidence, error)\n```\nGather 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.\n\n```go\ntype Prediction struct {\n\tText        string    `json:\"text\"`\n\tHeadSHA     string    `json:\"head_sha\"`\n\tFingerprint string    `json:\"fingerprint\"`\n\tGeneratedAt time.Time `json:\"generated_at\"`\n}\n```\nPrediction 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.\n\n```go\nfunc LoadCached(ctx context.Context, st store.Store, root string, fingerprint string) (Prediction, bool)\n```\nLoadCached returns the cached prediction and whether it matches the current (HEAD, working-tree) state — i.e. can be served without a model call.\n\n","path":"github.com/memcode-ai/memcode/internal/predict","name":"predict","synopsis":"Package predict infers where a developer was working and what they were about to do next.","isRedistributable":true}
