Expand description
Facts a session leaves behind, kept without anyone asking. When a
runner ends a session, the hook reads its transcript and keeps up to
MAX_PER_SESSION sentences that state something durable: a rule
(“always”, “never”, “must”), a cause (“root cause”, “because”, “turns
out”), or a fix. Each is written at once as a note whose
source.basis is agent, carrying via:session-end, the session,
and the open sitting’s issue. The read side goes by that stored basis:
recall, search and the island label it an unverified agent note, and
no prompt hook hands it on as a fact or a rule. With no sitting,
packset has no place for a note, and the write is skipped. No model
runs: the extraction is a bounded, deterministic read. A sentence
already kept (by its normalized form) is not written again.
The read runs at session end. LJOS_EXTRACT=off turns it off.
A mined sentence is still nobody’s claim: the note stays on the
tracker, and no prompt hook injects it.
Constants§
- MAX_
PER_ SESSION - The most facts one session writes.
- MAX_
TRANSCRIPT_ BYTES - The longest transcript read, in bytes, from its end.
Functions§
- asked_
by asked_forover the variable’s value, so a test names it.- asked_
for - Whether session-end extraction runs. It does, unless
LJOS_EXTRACT=off. - at_
session_ end - Hand the session finish to a detached process and return. The hook does not read the transcript and does not call the pack. The child fires the session’s memories, writes the notes, and drains a queued tracker push. Returns 0: the count is not known until the child ends.
- facts
- Up to
MAX_PER_SESSIONfacts from a transcript, newest last, with no two of the same normalized form and none inkept. - is_fact
- Whether a sentence states something durable enough to keep.
- kept
- The normalized forms already kept on this machine.
- normal
- A sentence’s form for deduplication: lowercase words only.
- prose
- The prose of a transcript: JSONL with one message a line (Claude Code, Codex and most runners), or plain text.
- read_
tail - The last
capbytes ofpath, or the whole file when it is shorter. The head of a long transcript is not read.Nonewhen the file cannot be opened. - run_
finish_ job - The detached session finish.
pathis the jobschedule_finishwrote. - schedule_
finish - Write the hook payload and start
ljos hook --finish-sessionin its own session. A failure to start is one line. The hook does not do the work itself.