learn

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package learn is the background learning worker: it drains the SessionEnd inbox through the mining pipeline under a lockfile, per-transcript cursors, and the llmtier spend caps. Spawned detached by the session-end hook and runnable manually as `culi learn`. It must be safe to run at any moment: locked ⇒ exit quietly; capped ⇒ stop, keep the queue; no backend ⇒ report options, keep the queue.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	FromStart  bool // ignore cursors, re-mine transcripts from the beginning
	ForceStyle bool // bypass the style-synthesis trigger policy
	IgnoreCaps bool // drain the whole backlog now, ignoring the daily USD/call caps
}

Options tunes one worker run.

type Summary

type Summary struct {
	Backend     string
	Jobs        int // jobs seen
	Mined       int // sessions that produced windows and a model call
	Clean       int // sessions with zero windows (free)
	Created     []string
	Reinforced  []string
	Confirmed   []string
	Retired     []string
	StyleObs    int
	Style       style.Result    // pipeline B synthesis, when it fired
	Patterns    patterns.Result // pipeline D branch index
	Usage       llmgen.Usage
	Notes       []string
	Capped      bool
	BackendDown bool // backend unavailable (CLI logged out / bad key) — run halted, jobs kept queued
}

Summary reports one worker run.

func Run

func Run(ctx context.Context, base string, cfg config.Config, opts Options, logf func(string, ...any)) (Summary, error)

Run drains the inbox once and fires the policy-gated style synthesis. Errors that concern one job go to Notes and the fail ladder; only setup failures return an error.

Directories

Path Synopsis
Package branchgen implements learning pipeline C (`culi gen`): repository git facts → two one-shot structured calls (Strong drafts CLAUDE.md sections, Cheap extracts repo-scoped cards) → idempotent writes.
Package branchgen implements learning pipeline C (`culi gen`): repository git facts → two one-shot structured calls (Strong drafts CLAUDE.md sections, Cheap extracts repo-scoped cards) → idempotent writes.
Package gitfacts renders a deterministic, zero-LLM analysis of a git repository: modules and churn, commit conventions, dependencies, build/test layout, branch-unique work, and the existing CLAUDE.md as a prior.
Package gitfacts renders a deterministic, zero-LLM analysis of a git repository: modules and churn, commit conventions, dependencies, build/test layout, branch-unique work, and the existing CLAUDE.md as a prior.
Package llmtier gives the learning pipelines their model access: an explicit Cheap/Strong generator pair (plan §cost control) behind the multi-backend llmgen seam, gated by a persistent daily spend ledger.
Package llmtier gives the learning pipelines their model access: an explicit Cheap/Strong generator pair (plan §cost control) behind the multi-backend llmgen seam, gated by a persistent daily spend ledger.
Package mine implements learning pipeline A: deterministic signal windows from one session's transcript → a single cheap structured call (escalated once on failure) → deduplicated candidate cards with a reinforcement lifecycle.
Package mine implements learning pipeline A: deterministic signal windows from one session's transcript → a single cheap structured call (escalated once on failure) → deduplicated candidate cards with a reinforcement lifecycle.
Package patterns implements learning pipeline D: an offline cross-branch pattern index.
Package patterns implements learning pipeline D: an offline cross-branch pattern index.
Package queue manages the learn inbox: job files written by the SessionEnd hook, a lockfile so only one worker mines at a time, and per-transcript byte cursors.
Package queue manages the learn inbox: job files written by the SessionEnd hook, a lockfile so only one worker mines at a time, and per-transcript byte cursors.
Package style implements learning pipeline B: periodic synthesis of the per-session style observations that the miner appends to state/style_observations.jsonl.
Package style implements learning pipeline B: periodic synthesis of the per-session style observations that the miner appends to state/style_observations.jsonl.
Package transcript reads Claude Code session transcripts (JSONL) and extracts deterministic signal windows for the learning miner — the zero-LLM stage 0 that decides whether a session is worth any model call at all.
Package transcript reads Claude Code session transcripts (JSONL) and extracts deterministic signal windows for the learning miner — the zero-LLM stage 0 that decides whether a session is worth any model call at all.

Jump to

Keyboard shortcuts

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