@cchistory/lite 0.5.0 → 0.7.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.
Files changed (190) hide show
  1. package/INSTALL.md +1 -1
  2. package/apps/lite-cli/dist/agent-contract.d.ts +5 -2
  3. package/apps/lite-cli/dist/agent-contract.d.ts.map +1 -1
  4. package/apps/lite-cli/dist/agent-contract.js +20 -9
  5. package/apps/lite-cli/dist/agent-contract.js.map +1 -1
  6. package/apps/lite-cli/dist/agent-journeys.test.d.ts +2 -0
  7. package/apps/lite-cli/dist/agent-journeys.test.d.ts.map +1 -0
  8. package/apps/lite-cli/dist/agent-journeys.test.js +403 -0
  9. package/apps/lite-cli/dist/agent-journeys.test.js.map +1 -0
  10. package/apps/lite-cli/dist/bin.js +3 -3
  11. package/apps/lite-cli/dist/bin.js.map +1 -1
  12. package/apps/lite-cli/dist/index.d.ts.map +1 -1
  13. package/apps/lite-cli/dist/index.js +55 -13
  14. package/apps/lite-cli/dist/index.js.map +1 -1
  15. package/apps/lite-cli/dist/index.test.js +34 -69
  16. package/apps/lite-cli/dist/index.test.js.map +1 -1
  17. package/apps/lite-cli/dist/query.d.ts +15 -2
  18. package/apps/lite-cli/dist/query.d.ts.map +1 -1
  19. package/apps/lite-cli/dist/query.js +79 -4
  20. package/apps/lite-cli/dist/query.js.map +1 -1
  21. package/apps/lite-cli/dist/shell.d.ts +2 -1
  22. package/apps/lite-cli/dist/shell.d.ts.map +1 -1
  23. package/apps/lite-cli/dist/shell.js +20 -16
  24. package/apps/lite-cli/dist/shell.js.map +1 -1
  25. package/apps/lite-cli/dist/version.d.ts +1 -1
  26. package/apps/lite-cli/dist/version.js +1 -1
  27. package/apps/lite-tui/dist/bin.js +3 -3
  28. package/apps/lite-tui/dist/bin.js.map +1 -1
  29. package/apps/lite-tui/dist/index.d.ts.map +1 -1
  30. package/apps/lite-tui/dist/index.js +4 -0
  31. package/apps/lite-tui/dist/index.js.map +1 -1
  32. package/apps/lite-tui/dist/index.test.js +5 -5
  33. package/apps/lite-tui/dist/index.test.js.map +1 -1
  34. package/apps/lite-tui/dist/model.d.ts.map +1 -1
  35. package/apps/lite-tui/dist/model.js +2 -1
  36. package/apps/lite-tui/dist/model.js.map +1 -1
  37. package/apps/lite-tui/dist/render.d.ts +1 -1
  38. package/apps/lite-tui/dist/version.d.ts +1 -1
  39. package/apps/lite-tui/dist/version.js +1 -1
  40. package/bin/cchistory-lite-tui.mjs +3 -3
  41. package/bin/cchistory-lite.mjs +3 -3
  42. package/docs/guide/agent-evidence.md +154 -0
  43. package/docs/guide/for-agents.md +45 -25
  44. package/docs/guide/lite.md +16 -4
  45. package/docs/guide/query.md +11 -2
  46. package/node_modules/@cchistory/canonical/dist/conversation-evidence.d.ts +85 -0
  47. package/node_modules/@cchistory/canonical/dist/conversation-evidence.d.ts.map +1 -0
  48. package/node_modules/@cchistory/canonical/dist/conversation-evidence.js +191 -0
  49. package/node_modules/@cchistory/canonical/dist/conversation-evidence.js.map +1 -0
  50. package/node_modules/@cchistory/canonical/dist/conversation-evidence.test.d.ts +2 -0
  51. package/node_modules/@cchistory/canonical/dist/conversation-evidence.test.d.ts.map +1 -0
  52. package/node_modules/@cchistory/canonical/dist/conversation-evidence.test.js +105 -0
  53. package/node_modules/@cchistory/canonical/dist/conversation-evidence.test.js.map +1 -0
  54. package/node_modules/@cchistory/canonical/dist/index.d.ts +2 -0
  55. package/node_modules/@cchistory/canonical/dist/index.d.ts.map +1 -1
  56. package/node_modules/@cchistory/canonical/dist/index.js +2 -0
  57. package/node_modules/@cchistory/canonical/dist/index.js.map +1 -1
  58. package/node_modules/@cchistory/canonical/dist/projection-audit.d.ts +4 -3
  59. package/node_modules/@cchistory/canonical/dist/projection-audit.d.ts.map +1 -1
  60. package/node_modules/@cchistory/canonical/dist/projection-audit.js +14 -0
  61. package/node_modules/@cchistory/canonical/dist/projection-audit.js.map +1 -1
  62. package/node_modules/@cchistory/canonical/dist/read-status.d.ts +11 -0
  63. package/node_modules/@cchistory/canonical/dist/read-status.d.ts.map +1 -0
  64. package/node_modules/@cchistory/canonical/dist/read-status.js +14 -0
  65. package/node_modules/@cchistory/canonical/dist/read-status.js.map +1 -0
  66. package/node_modules/@cchistory/canonical/dist/session-family.js +1 -1
  67. package/node_modules/@cchistory/canonical/dist/session-family.js.map +1 -1
  68. package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts +7 -3
  69. package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts.map +1 -1
  70. package/node_modules/@cchistory/canonical/dist/session-interpreter.js +15 -13
  71. package/node_modules/@cchistory/canonical/dist/session-interpreter.js.map +1 -1
  72. package/node_modules/@cchistory/canonical/package.json +1 -1
  73. package/node_modules/@cchistory/domain/dist/conversation-evidence.d.ts +24 -0
  74. package/node_modules/@cchistory/domain/dist/conversation-evidence.d.ts.map +1 -0
  75. package/node_modules/@cchistory/domain/dist/conversation-evidence.js +2 -0
  76. package/node_modules/@cchistory/domain/dist/conversation-evidence.js.map +1 -0
  77. package/node_modules/@cchistory/domain/dist/index.d.ts +5 -0
  78. package/node_modules/@cchistory/domain/dist/index.d.ts.map +1 -1
  79. package/node_modules/@cchistory/domain/dist/index.js.map +1 -1
  80. package/node_modules/@cchistory/domain/package.json +1 -1
  81. package/node_modules/@cchistory/live-runtime/dist/bootstrap.d.ts +1 -0
  82. package/node_modules/@cchistory/live-runtime/dist/bootstrap.d.ts.map +1 -1
  83. package/node_modules/@cchistory/live-runtime/dist/bootstrap.js +1 -0
  84. package/node_modules/@cchistory/live-runtime/dist/bootstrap.js.map +1 -1
  85. package/node_modules/@cchistory/live-runtime/dist/bounded-cache.d.ts +15 -0
  86. package/node_modules/@cchistory/live-runtime/dist/bounded-cache.d.ts.map +1 -0
  87. package/node_modules/@cchistory/live-runtime/dist/bounded-cache.js +44 -0
  88. package/node_modules/@cchistory/live-runtime/dist/bounded-cache.js.map +1 -0
  89. package/node_modules/@cchistory/live-runtime/dist/bounded-cache.test.d.ts +2 -0
  90. package/node_modules/@cchistory/live-runtime/dist/bounded-cache.test.d.ts.map +1 -0
  91. package/node_modules/@cchistory/live-runtime/dist/bounded-cache.test.js +45 -0
  92. package/node_modules/@cchistory/live-runtime/dist/bounded-cache.test.js.map +1 -0
  93. package/node_modules/@cchistory/live-runtime/dist/diagnostics.d.ts +7 -0
  94. package/node_modules/@cchistory/live-runtime/dist/diagnostics.d.ts.map +1 -0
  95. package/node_modules/@cchistory/live-runtime/dist/diagnostics.js +2 -0
  96. package/node_modules/@cchistory/live-runtime/dist/diagnostics.js.map +1 -0
  97. package/node_modules/@cchistory/live-runtime/dist/history-reader.d.ts +24 -0
  98. package/node_modules/@cchistory/live-runtime/dist/history-reader.d.ts.map +1 -0
  99. package/node_modules/@cchistory/live-runtime/dist/history-reader.js +155 -0
  100. package/node_modules/@cchistory/live-runtime/dist/history-reader.js.map +1 -0
  101. package/node_modules/@cchistory/live-runtime/dist/index.d.ts +92 -6
  102. package/node_modules/@cchistory/live-runtime/dist/index.d.ts.map +1 -1
  103. package/node_modules/@cchistory/live-runtime/dist/index.js +249 -70
  104. package/node_modules/@cchistory/live-runtime/dist/index.js.map +1 -1
  105. package/node_modules/@cchistory/live-runtime/dist/index.test.js +6 -1
  106. package/node_modules/@cchistory/live-runtime/dist/index.test.js.map +1 -1
  107. package/node_modules/@cchistory/live-runtime/dist/launcher-memory.d.ts +12 -0
  108. package/node_modules/@cchistory/live-runtime/dist/launcher-memory.d.ts.map +1 -0
  109. package/node_modules/@cchistory/live-runtime/dist/launcher-memory.js +44 -0
  110. package/node_modules/@cchistory/live-runtime/dist/launcher-memory.js.map +1 -0
  111. package/node_modules/@cchistory/live-runtime/dist/launcher-memory.test.d.ts +2 -0
  112. package/node_modules/@cchistory/live-runtime/dist/launcher-memory.test.d.ts.map +1 -0
  113. package/node_modules/@cchistory/live-runtime/dist/launcher-memory.test.js +20 -0
  114. package/node_modules/@cchistory/live-runtime/dist/launcher-memory.test.js.map +1 -0
  115. package/node_modules/@cchistory/live-runtime/dist/live-read-recovery.test.d.ts +2 -0
  116. package/node_modules/@cchistory/live-runtime/dist/live-read-recovery.test.d.ts.map +1 -0
  117. package/node_modules/@cchistory/live-runtime/dist/live-read-recovery.test.js +92 -0
  118. package/node_modules/@cchistory/live-runtime/dist/live-read-recovery.test.js.map +1 -0
  119. package/node_modules/@cchistory/live-runtime/dist/scan-guard.d.ts +1 -0
  120. package/node_modules/@cchistory/live-runtime/dist/scan-guard.d.ts.map +1 -1
  121. package/node_modules/@cchistory/live-runtime/dist/scan-guard.js +7 -13
  122. package/node_modules/@cchistory/live-runtime/dist/scan-guard.js.map +1 -1
  123. package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js +50 -55
  124. package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js.map +1 -1
  125. package/node_modules/@cchistory/live-runtime/dist/selective-query.d.ts +2 -1
  126. package/node_modules/@cchistory/live-runtime/dist/selective-query.d.ts.map +1 -1
  127. package/node_modules/@cchistory/live-runtime/dist/selective-query.js.map +1 -1
  128. package/node_modules/@cchistory/live-runtime/dist/selective-query.test.js +8 -3
  129. package/node_modules/@cchistory/live-runtime/dist/selective-query.test.js.map +1 -1
  130. package/node_modules/@cchistory/live-runtime/dist/system-memory.test.js +3 -3
  131. package/node_modules/@cchistory/live-runtime/dist/system-memory.test.js.map +1 -1
  132. package/node_modules/@cchistory/live-runtime/package.json +1 -1
  133. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.d.ts +3 -0
  134. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.d.ts.map +1 -1
  135. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.js.map +1 -1
  136. package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.d.ts +12 -0
  137. package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.d.ts.map +1 -0
  138. package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.js +32 -0
  139. package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.js.map +1 -0
  140. package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.test.d.ts +2 -0
  141. package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.test.d.ts.map +1 -0
  142. package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.test.js +21 -0
  143. package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.test.js.map +1 -0
  144. package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.js +3 -2
  145. package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.js.map +1 -1
  146. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.d.ts +3 -1
  147. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.d.ts.map +1 -1
  148. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.js +56 -38
  149. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.js.map +1 -1
  150. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.test.js +76 -1
  151. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.test.js.map +1 -1
  152. package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts +16 -5
  153. package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts.map +1 -1
  154. package/node_modules/@cchistory/source-adapters/dist/core/parser.js +136 -76
  155. package/node_modules/@cchistory/source-adapters/dist/core/parser.js.map +1 -1
  156. package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts.map +1 -1
  157. package/node_modules/@cchistory/source-adapters/dist/core/probe.js +75 -54
  158. package/node_modules/@cchistory/source-adapters/dist/core/probe.js.map +1 -1
  159. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.d.ts +4 -1
  160. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.d.ts.map +1 -1
  161. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.js +5 -3
  162. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.js.map +1 -1
  163. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.js +61 -2
  164. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.js.map +1 -1
  165. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts +6 -2
  166. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts.map +1 -1
  167. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js +5 -5
  168. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js.map +1 -1
  169. package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts +4 -1
  170. package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts.map +1 -1
  171. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts +1 -0
  172. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts.map +1 -1
  173. package/node_modules/@cchistory/source-adapters/dist/index.test.js +1 -0
  174. package/node_modules/@cchistory/source-adapters/dist/index.test.js.map +1 -1
  175. package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js +49 -1
  176. package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js.map +1 -1
  177. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts +2 -0
  178. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts.map +1 -1
  179. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js +48 -29
  180. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js.map +1 -1
  181. package/node_modules/@cchistory/source-adapters/package.json +1 -1
  182. package/package.json +5 -5
  183. package/schemas/cchistory-lite-agent-v1.schema.json +8 -5
  184. package/schemas/cchistory-lite-canonical-v1.schema.json +82 -0
  185. package/schemas/cchistory-lite-diagnostic-v1.schema.json +27 -0
  186. package/schemas/cchistory-lite-query-result-v2.schema.json +232 -4
  187. package/schemas/cchistory-lite-query-result-v3.schema.json +45 -1
  188. package/schemas/cchistory-lite-query-v2.schema.json +150 -8
  189. package/schemas/cchistory-lite-v2.schema.json +82 -0
  190. package/skills/using-cchistory-lite/SKILL.md +86 -127
@@ -1,5 +1,5 @@
1
1
  import assert from "node:assert/strict";
2
- import { access, cp, mkdir, mkdtemp, readFile, rm, symlink, writeFile } from "node:fs/promises";
2
+ import { access, mkdir, mkdtemp, readFile, rm, symlink, writeFile } from "node:fs/promises";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
5
  import { PassThrough } from "node:stream";
@@ -935,6 +935,7 @@ test("Lite CLI help documents latest, limits, and directory scope", async () =>
935
935
  assert.match(help, /cchistory-lite help \[command\]/);
936
936
  // store/db appear only in the closing line that documents their absence.
937
937
  const knownFlags = new Set([
938
+ "diagnostics",
938
939
  "source-root",
939
940
  "source",
940
941
  "limit-files",
@@ -956,6 +957,8 @@ test("Lite CLI help documents latest, limits, and directory scope", async () =>
956
957
  "db",
957
958
  ]);
958
959
  const documentedFlags = new Set([...help.matchAll(/--([a-z][a-z-]*)/gu)].map((match) => match[1]));
960
+ assert.match(help, /NODE_OPTIONS='--max-old-space-size=8192'/);
961
+ documentedFlags.delete("max-old-space-size"); // Node option, not a Lite argument.
959
962
  for (const flag of documentedFlags) {
960
963
  assert.ok(knownFlags.has(flag), `help documents unknown option --${flag}`);
961
964
  }
@@ -1239,7 +1242,7 @@ test("Lite shell JSON-lines searches sessions against one snapshot and refreshes
1239
1242
  assert.equal(search?.shown, search?.results.length);
1240
1243
  assert.ok((search?.total ?? 0) >= (search?.shown ?? 0));
1241
1244
  });
1242
- test("Lite shell JSON-lines replies from a line before stdin closes and loads matching context", async () => {
1245
+ test("Lite shell JSON-lines replies before stdin closes and targets the resolved session", async () => {
1243
1246
  const snapshot = await getCodexSnapshot();
1244
1247
  const turn = snapshot.listResolvedTurns().find((entry) => snapshot.getTurnContext(entry.id)?.assistant_replies.length);
1245
1248
  assert.ok(turn);
@@ -1252,7 +1255,7 @@ test("Lite shell JSON-lines replies from a line before stdin closes and loads ma
1252
1255
  stdinIsTTY: false,
1253
1256
  scan: async (options) => {
1254
1257
  scans.push(options);
1255
- return options.contextMode === "matching" ? snapshot : light;
1258
+ return options.contextMode === "full" ? snapshot : light;
1256
1259
  },
1257
1260
  });
1258
1261
  const running = runLiteCli(["shell", "--no-dir"], captured.io);
@@ -1269,8 +1272,7 @@ test("Lite shell JSON-lines replies from a line before stdin closes and loads ma
1269
1272
  stdin.end();
1270
1273
  assert.equal(await running, 0);
1271
1274
  assert.ok(scans.some((options) => options.contextMode === "none"));
1272
- assert.ok(scans.some((options) => options.contextMode === "matching"
1273
- && options.contextTargets?.some((target) => target.kind === "turn" && target.ref === turn.id)));
1275
+ assert.ok(scans.some((options) => options.contextMode === "full" && options.sessionRefs?.includes(turn.session_id)));
1274
1276
  const payloads = captured.stdout.join("").trim().split("\n").map((line) => JSON.parse(line));
1275
1277
  const replies = payloads.find((payload) => payload.operations?.[0]?.result?.turns);
1276
1278
  assert.ok((replies?.operations?.[0]?.result?.turns?.[0]?.assistant_replies?.length ?? 0) > 0);
@@ -1341,67 +1343,19 @@ test("Lite shell JSON-lines keeps the snapshot when refresh fails and uses struc
1341
1343
  const startupError = JSON.parse(startup.stdout.join(""));
1342
1344
  assert.equal(startupError.error.code, "scan_failed");
1343
1345
  });
1344
- test("Lite CLI scan guard refuses a scan whose estimate risks the machine, teaches the bounds, and bends to the kill-switch", async () => {
1345
- const tempHome = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-guard-cli-"));
1346
- const fixtureRoot = path.join(tempHome, "codex-sessions");
1347
- try {
1348
- await cp(codexRoot, fixtureRoot, { recursive: true });
1349
- // Exercise guard-to-surface behavior with a controlled risk estimate. Runtime
1350
- // tests cover adapter selection; unrelated files must not inflate the estimate.
1351
- const guardedIo = () => captureIo(tempHome, undefined, {
1352
- scan: (options) => scanLiteHistory({
1353
- ...options,
1354
- scanGuardDeps: {
1355
- walkRootBytes: async () => options.directoryScope ? 0 : 256 * 1024 ** 3,
1356
- readAvailableBytes: () => 1024 ** 3,
1357
- },
1358
- }),
1359
- });
1360
- const sourceArgs = ["--source-root", `codex=${fixtureRoot}`, "--source", "codex", "--safe"];
1361
- const refused = guardedIo();
1362
- assert.equal(await runLiteCli(["sources", "--complete", ...sourceArgs], refused.io), 1);
1363
- assert.equal(refused.stdout.join(""), "");
1364
- const message = refused.stderr.join("");
1365
- assert.match(message, /Refusing to scan/);
1366
- assert.match(message, /Selected source roots/);
1367
- assert.match(message, /codex/);
1368
- assert.match(message, /this scan has no --dir filter/);
1369
- assert.match(message, /keep the requested scope/);
1370
- assert.match(message, /File count and sample size are not memory bounds/);
1371
- assert.match(message, /sample/);
1372
- assert.match(message, /sources --json/);
1373
- assert.match(message, /shell/);
1374
- assert.match(message, /No complete result/);
1375
- assert.doesNotMatch(message, /CCHISTORY_SCAN_GUARD=0/);
1376
- assert.doesNotMatch(message, /--dir is already on/);
1377
- assert.doesNotMatch(message, /does not shrink source bytes/);
1378
- const scopedLatest = guardedIo();
1379
- assert.equal(await runLiteCli(["latest", "--dir", "/workspace/codex-delegated", ...sourceArgs], scopedLatest.io), 0, scopedLatest.stderr.join(""));
1380
- const defaultDir = guardedIo();
1381
- assert.equal(await runLiteCli(["latest", ...sourceArgs], defaultDir.io), 0, defaultDir.stderr.join(""));
1382
- const refusedJson = guardedIo();
1383
- assert.equal(await runLiteCli(["sources", "--complete", "--json", ...sourceArgs], refusedJson.io), 1);
1384
- assert.equal(refusedJson.stdout.join(""), "");
1385
- const errorPayload = JSON.parse(refusedJson.stderr.join(""));
1386
- assert.equal(errorPayload.schema, "cchistory-lite-error/v1");
1387
- assert.equal(errorPayload.error.code, "scan_guard_refused");
1388
- assert.match(errorPayload.error.message, /Refusing to scan/);
1389
- // Sample/exact probes bypass only the lock; an excessive estimate still refuses.
1390
- const sampled = guardedIo();
1391
- assert.equal(await runLiteCli(["sample", "1", ...sourceArgs, "--no-dir"], sampled.io), 1, sampled.stderr.join(""));
1392
- const shown = guardedIo();
1393
- assert.equal(await runLiteCli(["show", "session", "sess:codex:019ce4fd-8290-7501-afc4-0e9486733614", ...sourceArgs], shown.io), 1, shown.stderr.join(""));
1394
- process.env.CCHISTORY_SCAN_GUARD = "0";
1395
- try {
1396
- const allowed = guardedIo();
1397
- assert.equal(await runLiteCli(["sources", "--complete", ...sourceArgs], allowed.io), 0, allowed.stderr.join(""));
1398
- }
1399
- finally {
1400
- delete process.env.CCHISTORY_SCAN_GUARD;
1401
- }
1402
- }
1403
- finally {
1404
- await rm(tempHome, { recursive: true, force: true });
1346
+ test("Lite CLI warns on large aggregate estimates while returning readable history", async () => {
1347
+ const ioForScan = () => captureIo(repoRoot, undefined, {
1348
+ scan: options => scanLiteHistory({ ...options, scanGuardDeps: {
1349
+ walkRootBytes: async () => 256 * 1024 ** 3, readAvailableBytes: () => 1024 ** 3,
1350
+ } }),
1351
+ });
1352
+ const sourceArgs = ["--source-root", `codex=${codexRoot}`, "--source", "codex", "--safe"];
1353
+ for (const args of [["sources", "--complete"], ["sources", "--complete", "--json"], ["sample", "1", "--no-dir"]]) {
1354
+ const captured = ioForScan();
1355
+ assert.equal(await runLiteCli([...args, ...sourceArgs], captured.io), 0, captured.stderr.join(""));
1356
+ assert.ok(captured.stdout.join("").length > 0);
1357
+ assert.match(captured.stderr.join(""), /Scan guard warning:.*proceeding/);
1358
+ assert.doesNotMatch(captured.stderr.join(""), /Refusing to scan/);
1405
1359
  }
1406
1360
  });
1407
1361
  test("Lite CLI maps scan guard refusals and aborts to exit 1 with distinct structured codes", async () => {
@@ -1533,11 +1487,12 @@ test("Lite CLI agent prints the machine-readable contract without scanning", asy
1533
1487
  assert.equal(guard.watchdog_floor.initial_available_fraction, SCAN_WATCHDOG_AVAILABLE_RESERVE_FRACTION);
1534
1488
  assert.deepEqual(guard.kill_switch, { env: "CCHISTORY_SCAN_GUARD", value: "0" });
1535
1489
  assert.deepEqual([...guard.error_codes].sort(), ["read_budget_exceeded", "scan_guard_aborted", "scan_guard_refused"]);
1536
- assert.equal(contract.cost_model.heap_ceiling.policy, "node_default_or_explicit");
1537
- assert.equal(contract.cost_model.heap_ceiling.automatic_reexec, false);
1490
+ assert.equal(contract.cost_model.heap_ceiling.policy, "adaptive_default_or_explicit");
1491
+ assert.equal(contract.cost_model.heap_ceiling.automatic_reexec, true);
1538
1492
  assert.equal(contract.trust_model.content_trust, "untrusted_history");
1539
1493
  const schemaIds = contract.output_schemas.map((entry) => entry.id);
1540
1494
  for (const id of [
1495
+ "cchistory-lite-diagnostic/v1",
1541
1496
  "cchistory-lite/v2",
1542
1497
  "cchistory-lite-canonical/v1",
1543
1498
  "cchistory-lite-query/v2",
@@ -1566,6 +1521,16 @@ test("Lite CLI agent contract satisfies its shipped JSON schema structurally", a
1566
1521
  }
1567
1522
  assert.equal(contract.schema, schema.properties.schema.const);
1568
1523
  assert.equal(contract.kind, schema.properties.kind.const);
1524
+ const heap = contract.cost_model.heap_ceiling;
1525
+ const heapSchema = schema.properties.cost_model.properties.heap_ceiling.properties;
1526
+ assert.equal(heap.policy, heapSchema.policy.const);
1527
+ assert.equal(heap.automatic_reexec, heapSchema.automatic_reexec.const);
1528
+ const guard = contract.cost_model.scan_guard;
1529
+ const guardSchema = schema.properties.cost_model.properties.scan_guard.properties;
1530
+ assert.deepEqual(Object.keys(guard).sort(), Object.keys(guardSchema).sort());
1531
+ assert.equal(guard.estimate_policy, guardSchema.estimate_policy.const);
1532
+ assert.equal(guard.read_budget_policy, guardSchema.read_budget_policy.const);
1533
+ assert.deepEqual(Object.keys(guard.watchdog_floor).sort(), Object.keys(guardSchema.watchdog_floor.properties).sort());
1569
1534
  const commands = contract.commands;
1570
1535
  assert.deepEqual(Object.keys(commands).sort(), [...schema.properties.commands.required].sort());
1571
1536
  for (const [name, command] of Object.entries(commands)) {
@@ -1602,7 +1567,7 @@ test("Lite CLI agent contract flags match the parser in both directions", async
1602
1567
  const parserFlags = [
1603
1568
  "--source-root", "--source", "--limit-files", "--limit", "--offset", "--project", "--by",
1604
1569
  "--format", "--out", "--dir", "--request", "--safe", "--json", "--all", "--no-dir",
1605
- "--help", "--version", "--sql", "--sql-file", "--params", "--complete", "--idle-timeout",
1570
+ "--help", "--version", "--sql", "--sql-file", "--params", "--complete", "--idle-timeout", "--diagnostics",
1606
1571
  ];
1607
1572
  assert.deepEqual([...universe].sort(), [...parserFlags].sort());
1608
1573
  const tails = {