From e22664ecbe29dec83cb8dd267e98cdd446fb9aeb Mon Sep 17 00:00:00 2001 From: ozymandiashh <234437643+ozymandiashh@users.noreply.github.com> Date: Tue, 6 Oct 2026 22:15:06 +0300 Subject: [PATCH] Restore usage from Mistral Vibe Unified Harness sessions (#1599) * Restore usage from Mistral Vibe Unified Harness sessions * fix(mistral-vibe): read unpinned Vibe 2.26 unified sessions exactly An unpinned session has session_metadata.active_model null, so the parser dropped it entirely. Fall back to config.toml's active_model, then Vibe's default mistral-medium-3.5. Split the rotated journal prefix into as many calls as runtime state lists completions, so call counts match. Drop the tool group prefix from history names (file_system.bash) and attach a turn's tools to its first call only. Re-derive settled days (DAILY_CACHE_VERSION 58). Adds a redacted fixture from a real 2.26.0 session. --------- Co-authored-by: Resham Joshi <65915470+iamtoruk@users.noreply.github.com> --- docs/providers/mistral-vibe.md | 54 +- src/daily-cache.ts | 5 +- src/providers/mistral-vibe-unified.ts | 220 +++ src/providers/mistral-vibe.ts | 28 + src/session-cache.ts | 24 +- tests/fixtures/mistral-vibe-unified-2.26.json | 1398 +++++++++++++++++ tests/fixtures/mistral-vibe-unified.json | 801 ++++++++++ tests/fixtures/mistral-vibe-unified.md | 37 + tests/providers/mistral-vibe-unified.test.ts | 193 +++ 9 files changed, 2752 insertions(+), 8 deletions(-) create mode 100644 src/providers/mistral-vibe-unified.ts create mode 100644 tests/fixtures/mistral-vibe-unified-2.26.json create mode 100644 tests/fixtures/mistral-vibe-unified.json create mode 100644 tests/fixtures/mistral-vibe-unified.md create mode 100644 tests/providers/mistral-vibe-unified.test.ts diff --git a/docs/providers/mistral-vibe.md b/docs/providers/mistral-vibe.md index 244ebae1..89cce96e 100644 --- a/docs/providers/mistral-vibe.md +++ b/docs/providers/mistral-vibe.md @@ -12,34 +12,76 @@ Mistral Vibe CLI. ## Storage format -Vibe 2.x stores each session as a directory: +Legacy Vibe 2.x stores each session as a directory: - `meta.json` contains session metadata, cumulative token totals, active model config, model prices, timestamps, working directory, and available tools. - `messages.jsonl` contains non-system messages and assistant `tool_calls`. Subagent traces are stored under a parent session's `agents/` folder with the same `meta.json` / `messages.jsonl` shape, so CodeBurn scans those one level down as separate sessions. +Vibe 2.25's Unified Harness (still the layout in 2.26) stores every session +under `unified//`. A subagent is its own sibling session there, +linked by `parent_session_id`; its usage is not included in the parent's. Its `meta.json` has no `stats`, and there is no +`messages.jsonl`. `CURRENT` selects a committed generation containing +`projection-state.json`, `runtime-state.json`, and a manifest. The projection's +history can be stored in content-addressed `chunks/` files. + +CodeBurn reads `snapshot.session.tokenUsage` and the cumulative usage envelopes +in `journal/*.jsonl`. It supports both `projection_advanced` and +`projection_delta` records. These are recovery journals: Vibe retains only two +segments after checkpointing. Summing `action_result` records alone loses older +usage, while summing every nested usage object double-counts copies of a call. +CodeBurn takes deltas between cumulative envelopes and recovers the older prefix +from the snapshot. Each later envelope step is one call with its exact usage +(the same numbers as that call's `action_result.result.usage`). The rotated +prefix is split evenly into as many calls as `runtime-state.json` lists +succeeded `completion` actions, across its recorded turns. Call counts and +session totals stay exact; per-call values inside that prefix are an even split. + ## Caching -Current Vibe local logs do not expose cache-read/cache-write token fields, so +Legacy Vibe local logs do not expose cache-read/cache-write token fields, so CodeBurn reports cache token counts as `0`. When `meta.json.stats.session_cost` is present, CodeBurn uses that session total instead of re-estimating from prompt/completion token prices because it is the best cache-aware cost signal available in the local log shape. +Unified `inputTokens` includes `cachedInputTokens`. CodeBurn subtracts cached +input from ordinary input and records it as cache-read usage, then estimates +cost using the pricing catalog. Unified sessions persist no cost of their own +(Vibe's `session_cost` is computed in memory only), so these costs are marked +estimated. It does not treat `contextUsage` (the latest context window) as +cumulative spend. + +The model is not recorded per call. `runtime-state.json` +`session_metadata.active_model` is only a pin and is `null` for an unpinned +session, which runs the configured default. CodeBurn then reads the top-level +`active_model` from `$VIBE_HOME/config.toml` at parse time, falling back to +`mistral-medium-3.5` (Vibe's built-in default, priced at Vibe's own rates of +$1.5/M input, $0.15/M cached, $7.5/M output). Changing `config.toml` later does +not reprice sessions already cached, and mid-session model switches are not +recoverable. + +The source cache fingerprints `CURRENT`, metadata, and the bounded journal +segments. Appending usage invalidates the cache even before Vibe publishes a new +generation. Generation contents and chunks are immutable once published. + ## Deduplication -Per `mistral-vibe:`. +Legacy message IDs, or the session ID for an aggregate fallback. Unified usage +uses the session ID, projection sequence, turn ID, and call index. Repeated journal sequences +and cumulative totals are not counted again. ## Quirks - **Usage is cumulative per session.** Vibe does not write per-assistant-message token usage into `messages.jsonl`; token counts come from `meta.json.stats.session_prompt_tokens` and `session_completion_tokens`. CodeBurn splits assistant-message tools into their user turns for classification and distributes the cumulative token/cost totals across those assistant calls so session totals remain unchanged. - **Cost prefers Vibe's own session total.** `meta.json.stats.session_cost` is used first. If it is missing, `meta.json.stats.input_price_per_million` and `output_price_per_million` are used with the active model config as a fallback. LiteLLM pricing is only used when Vibe provides no price data. - **Project names come from metadata.** Discovery uses `meta.json.environment.working_directory` and falls back to the session directory name if that field is missing. +- **Unified tool names carry their group** (`file_system.bash`, `ui.ask_user_question`). CodeBurn drops the group before mapping, and a turn's tools are attached to its first call only. - **Tool calls come from messages.** Assistant `tool_calls[*].function.name` is normalized to the standard CodeBurn names (`bash` to `Bash`, `search_replace` to `Edit`, etc.). Bash commands are extracted from `function.arguments.command`. ## When fixing a bug here -1. Reproduce with a fixture that has both `meta.json` and `messages.jsonl`; both files are required for current Vibe sessions. -2. If the bug is "wrong total", check `meta.json.stats` first. `messages.jsonl` is only for prompts and tool calls. -3. If a future Vibe release adds per-turn usage, add tests before changing the one-record-per-session behavior so historical sessions continue to parse correctly. +1. Identify the harness first. Legacy sessions require `meta.json` and `messages.jsonl`; Unified sessions use `CURRENT`, generations, chunks, and journals. +2. Check legacy `meta.json.stats` or Unified projection `session.tokenUsage`, never `contextUsage`. +3. Test journal rotation and appends against a warm CodeBurn cache, as well as legacy compatibility. See `tests/fixtures/mistral-vibe-unified.md` for fixture provenance. diff --git a/src/daily-cache.ts b/src/daily-cache.ts index bc33c6cb..83727cad 100644 --- a/src/daily-cache.ts +++ b/src/daily-cache.ts @@ -295,7 +295,10 @@ import type { DateRange, ProjectSummary } from './types.js' // created_at move from the file-mtime day to their first step's day, so a // session that crossed midnight moves calls to an earlier day, and antigravity // joins PENDING_REDERIVE_PROVIDER_VERSIONS at 59. -export const DAILY_CACHE_VERSION = 59 +// v60: Mistral Vibe 2.26 Unified Harness sessions (`unified//`) are read; +// days finalized while they were skipped re-derive. Calls only rise, so no +// PENDING_REDERIVE_PROVIDER_VERSIONS entry is needed. +export const DAILY_CACHE_VERSION = 60 const MIN_SUPPORTED_VERSION = 28 /// Providers whose per-day CALL COUNT means something different at diff --git a/src/providers/mistral-vibe-unified.ts b/src/providers/mistral-vibe-unified.ts new file mode 100644 index 00000000..5295374a --- /dev/null +++ b/src/providers/mistral-vibe-unified.ts @@ -0,0 +1,220 @@ +import { readdir } from 'fs/promises' +import { basename, dirname, join } from 'path' +import { readSessionFile, readSessionLines } from '../fs-utils.js' +import { calculateCost } from '../models.js' +import { extractBashCommands } from '../bash-utils.js' +import type { ParsedProviderCall } from './types.js' + +type ObjectValue = Record +type Usage = { input: number; output: number; cached: number } +type UsagePoint = { sequence: number; state: ObjectValue; usage: Usage } + +function object(value: unknown): ObjectValue { + return value !== null && typeof value === 'object' && !Array.isArray(value) ? value as ObjectValue : {} +} + +function array(value: unknown): unknown[] { return Array.isArray(value) ? value : [] } +function text(value: unknown): string { return typeof value === 'string' ? value : '' } +function count(value: unknown): number { + return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? value : 0 +} + +async function json(path: string): Promise { + const raw = await readSessionFile(path) + if (raw === null) return null + try { return object(JSON.parse(raw)) } catch { return null } +} + +function usagePoint(sequence: number, stateValue: unknown): UsagePoint | null { + const state = object(stateValue) + const usage = object(object(state.session).tokenUsage) + if (!Object.keys(usage).length) return null + const input = count(usage.inputTokens) + return { sequence, state, usage: { + input, output: count(usage.outputTokens), cached: Math.min(input, count(usage.cachedInputTokens)), + } } +} + +function content(value: unknown): string { + return typeof value === 'string' ? value : array(value).map(part => text(object(part).text)).join(' ') +} + +function timestamp(value: unknown, fallback: string): string { + if (typeof value !== 'number' || !Number.isFinite(value)) return fallback + const date = new Date(value) + return Number.isNaN(date.getTime()) ? fallback : date.toISOString() +} + +/** + * Vibe 2.25's journal is a recovery log, not an append-only usage ledger. + * CURRENT selects the committed snapshot; only two journal segments survive + * checkpoint rotation. Read cumulative projection usage (never contextUsage or + * duplicate action_result/core_input copies), then take deltas between envelopes. + */ +export async function readUnifiedVibeCalls( + currentPath: string, + toolDisplayName: (name: string) => string, + defaultModel: string, +): Promise { + const dir = dirname(currentPath) + const current = await json(currentPath) + if (current?.store_format !== 'mistral.vibe.unified-session-store/v1') return [] + const generation = text(current.generation) + if (!/^\d{16}$/.test(generation)) return [] + const generationDir = join(dir, 'generations', generation) + const projection = await json(join(generationDir, 'projection-state.json')) + const runtime = await json(join(generationDir, 'runtime-state.json')) + const manifest = await json(join(generationDir, 'manifest.json')) + if (!projection || !runtime || !manifest) return [] + const sessionId = text(current.session_id) || basename(dir) + if (projection.session_id !== sessionId || runtime.session_id !== sessionId) return [] + const snapshotSequence = count(current.snapshot_sequence) + const snapshot = object(projection.snapshot) + const meta = await json(join(dir, 'meta.json')) + const sessionMetadata = object(runtime.session_metadata) + // active_model is a pin; an unpinned session runs the configured default. + const model = text(sessionMetadata.active_model) || text(object(meta?.config).active_model) || defaultModel + const fallbackTime = text(meta?.end_time) || text(meta?.start_time) + const projectPath = text(sessionMetadata.cwd) || text(object(meta?.environment).working_directory) + + const entries = new Map() + const addEntries = (values: unknown) => { + for (const value of array(values)) { + const entry = object(value) + if (typeof entry.id === 'string') entries.set(entry.id, entry) + } + } + addEntries(object(snapshot.history).entries) + // Manifest chunk names are content hashes, never arbitrary paths from a log. + for (const hash of array(object(manifest.projection_state).chunks)) { + if (typeof hash !== 'string' || !/^[a-f0-9]{64}$/.test(hash)) return [] + const raw = await readSessionFile(join(dir, 'chunks', `${hash}.json`)) + if (raw === null) return [] + try { addEntries(JSON.parse(raw)) } catch { return [] } + } + + const points = new Map() + const addPoint = (sequence: number, state: unknown) => { + const point = usagePoint(sequence, state) + if (point) points.set(sequence, point) + } + addPoint(snapshotSequence, snapshot) + const journalDir = join(dir, 'journal') + const segments = (await readdir(journalDir).catch(() => [])) + .filter(name => /^\d{16}\.jsonl$/.test(name)).sort() + const seenSequences = new Set() + for (const segment of segments) { + for await (const line of readSessionLines(join(journalDir, segment))) { + let record: ObjectValue + try { record = object(JSON.parse(line)) } catch { continue } + const sequence = count(record.sequence) + if (!sequence || seenSequences.has(sequence)) continue + seenSequences.add(sequence) + const payload = object(record.payload) + if (record.type === 'projection_advanced') { + addPoint(sequence, payload.snapshot) + if (sequence > snapshotSequence) { + entries.clear() + addEntries(object(object(payload.snapshot).history).entries) + } + } else if (record.type === 'projection_delta') { + for (const value of array(payload.delta)) { + const op = object(value) + if (op.op === 'set_envelope') addPoint(sequence, op.state) + if (sequence <= snapshotSequence) continue + if (op.op === 'append_entry' || op.op === 'replace_entry') addEntries([op.entry]) + else if (op.op === 'remove_entry') entries.delete(text(op.id)) + else if (op.op === 'set_history_entries') { + entries.clear() + addEntries(op.entries) + } + } + } + } + } + + const history = [...entries.values()].sort((a, b) => count(a.createdAt) - count(b.createdAt)) + const steps: { point: UsagePoint; delta: Usage; first: boolean }[] = [] + let previous: Usage = { input: 0, output: 0, cached: 0 } + for (const point of [...points.values()].sort((a, b) => a.sequence - b.sequence)) { + const { usage } = point + // Projection counters are cumulative. Replayed/stale envelopes cannot add + // usage again, and context-window shrinkage is not new billable usage. + if (usage.input < previous.input || usage.output < previous.output || usage.cached < previous.cached) continue + const delta = { + input: usage.input - previous.input, + output: usage.output - previous.output, + cached: Math.min(usage.input - previous.input, usage.cached - previous.cached), + } + const first = previous.input === 0 && previous.output === 0 + previous = usage + if (delta.input || delta.output) steps.push({ point, delta, first }) + } + // Rotation drops the per-call usage of the prefix, but runtime state still + // lists every completion, so the prefix splits into that many calls. + const completions = array(runtime.actions).filter(value => { + const action = object(value) + return action.kind === 'completion' && action.state === 'succeeded' + }).length + const journalCalls = steps.filter(step => !step.first && step.point.sequence <= snapshotSequence).length + const prefixCalls = Math.max(1, completions - journalCalls) + const split = (total: number, index: number, parts: number) => + Math.floor(total / parts) + (index < total % parts ? 1 : 0) + + const calls: ParsedProviderCall[] = [] + const turnsWithTools = new Set() + for (const { point, delta, first } of steps) { + const session = object(point.state.session) + const pointTime = count(session.updatedAt) + const turnId = text(object(point.state.latestTurn).id) || `${sessionId}:snapshot` + // After rotation, older per-call usage is gone. Allocate that prefix across + // its recorded turns, just as the legacy parser allocates cumulative stats. + const olderTurns = first ? [...new Set(history + .filter(entry => count(entry.createdAt) <= pointTime && (entry.role === 'assistant' || entry.type === 'effect')) + .map(entry => text(entry.turnId)).filter(Boolean))] : [] + const turnIds = olderTurns.length ? olderTurns : [turnId] + const slots = first + ? turnIds.flatMap((id, index) => Array(Math.max(1, split(prefixCalls, index, turnIds.length))).fill(id)) + : turnIds + for (const [index, id] of slots.entries()) { + const turnEntries = history.filter(entry => entry.turnId === id) + const user = turnEntries.find(entry => entry.role === 'user') + const assistant = turnEntries.find(entry => entry.role === 'assistant' || entry.type === 'effect') + const tools: string[] = [] + const bashCommands: string[] = [] + // A turn's tools ride on its first call only, so per-call tool counts stay real. + if (!turnsWithTools.has(id)) { + turnsWithTools.add(id) + for (const entry of turnEntries) { + const detail = object(entry.detail) + const rawName = text(detail.toolName) + if (!rawName) continue + // History names carry the tool group: `file_system.bash`, `ui.ask_user_question`. + const name = toolDisplayName(rawName.replace(/^.*\./, '')) + tools.push(name) + if (name === 'Bash') { + const command = text(object(detail.input).command) + if (command) bashCommands.push(...extractBashCommands(command)) + } + } + } + const inputTokens = split(delta.input - delta.cached, index, slots.length) + const outputTokens = split(delta.output, index, slots.length) + const cacheReadInputTokens = split(delta.cached, index, slots.length) + calls.push({ + provider: 'mistral-vibe', model, inputTokens, outputTokens, + cacheReadInputTokens, cachedInputTokens: cacheReadInputTokens, + cacheCreationInputTokens: 0, reasoningTokens: 0, webSearchRequests: 0, + costUSD: calculateCost(model, inputTokens, outputTokens, 0, cacheReadInputTokens, 0), + costIsEstimated: true, + tools: [...new Set(tools)], bashCommands: [...new Set(bashCommands)], + timestamp: timestamp(first ? assistant?.createdAt ?? pointTime : pointTime, fallbackTime), + speed: 'standard', sessionId, turnId: id, + deduplicationKey: `mistral-vibe:${sessionId}:unified:${point.sequence}:${id}:${index}`, + userMessage: (content(user?.content) || text(session.preview) || text(meta?.title)).slice(0, 500), + ...(projectPath ? { projectPath, workingDirectory: projectPath } : {}), + }) + } + } + return calls +} diff --git a/src/providers/mistral-vibe.ts b/src/providers/mistral-vibe.ts index 23c3667f..e6b3733e 100644 --- a/src/providers/mistral-vibe.ts +++ b/src/providers/mistral-vibe.ts @@ -7,6 +7,7 @@ import { calculateCost } from '../models.js' import { extractBashCommands } from '../bash-utils.js' import type { ProbeRoot, Provider, SessionSource, SessionParser, ParsedProviderCall } from './types.js' import { safeNumber } from '../parser.js' +import { readUnifiedVibeCalls } from './mistral-vibe-unified.js' const METADATA_FILENAME = 'meta.json' const MESSAGES_FILENAME = 'messages.jsonl' @@ -163,6 +164,13 @@ async function discoverSessionDirs(root: string): Promise { return sessionDirs } +// Vibe resolves an unpinned session to config.toml's top-level active_model. +async function configuredModel(sessionsDir: string): Promise { + const raw = await readSessionFile(join(sessionsDir, '..', '..', 'config.toml')) + const topLevel = raw?.split(/^\s*\[/m)[0] ?? '' + return topLevel.match(/^\s*active_model\s*=\s*["']([^"']+)["']/m)?.[1] ?? DEFAULT_MODEL +} + function activeModelConfig(metadata: VibeMetadata): VibeModelConfig | null { const activeModel = metadata.config?.active_model const models = metadata.config?.models @@ -428,10 +436,30 @@ export function createMistralVibeProvider(sessionsDir?: string): Provider { }) } + const unifiedDir = join(dir, 'unified') + for (const entry of (await readdir(unifiedDir).catch(() => [])).sort()) { + const sessionDir = join(unifiedDir, entry) + const currentPath = join(sessionDir, 'CURRENT') + if (!await isFile(currentPath)) continue + const metadata = await readJsonFile(join(sessionDir, METADATA_FILENAME)) + const cwd = metadata?.environment?.working_directory + sources.push({ path: currentPath, project: cwd ? basename(cwd) : entry, provider: 'mistral-vibe' }) + } + return sources }, createSessionParser(source: SessionSource, seenKeys: Set): SessionParser { + if (basename(source.path) === 'CURRENT') { + return { async *parse() { + const defaultModel = await configuredModel(dir) + for (const call of await readUnifiedVibeCalls(source.path, name => toolNameMap[name] ?? name, defaultModel)) { + if (seenKeys.has(call.deduplicationKey)) continue + seenKeys.add(call.deduplicationKey) + yield call + } + } } + } return createParser(source, seenKeys) }, } diff --git a/src/session-cache.ts b/src/session-cache.ts index cf0c0e2c..c76b29b3 100644 --- a/src/session-cache.ts +++ b/src/session-cache.ts @@ -1,7 +1,7 @@ import { readFile, stat, open, rename, unlink, readdir, mkdir, rm, type FileHandle } from 'fs/promises' import { existsSync, readFileSync, unlinkSync } from 'fs' import { createHash, randomBytes } from 'crypto' -import { join } from 'path' +import { basename, dirname, join } from 'path' import { StringDecoder } from 'string_decoder' import { getCodeburnCacheDir, RETIRED_PROVIDER_NAMES } from './cache-dir.js' @@ -2539,6 +2539,28 @@ export async function fingerprintFile(filePath: string): Promise [])) + .filter(name => /^\d{16}\.jsonl$/.test(name)).sort() + const hash = createHash('sha256').update(`${s.ino}:${s.mtimeMs}:${s.size}`) + let mtimeMs = s.mtimeMs + let sizeBytes = s.size + for (const path of [join(dir, 'meta.json'), ...names.map(name => join(journal, name))]) { + const info = await stat(path).catch(() => null) + hash.update(`\0${path}:${info?.ino}:${info?.mtimeMs}:${info?.size}`) + if (info) { + mtimeMs = Math.max(mtimeMs, info.mtimeMs) + sizeBytes += info.size + } + } + // Composite identity changes even when a non-newest segment is rewritten; + // keep sizeBytes real because the parser also uses it for workload sizing. + return { dev: s.dev, ino: parseInt(hash.digest('hex').slice(0, 12), 16), mtimeMs, sizeBytes } + } // A source path that IS a SQLite database (copilot OTel's agent-traces.db) // needs the same WAL fold as the virtual-suffix forms below. if (SQLITE_DB_PATH.test(filePath)) return fingerprintSqliteFile(filePath) diff --git a/tests/fixtures/mistral-vibe-unified-2.26.json b/tests/fixtures/mistral-vibe-unified-2.26.json new file mode 100644 index 00000000..9cdda3f3 --- /dev/null +++ b/tests/fixtures/mistral-vibe-unified-2.26.json @@ -0,0 +1,1398 @@ +{ + "CURRENT": { + "generation": "0000000000000147", + "manifest_sha256": "7383c6a0686358c2aa2073aa00afc0972c4494ce445579ee76842ac2468a139f", + "session_id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "snapshot_sequence": 147, + "store_format": "mistral.vibe.unified-session-store/v1", + "store_format_minor": 8 + }, + "meta.json": { + "session_id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "parent_session_id": null, + "start_time": "2026-10-06T18:02:07.158000+00:00", + "end_time": "2026-10-06T18:02:51.152000+00:00", + "child_sessions": [], + "config": null, + "environment": { + "working_directory": "/tmp/vibe-test" + }, + "title": "redacted" + }, + "generations/0000000000000147/manifest.json": { + "checkpoint": { + "checkpoint_version": 1, + "chunks": [ + "c57bfb6ef60a4c95bca25e5565e69274284de035138c2011779e5dba1b13babc" + ], + "path": "checkpoint.json", + "sha256": "81338499aea849a27947229ce76a9535beda8f94ea9f76fc6316ffc496856803" + }, + "created_at": "2026-10-06T18:02:51.188Z", + "execution_state": "quiescent", + "generation": "0000000000000147", + "interop_export": null, + "manifest_version": 1, + "projection_state": { + "chunks": [ + "f528c78b23297ad4555d7ab1a4bf32788d42f31c53afdc229aacc6c7331e5177" + ], + "path": "projection-state.json", + "sha256": "a89797737063a7e55d2338de43862383c68d6411dd7aabdec51d8281805729f9" + }, + "recovery_journal_segment": { + "first_sequence": 148, + "path": "journal/0000000000000148.jsonl" + }, + "runtime_state": { + "chunks": [ + "6d97221bbcdfe4a46fc17409a3f7e2ee734caddfae0533cceb0107e0bffcd1f2" + ], + "path": "runtime-state.json", + "sha256": "625acadcfb833a4f1701c3a943a3aa4f021a8181e196ce2ea5328228e6ff90e0" + }, + "session_id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "snapshot_sequence": 147 + }, + "generations/0000000000000147/projection-state.json": { + "projection_state_version": 1, + "session_id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "snapshot": { + "activeCallbacks": [], + "format": "harness.public-session-state/v1", + "history": { + "cursor": { + "after": null, + "before": null + }, + "entries": [], + "range": "latest" + }, + "latestTurn": { + "completedAt": 1791309771152, + "id": "turn-9674c56e0c67831ff3c246347b7d0a79", + "inputEntryId": "72b2578d-2e28-4210-b00d-d99bb2439ac0", + "queueItemId": "7e359c6a-2b17-490d-8d31-ab4f08afd044", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "startedAt": 1791309761900, + "status": "completed", + "stopReason": null + }, + "session": { + "contextUsage": { + "cachedInputTokens": 13568, + "inputTokens": 13803, + "outputTokens": 128, + "totalTokens": 13931 + }, + "createdAt": 1791309727158, + "id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "parentSessionId": null, + "preview": "redacted", + "rootSessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "status": { + "type": "idle" + }, + "title": "redacted", + "titleSource": "auto", + "tokenUsage": { + "cachedInputTokens": 131200, + "inputTokens": 142427, + "outputTokens": 1216, + "totalTokens": 143643 + }, + "updatedAt": 1791309771152 + }, + "turnQueue": { + "items": [], + "maxItems": 32, + "paused": false + } + }, + "snapshot_sequence": 147, + "watermark": 44 + }, + "generations/0000000000000147/runtime-state.json": { + "runtime_state_version": 3, + "session_id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "snapshot_sequence": 147, + "session_metadata": { + "active_model": null, + "agent_name": null, + "cwd": "/tmp/vibe-test", + "parent_session_id": null, + "reasoning_effort": null, + "root_session_id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "subagent_policy_ceiling_digest": null, + "subagent_spawn_key": null, + "subagent_template_digest": null + }, + "actions": [ + { + "action_id": "09a4c489-d95b-578a-98cb-e99221840bcb", + "kind": "tool", + "state": "succeeded" + }, + { + "action_id": "0ed82f7c-442a-5ccc-8ec8-d37fc656ce0b", + "kind": "tool", + "state": "succeeded" + }, + { + "action_id": "1378dff6-849b-5666-a6de-4a5e92e2c0e4", + "kind": "completion", + "state": "succeeded" + }, + { + "action_id": "26627edd-7423-53b1-b262-e4e6b33e6f7e", + "kind": "tool", + "state": "succeeded" + }, + { + "action_id": "269779a6-ca3a-5d6d-af02-2ce2aa981451", + "kind": "hook", + "state": "succeeded" + }, + { + "action_id": "2ef43c39-34cb-54e9-9a05-0019ba8a9220", + "kind": "completion", + "state": "succeeded" + }, + { + "action_id": "2f08cadb-fc5e-5233-9d00-3706461ab238", + "kind": "hook", + "state": "succeeded" + }, + { + "action_id": "338d7a5b-b85d-5f7c-a615-93544387d01f", + "kind": "hook", + "state": "succeeded" + }, + { + "action_id": "3725b122-b403-5c43-bb5a-3d1ffe69cc8a", + "kind": "tool", + "state": "succeeded" + }, + { + "action_id": "3d5d431d-2727-57d9-ba05-987f8fc0e2c0", + "kind": "tool", + "state": "succeeded" + }, + { + "action_id": "3f76ee3a-73ba-5257-b28a-d970b40f1603", + "kind": "completion", + "state": "succeeded" + }, + { + "action_id": "3fbb848d-e31f-5ade-bb50-b211e2130117", + "kind": "completion", + "state": "succeeded" + }, + { + "action_id": "4e7d1977-abce-5fbd-a170-b3ce8c9ec096", + "kind": "hook", + "state": "succeeded" + }, + { + "action_id": "54dd1d0d-03ec-55c9-a1f5-957a4bde5776", + "kind": "hook", + "state": "succeeded" + }, + { + "action_id": "58d5d5aa-79ee-50cc-a99c-d6380386f283", + "kind": "tool", + "state": "succeeded" + }, + { + "action_id": "65033466-74cb-5f72-ba35-9b201855afdc", + "kind": "hook", + "state": "succeeded" + }, + { + "action_id": "6d1423f9-476a-55b1-a893-f7b4114811bf", + "kind": "completion", + "state": "succeeded" + }, + { + "action_id": "7ff50b68-6b47-50a6-b326-203b3ee9912f", + "kind": "completion", + "state": "succeeded" + }, + { + "action_id": "82d80022-9553-5d04-963b-7754d2553f7d", + "kind": "completion", + "state": "succeeded" + }, + { + "action_id": "a2a48bad-0a51-542e-9c35-f18230e13744", + "kind": "tool", + "state": "succeeded" + }, + { + "action_id": "a5c77626-53f4-5b2f-a922-ad2059b6179c", + "kind": "completion", + "state": "succeeded" + }, + { + "action_id": "a72fff7e-067c-5688-b33b-cf7d6c9e1fc5", + "kind": "tool", + "state": "succeeded" + }, + { + "action_id": "a7ebf62d-4b65-5fd8-8455-0c83f8f5d1e3", + "kind": "hook", + "state": "succeeded" + }, + { + "action_id": "b31a5a4b-7933-5e6c-9ca9-8cf198905dc6", + "kind": "completion", + "state": "succeeded" + }, + { + "action_id": "c0765f86-3064-59a6-932d-b366a9a713d9", + "kind": "completion", + "state": "succeeded" + }, + { + "action_id": "c8467337-19c6-50b5-9d5e-4141d6ed3cd2", + "kind": "hook", + "state": "succeeded" + }, + { + "action_id": "db7053a3-4023-5edc-bc54-1d7c12994541", + "kind": "tool", + "state": "succeeded" + }, + { + "action_id": "e7ed0189-9056-53e1-9f6c-c911d8f77a2c", + "kind": "completion", + "state": "succeeded" + }, + { + "action_id": "ea07f233-2415-5129-a41a-0780888260d6", + "kind": "hook", + "state": "succeeded" + }, + { + "action_id": "f068564b-11ed-5057-9f69-1c55ee342f12", + "kind": "tool", + "state": "succeeded" + }, + { + "action_id": "fb5e2091-8b30-5c07-a477-5deae59c9350", + "kind": "hook", + "state": "succeeded" + } + ] + }, + "chunks/f528c78b23297ad4555d7ab1a4bf32788d42f31c53afdc229aacc6c7331e5177.json": [ + { + "id": "150c6b85-82dc-40ec-8c59-40f96f98289a", + "type": "message", + "role": "user", + "turnId": "turn-39227d9ddd802f0fe796acd937197f5f", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309738921, + "updatedAt": 1791309738921, + "generationStatus": "completed", + "content": "redacted" + }, + { + "id": "reasoning-e7ed0189-9056-53e1-9f6c-c911d8f77a2c-0", + "type": "reasoning", + "turnId": "turn-39227d9ddd802f0fe796acd937197f5f", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309742017, + "updatedAt": 1791309742017, + "generationStatus": "completed" + }, + { + "id": "effect-3725b122-b403-5c43-bb5a-3d1ffe69cc8a", + "type": "effect", + "turnId": "turn-39227d9ddd802f0fe796acd937197f5f", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309742021, + "updatedAt": 1791309747303, + "generationStatus": "completed", + "detail": { + "display": "redacted", + "input": { + "command": "python3 -m unittest" + }, + "kind": "tool", + "toolName": "file_system.bash" + } + }, + { + "id": "reasoning-7ff50b68-6b47-50a6-b326-203b3ee9912f-0", + "type": "reasoning", + "turnId": "turn-39227d9ddd802f0fe796acd937197f5f", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309748402, + "updatedAt": 1791309748402, + "generationStatus": "completed" + }, + { + "id": "effect-3d5d431d-2727-57d9-ba05-987f8fc0e2c0", + "type": "effect", + "turnId": "turn-39227d9ddd802f0fe796acd937197f5f", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309748405, + "updatedAt": 1791309748434, + "generationStatus": "completed", + "detail": { + "display": "redacted", + "input": { + "path": "redacted" + }, + "kind": "tool", + "toolName": "file_system.read_file" + } + }, + { + "id": "effect-0ed82f7c-442a-5ccc-8ec8-d37fc656ce0b", + "type": "effect", + "turnId": "turn-39227d9ddd802f0fe796acd937197f5f", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309748410, + "updatedAt": 1791309748438, + "generationStatus": "completed", + "detail": { + "display": "redacted", + "input": { + "path": "redacted" + }, + "kind": "tool", + "toolName": "file_system.read_file" + } + }, + { + "id": "reasoning-82d80022-9553-5d04-963b-7754d2553f7d-0", + "type": "reasoning", + "turnId": "turn-39227d9ddd802f0fe796acd937197f5f", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309749972, + "updatedAt": 1791309749972, + "generationStatus": "completed" + }, + { + "id": "effect-26627edd-7423-53b1-b262-e4e6b33e6f7e", + "type": "effect", + "turnId": "turn-39227d9ddd802f0fe796acd937197f5f", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309749976, + "updatedAt": 1791309749994, + "generationStatus": "completed", + "detail": { + "display": "redacted", + "input": { + "content": "redacted", + "file_path": "redacted" + }, + "kind": "tool", + "toolName": "file_system.search_replace" + } + }, + { + "id": "reasoning-2ef43c39-34cb-54e9-9a05-0019ba8a9220-0", + "type": "reasoning", + "turnId": "turn-39227d9ddd802f0fe796acd937197f5f", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309753256, + "updatedAt": 1791309753256, + "generationStatus": "completed" + }, + { + "id": "effect-f068564b-11ed-5057-9f69-1c55ee342f12", + "type": "effect", + "turnId": "turn-39227d9ddd802f0fe796acd937197f5f", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309753268, + "updatedAt": 1791309755705, + "generationStatus": "completed", + "detail": { + "display": "redacted", + "input": { + "command": "python3 -m unittest" + }, + "kind": "tool", + "toolName": "file_system.bash" + } + }, + { + "id": "reasoning-a5c77626-53f4-5b2f-a922-ad2059b6179c-0", + "type": "reasoning", + "turnId": "turn-39227d9ddd802f0fe796acd937197f5f", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309756505, + "updatedAt": 1791309756505, + "generationStatus": "completed" + }, + { + "id": "effect-db7053a3-4023-5edc-bc54-1d7c12994541", + "type": "effect", + "turnId": "turn-39227d9ddd802f0fe796acd937197f5f", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309756508, + "updatedAt": 1791309756528, + "generationStatus": "completed", + "detail": { + "display": "redacted", + "input": { + "path": "redacted" + }, + "kind": "tool", + "toolName": "file_system.read_file" + } + }, + { + "id": "assistant-3f76ee3a-73ba-5257-b28a-d970b40f1603", + "type": "message", + "role": "assistant", + "turnId": "turn-39227d9ddd802f0fe796acd937197f5f", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309757693, + "updatedAt": 1791309757693, + "generationStatus": "completed", + "content": "redacted" + }, + { + "id": "72b2578d-2e28-4210-b00d-d99bb2439ac0", + "type": "message", + "role": "user", + "turnId": "turn-9674c56e0c67831ff3c246347b7d0a79", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309761900, + "updatedAt": 1791309761900, + "generationStatus": "completed", + "content": "redacted" + }, + { + "id": "reasoning-1378dff6-849b-5666-a6de-4a5e92e2c0e4-0", + "type": "reasoning", + "turnId": "turn-9674c56e0c67831ff3c246347b7d0a79", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309763404, + "updatedAt": 1791309763404, + "generationStatus": "completed" + }, + { + "id": "effect-a2a48bad-0a51-542e-9c35-f18230e13744", + "type": "effect", + "turnId": "turn-9674c56e0c67831ff3c246347b7d0a79", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309763408, + "updatedAt": 1791309763422, + "generationStatus": "completed", + "detail": { + "display": "redacted", + "input": { + "content": "redacted", + "file_path": "redacted" + }, + "kind": "tool", + "toolName": "file_system.search_replace" + } + }, + { + "id": "reasoning-b31a5a4b-7933-5e6c-9ca9-8cf198905dc6-0", + "type": "reasoning", + "turnId": "turn-9674c56e0c67831ff3c246347b7d0a79", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309765554, + "updatedAt": 1791309765554, + "generationStatus": "completed" + }, + { + "id": "effect-09a4c489-d95b-578a-98cb-e99221840bcb", + "type": "effect", + "turnId": "turn-9674c56e0c67831ff3c246347b7d0a79", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309765558, + "updatedAt": 1791309765577, + "generationStatus": "completed", + "detail": { + "display": "redacted", + "input": { + "content": "redacted", + "file_path": "redacted" + }, + "kind": "tool", + "toolName": "file_system.search_replace" + } + }, + { + "id": "reasoning-3fbb848d-e31f-5ade-bb50-b211e2130117-0", + "type": "reasoning", + "turnId": "turn-9674c56e0c67831ff3c246347b7d0a79", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309768990, + "updatedAt": 1791309768990, + "generationStatus": "completed" + }, + { + "id": "effect-a72fff7e-067c-5688-b33b-cf7d6c9e1fc5", + "type": "effect", + "turnId": "turn-9674c56e0c67831ff3c246347b7d0a79", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309768995, + "updatedAt": 1791309769009, + "generationStatus": "completed", + "detail": { + "display": "redacted", + "input": { + "content": "redacted", + "file_path": "redacted" + }, + "kind": "tool", + "toolName": "file_system.search_replace" + } + }, + { + "id": "reasoning-6d1423f9-476a-55b1-a893-f7b4114811bf-0", + "type": "reasoning", + "turnId": "turn-9674c56e0c67831ff3c246347b7d0a79", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309769897, + "updatedAt": 1791309769897, + "generationStatus": "completed" + }, + { + "id": "effect-58d5d5aa-79ee-50cc-a99c-d6380386f283", + "type": "effect", + "turnId": "turn-9674c56e0c67831ff3c246347b7d0a79", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309769903, + "updatedAt": 1791309769980, + "generationStatus": "completed", + "detail": { + "display": "redacted", + "input": { + "command": "python3 -m unittest" + }, + "kind": "tool", + "toolName": "file_system.bash" + } + }, + { + "id": "assistant-c0765f86-3064-59a6-932d-b366a9a713d9", + "type": "message", + "role": "assistant", + "turnId": "turn-9674c56e0c67831ff3c246347b7d0a79", + "sessionId": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309771152, + "updatedAt": 1791309771152, + "generationStatus": "completed", + "content": "redacted" + } + ], + "journal/0000000000000087.jsonl": [ + { + "sequence": 87, + "type": "projection_delta", + "payload": { + "delta": [ + { + "op": "set_envelope", + "state": { + "session": { + "id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309727158, + "updatedAt": 1791309758232, + "tokenUsage": { + "cachedInputTokens": 64896, + "inputTokens": 75035, + "outputTokens": 576, + "totalTokens": 75611 + }, + "contextUsage": { + "cachedInputTokens": 12800, + "inputTokens": 12967, + "outputTokens": 118, + "totalTokens": 13085 + } + }, + "latestTurn": { + "id": "turn-39227d9ddd802f0fe796acd937197f5f" + } + } + } + ], + "watermark": 26 + } + }, + { + "sequence": 90, + "type": "projection_delta", + "payload": { + "delta": [ + { + "op": "set_envelope", + "state": { + "session": { + "id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309727158, + "updatedAt": 1791309761900, + "tokenUsage": { + "cachedInputTokens": 64896, + "inputTokens": 75035, + "outputTokens": 576, + "totalTokens": 75611 + }, + "contextUsage": { + "cachedInputTokens": 12800, + "inputTokens": 12967, + "outputTokens": 118, + "totalTokens": 13085 + } + }, + "latestTurn": { + "id": "turn-9674c56e0c67831ff3c246347b7d0a79" + } + } + } + ], + "watermark": 27 + } + }, + { + "sequence": 92, + "type": "action_result", + "payload": { + "action_id": "1378dff6-849b-5666-a6de-4a5e92e2c0e4", + "result": { + "finish_reason": "tool_call", + "usage": { + "cached_input_tokens": 12928, + "input_tokens": 13113, + "output_tokens": 194, + "total_tokens": 13307 + } + } + } + }, + { + "sequence": 93, + "type": "core_input", + "payload": { + "action_id": "1378dff6-849b-5666-a6de-4a5e92e2c0e4", + "result": { + "finish_reason": "tool_call", + "usage": { + "cached_input_tokens": 12928, + "input_tokens": 13113, + "output_tokens": 194, + "total_tokens": 13307 + } + } + } + }, + { + "sequence": 94, + "type": "projection_delta", + "payload": { + "delta": [ + { + "op": "set_envelope", + "state": { + "session": { + "id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309727158, + "updatedAt": 1791309763404, + "tokenUsage": { + "cachedInputTokens": 77824, + "inputTokens": 88148, + "outputTokens": 770, + "totalTokens": 88918 + }, + "contextUsage": { + "cachedInputTokens": 12928, + "inputTokens": 13113, + "outputTokens": 194, + "totalTokens": 13307 + } + }, + "latestTurn": { + "id": "turn-9674c56e0c67831ff3c246347b7d0a79" + } + } + } + ], + "watermark": 28 + } + }, + { + "sequence": 96, + "type": "projection_delta", + "payload": { + "delta": [ + { + "op": "set_envelope", + "state": { + "session": { + "id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309727158, + "updatedAt": 1791309763408, + "tokenUsage": { + "cachedInputTokens": 77824, + "inputTokens": 88148, + "outputTokens": 770, + "totalTokens": 88918 + }, + "contextUsage": { + "cachedInputTokens": 12928, + "inputTokens": 13113, + "outputTokens": 194, + "totalTokens": 13307 + } + }, + "latestTurn": { + "id": "turn-9674c56e0c67831ff3c246347b7d0a79" + } + } + } + ], + "watermark": 29 + } + }, + { + "sequence": 99, + "type": "projection_delta", + "payload": { + "delta": [ + { + "op": "set_envelope", + "state": { + "session": { + "id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309727158, + "updatedAt": 1791309763417, + "tokenUsage": { + "cachedInputTokens": 77824, + "inputTokens": 88148, + "outputTokens": 770, + "totalTokens": 88918 + }, + "contextUsage": { + "cachedInputTokens": 12928, + "inputTokens": 13113, + "outputTokens": 194, + "totalTokens": 13307 + } + }, + "latestTurn": { + "id": "turn-9674c56e0c67831ff3c246347b7d0a79" + } + } + } + ], + "watermark": 30 + } + }, + { + "sequence": 103, + "type": "projection_delta", + "payload": { + "delta": [ + { + "op": "set_envelope", + "state": { + "session": { + "id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309727158, + "updatedAt": 1791309763422, + "tokenUsage": { + "cachedInputTokens": 77824, + "inputTokens": 88148, + "outputTokens": 770, + "totalTokens": 88918 + }, + "contextUsage": { + "cachedInputTokens": 12928, + "inputTokens": 13113, + "outputTokens": 194, + "totalTokens": 13307 + } + }, + "latestTurn": { + "id": "turn-9674c56e0c67831ff3c246347b7d0a79" + } + } + } + ], + "watermark": 31 + } + }, + { + "sequence": 105, + "type": "action_result", + "payload": { + "action_id": "b31a5a4b-7933-5e6c-9ca9-8cf198905dc6", + "result": { + "finish_reason": "tool_call", + "usage": { + "cached_input_tokens": 13056, + "input_tokens": 13341, + "output_tokens": 79, + "total_tokens": 13420 + } + } + } + }, + { + "sequence": 106, + "type": "core_input", + "payload": { + "action_id": "b31a5a4b-7933-5e6c-9ca9-8cf198905dc6", + "result": { + "finish_reason": "tool_call", + "usage": { + "cached_input_tokens": 13056, + "input_tokens": 13341, + "output_tokens": 79, + "total_tokens": 13420 + } + } + } + }, + { + "sequence": 107, + "type": "projection_delta", + "payload": { + "delta": [ + { + "op": "set_envelope", + "state": { + "session": { + "id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309727158, + "updatedAt": 1791309765554, + "tokenUsage": { + "cachedInputTokens": 90880, + "inputTokens": 101489, + "outputTokens": 849, + "totalTokens": 102338 + }, + "contextUsage": { + "cachedInputTokens": 13056, + "inputTokens": 13341, + "outputTokens": 79, + "totalTokens": 13420 + } + }, + "latestTurn": { + "id": "turn-9674c56e0c67831ff3c246347b7d0a79" + } + } + } + ], + "watermark": 32 + } + }, + { + "sequence": 109, + "type": "projection_delta", + "payload": { + "delta": [ + { + "op": "set_envelope", + "state": { + "session": { + "id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309727158, + "updatedAt": 1791309765558, + "tokenUsage": { + "cachedInputTokens": 90880, + "inputTokens": 101489, + "outputTokens": 849, + "totalTokens": 102338 + }, + "contextUsage": { + "cachedInputTokens": 13056, + "inputTokens": 13341, + "outputTokens": 79, + "totalTokens": 13420 + } + }, + "latestTurn": { + "id": "turn-9674c56e0c67831ff3c246347b7d0a79" + } + } + } + ], + "watermark": 33 + } + }, + { + "sequence": 112, + "type": "projection_delta", + "payload": { + "delta": [ + { + "op": "set_envelope", + "state": { + "session": { + "id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309727158, + "updatedAt": 1791309765573, + "tokenUsage": { + "cachedInputTokens": 90880, + "inputTokens": 101489, + "outputTokens": 849, + "totalTokens": 102338 + }, + "contextUsage": { + "cachedInputTokens": 13056, + "inputTokens": 13341, + "outputTokens": 79, + "totalTokens": 13420 + } + }, + "latestTurn": { + "id": "turn-9674c56e0c67831ff3c246347b7d0a79" + } + } + } + ], + "watermark": 34 + } + }, + { + "sequence": 116, + "type": "projection_delta", + "payload": { + "delta": [ + { + "op": "set_envelope", + "state": { + "session": { + "id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309727158, + "updatedAt": 1791309765577, + "tokenUsage": { + "cachedInputTokens": 90880, + "inputTokens": 101489, + "outputTokens": 849, + "totalTokens": 102338 + }, + "contextUsage": { + "cachedInputTokens": 13056, + "inputTokens": 13341, + "outputTokens": 79, + "totalTokens": 13420 + } + }, + "latestTurn": { + "id": "turn-9674c56e0c67831ff3c246347b7d0a79" + } + } + } + ], + "watermark": 35 + } + }, + { + "sequence": 118, + "type": "action_result", + "payload": { + "action_id": "3fbb848d-e31f-5ade-bb50-b211e2130117", + "result": { + "finish_reason": "tool_call", + "usage": { + "cached_input_tokens": 13312, + "input_tokens": 13454, + "output_tokens": 192, + "total_tokens": 13646 + } + } + } + }, + { + "sequence": 119, + "type": "core_input", + "payload": { + "action_id": "3fbb848d-e31f-5ade-bb50-b211e2130117", + "result": { + "finish_reason": "tool_call", + "usage": { + "cached_input_tokens": 13312, + "input_tokens": 13454, + "output_tokens": 192, + "total_tokens": 13646 + } + } + } + }, + { + "sequence": 120, + "type": "projection_delta", + "payload": { + "delta": [ + { + "op": "set_envelope", + "state": { + "session": { + "id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309727158, + "updatedAt": 1791309768990, + "tokenUsage": { + "cachedInputTokens": 104192, + "inputTokens": 114943, + "outputTokens": 1041, + "totalTokens": 115984 + }, + "contextUsage": { + "cachedInputTokens": 13312, + "inputTokens": 13454, + "outputTokens": 192, + "totalTokens": 13646 + } + }, + "latestTurn": { + "id": "turn-9674c56e0c67831ff3c246347b7d0a79" + } + } + } + ], + "watermark": 36 + } + }, + { + "sequence": 122, + "type": "projection_delta", + "payload": { + "delta": [ + { + "op": "set_envelope", + "state": { + "session": { + "id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309727158, + "updatedAt": 1791309768995, + "tokenUsage": { + "cachedInputTokens": 104192, + "inputTokens": 114943, + "outputTokens": 1041, + "totalTokens": 115984 + }, + "contextUsage": { + "cachedInputTokens": 13312, + "inputTokens": 13454, + "outputTokens": 192, + "totalTokens": 13646 + } + }, + "latestTurn": { + "id": "turn-9674c56e0c67831ff3c246347b7d0a79" + } + } + } + ], + "watermark": 37 + } + }, + { + "sequence": 125, + "type": "projection_delta", + "payload": { + "delta": [ + { + "op": "set_envelope", + "state": { + "session": { + "id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309727158, + "updatedAt": 1791309769004, + "tokenUsage": { + "cachedInputTokens": 104192, + "inputTokens": 114943, + "outputTokens": 1041, + "totalTokens": 115984 + }, + "contextUsage": { + "cachedInputTokens": 13312, + "inputTokens": 13454, + "outputTokens": 192, + "totalTokens": 13646 + } + }, + "latestTurn": { + "id": "turn-9674c56e0c67831ff3c246347b7d0a79" + } + } + } + ], + "watermark": 38 + } + }, + { + "sequence": 129, + "type": "projection_delta", + "payload": { + "delta": [ + { + "op": "set_envelope", + "state": { + "session": { + "id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309727158, + "updatedAt": 1791309769009, + "tokenUsage": { + "cachedInputTokens": 104192, + "inputTokens": 114943, + "outputTokens": 1041, + "totalTokens": 115984 + }, + "contextUsage": { + "cachedInputTokens": 13312, + "inputTokens": 13454, + "outputTokens": 192, + "totalTokens": 13646 + } + }, + "latestTurn": { + "id": "turn-9674c56e0c67831ff3c246347b7d0a79" + } + } + } + ], + "watermark": 39 + } + }, + { + "sequence": 131, + "type": "action_result", + "payload": { + "action_id": "6d1423f9-476a-55b1-a893-f7b4114811bf", + "result": { + "finish_reason": "tool_call", + "usage": { + "cached_input_tokens": 13440, + "input_tokens": 13681, + "output_tokens": 47, + "total_tokens": 13728 + } + } + } + }, + { + "sequence": 132, + "type": "core_input", + "payload": { + "action_id": "6d1423f9-476a-55b1-a893-f7b4114811bf", + "result": { + "finish_reason": "tool_call", + "usage": { + "cached_input_tokens": 13440, + "input_tokens": 13681, + "output_tokens": 47, + "total_tokens": 13728 + } + } + } + }, + { + "sequence": 133, + "type": "projection_delta", + "payload": { + "delta": [ + { + "op": "set_envelope", + "state": { + "session": { + "id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309727158, + "updatedAt": 1791309769897, + "tokenUsage": { + "cachedInputTokens": 117632, + "inputTokens": 128624, + "outputTokens": 1088, + "totalTokens": 129712 + }, + "contextUsage": { + "cachedInputTokens": 13440, + "inputTokens": 13681, + "outputTokens": 47, + "totalTokens": 13728 + } + }, + "latestTurn": { + "id": "turn-9674c56e0c67831ff3c246347b7d0a79" + } + } + } + ], + "watermark": 40 + } + }, + { + "sequence": 135, + "type": "projection_delta", + "payload": { + "delta": [ + { + "op": "set_envelope", + "state": { + "session": { + "id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309727158, + "updatedAt": 1791309769903, + "tokenUsage": { + "cachedInputTokens": 117632, + "inputTokens": 128624, + "outputTokens": 1088, + "totalTokens": 129712 + }, + "contextUsage": { + "cachedInputTokens": 13440, + "inputTokens": 13681, + "outputTokens": 47, + "totalTokens": 13728 + } + }, + "latestTurn": { + "id": "turn-9674c56e0c67831ff3c246347b7d0a79" + } + } + } + ], + "watermark": 41 + } + }, + { + "sequence": 138, + "type": "projection_delta", + "payload": { + "delta": [ + { + "op": "set_envelope", + "state": { + "session": { + "id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309727158, + "updatedAt": 1791309769975, + "tokenUsage": { + "cachedInputTokens": 117632, + "inputTokens": 128624, + "outputTokens": 1088, + "totalTokens": 129712 + }, + "contextUsage": { + "cachedInputTokens": 13440, + "inputTokens": 13681, + "outputTokens": 47, + "totalTokens": 13728 + } + }, + "latestTurn": { + "id": "turn-9674c56e0c67831ff3c246347b7d0a79" + } + } + } + ], + "watermark": 42 + } + }, + { + "sequence": 142, + "type": "projection_delta", + "payload": { + "delta": [ + { + "op": "set_envelope", + "state": { + "session": { + "id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309727158, + "updatedAt": 1791309769980, + "tokenUsage": { + "cachedInputTokens": 117632, + "inputTokens": 128624, + "outputTokens": 1088, + "totalTokens": 129712 + }, + "contextUsage": { + "cachedInputTokens": 13440, + "inputTokens": 13681, + "outputTokens": 47, + "totalTokens": 13728 + } + }, + "latestTurn": { + "id": "turn-9674c56e0c67831ff3c246347b7d0a79" + } + } + } + ], + "watermark": 43 + } + }, + { + "sequence": 144, + "type": "action_result", + "payload": { + "action_id": "c0765f86-3064-59a6-932d-b366a9a713d9", + "result": { + "finish_reason": "stop", + "usage": { + "cached_input_tokens": 13568, + "input_tokens": 13803, + "output_tokens": 128, + "total_tokens": 13931 + } + } + } + }, + { + "sequence": 145, + "type": "core_input", + "payload": { + "action_id": "c0765f86-3064-59a6-932d-b366a9a713d9", + "result": { + "finish_reason": "stop", + "usage": { + "cached_input_tokens": 13568, + "input_tokens": 13803, + "output_tokens": 128, + "total_tokens": 13931 + } + } + } + }, + { + "sequence": 146, + "type": "projection_delta", + "payload": { + "delta": [ + { + "op": "set_envelope", + "state": { + "session": { + "id": "f082d943-08f7-7c80-d0e4-dd99fd34afd6", + "createdAt": 1791309727158, + "updatedAt": 1791309771152, + "tokenUsage": { + "cachedInputTokens": 131200, + "inputTokens": 142427, + "outputTokens": 1216, + "totalTokens": 143643 + }, + "contextUsage": { + "cachedInputTokens": 13568, + "inputTokens": 13803, + "outputTokens": 128, + "totalTokens": 13931 + } + }, + "latestTurn": { + "id": "turn-9674c56e0c67831ff3c246347b7d0a79" + } + } + } + ], + "watermark": 44 + } + } + ], + "journal/0000000000000148.jsonl": [] +} \ No newline at end of file diff --git a/tests/fixtures/mistral-vibe-unified.json b/tests/fixtures/mistral-vibe-unified.json new file mode 100644 index 00000000..5e53372b --- /dev/null +++ b/tests/fixtures/mistral-vibe-unified.json @@ -0,0 +1,801 @@ +{ + "turn1": { + "CURRENT": { + "generation": "0000000000000008", + "manifest_sha256": "67e1b8469c09956b8139781f63f77d0d727ede7366922bfac6b21a01aaabf1b6", + "session_id": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "snapshot_sequence": 8, + "store_format": "mistral.vibe.unified-session-store/v1", + "store_format_minor": 7 + }, + "meta.json": { + "session_id": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "start_time": "2026-10-01T23:33:27.582000+00:00", + "end_time": "2026-10-01T23:33:28.883000+00:00", + "environment": { + "working_directory": "/tmp/vibe-repro" + }, + "config": null, + "title": null + }, + "generations/0000000000000008/manifest.json": { + "checkpoint": { + "checkpoint_version": 1, + "chunks": [ + "e26368dbad7c6038ed3197c97fedaaa73053eb235dda533a7c80f19b5ee0bcce" + ], + "path": "checkpoint.json", + "sha256": "7c2d0e779a6acd5adddf8f247eea94ab0affd41b092a27d77e60332b476e665e" + }, + "created_at": "2026-10-01T23:33:28.940Z", + "execution_state": "quiescent", + "generation": "0000000000000008", + "interop_export": null, + "manifest_version": 1, + "projection_state": { + "chunks": [ + "295c777bdde625d7e4d889c5d061b07e7d6b88af41d42de85b040f80c8e245a7" + ], + "path": "projection-state.json", + "sha256": "bf910877281b52d190644d5c58c937ea31105a732507e9368413b4ab4f04b449" + }, + "recovery_journal_segment": { + "first_sequence": 9, + "path": "journal/0000000000000009.jsonl" + }, + "runtime_state": { + "chunks": null, + "path": "runtime-state.json", + "sha256": "78a046ebc6462f17a2dae701088a8c6cafdf4200dcf89a18d579bf039273f1f7" + }, + "session_id": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "snapshot_sequence": 8 + }, + "generations/0000000000000008/projection-state.json": { + "projection_state_version": 1, + "session_id": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "snapshot": { + "activeCallbacks": [], + "format": "harness.public-session-state/v1", + "history": { + "cursor": { + "after": null, + "before": null + }, + "entries": [], + "range": "latest" + }, + "latestTurn": { + "completedAt": 1790897608883, + "id": "turn-7b0dbc3228e7fac94f5f61388fdf6ac0", + "queueItemId": null, + "sessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "startedAt": 1790897608324, + "status": "completed", + "stopReason": null + }, + "session": { + "contextUsage": { + "cachedInputTokens": 80, + "inputTokens": 120, + "outputTokens": 15, + "totalTokens": 135 + }, + "createdAt": 1790897607582, + "id": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "parentSessionId": null, + "preview": "Reply exactly: CODEBURN_MISTRAL_REPRO_OK", + "rootSessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "status": { + "type": "idle" + }, + "title": null, + "titleSource": "auto", + "tokenUsage": { + "cachedInputTokens": 80, + "inputTokens": 120, + "outputTokens": 15, + "totalTokens": 135 + }, + "updatedAt": 1790897608883 + }, + "turnQueue": { + "items": [], + "maxItems": 32, + "paused": false + } + }, + "snapshot_sequence": 8, + "watermark": 2 + }, + "generations/0000000000000008/runtime-state.json": { + "runtime_state_version": 3, + "session_id": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "session_metadata": { + "active_model": "mistral-medium-3.5", + "agent_name": null, + "cwd": "/tmp/vibe-repro", + "hook_bindings": [ + { + "id": "builtin:agents_md", + "order": 0, + "point": "post_tool_call", + "selector": { + "type": "always" + } + } + ], + "parent_session_id": null, + "reasoning_effort": "off", + "root_session_id": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "subagent_policy_ceiling_digest": null, + "subagent_spawn_key": null, + "subagent_template_digest": null + } + }, + "chunks/295c777bdde625d7e4d889c5d061b07e7d6b88af41d42de85b040f80c8e245a7.json": [ + { + "content": [ + { + "text": "Reply exactly: CODEBURN_MISTRAL_REPRO_OK", + "type": "text" + } + ], + "createdAt": 1790897608324, + "generationStatus": "completed", + "id": "user-turn-7b0dbc3228e7fac94f5f61388fdf6ac0-1", + "relatedEntryId": null, + "role": "user", + "sessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "source": "turn_start", + "turnId": "turn-7b0dbc3228e7fac94f5f61388fdf6ac0", + "type": "message", + "updatedAt": 1790897608324 + }, + { + "content": [ + { + "text": "CODEBURN_MISTRAL_REPRO_OK_1", + "type": "text" + } + ], + "createdAt": 1790897608883, + "generationStatus": "completed", + "id": "assistant-e6d6e722-0d24-5d5f-a441-31f6de3dd49f", + "outcome": { + "type": "committed" + }, + "relatedEntryId": null, + "role": "assistant", + "sessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "source": "harness", + "turnId": "turn-7b0dbc3228e7fac94f5f61388fdf6ac0", + "type": "message", + "updatedAt": 1790897608883 + } + ], + "journal/0000000000000009.jsonl": [], + "journal/0000000000000001.jsonl": [ + { + "payload": { + "delta": [ + { + "entry": { + "content": [ + { + "text": "Reply exactly: CODEBURN_MISTRAL_REPRO_OK", + "type": "text" + } + ], + "createdAt": 1790897608324, + "generationStatus": "completed", + "id": "user-turn-7b0dbc3228e7fac94f5f61388fdf6ac0-1", + "relatedEntryId": null, + "role": "user", + "sessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "source": "turn_start", + "turnId": "turn-7b0dbc3228e7fac94f5f61388fdf6ac0", + "type": "message", + "updatedAt": 1790897608324 + }, + "op": "append_entry" + }, + { + "op": "set_envelope", + "state": { + "activeCallbacks": [], + "format": "harness.public-session-state/v1", + "history": { + "cursor": { + "after": null, + "before": null + }, + "entries": [], + "range": "latest" + }, + "latestTurn": { + "id": "turn-7b0dbc3228e7fac94f5f61388fdf6ac0", + "queueItemId": null, + "sessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "startedAt": 1790897608324, + "status": "in_progress" + }, + "session": { + "contextUsage": null, + "createdAt": 1790897607582, + "id": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "parentSessionId": null, + "preview": "Reply exactly: CODEBURN_MISTRAL_REPRO_OK", + "rootSessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "status": { + "activeTurnId": "turn-7b0dbc3228e7fac94f5f61388fdf6ac0", + "type": "running" + }, + "title": null, + "titleSource": "auto", + "tokenUsage": null, + "updatedAt": 1790897608324 + }, + "turnQueue": { + "items": [], + "maxItems": 32, + "paused": false + } + } + } + ], + "watermark": 1 + }, + "previous_record_sha256": "f8baf6a135cf6ae7c6184e9006a34b670492ed26ed1aa37f58b7e6baf4b92fe8", + "record_sha256": "735b21e8df3e405c5d90104dd7799ecb5358532702086efaa048c43a614f7ed3", + "recovery_journal_record_version": 1, + "sequence": 3, + "type": "projection_delta" + }, + { + "payload": { + "action_id": "e6d6e722-0d24-5d5f-a441-31f6de3dd49f", + "result": { + "action_id": "e6d6e722-0d24-5d5f-a441-31f6de3dd49f", + "result": { + "finish_reason": "stop", + "parts": [ + { + "text": "CODEBURN_MISTRAL_REPRO_OK_1", + "type": "text" + } + ], + "usage": { + "cached_input_tokens": 80, + "input_tokens": 120, + "output_tokens": 15, + "total_tokens": 135 + } + }, + "type": "completion_succeeded" + }, + "state": "succeeded" + }, + "previous_record_sha256": "0b2243a7459c554715759a9299d21b5243cff6107a42e9db81517fbdb24ec267", + "record_sha256": "178f8356f9652c22240ade0c2516853d96a64569e511b3739254eccafbec5e2d", + "recovery_journal_record_version": 1, + "sequence": 5, + "type": "action_result" + }, + { + "payload": { + "delta": [ + { + "entry": { + "content": [ + { + "text": "CODEBURN_MISTRAL_REPRO_OK_1", + "type": "text" + } + ], + "createdAt": 1790897608883, + "generationStatus": "completed", + "id": "assistant-e6d6e722-0d24-5d5f-a441-31f6de3dd49f", + "outcome": { + "type": "committed" + }, + "relatedEntryId": null, + "role": "assistant", + "sessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "source": "harness", + "turnId": "turn-7b0dbc3228e7fac94f5f61388fdf6ac0", + "type": "message", + "updatedAt": 1790897608883 + }, + "op": "append_entry" + }, + { + "op": "set_envelope", + "state": { + "activeCallbacks": [], + "format": "harness.public-session-state/v1", + "history": { + "cursor": { + "after": null, + "before": null + }, + "entries": [], + "range": "latest" + }, + "latestTurn": { + "completedAt": 1790897608883, + "id": "turn-7b0dbc3228e7fac94f5f61388fdf6ac0", + "queueItemId": null, + "sessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "startedAt": 1790897608324, + "status": "completed", + "stopReason": null + }, + "session": { + "contextUsage": { + "cachedInputTokens": 80, + "inputTokens": 120, + "outputTokens": 15, + "totalTokens": 135 + }, + "createdAt": 1790897607582, + "id": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "parentSessionId": null, + "preview": "Reply exactly: CODEBURN_MISTRAL_REPRO_OK", + "rootSessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "status": { + "type": "idle" + }, + "title": null, + "titleSource": "auto", + "tokenUsage": { + "cachedInputTokens": 80, + "inputTokens": 120, + "outputTokens": 15, + "totalTokens": 135 + }, + "updatedAt": 1790897608883 + }, + "turnQueue": { + "items": [], + "maxItems": 32, + "paused": false + } + } + } + ], + "watermark": 2 + }, + "previous_record_sha256": "008c8130e7fe3582858ad44314534690697f79838bb698af11b885e8bdd30b83", + "record_sha256": "2ba334640e511404a9c67f56446a4270fdcfde898e7da1fcc9d877e6ab465a5b", + "recovery_journal_record_version": 1, + "sequence": 7, + "type": "projection_delta" + } + ] + }, + "turn2": { + "CURRENT": { + "generation": "0000000000000016", + "manifest_sha256": "b06ee12b3161b7fcfb31976bd33e3395f560908b731ccf085eedf13585173720", + "session_id": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "snapshot_sequence": 16, + "store_format": "mistral.vibe.unified-session-store/v1", + "store_format_minor": 7 + }, + "meta.json": { + "session_id": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "start_time": "2026-10-01T23:33:27.582000+00:00", + "end_time": "2026-10-01T23:33:43.273000+00:00", + "environment": { + "working_directory": "/tmp/vibe-repro" + }, + "config": null, + "title": null + }, + "generations/0000000000000016/manifest.json": { + "checkpoint": { + "checkpoint_version": 1, + "chunks": [ + "9b820017d720c888e61baa02e9ffa2b7c19650d25939f3e93647a9bb4c579541" + ], + "path": "checkpoint.json", + "sha256": "cbb575e57fba698512febef8b9f8832ea98b5f7f2d8fbfdc651a074f516233f9" + }, + "created_at": "2026-10-01T23:33:43.323Z", + "execution_state": "quiescent", + "generation": "0000000000000016", + "interop_export": null, + "manifest_version": 1, + "projection_state": { + "chunks": [ + "f6fcb81734343e577421024747680914d7ae28e36e198a2db3fdf8ee4864f37c" + ], + "path": "projection-state.json", + "sha256": "8549944647abb856ee7509e5aa6ce0c421e84e5d9f18f57270a723a8e8fbdd6a" + }, + "recovery_journal_segment": { + "first_sequence": 17, + "path": "journal/0000000000000017.jsonl" + }, + "runtime_state": { + "chunks": null, + "path": "runtime-state.json", + "sha256": "434ec4956afd78e9145e12f3ac9621bbf43e02deff185431935502cbffc37fee" + }, + "session_id": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "snapshot_sequence": 16 + }, + "generations/0000000000000016/projection-state.json": { + "projection_state_version": 1, + "session_id": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "snapshot": { + "activeCallbacks": [], + "format": "harness.public-session-state/v1", + "history": { + "cursor": { + "after": null, + "before": null + }, + "entries": [], + "range": "latest" + }, + "latestTurn": { + "completedAt": 1790897623273, + "id": "turn-4f76f79c4f5d115f4511b93d43316578", + "queueItemId": null, + "sessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "startedAt": 1790897622912, + "status": "completed", + "stopReason": null + }, + "session": { + "contextUsage": { + "cachedInputTokens": 64, + "inputTokens": 128, + "outputTokens": 10, + "totalTokens": 138 + }, + "createdAt": 1790897607582, + "id": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "parentSessionId": null, + "preview": "Reply exactly: CODEBURN_MISTRAL_REPRO_OK", + "rootSessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "status": { + "type": "idle" + }, + "title": null, + "titleSource": "auto", + "tokenUsage": { + "cachedInputTokens": 144, + "inputTokens": 248, + "outputTokens": 25, + "totalTokens": 273 + }, + "updatedAt": 1790897623273 + }, + "turnQueue": { + "items": [], + "maxItems": 32, + "paused": false + } + }, + "snapshot_sequence": 16, + "watermark": 4 + }, + "generations/0000000000000016/runtime-state.json": { + "runtime_state_version": 3, + "session_id": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "session_metadata": { + "active_model": "mistral-medium-3.5", + "agent_name": null, + "cwd": "/tmp/vibe-repro", + "hook_bindings": [ + { + "id": "builtin:agents_md", + "order": 0, + "point": "post_tool_call", + "selector": { + "type": "always" + } + } + ], + "parent_session_id": null, + "reasoning_effort": "off", + "root_session_id": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "subagent_policy_ceiling_digest": null, + "subagent_spawn_key": null, + "subagent_template_digest": null + } + }, + "chunks/f6fcb81734343e577421024747680914d7ae28e36e198a2db3fdf8ee4864f37c.json": [ + { + "content": [ + { + "text": "Reply exactly: CODEBURN_MISTRAL_REPRO_OK", + "type": "text" + } + ], + "createdAt": 1790897608324, + "generationStatus": "completed", + "id": "user-turn-7b0dbc3228e7fac94f5f61388fdf6ac0-1", + "relatedEntryId": null, + "role": "user", + "sessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "source": "turn_start", + "turnId": "turn-7b0dbc3228e7fac94f5f61388fdf6ac0", + "type": "message", + "updatedAt": 1790897608324 + }, + { + "content": [ + { + "text": "CODEBURN_MISTRAL_REPRO_OK_1", + "type": "text" + } + ], + "createdAt": 1790897608883, + "generationStatus": "completed", + "id": "assistant-e6d6e722-0d24-5d5f-a441-31f6de3dd49f", + "outcome": { + "type": "committed" + }, + "relatedEntryId": null, + "role": "assistant", + "sessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "source": "harness", + "turnId": "turn-7b0dbc3228e7fac94f5f61388fdf6ac0", + "type": "message", + "updatedAt": 1790897608883 + }, + { + "content": [ + { + "text": "Reply exactly: CODEBURN_MISTRAL_REPRO_OK", + "type": "text" + } + ], + "createdAt": 1790897622912, + "generationStatus": "completed", + "id": "user-turn-4f76f79c4f5d115f4511b93d43316578-3", + "relatedEntryId": null, + "role": "user", + "sessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "source": "turn_start", + "turnId": "turn-4f76f79c4f5d115f4511b93d43316578", + "type": "message", + "updatedAt": 1790897622912 + }, + { + "content": [ + { + "text": "CODEBURN_MISTRAL_REPRO_OK_2", + "type": "text" + } + ], + "createdAt": 1790897623273, + "generationStatus": "completed", + "id": "assistant-f092f4e1-afb8-53af-9710-cd0da761d798", + "outcome": { + "type": "committed" + }, + "relatedEntryId": null, + "role": "assistant", + "sessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "source": "harness", + "turnId": "turn-4f76f79c4f5d115f4511b93d43316578", + "type": "message", + "updatedAt": 1790897623273 + } + ], + "journal/0000000000000009.jsonl": [ + { + "payload": { + "delta": [ + { + "entry": { + "content": [ + { + "text": "Reply exactly: CODEBURN_MISTRAL_REPRO_OK", + "type": "text" + } + ], + "createdAt": 1790897622912, + "generationStatus": "completed", + "id": "user-turn-4f76f79c4f5d115f4511b93d43316578-3", + "relatedEntryId": null, + "role": "user", + "sessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "source": "turn_start", + "turnId": "turn-4f76f79c4f5d115f4511b93d43316578", + "type": "message", + "updatedAt": 1790897622912 + }, + "op": "append_entry" + }, + { + "op": "set_envelope", + "state": { + "activeCallbacks": [], + "format": "harness.public-session-state/v1", + "history": { + "cursor": { + "after": null, + "before": null + }, + "entries": [], + "range": "latest" + }, + "latestTurn": { + "id": "turn-4f76f79c4f5d115f4511b93d43316578", + "queueItemId": null, + "sessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "startedAt": 1790897622912, + "status": "in_progress" + }, + "session": { + "contextUsage": { + "cachedInputTokens": 80, + "inputTokens": 120, + "outputTokens": 15, + "totalTokens": 135 + }, + "createdAt": 1790897607582, + "id": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "parentSessionId": null, + "preview": "Reply exactly: CODEBURN_MISTRAL_REPRO_OK", + "rootSessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "status": { + "activeTurnId": "turn-4f76f79c4f5d115f4511b93d43316578", + "type": "running" + }, + "title": null, + "titleSource": "auto", + "tokenUsage": { + "cachedInputTokens": 80, + "inputTokens": 120, + "outputTokens": 15, + "totalTokens": 135 + }, + "updatedAt": 1790897622912 + }, + "turnQueue": { + "items": [], + "maxItems": 32, + "paused": false + } + } + } + ], + "watermark": 3 + }, + "previous_record_sha256": "ffa674204a66c44739a65b21ffbcc23cec6184c0945ee44077d84aaa0955baa0", + "record_sha256": "0c6bdc8b074314515c4d7be69ffca267113e88849745640ba74691ee4bd05f8c", + "recovery_journal_record_version": 1, + "sequence": 11, + "type": "projection_delta" + }, + { + "payload": { + "action_id": "f092f4e1-afb8-53af-9710-cd0da761d798", + "result": { + "action_id": "f092f4e1-afb8-53af-9710-cd0da761d798", + "result": { + "finish_reason": "stop", + "parts": [ + { + "text": "CODEBURN_MISTRAL_REPRO_OK_2", + "type": "text" + } + ], + "usage": { + "cached_input_tokens": 64, + "input_tokens": 128, + "output_tokens": 10, + "total_tokens": 138 + } + }, + "type": "completion_succeeded" + }, + "state": "succeeded" + }, + "previous_record_sha256": "dab7c0b0db4a638c6267978104f1479912bccd1eed3fcb3f8cc470cbf8c281ca", + "record_sha256": "6baa17c3035f666122a1e0c7017be4f85d4556d2c3967c41633b4c5d5adfeea6", + "recovery_journal_record_version": 1, + "sequence": 13, + "type": "action_result" + }, + { + "payload": { + "delta": [ + { + "entry": { + "content": [ + { + "text": "CODEBURN_MISTRAL_REPRO_OK_2", + "type": "text" + } + ], + "createdAt": 1790897623273, + "generationStatus": "completed", + "id": "assistant-f092f4e1-afb8-53af-9710-cd0da761d798", + "outcome": { + "type": "committed" + }, + "relatedEntryId": null, + "role": "assistant", + "sessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "source": "harness", + "turnId": "turn-4f76f79c4f5d115f4511b93d43316578", + "type": "message", + "updatedAt": 1790897623273 + }, + "op": "append_entry" + }, + { + "op": "set_envelope", + "state": { + "activeCallbacks": [], + "format": "harness.public-session-state/v1", + "history": { + "cursor": { + "after": null, + "before": null + }, + "entries": [], + "range": "latest" + }, + "latestTurn": { + "completedAt": 1790897623273, + "id": "turn-4f76f79c4f5d115f4511b93d43316578", + "queueItemId": null, + "sessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "startedAt": 1790897622912, + "status": "completed", + "stopReason": null + }, + "session": { + "contextUsage": { + "cachedInputTokens": 64, + "inputTokens": 128, + "outputTokens": 10, + "totalTokens": 138 + }, + "createdAt": 1790897607582, + "id": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "parentSessionId": null, + "preview": "Reply exactly: CODEBURN_MISTRAL_REPRO_OK", + "rootSessionId": "e5e3f04f-278a-6604-efbe-6c25f12f81de", + "status": { + "type": "idle" + }, + "title": null, + "titleSource": "auto", + "tokenUsage": { + "cachedInputTokens": 144, + "inputTokens": 248, + "outputTokens": 25, + "totalTokens": 273 + }, + "updatedAt": 1790897623273 + }, + "turnQueue": { + "items": [], + "maxItems": 32, + "paused": false + } + } + } + ], + "watermark": 4 + }, + "previous_record_sha256": "825c15bca94bc2c00816b680ef91324cfe07a3186a2d9eba4c7af0949cc7af8c", + "record_sha256": "2a880b28bad68c5abfae0c6477923e8e464dc7a18675c547b9f781d32dc59ddc", + "recovery_journal_record_version": 1, + "sequence": 15, + "type": "projection_delta" + } + ], + "journal/0000000000000017.jsonl": [] + } +} diff --git a/tests/fixtures/mistral-vibe-unified.md b/tests/fixtures/mistral-vibe-unified.md new file mode 100644 index 00000000..ad1a3a7a --- /dev/null +++ b/tests/fixtures/mistral-vibe-unified.md @@ -0,0 +1,37 @@ +# Mistral Vibe Unified Harness fixture + +`mistral-vibe-unified.json` contains two snapshots written by the unmodified +Mistral Vibe **2.25.8** CLI on macOS, using `--experimental-harness --trust +--disabled-tools '*' --max-turns 1 --output json -p ...`. The second invocation +uses `--continue` to resume the first session. + +The API was a local HTTP SSE fixture, not a paid Mistral response. It returned: + +| Turn | Prompt tokens (includes cache) | Cached prompt tokens | Completion tokens | +| --- | ---: | ---: | ---: | +| 1 | 120 | 80 | 15 | +| 2 | 128 | 64 | 10 | + +The CLI's actual storage, projection updates, generation publication, history +chunks, and journal rotation produced the fixture. After the second invocation, +the first journal segment has been removed. Expected CodeBurn totals are 104 +uncached input, 144 cache-read input, and 25 output tokens: **273 total**. + +The fixture preserves the selected CURRENT generation, its manifest and +projection, the referenced history chunks, and relevant journal records. Unused +runtime state and metadata were removed, and the working directory was replaced +with `/tmp/vibe-repro`. Embedded hashes are original provenance values, not +checksums of these minimized documents. No credentials or private conversation +content are included. + +## Vibe 2.26.0 fixture + +`mistral-vibe-unified-2.26.json` is a real Vibe **2.26.0** session against the +Mistral API: two prompts, 11 completions, no model pin (default +`mistral-medium-3.5`). The first prompt's journal segment had already rotated +away, so only the second prompt's 5 calls keep per-call usage. Totals: +142,427 input tokens of which 131,200 cached, 1,216 output. All prompt, file, +tool-output and title text is replaced with `redacted`, bash commands with +`python3 -m unittest`, and the working directory with `/tmp/vibe-test`. +Runtime state keeps only session metadata and action kinds and states; the +journal keeps cumulative envelopes and the usage of each completion. diff --git a/tests/providers/mistral-vibe-unified.test.ts b/tests/providers/mistral-vibe-unified.test.ts new file mode 100644 index 00000000..f197bfcd --- /dev/null +++ b/tests/providers/mistral-vibe-unified.test.ts @@ -0,0 +1,193 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { appendFile, mkdir, readFile, rm, writeFile } from 'fs/promises' +import { dirname, join } from 'path' +const testHome = vi.hoisted(() => { + const path = `${process.env['TMPDIR'] || '/tmp'}/vibe-unified-${process.pid}-${Date.now()}` + process.env['VIBE_HOME'] = `${path}/.vibe` + return path +}) +import fixture from '../fixtures/mistral-vibe-unified.json' +import fixture226 from '../fixtures/mistral-vibe-unified-2.26.json' +import { clearSessionCache, parseAllSessions } from '../../src/parser.js' +import { createMistralVibeProvider } from '../../src/providers/mistral-vibe.js' +import { fingerprintFile } from '../../src/session-cache.js' +import { setHome } from '../setup/home.js' +import type { ParsedProviderCall } from '../../src/providers/types.js' + +let home: string +let root: string +let session: string +let current: string + +beforeEach(async () => { + home = testHome + await mkdir(home, { recursive: true }) + setHome(home) + process.env['VIBE_HOME'] = join(home, '.vibe') + process.env['CODEBURN_CACHE_DIR'] = join(home, 'cache') + root = join(home, '.vibe/logs/session') + session = join(root, 'unified', fixture.turn1.CURRENT.session_id) + current = join(session, 'CURRENT') +}) + +afterEach(async () => { + clearSessionCache() + await rm(home, { recursive: true, force: true }) +}) + +async function writeSnapshot(files: Record, dir = session) { + await rm(dir, { recursive: true, force: true }) + for (const [name, value] of Object.entries(files)) { + const path = join(dir, name) + await mkdir(dirname(path), { recursive: true }) + await writeFile(path, name.endsWith('.jsonl') + ? (value as unknown[]).map(line => JSON.stringify(line)).join('\n') + '\n' + : JSON.stringify(value)) + } +} + +async function calls(seenKeys = new Set()): Promise { + const provider = createMistralVibeProvider(root) + const result: ParsedProviderCall[] = [] + for (const source of await provider.discoverSessions()) { + for await (const call of provider.createSessionParser(source, seenKeys).parse()) result.push(call) + } + return result +} + +function tokens(values: ParsedProviderCall[]) { + return values.reduce((sum, call) => ({ + input: sum.input + call.inputTokens, + output: sum.output + call.outputTokens, + cached: sum.cached + call.cacheReadInputTokens, + }), { input: 0, output: 0, cached: 0 }) +} + +describe('Mistral Vibe Unified Harness (real 2.25.8 store, local API fixture)', () => { + it('discovers CURRENT beside stats-free metadata and preserves cached input', async () => { + await writeSnapshot(fixture.turn1) + const provider = createMistralVibeProvider(root) + expect(await provider.discoverSessions()).toEqual([ + { path: current, project: 'vibe-repro', provider: 'mistral-vibe' }, + ]) + const parsed = await calls() + expect(parsed).toHaveLength(1) + expect(tokens(parsed)).toEqual({ input: 40, output: 15, cached: 80 }) + expect(parsed[0]).toMatchObject({ + model: 'mistral-medium-3.5', cachedInputTokens: 80, + userMessage: 'Reply exactly: CODEBURN_MISTRAL_REPRO_OK', + projectPath: '/tmp/vibe-repro', timestamp: '2026-10-01T23:33:28.883Z', + }) + expect(parsed[0]!.costUSD).toBeGreaterThan(0) + }) + + it('retains the first turn after Vibe prunes its journal and does not double-count projections', async () => { + await writeSnapshot(fixture.turn2) + const parsed = await calls() + expect(parsed.map(c => [c.inputTokens, c.outputTokens, c.cacheReadInputTokens])).toEqual([ + [40, 15, 80], [64, 10, 64], + ]) + expect(tokens(parsed)).toEqual({ input: 104, output: 25, cached: 144 }) + expect(new Set(parsed.map(c => c.turnId)).size).toBe(2) + const seen = new Set() + expect(await calls(seen)).toHaveLength(2) + expect(await calls(seen)).toHaveLength(0) + }) + + it('reads only the committed generation and handles fully pruned journals', async () => { + await writeSnapshot(fixture.turn2) + await rm(join(session, 'journal'), { recursive: true }) + // A partial, newer generation must never displace CURRENT. + const unpublished = join(session, 'generations/9999999999999999') + await mkdir(unpublished) + await writeFile(join(unpublished, 'projection-state.json'), '{}') + expect(tokens(await calls())).toEqual({ input: 104, output: 25, cached: 144 }) + }) + + it('reparses appended journal usage without a CURRENT or directory mtime change', async () => { + await writeSnapshot(fixture.turn1) + const before = await fingerprintFile(current) + const beforeCurrent = await readFile(current, 'utf8') + const initial = await parseAllSessions(undefined, 'mistral-vibe') + expect(initial.flatMap(p => p.sessions).flatMap(s => s.turns).flatMap(t => t.assistantCalls)) + .toHaveLength(1) + const tail = fixture.turn2['journal/0000000000000009.jsonl'] + await appendFile(join(session, 'journal/0000000000000009.jsonl'), tail.map(r => JSON.stringify(r)).join('\n') + '\n') + expect(await readFile(current, 'utf8')).toBe(beforeCurrent) + expect(await fingerprintFile(current)).not.toEqual(before) + clearSessionCache() + const after = await parseAllSessions(undefined, 'mistral-vibe') + const parsed = after.flatMap(p => p.sessions).flatMap(s => s.turns).flatMap(t => t.assistantCalls) + expect(parsed).toHaveLength(2) + expect(parsed.reduce((sum, c) => sum + c.usage.inputTokens + c.usage.cacheReadInputTokens + c.usage.outputTokens, 0)).toBe(273) + }) + + it('ignores duplicate journal sequences and truncated trailing writes', async () => { + await writeSnapshot(fixture.turn2) + const path = join(session, 'journal/0000000000000017.jsonl') + await appendFile(path, fixture.turn2['journal/0000000000000009.jsonl'].map(r => JSON.stringify(r)).join('\n') + '\n{"sequence":') + expect(tokens(await calls())).toEqual({ input: 104, output: 25, cached: 144 }) + }) + + it('does not interpret malformed manifests or paths outside the store', async () => { + await writeSnapshot(fixture.turn1) + await writeFile(current, JSON.stringify({ ...fixture.turn1.CURRENT, generation: '../../outside' })) + expect(await calls()).toEqual([]) + }) + + it('supports pre-delta projection_advanced records without reusing contextUsage', async () => { + const files = structuredClone(fixture.turn1) as Record + const records = fixture.turn1['journal/0000000000000001.jsonl'] + files['journal/0000000000000001.jsonl'] = records.flatMap(record => { + if (record.type !== 'projection_delta' || !('delta' in record.payload)) return [] + return record.payload.delta.filter(op => op.op === 'set_envelope').map(op => ({ + sequence: record.sequence, type: 'projection_advanced', payload: { snapshot: 'state' in op ? op.state : {} }, + })) + }) + await writeSnapshot(files) + expect(tokens(await calls())).toEqual({ input: 40, output: 15, cached: 80 }) + }) +}) + +// Redacted from a real Vibe 2.26.0 session: two prompts, 11 completions, the +// first prompt's journal segment already rotated away, no model pin. +describe('Mistral Vibe Unified Harness (real 2.26.0 session, redacted)', () => { + const dir = () => join(root, 'unified', fixture226.CURRENT.session_id) + + it('reads an unpinned session as the default model with exact totals and every call', async () => { + await writeSnapshot(fixture226, dir()) + const parsed = await calls() + expect(parsed).toHaveLength(11) + expect(new Set(parsed.map(c => c.model))).toEqual(new Set(['mistral-medium-3.5'])) + expect(tokens(parsed)).toEqual({ input: 11227, output: 1216, cached: 131200 }) + expect(parsed.reduce((sum, c) => sum + c.costUSD, 0)).toBeCloseTo(0.0456405, 9) + expect(parsed.slice(6).map(c => [c.inputTokens, c.cacheReadInputTokens, c.outputTokens])).toEqual([ + [185, 12928, 194], [285, 13056, 79], [142, 13312, 192], [241, 13440, 47], [235, 13568, 128], + ]) + expect(new Set(parsed.map(c => c.turnId)).size).toBe(2) + expect(parsed.flatMap(c => c.tools).sort()).toEqual(['Bash', 'Bash', 'Edit', 'Edit', 'Read']) + expect(new Set(parsed.flatMap(c => c.bashCommands))).toEqual(new Set(['python3'])) + }) + + it('uses config.toml active_model for an unpinned session', async () => { + await writeSnapshot(fixture226, dir()) + await writeFile(join(home, '.vibe/config.toml'), 'theme = "auto"\nactive_model = "le-chonk"\n\n[[models]]\nalias = "other"\n') + const parsed = await calls() + expect(new Set(parsed.map(c => c.model))).toEqual(new Set(['le-chonk'])) + expect(parsed.reduce((sum, c) => sum + c.costUSD, 0)).toBe(0) + }) + + it('counts a legacy session beside a unified one without overlap', async () => { + await writeSnapshot(fixture226, dir()) + const legacy = join(root, 'session_legacy') + await mkdir(legacy, { recursive: true }) + await writeFile(join(legacy, 'meta.json'), JSON.stringify({ + session_id: 'legacy', start_time: '2026-10-06T10:00:00Z', + stats: { session_prompt_tokens: 100, session_completion_tokens: 10, session_cost: 0.5 }, + })) + await writeFile(join(legacy, 'messages.jsonl'), JSON.stringify({ role: 'assistant', message_id: 'm1' }) + '\n') + const parsed = await calls() + expect(parsed).toHaveLength(12) + expect(tokens(parsed)).toEqual({ input: 11327, output: 1226, cached: 131200 }) + }) +})