hippo-memory 1.59.0 → 1.61.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/README.md +1 -1
- package/dist/ablation.js +9 -27
- package/dist/agent-memories/apply.js +4 -1
- package/dist/agent-memories/claude-code.js +1 -1
- package/dist/agent-memories/codex.js +1 -1
- package/dist/agent-memories/gemini.js +1 -1
- package/dist/agent-memories/legacy.js +1 -1
- package/dist/agent-memories/source.js +1 -1
- package/dist/agent-memories/sync.js +8 -3
- package/dist/ambient-store.d.ts +14 -0
- package/dist/ambient-store.js +90 -0
- package/dist/ambient.d.ts +23 -0
- package/dist/ambient.js +72 -50
- package/dist/api/assemble.d.ts +93 -0
- package/dist/api/assemble.js +152 -0
- package/dist/api/audit.d.ts +17 -0
- package/dist/api/audit.js +23 -0
- package/dist/api/auth.d.ts +79 -0
- package/dist/api/auth.js +178 -0
- package/dist/api/context-types.d.ts +105 -0
- package/dist/api/context-types.js +3 -0
- package/dist/api/context.d.ts +31 -0
- package/dist/api/context.js +705 -0
- package/dist/api/dormant.d.ts +30 -0
- package/dist/api/dormant.js +140 -0
- package/dist/api/drill-down.d.ts +84 -0
- package/dist/api/drill-down.js +123 -0
- package/dist/api/forget.d.ts +57 -0
- package/dist/api/forget.js +87 -0
- package/dist/api/goals.d.ts +18 -0
- package/dist/api/goals.js +33 -0
- package/dist/api/learn.d.ts +31 -0
- package/dist/api/learn.js +88 -0
- package/dist/api/outcome.d.ts +61 -0
- package/dist/api/outcome.js +66 -0
- package/dist/api/promote.d.ts +54 -0
- package/dist/api/promote.js +203 -0
- package/dist/api/quarantine.d.ts +24 -0
- package/dist/api/quarantine.js +121 -0
- package/dist/api/recall-types.d.ts +390 -0
- package/dist/api/recall-types.js +3 -0
- package/dist/api/recall.d.ts +36 -0
- package/dist/api/recall.js +634 -0
- package/dist/api/remember.d.ts +35 -0
- package/dist/api/remember.js +43 -0
- package/dist/api/sleep.d.ts +136 -0
- package/dist/api/sleep.js +271 -0
- package/dist/api/tokens.d.ts +26 -0
- package/dist/api/tokens.js +60 -0
- package/dist/api/types.d.ts +56 -0
- package/dist/api/types.js +38 -0
- package/dist/api.d.ts +20 -1260
- package/dist/api.js +25 -2711
- package/dist/audit.d.ts +3 -0
- package/dist/audit.js +7 -3
- package/dist/auth.d.ts +45 -4
- package/dist/auth.js +125 -48
- package/dist/autolearn.js +7 -4
- package/dist/capture/command.d.ts +33 -0
- package/dist/capture/command.js +264 -0
- package/dist/capture/compact.d.ts +44 -0
- package/dist/capture/compact.js +354 -0
- package/dist/capture/extract.d.ts +21 -0
- package/dist/capture/extract.js +464 -0
- package/dist/capture/transcript.d.ts +40 -0
- package/dist/capture/transcript.js +193 -0
- package/dist/capture-error.js +2 -1
- package/dist/churn-git.js +4 -2
- package/dist/cli/audit.d.ts +3 -0
- package/dist/cli/audit.js +159 -0
- package/dist/cli/auth.d.ts +2 -0
- package/dist/cli/auth.js +171 -0
- package/dist/cli/briefs.d.ts +4 -0
- package/dist/cli/briefs.js +435 -0
- package/dist/cli/card.d.ts +3 -0
- package/dist/cli/card.js +333 -0
- package/dist/cli/context.d.ts +15 -0
- package/dist/cli/context.js +366 -0
- package/dist/cli/continuity.d.ts +6 -0
- package/dist/cli/continuity.js +445 -0
- package/dist/cli/curate.d.ts +19 -0
- package/dist/cli/curate.js +555 -0
- package/dist/cli/dag.d.ts +5 -0
- package/dist/cli/dag.js +177 -0
- package/dist/cli/decisions.d.ts +4 -0
- package/dist/cli/decisions.js +528 -0
- package/dist/cli/eval.d.ts +5 -0
- package/dist/cli/eval.js +213 -0
- package/dist/cli/explain.d.ts +4 -0
- package/dist/cli/explain.js +150 -0
- package/dist/cli/goals.d.ts +2 -0
- package/dist/cli/goals.js +196 -0
- package/dist/cli/hook-blocks.d.ts +18 -0
- package/dist/cli/hook-blocks.js +233 -0
- package/dist/cli/init.d.ts +2 -0
- package/dist/cli/init.js +305 -0
- package/dist/cli/maintenance.d.ts +4 -0
- package/dist/cli/maintenance.js +179 -0
- package/dist/cli/playbooks.d.ts +4 -0
- package/dist/cli/playbooks.js +556 -0
- package/dist/cli/projects.js +1 -1
- package/dist/cli/recall.d.ts +7 -0
- package/dist/cli/recall.js +597 -0
- package/dist/cli/remember.d.ts +5 -0
- package/dist/cli/remember.js +442 -0
- package/dist/cli/serve.d.ts +5 -0
- package/dist/cli/serve.js +40 -0
- package/dist/cli/session-hooks.d.ts +29 -0
- package/dist/cli/session-hooks.js +637 -0
- package/dist/cli/setup.d.ts +4 -0
- package/dist/cli/setup.js +376 -0
- package/dist/cli/shared.d.ts +15 -19
- package/dist/cli/shared.js +50 -341
- package/dist/cli/slack.d.ts +2 -0
- package/dist/cli/slack.js +171 -0
- package/dist/cli/status.d.ts +18 -0
- package/dist/cli/status.js +400 -0
- package/dist/cli/transfer.d.ts +10 -0
- package/dist/cli/transfer.js +438 -0
- package/dist/cli/usage.d.ts +85 -0
- package/dist/cli/usage.js +741 -0
- package/dist/cli.d.ts +319 -13
- package/dist/cli.js +436 -8580
- package/dist/client.js +15 -8
- package/dist/compaction-record.js +12 -9
- package/dist/config.js +12 -11
- package/dist/connectors/github/backfill.js +94 -87
- package/dist/connectors/github/cli-impl.js +5 -3
- package/dist/connectors/github/dlq.js +67 -54
- package/dist/connectors/github/ingest.js +34 -35
- package/dist/connectors/github/tenant-routing.js +3 -2
- package/dist/connectors/github/webhook.js +135 -216
- package/dist/connectors/slack/dlq.js +49 -61
- package/dist/connectors/slack/ingest.js +55 -48
- package/dist/connectors/slack/tenant-routing.js +4 -3
- package/dist/connectors/slack/webhook.js +72 -74
- package/dist/consolidate/conflicts.d.ts +10 -0
- package/dist/consolidate/conflicts.js +178 -0
- package/dist/consolidate/decay.d.ts +12 -0
- package/dist/consolidate/decay.js +145 -0
- package/dist/consolidate/llm-passes.d.ts +3 -0
- package/dist/consolidate/llm-passes.js +141 -0
- package/dist/consolidate/merge.d.ts +7 -0
- package/dist/consolidate/merge.js +251 -0
- package/dist/consolidate/physics-pass.d.ts +3 -0
- package/dist/consolidate/physics-pass.js +60 -0
- package/dist/consolidate/run.d.ts +69 -0
- package/dist/consolidate/run.js +76 -0
- package/dist/consolidate/sleep.d.ts +18 -0
- package/dist/consolidate/sleep.js +209 -0
- package/dist/consolidate/traces.d.ts +4 -0
- package/dist/consolidate/traces.js +178 -0
- package/dist/context-auto.js +7 -11
- package/dist/context-render.d.ts +1 -1
- package/dist/context-render.js +1 -1
- package/dist/customer-notes.d.ts +3 -0
- package/dist/customer-notes.js +6 -4
- package/dist/dag.js +13 -12
- package/dist/dashboard-actions.d.ts +20 -0
- package/dist/dashboard-actions.js +88 -0
- package/dist/dashboard-params.d.ts +45 -0
- package/dist/dashboard-params.js +127 -0
- package/dist/dashboard-queries.d.ts +15 -0
- package/dist/dashboard-queries.js +355 -0
- package/dist/dashboard-snapshot.d.ts +138 -0
- package/dist/dashboard-snapshot.js +308 -0
- package/dist/dashboard-types.d.ts +163 -0
- package/dist/dashboard-types.js +3 -0
- package/dist/dashboard.d.ts +6 -7
- package/dist/dashboard.js +231 -203
- package/dist/db/busy.d.ts +5 -0
- package/dist/db/busy.js +24 -0
- package/dist/db/continuity.d.ts +5 -0
- package/dist/db/continuity.js +145 -0
- package/dist/db/meta.d.ts +8 -0
- package/dist/db/meta.js +35 -0
- package/dist/db/migrate.d.ts +9 -0
- package/dist/db/migrate.js +138 -0
- package/dist/db/migrations/index.d.ts +5 -0
- package/dist/db/migrations/index.js +109 -0
- package/dist/db/migrations/types.d.ts +14 -0
- package/dist/db/migrations/types.js +2 -0
- package/dist/db/migrations/v01.d.ts +3 -0
- package/dist/db/migrations/v01.js +38 -0
- package/dist/db/migrations/v02.d.ts +3 -0
- package/dist/db/migrations/v02.js +21 -0
- package/dist/db/migrations/v03.d.ts +3 -0
- package/dist/db/migrations/v03.js +22 -0
- package/dist/db/migrations/v04.d.ts +3 -0
- package/dist/db/migrations/v04.js +28 -0
- package/dist/db/migrations/v05.d.ts +3 -0
- package/dist/db/migrations/v05.js +21 -0
- package/dist/db/migrations/v06.d.ts +3 -0
- package/dist/db/migrations/v06.js +25 -0
- package/dist/db/migrations/v07.d.ts +3 -0
- package/dist/db/migrations/v07.js +13 -0
- package/dist/db/migrations/v08.d.ts +3 -0
- package/dist/db/migrations/v08.js +8 -0
- package/dist/db/migrations/v09.d.ts +3 -0
- package/dist/db/migrations/v09.js +13 -0
- package/dist/db/migrations/v10.d.ts +3 -0
- package/dist/db/migrations/v10.js +17 -0
- package/dist/db/migrations/v11.d.ts +3 -0
- package/dist/db/migrations/v11.js +15 -0
- package/dist/db/migrations/v12.d.ts +3 -0
- package/dist/db/migrations/v12.js +11 -0
- package/dist/db/migrations/v13.d.ts +3 -0
- package/dist/db/migrations/v13.js +15 -0
- package/dist/db/migrations/v14.d.ts +3 -0
- package/dist/db/migrations/v14.js +66 -0
- package/dist/db/migrations/v15.d.ts +3 -0
- package/dist/db/migrations/v15.js +42 -0
- package/dist/db/migrations/v16.d.ts +3 -0
- package/dist/db/migrations/v16.js +61 -0
- package/dist/db/migrations/v17.d.ts +3 -0
- package/dist/db/migrations/v17.js +46 -0
- package/dist/db/migrations/v18.d.ts +3 -0
- package/dist/db/migrations/v18.js +60 -0
- package/dist/db/migrations/v19.d.ts +3 -0
- package/dist/db/migrations/v19.js +28 -0
- package/dist/db/migrations/v20.d.ts +3 -0
- package/dist/db/migrations/v20.js +42 -0
- package/dist/db/migrations/v21.d.ts +3 -0
- package/dist/db/migrations/v21.js +16 -0
- package/dist/db/migrations/v22.d.ts +3 -0
- package/dist/db/migrations/v22.js +82 -0
- package/dist/db/migrations/v23.d.ts +3 -0
- package/dist/db/migrations/v23.js +48 -0
- package/dist/db/migrations/v24.d.ts +3 -0
- package/dist/db/migrations/v24.js +72 -0
- package/dist/db/migrations/v25.d.ts +3 -0
- package/dist/db/migrations/v25.js +46 -0
- package/dist/db/migrations/v26.d.ts +3 -0
- package/dist/db/migrations/v26.js +23 -0
- package/dist/db/migrations/v27.d.ts +3 -0
- package/dist/db/migrations/v27.js +57 -0
- package/dist/db/migrations/v28.d.ts +3 -0
- package/dist/db/migrations/v28.js +38 -0
- package/dist/db/migrations/v29.d.ts +3 -0
- package/dist/db/migrations/v29.js +78 -0
- package/dist/db/migrations/v30.d.ts +3 -0
- package/dist/db/migrations/v30.js +92 -0
- package/dist/db/migrations/v31.d.ts +3 -0
- package/dist/db/migrations/v31.js +74 -0
- package/dist/db/migrations/v32.d.ts +3 -0
- package/dist/db/migrations/v32.js +102 -0
- package/dist/db/migrations/v33.d.ts +3 -0
- package/dist/db/migrations/v33.js +104 -0
- package/dist/db/migrations/v34.d.ts +3 -0
- package/dist/db/migrations/v34.js +93 -0
- package/dist/db/migrations/v35.d.ts +3 -0
- package/dist/db/migrations/v35.js +98 -0
- package/dist/db/migrations/v36.d.ts +3 -0
- package/dist/db/migrations/v36.js +98 -0
- package/dist/db/migrations/v37.d.ts +3 -0
- package/dist/db/migrations/v37.js +219 -0
- package/dist/db/migrations/v38.d.ts +3 -0
- package/dist/db/migrations/v38.js +277 -0
- package/dist/db/migrations/v39.d.ts +3 -0
- package/dist/db/migrations/v39.js +59 -0
- package/dist/db/migrations/v40.d.ts +3 -0
- package/dist/db/migrations/v40.js +74 -0
- package/dist/db/migrations/v41.d.ts +3 -0
- package/dist/db/migrations/v41.js +43 -0
- package/dist/db/migrations/v42.d.ts +3 -0
- package/dist/db/migrations/v42.js +41 -0
- package/dist/db/migrations/v43.d.ts +3 -0
- package/dist/db/migrations/v43.js +67 -0
- package/dist/db/migrations/v44.d.ts +3 -0
- package/dist/db/migrations/v44.js +28 -0
- package/dist/db/migrations/v45.d.ts +3 -0
- package/dist/db/migrations/v45.js +30 -0
- package/dist/db/migrations/v46.d.ts +3 -0
- package/dist/db/migrations/v46.js +25 -0
- package/dist/db/migrations/v47.d.ts +3 -0
- package/dist/db/migrations/v47.js +17 -0
- package/dist/db/migrations/v48.d.ts +3 -0
- package/dist/db/migrations/v48.js +10 -0
- package/dist/db/migrations/v49.d.ts +3 -0
- package/dist/db/migrations/v49.js +31 -0
- package/dist/db/migrations/v50.d.ts +3 -0
- package/dist/db/migrations/v50.js +67 -0
- package/dist/db/migrations/v51.d.ts +3 -0
- package/dist/db/migrations/v51.js +14 -0
- package/dist/db/migrations/v52.d.ts +3 -0
- package/dist/db/migrations/v52.js +7 -0
- package/dist/db/open.d.ts +23 -0
- package/dist/db/open.js +146 -0
- package/dist/db/sqlite.d.ts +21 -0
- package/dist/db/sqlite.js +8 -0
- package/dist/db/tables.d.ts +7 -0
- package/dist/db/tables.js +38 -0
- package/dist/db.d.ts +6 -46
- package/dist/db.js +5 -3036
- package/dist/decisions.d.ts +4 -1
- package/dist/decisions.js +9 -7
- package/dist/dedupe.js +3 -2
- package/dist/delivery-recorder.js +5 -1
- package/dist/doctor.js +4 -3
- package/dist/dormant.js +1 -0
- package/dist/embedding-provider.d.ts +1 -1
- package/dist/embedding-provider.js +7 -5
- package/dist/embeddings.d.ts +9 -52
- package/dist/embeddings.js +47 -298
- package/dist/env.d.ts +75 -0
- package/dist/env.js +119 -0
- package/dist/eval-suite.js +1 -1
- package/dist/eval.js +2 -2
- package/dist/extract.js +5 -4
- package/dist/gated-write.js +3 -1
- package/dist/goals.d.ts +3 -1
- package/dist/goals.js +18 -0
- package/dist/graph/read.d.ts +73 -0
- package/dist/graph/read.js +325 -0
- package/dist/graph/rows.d.ts +45 -0
- package/dist/graph/rows.js +51 -0
- package/dist/graph/types.d.ts +83 -0
- package/dist/graph/types.js +11 -0
- package/dist/graph/write.d.ts +93 -0
- package/dist/{graph.js → graph/write.js} +8 -391
- package/dist/graph-extract.js +2 -1
- package/dist/graph-recall.d.ts +1 -1
- package/dist/graph-recall.js +2 -2
- package/dist/graph-stream.js +1 -1
- package/dist/graph-view.d.ts +1 -1
- package/dist/graph-view.js +1 -1
- package/dist/half-life-migration.d.ts +1 -1
- package/dist/half-life-migration.js +2 -1
- package/dist/handoff.js +3 -0
- package/dist/hooks/codex-session.d.ts +8 -0
- package/dist/hooks/codex-session.js +76 -0
- package/dist/hooks/codex-wrapper.d.ts +55 -0
- package/dist/hooks/codex-wrapper.js +288 -0
- package/dist/hooks/json-hooks.d.ts +63 -0
- package/dist/hooks/json-hooks.js +356 -0
- package/dist/hooks/opencode.d.ts +50 -0
- package/dist/hooks/opencode.js +202 -0
- package/dist/hooks/shared.d.ts +54 -0
- package/dist/hooks/shared.js +77 -0
- package/dist/http-retry.d.ts +2 -0
- package/dist/http-retry.js +4 -3
- package/dist/http-util.d.ts +3 -0
- package/dist/http-util.js +10 -0
- package/dist/{importers.d.ts → importers/core.d.ts} +13 -17
- package/dist/importers/core.js +141 -0
- package/dist/importers/markdown-parse.d.ts +41 -0
- package/dist/importers/markdown-parse.js +132 -0
- package/dist/importers/markdown.d.ts +3 -0
- package/dist/importers/markdown.js +92 -0
- package/dist/importers/sources.d.ts +7 -0
- package/dist/importers/sources.js +229 -0
- package/dist/importers/vault.d.ts +11 -0
- package/dist/importers/vault.js +352 -0
- package/dist/incidents.d.ts +3 -0
- package/dist/incidents.js +8 -5
- package/dist/index.d.ts +25 -6
- package/dist/index.js +23 -6
- package/dist/invalidation.js +2 -1
- package/dist/judgment.js +7 -3
- package/dist/keyset.d.ts +13 -0
- package/dist/keyset.js +8 -0
- package/dist/local-embedding.d.ts +13 -0
- package/dist/local-embedding.js +165 -0
- package/dist/log.d.ts +7 -0
- package/dist/log.js +19 -1
- package/dist/mcp/admin-tools.d.ts +8 -0
- package/dist/mcp/admin-tools.js +116 -0
- package/dist/mcp/format.d.ts +27 -0
- package/dist/mcp/format.js +135 -0
- package/dist/mcp/memory-tools.d.ts +5 -0
- package/dist/mcp/memory-tools.js +83 -0
- package/dist/mcp/protocol.d.ts +83 -0
- package/dist/mcp/protocol.js +55 -0
- package/dist/mcp/recall-tools.d.ts +6 -0
- package/dist/mcp/recall-tools.js +320 -0
- package/dist/mcp/request.d.ts +10 -0
- package/dist/mcp/request.js +163 -0
- package/dist/mcp/server.d.ts +4 -70
- package/dist/mcp/server.js +8 -1172
- package/dist/mcp/session-state.d.ts +11 -0
- package/dist/mcp/session-state.js +28 -0
- package/dist/mcp/stdio.d.ts +8 -0
- package/dist/mcp/stdio.js +79 -0
- package/dist/mcp/tools.d.ts +11 -0
- package/dist/mcp/tools.js +247 -0
- package/dist/memory.d.ts +8 -3
- package/dist/memory.js +27 -1
- package/dist/multihop.d.ts +1 -1
- package/dist/multihop.js +2 -1
- package/dist/owner-validation.js +2 -1
- package/dist/physics-state.js +10 -7
- package/dist/policies.d.ts +3 -0
- package/dist/policies.js +8 -6
- package/dist/postinstall.js +3 -2
- package/dist/predictions/planning-fallacy.d.ts +100 -0
- package/dist/predictions/planning-fallacy.js +190 -0
- package/dist/{predictions.d.ts → predictions/store.d.ts} +7 -102
- package/dist/predictions/store.js +434 -0
- package/dist/processes.d.ts +3 -0
- package/dist/processes.js +8 -5
- package/dist/project-briefs.d.ts +3 -0
- package/dist/project-briefs.js +7 -5
- package/dist/project-identity.d.ts +1 -1
- package/dist/project-identity.js +12 -6
- package/dist/project-merge.js +3 -1
- package/dist/quarantine.d.ts +2 -1
- package/dist/quarantine.js +8 -5
- package/dist/raw-archive-mirror-cleanup.js +2 -1
- package/dist/raw-archive.js +1 -1
- package/dist/recall-history.js +3 -2
- package/dist/recall-pipeline.d.ts +2 -2
- package/dist/recall-pipeline.js +16 -8
- package/dist/recall-scope.js +1 -1
- package/dist/recall-trace.d.ts +3 -3
- package/dist/recall-trace.js +10 -14
- package/dist/refine-llm.js +20 -11
- package/dist/reject-flow.js +6 -1
- package/dist/rerankers/clef.d.ts +2 -2
- package/dist/rerankers/clef.js +72 -30
- package/dist/rerankers/cross-encoder.js +6 -4
- package/dist/rerankers/jev.d.ts +4 -2
- package/dist/rerankers/jev.js +24 -19
- package/dist/rerankers/llm.d.ts +4 -2
- package/dist/rerankers/llm.js +61 -41
- package/dist/rerankers/types.d.ts +1 -1
- package/dist/salience.js +1 -1
- package/dist/same-text.d.ts +2 -0
- package/dist/same-text.js +4 -0
- package/dist/scheduler.d.ts +1 -0
- package/dist/scheduler.js +26 -3
- package/dist/scope.js +4 -3
- package/dist/search/as-of.d.ts +10 -0
- package/dist/search/as-of.js +22 -0
- package/dist/search/bm25-search.d.ts +14 -0
- package/dist/search/bm25-search.js +43 -0
- package/dist/search/bm25.d.ts +15 -0
- package/dist/search/bm25.js +54 -0
- package/dist/search/boosts.d.ts +54 -0
- package/dist/search/boosts.js +94 -0
- package/dist/search/breakdown.d.ts +7 -0
- package/dist/search/breakdown.js +20 -0
- package/dist/search/explain.d.ts +25 -0
- package/dist/search/explain.js +31 -0
- package/dist/search/finalize.d.ts +8 -0
- package/dist/search/finalize.js +52 -0
- package/dist/search/fusion.d.ts +27 -0
- package/dist/search/fusion.js +42 -0
- package/dist/search/hybrid-score.d.ts +20 -0
- package/dist/search/hybrid-score.js +73 -0
- package/dist/search/hybrid.d.ts +46 -0
- package/dist/search/hybrid.js +64 -0
- package/dist/search/physics-search.d.ts +29 -0
- package/dist/search/physics-search.js +162 -0
- package/dist/search/rerank.d.ts +10 -0
- package/dist/search/rerank.js +72 -0
- package/dist/search/temporal.d.ts +15 -0
- package/dist/search/temporal.js +45 -0
- package/dist/search/types.d.ts +91 -0
- package/dist/search/types.js +2 -0
- package/dist/search/vector.d.ts +30 -0
- package/dist/search/vector.js +71 -0
- package/dist/secret-detect.d.ts +2 -0
- package/dist/secret-detect.js +3 -1
- package/dist/server/auth.d.ts +52 -0
- package/dist/server/auth.js +221 -0
- package/dist/server/client-ip.d.ts +25 -0
- package/dist/server/client-ip.js +92 -0
- package/dist/server/cursor.d.ts +23 -0
- package/dist/server/cursor.js +58 -0
- package/dist/server/lifecycle.d.ts +7 -0
- package/dist/server/lifecycle.js +29 -0
- package/dist/server/mcp-http.d.ts +5 -0
- package/dist/server/mcp-http.js +199 -0
- package/dist/server/request.d.ts +33 -0
- package/dist/server/request.js +103 -0
- package/dist/server/routes/admin.d.ts +9 -0
- package/dist/server/routes/admin.js +158 -0
- package/dist/server/routes/customer-notes.d.ts +7 -0
- package/dist/server/routes/customer-notes.js +112 -0
- package/dist/server/routes/decisions.d.ts +7 -0
- package/dist/server/routes/decisions.js +133 -0
- package/dist/server/routes/incidents.d.ts +7 -0
- package/dist/server/routes/incidents.js +126 -0
- package/dist/server/routes/memories.d.ts +10 -0
- package/dist/server/routes/memories.js +179 -0
- package/dist/server/routes/policies.d.ts +8 -0
- package/dist/server/routes/policies.js +151 -0
- package/dist/server/routes/predictions.d.ts +7 -0
- package/dist/server/routes/predictions.js +164 -0
- package/dist/server/routes/processes.d.ts +7 -0
- package/dist/server/routes/processes.js +161 -0
- package/dist/server/routes/project-briefs.d.ts +8 -0
- package/dist/server/routes/project-briefs.js +136 -0
- package/dist/server/routes/recall.d.ts +8 -0
- package/dist/server/routes/recall.js +340 -0
- package/dist/server/routes/skills.d.ts +8 -0
- package/dist/server/routes/skills.js +150 -0
- package/dist/server/types.d.ts +56 -0
- package/dist/server/types.js +2 -0
- package/dist/server/validation.d.ts +14 -0
- package/dist/server/validation.js +91 -0
- package/dist/server.d.ts +7 -61
- package/dist/server.js +92 -2368
- package/dist/session-digest.d.ts +1 -1
- package/dist/session-digest.js +9 -2
- package/dist/shared.d.ts +3 -1
- package/dist/shared.js +46 -40
- package/dist/skills.d.ts +3 -0
- package/dist/skills.js +7 -5
- package/dist/stdin.js +3 -2
- package/dist/store/audit-event.d.ts +19 -0
- package/dist/store/audit-event.js +33 -0
- package/dist/store/candidates.d.ts +42 -0
- package/dist/store/candidates.js +152 -0
- package/dist/store/conflicts.d.ts +44 -0
- package/dist/store/conflicts.js +444 -0
- package/dist/store/delete-and-batch.d.ts +63 -0
- package/dist/store/delete-and-batch.js +310 -0
- package/dist/store/entry-reads.d.ts +92 -0
- package/dist/store/entry-reads.js +255 -0
- package/dist/store/entry-row.d.ts +67 -0
- package/dist/store/entry-row.js +208 -0
- package/dist/store/entry-writes.d.ts +46 -0
- package/dist/store/entry-writes.js +148 -0
- package/dist/store/handoffs.d.ts +26 -0
- package/dist/store/handoffs.js +184 -0
- package/dist/store/index-and-stats.d.ts +52 -0
- package/dist/store/index-and-stats.js +214 -0
- package/dist/store/markdown.d.ts +10 -0
- package/dist/store/markdown.js +108 -0
- package/dist/store/mirrors.d.ts +49 -0
- package/dist/store/mirrors.js +312 -0
- package/dist/store/open.d.ts +15 -0
- package/dist/store/open.js +223 -0
- package/dist/store/rows.d.ts +178 -0
- package/dist/store/rows.js +158 -0
- package/dist/store/search-rows.d.ts +86 -0
- package/dist/store/search-rows.js +254 -0
- package/dist/store/sessions.d.ts +83 -0
- package/dist/store/sessions.js +272 -0
- package/dist/store/summaries.d.ts +94 -0
- package/dist/store/summaries.js +377 -0
- package/dist/store/tenant-lookup.d.ts +12 -0
- package/dist/store/tenant-lookup.js +16 -0
- package/dist/store-cards.js +2 -1
- package/dist/summary-dirty.d.ts +4 -0
- package/dist/summary-dirty.js +32 -0
- package/dist/support-bundle.js +4 -3
- package/dist/tenant.js +2 -2
- package/dist/token-ledger.js +1 -0
- package/dist/tokenize.d.ts +2 -0
- package/dist/tokenize.js +16 -0
- package/dist/transcript-tail.d.ts +7 -0
- package/dist/transcript-tail.js +48 -0
- package/dist/vector-store.d.ts +27 -0
- package/dist/vector-store.js +210 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.js +2 -2
- package/dist/working-memory.js +1 -1
- package/dist/yaml.js +36 -11
- package/dist-ui/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
- package/dist-ui/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
- package/dist-ui/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
- package/dist-ui/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- package/dist-ui/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
- package/dist-ui/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
- package/dist-ui/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
- package/dist-ui/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
- package/dist-ui/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
- package/dist-ui/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff +0 -0
- package/dist-ui/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
- package/dist-ui/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
- package/dist-ui/assets/index-DPN7cP19.js +33 -0
- package/dist-ui/assets/index-dFloKRVr.css +1 -0
- package/dist-ui/index.html +3 -25
- package/extensions/openclaw-plugin/openclaw.plugin.json +1 -1
- package/extensions/openclaw-plugin/package.json +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +2 -1
- package/dist/capture.d.ts +0 -155
- package/dist/capture.js +0 -1293
- package/dist/consolidate.d.ts +0 -58
- package/dist/consolidate.js +0 -1123
- package/dist/graph.d.ts +0 -245
- package/dist/hooks.d.ts +0 -208
- package/dist/hooks.js +0 -1073
- package/dist/importers.js +0 -897
- package/dist/predictions.js +0 -620
- package/dist/search.d.ts +0 -320
- package/dist/search.js +0 -968
- package/dist/store.d.ts +0 -744
- package/dist/store.js +0 -3372
- package/dist-ui/assets/d3-BiWEKnn4.js +0 -1
- package/dist-ui/assets/index-BhT8RvO6.js +0 -61
- package/dist-ui/assets/index-RoXXJ5dq.css +0 -1
- package/dist-ui/assets/three-BDgTxR1l.js +0 -4112
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
const ENTITIES_TABLE = `
|
|
2
|
+
CREATE TABLE entities (
|
|
3
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
4
|
+
tenant_id TEXT NOT NULL,
|
|
5
|
+
entity_type TEXT NOT NULL
|
|
6
|
+
CHECK (entity_type IN ('person', 'project', 'customer', 'system', 'policy', 'decision')),
|
|
7
|
+
name TEXT NOT NULL,
|
|
8
|
+
memory_id TEXT,
|
|
9
|
+
source_kind TEXT NOT NULL CHECK (source_kind IN ('distilled', 'superseded')),
|
|
10
|
+
source_object_type TEXT
|
|
11
|
+
CHECK (source_object_type IS NULL OR source_object_type IN ('decision', 'policy', 'customer', 'project')),
|
|
12
|
+
source_object_id INTEGER,
|
|
13
|
+
created_at TEXT NOT NULL,
|
|
14
|
+
FOREIGN KEY (memory_id) REFERENCES memories(id) ON DELETE SET NULL
|
|
15
|
+
)
|
|
16
|
+
`;
|
|
17
|
+
const RELATIONS_TABLE = `
|
|
18
|
+
CREATE TABLE relations (
|
|
19
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
20
|
+
tenant_id TEXT NOT NULL,
|
|
21
|
+
from_entity_id INTEGER NOT NULL,
|
|
22
|
+
to_entity_id INTEGER NOT NULL,
|
|
23
|
+
rel_type TEXT NOT NULL
|
|
24
|
+
CHECK (rel_type IN ('owns', 'supersedes', 'depends-on', 'blocked-by', 'references')),
|
|
25
|
+
memory_id TEXT,
|
|
26
|
+
source_kind TEXT NOT NULL CHECK (source_kind IN ('distilled', 'superseded')),
|
|
27
|
+
source_object_type TEXT
|
|
28
|
+
CHECK (source_object_type IS NULL OR source_object_type IN ('decision', 'policy', 'customer', 'project')),
|
|
29
|
+
source_object_id INTEGER,
|
|
30
|
+
created_at TEXT NOT NULL,
|
|
31
|
+
FOREIGN KEY (from_entity_id) REFERENCES entities(id) ON DELETE CASCADE,
|
|
32
|
+
FOREIGN KEY (to_entity_id) REFERENCES entities(id) ON DELETE CASCADE,
|
|
33
|
+
FOREIGN KEY (memory_id) REFERENCES memories(id) ON DELETE SET NULL
|
|
34
|
+
)
|
|
35
|
+
`;
|
|
36
|
+
// entities guard (dual-provenance): at least one valid provenance, no raw.
|
|
37
|
+
// - all-null -> ABORT.
|
|
38
|
+
// - memory path (memory_id NOT NULL): source_kind == the FK'd memory's kind
|
|
39
|
+
// (raw / lying source_kind ABORT) AND tenant-match.
|
|
40
|
+
// - object path (memory_id NULL): the (type,id) points at an EXISTING same-tenant
|
|
41
|
+
// E2 row whose status is active|superseded (explicit 4-way CASE per table).
|
|
42
|
+
const TRG_ENTITIES_CONSOLIDATED_ONLY_INSERT = `
|
|
43
|
+
CREATE TRIGGER IF NOT EXISTS trg_entities_consolidated_only_insert
|
|
44
|
+
BEFORE INSERT ON entities
|
|
45
|
+
BEGIN
|
|
46
|
+
SELECT CASE
|
|
47
|
+
WHEN (NEW.source_object_type IS NULL AND NEW.source_object_id IS NOT NULL)
|
|
48
|
+
OR (NEW.source_object_type IS NOT NULL AND NEW.source_object_id IS NULL)
|
|
49
|
+
THEN RAISE(ABORT, 'source_object_type and source_object_id must be set together (all-or-none)')
|
|
50
|
+
WHEN NEW.memory_id IS NULL AND NEW.source_object_id IS NULL
|
|
51
|
+
THEN RAISE(ABORT, 'graph row needs a memory or a source object')
|
|
52
|
+
WHEN NEW.memory_id IS NOT NULL AND NEW.source_kind != (SELECT kind FROM memories WHERE id = NEW.memory_id)
|
|
53
|
+
THEN RAISE(ABORT, 'entities.source_kind must equal the referenced memory kind; the graph indexes consolidated state only (no raw)')
|
|
54
|
+
WHEN NEW.memory_id IS NOT NULL AND NEW.tenant_id != (SELECT tenant_id FROM memories WHERE id = NEW.memory_id)
|
|
55
|
+
THEN RAISE(ABORT, 'entities.tenant_id must match memories.tenant_id for the referenced memory')
|
|
56
|
+
WHEN NEW.source_object_type ='decision'
|
|
57
|
+
AND NOT EXISTS (SELECT 1 FROM decisions WHERE id = NEW.source_object_id AND tenant_id = NEW.tenant_id AND status IN ('active', 'superseded'))
|
|
58
|
+
THEN RAISE(ABORT, 'entities.source_object must reference an active/superseded decision in the same tenant')
|
|
59
|
+
WHEN NEW.source_object_type ='policy'
|
|
60
|
+
AND NOT EXISTS (SELECT 1 FROM policies WHERE id = NEW.source_object_id AND tenant_id = NEW.tenant_id AND status IN ('active', 'superseded'))
|
|
61
|
+
THEN RAISE(ABORT, 'entities.source_object must reference an active/superseded policy in the same tenant')
|
|
62
|
+
WHEN NEW.source_object_type ='customer'
|
|
63
|
+
AND NOT EXISTS (SELECT 1 FROM customer_notes WHERE id = NEW.source_object_id AND tenant_id = NEW.tenant_id AND status IN ('active', 'superseded'))
|
|
64
|
+
THEN RAISE(ABORT, 'entities.source_object must reference an active/superseded customer_note in the same tenant')
|
|
65
|
+
WHEN NEW.source_object_type ='project'
|
|
66
|
+
AND NOT EXISTS (SELECT 1 FROM project_briefs WHERE id = NEW.source_object_id AND tenant_id = NEW.tenant_id AND status IN ('active', 'superseded'))
|
|
67
|
+
THEN RAISE(ABORT, 'entities.source_object must reference an active/superseded project_brief in the same tenant')
|
|
68
|
+
END;
|
|
69
|
+
END
|
|
70
|
+
`;
|
|
71
|
+
const TRG_ENTITIES_CONSOLIDATED_ONLY_UPDATE = `
|
|
72
|
+
CREATE TRIGGER IF NOT EXISTS trg_entities_consolidated_only_update
|
|
73
|
+
BEFORE UPDATE ON entities
|
|
74
|
+
WHEN NEW.memory_id IS NOT OLD.memory_id
|
|
75
|
+
OR NEW.source_kind IS NOT OLD.source_kind
|
|
76
|
+
OR NEW.tenant_id IS NOT OLD.tenant_id
|
|
77
|
+
OR NEW.source_object_type IS NOT OLD.source_object_type
|
|
78
|
+
OR NEW.source_object_id IS NOT OLD.source_object_id
|
|
79
|
+
BEGIN
|
|
80
|
+
-- NO all-null ABORT on UPDATE: node:sqlite fires this BEFORE UPDATE trigger from
|
|
81
|
+
-- the FK ON DELETE SET NULL action even with recursive_triggers OFF (empirically
|
|
82
|
+
-- verified - the plan's "SET NULL does not fire the guard" premise is false for
|
|
83
|
+
-- this build). A mirror forget on a memory-only entity legitimately produces an
|
|
84
|
+
-- all-null row; aborting here would block the memory delete. The INSERT guard
|
|
85
|
+
-- still forbids CREATING a provenance-less row, and the next graph rebuild clears
|
|
86
|
+
-- any all-null orphan. A raw UPDATE to all-null is harmless (not recall-surfaced).
|
|
87
|
+
-- Object-path STATUS is validated only when the object columns THEMSELVES change
|
|
88
|
+
-- (an explicit re-point), NOT on the FK ON DELETE SET NULL transition (which changes
|
|
89
|
+
-- only memory_id). This threads the needle (codex P1 + P2 round 4): the SET NULL of a
|
|
90
|
+
-- since-closed object's mirror is NOT blocked (object cols unchanged -> object checks
|
|
91
|
+
-- skip), while an explicit raw UPDATE that re-points the row to a bad/closed/cross-
|
|
92
|
+
-- tenant object IS rejected. all-or-none + memory-path (raw/tenant) always apply.
|
|
93
|
+
SELECT CASE
|
|
94
|
+
WHEN (NEW.source_object_type IS NULL AND NEW.source_object_id IS NOT NULL)
|
|
95
|
+
OR (NEW.source_object_type IS NOT NULL AND NEW.source_object_id IS NULL)
|
|
96
|
+
THEN RAISE(ABORT, 'entities.source_object_type and source_object_id must be set together (all-or-none)')
|
|
97
|
+
WHEN NEW.memory_id IS NOT NULL AND NEW.source_kind != (SELECT kind FROM memories WHERE id = NEW.memory_id)
|
|
98
|
+
THEN RAISE(ABORT, 'entities.source_kind must equal the referenced memory kind; the graph indexes consolidated state only (no raw)')
|
|
99
|
+
WHEN NEW.memory_id IS NOT NULL AND NEW.tenant_id != (SELECT tenant_id FROM memories WHERE id = NEW.memory_id)
|
|
100
|
+
THEN RAISE(ABORT, 'entities.tenant_id must match memories.tenant_id for the referenced memory')
|
|
101
|
+
WHEN (NEW.source_object_type IS NOT OLD.source_object_type OR NEW.source_object_id IS NOT OLD.source_object_id OR NEW.tenant_id IS NOT OLD.tenant_id)
|
|
102
|
+
AND NEW.source_object_type ='decision'
|
|
103
|
+
AND NOT EXISTS (SELECT 1 FROM decisions WHERE id = NEW.source_object_id AND tenant_id = NEW.tenant_id AND status IN ('active', 'superseded'))
|
|
104
|
+
THEN RAISE(ABORT, 'entities.source_object must reference an active/superseded decision in the same tenant')
|
|
105
|
+
WHEN (NEW.source_object_type IS NOT OLD.source_object_type OR NEW.source_object_id IS NOT OLD.source_object_id OR NEW.tenant_id IS NOT OLD.tenant_id)
|
|
106
|
+
AND NEW.source_object_type ='policy'
|
|
107
|
+
AND NOT EXISTS (SELECT 1 FROM policies WHERE id = NEW.source_object_id AND tenant_id = NEW.tenant_id AND status IN ('active', 'superseded'))
|
|
108
|
+
THEN RAISE(ABORT, 'entities.source_object must reference an active/superseded policy in the same tenant')
|
|
109
|
+
WHEN (NEW.source_object_type IS NOT OLD.source_object_type OR NEW.source_object_id IS NOT OLD.source_object_id OR NEW.tenant_id IS NOT OLD.tenant_id)
|
|
110
|
+
AND NEW.source_object_type ='customer'
|
|
111
|
+
AND NOT EXISTS (SELECT 1 FROM customer_notes WHERE id = NEW.source_object_id AND tenant_id = NEW.tenant_id AND status IN ('active', 'superseded'))
|
|
112
|
+
THEN RAISE(ABORT, 'entities.source_object must reference an active/superseded customer_note in the same tenant')
|
|
113
|
+
WHEN (NEW.source_object_type IS NOT OLD.source_object_type OR NEW.source_object_id IS NOT OLD.source_object_id OR NEW.tenant_id IS NOT OLD.tenant_id)
|
|
114
|
+
AND NEW.source_object_type ='project'
|
|
115
|
+
AND NOT EXISTS (SELECT 1 FROM project_briefs WHERE id = NEW.source_object_id AND tenant_id = NEW.tenant_id AND status IN ('active', 'superseded'))
|
|
116
|
+
THEN RAISE(ABORT, 'entities.source_object must reference an active/superseded project_brief in the same tenant')
|
|
117
|
+
END;
|
|
118
|
+
END
|
|
119
|
+
`;
|
|
120
|
+
// relations guard (dual-provenance) + the existing from/to endpoint same-tenant checks.
|
|
121
|
+
const TRG_RELATIONS_CONSOLIDATED_ONLY_INSERT = `
|
|
122
|
+
CREATE TRIGGER IF NOT EXISTS trg_relations_consolidated_only_insert
|
|
123
|
+
BEFORE INSERT ON relations
|
|
124
|
+
BEGIN
|
|
125
|
+
SELECT CASE
|
|
126
|
+
WHEN (NEW.source_object_type IS NULL AND NEW.source_object_id IS NOT NULL)
|
|
127
|
+
OR (NEW.source_object_type IS NOT NULL AND NEW.source_object_id IS NULL)
|
|
128
|
+
THEN RAISE(ABORT, 'source_object_type and source_object_id must be set together (all-or-none)')
|
|
129
|
+
WHEN NEW.memory_id IS NULL AND NEW.source_object_id IS NULL
|
|
130
|
+
THEN RAISE(ABORT, 'graph row needs a memory or a source object')
|
|
131
|
+
WHEN NEW.memory_id IS NOT NULL AND NEW.source_kind != (SELECT kind FROM memories WHERE id = NEW.memory_id)
|
|
132
|
+
THEN RAISE(ABORT, 'relations.source_kind must equal the referenced memory kind; the graph indexes consolidated state only (no raw)')
|
|
133
|
+
WHEN NEW.memory_id IS NOT NULL AND NEW.tenant_id != (SELECT tenant_id FROM memories WHERE id = NEW.memory_id)
|
|
134
|
+
THEN RAISE(ABORT, 'relations.tenant_id must match memories.tenant_id for the referenced memory')
|
|
135
|
+
WHEN NEW.source_object_type ='decision'
|
|
136
|
+
AND NOT EXISTS (SELECT 1 FROM decisions WHERE id = NEW.source_object_id AND tenant_id = NEW.tenant_id AND status IN ('active', 'superseded'))
|
|
137
|
+
THEN RAISE(ABORT, 'relations.source_object must reference an active/superseded decision in the same tenant')
|
|
138
|
+
WHEN NEW.source_object_type ='policy'
|
|
139
|
+
AND NOT EXISTS (SELECT 1 FROM policies WHERE id = NEW.source_object_id AND tenant_id = NEW.tenant_id AND status IN ('active', 'superseded'))
|
|
140
|
+
THEN RAISE(ABORT, 'relations.source_object must reference an active/superseded policy in the same tenant')
|
|
141
|
+
WHEN NEW.source_object_type ='customer'
|
|
142
|
+
AND NOT EXISTS (SELECT 1 FROM customer_notes WHERE id = NEW.source_object_id AND tenant_id = NEW.tenant_id AND status IN ('active', 'superseded'))
|
|
143
|
+
THEN RAISE(ABORT, 'relations.source_object must reference an active/superseded customer_note in the same tenant')
|
|
144
|
+
WHEN NEW.source_object_type ='project'
|
|
145
|
+
AND NOT EXISTS (SELECT 1 FROM project_briefs WHERE id = NEW.source_object_id AND tenant_id = NEW.tenant_id AND status IN ('active', 'superseded'))
|
|
146
|
+
THEN RAISE(ABORT, 'relations.source_object must reference an active/superseded project_brief in the same tenant')
|
|
147
|
+
WHEN NEW.tenant_id != (SELECT tenant_id FROM entities WHERE id = NEW.from_entity_id)
|
|
148
|
+
THEN RAISE(ABORT, 'relations.tenant_id must match the from_entity tenant (no cross-tenant edges)')
|
|
149
|
+
WHEN NEW.tenant_id != (SELECT tenant_id FROM entities WHERE id = NEW.to_entity_id)
|
|
150
|
+
THEN RAISE(ABORT, 'relations.tenant_id must match the to_entity tenant (no cross-tenant edges)')
|
|
151
|
+
END;
|
|
152
|
+
END
|
|
153
|
+
`;
|
|
154
|
+
const TRG_RELATIONS_CONSOLIDATED_ONLY_UPDATE = `
|
|
155
|
+
CREATE TRIGGER IF NOT EXISTS trg_relations_consolidated_only_update
|
|
156
|
+
BEFORE UPDATE ON relations
|
|
157
|
+
WHEN NEW.memory_id IS NOT OLD.memory_id
|
|
158
|
+
OR NEW.source_kind IS NOT OLD.source_kind
|
|
159
|
+
OR NEW.tenant_id IS NOT OLD.tenant_id
|
|
160
|
+
OR NEW.source_object_type IS NOT OLD.source_object_type
|
|
161
|
+
OR NEW.source_object_id IS NOT OLD.source_object_id
|
|
162
|
+
OR NEW.from_entity_id IS NOT OLD.from_entity_id
|
|
163
|
+
OR NEW.to_entity_id IS NOT OLD.to_entity_id
|
|
164
|
+
BEGIN
|
|
165
|
+
-- NO all-null ABORT on UPDATE (same reason as the entities UPDATE trigger): the FK
|
|
166
|
+
-- ON DELETE SET NULL fires this trigger in node:sqlite, and a mirror forget on a
|
|
167
|
+
-- memory-only relation legitimately nulls memory_id. The INSERT guard still forbids
|
|
168
|
+
-- creating a provenance-less relation; the rebuild clears any orphan.
|
|
169
|
+
-- Object-path STATUS validated only on an explicit object-column change, NOT on the
|
|
170
|
+
-- FK SET NULL transition (see the entities UPDATE trigger): SET NULL of a since-closed
|
|
171
|
+
-- object's mirror is not blocked (object cols unchanged), while an explicit re-point to
|
|
172
|
+
-- a bad object is rejected. all-or-none + memory-path + endpoint checks always apply.
|
|
173
|
+
SELECT CASE
|
|
174
|
+
WHEN (NEW.source_object_type IS NULL AND NEW.source_object_id IS NOT NULL)
|
|
175
|
+
OR (NEW.source_object_type IS NOT NULL AND NEW.source_object_id IS NULL)
|
|
176
|
+
THEN RAISE(ABORT, 'relations.source_object_type and source_object_id must be set together (all-or-none)')
|
|
177
|
+
WHEN NEW.memory_id IS NOT NULL AND NEW.source_kind != (SELECT kind FROM memories WHERE id = NEW.memory_id)
|
|
178
|
+
THEN RAISE(ABORT, 'relations.source_kind must equal the referenced memory kind; the graph indexes consolidated state only (no raw)')
|
|
179
|
+
WHEN NEW.memory_id IS NOT NULL AND NEW.tenant_id != (SELECT tenant_id FROM memories WHERE id = NEW.memory_id)
|
|
180
|
+
THEN RAISE(ABORT, 'relations.tenant_id must match memories.tenant_id for the referenced memory')
|
|
181
|
+
WHEN (NEW.source_object_type IS NOT OLD.source_object_type OR NEW.source_object_id IS NOT OLD.source_object_id OR NEW.tenant_id IS NOT OLD.tenant_id)
|
|
182
|
+
AND NEW.source_object_type ='decision'
|
|
183
|
+
AND NOT EXISTS (SELECT 1 FROM decisions WHERE id = NEW.source_object_id AND tenant_id = NEW.tenant_id AND status IN ('active', 'superseded'))
|
|
184
|
+
THEN RAISE(ABORT, 'relations.source_object must reference an active/superseded decision in the same tenant')
|
|
185
|
+
WHEN (NEW.source_object_type IS NOT OLD.source_object_type OR NEW.source_object_id IS NOT OLD.source_object_id OR NEW.tenant_id IS NOT OLD.tenant_id)
|
|
186
|
+
AND NEW.source_object_type ='policy'
|
|
187
|
+
AND NOT EXISTS (SELECT 1 FROM policies WHERE id = NEW.source_object_id AND tenant_id = NEW.tenant_id AND status IN ('active', 'superseded'))
|
|
188
|
+
THEN RAISE(ABORT, 'relations.source_object must reference an active/superseded policy in the same tenant')
|
|
189
|
+
WHEN (NEW.source_object_type IS NOT OLD.source_object_type OR NEW.source_object_id IS NOT OLD.source_object_id OR NEW.tenant_id IS NOT OLD.tenant_id)
|
|
190
|
+
AND NEW.source_object_type ='customer'
|
|
191
|
+
AND NOT EXISTS (SELECT 1 FROM customer_notes WHERE id = NEW.source_object_id AND tenant_id = NEW.tenant_id AND status IN ('active', 'superseded'))
|
|
192
|
+
THEN RAISE(ABORT, 'relations.source_object must reference an active/superseded customer_note in the same tenant')
|
|
193
|
+
WHEN (NEW.source_object_type IS NOT OLD.source_object_type OR NEW.source_object_id IS NOT OLD.source_object_id OR NEW.tenant_id IS NOT OLD.tenant_id)
|
|
194
|
+
AND NEW.source_object_type ='project'
|
|
195
|
+
AND NOT EXISTS (SELECT 1 FROM project_briefs WHERE id = NEW.source_object_id AND tenant_id = NEW.tenant_id AND status IN ('active', 'superseded'))
|
|
196
|
+
THEN RAISE(ABORT, 'relations.source_object must reference an active/superseded project_brief in the same tenant')
|
|
197
|
+
WHEN NEW.tenant_id != (SELECT tenant_id FROM entities WHERE id = NEW.from_entity_id)
|
|
198
|
+
THEN RAISE(ABORT, 'relations.tenant_id must match the from_entity tenant (no cross-tenant edges)')
|
|
199
|
+
WHEN NEW.tenant_id != (SELECT tenant_id FROM entities WHERE id = NEW.to_entity_id)
|
|
200
|
+
THEN RAISE(ABORT, 'relations.tenant_id must match the to_entity tenant (no cross-tenant edges)')
|
|
201
|
+
END;
|
|
202
|
+
END
|
|
203
|
+
`;
|
|
204
|
+
// Recreated VERBATIM from v37 (logic unchanged): an entity that is a relation
|
|
205
|
+
// endpoint cannot be moved cross-tenant while referenced. trg_memories_graph_referenced_guard
|
|
206
|
+
// (on memories) and trg_graph_queue_* (on graph_extraction_queue) are NOT recreated
|
|
207
|
+
// here: those tables are not dropped by v38, so the triggers survive.
|
|
208
|
+
const TRG_ENTITIES_NO_TENANT_MOVE_WHEN_REFERENCED = `
|
|
209
|
+
CREATE TRIGGER IF NOT EXISTS trg_entities_no_tenant_move_when_referenced
|
|
210
|
+
BEFORE UPDATE ON entities
|
|
211
|
+
WHEN NEW.tenant_id IS NOT OLD.tenant_id
|
|
212
|
+
AND EXISTS (SELECT 1 FROM relations WHERE from_entity_id = OLD.id OR to_entity_id = OLD.id)
|
|
213
|
+
BEGIN
|
|
214
|
+
SELECT RAISE(ABORT, 'cannot move an entity cross-tenant while a relation references it as an endpoint (E3.3 graph-on-consolidated guard); rebuild/remove the relations first');
|
|
215
|
+
END
|
|
216
|
+
`;
|
|
217
|
+
export const v38 = {
|
|
218
|
+
version: 38,
|
|
219
|
+
up: (db) => {
|
|
220
|
+
// E2-provenance: anchor graph entity/relation provenance to the authoritative E2
|
|
221
|
+
// object (decision/policy/customer-note/project-brief) instead of the decaying
|
|
222
|
+
// memory mirror (docs/plans/2026-06-03-graph-e2-provenance.md). An in-force E2
|
|
223
|
+
// object must STAY in the graph after its mirror memory is forgotten or
|
|
224
|
+
// consolidation-pruned. The graph is a PURE DERIVED CACHE (clearGraph + rebuild on
|
|
225
|
+
// every `graph extract` / `sleep`), so v38 DROPs+recreates entities/relations (no
|
|
226
|
+
// data copy) and the next extract repopulates. graph_extraction_queue is untouched.
|
|
227
|
+
//
|
|
228
|
+
// Two provenance paths, "at least one, no raw":
|
|
229
|
+
// - memory path (memory_id NOT NULL): source_kind must equal the FK'd memory's live
|
|
230
|
+
// kind and that kind is distilled|superseded (raw still ABORTs) + tenant-match.
|
|
231
|
+
// - object path (memory_id NULL): source_object_type/id must reference an EXISTING
|
|
232
|
+
// same-tenant E2 row whose status is active|superseded (not closed). E2 objects
|
|
233
|
+
// are consolidated BY CONSTRUCTION, so the no-raw invariant still holds.
|
|
234
|
+
// - all-null is rejected.
|
|
235
|
+
//
|
|
236
|
+
// memory_id is now NULLABLE with ON DELETE SET NULL (was NOT NULL / CASCADE), so a
|
|
237
|
+
// mirror forget/consolidate nulls the recall pointer without dropping the row. NOTE
|
|
238
|
+
// (empirically verified, contradicts the SQLite docs): node:sqlite DOES fire the
|
|
239
|
+
// BEFORE UPDATE guard from the FK SET NULL action even with recursive_triggers OFF.
|
|
240
|
+
// So the *_consolidated_only_UPDATE triggers deliberately OMIT the all-null ABORT
|
|
241
|
+
// (kept on INSERT) - otherwise a mirror delete of a memory-only row would be blocked.
|
|
242
|
+
// See the per-trigger comments below. A SET NULL leaves source_kind at its old value
|
|
243
|
+
// by design (the object path is distilled-by-construction; source_kind is only
|
|
244
|
+
// re-checked when memory_id NOT NULL).
|
|
245
|
+
// source_object_id is a SOFT (type,id) pointer (no hard FK) the rebuild re-validates,
|
|
246
|
+
// so a legitimate E2 hard-delete is never blocked; a `closed` E2 row drops at next
|
|
247
|
+
// extract. SQLite cannot parametrize a table name in a trigger, so the object-path
|
|
248
|
+
// validation is an explicit 4-way CASE (one arm per E2 table).
|
|
249
|
+
recreateGraphTables(db);
|
|
250
|
+
createGraphGuards(db);
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
function recreateGraphTables(db) {
|
|
254
|
+
// Drop child (relations FK entities) first, then parent.
|
|
255
|
+
db.exec('DROP TABLE IF EXISTS relations');
|
|
256
|
+
db.exec('DROP TABLE IF EXISTS entities');
|
|
257
|
+
db.exec(ENTITIES_TABLE);
|
|
258
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_entities_tenant ON entities(tenant_id)`);
|
|
259
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_entities_memory ON entities(memory_id)`);
|
|
260
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_entities_source_object ON entities(source_object_type, source_object_id) WHERE source_object_id IS NOT NULL`);
|
|
261
|
+
db.exec(RELATIONS_TABLE);
|
|
262
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_relations_tenant ON relations(tenant_id)`);
|
|
263
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_relations_from ON relations(from_entity_id)`);
|
|
264
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_relations_to ON relations(to_entity_id)`);
|
|
265
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_relations_memory ON relations(memory_id)`);
|
|
266
|
+
// Mirrors idx_entities_source_object: removeGraphEntitiesForObject (close-time cleanup)
|
|
267
|
+
// deletes relations by (source_object_type, source_object_id), so index that pair.
|
|
268
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_relations_source_object ON relations(source_object_type, source_object_id) WHERE source_object_id IS NOT NULL`);
|
|
269
|
+
}
|
|
270
|
+
function createGraphGuards(db) {
|
|
271
|
+
db.exec(TRG_ENTITIES_CONSOLIDATED_ONLY_INSERT);
|
|
272
|
+
db.exec(TRG_ENTITIES_CONSOLIDATED_ONLY_UPDATE);
|
|
273
|
+
db.exec(TRG_RELATIONS_CONSOLIDATED_ONLY_INSERT);
|
|
274
|
+
db.exec(TRG_RELATIONS_CONSOLIDATED_ONLY_UPDATE);
|
|
275
|
+
db.exec(TRG_ENTITIES_NO_TENANT_MOVE_WHEN_REFERENCED);
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=v38.js.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as os from 'os';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { compareSemver } from '../../version.js';
|
|
4
|
+
import { deriveOriginProject, originFromSource, isGlobalStoreRoot } from '../../project-identity.js';
|
|
5
|
+
import { tableHasColumn } from '../tables.js';
|
|
6
|
+
export const v39 = {
|
|
7
|
+
version: 39,
|
|
8
|
+
up: (db, ctx) => {
|
|
9
|
+
// Memory scope isolation (docs/plans/2026-07-01-memory-scope-isolation.md).
|
|
10
|
+
// origin_project: '<name>' = owned by that project, '' = user-global,
|
|
11
|
+
// NULL = legacy/unknown (ambient context treats NULL as deny).
|
|
12
|
+
if (!tableHasColumn(db, 'memories', 'origin_project')) {
|
|
13
|
+
db.exec(`ALTER TABLE memories ADD COLUMN origin_project TEXT`);
|
|
14
|
+
}
|
|
15
|
+
// Backfill on store-location evidence only (no path-tag guessing):
|
|
16
|
+
// 1. Rows shared from a project carry source 'shared:<project>:<ts>' -
|
|
17
|
+
// take <project>; a share whose <project> is the home dir basename
|
|
18
|
+
// maps to '' (user-global).
|
|
19
|
+
// 2. Every other row was written into THIS store, so it takes the
|
|
20
|
+
// store's own origin: `<project>/.hippo` -> '<project>', the
|
|
21
|
+
// home/global store -> '' (user-global).
|
|
22
|
+
// Rows stay NULL only when no hippoRoot was provided.
|
|
23
|
+
const hippoRoot = ctx?.hippoRoot;
|
|
24
|
+
if (hippoRoot) {
|
|
25
|
+
// Provenance-source evidence first (shared:<project>: / promoted:<localRoot>,
|
|
26
|
+
// parsed by the same helper the markdown-import stamp uses), then the
|
|
27
|
+
// store's own location for everything else.
|
|
28
|
+
const homeName = path.basename(os.homedir()).toLowerCase();
|
|
29
|
+
// SAFETY: sourcedRows' shape matches the two columns (id, source)
|
|
30
|
+
// named in the SELECT above.
|
|
31
|
+
const sourcedRows = db.prepare(`SELECT id, source FROM memories WHERE origin_project IS NULL AND (source LIKE 'shared:%' OR source LIKE 'promoted:%')`).all();
|
|
32
|
+
const setOrigin = db.prepare(`UPDATE memories SET origin_project = ? WHERE id = ?`);
|
|
33
|
+
for (const row of sourcedRows) {
|
|
34
|
+
const origin = originFromSource(row.source, homeName);
|
|
35
|
+
if (origin === null)
|
|
36
|
+
continue;
|
|
37
|
+
setOrigin.run(origin, row.id);
|
|
38
|
+
}
|
|
39
|
+
// The global root itself is ALWAYS user-global (''), regardless of
|
|
40
|
+
// what surrounds it on disk - a HIPPO_HOME inside a dotfiles git
|
|
41
|
+
// repo must not stamp the whole corpus with that repo's name.
|
|
42
|
+
const storeOrigin = isGlobalStoreRoot(hippoRoot)
|
|
43
|
+
? ''
|
|
44
|
+
: deriveOriginProject(path.dirname(hippoRoot));
|
|
45
|
+
db.prepare(`UPDATE memories SET origin_project = ? WHERE origin_project IS NULL`).run(storeOrigin);
|
|
46
|
+
}
|
|
47
|
+
// Rollback-safety guard (v24 precedent): a pre-isolation binary opening
|
|
48
|
+
// this DB would ignore origin_project and the secret veto and resume
|
|
49
|
+
// injecting cross-project rows. 1.24.0 is the first version with the
|
|
50
|
+
// isolation behavior. Forward-only - never lower an existing minimum.
|
|
51
|
+
// SAFETY: this get() result's shape matches the single `value` column
|
|
52
|
+
// named in the SELECT above.
|
|
53
|
+
const existingMin = db.prepare(`SELECT value FROM meta WHERE key = 'min_compatible_binary'`).get()?.value;
|
|
54
|
+
if (!existingMin || compareSemver('1.24.0', existingMin) > 0) {
|
|
55
|
+
db.prepare(`INSERT INTO meta(key, value) VALUES('min_compatible_binary', ?) ON CONFLICT(key) DO UPDATE SET value=excluded.value`).run('1.24.0');
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=v39.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export const v40 = {
|
|
2
|
+
version: 40,
|
|
3
|
+
up: (db) => {
|
|
4
|
+
// LC1 retrieval-trace persistence (docs/plans/2026-08-02-lc1-recall-trace-persistence.md).
|
|
5
|
+
// Follows the v18 goal_recall_log style: one parent trace row per
|
|
6
|
+
// recall, a WITHOUT ROWID child table for the ranked results, and a
|
|
7
|
+
// separate append-only outcomes table so audit_log pruning can never
|
|
8
|
+
// erase training data.
|
|
9
|
+
//
|
|
10
|
+
// F6 (deliberate, not an oversight): unlike v39, this migration does
|
|
11
|
+
// NOT bump `min_compatible_binary`. A pre-v40 binary opening this DB
|
|
12
|
+
// ignores the three new tables and keeps writing `last_retrieval_ids`
|
|
13
|
+
// exactly as before — it never touches `last_trace_id` (that key
|
|
14
|
+
// simply stays whatever it was). recordTraceOutcome's F4 consumer-
|
|
15
|
+
// side validation (recall-trace.ts) makes any resulting staleness
|
|
16
|
+
// harmless to linkage: it re-validates the named trace's tenant AND
|
|
17
|
+
// intersects credited ids against the trace's OWN result set before
|
|
18
|
+
// inserting, so a stale/mismatched trace id from an old-binary write
|
|
19
|
+
// gets silently skipped rather than mislinked. That preserves the
|
|
20
|
+
// plan's "drop the three tables + last_trace_id restores v39 behavior
|
|
21
|
+
// exactly" rollback promise — a min_compatible_binary bump would
|
|
22
|
+
// additionally lock old binaries out of the WHOLE store for what is
|
|
23
|
+
// purely an observability/training feature, which the rollback
|
|
24
|
+
// promise does not require.
|
|
25
|
+
db.exec(`
|
|
26
|
+
CREATE TABLE IF NOT EXISTS recall_traces (
|
|
27
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
28
|
+
ts TEXT NOT NULL,
|
|
29
|
+
tenant_id TEXT NOT NULL DEFAULT 'default',
|
|
30
|
+
session_id TEXT,
|
|
31
|
+
pipeline TEXT NOT NULL CHECK (pipeline IN ('api','cli','context','mcp')),
|
|
32
|
+
-- 'mcp' reserved for the deferred MCP wire-up. Deliberate: SQLite
|
|
33
|
+
-- cannot ALTER a CHECK constraint, so extending it later means a
|
|
34
|
+
-- full table-rebuild migration. One unused enum value now is
|
|
35
|
+
-- cheaper than that rebuild.
|
|
36
|
+
query_hash TEXT NOT NULL, -- sha256/16, NEVER raw query (audit convention, cli.ts:1532)
|
|
37
|
+
query_length INTEGER NOT NULL,
|
|
38
|
+
result_count INTEGER NOT NULL,
|
|
39
|
+
explain_mode INTEGER NOT NULL DEFAULT 0
|
|
40
|
+
);
|
|
41
|
+
CREATE INDEX IF NOT EXISTS idx_recall_traces_tenant_ts ON recall_traces(tenant_id, ts DESC);
|
|
42
|
+
|
|
43
|
+
CREATE TABLE IF NOT EXISTS recall_trace_results (
|
|
44
|
+
trace_id INTEGER NOT NULL REFERENCES recall_traces(id) ON DELETE CASCADE,
|
|
45
|
+
tenant_id TEXT NOT NULL DEFAULT 'default', -- denormalized like goal_recall_log (v18
|
|
46
|
+
-- precedent): tenant-scoped training queries
|
|
47
|
+
-- over the memory index must not need a join
|
|
48
|
+
-- back through recall_traces
|
|
49
|
+
memory_id TEXT NOT NULL, -- NO FK to memories: traces must OUTLIVE forgotten
|
|
50
|
+
-- memories (they are LC2's negative class). PRAGMA
|
|
51
|
+
-- foreign_keys=ON is real, so an FK would either
|
|
52
|
+
-- block inserts or cascade-delete exactly the rows
|
|
53
|
+
-- training needs. Deliberate.
|
|
54
|
+
result_rank INTEGER NOT NULL, -- NOT "rank" (SQL keyword; audit rule 10)
|
|
55
|
+
score REAL NOT NULL,
|
|
56
|
+
rerank_json TEXT, -- compact RerankStep[] when explain/trace present; else NULL
|
|
57
|
+
PRIMARY KEY (trace_id, result_rank)
|
|
58
|
+
) WITHOUT ROWID;
|
|
59
|
+
CREATE INDEX IF NOT EXISTS idx_recall_trace_results_tenant_memory
|
|
60
|
+
ON recall_trace_results(tenant_id, memory_id);
|
|
61
|
+
|
|
62
|
+
CREATE TABLE IF NOT EXISTS recall_trace_outcomes (
|
|
63
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
64
|
+
trace_id INTEGER NOT NULL REFERENCES recall_traces(id) ON DELETE CASCADE,
|
|
65
|
+
ts TEXT NOT NULL,
|
|
66
|
+
tenant_id TEXT NOT NULL DEFAULT 'default',
|
|
67
|
+
outcome TEXT NOT NULL CHECK (outcome IN ('positive','negative')),
|
|
68
|
+
memory_ids_json TEXT NOT NULL -- ids actually credited by this outcome event
|
|
69
|
+
);
|
|
70
|
+
CREATE INDEX IF NOT EXISTS idx_recall_trace_outcomes_trace ON recall_trace_outcomes(trace_id);
|
|
71
|
+
`);
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=v40.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export const v41 = {
|
|
2
|
+
version: 41,
|
|
3
|
+
up: (db) => {
|
|
4
|
+
// AT1 rejected-value tombstone (docs/plans/2026-08-15-at1-rejected-value-tombstone.md).
|
|
5
|
+
// Additive table, template = v40 above. A human who rejects a fact gets
|
|
6
|
+
// a durable say: the write-path guard in upsertEntryRow refuses any
|
|
7
|
+
// write that would re-introduce a value whose normalized digest
|
|
8
|
+
// matches a row here.
|
|
9
|
+
//
|
|
10
|
+
// No raw content and no preview stored. Follows the raw_archive
|
|
11
|
+
// redaction precedent (raw-archive.ts payload is {redacted:true, ...}):
|
|
12
|
+
// a rejected value may itself be a secret or PII ("never store my key
|
|
13
|
+
// again") — persisting it in the tombstone would defeat the point. The
|
|
14
|
+
// human sees the content at reject time (CLI echoes it); afterwards
|
|
15
|
+
// `reason` is the human-readable identity.
|
|
16
|
+
//
|
|
17
|
+
// No FK on source_memory_id (v40 precedent above: tombstone outlives
|
|
18
|
+
// the row it was sourced from) — provenance only.
|
|
19
|
+
//
|
|
20
|
+
// Reserved-word check on column names (skill-episode lesson, rule 10):
|
|
21
|
+
// tenant/digest/reason/rejected/source/normalized/chars are non-reserved.
|
|
22
|
+
//
|
|
23
|
+
// No min_compatible_binary bump — a deliberate tradeoff (plan §2,
|
|
24
|
+
// flagged to the ship gate). An old binary sharing a synced store
|
|
25
|
+
// writes WITHOUT the guard until upgraded; documented in
|
|
26
|
+
// MEMORY_ENVELOPE.md rather than hard-locking every old binary out of
|
|
27
|
+
// the store, which is disproportionate for the dominant single-user
|
|
28
|
+
// single-binary deployment.
|
|
29
|
+
db.exec(`
|
|
30
|
+
CREATE TABLE IF NOT EXISTS rejected_values (
|
|
31
|
+
tenant_id TEXT NOT NULL,
|
|
32
|
+
digest TEXT NOT NULL, -- sha256/64 of normalized content
|
|
33
|
+
reason TEXT, -- human-supplied; the only description stored
|
|
34
|
+
rejected_by TEXT, -- actor ('user:<id>' / 'cli' / ...)
|
|
35
|
+
rejected_at TEXT NOT NULL,
|
|
36
|
+
source_memory_id TEXT, -- provenance only; NO FK (tombstone outlives the row)
|
|
37
|
+
normalized_chars INTEGER, -- weak sanity aid for humans listing tombstones
|
|
38
|
+
PRIMARY KEY (tenant_id, digest)
|
|
39
|
+
) WITHOUT ROWID;
|
|
40
|
+
`);
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=v41.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { tableHasColumn } from '../tables.js';
|
|
2
|
+
export const v42 = {
|
|
3
|
+
version: 42,
|
|
4
|
+
up: (db) => {
|
|
5
|
+
// W1 handoff envelope (trajectories/01M2BQTM4AGFVMYY7G2XV5G7WY/plan.md).
|
|
6
|
+
// Five nullable columns so the envelope carries evidence and outcome
|
|
7
|
+
// and W2/W5 can filter on them without parsing JSON.
|
|
8
|
+
if (!tableHasColumn(db, 'session_handoffs', 'constraints_json')) {
|
|
9
|
+
db.exec(`ALTER TABLE session_handoffs ADD COLUMN constraints_json TEXT`);
|
|
10
|
+
}
|
|
11
|
+
if (!tableHasColumn(db, 'session_handoffs', 'evidence_json')) {
|
|
12
|
+
db.exec(`ALTER TABLE session_handoffs ADD COLUMN evidence_json TEXT`);
|
|
13
|
+
}
|
|
14
|
+
if (!tableHasColumn(db, 'session_handoffs', 'outcome')) {
|
|
15
|
+
db.exec(`ALTER TABLE session_handoffs ADD COLUMN outcome TEXT`);
|
|
16
|
+
// codex P2: backfill from session_complete so pre-existing handoffs don't
|
|
17
|
+
// all read as unfinished and get injected by the new 72h ambient fallback.
|
|
18
|
+
db.exec(`
|
|
19
|
+
UPDATE session_handoffs SET outcome = (
|
|
20
|
+
SELECT e.content FROM session_events e
|
|
21
|
+
WHERE e.tenant_id = session_handoffs.tenant_id AND e.session_id = session_handoffs.session_id
|
|
22
|
+
AND e.event_type = 'session_complete' AND e.content IN ('success','partial','failure')
|
|
23
|
+
ORDER BY e.created_at DESC, e.id DESC LIMIT 1
|
|
24
|
+
)
|
|
25
|
+
WHERE outcome IS NULL AND EXISTS (
|
|
26
|
+
SELECT 1 FROM session_events e
|
|
27
|
+
WHERE e.tenant_id = session_handoffs.tenant_id AND e.session_id = session_handoffs.session_id
|
|
28
|
+
AND e.event_type = 'session_complete' AND e.content IN ('success','partial','failure')
|
|
29
|
+
)
|
|
30
|
+
`);
|
|
31
|
+
}
|
|
32
|
+
if (!tableHasColumn(db, 'session_handoffs', 'target_runtime')) {
|
|
33
|
+
db.exec(`ALTER TABLE session_handoffs ADD COLUMN target_runtime TEXT`);
|
|
34
|
+
}
|
|
35
|
+
if (!tableHasColumn(db, 'session_handoffs', 'card_id')) {
|
|
36
|
+
db.exec(`ALTER TABLE session_handoffs ADD COLUMN card_id TEXT`);
|
|
37
|
+
}
|
|
38
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_session_handoffs_tenant_outcome ON session_handoffs(tenant_id, outcome, created_at DESC)`);
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=v42.js.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export const v43 = {
|
|
2
|
+
version: 43,
|
|
3
|
+
up: (db) => {
|
|
4
|
+
// W2a work-queue cards (trajectories/01M2D5VSYJFK4YXQ0RG2NGCPYJ/plan.md). Additive only, v41 precedent.
|
|
5
|
+
db.exec(`
|
|
6
|
+
CREATE TABLE IF NOT EXISTS cards (
|
|
7
|
+
id TEXT PRIMARY KEY,
|
|
8
|
+
title TEXT NOT NULL,
|
|
9
|
+
status TEXT NOT NULL DEFAULT 'backlog',
|
|
10
|
+
assignee_runtime TEXT,
|
|
11
|
+
repo TEXT,
|
|
12
|
+
contract TEXT,
|
|
13
|
+
budget INTEGER,
|
|
14
|
+
lease_until TEXT,
|
|
15
|
+
heartbeat_at TEXT,
|
|
16
|
+
created_at TEXT NOT NULL,
|
|
17
|
+
updated_at TEXT NOT NULL,
|
|
18
|
+
tenant_id TEXT NOT NULL DEFAULT 'default',
|
|
19
|
+
scope TEXT
|
|
20
|
+
) WITHOUT ROWID;
|
|
21
|
+
CREATE INDEX IF NOT EXISTS idx_cards_tenant_status
|
|
22
|
+
ON cards(tenant_id, status, updated_at DESC);
|
|
23
|
+
|
|
24
|
+
CREATE TABLE IF NOT EXISTS card_deps (
|
|
25
|
+
parent TEXT NOT NULL REFERENCES cards(id),
|
|
26
|
+
child TEXT NOT NULL REFERENCES cards(id),
|
|
27
|
+
tenant_id TEXT NOT NULL DEFAULT 'default',
|
|
28
|
+
created_at TEXT NOT NULL,
|
|
29
|
+
PRIMARY KEY (parent, child)
|
|
30
|
+
) WITHOUT ROWID;
|
|
31
|
+
CREATE INDEX IF NOT EXISTS idx_card_deps_tenant_child
|
|
32
|
+
ON card_deps(tenant_id, child);
|
|
33
|
+
CREATE INDEX IF NOT EXISTS idx_card_deps_tenant_parent
|
|
34
|
+
ON card_deps(tenant_id, parent);
|
|
35
|
+
|
|
36
|
+
CREATE TABLE IF NOT EXISTS card_runs (
|
|
37
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
38
|
+
card TEXT NOT NULL REFERENCES cards(id),
|
|
39
|
+
runtime TEXT NOT NULL,
|
|
40
|
+
session_id TEXT,
|
|
41
|
+
started TEXT NOT NULL,
|
|
42
|
+
ended TEXT,
|
|
43
|
+
outcome TEXT,
|
|
44
|
+
created_at TEXT NOT NULL,
|
|
45
|
+
updated_at TEXT NOT NULL,
|
|
46
|
+
tenant_id TEXT NOT NULL DEFAULT 'default'
|
|
47
|
+
);
|
|
48
|
+
CREATE INDEX IF NOT EXISTS idx_card_runs_tenant_card
|
|
49
|
+
ON card_runs(tenant_id, card, started DESC);
|
|
50
|
+
|
|
51
|
+
CREATE TABLE IF NOT EXISTS card_comments (
|
|
52
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
53
|
+
card_id TEXT NOT NULL REFERENCES cards(id),
|
|
54
|
+
author TEXT NOT NULL,
|
|
55
|
+
body TEXT NOT NULL,
|
|
56
|
+
created_at TEXT NOT NULL,
|
|
57
|
+
tenant_id TEXT NOT NULL DEFAULT 'default'
|
|
58
|
+
);
|
|
59
|
+
CREATE INDEX IF NOT EXISTS idx_card_comments_tenant_card
|
|
60
|
+
ON card_comments(tenant_id, card_id, created_at DESC);
|
|
61
|
+
|
|
62
|
+
CREATE INDEX IF NOT EXISTS idx_session_handoffs_tenant_card
|
|
63
|
+
ON session_handoffs(tenant_id, card_id, created_at DESC);
|
|
64
|
+
`);
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=v43.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const v44 = {
|
|
2
|
+
version: 44,
|
|
3
|
+
up: (db) => {
|
|
4
|
+
// Dormant memories (src/dormant.ts): with `dormant.enabled`, the sleep
|
|
5
|
+
// decay pass moves a faded memory here instead of deleting it. The row
|
|
6
|
+
// leaves `memories` in the same transaction, so recall, context and
|
|
7
|
+
// every sleep pass stop seeing it; entry_json is the full MemoryEntry
|
|
8
|
+
// snapshot `hippo dormant restore` writes back. No FK to memories (the
|
|
9
|
+
// memories row is gone by design). Additive only, v41 precedent: no
|
|
10
|
+
// min_compatible_binary bump. An older binary ignores the table and
|
|
11
|
+
// keeps deleting faded memories as it always did.
|
|
12
|
+
db.exec(`
|
|
13
|
+
CREATE TABLE IF NOT EXISTS dormant_memories (
|
|
14
|
+
tenant_id TEXT NOT NULL DEFAULT 'default',
|
|
15
|
+
id TEXT NOT NULL,
|
|
16
|
+
content TEXT NOT NULL,
|
|
17
|
+
entry_json TEXT NOT NULL,
|
|
18
|
+
reason TEXT NOT NULL,
|
|
19
|
+
strength REAL NOT NULL,
|
|
20
|
+
dormant_at TEXT NOT NULL,
|
|
21
|
+
PRIMARY KEY (tenant_id, id)
|
|
22
|
+
) WITHOUT ROWID;
|
|
23
|
+
CREATE INDEX IF NOT EXISTS idx_dormant_memories_tenant_time
|
|
24
|
+
ON dormant_memories(tenant_id, dormant_at DESC);
|
|
25
|
+
`);
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=v44.js.map
|