Files
jason.woltje 6bad02612a lead: commit dewey's untracked evidence (721 files: queue-124-review queue-143 queue-149 queue-165-review queue-170 queue-175 queue-177 queue-184 queue-191)
Unclaimed files left in the canonical checkout. Inventory: canonical-cleanup-inventory.md (commit-as-evidence groups). detect-secrets scan clean on 2026-11-02: hits are sha256 pins, git object ids, test sentinels already in tracked tests and unit-file lines.
2026-11-02 15:05:14 -06:00

39 lines
3.1 KiB
JavaScript

// Dewey's row 124 review probes (no live store, no repository write). Run from the r124 worktree root.
// p1: usage_records is the one table with an `at` column that Store's #verifyTimes skips.
// p2: the claude-code-only project-directory open refuses a symlinked project dir and session file.
import { mkdtempSync, mkdirSync, writeFileSync, rmSync, symlinkSync } from 'node:fs';
import { join, resolve } from 'node:path';
import { tmpdir } from 'node:os';
const { Store } = await import(resolve('packages/bus/src/store.mjs'));
const { readTurn } = await import(resolve('packages/plugins/usage-source/transcript/index.mjs'));
const out = {};
const root = mkdtempSync(join(tmpdir(), 'dewey-r124-probe-'));
try {
mkdirSync(join(root, 'store'), { mode: 0o700 });
const store = new Store(join(root, 'store'));
const bad = '2026-10-04T00:00:00Z';
const tryRun = (sql, ...args) => { try { store.run(sql, ...args); return 'accepted'; } catch (e) { return e.message; } };
out.p1_control_events = tryRun('INSERT INTO events(id,at,business,kind,body) VALUES(?,?,?,?,?)', 'e1', bad, 'demo', 'action.allowed', '{}');
out.p1_usage_records = tryRun(`INSERT INTO usage_records(at,business,run,instance,turn,source,phase,status,code)
VALUES (?,?,?,?,?,?,?,?,?)`, bad, 'demo', 'run1', 'coder', 'turn1', '@none', 'end', 'unknown', 'no-source');
out.p1_usage_rows = store.get('SELECT count(*) n FROM usage_records').n;
store.close();
let reopen; try { new Store(join(root, 'store')).close(); reopen = 'opened'; } catch (e) { reopen = e.message; }
out.p1_reopen_with_bad_at = reopen;
const entry = { type: 'assistant', message: { id: 'assistant1', role: 'assistant', usage: { input_tokens: 1, output_tokens: 2, cache_creation_input_tokens: 3, cache_read_input_tokens: 4 } } };
const real = join(root, 'real'); mkdirSync(real);
writeFileSync(join(real, 'session.jsonl'), JSON.stringify(entry) + '\n');
const c0 = join(root, 'c0'); mkdirSync(join(c0, 'project'), { recursive: true });
writeFileSync(join(c0, 'project', 'session.jsonl'), JSON.stringify(entry) + '\n');
out.p2_control = await readTurn({ harness: 'claude-code', root: c0 });
const c1 = join(root, 'c1'); mkdirSync(c1); symlinkSync(real, join(c1, 'project'));
out.p2_symlink_project_dir = await readTurn({ harness: 'claude-code', root: c1 });
const c2 = join(root, 'c2'); mkdirSync(join(c2, 'project'), { recursive: true }); symlinkSync(join(real, 'session.jsonl'), join(c2, 'project', 'session.jsonl'));
out.p2_symlink_session_file = await readTurn({ harness: 'claude-code', root: c2 });
const c3 = join(root, 'c3'); mkdirSync(join(c3, 'project'), { recursive: true }); writeFileSync(join(c3, 'project', 'session.jsonl'), '{"type":');
out.p2_cut_line = await readTurn({ harness: 'claude-code', root: c3 });
const c4 = join(root, 'c4'); mkdirSync(join(c4, 'project'), { recursive: true }); writeFileSync(join(c4, 'project', 'session.jsonl'), ' '.repeat(8 * 1024 * 1024 + 1));
out.p2_oversized = await readTurn({ harness: 'claude-code', root: c4 });
} finally { rmSync(root, { recursive: true, force: true }); }
console.log(JSON.stringify(out, null, 1));