@jungjaehoon/mama-core 2.4.1 → 4.0.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 +76 -239
- package/db/migrations/030-case-first-memory-substrate.sql +13 -98
- package/db/migrations/034-add-connector-event-scope-columns.sql +9 -13
- package/db/migrations/039-add-connector-event-operator-ingest-seq.sql +9 -95
- package/db/migrations/062-refresh-connector-event-sequences.sql +9 -113
- package/db/migrations/063-refresh-legacy-connector-event-updates.sql +9 -32
- package/db/migrations/067-add-connector-event-source-entity-id.sql +9 -13
- package/db/migrations/069-create-registry-nodes.sql +52 -0
- package/db/migrations/070-record-identity.sql +35 -0
- package/db/migrations/071-service-operation-origins.sql +187 -0
- package/db/migrations/072-observation-versions.sql +29 -0
- package/db/migrations/073-registry-corrections.sql +45 -0
- package/db/migrations/074-work-graph-ref-kinds.sql +39 -0
- package/db/migrations/075-agent-judgments.sql +58 -0
- package/db/migrations/076-scoped-checkpoint-bindings.sql +15 -0
- package/db/migrations/077-legacy-record-kind.sql +6 -0
- package/db/migrations/078-source-ingest-commands.sql +18 -0
- package/db/migrations/079-twin-edge-relations.sql +43 -0
- package/db/migrations/080-restore-duration-days.sql +7 -0
- package/db/migrations/081-mailbox.sql +61 -0
- package/db/migrations/082-commitments-row-id.sql +12 -0
- package/db/migrations/083-observation-is-the-evidence.sql +49 -0
- package/db/migrations/084-scope-kind-is-not-the-cores-to-list.sql +34 -0
- package/db/migrations/085-a-migration-has-a-source.sql +37 -0
- package/db/migrations/086-the-mailbox-is-generic.sql +110 -0
- package/db/migrations/087-mailbox-payload.sql +5 -0
- package/db/migrations/088-native-input-journal.sql +14 -0
- package/db/migrations/089-native-turn-receipt-lookup.sql +3 -0
- package/db/migrations/090-model-run-native-inputs.sql +29 -0
- package/db/migrations/091-native-turn-results.sql +11 -0
- package/db/migrations/092-restore-decision-fts.sql +34 -0
- package/db/migrations/093-native-turn-primary-kind.sql +14 -0
- package/db/migrations/094-commitment-run-provenance.sql +9 -0
- package/db/migrations/095-model-run-native-input-identity.sql +39 -0
- package/db/migrations/096-drop-connector-event-index-fts.sql +9 -0
- package/db/migrations/097-native-input-json-validity.sql +37 -0
- package/db/migrations/098-workflow-memory-kind.sql +105 -0
- package/dist/action-contracts.d.ts +212 -0
- package/dist/action-contracts.js +10 -0
- package/dist/api/catalog.d.ts +118 -0
- package/dist/api/catalog.js +1756 -0
- package/dist/api/dispatch.d.ts +76 -0
- package/dist/api/dispatch.js +372 -0
- package/dist/canonicalize.d.ts +2 -2
- package/dist/canonicalize.js +3 -3
- package/dist/client/client.d.ts +33 -0
- package/dist/client/client.js +123 -0
- package/dist/client/ipc.d.ts +81 -0
- package/dist/client/ipc.js +314 -0
- package/dist/db-adapter/base-adapter.d.ts +6 -66
- package/dist/db-adapter/base-adapter.js +6 -6
- package/dist/db-adapter/index.d.ts +5 -5
- package/dist/db-adapter/index.js +2 -5
- package/dist/db-adapter/node-sqlite-adapter.d.ts +85 -15
- package/dist/db-adapter/node-sqlite-adapter.js +1968 -570
- package/dist/db-manager.d.ts +53 -97
- package/dist/db-manager.js +121 -603
- package/dist/embedding/embedder.d.ts +132 -0
- package/dist/embedding/embedder.js +299 -0
- package/dist/identity/principal-repository.d.ts +2 -2
- package/dist/index.d.ts +43 -58
- package/dist/index.js +97 -145
- package/dist/{context-compile/channel-grant.d.ts → knowledge/access.d.ts} +12 -17
- package/dist/knowledge/access.js +663 -0
- package/dist/knowledge/case-errors.d.ts +31 -0
- package/dist/knowledge/case-errors.js +40 -0
- package/dist/{cases/search-rollup.d.ts → knowledge/case-search-rollup.d.ts} +5 -4
- package/dist/{cases/search-rollup.js → knowledge/case-search-rollup.js} +6 -8
- package/dist/{cases/store.d.ts → knowledge/case-store.d.ts} +3 -6
- package/dist/{cases/store.js → knowledge/case-store.js} +7 -42
- package/dist/{cases/timeline-range.d.ts → knowledge/case-timeline-range.d.ts} +3 -3
- package/dist/{cases/timeline-range.js → knowledge/case-timeline-range.js} +47 -25
- package/dist/{cases/types.d.ts → knowledge/case-types.d.ts} +8 -2
- package/dist/{cases/types.js → knowledge/case-types.js} +1 -1
- package/dist/knowledge/commitments.d.ts +188 -0
- package/dist/knowledge/commitments.js +370 -0
- package/dist/knowledge/decision-edges.d.ts +70 -0
- package/dist/knowledge/decision-edges.js +123 -0
- package/dist/{agent-graph/types.d.ts → knowledge/graph-query.d.ts} +80 -70
- package/dist/knowledge/graph-query.js +1585 -0
- package/dist/knowledge/identity.d.ts +16 -0
- package/dist/knowledge/identity.js +22 -0
- package/dist/knowledge/index.d.ts +47 -0
- package/dist/knowledge/index.js +90 -0
- package/dist/knowledge/judgments.d.ts +118 -0
- package/dist/knowledge/judgments.js +808 -0
- package/dist/knowledge/observations.d.ts +160 -0
- package/dist/knowledge/observations.js +449 -0
- package/dist/knowledge/question-type.d.ts +34 -0
- package/dist/knowledge/question-type.js +70 -0
- package/dist/{search → knowledge}/ranker-features.js +1 -1
- package/dist/{search → knowledge}/search-quality.d.ts +0 -1
- package/dist/knowledge/search.d.ts +38 -0
- package/dist/knowledge/search.js +91 -0
- package/dist/knowledge/source-ingest.d.ts +65 -0
- package/dist/knowledge/source-ingest.js +174 -0
- package/dist/{edges/types.d.ts → knowledge/twin-edge-types.d.ts} +31 -4
- package/dist/{edges/types.js → knowledge/twin-edge-types.js} +13 -2
- package/dist/knowledge/work-dates.d.ts +49 -0
- package/dist/knowledge/work-dates.js +120 -0
- package/dist/mama-api.d.ts +114 -778
- package/dist/mama-api.js +313 -2461
- package/dist/memory/api.d.ts +264 -24
- package/dist/memory/api.js +1633 -843
- package/dist/memory/bootstrap-builder.d.ts +2 -1
- package/dist/memory/bootstrap-builder.js +5 -5
- package/dist/memory/channel-summary-state-store.d.ts +3 -2
- package/dist/memory/channel-summary-state-store.js +53 -51
- package/dist/memory/channel-summary-store.d.ts +5 -3
- package/dist/memory/channel-summary-store.js +3 -8
- package/dist/memory/dashboard-read.d.ts +46 -0
- package/dist/memory/dashboard-read.js +94 -0
- package/dist/memory/event-store.d.ts +3 -3
- package/dist/memory/event-store.js +3 -10
- package/dist/memory/finding-store.d.ts +3 -2
- package/dist/memory/finding-store.js +2 -7
- package/dist/memory/graph-read.d.ts +52 -0
- package/dist/memory/graph-read.js +130 -0
- package/dist/memory/judgment-types.d.ts +394 -0
- package/dist/memory/judgment-types.js +16 -0
- package/dist/memory/provenance-audit.d.ts +5 -2
- package/dist/memory/provenance-audit.js +8 -14
- package/dist/memory/provenance-live.d.ts +141 -0
- package/dist/memory/provenance-live.js +409 -0
- package/dist/memory/provenance-query.d.ts +5 -4
- package/dist/memory/provenance-query.js +21 -29
- package/dist/memory/provenance-resolver.d.ts +191 -0
- package/dist/memory/provenance-resolver.js +155 -0
- package/dist/memory/provenance.d.ts +1 -11
- package/dist/memory/provenance.js +2 -33
- package/dist/memory/recall-sanitize.d.ts +55 -0
- package/dist/memory/recall-sanitize.js +144 -0
- package/dist/memory/secret-filter.d.ts +32 -0
- package/dist/memory/secret-filter.js +126 -0
- package/dist/memory/truth-store.d.ts +2 -1
- package/dist/memory/truth-store.js +1 -4
- package/dist/memory/types.d.ts +74 -24
- package/dist/memory/types.js +75 -5
- package/dist/memory/write-adapters.d.ts +98 -0
- package/dist/memory/write-adapters.js +242 -0
- package/dist/operations/owner-action-effects.d.ts +53 -0
- package/dist/operations/owner-action-effects.js +96 -0
- package/dist/provenance/source-ref.d.ts +1 -1
- package/dist/provenance/source-ref.js +0 -2
- package/dist/registry/corrections.d.ts +31 -0
- package/dist/registry/corrections.js +332 -0
- package/dist/registry/record-identity.d.ts +49 -0
- package/dist/registry/record-identity.js +133 -0
- package/dist/registry/store.d.ts +101 -0
- package/dist/registry/store.js +395 -0
- package/dist/registry/types.d.ts +28 -0
- package/dist/registry/types.js +5 -0
- package/dist/relevance-scorer.js +2 -2
- package/dist/runtime/agent-event-bus.d.ts +50 -0
- package/dist/runtime/agent-event-bus.js +101 -0
- package/dist/runtime/drivers/claude-cli-wrapper.d.ts +155 -0
- package/dist/runtime/drivers/claude-cli-wrapper.js +392 -0
- package/dist/runtime/drivers/cli-arg-redaction.d.ts +2 -0
- package/dist/runtime/drivers/cli-arg-redaction.js +18 -0
- package/dist/runtime/drivers/cli-secret-redaction.d.ts +17 -0
- package/dist/runtime/drivers/cli-secret-redaction.js +126 -0
- package/dist/runtime/drivers/codex-app-server-process.d.ts +277 -0
- package/dist/runtime/drivers/codex-app-server-process.js +2342 -0
- package/dist/runtime/drivers/codex-auxiliary-tools.d.ts +17 -0
- package/dist/runtime/drivers/codex-auxiliary-tools.js +267 -0
- package/dist/runtime/drivers/codex-home.d.ts +20 -0
- package/dist/runtime/drivers/codex-home.js +674 -0
- package/dist/runtime/drivers/codex-thread-registry.d.ts +63 -0
- package/dist/runtime/drivers/codex-thread-registry.js +433 -0
- package/dist/runtime/drivers/persistent-cli-adapter.d.ts +160 -0
- package/dist/runtime/drivers/persistent-cli-adapter.js +396 -0
- package/dist/runtime/drivers/persistent-cli-process.d.ts +424 -0
- package/dist/runtime/drivers/persistent-cli-process.js +1543 -0
- package/dist/runtime/drivers/types.d.ts +456 -0
- package/dist/runtime/drivers/types.js +110 -0
- package/dist/runtime/mailbox.d.ts +223 -0
- package/dist/runtime/mailbox.js +582 -0
- package/dist/runtime/model-run-store.d.ts +28 -0
- package/dist/{model-runs/store.js → runtime/model-run-store.js} +81 -41
- package/dist/{model-runs/types.d.ts → runtime/model-run-types.d.ts} +33 -4
- package/dist/{model-runs/types.js → runtime/model-run-types.js} +1 -1
- package/dist/runtime/native-effect-observer.d.ts +22 -0
- package/dist/runtime/native-effect-observer.js +103 -0
- package/dist/runtime/native-input-journal.d.ts +46 -0
- package/dist/runtime/native-input-journal.js +308 -0
- package/dist/runtime/native-prompt.d.ts +118 -0
- package/dist/runtime/native-prompt.js +496 -0
- package/dist/runtime/native-session.d.ts +10 -0
- package/dist/{agent-graph/index.js → runtime/native-session.js} +9 -6
- package/dist/runtime/native-tool-trace-observer.d.ts +5 -0
- package/dist/runtime/native-tool-trace-observer.js +65 -0
- package/dist/runtime/native-turn.d.ts +272 -0
- package/dist/runtime/native-turn.js +1041 -0
- package/dist/runtime/operations.d.ts +236 -0
- package/dist/runtime/operations.js +565 -0
- package/dist/runtime/post-tool-handler.d.ts +74 -0
- package/dist/runtime/post-tool-handler.js +137 -0
- package/dist/runtime/prompt-layers.d.ts +126 -0
- package/dist/runtime/prompt-layers.js +239 -0
- package/dist/runtime/runtime-process.d.ts +102 -0
- package/dist/runtime/runtime-process.js +206 -0
- package/dist/runtime/runtime.d.ts +278 -0
- package/dist/runtime/runtime.js +563 -0
- package/dist/runtime/session-pool.d.ts +176 -0
- package/dist/runtime/session-pool.js +369 -0
- package/dist/runtime/stimulus-payload.d.ts +5 -0
- package/dist/runtime/stimulus-payload.js +50 -0
- package/dist/runtime/subagent-bridge.d.ts +24 -0
- package/dist/{agent-graph/types.js → runtime/subagent-bridge.js} +1 -1
- package/dist/runtime/text-completion.d.ts +22 -0
- package/dist/{agent-situation/types.js → runtime/text-completion.js} +1 -1
- package/dist/runtime/token-estimator.d.ts +25 -0
- package/dist/runtime/token-estimator.js +75 -0
- package/dist/runtime/tool-trace-store.d.ts +22 -0
- package/dist/{model-runs → runtime}/tool-trace-store.js +46 -27
- package/dist/runtime/trace-summary.d.ts +5 -0
- package/dist/runtime/trace-summary.js +74 -0
- package/dist/runtime/turn-text.d.ts +23 -0
- package/dist/runtime/turn-text.js +41 -0
- package/dist/storage/database.d.ts +67 -0
- package/dist/storage/database.js +158 -0
- package/package.json +20 -34
- package/dist/agent-graph/alias-write.d.ts +0 -3
- package/dist/agent-graph/alias-write.js +0 -234
- package/dist/agent-graph/entity-resolve.d.ts +0 -3
- package/dist/agent-graph/entity-resolve.js +0 -271
- package/dist/agent-graph/errors.d.ts +0 -4
- package/dist/agent-graph/errors.js +0 -11
- package/dist/agent-graph/graph-query.d.ts +0 -5
- package/dist/agent-graph/graph-query.js +0 -360
- package/dist/agent-graph/index.d.ts +0 -6
- package/dist/agent-situation/builder.d.ts +0 -8
- package/dist/agent-situation/builder.js +0 -239
- package/dist/agent-situation/cache-key.d.ts +0 -4
- package/dist/agent-situation/cache-key.js +0 -64
- package/dist/agent-situation/index.d.ts +0 -7
- package/dist/agent-situation/index.js +0 -28
- package/dist/agent-situation/packet-store.d.ts +0 -27
- package/dist/agent-situation/packet-store.js +0 -228
- package/dist/agent-situation/ranking-policy.d.ts +0 -18
- package/dist/agent-situation/ranking-policy.js +0 -75
- package/dist/agent-situation/source-readers.d.ts +0 -52
- package/dist/agent-situation/source-readers.js +0 -300
- package/dist/agent-situation/types.d.ts +0 -195
- package/dist/cases/wiki-page-index.d.ts +0 -37
- package/dist/cases/wiki-page-index.js +0 -201
- package/dist/config-loader.d.ts +0 -68
- package/dist/config-loader.js +0 -239
- package/dist/connectors/event-index.d.ts +0 -24
- package/dist/connectors/event-index.js +0 -245
- package/dist/connectors/raw-query.d.ts +0 -40
- package/dist/connectors/raw-query.js +0 -412
- package/dist/connectors/types.d.ts +0 -117
- package/dist/connectors/types.js +0 -3
- package/dist/context-compile/boundary-defaults.d.ts +0 -12
- package/dist/context-compile/boundary-defaults.js +0 -105
- package/dist/context-compile/channel-grant.js +0 -66
- package/dist/context-compile/compiler-policy.d.ts +0 -39
- package/dist/context-compile/compiler-policy.js +0 -147
- package/dist/context-compile/compiler.d.ts +0 -18
- package/dist/context-compile/compiler.js +0 -404
- package/dist/context-compile/index.d.ts +0 -10
- package/dist/context-compile/index.js +0 -26
- package/dist/context-compile/packet-store.d.ts +0 -8
- package/dist/context-compile/packet-store.js +0 -239
- package/dist/context-compile/ref.d.ts +0 -7
- package/dist/context-compile/ref.js +0 -102
- package/dist/context-compile/source-readers.d.ts +0 -70
- package/dist/context-compile/source-readers.js +0 -840
- package/dist/context-compile/types.d.ts +0 -155
- package/dist/context-compile/types.js +0 -11
- package/dist/context-compile/visibility.d.ts +0 -21
- package/dist/context-compile/visibility.js +0 -224
- package/dist/decision-tracker.d.ts +0 -206
- package/dist/decision-tracker.js +0 -481
- package/dist/edges/ref-validation.d.ts +0 -7
- package/dist/edges/ref-validation.js +0 -321
- package/dist/edges/store.d.ts +0 -8
- package/dist/edges/store.js +0 -129
- package/dist/embedding-client.d.ts +0 -28
- package/dist/embedding-client.js +0 -53
- package/dist/embedding-server/index.d.ts +0 -67
- package/dist/embedding-server/index.js +0 -405
- package/dist/embedding-server/mobile/auth.d.ts +0 -44
- package/dist/embedding-server/mobile/auth.js +0 -150
- package/dist/embedding-server/mobile/daemon.d.ts +0 -129
- package/dist/embedding-server/mobile/daemon.js +0 -313
- package/dist/embedding-server/mobile/output-parser.d.ts +0 -115
- package/dist/embedding-server/mobile/output-parser.js +0 -241
- package/dist/embedding-server/mobile/session-api.d.ts +0 -57
- package/dist/embedding-server/mobile/session-api.js +0 -261
- package/dist/embedding-server/mobile/session-manager.d.ts +0 -138
- package/dist/embedding-server/mobile/session-manager.js +0 -378
- package/dist/embedding-server/mobile/websocket-handler.d.ts +0 -137
- package/dist/embedding-server/mobile/websocket-handler.js +0 -486
- package/dist/embeddings.d.ts +0 -68
- package/dist/embeddings.js +0 -244
- package/dist/entities/audit-metrics.d.ts +0 -68
- package/dist/entities/audit-metrics.js +0 -124
- package/dist/entities/candidate-generator.d.ts +0 -8
- package/dist/entities/candidate-generator.js +0 -24
- package/dist/entities/entity-linked-decision-counts.d.ts +0 -2
- package/dist/entities/entity-linked-decision-counts.js +0 -29
- package/dist/entities/entity-list.d.ts +0 -22
- package/dist/entities/entity-list.js +0 -3
- package/dist/entities/entity-orphan-list.d.ts +0 -17
- package/dist/entities/entity-orphan-list.js +0 -3
- package/dist/entities/entity-search.d.ts +0 -20
- package/dist/entities/entity-search.js +0 -3
- package/dist/entities/errors.d.ts +0 -55
- package/dist/entities/errors.js +0 -100
- package/dist/entities/lineage-store.d.ts +0 -28
- package/dist/entities/lineage-store.js +0 -204
- package/dist/entities/normalization.d.ts +0 -14
- package/dist/entities/normalization.js +0 -63
- package/dist/entities/policy-store.d.ts +0 -8
- package/dist/entities/policy-store.js +0 -75
- package/dist/entities/policy-types.d.ts +0 -72
- package/dist/entities/policy-types.js +0 -59
- package/dist/entities/projection.d.ts +0 -8
- package/dist/entities/projection.js +0 -82
- package/dist/entities/provenance-query.d.ts +0 -32
- package/dist/entities/provenance-query.js +0 -3
- package/dist/entities/read-identity.d.ts +0 -31
- package/dist/entities/read-identity.js +0 -264
- package/dist/entities/recall-bridge.d.ts +0 -5
- package/dist/entities/recall-bridge.js +0 -171
- package/dist/entities/resolution-engine.d.ts +0 -8
- package/dist/entities/resolution-engine.js +0 -3
- package/dist/entities/rollback-preview.d.ts +0 -35
- package/dist/entities/rollback-preview.js +0 -3
- package/dist/entities/source-locator.d.ts +0 -3
- package/dist/entities/source-locator.js +0 -32
- package/dist/entities/store.d.ts +0 -69
- package/dist/entities/store.js +0 -544
- package/dist/entities/types.d.ts +0 -166
- package/dist/entities/types.js +0 -30
- package/dist/memory/extraction-prompt.d.ts +0 -4
- package/dist/memory/extraction-prompt.js +0 -89
- package/dist/memory/scope-backfill.d.ts +0 -14
- package/dist/memory/scope-backfill.js +0 -3
- package/dist/memory/scope-store.d.ts +0 -4
- package/dist/memory/scope-store.js +0 -9
- package/dist/memory-store.d.ts +0 -87
- package/dist/memory-store.js +0 -78
- package/dist/model-runs/store.d.ts +0 -13
- package/dist/model-runs/tool-trace-store.d.ts +0 -8
- package/dist/notification-manager.d.ts +0 -7
- package/dist/notification-manager.js +0 -12
- package/dist/outcome-tracker.d.ts +0 -151
- package/dist/outcome-tracker.js +0 -271
- package/dist/query-intent.d.ts +0 -23
- package/dist/query-intent.js +0 -114
- package/dist/runtime/trusted-provenance.d.ts +0 -3
- package/dist/runtime/trusted-provenance.js +0 -6
- package/dist/search/question-type.d.ts +0 -5
- package/dist/search/question-type.js +0 -41
- package/dist/test-utils.d.ts +0 -80
- package/dist/test-utils.js +0 -218
- package/dist/tier-validator.d.ts +0 -43
- package/dist/tier-validator.js +0 -159
- package/dist/time-formatter.d.ts +0 -25
- package/dist/time-formatter.js +0 -93
- /package/dist/{search → knowledge}/feedback-store.d.ts +0 -0
- /package/dist/{search → knowledge}/feedback-store.js +0 -0
- /package/dist/{search → knowledge}/ranker-features.d.ts +0 -0
- /package/dist/{search → knowledge}/ranker-rescore.d.ts +0 -0
- /package/dist/{search → knowledge}/ranker-rescore.js +0 -0
- /package/dist/{search → knowledge}/ranker-trainer.d.ts +0 -0
- /package/dist/{search → knowledge}/ranker-trainer.js +0 -0
- /package/dist/{search → knowledge}/search-quality.js +0 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- Existing decisions are legacy memory records until an explicit judgment command
|
|
2
|
+
-- binds them to a judgment receipt. Migration recovery in the adapter preserves
|
|
3
|
+
-- the same distinction for databases that already applied migration 075.
|
|
4
|
+
|
|
5
|
+
INSERT OR IGNORE INTO schema_version (version, description)
|
|
6
|
+
VALUES (77, 'Distinguish legacy memory records from agent judgments');
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
-- Raw source ingestion commands. Every source.ingest command binds exactly one
|
|
2
|
+
-- immutable observation_versions row through command_bindings; the receipt is
|
|
3
|
+
-- replayed verbatim on idempotent retries so a retried ingest never duplicates.
|
|
4
|
+
|
|
5
|
+
CREATE TABLE IF NOT EXISTS source_commands (
|
|
6
|
+
command_id TEXT PRIMARY KEY REFERENCES command_bindings(command_id) ON DELETE RESTRICT,
|
|
7
|
+
observation_id TEXT NOT NULL REFERENCES observation_versions(observation_id) ON DELETE RESTRICT,
|
|
8
|
+
event_id TEXT,
|
|
9
|
+
committed_watermark INTEGER NOT NULL CHECK (committed_watermark >= 0),
|
|
10
|
+
receipt_json TEXT NOT NULL CHECK (json_valid(receipt_json)),
|
|
11
|
+
created_at INTEGER NOT NULL CHECK (created_at >= 0)
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
CREATE INDEX IF NOT EXISTS idx_source_commands_observation
|
|
15
|
+
ON source_commands(observation_id, created_at DESC);
|
|
16
|
+
|
|
17
|
+
INSERT OR IGNORE INTO schema_version (version, description)
|
|
18
|
+
VALUES (78, 'Source ingest command receipts bound to observations');
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
-- Extend twin_edges.edge_type with the judgment-boundary relations 'refines',
|
|
2
|
+
-- 'contradicts', and 'amends'. Authored record links use these relations; the
|
|
3
|
+
-- 074 shape predates them and rejects the inserts with a CHECK violation.
|
|
4
|
+
-- Rebuild the table like 074 did, preserving every row and column.
|
|
5
|
+
|
|
6
|
+
ALTER TABLE twin_edges RENAME TO twin_edges_legacy_079;
|
|
7
|
+
CREATE TABLE twin_edges (
|
|
8
|
+
edge_id TEXT PRIMARY KEY,
|
|
9
|
+
edge_type TEXT NOT NULL CHECK (edge_type IN ('supersedes','refines','contradicts','builds_on','debates','synthesizes','mentions','derived_from','case_member','alias_of','next_action_for','blocks','amends')),
|
|
10
|
+
subject_kind TEXT NOT NULL CHECK (subject_kind IN ('memory','case','entity','report','edge','registry','observation')),
|
|
11
|
+
subject_id TEXT NOT NULL,
|
|
12
|
+
object_kind TEXT NOT NULL CHECK (object_kind IN ('memory','case','entity','report','edge','raw','registry','observation')),
|
|
13
|
+
object_id TEXT NOT NULL,
|
|
14
|
+
relation_attrs_json TEXT,
|
|
15
|
+
confidence REAL NOT NULL DEFAULT 1.0 CHECK (confidence >= 0.0 AND confidence <= 1.0),
|
|
16
|
+
source TEXT NOT NULL CHECK (source IN ('agent','human','code')),
|
|
17
|
+
agent_id TEXT,
|
|
18
|
+
model_run_id TEXT,
|
|
19
|
+
envelope_hash TEXT,
|
|
20
|
+
human_actor_id TEXT,
|
|
21
|
+
human_actor_role TEXT,
|
|
22
|
+
authority_scope_json TEXT,
|
|
23
|
+
reason_classification TEXT,
|
|
24
|
+
reason_text TEXT,
|
|
25
|
+
evidence_refs_json TEXT,
|
|
26
|
+
request_idempotency_key TEXT,
|
|
27
|
+
edge_idempotency_key TEXT,
|
|
28
|
+
content_hash BLOB NOT NULL CHECK(length(content_hash)=32),
|
|
29
|
+
created_at INTEGER NOT NULL
|
|
30
|
+
);
|
|
31
|
+
INSERT INTO twin_edges SELECT * FROM twin_edges_legacy_079;
|
|
32
|
+
DROP TABLE twin_edges_legacy_079;
|
|
33
|
+
CREATE INDEX idx_twin_edges_subject ON twin_edges(subject_kind, subject_id, created_at DESC);
|
|
34
|
+
CREATE INDEX idx_twin_edges_object ON twin_edges(object_kind, object_id, created_at DESC);
|
|
35
|
+
CREATE INDEX idx_twin_edges_model_run_id ON twin_edges(model_run_id, created_at DESC);
|
|
36
|
+
CREATE INDEX idx_twin_edges_request_idempotency
|
|
37
|
+
ON twin_edges(model_run_id, request_idempotency_key, created_at DESC)
|
|
38
|
+
WHERE model_run_id IS NOT NULL AND request_idempotency_key IS NOT NULL;
|
|
39
|
+
CREATE UNIQUE INDEX ux_twin_edges_model_run_edge_idempotency
|
|
40
|
+
ON twin_edges(model_run_id, edge_idempotency_key)
|
|
41
|
+
WHERE model_run_id IS NOT NULL AND edge_idempotency_key IS NOT NULL;
|
|
42
|
+
INSERT OR IGNORE INTO schema_version (version, description)
|
|
43
|
+
VALUES (79, 'Twin edge relations for judgment links (refines/contradicts/amends)');
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
-- Restore decisions.duration_days. The column is part of the original
|
|
2
|
+
-- decision-graph schema (001) but the 025 kind-check rebuild omitted it while
|
|
3
|
+
-- outcome projections still write it. Databases that already carry the column
|
|
4
|
+
-- skip this through the runner's duplicate-column handling.
|
|
5
|
+
ALTER TABLE decisions ADD COLUMN duration_days INTEGER;
|
|
6
|
+
INSERT OR IGNORE INTO schema_version (version, description)
|
|
7
|
+
VALUES (80, 'Restore decisions.duration_days dropped by the 025 rebuild');
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
-- The owner-event mailbox moves into the core database.
|
|
2
|
+
--
|
|
3
|
+
-- These two tables have existed since the operator loop was built, but only ever
|
|
4
|
+
-- inside the product's own triggers.db, created inline by the class that used them.
|
|
5
|
+
-- Declaring them here is what lets the mailbox be opened against the core database
|
|
6
|
+
-- like every other core store. The shape is the one the live table already has,
|
|
7
|
+
-- including the three columns that were added by run-time ALTERs rather than by a
|
|
8
|
+
-- migration: retry_after, unresolved_reason and event_refs_json.
|
|
9
|
+
--
|
|
10
|
+
-- Existing rows are NOT moved here. A .sql migration cannot name another database
|
|
11
|
+
-- file, and the rows live in a path only the product knows. scripts/move-mailbox-rows.ts
|
|
12
|
+
-- does that part.
|
|
13
|
+
|
|
14
|
+
CREATE TABLE IF NOT EXISTS owner_event_inbox (
|
|
15
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
16
|
+
channel_key TEXT NOT NULL,
|
|
17
|
+
event_ids_json TEXT NOT NULL,
|
|
18
|
+
event_refs_json TEXT NOT NULL DEFAULT '[]',
|
|
19
|
+
lines_json TEXT NOT NULL,
|
|
20
|
+
activations_json TEXT NOT NULL,
|
|
21
|
+
status TEXT NOT NULL DEFAULT 'pending'
|
|
22
|
+
CHECK (status IN ('pending','claimed','acked','dead')),
|
|
23
|
+
attempts INTEGER NOT NULL DEFAULT 0,
|
|
24
|
+
last_error TEXT,
|
|
25
|
+
created_at INTEGER NOT NULL,
|
|
26
|
+
claimed_at INTEGER,
|
|
27
|
+
acked_at INTEGER,
|
|
28
|
+
retry_after INTEGER,
|
|
29
|
+
unresolved_reason TEXT
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
CREATE INDEX IF NOT EXISTS idx_owner_event_inbox_status
|
|
33
|
+
ON owner_event_inbox(status, id);
|
|
34
|
+
|
|
35
|
+
-- Dedupe horizon. One row per event id ever drained, pruned on a 30-day window.
|
|
36
|
+
CREATE TABLE IF NOT EXISTS owner_event_inbox_events (
|
|
37
|
+
event_id TEXT PRIMARY KEY,
|
|
38
|
+
seen_at INTEGER NOT NULL DEFAULT 0
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
CREATE INDEX IF NOT EXISTS idx_owner_event_inbox_events_seen
|
|
42
|
+
ON owner_event_inbox_events(seen_at);
|
|
43
|
+
|
|
44
|
+
-- When to wake, and for what. Nothing reads this yet: the design puts the reader
|
|
45
|
+
-- in 7.3, where the cron scheduler learns to wake from this table instead of from
|
|
46
|
+
-- config held in memory. The columns are only what that sentence states the table
|
|
47
|
+
-- is for -- which channel, when it is due, whether it fired. Anything else would be
|
|
48
|
+
-- a guess at the reader's needs, and a guess costs a second migration.
|
|
49
|
+
CREATE TABLE IF NOT EXISTS mailbox_schedules (
|
|
50
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
51
|
+
channel_key TEXT NOT NULL,
|
|
52
|
+
due_at INTEGER NOT NULL,
|
|
53
|
+
created_at INTEGER NOT NULL,
|
|
54
|
+
fired_at INTEGER
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
CREATE INDEX IF NOT EXISTS idx_mailbox_schedules_due
|
|
58
|
+
ON mailbox_schedules(fired_at, due_at);
|
|
59
|
+
|
|
60
|
+
INSERT OR IGNORE INTO schema_version (version, description)
|
|
61
|
+
VALUES (81, 'Owner-event mailbox tables move into the core database');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- The commitments rowid was called task_id.
|
|
2
|
+
--
|
|
3
|
+
-- A commitment is what this core knows how to hold: a record plus a revision
|
|
4
|
+
-- history. "Task" is one product's word for what it puts in one. Naming the rowid
|
|
5
|
+
-- after that product's word meant every other product installing this core read a
|
|
6
|
+
-- column about work it does not have.
|
|
7
|
+
--
|
|
8
|
+
-- RENAME COLUMN keeps the data, the AUTOINCREMENT sequence (sqlite_sequence is
|
|
9
|
+
-- keyed by table, not column) and every existing row id. Nothing is renumbered.
|
|
10
|
+
ALTER TABLE commitments RENAME COLUMN task_id TO row_id;
|
|
11
|
+
INSERT OR IGNORE INTO schema_version (version, description)
|
|
12
|
+
VALUES (82, 'Rename commitments.task_id to row_id');
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
-- An observation becomes the whole evidence record, and stops naming a connector.
|
|
2
|
+
--
|
|
3
|
+
-- Migration 030 built `connector_event_index` as the memory substrate, because at
|
|
4
|
+
-- the time the only producer of evidence was a connector. Migration 072 introduced
|
|
5
|
+
-- the neutral primitive, `observation_versions`, but attached it as a satellite --
|
|
6
|
+
-- `connector_event_index.current_observation_id` -- and left the old table as the
|
|
7
|
+
-- entry point. The foreign key has pointed the right way ever since; the reads did
|
|
8
|
+
-- not follow it.
|
|
9
|
+
--
|
|
10
|
+
-- Two things change here, both so the reads can. The observation gains the evidence
|
|
11
|
+
-- columns that only lived on the connector index, and the scope it carries as one
|
|
12
|
+
-- JSON blob becomes columns a visibility filter can index. What stays behind on
|
|
13
|
+
-- that index is what a polling loop needs to know about itself -- cursors,
|
|
14
|
+
-- sequences, sweep times -- which is the connector framework's business and not the
|
|
15
|
+
-- core's.
|
|
16
|
+
--
|
|
17
|
+
-- The column that named a connector is now `source`: the pair is (namespace,
|
|
18
|
+
-- id-within-it), the same shape as source_id/source_at/source_locator beside it. A
|
|
19
|
+
-- deployment with no connectors still has observations. That rename is made in 072
|
|
20
|
+
-- itself rather than here, because the driver carries its own copy of this table's
|
|
21
|
+
-- schema and rebuilds the table when the two disagree -- so a rename applied after
|
|
22
|
+
-- the fact is undone before the next statement runs. Editing a shipped migration is
|
|
23
|
+
-- only available because this store holds test data; see the owner's note that
|
|
24
|
+
-- MAMA is a testbed and kagemusha keeps the real corpus.
|
|
25
|
+
|
|
26
|
+
-- Evidence the connector index held alone. All of it describes what was observed.
|
|
27
|
+
ALTER TABLE observation_versions ADD COLUMN source_type TEXT;
|
|
28
|
+
ALTER TABLE observation_versions ADD COLUMN source_locator TEXT;
|
|
29
|
+
ALTER TABLE observation_versions ADD COLUMN title TEXT;
|
|
30
|
+
ALTER TABLE observation_versions ADD COLUMN artifact_locator TEXT;
|
|
31
|
+
ALTER TABLE observation_versions ADD COLUMN artifact_title TEXT;
|
|
32
|
+
ALTER TABLE observation_versions ADD COLUMN event_date TEXT;
|
|
33
|
+
ALTER TABLE observation_versions ADD COLUMN source_entity_id TEXT;
|
|
34
|
+
|
|
35
|
+
-- Scope out of the JSON blob. Raw visibility is decided against these four, and a
|
|
36
|
+
-- filter that cannot reach a column cannot be a WHERE clause.
|
|
37
|
+
ALTER TABLE observation_versions ADD COLUMN channel TEXT;
|
|
38
|
+
ALTER TABLE observation_versions ADD COLUMN project_id TEXT;
|
|
39
|
+
ALTER TABLE observation_versions ADD COLUMN tenant_id TEXT;
|
|
40
|
+
ALTER TABLE observation_versions ADD COLUMN memory_scope_kind TEXT;
|
|
41
|
+
ALTER TABLE observation_versions ADD COLUMN memory_scope_id TEXT;
|
|
42
|
+
|
|
43
|
+
CREATE INDEX IF NOT EXISTS idx_observation_visibility
|
|
44
|
+
ON observation_versions(source, channel, project_id, tenant_id);
|
|
45
|
+
CREATE INDEX IF NOT EXISTS idx_observation_artifact
|
|
46
|
+
ON observation_versions(artifact_locator);
|
|
47
|
+
|
|
48
|
+
INSERT OR IGNORE INTO schema_version (version, description)
|
|
49
|
+
VALUES (83, 'An observation is the whole evidence record and names no connector');
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
-- A scope kind is the consumer's word, not the core's list.
|
|
2
|
+
--
|
|
3
|
+
-- `memory_scopes` had it right in shape: a scope is a (kind, id) pair, and the
|
|
4
|
+
-- pair is what the core reasons about. Then it also enumerated the kinds --
|
|
5
|
+
-- global, user, channel, project -- which is a statement about one deployment's
|
|
6
|
+
-- world. `channel` is a chat concept; a consumer with no chat has to satisfy a
|
|
7
|
+
-- constraint naming it, and a consumer with a kind of its own cannot store one at
|
|
8
|
+
-- all.
|
|
9
|
+
--
|
|
10
|
+
-- The core defines the question. It must not also answer it. What is kept is the
|
|
11
|
+
-- only part that is the core's: a kind is nonblank text.
|
|
12
|
+
--
|
|
13
|
+
-- SQLite cannot drop a CHECK, so the table is rebuilt. The rows carry over.
|
|
14
|
+
|
|
15
|
+
PRAGMA foreign_keys = OFF;
|
|
16
|
+
|
|
17
|
+
CREATE TABLE memory_scopes_084 (
|
|
18
|
+
id TEXT PRIMARY KEY,
|
|
19
|
+
kind TEXT NOT NULL CHECK (length(trim(kind)) > 0),
|
|
20
|
+
external_id TEXT NOT NULL,
|
|
21
|
+
created_at INTEGER DEFAULT (unixepoch() * 1000),
|
|
22
|
+
UNIQUE(kind, external_id)
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
INSERT INTO memory_scopes_084 (id, kind, external_id, created_at)
|
|
26
|
+
SELECT id, kind, external_id, created_at FROM memory_scopes;
|
|
27
|
+
|
|
28
|
+
DROP TABLE memory_scopes;
|
|
29
|
+
ALTER TABLE memory_scopes_084 RENAME TO memory_scopes;
|
|
30
|
+
|
|
31
|
+
PRAGMA foreign_keys = ON;
|
|
32
|
+
|
|
33
|
+
INSERT OR IGNORE INTO schema_version (version, description)
|
|
34
|
+
VALUES (84, 'A scope kind is the consumer word, not a list the core keeps');
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
-- A migration belongs to whoever wrote it.
|
|
2
|
+
--
|
|
3
|
+
-- `schema_version` keyed migrations on a number alone, and progress was
|
|
4
|
+
-- `MAX(version)`. Both assume one author. With the core at 084, no other package
|
|
5
|
+
-- can number a migration: 085 is the core's next, and a package that picked 200
|
|
6
|
+
-- would make every later core migration look already applied.
|
|
7
|
+
--
|
|
8
|
+
-- So there was nowhere for a package's own table to live except inside the core,
|
|
9
|
+
-- and that is why the connector tables -- which one of four consumers has any use
|
|
10
|
+
-- for -- are declared by core migrations and created in every consumer's database.
|
|
11
|
+
--
|
|
12
|
+
-- Identity becomes (source, version). Rows written before this belong to the core,
|
|
13
|
+
-- which is the only author there has been.
|
|
14
|
+
|
|
15
|
+
PRAGMA foreign_keys = OFF;
|
|
16
|
+
|
|
17
|
+
CREATE TABLE schema_version_085 (
|
|
18
|
+
source TEXT NOT NULL DEFAULT 'core' CHECK (length(trim(source)) > 0),
|
|
19
|
+
version INTEGER NOT NULL,
|
|
20
|
+
applied_at INTEGER DEFAULT (unixepoch()),
|
|
21
|
+
description TEXT,
|
|
22
|
+
PRIMARY KEY (source, version)
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
-- Only (version, description) carry over. `applied_at` is not copied: a database
|
|
26
|
+
-- old enough to predate it does not have the column, and when it ran is not a fact
|
|
27
|
+
-- anything reads. The new table defaults it.
|
|
28
|
+
INSERT INTO schema_version_085 (source, version, description)
|
|
29
|
+
SELECT 'core', version, description FROM schema_version;
|
|
30
|
+
|
|
31
|
+
DROP TABLE schema_version;
|
|
32
|
+
ALTER TABLE schema_version_085 RENAME TO schema_version;
|
|
33
|
+
|
|
34
|
+
PRAGMA foreign_keys = ON;
|
|
35
|
+
|
|
36
|
+
INSERT OR IGNORE INTO schema_version (source, version, description)
|
|
37
|
+
VALUES ('core', 85, 'A migration is identified by (source, version)');
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
-- The mailbox that any consumer can use.
|
|
2
|
+
--
|
|
3
|
+
-- Migration 081 declared the owner-event inbox in the core database: its display
|
|
4
|
+
-- lines, its frozen procedure activations, its `OwnerEvent` name. Those are one
|
|
5
|
+
-- consumer's vocabulary, and a core that requires them makes "receive something
|
|
6
|
+
-- durably" unusable without MAMA's trigger loop. The design's own §5.2 measures
|
|
7
|
+
-- exactly that, so W6 was corrected: the mechanism of intake is the core's, the
|
|
8
|
+
-- words for what it carries are the product's.
|
|
9
|
+
--
|
|
10
|
+
-- 081 IS NOT EDITED. It is applied history, and editing an applied migration makes
|
|
11
|
+
-- the file and the databases that already ran it say different things. Its two
|
|
12
|
+
-- tables stay where they are, and the product's compatibility inbox
|
|
13
|
+
-- (standalone/src/operator/owner-event-inbox.ts) keeps draining its own rows from
|
|
14
|
+
-- its own store. This migration goes forward instead.
|
|
15
|
+
--
|
|
16
|
+
-- WHAT TRANSFERS, AND WHAT DELIBERATELY DOES NOT.
|
|
17
|
+
--
|
|
18
|
+
-- The dedupe horizon transfers. "This id already came in" is a purely mechanical
|
|
19
|
+
-- fact with no vocabulary in it, and losing it means a connector's redelivery
|
|
20
|
+
-- walks in through the new door as if it were new. Copied INSERT OR IGNORE, so
|
|
21
|
+
-- re-running changes nothing.
|
|
22
|
+
--
|
|
23
|
+
-- The rows do not transfer -- and that is how their attempts and receipts are
|
|
24
|
+
-- preserved, not how they are lost. A generic intake has nowhere to put a
|
|
25
|
+
-- procedure activation, and moving a row while dropping one would lose a contract
|
|
26
|
+
-- the producer froze before its cursor advanced. The compatibility inbox keeps
|
|
27
|
+
-- every row, every attempt count and every ack exactly where it already is;
|
|
28
|
+
-- producers move to the new door one slice at a time, and each slice's old rows
|
|
29
|
+
-- are already drained by the loop that owns them before its caller is deleted.
|
|
30
|
+
-- Measured 2026-09-22: core owner_event_inbox 0 rows, operator pending 0 rows,
|
|
31
|
+
-- owner_event_inbox_events 12 rows -- those 12 are the whole transfer.
|
|
32
|
+
|
|
33
|
+
CREATE TABLE IF NOT EXISTS mailbox_inputs (
|
|
34
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
35
|
+
-- Identity: what the producer calls this stimulus.
|
|
36
|
+
stimulus_id TEXT NOT NULL,
|
|
37
|
+
-- Stated by the producer, one of owner_message / source_delta / scheduled.
|
|
38
|
+
-- NULLABLE with no DEFAULT: a row whose producer stated none reads back as
|
|
39
|
+
-- "not stated", which is true. The host never derives it from the content --
|
|
40
|
+
-- reading a message body to decide what kind of work it is is the
|
|
41
|
+
-- classification this contract removes.
|
|
42
|
+
kind TEXT,
|
|
43
|
+
-- Principal: whose stimulus this is.
|
|
44
|
+
principal_id TEXT NOT NULL,
|
|
45
|
+
-- Source: where it came from, canonical at the producer.
|
|
46
|
+
channel_key TEXT NOT NULL,
|
|
47
|
+
-- Content: the bounded change notice. Never the whole context.
|
|
48
|
+
preview_json TEXT NOT NULL DEFAULT '[]',
|
|
49
|
+
-- Reply: where an answer goes back, when the producer can name one.
|
|
50
|
+
reply_to TEXT,
|
|
51
|
+
-- Coalesce: what may mechanically merge with what, while both are pending.
|
|
52
|
+
coalesce_key TEXT,
|
|
53
|
+
-- Time: when it happened, as against when it was accepted.
|
|
54
|
+
occurred_at INTEGER NOT NULL,
|
|
55
|
+
created_at INTEGER NOT NULL,
|
|
56
|
+
-- Delivery state, and nothing about the work.
|
|
57
|
+
status TEXT NOT NULL DEFAULT 'pending'
|
|
58
|
+
CHECK (status IN ('pending','claimed','acked','dead')),
|
|
59
|
+
attempts INTEGER NOT NULL DEFAULT 0,
|
|
60
|
+
last_error TEXT,
|
|
61
|
+
claimed_at INTEGER,
|
|
62
|
+
acked_at INTEGER,
|
|
63
|
+
retry_after INTEGER
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
CREATE INDEX IF NOT EXISTS idx_mailbox_inputs_status
|
|
67
|
+
ON mailbox_inputs(status, id);
|
|
68
|
+
CREATE INDEX IF NOT EXISTS idx_mailbox_inputs_coalesce
|
|
69
|
+
ON mailbox_inputs(status, coalesce_key);
|
|
70
|
+
|
|
71
|
+
-- Preserved observation identity, one row per ref. A separate table because refs
|
|
72
|
+
-- are the dedupe and cause set: they are queried, not just displayed.
|
|
73
|
+
CREATE TABLE IF NOT EXISTS mailbox_input_refs (
|
|
74
|
+
input_id INTEGER NOT NULL REFERENCES mailbox_inputs(id) ON DELETE CASCADE,
|
|
75
|
+
ref_id TEXT NOT NULL,
|
|
76
|
+
observation_ref TEXT,
|
|
77
|
+
PRIMARY KEY (input_id, ref_id)
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
-- The 30-day dedupe horizon. One row per ref ever accepted.
|
|
81
|
+
CREATE TABLE IF NOT EXISTS mailbox_seen (
|
|
82
|
+
ref_id TEXT PRIMARY KEY,
|
|
83
|
+
seen_at INTEGER NOT NULL DEFAULT 0
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
CREATE INDEX IF NOT EXISTS idx_mailbox_seen_at ON mailbox_seen(seen_at);
|
|
87
|
+
|
|
88
|
+
-- When to wake, and for what channel. 081 declared this one already and it was
|
|
89
|
+
-- generic from the start -- this daemon's own alarm clock, not anyone's calendar
|
|
90
|
+
-- (design §6.3). Repeated IF NOT EXISTS so the generic contract stands on its own
|
|
91
|
+
-- rather than on a migration written for one consumer.
|
|
92
|
+
CREATE TABLE IF NOT EXISTS mailbox_schedules (
|
|
93
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
94
|
+
channel_key TEXT NOT NULL,
|
|
95
|
+
due_at INTEGER NOT NULL,
|
|
96
|
+
created_at INTEGER NOT NULL,
|
|
97
|
+
fired_at INTEGER
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
CREATE INDEX IF NOT EXISTS idx_mailbox_schedules_due
|
|
101
|
+
ON mailbox_schedules(fired_at, due_at);
|
|
102
|
+
|
|
103
|
+
-- Carry the horizon forward. 081 created owner_event_inbox_events in this same
|
|
104
|
+
-- database, so it is always present here; on an install that never drained a
|
|
105
|
+
-- single event it is empty and this is a no-op.
|
|
106
|
+
INSERT OR IGNORE INTO mailbox_seen (ref_id, seen_at)
|
|
107
|
+
SELECT event_id, seen_at FROM owner_event_inbox_events;
|
|
108
|
+
|
|
109
|
+
INSERT OR IGNORE INTO schema_version (source, version, description)
|
|
110
|
+
VALUES ('core', 86, 'the mailbox is generic: durable intake, schedule, delivery and ack only');
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
-- Consumer-owned input data. NULL denotes an old input with no preserved payload;
|
|
2
|
+
-- a JSON null is the text 'null'. Never reconstruct missing data from a preview.
|
|
3
|
+
ALTER TABLE mailbox_inputs ADD COLUMN payload_json TEXT;
|
|
4
|
+
CREATE INDEX IF NOT EXISTS idx_mailbox_inputs_identity
|
|
5
|
+
ON mailbox_inputs(principal_id, stimulus_id);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
-- Native input facts are separate from both work judgments and external effects.
|
|
2
|
+
CREATE TABLE IF NOT EXISTS native_input_deliveries (
|
|
3
|
+
input_id INTEGER PRIMARY KEY REFERENCES mailbox_inputs(id) ON DELETE CASCADE,
|
|
4
|
+
invocation_id TEXT UNIQUE,
|
|
5
|
+
state TEXT NOT NULL CHECK (state IN ('prepared','dispatching','accepted','settled','uncertain')),
|
|
6
|
+
dispatch_json TEXT,
|
|
7
|
+
receipt_json TEXT,
|
|
8
|
+
error TEXT,
|
|
9
|
+
updated_at INTEGER NOT NULL
|
|
10
|
+
);
|
|
11
|
+
-- Earlier claims did not record whether native execution had begun. Do not replay them on a guess.
|
|
12
|
+
INSERT OR IGNORE INTO native_input_deliveries (input_id, state, error, updated_at)
|
|
13
|
+
SELECT id, 'uncertain', 'Legacy input has no native dispatch record', created_at
|
|
14
|
+
FROM mailbox_inputs WHERE status = 'claimed' OR (status = 'pending' AND attempts > 0);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
-- A model run's first accepted input names its native turn. Every later steer
|
|
2
|
+
-- shares that turn receipt, so membership is projected from the durable journal
|
|
3
|
+
-- instead of copied into a second queue or fabricated for historical runs.
|
|
4
|
+
CREATE INDEX IF NOT EXISTS idx_mailbox_inputs_identity
|
|
5
|
+
ON mailbox_inputs(principal_id, stimulus_id);
|
|
6
|
+
|
|
7
|
+
CREATE VIEW IF NOT EXISTS model_run_native_inputs AS
|
|
8
|
+
SELECT
|
|
9
|
+
mr.model_run_id,
|
|
10
|
+
child.id AS input_id,
|
|
11
|
+
child.stimulus_id,
|
|
12
|
+
child.kind,
|
|
13
|
+
child.principal_id,
|
|
14
|
+
child.channel_key,
|
|
15
|
+
child.occurred_at,
|
|
16
|
+
child.status,
|
|
17
|
+
child_delivery.state AS native_state
|
|
18
|
+
FROM model_runs mr
|
|
19
|
+
JOIN mailbox_inputs root
|
|
20
|
+
ON root.stimulus_id = CASE WHEN json_valid(mr.input_refs_json)
|
|
21
|
+
THEN json_extract(mr.input_refs_json, '$.sourceMessageRef') ELSE NULL END
|
|
22
|
+
AND root.principal_id = CASE WHEN json_valid(mr.input_refs_json)
|
|
23
|
+
THEN json_extract(mr.input_refs_json, '$.principalId') ELSE NULL END
|
|
24
|
+
JOIN native_input_deliveries root_delivery
|
|
25
|
+
ON root_delivery.input_id = root.id AND root_delivery.receipt_json IS NOT NULL
|
|
26
|
+
JOIN native_input_deliveries child_delivery
|
|
27
|
+
ON child_delivery.receipt_json = root_delivery.receipt_json
|
|
28
|
+
JOIN mailbox_inputs child
|
|
29
|
+
ON child.id = child_delivery.input_id AND child.principal_id = root.principal_id;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- One final native response belongs to the turn receipt, even when several
|
|
2
|
+
-- accepted mailbox inputs shared that turn. Keep it beyond mailbox pruning so
|
|
3
|
+
-- a later input can reconcile without replaying the model or external effects.
|
|
4
|
+
CREATE TABLE IF NOT EXISTS native_turn_results (
|
|
5
|
+
receipt_json TEXT NOT NULL,
|
|
6
|
+
principal_id TEXT NOT NULL,
|
|
7
|
+
primary_stimulus_id TEXT NOT NULL,
|
|
8
|
+
result_json TEXT NOT NULL CHECK (json_valid(result_json)),
|
|
9
|
+
created_at INTEGER NOT NULL,
|
|
10
|
+
PRIMARY KEY (receipt_json, principal_id)
|
|
11
|
+
);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
-- 025 rebuilt decisions after 015 installed these triggers. SQLite drops a
|
|
2
|
+
-- table's triggers with that table, leaving the external-content FTS index
|
|
3
|
+
-- readable from decisions but no longer synchronized with new writes.
|
|
4
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS decisions_fts USING fts5(
|
|
5
|
+
topic, decision, reasoning,
|
|
6
|
+
content='decisions',
|
|
7
|
+
content_rowid='rowid'
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
DROP TRIGGER IF EXISTS decisions_ai;
|
|
11
|
+
DROP TRIGGER IF EXISTS decisions_ad;
|
|
12
|
+
DROP TRIGGER IF EXISTS decisions_au;
|
|
13
|
+
DROP TRIGGER IF EXISTS decisions_au2;
|
|
14
|
+
|
|
15
|
+
CREATE TRIGGER decisions_ai AFTER INSERT ON decisions BEGIN
|
|
16
|
+
INSERT INTO decisions_fts(rowid, topic, decision, reasoning)
|
|
17
|
+
VALUES (new.rowid, new.topic, new.decision, new.reasoning);
|
|
18
|
+
END;
|
|
19
|
+
CREATE TRIGGER decisions_ad BEFORE DELETE ON decisions BEGIN
|
|
20
|
+
INSERT INTO decisions_fts(decisions_fts, rowid, topic, decision, reasoning)
|
|
21
|
+
VALUES ('delete', old.rowid, old.topic, old.decision, old.reasoning);
|
|
22
|
+
END;
|
|
23
|
+
CREATE TRIGGER decisions_au BEFORE UPDATE ON decisions BEGIN
|
|
24
|
+
INSERT INTO decisions_fts(decisions_fts, rowid, topic, decision, reasoning)
|
|
25
|
+
VALUES ('delete', old.rowid, old.topic, old.decision, old.reasoning);
|
|
26
|
+
END;
|
|
27
|
+
CREATE TRIGGER decisions_au2 AFTER UPDATE ON decisions BEGIN
|
|
28
|
+
INSERT INTO decisions_fts(rowid, topic, decision, reasoning)
|
|
29
|
+
VALUES (new.rowid, new.topic, new.decision, new.reasoning);
|
|
30
|
+
END;
|
|
31
|
+
|
|
32
|
+
INSERT INTO decisions_fts(decisions_fts) VALUES ('rebuild');
|
|
33
|
+
INSERT OR IGNORE INTO schema_version(version, description)
|
|
34
|
+
VALUES (92, 'Restore decisions FTS synchronization after the table rebuild');
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
-- The reply owner may be a background input, not a messenger message. Preserve
|
|
2
|
+
-- the producer-stated kind beyond mailbox pruning so recovery never invents a
|
|
3
|
+
-- Telegram shared-reply target from a source delta or scheduled turn.
|
|
4
|
+
ALTER TABLE native_turn_results ADD COLUMN primary_kind TEXT
|
|
5
|
+
CHECK (primary_kind IS NULL OR primary_kind IN
|
|
6
|
+
('owner_message', 'source_delta', 'scheduled', 'native_event'));
|
|
7
|
+
|
|
8
|
+
UPDATE native_turn_results
|
|
9
|
+
SET primary_kind = (
|
|
10
|
+
SELECT m.kind FROM mailbox_inputs m
|
|
11
|
+
WHERE m.stimulus_id = native_turn_results.primary_stimulus_id
|
|
12
|
+
AND m.principal_id = native_turn_results.principal_id
|
|
13
|
+
ORDER BY m.id ASC LIMIT 1
|
|
14
|
+
);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- A commitment's current head and each historical revision retain the run and
|
|
2
|
+
-- agent that authored them. Existing rows remain unknown; do not infer origins.
|
|
3
|
+
ALTER TABLE commitments ADD COLUMN agent_id TEXT;
|
|
4
|
+
ALTER TABLE commitments ADD COLUMN model_run_id TEXT;
|
|
5
|
+
ALTER TABLE commitment_assignments ADD COLUMN agent_id TEXT;
|
|
6
|
+
ALTER TABLE commitment_assignments ADD COLUMN model_run_id TEXT;
|
|
7
|
+
|
|
8
|
+
INSERT OR IGNORE INTO schema_version (version, description)
|
|
9
|
+
VALUES (94, 'Commitment run and agent provenance');
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
-- A model run's native invocation ID is the core-owned identity of its first
|
|
2
|
+
-- accepted input. sourceMessageRef may be a product effect occurrence, not the
|
|
3
|
+
-- mailbox stimulus ID. Preserve the old ref join only for historical rows that
|
|
4
|
+
-- predate nativeInputId; never fall back from a stated but unmatched native ID.
|
|
5
|
+
DROP VIEW IF EXISTS model_run_native_inputs;
|
|
6
|
+
CREATE VIEW model_run_native_inputs AS
|
|
7
|
+
SELECT
|
|
8
|
+
mr.model_run_id,
|
|
9
|
+
child.id AS input_id,
|
|
10
|
+
child.stimulus_id,
|
|
11
|
+
child.kind,
|
|
12
|
+
child.principal_id,
|
|
13
|
+
child.channel_key,
|
|
14
|
+
child.occurred_at,
|
|
15
|
+
child.status,
|
|
16
|
+
child_delivery.state AS native_state
|
|
17
|
+
FROM model_runs mr
|
|
18
|
+
JOIN native_input_deliveries root_delivery
|
|
19
|
+
ON root_delivery.input_id = CASE WHEN json_valid(mr.input_refs_json) THEN
|
|
20
|
+
CASE WHEN json_type(mr.input_refs_json, '$.nativeInputId') IS NOT NULL THEN
|
|
21
|
+
(SELECT input_id FROM native_input_deliveries
|
|
22
|
+
WHERE invocation_id = json_extract(mr.input_refs_json, '$.nativeInputId'))
|
|
23
|
+
ELSE
|
|
24
|
+
(SELECT id FROM mailbox_inputs
|
|
25
|
+
WHERE principal_id = json_extract(mr.input_refs_json, '$.principalId')
|
|
26
|
+
AND stimulus_id = json_extract(mr.input_refs_json, '$.sourceMessageRef'))
|
|
27
|
+
END
|
|
28
|
+
ELSE NULL END
|
|
29
|
+
AND root_delivery.receipt_json IS NOT NULL
|
|
30
|
+
JOIN mailbox_inputs root
|
|
31
|
+
ON root.id = root_delivery.input_id
|
|
32
|
+
AND root.principal_id = json_extract(mr.input_refs_json, '$.principalId')
|
|
33
|
+
JOIN native_input_deliveries child_delivery
|
|
34
|
+
ON child_delivery.receipt_json = root_delivery.receipt_json
|
|
35
|
+
JOIN mailbox_inputs child
|
|
36
|
+
ON child.id = child_delivery.input_id AND child.principal_id = root.principal_id;
|
|
37
|
+
|
|
38
|
+
INSERT OR IGNORE INTO schema_version (version, description)
|
|
39
|
+
VALUES (95, 'Model-run cohort follows accepted native input identity');
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- Stored source search scans literal substrings in connector_event_index.
|
|
2
|
+
-- Other core consumers never created this product index, so absence is expected.
|
|
3
|
+
DROP TRIGGER IF EXISTS trg_connector_event_index_ai;
|
|
4
|
+
DROP TRIGGER IF EXISTS trg_connector_event_index_au;
|
|
5
|
+
DROP TRIGGER IF EXISTS trg_connector_event_index_ad;
|
|
6
|
+
DROP TABLE IF EXISTS connector_event_index_fts;
|
|
7
|
+
|
|
8
|
+
INSERT OR IGNORE INTO schema_version (version, description)
|
|
9
|
+
VALUES (96, 'Drop the unused connector event full-text index');
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
-- Each JSON expression must be guarded independently: SQLite may reorder joins.
|
|
2
|
+
DROP VIEW IF EXISTS model_run_native_inputs;
|
|
3
|
+
CREATE VIEW model_run_native_inputs AS
|
|
4
|
+
SELECT
|
|
5
|
+
mr.model_run_id,
|
|
6
|
+
child.id AS input_id,
|
|
7
|
+
child.stimulus_id,
|
|
8
|
+
child.kind,
|
|
9
|
+
child.principal_id,
|
|
10
|
+
child.channel_key,
|
|
11
|
+
child.occurred_at,
|
|
12
|
+
child.status,
|
|
13
|
+
child_delivery.state AS native_state
|
|
14
|
+
FROM model_runs mr
|
|
15
|
+
JOIN native_input_deliveries root_delivery
|
|
16
|
+
ON root_delivery.input_id = CASE WHEN json_valid(mr.input_refs_json) THEN
|
|
17
|
+
CASE WHEN json_type(mr.input_refs_json, '$.nativeInputId') IS NOT NULL THEN
|
|
18
|
+
(SELECT input_id FROM native_input_deliveries
|
|
19
|
+
WHERE invocation_id = json_extract(mr.input_refs_json, '$.nativeInputId'))
|
|
20
|
+
ELSE
|
|
21
|
+
(SELECT id FROM mailbox_inputs
|
|
22
|
+
WHERE principal_id = json_extract(mr.input_refs_json, '$.principalId')
|
|
23
|
+
AND stimulus_id = json_extract(mr.input_refs_json, '$.sourceMessageRef'))
|
|
24
|
+
END
|
|
25
|
+
ELSE NULL END
|
|
26
|
+
AND root_delivery.receipt_json IS NOT NULL
|
|
27
|
+
JOIN mailbox_inputs root
|
|
28
|
+
ON root.id = root_delivery.input_id
|
|
29
|
+
AND root.principal_id = CASE WHEN json_valid(mr.input_refs_json)
|
|
30
|
+
THEN json_extract(mr.input_refs_json, '$.principalId') ELSE NULL END
|
|
31
|
+
JOIN native_input_deliveries child_delivery
|
|
32
|
+
ON child_delivery.receipt_json = root_delivery.receipt_json
|
|
33
|
+
JOIN mailbox_inputs child
|
|
34
|
+
ON child.id = child_delivery.input_id AND child.principal_id = root.principal_id;
|
|
35
|
+
|
|
36
|
+
INSERT OR IGNORE INTO schema_version (version, description)
|
|
37
|
+
VALUES (97, 'Guard native input view joins against malformed historical JSON');
|