Decisions

decisions.mine()

Mine every AskUserQuestion decision round under root.

Usage

Source

decisions.mine(root)

Walks the transcript tree at root — one *.jsonl per session — and lifts every typed round into a DecisionRow, keyed by the transcript’s stem as the session id. Uses whose result predates the typed lift are quarantined, never dropped.

Parameters

root: Path
The transcript directory to mine, for example a corpus mirror or ~/.claude/projects.

Returns

MineResult
The mined rows and the quarantined uses.

decisions.DecisionRow

One AskUserQuestion round: the question, its options, and the user’s pick.

Usage

Source

decisions.DecisionRow(
    id,
    session_id,
    occurred_at,
    turn_index,
    event_uuid,
    tool_use_id,
    question,
    header,
    options,
    multi_select,
    answer,
    chosen_index,
    is_custom,
    split
)

Attributes

id: str

The round’s stable content id (session, event, tool use, and round index hashed), the parquet dedup key.

session_id: str

The session the round was mined from.

occurred_at: str

ISO-8601 timestamp of the assistant turn that asked.

turn_index: int

The turn the round fired in — the anchor into the session.

event_uuid: str

The uuid of the asking assistant event, the precise anchor.

tool_use_id: str | None

The AskUserQuestion tool-use block id, or None.

question: str

The prompt text shown to the user.

header: str | None

The round’s short header, or None when the ask omitted one.

options: tuple[str, …]

The offered option labels, in presentation order, verbatim (a trailing " (Recommended)" is kept).

multi_select: bool

Whether the round accepted more than one selection.

answer: str | None

The user’s pick, verbatim — the raw answer string the platform recorded (joined labels and/or custom text), or None when unanswered.

chosen_index: tuple[int, …]

The options indices the user selected, in pick order; empty when the pick was entirely off-menu or the round was unanswered.

is_custom: bool

Whether the answer carried free-typed text beyond the offered options — the user went off-menu.

split: str
The deterministic session-hash split (train/test).

Methods

Name Description
from_record() Rebuild a row from one decisions-parquet record.
to_record() The row as an Arrow-writable mapping, tuples lowered to lists.
from_record()

Rebuild a row from one decisions-parquet record.

Usage

Source

from_record(record)
to_record()

The row as an Arrow-writable mapping, tuples lowered to lists.

Usage

Source

to_record()

decisions.MineResult

The mined decision rows and the quarantined, un-typed uses.

Usage

Source

decisions.MineResult(rows, quarantined)

Attributes

rows: tuple[DecisionRow, …]

One DecisionRow per typed decision round.

quarantined: tuple[Quarantine, …]
One Quarantine per AskUserQuestion use whose result predates the typed lift.

decisions.Quarantine

An AskUserQuestion use whose result carries no typed rounds.

Usage

Source

decisions.Quarantine(session_id, event_uuid, tool_use_id, result_type)

Attributes

session_id: str

The session the use was mined from.

event_uuid: str

The uuid of the asking assistant event.

tool_use_id: str | None

The AskUserQuestion tool-use block id, or None.

result_type: str
The result type that displaced the typed round, e.g. TextResult (a rejection), OtherResult, or NoneType (never answered).

decisions.write_decisions()

Write the mined rows to out as parquet, stamping the digest and quarantine count.

Usage

Source

decisions.write_decisions(result, out)

The order-invariant ~cc_steer.retrain.data.dataset_digest() and the quarantine count ride in the parquet schema metadata, so a later read_decisions() reads the receipt back off the file itself.

Returns

DatasetDigest
The dataset digest stamped into the file.

decisions.read_decisions()

Read a decisions parquet back into rows, its digest, and its quarantine count.

Usage

Source

decisions.read_decisions(path)

decisions.stats_of()

Aggregate mined rows into the counts the decisions stats command prints.

Usage

Source

decisions.stats_of(rows, *, quarantined)

decisions.DecisionStats

Aggregate counts over a decisions dataset.

Usage

Source

decisions.DecisionStats(total, by_split, multi_select, custom, quarantined)

Attributes

total: int

The number of mined decision rounds.

by_split: Mapping[str, int]

Round counts keyed by split, descending.

multi_select: int

Rounds that accepted more than one selection.

custom: int

Rounds whose answer went off-menu.

quarantined: int
AskUserQuestion uses that carried no typed rounds.

Methods

Name Description
render() The human-readable summary the decisions stats command prints.
to_dict() Serializes the stats to a JSON-ready dictionary.
render()

The human-readable summary the decisions stats command prints.

Usage

Source

render()
to_dict()

Serializes the stats to a JSON-ready dictionary.

Usage

Source

to_dict()