Help us shape the future of Go! Take the 2026 Go Developer Survey

session

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 6 Imported by: 0

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

View Source
const (
	RoleUser      = "user"
	RoleAssistant = "assistant"
)

Roles a normalised turn can carry.

Variables

This section is empty.

Functions

This section is empty.

Types

type Digest

type Digest struct {
	ID    string
	Turns []Turn
}

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

func LoadClaude(r io.Reader) (Digest, error)

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.

func Summarise

func Summarise(digests []Digest) Report

Summarise folds digests into one report. Pure; the caller reads the files.

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

func Retries(d Digest) []Retry

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.

type Turn

type Turn struct {
	Role string
	Text string
}

Turn is one conversational turn, reduced to who spoke and what they said.

Jump to

Keyboard shortcuts

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