@cchistory/lite 0.4.5 → 0.6.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/INSTALL.md +1 -1
- package/apps/lite-cli/dist/agent-contract.d.ts +7 -5
- package/apps/lite-cli/dist/agent-contract.d.ts.map +1 -1
- package/apps/lite-cli/dist/agent-contract.js +36 -25
- package/apps/lite-cli/dist/agent-contract.js.map +1 -1
- package/apps/lite-cli/dist/bin.js +2 -2
- package/apps/lite-cli/dist/bin.js.map +1 -1
- package/apps/lite-cli/dist/index.d.ts.map +1 -1
- package/apps/lite-cli/dist/index.js +151 -66
- package/apps/lite-cli/dist/index.js.map +1 -1
- package/apps/lite-cli/dist/index.test.js +59 -89
- package/apps/lite-cli/dist/index.test.js.map +1 -1
- package/apps/lite-cli/dist/query.d.ts +4 -1
- package/apps/lite-cli/dist/query.d.ts.map +1 -1
- package/apps/lite-cli/dist/query.js +45 -29
- package/apps/lite-cli/dist/query.js.map +1 -1
- package/apps/lite-cli/dist/resource-errors.d.ts +3 -0
- package/apps/lite-cli/dist/resource-errors.d.ts.map +1 -0
- package/apps/lite-cli/dist/resource-errors.js +17 -0
- package/apps/lite-cli/dist/resource-errors.js.map +1 -0
- package/apps/lite-cli/dist/shell.d.ts +12 -2
- package/apps/lite-cli/dist/shell.d.ts.map +1 -1
- package/apps/lite-cli/dist/shell.js +129 -57
- package/apps/lite-cli/dist/shell.js.map +1 -1
- package/apps/lite-cli/dist/sql-query.test.d.ts +2 -0
- package/apps/lite-cli/dist/sql-query.test.d.ts.map +1 -0
- package/apps/lite-cli/dist/sql-query.test.js +290 -0
- package/apps/lite-cli/dist/sql-query.test.js.map +1 -0
- package/apps/lite-cli/dist/version.d.ts +1 -1
- package/apps/lite-cli/dist/version.js +1 -1
- package/apps/lite-tui/dist/bin.js +2 -2
- package/apps/lite-tui/dist/bin.js.map +1 -1
- package/apps/lite-tui/dist/index.d.ts.map +1 -1
- package/apps/lite-tui/dist/index.js +6 -2
- package/apps/lite-tui/dist/index.js.map +1 -1
- package/apps/lite-tui/dist/index.test.js +10 -8
- package/apps/lite-tui/dist/index.test.js.map +1 -1
- package/apps/lite-tui/dist/render.d.ts +1 -1
- package/apps/lite-tui/dist/version.d.ts +1 -1
- package/apps/lite-tui/dist/version.js +1 -1
- package/bin/cchistory-lite-tui.mjs +2 -2
- package/bin/cchistory-lite.mjs +2 -2
- package/docs/guide/for-agents.md +66 -46
- package/docs/guide/lite.md +53 -11
- package/docs/guide/queries/latest-sessions.sql +4 -0
- package/docs/guide/queries/latest-turns.sql +1 -0
- package/docs/guide/queries/list-sessions.sql +2 -0
- package/docs/guide/query.md +153 -0
- package/node_modules/@cchistory/canonical/dist/directory-scope.d.ts +7 -0
- package/node_modules/@cchistory/canonical/dist/directory-scope.d.ts.map +1 -1
- package/node_modules/@cchistory/canonical/dist/directory-scope.js +11 -0
- package/node_modules/@cchistory/canonical/dist/directory-scope.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/index.d.ts +5 -1
- package/node_modules/@cchistory/canonical/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/canonical/dist/index.js +5 -1
- package/node_modules/@cchistory/canonical/dist/index.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/query.d.ts +15 -0
- package/node_modules/@cchistory/canonical/dist/query.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/query.js +208 -0
- package/node_modules/@cchistory/canonical/dist/query.js.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-family.d.ts +1 -0
- package/node_modules/@cchistory/canonical/dist/session-family.d.ts.map +1 -1
- package/node_modules/@cchistory/canonical/dist/session-family.js +3 -0
- package/node_modules/@cchistory/canonical/dist/session-family.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/session-family.test.js +61 -0
- package/node_modules/@cchistory/canonical/dist/session-family.test.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts +30 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.js +713 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.js.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.test.d.ts +2 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.test.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.test.js +56 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.test.js.map +1 -0
- package/node_modules/@cchistory/canonical/package.json +1 -1
- package/node_modules/@cchistory/domain/dist/evidence-atoms.d.ts +7 -0
- package/node_modules/@cchistory/domain/dist/evidence-atoms.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/evidence-atoms.js +36 -0
- package/node_modules/@cchistory/domain/dist/evidence-atoms.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/evidence-values.d.ts +26 -0
- package/node_modules/@cchistory/domain/dist/evidence-values.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/evidence-values.js +80 -0
- package/node_modules/@cchistory/domain/dist/evidence-values.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/index.d.ts +6 -0
- package/node_modules/@cchistory/domain/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/domain/dist/index.js +5 -0
- package/node_modules/@cchistory/domain/dist/index.js.map +1 -1
- package/node_modules/@cchistory/domain/dist/masks.d.ts +31 -0
- package/node_modules/@cchistory/domain/dist/masks.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/masks.js +342 -0
- package/node_modules/@cchistory/domain/dist/masks.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/parsed-session.d.ts +58 -0
- package/node_modules/@cchistory/domain/dist/parsed-session.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/parsed-session.js +2 -0
- package/node_modules/@cchistory/domain/dist/parsed-session.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/query.d.ts +67 -0
- package/node_modules/@cchistory/domain/dist/query.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/query.js +2 -0
- package/node_modules/@cchistory/domain/dist/query.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/token-evidence.d.ts +14 -0
- package/node_modules/@cchistory/domain/dist/token-evidence.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/token-evidence.js +247 -0
- package/node_modules/@cchistory/domain/dist/token-evidence.js.map +1 -0
- package/node_modules/@cchistory/domain/package.json +1 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.d.ts +1 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.js +1 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/index.d.ts +30 -9
- package/node_modules/@cchistory/live-runtime/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/index.js +314 -143
- package/node_modules/@cchistory/live-runtime/dist/index.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/index.test.js +177 -20
- package/node_modules/@cchistory/live-runtime/dist/index.test.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.d.ts +12 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.js +44 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.test.js +20 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/live-read-recovery.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/live-read-recovery.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/live-read-recovery.test.js +92 -0
- package/node_modules/@cchistory/live-runtime/dist/live-read-recovery.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.d.ts +16 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.js +55 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.js +192 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.d.ts +22 -22
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.js +53 -47
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js +287 -83
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/selective-query.d.ts +47 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.js +15 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.test.js +171 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.d.ts +37 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.js +301 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.test.js +67 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-worker.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-worker.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-worker.js +14 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-worker.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/system-memory.d.ts +13 -10
- package/node_modules/@cchistory/live-runtime/dist/system-memory.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/system-memory.js +61 -34
- package/node_modules/@cchistory/live-runtime/dist/system-memory.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/system-memory.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/system-memory.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/system-memory.test.js +76 -0
- package/node_modules/@cchistory/live-runtime/dist/system-memory.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/package.json +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/discovery.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/core/discovery.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/factories.d.ts +2 -4
- package/node_modules/@cchistory/source-adapters/dist/core/factories.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/factories.js +1 -23
- package/node_modules/@cchistory/source-adapters/dist/core/factories.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.d.ts +25 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.js +81 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.d.ts +2 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.js +122 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/git-project.js +2 -11
- package/node_modules/@cchistory/source-adapters/dist/core/git-project.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.test.js +31 -1
- package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts +4 -3
- package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/parser.js +32 -13
- package/node_modules/@cchistory/source-adapters/dist/core/parser.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts +8 -6
- package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/probe.js +46 -45
- package/node_modules/@cchistory/source-adapters/dist/core/probe.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/projections.d.ts +2 -28
- package/node_modules/@cchistory/source-adapters/dist/core/projections.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/projections.js +2 -695
- package/node_modules/@cchistory/source-adapters/dist/core/projections.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/projections.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/core/projections.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.d.ts +18 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.js +27 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.d.ts +2 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.js +76 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.d.ts +6 -0
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/token-usage.d.ts +1 -13
- package/node_modules/@cchistory/source-adapters/dist/core/token-usage.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/token-usage.js +1 -246
- package/node_modules/@cchistory/source-adapters/dist/core/token-usage.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/tokens.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/tokens.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/type-guards.d.ts +1 -25
- package/node_modules/@cchistory/source-adapters/dist/core/type-guards.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/type-guards.js +1 -79
- package/node_modules/@cchistory/source-adapters/dist/core/type-guards.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts +6 -35
- package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.d.ts +2 -1
- package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.js +14 -10
- package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.d.ts +6 -0
- package/node_modules/@cchistory/source-adapters/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.js +4 -0
- package/node_modules/@cchistory/source-adapters/dist/index.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts +2 -0
- package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.test.js +2 -0
- package/node_modules/@cchistory/source-adapters/dist/index.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/masks.d.ts +1 -30
- package/node_modules/@cchistory/source-adapters/dist/masks.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/masks.js +1 -341
- package/node_modules/@cchistory/source-adapters/dist/masks.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/accio.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/accio.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/claude.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/claude.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.d.ts +14 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.js +103 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.d.ts +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.js +5 -3
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.js +24 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js +11 -9
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.d.ts +8 -0
- package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.js +7 -0
- package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/test-helpers.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/package.json +1 -1
- package/node_modules/commander/LICENSE +22 -0
- package/node_modules/commander/Readme.md +428 -0
- package/node_modules/commander/index.js +1224 -0
- package/node_modules/commander/package.json +38 -0
- package/node_modules/commander/typings/index.d.ts +310 -0
- package/node_modules/discontinuous-range/.npmignore +28 -0
- package/node_modules/discontinuous-range/.travis.yml +4 -0
- package/node_modules/discontinuous-range/LICENSE +21 -0
- package/node_modules/discontinuous-range/README.md +23 -0
- package/node_modules/discontinuous-range/index.js +144 -0
- package/node_modules/discontinuous-range/package.json +27 -0
- package/node_modules/discontinuous-range/test/main-test.js +96 -0
- package/node_modules/moo/LICENSE +29 -0
- package/node_modules/moo/README.md +385 -0
- package/node_modules/moo/moo.js +645 -0
- package/node_modules/moo/package.json +29 -0
- package/node_modules/nearley/LICENSE.txt +21 -0
- package/node_modules/nearley/README.md +80 -0
- package/node_modules/nearley/bin/nearley-railroad.js +121 -0
- package/node_modules/nearley/bin/nearley-test.js +64 -0
- package/node_modules/nearley/bin/nearley-unparse.js +29 -0
- package/node_modules/nearley/bin/nearleyc.js +38 -0
- package/node_modules/nearley/builtin/cow.ne +2 -0
- package/node_modules/nearley/builtin/number.ne +51 -0
- package/node_modules/nearley/builtin/postprocessors.ne +36 -0
- package/node_modules/nearley/builtin/string.ne +26 -0
- package/node_modules/nearley/builtin/whitespace.ne +5 -0
- package/node_modules/nearley/lib/compile.js +307 -0
- package/node_modules/nearley/lib/generate.js +244 -0
- package/node_modules/nearley/lib/lint.js +28 -0
- package/node_modules/nearley/lib/nearley-language-bootstrapped.js +132 -0
- package/node_modules/nearley/lib/nearley-language-bootstrapped.ne +126 -0
- package/node_modules/nearley/lib/nearley.js +564 -0
- package/node_modules/nearley/lib/stream.js +18 -0
- package/node_modules/nearley/lib/unparse.js +139 -0
- package/node_modules/nearley/package.json +63 -0
- package/node_modules/pgsql-ast-parser/ast-mapper.d.ts +237 -0
- package/node_modules/pgsql-ast-parser/ast-mapper.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/ast-mapper.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/ast-mapper.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/ast-visitor.d.ts +33 -0
- package/node_modules/pgsql-ast-parser/ast-visitor.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/ast-visitor.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/ast-visitor.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/index.d.ts +11 -0
- package/node_modules/pgsql-ast-parser/index.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/index.js +6484 -0
- package/node_modules/pgsql-ast-parser/index.js.map +1 -0
- package/node_modules/pgsql-ast-parser/interfaces.d.ts +1 -0
- package/node_modules/pgsql-ast-parser/interfaces.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/keywords.d.ts +2 -0
- package/node_modules/pgsql-ast-parser/keywords.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/lexer.d.ts +15 -0
- package/node_modules/pgsql-ast-parser/lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/lexer.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/lexer.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array-lexer.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array-lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric-lexer.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric-lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-builder.d.ts +10 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-builder.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso-lexer.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso-lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-lexer.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/package.json +69 -0
- package/node_modules/pgsql-ast-parser/parser.d.ts +33 -0
- package/node_modules/pgsql-ast-parser/parser.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/pg-escape.d.ts +2 -0
- package/node_modules/pgsql-ast-parser/pg-escape.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/readme.md +255 -0
- package/node_modules/pgsql-ast-parser/src/ast-mapper.spec.ts +296 -0
- package/node_modules/pgsql-ast-parser/src/ast-mapper.ts +1378 -0
- package/node_modules/pgsql-ast-parser/src/ast-visitor.spec.ts +57 -0
- package/node_modules/pgsql-ast-parser/src/ast-visitor.ts +101 -0
- package/node_modules/pgsql-ast-parser/src/index.ts +10 -0
- package/node_modules/pgsql-ast-parser/src/interfaces.ts +0 -0
- package/node_modules/pgsql-ast-parser/src/keywords.ts +8 -0
- package/node_modules/pgsql-ast-parser/src/lexer.spec.ts +245 -0
- package/node_modules/pgsql-ast-parser/src/lexer.ts +267 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array-lexer.ts +27 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array.ne +18 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array.spec.ts +55 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric-lexer.ts +26 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric.ne +88 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric.spec.ts +131 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-builder.ts +148 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-iso-lexer.ts +17 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-iso.ne +53 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-lexer.ts +26 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval.ne +54 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval.spec.ts +106 -0
- package/node_modules/pgsql-ast-parser/src/parser.ts +142 -0
- package/node_modules/pgsql-ast-parser/src/pg-escape.ts +14 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-index.ne +29 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-index.spec.ts +35 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-table.ne +123 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-table.spec.ts +476 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-type.ne +33 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-type.spec.ts +29 -0
- package/node_modules/pgsql-ast-parser/src/syntax/ast.ts +1150 -0
- package/node_modules/pgsql-ast-parser/src/syntax/base.ne +369 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-extension.ne +17 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-extension.spec.ts +37 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-index.ne +62 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-index.spec.ts +245 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-table.ne +174 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-table.spec.ts +761 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-type.ne +40 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-type.spec.ts +32 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-view.ne +68 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-view.spec.ts +187 -0
- package/node_modules/pgsql-ast-parser/src/syntax/deallocate.ne +13 -0
- package/node_modules/pgsql-ast-parser/src/syntax/deallocate.spec.ts +19 -0
- package/node_modules/pgsql-ast-parser/src/syntax/delete.ne +36 -0
- package/node_modules/pgsql-ast-parser/src/syntax/delete.spec.ts +71 -0
- package/node_modules/pgsql-ast-parser/src/syntax/drop.ne +28 -0
- package/node_modules/pgsql-ast-parser/src/syntax/drop.spec.ts +77 -0
- package/node_modules/pgsql-ast-parser/src/syntax/edge-cases.spec.ts +41 -0
- package/node_modules/pgsql-ast-parser/src/syntax/expr.ne +350 -0
- package/node_modules/pgsql-ast-parser/src/syntax/expr.spec.ts +1638 -0
- package/node_modules/pgsql-ast-parser/src/syntax/functions.ne +114 -0
- package/node_modules/pgsql-ast-parser/src/syntax/functions.spec.ts +235 -0
- package/node_modules/pgsql-ast-parser/src/syntax/insert.ne +63 -0
- package/node_modules/pgsql-ast-parser/src/syntax/insert.spec.ts +292 -0
- package/node_modules/pgsql-ast-parser/src/syntax/main.ne +77 -0
- package/node_modules/pgsql-ast-parser/src/syntax/nearley.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/src/syntax/prepare.ne +8 -0
- package/node_modules/pgsql-ast-parser/src/syntax/prepare.spec.ts +44 -0
- package/node_modules/pgsql-ast-parser/src/syntax/refresh-materialized-view.ne +19 -0
- package/node_modules/pgsql-ast-parser/src/syntax/refresh-materialized-view.spec.ts +42 -0
- package/node_modules/pgsql-ast-parser/src/syntax/select.ne +223 -0
- package/node_modules/pgsql-ast-parser/src/syntax/select.spec.ts +1063 -0
- package/node_modules/pgsql-ast-parser/src/syntax/sequence.ne +101 -0
- package/node_modules/pgsql-ast-parser/src/syntax/sequence.spec.ts +103 -0
- package/node_modules/pgsql-ast-parser/src/syntax/simple-statements.ne +168 -0
- package/node_modules/pgsql-ast-parser/src/syntax/simple-statements.spec.ts +327 -0
- package/node_modules/pgsql-ast-parser/src/syntax/spec-utils.ts +333 -0
- package/node_modules/pgsql-ast-parser/src/syntax/union.ne +18 -0
- package/node_modules/pgsql-ast-parser/src/syntax/union.spec.ts +125 -0
- package/node_modules/pgsql-ast-parser/src/syntax/update.ne +56 -0
- package/node_modules/pgsql-ast-parser/src/syntax/update.spec.ts +87 -0
- package/node_modules/pgsql-ast-parser/src/syntax/with.ne +41 -0
- package/node_modules/pgsql-ast-parser/src/syntax/with.spec.ts +155 -0
- package/node_modules/pgsql-ast-parser/src/to-sql.spec.ts +85 -0
- package/node_modules/pgsql-ast-parser/src/to-sql.ts +1555 -0
- package/node_modules/pgsql-ast-parser/src/utils.ts +47 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-index.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-index.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-table.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-table.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-type.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-type.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/ast.d.ts +826 -0
- package/node_modules/pgsql-ast-parser/syntax/ast.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-extension.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-extension.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-index.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-index.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-table.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-table.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-type.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-type.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-view.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-view.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/deallocate.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/deallocate.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/delete.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/delete.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/drop.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/drop.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/edge-cases.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/edge-cases.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/expr.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/expr.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/functions.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/functions.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/insert.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/insert.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/main.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/syntax/main.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/prepare.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/prepare.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/refresh-materialized-view.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/refresh-materialized-view.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/select.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/select.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/sequence.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/sequence.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/simple-statements.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/simple-statements.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/spec-utils.d.ts +35 -0
- package/node_modules/pgsql-ast-parser/syntax/spec-utils.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/union.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/union.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/update.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/update.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/with.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/with.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/to-sql.d.ts +7 -0
- package/node_modules/pgsql-ast-parser/to-sql.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/to-sql.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/to-sql.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/utils.d.ts +16 -0
- package/node_modules/pgsql-ast-parser/utils.d.ts.map +1 -0
- package/node_modules/railroad-diagrams/.gitattributes +22 -0
- package/node_modules/railroad-diagrams/.npmignore +163 -0
- package/node_modules/railroad-diagrams/README.md +86 -0
- package/node_modules/railroad-diagrams/css-example.py-js +183 -0
- package/node_modules/railroad-diagrams/example.html +141 -0
- package/node_modules/railroad-diagrams/generator.html +59 -0
- package/node_modules/railroad-diagrams/package.json +23 -0
- package/node_modules/railroad-diagrams/railroad-diagrams.css +23 -0
- package/node_modules/railroad-diagrams/railroad-diagrams.js +524 -0
- package/node_modules/railroad-diagrams/railroad_diagrams.py +427 -0
- package/node_modules/randexp/LICENSE +19 -0
- package/node_modules/randexp/README.md +134 -0
- package/node_modules/randexp/lib/randexp.js +245 -0
- package/node_modules/randexp/package.json +48 -0
- package/node_modules/ret/LICENSE +19 -0
- package/node_modules/ret/README.md +183 -0
- package/node_modules/ret/lib/index.js +282 -0
- package/node_modules/ret/lib/positions.js +17 -0
- package/node_modules/ret/lib/sets.js +82 -0
- package/node_modules/ret/lib/types.js +10 -0
- package/node_modules/ret/lib/util.js +111 -0
- package/node_modules/ret/package.json +35 -0
- package/package.json +22 -6
- package/schemas/cchistory-lite-agent-v1.schema.json +6 -7
- package/schemas/cchistory-lite-error-v1.schema.json +58 -8
- package/schemas/cchistory-lite-query-result-v2.schema.json +66 -11
- package/schemas/cchistory-lite-query-result-v3.schema.json +219 -0
- package/schemas/cchistory-lite-query-v3.schema.json +57 -0
- package/schemas/cchistory-lite-source-inventory-v1.schema.json +72 -0
- package/skills/using-cchistory-lite/SKILL.md +126 -55
- package/node_modules/@cchistory/live-runtime/dist/node-memory.d.ts +0 -8
- package/node_modules/@cchistory/live-runtime/dist/node-memory.d.ts.map +0 -1
- package/node_modules/@cchistory/live-runtime/dist/node-memory.js +0 -110
- package/node_modules/@cchistory/live-runtime/dist/node-memory.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
|
-
import {
|
|
2
|
+
import { appendFileSync, cpSync, utimesSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { access, cp, mkdir, mkdtemp, readFile, rm, stat, symlink, truncate, writeFile } from "node:fs/promises";
|
|
3
4
|
import os from "node:os";
|
|
4
5
|
import path from "node:path";
|
|
5
6
|
import test from "node:test";
|
|
6
7
|
import { fileURLToPath } from "node:url";
|
|
7
8
|
import { acquireScanLock, assessScanRisk, createScanWatchdog, defaultScanLockPath, formatScanGuardBytes, isScanGuardEnabled, readAvailableMemoryBytes, scanLiteHistory, ScanGuardAbortedError, ScanGuardRefusedError, } from "./index.js";
|
|
8
|
-
import { calculateAdaptiveOldSpaceMiB, resolveAdaptiveOldSpaceMiB } from "./node-memory.js";
|
|
9
9
|
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../..");
|
|
10
10
|
const mockDataRoot = path.join(repoRoot, "mock_data");
|
|
11
11
|
const codexRoot = path.join(mockDataRoot, ".codex", "sessions");
|
|
@@ -25,14 +25,14 @@ function guardedFixtureScan(scanGuard, scanGuardDeps) {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
// ── Pre-flight estimate ──
|
|
28
|
-
test("scan guard thresholds: ok at exactly 50%, warn
|
|
28
|
+
test("scan guard thresholds: ok at exactly 50%, warn above it without treating estimates as proof", async () => {
|
|
29
29
|
const available = 1024;
|
|
30
30
|
const assess = (bytes, profile = "light") => assessScanRisk({ roots: ["/root"], profile }, { walkRootBytes: async () => bytes, readAvailableBytes: () => available });
|
|
31
31
|
// light ×4: 512 is exactly 50% of 1024 → ok; 768 is exactly 75% → warn.
|
|
32
32
|
assert.equal((await assess(128)).status, "ok");
|
|
33
33
|
assert.equal((await assess(129)).status, "warn");
|
|
34
34
|
assert.equal((await assess(192)).status, "warn");
|
|
35
|
-
assert.equal((await assess(193)).status, "
|
|
35
|
+
assert.equal((await assess(193)).status, "warn");
|
|
36
36
|
const refusal = await assess(193);
|
|
37
37
|
assert.equal(refusal.estimatedBytes, 193 * 4);
|
|
38
38
|
assert.equal(refusal.scannedBytes, 193);
|
|
@@ -63,9 +63,20 @@ test("scan guard multiplier: full scans estimate 8×, light scans 4×", async ()
|
|
|
63
63
|
assert.equal(light.status, "ok");
|
|
64
64
|
const full = await assessScanRisk({ roots: ["/root"], profile: "full" }, deps);
|
|
65
65
|
assert.equal(full.estimatedBytes, 800);
|
|
66
|
-
assert.equal(full.status, "
|
|
66
|
+
assert.equal(full.status, "warn");
|
|
67
67
|
});
|
|
68
|
-
test("scan
|
|
68
|
+
test("scan estimates distinguish adapter slots sharing the same root", async () => {
|
|
69
|
+
const assessment = await assessScanRisk({
|
|
70
|
+
roots: [{ path: "/shared", slot_id: "cursor" }, { path: "/shared", slot_id: "cursor_agent" }],
|
|
71
|
+
profile: "light",
|
|
72
|
+
}, {
|
|
73
|
+
walkRootBytes: async (_root, _limit, slotId) => slotId === "cursor" ? 100 : 10,
|
|
74
|
+
readAvailableBytes: () => 1024,
|
|
75
|
+
});
|
|
76
|
+
assert.deepEqual(assessment.roots?.map((root) => root.bytes), [100, 10]);
|
|
77
|
+
assert.equal(assessment.scannedBytes, 110);
|
|
78
|
+
});
|
|
79
|
+
test("scan guard records a failed walk and uses remaining heap when availability is unknown", async () => {
|
|
69
80
|
const walkFailure = await assessScanRisk({ roots: ["/root"], profile: "light" }, {
|
|
70
81
|
walkRootBytes: async () => {
|
|
71
82
|
throw new Error("EACCES");
|
|
@@ -74,9 +85,9 @@ test("scan guard degrades to ok when the walk fails or availability is unknown",
|
|
|
74
85
|
});
|
|
75
86
|
assert.equal(walkFailure.status, "ok");
|
|
76
87
|
assert.match(walkFailure.detail, /could not walk/);
|
|
77
|
-
const unknown = await assessScanRisk({ roots: ["/root"], profile: "full" }, { walkRootBytes: async () => 10 * GIB, readAvailableBytes: () => undefined });
|
|
78
|
-
assert.equal(unknown.status, "
|
|
79
|
-
assert.
|
|
88
|
+
const unknown = await assessScanRisk({ roots: ["/root"], profile: "full" }, { walkRootBytes: async () => 10 * GIB, readAvailableBytes: () => undefined, readHeapBytes: () => GIB });
|
|
89
|
+
assert.equal(unknown.status, "warn");
|
|
90
|
+
assert.equal(unknown.availableBytes, GIB);
|
|
80
91
|
assert.equal(unknown.estimatedBytes, 80 * GIB);
|
|
81
92
|
});
|
|
82
93
|
test("scan guard walk sums regular files, honors the limitFiles cap, and never follows symlinks", async () => {
|
|
@@ -107,21 +118,21 @@ test("scan guard walk treats a missing root as zero bytes", async () => {
|
|
|
107
118
|
// ── Available-memory reading ──
|
|
108
119
|
test("available memory prefers Linux MemAvailable, falls back to freemem, and obeys the cgroup cap", () => {
|
|
109
120
|
const meminfo = "MemTotal: 33554432 kB\nMemFree: 1024 kB\nMemAvailable: 16777216 kB\nBuffers: 1 kB\n";
|
|
110
|
-
assert.equal(readAvailableMemoryBytes({
|
|
121
|
+
assert.equal(readAvailableMemoryBytes({ totalmem: () => 64 * GIB, availableMemory: () => { throw new Error("unavailable process signal"); },
|
|
111
122
|
platform: "linux",
|
|
112
123
|
readMeminfo: () => meminfo,
|
|
113
124
|
freemem: () => 111,
|
|
114
125
|
constrainedMemory: () => 0,
|
|
115
126
|
}), 16777216 * 1024);
|
|
116
127
|
// MemAvailable predates older kernels: fall back to freemem.
|
|
117
|
-
assert.equal(readAvailableMemoryBytes({
|
|
128
|
+
assert.equal(readAvailableMemoryBytes({ totalmem: () => 64 * GIB, availableMemory: () => { throw new Error("unavailable process signal"); },
|
|
118
129
|
platform: "linux",
|
|
119
130
|
readMeminfo: () => "MemTotal: 33554432 kB\nMemFree: 2048 kB\n",
|
|
120
131
|
freemem: () => 4096,
|
|
121
132
|
constrainedMemory: () => 0,
|
|
122
133
|
}), 4096);
|
|
123
134
|
// An unreadable meminfo falls back to freemem rather than unknown.
|
|
124
|
-
assert.equal(readAvailableMemoryBytes({
|
|
135
|
+
assert.equal(readAvailableMemoryBytes({ totalmem: () => 64 * GIB, availableMemory: () => { throw new Error("unavailable process signal"); },
|
|
125
136
|
platform: "linux",
|
|
126
137
|
readMeminfo: () => {
|
|
127
138
|
throw new Error("EPERM");
|
|
@@ -129,17 +140,17 @@ test("available memory prefers Linux MemAvailable, falls back to freemem, and ob
|
|
|
129
140
|
freemem: () => 8192,
|
|
130
141
|
constrainedMemory: () => 0,
|
|
131
142
|
}), 8192);
|
|
132
|
-
//
|
|
133
|
-
assert.equal(readAvailableMemoryBytes({ platform: "
|
|
143
|
+
// Other platforms fall back to freemem.
|
|
144
|
+
assert.equal(readAvailableMemoryBytes({ totalmem: () => 64 * GIB, availableMemory: () => { throw new Error("unavailable process signal"); }, platform: "win32", freemem: () => 16384, constrainedMemory: () => 0 }), 16384);
|
|
134
145
|
// An enforced cgroup limit caps the host-wide signal.
|
|
135
|
-
assert.equal(readAvailableMemoryBytes({
|
|
146
|
+
assert.equal(readAvailableMemoryBytes({ totalmem: () => 64 * GIB, availableMemory: () => { throw new Error("unavailable process signal"); },
|
|
136
147
|
platform: "linux",
|
|
137
148
|
readMeminfo: () => meminfo,
|
|
138
149
|
freemem: () => 0,
|
|
139
150
|
constrainedMemory: () => 1024,
|
|
140
151
|
}), 1024);
|
|
141
152
|
// Every signal failing means unknown, never an error.
|
|
142
|
-
assert.equal(readAvailableMemoryBytes({
|
|
153
|
+
assert.equal(readAvailableMemoryBytes({ totalmem: () => 64 * GIB, availableMemory: () => { throw new Error("unavailable process signal"); },
|
|
143
154
|
platform: "linux",
|
|
144
155
|
readMeminfo: () => {
|
|
145
156
|
throw new Error("EPERM");
|
|
@@ -152,30 +163,6 @@ test("available memory prefers Linux MemAvailable, falls back to freemem, and ob
|
|
|
152
163
|
},
|
|
153
164
|
}), undefined);
|
|
154
165
|
});
|
|
155
|
-
// ── Adaptive heap ceiling ──
|
|
156
|
-
test("adaptive heap ceiling tracks available memory between a 512 MiB floor and the 4 GiB cap", () => {
|
|
157
|
-
// Big idle machine: available ≈ total, so the R43 cap still holds.
|
|
158
|
-
assert.equal(calculateAdaptiveOldSpaceMiB(32 * GIB, 32 * GIB), 4096);
|
|
159
|
-
assert.equal(calculateAdaptiveOldSpaceMiB(32 * GIB, 8 * GIB), 4096);
|
|
160
|
-
// Memory-tight machine: half of what is actually free.
|
|
161
|
-
assert.equal(calculateAdaptiveOldSpaceMiB(32 * GIB, 4 * GIB), 2048);
|
|
162
|
-
assert.equal(calculateAdaptiveOldSpaceMiB(8 * GIB, 2 * GIB), 1024);
|
|
163
|
-
// Floor: below ~512 MiB old-space Lite could not project at all.
|
|
164
|
-
assert.equal(calculateAdaptiveOldSpaceMiB(32 * GIB, 600 * MIB), 512);
|
|
165
|
-
assert.equal(calculateAdaptiveOldSpaceMiB(32 * GIB, 1), 512);
|
|
166
|
-
// Unknown availability keeps the pre-guard total/2 policy, never worse.
|
|
167
|
-
assert.equal(calculateAdaptiveOldSpaceMiB(8 * GIB), 4096);
|
|
168
|
-
assert.equal(calculateAdaptiveOldSpaceMiB(3 * GIB), 1536);
|
|
169
|
-
assert.equal(calculateAdaptiveOldSpaceMiB(3 * GIB, Number.NaN), 1536);
|
|
170
|
-
assert.equal(calculateAdaptiveOldSpaceMiB(3 * GIB, 0), 1536);
|
|
171
|
-
});
|
|
172
|
-
test("resolveAdaptiveOldSpaceMiB treats a throwing reader as unknown availability", () => {
|
|
173
|
-
assert.equal(resolveAdaptiveOldSpaceMiB(32 * GIB, () => 4 * GIB), 2048);
|
|
174
|
-
assert.equal(resolveAdaptiveOldSpaceMiB(32 * GIB, () => undefined), 4096);
|
|
175
|
-
assert.equal(resolveAdaptiveOldSpaceMiB(32 * GIB, () => {
|
|
176
|
-
throw new Error("no meminfo");
|
|
177
|
-
}), 4096);
|
|
178
|
-
});
|
|
179
166
|
// ── Advisory scan lock ──
|
|
180
167
|
test("scan lock holds only pid and startedAt, and release removes it", async () => {
|
|
181
168
|
const lockDir = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-lock-"));
|
|
@@ -308,9 +295,13 @@ test("the default scan lock lives in the runtime/temp dir and never under a Full
|
|
|
308
295
|
}
|
|
309
296
|
});
|
|
310
297
|
// ── Scan watchdog ──
|
|
311
|
-
test("
|
|
312
|
-
assert.equal(createScanWatchdog({ totalBytes:
|
|
313
|
-
assert.equal(createScanWatchdog({ totalBytes: 64 * GIB, readAvailableBytes: () => undefined }).floorBytes,
|
|
298
|
+
test("watchdog reserve follows starting availability even on a large constrained host", () => {
|
|
299
|
+
assert.equal(createScanWatchdog({ totalBytes: 64 * GIB, initialAvailableBytes: 128 * MIB }).floorBytes, 32 * MIB);
|
|
300
|
+
assert.equal(createScanWatchdog({ totalBytes: 64 * GIB, readAvailableBytes: () => undefined }).floorBytes, 0);
|
|
301
|
+
assert.throws(() => createScanWatchdog({ readAvailableBytes: () => 0 }).assertHealthy(), ScanGuardAbortedError);
|
|
302
|
+
const roomy = createScanWatchdog({ initialAvailableBytes: 32 * GIB, readAvailableBytes: () => 4 * GIB });
|
|
303
|
+
assert.equal(roomy.floorBytes, 512 * MIB);
|
|
304
|
+
assert.doesNotThrow(() => roomy.assertHealthy());
|
|
314
305
|
});
|
|
315
306
|
test("scan watchdog checks on the file cadence and aborts below the floor", () => {
|
|
316
307
|
const floor = 512 * MIB;
|
|
@@ -385,7 +376,7 @@ test("CCHISTORY_SCAN_GUARD kill-switch parsing", () => {
|
|
|
385
376
|
assert.equal(isScanGuardEnabled("false"), false);
|
|
386
377
|
assert.equal(isScanGuardEnabled(" FALSE "), false);
|
|
387
378
|
});
|
|
388
|
-
test("refusal and warning text
|
|
379
|
+
test("refusal and warning text distinguish resource limits without recommending guard bypass", async () => {
|
|
389
380
|
const assessment = await assessScanRisk({ roots: ["/root"], profile: "light" }, { walkRootBytes: async () => 193, readAvailableBytes: () => 1024 });
|
|
390
381
|
const estimateRefusal = new ScanGuardRefusedError({ reason: "estimated_memory", assessment });
|
|
391
382
|
assert.match(estimateRefusal.message, /Refusing to scan/);
|
|
@@ -395,12 +386,11 @@ test("refusal and warning text name the numbers, the bounds, and the override",
|
|
|
395
386
|
assert.match(estimateRefusal.message, /\/root/);
|
|
396
387
|
assert.match(estimateRefusal.message, /193 B/);
|
|
397
388
|
assert.match(estimateRefusal.message, /this scan has no --dir filter/);
|
|
398
|
-
assert.match(estimateRefusal.message,
|
|
399
|
-
assert.match(estimateRefusal.message,
|
|
400
|
-
assert.match(estimateRefusal.message,
|
|
401
|
-
assert.match(estimateRefusal.message, /
|
|
402
|
-
assert.
|
|
403
|
-
assert.match(estimateRefusal.message, /CCHISTORY_SCAN_GUARD=0/);
|
|
389
|
+
assert.match(estimateRefusal.message, /No complete result/);
|
|
390
|
+
assert.match(estimateRefusal.message, /keep the requested scope/);
|
|
391
|
+
assert.match(estimateRefusal.message, /sources --json/);
|
|
392
|
+
assert.match(estimateRefusal.message, /shell/);
|
|
393
|
+
assert.doesNotMatch(estimateRefusal.message, /CCHISTORY_SCAN_GUARD=0/);
|
|
404
394
|
assert.doesNotMatch(estimateRefusal.message, /does not shrink source bytes/);
|
|
405
395
|
assert.doesNotMatch(estimateRefusal.message, /Narrow the scan with --source, --dir/);
|
|
406
396
|
const scopedAssessment = await assessScanRisk({ roots: ["/root"], profile: "light", directoryScoped: true }, { walkRootBytes: async () => 193, readAvailableBytes: () => 1024 });
|
|
@@ -416,19 +406,232 @@ test("refusal and warning text name the numbers, the bounds, and the override",
|
|
|
416
406
|
});
|
|
417
407
|
assert.match(lockRefusal.message, /pid 4321/);
|
|
418
408
|
assert.match(lockRefusal.message, /waited 30s/);
|
|
419
|
-
assert.match(lockRefusal.message,
|
|
420
|
-
assert.match(lockRefusal.message,
|
|
421
|
-
assert.
|
|
409
|
+
assert.match(lockRefusal.message, /shell/);
|
|
410
|
+
assert.match(lockRefusal.message, /Wait for that scan to finish/);
|
|
411
|
+
assert.doesNotMatch(lockRefusal.message, /CCHISTORY_SCAN_GUARD=0/);
|
|
422
412
|
const abort = new ScanGuardAbortedError({ availableBytes: 300 * MIB, floorBytes: 512 * MIB });
|
|
423
413
|
assert.match(abort.message, /Scan aborted/);
|
|
424
414
|
assert.match(abort.message, /300 MiB/);
|
|
425
415
|
assert.match(abort.message, /512 MiB/);
|
|
426
|
-
assert.
|
|
416
|
+
assert.doesNotMatch(abort.message, /CCHISTORY_SCAN_GUARD=0/);
|
|
427
417
|
assert.equal(formatScanGuardBytes(512), "512 B");
|
|
428
418
|
assert.equal(formatScanGuardBytes(1536), "1.5 KiB");
|
|
429
419
|
assert.equal(formatScanGuardBytes(200 * GIB), "200 GiB");
|
|
430
420
|
});
|
|
431
421
|
// ── Guarded scan integration ──
|
|
422
|
+
test("unscoped --limit-files estimates the adapter-selected ZCode database and its WAL before reading", async () => {
|
|
423
|
+
const root = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-plan-zcode-"));
|
|
424
|
+
try {
|
|
425
|
+
const sourceRoot = path.join(root, ".zcode");
|
|
426
|
+
const db = path.join(sourceRoot, "cli/db/db.sqlite");
|
|
427
|
+
await mkdir(path.dirname(db), { recursive: true });
|
|
428
|
+
await writeFile(path.join(sourceRoot, "a-config.json"), "{}\n");
|
|
429
|
+
await writeFile(db, "");
|
|
430
|
+
await truncate(db, 128 * MIB);
|
|
431
|
+
await writeFile(`${db}-wal`, "");
|
|
432
|
+
await truncate(`${db}-wal`, 8 * MIB);
|
|
433
|
+
for (const safeMode of [true, false]) {
|
|
434
|
+
const expectedBytes = (await stat(db)).size + (await stat(`${db}-wal`)).size + (await stat(`${db}-shm`).catch(() => ({ size: 0 }))).size;
|
|
435
|
+
const parsedFiles = [];
|
|
436
|
+
const events = [];
|
|
437
|
+
const snapshot = await scanLiteHistory({
|
|
438
|
+
homeDir: root,
|
|
439
|
+
sourceRefs: ["zcode"],
|
|
440
|
+
sourceRoots: [{ sourceRef: "zcode", baseDir: sourceRoot }],
|
|
441
|
+
limitFiles: 1,
|
|
442
|
+
safeMode,
|
|
443
|
+
scanGuard: { profile: "light" },
|
|
444
|
+
scanGuardDeps: { lock: { lockPath: path.join(root, "scan.lock") }, readAvailableBytes: () => 512 * MIB },
|
|
445
|
+
onScanGuardEvent: event => events.push(event),
|
|
446
|
+
onProgress: (event) => {
|
|
447
|
+
if (event.stage === "file_start" && event.file_path)
|
|
448
|
+
parsedFiles.push(event.file_path);
|
|
449
|
+
},
|
|
450
|
+
});
|
|
451
|
+
assert.equal(events[0]?.assessment.scannedBytes, expectedBytes);
|
|
452
|
+
assert.deepEqual(parsedFiles, [db]);
|
|
453
|
+
assert.ok(snapshot.data.loss_audits.length > 0);
|
|
454
|
+
assert.deepEqual(snapshot.projectionIssues, []);
|
|
455
|
+
await assert.rejects(access(path.join(root, "scan.lock")));
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
finally {
|
|
459
|
+
await rm(root, { recursive: true, force: true });
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
test("the guard includes Cursor supplemental storage outside the selected projects root", async () => {
|
|
463
|
+
const root = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-plan-cursor-"));
|
|
464
|
+
try {
|
|
465
|
+
const projects = path.join(root, ".cursor/projects");
|
|
466
|
+
const db = path.join(root, ".config/Cursor/User/workspaceStorage/fixture/state.vscdb");
|
|
467
|
+
await mkdir(projects, { recursive: true });
|
|
468
|
+
await mkdir(path.dirname(db), { recursive: true });
|
|
469
|
+
await writeFile(db, "");
|
|
470
|
+
await truncate(db, 128 * MIB);
|
|
471
|
+
const events = [];
|
|
472
|
+
const snapshot = await scanLiteHistory({
|
|
473
|
+
homeDir: root,
|
|
474
|
+
sourceRefs: ["cursor"],
|
|
475
|
+
sourceRoots: [{ sourceRef: "cursor", baseDir: projects }],
|
|
476
|
+
limitFiles: 1,
|
|
477
|
+
onScanGuardEvent: event => events.push(event),
|
|
478
|
+
safeMode: true,
|
|
479
|
+
scanGuard: { profile: "light" },
|
|
480
|
+
scanGuardDeps: { lock: { lockPath: path.join(root, "scan.lock") }, readAvailableBytes: () => 512 * MIB },
|
|
481
|
+
});
|
|
482
|
+
assert.equal(events[0]?.assessment.scannedBytes, 128 * MIB);
|
|
483
|
+
assert.ok(snapshot.data.loss_audits.length > 0);
|
|
484
|
+
assert.deepEqual(snapshot.projectionIssues, []);
|
|
485
|
+
}
|
|
486
|
+
finally {
|
|
487
|
+
await rm(root, { recursive: true, force: true });
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
test("whole-file session identity lookups are budgeted before locating the requested session", async () => {
|
|
491
|
+
const root = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-plan-identity-"));
|
|
492
|
+
try {
|
|
493
|
+
const file = path.join(root, "unrelated.json");
|
|
494
|
+
await cp(path.join(mockDataRoot, ".local/share/amp/threads/T-019d19fb-1a2b-7345-8cde-0f1a2b3c4d5e.json"), file);
|
|
495
|
+
await truncate(file, 256 * GIB);
|
|
496
|
+
await assert.rejects(scanLiteHistory({
|
|
497
|
+
homeDir: emptyHome,
|
|
498
|
+
sourceRefs: ["amp"],
|
|
499
|
+
sourceRoots: [{ sourceRef: "amp", baseDir: root }],
|
|
500
|
+
sessionRefs: ["sess:amp:requested"],
|
|
501
|
+
safeMode: true,
|
|
502
|
+
scanGuard: { profile: "light" },
|
|
503
|
+
scanGuardDeps: { lock: { lockPath: path.join(root, "scan.lock") }, readAvailableBytes: () => GIB },
|
|
504
|
+
}), /did not find requested session/);
|
|
505
|
+
await assert.rejects(access(path.join(root, "scan.lock")));
|
|
506
|
+
}
|
|
507
|
+
finally {
|
|
508
|
+
await rm(root, { recursive: true, force: true });
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
test("estimation and execution keep one inventory; the next scan discovers new files", async () => {
|
|
512
|
+
const root = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-plan-inventory-"));
|
|
513
|
+
try {
|
|
514
|
+
const sessions = path.join(root, "sessions");
|
|
515
|
+
await mkdir(sessions);
|
|
516
|
+
const first = path.join(sessions, "first.jsonl");
|
|
517
|
+
const second = path.join(sessions, "second.jsonl");
|
|
518
|
+
await cp(path.join(mockDataRoot, "fixtures/source-shapes/codex/ordinary-fork.jsonl"), first);
|
|
519
|
+
const bytes = (await stat(first)).size;
|
|
520
|
+
const events = [];
|
|
521
|
+
const parsedFiles = [];
|
|
522
|
+
const options = {
|
|
523
|
+
homeDir: root,
|
|
524
|
+
sourceRefs: ["codex"],
|
|
525
|
+
sourceRoots: [{ sourceRef: "codex", baseDir: sessions }],
|
|
526
|
+
safeMode: true,
|
|
527
|
+
contextMode: "none",
|
|
528
|
+
};
|
|
529
|
+
const initial = await scanLiteHistory({
|
|
530
|
+
...options,
|
|
531
|
+
scanGuard: { profile: "light" },
|
|
532
|
+
scanGuardDeps: {
|
|
533
|
+
lock: { lockPath: path.join(root, "scan.lock") },
|
|
534
|
+
readAvailableBytes: () => bytes * 6,
|
|
535
|
+
watchdog: { readAvailableBytes: () => GIB },
|
|
536
|
+
},
|
|
537
|
+
onScanGuardEvent: (event) => {
|
|
538
|
+
events.push(event);
|
|
539
|
+
cpSync(path.join(codexRoot, "2026/04/12/rollout-2026-04-12T09-00-00-codex-delegation-parent.jsonl"), second);
|
|
540
|
+
},
|
|
541
|
+
onProgress: (event) => {
|
|
542
|
+
if (event.stage === "file_start" && event.file_path)
|
|
543
|
+
parsedFiles.push(event.file_path);
|
|
544
|
+
},
|
|
545
|
+
});
|
|
546
|
+
assert.equal(events.length, 1);
|
|
547
|
+
assert.equal(events[0]?.type, "warn");
|
|
548
|
+
if (events[0]?.type === "warn")
|
|
549
|
+
assert.equal(events[0].assessment.scannedBytes, bytes);
|
|
550
|
+
assert.deepEqual(parsedFiles, [first]);
|
|
551
|
+
assert.equal(initial.listResolvedSessions().length, 1);
|
|
552
|
+
assert.deepEqual(initial.projectionIssues, []);
|
|
553
|
+
const refreshed = await scanLiteHistory(options);
|
|
554
|
+
assert.equal(refreshed.listResolvedSessions().length, 2);
|
|
555
|
+
assert.deepEqual(refreshed.projectionIssues, []);
|
|
556
|
+
}
|
|
557
|
+
finally {
|
|
558
|
+
await rm(root, { recursive: true, force: true });
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
test("ongoing appends remain readable and release the scan lock", async () => {
|
|
562
|
+
const root = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-plan-change-"));
|
|
563
|
+
try {
|
|
564
|
+
const file = path.join(root, "rollout.jsonl");
|
|
565
|
+
await cp(path.join(mockDataRoot, "fixtures/source-shapes/codex/ordinary-fork.jsonl"), file);
|
|
566
|
+
let parseStarts = 0;
|
|
567
|
+
const snapshot = await scanLiteHistory({
|
|
568
|
+
homeDir: emptyHome,
|
|
569
|
+
sourceRefs: ["codex"],
|
|
570
|
+
sourceRoots: [{ sourceRef: "codex", baseDir: root }],
|
|
571
|
+
safeMode: true,
|
|
572
|
+
scanGuard: { profile: "light" },
|
|
573
|
+
scanGuardDeps: { lock: { lockPath: path.join(root, "scan.lock") }, readAvailableBytes: () => GIB },
|
|
574
|
+
onProgress: (event) => {
|
|
575
|
+
if (event.stage === "file_start") {
|
|
576
|
+
appendFileSync(file, "\n");
|
|
577
|
+
const modified = new Date("2030-01-01T00:00:00.000Z");
|
|
578
|
+
utimesSync(file, modified, modified);
|
|
579
|
+
}
|
|
580
|
+
if (event.stage === "file_capture_done")
|
|
581
|
+
parseStarts += 1;
|
|
582
|
+
},
|
|
583
|
+
});
|
|
584
|
+
assert.ok(parseStarts > 0);
|
|
585
|
+
assert.equal(snapshot.listResolvedSessions().length, 1);
|
|
586
|
+
assert.deepEqual(snapshot.projectionIssues, []);
|
|
587
|
+
await assert.rejects(access(path.join(root, "scan.lock")));
|
|
588
|
+
}
|
|
589
|
+
finally {
|
|
590
|
+
await rm(root, { recursive: true, force: true });
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
test("directory pruning is invalidated when excluded metadata changes after estimation", async () => {
|
|
594
|
+
const root = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-plan-scope-"));
|
|
595
|
+
try {
|
|
596
|
+
const inside = path.join(root, "inside.jsonl");
|
|
597
|
+
const outside = path.join(root, "outside.jsonl");
|
|
598
|
+
await cp(path.join(codexRoot, "2026/04/12/rollout-2026-04-12T09-00-00-codex-delegation-parent.jsonl"), inside);
|
|
599
|
+
await cp(path.join(mockDataRoot, "fixtures/source-shapes/codex/ordinary-fork.jsonl"), outside);
|
|
600
|
+
const outsideText = await readFile(outside, "utf8");
|
|
601
|
+
const bytes = (await stat(inside)).size;
|
|
602
|
+
let parsedFiles = 0;
|
|
603
|
+
let changed = false;
|
|
604
|
+
const snapshot = await scanLiteHistory({
|
|
605
|
+
homeDir: emptyHome,
|
|
606
|
+
sourceRefs: ["codex"],
|
|
607
|
+
sourceRoots: [{ sourceRef: "codex", baseDir: root }],
|
|
608
|
+
directoryScope: "/workspace/codex-delegated",
|
|
609
|
+
safeMode: true,
|
|
610
|
+
scanGuard: { profile: "light" },
|
|
611
|
+
scanGuardDeps: {
|
|
612
|
+
lock: { lockPath: path.join(root, "scan.lock") },
|
|
613
|
+
readAvailableBytes: () => bytes * 6,
|
|
614
|
+
watchdog: { readAvailableBytes: () => GIB },
|
|
615
|
+
},
|
|
616
|
+
onScanGuardEvent: () => {
|
|
617
|
+
changed = true;
|
|
618
|
+
writeFileSync(outside, outsideText.replaceAll("/workspace/codex-ordinary-fork", "/workspace/codex-delegated"));
|
|
619
|
+
const modified = new Date("2030-01-01T00:00:00.000Z");
|
|
620
|
+
utimesSync(outside, modified, modified);
|
|
621
|
+
},
|
|
622
|
+
onProgress: (event) => { if (event.stage === "file_start")
|
|
623
|
+
parsedFiles += 1; },
|
|
624
|
+
});
|
|
625
|
+
assert.ok(changed, "the scoped estimate must reach the warning callback");
|
|
626
|
+
assert.equal(parsedFiles, 2);
|
|
627
|
+
assert.equal(snapshot.listResolvedSessions({ directoryScope: "/workspace/codex-delegated" }).length, 2);
|
|
628
|
+
assert.deepEqual(snapshot.projectionIssues, []);
|
|
629
|
+
await assert.rejects(access(path.join(root, "scan.lock")));
|
|
630
|
+
}
|
|
631
|
+
finally {
|
|
632
|
+
await rm(root, { recursive: true, force: true });
|
|
633
|
+
}
|
|
634
|
+
});
|
|
432
635
|
test("a guarded scan over the tiny fixture corpus assesses ok and succeeds without events", async () => {
|
|
433
636
|
// The existing suite relies on this: mock_data fixtures are tiny, so the
|
|
434
637
|
// guard never fires there.
|
|
@@ -484,20 +687,15 @@ test("a guarded scan refuses behind a held lock; bypassed probes skip the lock",
|
|
|
484
687
|
await rm(lockDir, { recursive: true, force: true });
|
|
485
688
|
}
|
|
486
689
|
});
|
|
487
|
-
test("an estimate
|
|
690
|
+
test("an excessive aggregate estimate warns, preserves readable history, and releases the lock", async () => {
|
|
488
691
|
const lockDir = await mkdtemp(path.join(os.tmpdir(), "cchistory-lite-scan-lock-"));
|
|
489
692
|
try {
|
|
490
693
|
const lockPath = path.join(lockDir, "scan.lock");
|
|
491
|
-
await
|
|
492
|
-
lock: { lockPath },
|
|
493
|
-
walkRootBytes: async () => GIB,
|
|
494
|
-
readAvailableBytes: () => 96 * MIB,
|
|
495
|
-
}), (error) => {
|
|
496
|
-
assert.ok(error instanceof ScanGuardRefusedError);
|
|
497
|
-
assert.equal(error.reason, "estimated_memory");
|
|
498
|
-
assert.match(error.message, /CCHISTORY_SCAN_GUARD=0/);
|
|
499
|
-
return true;
|
|
694
|
+
const snapshot = await guardedFixtureScan({ profile: "light" }, {
|
|
695
|
+
lock: { lockPath }, walkRootBytes: async () => GIB, readAvailableBytes: () => 96 * MIB,
|
|
500
696
|
});
|
|
697
|
+
assert.ok(snapshot.listResolvedSessions().length > 0);
|
|
698
|
+
assert.deepEqual(snapshot.projectionIssues, []);
|
|
501
699
|
await assert.rejects(access(lockPath));
|
|
502
700
|
}
|
|
503
701
|
finally {
|
|
@@ -516,9 +714,9 @@ test("a warn assessment emits exactly one event and the scan proceeds", async ()
|
|
|
516
714
|
scanGuard: { profile: "light" },
|
|
517
715
|
onScanGuardEvent: (event) => events.push(event),
|
|
518
716
|
scanGuardDeps: {
|
|
519
|
-
walkRootBytes: async () => 100,
|
|
520
|
-
// 400 estimated > 350 (50% of 700) but < 525 (75%) → warn, then proceed.
|
|
521
|
-
readAvailableBytes: () => 700,
|
|
717
|
+
walkRootBytes: async () => 100 * MIB,
|
|
718
|
+
// Scaled MiB: 400 estimated > 350 (50% of 700) but < 525 (75%) → warn, then proceed.
|
|
719
|
+
readAvailableBytes: () => 700 * MIB,
|
|
522
720
|
},
|
|
523
721
|
});
|
|
524
722
|
assert.ok(snapshot.listSources().length > 0);
|
|
@@ -536,8 +734,8 @@ test("the watchdog aborts a guarded scan when available memory collapses mid-pro
|
|
|
536
734
|
};
|
|
537
735
|
await assert.rejects(guardedFixtureScan({ profile: "light" }, { readAvailableBytes, watchdog: { checkEveryFiles: 1, floorBytes: 512 * MIB } }), (error) => {
|
|
538
736
|
assert.ok(error instanceof ScanGuardAbortedError);
|
|
539
|
-
assert.match(error.message, /
|
|
540
|
-
assert.
|
|
737
|
+
assert.match(error.message, /reserve set at scan start/);
|
|
738
|
+
assert.doesNotMatch(error.message, /CCHISTORY_SCAN_GUARD=0/);
|
|
541
739
|
return true;
|
|
542
740
|
});
|
|
543
741
|
assert.ok(reads > 1);
|
|
@@ -558,7 +756,7 @@ test("a --dir estimate prices matching source files and ignores junk plus out-of
|
|
|
558
756
|
})}\n`);
|
|
559
757
|
await truncate(outsideSession, 256 * GIB);
|
|
560
758
|
const tightMemory = { readAvailableBytes: () => 512 * MIB };
|
|
561
|
-
await
|
|
759
|
+
const unscoped = await scanLiteHistory({
|
|
562
760
|
homeDir: emptyHome,
|
|
563
761
|
hostname: "cchistory-lite-dir-estimate-host",
|
|
564
762
|
sourceRefs: ["codex"],
|
|
@@ -567,13 +765,10 @@ test("a --dir estimate prices matching source files and ignores junk plus out-of
|
|
|
567
765
|
contextMode: "none",
|
|
568
766
|
scanGuard: { profile: "light" },
|
|
569
767
|
scanGuardDeps: tightMemory,
|
|
570
|
-
}), (error) => {
|
|
571
|
-
assert.ok(error instanceof ScanGuardRefusedError);
|
|
572
|
-
assert.equal(error.reason, "estimated_memory");
|
|
573
|
-
assert.equal(error.assessment?.directoryScoped, undefined);
|
|
574
|
-
assert.match(error.message, /this scan has no --dir filter/);
|
|
575
|
-
return true;
|
|
576
768
|
});
|
|
769
|
+
assert.ok(unscoped.listResolvedSessions().length > 0);
|
|
770
|
+
assert.ok(unscoped.data.loss_audits.some(a => a.detail.includes("Read budget exceeded")));
|
|
771
|
+
assert.deepEqual(unscoped.projectionIssues, []);
|
|
577
772
|
const scoped = await scanLiteHistory({
|
|
578
773
|
homeDir: emptyHome,
|
|
579
774
|
hostname: "cchistory-lite-dir-estimate-host",
|
|
@@ -608,7 +803,7 @@ test("a --dir estimate keeps a logical-session group whose known cwds conflict",
|
|
|
608
803
|
await writeSession("split-a.jsonl", "/workspace/alpha", "1");
|
|
609
804
|
const splitB = await writeSession("split-b.jsonl", "/workspace/beta", "2");
|
|
610
805
|
await truncate(splitB, 256 * GIB);
|
|
611
|
-
await
|
|
806
|
+
const snapshot = await scanLiteHistory({
|
|
612
807
|
homeDir: emptyHome,
|
|
613
808
|
hostname: "cchistory-lite-dir-conflict-host",
|
|
614
809
|
sourceRefs: ["codex"],
|
|
@@ -618,13 +813,9 @@ test("a --dir estimate keeps a logical-session group whose known cwds conflict",
|
|
|
618
813
|
contextMode: "none",
|
|
619
814
|
scanGuard: { profile: "light" },
|
|
620
815
|
scanGuardDeps: { readAvailableBytes: () => 512 * MIB },
|
|
621
|
-
}), (error) => {
|
|
622
|
-
assert.ok(error instanceof ScanGuardRefusedError);
|
|
623
|
-
assert.equal(error.reason, "estimated_memory");
|
|
624
|
-
assert.equal(error.assessment?.directoryScoped, true);
|
|
625
|
-
assert.ok((error.assessment?.scannedBytes ?? 0) >= 256 * GIB);
|
|
626
|
-
return true;
|
|
627
816
|
});
|
|
817
|
+
assert.ok(snapshot.data.loss_audits.some(a => a.detail.includes("Read budget exceeded")));
|
|
818
|
+
assert.deepEqual(snapshot.projectionIssues, []);
|
|
628
819
|
}
|
|
629
820
|
finally {
|
|
630
821
|
await rm(tempHome, { recursive: true, force: true });
|
|
@@ -647,4 +838,17 @@ test("CCHISTORY_SCAN_GUARD=0 disables the lock, the estimate, and the watchdog",
|
|
|
647
838
|
delete process.env.CCHISTORY_SCAN_GUARD;
|
|
648
839
|
}
|
|
649
840
|
});
|
|
841
|
+
test("process available memory wins over host totals and preserves actual exhaustion", () => {
|
|
842
|
+
for (const available of [0, 128 * MIB]) {
|
|
843
|
+
assert.equal(readAvailableMemoryBytes({ totalmem: () => 64 * GIB, availableMemory: () => available, platform: "linux",
|
|
844
|
+
constrainedMemory: () => GIB, readMeminfo: () => "MemAvailable: 16777216 kB\n", freemem: () => 16 * GIB }), available);
|
|
845
|
+
}
|
|
846
|
+
});
|
|
847
|
+
test("sample/exact queue bypass retains local read admission without refusing the aggregate estimate", async () => {
|
|
848
|
+
const snapshot = await guardedFixtureScan({ profile: "light", bypass: true }, {
|
|
849
|
+
walkRootBytes: async () => MIB, readAvailableBytes: () => MIB, readHeapBytes: () => GIB,
|
|
850
|
+
});
|
|
851
|
+
assert.ok(snapshot.listResolvedSessions().length > 0);
|
|
852
|
+
assert.deepEqual(snapshot.projectionIssues, []);
|
|
853
|
+
});
|
|
650
854
|
//# sourceMappingURL=scan-guard.test.js.map
|