Documentation
¶
Overview ¶
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. Clean sessions cost zero model calls; every model call is capped by llmtier's ledger.
Index ¶
- func Confirm(ctx context.Context, s *store.Store, kdir, id string) (string, error)
- func Reject(ctx context.Context, s *store.Store, kdir, id string) error
- func RetireCard(ctx context.Context, s *store.Store, kdir, id string) (bool, error)
- func RetireStaleCandidates(ctx context.Context, s *store.Store, kdir string, ttl time.Duration, ...) ([]string, error)
- type Miner
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Confirm ¶
Confirm flips a candidate to confirmed (review approval or forced promote) and retires the card it supersedes. Returns the retired ID ("" if none).
func RetireCard ¶
RetireCard sets status: retired on a culi-authored card (shared with `culi review`, which retires superseded cards on approval). Returns false when the card is missing or hand-authored — never an error worth failing a mine over.
func RetireStaleCandidates ¶
func RetireStaleCandidates(ctx context.Context, s *store.Store, kdir string, ttl time.Duration, now time.Time) ([]string, error)
RetireStaleCandidates retires candidate cards left unreinforced for longer than ttl. The clock is the card file's mtime: every create, reinforce, or edit round-trips through knowledge.UpdateFile's atomic rename, so an untouched candidate keeps its birth mtime while a re-observed one resets it.
Only candidates are eligible. Confirmed cards — including imported ones, which are also culi-authored — are NEVER auto-retired here; a dormant confirmed card is surfaced by `culi stats`, not deleted, because a wrongly deleted rule steers every future session (C4). Retirement itself is a reversible status flip on the file (RetireCard), committed to the knowledge git history by the caller. Returns the retired card IDs.
Rejected alternative: an explicit `updated:` frontmatter field. File mtime already tracks exactly the mutations that count, at zero schema/render/ backfill cost — and retirement being non-destructive absorbs mtime's one weakness (a git checkout that resets it merely restarts the clock).
Types ¶
type Miner ¶
type Miner struct {
Base string // culi home
Store *store.Store
Tier *llmtier.Tier
Emb embed.Embedder // nil ⇒ lexical dedup only
EmbModel string
// ConfirmAt overrides the observations-to-confirm threshold (learn.confirm_at).
// 0 ⇒ defaultConfirmAt. 1 auto-confirms candidates on first sighting.
ConfirmAt int
Logf func(format string, args ...any) // optional diagnostics
// WriteMu, when set, serializes the store-writing tail (apply + reindex)
// across concurrent MineSession calls — the index is single-writer (WAL),
// so a --no-cap parallel drain fans out the LLM calls but funnels writes.
WriteMu *sync.Mutex
// contains filtered or unexported fields
}
Miner mines one session at a time. Fields are dependencies, wired by the worker.
func (*Miner) MineSession ¶
func (m *Miner) MineSession(ctx context.Context, job queue.Job, cur queue.Cursor) (Result, queue.Cursor, error)
MineSession processes one queued job from its cursor and returns the new cursor. Zero windows ⇒ zero LLM calls (the common, free case). An ErrCapped from the tier is returned as-is so the worker stops and keeps the job.
type Result ¶
type Result struct {
Windows int
Created []string // new candidate card IDs
Reinforced []string // existing card IDs bumped
Confirmed []string // cards that crossed the 2-observation gate
Retired []string // superseded cards retired on confirm
StyleObs int
Notes []string
Usage llmgen.Usage
Escalated bool
}
Result summarizes one mined session.