Rust-first harness runtime research and implementation workspace.
This repository studies the exposed Claude Code architecture at the systems level and rebuilds the useful harness ideas as an original Rust-native CLI/runtime. The target is not path parity or source transliteration. The primary target is a usable, inspectable Claude Code-style CLI Hamza can run directly; clean reusable runtime components are a secondary outcome that can later donate into Horizon/Rune.
The repository already contains:
- a Cargo workspace
- Rust crates for core/session/tools/commands/runtime/cli boundaries
- architecture and implementation planning docs
- retained JSON snapshot/reference material used to understand architectural surfaces
The repository is still early, but the Rust MVP lane is already partially implemented and tracked incrementally through the active GitHub issue queue.
.
├── Cargo.toml
├── Cargo.lock
├── ARCHITECTURE.md
├── PORTING_PLAN.md
├── archive/
│ └── reference_data/
└── crates/
├── harness-cli/
├── harness-commands/
├── harness-core/
├── harness-runtime/
├── harness-session/
└── harness-tools/
archive/reference_data/ is the canonical home for retained JSON snapshot material from the architecture study. It is kept in the repo for design context and documentation, but it is not part of the active Rust runtime path. Moving it out of src/ keeps the primary Claude Code CLI/runtime surface visually clean while preserving the research artifacts that informed the port.
The first meaningful milestone is:
- typed core models
- session + transcript persistence
- tool and command registries
- deterministic routing
- runtime turn processor with structured events
- CLI commands for summary, route, bootstrap, resume, tools, commands, session listing, session inspection, transcript inspection, session export, session comparison, session deletion, session import, session search, and session fork
See:
ARCHITECTURE.mdPORTING_PLAN.md- the active GitHub issue queue for the next atomic slice
Build the workspace:
cargo checkRun tests:
cargo test -p harness-core
cargo test -p harness-tools
cargo test -p harness-commands
cargo test -p harness-session
cargo test -p harness-runtime
cargo test -p harness-cli
cargo testRun clippy strictly:
cargo clippy --workspace --all-targets -- -D warningsRun the CLI:
cargo run -p harness-cli -- --helpThe examples below reflect the current seeded runtime surface and are protected by cargo test -p harness-cli. bootstrap creates a session file under .sessions/, which is gitignored, so the README uses stable placeholders for generated values that vary per run: <session-id> for ids, <created-at-ms> and <updated-at-ms> for persisted recency/activity metadata, and matching .sessions/<session-id>.json session paths plus .sessions/<session-id>.transcript.json transcript paths.
Each persisted session now ships a sibling transcript file at .sessions/<session-id>.transcript.json in a deterministic format: { session_id, created_at_ms, updated_at_ms, entries: [{ turn_index, prompt }] }. Entries are appended in turn_index order, rewritten on every bootstrap and resume, and inspectable through transcript-show <selector> (raw session_id, latest, or label:<name>).
cargo run -q -p harness-cli -- summarycommands=3 tools=3 denied_prefixes=bash
cargo run -q -p harness-cli -- route "review bash"[
{
"kind": "command",
"name": "review",
"score": 1
},
{
"kind": "tool",
"name": "Bash",
"score": 1
}
]cargo run -q -p harness-cli -- tools[
{
"name": "ReadFile",
"description": "Read a file from disk"
},
{
"name": "EditFile",
"description": "Edit a file on disk"
},
{
"name": "Bash",
"description": "Execute shell commands"
}
]cargo run -q -p harness-cli -- commands[
{
"name": "review",
"description": "Review code or diffs"
},
{
"name": "agents",
"description": "Inspect agent state"
},
{
"name": "setup",
"description": "Show runtime setup state"
}
]cargo run -q -p harness-cli -- bootstrap "review bash"{
"session": {
"session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"messages": [
"review bash"
],
"usage": {
"input_tokens": 2,
"output_tokens": 2
}
},
"transcript": {
"entries": [
{
"turn_index": 0,
"prompt": "review bash"
}
],
"flushed": true
},
"matches": [
{
"kind": "command",
"name": "review",
"score": 1
},
{
"kind": "tool",
"name": "Bash",
"score": 1
}
],
"denials": [
{
"subject": "Bash",
"reason": "tool blocked by permission policy"
}
],
"command_results": [
{
"name": "review",
"handled": true,
"message": "command 'review' would handle prompt \"review bash\""
}
],
"tool_results": [],
"events": [
{
"SessionStarted": {
"session_id": "<session-id>"
}
},
{
"PromptReceived": {
"prompt": "review bash"
}
},
{
"RouteComputed": {
"match_count": 2
}
},
{
"CommandMatched": {
"name": "review",
"score": 1
}
},
{
"ToolMatched": {
"name": "Bash",
"score": 1
}
},
{
"PermissionDenied": {
"subject": "Bash",
"reason": "tool blocked by permission policy"
}
},
{
"CommandInvoked": {
"name": "review"
}
},
{
"CommandCompleted": {
"name": "review",
"handled": true
}
},
{
"TurnCompleted": {
"stop_reason": "completed"
}
},
{
"SessionPersisted": {
"path": ".sessions/<session-id>.json"
}
},
{
"TranscriptPersisted": {
"path": ".sessions/<session-id>.transcript.json"
}
}
],
"persisted_path": ".sessions/<session-id>.json",
"persisted_transcript_path": ".sessions/<session-id>.transcript.json"
}Append a new turn to an existing persisted session. <selector> accepts raw session_id, latest, or label:<name> — all three forms are routed through the shared selector-resolution path so resume targets the same persisted session regardless of which form was typed. The resumed turn is appended to the same session file rather than starting a new session, and updated_at_ms is refreshed so subsequent latest lookups point at the most recently active session. Machine-readable JSON output continues to identify the actual resolved session_id via resumed_session_id rather than echoing the selector string, so downstream tooling can rely on the resolved id even when the user typed label:<name> or latest. Selector failures are deterministic: unknown id/label surfaces as SessionNotFound, duplicate labels as AmbiguousLabel, and an empty label: as MalformedSelector.
cargo run -q -p harness-cli -- resume <session-id> "review summary"{
"resumed_session_id": "<session-id>",
"appended_turn_index": 1,
"session": {
"session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"messages": [
"review bash",
"review summary"
],
"usage": {
"input_tokens": 4,
"output_tokens": 4
}
},
"transcript": {
"entries": [
{
"turn_index": 0,
"prompt": "review bash"
},
{
"turn_index": 1,
"prompt": "review summary"
}
],
"flushed": true
},
"matches": [
{
"kind": "command",
"name": "review",
"score": 1
}
],
"denials": [],
"command_results": [
{
"name": "review",
"handled": true,
"message": "command 'review' would handle prompt \"review summary\""
}
],
"tool_results": [],
"events": [
{
"SessionResumed": {
"session_id": "<session-id>",
"turn_index": 1
}
},
{
"PromptReceived": {
"prompt": "review summary"
}
},
{
"RouteComputed": {
"match_count": 1
}
},
{
"CommandMatched": {
"name": "review",
"score": 1
}
},
{
"CommandInvoked": {
"name": "review"
}
},
{
"CommandCompleted": {
"name": "review",
"handled": true
}
},
{
"TurnCompleted": {
"stop_reason": "completed"
}
},
{
"SessionPersisted": {
"path": ".sessions/<session-id>.json"
}
},
{
"TranscriptPersisted": {
"path": ".sessions/<session-id>.transcript.json"
}
}
],
"persisted_path": ".sessions/<session-id>.json",
"persisted_transcript_path": ".sessions/<session-id>.transcript.json"
}latest and label:<name> are supported as resume targets too:
cargo run -q -p harness-cli -- resume latest "review summary"
cargo run -q -p harness-cli -- resume label:runtime-review "review summary"cargo run -q -p harness-cli -- sessions[
{
"session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"message_count": 1,
"persisted_path": ".sessions/<session-id>.json"
}
]Pass --limit <n> to cap the listing to at most the newest n persisted sessions in the existing newest-first ordering. The per-row JSON shape is preserved — --limit only truncates the array, it does not wrap the output. --limit 0 returns an empty array cleanly, a --limit larger than the store returns every available session, and omitting --limit preserves the unlimited listing above exactly.
cargo run -q -p harness-cli -- sessions --limit 1Inspect the persisted state of a single session. <selector> accepts any of the three forms every other single-session command accepts — a raw session_id, the literal latest, or label:<name> — routed through the shared selector-resolution path. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. The JSON output always restates the actual resolved session_id, never the typed selector string.
Pass --limit <n> to cap the messages array to at most the first n messages in the existing canonical append order. Pass --tail <n> instead to inspect only the newest n messages while preserving canonical append order within the returned slice. The outer JSON shape is preserved for both flags — they only reshape messages; no wrapper object is introduced. --limit 0 / --tail 0 return messages: [] cleanly, a --limit / --tail larger than the persisted message count returns every message cleanly, and omitting both preserves the unlimited behavior below exactly. --limit and --tail are mutually exclusive at parse time so output-shaping semantics stay deterministic. Negative and non-numeric --limit / --tail values fail cleanly at parse time. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- session-show <session-id>
cargo run -q -p harness-cli -- session-show <session-id> --limit 1
cargo run -q -p harness-cli -- session-show <session-id> --tail 1{
"session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"messages": [
"review bash"
],
"usage": {
"input_tokens": 2,
"output_tokens": 2
}
}cargo run -q -p harness-cli -- session-show latest{
"session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"messages": [
"review bash"
],
"usage": {
"input_tokens": 2,
"output_tokens": 2
}
}label:<name> targets the persisted session whose label was set via session-rename, and the output still surfaces the actual resolved session_id rather than the label string.
cargo run -q -p harness-cli -- session-show label:runtime-reviewInspect the persisted transcript for a single session. <selector> accepts any of the three forms every other single-session command accepts — a raw session_id, the literal latest, or label:<name> — routed through the shared selector-resolution path. The output restates the owning session_id and the session's recency metadata so it is self-describing, and lists turns in append order. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector.
Pass --limit <n> to cap the entries array to at most the first n entries in the existing canonical append order. Pass --tail <n> instead to inspect only the newest n entries while preserving canonical append order within the returned slice. The outer JSON shape is preserved for both flags — they only reshape entries; no wrapper object is introduced. --limit 0 / --tail 0 return entries: [] cleanly, a --limit / --tail larger than the persisted transcript length returns every entry cleanly, and omitting both preserves the unlimited behavior above exactly. --limit and --tail are mutually exclusive at parse time so output-shaping semantics stay deterministic. Negative and non-numeric --limit / --tail values fail cleanly at parse time. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- transcript-show <session-id>
cargo run -q -p harness-cli -- transcript-show <session-id> --limit 1
cargo run -q -p harness-cli -- transcript-show <session-id> --tail 1{
"session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"entries": [
{
"turn_index": 0,
"prompt": "review bash"
}
]
}latest resolves to the transcript of the most recently active persisted session, mirroring how session-show latest resolves session state.
cargo run -q -p harness-cli -- transcript-show latest{
"session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"entries": [
{
"turn_index": 0,
"prompt": "review bash"
}
]
}label:<name> targets the persisted transcript whose session was labeled via session-rename, and the output still surfaces the resolved session_id rather than the label string.
cargo run -q -p harness-cli -- transcript-show label:runtime-reviewInspect only the newest transcript entries for a persisted session without dumping the full transcript. Accepts the same selector forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, transcript-show, etc. --count <n> controls how many most-recent entries are returned; when omitted, the default is 10. A --count larger than the persisted transcript simply returns every available entry, and --count 0 returns an empty entries array without erroring. Output uses a deterministic shape: { selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, returned_entries, entries }, where selector echoes the raw input, resolved_session_id is the persisted id the selector actually maps to, total_entries is the full transcript length, returned_entries == entries.len(), and entries preserves the source transcript's turn_index ordering so the tail slice is self-describing. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- transcript-tail <session-id>
cargo run -q -p harness-cli -- transcript-tail latest --count 2
cargo run -q -p harness-cli -- transcript-tail label:runtime-review --count 1{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"total_entries": 1,
"returned_entries": 1,
"entries": [
{
"turn_index": 0,
"prompt": "review bash"
}
]
}Search the persisted transcript for a single selected session by prompt text without touching any other session. Accepts the same selector forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, transcript-show, transcript-tail, etc. The query is matched case-insensitively as a substring against each transcript entry's prompt text (mirroring session-find semantics), and an empty query is treated as a no-op that returns zero matches rather than erroring. Output uses a deterministic shape: { selector, resolved_session_id, query, created_at_ms, updated_at_ms, total_entries, match_count, matches }, where selector echoes the raw input, resolved_session_id is the persisted id the selector actually maps to, total_entries is the full transcript length, match_count == matches.len(), and each entry in matches records the matched turn_index plus the persisted prompt text in the source transcript's turn_index order so callers can jump straight to the matched turn. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
Pass --limit <n> to cap the matches array to at most the first n entries in the existing source transcript turn_index ordering. Pass --tail <n> instead to inspect only the newest n matches while preserving ascending turn_index order within the returned slice. The outer JSON shape is preserved for both flags — they only reshape matches and recompute match_count so match_count == matches.len() still holds; no wrapper object is introduced. Query and selector semantics are preserved — an empty query and a no-match query still return match_count: 0 with an empty matches array regardless of --limit / --tail. --limit 0 / --tail 0 return match_count: 0 with an empty matches array cleanly, a --limit / --tail larger than the match count returns every match unchanged, and omitting both preserves the unlimited behavior above exactly. --limit and --tail are mutually exclusive at parse time so output-shaping semantics stay deterministic. Negative and non-numeric --limit / --tail values fail cleanly at parse time.
cargo run -q -p harness-cli -- transcript-find <session-id> review
cargo run -q -p harness-cli -- transcript-find latest review
cargo run -q -p harness-cli -- transcript-find label:runtime-review review
cargo run -q -p harness-cli -- transcript-find <session-id> review --limit 1
cargo run -q -p harness-cli -- transcript-find <session-id> review --tail 1{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"query": "review",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"total_entries": 1,
"match_count": 1,
"matches": [
{
"turn_index": 0,
"prompt": "review bash"
}
]
}Inspect a bounded forward slice of a persisted session's transcript beginning at a specific turn_index without dumping the entire transcript. Useful as the natural follow-up to transcript-find (jump straight to the window around a matched turn) and to transcript-tail (ask for a specific mid-transcript window rather than only the newest entries). Accepts the same selector forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, transcript-show, transcript-tail, transcript-find, etc. --count <n> controls the maximum number of forward entries returned starting from turn_index == <start>; when omitted, the default is 10. A --count larger than the remaining entries returns the available tail cleanly, a --start past the end of the transcript (or on an empty transcript) returns an empty entries array without erroring, and negative / non-numeric --start or --count values fail cleanly at parse time. Output uses a deterministic shape: { selector, resolved_session_id, start_turn_index, requested_count, created_at_ms, updated_at_ms, total_entries, returned_entries, entries }, where selector echoes the raw input, resolved_session_id is the persisted id the selector actually maps to, start_turn_index and requested_count echo the requested window, total_entries is the full transcript length, returned_entries == entries.len(), and entries preserves the source transcript's turn_index ordering so the window slice is self-describing. Each entry carries at least turn_index and prompt. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- transcript-range <session-id> --start 0
cargo run -q -p harness-cli -- transcript-range latest --start 1 --count 2
cargo run -q -p harness-cli -- transcript-range label:runtime-review --start 0 --count 5{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"start_turn_index": 0,
"requested_count": 10,
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"total_entries": 1,
"returned_entries": 1,
"entries": [
{
"turn_index": 0,
"prompt": "review bash"
}
]
}Inspect a bounded symmetric window around a specific turn_index in a persisted session's transcript without dumping the entire transcript. Useful as the natural follow-up to transcript-find (jump straight to a matched turn with surrounding context) and to transcript-range (ask for a centered window rather than a forward slice). Accepts the same selector forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, transcript-show, transcript-tail, transcript-find, transcript-range, etc. --before <n> and --after <n> each default to 2 and control how many entries are returned on either side of the centered turn_index == <turn> entry. A window extending past either transcript bound is clipped cleanly to the available in-range entries, a --turn past the end of the transcript (or on an empty transcript) returns an empty entries array without erroring, and negative / non-numeric --turn, --before, or --after values fail cleanly at parse time. Output uses a deterministic shape: { selector, resolved_session_id, center_turn_index, requested_before, requested_after, created_at_ms, updated_at_ms, total_entries, returned_entries, entries }, where selector echoes the raw input, resolved_session_id is the persisted id the selector actually maps to, center_turn_index, requested_before, and requested_after echo the requested window, total_entries is the full transcript length, returned_entries == entries.len(), and entries preserves the source transcript's turn_index ordering so the window slice is self-describing. Each entry carries at least turn_index and prompt. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- transcript-context <session-id> --turn 0
cargo run -q -p harness-cli -- transcript-context latest --turn 1 --before 1 --after 1
cargo run -q -p harness-cli -- transcript-context label:runtime-review --turn 2 --before 2 --after 2{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"center_turn_index": 0,
"requested_before": 2,
"requested_after": 2,
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"total_entries": 1,
"returned_entries": 1,
"entries": [
{
"turn_index": 0,
"prompt": "review bash"
}
]
}Inspect a single persisted transcript entry by its exact turn_index. Useful as the direct single-turn drill-down that pairs with transcript-find (jump to one matched turn without a surrounding window), transcript-range (pick one entry out of a forward slice), and transcript-context (look at just the centered entry itself). Accepts the same selector forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, transcript-show, transcript-tail, transcript-find, transcript-range, transcript-context, etc. The search is scoped to the resolved session's persisted transcript only. Output uses a deterministic shape: { selector, resolved_session_id, turn_index, created_at_ms, updated_at_ms, total_entries, entry }, where selector echoes the raw input, resolved_session_id is the persisted id the selector actually maps to, turn_index echoes the requested turn, total_entries is the full transcript length, and entry carries at least turn_index and prompt. Because the contract is to return exactly one entry, an empty transcript and a --turn past the end of the transcript both fail cleanly and deterministically as transcript turn out of range rather than silently returning nothing. Negative / non-numeric --turn values fail cleanly at parse time. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- transcript-turn-show <session-id> --turn 0
cargo run -q -p harness-cli -- transcript-turn-show latest --turn 1
cargo run -q -p harness-cli -- transcript-turn-show label:runtime-review --turn 2{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"turn_index": 0,
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"total_entries": 1,
"entry": {
"turn_index": 0,
"prompt": "review bash"
}
}Inspect the newest persisted transcript entry for a single session — the one whose turn_index is the highest available. Useful as a quick "what did I ask last?" drill-down that avoids having to first discover total_entries via transcript-tail and then subtract one to call transcript-turn-show. Accepts the same selector forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, transcript-show, transcript-tail, transcript-find, transcript-range, transcript-turn-show, transcript-context, etc. The search is scoped to the resolved session's persisted transcript only. Output uses a deterministic shape: { selector, resolved_session_id, turn_index, created_at_ms, updated_at_ms, total_entries, entry }, where selector echoes the raw input, resolved_session_id is the persisted id the selector actually maps to, turn_index is the newest transcript turn_index present, total_entries is the full transcript length, and entry carries at least turn_index and prompt. Because the contract is to return exactly one entry, an empty transcript has no last turn and fails cleanly and deterministically as transcript turn out of range rather than silently returning nothing. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- transcript-last-turn <session-id>
cargo run -q -p harness-cli -- transcript-last-turn latest
cargo run -q -p harness-cli -- transcript-last-turn label:runtime-review{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"turn_index": 2,
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"total_entries": 3,
"entry": {
"turn_index": 2,
"prompt": "third prompt"
}
}Inspect the oldest persisted transcript entry for a single session — the one whose turn_index is the lowest available (always 0 when non-empty). Useful as a quick "what did I ask first?" drill-down that avoids having to call transcript-turn-show ... --turn 0, and as the symmetric counterpart to transcript-last-turn. Accepts the same selector forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, transcript-show, transcript-tail, transcript-find, transcript-range, transcript-turn-show, transcript-context, transcript-last-turn, etc. The search is scoped to the resolved session's persisted transcript only. Output uses a deterministic shape: { selector, resolved_session_id, turn_index, created_at_ms, updated_at_ms, total_entries, entry }, where selector echoes the raw input, resolved_session_id is the persisted id the selector actually maps to, turn_index is the oldest transcript turn_index present, total_entries is the full transcript length, and entry carries at least turn_index and prompt. Because the contract is to return exactly one entry, an empty transcript has no first turn and fails cleanly and deterministically as transcript turn out of range rather than silently returning nothing. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- transcript-first-turn <session-id>
cargo run -q -p harness-cli -- transcript-first-turn latest
cargo run -q -p harness-cli -- transcript-first-turn label:runtime-review{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"turn_index": 0,
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"total_entries": 3,
"entry": {
"turn_index": 0,
"prompt": "first prompt"
}
}Inspect the persisted transcript length for a single session without returning any transcript entries. Useful as a cheap "how big is this transcript?" probe for scripting, pagination planning, and for confirming that a session has accumulated turns before calling the other transcript-* inspectors. Accepts the same selector forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, transcript-show, transcript-tail, transcript-find, transcript-range, transcript-turn-show, transcript-context, transcript-last-turn, transcript-first-turn, etc. The inspection is scoped to the resolved session's persisted transcript only. Output uses a deterministic shape: { selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries }, where selector echoes the raw input, resolved_session_id is the persisted id the selector actually maps to, and total_entries equals the persisted transcript length. Empty transcripts succeed cleanly with total_entries: 0 — unlike transcript-first-turn / transcript-last-turn, this command's contract does not require returning an entry, so the empty case is valid. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- transcript-entry-count <session-id>
cargo run -q -p harness-cli -- transcript-entry-count latest
cargo run -q -p harness-cli -- transcript-entry-count label:runtime-review{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"total_entries": 3
}Inspect whether a single persisted session transcript is empty without returning any transcript entries. Useful as the cheapest inspect-only guard before calling the other transcript-* inspectors, especially for scripts that only need a boolean answer rather than the exact transcript length. Accepts the same selector forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, transcript-show, transcript-tail, transcript-find, transcript-range, transcript-turn-show, transcript-context, transcript-last-turn, transcript-first-turn, transcript-entry-count, etc. The inspection is scoped to the resolved session's persisted transcript only. Output uses a deterministic shape: { selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, has_entries }, where selector echoes the raw input, resolved_session_id is the persisted id the selector actually maps to, total_entries equals the persisted transcript length, and has_entries is true when total_entries > 0 and false otherwise. Empty transcripts succeed cleanly with total_entries: 0 and has_entries: false. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- transcript-has-entries <session-id>
cargo run -q -p harness-cli -- transcript-has-entries latest
cargo run -q -p harness-cli -- transcript-has-entries label:runtime-review{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"total_entries": 2,
"has_entries": true
}Inspect whether a single persisted session transcript contains an entry whose turn_index exactly matches the requested --turn, without returning any transcript entries. Useful as an inspect-only probe for scripts that want a deterministic boolean answer before deciding whether to call transcript-turn-show, transcript-context, or another transcript inspector. Accepts the same selector forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, transcript-show, transcript-tail, transcript-find, transcript-range, transcript-turn-show, transcript-context, transcript-last-turn, transcript-first-turn, transcript-entry-count, transcript-has-entries, etc. The inspection is scoped to the resolved session's persisted transcript only. Output uses a deterministic shape: { selector, resolved_session_id, turn_index, created_at_ms, updated_at_ms, total_entries, exists }, where selector echoes the raw input, resolved_session_id is the persisted id the selector actually maps to, turn_index echoes the requested turn, total_entries equals the persisted transcript length, and exists is true exactly when the resolved persisted transcript contains an entry whose turn_index == <turn-index>. Empty transcripts succeed cleanly with total_entries: 0 and exists: false, and a --turn past the end of the transcript also succeeds cleanly with exists: false rather than erroring. Negative / non-numeric --turn values fail cleanly at parse time. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- transcript-turn-exists <session-id> --turn 0
cargo run -q -p harness-cli -- transcript-turn-exists latest --turn 1
cargo run -q -p harness-cli -- transcript-turn-exists label:runtime-review --turn 2{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"turn_index": 2,
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"total_entries": 3,
"exists": true
}Inspect the ascending list of turn_index values present in a single persisted session transcript without returning any transcript entry payloads. Useful as an inspect-only probe for scripts that want to enumerate the available turns before calling transcript-turn-show, transcript-context, transcript-range, or another transcript inspector. Accepts the same selector forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, transcript-show, transcript-tail, transcript-find, transcript-range, transcript-turn-show, transcript-context, transcript-last-turn, transcript-first-turn, transcript-entry-count, transcript-has-entries, transcript-turn-exists, etc. The inspection is scoped to the resolved session's persisted transcript only. Output uses a deterministic shape: { selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, turn_indexes }, where selector echoes the raw input, resolved_session_id is the persisted id the selector actually maps to, total_entries equals the persisted transcript length, and turn_indexes is a deterministic ascending array of the turn_index values present in the resolved persisted transcript. Empty transcripts succeed cleanly with total_entries: 0 and turn_indexes: [].
Pass --limit <n> to cap turn_indexes to at most the first n indexes in the existing ascending order. Pass --tail <n> instead to inspect only the highest n indexes while preserving ascending order within the returned slice. The outer JSON shape is preserved for both flags — they only reshape turn_indexes; total_entries continues to reflect the full persisted transcript length and no wrapper object is introduced. --limit 0 / --tail 0 return turn_indexes: [] cleanly, a --limit / --tail larger than total_entries returns every present index cleanly, and omitting both preserves the unlimited behavior above exactly. --limit and --tail are mutually exclusive at parse time so output-shaping semantics stay deterministic. Negative and non-numeric --limit / --tail values fail cleanly at parse time. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- transcript-turn-indexes <session-id>
cargo run -q -p harness-cli -- transcript-turn-indexes latest
cargo run -q -p harness-cli -- transcript-turn-indexes label:runtime-review
cargo run -q -p harness-cli -- transcript-turn-indexes <session-id> --limit 2
cargo run -q -p harness-cli -- transcript-turn-indexes <session-id> --tail 2{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"total_entries": 3,
"turn_indexes": [0, 1, 2]
}Inspect only the lowest and highest turn_index values present in a single persisted session transcript, without returning any transcript entry payloads. Useful as the cheapest inspect-only bounds probe for scripts that only need to know the turn span before deciding whether to call transcript-turn-show, transcript-context, transcript-range, or transcript-turn-indexes. Accepts the same selector forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, transcript-show, transcript-tail, transcript-find, transcript-range, transcript-turn-show, transcript-context, transcript-last-turn, transcript-first-turn, transcript-entry-count, transcript-has-entries, transcript-turn-exists, transcript-turn-indexes, etc. The inspection is scoped to the resolved session's persisted transcript only. Output uses a deterministic shape: { selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, first_turn_index, last_turn_index }, where selector echoes the raw input, resolved_session_id is the persisted id the selector actually maps to, total_entries equals the persisted transcript length, first_turn_index is the smallest present turn_index, and last_turn_index is the largest present turn_index. Empty transcripts succeed cleanly with total_entries: 0, first_turn_index: null, and last_turn_index: null. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- transcript-turn-index-range <session-id>
cargo run -q -p harness-cli -- transcript-turn-index-range latest
cargo run -q -p harness-cli -- transcript-turn-index-range label:runtime-review{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"total_entries": 3,
"first_turn_index": 0,
"last_turn_index": 2
}Inspect whether a single persisted session transcript has at least one missing integer turn_index between the smallest and largest present turn_index values, without returning any transcript entry payloads. Useful as an inspect-only continuity probe for scripts that want a deterministic boolean answer before deciding whether to call transcript-turn-indexes, transcript-turn-index-range, transcript-turn-show, transcript-context, or another transcript inspector. Accepts the same selector forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, transcript-show, transcript-tail, transcript-find, transcript-range, transcript-turn-show, transcript-context, transcript-last-turn, transcript-first-turn, transcript-entry-count, transcript-has-entries, transcript-turn-exists, transcript-turn-indexes, transcript-turn-index-range, etc. The inspection is scoped to the resolved session's persisted transcript only. Output uses a deterministic shape: { selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, has_turn_gaps }, where selector echoes the raw input, resolved_session_id is the persisted id the selector actually maps to, total_entries equals the persisted transcript length, and has_turn_gaps is true exactly when at least one integer turn_index between the smallest and largest present turn_index values is missing from the resolved persisted transcript. Empty transcripts and single-entry transcripts succeed cleanly with has_turn_gaps: false. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- transcript-has-turn-gaps <session-id>
cargo run -q -p harness-cli -- transcript-has-turn-gaps latest
cargo run -q -p harness-cli -- transcript-has-turn-gaps label:runtime-review{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"total_entries": 3,
"has_turn_gaps": false
}Inspect which integer turn_index values are missing inside the persisted turn span of a single persisted session transcript, without returning any transcript entry payloads. Useful as the inspect-only continuity-diagnostic probe for scripts that already know the transcript has gaps (via transcript-has-turn-gaps) and need to explain or repair them before deciding whether to call transcript-turn-show, transcript-context, transcript-range, or another transcript inspector. Accepts the same selector forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, transcript-show, transcript-tail, transcript-find, transcript-range, transcript-turn-show, transcript-context, transcript-last-turn, transcript-first-turn, transcript-entry-count, transcript-has-entries, transcript-turn-exists, transcript-turn-indexes, transcript-turn-index-range, transcript-has-turn-gaps, etc. The inspection is scoped to the resolved session's persisted transcript only. Output uses a deterministic shape: { selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, missing_turn_indexes }, where selector echoes the raw input, resolved_session_id is the persisted id the selector actually maps to, total_entries equals the persisted transcript length, and missing_turn_indexes is an ascending array of every missing integer turn_index between the smallest and largest present turn_index values in the resolved persisted transcript. Empty transcripts, single-entry transcripts, and contiguous transcripts succeed cleanly with missing_turn_indexes: [].
Pass --limit <n> to cap missing_turn_indexes to at most the first n missing indexes in the existing ascending order. Pass --tail <n> instead to inspect only the newest n missing indexes — the highest n gap indexes — while preserving ascending order within the returned slice. The outer JSON shape is preserved for both flags — they only reshape missing_turn_indexes; total_entries continues to reflect the full persisted transcript length and no wrapper object is introduced. --limit 0 / --tail 0 return missing_turn_indexes: [] cleanly, a --limit / --tail larger than the number of missing indexes returns every missing index cleanly, and omitting both preserves the unlimited behavior above exactly. --limit and --tail are mutually exclusive at parse time so output-shaping semantics stay deterministic. Negative and non-numeric --limit / --tail values fail cleanly at parse time. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- transcript-missing-turn-indexes <session-id>
cargo run -q -p harness-cli -- transcript-missing-turn-indexes latest
cargo run -q -p harness-cli -- transcript-missing-turn-indexes label:runtime-review
cargo run -q -p harness-cli -- transcript-missing-turn-indexes <session-id> --limit 2
cargo run -q -p harness-cli -- transcript-missing-turn-indexes <session-id> --tail 2{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"total_entries": 3,
"missing_turn_indexes": []
}Inspect how densely populated a single persisted session transcript's turn_index span is, without returning any transcript entry payloads. Useful as the inspect-only continuity-ratio probe for scripts that want to quantify transcript continuity quality (for dashboards, health checks, or triage decisions) without pulling the full present / missing index arrays returned by transcript-turn-indexes or transcript-missing-turn-indexes. Accepts the same selector forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, transcript-show, transcript-tail, transcript-find, transcript-range, transcript-turn-show, transcript-context, transcript-last-turn, transcript-first-turn, transcript-entry-count, transcript-has-entries, transcript-turn-exists, transcript-turn-indexes, transcript-turn-index-range, transcript-has-turn-gaps, transcript-missing-turn-indexes, etc. The inspection is scoped to the resolved session's persisted transcript only. Output uses a deterministic shape: { selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, span_entry_count, missing_turn_count, turn_density }, where selector echoes the raw input, resolved_session_id is the persisted id the selector actually maps to, total_entries equals the persisted transcript length, span_entry_count is the number of integer turn positions in the inclusive span from the smallest present turn_index to the largest present turn_index, missing_turn_count equals span_entry_count - total_entries, and turn_density equals total_entries / span_entry_count as a deterministic numeric value. Empty transcripts succeed cleanly with total_entries: 0, span_entry_count: 0, missing_turn_count: 0, and turn_density: 1.0. Single-entry and contiguous transcripts report missing_turn_count: 0 and turn_density: 1.0. Gapped transcripts report a turn_density strictly less than 1.0. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- transcript-turn-density <session-id>
cargo run -q -p harness-cli -- transcript-turn-density latest
cargo run -q -p harness-cli -- transcript-turn-density label:runtime-review{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"total_entries": 3,
"span_entry_count": 3,
"missing_turn_count": 0,
"turn_density": 1.0
}Inspect the contiguous runs of missing integer turn_index values inside the persisted turn span of a single persisted session transcript, without returning any transcript entry payloads. Useful as the inspect-only continuity gap-run probe for scripts that already know the transcript has gaps (via transcript-has-turn-gaps) and want to describe those gaps as ranges — for backfill planners, repair scripts, or triage dashboards — without the fully-expanded per-index list returned by transcript-missing-turn-indexes. Accepts the same selector forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, transcript-show, transcript-tail, transcript-find, transcript-range, transcript-turn-show, transcript-context, transcript-last-turn, transcript-first-turn, transcript-entry-count, transcript-has-entries, transcript-turn-exists, transcript-turn-indexes, transcript-turn-index-range, transcript-has-turn-gaps, transcript-missing-turn-indexes, transcript-turn-density, etc. The inspection is scoped to the resolved session's persisted transcript only. Output uses a deterministic shape: { selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, gap_ranges }, where selector echoes the raw input, resolved_session_id is the persisted id the selector actually maps to, total_entries equals the persisted transcript length, and gap_ranges is an ascending array of contiguous missing-turn runs between the smallest and largest present turn_index values. Each range carries { start_turn_index, end_turn_index, missing_count } with inclusive bounds; single missing turns collapse to start_turn_index == end_turn_index and missing_count == 1; adjacent missing turns collapse into one range and disjoint gaps produce multiple ascending ranges. Empty transcripts, single-entry transcripts, and contiguous transcripts succeed cleanly with gap_ranges: [].
Pass --limit <n> to cap gap_ranges to at most the first n ranges in the existing ascending order. Pass --tail <n> instead to inspect only the newest n gap ranges — the last n ranges from the existing ascending order — while preserving ascending order within the returned slice. The outer JSON shape is preserved for both flags — they only reshape gap_ranges; total_entries continues to reflect the full persisted transcript length and no wrapper object is introduced. --limit 0 / --tail 0 return gap_ranges: [] cleanly, a --limit / --tail larger than the number of gap ranges returns every gap range cleanly, and omitting both preserves the unlimited behavior above exactly. --limit and --tail are mutually exclusive at parse time so output-shaping semantics stay deterministic. Negative and non-numeric --limit / --tail values fail cleanly at parse time. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- transcript-gap-ranges <session-id>
cargo run -q -p harness-cli -- transcript-gap-ranges latest
cargo run -q -p harness-cli -- transcript-gap-ranges label:runtime-review
cargo run -q -p harness-cli -- transcript-gap-ranges <session-id> --limit 2
cargo run -q -p harness-cli -- transcript-gap-ranges <session-id> --tail 2{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"total_entries": 3,
"gap_ranges": []
}Inspect only the single largest contiguous run of missing integer turn_index values inside the persisted turn span of a single persisted session transcript, without returning any transcript entry payloads. Useful as the inspect-only continuity max-gap probe for scripts that already know the transcript has gaps (via transcript-has-turn-gaps) and want the worst single gap run — for backfill prioritization, repair triage, or summarization dashboards — without the fully-expanded list returned by transcript-gap-ranges. Accepts the same selector forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, transcript-show, transcript-tail, transcript-find, transcript-range, transcript-turn-show, transcript-context, transcript-last-turn, transcript-first-turn, transcript-entry-count, transcript-has-entries, transcript-turn-exists, transcript-turn-indexes, transcript-turn-index-range, transcript-has-turn-gaps, transcript-missing-turn-indexes, transcript-turn-density, transcript-gap-ranges, etc. The inspection is scoped to the resolved session's persisted transcript only. Output uses a deterministic shape: { selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, largest_gap }, where selector echoes the raw input, resolved_session_id is the persisted id the selector actually maps to, total_entries equals the persisted transcript length, and largest_gap is either null when no gap exists or an object carrying { start_turn_index, end_turn_index, missing_count } with inclusive bounds. A single missing turn collapses to a run where start_turn_index == end_turn_index and missing_count == 1; when multiple gap runs tie for the highest missing_count, the earliest run (lowest start_turn_index) wins deterministically. Empty transcripts, single-entry transcripts, and contiguous transcripts succeed cleanly with largest_gap: null. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- transcript-largest-gap <session-id>
cargo run -q -p harness-cli -- transcript-largest-gap latest
cargo run -q -p harness-cli -- transcript-largest-gap label:runtime-review{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"total_entries": 3,
"largest_gap": null
}Inspect only the single smallest contiguous run of missing integer turn_index values inside the persisted turn span of a single persisted session transcript, without returning any transcript entry payloads. Useful as the inspect-only continuity min-gap probe for scripts that already know the transcript has gaps (via transcript-has-turn-gaps) and want the narrowest single gap run — for backfill triage of the easiest-to-repair run, repair sequencing, or fragmentation dashboards — without the fully-expanded list returned by transcript-gap-ranges or the worst-run-only detail returned by transcript-largest-gap. Accepts the same selector forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, transcript-show, transcript-tail, transcript-find, transcript-range, transcript-turn-show, transcript-context, transcript-last-turn, transcript-first-turn, transcript-entry-count, transcript-has-entries, transcript-turn-exists, transcript-turn-indexes, transcript-turn-index-range, transcript-has-turn-gaps, transcript-missing-turn-indexes, transcript-turn-density, transcript-gap-ranges, transcript-largest-gap, etc. The inspection is scoped to the resolved session's persisted transcript only. Output uses a deterministic shape: { selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, smallest_gap }, where selector echoes the raw input, resolved_session_id is the persisted id the selector actually maps to, total_entries equals the persisted transcript length, and smallest_gap is either null when no gap exists or an object carrying { start_turn_index, end_turn_index, missing_count } with inclusive bounds. A single missing turn collapses to a run where start_turn_index == end_turn_index and missing_count == 1; when multiple gap runs tie for the lowest missing_count, the earliest run (lowest start_turn_index) wins deterministically. Empty transcripts, single-entry transcripts, and contiguous transcripts succeed cleanly with smallest_gap: null. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- transcript-smallest-gap <session-id>
cargo run -q -p harness-cli -- transcript-smallest-gap latest
cargo run -q -p harness-cli -- transcript-smallest-gap label:runtime-review{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"total_entries": 3,
"smallest_gap": null
}Inspect only the number of contiguous runs of missing integer turn_index values inside the persisted turn span of a single persisted session transcript, without returning the runs themselves or any transcript entry payloads. Useful as the inspect-only continuity gap-run-count probe for scripts that already know the transcript has gaps (via transcript-has-turn-gaps) and want a single scalar describing how fragmented the missing turns are — for dashboards, triage heuristics, or health checks — without the per-range detail returned by transcript-gap-ranges or the single worst-run detail returned by transcript-largest-gap. Accepts the same selector forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, transcript-show, transcript-tail, transcript-find, transcript-range, transcript-turn-show, transcript-context, transcript-last-turn, transcript-first-turn, transcript-entry-count, transcript-has-entries, transcript-turn-exists, transcript-turn-indexes, transcript-turn-index-range, transcript-has-turn-gaps, transcript-missing-turn-indexes, transcript-turn-density, transcript-gap-ranges, transcript-largest-gap, etc. The inspection is scoped to the resolved session's persisted transcript only. Output uses a deterministic shape: { selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, gap_count }, where selector echoes the raw input, resolved_session_id is the persisted id the selector actually maps to, total_entries equals the persisted transcript length, and gap_count is the number of contiguous missing-turn_index runs between the smallest and largest present turn_index values. Adjacent missing turns collapse into one run; disjoint runs count separately. Empty transcripts, single-entry transcripts, and contiguous transcripts succeed cleanly with gap_count: 0. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- transcript-gap-count <session-id>
cargo run -q -p harness-cli -- transcript-gap-count latest
cargo run -q -p harness-cli -- transcript-gap-count label:runtime-review{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"total_entries": 3,
"gap_count": 0
}Inspect only the total count of individual missing integer turn_index values inside the persisted turn span of a single persisted session transcript, without returning the missing indexes themselves or any transcript entry payloads. Useful as the inspect-only continuity missing-turn-tally probe for scripts that already know the transcript has gaps (via transcript-has-turn-gaps) and want a single scalar describing how many turns are missing in total — for dashboards, triage heuristics, or health checks — without the per-index detail returned by transcript-missing-turn-indexes, the per-run detail returned by transcript-gap-ranges, or the compound missing_turn_count / turn_density payload returned by transcript-turn-density. Accepts the same selector forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, transcript-show, transcript-tail, transcript-find, transcript-range, transcript-turn-show, transcript-context, transcript-last-turn, transcript-first-turn, transcript-entry-count, transcript-has-entries, transcript-turn-exists, transcript-turn-indexes, transcript-turn-index-range, transcript-has-turn-gaps, transcript-missing-turn-indexes, transcript-turn-density, transcript-gap-ranges, transcript-largest-gap, transcript-smallest-gap, transcript-gap-count, etc. The inspection is scoped to the resolved session's persisted transcript only. Output uses a deterministic shape: { selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, missing_turn_count }, where selector echoes the raw input, resolved_session_id is the persisted id the selector actually maps to, total_entries equals the persisted transcript length, and missing_turn_count is the number of individual missing integer turn_index values between the smallest and largest present turn_index values. Every missing integer position is counted — one missing turn contributes 1, a run of three missing turns contributes 3, and disjoint runs sum additively. Empty transcripts, single-entry transcripts, and contiguous transcripts succeed cleanly with missing_turn_count: 0. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. No persisted session state, transcript entry, label, pinned flag, id, path, or ordering metadata is mutated.
cargo run -q -p harness-cli -- transcript-missing-turn-count <session-id>
cargo run -q -p harness-cli -- transcript-missing-turn-count latest
cargo run -q -p harness-cli -- transcript-missing-turn-count label:runtime-review{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"total_entries": 3,
"missing_turn_count": 0
}Export one persisted session as a single machine-readable JSON bundle that packages the session state and its transcript together. <selector> accepts any of the three forms every other single-session command accepts — a raw session_id, the literal latest, or label:<name> — routed through the shared selector-resolution path. The output uses a deterministic shape: { exported_session_id, session, transcript }, where session is the same structure printed by session-show and transcript is the same structure printed by transcript-show. The exported_session_id confirms which session was exported, always restates the actual resolved session_id (never the typed selector string), and equals the session_id inside both nested records. Turn ordering in transcript.entries is preserved in turn_index order so the bundle is safe to attach to bug reports or archive outside the repo-local .sessions/ layout. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector.
cargo run -q -p harness-cli -- session-export <session-id>{
"exported_session_id": "<session-id>",
"session": {
"session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"messages": [
"review bash"
],
"usage": {
"input_tokens": 2,
"output_tokens": 2
}
},
"transcript": {
"session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"entries": [
{
"turn_index": 0,
"prompt": "review bash"
}
]
}
}latest resolves to the most recently active persisted session, mirroring how session-show latest and transcript-show latest resolve their targets.
cargo run -q -p harness-cli -- session-export latest{
"exported_session_id": "<session-id>",
"session": {
"session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"messages": [
"review bash"
],
"usage": {
"input_tokens": 2,
"output_tokens": 2
}
},
"transcript": {
"session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"entries": [
{
"turn_index": 0,
"prompt": "review bash"
}
]
}
}Compare two persisted sessions side-by-side as a single machine-readable JSON bundle. Both positional arguments accept the same three selector forms every other single-session command accepts — a raw session_id, the literal latest, or label:<name> — routed through the shared selector-resolution path so the two sides are independent and can mix forms freely (for example label:left-review latest). The output uses a deterministic shape: { left_session_id, right_session_id, left, right, differences }. Both left and right carry the compared session's resolved session_id, recency metadata (created_at_ms, updated_at_ms), and activity metadata (message_count, transcript_entry_count). differences reports signed deltas computed as right - left so the comparison direction is preserved, plus a same_session flag that is true when both sides resolve to the same persisted session. Machine-readable output always surfaces the actual resolved session_id values rather than the typed selector strings. Selector failure semantics are unchanged and apply independently to each side: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector.
cargo run -q -p harness-cli -- session-compare <left-session-id> <right-session-id>{
"left_session_id": "<left-session-id>",
"right_session_id": "<right-session-id>",
"left": {
"session_id": "<left-session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"message_count": 1,
"transcript_entry_count": 1
},
"right": {
"session_id": "<right-session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"message_count": 1,
"transcript_entry_count": 1
},
"differences": {
"same_session": false,
"created_at_ms_delta": <created-at-ms-delta>,
"updated_at_ms_delta": <updated-at-ms-delta>,
"message_count_delta": 0,
"transcript_entry_count_delta": 0
}
}Resolving both sides to latest yields a deterministic self-comparison where same_session is true and every delta is 0. This is the smallest way to confirm the comparison path is healthy without needing two distinct persisted sessions in hand.
cargo run -q -p harness-cli -- session-compare latest latest{
"left_session_id": "<session-id>",
"right_session_id": "<session-id>",
"left": {
"session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"message_count": 1,
"transcript_entry_count": 1
},
"right": {
"session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"message_count": 1,
"transcript_entry_count": 1
},
"differences": {
"same_session": true,
"created_at_ms_delta": 0,
"updated_at_ms_delta": 0,
"message_count_delta": 0,
"transcript_entry_count_delta": 0
}
}Remove one persisted session cleanly. <selector> accepts any of the three forms every other single-session command accepts — a raw session_id, the literal latest, or label:<name> — routed through the shared selector-resolution path. Deletion takes both persisted artifacts for the session in one call: the session JSON (.sessions/<session-id>.json) and its sibling transcript JSON (.sessions/<session-id>.transcript.json). The output uses a deterministic shape: { deleted_session_id, removed_paths }, where deleted_session_id confirms which session was targeted and always restates the actual resolved session_id (never the typed selector string), and removed_paths lists the files that were actually removed in the order the store removed them (session JSON first, then transcript). Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. If the target session does not exist the command fails without deleting anything else.
cargo run -q -p harness-cli -- session-delete <session-id>{
"deleted_session_id": "<session-id>",
"removed_paths": [
".sessions/<session-id>.json",
".sessions/<session-id>.transcript.json"
]
}latest resolves to the most recently active persisted session, mirroring how session-show latest, transcript-show latest, session-export latest, and session-compare latest latest resolve their targets. This is the ergonomic way to drop the session you just created without having to copy its id by hand.
cargo run -q -p harness-cli -- session-delete latest{
"deleted_session_id": "<session-id>",
"removed_paths": [
".sessions/<session-id>.json",
".sessions/<session-id>.transcript.json"
]
}Restore a persisted session from a bundle file previously emitted by session-export. The input must match the exported shape { exported_session_id, session, transcript }: the three ids must agree, and transcript turn_index values must be monotonic starting at 0. On success both persisted artifacts are recreated in the local .sessions/ directory — the session JSON at .sessions/<session-id>.json and the sibling transcript JSON at .sessions/<session-id>.transcript.json — preserving the imported session id, recency/activity metadata, and turn_index ordering exactly as carried in the bundle. If the bundle is malformed or the target session id already exists locally, the command fails cleanly without overwriting unrelated persisted sessions.
cargo run -q -p harness-cli -- session-import ./bundle.json{
"imported_session_id": "<session-id>",
"session_path": ".sessions/<session-id>.json",
"transcript_path": ".sessions/<session-id>.transcript.json"
}Search persisted local sessions by transcript prompt text without mutating any session state. The query is matched case-insensitively as a substring against each persisted transcript entry. The output is a deterministic JSON array of result objects, one per session that contains at least one matching transcript entry, ordered using the same newest-first session ordering as sessions (most recently updated session first, then by created-at, then by session id). Each result identifies the matched session_id and includes the session's recency metadata (created_at_ms, updated_at_ms), message_count, persisted_path, and a matches array. Each entry in matches records the matched turn_index plus the persisted prompt text, so the result is useful from the terminal without a follow-up transcript-show call. An empty query and a query with no matches both succeed cleanly with an empty array ([]) instead of erroring.
cargo run -q -p harness-cli -- session-find review[
{
"session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"message_count": 1,
"persisted_path": ".sessions/<session-id>.json",
"matches": [
{
"turn_index": 0,
"prompt": "review bash"
}
]
}
]Pass --limit <n> to cap the result set to at most the newest n matching persisted sessions in the existing newest-first ordering. Pass --tail <n> instead to return only the last n rows from that same ordered result set — because session-find is newest-first, --tail surfaces the oldest n matching sessions while preserving the ordering. The per-row JSON shape is preserved — both flags only slice the array, they do not wrap the output. Match filtering is preserved too — sessions with no matching transcript entries stay omitted, and each retained row's matches array is unchanged. --limit 0 / --tail 0 return an empty array cleanly, a --limit / --tail larger than the matched subset returns every matching session, and omitting both flags preserves the unlimited listing above exactly. --limit and --tail are mutually exclusive at parse time so output-shaping semantics stay deterministic. Negative and non-numeric --limit / --tail values fail cleanly at parse time.
cargo run -q -p harness-cli -- session-find review --limit 1
cargo run -q -p harness-cli -- session-find review --tail 1An empty query, or a query that matches no persisted transcript entries, returns an empty JSON array instead of erroring. The example below uses a query that no persisted transcript contains, so the output is the deterministic empty result [].
cargo run -q -p harness-cli -- session-find definitely-not-present[]Fork a persisted session so a new line of work can diverge from an existing turn without mutating the source. <selector> identifies the source session and accepts any of the three forms every other single-session command accepts — a raw session_id, the literal latest, or label:<name> — routed through the shared selector-resolution path. The fork creates a fresh session_id, carries forward the source session's messages and transcript in order, and appends the new prompt as the first divergent turn. Both persisted artifacts are written for the forked session — the session JSON at .sessions/<forked-session-id>.json and the sibling transcript JSON at .sessions/<forked-session-id>.transcript.json — while the source session JSON and transcript are left exactly as they were. The output uses a deterministic shape: { source_session_id, forked_session_id, appended_turn_index, session_path, transcript_path }. source_session_id confirms which session the fork diverged from, always restates the actual resolved session_id (never the typed selector string); forked_session_id is the new persisted id; and appended_turn_index marks where the new prompt landed in the forked transcript (equal to the source's message count). Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector.
cargo run -q -p harness-cli -- session-fork <source-session-id> "try again"{
"source_session_id": "<source-session-id>",
"forked_session_id": "<forked-session-id>",
"appended_turn_index": 1,
"session_path": ".sessions/<forked-session-id>.json",
"transcript_path": ".sessions/<forked-session-id>.transcript.json"
}latest resolves to the most recently active persisted session, mirroring how session-show latest, transcript-show latest, session-export latest, session-compare latest latest, and session-delete latest resolve their targets. This is the ergonomic way to branch off the session you just worked on without having to copy its id by hand.
cargo run -q -p harness-cli -- session-fork latest "try again"{
"source_session_id": "<source-session-id>",
"forked_session_id": "<forked-session-id>",
"appended_turn_index": 1,
"session_path": ".sessions/<forked-session-id>.json",
"transcript_path": ".sessions/<forked-session-id>.transcript.json"
}Attach a deterministic human-readable label to a persisted session so it is easier to recognize in sessions, session-show, session-export, and related output. <selector> accepts any of the three forms every other single-session command accepts — a raw session_id, the literal latest, or label:<old-name> — routed through the shared selector-resolution path, and <label> is the new label to apply. The rename preserves the existing session_id, does not mutate transcript entries or transcript ordering, and does not bump updated_at_ms so newest-first ordering stays activity-based. Labels are trimmed of surrounding whitespace, and empty or whitespace-only labels are rejected cleanly. The output uses a deterministic shape: { renamed_session_id, applied_label }, where renamed_session_id confirms which session was targeted and always restates the actual resolved session_id (never the typed selector string), and applied_label is the normalized label that was persisted. Older unlabeled sessions stay readable — the label field only appears in persisted JSON after a session has actually been labeled. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector.
cargo run -q -p harness-cli -- session-rename <session-id> runtime-review{
"renamed_session_id": "<session-id>",
"applied_label": "runtime-review"
}latest resolves to the most recently active persisted session, mirroring how session-show latest, transcript-show latest, session-export latest, session-compare latest latest, session-delete latest, and session-fork latest resolve their targets. This is the ergonomic way to label the session you just worked on without having to copy its id by hand.
cargo run -q -p harness-cli -- session-rename latest runtime-review{
"renamed_session_id": "<session-id>",
"applied_label": "runtime-review"
}Once a session has been renamed via session-rename, the label:<name> selector targets that session anywhere a single persisted session id is accepted: session-show, transcript-show, resume, session-export, session-delete, session-fork, session-rename, and on either side of session-compare. Raw session ids and the latest selector continue to behave exactly as before — label support is additive.
cargo run -q -p harness-cli -- session-show label:runtime-review
cargo run -q -p harness-cli -- session-compare label:runtime-review latestSelector resolution rules:
latest— most recently active persisted session, ordering driven byupdated_at_ms(unchanged)label:<name>— the unique persisted session whose normalized label equals<name>(whitespace around<name>is trimmed)- anything else — treated as a raw session id and looked up directly
Failure modes are deterministic and distinct so the CLI surfaces the right diagnosis:
- unknown label (no persisted session carries
<name>) →session not found: label:<name> - ambiguous label (more than one persisted session shares
<name>) →ambiguous session label: label "<name>" matches N persisted sessions - malformed selector (
label:with no name) →malformed session selector: label selector requires a non-empty label after \label:``
Machine-readable JSON outputs continue to identify the actual resolved session_id values rather than echoing the selector string, so downstream tooling can rely on the resolved id even when the user typed label:<name> or latest. Older unlabeled sessions and mixed labeled/unlabeled stores keep working — sessions without a label are transparently skipped during label resolution.
Remove the persisted label from a session without touching its session_id, transcript entries, transcript ordering, or updated_at_ms — newest-first ordering stays activity-based. The output uses a deterministic shape: { unlabeled_session_id, removed_label }, where unlabeled_session_id confirms which session was targeted and removed_label is the label that was cleared. <selector> accepts raw session_id, latest, or label:<name> routed through the shared selector-resolution path. Older unlabeled sessions remain backward-compatible: once a label is removed, the session no longer serializes a label field at all (no null, no empty string). Attempting to unlabel a session that is already unlabeled fails cleanly with session already unlabeled: <session-id> so the operation never silently no-ops, and unknown session ids or selectors still surface as session not found.
cargo run -q -p harness-cli -- session-unlabel <session-id>{
"unlabeled_session_id": "<session-id>",
"removed_label": "runtime-review"
}latest resolves to the most recently active persisted session, and label:<name> is accepted here too, mirroring every other single-session command. This closes the label-management loop alongside session-rename, session-labels, and label:<name> selectors: rename a session, discover labels, target by label, and remove a label when it is no longer useful — all without disturbing transcript history.
cargo run -q -p harness-cli -- session-unlabel latest
cargo run -q -p harness-cli -- session-unlabel label:runtime-review{
"unlabeled_session_id": "<session-id>",
"removed_label": "runtime-review"
}List every persisted session that currently carries a label, without touching session state or transcripts. Output is a deterministic JSON array ordered using the same newest-first ordering as sessions (most recently updated first, then by created_at_ms, then by session_id, then by persisted_path). Each entry exposes label, session_id, created_at_ms, updated_at_ms, message_count, and persisted_path so the listing is useful from the terminal without a follow-up session-show. Unlabeled sessions are omitted. Duplicate labels stay visible as separate rows — the listing makes ambiguity discoverable before a label:<name> selector would fail with AmbiguousLabel.
cargo run -q -p harness-cli -- session-labels[
{
"label": "runtime-review",
"session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"message_count": 1,
"persisted_path": ".sessions/<session-id>.json"
}
]Pass --limit <n> to cap the listing to at most the newest n labeled persisted sessions in the existing newest-first ordering. Or pass --tail <n> to retain only the last n rows from that same ordered labeled subset — because the listing is already newest-first, --tail surfaces the oldest retained labeled sessions while preserving their existing ordering. The per-row JSON shape is preserved in both cases — these flags only slice the array, they do not wrap the output. Labeled-session filtering is preserved too — unlabeled sessions stay omitted and duplicate labels remain visible as separate rows under limiting or tailing. --limit 0 / --tail 0 return an empty array cleanly, oversized bounds return every labeled session cleanly, omitting both flags preserves the unlimited listing above exactly, and --limit conflicts with --tail at clap parse time so the bounded-output semantics stay deterministic.
cargo run -q -p harness-cli -- session-labels --limit 1
cargo run -q -p harness-cli -- session-labels --tail 1If no persisted session carries a label, session-labels returns an empty JSON array instead of erroring, so scripts can treat "no labels" and "none yet" identically.
cargo run -q -p harness-cli -- session-labels[]List every persisted session that is currently pinned, without touching session state or transcripts. Output is a deterministic JSON array ordered using the same newest-first ordering as sessions and session-labels (most recently updated first, then by created_at_ms, then by session_id, then by persisted_path). Each entry exposes session_id, created_at_ms, updated_at_ms, message_count, persisted_path, and pinned, and surfaces label when the pinned session carries one so the listing is useful from the terminal without a follow-up session-show. Unpinned sessions are omitted. Duplicate labels on pinned sessions stay visible as separate rows — nothing is collapsed. Pair it with session-prune --keep <count> to audit which sessions are protected from prune before running the prune.
cargo run -q -p harness-cli -- session-pins[
{
"session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"message_count": 1,
"persisted_path": ".sessions/<session-id>.json",
"pinned": true,
"label": "runtime-review"
}
]Pass --limit <n> to cap the listing to at most the newest n pinned persisted sessions in the existing newest-first ordering. The per-row JSON shape is preserved — --limit only truncates the array, it does not wrap the output. Pinned-session filtering is preserved too — unpinned sessions stay omitted and duplicate labels on pinned sessions remain visible as separate rows under limiting. --limit 0 returns an empty array cleanly, a --limit larger than the pinned subset returns every pinned session, and omitting --limit preserves the unlimited listing above exactly.
cargo run -q -p harness-cli -- session-pins --limit 1If no persisted session is pinned, session-pins returns an empty JSON array instead of erroring, so scripts can treat "no pins" and "none yet" identically.
cargo run -q -p harness-cli -- session-pins[]Atomically replace the persisted label on a session that already carries one, in a single step instead of chaining session-unlabel with session-rename. The retag preserves the existing session_id, does not mutate transcript entries or transcript ordering, and does not bump updated_at_ms so newest-first ordering stays activity-based. Labels are trimmed of surrounding whitespace, and empty or whitespace-only labels are rejected cleanly. If the requested label normalizes to the same effective value already persisted on the session, the command fails with session already labeled: ... rather than silently no-opping. The output uses a deterministic shape: { retagged_session_id, previous_label, applied_label }, where retagged_session_id confirms which session was targeted, previous_label is the label that was replaced, and applied_label is the normalized label that now sits on the session. <selector> accepts raw session_id, latest, or label:<old-name> routed through the shared selector-resolution path. Older unlabeled sessions remain readable — the label field only appears in persisted JSON after a session has actually been labeled.
cargo run -q -p harness-cli -- session-retag <session-id> release-candidate{
"retagged_session_id": "<session-id>",
"previous_label": "runtime-review",
"applied_label": "release-candidate"
}latest resolves to the most recently active persisted session, and label:<old-name> is accepted here too, mirroring every other single-session command. This makes session-retag label:<old-name> <new-name> the ergonomic single-step relabel: find the session by its current label, apply the new one, and keep transcript history untouched.
cargo run -q -p harness-cli -- session-retag latest release-candidate
cargo run -q -p harness-cli -- session-retag label:runtime-review release-candidate{
"retagged_session_id": "<session-id>",
"previous_label": "runtime-review",
"applied_label": "release-candidate"
}Bulk-remove older persisted sessions without touching the newest <count> prune-eligible (unpinned) sessions. Pinned sessions are always preserved and are reported under pinned_preserved_count / pinned_preserved regardless of <count> — see session-pin <selector>. Ordering matches sessions and session-labels (most recently updated first, then created_at_ms, then session_id, then persisted_path), applied only across the unpinned subset, so the "newest N" preserved set is the same one every other command surfaces after excluding pinned sessions. For each pruned session, both persisted artifacts are removed together: the .sessions/<session-id>.json file and the sibling .sessions/<session-id>.transcript.json. Preserved sessions are never mutated — their label, pinned flag, transcript entries, transcript ordering, and activity metadata stay exactly as they were. The output uses a deterministic shape: { kept_count, pruned_count, pinned_preserved_count, removed, pinned_preserved }, where removed is a JSON array — one entry per pruned session — identifying the pruned session_id together with the removed session_path and transcript_path, and pinned_preserved is a JSON array of session_id values for every pinned session that was held back from pruning. If the store already contains <count> or fewer unpinned sessions the call succeeds cleanly with removed: []. --keep 0 is supported and prunes every unpinned persisted session.
cargo run -q -p harness-cli -- session-prune --keep 1{
"kept_count": 1,
"pruned_count": 1,
"pinned_preserved_count": 0,
"removed": [
{
"session_id": "<pruned-session-id>",
"session_path": ".sessions/<pruned-session-id>.json",
"transcript_path": ".sessions/<pruned-session-id>.transcript.json"
}
],
"pinned_preserved": []
}When the store already contains <count> or fewer unpinned persisted sessions, session-prune returns a deterministic empty removed array instead of erroring, so scripts can treat "already within the retention budget" and "just ran a prune" identically. Pinned sessions do not count against the retention budget and surface through pinned_preserved_count / pinned_preserved.
cargo run -q -p harness-cli -- session-prune --keep 10{
"kept_count": 1,
"pruned_count": 0,
"pinned_preserved_count": 0,
"removed": [],
"pinned_preserved": []
}Mark a persisted session as pinned so it is permanently excluded from session-prune's retention-based removal regardless of the --keep budget. <selector> accepts any of the three forms every other single-session command accepts — a raw session_id, the literal latest, or label:<name> — routed through the shared selector-resolution path. Pin preserves the existing session_id, does not mutate transcript entries or transcript ordering, and does not bump updated_at_ms so newest-first ordering stays activity-based. Messages, usage, and labels are untouched. The output uses a deterministic shape: { pinned_session_id, pinned }, where pinned_session_id confirms which session was targeted and always restates the actual resolved session_id (never the typed selector string), and pinned is true on success. Older unpinned sessions stay byte-compatible: the pinned field is only serialized into persisted JSON after a session has actually been pinned. Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. Attempting to pin a session that is already pinned fails cleanly with session already pinned: <session-id> so the operation never silently no-ops.
cargo run -q -p harness-cli -- session-pin <session-id>{
"pinned_session_id": "<session-id>",
"pinned": true
}latest resolves to the most recently active persisted session, and label:<name> is accepted here too, mirroring every other single-session command via the shared selector path. session-pin pairs with session-prune so the sessions you care about can be pinned once and then stay safe from any future prune invocation.
cargo run -q -p harness-cli -- session-pin latest
cargo run -q -p harness-cli -- session-pin label:runtime-review{
"pinned_session_id": "<session-id>",
"pinned": true
}Clear the pinned flag on a persisted session so it becomes eligible for session-prune again. <selector> accepts any of the three forms every other single-session command accepts — a raw session_id, the literal latest, or label:<name> — routed through the shared selector-resolution path. Unpin preserves the existing session_id, does not mutate transcript entries or transcript ordering, and does not bump updated_at_ms so newest-first ordering stays activity-based. Messages, usage, and labels are untouched. The output uses a deterministic shape: { unpinned_session_id, pinned }, where unpinned_session_id confirms which session was targeted and always restates the actual resolved session_id (never the typed selector string), and pinned is false on success. Older unpinned sessions stay backward-compatible: once the pin is cleared, the session no longer serializes a pinned field at all (no null, no false). Selector failure semantics are unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label, and label: with no name surfaces as malformed selector. Attempting to unpin a session that is not pinned fails cleanly with session already unpinned: <session-id> so the operation never silently no-ops.
cargo run -q -p harness-cli -- session-unpin <session-id>{
"unpinned_session_id": "<session-id>",
"pinned": false
}latest resolves to the most recently active persisted session, and label:<name> is accepted here too, mirroring every other single-session command. This closes the pin-management loop alongside session-pin and session-prune: pin the sessions you want to keep, prune the rest on a budget, and unpin anything that no longer needs that protection — all without disturbing transcript history.
cargo run -q -p harness-cli -- session-unpin latest
cargo run -q -p harness-cli -- session-unpin label:runtime-review{
"unpinned_session_id": "<session-id>",
"pinned": false
}Resolve a single-session selector and surface the targeted persisted session's descriptive metadata without mutating any persisted state, transcript entry, label, pinned flag, id, path, or ordering metadata. Accepts the same forms every other single-session command accepts — a raw session_id, latest, or label:<name> — routed through the shared selector-resolution path so behavior is identical to session-show, session-pin, etc. Output uses a deterministic shape: { selector, resolved_session_id, created_at_ms, updated_at_ms, message_count, persisted_path, label?, pinned? }, where selector echoes the raw input verbatim (so scripts can correlate the request with the resolution) and resolved_session_id is the persisted id the selector actually maps to. label is only emitted when the targeted session carries one, and pinned is only emitted when true, mirroring how those fields appear on existing listings. Selector failure semantics stay unchanged: unknown ids and unknown labels surface as session not found, duplicate labels surface as ambiguous label (before any mutating command would otherwise pick one arbitrarily), and label: with no name surfaces as malformed selector.
cargo run -q -p harness-cli -- session-selector-check <session-id>{
"selector": "<session-id>",
"resolved_session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"message_count": 1,
"persisted_path": ".sessions/<session-id>.json"
}latest resolves to the most recently active persisted session, and label:<name> is accepted here too. Pinned and labeled sessions surface pinned: true and label: "<name>" in the output so inspect-only scripts can confirm both the resolution target and its protection / naming state in a single call, without having to fan out to session-show, session-pins, and session-labels separately.
cargo run -q -p harness-cli -- session-selector-check latest
cargo run -q -p harness-cli -- session-selector-check label:runtime-review{
"selector": "label:runtime-review",
"resolved_session_id": "<session-id>",
"created_at_ms": <created-at-ms>,
"updated_at_ms": <updated-at-ms>,
"message_count": 1,
"persisted_path": ".sessions/<session-id>.json",
"label": "runtime-review",
"pinned": true
}Current protected Rust surface:
harness-coreprompt/name wrappers and token accounting helpers- seeded tool registry behavior plus permission-policy prefix denial in
harness-tools - seeded command registry behavior in
harness-commands harness-sessionsave/load round-trip persistence- transcript compaction behavior in
harness-session - deterministic route ordering in
harness-runtime - bootstrap permission denial + session persistence behavior in
harness-runtime harness-sessionrecency metadata, newest-first listing, latest-session lookup, and activity-orderedlatestafter a persisted session is resumed- README-backed CLI output regression coverage for
summary,route <prompt>,tools,commands, andsessions - README-backed persisted-session example coverage for
bootstrap <prompt>,session-show <selector>(raw id,latest, andlabel:<name>), with generated session identifiers normalized to<session-id>and generated recency metadata normalized to<created-at-ms>/<updated-at-ms>in test assertions harness-runtimesession resume behavior: an appended turn targets the original session id, bumpsupdated_at_ms, and emits aSessionResumedevent;resume latesttargets the most recently active session- README-backed CLI coverage for
resume <selector> "review summary"(raw id,latest, andlabel:<name>) confirming the resumed turn is appended to the existing persisted session and the output exposes the resolvedresumed_session_idplus the appended turn index harness-sessiontranscript persistence: save/load round-trip preservesturn_indexordering, transcript files are excluded from session listings, andlatest_transcriptfollows the most recently updated sessionharness-runtimetranscript persistence:bootstrapwrites a transcript file alongside the session, emits aTranscriptPersistedevent, andresumerewrites the transcript soturn_indexordering is extended in place- README-backed CLI coverage for
transcript-show <selector>(raw id,latest, andlabel:<name>) confirming the output restates the owningsession_idand preserves turn ordering, plus selector failure coverage for unknown / ambiguous / malformed label selectors on bothsession-showandtranscript-show harness-sessionSessionExportbundle round-trip: packages session state plus transcript, confirms the exported session id, and preservesturn_indexordering in the exported transcript with deterministic serializationharness-runtimeexport_sessionbehavior: bundles the persisted session and its transcript for an explicit id, andlatestresolves to the same bundle- README-backed CLI coverage for
session-export <selector>(raw id,latest, andlabel:<name>) confirming the output exposes theexported_session_idas the actual resolvedsession_idand preserves turn ordering, plus selector failure coverage for unknown / ambiguous / malformed label selectors harness-sessionSessionComparisonbundle: pairs two sides with shared recency/activity metadata, reports signedright - leftdeltas (including negative deltas when order is reversed), exposes asame_sessionflag, and serializes deterministicallyharness-runtimecompare_sessionsbehavior: resolves explicit ids and thelatestselector on either side, computes deltas against persisted session state plus transcripts, and treats a self-comparison assame_session: truewith zero deltas- README-backed CLI coverage for
session-compare <left-selector> <right-selector>(raw id on both sides,latest latest, mixedlabel:<name>+latest, andlabel:<name>on both sides) confirming the output identifies both compared session ids as the actual resolvedsession_idvalues rather than the typed selector strings, that alatest latestself-comparison reportssame_session: truewith every delta equal to0, plus selector-failure coverage for unknown / ambiguous / malformed label selectors applied independently to each side harness-sessionSessionStore::deletebehavior: removes both the session JSON and its sibling transcript JSON, reports the removed paths in deterministic order, and fails withSessionNotFoundwithout touching sibling sessions when the target does not existharness-runtimedelete_sessionbehavior: resolves thelatestselector to the most recently active persisted session, removes both persisted artifacts for that session, and leaves untouched sessions intact- README-backed CLI coverage for
session-delete <selector>(raw id,latest, andlabel:<name>) confirming the output identifies the deleted session id as the actual resolvedsession_id, lists the removed paths insession.jsonthentranscript.jsonorder, and that the session disappears from subsequent listings, plus selector failure coverage for unknown / ambiguous / malformed label selectors harness-sessionSessionStore::import_bundlebehavior: validates that the bundle'sexported_session_id, nestedsession.session_id, and nestedtranscript.session_idall agree, rejects bundles whose transcriptturn_indexvalues are non-monotonic, refuses to overwrite an existing persisted session id, and on success writes both the session JSON and its sibling transcript JSON preserving the imported session id, recency/activity metadata, and turn ordering exactly as carried in the bundleharness-runtimeimport_sessionbehavior: reads a persisted bundle from a user-supplied path, round-trips asession-exportbundle into a fresh store, reports the imported session id plus the written session and transcript paths, and fails cleanly when the bundle path is missing or the target session id already exists locally- README-backed CLI coverage for
session-import <bundle-path>confirming the output identifies the imported session id and the written session and transcript paths, and that a duplicate import against the same store fails cleanly without touching the already-imported session harness-sessionSessionStore::findbehavior: matches persisted transcript prompt text case-insensitively, orders results using the existing newest-first session ordering, preservesturn_indexordering inside each result'smatchesarray, and returns an empty result set for both an empty query and a query with no matches without mutating any persisted session stateharness-runtimefind_sessionsbehavior: surfaces matches across bootstrap and resume-appended turns for an explicit query, scopes to sessions whose transcripts contain the query, and treats both unmatched queries and the empty query as a clean empty result set- README-backed CLI coverage for
session-find <query>confirming a positive search reports the matched session id withturn_index-orderedmatches, and that a query with no matches produces a deterministic empty JSON array - focused CLI coverage for
session-find <query> --limit <n>confirming that omitting--limitpreserves the unlimited behavior exactly, that an empty query and a no-match query both remain a clean empty array with and without--limit, that--limit 0returns an empty array cleanly, that--limit 1returns only the newest matching session, that a limit smaller than the match count returns the newest-first prefix of the default ordering while non-matching sessions stay omitted, that a limit larger than the match count returns every matching session unchanged, that each retained row'smatchesarray is unchanged under limiting, that limiting does not mutate any persisted session or transcript, and that negative or non-numeric--limitvalues fail cleanly at parse time harness-sessionSessionStore::forkbehavior: creates a freshsession_idrather than mutating the source, copies source messages and transcript entries forward in turn-index order, appends the new prompt as the first divergent turn, persists both the forked session JSON and its sibling transcript JSON, leaves the source session JSON and transcript exactly as they were, and reportsSessionNotFoundcleanly when the source id does not existharness-runtimefork_sessionbehavior: resolves thelatestselector to the most recently active persisted session, delegates to the store to write the forked session plus transcript, and fails cleanly for a missing source id without leaving partial persisted artifacts behind- README-backed CLI coverage for
session-fork <selector> "try again"(raw id,latest, andlabel:<name>) confirming the output identifies both the source and forked session ids (withsource_session_idrestating the actual resolvedsession_id), exposes theappended_turn_index, and reports the written session and transcript paths while the source session and transcript remain unchanged, plus selector failure coverage for unknown / ambiguous / malformed label selectors harness-sessionSessionStore::renamebehavior: trims surrounding whitespace on the label, rejects empty and whitespace-only labels withInvalidLabel, reportsSessionNotFoundcleanly when the target session does not exist, preserves the existingsession_id, does not mutate transcript entries or ordering, and does not bumpupdated_at_msso newest-first ordering stays activity-based; persisted JSON for unlabeled sessions remains identical in shape (nolabelfield is emitted) so older sessions stay readableharness-runtimerename_sessionbehavior: resolves explicit session ids and thelatestselector to the most recently active persisted session, delegates to the store to persist the normalized label, and fails cleanly with a descriptive error for invalid labels and unknown session ids without mutating any other persisted state- README-backed CLI coverage for
session-rename <selector> <label>(raw id,latest, andlabel:<old-name>) confirming the output identifies the targeted session id as the actual resolvedsession_idand the applied label, that the rename leaves transcript entries and ordering untouched, that unknown session ids and empty/whitespace-only labels fail cleanly, plus selector failure coverage for unknown / ambiguous / malformed label selectors harness-sessionSessionSelectorparsing andSessionStore::resolve_selectorbehavior: dispatcheslatest,label:<name>, and raw id forms against persisted state, with unknown labels reported asSessionNotFound("label:<name>"), duplicate labels reported asAmbiguousLabel, and an emptylabel:reported asMalformedSelector; sessions without a label are transparently skipped so mixed labeled/unlabeled stores keep workingharness-runtimelabel selector behavior:load_session,load_transcript,delete_session,export_session,compare_sessions,fork_session, andrename_sessionall acceptlabel:<name>wherever they previously accepted an explicit persisted session id, with raw ids andlatestunchanged; machine-readable outputs continue to identify the actual resolvedsession_idvalues rather than the selector string- README-backed CLI coverage for label-based single-session targeting (
session-show label:<name>) confirming raw-id targeting still works unchanged after a label is applied, the resolvedsession_id(not the label string) appears in the JSON output, and forsession-compare label:<name> latestconfirming the mixed label-plus-latest path resolves both sides to the correct persisted session ids; unknown, ambiguous, and malformed label selectors fail cleanly with distinct diagnostics harness-sessionSessionStore::list_labelsbehavior: emits one entry per labeled persisted session, uses the same newest-first ordering aslist(), omits unlabeled sessions, keeps duplicate labels visible as separate rows so ambiguity is discoverable, returns a clean empty vector when no persisted session carries a label, and never mutates persisted stateharness-runtimelist_session_labelsbehavior: delegates to the store so the CLI surface shares ordering and omission semantics withlist_labels, and surfaces an empty listing cleanly when no persisted session is labeled- README-backed CLI coverage for
session-labelsandsession-labels <empty-store>confirming the listing is newest-first, exposeslabel,session_id, recency metadata,message_count, andpersisted_path, omits unlabeled sessions, keeps duplicate labels as separate rows, and returns a deterministic empty JSON array when no persisted session is labeled harness-sessionSessionStore::unlabelbehavior: clears the persistedlabelfield while preserving the existingsession_id,created_at_ms,updated_at_ms, messages, usage, and transcript entries/ordering, reportsSessionAlreadyUnlabeledcleanly for a session that carries no label, reportsSessionNotFoundfor missing ids, and keeps persisted JSON free of anull/emptylabelfield so older unlabeled sessions stay backward-compatibleharness-runtimeunlabel_sessionbehavior: accepts explicit ids, thelatestselector, andlabel:<name>(via the sharedresolve_selectorpath), delegates to the store, and surfaces unknown selectors and already-unlabeled sessions as distinct, descriptive errors without mutating any other persisted state- README-backed CLI coverage for
session-unlabel <selector>,session-unlabel latest, andsession-unlabel label:<name>confirming the output identifies the resolvedunlabeled_session_idand theremoved_label, that the unlabel leaves transcript entries and ordering untouched, thatupdated_at_msis not bumped, that the unlabeled session disappears fromsession-labelswhile transcript/session content stays unchanged, and that an already-unlabeled session fails cleanly without touching persisted state harness-sessionSessionStore::retagbehavior: trims surrounding whitespace on the new label, rejects empty and whitespace-only labels withInvalidLabel, preserves the existingsession_idand does not mutate transcript entries, transcript ordering, messages, orupdated_at_ms, surfacesSessionAlreadyLabeledwhen the requested label normalizes to the same effective value already persisted, surfacesSessionAlreadyUnlabeledwhen the target session has no label to replace, and surfacesSessionNotFoundcleanly for unknown session idsharness-runtimeretag_sessionbehavior: accepts explicit ids, thelatestselector, andlabel:<name>(via the sharedresolve_selectorpath), delegates to the store, and surfaces unknown selectors, already-unlabeled sessions, and same-effective-label attempts as distinct, descriptive errors without mutating any other persisted state- README-backed CLI coverage for
session-retag <selector> <label>,session-retag latest <label>, andsession-retag label:<old-name> <new-name>confirming the output identifies the resolvedretagged_session_id, theprevious_label, and theapplied_label, that the retag leaves transcript entries and ordering untouched, thatupdated_at_msis not bumped, thatsession-labelsreflects the new label while transcript/session content and ordering stay unchanged, and that a same-effective-label request fails cleanly without touching persisted state harness-sessionSessionStore::prunebehavior: preserves the newest<keep>prune-eligible (unpinned) persisted sessions using the same newest-first ordering aslist()(updated_at_ms→created_at_ms→session_id→persisted_path) applied only across unpinned sessions, removes both persisted artifacts (.sessions/<id>.jsonand.sessions/<id>.transcript.json) together for every older unpinned session, reportskept_count,pruned_count,pinned_preserved_count, a deterministicremovedarray identifying each prunedsession_idtogether with the removed session and transcript paths, and a deterministicpinned_preservedarray listing every pinned session that was held back, leaves preserved sessions' labels, pinned flag, transcript entries, transcript ordering, and activity metadata untouched, supports--keep 0to prune every unpinned persisted session, returns a clean emptyremovedlisting when the store already contains<= keepunpinned sessions, and returns a clean empty listing for a missing root directoryharness-runtimeprune_sessionsbehavior: delegates to the store so the CLI surface shares ordering, removal semantics, pinned-preservation, and deterministic output withSessionStore::prune, and continues to surface preserved sessions newest-first throughlist_sessionsafter a prune- README-backed CLI coverage for
session-prune --keep <count>andsession-prune <no-op>confirming the output exposeskept_count,pruned_count,pinned_preserved_count, aremovedarray withsession_id,session_path, andtranscript_pathper pruned entry, and apinned_preservedarray of rescued session ids, preserves the newest<count>unpinned sessions in the subsequentsessionslisting, removes both persisted artifacts for every older unpinned session, and returns a deterministic emptyremovedarray when the store already contains<= countunpinned persisted sessions harness-sessionSessionStore::pin/SessionStore::unpinbehavior: sets / clears the persistedpinnedflag while preserving the existingsession_id,created_at_ms,updated_at_ms, messages, usage, label, and transcript entries/ordering; reportsSessionAlreadyPinned/SessionAlreadyUnpinnedcleanly when the operation would be a no-op, reportsSessionNotFoundfor missing ids, and keeps persisted JSON free of apinned: falsefield so older unpinned sessions stay byte-compatibleharness-runtimepin_session/unpin_sessionbehavior: accepts explicit ids, thelatestselector, andlabel:<name>via the sharedresolve_selectorpath, delegates to the store, and surfaces unknown selectors / already-pinned / already-unpinned states as distinct, descriptive errors without mutating any other persisted state; pinned sessions surviveprune_sessionsregardless of<keep>and are reported viapinned_preserved_count/pinned_preserved- README-backed CLI coverage for
session-pin <selector>andsession-unpin <selector>(raw id,latest, andlabel:<name>) confirming the output identifies the resolvedpinned_session_id/unpinned_session_id(as the actual resolvedsession_id) and the resulting pinned state, that pin/unpin leave transcript entries and ordering untouched, thatupdated_at_msis not bumped (newest-first ordering stays activity-based), that the persisted JSON carriespinned: trueonly while pinned and omits the field entirely after unpin, plus selector failure coverage for unknown / ambiguous / malformed label selectors, and CLI coverage forsession-prune --keep <count>with a pinned session confirming the pinned session is excluded from pruning and surfaces viapinned_preservedwhile other older unpinned sessions are still removed deterministically harness-sessionSessionStore::list_pinsbehavior: emits one entry per pinned persisted session, uses the same newest-first ordering aslist()(updated_at_ms→created_at_ms→session_id→persisted_path), omits unpinned sessions, surfaceslabelwhen the pinned session carries one (and omits the field when unlabeled), keeps duplicate labels on pinned sessions visible as separate rows, returns a clean empty vector when no persisted session is pinned, and never mutates persisted stateharness-runtimelist_session_pinsbehavior: delegates to the store so the CLI surface shares ordering, omission, and label-surfacing semantics withlist_pins, and surfaces an empty listing cleanly when no persisted session is pinned- README-backed CLI coverage for
session-pinsandsession-pins <empty-store>confirming the listing is newest-first, exposessession_id, recency metadata,message_count,persisted_path, andpinned: true, surfaceslabelonly when the pinned session carries one, omits unpinned sessions, and returns a deterministic empty JSON array when no persisted session is pinned harness-sessionSessionStore::check_selectorbehavior: routes the selector through the sharedresolve_selectormachinery, surfaces the resolved persisted session'ssession_id,created_at_ms,updated_at_ms,message_count,persisted_path, and — when present —labelandpinned, leaves persisted session state, transcripts, labels, pinned flags, ids, paths, and ordering metadata untouched, and preserves existing selector failure semantics (unknown id/label →SessionNotFound, duplicate labels →AmbiguousLabel, emptylabel:→MalformedSelector)harness-runtimecheck_session_selectorbehavior: delegates to the store so the CLI surface shares selector resolution with every other single-session command, and surfaces unknown / ambiguous / malformed selectors as distinct, descriptive errors without mutating any persisted state- README-backed CLI coverage for
session-selector-check <id>,session-selector-check latest, andsession-selector-check label:<name>confirming the output echoes the raw selector, identifies the resolvedsession_id, exposes recency metadata /message_count/persisted_path, surfaceslabelandpinned: trueonly when the targeted session carries them, and that unknown ids/labels, duplicate labels, and malformed label selectors fail cleanly with distinct diagnostics harness-sessionSessionStore::tail_transcriptbehavior: routes the selector through the sharedresolve_selectormachinery, returns the newestcountentries from the persisted transcript preservingturn_indexordering, caps a larger-than-transcript count at every available entry, treatscount == 0as a clean empty tail, exposestotal_entriesandreturned_entriesalongside the trimmedentries, leaves persisted session state, transcripts, labels, pinned flags, ids, paths, and ordering metadata untouched, and preserves existing selector failure semantics (unknown id/label →SessionNotFound, duplicate labels →AmbiguousLabel, emptylabel:→MalformedSelector)harness-runtimetail_session_transcriptbehavior: delegates to the store so the CLI surface shares selector resolution with every other single-session command, and surfaces unknown / ambiguous / malformed selectors as distinct, descriptive errors without mutating any persisted state- README-backed CLI coverage for
transcript-tail <id>,transcript-tail latest --count <n>, andtranscript-tail label:<name> --count <n>confirming the output echoes the raw selector, identifies the resolvedsession_id, reportstotal_entries/returned_entries, preservesturn_indexordering in the returned tail, handles empty transcripts and--countvalues larger than the transcript cleanly, and surfaces unknown ids/labels, duplicate labels, and malformed label selectors as distinct diagnostics without mutating persisted state harness-sessionSessionStore::find_in_transcriptbehavior: routes the selector through the sharedresolve_selectormachinery, matches transcript prompt text case-insensitively as a substring, preservesturn_indexordering insidematches, treats both the empty query and no-match queries as a clean emptymatchesarray withmatch_count == 0, exposesselector,resolved_session_id,query,total_entries, andmatch_countalongsidematches, leaves persisted session state, transcripts, labels, pinned flags, ids, paths, and ordering metadata untouched, and preserves existing selector failure semantics (unknown id/label →SessionNotFound, duplicate labels →AmbiguousLabel, emptylabel:→MalformedSelector)harness-runtimefind_in_session_transcriptbehavior: delegates to the store so the CLI surface shares selector resolution with every other single-session command, and surfaces unknown / ambiguous / malformed selectors as distinct, descriptive errors without mutating any persisted state- CLI coverage for
transcript-find <id> <query>,transcript-find latest <query>, andtranscript-find label:<name> <query>confirming the output echoes the raw selector and query, identifies the resolvedsession_id, reportstotal_entries/match_count, preservesturn_indexordering inmatches, handles empty queries and no-match queries cleanly, and surfaces unknown ids/labels, duplicate labels, and malformed label selectors as distinct diagnostics without mutating persisted state - focused CLI coverage for
transcript-find <selector> <query> --limit <n>confirming that omitting--limitpreserves the unlimited behavior exactly, that an empty query and a no-match query both remain a cleanmatch_count: 0with an emptymatchesarray with and without--limit, that--limit 0returnsmatch_count: 0with an emptymatchesarray cleanly, that--limit 1returns only the first match in sourceturn_indexorder, that a limit smaller than the match count returns theturn_index-ordered prefix of the default matches, that a limit larger than the match count returns every match unchanged, that the outer JSON shape stays unchanged andmatch_countis recomputed to equalmatches.len()under limiting, thatlatestandlabel:<name>selectors honor the limit while preserving their existing selector semantics, that limiting does not mutate any persisted session or transcript, and that negative or non-numeric--limitvalues fail cleanly at parse time harness-sessionSessionStore::context_transcriptbehavior: routes the selector through the sharedresolve_selectormachinery, returns a bounded symmetric window around the requestedturn_indexpreservingturn_indexordering, clips windows that extend past either transcript bound to the available in-range entries, treats an out-of-rangeturn(including on an empty transcript) as a clean emptyentriesarray, exposescenter_turn_index,requested_before,requested_after,total_entries, andreturned_entriesalongside the windowentries, leaves persisted session state, transcripts, labels, pinned flags, ids, paths, and ordering metadata untouched, and preserves existing selector failure semantics (unknown id/label →SessionNotFound, duplicate labels →AmbiguousLabel, emptylabel:→MalformedSelector)harness-runtimecontext_session_transcriptbehavior: delegates to the store so the CLI surface shares selector resolution with every other single-session command, and surfaces unknown / ambiguous / malformed selectors as distinct, descriptive errors without mutating any persisted state- CLI coverage for
transcript-context <id> --turn <n>,transcript-context latest --turn <n>, andtranscript-context label:<name> --turn <n>confirming the output echoes the raw selector, identifies the resolvedsession_id, reportscenter_turn_index/requested_before/requested_after/total_entries/returned_entries, preservesturn_indexordering inentries, clips start- and end-boundary windows cleanly, handles empty transcripts and out-of-range--turnvalues cleanly, rejects negative / non-numeric--beforeand--aftervalues at parse time, and surfaces unknown ids/labels, duplicate labels, and malformed label selectors as distinct diagnostics without mutating persisted state harness-sessionSessionStore::has_entries_transcriptbehavior: routes the selector through the sharedresolve_selectormachinery, returns a deterministic{ selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, has_entries }summary for the resolved persisted transcript without returning transcript entries, reportshas_entries == (total_entries > 0), treats empty transcripts as a clean success withtotal_entries: 0andhas_entries: false, leaves persisted session state, transcripts, labels, pinned flags, ids, paths, and ordering metadata untouched, and preserves existing selector failure semantics (unknown id/label →SessionNotFound, duplicate labels →AmbiguousLabel, emptylabel:→MalformedSelector)harness-runtimehas_entries_session_transcriptbehavior: delegates to the store so the CLI surface shares selector resolution with every other single-session command, and surfaces unknown / ambiguous / malformed selectors as distinct, descriptive errors without mutating any persisted state- focused CLI coverage for
transcript-has-entries <id>,transcript-has-entries latest, andtranscript-has-entries label:<name>confirming the output echoes the raw selector, identifies the resolvedsession_id, reportstotal_entries/has_entries, treats non-empty and empty transcripts cleanly, and surfaces unknown ids/labels, duplicate labels, and malformed label selectors as distinct diagnostics without mutating persisted state harness-sessionSessionStore::turn_exists_transcriptbehavior: routes the selector through the sharedresolve_selectormachinery, returns a deterministic{ selector, resolved_session_id, turn_index, created_at_ms, updated_at_ms, total_entries, exists }summary for the resolved persisted transcript without returning transcript entries, reportsexists == any(entry.turn_index == <turn-index>), treats empty transcripts and out-of-range turns as a clean success withexists: false, leaves persisted session state, transcripts, labels, pinned flags, ids, paths, and ordering metadata untouched, and preserves existing selector failure semantics (unknown id/label →SessionNotFound, duplicate labels →AmbiguousLabel, emptylabel:→MalformedSelector)harness-runtimeturn_exists_session_transcriptbehavior: delegates to the store so the CLI surface shares selector resolution with every other single-session command, and surfaces unknown / ambiguous / malformed selectors as distinct, descriptive errors without mutating any persisted state- focused CLI coverage for
transcript-turn-exists <id>,transcript-turn-exists latest, andtranscript-turn-exists label:<name>confirming the output echoes the raw selector, identifies the resolvedsession_id, reportsturn_index/total_entries/exists, treats existing turns, missing turns, and empty transcripts cleanly, rejects negative / non-numeric--turnvalues at parse time, and surfaces unknown ids/labels, duplicate labels, and malformed label selectors as distinct diagnostics without mutating persisted state harness-sessionSessionStore::turn_indexes_transcriptbehavior: routes the selector through the sharedresolve_selectormachinery, returns a deterministic{ selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, turn_indexes }summary for the resolved persisted transcript without returning transcript entries, reportsturn_indexesas an ascending array of theturn_indexvalues present in the transcript, treats empty transcripts as a clean success withtotal_entries: 0andturn_indexes: [], leaves persisted session state, transcripts, labels, pinned flags, ids, paths, and ordering metadata untouched, and preserves existing selector failure semantics (unknown id/label →SessionNotFound, duplicate labels →AmbiguousLabel, emptylabel:→MalformedSelector)harness-runtimeturn_indexes_session_transcriptbehavior: delegates to the store so the CLI surface shares selector resolution with every other single-session command, and surfaces unknown / ambiguous / malformed selectors as distinct, descriptive errors without mutating any persisted state- focused CLI coverage for
transcript-turn-indexes <id>,transcript-turn-indexes latest, andtranscript-turn-indexes label:<name>confirming the output echoes the raw selector, identifies the resolvedsession_id, reportstotal_entries/turn_indexes, returnsturn_indexesin ascending order, treats non-empty and empty transcripts cleanly, and surfaces unknown ids/labels, duplicate labels, and malformed label selectors as distinct diagnostics without mutating persisted state harness-sessionSessionStore::turn_range_transcriptbehavior: routes the selector through the sharedresolve_selectormachinery, returns a deterministic{ selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, first_turn_index, last_turn_index }summary for the resolved persisted transcript without returning transcript entries, reportsfirst_turn_index/last_turn_indexas the smallest and largest presentturn_indexvalues in the transcript, treats empty transcripts as a clean success withtotal_entries: 0and both boundsnull, leaves persisted session state, transcripts, labels, pinned flags, ids, paths, and ordering metadata untouched, and preserves existing selector failure semantics (unknown id/label →SessionNotFound, duplicate labels →AmbiguousLabel, emptylabel:→MalformedSelector)harness-runtimeturn_range_session_transcriptbehavior: delegates to the store so the CLI surface shares selector resolution with every other single-session command, and surfaces unknown / ambiguous / malformed selectors as distinct, descriptive errors without mutating any persisted state- focused CLI coverage for
transcript-turn-index-range <id>,transcript-turn-index-range latest, andtranscript-turn-index-range label:<name>confirming the output echoes the raw selector, identifies the resolvedsession_id, reportstotal_entries/first_turn_index/last_turn_index, treats non-empty and empty transcripts cleanly, and surfaces unknown ids/labels, duplicate labels, and malformed label selectors as distinct diagnostics without mutating persisted state harness-sessionSessionStore::has_turn_gaps_transcriptbehavior: routes the selector through the sharedresolve_selectormachinery, returns a deterministic{ selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, has_turn_gaps }summary for the resolved persisted transcript without returning transcript entries, reportshas_turn_gapsastrueexactly when at least one integerturn_indexbetween the smallest and largest presentturn_indexvalues is missing from the resolved persisted transcript, treats empty and single-entry transcripts as a clean success withhas_turn_gaps: false, leaves persisted session state, transcripts, labels, pinned flags, ids, paths, and ordering metadata untouched, and preserves existing selector failure semantics (unknown id/label →SessionNotFound, duplicate labels →AmbiguousLabel, emptylabel:→MalformedSelector)harness-runtimehas_turn_gaps_session_transcriptbehavior: delegates to the store so the CLI surface shares selector resolution with every other single-session command, and surfaces unknown / ambiguous / malformed selectors as distinct, descriptive errors without mutating any persisted state- focused CLI coverage for
transcript-has-turn-gaps <id>,transcript-has-turn-gaps latest, andtranscript-has-turn-gaps label:<name>confirming the output echoes the raw selector, identifies the resolvedsession_id, reportstotal_entries/has_turn_gaps, treats contiguous transcripts, transcripts with an internal gap, and empty transcripts cleanly, and surfaces unknown ids/labels, duplicate labels, and malformed label selectors as distinct diagnostics without mutating persisted state harness-sessionSessionStore::missing_turn_indexes_transcriptbehavior: routes the selector through the sharedresolve_selectormachinery, returns a deterministic{ selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, missing_turn_indexes }summary for the resolved persisted transcript without returning transcript entries, reportsmissing_turn_indexesas an ascending array of every missing integerturn_indexbetween the smallest and largest presentturn_indexvalues in the resolved persisted transcript, treats empty, single-entry, and contiguous transcripts as a clean success withmissing_turn_indexes: [], leaves persisted session state, transcripts, labels, pinned flags, ids, paths, and ordering metadata untouched, and preserves existing selector failure semantics (unknown id/label →SessionNotFound, duplicate labels →AmbiguousLabel, emptylabel:→MalformedSelector)harness-runtimemissing_turn_indexes_session_transcriptbehavior: delegates to the store so the CLI surface shares selector resolution with every other single-session command, and surfaces unknown / ambiguous / malformed selectors as distinct, descriptive errors without mutating any persisted state- focused CLI coverage for
transcript-missing-turn-indexes <id>,transcript-missing-turn-indexes latest, andtranscript-missing-turn-indexes label:<name>confirming the output echoes the raw selector, identifies the resolvedsession_id, reportstotal_entries/missing_turn_indexes, treats contiguous transcripts, transcripts with a single internal gap, transcripts with multiple internal gaps, and empty transcripts cleanly, and surfaces unknown ids/labels, duplicate labels, and malformed label selectors as distinct diagnostics without mutating persisted state harness-sessionSessionStore::turn_density_transcriptbehavior: routes the selector through the sharedresolve_selectormachinery, returns a deterministic{ selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, span_entry_count, missing_turn_count, turn_density }summary for the resolved persisted transcript without returning transcript entries, reportsspan_entry_countas the inclusive integer span from the smallest presentturn_indexto the largest presentturn_index,missing_turn_countasspan_entry_count - total_entries, andturn_densityastotal_entries / span_entry_countas a deterministic numeric value, treats empty transcripts as a clean success withspan_entry_count: 0,missing_turn_count: 0, andturn_density: 1.0, treats single-entry and contiguous transcripts as a clean success withmissing_turn_count: 0andturn_density: 1.0, reportsturn_density < 1.0on gapped transcripts, leaves persisted session state, transcripts, labels, pinned flags, ids, paths, and ordering metadata untouched, and preserves existing selector failure semantics (unknown id/label →SessionNotFound, duplicate labels →AmbiguousLabel, emptylabel:→MalformedSelector)harness-runtimeturn_density_session_transcriptbehavior: delegates to the store so the CLI surface shares selector resolution with every other single-session command, and surfaces unknown / ambiguous / malformed selectors as distinct, descriptive errors without mutating any persisted state- focused CLI coverage for
transcript-turn-density <id>,transcript-turn-density latest, andtranscript-turn-density label:<name>confirming the output echoes the raw selector, identifies the resolvedsession_id, reportstotal_entries/span_entry_count/missing_turn_count/turn_density, treats contiguous transcripts, single-entry transcripts, empty transcripts, and gapped transcripts cleanly, and surfaces unknown ids/labels, duplicate labels, and malformed label selectors as distinct diagnostics without mutating persisted state
Validation commands:
cargo test -p harness-core
cargo test -p harness-tools
cargo test -p harness-commands
cargo test -p harness-session
cargo test -p harness-runtime
cargo test -p harness-cli
cargo testMore runtime and CLI coverage should continue incrementally through the active issue queue.
The CLI example blocks above are a protected regression surface: if visible seeded output changes, update the README and the harness-cli example tests in the same PR.
Use the smallest validation command that proves the touched surface, then widen only when the slice needs it:
cargo checkfor fast workspace sanity- targeted
cargo test -p <crate>for the crate you changed cargo run -q -p harness-cli -- <command>when a CLI-facing slice changes visible behavior or docscargo testbefore merge when the change crosses crate boundaries or updates shared runtime behaviorcargo clippy --workspace --all-targets -- -D warningsfor code-heavy slices before final merge
For this repository, documentation is part of done. If README examples or command descriptions change, validate them against the actual CLI output before opening the PR.
- create an issue for the slice
- branch from
main - implement a small atomic unit
- validate with
cargo check,cargo test, andcargo clippy --workspace --all-targets -- -D warnings - open a PR
- merge cleanly
This repo is a clean-room implementation effort informed by architectural study. It is not an official Anthropic project and is not affiliated with Anthropic.
- architecture capture
- workspace bootstrap
- core domain types
- session/transcript persistence
- registries
- router/runtime loop
- CLI inspection surface
- CLI usage examples and validation flow
- cleanup of obsolete Python-first scaffolding
- move retained architecture-study snapshots under
archive/reference_data/ - CLI session resume for persisted sessions (
resume <selector> <prompt>— raw id,latest, andlabel:<name>) routed through the shared selector-resolution path; the resumed turn is appended to the existing persisted session,updated_at_msis refreshed, and machine-readable JSON output continues to identify the actual resolvedsession_idviaresumed_session_idrather than the typed selector string; selector failures stay deterministic (unknown id/label →SessionNotFound, duplicate labels →AmbiguousLabel, emptylabel:→MalformedSelector) - Persisted transcript files per session and CLI transcript inspection (
transcript-show <selector>— raw id,latest, andlabel:<name>) - CLI session export for persisted session bundles (
session-export <selector>— raw id,latest, andlabel:<name>) in a deterministic JSON shape packaging session state plus transcript, withexported_session_idsurfacing the actual resolvedsession_idrather than the typed selector string and selector failures routed through the sharedSessionNotFound/AmbiguousLabel/MalformedSelectordiagnostics - CLI session comparison for persisted sessions (
session-compare <left-selector> <right-selector>— each side independently accepts rawsession_id,latest, orlabel:<name>routed through the shared selector-resolution path) in a deterministic JSON shape that identifies both compared session ids as the actual resolvedsession_idvalues (never the typed selector strings) and reports signed deltas for recency metadata and transcript/turn counts, with selector failure semantics routed through the sharedSessionNotFound/AmbiguousLabel/MalformedSelectordiagnostics independently on each side - CLI session deletion for persisted sessions (
session-delete <selector>— raw id,latest, andlabel:<name>) that removes both the session JSON and its sibling transcript JSON in one call, with deterministic JSON output identifying the deleted session id (as the actual resolvedsession_id, never the typed selector string) plus the removed paths, selector failures routed through the sharedSessionNotFound/AmbiguousLabel/MalformedSelectordiagnostics, and a clean failure when the target session does not exist - CLI session import for persisted session bundles (
session-import <bundle-path>) that accepts the deterministic{ exported_session_id, session, transcript }shape emitted bysession-export, recreates both persisted artifacts preserving the imported session id, recency/activity metadata, and transcriptturn_indexordering, and fails cleanly without overwriting unrelated persisted sessions when the bundle is invalid or the target session id already exists locally - CLI session search for persisted transcripts (
session-find <query>) that case-insensitively matches transcript prompt text without mutating session state, returns a deterministic JSON array ordered using the existing newest-first session ordering, identifies each matchedsession_idwith recency/activity metadata plus amatchesarray of{ turn_index, prompt }so results are useful from the terminal, and treats both empty queries and queries with no matches as a clean empty array instead of an error - CLI session fork for persisted sessions (
session-fork <selector> <prompt>— raw id,latest, andlabel:<name>) that creates a fresh persisted session id rather than mutating the source, carries the source session messages and transcript forward in turn-index order, appends the new prompt as the first divergent turn, writes both forked persisted artifacts (.sessions/<forked-session-id>.jsonand its sibling transcript JSON), and emits a deterministic{ source_session_id, forked_session_id, appended_turn_index, session_path, transcript_path }shape wheresource_session_idis the actual resolvedsession_id(never the typed selector string) while leaving the source session and transcript unchanged; selector failures routed through the sharedSessionNotFound/AmbiguousLabel/MalformedSelectordiagnostics - CLI session rename for persisted sessions (
session-rename <selector> <label>— raw id,latest, andlabel:<old-name>) that attaches a trimmed, non-empty human-readable label to persisted session metadata while preserving the existingsession_id, leaving transcript entries and ordering untouched, and not bumpingupdated_at_msso newest-first ordering stays activity-based; emits a deterministic{ renamed_session_id, applied_label }shape whererenamed_session_idis the actual resolvedsession_id(never the typed selector string), fails cleanly for empty/whitespace-only labels, routes selector failures through the sharedSessionNotFound/AmbiguousLabel/MalformedSelectordiagnostics, and keeps older unlabeled sessions readable by only emitting the label field once a session has actually been labeled - CLI session-labels for persisted sessions (
session-labels) that lists every persisted session carrying a label without mutating session state, emits a deterministic JSON array ordered using the existing newest-first persisted-session ordering, exposeslabel,session_id, recency metadata (created_at_ms,updated_at_ms),message_count, andpersisted_pathper entry, omits unlabeled sessions, keeps duplicate labels visible as separate rows so ambiguity is discoverable before alabel:<name>selector would fail, and returns a clean empty JSON array when no persisted session carries a label - CLI label selectors (
label:<name>) for persisted sessions accepted anywhere a single persisted session id is accepted (session-show,transcript-show,resume,session-export,session-delete,session-fork,session-rename, and either side ofsession-compare); raw session ids andlatestkeep their existing behavior, machine-readable JSON outputs continue to surface the actual resolvedsession_id, and unknown labels, ambiguous labels (more than one persisted session sharing the same label), and malformed selectors (label:with no name) all fail cleanly with distinct diagnostics; activity-based newest-first ordering is unchanged and mixed labeled/unlabeled stores stay backward-compatible - CLI session-unlabel for persisted sessions (
session-unlabel <selector>,session-unlabel latest, andsession-unlabel label:<name>) that removes only the persistedlabelmetadata field while preserving the existingsession_id, leaving transcript entries and ordering untouched, and not bumpingupdated_at_msso newest-first ordering stays activity-based; emits a deterministic{ unlabeled_session_id, removed_label }shape, fails cleanly for unknown sessions/selectors and for attempts to unlabel a session that is already unlabeled, and keeps older unlabeled sessions backward-compatible by not serializing a null/empty label field after removal - CLI session-retag for persisted sessions (
session-retag <selector> <label>,session-retag latest <label>, andsession-retag label:<old-name> <new-name>) that atomically replaces the persistedlabelmetadata field while preserving the existingsession_id, leaving transcript entries and ordering untouched, and not bumpingupdated_at_msso newest-first ordering stays activity-based; emits a deterministic{ retagged_session_id, previous_label, applied_label }shape, fails cleanly for unknown sessions/selectors, empty/whitespace-only labels, attempts to retag a session that carries no label, and attempts where the requested label normalizes to the same effective value already present, and keeps older unlabeled sessions backward-compatible by only serializing the label field when present - CLI session-pin / session-unpin for persisted sessions (
session-pin <selector>andsession-unpin <selector>— raw id,latest, andlabel:<name>) that toggle a deterministicpinnedflag on session metadata while preserving the existingsession_id, leaving transcript entries and ordering untouched, and not bumpingupdated_at_msso newest-first ordering stays activity-based; emits deterministic{ pinned_session_id, pinned }/{ unpinned_session_id, pinned }shapes where the resolved id is the actual persistedsession_id(never the typed selector string), routes selector failures through the sharedSessionNotFound/AmbiguousLabel/MalformedSelectordiagnostics, keeps older unpinned sessions backward-compatible by only serializing thepinnedfield when the session is actually pinned, surfaces thepinnedflag throughsessions,session-show,session-export,session-compare, andsession-labels, and makessession-prune --keep <count>skip pinned sessions — apply newest-first ordering only across the unpinned subset and report rescued pins via a newpinned_preserved_countandpinned_preservedpair on the prune output - CLI session-selector-check for persisted sessions (
session-selector-check <id>,session-selector-check latest, andsession-selector-check label:<name>) that routes the selector through the shared selector-resolution path and surfaces the resolved persisted session's descriptive metadata without mutating session state, transcript entries, labels, pinned flags, ids, paths, or ordering metadata; emits a deterministic{ selector, resolved_session_id, created_at_ms, updated_at_ms, message_count, persisted_path, label?, pinned? }shape whereselectorechoes the raw input,labelonly appears when the targeted session carries one, andpinnedonly appears whentrue; preserves existing selector failure semantics unchanged (unknown id/label →session not found, duplicate labels →ambiguous label, emptylabel:→malformed selector) - CLI transcript-tail for persisted sessions (
transcript-tail <id>,transcript-tail latest, andtranscript-tail label:<name>, with an optional--count <n>that defaults to10) that routes the selector through the shared selector-resolution path and returns the newest transcript entries for the resolved session without mutating any persisted state; emits a deterministic{ selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, returned_entries, entries }shape whereselectorechoes the raw input,entriespreservesturn_indexordering within the returned tail slice, a--countlarger than the transcript returns every available entry, and an empty transcript or--count 0returns an emptyentriesarray cleanly; preserves existing selector failure semantics unchanged (unknown id/label →session not found, duplicate labels →ambiguous label, emptylabel:→malformed selector) - CLI transcript-context for persisted sessions (
transcript-context <id> --turn <n>,transcript-context latest --turn <n>, andtranscript-context label:<name> --turn <n>, with optional--before <n>/--after <n>each defaulting to2) that routes the selector through the shared selector-resolution path and returns a bounded symmetric window around the requestedturn_indexfor the resolved session without mutating any persisted state; emits a deterministic{ selector, resolved_session_id, center_turn_index, requested_before, requested_after, created_at_ms, updated_at_ms, total_entries, returned_entries, entries }shape whereselectorechoes the raw input,entriespreservesturn_indexordering within the returned window, windows that extend past either transcript bound are clipped cleanly to the available in-range entries, an out-of-range--turnor empty transcript returns an emptyentriesarray cleanly, and negative / non-numeric--turn/--before/--aftervalues fail cleanly at parse time; preserves existing selector failure semantics unchanged (unknown id/label →session not found, duplicate labels →ambiguous label, emptylabel:→malformed selector) - CLI transcript-has-entries for persisted sessions (
transcript-has-entries <id>,transcript-has-entries latest, andtranscript-has-entries label:<name>) that routes the selector through the shared selector-resolution path and returns a deterministic inspect-only{ selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, has_entries }shape for the resolved persisted transcript without returning transcript entries or mutating any persisted state;has_entriesistrueexactly whentotal_entries > 0, empty transcripts succeed cleanly withtotal_entries: 0andhas_entries: false, and existing selector failure semantics remain unchanged (unknown id/label →session not found, duplicate labels →ambiguous label, emptylabel:→malformed selector) - CLI transcript-turn-exists for persisted sessions (
transcript-turn-exists <id> --turn <turn-index>,transcript-turn-exists latest --turn <turn-index>, andtranscript-turn-exists label:<name> --turn <turn-index>) that routes the selector through the shared selector-resolution path and returns a deterministic inspect-only{ selector, resolved_session_id, turn_index, created_at_ms, updated_at_ms, total_entries, exists }shape for the resolved persisted transcript without returning transcript entries or mutating any persisted state;existsistrueexactly when the resolved persisted transcript contains an entry whoseturn_index == <turn-index>, empty transcripts and out-of-range turns succeed cleanly withexists: false, negative / non-numeric--turnvalues fail cleanly at parse time, and existing selector failure semantics remain unchanged (unknown id/label →session not found, duplicate labels →ambiguous label, emptylabel:→malformed selector) - CLI transcript-turn-indexes for persisted sessions (
transcript-turn-indexes <id>,transcript-turn-indexes latest, andtranscript-turn-indexes label:<name>) that routes the selector through the shared selector-resolution path and returns a deterministic inspect-only{ selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, turn_indexes }shape for the resolved persisted transcript without returning transcript entries or mutating any persisted state;turn_indexesis an ascending array of theturn_indexvalues present in the resolved persisted transcript, empty transcripts succeed cleanly withtotal_entries: 0andturn_indexes: [], and existing selector failure semantics remain unchanged (unknown id/label →session not found, duplicate labels →ambiguous label, emptylabel:→malformed selector) - CLI transcript-turn-index-range for persisted sessions (
transcript-turn-index-range <id>,transcript-turn-index-range latest, andtranscript-turn-index-range label:<name>) that routes the selector through the shared selector-resolution path and returns a deterministic inspect-only{ selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, first_turn_index, last_turn_index }shape for the resolved persisted transcript without returning transcript entries or mutating any persisted state;first_turn_index/last_turn_indexare the smallest and largest presentturn_indexvalues in the resolved persisted transcript, empty transcripts succeed cleanly withtotal_entries: 0and both boundsnull, and existing selector failure semantics remain unchanged (unknown id/label →session not found, duplicate labels →ambiguous label, emptylabel:→malformed selector) - CLI transcript-has-turn-gaps for persisted sessions (
transcript-has-turn-gaps <id>,transcript-has-turn-gaps latest, andtranscript-has-turn-gaps label:<name>) that routes the selector through the shared selector-resolution path and returns a deterministic inspect-only{ selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, has_turn_gaps }shape for the resolved persisted transcript without returning transcript entries or mutating any persisted state;has_turn_gapsistrueexactly when at least one integerturn_indexbetween the smallest and largest presentturn_indexvalues is missing from the resolved persisted transcript, empty and single-entry transcripts succeed cleanly withhas_turn_gaps: false, and existing selector failure semantics remain unchanged (unknown id/label →session not found, duplicate labels →ambiguous label, emptylabel:→malformed selector) - CLI transcript-missing-turn-indexes for persisted sessions (
transcript-missing-turn-indexes <id>,transcript-missing-turn-indexes latest, andtranscript-missing-turn-indexes label:<name>) that routes the selector through the shared selector-resolution path and returns a deterministic inspect-only{ selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, missing_turn_indexes }shape for the resolved persisted transcript without returning transcript entries or mutating any persisted state;missing_turn_indexesis an ascending array of every missing integerturn_indexbetween the smallest and largest presentturn_indexvalues in the resolved persisted transcript, empty / single-entry / contiguous transcripts succeed cleanly withmissing_turn_indexes: [], and existing selector failure semantics remain unchanged (unknown id/label →session not found, duplicate labels →ambiguous label, emptylabel:→malformed selector) - CLI transcript-turn-density for persisted sessions (
transcript-turn-density <id>,transcript-turn-density latest, andtranscript-turn-density label:<name>) that routes the selector through the shared selector-resolution path and returns a deterministic inspect-only{ selector, resolved_session_id, created_at_ms, updated_at_ms, total_entries, span_entry_count, missing_turn_count, turn_density }shape for the resolved persisted transcript without returning transcript entries or mutating any persisted state;span_entry_countis the inclusive integer span from the smallest presentturn_indexto the largest presentturn_index,missing_turn_countequalsspan_entry_count - total_entries, andturn_densityequalstotal_entries / span_entry_countas a deterministic numeric value, empty transcripts succeed cleanly withspan_entry_count: 0/missing_turn_count: 0/turn_density: 1.0, single-entry / contiguous transcripts reportmissing_turn_count: 0/turn_density: 1.0, gapped transcripts reportturn_density < 1.0, and existing selector failure semantics remain unchanged (unknown id/label →session not found, duplicate labels →ambiguous label, emptylabel:→malformed selector)