@cchistory/lite 0.4.5 → 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 +32 -25
- 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 +147 -66
- package/apps/lite-cli/dist/index.js.map +1 -1
- package/apps/lite-cli/dist/index.test.js +76 -60
- 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 -46
- package/docs/guide/lite.md +49 -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 +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 -142
- 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 +21 -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 -41
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js +266 -57
- 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 -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
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { CanonicalQueryResult, LogicalQuery, LossAuditRecord, SourceStatus } from "@cchistory/domain";
|
|
2
|
+
import { type ProjectionAuditIssue } from "@cchistory/canonical";
|
|
3
|
+
export interface QueryReadWork {
|
|
4
|
+
/** Entries returned by source discovery, before scope/group selection. */
|
|
5
|
+
discoveredPrimaryFiles: number;
|
|
6
|
+
plannedPrimaryFiles: number;
|
|
7
|
+
/** Unique files consulted for grouping metadata; not bytes or physical read-call counts. */
|
|
8
|
+
metadataEvidenceFiles: number;
|
|
9
|
+
inventoryFiles: number;
|
|
10
|
+
inventoryBytesRead: number;
|
|
11
|
+
inventoryRecordsDecoded: number;
|
|
12
|
+
payloadFilesProcessed: number;
|
|
13
|
+
/** Collected native records passed through the payload pipeline, not JSON.parse invocations. */
|
|
14
|
+
payloadRecordsProcessed: number;
|
|
15
|
+
canonicalInterpretations: number;
|
|
16
|
+
retainedSessions: number;
|
|
17
|
+
retainedTurns: number;
|
|
18
|
+
skippedPrimaryFiles: number;
|
|
19
|
+
fallbackReason?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface LiveQueryRead {
|
|
22
|
+
identity: {
|
|
23
|
+
id: string;
|
|
24
|
+
prepared_at: string;
|
|
25
|
+
};
|
|
26
|
+
sourceIds: string[];
|
|
27
|
+
directoryScope?: string;
|
|
28
|
+
directoryScopeDiagnostics?: ReturnType<typeof import("@cchistory/canonical").summarizeDirectoryScope>;
|
|
29
|
+
result: CanonicalQueryResult;
|
|
30
|
+
projectionIssues: readonly ProjectionAuditIssue[];
|
|
31
|
+
sources: SourceStatus[];
|
|
32
|
+
lossAudits: LossAuditRecord[];
|
|
33
|
+
/** Work counters are library diagnostics, not a second user query result format. */
|
|
34
|
+
work: QueryReadWork;
|
|
35
|
+
}
|
|
36
|
+
export interface SelectiveGroupPlan {
|
|
37
|
+
groups: {
|
|
38
|
+
files: readonly string[];
|
|
39
|
+
targetSessionRefs?: readonly string[];
|
|
40
|
+
}[];
|
|
41
|
+
upperBounds: string[];
|
|
42
|
+
query: LogicalQuery;
|
|
43
|
+
stopped: boolean;
|
|
44
|
+
}
|
|
45
|
+
export declare function newQueryReadWork(): QueryReadWork;
|
|
46
|
+
export declare function isSelectiveLatestQuery(query: LogicalQuery): boolean;
|
|
47
|
+
//# sourceMappingURL=selective-query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selective-query.d.ts","sourceRoot":"","sources":["../src/selective-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC3G,OAAO,EAA2B,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE1F,MAAM,WAAW,aAAa;IAC5B,0EAA0E;IAC1E,sBAAsB,EAAE,MAAM,CAAC;IAC/B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,4FAA4F;IAC5F,qBAAqB,EAAE,MAAM,CAAC;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,uBAAuB,EAAE,MAAM,CAAC;IAChC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gGAAgG;IAChG,uBAAuB,EAAE,MAAM,CAAC;IAChC,wBAAwB,EAAE,MAAM,CAAC;IACjC,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AACD,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9C,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yBAAyB,CAAC,EAAE,UAAU,CAAC,cAAc,sBAAsB,EAAE,uBAAuB,CAAC,CAAC;IACtG,MAAM,EAAE,oBAAoB,CAAC;IAC7B,gBAAgB,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAClD,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,oFAAoF;IACpF,IAAI,EAAE,aAAa,CAAC;CACrB;AACD,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE;QAAE,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;QAAC,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IAC9E,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB;AACD,wBAAgB,gBAAgB,IAAI,aAAa,CAIhD;AACD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAOnE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { collectionQueryTemplate } from "@cchistory/canonical";
|
|
2
|
+
export function newQueryReadWork() {
|
|
3
|
+
return { discoveredPrimaryFiles: 0, plannedPrimaryFiles: 0, metadataEvidenceFiles: 0, inventoryFiles: 0, inventoryBytesRead: 0,
|
|
4
|
+
inventoryRecordsDecoded: 0, payloadFilesProcessed: 0, payloadRecordsProcessed: 0,
|
|
5
|
+
canonicalInterpretations: 0, retainedSessions: 0, retainedTurns: 0, skippedPrimaryFiles: 0 };
|
|
6
|
+
}
|
|
7
|
+
export function isSelectiveLatestQuery(query) {
|
|
8
|
+
const template = collectionQueryTemplate("latest-sessions", query.limit);
|
|
9
|
+
return query.collection === "sessions" && !query.complete && query.offset === 0
|
|
10
|
+
&& query.limit >= 1 && query.limit <= 1000
|
|
11
|
+
&& JSON.stringify(query.columns) === JSON.stringify(["id", "title", "last_message_at"])
|
|
12
|
+
&& JSON.stringify(query.predicate) === JSON.stringify(template.predicate)
|
|
13
|
+
&& JSON.stringify(query.order) === JSON.stringify(template.order);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=selective-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selective-query.js","sourceRoot":"","sources":["../src/selective-query.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAA6B,MAAM,sBAAsB,CAAC;AAsC1F,MAAM,UAAU,gBAAgB;IAC9B,OAAO,EAAE,sBAAsB,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC,EAAE,qBAAqB,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,kBAAkB,EAAE,CAAC;QAC5H,uBAAuB,EAAE,CAAC,EAAE,qBAAqB,EAAE,CAAC,EAAE,uBAAuB,EAAE,CAAC;QAChF,wBAAwB,EAAE,CAAC,EAAE,gBAAgB,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC,EAAE,CAAC;AACjG,CAAC;AACD,MAAM,UAAU,sBAAsB,CAAC,KAAmB;IACxD,MAAM,QAAQ,GAAG,uBAAuB,CAAC,iBAAiB,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACzE,OAAO,KAAK,CAAC,UAAU,KAAK,UAAU,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;WAC1E,KAAK,CAAC,KAAK,IAAI,CAAC,IAAI,KAAK,CAAC,KAAK,IAAI,IAAI;WACvC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;WACpF,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC;WACtE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selective-query.test.d.ts","sourceRoot":"","sources":["../src/selective-query.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { appendFileSync, utimesSync } from "node:fs";
|
|
3
|
+
import { copyFile, mkdtemp, readFile, rm, utimes, writeFile } from "node:fs/promises";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import test from "node:test";
|
|
7
|
+
import { SourceFileReadPlanChangedError } from "@cchistory/source-adapters";
|
|
8
|
+
import { scanLiteHistory, scanLiteQuery } from "./index.js";
|
|
9
|
+
import { compileSql } from "./sql-query.js";
|
|
10
|
+
import { isSelectiveLatestQuery } from "./selective-query.js";
|
|
11
|
+
const fixture = new URL("../../../mock_data/fixtures/selective-latest/", import.meta.url);
|
|
12
|
+
const variants = JSON.parse(await readFile(new URL("variants.json", fixture), "utf8"));
|
|
13
|
+
const names = ["newest", "tie-a", "tie-b", "oldest", "empty"];
|
|
14
|
+
const sql = "SELECT id, title, last_message_at FROM sessions WHERE is_top_level = TRUE AND turn_count > 0 ORDER BY last_message_at DESC NULLS LAST LIMIT $1";
|
|
15
|
+
const query = await compileSql(sql, [2]);
|
|
16
|
+
async function withCorpus(run) {
|
|
17
|
+
const root = await mkdtemp(path.join(os.tmpdir(), "cchistory-selective-"));
|
|
18
|
+
try {
|
|
19
|
+
for (const name of names) {
|
|
20
|
+
const file = path.join(root, `${name}.jsonl`);
|
|
21
|
+
await copyFile(new URL(`${name}.jsonl`, fixture), file);
|
|
22
|
+
// Deliberately contradict conversation order; never depend on copy speed or clock ticks.
|
|
23
|
+
const mtime = new Date(name === "oldest" ? "2026-08-01T00:00:00Z" : "2026-02-01T00:00:00Z");
|
|
24
|
+
await utimes(file, mtime, mtime);
|
|
25
|
+
}
|
|
26
|
+
await run(root, { homeDir: root, hostname: "selective-fixture", sourceRoots: [{ sourceRef: "codex", baseDir: root }], sourceRefs: ["codex"], contextMode: "none" });
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
await rm(root, { recursive: true, force: true });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function writeRecords(root, file, records) {
|
|
33
|
+
await writeFile(path.join(root, file), records.map(r => JSON.stringify(r)).join("\n") + "\n");
|
|
34
|
+
await utimes(path.join(root, file), new Date("2026-03-01T00:00:00Z"), new Date("2026-03-01T00:00:00Z"));
|
|
35
|
+
}
|
|
36
|
+
test("M3: exact latest ignores mtime, interprets tied candidates and skips only strictly older groups", async () => {
|
|
37
|
+
assert.ok(isSelectiveLatestQuery(query));
|
|
38
|
+
await withCorpus(async (_root, options) => {
|
|
39
|
+
const read = await scanLiteQuery(query, options);
|
|
40
|
+
const full = await scanLiteHistory(options);
|
|
41
|
+
assert.deepEqual(read.result.rows, full.executeCollectionQuery(query).rows);
|
|
42
|
+
assert.deepEqual(read.result.ids, ["sess:codex:newest", "sess:codex:tie-a"]);
|
|
43
|
+
assert.deepEqual(read.result.coverage, { execution: "selective", rows: "exact", diagnostics: "observed" });
|
|
44
|
+
assert.equal(read.result.total, null);
|
|
45
|
+
assert.deepEqual(read.projectionIssues, []);
|
|
46
|
+
assert.deepEqual(full.projectionIssues, []);
|
|
47
|
+
assert.equal(read.work.discoveredPrimaryFiles, 5);
|
|
48
|
+
assert.equal(read.work.metadataEvidenceFiles, 5);
|
|
49
|
+
assert.equal(read.work.inventoryFiles, 5);
|
|
50
|
+
assert.equal(read.work.inventoryRecordsDecoded, 13);
|
|
51
|
+
assert.ok(read.work.inventoryBytesRead > 0);
|
|
52
|
+
assert.equal(read.work.payloadFilesProcessed, 4, "empty and both tied groups must be read");
|
|
53
|
+
assert.equal(read.work.canonicalInterpretations, 4);
|
|
54
|
+
assert.equal(read.work.skippedPrimaryFiles, 1);
|
|
55
|
+
assert.equal(read.work.retainedSessions, 4);
|
|
56
|
+
assert.equal(read.work.retainedTurns, 3);
|
|
57
|
+
assert.equal("data" in read, false, "a partial read is not exposed as a reusable full snapshot");
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
test("M3: split native files are interpreted as one complete logical session", async () => {
|
|
61
|
+
await withCorpus(async (root, options) => {
|
|
62
|
+
await writeRecords(root, "split.jsonl", variants.split);
|
|
63
|
+
const read = await scanLiteQuery(query, options);
|
|
64
|
+
const full = await scanLiteHistory(options);
|
|
65
|
+
assert.deepEqual(read.result.rows, full.executeCollectionQuery(query).rows);
|
|
66
|
+
assert.equal(read.result.ids[0], "sess:codex:oldest");
|
|
67
|
+
assert.equal(read.result.coverage.execution, "selective");
|
|
68
|
+
assert.equal(read.work.payloadFilesProcessed, 4);
|
|
69
|
+
assert.equal(read.work.canonicalInterpretations, 3);
|
|
70
|
+
assert.equal(read.work.skippedPrimaryFiles, 2);
|
|
71
|
+
assert.deepEqual(read.projectionIssues, []);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
test("M3: uncertain timestamps, identity, syntax and family evidence use the complete reader", async () => {
|
|
75
|
+
for (const variant of ["timestamp", "identity", "unknown", "family_tool", "family_tool_whitespace", "child", "malformed", "oversized"]) {
|
|
76
|
+
await withCorpus(async (root, options) => {
|
|
77
|
+
const file = path.join(root, "oldest.jsonl");
|
|
78
|
+
const records = (await readFile(file, "utf8")).trim().split("\n").map(line => JSON.parse(line));
|
|
79
|
+
if (variant === "timestamp")
|
|
80
|
+
delete records[0].timestamp;
|
|
81
|
+
else if (variant === "identity")
|
|
82
|
+
records.shift();
|
|
83
|
+
else if (variant === "child")
|
|
84
|
+
await writeRecords(root, "child.jsonl", variants.child);
|
|
85
|
+
else if (variant === "unknown" || variant === "family_tool")
|
|
86
|
+
records.push(variants[variant]);
|
|
87
|
+
else if (variant === "family_tool_whitespace") {
|
|
88
|
+
const call = structuredClone(variants.family_tool);
|
|
89
|
+
call.payload.name = ` ${call.payload.name} `;
|
|
90
|
+
records.push(call);
|
|
91
|
+
}
|
|
92
|
+
else if (variant === "oversized")
|
|
93
|
+
records[1].payload.content[0].text = "x".repeat(1024 * 1024 + 1);
|
|
94
|
+
await writeRecords(root, "oldest.jsonl", records);
|
|
95
|
+
if (variant === "malformed")
|
|
96
|
+
appendFileSync(file, "{invalid\n");
|
|
97
|
+
const read = await scanLiteQuery(query, options);
|
|
98
|
+
const full = await scanLiteHistory(options);
|
|
99
|
+
assert.deepEqual(read.result.rows, full.executeCollectionQuery(query).rows, variant);
|
|
100
|
+
assert.equal(read.result.coverage.execution, "complete", variant);
|
|
101
|
+
assert.equal(read.result.coverage.diagnostics, "complete", variant);
|
|
102
|
+
assert.equal(read.work.skippedPrimaryFiles, 0, variant);
|
|
103
|
+
assert.ok(read.work.fallbackReason, variant);
|
|
104
|
+
assert.deepEqual(read.projectionIssues, full.projectionIssues, variant);
|
|
105
|
+
assert.equal(read.lossAudits.length, full.data.loss_audits.length, variant);
|
|
106
|
+
if (variant === "child")
|
|
107
|
+
assert.ok(!read.result.ids.includes("sess:codex:child"));
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
test("M3: complete totals and other query shapes bypass the inventory; insufficient rows do not claim pruning", async () => {
|
|
112
|
+
await withCorpus(async (_root, options) => {
|
|
113
|
+
for (const q of [{ ...query, complete: true }, { ...query, offset: 1 }, { ...query, columns: ["id"] }]) {
|
|
114
|
+
const read = await scanLiteQuery(q, options);
|
|
115
|
+
const full = await scanLiteHistory(options);
|
|
116
|
+
assert.deepEqual(read.result, full.executeCollectionQuery(q));
|
|
117
|
+
assert.equal(read.work.inventoryFiles, 0);
|
|
118
|
+
assert.equal(read.work.canonicalInterpretations, 5);
|
|
119
|
+
assert.equal(read.work.payloadRecordsProcessed, 13);
|
|
120
|
+
assert.equal(read.work.retainedSessions, 5);
|
|
121
|
+
if (q.complete)
|
|
122
|
+
assert.equal(read.result.total, 4);
|
|
123
|
+
}
|
|
124
|
+
const read = await scanLiteQuery({ ...query, limit: 10 }, options);
|
|
125
|
+
assert.equal(read.result.coverage.execution, "complete");
|
|
126
|
+
assert.equal(read.work.skippedPrimaryFiles, 0);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
test("M3: a skipped file changing after inventory aborts the attempt", async () => {
|
|
130
|
+
await withCorpus(async (root, options) => {
|
|
131
|
+
let changed = false;
|
|
132
|
+
options.onProgress = event => {
|
|
133
|
+
if (event.stage !== "file_start" || changed)
|
|
134
|
+
return;
|
|
135
|
+
changed = true;
|
|
136
|
+
const file = path.join(root, "oldest.jsonl");
|
|
137
|
+
appendFileSync(file, JSON.stringify(variants.changed) + "\n");
|
|
138
|
+
utimesSync(file, new Date("2026-08-02T00:00:00Z"), new Date("2026-08-02T00:00:00Z"));
|
|
139
|
+
};
|
|
140
|
+
await assert.rejects(scanLiteQuery(query, options), SourceFileReadPlanChangedError);
|
|
141
|
+
assert.ok(changed);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
test("M3: bounds inspect all timestamps and scope or multiple sources retain complete-reference behavior", async () => {
|
|
145
|
+
await withCorpus(async (root, options) => {
|
|
146
|
+
const records = (await readFile(path.join(root, "oldest.jsonl"), "utf8")).trim().split("\n").map(line => JSON.parse(line));
|
|
147
|
+
// The last line is old metadata; a tail timestamp would wrongly hide the newest real message.
|
|
148
|
+
await writeRecords(root, "oldest.jsonl", [...records, variants.changed, records[0]]);
|
|
149
|
+
const read = await scanLiteQuery(query, options);
|
|
150
|
+
const full = await scanLiteHistory(options);
|
|
151
|
+
assert.deepEqual(read.result.rows, full.executeCollectionQuery(query).rows);
|
|
152
|
+
assert.equal(read.result.ids[0], "sess:codex:oldest");
|
|
153
|
+
assert.equal(read.result.coverage.execution, "selective");
|
|
154
|
+
for (const directoryScope of ["/fixture/query-project", "/fixture/other-project"]) {
|
|
155
|
+
const scoped = await scanLiteQuery(query, { ...options, directoryScope });
|
|
156
|
+
const reference = await scanLiteHistory({ ...options, directoryScope });
|
|
157
|
+
assert.deepEqual(scoped.result.rows, reference.executeCollectionQuery(query, { directoryScope }).rows);
|
|
158
|
+
}
|
|
159
|
+
const mixedOptions = { ...options, sourceRefs: ["codex", "claude_code"], sourceRoots: [...options.sourceRoots, { sourceRef: "claude_code", baseDir: path.join(root, "missing-claude") }] };
|
|
160
|
+
const mixed = await scanLiteQuery(query, mixedOptions);
|
|
161
|
+
assert.equal(mixed.work.inventoryFiles, 0);
|
|
162
|
+
assert.equal(mixed.result.coverage.execution, "complete");
|
|
163
|
+
assert.deepEqual(mixed.result.rows, (await scanLiteHistory(mixedOptions)).executeCollectionQuery(query).rows);
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
//# sourceMappingURL=selective-query.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selective-query.test.js","sourceRoot":"","sources":["../src/selective-query.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM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Value } from "@cchistory/domain";
|
|
2
|
+
export declare const SQL_REQUEST_SCHEMA = "cchistory-lite-query/v3";
|
|
3
|
+
export declare const SQL_RESULT_SCHEMA = "cchistory-lite-query-result/v3";
|
|
4
|
+
export declare const MAX_SQL_BYTES = 16384;
|
|
5
|
+
export declare const MAX_QUERY_REQUEST_BYTES = 1048576;
|
|
6
|
+
export type QueryRejectionReason = "syntax" | "unsupported" | "field" | "parameter" | "type" | "budget";
|
|
7
|
+
export declare class QueryValidationError extends Error {
|
|
8
|
+
readonly reason: QueryRejectionReason;
|
|
9
|
+
readonly operationId?: string | undefined;
|
|
10
|
+
readonly code = "invalid_query_request";
|
|
11
|
+
constructor(message: string, reason: QueryRejectionReason, operationId?: string | undefined);
|
|
12
|
+
}
|
|
13
|
+
export interface SqlOperation {
|
|
14
|
+
id: string;
|
|
15
|
+
kind: "sql";
|
|
16
|
+
sql: string;
|
|
17
|
+
params: QueryValue[];
|
|
18
|
+
complete: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface SqlRequest {
|
|
21
|
+
schema: typeof SQL_REQUEST_SCHEMA;
|
|
22
|
+
operations: SqlOperation[];
|
|
23
|
+
}
|
|
24
|
+
export interface CompiledSqlRequest {
|
|
25
|
+
schema: typeof SQL_REQUEST_SCHEMA;
|
|
26
|
+
operations: {
|
|
27
|
+
id: string;
|
|
28
|
+
kind: "sql";
|
|
29
|
+
query: LogicalQuery;
|
|
30
|
+
}[];
|
|
31
|
+
}
|
|
32
|
+
export declare function parseSqlRequest(raw: string): SqlRequest;
|
|
33
|
+
export declare function compileSqlRequest(request: SqlRequest): Promise<CompiledSqlRequest>;
|
|
34
|
+
export declare function compileSql(sql: string, params?: QueryValue[], complete?: boolean): Promise<LogicalQuery>;
|
|
35
|
+
/** Positive AST allowlist. Parser support does not grant a feature to the product. */
|
|
36
|
+
export declare function lowerSqlAst(ast: unknown, params: QueryValue[], complete: boolean): LogicalQuery;
|
|
37
|
+
//# sourceMappingURL=sql-query.d.ts.map
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UAAU,CAmBvD;AAYD,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA4BxF;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,UAAU,EAAO,EAAE,QAAQ,UAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,CAEhH;AAeD,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,OAAO,GAAG,YAAY,CAmG/F"}
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { Worker } from "node:worker_threads";
|
|
2
|
+
import { QUERY_COLUMNS } from "@cchistory/canonical";
|
|
3
|
+
export const SQL_REQUEST_SCHEMA = "cchistory-lite-query/v3";
|
|
4
|
+
export const SQL_RESULT_SCHEMA = "cchistory-lite-query-result/v3";
|
|
5
|
+
export const MAX_SQL_BYTES = 16_384;
|
|
6
|
+
export const MAX_QUERY_REQUEST_BYTES = 1_048_576;
|
|
7
|
+
export class QueryValidationError extends Error {
|
|
8
|
+
reason;
|
|
9
|
+
operationId;
|
|
10
|
+
code = "invalid_query_request";
|
|
11
|
+
constructor(message, reason, operationId) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.reason = reason;
|
|
14
|
+
this.operationId = operationId;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const fail = (reason, message) => { throw new QueryValidationError(message, reason); };
|
|
18
|
+
function node(value) {
|
|
19
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
20
|
+
return fail("unsupported", "Expected a supported SQL node.");
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
function only(value, keys) {
|
|
24
|
+
if (Object.keys(value).some(k => !keys.includes(k)))
|
|
25
|
+
fail("unsupported", "Unsupported query construct or option.");
|
|
26
|
+
}
|
|
27
|
+
export function parseSqlRequest(raw) {
|
|
28
|
+
if (Buffer.byteLength(raw) > MAX_QUERY_REQUEST_BYTES)
|
|
29
|
+
fail("budget", "Query request exceeds 1 MiB.");
|
|
30
|
+
let value;
|
|
31
|
+
try {
|
|
32
|
+
value = JSON.parse(raw);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return fail("syntax", "Query request must be JSON.");
|
|
36
|
+
}
|
|
37
|
+
const root = node(value);
|
|
38
|
+
only(root, ["schema", "operations"]);
|
|
39
|
+
if (root.schema !== SQL_REQUEST_SCHEMA)
|
|
40
|
+
fail("unsupported", `Expected ${SQL_REQUEST_SCHEMA}.`);
|
|
41
|
+
if (!Array.isArray(root.operations) || root.operations.length < 1 || root.operations.length > 16)
|
|
42
|
+
fail("budget", "Expected 1–16 SQL operations.");
|
|
43
|
+
const seen = new Set();
|
|
44
|
+
const operations = root.operations.map(value => {
|
|
45
|
+
const op = node(value);
|
|
46
|
+
only(op, ["id", "kind", "sql", "params", "complete"]);
|
|
47
|
+
if (typeof op.id !== "string" || !op.id.trim() || seen.has(op.id))
|
|
48
|
+
fail("parameter", "Operation IDs must be nonempty and unique.");
|
|
49
|
+
if (op.kind !== "sql")
|
|
50
|
+
fail("unsupported", "v3 accepts SQL operations only.");
|
|
51
|
+
if (op.complete !== undefined && typeof op.complete !== "boolean")
|
|
52
|
+
fail("type", "complete must be a boolean.");
|
|
53
|
+
seen.add(op.id);
|
|
54
|
+
try {
|
|
55
|
+
validateSqlInput(op.sql, op.params === undefined ? [] : op.params);
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
if (e instanceof QueryValidationError)
|
|
59
|
+
throw new QueryValidationError(e.message, e.reason, op.id);
|
|
60
|
+
throw e;
|
|
61
|
+
}
|
|
62
|
+
return { id: op.id, kind: "sql", sql: op.sql, params: (op.params === undefined ? [] : op.params), complete: op.complete === true };
|
|
63
|
+
});
|
|
64
|
+
return { schema: SQL_REQUEST_SCHEMA, operations };
|
|
65
|
+
}
|
|
66
|
+
function validateSqlInput(sql, params) {
|
|
67
|
+
if (typeof sql !== "string" || !sql.trim())
|
|
68
|
+
fail("syntax", "SQL must be a nonempty string.");
|
|
69
|
+
if (Buffer.byteLength(sql) > MAX_SQL_BYTES)
|
|
70
|
+
fail("budget", "SQL exceeds 16 KiB.");
|
|
71
|
+
if (!Array.isArray(params) || params.length > 32)
|
|
72
|
+
fail("parameter", "Bind at most 32 scalar parameters.");
|
|
73
|
+
if (Buffer.byteLength(JSON.stringify(params)) > MAX_SQL_BYTES)
|
|
74
|
+
fail("budget", "Parameters exceed 16 KiB.");
|
|
75
|
+
if (params.some(v => v !== null && !["string", "number", "boolean"].includes(typeof v) || typeof v === "number" && !Number.isFinite(v))) {
|
|
76
|
+
fail("parameter", "Parameters must be finite JSON scalars or null.");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export async function compileSqlRequest(request) {
|
|
80
|
+
// Revalidate library callers too, before starting a worker or touching history.
|
|
81
|
+
const checked = parseSqlRequest(JSON.stringify(request));
|
|
82
|
+
const worker = new Worker(new URL("./sql-worker.js", import.meta.url));
|
|
83
|
+
const message = (timeout) => new Promise((resolve, reject) => {
|
|
84
|
+
const cleanup = () => { clearTimeout(timer); worker.off("message", onMessage); worker.off("error", onError); worker.off("exit", onExit); };
|
|
85
|
+
const onMessage = (value) => { cleanup(); resolve(value); };
|
|
86
|
+
const onError = (error) => { cleanup(); reject(error); };
|
|
87
|
+
const onExit = () => onError(new QueryValidationError("SQL parser exited before completing the request.", "budget"));
|
|
88
|
+
const timer = setTimeout(() => onError(new QueryValidationError("SQL parser exceeded its execution deadline.", "budget")), timeout);
|
|
89
|
+
worker.once("message", onMessage);
|
|
90
|
+
worker.once("error", onError);
|
|
91
|
+
worker.once("exit", onExit);
|
|
92
|
+
});
|
|
93
|
+
try {
|
|
94
|
+
await message(5000);
|
|
95
|
+
const operations = [];
|
|
96
|
+
for (const op of checked.operations) {
|
|
97
|
+
try {
|
|
98
|
+
const pending = message(1000);
|
|
99
|
+
worker.postMessage(op.sql);
|
|
100
|
+
const parsed = await pending;
|
|
101
|
+
if (parsed.error)
|
|
102
|
+
fail("syntax", String(parsed.error));
|
|
103
|
+
operations.push({ id: op.id, kind: "sql", query: lowerSqlAst(parsed.ast, op.params, op.complete) });
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
if (e instanceof QueryValidationError)
|
|
107
|
+
throw new QueryValidationError(e.message, e.reason, op.id);
|
|
108
|
+
throw e;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return { schema: SQL_REQUEST_SCHEMA, operations };
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
await worker.terminate();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export async function compileSql(sql, params = [], complete = false) {
|
|
118
|
+
return (await compileSqlRequest({ schema: SQL_REQUEST_SCHEMA, operations: [{ id: "query", kind: "sql", sql, params, complete }] })).operations[0].query;
|
|
119
|
+
}
|
|
120
|
+
function timestamp(value, parameter) {
|
|
121
|
+
const reject = () => fail(parameter ? "parameter" : "type", "Expected a valid RFC3339 timestamp with a timezone and millisecond precision.");
|
|
122
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?(Z|[+-]\d{2}:\d{2})$/u.exec(value);
|
|
123
|
+
if (!m)
|
|
124
|
+
return reject();
|
|
125
|
+
const [year, month, day, hour, minute, second] = m.slice(1, 7).map(Number);
|
|
126
|
+
const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
127
|
+
const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
128
|
+
if (month < 1 || month > 12 || day < 1 || day > days[month - 1] || hour > 23 || minute > 59 || second > 59)
|
|
129
|
+
return reject();
|
|
130
|
+
if (m[8] !== "Z" && (Number(m[8].slice(1, 3)) > 23 || Number(m[8].slice(4)) > 59))
|
|
131
|
+
return reject();
|
|
132
|
+
const date = new Date(value);
|
|
133
|
+
if (!Number.isFinite(date.getTime()))
|
|
134
|
+
return reject();
|
|
135
|
+
return date.toISOString();
|
|
136
|
+
}
|
|
137
|
+
/** Positive AST allowlist. Parser support does not grant a feature to the product. */
|
|
138
|
+
export function lowerSqlAst(ast, params, complete) {
|
|
139
|
+
if (!Array.isArray(ast) || ast.length !== 1)
|
|
140
|
+
return fail("unsupported", "Exactly one SELECT statement is required.");
|
|
141
|
+
const select = node(ast[0]);
|
|
142
|
+
only(select, ["type", "columns", "from", "where", "orderBy", "limit"]);
|
|
143
|
+
if (select.type !== "select")
|
|
144
|
+
fail("unsupported", "Only SELECT is supported.");
|
|
145
|
+
if (!Array.isArray(select.from) || select.from.length !== 1)
|
|
146
|
+
fail("unsupported", "Select one collection.");
|
|
147
|
+
const from = node(select.from[0]);
|
|
148
|
+
only(from, ["type", "name"]);
|
|
149
|
+
if (from.type !== "table")
|
|
150
|
+
fail("unsupported", "Select one collection.");
|
|
151
|
+
const table = node(from.name);
|
|
152
|
+
only(table, ["name"]);
|
|
153
|
+
if (table.name !== "sessions" && table.name !== "turns")
|
|
154
|
+
fail("field", "Collection must be sessions or turns.");
|
|
155
|
+
const collection = table.name;
|
|
156
|
+
const fields = new Map(QUERY_COLUMNS[collection].map(c => [c.name, c]));
|
|
157
|
+
const ref = (raw) => {
|
|
158
|
+
const n = node(raw);
|
|
159
|
+
only(n, ["type", "name"]);
|
|
160
|
+
if (n.type !== "ref")
|
|
161
|
+
return fail("unsupported", "Expected a bare public field.");
|
|
162
|
+
if (typeof n.name !== "string" || !fields.has(n.name))
|
|
163
|
+
return fail("field", `Unknown ${collection} field: ${String(n.name)}.`);
|
|
164
|
+
return n.name;
|
|
165
|
+
};
|
|
166
|
+
const used = new Set(), expectedTypes = new Map();
|
|
167
|
+
const value = (raw, type) => {
|
|
168
|
+
const n = node(raw);
|
|
169
|
+
let v;
|
|
170
|
+
const parameter = n.type === "parameter";
|
|
171
|
+
if (parameter) {
|
|
172
|
+
only(n, ["type", "name"]);
|
|
173
|
+
const index = Number(String(n.name).slice(1));
|
|
174
|
+
if (!/^\$[1-9]\d*$/u.test(String(n.name)) || index > params.length)
|
|
175
|
+
return fail("parameter", "Missing parameter binding.");
|
|
176
|
+
used.add(index);
|
|
177
|
+
if (expectedTypes.has(index) && expectedTypes.get(index) !== type)
|
|
178
|
+
return fail("type", "Repeated parameter requires incompatible types.");
|
|
179
|
+
expectedTypes.set(index, type);
|
|
180
|
+
v = params[index - 1];
|
|
181
|
+
}
|
|
182
|
+
else if (n.type === "null") {
|
|
183
|
+
only(n, ["type"]);
|
|
184
|
+
v = null;
|
|
185
|
+
}
|
|
186
|
+
else if (["string", "integer", "numeric", "boolean"].includes(String(n.type))) {
|
|
187
|
+
only(n, ["type", "value"]);
|
|
188
|
+
v = n.value;
|
|
189
|
+
}
|
|
190
|
+
else if (n.type === "unary" && ["-", "+"].includes(String(n.op))) {
|
|
191
|
+
only(n, ["type", "op", "operand"]);
|
|
192
|
+
const operand = node(n.operand);
|
|
193
|
+
if (!["integer", "numeric"].includes(String(operand.type)))
|
|
194
|
+
return fail("unsupported", "Only numeric literal signs are supported.");
|
|
195
|
+
const literal = value(operand, "number");
|
|
196
|
+
v = n.op === "-" ? -literal : literal;
|
|
197
|
+
}
|
|
198
|
+
else
|
|
199
|
+
return fail("unsupported", "Expected a scalar literal or bound parameter.");
|
|
200
|
+
if (v === null)
|
|
201
|
+
return null;
|
|
202
|
+
if (typeof v !== (type === "timestamp" ? "string" : type) || typeof v === "number" && !Number.isFinite(v))
|
|
203
|
+
return fail("type", `Expected ${type} operand.`);
|
|
204
|
+
return type === "timestamp" ? timestamp(v, parameter) : v;
|
|
205
|
+
};
|
|
206
|
+
let leaves = 0;
|
|
207
|
+
const predicate = (raw, depth = 0) => {
|
|
208
|
+
if (depth > 8 || ++leaves > 128)
|
|
209
|
+
return fail("budget", "Predicate complexity exceeds v1 bounds.");
|
|
210
|
+
const n = node(raw);
|
|
211
|
+
if (n.type === "binary" && (n.op === "AND" || n.op === "OR")) {
|
|
212
|
+
leaves--;
|
|
213
|
+
only(n, ["type", "op", "left", "right"]);
|
|
214
|
+
return { kind: n.op === "AND" ? "and" : "or", left: predicate(n.left, depth + 1), right: predicate(n.right, depth + 1) };
|
|
215
|
+
}
|
|
216
|
+
if (n.type === "unary" && n.op === "NOT") {
|
|
217
|
+
leaves--;
|
|
218
|
+
only(n, ["type", "op", "operand"]);
|
|
219
|
+
return { kind: "not", operand: predicate(n.operand, depth + 1) };
|
|
220
|
+
}
|
|
221
|
+
if (leaves > 64)
|
|
222
|
+
return fail("budget", "At most 64 predicate leaves are supported.");
|
|
223
|
+
if (n.type === "unary" && (n.op === "IS NULL" || n.op === "IS NOT NULL")) {
|
|
224
|
+
only(n, ["type", "op", "operand"]);
|
|
225
|
+
return { kind: "null", field: ref(n.operand), negate: n.op === "IS NOT NULL" };
|
|
226
|
+
}
|
|
227
|
+
if (n.type === "ternary" && (n.op === "BETWEEN" || n.op === "NOT BETWEEN")) {
|
|
228
|
+
only(n, ["type", "op", "value", "lo", "hi"]);
|
|
229
|
+
const field = ref(n.value), type = fields.get(field).type;
|
|
230
|
+
if (type !== "number" && type !== "timestamp")
|
|
231
|
+
return fail("type", "BETWEEN requires a number or timestamp field.");
|
|
232
|
+
const range = { kind: "and", left: { kind: "compare", field, op: ">=", value: value(n.lo, type) }, right: { kind: "compare", field, op: "<=", value: value(n.hi, type) } };
|
|
233
|
+
return n.op === "BETWEEN" ? range : { kind: "not", operand: range };
|
|
234
|
+
}
|
|
235
|
+
if (n.type !== "binary")
|
|
236
|
+
return fail("unsupported", "Unsupported predicate.");
|
|
237
|
+
only(n, ["type", "op", "left", "right"]);
|
|
238
|
+
const field = ref(n.left), type = fields.get(field).type, op = String(n.op);
|
|
239
|
+
if (op === "IN" || op === "NOT IN") {
|
|
240
|
+
const list = node(n.right);
|
|
241
|
+
only(list, ["type", "expressions"]);
|
|
242
|
+
if (list.type !== "list" || !Array.isArray(list.expressions))
|
|
243
|
+
return fail("unsupported", "IN requires a value list.");
|
|
244
|
+
if (list.expressions.length < 1 || list.expressions.length > 32)
|
|
245
|
+
return fail("budget", "IN accepts 1–32 values.");
|
|
246
|
+
return { kind: "in", field, values: list.expressions.map(v => value(v, type)), negate: op === "NOT IN" };
|
|
247
|
+
}
|
|
248
|
+
if (op === "LIKE" || op === "NOT LIKE") {
|
|
249
|
+
if (type !== "string")
|
|
250
|
+
return fail("type", "LIKE requires a string field.");
|
|
251
|
+
const pattern = value(n.right, "string");
|
|
252
|
+
if (pattern !== null && (pattern.match(/\\+$/u)?.[0].length ?? 0) % 2 === 1)
|
|
253
|
+
return fail(node(n.right).type === "parameter" ? "parameter" : "type", "LIKE pattern has a dangling escape.");
|
|
254
|
+
return { kind: "like", field, pattern, negate: op === "NOT LIKE" };
|
|
255
|
+
}
|
|
256
|
+
if (!["=", "!=", "<", "<=", ">", ">="].includes(op))
|
|
257
|
+
return fail("unsupported", `Unsupported operator: ${op}.`);
|
|
258
|
+
if (op !== "=" && op !== "!=" && type !== "number" && type !== "timestamp")
|
|
259
|
+
return fail("type", "Ordering comparisons require numbers or timestamps.");
|
|
260
|
+
return { kind: "compare", field, op: op, value: value(n.right, type) };
|
|
261
|
+
};
|
|
262
|
+
if (!Array.isArray(select.columns) || !select.columns.length)
|
|
263
|
+
fail("field", "Select public columns.");
|
|
264
|
+
const projections = select.columns.map(raw => { const c = node(raw); only(c, ["expr"]); return c.expr; });
|
|
265
|
+
let columns;
|
|
266
|
+
if (projections.length === 1 && node(projections[0]).type === "ref" && node(projections[0]).name === "*") {
|
|
267
|
+
only(node(projections[0]), ["type", "name"]);
|
|
268
|
+
columns = [...fields.keys()];
|
|
269
|
+
}
|
|
270
|
+
else
|
|
271
|
+
columns = projections.map(ref);
|
|
272
|
+
if (new Set(columns).size !== columns.length)
|
|
273
|
+
fail("field", "Duplicate columns are not supported.");
|
|
274
|
+
const where = select.where === undefined ? undefined : predicate(select.where);
|
|
275
|
+
if (select.orderBy !== undefined && !Array.isArray(select.orderBy))
|
|
276
|
+
fail("unsupported", "Unsupported ordering.");
|
|
277
|
+
const order = (select.orderBy ?? []).map(raw => {
|
|
278
|
+
const o = node(raw);
|
|
279
|
+
only(o, ["by", "order", "nulls"]);
|
|
280
|
+
const field = ref(o.by);
|
|
281
|
+
const direction = o.order ?? "ASC", nulls = o.nulls ?? (direction === "ASC" ? "LAST" : "FIRST");
|
|
282
|
+
if (direction !== "ASC" && direction !== "DESC" || nulls !== "FIRST" && nulls !== "LAST")
|
|
283
|
+
fail("unsupported", "Unsupported ordering.");
|
|
284
|
+
return { field, direction: direction, nulls: nulls };
|
|
285
|
+
});
|
|
286
|
+
if (order.length > 3 || new Set(order.map(x => x.field)).size !== order.length)
|
|
287
|
+
fail("budget", "Order by up to three distinct fields.");
|
|
288
|
+
if (select.limit === undefined)
|
|
289
|
+
return fail("budget", "An explicit LIMIT is required.");
|
|
290
|
+
const page = node(select.limit);
|
|
291
|
+
only(page, ["limit", "offset"]);
|
|
292
|
+
if (page.limit === undefined)
|
|
293
|
+
return fail("budget", "An explicit LIMIT is required.");
|
|
294
|
+
const limit = value(page.limit, "number"), offset = page.offset === undefined ? 0 : value(page.offset, "number");
|
|
295
|
+
if (typeof limit !== "number" || !Number.isSafeInteger(limit) || limit < 1 || limit > 1000 || typeof offset !== "number" || !Number.isSafeInteger(offset) || offset < 0 || offset > 100000)
|
|
296
|
+
return fail("budget", "LIMIT must be 1–1000 and OFFSET 0–100000.");
|
|
297
|
+
if (used.size !== params.length || [...used].some(i => i < 1 || i > used.size))
|
|
298
|
+
fail("parameter", "Bindings must exactly match contiguous $1…$N references.");
|
|
299
|
+
return { collection, columns, predicate: where, order, limit, offset, complete };
|
|
300
|
+
}
|
|
301
|
+
//# sourceMappingURL=sql-query.js.map
|