@quolu/lattice 0.1.0 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -4
- package/bin/lattice-bridge.mjs +87 -0
- package/bin/lattice-dashboard.mjs +70 -0
- package/bin/lattice-mcp.mjs +9 -9
- package/bin/lattice.mjs +61 -8
- package/docs/bridge-setup.md +87 -0
- package/docs/schemas/lattice.plan_create_input.v1.schema.json +56 -0
- package/docs/schemas/lattice.plan_create_input.v2.schema.json +72 -0
- package/docs/schemas/lattice.plan_create_input.v3.schema.json +81 -0
- package/package.json +19 -7
- package/sensor/dist/bin/command-supervision.d.ts +1 -1
- package/sensor/dist/bin/command-supervision.js +4 -4
- package/sensor/dist/bin/command-supervision.js.map +1 -1
- package/sensor/dist/bin/fatal-handler.js +2 -2
- package/sensor/dist/bin/fatal-handler.js.map +1 -1
- package/sensor/dist/bin/{codegraph.js → lattice-sensor.js} +207 -328
- package/sensor/dist/bin/node-version-check.d.ts +7 -5
- package/sensor/dist/bin/node-version-check.d.ts.map +1 -1
- package/sensor/dist/bin/node-version-check.js +19 -14
- package/sensor/dist/bin/node-version-check.js.map +1 -1
- package/sensor/dist/context/index.d.ts +1 -1
- package/sensor/dist/context/index.js +6 -6
- package/sensor/dist/context/index.js.map +1 -1
- package/sensor/dist/db/index.d.ts +5 -5
- package/sensor/dist/db/index.d.ts.map +1 -1
- package/sensor/dist/db/index.js +7 -7
- package/sensor/dist/db/index.js.map +1 -1
- package/sensor/dist/db/migrations.js +1 -1
- package/sensor/dist/db/migrations.js.map +1 -1
- package/sensor/dist/db/queries.d.ts +1 -1
- package/sensor/dist/db/queries.js +5 -5
- package/sensor/dist/db/queries.js.map +1 -1
- package/sensor/dist/db/schema.sql +2 -2
- package/sensor/dist/db/sqlite-adapter.d.ts +2 -2
- package/sensor/dist/db/sqlite-adapter.js +3 -3
- package/sensor/dist/db/sqlite-adapter.js.map +1 -1
- package/sensor/dist/db/wal-valve.d.ts +1 -1
- package/sensor/dist/db/wal-valve.d.ts.map +1 -1
- package/sensor/dist/db/wal-valve.js +2 -2
- package/sensor/dist/db/wal-valve.js.map +1 -1
- package/sensor/dist/directory.d.ts +27 -63
- package/sensor/dist/directory.d.ts.map +1 -1
- package/sensor/dist/directory.js +78 -134
- package/sensor/dist/directory.js.map +1 -1
- package/sensor/dist/errors.d.ts +15 -15
- package/sensor/dist/errors.d.ts.map +1 -1
- package/sensor/dist/errors.js +21 -21
- package/sensor/dist/errors.js.map +1 -1
- package/sensor/dist/extraction/dynamic-import.d.ts +1 -1
- package/sensor/dist/extraction/dynamic-import.js +1 -1
- package/sensor/dist/extraction/extraction-version.d.ts +1 -1
- package/sensor/dist/extraction/extraction-version.js +1 -1
- package/sensor/dist/extraction/generated-detection.d.ts +1 -1
- package/sensor/dist/extraction/generated-detection.js +1 -1
- package/sensor/dist/extraction/grammars.d.ts +3 -3
- package/sensor/dist/extraction/grammars.js +5 -5
- package/sensor/dist/extraction/grammars.js.map +1 -1
- package/sensor/dist/extraction/index.d.ts +6 -6
- package/sensor/dist/extraction/index.js +50 -50
- package/sensor/dist/extraction/index.js.map +1 -1
- package/sensor/dist/extraction/kernel/decode.d.ts +1 -1
- package/sensor/dist/extraction/kernel/decode.js +1 -1
- package/sensor/dist/extraction/kernel/index.d.ts +3 -3
- package/sensor/dist/extraction/kernel/index.js +6 -6
- package/sensor/dist/extraction/kernel/index.js.map +1 -1
- package/sensor/dist/extraction/kernel/layout.d.ts +1 -1
- package/sensor/dist/extraction/kernel/layout.js +1 -1
- package/sensor/dist/extraction/kernel/loader.d.ts +6 -6
- package/sensor/dist/extraction/kernel/loader.js +13 -13
- package/sensor/dist/extraction/kernel/loader.js.map +1 -1
- package/sensor/dist/extraction/languages/cfquery.d.ts +1 -1
- package/sensor/dist/extraction/languages/cfquery.js +1 -1
- package/sensor/dist/extraction/languages/lua.d.ts +11 -0
- package/sensor/dist/extraction/languages/lua.d.ts.map +1 -1
- package/sensor/dist/extraction/languages/lua.js +1 -0
- package/sensor/dist/extraction/languages/lua.js.map +1 -1
- package/sensor/dist/extraction/parse-pool.d.ts +5 -5
- package/sensor/dist/extraction/parse-pool.d.ts.map +1 -1
- package/sensor/dist/extraction/parse-pool.js +4 -4
- package/sensor/dist/extraction/parse-worker.js +1 -1
- package/sensor/dist/extraction/parse-worker.js.map +1 -1
- package/sensor/dist/extraction/store-writer.d.ts +1 -1
- package/sensor/dist/extraction/store-writer.js +1 -1
- package/sensor/dist/extraction/svelte-extractor.d.ts +1 -1
- package/sensor/dist/extraction/svelte-extractor.js +1 -1
- package/sensor/dist/extraction/tree-sitter-helpers.js +1 -1
- package/sensor/dist/extraction/tree-sitter.d.ts +2 -2
- package/sensor/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/sensor/dist/extraction/tree-sitter.js +71 -4
- package/sensor/dist/extraction/tree-sitter.js.map +1 -1
- package/sensor/dist/extraction/wasm-runtime-flags.d.ts +2 -2
- package/sensor/dist/extraction/wasm-runtime-flags.d.ts.map +1 -1
- package/sensor/dist/extraction/wasm-runtime-flags.js +5 -5
- package/sensor/dist/extraction/wasm-runtime-flags.js.map +1 -1
- package/sensor/dist/index.d.ts +36 -36
- package/sensor/dist/index.d.ts.map +1 -1
- package/sensor/dist/index.js +71 -71
- package/sensor/dist/index.js.map +1 -1
- package/sensor/dist/mcp/daemon-manager.js +1 -1
- package/sensor/dist/mcp/daemon-paths.d.ts +3 -3
- package/sensor/dist/mcp/daemon-paths.js +7 -7
- package/sensor/dist/mcp/daemon-paths.js.map +1 -1
- package/sensor/dist/mcp/daemon-registry.d.ts +2 -2
- package/sensor/dist/mcp/daemon-registry.js +5 -5
- package/sensor/dist/mcp/daemon.d.ts +7 -7
- package/sensor/dist/mcp/daemon.d.ts.map +1 -1
- package/sensor/dist/mcp/daemon.js +21 -21
- package/sensor/dist/mcp/daemon.js.map +1 -1
- package/sensor/dist/mcp/dynamic-boundaries.js +1 -1
- package/sensor/dist/mcp/engine.d.ts +9 -9
- package/sensor/dist/mcp/engine.d.ts.map +1 -1
- package/sensor/dist/mcp/engine.js +44 -44
- package/sensor/dist/mcp/engine.js.map +1 -1
- package/sensor/dist/mcp/index.d.ts +14 -14
- package/sensor/dist/mcp/index.d.ts.map +1 -1
- package/sensor/dist/mcp/index.js +41 -41
- package/sensor/dist/mcp/index.js.map +1 -1
- package/sensor/dist/mcp/liveness-watchdog.js +7 -7
- package/sensor/dist/mcp/liveness-watchdog.js.map +1 -1
- package/sensor/dist/mcp/ppid-watchdog.d.ts +3 -3
- package/sensor/dist/mcp/ppid-watchdog.js +2 -2
- package/sensor/dist/mcp/proxy.d.ts.map +1 -1
- package/sensor/dist/mcp/proxy.js +37 -37
- package/sensor/dist/mcp/proxy.js.map +1 -1
- package/sensor/dist/mcp/query-pool.d.ts +3 -3
- package/sensor/dist/mcp/query-pool.js +7 -7
- package/sensor/dist/mcp/query-pool.js.map +1 -1
- package/sensor/dist/mcp/query-worker.d.ts +2 -2
- package/sensor/dist/mcp/query-worker.js +7 -7
- package/sensor/dist/mcp/query-worker.js.map +1 -1
- package/sensor/dist/mcp/server-instructions.d.ts +10 -12
- package/sensor/dist/mcp/server-instructions.d.ts.map +1 -1
- package/sensor/dist/mcp/server-instructions.js +39 -37
- package/sensor/dist/mcp/server-instructions.js.map +1 -1
- package/sensor/dist/mcp/session.d.ts +2 -2
- package/sensor/dist/mcp/session.js +18 -18
- package/sensor/dist/mcp/session.js.map +1 -1
- package/sensor/dist/mcp/startup-handshake.d.ts +3 -3
- package/sensor/dist/mcp/startup-handshake.d.ts.map +1 -1
- package/sensor/dist/mcp/startup-handshake.js +3 -3
- package/sensor/dist/mcp/startup-handshake.js.map +1 -1
- package/sensor/dist/mcp/tools.d.ts +53 -53
- package/sensor/dist/mcp/tools.d.ts.map +1 -1
- package/sensor/dist/mcp/tools.js +180 -216
- package/sensor/dist/mcp/tools.js.map +1 -1
- package/sensor/dist/mcp/transport.d.ts +1 -1
- package/sensor/dist/mcp/transport.js +6 -6
- package/sensor/dist/mcp/transport.js.map +1 -1
- package/sensor/dist/mcp/version.d.ts +2 -2
- package/sensor/dist/mcp/version.d.ts.map +1 -1
- package/sensor/dist/mcp/version.js +3 -3
- package/sensor/dist/mcp/version.js.map +1 -1
- package/sensor/dist/project-config.d.ts +6 -6
- package/sensor/dist/project-config.d.ts.map +1 -1
- package/sensor/dist/project-config.js +10 -10
- package/sensor/dist/project-config.js.map +1 -1
- package/sensor/dist/resolution/callback-synthesizer.js +4 -4
- package/sensor/dist/resolution/callback-synthesizer.js.map +1 -1
- package/sensor/dist/resolution/frameworks/drupal.d.ts +3 -3
- package/sensor/dist/resolution/frameworks/drupal.js +3 -3
- package/sensor/dist/resolution/frameworks/fabric.js +1 -1
- package/sensor/dist/resolution/frameworks/fabric.js.map +1 -1
- package/sensor/dist/resolution/frameworks/java.js +1 -1
- package/sensor/dist/resolution/frameworks/java.js.map +1 -1
- package/sensor/dist/resolution/frameworks/svelte.js +1 -1
- package/sensor/dist/resolution/frameworks/svelte.js.map +1 -1
- package/sensor/dist/resolution/goframe-synthesizer.d.ts +1 -1
- package/sensor/dist/resolution/goframe-synthesizer.js +1 -1
- package/sensor/dist/resolution/index.d.ts +1 -1
- package/sensor/dist/resolution/index.js +9 -9
- package/sensor/dist/resolution/index.js.map +1 -1
- package/sensor/dist/resolution/name-matcher.js +2 -2
- package/sensor/dist/resolution/name-matcher.js.map +1 -1
- package/sensor/dist/resolution/resolver-pool.d.ts +2 -2
- package/sensor/dist/resolution/resolver-pool.js +4 -4
- package/sensor/dist/resolution/resolver-pool.js.map +1 -1
- package/sensor/dist/resolution/resolver-worker.js +2 -2
- package/sensor/dist/resolution/resolver-worker.js.map +1 -1
- package/sensor/dist/resolution/workspace-packages.js +1 -1
- package/sensor/dist/resolution/workspace-packages.js.map +1 -1
- package/sensor/dist/search/identifier-segments.d.ts +1 -1
- package/sensor/dist/search/identifier-segments.js +1 -1
- package/sensor/dist/search/query-utils.d.ts +1 -0
- package/sensor/dist/search/query-utils.d.ts.map +1 -1
- package/sensor/dist/search/query-utils.js +10 -3
- package/sensor/dist/search/query-utils.js.map +1 -1
- package/sensor/dist/sync/git-hooks.d.ts +9 -9
- package/sensor/dist/sync/git-hooks.d.ts.map +1 -1
- package/sensor/dist/sync/git-hooks.js +15 -15
- package/sensor/dist/sync/git-hooks.js.map +1 -1
- package/sensor/dist/sync/watch-policy.d.ts +2 -2
- package/sensor/dist/sync/watch-policy.js +5 -5
- package/sensor/dist/sync/watch-policy.js.map +1 -1
- package/sensor/dist/sync/watcher.d.ts +2 -2
- package/sensor/dist/sync/watcher.d.ts.map +1 -1
- package/sensor/dist/sync/watcher.js +16 -16
- package/sensor/dist/sync/watcher.js.map +1 -1
- package/sensor/dist/sync/worktree.d.ts +5 -5
- package/sensor/dist/sync/worktree.d.ts.map +1 -1
- package/sensor/dist/sync/worktree.js +9 -9
- package/sensor/dist/sync/worktree.js.map +1 -1
- package/sensor/dist/telemetry/index.d.ts +8 -8
- package/sensor/dist/telemetry/index.d.ts.map +1 -1
- package/sensor/dist/telemetry/index.js +16 -16
- package/sensor/dist/telemetry/index.js.map +1 -1
- package/sensor/dist/types.d.ts +2 -2
- package/sensor/dist/types.js +1 -1
- package/sensor/dist/ui/color.d.ts +2 -2
- package/sensor/dist/ui/color.js +2 -2
- package/sensor/dist/ui/glyphs.d.ts +3 -3
- package/sensor/dist/ui/glyphs.js +7 -7
- package/sensor/dist/ui/glyphs.js.map +1 -1
- package/sensor/dist/utils.d.ts +4 -4
- package/sensor/dist/utils.js +8 -8
- package/sensor/dist/utils.js.map +1 -1
- package/sensor/package.json +8 -13
- package/src/artifact-contracts.mjs +2 -2
- package/src/boundary-compiler.mjs +28 -28
- package/src/boundary-observation-compiler-v2.mjs +10 -10
- package/src/bounded-seam.mjs +144 -0
- package/src/bridge-cli.mjs +227 -0
- package/src/bridge-config.mjs +346 -0
- package/src/bridge-daemon.mjs +328 -0
- package/src/bridge-launch-agent.mjs +311 -0
- package/src/bridge-server.mjs +309 -0
- package/src/cli-help.mjs +163 -0
- package/src/control-compiler.mjs +30 -30
- package/src/dag-chain.mjs +261 -0
- package/src/factory-diagnostics.mjs +8 -7
- package/src/hash-chain.mjs +76 -0
- package/src/node-version-guard.mjs +5 -4
- package/src/project-cli.mjs +392 -0
- package/src/project-identity.mjs +71 -0
- package/src/rc1-evidence-bundle.mjs +16 -16
- package/src/rc1-v4-campaign.mjs +15 -14
- package/src/rc1-v5-artifact-set.mjs +2 -2
- package/src/rc1-v5-campaign.mjs +15 -14
- package/src/rc1-v6-artifact-set.mjs +18 -18
- package/src/rc1-v6-campaign.mjs +16 -16
- package/src/rc1-v6-causal-binding.mjs +16 -14
- package/src/rc1-v6-measurement.mjs +20 -38
- package/src/rc2-artifact-set.mjs +45 -40
- package/src/rc2-campaign.mjs +48 -66
- package/src/rc2-delivery-policy-front-end.mjs +30 -30
- package/src/rc2-rc1-transfer-front-end.mjs +5 -5
- package/src/rc3-actual-dogfood.mjs +6 -6
- package/src/rc3-dogfood-scaffold.mjs +12 -7
- package/src/rc3-scripted-campaign.mjs +75 -21
- package/src/rc4-stage1-dogfood.mjs +24 -7
- package/src/runtime-cli.mjs +2424 -45
- package/src/runtime-contracts.mjs +7 -7
- package/src/runtime-control-store.mjs +547 -0
- package/src/runtime-controller-protocol.mjs +517 -0
- package/src/runtime-direct-os-observer.mjs +284 -0
- package/src/runtime-engine.mjs +2 -2
- package/src/runtime-errors.mjs +1 -1
- package/src/runtime-event-store.mjs +15 -43
- package/src/runtime-front-end.mjs +26 -26
- package/src/runtime-gate-store.mjs +477 -0
- package/src/runtime-hold-recompile.mjs +214 -23
- package/src/runtime-lifecycle-lock.mjs +290 -0
- package/src/runtime-managed-supervisor.mjs +1276 -0
- package/src/runtime-multi-epoch-store.mjs +761 -0
- package/src/runtime-projection.mjs +62 -0
- package/src/seam-transform.mjs +38 -38
- package/src/{codegraph-adapter.mjs → sensor-adapter.mjs} +7 -7
- package/src/sensor-cli.mjs +107 -0
- package/src/sensor-runtime.mjs +48 -0
- package/src/timestamp-contract.mjs +8 -0
- package/src/todo-chain.mjs +178 -0
- package/src/todo-cli.mjs +1032 -0
- package/src/todo-contracts.mjs +501 -0
- package/src/todo-dashboard-registry.mjs +318 -0
- package/src/todo-gantt-html.mjs +416 -0
- package/src/todo-gantt-layout.mjs +603 -0
- package/src/todo-gantt-live.mjs +269 -0
- package/src/todo-gantt-presentation.mjs +217 -0
- package/src/todo-gantt-svg.mjs +249 -0
- package/src/todo-markdown-renderer.mjs +260 -0
- package/src/todo-migration.mjs +260 -0
- package/src/todo-narrative-anchor.mjs +130 -0
- package/src/todo-revision.mjs +425 -0
- package/src/todo-status.mjs +340 -0
- package/src/todo-store.mjs +3451 -0
- package/src/treatment-compiler.mjs +28 -28
- package/src/treatment-runner.mjs +42 -44
- package/sensor/dist/bin/codegraph.d.ts +0 -26
- package/sensor/dist/bin/codegraph.d.ts.map +0 -1
- package/sensor/dist/bin/codegraph.js.map +0 -1
- package/sensor/dist/bin/uninstall.d.ts +0 -14
- package/sensor/dist/bin/uninstall.d.ts.map +0 -1
- package/sensor/dist/bin/uninstall.js +0 -36
- package/sensor/dist/bin/uninstall.js.map +0 -1
- package/sensor/dist/installer/beta-signup.d.ts +0 -54
- package/sensor/dist/installer/beta-signup.d.ts.map +0 -1
- package/sensor/dist/installer/beta-signup.js +0 -178
- package/sensor/dist/installer/beta-signup.js.map +0 -1
- package/sensor/dist/installer/config-writer.d.ts +0 -28
- package/sensor/dist/installer/config-writer.d.ts.map +0 -1
- package/sensor/dist/installer/config-writer.js +0 -91
- package/sensor/dist/installer/config-writer.js.map +0 -1
- package/sensor/dist/installer/index.d.ts +0 -142
- package/sensor/dist/installer/index.d.ts.map +0 -1
- package/sensor/dist/installer/index.js +0 -622
- package/sensor/dist/installer/index.js.map +0 -1
- package/sensor/dist/installer/instructions-template.d.ts +0 -41
- package/sensor/dist/installer/instructions-template.d.ts.map +0 -1
- package/sensor/dist/installer/instructions-template.js +0 -53
- package/sensor/dist/installer/instructions-template.js.map +0 -1
- package/sensor/dist/installer/targets/antigravity.d.ts +0 -57
- package/sensor/dist/installer/targets/antigravity.d.ts.map +0 -1
- package/sensor/dist/installer/targets/antigravity.js +0 -308
- package/sensor/dist/installer/targets/antigravity.js.map +0 -1
- package/sensor/dist/installer/targets/claude.d.ts +0 -62
- package/sensor/dist/installer/targets/claude.d.ts.map +0 -1
- package/sensor/dist/installer/targets/claude.js +0 -454
- package/sensor/dist/installer/targets/claude.js.map +0 -1
- package/sensor/dist/installer/targets/codex.d.ts +0 -18
- package/sensor/dist/installer/targets/codex.d.ts.map +0 -1
- package/sensor/dist/installer/targets/codex.js +0 -185
- package/sensor/dist/installer/targets/codex.js.map +0 -1
- package/sensor/dist/installer/targets/cursor.d.ts +0 -35
- package/sensor/dist/installer/targets/cursor.d.ts.map +0 -1
- package/sensor/dist/installer/targets/cursor.js +0 -254
- package/sensor/dist/installer/targets/cursor.js.map +0 -1
- package/sensor/dist/installer/targets/gemini.d.ts +0 -26
- package/sensor/dist/installer/targets/gemini.d.ts.map +0 -1
- package/sensor/dist/installer/targets/gemini.js +0 -165
- package/sensor/dist/installer/targets/gemini.js.map +0 -1
- package/sensor/dist/installer/targets/hermes.d.ts +0 -18
- package/sensor/dist/installer/targets/hermes.d.ts.map +0 -1
- package/sensor/dist/installer/targets/hermes.js +0 -359
- package/sensor/dist/installer/targets/hermes.js.map +0 -1
- package/sensor/dist/installer/targets/kiro.d.ts +0 -27
- package/sensor/dist/installer/targets/kiro.d.ts.map +0 -1
- package/sensor/dist/installer/targets/kiro.js +0 -178
- package/sensor/dist/installer/targets/kiro.js.map +0 -1
- package/sensor/dist/installer/targets/opencode.d.ts +0 -38
- package/sensor/dist/installer/targets/opencode.d.ts.map +0 -1
- package/sensor/dist/installer/targets/opencode.js +0 -288
- package/sensor/dist/installer/targets/opencode.js.map +0 -1
- package/sensor/dist/installer/targets/registry.d.ts +0 -35
- package/sensor/dist/installer/targets/registry.d.ts.map +0 -1
- package/sensor/dist/installer/targets/registry.js +0 -91
- package/sensor/dist/installer/targets/registry.js.map +0 -1
- package/sensor/dist/installer/targets/shared.d.ts +0 -101
- package/sensor/dist/installer/targets/shared.d.ts.map +0 -1
- package/sensor/dist/installer/targets/shared.js +0 -264
- package/sensor/dist/installer/targets/shared.js.map +0 -1
- package/sensor/dist/installer/targets/toml.d.ts +0 -52
- package/sensor/dist/installer/targets/toml.d.ts.map +0 -1
- package/sensor/dist/installer/targets/toml.js +0 -147
- package/sensor/dist/installer/targets/toml.js.map +0 -1
- package/sensor/dist/installer/targets/types.d.ts +0 -108
- package/sensor/dist/installer/targets/types.d.ts.map +0 -1
- package/sensor/dist/installer/targets/types.js +0 -16
- package/sensor/dist/installer/targets/types.js.map +0 -1
- package/sensor/dist/upgrade/index.d.ts +0 -171
- package/sensor/dist/upgrade/index.d.ts.map +0 -1
- package/sensor/dist/upgrade/index.js +0 -659
- package/sensor/dist/upgrade/index.js.map +0 -1
- package/sensor/dist/upgrade/remove-binary.d.ts +0 -87
- package/sensor/dist/upgrade/remove-binary.d.ts.map +0 -1
- package/sensor/dist/upgrade/remove-binary.js +0 -289
- package/sensor/dist/upgrade/remove-binary.js.map +0 -1
- package/sensor/dist/upgrade/update-check.d.ts +0 -92
- package/sensor/dist/upgrade/update-check.d.ts.map +0 -1
- package/sensor/dist/upgrade/update-check.js +0 -258
- package/sensor/dist/upgrade/update-check.js.map +0 -1
- package/src/bootstrap.mjs +0 -88
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TODO_LIMITS,
|
|
3
|
+
exactRecord,
|
|
4
|
+
isStrictTodoTimestamp,
|
|
5
|
+
isTodoDigest,
|
|
6
|
+
isTodoIdentifier,
|
|
7
|
+
isTodoRef,
|
|
8
|
+
todoSelfDigest,
|
|
9
|
+
} from './todo-contracts.mjs';
|
|
10
|
+
import {
|
|
11
|
+
TodoStoreError,
|
|
12
|
+
appendImportedPlan,
|
|
13
|
+
createTodoStoreWriter,
|
|
14
|
+
} from './todo-store.mjs';
|
|
15
|
+
|
|
16
|
+
export const TODO_EXTRACTION_SCHEMA = 'lattice.todo_extraction.v1';
|
|
17
|
+
export const TODO_EXTRACTION_SCHEMA_V2 = 'lattice.todo_extraction.v2';
|
|
18
|
+
|
|
19
|
+
const V1_DISPOSITIONS = new Set([
|
|
20
|
+
'register_pending',
|
|
21
|
+
'register_done',
|
|
22
|
+
'exclude_superseded',
|
|
23
|
+
'exclude_compatibility_record',
|
|
24
|
+
'unknown_requires_evidence',
|
|
25
|
+
]);
|
|
26
|
+
const V2_DISPOSITIONS = new Set([...V1_DISPOSITIONS, 'register_in_progress']);
|
|
27
|
+
const CHECKBOX_STATES = new Set(['checked', 'unchecked', 'absent', 'ambiguous']);
|
|
28
|
+
const COMMIT_OID = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u;
|
|
29
|
+
|
|
30
|
+
function boundedText(value, maximumBytes = 16_384) {
|
|
31
|
+
return typeof value === 'string' && value.length > 0 && Buffer.byteLength(value) <= maximumBytes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function nullableText(value) {
|
|
35
|
+
return value === null || boundedText(value);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function actor(value) {
|
|
39
|
+
return exactRecord(value, ['host', 'session', 'agent'])
|
|
40
|
+
&& [value.host, value.session, value.agent].every(isTodoIdentifier);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function nodeRef(value) {
|
|
44
|
+
return (exactRecord(value, ['project_id', 'plan_key', 'task_id'])
|
|
45
|
+
|| exactRecord(value, ['project_id', 'plan_key', 'task_id', 'expected_topology_digest']))
|
|
46
|
+
&& isTodoIdentifier(value.project_id) && isTodoIdentifier(value.plan_key)
|
|
47
|
+
&& isTodoIdentifier(value.task_id)
|
|
48
|
+
&& (value.expected_topology_digest === undefined || isTodoDigest(value.expected_topology_digest));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function refKey(value) {
|
|
52
|
+
return `${value.project_id}\0${value.plan_key}\0${value.task_id}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function sortedStrictly(values, key = (value) => value) {
|
|
56
|
+
return values.every((value, index) => index === 0 || key(values[index - 1]) < key(value));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function sourceLocation(value) {
|
|
60
|
+
return exactRecord(value, [
|
|
61
|
+
'origin_plan_ref', 'origin_line', 'source_commit', 'heading_path', 'markdown_depth',
|
|
62
|
+
'parent_task_id', 'checkbox_state',
|
|
63
|
+
]) && isTodoRef(value.origin_plan_ref) && Number.isSafeInteger(value.origin_line) && value.origin_line >= 1
|
|
64
|
+
&& COMMIT_OID.test(value.source_commit)
|
|
65
|
+
&& Array.isArray(value.heading_path) && value.heading_path.length <= 32
|
|
66
|
+
&& value.heading_path.every((part) => boundedText(part, 1_024))
|
|
67
|
+
&& Number.isSafeInteger(value.markdown_depth) && value.markdown_depth >= 0 && value.markdown_depth <= 64
|
|
68
|
+
&& (value.parent_task_id === null || isTodoIdentifier(value.parent_task_id))
|
|
69
|
+
&& CHECKBOX_STATES.has(value.checkbox_state);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function migrationContext(value) {
|
|
73
|
+
return exactRecord(value, [
|
|
74
|
+
'external_canonical_ref', 'carry_over_ref', 'h_required', 'condition', 'evidence_refs', 'notes',
|
|
75
|
+
]) && nullableText(value.external_canonical_ref) && nullableText(value.carry_over_ref)
|
|
76
|
+
&& typeof value.h_required === 'boolean' && nullableText(value.condition)
|
|
77
|
+
&& Array.isArray(value.evidence_refs) && value.evidence_refs.length <= 64
|
|
78
|
+
&& value.evidence_refs.every((entry) => boundedText(entry, 4_096))
|
|
79
|
+
&& Array.isArray(value.notes) && value.notes.length <= 64
|
|
80
|
+
&& value.notes.every((entry) => boundedText(entry, 4_096));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function completion(value) {
|
|
84
|
+
return exactRecord(value, ['done_mode', 'completed_at'])
|
|
85
|
+
&& value.done_mode === 'historical_import'
|
|
86
|
+
&& (value.completed_at === 'unknown_requires_evidence' || isStrictTodoTimestamp(value.completed_at));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function historicalStart(value) {
|
|
90
|
+
return exactRecord(value, ['start_mode', 'status', 'started_at'])
|
|
91
|
+
&& value.start_mode === 'historical_import' && value.status === 'in-progress'
|
|
92
|
+
&& (value.started_at === 'unknown_requires_evidence' || isStrictTodoTimestamp(value.started_at));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function extractionTask(value, schema) {
|
|
96
|
+
const v2 = schema === TODO_EXTRACTION_SCHEMA_V2;
|
|
97
|
+
const keys = [
|
|
98
|
+
'task_id', 'title', 'lane', 'narrative_ref', 'compile_binding', 'disposition',
|
|
99
|
+
'completion', 'source', 'migration_context',
|
|
100
|
+
];
|
|
101
|
+
if (v2) keys.push('start');
|
|
102
|
+
if (!exactRecord(value, keys) || !isTodoIdentifier(value.task_id) || !boundedText(value.title)
|
|
103
|
+
|| !isTodoIdentifier(value.lane) || (value.narrative_ref !== null && !isTodoRef(value.narrative_ref))
|
|
104
|
+
|| value.compile_binding !== null || !(v2 ? V2_DISPOSITIONS : V1_DISPOSITIONS).has(value.disposition)
|
|
105
|
+
|| !sourceLocation(value.source) || !migrationContext(value.migration_context)) return false;
|
|
106
|
+
if (!v2) return value.disposition === 'register_done' ? completion(value.completion) : value.completion === null;
|
|
107
|
+
if (value.disposition === 'register_done') return value.start === null && completion(value.completion);
|
|
108
|
+
if (value.disposition === 'register_in_progress') {
|
|
109
|
+
return historicalStart(value.start) && value.completion === null;
|
|
110
|
+
}
|
|
111
|
+
return value.start === null && value.completion === null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function validateEdges(value) {
|
|
115
|
+
return Array.isArray(value) && value.length <= TODO_LIMITS.edgesPerPlan
|
|
116
|
+
&& value.every((edge) => exactRecord(edge, ['from', 'to']) && nodeRef(edge.from) && nodeRef(edge.to))
|
|
117
|
+
&& sortedStrictly(value, (edge) => `${refKey(edge.from)}\0${refKey(edge.to)}`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function validateJoins(value) {
|
|
121
|
+
return Array.isArray(value) && value.length <= TODO_LIMITS.joinsPerPlan
|
|
122
|
+
&& value.every((join) => exactRecord(join, ['id', 'after', 'before'])
|
|
123
|
+
&& isTodoIdentifier(join.id) && Array.isArray(join.after) && join.after.length > 0
|
|
124
|
+
&& join.after.length <= TODO_LIMITS.tasksPerPlan && join.after.every(nodeRef)
|
|
125
|
+
&& sortedStrictly(join.after, refKey) && nodeRef(join.before))
|
|
126
|
+
&& sortedStrictly(value, (join) => join.id);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function registeredTaskIds(value) {
|
|
130
|
+
return new Set(value.tasks
|
|
131
|
+
.filter(({ disposition }) => disposition.startsWith('register_'))
|
|
132
|
+
.map(({ task_id }) => task_id));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function localRefsResolve(value) {
|
|
136
|
+
const registered = registeredTaskIds(value);
|
|
137
|
+
const local = (ref) => ref.project_id !== value.project_id || ref.plan_key !== value.plan_key
|
|
138
|
+
|| registered.has(ref.task_id);
|
|
139
|
+
return value.hard_dependencies.every((edge) => local(edge.from) && local(edge.to))
|
|
140
|
+
&& value.joins.every((join) => local(join.before) && join.after.every(local));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Exact, bounded validation for the AI-authored G4 intermediate artifact. */
|
|
144
|
+
export function validateTodoExtraction(value) {
|
|
145
|
+
try {
|
|
146
|
+
const schema = value?.schema;
|
|
147
|
+
if (!exactRecord(value, [
|
|
148
|
+
'schema', 'project_id', 'plan_key', 'plan_version', 'actor', 'recorded_at',
|
|
149
|
+
'tasks', 'hard_dependencies', 'joins', 'extraction_digest',
|
|
150
|
+
]) || ![TODO_EXTRACTION_SCHEMA, TODO_EXTRACTION_SCHEMA_V2].includes(schema)
|
|
151
|
+
|| !isTodoIdentifier(value.project_id)
|
|
152
|
+
|| !isTodoIdentifier(value.plan_key) || !isTodoIdentifier(value.plan_version)
|
|
153
|
+
|| !actor(value.actor) || !isStrictTodoTimestamp(value.recorded_at)
|
|
154
|
+
|| !Array.isArray(value.tasks) || value.tasks.length === 0
|
|
155
|
+
|| value.tasks.length > TODO_LIMITS.tasksPerPlan
|
|
156
|
+
|| !value.tasks.every((task) => extractionTask(task, schema))
|
|
157
|
+
|| !sortedStrictly(value.tasks, (task) => task.task_id)
|
|
158
|
+
|| new Set(value.tasks.map(({ task_id }) => task_id)).size !== value.tasks.length
|
|
159
|
+
|| !validateEdges(value.hard_dependencies) || !validateJoins(value.joins)
|
|
160
|
+
|| !isTodoDigest(value.extraction_digest)
|
|
161
|
+
|| value.extraction_digest !== todoSelfDigest(value, 'extraction_digest')) return false;
|
|
162
|
+
|
|
163
|
+
const taskIds = new Set(value.tasks.map(({ task_id }) => task_id));
|
|
164
|
+
if (value.tasks.some((task) => task.source.parent_task_id === task.task_id
|
|
165
|
+
|| (task.source.parent_task_id !== null && !taskIds.has(task.source.parent_task_id)))) return false;
|
|
166
|
+
return localRefsResolve(value);
|
|
167
|
+
} catch {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function todoExtractionImportSource(task) {
|
|
173
|
+
return {
|
|
174
|
+
schema: 'lattice.todo_import_source.v1',
|
|
175
|
+
origin_plan_ref: task.source.origin_plan_ref,
|
|
176
|
+
origin_line: task.source.origin_line,
|
|
177
|
+
source_commit: task.source.source_commit,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Translate an already-extracted artifact into appendImportedPlan input.
|
|
183
|
+
* Source locations are passed to the importer but no Markdown is read here.
|
|
184
|
+
* Unresolved records stop the whole transaction so the owner can adjudicate
|
|
185
|
+
* the JSON and rerun the same command.
|
|
186
|
+
*/
|
|
187
|
+
export function compileTodoExtraction(value, repoRoot) {
|
|
188
|
+
if (!validateTodoExtraction(value)) {
|
|
189
|
+
throw new TodoStoreError('INVALID_TODO_EXTRACTION', 'schema_invalid');
|
|
190
|
+
}
|
|
191
|
+
const unresolved = value.tasks
|
|
192
|
+
.filter(({ disposition }) => disposition === 'unknown_requires_evidence')
|
|
193
|
+
.map(({ task_id }) => task_id);
|
|
194
|
+
if (unresolved.length > 0) {
|
|
195
|
+
throw new TodoStoreError('MIGRATION_UNRESOLVED', 'unknown_requires_evidence', undefined, {
|
|
196
|
+
task_ids: unresolved,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const registered = value.tasks.filter(({ disposition }) => disposition.startsWith('register_'));
|
|
201
|
+
if (registered.length === 0) {
|
|
202
|
+
throw new TodoStoreError('MIGRATION_EMPTY', 'no_registered_tasks');
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
repoRoot,
|
|
206
|
+
writer: createTodoStoreWriter({ caller: 'g4-migration' }),
|
|
207
|
+
initializeIfMissing: {
|
|
208
|
+
projectId: value.project_id,
|
|
209
|
+
repositories: [{ repo_id: 'self', path: '.' }],
|
|
210
|
+
},
|
|
211
|
+
plan: {
|
|
212
|
+
schema: 'lattice.todo_plan.v2',
|
|
213
|
+
project_id: value.project_id,
|
|
214
|
+
plan_key: value.plan_key,
|
|
215
|
+
plan_version: value.plan_version,
|
|
216
|
+
predecessor_plan_digest: null,
|
|
217
|
+
tasks: registered.map((task) => ({
|
|
218
|
+
task_id: task.task_id,
|
|
219
|
+
title: task.title,
|
|
220
|
+
lane: task.lane,
|
|
221
|
+
narrative_ref: task.narrative_ref,
|
|
222
|
+
narrative_anchor: null,
|
|
223
|
+
compile_binding: null,
|
|
224
|
+
})),
|
|
225
|
+
hard_dependencies: value.hard_dependencies,
|
|
226
|
+
joins: value.joins,
|
|
227
|
+
},
|
|
228
|
+
narrativeAnchorSources: registered.map((task) => ({
|
|
229
|
+
task_id: task.task_id,
|
|
230
|
+
origin_plan_ref: task.source.origin_plan_ref,
|
|
231
|
+
origin_line: task.source.origin_line,
|
|
232
|
+
source_commit: task.source.source_commit,
|
|
233
|
+
checkbox_state: task.source.checkbox_state,
|
|
234
|
+
})),
|
|
235
|
+
genesis: {
|
|
236
|
+
actor: value.actor,
|
|
237
|
+
recorded_at: value.recorded_at,
|
|
238
|
+
provenance: null,
|
|
239
|
+
},
|
|
240
|
+
completedTasks: registered
|
|
241
|
+
.filter(({ disposition }) => disposition === 'register_done')
|
|
242
|
+
.map((task) => ({
|
|
243
|
+
task_id: task.task_id,
|
|
244
|
+
completed_at: task.completion.completed_at,
|
|
245
|
+
evidence: todoExtractionImportSource(task),
|
|
246
|
+
})),
|
|
247
|
+
inProgressTasks: registered
|
|
248
|
+
.filter(({ disposition }) => disposition === 'register_in_progress')
|
|
249
|
+
.map((task) => ({
|
|
250
|
+
task_id: task.task_id,
|
|
251
|
+
started_at: task.start.started_at,
|
|
252
|
+
evidence: todoExtractionImportSource(task),
|
|
253
|
+
})),
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export async function appendTodoExtraction({ repoRoot, extraction }) {
|
|
258
|
+
const request = compileTodoExtraction(extraction, repoRoot);
|
|
259
|
+
return appendImportedPlan(request);
|
|
260
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
|
|
3
|
+
import { parseTodoMarkdownDocument } from './todo-markdown-renderer.mjs';
|
|
4
|
+
|
|
5
|
+
const REASONS = Object.freeze({
|
|
6
|
+
ANCHOR_MISSING: 'anchor_missing',
|
|
7
|
+
PATH_MISMATCH: 'path_mismatch',
|
|
8
|
+
LINE_MISSING: 'line_missing',
|
|
9
|
+
DIGEST_MISMATCH: 'digest_mismatch',
|
|
10
|
+
NOT_CHECKBOX: 'not_checkbox',
|
|
11
|
+
DUPLICATE_CLAIM: 'duplicate_claim',
|
|
12
|
+
AST_LOCATION_MISSING: 'ast_location_missing',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
function refKey(ref) {
|
|
16
|
+
return JSON.stringify([ref.project_id, ref.plan_key, ref.task_id]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function compareText(left, right) {
|
|
20
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function compareRefs(left, right) {
|
|
24
|
+
return compareText(left.project_id, right.project_id)
|
|
25
|
+
|| compareText(left.plan_key, right.plan_key)
|
|
26
|
+
|| compareText(left.task_id, right.task_id);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function listItems(tree) {
|
|
30
|
+
const result = [];
|
|
31
|
+
const visit = (node) => {
|
|
32
|
+
if (node === null || typeof node !== 'object') return;
|
|
33
|
+
if (node.type === 'listItem') result.push(node);
|
|
34
|
+
if (Array.isArray(node.children)) for (const child of node.children) visit(child);
|
|
35
|
+
};
|
|
36
|
+
visit(tree);
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function outcome(ref, narrativeRef, anchor, reason) {
|
|
41
|
+
return {
|
|
42
|
+
ref,
|
|
43
|
+
narrative_ref: narrativeRef,
|
|
44
|
+
anchored: reason === null,
|
|
45
|
+
reason,
|
|
46
|
+
origin_line: anchor?.origin_line ?? null,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function verifyNarrativeAnchors({
|
|
51
|
+
readModel,
|
|
52
|
+
narratives,
|
|
53
|
+
parseMarkdown = parseTodoMarkdownDocument,
|
|
54
|
+
}) {
|
|
55
|
+
if (readModel?.schema !== 'lattice.todo_store_read.v1' || !Array.isArray(readModel.members)) {
|
|
56
|
+
throw new TypeError('readModel must be lattice.todo_store_read.v1');
|
|
57
|
+
}
|
|
58
|
+
if (!Array.isArray(narratives)) throw new TypeError('narratives must be an array');
|
|
59
|
+
if (typeof parseMarkdown !== 'function') throw new TypeError('parseMarkdown must be a function');
|
|
60
|
+
|
|
61
|
+
const supplied = new Map(narratives.map((entry) => [refKey(entry.ref), entry]));
|
|
62
|
+
const candidates = [];
|
|
63
|
+
for (const member of readModel.members) for (const task of member.plan.tasks) {
|
|
64
|
+
const ref = {
|
|
65
|
+
project_id: member.plan.project_id,
|
|
66
|
+
plan_key: member.plan.plan_key,
|
|
67
|
+
task_id: task.task_id,
|
|
68
|
+
};
|
|
69
|
+
const anchor = task.narrative_anchor ?? null;
|
|
70
|
+
const narrative = supplied.get(refKey(ref));
|
|
71
|
+
candidates.push({ ref, task, anchor, narrative });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const duplicateClaims = new Set();
|
|
75
|
+
const claims = new Map();
|
|
76
|
+
for (const candidate of candidates) {
|
|
77
|
+
const { anchor, narrative, task } = candidate;
|
|
78
|
+
if (anchor === null || task.narrative_ref !== anchor.origin_plan_ref
|
|
79
|
+
|| narrative?.narrative_ref !== task.narrative_ref || typeof narrative?.markdown !== 'string') continue;
|
|
80
|
+
const claimKey = JSON.stringify([anchor.origin_plan_ref, anchor.origin_line]);
|
|
81
|
+
const claimed = claims.get(claimKey) ?? [];
|
|
82
|
+
claimed.push(candidate);
|
|
83
|
+
claims.set(claimKey, claimed);
|
|
84
|
+
}
|
|
85
|
+
for (const claimed of claims.values()) {
|
|
86
|
+
if (claimed.length > 1) for (const candidate of claimed) duplicateClaims.add(refKey(candidate.ref));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const parsedDocuments = new Map();
|
|
90
|
+
const outcomes = candidates.map(({ ref, task, anchor, narrative }) => {
|
|
91
|
+
if (anchor === null) return outcome(ref, task.narrative_ref, anchor, REASONS.ANCHOR_MISSING);
|
|
92
|
+
if (task.narrative_ref !== anchor.origin_plan_ref
|
|
93
|
+
|| narrative?.narrative_ref !== task.narrative_ref || typeof narrative?.markdown !== 'string') {
|
|
94
|
+
return outcome(ref, task.narrative_ref, anchor, REASONS.PATH_MISMATCH);
|
|
95
|
+
}
|
|
96
|
+
if (duplicateClaims.has(refKey(ref))) {
|
|
97
|
+
return outcome(ref, task.narrative_ref, anchor, REASONS.DUPLICATE_CLAIM);
|
|
98
|
+
}
|
|
99
|
+
const lines = narrative.markdown.split('\n');
|
|
100
|
+
if (!Number.isSafeInteger(anchor.origin_line) || anchor.origin_line < 1
|
|
101
|
+
|| anchor.origin_line > lines.length) {
|
|
102
|
+
return outcome(ref, task.narrative_ref, anchor, REASONS.LINE_MISSING);
|
|
103
|
+
}
|
|
104
|
+
const line = lines[anchor.origin_line - 1];
|
|
105
|
+
const lineDigest = createHash('sha256').update(Buffer.from(line, 'utf8')).digest('hex');
|
|
106
|
+
if (lineDigest !== anchor.source_line_digest) {
|
|
107
|
+
return outcome(ref, task.narrative_ref, anchor, REASONS.DIGEST_MISMATCH);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const documentKey = JSON.stringify([task.narrative_ref, narrative.markdown]);
|
|
111
|
+
let items = parsedDocuments.get(documentKey);
|
|
112
|
+
if (items === undefined) {
|
|
113
|
+
items = listItems(parseMarkdown(narrative.markdown));
|
|
114
|
+
parsedDocuments.set(documentKey, items);
|
|
115
|
+
}
|
|
116
|
+
const matched = items.find((item) => item.position?.start?.line === anchor.origin_line);
|
|
117
|
+
if (matched !== undefined && typeof matched.checked === 'boolean') {
|
|
118
|
+
return outcome(ref, task.narrative_ref, anchor, null);
|
|
119
|
+
}
|
|
120
|
+
if (matched === undefined && items.some((item) => !Number.isSafeInteger(item.position?.start?.line))) {
|
|
121
|
+
return outcome(ref, task.narrative_ref, anchor, REASONS.AST_LOCATION_MISSING);
|
|
122
|
+
}
|
|
123
|
+
return outcome(ref, task.narrative_ref, anchor, REASONS.NOT_CHECKBOX);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
outcomes.sort((left, right) => compareRefs(left.ref, right.ref));
|
|
127
|
+
return outcomes;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const TODO_NARRATIVE_ANCHOR_REASONS = REASONS;
|