@cchistory/lite 0.4.4 → 0.5.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 +4 -5
- package/apps/lite-cli/dist/agent-contract.d.ts.map +1 -1
- package/apps/lite-cli/dist/agent-contract.js +35 -28
- package/apps/lite-cli/dist/agent-contract.js.map +1 -1
- package/apps/lite-cli/dist/bin.js +3 -3
- 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 +155 -81
- package/apps/lite-cli/dist/index.js.map +1 -1
- package/apps/lite-cli/dist/index.test.js +87 -63
- 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 +3 -3
- 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 +2 -2
- package/apps/lite-tui/dist/index.js.map +1 -1
- package/apps/lite-tui/dist/index.test.js +5 -3
- 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 +3 -3
- package/bin/cchistory-lite.mjs +3 -3
- package/docs/guide/for-agents.md +65 -42
- package/docs/guide/lite.md +64 -24
- 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 +0 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.js +0 -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 +263 -58
- 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/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 +32 -23
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.js +65 -45
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js +363 -59
- 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 +166 -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 +80 -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/parser.d.ts +2 -1
- package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/parser.js +4 -4
- 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 +54 -36
- 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 +75 -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 +125 -53
- 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
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { interpretSessionEvidence } from "@cchistory/canonical";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import { appendFile, cp, mkdir, mkdtemp, readFile, rm, utimes } from "node:fs/promises";
|
|
5
|
+
import { syncBuiltinESMExports } from "node:module";
|
|
6
|
+
import os from "node:os";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import test from "node:test";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { assertSourceFileReadPlanCurrent, getDefaultSourcesForHost, inspectSourceFilesLogicalSessionMetadata, runSourceProbe, SourceFileReadPlanChangedError, } from "@cchistory/source-adapters";
|
|
11
|
+
import { buildLiveSnapshot, resolveLiteSources, scanLiteHistory } from "./index.js";
|
|
12
|
+
import { PreparationMetadata } from "./preparation-metadata.js";
|
|
13
|
+
const mockData = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../../mock_data");
|
|
14
|
+
const codexFixture = path.join(mockData, "fixtures/source-shapes/codex/ordinary-fork.jsonl");
|
|
15
|
+
const parentFixture = path.join(mockData, ".codex/sessions/2026/04/12/rollout-2026-04-12T09-00-00-codex-delegation-parent.jsonl");
|
|
16
|
+
const later = new Date("2030-01-01T00:00:00.000Z");
|
|
17
|
+
async function seed() {
|
|
18
|
+
const root = await mkdtemp(path.join(os.tmpdir(), "cchistory-preparation-metadata-"));
|
|
19
|
+
const source = getDefaultSourcesForHost({ homeDir: root, includeMissing: true }).find((entry) => entry.platform === "codex");
|
|
20
|
+
return { root, source: { ...source, base_dir: root } };
|
|
21
|
+
}
|
|
22
|
+
test("preparation reuses unchanged metadata by source and path, preserving requested order", async () => {
|
|
23
|
+
const { root, source } = await seed();
|
|
24
|
+
try {
|
|
25
|
+
const files = [path.join(root, "fork.jsonl"), path.join(root, "parent.jsonl")];
|
|
26
|
+
await cp(codexFixture, files[0]);
|
|
27
|
+
await cp(parentFixture, files[1]);
|
|
28
|
+
const reads = [];
|
|
29
|
+
const preparation = new PreparationMetadata(async (platform, paths, options) => {
|
|
30
|
+
reads.push([...paths]);
|
|
31
|
+
return inspectSourceFilesLogicalSessionMetadata(platform, paths, options);
|
|
32
|
+
});
|
|
33
|
+
const options = { includeWorkspaceMetadata: true, workspaceScan: "first" };
|
|
34
|
+
const first = await preparation.inspect(source, files, options);
|
|
35
|
+
first.metadata[0].sessionKey = "caller-mutated";
|
|
36
|
+
const reversed = await preparation.inspect(source, [files[1], files[0], files[1]], options);
|
|
37
|
+
assert.deepEqual(reads, [files]);
|
|
38
|
+
assert.deepEqual(reversed.metadata.map((entry) => entry.sessionKey), [
|
|
39
|
+
"sess:codex:codex-delegation-parent", "sess:codex:codex-ordinary-fork", "sess:codex:codex-delegation-parent",
|
|
40
|
+
]);
|
|
41
|
+
assert.equal(reversed.evidence[0], first.evidence[0]);
|
|
42
|
+
await preparation.inspect({ ...source, id: `${source.id}-other` }, [files[0]], options);
|
|
43
|
+
assert.equal(reads.length, 2, "different sources must not share an entry");
|
|
44
|
+
// Excluded files still support earlier selection decisions even when only a subset is reused.
|
|
45
|
+
await appendFile(files[0], "\n");
|
|
46
|
+
await utimes(files[0], later, later);
|
|
47
|
+
const subset = await preparation.inspect(source, [files[1]], options);
|
|
48
|
+
await assert.rejects(assertSourceFileReadPlanCurrent(subset.evidence[0]), SourceFileReadPlanChangedError);
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
await rm(root, { recursive: true, force: true });
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
test("identity, first cwd, and full cwd remain separate metadata contracts", async () => {
|
|
55
|
+
const { root, source } = await seed();
|
|
56
|
+
try {
|
|
57
|
+
const file = path.join(root, "changing-cwd.jsonl");
|
|
58
|
+
await cp(codexFixture, file);
|
|
59
|
+
// A later fixture record changes cwd: the first-line optimization must not answer a full scan.
|
|
60
|
+
const laterRecord = (await readFile(parentFixture, "utf8")).split("\n")[0]
|
|
61
|
+
.replace("01:00:00", "02:00:00");
|
|
62
|
+
await appendFile(file, `${laterRecord}\n`);
|
|
63
|
+
await utimes(file, later, later);
|
|
64
|
+
let reads = 0;
|
|
65
|
+
const preparation = new PreparationMetadata(async (...args) => {
|
|
66
|
+
reads += 1;
|
|
67
|
+
return inspectSourceFilesLogicalSessionMetadata(...args);
|
|
68
|
+
});
|
|
69
|
+
const first = await preparation.inspect(source, [file], { workspaceScan: "first" });
|
|
70
|
+
const full = await preparation.inspect(source, [file], {});
|
|
71
|
+
const identity = await preparation.inspect(source, [file], { includeWorkspaceMetadata: false });
|
|
72
|
+
assert.equal(first.metadata[0]?.workingDirectory, "/workspace/codex-ordinary-fork");
|
|
73
|
+
assert.equal(full.metadata[0]?.workingDirectory, "/workspace/codex-delegated");
|
|
74
|
+
assert.equal(identity.metadata[0]?.workingDirectoryState, "absent");
|
|
75
|
+
assert.equal(identity.metadata[0]?.sessionKey, first.metadata[0]?.sessionKey);
|
|
76
|
+
assert.deepEqual(await preparation.inspect(source, [file], { includeWorkspaceMetadata: true, workspaceScan: "full" }), full);
|
|
77
|
+
assert.equal(reads, 3);
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
await rm(root, { recursive: true, force: true });
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
test("metadata reuse rejects changed or removed evidence; a new attempt reads afresh", async () => {
|
|
84
|
+
const { root, source } = await seed();
|
|
85
|
+
try {
|
|
86
|
+
const file = path.join(root, "fork.jsonl");
|
|
87
|
+
await cp(codexFixture, file);
|
|
88
|
+
let reads = 0;
|
|
89
|
+
const inspect = async (...args) => {
|
|
90
|
+
reads += 1;
|
|
91
|
+
return inspectSourceFilesLogicalSessionMetadata(...args);
|
|
92
|
+
};
|
|
93
|
+
const preparation = new PreparationMetadata(inspect);
|
|
94
|
+
await preparation.inspect(source, [file], {});
|
|
95
|
+
await appendFile(file, "\n");
|
|
96
|
+
await utimes(file, later, later);
|
|
97
|
+
await assert.rejects(preparation.inspect(source, [file], {}), SourceFileReadPlanChangedError);
|
|
98
|
+
assert.equal(reads, 1);
|
|
99
|
+
const fresh = new PreparationMetadata(inspect);
|
|
100
|
+
await fresh.inspect(source, [file], {});
|
|
101
|
+
assert.equal(reads, 2);
|
|
102
|
+
await rm(file);
|
|
103
|
+
await assert.rejects(fresh.inspect(source, [file], {}), SourceFileReadPlanChangedError);
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
await rm(root, { recursive: true, force: true });
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
test("metadata changed during inspection is never admitted for reuse", async () => {
|
|
110
|
+
const { root, source } = await seed();
|
|
111
|
+
try {
|
|
112
|
+
const file = path.join(root, "fork.jsonl");
|
|
113
|
+
await cp(codexFixture, file);
|
|
114
|
+
let reads = 0;
|
|
115
|
+
const preparation = new PreparationMetadata(async (...args) => {
|
|
116
|
+
reads += 1;
|
|
117
|
+
const result = await inspectSourceFilesLogicalSessionMetadata(...args);
|
|
118
|
+
if (reads === 1) {
|
|
119
|
+
await appendFile(file, "\n");
|
|
120
|
+
await utimes(file, later, later);
|
|
121
|
+
}
|
|
122
|
+
return result;
|
|
123
|
+
});
|
|
124
|
+
await assert.rejects(preparation.inspect(source, [file], {}), SourceFileReadPlanChangedError);
|
|
125
|
+
await preparation.inspect(source, [file], {});
|
|
126
|
+
assert.equal(reads, 2);
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
await rm(root, { recursive: true, force: true });
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
test("reused uncertain metadata stays uncertain and newly appearing evidence invalidates it", async () => {
|
|
133
|
+
const { root, source } = await seed();
|
|
134
|
+
try {
|
|
135
|
+
const missing = path.join(root, "missing.jsonl");
|
|
136
|
+
let reads = 0;
|
|
137
|
+
const preparation = new PreparationMetadata(async (...args) => {
|
|
138
|
+
reads += 1;
|
|
139
|
+
return inspectSourceFilesLogicalSessionMetadata(...args);
|
|
140
|
+
});
|
|
141
|
+
const first = await preparation.inspect(source, [missing], {});
|
|
142
|
+
assert.equal(first.metadata[0]?.sessionKeyState, "uncertain");
|
|
143
|
+
assert.equal(first.metadata[0]?.workingDirectoryState, "uncertain");
|
|
144
|
+
assert.deepEqual(await preparation.inspect(source, [missing], {}), first);
|
|
145
|
+
assert.equal(reads, 1);
|
|
146
|
+
await cp(codexFixture, missing);
|
|
147
|
+
await assert.rejects(preparation.inspect(source, [missing], {}), SourceFileReadPlanChangedError);
|
|
148
|
+
}
|
|
149
|
+
finally {
|
|
150
|
+
await rm(root, { recursive: true, force: true });
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
test("sample --dir reuses Claude metadata while preserving projection and refresh isolation", async (t) => {
|
|
154
|
+
const root = await mkdtemp(path.join(os.tmpdir(), "cchistory-preparation-sample-"));
|
|
155
|
+
const originalCreateReadStream = fs.createReadStream;
|
|
156
|
+
const file = path.join(root, "projects/-workspace-claude-resume/ordinary.jsonl");
|
|
157
|
+
let reads = 0;
|
|
158
|
+
try {
|
|
159
|
+
await mkdir(path.dirname(file), { recursive: true });
|
|
160
|
+
await cp(path.join(mockData, "fixtures/source-shapes/claude/ordinary-parent-uuid.jsonl"), file);
|
|
161
|
+
const baseDir = path.join(root, "projects");
|
|
162
|
+
const options = {
|
|
163
|
+
homeDir: root,
|
|
164
|
+
sourceRefs: ["claude_code"],
|
|
165
|
+
sourceRoots: [{ sourceRef: "claude_code", baseDir }],
|
|
166
|
+
directoryScope: "/workspace/claude-resume",
|
|
167
|
+
sample: { perSource: 1 },
|
|
168
|
+
safeMode: true,
|
|
169
|
+
contextMode: "none",
|
|
170
|
+
};
|
|
171
|
+
const expected = buildLiveSnapshot(await runSourceProbe(interpretSessionEvidence, { safe_mode: true }, await resolveLiteSources(options)));
|
|
172
|
+
t.mock.method(fs, "createReadStream", ((target, streamOptions) => {
|
|
173
|
+
if (target === file)
|
|
174
|
+
reads += 1;
|
|
175
|
+
return originalCreateReadStream(target, streamOptions);
|
|
176
|
+
}));
|
|
177
|
+
syncBuiltinESMExports();
|
|
178
|
+
const actual = await scanLiteHistory(options);
|
|
179
|
+
assert.equal(reads, 1, "the sample and logical grouping must share one full metadata read");
|
|
180
|
+
assert.deepEqual(actual.listResolvedSessions(), expected.listResolvedSessions());
|
|
181
|
+
assert.deepEqual(actual.listResolvedTurns(), expected.listResolvedTurns());
|
|
182
|
+
assert.deepEqual(actual.projectionIssues, []);
|
|
183
|
+
await scanLiteHistory(options);
|
|
184
|
+
assert.equal(reads, 2, "refresh must own a fresh preparation");
|
|
185
|
+
}
|
|
186
|
+
finally {
|
|
187
|
+
t.mock.restoreAll();
|
|
188
|
+
syncBuiltinESMExports();
|
|
189
|
+
await rm(root, { recursive: true, force: true });
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
//# sourceMappingURL=preparation-metadata.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preparation-metadata.test.js","sourceRoot":"","sources":["../src/preparation-metadata.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAE,qBAAqB,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;QACxB,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC;QAC9C,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,mEAAmE,CAAC,CAAC;QAC5F,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,oBAAoB,EAAE,EAAE,QAAQ,CAAC,oBAAoB,EAAE,CAAC,CAAC;QACjF,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,iBAAiB,EAAE,EAAE,QAAQ,CAAC,iBAAiB,EAAE,CAAC,CAAC;QAC3E,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;QAC9C,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC;QAC/B,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,sCAAsC,CAAC,CAAC;IACjE,CAAC;YAAS,CAAC;QACT,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;QACpB,qBAAqB,EAAE,CAAC;QACxB,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1,21 +1,11 @@
|
|
|
1
|
+
import { type AvailableMemoryReading } from "./system-memory.js";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* 1. The adaptive heap ceiling (node-memory.ts) budgets old-space from
|
|
9
|
-
* AVAILABLE memory rather than host totals.
|
|
10
|
-
* 2. An advisory lock serializes full scans on this machine.
|
|
11
|
-
* 3. A watchdog aborts a scan if available memory collapses mid-probe.
|
|
12
|
-
* 4. A pre-flight estimate (sound because the lock serializes scans) refuses
|
|
13
|
-
* scans whose conservative peak estimate risks the machine.
|
|
14
|
-
*
|
|
15
|
-
* Everything here is best-effort: internal errors degrade to "proceed", never
|
|
16
|
-
* to a blocked scan. Only the explicit refuse/abort paths stop one. The
|
|
17
|
-
* kill-switch env is read by the caller (the live-runtime entry), not here, so
|
|
18
|
-
* tests pass behavior explicitly.
|
|
3
|
+
* Best-effort scan admission: shared availability readings, a scan queue,
|
|
4
|
+
* preflight estimates and progress/checkpoint sampling. Native-byte admission
|
|
5
|
+
* is installed by live-runtime and consumed by adapters before payload reads.
|
|
6
|
+
* These heuristics cannot guarantee against every synchronous/native allocation
|
|
7
|
+
* or concurrent change in host load. Only explicit budget/refusal paths stop a
|
|
8
|
+
* scan; unavailable OS signals fall back to the remaining V8 heap for admission.
|
|
19
9
|
*/
|
|
20
10
|
export type ScanGuardProfile = "light" | "full";
|
|
21
11
|
export type ScanGuardStatus = "ok" | "warn" | "refuse";
|
|
@@ -26,8 +16,8 @@ export declare const SCAN_GUARD_WARN_AVAILABLE_FRACTION = 0.5;
|
|
|
26
16
|
export declare const SCAN_LOCK_WAIT_MS = 30000;
|
|
27
17
|
export declare const SCAN_LOCK_POLL_MS = 250;
|
|
28
18
|
export declare const SCAN_LOCK_MAX_HOLDER_AGE_MS: number;
|
|
29
|
-
export declare const
|
|
30
|
-
export declare
|
|
19
|
+
export declare const SCAN_WATCHDOG_AVAILABLE_RESERVE_FRACTION: number;
|
|
20
|
+
export declare function readRemainingHeapBytes(): number;
|
|
31
21
|
export declare const SCAN_WATCHDOG_CHECK_EVERY_FILES = 64;
|
|
32
22
|
export declare const SCAN_WATCHDOG_CHECK_INTERVAL_MS = 1000;
|
|
33
23
|
export interface ScanRiskRoot {
|
|
@@ -41,12 +31,22 @@ export interface ScanRiskAssessment {
|
|
|
41
31
|
profile: ScanGuardProfile;
|
|
42
32
|
/** scannedBytes × the profile multiplier — the conservative peak estimate. */
|
|
43
33
|
estimatedBytes: number;
|
|
44
|
-
/**
|
|
34
|
+
/** Effective admission headroom: smaller of the system estimate and V8 heap. */
|
|
45
35
|
availableBytes?: number;
|
|
46
|
-
/**
|
|
36
|
+
/** OS estimate, not total physical RAM or a guaranteed allocation allowance. */
|
|
37
|
+
systemAvailableBytes?: number;
|
|
38
|
+
heapAvailableBytes?: number;
|
|
39
|
+
memorySignal?: AvailableMemoryReading["source"] | "injected";
|
|
40
|
+
limitingResource?: "system" | "heap";
|
|
41
|
+
/** Bytes the scan would probe under the selected roots, pre-multiplier. */
|
|
47
42
|
scannedBytes: number;
|
|
48
43
|
/** Per-root walk totals that summed to scannedBytes. */
|
|
49
44
|
roots?: readonly ScanRiskRoot[];
|
|
45
|
+
/**
|
|
46
|
+
* True when the estimate counted `--dir`-filtered files rather than every
|
|
47
|
+
* regular file under the selected roots.
|
|
48
|
+
*/
|
|
49
|
+
directoryScoped?: boolean;
|
|
50
50
|
/** Neutral machine-readable note; surfaces compose the human message. */
|
|
51
51
|
detail: string;
|
|
52
52
|
}
|
|
@@ -60,10 +60,17 @@ export interface AssessScanRiskInput {
|
|
|
60
60
|
/** Per-root cap on files counted, mirroring limit_files_per_source. */
|
|
61
61
|
limitFiles?: number;
|
|
62
62
|
profile: ScanGuardProfile;
|
|
63
|
+
/**
|
|
64
|
+
* When true, the caller walked the same `--dir`-filtered file set the scan
|
|
65
|
+
* would probe. Refusal copy then says the estimate is already scoped.
|
|
66
|
+
*/
|
|
67
|
+
directoryScoped?: boolean;
|
|
63
68
|
}
|
|
64
69
|
export interface AssessScanRiskDeps {
|
|
65
|
-
walkRootBytes?: (root: string, limitFiles?: number) => Promise<number>;
|
|
70
|
+
walkRootBytes?: (root: string, limitFiles?: number, slotId?: string) => Promise<number>;
|
|
66
71
|
readAvailableBytes?: () => number | undefined;
|
|
72
|
+
readMemory?: () => AvailableMemoryReading;
|
|
73
|
+
readHeapBytes?: () => number;
|
|
67
74
|
}
|
|
68
75
|
export declare function assessScanRisk(input: AssessScanRiskInput, deps?: AssessScanRiskDeps): Promise<ScanRiskAssessment>;
|
|
69
76
|
export interface ScanLockHolder {
|
|
@@ -102,7 +109,9 @@ export declare function acquireScanLock(deps?: ScanLockDeps): Promise<ScanLockAc
|
|
|
102
109
|
export declare function defaultScanLockPath(env?: NodeJS.ProcessEnv, tmpdir?: () => string): string;
|
|
103
110
|
export interface ScanWatchdogDeps {
|
|
104
111
|
readAvailableBytes?: () => number | undefined;
|
|
105
|
-
/**
|
|
112
|
+
/** Initial available bytes, sampled once when omitted. */
|
|
113
|
+
initialAvailableBytes?: number;
|
|
114
|
+
/** @deprecated Host total is deliberately ignored. */
|
|
106
115
|
totalBytes?: number;
|
|
107
116
|
/** Explicit floor override; wins over the computed one. */
|
|
108
117
|
floorBytes?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan-guard.d.ts","sourceRoot":"","sources":["../src/scan-guard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scan-guard.d.ts","sourceRoot":"","sources":["../src/scan-guard.ts"],"names":[],"mappings":"AAMA,OAAO,EAAiD,KAAK,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEhH;;;;;;;GAOG;AAEH,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,MAAM,CAAC;AAChD,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,MAAM,GAAG,QAAQ,CAAC;AAOvD,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAC9C,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAI7C,eAAO,MAAM,oCAAoC,OAAO,CAAC;AACzD,eAAO,MAAM,kCAAkC,MAAM,CAAC;AAKtD,eAAO,MAAM,iBAAiB,QAAS,CAAC;AACxC,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,2BAA2B,QAAc,CAAC;AAKvD,eAAO,MAAM,wCAAwC,QAA2C,CAAC;AACjG,wBAAgB,sBAAsB,IAAI,MAAM,CAG/C;AAGD,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAClD,eAAO,MAAM,+BAA+B,OAAQ,CAAC;AAErD,MAAM,WAAW,YAAY;IA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AE,MAAM,CAAC;KACnB;CAQF;AAED,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,IAAI,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE;CAWlE;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,kBAAkB,CAAC;CAChC;AAED,MAAM,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAEhD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAIxE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAW1D;AAED,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,kBAAkB,GAAG,MAAM,CAQ7E"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { readFileSync, unlinkSync } from "node:fs";
|
|
2
2
|
import { mkdir, open, readdir, readFile, stat, unlink } from "node:fs/promises";
|
|
3
3
|
import os from "node:os";
|
|
4
|
+
import { getHeapStatistics } from "node:v8";
|
|
4
5
|
import path from "node:path";
|
|
5
6
|
import process from "node:process";
|
|
6
|
-
import { readAvailableMemoryBytes } from "./system-memory.js";
|
|
7
|
+
import { readAvailableMemory, readAvailableMemoryBytes } from "./system-memory.js";
|
|
7
8
|
// JS object graphs run several times larger than the raw bytes they were
|
|
8
9
|
// parsed from, and even a light scan peaks during per-session parsing (the
|
|
9
10
|
// probe builds full turn context before contextMode "none" discards it). A
|
|
10
11
|
// full scan additionally retains every turn's context until exit. Both
|
|
11
|
-
// multipliers are
|
|
12
|
+
// multipliers are conservative planning heuristics, not proven allocation bounds.
|
|
12
13
|
export const LIGHT_SCAN_MEMORY_MULTIPLIER = 4;
|
|
13
14
|
export const FULL_SCAN_MEMORY_MULTIPLIER = 8;
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
// rest while the scan runs.
|
|
15
|
+
// Use fractions of the smaller of estimated system availability and remaining
|
|
16
|
+
// V8 heap. Leave room for allocation overhead and concurrent changes in load.
|
|
17
17
|
export const SCAN_GUARD_REFUSE_AVAILABLE_FRACTION = 0.75;
|
|
18
18
|
export const SCAN_GUARD_WARN_AVAILABLE_FRACTION = 0.5;
|
|
19
19
|
// A full scan normally takes seconds; 30s bounds the wait so a queued command
|
|
@@ -23,12 +23,13 @@ export const SCAN_LOCK_WAIT_MS = 30_000;
|
|
|
23
23
|
export const SCAN_LOCK_POLL_MS = 250;
|
|
24
24
|
export const SCAN_LOCK_MAX_HOLDER_AGE_MS = 30 * 60_000;
|
|
25
25
|
const SCAN_LOCK_MAX_STEALS = 3;
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
// Reserve a quarter of the availability observed when this scan starts. This
|
|
27
|
+
// shares the preflight consumption fraction and never uses host total in a container.
|
|
28
|
+
export const SCAN_WATCHDOG_AVAILABLE_RESERVE_FRACTION = 1 - SCAN_GUARD_REFUSE_AVAILABLE_FRACTION;
|
|
29
|
+
export function readRemainingHeapBytes() {
|
|
30
|
+
const heap = getHeapStatistics();
|
|
31
|
+
return Math.max(0, heap.heap_size_limit - heap.used_heap_size);
|
|
32
|
+
}
|
|
32
33
|
// A meminfo read is microseconds; every 64 files or 1s keeps the check off the
|
|
33
34
|
// hot path while bounding how long a collapse goes unnoticed on slow scans.
|
|
34
35
|
export const SCAN_WATCHDOG_CHECK_EVERY_FILES = 64;
|
|
@@ -42,7 +43,7 @@ export async function assessScanRisk(input, deps = {}) {
|
|
|
42
43
|
let walkFailed = false;
|
|
43
44
|
for (const root of normalizedRoots) {
|
|
44
45
|
try {
|
|
45
|
-
const bytes = await walk(root.path, input.limitFiles);
|
|
46
|
+
const bytes = await walk(root.path, input.limitFiles, root.slot_id);
|
|
46
47
|
roots.push({ path: root.path, bytes, ...(root.slot_id ? { slot_id: root.slot_id } : {}) });
|
|
47
48
|
scannedBytes += bytes;
|
|
48
49
|
}
|
|
@@ -53,19 +54,29 @@ export async function assessScanRisk(input, deps = {}) {
|
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
const estimatedBytes = scannedBytes * multiplier;
|
|
56
|
-
let
|
|
57
|
+
let memory;
|
|
57
58
|
try {
|
|
58
|
-
|
|
59
|
+
memory = deps.readAvailableBytes
|
|
60
|
+
? { bytes: deps.readAvailableBytes(), source: "injected" }
|
|
61
|
+
: (deps.readMemory ?? readAvailableMemory)();
|
|
59
62
|
}
|
|
60
63
|
catch {
|
|
61
|
-
|
|
64
|
+
memory = { source: "unknown" };
|
|
62
65
|
}
|
|
66
|
+
const heapBytes = Math.max(0, (deps.readHeapBytes ?? readRemainingHeapBytes)());
|
|
67
|
+
const systemAvailableBytes = memory.bytes;
|
|
68
|
+
const availableBytes = systemAvailableBytes === undefined ? heapBytes : Math.min(systemAvailableBytes, heapBytes);
|
|
63
69
|
const shared = {
|
|
64
70
|
profile: input.profile,
|
|
65
71
|
estimatedBytes,
|
|
66
72
|
availableBytes,
|
|
73
|
+
systemAvailableBytes,
|
|
74
|
+
heapAvailableBytes: heapBytes,
|
|
75
|
+
memorySignal: systemAvailableBytes === undefined ? "unknown" : memory.source,
|
|
76
|
+
limitingResource: systemAvailableBytes === undefined || heapBytes <= systemAvailableBytes ? "heap" : "system",
|
|
67
77
|
scannedBytes,
|
|
68
78
|
roots,
|
|
79
|
+
...(input.directoryScoped ? { directoryScoped: true } : {}),
|
|
69
80
|
};
|
|
70
81
|
if (walkFailed) {
|
|
71
82
|
return {
|
|
@@ -74,31 +85,24 @@ export async function assessScanRisk(input, deps = {}) {
|
|
|
74
85
|
detail: "scan guard could not walk every selected root; proceeding without a complete estimate",
|
|
75
86
|
};
|
|
76
87
|
}
|
|
77
|
-
if (availableBytes === undefined) {
|
|
78
|
-
return {
|
|
79
|
-
...shared,
|
|
80
|
-
status: "ok",
|
|
81
|
-
detail: "available system memory is unknown; proceeding without a memory estimate",
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
88
|
if (estimatedBytes > availableBytes * SCAN_GUARD_REFUSE_AVAILABLE_FRACTION) {
|
|
85
89
|
return {
|
|
86
90
|
...shared,
|
|
87
91
|
status: "refuse",
|
|
88
|
-
detail: "estimated peak exceeds 75% of
|
|
92
|
+
detail: "estimated peak exceeds 75% of admission headroom",
|
|
89
93
|
};
|
|
90
94
|
}
|
|
91
95
|
if (estimatedBytes > availableBytes * SCAN_GUARD_WARN_AVAILABLE_FRACTION) {
|
|
92
96
|
return {
|
|
93
97
|
...shared,
|
|
94
98
|
status: "warn",
|
|
95
|
-
detail: "estimated peak exceeds 50% of
|
|
99
|
+
detail: "estimated peak exceeds 50% of admission headroom",
|
|
96
100
|
};
|
|
97
101
|
}
|
|
98
102
|
return {
|
|
99
103
|
...shared,
|
|
100
104
|
status: "ok",
|
|
101
|
-
detail: "estimated peak within
|
|
105
|
+
detail: "estimated peak within admission headroom",
|
|
102
106
|
};
|
|
103
107
|
}
|
|
104
108
|
/**
|
|
@@ -302,7 +306,14 @@ function isAlreadyExistsError(error) {
|
|
|
302
306
|
export function createScanWatchdog(deps = {}) {
|
|
303
307
|
const now = deps.now ?? Date.now;
|
|
304
308
|
const readAvailable = deps.readAvailableBytes ?? (() => readAvailableMemoryBytes());
|
|
305
|
-
|
|
309
|
+
let initialAvailableBytes = deps.initialAvailableBytes;
|
|
310
|
+
if (initialAvailableBytes === undefined && deps.floorBytes === undefined) {
|
|
311
|
+
try {
|
|
312
|
+
initialAvailableBytes = readAvailable();
|
|
313
|
+
}
|
|
314
|
+
catch { /* unknown */ }
|
|
315
|
+
}
|
|
316
|
+
const floorBytes = deps.floorBytes ?? Math.floor((initialAvailableBytes ?? 0) * SCAN_WATCHDOG_AVAILABLE_RESERVE_FRACTION);
|
|
306
317
|
const checkEveryFiles = deps.checkEveryFiles ?? SCAN_WATCHDOG_CHECK_EVERY_FILES;
|
|
307
318
|
const checkIntervalMs = deps.checkIntervalMs ?? SCAN_WATCHDOG_CHECK_INTERVAL_MS;
|
|
308
319
|
let filesSinceCheck = 0;
|
|
@@ -324,7 +335,7 @@ export function createScanWatchdog(deps = {}) {
|
|
|
324
335
|
}
|
|
325
336
|
if (available === undefined)
|
|
326
337
|
return; // Unknown availability: nothing to compare.
|
|
327
|
-
if (available < floorBytes) {
|
|
338
|
+
if (available === 0 || available < floorBytes) {
|
|
328
339
|
breached = true;
|
|
329
340
|
breachAvailableBytes = available;
|
|
330
341
|
abort();
|
|
@@ -343,6 +354,7 @@ export function createScanWatchdog(deps = {}) {
|
|
|
343
354
|
assertHealthy() {
|
|
344
355
|
if (breached)
|
|
345
356
|
abort();
|
|
357
|
+
check();
|
|
346
358
|
},
|
|
347
359
|
};
|
|
348
360
|
}
|
|
@@ -364,9 +376,8 @@ export class ScanGuardAbortedError extends Error {
|
|
|
364
376
|
availableBytes;
|
|
365
377
|
floorBytes;
|
|
366
378
|
constructor(init) {
|
|
367
|
-
super(`Scan aborted: available
|
|
368
|
-
|
|
369
|
-
`Retry when the machine is less loaded. Override the guard with CCHISTORY_SCAN_GUARD=0.`);
|
|
379
|
+
super(`Scan aborted: system available-memory estimate dropped to ${init.availableBytes === undefined ? "an unknown level" : formatScanGuardBytes(init.availableBytes)}, below the ${formatScanGuardBytes(init.floorBytes)} reserve set at scan start. ` +
|
|
380
|
+
formatScanBoundNextSteps());
|
|
370
381
|
this.name = "ScanGuardAbortedError";
|
|
371
382
|
this.availableBytes = init.availableBytes;
|
|
372
383
|
this.floorBytes = init.floorBytes;
|
|
@@ -399,8 +410,7 @@ export function formatScanGuardWarning(assessment) {
|
|
|
399
410
|
const multiplier = assessment.profile === "full" ? FULL_SCAN_MEMORY_MULTIPLIER : LIGHT_SCAN_MEMORY_MULTIPLIER;
|
|
400
411
|
return `Scan guard warning: estimated peak memory ${formatScanGuardBytes(assessment.estimatedBytes)} ` +
|
|
401
412
|
`(${assessment.profile} scan of ${formatScanGuardBytes(assessment.scannedBytes)} source bytes, ×${multiplier}) ` +
|
|
402
|
-
`exceeds 50% of the ${available}
|
|
403
|
-
`Consider \`sample\`, \`shell\`, or \`query\` to lower peak memory; CCHISTORY_SCAN_GUARD=0 disables the guard.`;
|
|
413
|
+
`exceeds 50% of the ${available} admission headroom; proceeding. ${formatMemorySignals(assessment)}`;
|
|
404
414
|
}
|
|
405
415
|
function buildRefusalMessage(init) {
|
|
406
416
|
if (init.reason === "scan_in_progress") {
|
|
@@ -411,35 +421,45 @@ function buildRefusalMessage(init) {
|
|
|
411
421
|
const waitedSeconds = Math.round((init.waitedMs ?? 0) / 1000);
|
|
412
422
|
return `Refusing to scan: another cchistory-lite scan is still running (${holderDescription}); ` +
|
|
413
423
|
`waited ${waitedSeconds}s for it to finish. ` +
|
|
414
|
-
`
|
|
415
|
-
`\`sample\` and \`show session <exact id>\` bypass the scan lock. ` +
|
|
416
|
-
`Override the guard with CCHISTORY_SCAN_GUARD=0.`;
|
|
424
|
+
`Wait for that scan to finish, or reuse its \`shell\` / \`query\` session.`;
|
|
417
425
|
}
|
|
418
426
|
const assessment = init.assessment;
|
|
419
427
|
const multiplier = assessment?.profile === "full" ? FULL_SCAN_MEMORY_MULTIPLIER : LIGHT_SCAN_MEMORY_MULTIPLIER;
|
|
420
428
|
const available = assessment?.availableBytes === undefined
|
|
421
429
|
? "unknown"
|
|
422
430
|
: formatScanGuardBytes(assessment.availableBytes);
|
|
431
|
+
const directoryNote = assessment?.directoryScoped
|
|
432
|
+
? "--dir already limited this estimate to files that may match that working directory."
|
|
433
|
+
: "--dir also bounds the estimate when a collection command uses it; this scan has no --dir filter.";
|
|
423
434
|
return `Refusing to scan: estimated peak memory ${formatScanGuardBytes(assessment?.estimatedBytes ?? 0)} ` +
|
|
424
435
|
`(${assessment?.profile ?? "light"} scan of ${formatScanGuardBytes(assessment?.scannedBytes ?? 0)} source bytes, ×${multiplier}) ` +
|
|
425
|
-
`exceeds 75% of the ${available}
|
|
426
|
-
`${formatSelectedSourceRoots(assessment
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
436
|
+
`exceeds 75% of the ${available} admission headroom. ${formatMemorySignals(assessment)}` +
|
|
437
|
+
`${formatSelectedSourceRoots(assessment)} ` +
|
|
438
|
+
`${directoryNote} ` +
|
|
439
|
+
formatScanBoundNextSteps();
|
|
440
|
+
}
|
|
441
|
+
function formatMemorySignals(assessment) {
|
|
442
|
+
const system = assessment?.systemAvailableBytes === undefined ? "unknown" : formatScanGuardBytes(assessment.systemAvailableBytes);
|
|
443
|
+
const heap = assessment?.heapAvailableBytes === undefined ? "unknown" : formatScanGuardBytes(assessment.heapAvailableBytes);
|
|
444
|
+
return `System available-memory estimate: ${system} (${assessment?.memorySignal ?? "unknown"}); ` +
|
|
445
|
+
`remaining V8 heap: ${heap}; limiting resource: ${assessment?.limitingResource ?? "unknown"}. ` +
|
|
446
|
+
"Lite does not set the Node heap limit.";
|
|
430
447
|
}
|
|
431
|
-
function formatSelectedSourceRoots(
|
|
448
|
+
function formatSelectedSourceRoots(assessment) {
|
|
449
|
+
const roots = assessment?.roots;
|
|
432
450
|
if (!roots?.length)
|
|
433
451
|
return "";
|
|
434
452
|
const lines = roots.map((root) => {
|
|
435
453
|
const slot = root.slot_id ? `${root.slot_id} ` : "";
|
|
436
454
|
return ` ${slot}${root.path} ${formatScanGuardBytes(root.bytes)}`;
|
|
437
455
|
});
|
|
438
|
-
|
|
456
|
+
const heading = assessment?.directoryScoped
|
|
457
|
+
? "Selected source roots after --dir filter:"
|
|
458
|
+
: "Selected source roots:";
|
|
459
|
+
return ` ${heading}\n${lines.join("\n")}`;
|
|
439
460
|
}
|
|
440
461
|
function formatScanBoundNextSteps() {
|
|
441
|
-
return "
|
|
442
|
-
"
|
|
443
|
-
"to list slots without a full parse; `shell` / `query` amortize one scan over many reads.";
|
|
462
|
+
return "No complete result was produced; keep the requested scope. `cchistory-lite sources --json` lists adapter roots without parsing history. " +
|
|
463
|
+
"Report the resource limit before changing scope or memory settings. File count and sample size are not memory bounds; shell reuses a successful read.";
|
|
444
464
|
}
|
|
445
465
|
//# sourceMappingURL=scan-guard.js.map
|