@remnic/core 9.3.712 → 9.3.714
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/dist/access-boundary.d.ts +6 -6
- package/dist/access-boundary.js +17 -16
- package/dist/access-cli.js +40 -39
- package/dist/access-cli.js.map +1 -1
- package/dist/access-http.d.ts +5 -5
- package/dist/access-http.js +24 -23
- package/dist/access-mcp.d.ts +18 -5
- package/dist/access-mcp.js +21 -20
- package/dist/access-operations-batch.js +18 -17
- package/dist/access-operations.d.ts +6 -5
- package/dist/access-operations.js +20 -19
- package/dist/access-schema.d.ts +10 -0
- package/dist/access-schema.js +1 -1
- package/dist/{access-service-Dx2rSJjH.d.ts → access-service-lddjZoRh.d.ts} +20 -5
- package/dist/access-service.d.ts +5 -5
- package/dist/access-service.js +16 -15
- package/dist/access-surface-catalog.d.ts +5 -5
- package/dist/access-surface-catalog.js +6 -1
- package/dist/access-surface-catalog.js.map +1 -1
- package/dist/action-confidence.d.ts +1 -1
- package/dist/active-memory-bridge.d.ts +3 -1
- package/dist/active-memory-bridge.js +2 -1
- package/dist/active-recall.d.ts +1 -1
- package/dist/active-recall.js +4 -3
- package/dist/active-recall.js.map +1 -1
- package/dist/adapters/index.js +4 -4
- package/dist/adapters/registry.js +2 -2
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +4 -4
- package/dist/briefing.d.ts +1 -1
- package/dist/briefing.js +8 -7
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer.d.ts +1 -1
- package/dist/calibration.d.ts +1 -1
- package/dist/capabilities.d.ts +1 -1
- package/dist/{catalog-CadPvH29.d.ts → catalog-CbR0CsUw.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-consolidation.js +9 -8
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/{chunk-OMSTU233.js → chunk-2KAYTPPT.js} +4 -4
- package/dist/{chunk-VYZNWH4J.js → chunk-2SXMCQEQ.js} +3 -3
- package/dist/{chunk-NXL5CVE7.js → chunk-2Y6LMOQQ.js} +2 -2
- package/dist/{chunk-AMXOCZHE.js → chunk-3VUPWDSE.js} +15 -3
- package/dist/{chunk-AMXOCZHE.js.map → chunk-3VUPWDSE.js.map} +1 -1
- package/dist/{chunk-FVQJYWH7.js → chunk-5GKPFL3S.js} +1 -1
- package/dist/{chunk-FVQJYWH7.js.map → chunk-5GKPFL3S.js.map} +1 -1
- package/dist/{chunk-LQ4J7ELC.js → chunk-67HG7KFE.js} +2 -2
- package/dist/{chunk-ZBG4K36I.js → chunk-6FUJ2VYY.js} +3 -3
- package/dist/{chunk-GMRNKPWO.js → chunk-6QUPUTT7.js} +2 -2
- package/dist/{chunk-Z56IHRVV.js → chunk-6UU43ZGD.js} +2 -2
- package/dist/{chunk-APJQ6UEA.js → chunk-AGNBY3VG.js} +4 -4
- package/dist/{chunk-OWOKOFXK.js → chunk-AJOIM6UR.js} +2 -2
- package/dist/{chunk-JBPKEARU.js → chunk-AU7Q3LSC.js} +4 -4
- package/dist/{chunk-YVWZW37D.js → chunk-BNOAB5HH.js} +62 -12
- package/dist/{chunk-YVWZW37D.js.map → chunk-BNOAB5HH.js.map} +1 -1
- package/dist/{chunk-A2R5NV6O.js → chunk-CTAHKIG6.js} +205 -29
- package/dist/chunk-CTAHKIG6.js.map +1 -0
- package/dist/{chunk-K22IJO4R.js → chunk-CTOQEZSN.js} +2 -2
- package/dist/{chunk-SINGJCUR.js → chunk-CX77GNMB.js} +14 -3
- package/dist/chunk-CX77GNMB.js.map +1 -0
- package/dist/{chunk-HSDJCT3V.js → chunk-DXGS5YOQ.js} +3 -3
- package/dist/{chunk-HV57RHMD.js → chunk-EH5ED3C6.js} +2 -2
- package/dist/{chunk-NUWZFSKC.js → chunk-FVZ2ISIX.js} +9 -1
- package/dist/chunk-FVZ2ISIX.js.map +1 -0
- package/dist/{chunk-GKPIY7EQ.js → chunk-FXZKXW7C.js} +117 -46
- package/dist/chunk-FXZKXW7C.js.map +1 -0
- package/dist/{chunk-7NDYFAJS.js → chunk-GM3BMWKR.js} +2 -2
- package/dist/{chunk-ZVDRL6SK.js → chunk-HHLWSWWF.js} +2 -2
- package/dist/chunk-HHLWSWWF.js.map +1 -0
- package/dist/{chunk-5QUS24F7.js → chunk-I56LKMF7.js} +2 -2
- package/dist/{chunk-Z3B2YW56.js → chunk-IHMT6XTY.js} +9 -5
- package/dist/chunk-IHMT6XTY.js.map +1 -0
- package/dist/chunk-JAKIDQB2.js +173 -0
- package/dist/chunk-JAKIDQB2.js.map +1 -0
- package/dist/{chunk-35YJ6KCV.js → chunk-JEIROMLX.js} +2 -2
- package/dist/{chunk-SKQCFAYU.js → chunk-JVEMUX6L.js} +2 -2
- package/dist/{chunk-CXMXAC5R.js → chunk-K44MIN6D.js} +3 -3
- package/dist/{chunk-5KQCOIPW.js → chunk-MECU6WSH.js} +188 -31
- package/dist/chunk-MECU6WSH.js.map +1 -0
- package/dist/{chunk-BQCFXAMN.js → chunk-MPHDVHIB.js} +2 -2
- package/dist/{chunk-BOGENF7P.js → chunk-MSVSP5VO.js} +1 -1
- package/dist/chunk-MSVSP5VO.js.map +1 -0
- package/dist/{chunk-QXNFQKWU.js → chunk-MTHNJCOJ.js} +2 -2
- package/dist/{chunk-3TCRU4JA.js → chunk-O62P2LFL.js} +2 -2
- package/dist/{chunk-JSDZMOT7.js → chunk-OC56UWV5.js} +11 -11
- package/dist/{chunk-7IBEWQLG.js → chunk-QOIONSOI.js} +2 -2
- package/dist/{chunk-4P5UAL3C.js → chunk-RBHANGVX.js} +6 -6
- package/dist/{chunk-SK2CR6MW.js → chunk-RVLB4E6N.js} +2 -2
- package/dist/{chunk-I3BT2IDW.js → chunk-SYDHFFAW.js} +1110 -28
- package/dist/chunk-SYDHFFAW.js.map +1 -0
- package/dist/{chunk-VILEUJXC.js → chunk-UC4YOAC2.js} +74 -2
- package/dist/{chunk-VILEUJXC.js.map → chunk-UC4YOAC2.js.map} +1 -1
- package/dist/{chunk-CNVIWMQI.js → chunk-UY4JMEAK.js} +2 -2
- package/dist/{chunk-S6FQLQGH.js → chunk-V7GDTQ6I.js} +2 -2
- package/dist/{chunk-JNOYYWCA.js → chunk-VO4UICII.js} +3 -3
- package/dist/{chunk-54TI5GLV.js → chunk-WI4QX7GH.js} +3 -3
- package/dist/{chunk-3XHD3XGK.js → chunk-XCTDHF7U.js} +30 -2
- package/dist/chunk-XCTDHF7U.js.map +1 -0
- package/dist/{chunk-XKU4YE6Z.js → chunk-XZTUMWKQ.js} +2 -2
- package/dist/{cli-DTWRoJEI.d.ts → cli-iAiVkbYJ.d.ts} +3 -3
- package/dist/cli.d.ts +6 -6
- package/dist/cli.js +43 -42
- package/dist/compounding/engine.d.ts +1 -1
- package/dist/compounding/engine.js +8 -7
- package/dist/compounding/preference-consolidator.d.ts +1 -1
- package/dist/compression-optimizer.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +4 -3
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +8 -7
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +9 -8
- package/dist/consolidation-provenance-check.d.ts +1 -1
- package/dist/consolidation-undo.d.ts +1 -1
- package/dist/contradiction/index.d.ts +1 -1
- package/dist/conversation-index/backend.d.ts +1 -1
- package/dist/conversation-index/chunker.d.ts +1 -1
- package/dist/conversation-index/faiss-adapter.d.ts +1 -1
- package/dist/conversation-index/indexer.d.ts +1 -1
- package/dist/conversation-index/search.d.ts +1 -1
- package/dist/day-summary.d.ts +1 -1
- package/dist/delinearize.d.ts +1 -1
- package/dist/direct-answer-wiring.d.ts +1 -1
- package/dist/direct-answer.d.ts +1 -1
- package/dist/embedding-fallback.d.ts +1 -1
- package/dist/enrichment/index.d.ts +1 -1
- package/dist/entity-retrieval.d.ts +1 -1
- package/dist/entity-retrieval.js +8 -7
- package/dist/entity-schema.d.ts +1 -1
- package/dist/explicit-capture.d.ts +4 -4
- package/dist/explicit-capture.js +3 -2
- package/dist/extraction-faithfulness.d.ts +1 -1
- package/dist/extraction-judge-telemetry.d.ts +1 -1
- package/dist/extraction-judge-training.d.ts +1 -1
- package/dist/extraction-judge.d.ts +1 -1
- package/dist/extraction.d.ts +1 -1
- package/dist/extraction.js +4 -3
- package/dist/fallback-llm.d.ts +1 -1
- package/dist/identity-continuity.d.ts +1 -1
- package/dist/importance.d.ts +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.js +62 -61
- package/dist/index.js.map +1 -1
- package/dist/intent.d.ts +1 -1
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/index.js +3 -3
- package/dist/lcm/tools.d.ts +1 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/live-connectors-runner.d.ts +1 -1
- package/dist/local-llm.d.ts +1 -1
- package/dist/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/memory-governance.js +8 -7
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +8 -7
- package/dist/maintenance/rebuild-memory-projection.js +9 -8
- package/dist/mcp-memory-inspector-app.d.ts +5 -5
- package/dist/memory-action-policy.d.ts +1 -1
- package/dist/memory-cache.d.ts +1 -1
- package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
- package/dist/memory-projection-store.d.ts +1 -1
- package/dist/memory-provenance.d.ts +1 -1
- package/dist/memory-worth-outcomes.d.ts +1 -1
- package/dist/models-json.d.ts +1 -1
- package/dist/namespaces/migrate.d.ts +2 -2
- package/dist/namespaces/migrate.js +12 -11
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/search.js +3 -3
- package/dist/namespaces/storage.d.ts +2 -2
- package/dist/namespaces/storage.js +8 -7
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +1 -1
- package/dist/operator-toolkit.js +17 -16
- package/dist/orchestration/maintenance.d.ts +2 -2
- package/dist/orchestration/maintenance.js +10 -9
- package/dist/{orchestrator-B1iVjEyc.d.ts → orchestrator-iVZWi8aW.d.ts} +21 -4
- package/dist/orchestrator.d.ts +4 -4
- package/dist/orchestrator.js +32 -31
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/provenance.d.ts +1 -1
- package/dist/provenance.js +3 -2
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +1 -1
- package/dist/recall-disclosure-escalation.d.ts +1 -1
- package/dist/recall-explain-renderer.d.ts +1 -1
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-handles.d.ts +228 -0
- package/dist/recall-handles.js +42 -0
- package/dist/recall-handles.js.map +1 -0
- package/dist/recall-planner-llm.d.ts +1 -1
- package/dist/recall-state.d.ts +40 -2
- package/dist/recall-state.js +3 -1
- package/dist/recall-tag-filter.d.ts +1 -1
- package/dist/recall-xray-cli.d.ts +1 -1
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +1 -1
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +1 -1
- package/dist/recall-xray.js +2 -2
- package/dist/resolve-auth-token.d.ts +1 -1
- package/dist/resume-bundles.js +5 -4
- package/dist/retrieval-agents.d.ts +1 -1
- package/dist/retrieval-tiers.d.ts +1 -1
- package/dist/routing/engine.d.ts +1 -1
- package/dist/routing/store.d.ts +1 -1
- package/dist/sanitize.d.ts +2 -0
- package/dist/sanitize.js +6 -2
- package/dist/search/embed-helper.d.ts +1 -1
- package/dist/search/factory.d.ts +1 -1
- package/dist/search/factory.js +2 -2
- package/dist/search/index.d.ts +1 -1
- package/dist/search/index.js +4 -4
- package/dist/search/lancedb-backend.d.ts +1 -1
- package/dist/search/meilisearch-backend.d.ts +1 -1
- package/dist/search/noop-backend.d.ts +1 -1
- package/dist/search/orama-backend.d.ts +1 -1
- package/dist/search/port.d.ts +1 -1
- package/dist/search/remote-backend.d.ts +1 -1
- package/dist/{semantic-consolidation-CY8uVRNJ.d.ts → semantic-consolidation-DSjMDZ1u.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +9 -8
- package/dist/semantic-rule-promotion.js +8 -7
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +8 -7
- package/dist/session-observer-bands.d.ts +1 -1
- package/dist/session-observer-state.d.ts +1 -1
- package/dist/shared-context/manager.d.ts +3 -3
- package/dist/signal.d.ts +1 -1
- package/dist/storage.d.ts +1 -1
- package/dist/storage.js +7 -6
- package/dist/summarizer.d.ts +1 -1
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/temporal-supersession.d.ts +1 -1
- package/dist/temporal-validity.d.ts +1 -1
- package/dist/threading.d.ts +1 -1
- package/dist/tier-migration.d.ts +1 -1
- package/dist/tier-routing.d.ts +1 -1
- package/dist/topics.d.ts +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/transfer/import-sqlite.js +2 -2
- package/dist/{types-Dr0Cw3L9.d.ts → types-D9dwzU_x.d.ts} +25 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/utility-runtime.d.ts +1 -1
- package/dist/verified-recall.js +8 -7
- package/package.json +2 -2
- package/src/access-boundary.ts +4 -1
- package/src/access-http.ts +78 -20
- package/src/access-mcp.test.ts +29 -0
- package/src/access-mcp.ts +99 -17
- package/src/access-operations-batch.ts +14 -0
- package/src/access-operations.ts +5 -0
- package/src/access-schema.ts +8 -0
- package/src/access-service-observe-idempotency.test.ts +308 -0
- package/src/access-service.ts +106 -5
- package/src/access-surface-catalog.test.ts +4 -2
- package/src/access-surface-catalog.ts +5 -0
- package/src/active-memory-bridge.test.ts +72 -0
- package/src/active-memory-bridge.ts +21 -2
- package/src/chat/chat-cli.test.ts +142 -0
- package/src/chat/chat-cli.ts +206 -0
- package/src/chat/chat-config.ts +57 -0
- package/src/chat/chat-engine.test.ts +272 -0
- package/src/chat/chat-engine.ts +518 -0
- package/src/chat/chat-executor.ts +133 -0
- package/src/chat/chat-factory.ts +161 -0
- package/src/chat/chat-http.test.ts +197 -0
- package/src/chat/chat-http.ts +222 -0
- package/src/chat/chat-llm.ts +229 -0
- package/src/chat/chat-mcp.test.ts +135 -0
- package/src/chat/chat-security.test.ts +491 -0
- package/src/chat/chat-session.ts +296 -0
- package/src/chat/chat-system-prompt.ts +76 -0
- package/src/chat/chat-tools.ts +255 -0
- package/src/chat/chat-types.ts +167 -0
- package/src/cli.ts +20 -0
- package/src/config.ts +9 -0
- package/src/orchestrator.ts +106 -5
- package/src/recall-handles-wiring.test.ts +477 -0
- package/src/recall-handles.test.ts +283 -0
- package/src/recall-handles.ts +414 -0
- package/src/recall-state.ts +99 -0
- package/src/sanitize.ts +6 -0
- package/src/types.ts +29 -0
- package/dist/chunk-3XHD3XGK.js.map +0 -1
- package/dist/chunk-5KQCOIPW.js.map +0 -1
- package/dist/chunk-A2R5NV6O.js.map +0 -1
- package/dist/chunk-BOGENF7P.js.map +0 -1
- package/dist/chunk-GKPIY7EQ.js.map +0 -1
- package/dist/chunk-I3BT2IDW.js.map +0 -1
- package/dist/chunk-NUWZFSKC.js.map +0 -1
- package/dist/chunk-SINGJCUR.js.map +0 -1
- package/dist/chunk-Z3B2YW56.js.map +0 -1
- package/dist/chunk-ZVDRL6SK.js.map +0 -1
- /package/dist/{chunk-OMSTU233.js.map → chunk-2KAYTPPT.js.map} +0 -0
- /package/dist/{chunk-VYZNWH4J.js.map → chunk-2SXMCQEQ.js.map} +0 -0
- /package/dist/{chunk-NXL5CVE7.js.map → chunk-2Y6LMOQQ.js.map} +0 -0
- /package/dist/{chunk-LQ4J7ELC.js.map → chunk-67HG7KFE.js.map} +0 -0
- /package/dist/{chunk-ZBG4K36I.js.map → chunk-6FUJ2VYY.js.map} +0 -0
- /package/dist/{chunk-GMRNKPWO.js.map → chunk-6QUPUTT7.js.map} +0 -0
- /package/dist/{chunk-Z56IHRVV.js.map → chunk-6UU43ZGD.js.map} +0 -0
- /package/dist/{chunk-APJQ6UEA.js.map → chunk-AGNBY3VG.js.map} +0 -0
- /package/dist/{chunk-OWOKOFXK.js.map → chunk-AJOIM6UR.js.map} +0 -0
- /package/dist/{chunk-JBPKEARU.js.map → chunk-AU7Q3LSC.js.map} +0 -0
- /package/dist/{chunk-K22IJO4R.js.map → chunk-CTOQEZSN.js.map} +0 -0
- /package/dist/{chunk-HSDJCT3V.js.map → chunk-DXGS5YOQ.js.map} +0 -0
- /package/dist/{chunk-HV57RHMD.js.map → chunk-EH5ED3C6.js.map} +0 -0
- /package/dist/{chunk-7NDYFAJS.js.map → chunk-GM3BMWKR.js.map} +0 -0
- /package/dist/{chunk-5QUS24F7.js.map → chunk-I56LKMF7.js.map} +0 -0
- /package/dist/{chunk-35YJ6KCV.js.map → chunk-JEIROMLX.js.map} +0 -0
- /package/dist/{chunk-SKQCFAYU.js.map → chunk-JVEMUX6L.js.map} +0 -0
- /package/dist/{chunk-CXMXAC5R.js.map → chunk-K44MIN6D.js.map} +0 -0
- /package/dist/{chunk-BQCFXAMN.js.map → chunk-MPHDVHIB.js.map} +0 -0
- /package/dist/{chunk-QXNFQKWU.js.map → chunk-MTHNJCOJ.js.map} +0 -0
- /package/dist/{chunk-3TCRU4JA.js.map → chunk-O62P2LFL.js.map} +0 -0
- /package/dist/{chunk-JSDZMOT7.js.map → chunk-OC56UWV5.js.map} +0 -0
- /package/dist/{chunk-7IBEWQLG.js.map → chunk-QOIONSOI.js.map} +0 -0
- /package/dist/{chunk-4P5UAL3C.js.map → chunk-RBHANGVX.js.map} +0 -0
- /package/dist/{chunk-SK2CR6MW.js.map → chunk-RVLB4E6N.js.map} +0 -0
- /package/dist/{chunk-CNVIWMQI.js.map → chunk-UY4JMEAK.js.map} +0 -0
- /package/dist/{chunk-S6FQLQGH.js.map → chunk-V7GDTQ6I.js.map} +0 -0
- /package/dist/{chunk-JNOYYWCA.js.map → chunk-VO4UICII.js.map} +0 -0
- /package/dist/{chunk-54TI5GLV.js.map → chunk-WI4QX7GH.js.map} +0 -0
- /package/dist/{chunk-XKU4YE6Z.js.map → chunk-XZTUMWKQ.js.map} +0 -0
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
readNamespaceMaintenanceLastRanStatuses,
|
|
4
4
|
readNamespaceMaintenanceStatuses,
|
|
5
5
|
runNamespaceMaintenancePlan
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6QUPUTT7.js";
|
|
7
7
|
|
|
8
8
|
// src/maintenance/namespace-maintenance-fanout.ts
|
|
9
9
|
var NAMESPACE_MAINTENANCE_JOBS = [
|
|
@@ -146,4 +146,4 @@ export {
|
|
|
146
146
|
summarizeNamespaceMaintenanceHealth,
|
|
147
147
|
formatNamespaceMaintenanceHealthText
|
|
148
148
|
};
|
|
149
|
-
//# sourceMappingURL=chunk-
|
|
149
|
+
//# sourceMappingURL=chunk-GM3BMWKR.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EngramAccessInputError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BNOAB5HH.js";
|
|
4
4
|
import {
|
|
5
5
|
expandTildePath
|
|
6
6
|
} from "./chunk-EYIEWJNI.js";
|
|
@@ -104,4 +104,4 @@ export {
|
|
|
104
104
|
listRegisteredOperations,
|
|
105
105
|
__resetRegistryForTest
|
|
106
106
|
};
|
|
107
|
-
//# sourceMappingURL=chunk-
|
|
107
|
+
//# sourceMappingURL=chunk-HHLWSWWF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/access-boundary.ts"],"sourcesContent":["/**\n * Single input-validation and error boundary for the CLI/MCP/HTTP access\n * surfaces (issue #1525, epic #1520 Phase 1).\n *\n * Every operation that crosses the access-service facade passes through ONE\n * registry entry: a zod-validated request envelope, a shared error mapper,\n * and the \"reject invalid input and list valid options\" behavior that\n * CLAUDE.md rules 14/17/24/28/36/48/51 previously had to be re-implemented\n * per handler. The three surfaces become thin adapters — one operation\n * definition, three transports — so a validation fix lands everywhere at\n * once.\n *\n * Host-agnostic (rule 31): operation names carry no `openclaw-*`/`engram-*`\n * prefix. Session/namespace tenancy stays in the handler layer (resolved via\n * ScopePlan #1521); the boundary validates SHAPE, not tenancy.\n */\n\nimport { z } from \"zod\";\nimport { EngramAccessInputError, type EngramAccessService } from \"./access-service.js\";\nimport { expandTildePath } from \"./utils/path.js\";\n\n// ---------------------------------------------------------------------------\n// Canonical operation names — host-agnostic (rule 31)\n// ---------------------------------------------------------------------------\n\n/**\n * Canonical operation ids. One id is shared by the MCP tool, the HTTP route,\n * and the CLI command that expose the same operation. Add to this union as\n * each domain-group migration PR (memory ops → connectors → namespaces …)\n * lands; the fitness test in `access-surface-catalog.test.ts` treats the\n * registered set as the migration state.\n */\nexport type OperationName =\n | \"memory_get\"\n | \"memory_search\"\n | \"memory_store\"\n | \"coding_decision\"\n | \"coding_architecture\"\n // codegraph parity tools (issue #1554) -- each maps to one codegraph_*\n // boundary operation that delegates to the surface handler in\n // coding/codegraph-surfaces.ts. Names match the external tool suffixes.\n | \"codegraph_index\"\n | \"codegraph_list_projects\"\n | \"codegraph_delete_project\"\n | \"codegraph_index_status\"\n | \"codegraph_search_graph\"\n | \"codegraph_trace_path\"\n | \"codegraph_detect_changes\"\n | \"codegraph_query_graph\"\n | \"codegraph_get_schema\"\n | \"codegraph_get_snippet\"\n | \"codegraph_get_architecture\"\n | \"codegraph_search_code\"\n | \"codegraph_manage_adr\"\n | \"codegraph_ingest_traces\"\n | \"memory_correct_plan\"\n | \"memory_correct_apply\"\n | \"coding_delta\"\n // Remaining MCP/HTTP handlers migrated through the boundary (issue #1525).\n | \"recall\"\n | \"recall_explain\"\n | \"set_coding_context\"\n | \"recall_tier_explain\"\n | \"recall_xray\"\n | \"wearables_status\"\n | \"wearables_sync\"\n | \"transcript_day\"\n | \"transcript_search\"\n | \"transcript_memories\"\n | \"action_confidence\"\n | \"chatgpt_memory_inspector\"\n | \"day_summary\"\n | \"capsule_export\"\n | \"capsule_import\"\n | \"capsule_list\"\n | \"memory_governance_run\"\n | \"procedure_mining_run\"\n | \"pattern_reinforcement_run\"\n | \"procedural_stats\"\n | \"memory_timeline\"\n | \"suggestion_submit\"\n | \"entity_get\"\n | \"review_queue_list\"\n | \"observe\"\n | \"lcm_search\"\n | \"lcm_compaction_flush\"\n | \"lcm_compaction_record\"\n | \"continuity_audit_generate\"\n | \"continuity_incident_open\"\n | \"continuity_incident_close\"\n | \"continuity_incident_list\"\n | \"continuity_loop_add_or_update\"\n | \"continuity_loop_review\"\n | \"identity_anchor_get\"\n | \"identity_anchor_update\"\n | \"memory_identity\"\n | \"work_task\"\n | \"work_project\"\n | \"work_board\"\n | \"shared_context_write_output\"\n | \"shared_feedback_record\"\n | \"shared_priorities_append\"\n | \"shared_context_cross_signals_run\"\n | \"shared_context_curate_daily\"\n | \"compounding_weekly_synthesize\"\n | \"compounding_promote_candidate\"\n | \"compression_guidelines_optimize\"\n | \"compression_guidelines_activate\"\n | \"memory_profile\"\n | \"memory_entities_list\"\n | \"memory_questions\"\n | \"memory_last_recall\"\n | \"memory_intent_debug\"\n | \"memory_qmd_debug\"\n | \"memory_graph_explain\"\n | \"graph_snapshot\"\n | \"memory_feedback\"\n | \"memory_promote\"\n | \"memory_outcome\"\n | \"memory_action_apply\"\n | \"context_checkpoint\"\n | \"briefing\"\n | \"review_list\"\n | \"review_resolve\"\n | \"contradiction_scan_run\"\n | \"memory_summarize_hourly\"\n | \"conversation_index_update\"\n | \"profiling_report\"\n | \"graph_edge_decay_run\"\n | \"live_connectors_run\"\n | \"peer_list\"\n | \"peer_get\"\n | \"peer_set\"\n | \"peer_delete\"\n | \"peer_profile_get\"\n | \"peer_forget\"\n | \"console_state\"\n | \"dreams_status\"\n | \"dreams_run\"\n // HTTP-only routes (no direct MCP tool equivalent).\n | \"offline_sync_snapshot\"\n | \"offline_sync_snapshot_stream\"\n | \"offline_sync_files\"\n | \"offline_sync_file_content\"\n | \"offline_sync_apply_file_content\"\n | \"offline_sync_apply\"\n | \"lcm_status\"\n | \"memory_list\"\n | \"entity_list\"\n | \"maintenance_status\"\n | \"quality_status\"\n | \"trust_zones_status\"\n | \"trust_zones_records\"\n | \"review_disposition\"\n | \"trust_zones_promote\"\n | \"trust_zones_demo_seed\"\n | \"citations_observed\"\n | \"contradiction_detail\"\n | \"graph_events\"\n // Chat surface — conversational memory inspection/correction (issue #1583).\n | \"chat_message\"\n | \"chat_events\";\n\n// ---------------------------------------------------------------------------\n// Operation context — what every handler receives\n// ---------------------------------------------------------------------------\n\n/**\n * Per-call context. `service` is the facade the handler delegates to; the\n * boundary never reaches past it. `authenticatedPrincipal` is resolved by\n * the SURFACE (MCP header / HTTP identity / CLI flag) before the boundary\n * runs, so handlers stay principal-source-agnostic. `hooks` carries\n * transport-level callbacks (e.g. HTTP write-quota enforcement) that must\n * fire atomically inside the service call; surfaces that have no such hook\n * leave it undefined.\n */\nexport interface OperationContext {\n readonly service: EngramAccessService;\n readonly authenticatedPrincipal?: string;\n readonly hooks?: OperationHooks;\n}\n\n/**\n * Transport-level callbacks a handler forwards into the service call. Kept\n * narrow on purpose: the boundary owns validation + dispatch shape, not\n * transport policy. Add fields here only when a surface genuinely needs a\n * callback the service itself consumes.\n */\nexport interface OperationHooks {\n /** HTTP write-quota gate; throws to reject the write when exhausted. */\n readonly enforceWriteQuota?: () => void | Promise<void>;\n}\n\n// ---------------------------------------------------------------------------\n// Operation spec + bound operation\n// ---------------------------------------------------------------------------\n\nexport interface OperationSpec<In, Out> {\n /** Canonical operation id; matches an {@link OperationName}. */\n readonly name: OperationName;\n readonly description: string;\n /** Zod schema validating the raw request envelope. */\n readonly schema: z.ZodType<In>;\n /** Handler invoked with the parsed input; throws EngramAccessInputError for domain faults. */\n readonly handler: (input: In, ctx: OperationContext) => Promise<Out>;\n}\n\nexport interface BoundOperation<In = unknown, Out = unknown> {\n readonly spec: OperationSpec<In, Out>;\n /** Validate the raw envelope, then invoke the handler. Throws EngramAccessInputError on any validation failure. */\n readonly run: (rawInput: unknown, ctx: OperationContext) => Promise<Out>;\n}\n\n// ---------------------------------------------------------------------------\n// Shared normalizers the boundary owns (rules 17, 28, 36, 48, 51)\n// ---------------------------------------------------------------------------\n\n/**\n * Coerce boolean-like strings at the edge (rule 36). Accepts actual booleans\n * and the string spellings clients send (\"true\"/\"false\"/\"1\"/\"0\"/\"yes\"/\"no\"/\n * \"on\"/\"off\", case-insensitive). Rejects anything else loudly — `Boolean(\"false\")`\n * would silently be `true`, which is the bug rule 36 exists to prevent.\n *\n * `undefined`/`null`/`\"\"` → `undefined`, so callers can keep treating an\n * absent flag as \"use the default\" without a separate presence check.\n */\nexport function coerceBooleanLike(value: unknown): boolean | undefined {\n if (value === undefined || value === null || value === \"\") return undefined;\n if (typeof value === \"boolean\") return value;\n if (typeof value === \"string\") {\n const lower = value.trim().toLowerCase();\n if (lower === \"true\" || lower === \"1\" || lower === \"yes\" || lower === \"on\") return true;\n if (lower === \"false\" || lower === \"0\" || lower === \"no\" || lower === \"off\") return false;\n }\n throw new EngramAccessInputError(\n `expected a boolean-like value (true|false|1|0|yes|no|on|off); got ${JSON.stringify(value)}`,\n );\n}\n\n/**\n * Coerce + validate a positive integer from a numeric string or number\n * (rule 28). Loosely-typed MCP/CLI clients send `\"5\"`; `typeof saved === \"number\"`\n * on read-back would reject it later, so we coerce at the edge and reject\n * booleans/objects loudly (`Number(true) === 1` would silently pass otherwise).\n *\n * `undefined`/`null`/`\"\"` → `undefined`.\n */\nexport function coercePositiveInteger(value: unknown, label: string): number | undefined {\n if (value === undefined || value === null || value === \"\") return undefined;\n if (typeof value === \"number\") {\n if (!Number.isFinite(value) || value <= 0 || !Number.isInteger(value)) {\n throw new EngramAccessInputError(`${label} expects a positive integer; got ${JSON.stringify(value)}`);\n }\n return value;\n }\n if (typeof value === \"string\") {\n const trimmed = value.trim();\n if (!/^[+-]?\\d+$/.test(trimmed)) {\n throw new EngramAccessInputError(`${label} expects a positive integer; got ${JSON.stringify(value)}`);\n }\n const parsed = Number(trimmed);\n if (!Number.isSafeInteger(parsed) || parsed <= 0) {\n throw new EngramAccessInputError(`${label} expects a positive integer; got ${JSON.stringify(value)}`);\n }\n return parsed;\n }\n throw new EngramAccessInputError(`${label} expects a positive integer; got ${JSON.stringify(value)}`);\n}\n\n/**\n * Expand `~` in a path-shaped input (rule 17). Node `fs` does NOT expand `~`;\n * ad-hoc regex drifts. `undefined`/`null`/`\"\"` → `undefined`.\n */\nexport function normalizeOptionalPath(value: unknown): string | undefined {\n if (value === undefined || value === null || value === \"\") return undefined;\n if (typeof value !== \"string\") {\n throw new EngramAccessInputError(`expected a path string; got ${JSON.stringify(value)}`);\n }\n return expandTildePath(value);\n}\n\n// ---------------------------------------------------------------------------\n// Error formatting — rule 51: list valid options, never silently default\n// ---------------------------------------------------------------------------\n\n/**\n * Turn a zod failure into an {@link EngramAccessInputError} whose message\n * names the offending field and — for enum/union issues — lists the valid\n * options, so the caller can correct rather than guess (rule 51).\n */\nexport function formatZodIssues(error: z.ZodError): string {\n const parts: string[] = [];\n for (const issue of error.issues) {\n const path = issue.path.length > 0 ? issue.path.join(\".\") : \"(root)\";\n const options = enumOptionsFromIssue(issue);\n const suffix = options ? `. Valid: ${options.join(\", \")}` : \"\";\n parts.push(`${path}: ${issue.message}${suffix}`);\n }\n return parts.length > 0\n ? `request validation failed: ${parts.join(\"; \")}`\n : \"request validation failed\";\n}\n\nfunction enumOptionsFromIssue(issue: z.ZodIssue): readonly string[] | undefined {\n // zod exposes accepted enum values on the issue for ZodEnum / ZodNativeEnum\n // and on the options of invalid_union discriminators. Reading them here\n // keeps \"list valid options\" in ONE place rather than per handler.\n if (issue.code === z.ZodIssueCode.invalid_enum_value) {\n const rawOptions = (issue as { options?: unknown }).options;\n if (Array.isArray(rawOptions)) {\n return rawOptions.map((opt) => String(opt));\n }\n }\n return undefined;\n}\n\n// ---------------------------------------------------------------------------\n// Registry\n// ---------------------------------------------------------------------------\n\nconst registry = new Map<OperationName, BoundOperation>();\n\n/**\n * Register an operation. Throws if the name is already registered — duplicate\n * registration is a programming error, not a runtime input fault, so it throws\n * a plain Error (not the input-error class surfaces translate for clients).\n */\nexport function defineOperation<In, Out>(spec: OperationSpec<In, Out>): BoundOperation<In, Out> {\n if (registry.has(spec.name)) {\n throw new Error(`access-boundary: operation already registered: ${spec.name}`);\n }\n const bound: BoundOperation<In, Out> = {\n spec,\n run: async (rawInput, ctx) => {\n const parseResult = spec.schema.safeParse(rawInput);\n if (!parseResult.success) {\n throw new EngramAccessInputError(formatZodIssues(parseResult.error));\n }\n return spec.handler(parseResult.data, ctx);\n },\n };\n // Store under the canonical name; the cast is safe because In/Out are\n // erased at the registry boundary and recovered by callers via getOperation.\n registry.set(spec.name, bound as unknown as BoundOperation);\n return bound;\n}\n\n/** Look up a registered operation by canonical name. */\nexport function getOperation(name: OperationName): BoundOperation | undefined {\n return registry.get(name);\n}\n\n/** All registered operation names. */\nexport function listRegisteredOperations(): readonly OperationName[] {\n return [...registry.keys()];\n}\n\n/** Test-only: clear the registry so pilot definitions can be re-registered. */\nexport function __resetRegistryForTest(): void {\n registry.clear();\n}\n"],"mappings":";;;;;;;;AAiBA,SAAS,SAAS;AAiNX,SAAS,kBAAkB,OAAqC;AACrE,MAAI,UAAU,UAAa,UAAU,QAAQ,UAAU,GAAI,QAAO;AAClE,MAAI,OAAO,UAAU,UAAW,QAAO;AACvC,MAAI,OAAO,UAAU,UAAU;AAC7B,UAAM,QAAQ,MAAM,KAAK,EAAE,YAAY;AACvC,QAAI,UAAU,UAAU,UAAU,OAAO,UAAU,SAAS,UAAU,KAAM,QAAO;AACnF,QAAI,UAAU,WAAW,UAAU,OAAO,UAAU,QAAQ,UAAU,MAAO,QAAO;AAAA,EACtF;AACA,QAAM,IAAI;AAA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
4
|
import {
|
|
5
5
|
summarizeDisclosureTokens
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-AJOIM6UR.js";
|
|
7
7
|
import {
|
|
8
8
|
summarizeRetrievedMemoryProvenance
|
|
9
9
|
} from "./chunk-I4WBNM3M.js";
|
|
@@ -587,4 +587,4 @@ export {
|
|
|
587
587
|
renderRecallExplain,
|
|
588
588
|
parseRecallExplainFormat
|
|
589
589
|
};
|
|
590
|
-
//# sourceMappingURL=chunk-
|
|
590
|
+
//# sourceMappingURL=chunk-I56LKMF7.js.map
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
memoryStoreRequestSchema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FVZ2ISIX.js";
|
|
4
4
|
import {
|
|
5
5
|
defineOperation
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HHLWSWWF.js";
|
|
7
7
|
import {
|
|
8
8
|
CorrectionContractError,
|
|
9
9
|
DECISION_SUBCOMMANDS,
|
|
10
10
|
DELTA_SUBCOMMANDS,
|
|
11
11
|
EngramAccessInputError,
|
|
12
12
|
isCodegraphToolName
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BNOAB5HH.js";
|
|
14
14
|
|
|
15
15
|
// src/access-operations.ts
|
|
16
16
|
import { z } from "zod";
|
|
17
17
|
var memoryGetSchema = z.object({
|
|
18
18
|
memoryId: z.string().trim().min(1, "memoryId is required").max(512),
|
|
19
|
+
// Issue #1582 — when memoryId is a `[m:xxxx]` handle, sessionKey scopes the
|
|
20
|
+
// resolution to this session's recent recall history.
|
|
21
|
+
sessionKey: z.string().trim().min(1).max(512).nullable().optional(),
|
|
19
22
|
namespace: z.string().trim().max(256).nullable().optional()
|
|
20
23
|
});
|
|
21
24
|
var memoryGetOperation = defineOperation({
|
|
@@ -26,7 +29,8 @@ var memoryGetOperation = defineOperation({
|
|
|
26
29
|
const result = await ctx.service.memoryGet(
|
|
27
30
|
input.memoryId,
|
|
28
31
|
input.namespace ?? void 0,
|
|
29
|
-
ctx.authenticatedPrincipal
|
|
32
|
+
ctx.authenticatedPrincipal,
|
|
33
|
+
input.sessionKey ?? void 0
|
|
30
34
|
);
|
|
31
35
|
return { result };
|
|
32
36
|
}
|
|
@@ -459,4 +463,4 @@ export {
|
|
|
459
463
|
codegraphIngestTracesOperation,
|
|
460
464
|
REGISTERED_OPERATIONS
|
|
461
465
|
};
|
|
462
|
-
//# sourceMappingURL=chunk-
|
|
466
|
+
//# sourceMappingURL=chunk-IHMT6XTY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/access-operations.ts"],"sourcesContent":["/**\n * Pilot operation definitions for the access boundary (issue #1525).\n *\n * Three operations migrate through the registry in this PR — `memory_get`,\n * `memory_search`, and the `memory_store` write op — so the boundary's\n * normalization matrix (rules 17/28/36/48/51) and shared error mapping reach\n * MCP, HTTP, and CLI from one place. Domain-group migrations (memory ops →\n * connectors → namespaces …) land as follow-up PRs that add `defineOperation`\n * calls here and delete the surface-local validation they replace.\n *\n * Importing this module for its side effects registers the pilot operations;\n * surfaces then dispatch via {@link getOperation} from `./access-boundary.js`.\n */\n\nimport { z } from \"zod\";\n\nimport { defineOperation } from \"./access-boundary.js\";\nimport { memoryStoreRequestSchema, type MemoryStoreRequest } from \"./access-schema.js\";\nimport { EngramAccessInputError } from \"./access-service.js\";\nimport { CorrectionContractError } from \"./correction/correction-contract.js\";\nimport type {\n EngramAccessMemoryResponse,\n EngramAccessWriteResponse,\n} from \"./access-service.js\";\nimport {\n DECISION_SUBCOMMANDS,\n type DecisionSurfaceRequest,\n type DecisionSurfaceResponse,\n} from \"./coding/decision-surfaces.js\";\nimport {\n type ArchitectureSurfaceRequest,\n type ArchitectureSurfaceResponse,\n} from \"./coding/architecture-surfaces.js\";\nimport {\n type CodegraphSurfaceRequest,\n type CodegraphSurfaceResponse,\n isCodegraphToolName,\n} from \"./coding/codegraph-surfaces.js\";\nimport {\n DELTA_SUBCOMMANDS,\n type DeltaSurfaceRequest,\n type DeltaSurfaceResponse,\n} from \"./coding/session-delta-surfaces.js\";\n\n// ---------------------------------------------------------------------------\n// memory_get — fetch one memory by id\n// ---------------------------------------------------------------------------\n\n/**\n * `memoryId` is required and non-empty (rule 51: the MCP dispatcher previously\n * fell back to `typeof args.memoryId === \"string\" ? args.memoryId : \"\"`,\n * silently passing an empty id into the service). `namespace` is\n * `.nullable().optional()` because MCP clients send `null` (gotcha #2).\n * `namespace` has no `.min(1)` because the pre-boundary handlers forwarded\n * empty/whitespace strings, and `resolveNamespace` treats empty identically\n * to absent (both trim to falsy → default namespace). Rejecting empty would\n * break HTTP callers that send a bare `?namespace=` (Cursor review).\n */\nconst memoryGetSchema = z.object({\n memoryId: z.string().trim().min(1, \"memoryId is required\").max(512),\n // Issue #1582 — when memoryId is a `[m:xxxx]` handle, sessionKey scopes the\n // resolution to this session's recent recall history.\n sessionKey: z.string().trim().min(1).max(512).nullable().optional(),\n namespace: z.string().trim().max(256).nullable().optional(),\n});\n\nexport interface MemoryGetInput {\n readonly memoryId: string;\n readonly sessionKey?: string | null;\n readonly namespace?: string | null;\n}\n\nexport interface MemoryGetOutput {\n readonly result: EngramAccessMemoryResponse;\n}\n\nexport const memoryGetOperation = defineOperation<MemoryGetInput, MemoryGetOutput>({\n name: \"memory_get\",\n description: \"Fetch one memory by id.\",\n schema: memoryGetSchema,\n handler: async (input, ctx) => {\n const result = await ctx.service.memoryGet(\n input.memoryId,\n input.namespace ?? undefined,\n ctx.authenticatedPrincipal,\n input.sessionKey ?? undefined,\n );\n return { result };\n },\n});\n\n// ---------------------------------------------------------------------------\n// memory_search — semantic search across memories\n// ---------------------------------------------------------------------------\n\nconst memorySearchSchema = z.object({\n query: z.string().trim().min(1, \"query is required\").max(2048),\n namespace: z.string().trim().max(256).nullable().optional(),\n // No upper cap: the pre-boundary MCP handler forwarded any finite number to\n // memorySearch, and the QMD/search backends honor large limits. Capping at\n // 100 would reject existing clients that request larger result sets.\n maxResults: z.number().int().min(1).nullable().optional(),\n collection: z.string().trim().min(1).max(256).nullable().optional(),\n});\n\nexport interface MemorySearchInput {\n readonly query: string;\n readonly namespace?: string | null;\n readonly maxResults?: number | null;\n readonly collection?: string | null;\n}\n\nexport interface MemorySearchOutput {\n readonly result: {\n readonly query: string;\n readonly results: ReadonlyArray<{ path: string; score: number; snippet: string }>;\n readonly count: number;\n };\n}\n\nexport const memorySearchOperation = defineOperation<MemorySearchInput, MemorySearchOutput>({\n name: \"memory_search\",\n description: \"Search memories across readable namespaces.\",\n schema: memorySearchSchema,\n handler: async (input, ctx) => {\n const result = await ctx.service.memorySearch({\n query: input.query,\n namespace: input.namespace ?? undefined,\n maxResults: input.maxResults ?? undefined,\n collection: input.collection ?? undefined,\n principal: ctx.authenticatedPrincipal,\n });\n return { result };\n },\n});\n\n// ---------------------------------------------------------------------------\n// memory_store — the pilot WRITE op\n// ---------------------------------------------------------------------------\n\nexport type MemoryStoreInput = MemoryStoreRequest;\n\nexport interface MemoryStoreOutput {\n readonly result: EngramAccessWriteResponse;\n}\n\nexport const memoryStoreOperation = defineOperation<MemoryStoreInput, MemoryStoreOutput>({\n name: \"memory_store\",\n description: \"Store an explicit memory through the access layer.\",\n // Reuse the existing schema verbatim — the migration is behavior-preserving;\n // the schema's external contract is NOT changing in this PR (per the issue's\n // pitfall note).\n schema: memoryStoreRequestSchema,\n handler: async (input, ctx) => {\n const result = await ctx.service.memoryStore(\n {\n ...input,\n authenticatedPrincipal: ctx.authenticatedPrincipal,\n },\n // Forward transport-level hooks (e.g. HTTP's atomic write-quota gate)\n // so the hook still fires inside the service's idempotent-write lock —\n // never before, never on a replay (#1434 invariant preserved by the\n // boundary migration).\n\n ctx.hooks,\n );\n return { result };\n },\n});\n\n// ---------------------------------------------------------------------------\n// coding_decision — decision-record surfaces (issue #1548 Track A PR 2)\n// ---------------------------------------------------------------------------\n\n/**\n * The subcommand field is required and MUST be one of the four valid values\n * (rule 51 — reject loudly, list the options, never silently default). The\n * remaining fields are optional because each subcommand uses a different\n * subset; the handler validates subcommand-specific requirements after\n * routing.\n */\n/**\n * MCP clients send `null` for absent optional fields. Zod `.optional()`\n * rejects `null`, so strip nulls at the object level before the inner\n * schema validates (review: cursor null-field thread).\n */\nconst codingDecisionSchema = z.preprocess(\n (data) => {\n if (data && typeof data === \"object\" && !Array.isArray(data)) {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(data as Record<string, unknown>)) {\n if (v !== null) out[k] = v;\n }\n return out;\n }\n return data;\n },\n z.object({\n subcommand: z.enum(DECISION_SUBCOMMANDS),\n sessionKey: z.string().trim().max(512).optional(),\n namespace: z.string().trim().max(256).optional(),\n id: z.string().trim().max(512).optional(),\n title: z.string().trim().max(512).optional(),\n status: z.string().trim().max(64).optional(),\n context: z.string().trim().max(8192).optional(),\n decision: z.string().trim().max(8192).optional(),\n consequences: z.string().trim().max(8192).optional(),\n entityRefs: z.array(z.string().trim().min(1).max(256)).optional(),\n supersedesId: z.string().trim().max(512).optional(),\n }),\n);\n\nexport type CodingDecisionInput = DecisionSurfaceRequest;\nexport type CodingDecisionOutput = { result: DecisionSurfaceResponse };\n\nexport const codingDecisionOperation = defineOperation<\n CodingDecisionInput,\n CodingDecisionOutput\n>({\n name: \"coding_decision\",\n description:\n \"List, get, record, or supersede decision records in the session's coding namespace (issue #1548 Track A).\",\n schema: codingDecisionSchema as z.ZodType<CodingDecisionInput>,\n handler: async (input, ctx) => {\n const result = await ctx.service.codingDecision(input, ctx.authenticatedPrincipal);\n return { result };\n },\n});\n\n// ---------------------------------------------------------------------------\n// coding_architecture — architecture-card surfaces (issue #1548 Track A PR 3)\n// ---------------------------------------------------------------------------\n\nconst codingArchitectureSchema = z.preprocess(\n (data) => {\n if (data !== null && typeof data === \"object\" && !Array.isArray(data)) {\n const obj = data as Record<string, unknown>;\n const cleaned: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (value !== null) cleaned[key] = value;\n }\n return cleaned;\n }\n return data;\n },\n z.object({\n subcommand: z.enum([\"get\", \"refresh\"]),\n sessionKey: z.string().optional(),\n namespace: z.string().optional(),\n }),\n);\n\nexport type CodingArchitectureInput = ArchitectureSurfaceRequest;\nexport type CodingArchitectureOutput = { result: ArchitectureSurfaceResponse };\n\nexport const codingArchitectureOperation = defineOperation<\n CodingArchitectureInput,\n CodingArchitectureOutput\n>({\n name: \"coding_architecture\",\n description:\n \"Get or refresh the architecture card for the session's coding namespace (issue #1548 Track A PR 3).\",\n schema: codingArchitectureSchema as z.ZodType<CodingArchitectureInput>,\n handler: async (input, ctx) => {\n const result = await ctx.service.codingArchitecture(input, ctx.authenticatedPrincipal);\n return { result };\n },\n});\n\nconst codegraphSurfaceSchema = z.preprocess(\n (data) => {\n if (data !== null && typeof data === \"object\" && !Array.isArray(data)) {\n const obj = data as Record<string, unknown>;\n const cleaned: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (value !== null) cleaned[key] = value;\n }\n return cleaned;\n }\n return data;\n },\n z.object({\n tool: z.string().refine(isCodegraphToolName, {\n message: \"tool must be one of the codegraph tool names\",\n }),\n sessionKey: z.string().max(512).optional(),\n principal: z.string().max(256).optional(),\n project: z.string().max(256).optional(),\n query: z.string().max(2048).optional(),\n limit: z.number().int().positive().max(200).optional(),\n start: z.string().max(512).optional(),\n direction: z.string().max(64).optional(),\n depth: z.number().int().positive().max(10).optional(),\n qualifiedName: z.string().max(1024).optional(),\n path: z.string().max(2048).optional(),\n structuredQuery: z.record(z.string(), z.unknown()).optional(),\n head: z.string().max(256).optional(),\n repoRoot: z.string().max(2048).optional(),\n mode: z.string().max(64).optional(),\n confirm: z.boolean().optional(),\n subcommand: z.string().max(64).optional(),\n id: z.string().max(512).optional(),\n title: z.string().max(512).optional(),\n status: z.string().max(64).optional(),\n context: z.string().max(8192).optional(),\n decision: z.string().max(8192).optional(),\n consequences: z.string().max(8192).optional(),\n entityRefs: z.array(z.string().max(256)).optional(),\n supersedesId: z.string().max(512).optional(),\n traces: z.array(z.unknown()).optional(),\n }),\n) as z.ZodType<CodegraphSurfaceRequest>;\n\n// ---------------------------------------------------------------------------\n// coding_delta — session-delta surface (issue #1548 Track A PR 4)\n// ---------------------------------------------------------------------------\n\nconst codingDeltaSchema = z.preprocess(\n (data) => {\n if (data !== null && typeof data === \"object\" && !Array.isArray(data)) {\n const obj = data as Record<string, unknown>;\n const cleaned: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (value !== null) cleaned[key] = value;\n }\n return cleaned;\n }\n return data;\n },\n z.object({\n subcommand: z.enum(DELTA_SUBCOMMANDS),\n sessionKey: z.string().trim().max(512).optional(),\n namespace: z.string().trim().max(256).optional(),\n }),\n);\n\nexport type CodingDeltaInput = DeltaSurfaceRequest;\nexport type CodingDeltaOutput = { result: DeltaSurfaceResponse };\n\nexport const codingDeltaOperation = defineOperation<\n CodingDeltaInput,\n CodingDeltaOutput\n>({\n name: \"coding_delta\",\n description:\n \"Get the session delta (commits + touched files since last seen) for the session's coding namespace (issue #1548 Track A PR 4).\",\n schema: codingDeltaSchema as z.ZodType<CodingDeltaInput>,\n handler: async (input, ctx) => {\n const result = await ctx.service.codingDelta(input, ctx.authenticatedPrincipal);\n return { result };\n },\n});\n\n// ---------------------------------------------------------------------------\n// memory_correct_plan / memory_correct_apply — Correction Contract (#1580)\n// ---------------------------------------------------------------------------\n//\n// One plan/apply pipeline for every memory correction (supersession,\n// invalidation, tombstone, edit, rescope, redaction). The MCP/HTTP/CLI\n// surfaces all dispatch through these two ops so the boundary's validation +\n// error mapping reach every correction path (rule 22 / 39).\n\nconst memoryCorrectPlanSchema = z.preprocess(\n (data) => {\n if (data && typeof data === \"object\" && !Array.isArray(data)) {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(data as Record<string, unknown>)) {\n if (v !== null) out[k] = v;\n }\n return out;\n }\n return data;\n },\n z.object({\n text: z.string().trim().min(1).max(10_000),\n targetIds: z.array(z.string().trim().min(1).max(512)).optional(),\n sessionKey: z.string().trim().max(512).optional(),\n namespace: z.string().trim().max(256).optional(),\n }),\n);\n\nexport interface MemoryCorrectPlanInput {\n text: string;\n targetIds?: string[];\n sessionKey?: string;\n namespace?: string;\n}\n\nexport interface MemoryCorrectPlanOutput {\n readonly result: unknown; // CorrectionPlan — opaque to the boundary\n}\n\nexport const memoryCorrectPlanOperation = defineOperation<\n MemoryCorrectPlanInput,\n MemoryCorrectPlanOutput\n>({\n name: \"memory_correct_plan\",\n description:\n \"Plan a memory correction from a plain-language statement (issue #1580). Returns a CorrectionPlan with a diff preview; apply via memory_correct_apply.\",\n schema: memoryCorrectPlanSchema as z.ZodType<MemoryCorrectPlanInput>,\n handler: async (input, ctx) => {\n try {\n const result = await ctx.service.correctionPlan({\n text: input.text,\n ...(input.targetIds ? { targetIds: input.targetIds } : {}),\n ...(input.sessionKey ? { sessionKey: input.sessionKey } : {}),\n ...(input.namespace ? { namespace: input.namespace } : {}),\n ...(ctx.authenticatedPrincipal ? { principal: ctx.authenticatedPrincipal } : {}),\n });\n return { result };\n } catch (err) {\n if (err instanceof CorrectionContractError) throw new EngramAccessInputError(err.message);\n throw err;\n }\n },\n});\n\nconst memoryCorrectApplySchema = z.preprocess(\n (data) => {\n if (data && typeof data === \"object\" && !Array.isArray(data)) {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(data as Record<string, unknown>)) {\n if (v !== null) out[k] = v;\n }\n return out;\n }\n return data;\n },\n z.object({\n planId: z.string().trim().min(1).max(512),\n confirm: z.boolean().optional(),\n sessionKey: z.string().trim().max(512).optional(),\n namespace: z.string().trim().max(256).optional(),\n }),\n);\n\nexport interface MemoryCorrectApplyInput {\n planId: string;\n confirm?: boolean;\n sessionKey?: string;\n namespace?: string;\n}\n\nexport interface MemoryCorrectApplyOutput {\n readonly result: unknown; // CorrectionOutcome — opaque to the boundary\n}\n\nexport const memoryCorrectApplyOperation = defineOperation<\n MemoryCorrectApplyInput,\n MemoryCorrectApplyOutput\n>({\n name: \"memory_correct_apply\",\n description:\n \"Apply a planned memory correction by planId (issue #1580). Requires confirm: true when correction.applyRequiresConfirm is on (default).\",\n schema: memoryCorrectApplySchema as z.ZodType<MemoryCorrectApplyInput>,\n handler: async (input, ctx) => {\n try {\n const result = await ctx.service.correctionApply(input.planId, {\n confirm: input.confirm === true,\n ...(input.sessionKey ? { sessionKey: input.sessionKey } : {}),\n ...(input.namespace ? { namespace: input.namespace } : {}),\n ...(ctx.authenticatedPrincipal ? { principal: ctx.authenticatedPrincipal } : {}),\n });\n return { result };\n } catch (err) {\n if (err instanceof CorrectionContractError) throw new EngramAccessInputError(err.message);\n throw err;\n }\n },\n});\n\n// ---------------------------------------------------------------------------\n// Surface registration map — what each transport calls the pilot ops\n// ---------------------------------------------------------------------------\n\n/**\n * The canonical short names (no `engram.`/`remnic.` prefix) of the operations\n * the boundary owns today. The fitness test treats this set as the migrated\n * set; everything else on a surface is unmigrated and counted by the ratchet.\n */\nexport const codegraphIndexOperation = defineOperation<\n CodegraphSurfaceRequest,\n { result: CodegraphSurfaceResponse }\n>({\n name: \"codegraph_index\",\n description:\n \"Codegraph parity tool (issue #1554): index. Delegates to the shared codegraph surface handler.\",\n schema: codegraphSurfaceSchema,\n handler: async (input, ctx) => {\n const result = await ctx.service.codegraphTool(input, ctx.authenticatedPrincipal);\n return { result };\n },\n});\n\nexport const codegraphListProjectsOperation = defineOperation<\n CodegraphSurfaceRequest,\n { result: CodegraphSurfaceResponse }\n>({\n name: \"codegraph_list_projects\",\n description:\n \"Codegraph parity tool (issue #1554): list_projects. Delegates to the shared codegraph surface handler.\",\n schema: codegraphSurfaceSchema,\n handler: async (input, ctx) => {\n const result = await ctx.service.codegraphTool(input, ctx.authenticatedPrincipal);\n return { result };\n },\n});\n\nexport const codegraphDeleteProjectOperation = defineOperation<\n CodegraphSurfaceRequest,\n { result: CodegraphSurfaceResponse }\n>({\n name: \"codegraph_delete_project\",\n description:\n \"Codegraph parity tool (issue #1554): delete_project. Delegates to the shared codegraph surface handler.\",\n schema: codegraphSurfaceSchema,\n handler: async (input, ctx) => {\n const result = await ctx.service.codegraphTool(input, ctx.authenticatedPrincipal);\n return { result };\n },\n});\n\nexport const codegraphIndexStatusOperation = defineOperation<\n CodegraphSurfaceRequest,\n { result: CodegraphSurfaceResponse }\n>({\n name: \"codegraph_index_status\",\n description:\n \"Codegraph parity tool (issue #1554): index_status. Delegates to the shared codegraph surface handler.\",\n schema: codegraphSurfaceSchema,\n handler: async (input, ctx) => {\n const result = await ctx.service.codegraphTool(input, ctx.authenticatedPrincipal);\n return { result };\n },\n});\n\nexport const codegraphSearchGraphOperation = defineOperation<\n CodegraphSurfaceRequest,\n { result: CodegraphSurfaceResponse }\n>({\n name: \"codegraph_search_graph\",\n description:\n \"Codegraph parity tool (issue #1554): search_graph. Delegates to the shared codegraph surface handler.\",\n schema: codegraphSurfaceSchema,\n handler: async (input, ctx) => {\n const result = await ctx.service.codegraphTool(input, ctx.authenticatedPrincipal);\n return { result };\n },\n});\n\nexport const codegraphTracePathOperation = defineOperation<\n CodegraphSurfaceRequest,\n { result: CodegraphSurfaceResponse }\n>({\n name: \"codegraph_trace_path\",\n description:\n \"Codegraph parity tool (issue #1554): trace_path. Delegates to the shared codegraph surface handler.\",\n schema: codegraphSurfaceSchema,\n handler: async (input, ctx) => {\n const result = await ctx.service.codegraphTool(input, ctx.authenticatedPrincipal);\n return { result };\n },\n});\n\nexport const codegraphDetectChangesOperation = defineOperation<\n CodegraphSurfaceRequest,\n { result: CodegraphSurfaceResponse }\n>({\n name: \"codegraph_detect_changes\",\n description:\n \"Codegraph parity tool (issue #1554): detect_changes. Delegates to the shared codegraph surface handler.\",\n schema: codegraphSurfaceSchema,\n handler: async (input, ctx) => {\n const result = await ctx.service.codegraphTool(input, ctx.authenticatedPrincipal);\n return { result };\n },\n});\n\nexport const codegraphQueryGraphOperation = defineOperation<\n CodegraphSurfaceRequest,\n { result: CodegraphSurfaceResponse }\n>({\n name: \"codegraph_query_graph\",\n description:\n \"Codegraph parity tool (issue #1554): query_graph. Delegates to the shared codegraph surface handler.\",\n schema: codegraphSurfaceSchema,\n handler: async (input, ctx) => {\n const result = await ctx.service.codegraphTool(input, ctx.authenticatedPrincipal);\n return { result };\n },\n});\n\nexport const codegraphGetSchemaOperation = defineOperation<\n CodegraphSurfaceRequest,\n { result: CodegraphSurfaceResponse }\n>({\n name: \"codegraph_get_schema\",\n description:\n \"Codegraph parity tool (issue #1554): get_schema. Delegates to the shared codegraph surface handler.\",\n schema: codegraphSurfaceSchema,\n handler: async (input, ctx) => {\n const result = await ctx.service.codegraphTool(input, ctx.authenticatedPrincipal);\n return { result };\n },\n});\n\nexport const codegraphGetSnippetOperation = defineOperation<\n CodegraphSurfaceRequest,\n { result: CodegraphSurfaceResponse }\n>({\n name: \"codegraph_get_snippet\",\n description:\n \"Codegraph parity tool (issue #1554): get_snippet. Delegates to the shared codegraph surface handler.\",\n schema: codegraphSurfaceSchema,\n handler: async (input, ctx) => {\n const result = await ctx.service.codegraphTool(input, ctx.authenticatedPrincipal);\n return { result };\n },\n});\n\nexport const codegraphGetArchitectureOperation = defineOperation<\n CodegraphSurfaceRequest,\n { result: CodegraphSurfaceResponse }\n>({\n name: \"codegraph_get_architecture\",\n description:\n \"Codegraph parity tool (issue #1554): get_architecture. Delegates to the shared codegraph surface handler.\",\n schema: codegraphSurfaceSchema,\n handler: async (input, ctx) => {\n const result = await ctx.service.codegraphTool(input, ctx.authenticatedPrincipal);\n return { result };\n },\n});\n\nexport const codegraphSearchCodeOperation = defineOperation<\n CodegraphSurfaceRequest,\n { result: CodegraphSurfaceResponse }\n>({\n name: \"codegraph_search_code\",\n description:\n \"Codegraph parity tool (issue #1554): search_code. Delegates to the shared codegraph surface handler.\",\n schema: codegraphSurfaceSchema,\n handler: async (input, ctx) => {\n const result = await ctx.service.codegraphTool(input, ctx.authenticatedPrincipal);\n return { result };\n },\n});\n\nexport const codegraphManageAdrOperation = defineOperation<\n CodegraphSurfaceRequest,\n { result: CodegraphSurfaceResponse }\n>({\n name: \"codegraph_manage_adr\",\n description:\n \"Codegraph parity tool (issue #1554): manage_adr. Delegates to the shared codegraph surface handler.\",\n schema: codegraphSurfaceSchema,\n handler: async (input, ctx) => {\n const result = await ctx.service.codegraphTool(input, ctx.authenticatedPrincipal);\n return { result };\n },\n});\n\nexport const codegraphIngestTracesOperation = defineOperation<\n CodegraphSurfaceRequest,\n { result: CodegraphSurfaceResponse }\n>({\n name: \"codegraph_ingest_traces\",\n description:\n \"Codegraph parity tool (issue #1554): ingest_traces. Delegates to the shared codegraph surface handler.\",\n schema: codegraphSurfaceSchema,\n handler: async (input, ctx) => {\n const result = await ctx.service.codegraphTool(input, ctx.authenticatedPrincipal);\n return { result };\n },\n});\n\n// Batch-migrated operations (issue #1525): registers all remaining\n// handlers through the boundary as a side effect of importing this module.\nimport \"./access-operations-batch.js\";\n\nexport const REGISTERED_OPERATIONS = [\n memoryGetOperation.spec.name,\n memorySearchOperation.spec.name,\n memoryStoreOperation.spec.name,\n codingDecisionOperation.spec.name,\n codingArchitectureOperation.spec.name,\n codegraphIndexOperation.spec.name,\n codegraphListProjectsOperation.spec.name,\n codegraphDeleteProjectOperation.spec.name,\n codegraphIndexStatusOperation.spec.name,\n codegraphSearchGraphOperation.spec.name,\n codegraphTracePathOperation.spec.name,\n codegraphDetectChangesOperation.spec.name,\n codegraphQueryGraphOperation.spec.name,\n codegraphGetSchemaOperation.spec.name,\n codegraphGetSnippetOperation.spec.name,\n codegraphGetArchitectureOperation.spec.name,\n codegraphSearchCodeOperation.spec.name,\n codegraphManageAdrOperation.spec.name,\n codegraphIngestTracesOperation.spec.name,\n codingDeltaOperation.spec.name,\n memoryCorrectPlanOperation.spec.name,\n memoryCorrectApplyOperation.spec.name,\n] as const;\n"],"mappings":";;;;;;;;;;;;;;;AAcA,SAAS,SAAS;AA4ClB,IAAM,kBAAkB,EAAE,OAAO;AAAA,EAC/B,UAAU,EAAE,OA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AI,sBAAsB;AAChF,WAAO,EAAE,OAAO;AAAA,EAClB;AACF,CAAC;AAMM,IAAM,wBAAwB;AAAA,EACnC,mBAAmB,KAAK;AAAA,EACxB,sBAAsB,KAAK;AAAA,EAC3B,qBAAqB,KAAK;AAAA,EAC1B,wBAAwB,KAAK;AAAA,EAC7B,4BAA4B,KAAK;AAAA,EACjC,wBAAwB,KAAK;AAAA,EAC7B,+BAA+B,KAAK;AAAA,EACpC,gCAAgC,KAAK;AAAA,EACrC,8BAA8B,KAAK;AAAA,EACnC,8BAA8B,KAAK;AAAA,EACnC,4BAA4B,KAAK;AAAA,EACjC,gCAAgC,KAAK;AAAA,EACrC,6BAA6B,KAAK;AAAA,EAClC,4BAA4B,KAAK;AAAA,EACjC,6BAA6B,KAAK;AAAA,EAClC,kCAAkC,KAAK;AAAA,EACvC,6BAA6B,KAAK;AAAA,EAClC,4BAA4B,KAAK;AAAA,EACjC,+BAA+B,KAAK;AAAA,EACpC,qBAAqB,KAAK;AAAA,EAC1B,2BAA2B,KAAK;AAAA,EAChC,4BAA4B,KAAK;AACnC;","names":[]}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// src/recall-handles.ts
|
|
2
|
+
import { createHash } from "crypto";
|
|
3
|
+
var HANDLE_DEFAULT_WIDTH = 4;
|
|
4
|
+
var HANDLE_EXTENDED_WIDTH = 6;
|
|
5
|
+
var HANDLE_MIN_WIDTH = 4;
|
|
6
|
+
var HANDLE_MAX_WIDTH = 8;
|
|
7
|
+
var HANDLE_REGEX = /\[m:[0-9a-f]{4,8}\]/g;
|
|
8
|
+
var MEMORY_ID_PATTERN = /^[a-z][a-z0-9_]*-\d+-[a-z0-9-]+$/;
|
|
9
|
+
function handleFor(memoryId, width = HANDLE_DEFAULT_WIDTH) {
|
|
10
|
+
const w = clampWidth(width);
|
|
11
|
+
return createHash("sha256").update(memoryId).digest("hex").slice(0, w);
|
|
12
|
+
}
|
|
13
|
+
function clampWidth(width) {
|
|
14
|
+
if (!Number.isFinite(width)) return HANDLE_DEFAULT_WIDTH;
|
|
15
|
+
return Math.min(HANDLE_MAX_WIDTH, Math.max(HANDLE_MIN_WIDTH, Math.floor(width)));
|
|
16
|
+
}
|
|
17
|
+
function renderHandle(memoryId, widthOverride) {
|
|
18
|
+
return `[m:${handleFor(memoryId, widthOverride ?? HANDLE_DEFAULT_WIDTH)}]`;
|
|
19
|
+
}
|
|
20
|
+
function appendHandle(line, memoryId, widthOverride) {
|
|
21
|
+
const handle = renderHandle(memoryId, widthOverride);
|
|
22
|
+
const trimmed = line.replace(/\s+$/, "");
|
|
23
|
+
return `${trimmed} ${handle}`;
|
|
24
|
+
}
|
|
25
|
+
function renderHandlesForInjection(memoryIds) {
|
|
26
|
+
const idsByDefaultHandle = /* @__PURE__ */ new Map();
|
|
27
|
+
for (const memoryId of memoryIds) {
|
|
28
|
+
if (!memoryId) continue;
|
|
29
|
+
const defaultHandle = handleFor(memoryId, HANDLE_DEFAULT_WIDTH);
|
|
30
|
+
const group = idsByDefaultHandle.get(defaultHandle);
|
|
31
|
+
if (group) group.push(memoryId);
|
|
32
|
+
else idsByDefaultHandle.set(defaultHandle, [memoryId]);
|
|
33
|
+
}
|
|
34
|
+
const entries = [];
|
|
35
|
+
for (const memoryId of memoryIds) {
|
|
36
|
+
if (!memoryId) continue;
|
|
37
|
+
const defaultHandle = handleFor(memoryId, HANDLE_DEFAULT_WIDTH);
|
|
38
|
+
const group = idsByDefaultHandle.get(defaultHandle) ?? [memoryId];
|
|
39
|
+
const width = group.length > 1 ? HANDLE_EXTENDED_WIDTH : HANDLE_DEFAULT_WIDTH;
|
|
40
|
+
entries.push({ memoryId, width, handle: `[m:${handleFor(memoryId, width)}]` });
|
|
41
|
+
}
|
|
42
|
+
let widened = true;
|
|
43
|
+
while (widened) {
|
|
44
|
+
widened = false;
|
|
45
|
+
const tokenToIndices = /* @__PURE__ */ new Map();
|
|
46
|
+
for (let i = 0; i < entries.length; i++) {
|
|
47
|
+
const token = entries[i].handle;
|
|
48
|
+
const arr = tokenToIndices.get(token);
|
|
49
|
+
if (arr) arr.push(i);
|
|
50
|
+
else tokenToIndices.set(token, [i]);
|
|
51
|
+
}
|
|
52
|
+
for (const indices of tokenToIndices.values()) {
|
|
53
|
+
if (indices.length < 2) continue;
|
|
54
|
+
const uniqueIds = new Set(indices.map((idx) => entries[idx].memoryId));
|
|
55
|
+
if (uniqueIds.size < 2) continue;
|
|
56
|
+
let anyWidened = false;
|
|
57
|
+
for (const idx of indices) {
|
|
58
|
+
const entry = entries[idx];
|
|
59
|
+
if (entry.width >= HANDLE_MAX_WIDTH) continue;
|
|
60
|
+
entry.width += 1;
|
|
61
|
+
entry.handle = `[m:${handleFor(entry.memoryId, entry.width)}]`;
|
|
62
|
+
anyWidened = true;
|
|
63
|
+
}
|
|
64
|
+
if (anyWidened) widened = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return entries;
|
|
68
|
+
}
|
|
69
|
+
function buildHandleIndexForResults(results, enabled) {
|
|
70
|
+
if (!enabled) return /* @__PURE__ */ new Map();
|
|
71
|
+
const ids = [];
|
|
72
|
+
const idIndexByResult = results.map((r) => {
|
|
73
|
+
const match = r.path.match(/([^/]+)\.md$/);
|
|
74
|
+
if (!match) return null;
|
|
75
|
+
const candidate = match[1];
|
|
76
|
+
if (!MEMORY_ID_PATTERN.test(candidate)) return null;
|
|
77
|
+
ids.push(candidate);
|
|
78
|
+
return ids.length - 1;
|
|
79
|
+
});
|
|
80
|
+
const entries = renderHandlesForInjection(ids);
|
|
81
|
+
const handleByIndex = /* @__PURE__ */ new Map();
|
|
82
|
+
results.forEach((_r, i) => {
|
|
83
|
+
const idIndex = idIndexByResult[i];
|
|
84
|
+
if (idIndex === null) return;
|
|
85
|
+
const entry = entries[idIndex];
|
|
86
|
+
if (entry) handleByIndex.set(i, entry.handle);
|
|
87
|
+
});
|
|
88
|
+
return handleByIndex;
|
|
89
|
+
}
|
|
90
|
+
function parseHandles(text) {
|
|
91
|
+
if (typeof text !== "string" || text.length === 0) return [];
|
|
92
|
+
const out = [];
|
|
93
|
+
HANDLE_REGEX.lastIndex = 0;
|
|
94
|
+
let match;
|
|
95
|
+
while ((match = HANDLE_REGEX.exec(text)) !== null) {
|
|
96
|
+
out.push(match[0]);
|
|
97
|
+
}
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
function stripHandles(text) {
|
|
101
|
+
if (typeof text !== "string" || text.length === 0) return text;
|
|
102
|
+
return text.replace(/\s?\[m:[0-9a-f]{4,8}\]/g, "").replace(/[ \t]{2,}/g, " ").replace(/[ \t]+$/g, "");
|
|
103
|
+
}
|
|
104
|
+
function normalizeHandle(token) {
|
|
105
|
+
if (typeof token !== "string" || token.length === 0) return null;
|
|
106
|
+
const trimmed = token.trim().toLowerCase();
|
|
107
|
+
const bracketed = /^\[m:([0-9a-f]{4,8})\]$/.exec(trimmed);
|
|
108
|
+
if (bracketed) return bracketed[1] ?? null;
|
|
109
|
+
const prefixed = /^m:([0-9a-f]{4,8})$/.exec(trimmed);
|
|
110
|
+
if (prefixed) return prefixed[1] ?? null;
|
|
111
|
+
const bare = /^([0-9a-f]{4,8})$/.exec(trimmed);
|
|
112
|
+
if (bare) return bare[1] ?? null;
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
function isHandleToken(token) {
|
|
116
|
+
return normalizeHandle(token) !== null;
|
|
117
|
+
}
|
|
118
|
+
function parseIdOrHandle(ref) {
|
|
119
|
+
const hex = normalizeHandle(ref);
|
|
120
|
+
if (hex !== null) {
|
|
121
|
+
return { raw: ref, isHandle: true, value: hex };
|
|
122
|
+
}
|
|
123
|
+
return { raw: ref, isHandle: false, value: ref };
|
|
124
|
+
}
|
|
125
|
+
function resolveHandle(handle, snapshots, depth = DEFAULT_HANDLE_SNAPSHOT_DEPTH) {
|
|
126
|
+
const hex = normalizeHandle(handle);
|
|
127
|
+
if (hex === null) {
|
|
128
|
+
return { ok: false, reason: "not_found" };
|
|
129
|
+
}
|
|
130
|
+
const width = hex.length;
|
|
131
|
+
const limit = Math.max(0, Math.min(depth, snapshots.length));
|
|
132
|
+
const matches = /* @__PURE__ */ new Set();
|
|
133
|
+
for (let i = 0; i < limit; i += 1) {
|
|
134
|
+
const snap = snapshots[i];
|
|
135
|
+
if (!snap) continue;
|
|
136
|
+
for (const memoryId of snap.memoryIds) {
|
|
137
|
+
if (!memoryId) continue;
|
|
138
|
+
if (handleFor(memoryId, width) === hex) {
|
|
139
|
+
matches.add(memoryId);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (matches.size === 0) {
|
|
144
|
+
return { ok: false, reason: "not_found" };
|
|
145
|
+
}
|
|
146
|
+
if (matches.size === 1) {
|
|
147
|
+
return { ok: true, memoryId: matches.values().next().value };
|
|
148
|
+
}
|
|
149
|
+
return { ok: false, reason: "ambiguous", candidates: [...matches] };
|
|
150
|
+
}
|
|
151
|
+
var DEFAULT_HANDLE_SNAPSHOT_DEPTH = 5;
|
|
152
|
+
|
|
153
|
+
export {
|
|
154
|
+
HANDLE_DEFAULT_WIDTH,
|
|
155
|
+
HANDLE_EXTENDED_WIDTH,
|
|
156
|
+
HANDLE_MIN_WIDTH,
|
|
157
|
+
HANDLE_MAX_WIDTH,
|
|
158
|
+
HANDLE_REGEX,
|
|
159
|
+
MEMORY_ID_PATTERN,
|
|
160
|
+
handleFor,
|
|
161
|
+
renderHandle,
|
|
162
|
+
appendHandle,
|
|
163
|
+
renderHandlesForInjection,
|
|
164
|
+
buildHandleIndexForResults,
|
|
165
|
+
parseHandles,
|
|
166
|
+
stripHandles,
|
|
167
|
+
normalizeHandle,
|
|
168
|
+
isHandleToken,
|
|
169
|
+
parseIdOrHandle,
|
|
170
|
+
resolveHandle,
|
|
171
|
+
DEFAULT_HANDLE_SNAPSHOT_DEPTH
|
|
172
|
+
};
|
|
173
|
+
//# sourceMappingURL=chunk-JAKIDQB2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/recall-handles.ts"],"sourcesContent":["/**\n * recall-handles.ts — injection-time memory handles (issue #1582).\n *\n * Every injected memory gets a stable short handle — `[m:4f2a]` — so a user\n * (or the agent) can react to ONE specific memory in-band (\"[m:4f2a] is\n * stale\", thumbs-down, \"correct that\") without a context switch to a CLI or\n * console. The handle is derived from the memory **id** (never the content),\n * so it is stable across edits/versioning.\n *\n * This module is PURE — no I/O, no side effects, no state. It owns:\n * - {@link handleFor} — deterministic 4-hex handle from a memory id.\n * - {@link renderHandle} / {@link renderHandlesForInjection} — render the\n * `[m:xxxx]` token for one memory (or a whole injection set, extending to\n * 6 chars on intra-injection collision).\n * - {@link parseHandles} — extract handle tokens from prose.\n * - {@link normalizeHandle} / {@link isHandleToken} — classify a string.\n * - {@link resolveHandle} — map a handle back to a memory id against the\n * session's recent recall snapshots (hit / not-found / ambiguous).\n *\n * Design rules honored (issue #1582 design + pitfalls):\n * - Handles are derived from the id only — never hashed with content, never\n * persisted into memory files or rawContent (rule 23). Rendering happens\n * at injection time only.\n * - Resolution is per-session and snapshot-scoped — there is NEVER a global\n * handle→id map (collision space too small globally, leaks across\n * principals — rule 42). Misses are tagged, never guessed (rule 34/51).\n * - The formatter is allocation-light: a string append at render time, no\n * per-memory object churn, because it runs on every recall.\n */\n\nimport { createHash } from \"node:crypto\";\n\n/**\n * Default handle width in hex characters (4 → 65 536-handle space).\n * Per-injection sets are ~10–40 memories, so in-context collisions are\n * vanishingly rare; {@link renderHandlesForInjection} widens the colliding\n * member to {@link HANDLE_EXTENDED_WIDTH} when two ids in ONE injection would\n * collide.\n */\nexport const HANDLE_DEFAULT_WIDTH = 4;\n\n/**\n * Width used to disambiguate two ids that collide at the default width within\n * a single injection. 6 hex chars → ~16 M-handle space, which is comfortably\n * beyond per-injection set sizes.\n */\nexport const HANDLE_EXTENDED_WIDTH = 6;\n\n/** Minimum/maximum accepted hex widths for a rendered/parsed handle. */\nexport const HANDLE_MIN_WIDTH = 4;\nexport const HANDLE_MAX_WIDTH = 8;\n\n/**\n * Regex matching a rendered handle token anywhere in prose: `[m:` followed by\n * 4–8 lowercase hex chars and a closing `]`. Malformed tokens (`[m:xyz!]`,\n * `[m:abc]` with uppercase, missing bracket) are intentionally NOT matched.\n * Used by {@link parseHandles} and the sanitizer.\n */\nexport const HANDLE_REGEX = /\\[m:[0-9a-f]{4,8}\\]/g;\n\n/**\n * Memory ids are `<category>-<timestamp>-<suffix>` (e.g. `fact-1770469224307-eelr`,\n * `artifact-...`, `reasoning_trace-...`, plus parent-`-chunk-N` variants). The\n * category segment allows underscores because `MemoryCategory` includes\n * `reasoning_trace` (codex review); bare names (`Widget`) still fail. Entity\n * reconstructions and other non-memory `.md` rows use bare names (`Widget`)\n * that must NOT receive a handle — citing one would resolve to a basename no\n * storage can load. This pattern gates handle rendering/recording to plausible\n * memory ids only (issue #1582, codex review).\n */\nexport const MEMORY_ID_PATTERN = /^[a-z][a-z0-9_]*-\\d+-[a-z0-9-]+$/;\n\n/**\n * Derive the deterministic handle hex for a memory id at a given width.\n *\n * `handleFor(id) === handleFor(id)` always, and `handleFor(id, w)` is a prefix\n * of `handleFor(id, w+1)` (both slice the same sha256 hex digest), so widening\n * for collision-disambiguation never changes the shorter prefix.\n *\n * @param memoryId Stable memory id (e.g. `fact-1770469224307-eelr`).\n * @param width Hex width. Defaults to {@link HANDLE_DEFAULT_WIDTH}.\n * Clamped to [4, 8]; the digest has 64 hex chars available.\n */\nexport function handleFor(memoryId: string, width: number = HANDLE_DEFAULT_WIDTH): string {\n const w = clampWidth(width);\n return createHash(\"sha256\").update(memoryId).digest(\"hex\").slice(0, w);\n}\n\nfunction clampWidth(width: number): number {\n if (!Number.isFinite(width)) return HANDLE_DEFAULT_WIDTH;\n return Math.min(HANDLE_MAX_WIDTH, Math.max(HANDLE_MIN_WIDTH, Math.floor(width)));\n}\n\n/**\n * Render the `[m:xxxx]` token for one memory id. Width override is for the\n * collision-extension path in {@link renderHandlesForInjection}; callers that\n * render a single handle in isolation should omit it.\n */\nexport function renderHandle(memoryId: string, widthOverride?: number): string {\n return `[m:${handleFor(memoryId, widthOverride ?? HANDLE_DEFAULT_WIDTH)}]`;\n}\n\n/**\n * Append a handle to a memory line, allocation-light. When `widthOverride` is\n * omitted the default-width handle is used; pass the widened width from\n * {@link renderHandlesForInjection} for a colliding member.\n *\n * appendHandle(\"API rate limit is 1000 rpm.\", \"fact-1-abc\")\n * // → \"API rate limit is 1000 rpm. [m:4f2a]\"\n */\nexport function appendHandle(line: string, memoryId: string, widthOverride?: number): string {\n const handle = renderHandle(memoryId, widthOverride);\n // Single trailing space before the handle; collapse a double space if the\n // line already ended in whitespace so output stays clean.\n const trimmed = line.replace(/\\s+$/, \"\");\n return `${trimmed} ${handle}`;\n}\n\n/**\n * Result of {@link renderHandlesForInjection}: for each memory id, the width\n * used (default 4, or 6 when widened to break an intra-injection collision)\n * and the rendered token. Ordered for stable iteration.\n */\nexport interface InjectionHandleEntry {\n memoryId: string;\n width: number;\n handle: string;\n}\n\n/**\n * Build handles for a whole injection set, widening to 6 chars when two ids\n * collide at the default width within THIS set (so each rendered token is\n * unique in context). Idempotent for the same input.\n *\n * The collision case is vanishingly rare (~10–40 memories per injection), but\n * widening guarantees a user can always point at exactly one memory in-band.\n */\nexport function renderHandlesForInjection(\n memoryIds: readonly string[],\n): InjectionHandleEntry[] {\n // Group ids by their default-width handle so every member of a 4-char\n // collision group widens to 6 together — not just the later one. Widening\n // only the second id would leave the first rendering a 4-char token whose\n // resolution is ambiguous against the group (codex review).\n const idsByDefaultHandle = new Map<string, string[]>();\n for (const memoryId of memoryIds) {\n if (!memoryId) continue;\n const defaultHandle = handleFor(memoryId, HANDLE_DEFAULT_WIDTH);\n const group = idsByDefaultHandle.get(defaultHandle);\n if (group) group.push(memoryId);\n else idsByDefaultHandle.set(defaultHandle, [memoryId]);\n }\n const entries: InjectionHandleEntry[] = [];\n for (const memoryId of memoryIds) {\n if (!memoryId) continue;\n const defaultHandle = handleFor(memoryId, HANDLE_DEFAULT_WIDTH);\n const group = idsByDefaultHandle.get(defaultHandle) ?? [memoryId];\n const width = group.length > 1 ? HANDLE_EXTENDED_WIDTH : HANDLE_DEFAULT_WIDTH;\n entries.push({ memoryId, width, handle: `[m:${handleFor(memoryId, width)}]` });\n }\n // Reconciliation pass: if two DIFFERENT ids still produce the same rendered\n // token at their assigned width — the pathological case where they also\n // collide at the extended 6-char width — widen ALL members of the collision\n // group together, never just the later one. Leaving the first at 6 chars\n // while widening the second to 7 makes the first token resolve ambiguously\n // (both ids match at width 6). Iterate until no collision remains or every\n // member reaches HANDLE_MAX_WIDTH (codex review).\n let widened = true;\n while (widened) {\n widened = false;\n const tokenToIndices = new Map<string, number[]>();\n for (let i = 0; i < entries.length; i++) {\n const token = entries[i]!.handle;\n const arr = tokenToIndices.get(token);\n if (arr) arr.push(i);\n else tokenToIndices.set(token, [i]);\n }\n for (const indices of tokenToIndices.values()) {\n if (indices.length < 2) continue;\n const uniqueIds = new Set(indices.map((idx) => entries[idx]!.memoryId));\n if (uniqueIds.size < 2) continue; // same id listed twice — same handle is fine\n // Only continue widening if at least one entry has room to grow.\n // When every member has reached HANDLE_MAX_WIDTH the collision is\n // irreducible (two ids with identical sha256 8-char prefixes —\n // astronomically unlikely for real data); stop to avoid an infinite loop.\n let anyWidened = false;\n for (const idx of indices) {\n const entry = entries[idx]!;\n if (entry.width >= HANDLE_MAX_WIDTH) continue;\n entry.width += 1;\n entry.handle = `[m:${handleFor(entry.memoryId, entry.width)}]`;\n anyWidened = true;\n }\n if (anyWidened) widened = true;\n }\n }\n return entries;\n}\n\n/**\n * Build a `resultIndex → handle` map for a QMD result set. Returns an empty\n * map when handles are disabled or no result carries a handle-eligible memory\n * id. Extracted from the orchestrator's `formatQmdResults` so the rendering\n * logic lives in the pure handles module, not the god file (issue #1582,\n * rule 4).\n *\n * Only real memory ids (matching {@link MEMORY_ID_PATTERN}) are handle-eligible;\n * entity reconstructions and other non-memory `.md` rows get no handle.\n *\n * @param results QMD search results (each has a `path` like `…/fact-x.md`).\n * @param enabled Whether handle rendering is on. The caller gates on both the\n * config flag and session-key availability — handles rendered\n * without a session key can never be resolved, so they must\n * not be shown (cursor review of #1582).\n */\nexport function buildHandleIndexForResults(\n results: readonly { path: string }[],\n enabled: boolean,\n): Map<number, string> {\n if (!enabled) return new Map();\n const ids: string[] = [];\n const idIndexByResult: Array<number | null> = results.map((r) => {\n const match = r.path.match(/([^/]+)\\.md$/);\n if (!match) return null;\n const candidate = match[1] as string;\n if (!MEMORY_ID_PATTERN.test(candidate)) return null;\n ids.push(candidate);\n return ids.length - 1;\n });\n const entries = renderHandlesForInjection(ids);\n const handleByIndex = new Map<number, string>();\n results.forEach((_r, i) => {\n const idIndex = idIndexByResult[i];\n if (idIndex === null) return;\n const entry = entries[idIndex];\n if (entry) handleByIndex.set(i, entry.handle);\n });\n return handleByIndex;\n}\n\n/**\n * Extract every handle token from prose, in order of appearance. Returns the\n * full rendered tokens (e.g. `[m:4f2a]`) so callers can locate them in text.\n * Malformed tokens are ignored. Duplicates are preserved (a user may cite the\n * same memory twice).\n *\n * parseHandles(\"see [m:4f2a] (also [m:1b9e]) — not [m:xyz!]\")\n * // → [\"[m:4f2a]\", \"[m:1b9e]\"]\n */\nexport function parseHandles(text: string): string[] {\n if (typeof text !== \"string\" || text.length === 0) return [];\n const out: string[] = [];\n // Reset lastIndex because HANDLE_REGEX is /g and may be reused.\n HANDLE_REGEX.lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = HANDLE_REGEX.exec(text)) !== null) {\n out.push(match[0]);\n }\n return out;\n}\n\n/**\n * Strip every handle token from text, collapsing the spacing it introduced.\n * Used by the sanitizer so handles observed back into the pipeline never\n * become memory content (issue #1582 hygiene §2).\n *\n * stripHandles(\"API limit 1000 rpm. [m:4f2a]\") → \"API limit 1000 rpm.\"\n */\nexport function stripHandles(text: string): string {\n if (typeof text !== \"string\" || text.length === 0) return text;\n // Remove the token and the single preceding space that {@link appendHandle}\n // added, then tidy any double space left behind.\n // \\\\s? (not \\\\s*): the renderer appends exactly one preceding space, and a\n // bounded quantifier avoids the polynomial-ReDoS flag on uncontrolled input.\n // A stray run of spaces is collapsed by the following line.\n return text\n .replace(/\\s?\\[m:[0-9a-f]{4,8}\\]/g, \"\")\n .replace(/[ \\t]{2,}/g, \" \")\n .replace(/[ \\t]+$/g, \"\");\n}\n\n/**\n * Normalize a handle token (or bare hex) to its lowercase hex core, or `null`\n * when the input is not a handle. Accepts both the rendered `[m:4f2a]` form\n * and the bare `m:4f2a` / `4f2a` form a user might type.\n *\n * normalizeHandle(\"[m:4f2a]\") → \"4f2a\"\n * normalizeHandle(\"m:4f2a\") → \"4f2a\"\n * normalizeHandle(\"4f2a\") → \"4f2a\"\n * normalizeHandle(\"fact-1\") → null\n */\nexport function normalizeHandle(token: string): string | null {\n if (typeof token !== \"string\" || token.length === 0) return null;\n const trimmed = token.trim().toLowerCase();\n // [m:4f2a]\n const bracketed = /^\\[m:([0-9a-f]{4,8})\\]$/.exec(trimmed);\n if (bracketed) return bracketed[1] ?? null;\n // m:4f2a\n const prefixed = /^m:([0-9a-f]{4,8})$/.exec(trimmed);\n if (prefixed) return prefixed[1] ?? null;\n // bare 4f2a — only treat as a handle when it is pure hex in the width range,\n // so we don't mis-classify a real memory id that happens to be 4 hex chars.\n const bare = /^([0-9a-f]{4,8})$/.exec(trimmed);\n if (bare) return bare[1] ?? null;\n return null;\n}\n\n/**\n * Whether a string looks like a handle token (rendered or bare). Cheaper\n * boolean form of {@link normalizeHandle} for callers that only need to branch.\n */\nexport function isHandleToken(token: string): boolean {\n return normalizeHandle(token) !== null;\n}\n\n/**\n * A flattened id-or-handle reference: either a raw memory id or the hex core\n * of a handle. {@link resolveMemoryIdOrHandle} produces this so the snapshot\n * lookup only runs for actual handles.\n */\nexport interface ParsedIdOrHandle {\n /** The original reference as supplied by the caller. */\n raw: string;\n /** `true` when `raw` is a handle that still needs snapshot resolution. */\n isHandle: boolean;\n /** For a handle, its hex core; for a raw id, the id itself. */\n value: string;\n}\n\n/**\n * Classify a single caller reference as id-or-handle.\n */\nexport function parseIdOrHandle(ref: string): ParsedIdOrHandle {\n const hex = normalizeHandle(ref);\n if (hex !== null) {\n return { raw: ref, isHandle: true, value: hex };\n }\n return { raw: ref, isHandle: false, value: ref };\n}\n\n/**\n * A flattened view of the memory-id sets a session has recently recalled.\n * Each entry is one past recall's admitted memory ids (newest first).\n * Resolution never sees raw {@link LastRecallSnapshot}s — callers flatten to\n * this so the pure resolver has no dependency on the snapshot type.\n */\nexport interface RecallSnapshotIds {\n memoryIds: readonly string[];\n}\n\n/**\n * Result of resolving a handle against recent recall snapshots.\n * - `{ ok: true, memoryId }` — exactly one match within the lookback window.\n * - `{ ok: false, reason: \"not_found\" }` — no memory id produced this handle\n * within the window (misses are acceptable and tagged, never guessed).\n * - `{ ok: false, reason: \"ambiguous\", candidates }` — two DIFFERENT memory\n * ids in the window collide on the same handle; the caller must disambiguate\n * (rule 34/51: never guess).\n */\nexport type ResolveHandleResult =\n | { ok: true; memoryId: string }\n | { ok: false; reason: \"not_found\" }\n | { ok: false; reason: \"ambiguous\"; candidates: string[] };\n\n/**\n * Resolve a handle hex (or a rendered token / bare form) to its memory id\n * against the session's recent recall snapshots.\n *\n * @param handle A handle token, bare hex, or `m:hex` form.\n * @param snapshots Recent recall snapshots for the session, newest first.\n * Only the first `depth` entries are searched.\n * @param depth How many snapshots (newest-first) to search. Defaults to\n * {@link DEFAULT_HANDLE_SNAPSHOT_DEPTH}.\n */\nexport function resolveHandle(\n handle: string,\n snapshots: readonly RecallSnapshotIds[],\n depth: number = DEFAULT_HANDLE_SNAPSHOT_DEPTH,\n): ResolveHandleResult {\n const hex = normalizeHandle(handle);\n if (hex === null) {\n return { ok: false, reason: \"not_found\" };\n }\n // A handle resolves when a memory id's handle is a PREFIX of `hex` (handles\n // widened to 6 chars for collision still match their own 4-char core, and a\n // user citing the short form must still resolve the widened memory).\n const width = hex.length;\n const limit = Math.max(0, Math.min(depth, snapshots.length));\n const matches = new Set<string>();\n for (let i = 0; i < limit; i += 1) {\n const snap = snapshots[i];\n if (!snap) continue;\n for (const memoryId of snap.memoryIds) {\n if (!memoryId) continue;\n if (handleFor(memoryId, width) === hex) {\n matches.add(memoryId);\n }\n }\n }\n if (matches.size === 0) {\n return { ok: false, reason: \"not_found\" };\n }\n if (matches.size === 1) {\n return { ok: true, memoryId: matches.values().next().value as string };\n }\n return { ok: false, reason: \"ambiguous\", candidates: [...matches] };\n}\n\n/**\n * Default snapshot lookback depth for handle resolution (issue #1582 config\n * `recall.handleSnapshotDepth`). Older-than-N snapshots are not searched and a\n * miss is tagged rather than widening the window.\n */\nexport const DEFAULT_HANDLE_SNAPSHOT_DEPTH = 5;\n"],"mappings":";AA8BA,SAAS,kBAAkB;AASpB,IAAM,uBAAuB;AAO7B,IAAM,wBAAwB;AAG9B,IAAM,mBAAmB;AACzB,IAAM,mBAAmB;AAQzB,IAAM,eAAe;AAYrB,IAAM,oBAAoB;AAa1B,SAAS,UAAU,UAAkB,QAAgB,sBAA8B;AACxF,QAAM,IAAI,WAAW,KAAK;AAC1B,SAAO,WAAW,QAAQ,EAAE,OAAO,QAAQ,EAAE,OAAO,KAAK,EAAE,MAAM,GAAG,CAAC;AACvE;AAEA,SAAS,WAAW,OAAuB;AACzC,MAAI,CAAC,OAAO,SAAS,KAAK,EAAG,QAAO;AACpC,SAAO,KAAK,IAAI,kBAAkB,KAAK,IAAI,kBAAkB,KAAK,MAAM,KAAK,CAAC,CAAC;AACjF;AAOO,SAAS,aAAa,UAAkB,eAAgC;AAC7E,SAAO,MAAM,UAAU,UAAU,iBAAiB,oBAAoB,CAAC;AACzE;AAUO,SAAS,aAAa,MAAc,UAAkB,eAAgC;AAC3F,QAAM,SAAS,aAAa,UAAU,aAAa;AAGnD,QAAM,UAAU,KAAK,QAAQ,QAAQ,EAAE;AACvC,SAAO,GAAG,OAAO,IAAI,MAAM;AAC7B;AAqBO,SAAS,0BACd,WACwB;AAKxB,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AAQ,YAAY;AAAA,EAC1C;AACA,MAAI,QAAQ,SAAS,GAAG;AACtB,WAAO,EAAE,IAAI,MAAM,UAAU,QAAQ,OAAO,EAAE,KAAK,EAAE,MAAgB;AAAA,EACvE;AACA,SAAO,EAAE,IAAI,OAAO,QAAQ,aAAa,YAAY,CAAC,GAAG,OAAO,EAAE;AACpE;AAOO,IAAM,gCAAgC;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
StorageManager,
|
|
3
3
|
normalizeEntityName
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OC56UWV5.js";
|
|
5
5
|
import {
|
|
6
6
|
extractJsonCandidates
|
|
7
7
|
} from "./chunk-RGMVMVMF.js";
|
|
@@ -870,4 +870,4 @@ export {
|
|
|
870
870
|
resolveBriefingSaveDir,
|
|
871
871
|
briefingFilename
|
|
872
872
|
};
|
|
873
|
-
//# sourceMappingURL=chunk-
|
|
873
|
+
//# sourceMappingURL=chunk-JEIROMLX.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-ZBJMUXZH.js";
|
|
5
5
|
import {
|
|
6
6
|
StorageManager
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-OC56UWV5.js";
|
|
8
8
|
import {
|
|
9
9
|
getCachedRuleMemories,
|
|
10
10
|
setCachedRuleMemories
|
|
@@ -117,4 +117,4 @@ export {
|
|
|
117
117
|
compareVerifiedSemanticRuleResults,
|
|
118
118
|
searchVerifiedSemanticRules
|
|
119
119
|
};
|
|
120
|
-
//# sourceMappingURL=chunk-
|
|
120
|
+
//# sourceMappingURL=chunk-JVEMUX6L.js.map
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
listMemoryGovernanceRuns,
|
|
12
12
|
readMemoryGovernanceRunArtifact
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-XZTUMWKQ.js";
|
|
14
14
|
import {
|
|
15
15
|
StorageManager
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-OC56UWV5.js";
|
|
17
17
|
import {
|
|
18
18
|
MEMORY_LIFECYCLE_EVENT_SORT_ORDER,
|
|
19
19
|
buildLifecycleEventsForMemory,
|
|
@@ -929,4 +929,4 @@ export {
|
|
|
929
929
|
verifyMemoryProjection,
|
|
930
930
|
repairMemoryProjection
|
|
931
931
|
};
|
|
932
|
-
//# sourceMappingURL=chunk-
|
|
932
|
+
//# sourceMappingURL=chunk-K44MIN6D.js.map
|