Documentation
¶
Overview ¶
Package session normalises foreign agent-session stores into one digest the harness can mine, and mines them for corrections that never became arcs.
**It is deliberately not wired to anything.** `consolidate.Harvest` reads closed arcs and nothing here reaches it: mining sessions the harness never governed is a heuristic, and its output would otherwise land in the held-out splits that score a candidate edit, where a wrong inference does not add noise but moves the objective. The decision (SPEC-ADDITIONS §18 step 1) is that a signal carries provenance and only arc-derived signals enter the splits; the step before that is knowing how often this heuristic is wrong, which is what the report exists to show.
Reading someone else's on-disk format will rot, so each format gets one file behind this package's types and a format change stays one file.
Index ¶
Constants ¶
const ( RoleUser = "user" RoleAssistant = "assistant" )
Roles a normalised turn can carry.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Digest ¶
Digest is one foreign session, normalised. Everything format-specific is resolved before this point, so the miners below never learn a vendor's schema.
func LoadClaude ¶
LoadClaude normalises a Claude Code transcript (one JSON object per line).
Only user and assistant turns survive. A `tool_result` user turn is the harness replying to itself, not a person, and counting it as a prompt would make every tool call look like a correction — the single largest false positive available here.
A malformed line is skipped rather than fatal, which is the opposite of the evidence log's rule and deliberately so: that log is adh's own and its corruption is a defect, while this is someone else's format read at a distance, and one unparseable line is expected rather than alarming.
type Report ¶
type Report struct {
Sessions int `json:"sessions"`
Turns int `json:"turns"`
Retries []Retry `json:"retries"`
ByMarker map[string]int `json:"by_marker"`
}
Report is what a corpus of sessions yields, before anything is done with it.
type Retry ¶
type Retry struct {
Session string
// Turn is the index in the digest, so a reader can find it in the transcript.
Turn int
// Marker is which opening matched, so the report can show which rule fired and a
// bad rule can be identified rather than merely suspected.
Marker string
// Prompt is the corrective turn, truncated.
Prompt string
}
Retry is one detected correction: a user turn that answered an assistant turn by saying it was wrong.
func Retries ¶
Retries finds corrective turns in one digest. Pure.
The rule: a user turn that directly follows an assistant turn and opens with a negative-feedback marker. Requiring the assistant turn first is what distinguishes *the last attempt was wrong* from a user simply beginning a message with "no" — without it, the opening turn of a session can match.
**Known false positives, stated because the next reader's instinct is to trust the count.** A user quoting an error message that opens with one of these words; a correction aimed at the user's own previous instruction rather than at the assistant; and "still " matching "still running" as readily as "still broken". **Known false negatives:** any correction phrased politely, which is most of them. The count is a lower bound on corrections and an upper bound on nothing.