Documentation
¶
Overview ¶
Package focus is memcode's COGNITIVE / attention axis — what the human is attending to — the complement of package room (the emotional / interaction axis). Doctrine: memcode models attention moving through commitments. room models how the interaction is going; focus models what the human is attending to; objectives model commitments that became durable.
FocusState is a pure DERIVED projection over the episodic log + objectives: rebuildable, deletable, no canonical store. A focus strand is a transient candidate objective; an objective is a strand that crossed a commitment threshold, so the durable layer here is just the active objectives — no parallel store.
Phase 0 derives transitions DETERMINISTICALLY from signals already in the log (commits → milestone; terse "done/forget/park" language → status changes; a new substantive ask → the prior strand pauses). Fuzzy strand identity/merge is left to a later model-judged pass — the same determinism-for-facts, judgment-for-judgment rule used elsewhere. It is intentionally simple; we dogfood whether it's useful before investing in clustering.
Index ¶
Constants ¶
const ( BurstSessions = 5 BurstGap = 48 * time.Hour BurstPerSession = 120 )
The orientation window FromLog reduces: the most recent prior session ALWAYS loads (that's "where you left off", however old); older sessions join only while consecutive gaps stay within BurstGap (one stretch of work), capped at BurstSessions. PerSession caps IO, not meaning.
Variables ¶
This section is empty.
Functions ¶
func Render ¶
Render formats the state as the cold-start orientation block. It leads with the UNFINISHED threads (numbered, newest first, with provenance notes) and closes with reconciliation semantics: verify against git, then account for every thread — resume, done, or dropped — never silently omit one. Redaction is the caller's responsibility — titles come from user text. Empty when nothing to show.
Types ¶
type State ¶
type State struct {
Current string // the strand the user is on right now ("" if none active)
Open []Strand // active, not yet the current focus
Paused []Strand // superseded, aborted, or explicitly parked — UNFINISHED work
Completed []Strand // reached a commit/verify or an explicit "done"
Dropped []Strand // explicitly abandoned
Decisions []string // durable commitments (active objectives)
// Elided counts strands cut by the per-bucket cap (paused+completed+dropped).
// Rendered as PROSE ("…and N older threads"), never as a fake list entry —
// a "(+1 more)" thread the model must "account for" is noise, not memory.
Elided int
// contains filtered or unexported fields
}
State is the reduced attention snapshot. Buckets hold strands, most recent FIRST.
func FromLog ¶
func FromLog(root, excludeSessionID string, objs []objectives.Objective) State
FromLog computes the live FocusState for a repo: the current work burst of prior sessions plus the current session's records, reduced as ONE chronological stream. The single source of truth for orientation (runtime.focusNow) and the memcode{session} tool — one window, one reducer.
func Reduce ¶
func Reduce(recs []sessionlog.Record, objs []objectives.Objective) State
Reduce projects episodic records (chronological) plus objectives into a FocusState.
func (State) Lines ¶
Lines renders the state as plain "label: a · b" facts (no header) — the form to FEED a synthesis prompt (/predict) as grounding. Empty when there's nothing to surface.
func (State) Unfinished ¶
Unfinished returns the open work, newest first: the (prior-session) current strand, then open, then paused. This is the list a status answer must account for — the digest and memcode{session} both render it.
type Status ¶
type Status string
Status is a soft attention state. `Dropped` is used ONLY on a clear forget/abandon signal — humans say "skip" temporarily far more often than they truly abandon.
type Strand ¶
type Strand struct {
Title string
Full string // the complete user message (untruncated) — act on THIS, not Title
Note string
Session string // source session id, so the thread names where to recover full context
}
Strand is one thread of work: the user's ask, its FULL verbatim text, an optional provenance note ("plan cancelled mid-flight — never executed"), and the session it came from. Title is a display summary (first line, capped); Full is the complete request the agent must act on — the two diverge for a long ask, and acting on the truncated Title instead of Full is exactly the bug that amputated a multi-part spec.