@alizain/doublecheck 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -4
- package/dist/cli.mjs +24 -3
- package/dist/cli.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -69,14 +69,24 @@ missing token / checks / image abort loudly up front.
|
|
|
69
69
|
npm install -g @alizain/doublecheck # installs the `doublecheck` command; or, from a clone: pnpm install
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
Guests boot from
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
Guests boot from an image with both agent CLIs baked in. An installed release
|
|
73
|
+
needs no image step: the runner resolves
|
|
74
|
+
`ghcr.io/alizain/doublecheck-guest:<its own version>` and pulls it on first
|
|
75
|
+
run (~1 GB, once per version — the release workflow publishes it for
|
|
76
|
+
amd64+arm64 alongside the npm package).
|
|
77
|
+
|
|
78
|
+
From a clone (version `0.0.0-development`) guests use a locally built image
|
|
79
|
+
instead. Build it once (needs a running Docker daemon; rebuild to pick up
|
|
80
|
+
newer agent CLIs):
|
|
75
81
|
|
|
76
82
|
```bash
|
|
77
83
|
./scripts/build-guest-image.sh
|
|
78
84
|
```
|
|
79
85
|
|
|
86
|
+
`DOUBLECHECK_GUEST_IMAGE=<ref>` overrides the image for any install — the
|
|
87
|
+
named ref must already be in the microsandbox cache (it is never pulled);
|
|
88
|
+
useful offline or for custom guest images.
|
|
89
|
+
|
|
80
90
|
## Usage
|
|
81
91
|
|
|
82
92
|
```bash
|
|
@@ -191,9 +201,20 @@ pushing to main.
|
|
|
191
201
|
|
|
192
202
|
```bash
|
|
193
203
|
gh workflow run release -f dry_run=true # preview next version + notes, publish nothing
|
|
194
|
-
gh workflow run release -f dry_run=false # ship: npm publish + GitHub Release + tag
|
|
204
|
+
gh workflow run release -f dry_run=false # ship: npm publish + GitHub Release + tag + guest image
|
|
205
|
+
gh workflow run release -f image_version=X.Y.Z # no release: (re)build + push the guest image
|
|
206
|
+
# for an existing version (recovery, or refreshing
|
|
207
|
+
# the baked-in agent CLIs)
|
|
195
208
|
```
|
|
196
209
|
|
|
210
|
+
A real release also builds `Dockerfile.guest` for amd64+arm64 and pushes
|
|
211
|
+
`ghcr.io/alizain/doublecheck-guest:<version>` (+ `:latest`) — the image
|
|
212
|
+
installed CLIs pull at runtime. The ghcr package must be **public** for those
|
|
213
|
+
unauthenticated pulls (one-time visibility flip in the package settings after
|
|
214
|
+
the very first push). `image_version` mutates an existing tag in place;
|
|
215
|
+
machines that already pulled it keep their cached copy (the runner pulls
|
|
216
|
+
if-missing and never re-checks).
|
|
217
|
+
|
|
197
218
|
- **Only `feat:` / `fix:` / `BREAKING CHANGE:` commits trigger a release** and
|
|
198
219
|
decide the bump (minor / patch / major). Other commit styles ride along
|
|
199
220
|
unreleased — use `docs:`/`chore:`/plain messages for work that shouldn't ship
|
package/dist/cli.mjs
CHANGED
|
@@ -293,8 +293,27 @@ function progressSink(label, describe) {
|
|
|
293
293
|
|
|
294
294
|
//#endregion
|
|
295
295
|
//#region src/runner.ts
|
|
296
|
-
const
|
|
296
|
+
const GUEST_IMAGE_REPO = "ghcr.io/alizain/doublecheck-guest";
|
|
297
|
+
const LOCAL_GUEST_IMAGE = "doublecheck-guest:latest";
|
|
298
|
+
const DEV_VERSION = "0.0.0-development";
|
|
297
299
|
const GUEST_MEMORY_MIB = 2048;
|
|
300
|
+
function decideGuestImage(version, override) {
|
|
301
|
+
if (override) return {
|
|
302
|
+
ref: override,
|
|
303
|
+
pullPolicy: "never"
|
|
304
|
+
};
|
|
305
|
+
if (version === "0.0.0-development") return {
|
|
306
|
+
ref: LOCAL_GUEST_IMAGE,
|
|
307
|
+
pullPolicy: "never"
|
|
308
|
+
};
|
|
309
|
+
return {
|
|
310
|
+
ref: `${GUEST_IMAGE_REPO}:${version}`,
|
|
311
|
+
pullPolicy: "if-missing"
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function packageVersion() {
|
|
315
|
+
return JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8")).version;
|
|
316
|
+
}
|
|
298
317
|
function feedLines(carry, chunk) {
|
|
299
318
|
const parts = (carry + chunk).split("\n");
|
|
300
319
|
const rest = parts.pop() ?? "";
|
|
@@ -322,6 +341,7 @@ function decideOutcome(exitCode, report, workdir) {
|
|
|
322
341
|
async function runAgent(opts) {
|
|
323
342
|
const microsandbox = await import("microsandbox");
|
|
324
343
|
const name = `doublecheck-${basename(opts.workdir)}`;
|
|
344
|
+
const image = decideGuestImage(packageVersion(), process.env.DOUBLECHECK_GUEST_IMAGE);
|
|
325
345
|
const network = opts.network;
|
|
326
346
|
const policy = network === "all" ? microsandbox.NetworkPolicy.allowAll() : microsandbox.NetworkPolicy.builder().defaultDeny().egress((rb) => {
|
|
327
347
|
let rules = rb;
|
|
@@ -331,7 +351,7 @@ async function runAgent(opts) {
|
|
|
331
351
|
let sandbox = null;
|
|
332
352
|
try {
|
|
333
353
|
try {
|
|
334
|
-
sandbox = await microsandbox.Sandbox.builder(name).image(
|
|
354
|
+
sandbox = await microsandbox.Sandbox.builder(name).image(image.ref).memory(GUEST_MEMORY_MIB).pullPolicy(image.pullPolicy).replace().workdir(opts.workdir).envs(opts.spec.env).volume(opts.mount, (mb) => mb.bind(opts.mount).readonly()).volume(opts.workdir, (mb) => mb.bind(opts.workdir)).patch((pb) => {
|
|
335
355
|
let p = pb;
|
|
336
356
|
for (const f of opts.spec.files) p = p.text(f.path, f.content, {
|
|
337
357
|
mode: 384,
|
|
@@ -340,7 +360,8 @@ async function runAgent(opts) {
|
|
|
340
360
|
return p;
|
|
341
361
|
}).network((nb) => nb.policy(policy)).create();
|
|
342
362
|
} catch (e) {
|
|
343
|
-
if (String(e).includes("not cached")) throw new Error(`guest image ${
|
|
363
|
+
if (image.pullPolicy === "never" && String(e).includes("not cached")) throw new Error(`guest image ${image.ref} is not in the microsandbox cache — run scripts/build-guest-image.sh (${String(e)})`);
|
|
364
|
+
if (image.pullPolicy === "if-missing") throw new Error(`guest ${image.ref} failed to boot — if this is a pull failure, check network access to ghcr.io and that the package is public; a locally built image can be forced with DOUBLECHECK_GUEST_IMAGE=doublecheck-guest:latest (${String(e)})`);
|
|
344
365
|
throw e;
|
|
345
366
|
}
|
|
346
367
|
const handle = await sandbox.execStreamWith("bash", (e) => e.args(["-c", opts.spec.command]));
|
package/dist/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","names":["GUEST_HOME"],"sources":["../src/contract.ts","../src/claude.ts","../src/codex.ts","../src/agent-cli.ts","../src/runner.ts","../src/check.ts","../src/transcript.ts","../src/catalog.ts","../src/mine.ts","../src/cli.ts"],"sourcesContent":["// The agent contract: what the harness stages for the agent and what the\n// agent must leave behind. Any adapter (claude, codex) runs under this same\n// contract, which is what keeps the harness CLI-agnostic. The one per-agent\n// piece is `writeTool`: the phrase naming how THIS agent creates a file\n// (claude has a literal Write tool; codex is just told to create the file —\n// naming a tool it doesn't have would invite it to distrust its brief).\n\n// Staged into the scratch workdir before boot; the rw bind mount delivers it.\nexport const PROMPT_FILE = \"prompt.txt\"\n// The agent writes its findings here (relative to its cwd); the host reads it\n// back after exit. Missing report = failure.\nexport const REPORT_FILE = \"report.md\"\n\n// Weak models reliably skip a report contract stated once at the prompt's\n// tail unless it leads with the stakes and orders the file created first\n// (measured: haiku went from ~50% to 3/3 with this wording). Two hard-won\n// additions (2026-07-05, all three cutover inspectors lost their reports):\n// the path is ABSOLUTE — agents cd into the inspected tree to run git, and a\n// relative ./report.md then lands in the read-only mount — and the\n// create-first order is repeated near the top of the prompt (see\n// firstActionLine), because on long prompts the tail alone loses its grip.\nfunction reportContract(\n\tactivity: string,\n\tdeliverable: string,\n\tworkdir: string,\n\twriteTool: string | null,\n): string {\n\tconst tool = writeTool ? ` ${writeTool}` : \"\"\n\treturn `## Report — the only output that counts\n\nYour final chat reply is discarded. The only thing read back is the file \\`${workdir}/${REPORT_FILE}\\` — if it does not exist when you exit, this run FAILS. Always use that absolute path: if you \\`cd\\` elsewhere (into the inspected tree, say), a relative \\`./${REPORT_FILE}\\` lands in the wrong place, or in a read-only mount where the write fails.\n\nSo: create \\`${workdir}/${REPORT_FILE}\\`${tool} BEFORE you start ${activity} (a title line is enough), and update it as you work. The final state of the file when you finish is ${deliverable}.`\n}\n\nfunction firstActionLine(workdir: string, writeTool: string | null): string {\n\tconst tool = writeTool ? ` ${writeTool}` : \"\"\n\treturn `Your FIRST action, before anything else: create \\`${workdir}/${REPORT_FILE}\\`${tool} (a title line is enough). The full report contract is at the end of this prompt.`\n}\n\n// Environment preamble + optional run context + check body + report\n// contract. Checks are timeless standards; everything run-specific (intent,\n// sanctioned exceptions, scope) arrives in the operator's run context — the\n// harness knows nothing about git.\nexport function composePrompt(opts: {\n\tcheckBody: string\n\ttarget: string\n\tworkdir: string\n\trunContext: string | null\n\twriteTool: string | null\n}): string {\n\tconst contextSection = opts.runContext\n\t\t? `## Run context (from the operator)\n\nThe operator's brief for this run: the intent behind the work under review, known nuances, sanctioned exceptions, and possibly a Scope naming exactly what is under review. Judge requestedness against it — what the brief explicitly sanctions is not a finding. If it names a Scope, the Scope defines the change under review: findings must concern that change, and the rest of the tree is reference for judgment — with one exception. For concepts the scoped change retires or renames, surviving references anywhere in the tree are reportable findings: the Scope bounds what counts as the change, not where survivors may hide.\n\n${opts.runContext}\n\n---\n\n`\n\t\t: \"\"\n\treturn `## Environment\n\nYou are a code inspector running inside a sandboxed microVM with full permissions and unrestricted internet access.\n\n- The code under inspection is mounted read-only at \\`${opts.target}\\`. You cannot modify it — inspect, don't fix.\n- \\`git\\` and \\`rg\\` are installed.\n- Your current working directory is a writable scratch workspace: \\`${opts.workdir}\\`.\n\n${firstActionLine(opts.workdir, opts.writeTool)}\n\n## Inspection discipline\n\nMeasured on real runs: inspectors that skip these rules produce reports whose verdicts are right but whose evidence is partly fabricated — which is worse than no report.\n\n- Before inspecting, enumerate what is under review (the Run context's Scope list if one is given; otherwise your own enumeration of the target) and keep a ledger as you work: **examined** (content actually opened), **name-only**, **not examined**. End your report with that ledger, with a one-line reason for anything not examined.\n- Use verification verbs — \"verified\", \"confirmed\", \"checked\", \"read\", \"diffed\", \"grepped\", \"spot-checked\" — ONLY for actions you actually performed in this session on content you actually opened. Everything else must be labeled as inference: \"assumed identical by generation — not opened.\"\n- Never truncate output you will base a claim on — no \\`| head\\` / \\`| tail\\` on a diff or search you intend to cite. Examine files one at a time instead.\n\n---\n\n${contextSection}${opts.checkBody}\n\n---\n\n${reportContract(\"inspecting\", \"the check's report\", opts.workdir, opts.writeTool)}\n\nEvery single line of your report will be read in full by the operator's agent — nothing is skimmed, so every line costs attention. Verify each finding against the actual code before writing it down. A report that says \"no findings\" is a perfectly good report; an unverified finding is not.`\n}\n\n// The mining prompt: digest of one conversation + what counts as a durable\n// preference observation + the block format the catalog accumulates.\nexport function composeMinePrompt(\n\tdigest: string,\n\tworkdir: string,\n\twriteTool: string | null,\n): string {\n\treturn `## Environment\n\nYou are running inside a sandboxed microVM with no network access. The machine's Claude Code transcripts are mounted read-only at their real paths; your current working directory is a writable scratch workspace: \\`${workdir}\\`.\n\n${firstActionLine(workdir, writeTool)}\n\n## Task\n\nYou are mining ONE Claude Code conversation for the operator's durable preferences — how they want engineering done, in any conversation, not what they wanted built in this one.\n\nBelow is the conversation digest: every genuine human turn, numbered, in order. When a turn is a terse correction or interruption (\"no\", \"stop\", \"don't\", \"why did you…\", \"[Request interrupted]\"), recover its context: the \"# source:\" header names the full session transcript — Grep that turn's text in it to find its line, then Read the assistant turns IMMEDIATELY BEFORE it with offset/limit. The preference lives in the contrast between what the assistant did and what the operator demanded. NEVER read a transcript whole — some are tens of MB.\n\n---\n\n${digest}\n\n---\n\n## What counts as an observation (strict)\n\nA durable preference, backed by a verbatim quote from the digest or transcript:\n\n- **kind: code** — how code should be written/structured/shaped (\"no silent fallbacks\", \"reuse the existing helper instead of hand-rolling\").\n- **kind: workflow** — how work should proceed (\"verify before claiming done\", \"ask before making scope decisions\").\n- **kind: style** — how prose/output/docs should read.\n\nExclude task-of-the-moment directives with no durable signal (\"add a tab to home.tsx\", \"kill the dev server\"). Exclude anything you cannot quote. Be conservative: a weak or speculative observation is worse than none.\n\n## Observation format\n\nThe report is observation blocks and NOTHING else — no title, no preamble, no summary or conclusion sections. One block per observation:\n\n## <kebab-case-name>\n- **observation:** <one sentence: the durable preference>\n- **kind:** code | workflow | style\n- **evidence:** \"<verbatim quote>\" — turn <N>\n\nFor **code** observations that an LLM reviewer could check against a diff or file tree (a concrete change could flip PASS↔FAIL), and ONLY for those — never on workflow or style blocks — ALSO add:\n\n- **pass/fail:** PASS when <…>; FAIL when <…>\n- **why-LLM:** <why a deterministic linter cannot enforce this>\n- **scope:** diff-only | needs-tree\n\nIf the conversation carries no durable preference signal, the report is exactly these two lines and nothing more:\n\nNo durable preference signal.\n<one sentence: what the conversation was about instead>\n\n${reportContract(\"mining\", \"the mined observations\", workdir, writeTool)}`\n}\n","import { PROMPT_FILE } from \"./contract.ts\"\nimport type { AgentSpec } from \"./runner.ts\"\n\nconst GUEST_HOME = \"/root\"\n\n// The claude adapter: produce the AgentSpec that runs `claude -p` in the guest.\nexport function claudeAgent(opts: {\n\ttoken: string\n\tmodel: string\n\tworkdir: string\n}): AgentSpec {\n\treturn {\n\t\t// Headless claude -p cannot answer permission prompts, so in \"default\"\n\t\t// mode every tool is auto-denied and the agent produces nothing. The\n\t\t// microVM is the safety boundary here, so bypass the per-tool gate;\n\t\t// IS_SANDBOX=1 is what lets that run as root without claude's refusal.\n\t\tcommand:\n\t\t\t\"claude -p --no-session-persistence \" +\n\t\t\t\"--dangerously-skip-permissions \" +\n\t\t\t// --verbose is required by claude -p with stream-json output; it only\n\t\t\t// widens what lands on stdout, which describeStreamLine already labels.\n\t\t\t\"--output-format stream-json --verbose \" +\n\t\t\t// Not a permission gate — a contract guard. The default headless tool\n\t\t\t// set omits Glob/Grep and includes harness tools (ReportFindings,\n\t\t\t// TaskCreate, …) that hijack the report: haiku \"reports findings\"\n\t\t\t// through them and never writes report.md (verified live). This pins\n\t\t\t// the inspector's full toolkit and nothing else.\n\t\t\t`--tools Task Bash Read Write Edit Glob Grep WebSearch WebFetch < ${PROMPT_FILE}`,\n\t\tenv: {\n\t\t\tHOME: GUEST_HOME,\n\t\t\tIS_SANDBOX: \"1\",\n\t\t\tGIT_OPTIONAL_LOCKS: \"0\",\n\t\t\tANTHROPIC_MODEL: opts.model,\n\t\t\tCLAUDE_CODE_OAUTH_TOKEN: opts.token,\n\t\t},\n\t\t// Minimal trust-accepted entry keyed to the guest cwd so headless claude\n\t\t// skips the trust prompt. Deliberately NOT a copy of any host .claude.json.\n\t\tfiles: [\n\t\t\t{\n\t\t\t\tpath: `${GUEST_HOME}/.claude.json`,\n\t\t\t\tcontent: `${JSON.stringify(\n\t\t\t\t\t{ projects: { [opts.workdir]: { hasTrustDialogAccepted: true } } },\n\t\t\t\t\tnull,\n\t\t\t\t\t\"\\t\",\n\t\t\t\t)}\\n`,\n\t\t\t},\n\t\t],\n\t}\n}\n\ninterface StreamLine {\n\ttype?: string\n\tsubtype?: string\n\tmessage?: { content?: Array<{ type?: string; text?: string; name?: string }> }\n\tduration_ms?: number\n}\n\n// One human-readable label per stream-json stdout line; null for lines that\n// aren't claude's JSON (dropped from the progress stream).\nexport function describeClaudeStreamLine(line: string): string | null {\n\tlet obj: StreamLine\n\ttry {\n\t\tobj = JSON.parse(line) as StreamLine\n\t} catch {\n\t\treturn null\n\t}\n\tconst label = (obj.type ?? \"\") + (obj.subtype ? `:${obj.subtype}` : \"\")\n\t// A once-per-second heartbeat with no content — pure noise in the stream.\n\tif (label === \"system:thinking_tokens\") return null\n\tlet detail = \"\"\n\tif (obj.type === \"assistant\") {\n\t\tconst content = obj.message?.content ?? []\n\t\tconst tools = content\n\t\t\t.filter((b) => b.type === \"tool_use\" && b.name)\n\t\t\t.map((b) => b.name)\n\t\tconst chars = content.reduce((n, b) => n + (b.text?.length ?? 0), 0)\n\t\tdetail = tools.length ? ` ${tools.join(\",\")}` : ` ${chars} chars`\n\t} else if (obj.type === \"result\") {\n\t\tdetail = ` ${obj.subtype}, ${((obj.duration_ms ?? 0) / 1000).toFixed(1)}s`\n\t}\n\treturn `[${label}]${detail}`\n}\n","import { PROMPT_FILE } from \"./contract.ts\"\nimport type { AgentSpec } from \"./runner.ts\"\n\nconst GUEST_HOME = \"/root\"\n\n// Guest-only codex config — deliberately NOT a copy of any host config.toml\n// (which carries MCP API keys, personality, plugins, a trust table). Each key\n// is load-bearing:\n// - model rides here rather than as a `-m` flag so nothing operator-supplied\n// is ever interpolated into the guest's bash command string.\n// - approval_policy/sandbox_mode double the bypass flag on the command line;\n// either alone is a documented trust-prompt suppressor, some builds leak\n// with only one (openai/codex#14547).\n// - model_reasoning_effort: operator decision — plan billing is flat-rate,\n// so there is no haiku-style cost gradient to encode in a cheaper setting.\n// - web_search is a server-side tool (the guest never fetches pages itself);\n// \"live\" pins it rather than relying on the full-access auto-upgrade.\n// - project_doc_max_bytes = 0 disables all AGENTS.md loading: the piped\n// prompt is the agent's only input.\n// - features.plugins/apps = false stop codex's boot-time marketplace clone\n// and apps fetch (verified live): under restricted egress they hang, and\n// under any egress they inject tools (e.g. a git-push skill) the contract\n// never sanctioned.\nfunction guestConfig(model: string): string {\n\treturn `model = \"${model}\"\napproval_policy = \"never\"\nsandbox_mode = \"danger-full-access\"\nmodel_reasoning_effort = \"xhigh\"\nweb_search = \"live\"\nproject_doc_max_bytes = 0\ncli_auth_credentials_store = \"file\"\n\n[features]\nplugins = false\napps = false\n`\n}\n\n// The codex adapter: produce the AgentSpec that runs `codex exec` in the guest.\nexport function codexAgent(opts: {\n\t// Byte-for-byte content of the operator's ~/.codex/auth.json; staleness is\n\t// the caller's preflight (a guest-side token refresh would rotate the\n\t// single-use refresh token and poison the host session).\n\tauthJson: string\n\tmodel: string\n\tworkdir: string\n}): AgentSpec {\n\treturn {\n\t\t// Headless codex cannot answer approval prompts, and its own bwrap\n\t\t// sandbox needs user namespaces the guest may not grant — the microVM is\n\t\t// the safety boundary, so bypass both (OpenAI's documented container\n\t\t// guidance). --ephemeral writes no session rollout files;\n\t\t// --skip-git-repo-check because the scratch cwd is not a git repo.\n\t\tcommand:\n\t\t\t\"codex exec --json --skip-git-repo-check \" +\n\t\t\t\"--dangerously-bypass-approvals-and-sandbox --ephemeral \" +\n\t\t\t`- < ${PROMPT_FILE}`,\n\t\tenv: {\n\t\t\t// CODEX_HOME defaults to $HOME/.codex, where both staged files land.\n\t\t\tHOME: GUEST_HOME,\n\t\t\tGIT_OPTIONAL_LOCKS: \"0\",\n\t\t},\n\t\tfiles: [\n\t\t\t{ path: `${GUEST_HOME}/.codex/auth.json`, content: opts.authJson },\n\t\t\t{\n\t\t\t\tpath: `${GUEST_HOME}/.codex/config.toml`,\n\t\t\t\tcontent: guestConfig(opts.model),\n\t\t\t},\n\t\t],\n\t}\n}\n\n// The freshness window for a staged ChatGPT-auth auth.json. Codex refreshes\n// tokens when last_refresh is ~8 days old (or on a 401), refresh tokens are\n// single-use, and a refresh performed INSIDE a guest rotates the token family\n// — the host's copy then dies with \"refresh token was already used\" (forced\n// re-login). 7 days leaves a day of margin below codex's own threshold.\nexport const CODEX_AUTH_MAX_AGE_DAYS = 7\n\ninterface CodexAuth {\n\ttokens?: { refresh_token?: string }\n\tlast_refresh?: string\n\tOPENAI_API_KEY?: string\n}\n\n// Pure preflight: throw (with the operator's next action) unless this\n// auth.json is safe to stage into guests. An api-key-mode auth.json (no\n// tokens, an OPENAI_API_KEY field) carries no refresh semantics, so no\n// staleness guard applies.\nexport function validateCodexAuth(content: string, now: Date, where: string): void {\n\tlet auth: CodexAuth\n\ttry {\n\t\tauth = JSON.parse(content) as CodexAuth\n\t} catch {\n\t\tthrow new Error(`${where} is not valid JSON — run \\`codex login\\` on the host`)\n\t}\n\tif (auth.tokens?.refresh_token) {\n\t\tconst ageDays = (now.getTime() - Date.parse(auth.last_refresh ?? \"\")) / 86_400_000\n\t\tif (!(ageDays <= CODEX_AUTH_MAX_AGE_DAYS)) {\n\t\t\tthrow new Error(\n\t\t\t\t`${where} tokens were last refreshed over ${CODEX_AUTH_MAX_AGE_DAYS} days ago (codex refreshes at ~8 days, and a refresh inside a guest would rotate the single-use refresh token and poison this host's session) — run any codex command on the host to refresh, then retry`,\n\t\t\t)\n\t\t}\n\t\treturn\n\t}\n\tif (auth.OPENAI_API_KEY) return\n\tthrow new Error(\n\t\t`${where} has neither ChatGPT tokens nor an API key — run \\`codex login\\` on the host`,\n\t)\n}\n\ninterface CodexStreamLine {\n\ttype?: string\n\titem?: {\n\t\ttype?: string\n\t\ttext?: string\n\t\tcommand?: string\n\t\tchanges?: Array<{ path?: string }>\n\t}\n\tusage?: { input_tokens?: number; output_tokens?: number }\n\terror?: { message?: string }\n\tmessage?: string\n}\n\nconst clip = (s: string, max = 60): string => (s.length > max ? `${s.slice(0, max)}…` : s)\n\n// One human-readable label per --json stdout line; null for lines that aren't\n// codex's JSON (dropped from the progress stream). Event taxonomy:\n// thread.started / turn.started / turn.completed / turn.failed /\n// item.{started,updated,completed} (item.type = agent_message,\n// command_execution, file_change, reasoning, web_search, todo_list,\n// mcp_tool_call, error) / error.\nexport function describeCodexStreamLine(line: string): string | null {\n\tlet obj: CodexStreamLine\n\ttry {\n\t\tobj = JSON.parse(line) as CodexStreamLine\n\t} catch {\n\t\treturn null\n\t}\n\tconst item = obj.item\n\tconst label = (obj.type ?? \"\") + (item?.type ? `:${item.type}` : \"\")\n\tlet detail = \"\"\n\tif (item?.type === \"agent_message\") {\n\t\tdetail = ` ${item.text?.length ?? 0} chars`\n\t} else if (item?.type === \"command_execution\" && item.command) {\n\t\tdetail = ` ${clip(item.command)}`\n\t} else if (item?.type === \"file_change\") {\n\t\tdetail = ` ${(item.changes ?? []).length} file(s)`\n\t} else if (obj.type === \"turn.completed\") {\n\t\tdetail = ` ${obj.usage?.input_tokens ?? 0} in, ${obj.usage?.output_tokens ?? 0} out tokens`\n\t} else if (obj.type === \"turn.failed\") {\n\t\tdetail = ` ${clip(obj.error?.message ?? \"\")}`\n\t} else if (obj.type === \"error\") {\n\t\tdetail = ` ${clip(obj.message ?? \"\")}`\n\t}\n\treturn `[${label}]${detail}`\n}\n","import { readFileSync } from \"node:fs\"\nimport { homedir } from \"node:os\"\nimport { join } from \"node:path\"\nimport { claudeAgent, describeClaudeStreamLine } from \"./claude.ts\"\nimport { codexAgent, describeCodexStreamLine, validateCodexAuth } from \"./codex.ts\"\nimport type { AgentSpec } from \"./runner.ts\"\n\n// The agent CLI: the brand of agent (claude, codex) the operator picks with\n// --agent, and everything the workflows need from it. Not to be confused with\n// the harness (doublecheck's own mechanics) or an agent (one running\n// inspector instance, described by an AgentSpec).\nexport interface AgentCli {\n\tname: string\n\t// Applied only when --model is absent.\n\tdefaultModel: { check: string; mine: string }\n\t// The phrase the report contract uses to tell this agent how to create a\n\t// file; null when the prompt should just say \"create <path>\".\n\twriteToolPhrase: string | null\n\t// Domain suffixes for restricted-egress workflows (mine): the CLI's own\n\t// API endpoints, so the only reachable destination is the service the\n\t// agent already sends its context to.\n\tegressDomains: string[]\n\t// Host-side preflight: the secret material staged into every guest, or an\n\t// actionable error. Runs once per invocation, before any guest boots.\n\tcredentials(): string\n\tagent(opts: { credentials: string; model: string; workdir: string }): AgentSpec\n\tdescribeStreamLine(line: string): string | null\n}\n\nconst claude: AgentCli = {\n\tname: \"claude\",\n\tdefaultModel: { check: \"haiku\", mine: \"opus\" },\n\twriteToolPhrase: \"with the Write tool\",\n\tegressDomains: [\"anthropic.com\"],\n\tcredentials: () => {\n\t\tconst token = process.env.CLAUDE_CODE_OAUTH_TOKEN\n\t\tif (!token) {\n\t\t\tthrow new Error(\n\t\t\t\t\"CLAUDE_CODE_OAUTH_TOKEN is required in the environment (it is injected into each agent's sandbox)\",\n\t\t\t)\n\t\t}\n\t\treturn token\n\t},\n\tagent: ({ credentials, model, workdir }) =>\n\t\tclaudeAgent({ token: credentials, model, workdir }),\n\tdescribeStreamLine: describeClaudeStreamLine,\n}\n\nconst codex: AgentCli = {\n\tname: \"codex\",\n\t// No haiku-style cheap default: plan billing is flat-rate, and the staged\n\t// guest config already pins xhigh reasoning effort (operator decision).\n\tdefaultModel: { check: \"gpt-5.5\", mine: \"gpt-5.5\" },\n\twriteToolPhrase: null,\n\t// ChatGPT-plan inference lives at chatgpt.com/backend-api/codex; the\n\t// openai.com suffix covers auth.openai.com, where a 401-forced token\n\t// refresh would have to go.\n\tegressDomains: [\"chatgpt.com\", \"openai.com\"],\n\tcredentials: () => {\n\t\tconst authPath = join(homedir(), \".codex\", \"auth.json\")\n\t\tlet content: string\n\t\ttry {\n\t\t\tcontent = readFileSync(authPath, \"utf-8\")\n\t\t} catch {\n\t\t\tthrow new Error(`no readable ${authPath} — run \\`codex login\\` on the host`)\n\t\t}\n\t\tvalidateCodexAuth(content, new Date(), authPath)\n\t\treturn content\n\t},\n\tagent: ({ credentials, model, workdir }) =>\n\t\tcodexAgent({ authJson: credentials, model, workdir }),\n\tdescribeStreamLine: describeCodexStreamLine,\n}\n\nconst AGENT_CLIS: Record<string, AgentCli> = { claude, codex }\n\nexport function resolveAgentCli(name: string): AgentCli {\n\tconst cli = AGENT_CLIS[name]\n\tif (!cli) {\n\t\tthrow new Error(\n\t\t\t`unknown agent \"${name}\" (have: ${Object.keys(AGENT_CLIS).join(\", \")})`,\n\t\t)\n\t}\n\treturn cli\n}\n\n// One resolved, preflighted agent selection, shared by every unit of a run.\nexport interface AgentRun {\n\tcli: AgentCli\n\tcredentials: string\n\tmodel: string\n}\n\n// Resolve --agent/--model into what a workflow's units consume: the CLI, its\n// preflighted credentials, and the model (explicit flag, else the CLI's\n// default for this workflow).\nexport function resolveAgentRun(\n\tname: string,\n\tmodel: string | undefined,\n\tworkflow: \"check\" | \"mine\",\n): AgentRun {\n\tconst cli = resolveAgentCli(name)\n\treturn {\n\t\tcli,\n\t\tcredentials: cli.credentials(),\n\t\tmodel: model ?? cli.defaultModel[workflow],\n\t}\n}\n\n// The per-unit progress sink both workflow shells hang on runAgent: guest\n// stderr passes through as `[label] ! line`, stdout is the agent CLI's JSON\n// stream, labelled by its describeStreamLine (non-JSON lines dropped).\nexport function progressSink(\n\tlabel: string,\n\tdescribe: (line: string) => string | null,\n): (kind: \"stdout\" | \"stderr\", line: string) => void {\n\treturn (kind, line) => {\n\t\tif (kind === \"stderr\") {\n\t\t\tprocess.stderr.write(`[${label}] ! ${line}\\n`)\n\t\t\treturn\n\t\t}\n\t\tconst described = describe(line)\n\t\tif (described) process.stderr.write(`[${label}] ${described}\\n`)\n\t}\n}\n","import { existsSync, readFileSync } from \"node:fs\"\nimport { basename, join } from \"node:path\"\nimport type { ExecEvent } from \"microsandbox\"\nimport { REPORT_FILE } from \"./contract.ts\"\n\n// microsandbox exports its fluent builders as value-only consts; recover their\n// instance types via a type-only import (erased at build) so the native module\n// only loads behind the `await import` in runAgent.\ntype MountBuilder = InstanceType<typeof import(\"microsandbox\").MountBuilder>\ntype PatchBuilder = InstanceType<typeof import(\"microsandbox\").PatchBuilder>\ntype ExecOptionsBuilder = InstanceType<typeof import(\"microsandbox\").ExecOptionsBuilder>\n// The SDK types `.network(cb)` as `(b: any) => any`, and we call the JS-shim\n// `.policy(...)`, absent from the native builder's types.\n// biome-ignore lint/suspicious/noExplicitAny: SDK types this builder callback as any\ntype NetworkBuilder = any\n\n// Locally built (Dockerfile.guest): node 24 slim + git/ripgrep/curl/wget + the\n// claude CLI baked in. Side-loaded into the microsandbox cache by\n// ./scripts/build-guest-image.sh — it exists nowhere else, hence pullPolicy\n// \"never\": a cache miss means \"run the build script\", not \"try Docker Hub\".\nconst GUEST_IMAGE = \"doublecheck-guest:latest\"\nconst GUEST_MEMORY_MIB = 2048\n\n// Staged into the guest before boot (e.g. claude's trust-accepted config).\nexport interface GuestFile {\n\tpath: string\n\tcontent: string\n}\n\n// What it takes to run one agent in a booted guest: a bash command executed in\n// the scratch cwd that must leave REPORT_FILE there, the env it needs, and\n// files staged into the guest. Plain data — adapters produce it, this runner\n// consumes it, tests fake it.\nexport interface AgentSpec {\n\tcommand: string\n\tenv: Record<string, string>\n\tfiles: GuestFile[]\n}\n\nexport type AgentOutcome =\n\t| { ok: true; report: string }\n\t| { ok: false; reason: string; partialReport: string | null }\n\n// Pure line buffering: fold a chunk into the carry, emit complete non-blank\n// lines, keep the unterminated tail.\nexport function feedLines(\n\tcarry: string,\n\tchunk: string,\n): { lines: string[]; carry: string } {\n\tconst parts = (carry + chunk).split(\"\\n\")\n\tconst rest = parts.pop() ?? \"\"\n\treturn { lines: parts.filter((l) => l.trim()), carry: rest }\n}\n\n// Pure outcome decision: what the exec left behind → what it means.\nexport function decideOutcome(\n\texitCode: number | null,\n\treport: string | null,\n\tworkdir: string,\n): AgentOutcome {\n\tif (exitCode !== 0) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\treason: `agent process exited ${exitCode}`,\n\t\t\tpartialReport: report,\n\t\t}\n\t}\n\tif (report === null) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\treason: `agent exited 0 but wrote no ${REPORT_FILE} (work dir: ${workdir})`,\n\t\t\tpartialReport: null,\n\t\t}\n\t}\n\treturn { ok: true, report }\n}\n\nexport interface RunAgentOpts {\n\t// Host dir the agent inspects, bind-mounted READ-ONLY at its real host\n\t// path: the target for `check`, the transcripts corpus for `mine`.\n\tmount: string\n\t// Scratch dir with PROMPT_FILE already inside; bind-mounted rw as the guest\n\t// cwd at its identical host path, so the agent's report lands back on the host.\n\tworkdir: string\n\tspec: AgentSpec\n\t// \"all\" for checks (inspectors may research); a domain-suffix allowlist for\n\t// miners: the personal corpus is mounted, so egress is pinned to the agent\n\t// CLI's own API domains — the only reachable destination is the service\n\t// the agent already sends its context to. NetworkPolicy.none() is not an\n\t// option here — it kills DNS entirely and the adapter can't reach its own\n\t// model API (measured: claude retries ~180s then exits 1).\n\tnetwork: \"all\" | { onlyDomains: string[] }\n\tonLine: (kind: \"stdout\" | \"stderr\", line: string) => void\n}\n\n// Boot a guest (ro mount + scratch rw as cwd), exec the agent command, stream\n// its output line-by-line, read the report back off the scratch dir, tear\n// down. Agent-level failures (exit ≠ 0, no report) return ok:false;\n// harness-level failures (image missing, boot error) throw.\nexport async function runAgent(opts: RunAgentOpts): Promise<AgentOutcome> {\n\tconst microsandbox = await import(\"microsandbox\")\n\tconst name = `doublecheck-${basename(opts.workdir)}`\n\tconst network = opts.network\n\tconst policy =\n\t\tnetwork === \"all\"\n\t\t\t? microsandbox.NetworkPolicy.allowAll()\n\t\t\t: microsandbox.NetworkPolicy.builder()\n\t\t\t\t\t.defaultDeny()\n\t\t\t\t\t.egress((rb) => {\n\t\t\t\t\t\tlet rules = rb\n\t\t\t\t\t\tfor (const domain of network.onlyDomains) {\n\t\t\t\t\t\t\trules = rules.allow((d) => d.domainSuffix(domain))\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn rules\n\t\t\t\t\t})\n\t\t\t\t\t.build()\n\tlet sandbox: InstanceType<typeof microsandbox.Sandbox> | null = null\n\ttry {\n\t\ttry {\n\t\t\tsandbox = await microsandbox.Sandbox.builder(name)\n\t\t\t\t.image(GUEST_IMAGE)\n\t\t\t\t.memory(GUEST_MEMORY_MIB)\n\t\t\t\t.pullPolicy(\"never\")\n\t\t\t\t.replace()\n\t\t\t\t.workdir(opts.workdir)\n\t\t\t\t.envs(opts.spec.env)\n\t\t\t\t.volume(opts.mount, (mb: MountBuilder) => mb.bind(opts.mount).readonly())\n\t\t\t\t.volume(opts.workdir, (mb: MountBuilder) => mb.bind(opts.workdir))\n\t\t\t\t.patch((pb: PatchBuilder) => {\n\t\t\t\t\tlet p = pb\n\t\t\t\t\tfor (const f of opts.spec.files) {\n\t\t\t\t\t\tp = p.text(f.path, f.content, { mode: 0o600, replace: true })\n\t\t\t\t\t}\n\t\t\t\t\treturn p\n\t\t\t\t})\n\t\t\t\t.network((nb: NetworkBuilder) => nb.policy(policy))\n\t\t\t\t.create()\n\t\t} catch (e) {\n\t\t\tif (String(e).includes(\"not cached\")) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`guest image ${GUEST_IMAGE} is not in the microsandbox cache — run scripts/build-guest-image.sh (${String(e)})`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\n\t\tconst handle = await sandbox.execStreamWith(\"bash\", (e: ExecOptionsBuilder) =>\n\t\t\te.args([\"-c\", opts.spec.command]),\n\t\t)\n\n\t\tconst carry: Record<\"stdout\" | \"stderr\", string> = { stdout: \"\", stderr: \"\" }\n\t\tlet exitCode: number | null = null\n\t\tfor (;;) {\n\t\t\tconst ev: ExecEvent | null = await handle.recv()\n\t\t\tif (ev === null) break\n\t\t\tif (ev.kind === \"stdout\" || ev.kind === \"stderr\") {\n\t\t\t\tconst fed = feedLines(carry[ev.kind], Buffer.from(ev.data).toString())\n\t\t\t\tcarry[ev.kind] = fed.carry\n\t\t\t\tfor (const line of fed.lines) opts.onLine(ev.kind, line)\n\t\t\t} else if (ev.kind === \"exited\") exitCode = ev.code\n\t\t}\n\t\tfor (const kind of [\"stdout\", \"stderr\"] as const) {\n\t\t\tif (carry[kind].trim()) opts.onLine(kind, carry[kind])\n\t\t}\n\n\t\tconst reportPath = join(opts.workdir, REPORT_FILE)\n\t\tconst report = existsSync(reportPath) ? readFileSync(reportPath, \"utf-8\") : null\n\t\treturn decideOutcome(exitCode, report, opts.workdir)\n\t} finally {\n\t\tif (sandbox) {\n\t\t\ttry {\n\t\t\t\tawait sandbox.stop()\n\t\t\t} catch (e) {\n\t\t\t\topts.onLine(\"stderr\", `sandbox stop failed: ${String(e)}`)\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tawait microsandbox.Sandbox.remove(name)\n\t\t\t} catch (e) {\n\t\t\t\topts.onLine(\"stderr\", `sandbox remove failed: ${String(e)}`)\n\t\t\t}\n\t\t}\n\t}\n}\n","import {\n\tappendFileSync,\n\tmkdirSync,\n\tmkdtempSync,\n\treaddirSync,\n\treadFileSync,\n\twriteFileSync,\n} from \"node:fs\"\nimport { tmpdir } from \"node:os\"\nimport { join } from \"node:path\"\nimport PQueue from \"p-queue\"\nimport { type AgentRun, progressSink, resolveAgentRun } from \"./agent-cli.ts\"\nimport { composePrompt, PROMPT_FILE, REPORT_FILE } from \"./contract.ts\"\nimport { runAgent } from \"./runner.ts\"\n\n// A check is a plain markdown file — no frontmatter, no schema. The body is\n// the inspector's instructions; the name is the filename minus .md. Checks\n// come from one or more --checks-dir directories (default:\n// $TARGET/.agents/checks).\nexport interface Check {\n\tname: string\n\tbody: string\n}\n\n// Pure selection: `only` (from repeated --check flags) filters, in the order\n// named; naming a check that doesn't exist is an error, not an empty run.\nexport function selectChecks(all: Check[], only: string[], where: string): Check[] {\n\tif (all.length === 0) throw new Error(`no checks (*.md) in ${where}`)\n\tif (only.length === 0) return all\n\tconst byName = new Map(all.map((c) => [c.name, c]))\n\treturn only.map((name) => {\n\t\tconst check = byName.get(name)\n\t\tif (!check) {\n\t\t\tconst have = all.map((c) => c.name).join(\", \")\n\t\t\tthrow new Error(`no check named \"${name}\" in ${where} (have: ${have})`)\n\t\t}\n\t\treturn check\n\t})\n}\n\n// Shell: read every check file from every checks dir, then select purely.\n// A missing dir is an error; the same check name in two dirs is an error —\n// no precedence rules, rename one.\nexport function discoverChecks(dirs: string[], only: string[]): Check[] {\n\tconst all: Array<Check & { dir: string }> = []\n\tfor (const dir of dirs) {\n\t\tlet entries: string[]\n\t\ttry {\n\t\t\tentries = readdirSync(dir)\n\t\t} catch {\n\t\t\tthrow new Error(`no checks directory at ${dir}`)\n\t\t}\n\t\tfor (const f of entries.filter((e) => e.endsWith(\".md\")).sort()) {\n\t\t\tconst name = f.slice(0, -\".md\".length)\n\t\t\tconst clash = all.find((c) => c.name === name)\n\t\t\tif (clash) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`check \"${name}\" exists in both ${clash.dir} and ${dir} — rename one`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tall.push({ name, body: readFileSync(join(dir, f), \"utf-8\"), dir })\n\t\t}\n\t}\n\tconst checks = all\n\t\t.map(({ name, body }) => ({ name, body }))\n\t\t.sort((a, b) => a.name.localeCompare(b.name))\n\treturn selectChecks(checks, only, dirs.join(\", \"))\n}\n\nexport interface CheckWorkflowOpts {\n\ttarget: string\n\tchecksDirs: string[]\n\tcontextFile: string | null\n\tagent: string\n\t// Absent = the agent CLI's default for checks.\n\tmodel?: string\n\tparallel: number\n\toutput: string\n\tonly: string[]\n\tsaveJsonl: boolean\n}\n\n// fs-safe local timestamp, one dir per run shared by all its checks:\n// 2026-07-05-143000\nexport function runTimestamp(d: Date): string {\n\tconst p = (n: number) => String(n).padStart(2, \"0\")\n\treturn `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}-${p(d.getHours())}${p(d.getMinutes())}${p(d.getSeconds())}`\n}\n\n// The report written when the agent failed: the failure is the report, plus\n// whatever partial report the agent managed to leave.\nexport function failureReport(reason: string, partialReport: string | null): string {\n\tconst partial = partialReport\n\t\t? `\\n---\\n\\nPartial ${REPORT_FILE} left by the agent:\\n\\n${partialReport}`\n\t\t: \"\"\n\treturn `# CHECK FAILED\\n\\n${reason}\\n${partial}`\n}\n\nasync function runOneCheck(\n\tcheck: Check,\n\topts: CheckWorkflowOpts,\n\trun: AgentRun,\n\trunContext: string | null,\n\toutDir: string,\n): Promise<boolean> {\n\tconst workdir = mkdtempSync(join(tmpdir(), `doublecheck-${check.name}-`))\n\twriteFileSync(\n\t\tjoin(workdir, PROMPT_FILE),\n\t\tcomposePrompt({\n\t\t\tcheckBody: check.body,\n\t\t\ttarget: opts.target,\n\t\t\tworkdir,\n\t\t\trunContext,\n\t\t\twriteTool: run.cli.writeToolPhrase,\n\t\t}),\n\t)\n\tconst spec = run.cli.agent({\n\t\tcredentials: run.credentials,\n\t\tmodel: run.model,\n\t\tworkdir,\n\t})\n\t// The report is the verdict; with --save-jsonl the raw stream is kept\n\t// beside it so a run can be audited after the ephemeral guest is gone\n\t// (which files the inspector read, what it skipped, whether report claims\n\t// trace to actual observations).\n\tconst sink = progressSink(check.name, run.cli.describeStreamLine)\n\tlet onLine = sink\n\tif (opts.saveJsonl) {\n\t\tconst streamPath = join(outDir, `${check.name}.stream.jsonl`)\n\t\tonLine = (kind, line) => {\n\t\t\tif (kind === \"stdout\") appendFileSync(streamPath, `${line}\\n`)\n\t\t\tsink(kind, line)\n\t\t}\n\t}\n\tconst outcome = await runAgent({\n\t\tmount: opts.target,\n\t\tworkdir,\n\t\tspec,\n\t\tnetwork: \"all\",\n\t\tonLine,\n\t})\n\tconst reportPath = join(outDir, `${check.name}.md`)\n\tif (outcome.ok) {\n\t\twriteFileSync(reportPath, outcome.report)\n\t\tprocess.stderr.write(`[${check.name}] report: ${reportPath}\\n`)\n\t\treturn true\n\t}\n\twriteFileSync(reportPath, failureReport(outcome.reason, outcome.partialReport))\n\tprocess.stderr.write(`[${check.name}] FAILED (${outcome.reason}): ${reportPath}\\n`)\n\treturn false\n}\n\n// The check workflow: one sandboxed agent per check, at most `parallel`\n// guests at once. Returns true only when every check produced a report; agent\n// failures still write a failure-record report and flip the run to false.\nexport async function runChecks(opts: CheckWorkflowOpts): Promise<boolean> {\n\tconst run = resolveAgentRun(opts.agent, opts.model, \"check\")\n\tconst checks = discoverChecks(opts.checksDirs, opts.only)\n\tlet runContext: string | null = null\n\tif (opts.contextFile) {\n\t\ttry {\n\t\t\trunContext = readFileSync(opts.contextFile, \"utf-8\")\n\t\t} catch (e) {\n\t\t\tthrow new Error(\n\t\t\t\t`--context file not readable: ${opts.contextFile} (${String(e)})`,\n\t\t\t)\n\t\t}\n\t}\n\tconst outDir = join(opts.output, runTimestamp(new Date()))\n\tmkdirSync(outDir, { recursive: true })\n\tprocess.stderr.write(\n\t\t`${checks.length} check(s) against ${opts.target} (agent ${run.cli.name}, model ${run.model}, parallel ${opts.parallel})\\n`,\n\t)\n\tconst queue = new PQueue({ concurrency: opts.parallel })\n\tconst results = await Promise.all(\n\t\tchecks.map((check) =>\n\t\t\tqueue.add(() => runOneCheck(check, opts, run, runContext, outDir)),\n\t\t),\n\t)\n\treturn results.every((ok) => ok === true)\n}\n","// Claude Code transcript (.jsonl) → the genuine human turns → a flat digest.\n// Port of the June-2026 jq extraction, verified against the same corpus: a\n// \"genuine human turn\" is type:user, not meta, not sidechain, text content\n// only — which excludes the three things that are also type:user in the JSONL\n// (tool_results, slash-command stdout wrappers, injected system-reminders).\n\n// Per-turn char cap in the digest; the mining agent greps the source jsonl\n// for full text when it needs context around a turn.\nconst TURN_CHAR_CAP = 2000\n\ninterface RawLine {\n\ttype?: string\n\tisMeta?: boolean\n\tisSidechain?: boolean\n\tmessage?: { content?: unknown }\n}\n\nconst NON_HUMAN_TEXT =\n\t/^\\s*<command-name>|<local-command-stdout>|^\\s*<local-command|^\\s*<system-reminder>|Caveat: The messages below/\n\n// Throws on an unparseable line — the caller decides what an unreadable\n// transcript means for its run (mine counts and reports them, visibly).\nexport function humanTurns(jsonl: string): string[] {\n\tconst turns: string[] = []\n\tfor (const line of jsonl.split(\"\\n\")) {\n\t\tif (!line.trim()) continue\n\t\tconst raw = JSON.parse(line) as RawLine\n\t\tif (raw.type !== \"user\" || raw.isMeta || raw.isSidechain) continue\n\t\tconst content = raw.message?.content\n\t\tconst text =\n\t\t\ttypeof content === \"string\"\n\t\t\t\t? content\n\t\t\t\t: Array.isArray(content)\n\t\t\t\t\t? content\n\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t(item): item is { type: \"text\"; text: string } =>\n\t\t\t\t\t\t\t\t\ttypeof item === \"object\" &&\n\t\t\t\t\t\t\t\t\titem !== null &&\n\t\t\t\t\t\t\t\t\t(item as { type?: string }).type === \"text\" &&\n\t\t\t\t\t\t\t\t\ttypeof (item as { text?: unknown }).text === \"string\",\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.map((item) => item.text)\n\t\t\t\t\t\t\t.join(\"\\n\")\n\t\t\t\t\t: \"\"\n\t\tif (!text) continue\n\t\tif (NON_HUMAN_TEXT.test(text)) continue\n\t\tturns.push(text.replace(/[\\n\\r]+/g, \" ⏎ \").slice(0, TURN_CHAR_CAP))\n\t}\n\treturn turns\n}\n\nexport interface DigestMeta {\n\tsource: string\n\tproject: string\n\tsession: string\n}\n\nexport function renderDigest(meta: DigestMeta, turns: string[]): string {\n\tconst numbered = turns\n\t\t.map((t, i) => `${String(i + 1).padStart(3, \" \")} | ${t}`)\n\t\t.join(\"\\n\")\n\treturn `# source: ${meta.source}\n# project: ${meta.project}\n# session: ${meta.session}\n# human_turns: ${turns.length}\n# To understand WHY a terse turn or interruption happened, grep its text in the\n# source file above and read the assistant turn(s) immediately before it.\n\n${numbered}\n`\n}\n","import { createHash } from \"node:crypto\"\nimport { existsSync, readdirSync, readFileSync, statSync } from \"node:fs\"\nimport { basename, join } from \"node:path\"\nimport { humanTurns, renderDigest } from \"./transcript.ts\"\n\n// One minable unit = one top-level transcript $PROJECTS/<project>/<session>.jsonl.\n// Its catalog home mirrors that path: $CATALOG/<project>/<session>/observations.md.\nexport interface Unit {\n\tproject: string\n\tsession: string\n\tjsonlPath: string\n}\n\nexport function enumerateUnits(projectsDir: string): Unit[] {\n\tlet projects: string[]\n\ttry {\n\t\tprojects = readdirSync(projectsDir).sort()\n\t} catch {\n\t\tthrow new Error(`no transcripts directory at ${projectsDir}`)\n\t}\n\tconst units: Unit[] = []\n\tfor (const project of projects) {\n\t\tconst dir = join(projectsDir, project)\n\t\tif (!statSync(dir).isDirectory()) continue\n\t\tfor (const f of readdirSync(dir).sort()) {\n\t\t\tif (!f.endsWith(\".jsonl\")) continue\n\t\t\tunits.push({\n\t\t\t\tproject,\n\t\t\t\tsession: basename(f, \".jsonl\"),\n\t\t\t\tjsonlPath: join(dir, f),\n\t\t\t})\n\t\t}\n\t}\n\treturn units\n}\n\nexport function observationsPath(catalogDir: string, unit: Unit): string {\n\treturn join(catalogDir, unit.project, unit.session, \"observations.md\")\n}\n\nexport type UnitStatus =\n\t// hash matches the recorded source_sha256 — skipped without parsing\n\t| { kind: \"mined\" }\n\t| { kind: \"below-threshold\"; turns: number }\n\t| {\n\t\t\tkind: \"pending\"\n\t\t\treason: \"new\" | \"changed\"\n\t\t\tturns: number\n\t\t\tdigest: string\n\t\t\tsourceSha256: string\n\t }\n\t// transcript has an unparseable line; reported visibly, never mined\n\t| { kind: \"unreadable\"; error: string }\n\n// Pure decision core: everything already read, nothing left but judgment.\nexport function decideUnitStatus(input: {\n\tunit: Unit\n\tjsonl: Buffer\n\trecordedSha256: string | null\n\tminTurns: number\n}): UnitStatus {\n\tconst sourceSha256 = createHash(\"sha256\").update(input.jsonl).digest(\"hex\")\n\tif (input.recordedSha256 === sourceSha256) return { kind: \"mined\" }\n\tlet turns: string[]\n\ttry {\n\t\tturns = humanTurns(input.jsonl.toString(\"utf-8\"))\n\t} catch (e) {\n\t\treturn { kind: \"unreadable\", error: String(e) }\n\t}\n\tif (turns.length < input.minTurns)\n\t\treturn { kind: \"below-threshold\", turns: turns.length }\n\treturn {\n\t\tkind: \"pending\",\n\t\treason: input.recordedSha256 === null ? \"new\" : \"changed\",\n\t\tturns: turns.length,\n\t\tdigest: renderDigest(\n\t\t\t{\n\t\t\t\tsource: input.unit.jsonlPath,\n\t\t\t\tproject: input.unit.project,\n\t\t\t\tsession: input.unit.session,\n\t\t\t},\n\t\t\tturns,\n\t\t),\n\t\tsourceSha256,\n\t}\n}\n\n// Shell: read the unit's inputs, then decide purely.\nexport function unitStatus(unit: Unit, catalogDir: string, minTurns: number): UnitStatus {\n\tconst obsPath = observationsPath(catalogDir, unit)\n\treturn decideUnitStatus({\n\t\tunit,\n\t\tjsonl: readFileSync(unit.jsonlPath),\n\t\trecordedSha256: existsSync(obsPath)\n\t\t\t? readSourceSha256(readFileSync(obsPath, \"utf-8\"))\n\t\t\t: null,\n\t\tminTurns,\n\t})\n}\n\nexport interface ObservationsMeta {\n\tsource: string\n\tsourceSha256: string\n\tminedAt: string\n\tmodel: string\n\thumanTurns: number\n}\n\n// The host composes the final file: frontmatter it alone can vouch for, then\n// the agent's report verbatim.\nexport function composeObservationsFile(meta: ObservationsMeta, body: string): string {\n\treturn `---\nsource: ${meta.source}\nsource_sha256: ${meta.sourceSha256}\nmined_at: ${meta.minedAt}\nmodel: ${meta.model}\nhuman_turns: ${meta.humanTurns}\n---\n\n${body.trimEnd()}\n`\n}\n\nexport function readSourceSha256(observationsMd: string): string | null {\n\treturn observationsMd.match(/^source_sha256: ([0-9a-f]{64})$/m)?.[1] ?? null\n}\n","import { mkdirSync, mkdtempSync, writeFileSync } from \"node:fs\"\nimport { tmpdir } from \"node:os\"\nimport { dirname, join } from \"node:path\"\nimport PQueue from \"p-queue\"\nimport {\n\ttype AgentRun,\n\tprogressSink,\n\tresolveAgentCli,\n\tresolveAgentRun,\n} from \"./agent-cli.ts\"\nimport {\n\tcomposeObservationsFile,\n\tenumerateUnits,\n\tobservationsPath,\n\ttype Unit,\n\ttype UnitStatus,\n\tunitStatus,\n} from \"./catalog.ts\"\nimport { composeMinePrompt, PROMPT_FILE } from \"./contract.ts\"\nimport { runAgent } from \"./runner.ts\"\n\nexport interface MineOpts {\n\tprojects: string\n\tcatalog: string\n\tagent: string\n\t// Absent = the agent CLI's default for mining.\n\tmodel?: string\n\tparallel: number\n\tminTurns: number\n\tlimit?: number\n\tdryRun: boolean\n}\n\nexport interface Pending {\n\tunit: Unit\n\tstatus: Extract<UnitStatus, { kind: \"pending\" }>\n}\n\n// What one mine invocation will and won't do, decided purely from the\n// per-unit statuses.\nexport interface MinePlan {\n\ttodo: Pending[]\n\tpendingTotal: number\n\tmined: number\n\tbelowThreshold: number\n\tunreadable: { unit: Unit; error: string }[]\n}\n\nexport function planMine(\n\tentries: { unit: Unit; status: UnitStatus }[],\n\tlimit?: number,\n): MinePlan {\n\tconst pending = entries.filter((e): e is Pending => e.status.kind === \"pending\")\n\treturn {\n\t\ttodo: limit ? pending.slice(0, limit) : pending,\n\t\tpendingTotal: pending.length,\n\t\tmined: entries.filter((e) => e.status.kind === \"mined\").length,\n\t\tbelowThreshold: entries.filter((e) => e.status.kind === \"below-threshold\").length,\n\t\tunreadable: entries.flatMap((e) =>\n\t\t\te.status.kind === \"unreadable\"\n\t\t\t\t? [{ unit: e.unit, error: e.status.error }]\n\t\t\t\t: [],\n\t\t),\n\t}\n}\n\nexport function summarizeMinePlan(plan: MinePlan, minTurns: number): string {\n\tconst total =\n\t\tplan.pendingTotal + plan.mined + plan.belowThreshold + plan.unreadable.length\n\tconst limited =\n\t\tplan.todo.length !== plan.pendingTotal ? ` (mining ${plan.todo.length})` : \"\"\n\treturn `${total} transcripts: ${plan.pendingTotal} pending${limited}, ${plan.mined} mined, ${plan.belowThreshold} below ${minTurns} turns, ${plan.unreadable.length} unreadable`\n}\n\nexport function dryRunRow({ unit, status }: Pending): string {\n\treturn `${status.reason.padEnd(7)} ${status.turns.toString().padStart(4)} turns ${unit.project}/${unit.session}`\n}\n\nasync function mineOneUnit(\n\t{ unit, status }: Pending,\n\topts: MineOpts,\n\trun: AgentRun,\n): Promise<boolean> {\n\tconst tag = unit.session.slice(0, 8)\n\tconst workdir = mkdtempSync(join(tmpdir(), `doublecheck-mine-${tag}-`))\n\twriteFileSync(\n\t\tjoin(workdir, PROMPT_FILE),\n\t\tcomposeMinePrompt(status.digest, workdir, run.cli.writeToolPhrase),\n\t)\n\tconst spec = run.cli.agent({\n\t\tcredentials: run.credentials,\n\t\tmodel: run.model,\n\t\tworkdir,\n\t})\n\tprocess.stderr.write(\n\t\t`[${tag}] mining ${unit.project}/${unit.session} (${status.turns} turns, ${status.reason})\\n`,\n\t)\n\tconst outcome = await runAgent({\n\t\tmount: opts.projects,\n\t\tworkdir,\n\t\tspec,\n\t\tnetwork: { onlyDomains: run.cli.egressDomains },\n\t\tonLine: progressSink(tag, run.cli.describeStreamLine),\n\t})\n\t// A failed mine writes NOTHING — the catalog is a durable asset; the next\n\t// run retries this unit because no hash gets recorded.\n\tif (!outcome.ok) {\n\t\tprocess.stderr.write(`[${tag}] FAILED (${outcome.reason})\\n`)\n\t\treturn false\n\t}\n\tconst obsPath = observationsPath(opts.catalog, unit)\n\tmkdirSync(dirname(obsPath), { recursive: true })\n\twriteFileSync(\n\t\tobsPath,\n\t\tcomposeObservationsFile(\n\t\t\t{\n\t\t\t\tsource: unit.jsonlPath,\n\t\t\t\tsourceSha256: status.sourceSha256,\n\t\t\t\tminedAt: new Date().toISOString(),\n\t\t\t\tmodel: run.model,\n\t\t\t\thumanTurns: status.turns,\n\t\t\t},\n\t\t\toutcome.report,\n\t\t),\n\t)\n\tprocess.stderr.write(`[${tag}] observations: ${obsPath}\\n`)\n\treturn true\n}\n\n// The mine workflow shell: gather statuses (I/O), plan purely, then either\n// print the plan (dry-run) or run one sandboxed agent per pending unit.\n// Returns true when nothing it attempted failed.\nexport async function runMine(opts: MineOpts): Promise<boolean> {\n\t// Validate the agent name before the dry-run/nothing-pending short-circuits\n\t// so a bad --agent errors on every invocation; the credentials preflight\n\t// stays below them (a dry run must not require credentials).\n\tresolveAgentCli(opts.agent)\n\tconst entries = enumerateUnits(opts.projects).map((unit) => ({\n\t\tunit,\n\t\tstatus: unitStatus(unit, opts.catalog, opts.minTurns),\n\t}))\n\tconst plan = planMine(entries, opts.limit)\n\tfor (const { unit, error } of plan.unreadable) {\n\t\tprocess.stderr.write(`UNREADABLE ${unit.project}/${unit.session}: ${error}\\n`)\n\t}\n\tprocess.stderr.write(`${summarizeMinePlan(plan, opts.minTurns)}\\n`)\n\n\tif (opts.dryRun) {\n\t\tfor (const pending of plan.todo) console.log(dryRunRow(pending))\n\t\treturn true\n\t}\n\tif (plan.todo.length === 0) return true\n\n\tconst run = resolveAgentRun(opts.agent, opts.model, \"mine\")\n\tconst queue = new PQueue({ concurrency: opts.parallel })\n\tconst results = await Promise.all(\n\t\tplan.todo.map((p) => queue.add(() => mineOneUnit(p, opts, run))),\n\t)\n\tconst failed = results.filter((ok) => ok !== true).length\n\tprocess.stderr.write(\n\t\t`mined ${results.length - failed}/${results.length}${failed ? `, ${failed} FAILED` : \"\"}\\n`,\n\t)\n\treturn failed === 0\n}\n","#!/usr/bin/env node\nimport { homedir } from \"node:os\"\nimport { join, resolve } from \"node:path\"\nimport { Command } from \"commander\"\nimport { runChecks } from \"./check.ts\"\nimport { runMine } from \"./mine.ts\"\n\nfunction parsePositiveInt(flag: string) {\n\treturn (v: string): number => {\n\t\tconst n = Number.parseInt(v, 10)\n\t\tif (!Number.isInteger(n) || n < 1)\n\t\t\tthrow new Error(`${flag} must be a positive integer, got \"${v}\"`)\n\t\treturn n\n\t}\n}\n\nconst collect = (v: string, prev: string[]): string[] => [...prev, v]\n\nconst program = new Command()\n\t.name(\"doublecheck\")\n\t.description(\n\t\t\"Run self-authored LLM code-inspectors (checks) against a target tree, one sandboxed agent per check\",\n\t)\n\nprogram\n\t.command(\"check\")\n\t.option(\"--target <dir>\", \"tree under inspection, mounted read-only\", process.cwd())\n\t.option(\n\t\t\"--checks-dir <dir>\",\n\t\t\"checks directory (repeatable; default: $TARGET/.agents/checks)\",\n\t\tcollect,\n\t\t[] as string[],\n\t)\n\t.option(\n\t\t\"--context <file>\",\n\t\t\"run-context file spliced into every inspector's prompt (intent, nuances, sanctioned exceptions, scope)\",\n\t)\n\t.option(\n\t\t\"--agent <name>\",\n\t\t\"agent CLI that runs the inspectors: claude or codex\",\n\t\t\"claude\",\n\t)\n\t.option(\n\t\t\"--model <model>\",\n\t\t\"model for the inspector agents (default per agent: claude haiku, codex gpt-5.5)\",\n\t)\n\t.option(\"--parallel <n>\", \"max concurrent checks\", parsePositiveInt(\"--parallel\"), 4)\n\t.option(\"--output <dir>\", \"reports root (default: $TARGET/.doublecheck)\")\n\t.option(\"--check <name>\", \"run only this check (repeatable)\", collect, [] as string[])\n\t.option(\n\t\t\"--save-jsonl\",\n\t\t\"persist each inspector's raw stream-json beside its report (audit trail)\",\n\t)\n\t.action(async (opts) => {\n\t\tconst target = resolve(opts.target)\n\t\tconst checksDirs: string[] =\n\t\t\topts.checksDir.length > 0\n\t\t\t\t? opts.checksDir.map((d: string) => resolve(d))\n\t\t\t\t: [join(target, \".agents\", \"checks\")]\n\t\tconst ok = await runChecks({\n\t\t\ttarget,\n\t\t\tchecksDirs,\n\t\t\tcontextFile: opts.context ? resolve(opts.context) : null,\n\t\t\tagent: opts.agent,\n\t\t\tmodel: opts.model,\n\t\t\tparallel: opts.parallel,\n\t\t\toutput: opts.output ? resolve(opts.output) : join(target, \".doublecheck\"),\n\t\t\tonly: opts.check,\n\t\t\tsaveJsonl: !!opts.saveJsonl,\n\t\t})\n\t\tif (!ok) process.exitCode = 1\n\t})\n\nprogram\n\t.command(\"mine\")\n\t.option(\n\t\t\"--projects <dir>\",\n\t\t\"Claude Code transcripts root\",\n\t\tjoin(homedir(), \".claude\", \"projects\"),\n\t)\n\t.option(\n\t\t\"--catalog <dir>\",\n\t\t\"observation catalog root\",\n\t\tjoin(homedir(), \".doublecheck\", \"catalog\"),\n\t)\n\t.option(\"--agent <name>\", \"agent CLI that runs the miners: claude or codex\", \"claude\")\n\t.option(\n\t\t\"--model <model>\",\n\t\t\"model for the mining agents (default per agent: claude opus, codex gpt-5.5 — a bad-model mine pollutes a durable asset)\",\n\t)\n\t.option(\"--parallel <n>\", \"max concurrent miners\", parsePositiveInt(\"--parallel\"), 4)\n\t.option(\n\t\t\"--min-turns <n>\",\n\t\t\"min genuine human turns for a real conversation\",\n\t\tparsePositiveInt(\"--min-turns\"),\n\t\t2,\n\t)\n\t.option(\"--limit <n>\", \"mine at most N pending units\", parsePositiveInt(\"--limit\"))\n\t.option(\"--dry-run\", \"list what would be mined without booting anything\")\n\t.action(async (opts) => {\n\t\tconst ok = await runMine({\n\t\t\tprojects: resolve(opts.projects),\n\t\t\tcatalog: resolve(opts.catalog),\n\t\t\tagent: opts.agent,\n\t\t\tmodel: opts.model,\n\t\t\tparallel: opts.parallel,\n\t\t\tminTurns: opts.minTurns,\n\t\t\tlimit: opts.limit,\n\t\t\tdryRun: !!opts.dryRun,\n\t\t})\n\t\tif (!ok) process.exitCode = 1\n\t})\n\nprogram.parseAsync().catch((e: unknown) => {\n\tconsole.error(e instanceof Error ? e.message : String(e))\n\tprocess.exit(1)\n})\n"],"mappings":";;;;;;;;;AAQA,MAAa,cAAc;AAG3B,MAAa,cAAc;AAU3B,SAAS,eACR,UACA,aACA,SACA,WACS;CACT,MAAM,OAAO,YAAY,IAAI,cAAc;CAC3C,OAAO;;6EAEqE,QAAQ,GAAG,YAAY,iKAAiK,YAAY;;eAElQ,QAAQ,GAAG,YAAY,IAAI,KAAK,oBAAoB,SAAS,uGAAuG,YAAY;AAC/L;AAEA,SAAS,gBAAgB,SAAiB,WAAkC;CAC3E,MAAM,OAAO,YAAY,IAAI,cAAc;CAC3C,OAAO,qDAAqD,QAAQ,GAAG,YAAY,IAAI,KAAK;AAC7F;AAMA,SAAgB,cAAc,MAMnB;CACV,MAAM,iBAAiB,KAAK,aACzB;;;;EAIF,KAAK,WAAW;;;;IAKd;CACH,OAAO;;;;wDAIgD,KAAK,OAAO;;sEAEE,KAAK,QAAQ;;EAEjF,gBAAgB,KAAK,SAAS,KAAK,SAAS,EAAE;;;;;;;;;;;;EAY9C,iBAAiB,KAAK,UAAU;;;;EAIhC,eAAe,cAAc,sBAAsB,KAAK,SAAS,KAAK,SAAS,EAAE;;;AAGnF;AAIA,SAAgB,kBACf,QACA,SACA,WACS;CACT,OAAO;;wNAEgN,QAAQ;;EAE9N,gBAAgB,SAAS,SAAS,EAAE;;;;;;;;;;EAUpC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCP,eAAe,UAAU,0BAA0B,SAAS,SAAS;AACvE;;;;AChJA,MAAMA,eAAa;AAGnB,SAAgB,YAAY,MAId;CACb,OAAO;EAKN,SACC,4KAUoE;EACrE,KAAK;GACJ,MAAMA;GACN,YAAY;GACZ,oBAAoB;GACpB,iBAAiB,KAAK;GACtB,yBAAyB,KAAK;EAC/B;EAGA,OAAO,CACN;GACC,MAAM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CAAC,CAAC,CACpF,OACA,mBACA,mDACA,iBAAiB,aAAa,GAC9B,CACD,CAAC,CACA,OAAO,eAAe,gCAAgC,iBAAiB,SAAS,CAAC,CAAC,CAClF,OAAO,aAAa,mDAAmD,CAAC,CACxE,OAAO,OAAO,SAAS;CAWvB,IAAI,CAAC,MAVY,QAAQ;EACxB,UAAU,QAAQ,KAAK,QAAQ;EAC/B,SAAS,QAAQ,KAAK,OAAO;EAC7B,OAAO,KAAK;EACZ,OAAO,KAAK;EACZ,UAAU,KAAK;EACf,UAAU,KAAK;EACf,OAAO,KAAK;EACZ,QAAQ,CAAC,CAAC,KAAK;CAChB,CAAC,GACQ,QAAQ,WAAW;AAC7B,CAAC;AAEF,QAAQ,WAAW,CAAC,CAAC,OAAO,MAAe;CAC1C,QAAQ,MAAM,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,CAAC;CACxD,QAAQ,KAAK,CAAC;AACf,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":["GUEST_HOME"],"sources":["../src/contract.ts","../src/claude.ts","../src/codex.ts","../src/agent-cli.ts","../src/runner.ts","../src/check.ts","../src/transcript.ts","../src/catalog.ts","../src/mine.ts","../src/cli.ts"],"sourcesContent":["// The agent contract: what the harness stages for the agent and what the\n// agent must leave behind. Any adapter (claude, codex) runs under this same\n// contract, which is what keeps the harness CLI-agnostic. The one per-agent\n// piece is `writeTool`: the phrase naming how THIS agent creates a file\n// (claude has a literal Write tool; codex is just told to create the file —\n// naming a tool it doesn't have would invite it to distrust its brief).\n\n// Staged into the scratch workdir before boot; the rw bind mount delivers it.\nexport const PROMPT_FILE = \"prompt.txt\"\n// The agent writes its findings here (relative to its cwd); the host reads it\n// back after exit. Missing report = failure.\nexport const REPORT_FILE = \"report.md\"\n\n// Weak models reliably skip a report contract stated once at the prompt's\n// tail unless it leads with the stakes and orders the file created first\n// (measured: haiku went from ~50% to 3/3 with this wording). Two hard-won\n// additions (2026-07-05, all three cutover inspectors lost their reports):\n// the path is ABSOLUTE — agents cd into the inspected tree to run git, and a\n// relative ./report.md then lands in the read-only mount — and the\n// create-first order is repeated near the top of the prompt (see\n// firstActionLine), because on long prompts the tail alone loses its grip.\nfunction reportContract(\n\tactivity: string,\n\tdeliverable: string,\n\tworkdir: string,\n\twriteTool: string | null,\n): string {\n\tconst tool = writeTool ? ` ${writeTool}` : \"\"\n\treturn `## Report — the only output that counts\n\nYour final chat reply is discarded. The only thing read back is the file \\`${workdir}/${REPORT_FILE}\\` — if it does not exist when you exit, this run FAILS. Always use that absolute path: if you \\`cd\\` elsewhere (into the inspected tree, say), a relative \\`./${REPORT_FILE}\\` lands in the wrong place, or in a read-only mount where the write fails.\n\nSo: create \\`${workdir}/${REPORT_FILE}\\`${tool} BEFORE you start ${activity} (a title line is enough), and update it as you work. The final state of the file when you finish is ${deliverable}.`\n}\n\nfunction firstActionLine(workdir: string, writeTool: string | null): string {\n\tconst tool = writeTool ? ` ${writeTool}` : \"\"\n\treturn `Your FIRST action, before anything else: create \\`${workdir}/${REPORT_FILE}\\`${tool} (a title line is enough). The full report contract is at the end of this prompt.`\n}\n\n// Environment preamble + optional run context + check body + report\n// contract. Checks are timeless standards; everything run-specific (intent,\n// sanctioned exceptions, scope) arrives in the operator's run context — the\n// harness knows nothing about git.\nexport function composePrompt(opts: {\n\tcheckBody: string\n\ttarget: string\n\tworkdir: string\n\trunContext: string | null\n\twriteTool: string | null\n}): string {\n\tconst contextSection = opts.runContext\n\t\t? `## Run context (from the operator)\n\nThe operator's brief for this run: the intent behind the work under review, known nuances, sanctioned exceptions, and possibly a Scope naming exactly what is under review. Judge requestedness against it — what the brief explicitly sanctions is not a finding. If it names a Scope, the Scope defines the change under review: findings must concern that change, and the rest of the tree is reference for judgment — with one exception. For concepts the scoped change retires or renames, surviving references anywhere in the tree are reportable findings: the Scope bounds what counts as the change, not where survivors may hide.\n\n${opts.runContext}\n\n---\n\n`\n\t\t: \"\"\n\treturn `## Environment\n\nYou are a code inspector running inside a sandboxed microVM with full permissions and unrestricted internet access.\n\n- The code under inspection is mounted read-only at \\`${opts.target}\\`. You cannot modify it — inspect, don't fix.\n- \\`git\\` and \\`rg\\` are installed.\n- Your current working directory is a writable scratch workspace: \\`${opts.workdir}\\`.\n\n${firstActionLine(opts.workdir, opts.writeTool)}\n\n## Inspection discipline\n\nMeasured on real runs: inspectors that skip these rules produce reports whose verdicts are right but whose evidence is partly fabricated — which is worse than no report.\n\n- Before inspecting, enumerate what is under review (the Run context's Scope list if one is given; otherwise your own enumeration of the target) and keep a ledger as you work: **examined** (content actually opened), **name-only**, **not examined**. End your report with that ledger, with a one-line reason for anything not examined.\n- Use verification verbs — \"verified\", \"confirmed\", \"checked\", \"read\", \"diffed\", \"grepped\", \"spot-checked\" — ONLY for actions you actually performed in this session on content you actually opened. Everything else must be labeled as inference: \"assumed identical by generation — not opened.\"\n- Never truncate output you will base a claim on — no \\`| head\\` / \\`| tail\\` on a diff or search you intend to cite. Examine files one at a time instead.\n\n---\n\n${contextSection}${opts.checkBody}\n\n---\n\n${reportContract(\"inspecting\", \"the check's report\", opts.workdir, opts.writeTool)}\n\nEvery single line of your report will be read in full by the operator's agent — nothing is skimmed, so every line costs attention. Verify each finding against the actual code before writing it down. A report that says \"no findings\" is a perfectly good report; an unverified finding is not.`\n}\n\n// The mining prompt: digest of one conversation + what counts as a durable\n// preference observation + the block format the catalog accumulates.\nexport function composeMinePrompt(\n\tdigest: string,\n\tworkdir: string,\n\twriteTool: string | null,\n): string {\n\treturn `## Environment\n\nYou are running inside a sandboxed microVM with no network access. The machine's Claude Code transcripts are mounted read-only at their real paths; your current working directory is a writable scratch workspace: \\`${workdir}\\`.\n\n${firstActionLine(workdir, writeTool)}\n\n## Task\n\nYou are mining ONE Claude Code conversation for the operator's durable preferences — how they want engineering done, in any conversation, not what they wanted built in this one.\n\nBelow is the conversation digest: every genuine human turn, numbered, in order. When a turn is a terse correction or interruption (\"no\", \"stop\", \"don't\", \"why did you…\", \"[Request interrupted]\"), recover its context: the \"# source:\" header names the full session transcript — Grep that turn's text in it to find its line, then Read the assistant turns IMMEDIATELY BEFORE it with offset/limit. The preference lives in the contrast between what the assistant did and what the operator demanded. NEVER read a transcript whole — some are tens of MB.\n\n---\n\n${digest}\n\n---\n\n## What counts as an observation (strict)\n\nA durable preference, backed by a verbatim quote from the digest or transcript:\n\n- **kind: code** — how code should be written/structured/shaped (\"no silent fallbacks\", \"reuse the existing helper instead of hand-rolling\").\n- **kind: workflow** — how work should proceed (\"verify before claiming done\", \"ask before making scope decisions\").\n- **kind: style** — how prose/output/docs should read.\n\nExclude task-of-the-moment directives with no durable signal (\"add a tab to home.tsx\", \"kill the dev server\"). Exclude anything you cannot quote. Be conservative: a weak or speculative observation is worse than none.\n\n## Observation format\n\nThe report is observation blocks and NOTHING else — no title, no preamble, no summary or conclusion sections. One block per observation:\n\n## <kebab-case-name>\n- **observation:** <one sentence: the durable preference>\n- **kind:** code | workflow | style\n- **evidence:** \"<verbatim quote>\" — turn <N>\n\nFor **code** observations that an LLM reviewer could check against a diff or file tree (a concrete change could flip PASS↔FAIL), and ONLY for those — never on workflow or style blocks — ALSO add:\n\n- **pass/fail:** PASS when <…>; FAIL when <…>\n- **why-LLM:** <why a deterministic linter cannot enforce this>\n- **scope:** diff-only | needs-tree\n\nIf the conversation carries no durable preference signal, the report is exactly these two lines and nothing more:\n\nNo durable preference signal.\n<one sentence: what the conversation was about instead>\n\n${reportContract(\"mining\", \"the mined observations\", workdir, writeTool)}`\n}\n","import { PROMPT_FILE } from \"./contract.ts\"\nimport type { AgentSpec } from \"./runner.ts\"\n\nconst GUEST_HOME = \"/root\"\n\n// The claude adapter: produce the AgentSpec that runs `claude -p` in the guest.\nexport function claudeAgent(opts: {\n\ttoken: string\n\tmodel: string\n\tworkdir: string\n}): AgentSpec {\n\treturn {\n\t\t// Headless claude -p cannot answer permission prompts, so in \"default\"\n\t\t// mode every tool is auto-denied and the agent produces nothing. The\n\t\t// microVM is the safety boundary here, so bypass the per-tool gate;\n\t\t// IS_SANDBOX=1 is what lets that run as root without claude's refusal.\n\t\tcommand:\n\t\t\t\"claude -p --no-session-persistence \" +\n\t\t\t\"--dangerously-skip-permissions \" +\n\t\t\t// --verbose is required by claude -p with stream-json output; it only\n\t\t\t// widens what lands on stdout, which describeStreamLine already labels.\n\t\t\t\"--output-format stream-json --verbose \" +\n\t\t\t// Not a permission gate — a contract guard. The default headless tool\n\t\t\t// set omits Glob/Grep and includes harness tools (ReportFindings,\n\t\t\t// TaskCreate, …) that hijack the report: haiku \"reports findings\"\n\t\t\t// through them and never writes report.md (verified live). This pins\n\t\t\t// the inspector's full toolkit and nothing else.\n\t\t\t`--tools Task Bash Read Write Edit Glob Grep WebSearch WebFetch < ${PROMPT_FILE}`,\n\t\tenv: {\n\t\t\tHOME: GUEST_HOME,\n\t\t\tIS_SANDBOX: \"1\",\n\t\t\tGIT_OPTIONAL_LOCKS: \"0\",\n\t\t\tANTHROPIC_MODEL: opts.model,\n\t\t\tCLAUDE_CODE_OAUTH_TOKEN: opts.token,\n\t\t},\n\t\t// Minimal trust-accepted entry keyed to the guest cwd so headless claude\n\t\t// skips the trust prompt. Deliberately NOT a copy of any host .claude.json.\n\t\tfiles: [\n\t\t\t{\n\t\t\t\tpath: `${GUEST_HOME}/.claude.json`,\n\t\t\t\tcontent: `${JSON.stringify(\n\t\t\t\t\t{ projects: { [opts.workdir]: { hasTrustDialogAccepted: true } } },\n\t\t\t\t\tnull,\n\t\t\t\t\t\"\\t\",\n\t\t\t\t)}\\n`,\n\t\t\t},\n\t\t],\n\t}\n}\n\ninterface StreamLine {\n\ttype?: string\n\tsubtype?: string\n\tmessage?: { content?: Array<{ type?: string; text?: string; name?: string }> }\n\tduration_ms?: number\n}\n\n// One human-readable label per stream-json stdout line; null for lines that\n// aren't claude's JSON (dropped from the progress stream).\nexport function describeClaudeStreamLine(line: string): string | null {\n\tlet obj: StreamLine\n\ttry {\n\t\tobj = JSON.parse(line) as StreamLine\n\t} catch {\n\t\treturn null\n\t}\n\tconst label = (obj.type ?? \"\") + (obj.subtype ? `:${obj.subtype}` : \"\")\n\t// A once-per-second heartbeat with no content — pure noise in the stream.\n\tif (label === \"system:thinking_tokens\") return null\n\tlet detail = \"\"\n\tif (obj.type === \"assistant\") {\n\t\tconst content = obj.message?.content ?? []\n\t\tconst tools = content\n\t\t\t.filter((b) => b.type === \"tool_use\" && b.name)\n\t\t\t.map((b) => b.name)\n\t\tconst chars = content.reduce((n, b) => n + (b.text?.length ?? 0), 0)\n\t\tdetail = tools.length ? ` ${tools.join(\",\")}` : ` ${chars} chars`\n\t} else if (obj.type === \"result\") {\n\t\tdetail = ` ${obj.subtype}, ${((obj.duration_ms ?? 0) / 1000).toFixed(1)}s`\n\t}\n\treturn `[${label}]${detail}`\n}\n","import { PROMPT_FILE } from \"./contract.ts\"\nimport type { AgentSpec } from \"./runner.ts\"\n\nconst GUEST_HOME = \"/root\"\n\n// Guest-only codex config — deliberately NOT a copy of any host config.toml\n// (which carries MCP API keys, personality, plugins, a trust table). Each key\n// is load-bearing:\n// - model rides here rather than as a `-m` flag so nothing operator-supplied\n// is ever interpolated into the guest's bash command string.\n// - approval_policy/sandbox_mode double the bypass flag on the command line;\n// either alone is a documented trust-prompt suppressor, some builds leak\n// with only one (openai/codex#14547).\n// - model_reasoning_effort: operator decision — plan billing is flat-rate,\n// so there is no haiku-style cost gradient to encode in a cheaper setting.\n// - web_search is a server-side tool (the guest never fetches pages itself);\n// \"live\" pins it rather than relying on the full-access auto-upgrade.\n// - project_doc_max_bytes = 0 disables all AGENTS.md loading: the piped\n// prompt is the agent's only input.\n// - features.plugins/apps = false stop codex's boot-time marketplace clone\n// and apps fetch (verified live): under restricted egress they hang, and\n// under any egress they inject tools (e.g. a git-push skill) the contract\n// never sanctioned.\nfunction guestConfig(model: string): string {\n\treturn `model = \"${model}\"\napproval_policy = \"never\"\nsandbox_mode = \"danger-full-access\"\nmodel_reasoning_effort = \"xhigh\"\nweb_search = \"live\"\nproject_doc_max_bytes = 0\ncli_auth_credentials_store = \"file\"\n\n[features]\nplugins = false\napps = false\n`\n}\n\n// The codex adapter: produce the AgentSpec that runs `codex exec` in the guest.\nexport function codexAgent(opts: {\n\t// Byte-for-byte content of the operator's ~/.codex/auth.json; staleness is\n\t// the caller's preflight (a guest-side token refresh would rotate the\n\t// single-use refresh token and poison the host session).\n\tauthJson: string\n\tmodel: string\n\tworkdir: string\n}): AgentSpec {\n\treturn {\n\t\t// Headless codex cannot answer approval prompts, and its own bwrap\n\t\t// sandbox needs user namespaces the guest may not grant — the microVM is\n\t\t// the safety boundary, so bypass both (OpenAI's documented container\n\t\t// guidance). --ephemeral writes no session rollout files;\n\t\t// --skip-git-repo-check because the scratch cwd is not a git repo.\n\t\tcommand:\n\t\t\t\"codex exec --json --skip-git-repo-check \" +\n\t\t\t\"--dangerously-bypass-approvals-and-sandbox --ephemeral \" +\n\t\t\t`- < ${PROMPT_FILE}`,\n\t\tenv: {\n\t\t\t// CODEX_HOME defaults to $HOME/.codex, where both staged files land.\n\t\t\tHOME: GUEST_HOME,\n\t\t\tGIT_OPTIONAL_LOCKS: \"0\",\n\t\t},\n\t\tfiles: [\n\t\t\t{ path: `${GUEST_HOME}/.codex/auth.json`, content: opts.authJson },\n\t\t\t{\n\t\t\t\tpath: `${GUEST_HOME}/.codex/config.toml`,\n\t\t\t\tcontent: guestConfig(opts.model),\n\t\t\t},\n\t\t],\n\t}\n}\n\n// The freshness window for a staged ChatGPT-auth auth.json. Codex refreshes\n// tokens when last_refresh is ~8 days old (or on a 401), refresh tokens are\n// single-use, and a refresh performed INSIDE a guest rotates the token family\n// — the host's copy then dies with \"refresh token was already used\" (forced\n// re-login). 7 days leaves a day of margin below codex's own threshold.\nexport const CODEX_AUTH_MAX_AGE_DAYS = 7\n\ninterface CodexAuth {\n\ttokens?: { refresh_token?: string }\n\tlast_refresh?: string\n\tOPENAI_API_KEY?: string\n}\n\n// Pure preflight: throw (with the operator's next action) unless this\n// auth.json is safe to stage into guests. An api-key-mode auth.json (no\n// tokens, an OPENAI_API_KEY field) carries no refresh semantics, so no\n// staleness guard applies.\nexport function validateCodexAuth(content: string, now: Date, where: string): void {\n\tlet auth: CodexAuth\n\ttry {\n\t\tauth = JSON.parse(content) as CodexAuth\n\t} catch {\n\t\tthrow new Error(`${where} is not valid JSON — run \\`codex login\\` on the host`)\n\t}\n\tif (auth.tokens?.refresh_token) {\n\t\tconst ageDays = (now.getTime() - Date.parse(auth.last_refresh ?? \"\")) / 86_400_000\n\t\tif (!(ageDays <= CODEX_AUTH_MAX_AGE_DAYS)) {\n\t\t\tthrow new Error(\n\t\t\t\t`${where} tokens were last refreshed over ${CODEX_AUTH_MAX_AGE_DAYS} days ago (codex refreshes at ~8 days, and a refresh inside a guest would rotate the single-use refresh token and poison this host's session) — run any codex command on the host to refresh, then retry`,\n\t\t\t)\n\t\t}\n\t\treturn\n\t}\n\tif (auth.OPENAI_API_KEY) return\n\tthrow new Error(\n\t\t`${where} has neither ChatGPT tokens nor an API key — run \\`codex login\\` on the host`,\n\t)\n}\n\ninterface CodexStreamLine {\n\ttype?: string\n\titem?: {\n\t\ttype?: string\n\t\ttext?: string\n\t\tcommand?: string\n\t\tchanges?: Array<{ path?: string }>\n\t}\n\tusage?: { input_tokens?: number; output_tokens?: number }\n\terror?: { message?: string }\n\tmessage?: string\n}\n\nconst clip = (s: string, max = 60): string => (s.length > max ? `${s.slice(0, max)}…` : s)\n\n// One human-readable label per --json stdout line; null for lines that aren't\n// codex's JSON (dropped from the progress stream). Event taxonomy:\n// thread.started / turn.started / turn.completed / turn.failed /\n// item.{started,updated,completed} (item.type = agent_message,\n// command_execution, file_change, reasoning, web_search, todo_list,\n// mcp_tool_call, error) / error.\nexport function describeCodexStreamLine(line: string): string | null {\n\tlet obj: CodexStreamLine\n\ttry {\n\t\tobj = JSON.parse(line) as CodexStreamLine\n\t} catch {\n\t\treturn null\n\t}\n\tconst item = obj.item\n\tconst label = (obj.type ?? \"\") + (item?.type ? `:${item.type}` : \"\")\n\tlet detail = \"\"\n\tif (item?.type === \"agent_message\") {\n\t\tdetail = ` ${item.text?.length ?? 0} chars`\n\t} else if (item?.type === \"command_execution\" && item.command) {\n\t\tdetail = ` ${clip(item.command)}`\n\t} else if (item?.type === \"file_change\") {\n\t\tdetail = ` ${(item.changes ?? []).length} file(s)`\n\t} else if (obj.type === \"turn.completed\") {\n\t\tdetail = ` ${obj.usage?.input_tokens ?? 0} in, ${obj.usage?.output_tokens ?? 0} out tokens`\n\t} else if (obj.type === \"turn.failed\") {\n\t\tdetail = ` ${clip(obj.error?.message ?? \"\")}`\n\t} else if (obj.type === \"error\") {\n\t\tdetail = ` ${clip(obj.message ?? \"\")}`\n\t}\n\treturn `[${label}]${detail}`\n}\n","import { readFileSync } from \"node:fs\"\nimport { homedir } from \"node:os\"\nimport { join } from \"node:path\"\nimport { claudeAgent, describeClaudeStreamLine } from \"./claude.ts\"\nimport { codexAgent, describeCodexStreamLine, validateCodexAuth } from \"./codex.ts\"\nimport type { AgentSpec } from \"./runner.ts\"\n\n// The agent CLI: the brand of agent (claude, codex) the operator picks with\n// --agent, and everything the workflows need from it. Not to be confused with\n// the harness (doublecheck's own mechanics) or an agent (one running\n// inspector instance, described by an AgentSpec).\nexport interface AgentCli {\n\tname: string\n\t// Applied only when --model is absent.\n\tdefaultModel: { check: string; mine: string }\n\t// The phrase the report contract uses to tell this agent how to create a\n\t// file; null when the prompt should just say \"create <path>\".\n\twriteToolPhrase: string | null\n\t// Domain suffixes for restricted-egress workflows (mine): the CLI's own\n\t// API endpoints, so the only reachable destination is the service the\n\t// agent already sends its context to.\n\tegressDomains: string[]\n\t// Host-side preflight: the secret material staged into every guest, or an\n\t// actionable error. Runs once per invocation, before any guest boots.\n\tcredentials(): string\n\tagent(opts: { credentials: string; model: string; workdir: string }): AgentSpec\n\tdescribeStreamLine(line: string): string | null\n}\n\nconst claude: AgentCli = {\n\tname: \"claude\",\n\tdefaultModel: { check: \"haiku\", mine: \"opus\" },\n\twriteToolPhrase: \"with the Write tool\",\n\tegressDomains: [\"anthropic.com\"],\n\tcredentials: () => {\n\t\tconst token = process.env.CLAUDE_CODE_OAUTH_TOKEN\n\t\tif (!token) {\n\t\t\tthrow new Error(\n\t\t\t\t\"CLAUDE_CODE_OAUTH_TOKEN is required in the environment (it is injected into each agent's sandbox)\",\n\t\t\t)\n\t\t}\n\t\treturn token\n\t},\n\tagent: ({ credentials, model, workdir }) =>\n\t\tclaudeAgent({ token: credentials, model, workdir }),\n\tdescribeStreamLine: describeClaudeStreamLine,\n}\n\nconst codex: AgentCli = {\n\tname: \"codex\",\n\t// No haiku-style cheap default: plan billing is flat-rate, and the staged\n\t// guest config already pins xhigh reasoning effort (operator decision).\n\tdefaultModel: { check: \"gpt-5.5\", mine: \"gpt-5.5\" },\n\twriteToolPhrase: null,\n\t// ChatGPT-plan inference lives at chatgpt.com/backend-api/codex; the\n\t// openai.com suffix covers auth.openai.com, where a 401-forced token\n\t// refresh would have to go.\n\tegressDomains: [\"chatgpt.com\", \"openai.com\"],\n\tcredentials: () => {\n\t\tconst authPath = join(homedir(), \".codex\", \"auth.json\")\n\t\tlet content: string\n\t\ttry {\n\t\t\tcontent = readFileSync(authPath, \"utf-8\")\n\t\t} catch {\n\t\t\tthrow new Error(`no readable ${authPath} — run \\`codex login\\` on the host`)\n\t\t}\n\t\tvalidateCodexAuth(content, new Date(), authPath)\n\t\treturn content\n\t},\n\tagent: ({ credentials, model, workdir }) =>\n\t\tcodexAgent({ authJson: credentials, model, workdir }),\n\tdescribeStreamLine: describeCodexStreamLine,\n}\n\nconst AGENT_CLIS: Record<string, AgentCli> = { claude, codex }\n\nexport function resolveAgentCli(name: string): AgentCli {\n\tconst cli = AGENT_CLIS[name]\n\tif (!cli) {\n\t\tthrow new Error(\n\t\t\t`unknown agent \"${name}\" (have: ${Object.keys(AGENT_CLIS).join(\", \")})`,\n\t\t)\n\t}\n\treturn cli\n}\n\n// One resolved, preflighted agent selection, shared by every unit of a run.\nexport interface AgentRun {\n\tcli: AgentCli\n\tcredentials: string\n\tmodel: string\n}\n\n// Resolve --agent/--model into what a workflow's units consume: the CLI, its\n// preflighted credentials, and the model (explicit flag, else the CLI's\n// default for this workflow).\nexport function resolveAgentRun(\n\tname: string,\n\tmodel: string | undefined,\n\tworkflow: \"check\" | \"mine\",\n): AgentRun {\n\tconst cli = resolveAgentCli(name)\n\treturn {\n\t\tcli,\n\t\tcredentials: cli.credentials(),\n\t\tmodel: model ?? cli.defaultModel[workflow],\n\t}\n}\n\n// The per-unit progress sink both workflow shells hang on runAgent: guest\n// stderr passes through as `[label] ! line`, stdout is the agent CLI's JSON\n// stream, labelled by its describeStreamLine (non-JSON lines dropped).\nexport function progressSink(\n\tlabel: string,\n\tdescribe: (line: string) => string | null,\n): (kind: \"stdout\" | \"stderr\", line: string) => void {\n\treturn (kind, line) => {\n\t\tif (kind === \"stderr\") {\n\t\t\tprocess.stderr.write(`[${label}] ! ${line}\\n`)\n\t\t\treturn\n\t\t}\n\t\tconst described = describe(line)\n\t\tif (described) process.stderr.write(`[${label}] ${described}\\n`)\n\t}\n}\n","import { existsSync, readFileSync } from \"node:fs\"\nimport { basename, join } from \"node:path\"\nimport type { ExecEvent } from \"microsandbox\"\nimport { REPORT_FILE } from \"./contract.ts\"\n\n// microsandbox exports its fluent builders as value-only consts; recover their\n// instance types via a type-only import (erased at build) so the native module\n// only loads behind the `await import` in runAgent.\ntype MountBuilder = InstanceType<typeof import(\"microsandbox\").MountBuilder>\ntype PatchBuilder = InstanceType<typeof import(\"microsandbox\").PatchBuilder>\ntype ExecOptionsBuilder = InstanceType<typeof import(\"microsandbox\").ExecOptionsBuilder>\n// The SDK types `.network(cb)` as `(b: any) => any`, and we call the JS-shim\n// `.policy(...)`, absent from the native builder's types.\n// biome-ignore lint/suspicious/noExplicitAny: SDK types this builder callback as any\ntype NetworkBuilder = any\n\n// The guest image (Dockerfile.guest): node 24 slim + git/ripgrep/curl/wget +\n// both agent CLIs baked in. Released versions pull the multi-arch image the\n// release workflow pushed to ghcr (tag = the package's own version, so CLI\n// and image always match); a dev tree (version 0.0.0-development) uses the\n// locally built image side-loaded by ./scripts/build-guest-image.sh, which\n// exists nowhere else — hence pullPolicy \"never\": a cache miss means \"run the\n// build script\", not \"try a registry\".\nconst GUEST_IMAGE_REPO = \"ghcr.io/alizain/doublecheck-guest\"\nconst LOCAL_GUEST_IMAGE = \"doublecheck-guest:latest\"\nexport const DEV_VERSION = \"0.0.0-development\"\nconst GUEST_MEMORY_MIB = 2048\n\nexport interface GuestImage {\n\tref: string\n\tpullPolicy: \"never\" | \"if-missing\"\n}\n\n// Pure: which image this doublecheck runs its guests from. An override (the\n// DOUBLECHECK_GUEST_IMAGE env var) is operator-managed: it must already be in\n// the msb cache, so it is never pulled.\nexport function decideGuestImage(version: string, override?: string): GuestImage {\n\tif (override) return { ref: override, pullPolicy: \"never\" }\n\tif (version === DEV_VERSION) return { ref: LOCAL_GUEST_IMAGE, pullPolicy: \"never\" }\n\treturn { ref: `${GUEST_IMAGE_REPO}:${version}`, pullPolicy: \"if-missing\" }\n}\n\n// Read at runtime, not import time: the dist bundle is built BEFORE\n// semantic-release stamps the real version into the published package.json,\n// so baking the version in at build time would pin every install to\n// 0.0.0-development. Works from both src/ (tsx) and dist/ (bundle) — each\n// sits one level below the package root.\nfunction packageVersion(): string {\n\tconst pkg = JSON.parse(\n\t\treadFileSync(new URL(\"../package.json\", import.meta.url), \"utf-8\"),\n\t) as { version: string }\n\treturn pkg.version\n}\n\n// Staged into the guest before boot (e.g. claude's trust-accepted config).\nexport interface GuestFile {\n\tpath: string\n\tcontent: string\n}\n\n// What it takes to run one agent in a booted guest: a bash command executed in\n// the scratch cwd that must leave REPORT_FILE there, the env it needs, and\n// files staged into the guest. Plain data — adapters produce it, this runner\n// consumes it, tests fake it.\nexport interface AgentSpec {\n\tcommand: string\n\tenv: Record<string, string>\n\tfiles: GuestFile[]\n}\n\nexport type AgentOutcome =\n\t| { ok: true; report: string }\n\t| { ok: false; reason: string; partialReport: string | null }\n\n// Pure line buffering: fold a chunk into the carry, emit complete non-blank\n// lines, keep the unterminated tail.\nexport function feedLines(\n\tcarry: string,\n\tchunk: string,\n): { lines: string[]; carry: string } {\n\tconst parts = (carry + chunk).split(\"\\n\")\n\tconst rest = parts.pop() ?? \"\"\n\treturn { lines: parts.filter((l) => l.trim()), carry: rest }\n}\n\n// Pure outcome decision: what the exec left behind → what it means.\nexport function decideOutcome(\n\texitCode: number | null,\n\treport: string | null,\n\tworkdir: string,\n): AgentOutcome {\n\tif (exitCode !== 0) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\treason: `agent process exited ${exitCode}`,\n\t\t\tpartialReport: report,\n\t\t}\n\t}\n\tif (report === null) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\treason: `agent exited 0 but wrote no ${REPORT_FILE} (work dir: ${workdir})`,\n\t\t\tpartialReport: null,\n\t\t}\n\t}\n\treturn { ok: true, report }\n}\n\nexport interface RunAgentOpts {\n\t// Host dir the agent inspects, bind-mounted READ-ONLY at its real host\n\t// path: the target for `check`, the transcripts corpus for `mine`.\n\tmount: string\n\t// Scratch dir with PROMPT_FILE already inside; bind-mounted rw as the guest\n\t// cwd at its identical host path, so the agent's report lands back on the host.\n\tworkdir: string\n\tspec: AgentSpec\n\t// \"all\" for checks (inspectors may research); a domain-suffix allowlist for\n\t// miners: the personal corpus is mounted, so egress is pinned to the agent\n\t// CLI's own API domains — the only reachable destination is the service\n\t// the agent already sends its context to. NetworkPolicy.none() is not an\n\t// option here — it kills DNS entirely and the adapter can't reach its own\n\t// model API (measured: claude retries ~180s then exits 1).\n\tnetwork: \"all\" | { onlyDomains: string[] }\n\tonLine: (kind: \"stdout\" | \"stderr\", line: string) => void\n}\n\n// Boot a guest (ro mount + scratch rw as cwd), exec the agent command, stream\n// its output line-by-line, read the report back off the scratch dir, tear\n// down. Agent-level failures (exit ≠ 0, no report) return ok:false;\n// harness-level failures (image missing, boot error) throw.\nexport async function runAgent(opts: RunAgentOpts): Promise<AgentOutcome> {\n\tconst microsandbox = await import(\"microsandbox\")\n\tconst name = `doublecheck-${basename(opts.workdir)}`\n\tconst image = decideGuestImage(packageVersion(), process.env.DOUBLECHECK_GUEST_IMAGE)\n\tconst network = opts.network\n\tconst policy =\n\t\tnetwork === \"all\"\n\t\t\t? microsandbox.NetworkPolicy.allowAll()\n\t\t\t: microsandbox.NetworkPolicy.builder()\n\t\t\t\t\t.defaultDeny()\n\t\t\t\t\t.egress((rb) => {\n\t\t\t\t\t\tlet rules = rb\n\t\t\t\t\t\tfor (const domain of network.onlyDomains) {\n\t\t\t\t\t\t\trules = rules.allow((d) => d.domainSuffix(domain))\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn rules\n\t\t\t\t\t})\n\t\t\t\t\t.build()\n\tlet sandbox: InstanceType<typeof microsandbox.Sandbox> | null = null\n\ttry {\n\t\ttry {\n\t\t\tsandbox = await microsandbox.Sandbox.builder(name)\n\t\t\t\t.image(image.ref)\n\t\t\t\t.memory(GUEST_MEMORY_MIB)\n\t\t\t\t.pullPolicy(image.pullPolicy)\n\t\t\t\t.replace()\n\t\t\t\t.workdir(opts.workdir)\n\t\t\t\t.envs(opts.spec.env)\n\t\t\t\t.volume(opts.mount, (mb: MountBuilder) => mb.bind(opts.mount).readonly())\n\t\t\t\t.volume(opts.workdir, (mb: MountBuilder) => mb.bind(opts.workdir))\n\t\t\t\t.patch((pb: PatchBuilder) => {\n\t\t\t\t\tlet p = pb\n\t\t\t\t\tfor (const f of opts.spec.files) {\n\t\t\t\t\t\tp = p.text(f.path, f.content, { mode: 0o600, replace: true })\n\t\t\t\t\t}\n\t\t\t\t\treturn p\n\t\t\t\t})\n\t\t\t\t.network((nb: NetworkBuilder) => nb.policy(policy))\n\t\t\t\t.create()\n\t\t} catch (e) {\n\t\t\tif (image.pullPolicy === \"never\" && String(e).includes(\"not cached\")) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`guest image ${image.ref} is not in the microsandbox cache — run scripts/build-guest-image.sh (${String(e)})`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (image.pullPolicy === \"if-missing\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`guest ${image.ref} failed to boot — if this is a pull failure, check network access to ghcr.io and that the package is public; a locally built image can be forced with DOUBLECHECK_GUEST_IMAGE=doublecheck-guest:latest (${String(e)})`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\n\t\tconst handle = await sandbox.execStreamWith(\"bash\", (e: ExecOptionsBuilder) =>\n\t\t\te.args([\"-c\", opts.spec.command]),\n\t\t)\n\n\t\tconst carry: Record<\"stdout\" | \"stderr\", string> = { stdout: \"\", stderr: \"\" }\n\t\tlet exitCode: number | null = null\n\t\tfor (;;) {\n\t\t\tconst ev: ExecEvent | null = await handle.recv()\n\t\t\tif (ev === null) break\n\t\t\tif (ev.kind === \"stdout\" || ev.kind === \"stderr\") {\n\t\t\t\tconst fed = feedLines(carry[ev.kind], Buffer.from(ev.data).toString())\n\t\t\t\tcarry[ev.kind] = fed.carry\n\t\t\t\tfor (const line of fed.lines) opts.onLine(ev.kind, line)\n\t\t\t} else if (ev.kind === \"exited\") exitCode = ev.code\n\t\t}\n\t\tfor (const kind of [\"stdout\", \"stderr\"] as const) {\n\t\t\tif (carry[kind].trim()) opts.onLine(kind, carry[kind])\n\t\t}\n\n\t\tconst reportPath = join(opts.workdir, REPORT_FILE)\n\t\tconst report = existsSync(reportPath) ? readFileSync(reportPath, \"utf-8\") : null\n\t\treturn decideOutcome(exitCode, report, opts.workdir)\n\t} finally {\n\t\tif (sandbox) {\n\t\t\ttry {\n\t\t\t\tawait sandbox.stop()\n\t\t\t} catch (e) {\n\t\t\t\topts.onLine(\"stderr\", `sandbox stop failed: ${String(e)}`)\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tawait microsandbox.Sandbox.remove(name)\n\t\t\t} catch (e) {\n\t\t\t\topts.onLine(\"stderr\", `sandbox remove failed: ${String(e)}`)\n\t\t\t}\n\t\t}\n\t}\n}\n","import {\n\tappendFileSync,\n\tmkdirSync,\n\tmkdtempSync,\n\treaddirSync,\n\treadFileSync,\n\twriteFileSync,\n} from \"node:fs\"\nimport { tmpdir } from \"node:os\"\nimport { join } from \"node:path\"\nimport PQueue from \"p-queue\"\nimport { type AgentRun, progressSink, resolveAgentRun } from \"./agent-cli.ts\"\nimport { composePrompt, PROMPT_FILE, REPORT_FILE } from \"./contract.ts\"\nimport { runAgent } from \"./runner.ts\"\n\n// A check is a plain markdown file — no frontmatter, no schema. The body is\n// the inspector's instructions; the name is the filename minus .md. Checks\n// come from one or more --checks-dir directories (default:\n// $TARGET/.agents/checks).\nexport interface Check {\n\tname: string\n\tbody: string\n}\n\n// Pure selection: `only` (from repeated --check flags) filters, in the order\n// named; naming a check that doesn't exist is an error, not an empty run.\nexport function selectChecks(all: Check[], only: string[], where: string): Check[] {\n\tif (all.length === 0) throw new Error(`no checks (*.md) in ${where}`)\n\tif (only.length === 0) return all\n\tconst byName = new Map(all.map((c) => [c.name, c]))\n\treturn only.map((name) => {\n\t\tconst check = byName.get(name)\n\t\tif (!check) {\n\t\t\tconst have = all.map((c) => c.name).join(\", \")\n\t\t\tthrow new Error(`no check named \"${name}\" in ${where} (have: ${have})`)\n\t\t}\n\t\treturn check\n\t})\n}\n\n// Shell: read every check file from every checks dir, then select purely.\n// A missing dir is an error; the same check name in two dirs is an error —\n// no precedence rules, rename one.\nexport function discoverChecks(dirs: string[], only: string[]): Check[] {\n\tconst all: Array<Check & { dir: string }> = []\n\tfor (const dir of dirs) {\n\t\tlet entries: string[]\n\t\ttry {\n\t\t\tentries = readdirSync(dir)\n\t\t} catch {\n\t\t\tthrow new Error(`no checks directory at ${dir}`)\n\t\t}\n\t\tfor (const f of entries.filter((e) => e.endsWith(\".md\")).sort()) {\n\t\t\tconst name = f.slice(0, -\".md\".length)\n\t\t\tconst clash = all.find((c) => c.name === name)\n\t\t\tif (clash) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`check \"${name}\" exists in both ${clash.dir} and ${dir} — rename one`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tall.push({ name, body: readFileSync(join(dir, f), \"utf-8\"), dir })\n\t\t}\n\t}\n\tconst checks = all\n\t\t.map(({ name, body }) => ({ name, body }))\n\t\t.sort((a, b) => a.name.localeCompare(b.name))\n\treturn selectChecks(checks, only, dirs.join(\", \"))\n}\n\nexport interface CheckWorkflowOpts {\n\ttarget: string\n\tchecksDirs: string[]\n\tcontextFile: string | null\n\tagent: string\n\t// Absent = the agent CLI's default for checks.\n\tmodel?: string\n\tparallel: number\n\toutput: string\n\tonly: string[]\n\tsaveJsonl: boolean\n}\n\n// fs-safe local timestamp, one dir per run shared by all its checks:\n// 2026-07-05-143000\nexport function runTimestamp(d: Date): string {\n\tconst p = (n: number) => String(n).padStart(2, \"0\")\n\treturn `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}-${p(d.getHours())}${p(d.getMinutes())}${p(d.getSeconds())}`\n}\n\n// The report written when the agent failed: the failure is the report, plus\n// whatever partial report the agent managed to leave.\nexport function failureReport(reason: string, partialReport: string | null): string {\n\tconst partial = partialReport\n\t\t? `\\n---\\n\\nPartial ${REPORT_FILE} left by the agent:\\n\\n${partialReport}`\n\t\t: \"\"\n\treturn `# CHECK FAILED\\n\\n${reason}\\n${partial}`\n}\n\nasync function runOneCheck(\n\tcheck: Check,\n\topts: CheckWorkflowOpts,\n\trun: AgentRun,\n\trunContext: string | null,\n\toutDir: string,\n): Promise<boolean> {\n\tconst workdir = mkdtempSync(join(tmpdir(), `doublecheck-${check.name}-`))\n\twriteFileSync(\n\t\tjoin(workdir, PROMPT_FILE),\n\t\tcomposePrompt({\n\t\t\tcheckBody: check.body,\n\t\t\ttarget: opts.target,\n\t\t\tworkdir,\n\t\t\trunContext,\n\t\t\twriteTool: run.cli.writeToolPhrase,\n\t\t}),\n\t)\n\tconst spec = run.cli.agent({\n\t\tcredentials: run.credentials,\n\t\tmodel: run.model,\n\t\tworkdir,\n\t})\n\t// The report is the verdict; with --save-jsonl the raw stream is kept\n\t// beside it so a run can be audited after the ephemeral guest is gone\n\t// (which files the inspector read, what it skipped, whether report claims\n\t// trace to actual observations).\n\tconst sink = progressSink(check.name, run.cli.describeStreamLine)\n\tlet onLine = sink\n\tif (opts.saveJsonl) {\n\t\tconst streamPath = join(outDir, `${check.name}.stream.jsonl`)\n\t\tonLine = (kind, line) => {\n\t\t\tif (kind === \"stdout\") appendFileSync(streamPath, `${line}\\n`)\n\t\t\tsink(kind, line)\n\t\t}\n\t}\n\tconst outcome = await runAgent({\n\t\tmount: opts.target,\n\t\tworkdir,\n\t\tspec,\n\t\tnetwork: \"all\",\n\t\tonLine,\n\t})\n\tconst reportPath = join(outDir, `${check.name}.md`)\n\tif (outcome.ok) {\n\t\twriteFileSync(reportPath, outcome.report)\n\t\tprocess.stderr.write(`[${check.name}] report: ${reportPath}\\n`)\n\t\treturn true\n\t}\n\twriteFileSync(reportPath, failureReport(outcome.reason, outcome.partialReport))\n\tprocess.stderr.write(`[${check.name}] FAILED (${outcome.reason}): ${reportPath}\\n`)\n\treturn false\n}\n\n// The check workflow: one sandboxed agent per check, at most `parallel`\n// guests at once. Returns true only when every check produced a report; agent\n// failures still write a failure-record report and flip the run to false.\nexport async function runChecks(opts: CheckWorkflowOpts): Promise<boolean> {\n\tconst run = resolveAgentRun(opts.agent, opts.model, \"check\")\n\tconst checks = discoverChecks(opts.checksDirs, opts.only)\n\tlet runContext: string | null = null\n\tif (opts.contextFile) {\n\t\ttry {\n\t\t\trunContext = readFileSync(opts.contextFile, \"utf-8\")\n\t\t} catch (e) {\n\t\t\tthrow new Error(\n\t\t\t\t`--context file not readable: ${opts.contextFile} (${String(e)})`,\n\t\t\t)\n\t\t}\n\t}\n\tconst outDir = join(opts.output, runTimestamp(new Date()))\n\tmkdirSync(outDir, { recursive: true })\n\tprocess.stderr.write(\n\t\t`${checks.length} check(s) against ${opts.target} (agent ${run.cli.name}, model ${run.model}, parallel ${opts.parallel})\\n`,\n\t)\n\tconst queue = new PQueue({ concurrency: opts.parallel })\n\tconst results = await Promise.all(\n\t\tchecks.map((check) =>\n\t\t\tqueue.add(() => runOneCheck(check, opts, run, runContext, outDir)),\n\t\t),\n\t)\n\treturn results.every((ok) => ok === true)\n}\n","// Claude Code transcript (.jsonl) → the genuine human turns → a flat digest.\n// Port of the June-2026 jq extraction, verified against the same corpus: a\n// \"genuine human turn\" is type:user, not meta, not sidechain, text content\n// only — which excludes the three things that are also type:user in the JSONL\n// (tool_results, slash-command stdout wrappers, injected system-reminders).\n\n// Per-turn char cap in the digest; the mining agent greps the source jsonl\n// for full text when it needs context around a turn.\nconst TURN_CHAR_CAP = 2000\n\ninterface RawLine {\n\ttype?: string\n\tisMeta?: boolean\n\tisSidechain?: boolean\n\tmessage?: { content?: unknown }\n}\n\nconst NON_HUMAN_TEXT =\n\t/^\\s*<command-name>|<local-command-stdout>|^\\s*<local-command|^\\s*<system-reminder>|Caveat: The messages below/\n\n// Throws on an unparseable line — the caller decides what an unreadable\n// transcript means for its run (mine counts and reports them, visibly).\nexport function humanTurns(jsonl: string): string[] {\n\tconst turns: string[] = []\n\tfor (const line of jsonl.split(\"\\n\")) {\n\t\tif (!line.trim()) continue\n\t\tconst raw = JSON.parse(line) as RawLine\n\t\tif (raw.type !== \"user\" || raw.isMeta || raw.isSidechain) continue\n\t\tconst content = raw.message?.content\n\t\tconst text =\n\t\t\ttypeof content === \"string\"\n\t\t\t\t? content\n\t\t\t\t: Array.isArray(content)\n\t\t\t\t\t? content\n\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t(item): item is { type: \"text\"; text: string } =>\n\t\t\t\t\t\t\t\t\ttypeof item === \"object\" &&\n\t\t\t\t\t\t\t\t\titem !== null &&\n\t\t\t\t\t\t\t\t\t(item as { type?: string }).type === \"text\" &&\n\t\t\t\t\t\t\t\t\ttypeof (item as { text?: unknown }).text === \"string\",\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.map((item) => item.text)\n\t\t\t\t\t\t\t.join(\"\\n\")\n\t\t\t\t\t: \"\"\n\t\tif (!text) continue\n\t\tif (NON_HUMAN_TEXT.test(text)) continue\n\t\tturns.push(text.replace(/[\\n\\r]+/g, \" ⏎ \").slice(0, TURN_CHAR_CAP))\n\t}\n\treturn turns\n}\n\nexport interface DigestMeta {\n\tsource: string\n\tproject: string\n\tsession: string\n}\n\nexport function renderDigest(meta: DigestMeta, turns: string[]): string {\n\tconst numbered = turns\n\t\t.map((t, i) => `${String(i + 1).padStart(3, \" \")} | ${t}`)\n\t\t.join(\"\\n\")\n\treturn `# source: ${meta.source}\n# project: ${meta.project}\n# session: ${meta.session}\n# human_turns: ${turns.length}\n# To understand WHY a terse turn or interruption happened, grep its text in the\n# source file above and read the assistant turn(s) immediately before it.\n\n${numbered}\n`\n}\n","import { createHash } from \"node:crypto\"\nimport { existsSync, readdirSync, readFileSync, statSync } from \"node:fs\"\nimport { basename, join } from \"node:path\"\nimport { humanTurns, renderDigest } from \"./transcript.ts\"\n\n// One minable unit = one top-level transcript $PROJECTS/<project>/<session>.jsonl.\n// Its catalog home mirrors that path: $CATALOG/<project>/<session>/observations.md.\nexport interface Unit {\n\tproject: string\n\tsession: string\n\tjsonlPath: string\n}\n\nexport function enumerateUnits(projectsDir: string): Unit[] {\n\tlet projects: string[]\n\ttry {\n\t\tprojects = readdirSync(projectsDir).sort()\n\t} catch {\n\t\tthrow new Error(`no transcripts directory at ${projectsDir}`)\n\t}\n\tconst units: Unit[] = []\n\tfor (const project of projects) {\n\t\tconst dir = join(projectsDir, project)\n\t\tif (!statSync(dir).isDirectory()) continue\n\t\tfor (const f of readdirSync(dir).sort()) {\n\t\t\tif (!f.endsWith(\".jsonl\")) continue\n\t\t\tunits.push({\n\t\t\t\tproject,\n\t\t\t\tsession: basename(f, \".jsonl\"),\n\t\t\t\tjsonlPath: join(dir, f),\n\t\t\t})\n\t\t}\n\t}\n\treturn units\n}\n\nexport function observationsPath(catalogDir: string, unit: Unit): string {\n\treturn join(catalogDir, unit.project, unit.session, \"observations.md\")\n}\n\nexport type UnitStatus =\n\t// hash matches the recorded source_sha256 — skipped without parsing\n\t| { kind: \"mined\" }\n\t| { kind: \"below-threshold\"; turns: number }\n\t| {\n\t\t\tkind: \"pending\"\n\t\t\treason: \"new\" | \"changed\"\n\t\t\tturns: number\n\t\t\tdigest: string\n\t\t\tsourceSha256: string\n\t }\n\t// transcript has an unparseable line; reported visibly, never mined\n\t| { kind: \"unreadable\"; error: string }\n\n// Pure decision core: everything already read, nothing left but judgment.\nexport function decideUnitStatus(input: {\n\tunit: Unit\n\tjsonl: Buffer\n\trecordedSha256: string | null\n\tminTurns: number\n}): UnitStatus {\n\tconst sourceSha256 = createHash(\"sha256\").update(input.jsonl).digest(\"hex\")\n\tif (input.recordedSha256 === sourceSha256) return { kind: \"mined\" }\n\tlet turns: string[]\n\ttry {\n\t\tturns = humanTurns(input.jsonl.toString(\"utf-8\"))\n\t} catch (e) {\n\t\treturn { kind: \"unreadable\", error: String(e) }\n\t}\n\tif (turns.length < input.minTurns)\n\t\treturn { kind: \"below-threshold\", turns: turns.length }\n\treturn {\n\t\tkind: \"pending\",\n\t\treason: input.recordedSha256 === null ? \"new\" : \"changed\",\n\t\tturns: turns.length,\n\t\tdigest: renderDigest(\n\t\t\t{\n\t\t\t\tsource: input.unit.jsonlPath,\n\t\t\t\tproject: input.unit.project,\n\t\t\t\tsession: input.unit.session,\n\t\t\t},\n\t\t\tturns,\n\t\t),\n\t\tsourceSha256,\n\t}\n}\n\n// Shell: read the unit's inputs, then decide purely.\nexport function unitStatus(unit: Unit, catalogDir: string, minTurns: number): UnitStatus {\n\tconst obsPath = observationsPath(catalogDir, unit)\n\treturn decideUnitStatus({\n\t\tunit,\n\t\tjsonl: readFileSync(unit.jsonlPath),\n\t\trecordedSha256: existsSync(obsPath)\n\t\t\t? readSourceSha256(readFileSync(obsPath, \"utf-8\"))\n\t\t\t: null,\n\t\tminTurns,\n\t})\n}\n\nexport interface ObservationsMeta {\n\tsource: string\n\tsourceSha256: string\n\tminedAt: string\n\tmodel: string\n\thumanTurns: number\n}\n\n// The host composes the final file: frontmatter it alone can vouch for, then\n// the agent's report verbatim.\nexport function composeObservationsFile(meta: ObservationsMeta, body: string): string {\n\treturn `---\nsource: ${meta.source}\nsource_sha256: ${meta.sourceSha256}\nmined_at: ${meta.minedAt}\nmodel: ${meta.model}\nhuman_turns: ${meta.humanTurns}\n---\n\n${body.trimEnd()}\n`\n}\n\nexport function readSourceSha256(observationsMd: string): string | null {\n\treturn observationsMd.match(/^source_sha256: ([0-9a-f]{64})$/m)?.[1] ?? null\n}\n","import { mkdirSync, mkdtempSync, writeFileSync } from \"node:fs\"\nimport { tmpdir } from \"node:os\"\nimport { dirname, join } from \"node:path\"\nimport PQueue from \"p-queue\"\nimport {\n\ttype AgentRun,\n\tprogressSink,\n\tresolveAgentCli,\n\tresolveAgentRun,\n} from \"./agent-cli.ts\"\nimport {\n\tcomposeObservationsFile,\n\tenumerateUnits,\n\tobservationsPath,\n\ttype Unit,\n\ttype UnitStatus,\n\tunitStatus,\n} from \"./catalog.ts\"\nimport { composeMinePrompt, PROMPT_FILE } from \"./contract.ts\"\nimport { runAgent } from \"./runner.ts\"\n\nexport interface MineOpts {\n\tprojects: string\n\tcatalog: string\n\tagent: string\n\t// Absent = the agent CLI's default for mining.\n\tmodel?: string\n\tparallel: number\n\tminTurns: number\n\tlimit?: number\n\tdryRun: boolean\n}\n\nexport interface Pending {\n\tunit: Unit\n\tstatus: Extract<UnitStatus, { kind: \"pending\" }>\n}\n\n// What one mine invocation will and won't do, decided purely from the\n// per-unit statuses.\nexport interface MinePlan {\n\ttodo: Pending[]\n\tpendingTotal: number\n\tmined: number\n\tbelowThreshold: number\n\tunreadable: { unit: Unit; error: string }[]\n}\n\nexport function planMine(\n\tentries: { unit: Unit; status: UnitStatus }[],\n\tlimit?: number,\n): MinePlan {\n\tconst pending = entries.filter((e): e is Pending => e.status.kind === \"pending\")\n\treturn {\n\t\ttodo: limit ? pending.slice(0, limit) : pending,\n\t\tpendingTotal: pending.length,\n\t\tmined: entries.filter((e) => e.status.kind === \"mined\").length,\n\t\tbelowThreshold: entries.filter((e) => e.status.kind === \"below-threshold\").length,\n\t\tunreadable: entries.flatMap((e) =>\n\t\t\te.status.kind === \"unreadable\"\n\t\t\t\t? [{ unit: e.unit, error: e.status.error }]\n\t\t\t\t: [],\n\t\t),\n\t}\n}\n\nexport function summarizeMinePlan(plan: MinePlan, minTurns: number): string {\n\tconst total =\n\t\tplan.pendingTotal + plan.mined + plan.belowThreshold + plan.unreadable.length\n\tconst limited =\n\t\tplan.todo.length !== plan.pendingTotal ? ` (mining ${plan.todo.length})` : \"\"\n\treturn `${total} transcripts: ${plan.pendingTotal} pending${limited}, ${plan.mined} mined, ${plan.belowThreshold} below ${minTurns} turns, ${plan.unreadable.length} unreadable`\n}\n\nexport function dryRunRow({ unit, status }: Pending): string {\n\treturn `${status.reason.padEnd(7)} ${status.turns.toString().padStart(4)} turns ${unit.project}/${unit.session}`\n}\n\nasync function mineOneUnit(\n\t{ unit, status }: Pending,\n\topts: MineOpts,\n\trun: AgentRun,\n): Promise<boolean> {\n\tconst tag = unit.session.slice(0, 8)\n\tconst workdir = mkdtempSync(join(tmpdir(), `doublecheck-mine-${tag}-`))\n\twriteFileSync(\n\t\tjoin(workdir, PROMPT_FILE),\n\t\tcomposeMinePrompt(status.digest, workdir, run.cli.writeToolPhrase),\n\t)\n\tconst spec = run.cli.agent({\n\t\tcredentials: run.credentials,\n\t\tmodel: run.model,\n\t\tworkdir,\n\t})\n\tprocess.stderr.write(\n\t\t`[${tag}] mining ${unit.project}/${unit.session} (${status.turns} turns, ${status.reason})\\n`,\n\t)\n\tconst outcome = await runAgent({\n\t\tmount: opts.projects,\n\t\tworkdir,\n\t\tspec,\n\t\tnetwork: { onlyDomains: run.cli.egressDomains },\n\t\tonLine: progressSink(tag, run.cli.describeStreamLine),\n\t})\n\t// A failed mine writes NOTHING — the catalog is a durable asset; the next\n\t// run retries this unit because no hash gets recorded.\n\tif (!outcome.ok) {\n\t\tprocess.stderr.write(`[${tag}] FAILED (${outcome.reason})\\n`)\n\t\treturn false\n\t}\n\tconst obsPath = observationsPath(opts.catalog, unit)\n\tmkdirSync(dirname(obsPath), { recursive: true })\n\twriteFileSync(\n\t\tobsPath,\n\t\tcomposeObservationsFile(\n\t\t\t{\n\t\t\t\tsource: unit.jsonlPath,\n\t\t\t\tsourceSha256: status.sourceSha256,\n\t\t\t\tminedAt: new Date().toISOString(),\n\t\t\t\tmodel: run.model,\n\t\t\t\thumanTurns: status.turns,\n\t\t\t},\n\t\t\toutcome.report,\n\t\t),\n\t)\n\tprocess.stderr.write(`[${tag}] observations: ${obsPath}\\n`)\n\treturn true\n}\n\n// The mine workflow shell: gather statuses (I/O), plan purely, then either\n// print the plan (dry-run) or run one sandboxed agent per pending unit.\n// Returns true when nothing it attempted failed.\nexport async function runMine(opts: MineOpts): Promise<boolean> {\n\t// Validate the agent name before the dry-run/nothing-pending short-circuits\n\t// so a bad --agent errors on every invocation; the credentials preflight\n\t// stays below them (a dry run must not require credentials).\n\tresolveAgentCli(opts.agent)\n\tconst entries = enumerateUnits(opts.projects).map((unit) => ({\n\t\tunit,\n\t\tstatus: unitStatus(unit, opts.catalog, opts.minTurns),\n\t}))\n\tconst plan = planMine(entries, opts.limit)\n\tfor (const { unit, error } of plan.unreadable) {\n\t\tprocess.stderr.write(`UNREADABLE ${unit.project}/${unit.session}: ${error}\\n`)\n\t}\n\tprocess.stderr.write(`${summarizeMinePlan(plan, opts.minTurns)}\\n`)\n\n\tif (opts.dryRun) {\n\t\tfor (const pending of plan.todo) console.log(dryRunRow(pending))\n\t\treturn true\n\t}\n\tif (plan.todo.length === 0) return true\n\n\tconst run = resolveAgentRun(opts.agent, opts.model, \"mine\")\n\tconst queue = new PQueue({ concurrency: opts.parallel })\n\tconst results = await Promise.all(\n\t\tplan.todo.map((p) => queue.add(() => mineOneUnit(p, opts, run))),\n\t)\n\tconst failed = results.filter((ok) => ok !== true).length\n\tprocess.stderr.write(\n\t\t`mined ${results.length - failed}/${results.length}${failed ? `, ${failed} FAILED` : \"\"}\\n`,\n\t)\n\treturn failed === 0\n}\n","#!/usr/bin/env node\nimport { homedir } from \"node:os\"\nimport { join, resolve } from \"node:path\"\nimport { Command } from \"commander\"\nimport { runChecks } from \"./check.ts\"\nimport { runMine } from \"./mine.ts\"\n\nfunction parsePositiveInt(flag: string) {\n\treturn (v: string): number => {\n\t\tconst n = Number.parseInt(v, 10)\n\t\tif (!Number.isInteger(n) || n < 1)\n\t\t\tthrow new Error(`${flag} must be a positive integer, got \"${v}\"`)\n\t\treturn n\n\t}\n}\n\nconst collect = (v: string, prev: string[]): string[] => [...prev, v]\n\nconst program = new Command()\n\t.name(\"doublecheck\")\n\t.description(\n\t\t\"Run self-authored LLM code-inspectors (checks) against a target tree, one sandboxed agent per check\",\n\t)\n\nprogram\n\t.command(\"check\")\n\t.option(\"--target <dir>\", \"tree under inspection, mounted read-only\", process.cwd())\n\t.option(\n\t\t\"--checks-dir <dir>\",\n\t\t\"checks directory (repeatable; default: $TARGET/.agents/checks)\",\n\t\tcollect,\n\t\t[] as string[],\n\t)\n\t.option(\n\t\t\"--context <file>\",\n\t\t\"run-context file spliced into every inspector's prompt (intent, nuances, sanctioned exceptions, scope)\",\n\t)\n\t.option(\n\t\t\"--agent <name>\",\n\t\t\"agent CLI that runs the inspectors: claude or codex\",\n\t\t\"claude\",\n\t)\n\t.option(\n\t\t\"--model <model>\",\n\t\t\"model for the inspector agents (default per agent: claude haiku, codex gpt-5.5)\",\n\t)\n\t.option(\"--parallel <n>\", \"max concurrent checks\", parsePositiveInt(\"--parallel\"), 4)\n\t.option(\"--output <dir>\", \"reports root (default: $TARGET/.doublecheck)\")\n\t.option(\"--check <name>\", \"run only this check (repeatable)\", collect, [] as string[])\n\t.option(\n\t\t\"--save-jsonl\",\n\t\t\"persist each inspector's raw stream-json beside its report (audit trail)\",\n\t)\n\t.action(async (opts) => {\n\t\tconst target = resolve(opts.target)\n\t\tconst checksDirs: string[] =\n\t\t\topts.checksDir.length > 0\n\t\t\t\t? opts.checksDir.map((d: string) => resolve(d))\n\t\t\t\t: [join(target, \".agents\", \"checks\")]\n\t\tconst ok = await runChecks({\n\t\t\ttarget,\n\t\t\tchecksDirs,\n\t\t\tcontextFile: opts.context ? resolve(opts.context) : null,\n\t\t\tagent: opts.agent,\n\t\t\tmodel: opts.model,\n\t\t\tparallel: opts.parallel,\n\t\t\toutput: opts.output ? resolve(opts.output) : join(target, \".doublecheck\"),\n\t\t\tonly: opts.check,\n\t\t\tsaveJsonl: !!opts.saveJsonl,\n\t\t})\n\t\tif (!ok) process.exitCode = 1\n\t})\n\nprogram\n\t.command(\"mine\")\n\t.option(\n\t\t\"--projects <dir>\",\n\t\t\"Claude Code transcripts root\",\n\t\tjoin(homedir(), \".claude\", \"projects\"),\n\t)\n\t.option(\n\t\t\"--catalog <dir>\",\n\t\t\"observation catalog root\",\n\t\tjoin(homedir(), \".doublecheck\", \"catalog\"),\n\t)\n\t.option(\"--agent <name>\", \"agent CLI that runs the miners: claude or codex\", \"claude\")\n\t.option(\n\t\t\"--model <model>\",\n\t\t\"model for the mining agents (default per agent: claude opus, codex gpt-5.5 — a bad-model mine pollutes a durable asset)\",\n\t)\n\t.option(\"--parallel <n>\", \"max concurrent miners\", parsePositiveInt(\"--parallel\"), 4)\n\t.option(\n\t\t\"--min-turns <n>\",\n\t\t\"min genuine human turns for a real conversation\",\n\t\tparsePositiveInt(\"--min-turns\"),\n\t\t2,\n\t)\n\t.option(\"--limit <n>\", \"mine at most N pending units\", parsePositiveInt(\"--limit\"))\n\t.option(\"--dry-run\", \"list what would be mined without booting anything\")\n\t.action(async (opts) => {\n\t\tconst ok = await runMine({\n\t\t\tprojects: resolve(opts.projects),\n\t\t\tcatalog: resolve(opts.catalog),\n\t\t\tagent: opts.agent,\n\t\t\tmodel: opts.model,\n\t\t\tparallel: opts.parallel,\n\t\t\tminTurns: opts.minTurns,\n\t\t\tlimit: opts.limit,\n\t\t\tdryRun: !!opts.dryRun,\n\t\t})\n\t\tif (!ok) process.exitCode = 1\n\t})\n\nprogram.parseAsync().catch((e: unknown) => {\n\tconsole.error(e instanceof Error ? e.message : String(e))\n\tprocess.exit(1)\n})\n"],"mappings":";;;;;;;;;AAQA,MAAa,cAAc;AAG3B,MAAa,cAAc;AAU3B,SAAS,eACR,UACA,aACA,SACA,WACS;CACT,MAAM,OAAO,YAAY,IAAI,cAAc;CAC3C,OAAO;;6EAEqE,QAAQ,GAAG,YAAY,iKAAiK,YAAY;;eAElQ,QAAQ,GAAG,YAAY,IAAI,KAAK,oBAAoB,SAAS,uGAAuG,YAAY;AAC/L;AAEA,SAAS,gBAAgB,SAAiB,WAAkC;CAC3E,MAAM,OAAO,YAAY,IAAI,cAAc;CAC3C,OAAO,qDAAqD,QAAQ,GAAG,YAAY,IAAI,KAAK;AAC7F;AAMA,SAAgB,cAAc,MAMnB;CACV,MAAM,iBAAiB,KAAK,aACzB;;;;EAIF,KAAK,WAAW;;;;IAKd;CACH,OAAO;;;;wDAIgD,KAAK,OAAO;;sEAEE,KAAK,QAAQ;;EAEjF,gBAAgB,KAAK,SAAS,KAAK,SAAS,EAAE;;;;;;;;;;;;EAY9C,iBAAiB,KAAK,UAAU;;;;EAIhC,eAAe,cAAc,sBAAsB,KAAK,SAAS,KAAK,SAAS,EAAE;;;AAGnF;AAIA,SAAgB,kBACf,QACA,SACA,WACS;CACT,OAAO;;wNAEgN,QAAQ;;EAE9N,gBAAgB,SAAS,SAAS,EAAE;;;;;;;;;;EAUpC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCP,eAAe,UAAU,0BAA0B,SAAS,SAAS;AACvE;;;;AChJA,MAAMA,eAAa;AAGnB,SAAgB,YAAY,MAId;CACb,OAAO;EAKN,SACC,4KAUoE;EACrE,KAAK;GACJ,MA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AAC;CACxD,QAAQ,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alizain/doublecheck",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Run self-authored LLM code-inspectors against a project — one sandboxed microVM agent per check, one markdown report each",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "pnpm@11.5.1",
|