@jungjaehoon/mama-core 2.4.1 → 4.1.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/db/migrations/099-commitment-revision-graph.sql +2 -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 +1985 -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/commitment-revision-migration.d.ts +4 -0
- package/dist/knowledge/commitment-revision-migration.js +50 -0
- package/dist/knowledge/commitments.d.ts +192 -0
- package/dist/knowledge/commitments.js +386 -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/judgment-edge.d.ts +6 -0
- package/dist/knowledge/judgment-edge.js +22 -0
- package/dist/knowledge/judgments.d.ts +118 -0
- package/dist/knowledge/judgments.js +802 -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 +152 -0
- package/dist/runtime/drivers/claude-cli-wrapper.js +375 -0
- package/dist/runtime/drivers/claude-effort.d.ts +4 -0
- package/dist/runtime/drivers/claude-effort.js +16 -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 +425 -0
- package/dist/runtime/drivers/persistent-cli-process.js +1529 -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,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_QUESTION_VOCABULARY = exports.QUESTION_TYPES = void 0;
|
|
4
|
+
exports.declareQuestionVocabulary = declareQuestionVocabulary;
|
|
5
|
+
exports.resetQuestionVocabulary = resetQuestionVocabulary;
|
|
6
|
+
exports.classifyQuestionType = classifyQuestionType;
|
|
7
|
+
exports.isQuestionType = isQuestionType;
|
|
8
|
+
exports.QUESTION_TYPES = [
|
|
9
|
+
'correction',
|
|
10
|
+
'artifact',
|
|
11
|
+
'timeline',
|
|
12
|
+
'status',
|
|
13
|
+
'decision_reason',
|
|
14
|
+
'how_to',
|
|
15
|
+
'unknown',
|
|
16
|
+
];
|
|
17
|
+
// Korean: patterns for classifyQuestionType() multilingual query routing.
|
|
18
|
+
// A language is not a product: these words name no deployment, no connector and no
|
|
19
|
+
// package. Domain words belong in a caller's vocabulary, not here.
|
|
20
|
+
exports.DEFAULT_QUESTION_VOCABULARY = [
|
|
21
|
+
{
|
|
22
|
+
type: 'correction',
|
|
23
|
+
pattern: /\b(fix|revert|correct|correction|supersede|superseded|revise|revision)\b|수정|되돌|정정|교정/i,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: 'artifact',
|
|
27
|
+
pattern: /\b(file|doc|docs|document|image|video|pdf|attachment|artifact)\b|파일|문서|이미지|영상|첨부/i,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: 'timeline',
|
|
31
|
+
pattern: /\b(when|history|before|after|around|timeline|chronology)\b|언제|이력|히스토리|(?:^|\s)(?:전|후)(?=$|\s|[?.!,]|에|의|로|부터|까지|는|를|가|와|도)|즈음|\bon\s+\d{4}(?:-\d{1,2})?(?:-\d{1,2})?\b|\b\d{4}-\d{1,2}-\d{1,2}\b/i,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: 'status',
|
|
35
|
+
pattern: /\b(status|state|current|currently|now|latest|progress|blocked|done)\b|상태|현재|최신|진행|진척/i,
|
|
36
|
+
},
|
|
37
|
+
{ type: 'decision_reason', pattern: /\b(why|reason|because|rationale)\b|근거|이유|왜|때문/i },
|
|
38
|
+
{
|
|
39
|
+
type: 'how_to',
|
|
40
|
+
pattern: /\b(how\s+to|how\s+do|setup|set\s+up|configure|configuration|install)\b|설정|구성|어떻게/i,
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
let vocabulary = exports.DEFAULT_QUESTION_VOCABULARY;
|
|
44
|
+
/**
|
|
45
|
+
* Declare the words this deployment asks questions with. Call once, at boot.
|
|
46
|
+
*
|
|
47
|
+
* Replaces the default outright rather than merging: a caller that wants the general
|
|
48
|
+
* words plus its own spreads DEFAULT_QUESTION_VOCABULARY itself, and can see in one
|
|
49
|
+
* place what its classifier actually knows.
|
|
50
|
+
*/
|
|
51
|
+
function declareQuestionVocabulary(next) {
|
|
52
|
+
vocabulary = next;
|
|
53
|
+
}
|
|
54
|
+
/** Restore the default. For tests that declared their own. */
|
|
55
|
+
function resetQuestionVocabulary() {
|
|
56
|
+
vocabulary = exports.DEFAULT_QUESTION_VOCABULARY;
|
|
57
|
+
}
|
|
58
|
+
function classifyQuestionType(query) {
|
|
59
|
+
const normalized = query.trim();
|
|
60
|
+
for (const entry of vocabulary) {
|
|
61
|
+
if (entry.pattern.test(normalized)) {
|
|
62
|
+
return entry.type;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return 'unknown';
|
|
66
|
+
}
|
|
67
|
+
function isQuestionType(value) {
|
|
68
|
+
return exports.QUESTION_TYPES.includes(value);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=question-type.js.map
|
|
@@ -22,7 +22,6 @@ export interface SearchHitDiagnostics {
|
|
|
22
22
|
retrieval_source: string;
|
|
23
23
|
vector_similarity: number | null;
|
|
24
24
|
lexical_support: boolean;
|
|
25
|
-
entity_support: boolean;
|
|
26
25
|
scope_support: boolean;
|
|
27
26
|
graph_source: 'primary' | 'expanded' | null;
|
|
28
27
|
is_vector_only: boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knowledge search: what the corpus can be asked for by meaning and by word.
|
|
3
|
+
*
|
|
4
|
+
* Both functions take the adapter they read through, so a caller cannot run a
|
|
5
|
+
* search against a database it did not open.
|
|
6
|
+
*
|
|
7
|
+
* @module knowledge/search
|
|
8
|
+
*/
|
|
9
|
+
import type { DatabaseInstance, DecisionRecord } from '../db-manager.js';
|
|
10
|
+
import type { MemoryKindFilter } from '../memory/types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Brute-force cosine similarity search over stored embeddings.
|
|
13
|
+
*
|
|
14
|
+
* Errors are not swallowed: an empty array means the corpus held nothing above
|
|
15
|
+
* `threshold`, never that the search failed.
|
|
16
|
+
*
|
|
17
|
+
* @param adapter - Database to read through
|
|
18
|
+
* @param queryEmbedding - Query embedding (1024-dim)
|
|
19
|
+
* @param limit - Max results to return
|
|
20
|
+
* @param threshold - Minimum similarity
|
|
21
|
+
* @param topicPrefix - Optional topic prefix pre-filter
|
|
22
|
+
* @param excludeStatuses - Optional decision statuses to pre-filter out
|
|
23
|
+
* @param kind - Optional memory kind pre-filter
|
|
24
|
+
*/
|
|
25
|
+
export declare function vectorSearch(adapter: DatabaseInstance, queryEmbedding: Float32Array | number[], limit?: number, threshold?: number, topicPrefix?: string, excludeStatuses?: readonly string[], kind?: MemoryKindFilter): Promise<DecisionRecord[]>;
|
|
26
|
+
/**
|
|
27
|
+
* FTS5 keyword search on the decisions table.
|
|
28
|
+
*
|
|
29
|
+
* @param adapter - Database to read through
|
|
30
|
+
* @param query - FTS5 MATCH expression
|
|
31
|
+
* @param limit - Max rows to return
|
|
32
|
+
* @returns Matching decision IDs with BM25 rank scores
|
|
33
|
+
*/
|
|
34
|
+
export declare function fts5Search(adapter: DatabaseInstance, query: string, limit?: number, kind?: MemoryKindFilter): Promise<{
|
|
35
|
+
id: string;
|
|
36
|
+
rank: number;
|
|
37
|
+
}[]>;
|
|
38
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Knowledge search: what the corpus can be asked for by meaning and by word.
|
|
4
|
+
*
|
|
5
|
+
* Both functions take the adapter they read through, so a caller cannot run a
|
|
6
|
+
* search against a database it did not open.
|
|
7
|
+
*
|
|
8
|
+
* @module knowledge/search
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.vectorSearch = vectorSearch;
|
|
12
|
+
exports.fts5Search = fts5Search;
|
|
13
|
+
/**
|
|
14
|
+
* Brute-force cosine similarity search over stored embeddings.
|
|
15
|
+
*
|
|
16
|
+
* Errors are not swallowed: an empty array means the corpus held nothing above
|
|
17
|
+
* `threshold`, never that the search failed.
|
|
18
|
+
*
|
|
19
|
+
* @param adapter - Database to read through
|
|
20
|
+
* @param queryEmbedding - Query embedding (1024-dim)
|
|
21
|
+
* @param limit - Max results to return
|
|
22
|
+
* @param threshold - Minimum similarity
|
|
23
|
+
* @param topicPrefix - Optional topic prefix pre-filter
|
|
24
|
+
* @param excludeStatuses - Optional decision statuses to pre-filter out
|
|
25
|
+
* @param kind - Optional memory kind pre-filter
|
|
26
|
+
*/
|
|
27
|
+
async function vectorSearch(adapter, queryEmbedding, limit = 5, threshold = 0.7, topicPrefix, excludeStatuses, kind) {
|
|
28
|
+
const results = await adapter.vectorSearch(queryEmbedding, limit * 3, topicPrefix, excludeStatuses, kind);
|
|
29
|
+
if (!results || results.length === 0) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
const stmt = adapter.prepare(`SELECT * FROM decisions WHERE rowid = ?`);
|
|
33
|
+
const decisions = [];
|
|
34
|
+
for (const row of results) {
|
|
35
|
+
const decision = stmt.get(row.rowid);
|
|
36
|
+
if (!decision) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const similarity = row.similarity ?? Math.max(0, 1.0 - (row.distance ?? 1));
|
|
40
|
+
const distance = row.distance ?? Math.max(0, 1.0 - similarity);
|
|
41
|
+
if (similarity >= threshold) {
|
|
42
|
+
decisions.push({
|
|
43
|
+
...decision,
|
|
44
|
+
distance,
|
|
45
|
+
similarity,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (decisions.length >= limit) {
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return decisions;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* FTS5 keyword search on the decisions table.
|
|
56
|
+
*
|
|
57
|
+
* @param adapter - Database to read through
|
|
58
|
+
* @param query - FTS5 MATCH expression
|
|
59
|
+
* @param limit - Max rows to return
|
|
60
|
+
* @returns Matching decision IDs with BM25 rank scores
|
|
61
|
+
*/
|
|
62
|
+
async function fts5Search(adapter, query, limit = 10, kind) {
|
|
63
|
+
// An absent FTS table is a real answer - no rows. A failing adapter is not,
|
|
64
|
+
// so this lookup is left unguarded and its errors reach the caller.
|
|
65
|
+
const tableCheck = adapter
|
|
66
|
+
.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='decisions_fts'")
|
|
67
|
+
.get();
|
|
68
|
+
if (!tableCheck)
|
|
69
|
+
return [];
|
|
70
|
+
// Query execution - let errors propagate to the caller
|
|
71
|
+
const kindClause = Array.isArray(kind)
|
|
72
|
+
? `AND d.kind IN (${kind.map(() => '?').join(', ')})`
|
|
73
|
+
: kind === undefined
|
|
74
|
+
? ''
|
|
75
|
+
: 'AND d.kind = ?';
|
|
76
|
+
const stmt = adapter.prepare(`
|
|
77
|
+
SELECT d.id, rank
|
|
78
|
+
FROM decisions_fts
|
|
79
|
+
JOIN decisions d ON decisions_fts.rowid = d.rowid
|
|
80
|
+
WHERE decisions_fts MATCH ?
|
|
81
|
+
${kindClause}
|
|
82
|
+
ORDER BY rank
|
|
83
|
+
LIMIT ?
|
|
84
|
+
`);
|
|
85
|
+
return (Array.isArray(kind)
|
|
86
|
+
? stmt.all(query, ...kind, limit)
|
|
87
|
+
: kind === undefined
|
|
88
|
+
? stmt.all(query, limit)
|
|
89
|
+
: stmt.all(query, kind, limit));
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { DatabaseAdapter } from '../db-manager.js';
|
|
2
|
+
import type { JsonValue } from '../memory/judgment-types.js';
|
|
3
|
+
import type { MemoryEventRecord, MemoryScopeRef } from '../memory/types.js';
|
|
4
|
+
import { type JudgmentAccess } from './judgments.js';
|
|
5
|
+
/**
|
|
6
|
+
* `source.ingest` — the raw-evidence half of the command boundary.
|
|
7
|
+
*
|
|
8
|
+
* One command stores exactly one immutable `observation_versions` row plus its
|
|
9
|
+
* provenance event. Observations are evidence, not judgments: no decisions row
|
|
10
|
+
* is created, no edges are inferred, and nothing is extracted. The command id
|
|
11
|
+
* binds the request through `command_bindings` so a retried ingest replays the
|
|
12
|
+
* recorded receipt instead of writing a second observation.
|
|
13
|
+
*/
|
|
14
|
+
export interface SourceIngestCommand {
|
|
15
|
+
/** Idempotency key. A repeated id replays the stored receipt; the same id
|
|
16
|
+
* bound to different content fails with COMMAND_CONFLICT. */
|
|
17
|
+
commandId: string;
|
|
18
|
+
/** Producing connector and the source-side identity of what was captured. */
|
|
19
|
+
source: {
|
|
20
|
+
connector: string;
|
|
21
|
+
id: string;
|
|
22
|
+
};
|
|
23
|
+
producerVersionId?: string | null;
|
|
24
|
+
/** The raw payload as observed. Never rewritten or summarized. */
|
|
25
|
+
body: string;
|
|
26
|
+
author?: string | null;
|
|
27
|
+
/** Source-side event time (ms epoch) when known. */
|
|
28
|
+
sourceAt?: number | null;
|
|
29
|
+
/** Capture time (ms epoch); defaults to commit time. */
|
|
30
|
+
observedAt?: number;
|
|
31
|
+
/** sha256 of body when omitted. */
|
|
32
|
+
contentHash?: string;
|
|
33
|
+
metadata?: Record<string, JsonValue>;
|
|
34
|
+
/** Free-form scope metadata persisted on the observation row. */
|
|
35
|
+
scope?: Record<string, JsonValue>;
|
|
36
|
+
/**
|
|
37
|
+
* Memory scopes this ingest is bound to. An explicit `[]` stores an unscoped
|
|
38
|
+
* observation; an omitted field inherits the access scope.
|
|
39
|
+
*/
|
|
40
|
+
scopes?: MemoryScopeRef[];
|
|
41
|
+
/** Provenance metadata for the observation's memory_events row. */
|
|
42
|
+
event?: {
|
|
43
|
+
eventType?: MemoryEventRecord['event_type'];
|
|
44
|
+
actor?: MemoryEventRecord['actor'];
|
|
45
|
+
sourceTurnId?: string;
|
|
46
|
+
reason?: string;
|
|
47
|
+
evidenceRefs?: string[];
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export interface SourceIngestReceipt {
|
|
51
|
+
status: 'committed';
|
|
52
|
+
commandId: string;
|
|
53
|
+
observationId: string;
|
|
54
|
+
eventId: string;
|
|
55
|
+
watermark: number;
|
|
56
|
+
diagnostics: Array<{
|
|
57
|
+
stage: string;
|
|
58
|
+
code: string;
|
|
59
|
+
message: string;
|
|
60
|
+
}>;
|
|
61
|
+
}
|
|
62
|
+
export declare function ingestSource(command: SourceIngestCommand, access: JudgmentAccess, options: {
|
|
63
|
+
adapter: DatabaseAdapter;
|
|
64
|
+
}): Promise<SourceIngestReceipt>;
|
|
65
|
+
//# sourceMappingURL=source-ingest.d.ts.map
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ingestSource = ingestSource;
|
|
7
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
8
|
+
const canonicalize_js_1 = require("../canonicalize.js");
|
|
9
|
+
const observations_js_1 = require("../knowledge/observations.js");
|
|
10
|
+
const event_store_js_1 = require("../memory/event-store.js");
|
|
11
|
+
const judgments_js_1 = require("./judgments.js");
|
|
12
|
+
function requireNonblank(value, field) {
|
|
13
|
+
if (typeof value !== 'string' || value.trim() === '') {
|
|
14
|
+
throw new judgments_js_1.JudgmentError('INVALID_COMMAND', `${field} must be nonblank`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function commandHash(command) {
|
|
18
|
+
return node_crypto_1.default.createHash('sha256').update((0, canonicalize_js_1.canonicalizeJSON)(command)).digest('hex');
|
|
19
|
+
}
|
|
20
|
+
function parseReceipt(value) {
|
|
21
|
+
let parsed;
|
|
22
|
+
try {
|
|
23
|
+
parsed = JSON.parse(value);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
throw new Error('source_commands.receipt_json is malformed', { cause: error });
|
|
27
|
+
}
|
|
28
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
29
|
+
throw new Error('source_commands.receipt_json must contain an object');
|
|
30
|
+
}
|
|
31
|
+
return parsed;
|
|
32
|
+
}
|
|
33
|
+
function assertReplay(adapter, command, access, hash) {
|
|
34
|
+
const binding = adapter
|
|
35
|
+
.prepare('SELECT principal_id, action, payload_hash, receipt_key FROM command_bindings WHERE command_id = ?')
|
|
36
|
+
.get(command.commandId);
|
|
37
|
+
if (!binding)
|
|
38
|
+
return null;
|
|
39
|
+
if (binding.principal_id !== access.principalId ||
|
|
40
|
+
binding.action !== 'source.ingest' ||
|
|
41
|
+
binding.payload_hash !== hash) {
|
|
42
|
+
throw new judgments_js_1.JudgmentError('COMMAND_CONFLICT', 'The command id is already bound to another request');
|
|
43
|
+
}
|
|
44
|
+
const row = adapter
|
|
45
|
+
.prepare('SELECT receipt_json FROM source_commands WHERE command_id = ?')
|
|
46
|
+
.get(command.commandId);
|
|
47
|
+
if (!row) {
|
|
48
|
+
throw new Error('Command binding has no source ingest receipt');
|
|
49
|
+
}
|
|
50
|
+
return parseReceipt(row.receipt_json);
|
|
51
|
+
}
|
|
52
|
+
async function ingestSourceOnAdapter(adapter, command, access) {
|
|
53
|
+
requireNonblank(command.commandId, 'commandId');
|
|
54
|
+
requireNonblank(command.source?.connector, 'source.connector');
|
|
55
|
+
requireNonblank(command.source?.id, 'source.id');
|
|
56
|
+
requireNonblank(command.body, 'body');
|
|
57
|
+
requireNonblank(access.principalId, 'principalId');
|
|
58
|
+
requireNonblank(access.agentId, 'agentId');
|
|
59
|
+
if (command.sourceAt !== undefined &&
|
|
60
|
+
command.sourceAt !== null &&
|
|
61
|
+
(!Number.isFinite(command.sourceAt) || command.sourceAt < 0)) {
|
|
62
|
+
throw new judgments_js_1.JudgmentError('INVALID_TIME', 'sourceAt must be a finite nonnegative epoch');
|
|
63
|
+
}
|
|
64
|
+
if (command.observedAt !== undefined &&
|
|
65
|
+
(!Number.isFinite(command.observedAt) || command.observedAt < 0)) {
|
|
66
|
+
throw new judgments_js_1.JudgmentError('INVALID_TIME', 'observedAt must be a finite nonnegative epoch');
|
|
67
|
+
}
|
|
68
|
+
// Admission is validated before any write: every scope the command claims
|
|
69
|
+
// must already be inside the caller's admitted access.
|
|
70
|
+
(0, judgments_js_1.admittedScopeIds)(access);
|
|
71
|
+
const boundScopes = (0, judgments_js_1.boundScopeIdsFor)(access, command);
|
|
72
|
+
const effectiveScopes = command.scopes ?? [...access.scopes];
|
|
73
|
+
const effectiveCommand = command.scopes
|
|
74
|
+
? command
|
|
75
|
+
: { ...command, scopes: [...access.scopes] };
|
|
76
|
+
const hash = commandHash(effectiveCommand);
|
|
77
|
+
const replay = assertReplay(adapter, command, access, hash);
|
|
78
|
+
if (replay) {
|
|
79
|
+
return replay;
|
|
80
|
+
}
|
|
81
|
+
const observedAt = command.observedAt ?? Date.now();
|
|
82
|
+
const contentHash = command.contentHash ?? node_crypto_1.default.createHash('sha256').update(command.body).digest('hex');
|
|
83
|
+
const observationInput = {
|
|
84
|
+
source: command.source.connector,
|
|
85
|
+
sourceId: command.source.id,
|
|
86
|
+
producerVersionId: command.producerVersionId ?? null,
|
|
87
|
+
body: command.body,
|
|
88
|
+
author: command.author ?? null,
|
|
89
|
+
sourceAt: command.sourceAt ?? null,
|
|
90
|
+
observedAt,
|
|
91
|
+
contentHash,
|
|
92
|
+
metadata: command.metadata ?? {},
|
|
93
|
+
scope: {
|
|
94
|
+
...(command.scope ?? {}),
|
|
95
|
+
scopes: boundScopes.map((scopeId, index) => ({
|
|
96
|
+
scopeId,
|
|
97
|
+
kind: effectiveScopes[index]?.kind,
|
|
98
|
+
externalId: effectiveScopes[index]?.id,
|
|
99
|
+
primary: index === 0,
|
|
100
|
+
})),
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
const boundObservationId = (0, observations_js_1.observationVersionId)(observationInput);
|
|
104
|
+
let replayedReceipt = null;
|
|
105
|
+
let committed = null;
|
|
106
|
+
const now = Date.now();
|
|
107
|
+
const transaction = adapter.transactionImmediate
|
|
108
|
+
? adapter.transactionImmediate.bind(adapter)
|
|
109
|
+
: adapter.transaction.bind(adapter);
|
|
110
|
+
transaction(() => {
|
|
111
|
+
const bindingResult = adapter
|
|
112
|
+
.prepare(`INSERT OR IGNORE INTO command_bindings
|
|
113
|
+
(command_id, principal_id, action, payload_hash, receipt_kind, receipt_key, created_at)
|
|
114
|
+
VALUES (?, ?, 'source.ingest', ?, 'observation', ?, ?)`)
|
|
115
|
+
.run(command.commandId, access.principalId, hash, boundObservationId, now);
|
|
116
|
+
if (bindingResult.changes === 0) {
|
|
117
|
+
replayedReceipt = assertReplay(adapter, command, access, hash);
|
|
118
|
+
if (!replayedReceipt) {
|
|
119
|
+
throw new Error('Command binding was not readable after a conflict-free insert');
|
|
120
|
+
}
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const observation = (0, observations_js_1.appendObservationVersion)(adapter, observationInput);
|
|
124
|
+
const eventId = (0, event_store_js_1.insertMemoryEventInTransaction)(adapter, {
|
|
125
|
+
event_type: command.event?.eventType ?? 'observed_conversation',
|
|
126
|
+
actor: command.event?.actor ?? `actor:${access.principalId}`,
|
|
127
|
+
source_turn_id: command.event?.sourceTurnId,
|
|
128
|
+
memory_id: observation.observationId,
|
|
129
|
+
topic: command.source.id,
|
|
130
|
+
scope_refs: effectiveScopes,
|
|
131
|
+
evidence_refs: command.event?.evidenceRefs,
|
|
132
|
+
reason: command.event?.reason ?? 'source ingest command',
|
|
133
|
+
created_at: observedAt,
|
|
134
|
+
});
|
|
135
|
+
const receipt = {
|
|
136
|
+
status: 'committed',
|
|
137
|
+
commandId: command.commandId,
|
|
138
|
+
observationId: observation.observationId,
|
|
139
|
+
eventId,
|
|
140
|
+
watermark: now,
|
|
141
|
+
diagnostics: [],
|
|
142
|
+
};
|
|
143
|
+
adapter
|
|
144
|
+
.prepare(`INSERT INTO source_commands
|
|
145
|
+
(command_id, observation_id, event_id, committed_watermark, receipt_json, created_at)
|
|
146
|
+
VALUES (?, ?, ?, ?, ?, ?)`)
|
|
147
|
+
.run(command.commandId, observation.observationId, eventId, receipt.watermark, (0, canonicalize_js_1.canonicalizeJSON)(receipt), now);
|
|
148
|
+
committed = { observationId: observation.observationId, eventId };
|
|
149
|
+
});
|
|
150
|
+
if (replayedReceipt) {
|
|
151
|
+
return replayedReceipt;
|
|
152
|
+
}
|
|
153
|
+
if (!committed) {
|
|
154
|
+
throw new Error('source.ingest committed no observation');
|
|
155
|
+
}
|
|
156
|
+
const committedRef = committed;
|
|
157
|
+
return {
|
|
158
|
+
status: 'committed',
|
|
159
|
+
commandId: command.commandId,
|
|
160
|
+
observationId: committedRef.observationId,
|
|
161
|
+
eventId: committedRef.eventId,
|
|
162
|
+
watermark: now,
|
|
163
|
+
diagnostics: [],
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
async function ingestSource(command, access, options) {
|
|
167
|
+
// The ingest boundary no longer reaches the process-global store: the
|
|
168
|
+
// caller names the database this observation commits to.
|
|
169
|
+
if (!options?.adapter) {
|
|
170
|
+
throw new judgments_js_1.JudgmentError('INVALID_COMMAND', 'ingestSource requires an explicit adapter; the process-global store is not a write path');
|
|
171
|
+
}
|
|
172
|
+
return ingestSourceOnAdapter(options.adapter, command, access);
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=source-ingest.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Buffer } from 'node:buffer';
|
|
2
|
-
export declare const TWIN_REF_KINDS: readonly ["memory", "case", "
|
|
2
|
+
export declare const TWIN_REF_KINDS: readonly ["memory", "case", "report", "edge", "raw", "registry", "observation"];
|
|
3
3
|
export type TwinRefKind = (typeof TWIN_REF_KINDS)[number];
|
|
4
4
|
export declare const TWIN_EDGE_SOURCES: readonly ["agent", "human", "code"];
|
|
5
5
|
export type TwinEdgeSource = (typeof TWIN_EDGE_SOURCES)[number];
|
|
6
|
-
export declare const TWIN_EDGE_TYPES: readonly ["supersedes", "builds_on", "debates", "synthesizes", "mentions", "derived_from", "case_member", "alias_of", "next_action_for", "blocks"];
|
|
6
|
+
export declare const TWIN_EDGE_TYPES: readonly ["supersedes", "refines", "contradicts", "builds_on", "debates", "synthesizes", "mentions", "derived_from", "case_member", "alias_of", "next_action_for", "blocks", "amends"];
|
|
7
7
|
export type TwinEdgeType = (typeof TWIN_EDGE_TYPES)[number];
|
|
8
8
|
export type TwinRef = {
|
|
9
9
|
[Kind in TwinRefKind]: {
|
|
@@ -15,7 +15,11 @@ export type TwinEdgeSubjectRef = Exclude<TwinRef, {
|
|
|
15
15
|
kind: 'raw';
|
|
16
16
|
}>;
|
|
17
17
|
export interface TwinScopeRef {
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* The consumer's word for what kind of scope this is. The core matches it; it
|
|
20
|
+
* does not read it. Closed lists of kinds used to live here, in three copies.
|
|
21
|
+
*/
|
|
22
|
+
kind: string;
|
|
19
23
|
id: string;
|
|
20
24
|
}
|
|
21
25
|
export interface TwinProjectRef {
|
|
@@ -23,12 +27,18 @@ export interface TwinProjectRef {
|
|
|
23
27
|
id: string;
|
|
24
28
|
}
|
|
25
29
|
export interface TwinVisibility {
|
|
30
|
+
principalId?: string;
|
|
31
|
+
agentId?: string;
|
|
26
32
|
scopes?: TwinScopeRef[];
|
|
27
33
|
connectors?: string[];
|
|
34
|
+
/** Host-stated connector-wide stored read, such as the configured owner has on source.read. */
|
|
35
|
+
connectorWideRead?: string[];
|
|
28
36
|
projectRefs?: TwinProjectRef[];
|
|
29
37
|
tenantId?: string | null;
|
|
30
38
|
startMs?: number | null;
|
|
31
39
|
asOfMs?: number | null;
|
|
40
|
+
/** Inclusive source/event-time ceiling for replay raw reads. */
|
|
41
|
+
maxSourceMs?: number | null;
|
|
32
42
|
/**
|
|
33
43
|
* Which channels of each connector may be read. When present it DECIDES raw visibility
|
|
34
44
|
* here exactly as it does in the reader, so a ref reached through an edge or named as a
|
|
@@ -36,6 +46,13 @@ export interface TwinVisibility {
|
|
|
36
46
|
* caller could reach past the read path by citing what it could not have read.
|
|
37
47
|
*/
|
|
38
48
|
channels?: Record<string, readonly string[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Read replaced records as history: lifts the superseded/superseded_by
|
|
51
|
+
* retirement check while every other rule — scope, connector, channel,
|
|
52
|
+
* tenant, time window — still applies. Quarantined, contradicted and stale
|
|
53
|
+
* records stay excluded in every mode; they are holds, not history.
|
|
54
|
+
*/
|
|
55
|
+
includeReplaced?: boolean;
|
|
39
56
|
}
|
|
40
57
|
export interface InsertTwinEdgeInput {
|
|
41
58
|
edge_id?: string;
|
|
@@ -57,6 +74,16 @@ export interface InsertTwinEdgeInput {
|
|
|
57
74
|
reason_text?: string;
|
|
58
75
|
evidence_refs?: unknown;
|
|
59
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* One fully resolved twin_edges row to write. Callers own edge_id, content_hash,
|
|
79
|
+
* and created_at because each write path derives them differently (deterministic
|
|
80
|
+
* command hashes vs fresh UUIDs); the writer owns the INSERT itself.
|
|
81
|
+
*/
|
|
82
|
+
export interface TwinEdgeInsert extends InsertTwinEdgeInput {
|
|
83
|
+
edge_id: string;
|
|
84
|
+
content_hash: Buffer;
|
|
85
|
+
created_at: number;
|
|
86
|
+
}
|
|
60
87
|
export interface TwinEdgeRecord {
|
|
61
88
|
edge_id: string;
|
|
62
89
|
edge_type: TwinEdgeType;
|
|
@@ -95,4 +122,4 @@ export interface ListVisibleTwinEdgesOptions {
|
|
|
95
122
|
* cannot silently drop the grant - it crossed this seam as an undeclared property. */
|
|
96
123
|
channels?: Record<string, readonly string[]>;
|
|
97
124
|
}
|
|
98
|
-
//# sourceMappingURL=types.d.ts.map
|
|
125
|
+
//# sourceMappingURL=twin-edge-types.d.ts.map
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TWIN_EDGE_TYPES = exports.TWIN_EDGE_SOURCES = exports.TWIN_REF_KINDS = void 0;
|
|
4
|
-
exports.TWIN_REF_KINDS = [
|
|
4
|
+
exports.TWIN_REF_KINDS = [
|
|
5
|
+
'memory',
|
|
6
|
+
'case',
|
|
7
|
+
'report',
|
|
8
|
+
'edge',
|
|
9
|
+
'raw',
|
|
10
|
+
'registry',
|
|
11
|
+
'observation',
|
|
12
|
+
];
|
|
5
13
|
exports.TWIN_EDGE_SOURCES = ['agent', 'human', 'code'];
|
|
6
14
|
exports.TWIN_EDGE_TYPES = [
|
|
7
15
|
'supersedes',
|
|
16
|
+
'refines',
|
|
17
|
+
'contradicts',
|
|
8
18
|
'builds_on',
|
|
9
19
|
'debates',
|
|
10
20
|
'synthesizes',
|
|
@@ -14,5 +24,6 @@ exports.TWIN_EDGE_TYPES = [
|
|
|
14
24
|
'alias_of',
|
|
15
25
|
'next_action_for',
|
|
16
26
|
'blocks',
|
|
27
|
+
'amends',
|
|
17
28
|
];
|
|
18
|
-
//# sourceMappingURL=types.js.map
|
|
29
|
+
//# sourceMappingURL=twin-edge-types.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The grammar of the OwnerWorkPatch date fields.
|
|
3
|
+
*
|
|
4
|
+
* A patch can state a deadline two ways: `dueAt` is an exact instant (RFC 3339
|
|
5
|
+
* with an explicit offset) and `deadline` is a bare calendar date. Readers fold
|
|
6
|
+
* the patch and parse both fields strictly, so a malformed value committed here
|
|
7
|
+
* makes the whole row unreadable. The writers validate before commit rather
|
|
8
|
+
* than letting a strict read discover the damage at boot.
|
|
9
|
+
*
|
|
10
|
+
* This module owns the field grammar only. Zone arithmetic — which local date
|
|
11
|
+
* an instant lands on, where a deadline day starts — belongs to the product's
|
|
12
|
+
* board projection, not the commitment log.
|
|
13
|
+
*
|
|
14
|
+
* @module knowledge/work-dates
|
|
15
|
+
*/
|
|
16
|
+
import type { OwnerWorkPatch } from '../memory/judgment-types.js';
|
|
17
|
+
export declare const WORK_PATCH_DUE_AT_PATTERN: string;
|
|
18
|
+
export declare const WORK_PATCH_DEADLINE_PATTERN: string;
|
|
19
|
+
export interface ParsedExactDueAt {
|
|
20
|
+
dueAt: number;
|
|
21
|
+
deadline: string;
|
|
22
|
+
offsetMinutes: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Parse a `dueAt` value: an RFC 3339 timestamp with an explicit offset.
|
|
26
|
+
*
|
|
27
|
+
* A bare date is not an instant and a bare instant without an offset does not
|
|
28
|
+
* say where midnight falls, so neither is accepted - the caller states the
|
|
29
|
+
* offset it means.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseExactDueAt(value: string): ParsedExactDueAt;
|
|
32
|
+
/**
|
|
33
|
+
* Reject a `deadline` value that is not a real calendar date.
|
|
34
|
+
*
|
|
35
|
+
* `2026-02-30` matches the date pattern but is not a day that exists, and a
|
|
36
|
+
* reader that computes the start of that day has no honest answer for it.
|
|
37
|
+
*/
|
|
38
|
+
export declare function assertIsoDate(value: string, field: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* Reject a work patch whose declared date fields cannot be read back.
|
|
41
|
+
*
|
|
42
|
+
* `null` is an absent statement, not a malformed one - the fold reads it as the
|
|
43
|
+
* field cleared. A non-null value must be a well-formed string of its grammar.
|
|
44
|
+
* What the fields mean together (whether `dueAt` and `deadline` may disagree)
|
|
45
|
+
* is the board's contract, not the log's: this checks only that each stated
|
|
46
|
+
* value parses.
|
|
47
|
+
*/
|
|
48
|
+
export declare function assertWorkPatchValues(set: OwnerWorkPatch): void;
|
|
49
|
+
//# sourceMappingURL=work-dates.d.ts.map
|