@snoai/memory 0.0.0-stage → 1.0.1
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/LICENSE +176 -0
- package/README.md +33 -2
- package/config/b-profile-section-registry.json +118 -0
- package/config/llm/compiled/2026-05-19T230932Z/manifest.json +25 -0
- package/config/llm/compiled/2026-05-19T230932Z/registry-root.json +67 -0
- package/config/llm/compiled/2026-05-19T230932Z/resolved/mem_claw/openai_gpt_5_nano.json +5 -0
- package/config/llm/compiled/2026-05-19T230932Z/resolved/mem_claw/openrouter_auto.json +5 -0
- package/config/llm/compiled/2026-05-19T230932Z/resolved/mem_claw/sno_ai_extract.json +5 -0
- package/config/llm/compiled/2026-05-19T230932Z/source/mem_claw/openai_gpt_5_nano.mda +24 -0
- package/config/llm/compiled/2026-05-19T230932Z/source/mem_claw/openrouter_auto.mda +24 -0
- package/config/llm/compiled/2026-05-19T230932Z/source/mem_claw/sno_ai_extract.mda +24 -0
- package/config/llm/compiled/2026-07-21T001311Z/manifest.json +43 -0
- package/config/llm/compiled/2026-07-21T001311Z/registry-root.json +97 -0
- package/config/llm/compiled/2026-07-21T001311Z/resolved/mem_claw/openai_gpt_5_nano.json +5 -0
- package/config/llm/compiled/2026-07-21T001311Z/resolved/mem_claw/openrouter_auto.json +5 -0
- package/config/llm/compiled/2026-07-21T001311Z/resolved/mem_claw/sno_ai_extract.json +5 -0
- package/config/llm/compiled/2026-07-21T001311Z/resolved/mem_claw/sno_conflict_verdict.json +10 -0
- package/config/llm/compiled/2026-07-21T001311Z/resolved/mem_claw/sno_extract_chat.json +10 -0
- package/config/llm/compiled/2026-07-21T001311Z/resolved/mem_claw/sno_extract_profile.json +10 -0
- package/config/llm/compiled/2026-07-21T001311Z/source/mem_claw/openai_gpt_5_nano.mda +24 -0
- package/config/llm/compiled/2026-07-21T001311Z/source/mem_claw/openrouter_auto.mda +24 -0
- package/config/llm/compiled/2026-07-21T001311Z/source/mem_claw/sno_ai_extract.mda +24 -0
- package/config/llm/compiled/2026-07-21T001311Z/source/mem_claw/sno_conflict_verdict.mda +27 -0
- package/config/llm/compiled/2026-07-21T001311Z/source/mem_claw/sno_extract_chat.mda +27 -0
- package/config/llm/compiled/2026-07-21T001311Z/source/mem_claw/sno_extract_profile.mda +27 -0
- package/config/llm/compiled/2026-08-29T060335Z/manifest.json +43 -0
- package/config/llm/compiled/2026-08-29T060335Z/registry-root.json +97 -0
- package/config/llm/compiled/2026-08-29T060335Z/resolved/mem_claw/openai_gpt_5_nano.json +5 -0
- package/config/llm/compiled/2026-08-29T060335Z/resolved/mem_claw/openrouter_auto.json +5 -0
- package/config/llm/compiled/2026-08-29T060335Z/resolved/mem_claw/sno_ai_extract.json +5 -0
- package/config/llm/compiled/2026-08-29T060335Z/resolved/mem_claw/sno_conflict_verdict.json +10 -0
- package/config/llm/compiled/2026-08-29T060335Z/resolved/mem_claw/sno_extract_chat.json +10 -0
- package/config/llm/compiled/2026-08-29T060335Z/resolved/mem_claw/sno_extract_profile.json +10 -0
- package/config/llm/compiled/2026-08-29T060335Z/source/mem_claw/openai_gpt_5_nano.mda +24 -0
- package/config/llm/compiled/2026-08-29T060335Z/source/mem_claw/openrouter_auto.mda +24 -0
- package/config/llm/compiled/2026-08-29T060335Z/source/mem_claw/sno_ai_extract.mda +24 -0
- package/config/llm/compiled/2026-08-29T060335Z/source/mem_claw/sno_conflict_verdict.mda +27 -0
- package/config/llm/compiled/2026-08-29T060335Z/source/mem_claw/sno_extract_chat.mda +27 -0
- package/config/llm/compiled/2026-08-29T060335Z/source/mem_claw/sno_extract_profile.mda +27 -0
- package/config/llm/compiled/2026-09-04T004828Z/manifest.json +43 -0
- package/config/llm/compiled/2026-09-04T004828Z/registry-root.json +97 -0
- package/config/llm/compiled/2026-09-04T004828Z/resolved/mem_claw/openai_gpt_5_nano.json +5 -0
- package/config/llm/compiled/2026-09-04T004828Z/resolved/mem_claw/openrouter_auto.json +5 -0
- package/config/llm/compiled/2026-09-04T004828Z/resolved/mem_claw/sno_ai_extract.json +5 -0
- package/config/llm/compiled/2026-09-04T004828Z/resolved/mem_claw/sno_conflict_verdict.json +10 -0
- package/config/llm/compiled/2026-09-04T004828Z/resolved/mem_claw/sno_extract_chat.json +10 -0
- package/config/llm/compiled/2026-09-04T004828Z/resolved/mem_claw/sno_extract_profile.json +10 -0
- package/config/llm/compiled/2026-09-04T004828Z/source/mem_claw/openai_gpt_5_nano.mda +24 -0
- package/config/llm/compiled/2026-09-04T004828Z/source/mem_claw/openrouter_auto.mda +24 -0
- package/config/llm/compiled/2026-09-04T004828Z/source/mem_claw/sno_ai_extract.mda +24 -0
- package/config/llm/compiled/2026-09-04T004828Z/source/mem_claw/sno_conflict_verdict.mda +27 -0
- package/config/llm/compiled/2026-09-04T004828Z/source/mem_claw/sno_extract_chat.mda +27 -0
- package/config/llm/compiled/2026-09-04T004828Z/source/mem_claw/sno_extract_profile.mda +27 -0
- package/config/llm/current.json +4 -0
- package/config/llm/source/mem_claw/openai_gpt_5_nano.mda +24 -0
- package/config/llm/source/mem_claw/openrouter_auto.mda +24 -0
- package/config/llm/source/mem_claw/sno_ai_extract.mda +24 -0
- package/config/llm/source/mem_claw/sno_conflict_verdict.mda +27 -0
- package/config/llm/source/mem_claw/sno_extract_chat.mda +27 -0
- package/config/llm/source/mem_claw/sno_extract_profile.mda +27 -0
- package/config/llm.trust.json +37 -0
- package/dist/_types-CUKHSRkS.d.ts +103 -0
- package/dist/access-tracker-BbEvEocb.d.ts +110 -0
- package/dist/adapter-B7Jox9-6.d.ts +69 -0
- package/dist/adapter-XaRHZWZ2.js +333 -0
- package/dist/agent-llm-port-5oXgBpzJ.d.ts +53 -0
- package/dist/all-resources-BQK2ugjB.js +6379 -0
- package/dist/all-resources-Dij6l5h0.d.ts +18 -0
- package/dist/ambient-learning-text-normalizer-CxjATmMp.js +170 -0
- package/dist/ambient-learning-text-normalizer-_fH3LeuK.d.ts +10 -0
- package/dist/atomic-extraction-reply-BJ9XV_9s.js +863 -0
- package/dist/atomic-extraction-skill-CcXmuCqL.js +56 -0
- package/dist/atomic-memory-extraction-C5rmogoY.js +3605 -0
- package/dist/atomic-memory-extraction-d9EG-4ti.d.ts +327 -0
- package/dist/b-profile-section-dictionary-provider-BHkoNqgk.js +1812 -0
- package/dist/b-profile-section-dictionary-provider-BxbksLj3.d.ts +62 -0
- package/dist/best-effort-BPZSzKk0.d.ts +9 -0
- package/dist/calendar-instruction-CzqZbAPG.js +194 -0
- package/dist/capture-policy-detector-CxbHPkMX.d.ts +53 -0
- package/dist/capture-policy-detector-DaMfy9CZ.js +357 -0
- package/dist/classifier-DnbbtwTS.d.ts +272 -0
- package/dist/client.d.ts +34 -0
- package/dist/client.js +306 -0
- package/dist/coding-skin.d.ts +51 -0
- package/dist/coding-skin.js +55 -0
- package/dist/config-CL90qYva.js +2576 -0
- package/dist/connection-3IVXpuPE.d.ts +391 -0
- package/dist/connection-C9YD5sgm.js +297 -0
- package/dist/daily-log-generator-CH_KuWHs.js +469 -0
- package/dist/daily-log-generator-CsQPHl4A.d.ts +73 -0
- package/dist/daily-spend-estimator-DiwzBlo1.d.ts +8 -0
- package/dist/data-bootstrap-Bl3lthzE.d.ts +30 -0
- package/dist/data-bootstrap-P8sie9WA.js +172 -0
- package/dist/data-paths-C7sNdqvP.d.ts +22 -0
- package/dist/derived-suppression-cache-CI0durYx.d.ts +36 -0
- package/dist/diagnostic-encoder.d.ts +6 -0
- package/dist/diagnostic-encoder.js +29 -0
- package/dist/embedding-provider-client-Q_hJonK9.js +294 -0
- package/dist/embedding-provider-client-vynZMuit.d.ts +94 -0
- package/dist/entry-metadata-parser-BIVSMCIk.js +20 -0
- package/dist/error-D-wb-rZw.js +23 -0
- package/dist/error-signals-D8_3vYu4.d.ts +28 -0
- package/dist/error-signals-lMH2uAdV.js +134 -0
- package/dist/errors-CeVRxf9V.d.ts +49 -0
- package/dist/extraction-text-sanitizer-B_AhIecT.d.ts +32 -0
- package/dist/i18n-text-DbD6Qify.d.ts +13 -0
- package/dist/index-0aqS8pVF.d.ts +351 -0
- package/dist/index-BO4RU_mc.d.ts +650 -0
- package/dist/index-DL8AVj0Z.d.ts +571 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +1201 -0
- package/dist/intent-analyzer-B5XVrWwe.d.ts +28 -0
- package/dist/internal/config/index.d.ts +2 -0
- package/dist/internal/config/index.js +581 -0
- package/dist/internal/config/plugin-config-schema.d.ts +2 -0
- package/dist/internal/config/plugin-config-schema.js +2 -0
- package/dist/internal/config/product-mode.d.ts +2 -0
- package/dist/internal/config/product-mode.js +36 -0
- package/dist/internal/config/settings.d.ts +2 -0
- package/dist/internal/config/settings.js +265 -0
- package/dist/internal/config/skill-categories.d.ts +4 -0
- package/dist/internal/config/skill-categories.js +68 -0
- package/dist/internal/config/skin-defaults.d.ts +6 -0
- package/dist/internal/config/skin-defaults.js +6 -0
- package/dist/internal/contract/discovery.d.ts +10 -0
- package/dist/internal/contract/discovery.js +53 -0
- package/dist/internal/contract/profile.d.ts +2 -0
- package/dist/internal/contract/profile.js +44 -0
- package/dist/internal/contract/routes.d.ts +2 -0
- package/dist/internal/contract/routes.js +62 -0
- package/dist/internal/engine/bindings/memory-cli-shared.d.ts +47 -0
- package/dist/internal/engine/bindings/memory-cli-shared.js +84 -0
- package/dist/internal/engine/bindings/memory-forget-tool.d.ts +5 -0
- package/dist/internal/engine/bindings/memory-forget-tool.js +66 -0
- package/dist/internal/engine/bindings/memory-list-tool.d.ts +5 -0
- package/dist/internal/engine/bindings/memory-list-tool.js +57 -0
- package/dist/internal/engine/bindings/memory-recall-tool.d.ts +10 -0
- package/dist/internal/engine/bindings/memory-recall-tool.js +283 -0
- package/dist/internal/engine/bindings/memory-reflection-resolve-tool.d.ts +5 -0
- package/dist/internal/engine/bindings/memory-reflection-resolve-tool.js +150 -0
- package/dist/internal/engine/bindings/memory-stats-tool.d.ts +5 -0
- package/dist/internal/engine/bindings/memory-stats-tool.js +43 -0
- package/dist/internal/engine/bindings/memory-store-tool.d.ts +5 -0
- package/dist/internal/engine/bindings/memory-store-tool.js +165 -0
- package/dist/internal/engine/bindings/memory-tool-access.d.ts +16 -0
- package/dist/internal/engine/bindings/memory-tool-access.js +46 -0
- package/dist/internal/engine/bindings/memory-tool-formatting.d.ts +62 -0
- package/dist/internal/engine/bindings/memory-tool-formatting.js +106 -0
- package/dist/internal/engine/bindings/memory-tool-results.d.ts +8 -0
- package/dist/internal/engine/bindings/memory-tool-results.js +41 -0
- package/dist/internal/engine/bindings/memory-tool-schemas.d.ts +109 -0
- package/dist/internal/engine/bindings/memory-tool-schemas.js +75 -0
- package/dist/internal/engine/bindings/memory-update-tool.d.ts +5 -0
- package/dist/internal/engine/bindings/memory-update-tool.js +127 -0
- package/dist/internal/engine/bindings/sno-station-mem-ambient-learning-hook.d.ts +14 -0
- package/dist/internal/engine/bindings/sno-station-mem-ambient-learning-hook.js +248 -0
- package/dist/internal/engine/bindings/sno-station-mem-auto-recall-hook.d.ts +12 -0
- package/dist/internal/engine/bindings/sno-station-mem-auto-recall-hook.js +324 -0
- package/dist/internal/engine/bindings/sno-station-mem-hook-types.d.ts +56 -0
- package/dist/internal/engine/bindings/sno-station-mem-hook-types.js +1 -0
- package/dist/internal/engine/bindings/sno-station-mem-insight-distill-factory.d.ts +14 -0
- package/dist/internal/engine/bindings/sno-station-mem-insight-distill-factory.js +119 -0
- package/dist/internal/engine/bindings/sno-station-mem-message-transcript.d.ts +52 -0
- package/dist/internal/engine/bindings/sno-station-mem-message-transcript.js +145 -0
- package/dist/internal/engine/bindings/sno-station-mem-reset-hook.d.ts +10 -0
- package/dist/internal/engine/bindings/sno-station-mem-reset-hook.js +9 -0
- package/dist/internal/engine/bindings/sno-station-mem-runtime-mode.d.ts +36 -0
- package/dist/internal/engine/bindings/sno-station-mem-runtime-mode.js +104 -0
- package/dist/internal/engine/bindings/sno-station-mem-session-state.d.ts +10 -0
- package/dist/internal/engine/bindings/sno-station-mem-session-state.js +27 -0
- package/dist/internal/engine/eval/trace.d.ts +2 -0
- package/dist/internal/engine/eval/trace.js +151 -0
- package/dist/internal/engine/extraction/ambient-learning-text-normalizer.d.ts +2 -0
- package/dist/internal/engine/extraction/ambient-learning-text-normalizer.js +2 -0
- package/dist/internal/engine/extraction/atomic-memory-extraction.d.ts +2 -0
- package/dist/internal/engine/extraction/atomic-memory-extraction.js +2 -0
- package/dist/internal/engine/extraction/b-profile-section-dictionary-provider.d.ts +2 -0
- package/dist/internal/engine/extraction/b-profile-section-dictionary-provider.js +2 -0
- package/dist/internal/engine/extraction/b-profile-section-rekey.d.ts +49 -0
- package/dist/internal/engine/extraction/b-profile-section-rekey.js +730 -0
- package/dist/internal/engine/extraction/capture-policy-detector.d.ts +2 -0
- package/dist/internal/engine/extraction/capture-policy-detector.js +2 -0
- package/dist/internal/engine/extraction/embedding-provider-client.d.ts +2 -0
- package/dist/internal/engine/extraction/embedding-provider-client.js +2 -0
- package/dist/internal/engine/extraction/extraction-text-sanitizer.d.ts +2 -0
- package/dist/internal/engine/extraction/extraction-text-sanitizer.js +114 -0
- package/dist/internal/engine/extraction/memory-metadata-codec.d.ts +3 -0
- package/dist/internal/engine/extraction/memory-metadata-codec.js +2 -0
- package/dist/internal/engine/extraction/memory-temporality-classifier.d.ts +2 -0
- package/dist/internal/engine/extraction/memory-temporality-classifier.js +2 -0
- package/dist/internal/engine/i18n/all-resources.d.ts +2 -0
- package/dist/internal/engine/i18n/all-resources.js +2 -0
- package/dist/internal/engine/i18n/locales.d.ts +2 -0
- package/dist/internal/engine/i18n/locales.js +19 -0
- package/dist/internal/engine/i18n/res/_types.d.ts +2 -0
- package/dist/internal/engine/i18n/res/_types.js +11 -0
- package/dist/internal/engine/observability/adapter.d.ts +2 -0
- package/dist/internal/engine/observability/adapter.js +2 -0
- package/dist/internal/engine/observability/best-effort.d.ts +2 -0
- package/dist/internal/engine/observability/best-effort.js +41 -0
- package/dist/internal/engine/observability/early-diagnostics.js +2 -0
- package/dist/internal/engine/observability/memory-snapshot.d.ts +2 -0
- package/dist/internal/engine/observability/memory-snapshot.js +44 -0
- package/dist/internal/engine/observability/observable-embedder.d.ts +2 -0
- package/dist/internal/engine/observability/observable-embedder.js +43 -0
- package/dist/internal/engine/observability/observable-llm-client.d.ts +2 -0
- package/dist/internal/engine/observability/observable-llm-client.js +98 -0
- package/dist/internal/engine/observability/observable-memory-store.d.ts +2 -0
- package/dist/internal/engine/observability/observable-memory-store.js +701 -0
- package/dist/internal/engine/observability/observable-retriever.d.ts +2 -0
- package/dist/internal/engine/observability/observable-retriever.js +95 -0
- package/dist/internal/engine/observability/runtime-diagnostics.d.ts +13 -0
- package/dist/internal/engine/observability/runtime-diagnostics.js +96 -0
- package/dist/internal/engine/observability/session-registry.d.ts +2 -0
- package/dist/internal/engine/observability/session-registry.js +58 -0
- package/dist/internal/engine/observability/version-metadata.d.ts +7 -0
- package/dist/internal/engine/observability/version-metadata.js +59 -0
- package/dist/internal/engine/operations/daily-spend-estimator.d.ts +2 -0
- package/dist/internal/engine/operations/daily-spend-estimator.js +97 -0
- package/dist/internal/engine/operations/learning-file-maintenance.d.ts +2 -0
- package/dist/internal/engine/operations/learning-file-maintenance.js +255 -0
- package/dist/internal/engine/operations/memory-tier-promoter.d.ts +2 -0
- package/dist/internal/engine/operations/memory-tier-promoter.js +95 -0
- package/dist/internal/engine/operations/runtime-audit-log.d.ts +3 -0
- package/dist/internal/engine/operations/runtime-audit-log.js +3 -0
- package/dist/internal/engine/provider/canonical-memory-corpus.d.ts +38 -0
- package/dist/internal/engine/provider/canonical-memory-corpus.js +253 -0
- package/dist/internal/engine/provider/provider-registration.d.ts +39 -0
- package/dist/internal/engine/provider/provider-registration.js +2 -0
- package/dist/internal/engine/provider/provider-row-renderer.d.ts +7 -0
- package/dist/internal/engine/provider/provider-row-renderer.js +53 -0
- package/dist/internal/engine/provider/provider-types.d.ts +2 -0
- package/dist/internal/engine/provider/provider-types.js +1 -0
- package/dist/internal/engine/reflection/daily-log-generator.d.ts +2 -0
- package/dist/internal/engine/reflection/daily-log-generator.js +2 -0
- package/dist/internal/engine/reflection/reflection-command-hooks.d.ts +2 -0
- package/dist/internal/engine/reflection/reflection-command-hooks.js +2 -0
- package/dist/internal/engine/reflection/reflection-deps.d.ts +2 -0
- package/dist/internal/engine/reflection/reflection-deps.js +1 -0
- package/dist/internal/engine/reflection/reflection-embedded-generator.d.ts +2 -0
- package/dist/internal/engine/reflection/reflection-embedded-generator.js +2 -0
- package/dist/internal/engine/reflection/reflection-injection-hooks.d.ts +2 -0
- package/dist/internal/engine/reflection/reflection-injection-hooks.js +219 -0
- package/dist/internal/engine/reflection/reflection-lifecycle-hooks.d.ts +2 -0
- package/dist/internal/engine/reflection/reflection-lifecycle-hooks.js +63 -0
- package/dist/internal/engine/reflection/strategy-hook-runner.d.ts +4 -0
- package/dist/internal/engine/reflection/strategy-hook-runner.js +3 -0
- package/dist/internal/engine/rem/classifier.d.ts +2 -0
- package/dist/internal/engine/rem/classifier.js +180 -0
- package/dist/internal/engine/rem/index.d.ts +4 -0
- package/dist/internal/engine/rem/index.js +2551 -0
- package/dist/internal/engine/rem/types.d.ts +2 -0
- package/dist/internal/engine/rem/types.js +40 -0
- package/dist/internal/engine/retrieval/access-tracker.d.ts +2 -0
- package/dist/internal/engine/retrieval/access-tracker.js +314 -0
- package/dist/internal/engine/retrieval/intent-analyzer.d.ts +2 -0
- package/dist/internal/engine/retrieval/intent-analyzer.js +27 -0
- package/dist/internal/engine/retrieval/retrieval-gate.d.ts +2 -0
- package/dist/internal/engine/retrieval/retrieval-gate.js +47 -0
- package/dist/internal/engine/retrieval/retriever.d.ts +2 -0
- package/dist/internal/engine/retrieval/retriever.js +2 -0
- package/dist/internal/engine/security/memory-scope-policy.d.ts +2 -0
- package/dist/internal/engine/security/memory-scope-policy.js +2 -0
- package/dist/internal/engine/security/redact.d.ts +2 -0
- package/dist/internal/engine/security/redact.js +34 -0
- package/dist/internal/engine/security/scopes.d.ts +3 -0
- package/dist/internal/engine/security/scopes.js +3 -0
- package/dist/internal/engine/shared/errors.d.ts +2 -0
- package/dist/internal/engine/shared/errors.js +66 -0
- package/dist/internal/engine/shared/i18n-text.d.ts +2 -0
- package/dist/internal/engine/shared/i18n-text.js +58 -0
- package/dist/internal/engine/shared/iso-date-time.d.ts +16 -0
- package/dist/internal/engine/shared/iso-date-time.js +40 -0
- package/dist/internal/engine/shared/lru.d.ts +2 -0
- package/dist/internal/engine/shared/lru.js +30 -0
- package/dist/internal/engine/shared/memory-kind-policy.d.ts +2 -0
- package/dist/internal/engine/shared/memory-kind-policy.js +64 -0
- package/dist/internal/engine/shared/paths.d.ts +3 -0
- package/dist/internal/engine/shared/paths.js +2 -0
- package/dist/internal/engine/shared/types.d.ts +3 -0
- package/dist/internal/engine/shared/types.js +25 -0
- package/dist/internal/engine/shared/utils.d.ts +2 -0
- package/dist/internal/engine/shared/utils.js +175 -0
- package/dist/internal/engine/telemetry/memory-telemetry-api.d.ts +134 -0
- package/dist/internal/engine/telemetry/memory-telemetry-api.js +730 -0
- package/dist/internal/engine/telemetry/memory-telemetry-observability.d.ts +24 -0
- package/dist/internal/engine/telemetry/memory-telemetry-observability.js +133 -0
- package/dist/internal/engine/telemetry/memory-telemetry-outbox.d.ts +2 -0
- package/dist/internal/engine/telemetry/memory-telemetry-outbox.js +443 -0
- package/dist/internal/engine/telemetry/memory-telemetry-types.d.ts +2 -0
- package/dist/internal/engine/telemetry/memory-telemetry-types.js +21 -0
- package/dist/internal/engine/telemetry/observe-ledger.d.ts +30 -0
- package/dist/internal/engine/telemetry/observe-ledger.js +111 -0
- package/dist/internal/model/agent-llm-port.d.ts +2 -0
- package/dist/internal/model/agent-llm-port.js +1 -0
- package/dist/internal/model/llm-client.d.ts +3 -0
- package/dist/internal/model/llm-client.js +3 -0
- package/dist/internal/model/llm-failure.d.ts +26 -0
- package/dist/internal/model/llm-failure.js +63 -0
- package/dist/internal/model/llm-mode-routing.d.ts +22 -0
- package/dist/internal/model/llm-mode-routing.js +37 -0
- package/dist/internal/store/atomic-memory-cutover-sql.d.ts +13 -0
- package/dist/internal/store/atomic-memory-cutover-sql.js +237 -0
- package/dist/internal/store/connection.d.ts +2 -0
- package/dist/internal/store/connection.js +2 -0
- package/dist/internal/store/data-bootstrap.d.ts +2 -0
- package/dist/internal/store/data-bootstrap.js +2 -0
- package/dist/internal/store/data-paths.d.ts +2 -0
- package/dist/internal/store/data-paths.js +65 -0
- package/dist/internal/store/maintenance.d.ts +75 -0
- package/dist/internal/store/maintenance.js +1401 -0
- package/dist/internal/store/memory-kinds-cutover-migrator.d.ts +28 -0
- package/dist/internal/store/memory-kinds-cutover-migrator.js +415 -0
- package/dist/internal/store/migrations.d.ts +27 -0
- package/dist/internal/store/migrations.js +201 -0
- package/dist/internal/store/sqlite-runtime.d.ts +2 -0
- package/dist/internal/store/sqlite-runtime.js +109 -0
- package/dist/internal/store/store.d.ts +3 -0
- package/dist/internal/store/store.js +2 -0
- package/dist/learning-file-maintenance-9b-Ut6Kv.d.ts +30 -0
- package/dist/llm-client-BSYUAcUb.js +1374 -0
- package/dist/llm-client-DOTSGzhe.d.ts +51 -0
- package/dist/locales-JxGmkG6t.d.ts +7 -0
- package/dist/log-site-catalog.generated-BMKWj-Nx.js +2321 -0
- package/dist/log-site-catalog.json +1 -0
- package/dist/lru-DyoaTyIs.d.ts +14 -0
- package/dist/memdump.d.ts +52 -0
- package/dist/memdump.js +163 -0
- package/dist/memory-entry-projector-DHo8jH10.js +1015 -0
- package/dist/memory-kind-policy-BiuRjSJc.d.ts +23 -0
- package/dist/memory-metadata-codec-DL1sbJiN.js +577 -0
- package/dist/memory-metadata-codec-DUvsYe_X.d.ts +68 -0
- package/dist/memory-runtime-DqUS4cWi.js +19459 -0
- package/dist/memory-scope-policy-1gg5QlWZ.d.ts +67 -0
- package/dist/memory-scope-policy-DICSCURA.js +283 -0
- package/dist/memory-snapshot-CqY1BUUA.d.ts +16 -0
- package/dist/memory-source-order-YMRoeDLd.js +134 -0
- package/dist/memory-store-base-CQ_bHlYA.d.ts +1094 -0
- package/dist/memory-store-shared-DqpWJXZZ.js +158 -0
- package/dist/memory-store-write-validation-B_hDG2zf.js +243 -0
- package/dist/memory-telemetry-incidents-BWA9kcZx.js +8 -0
- package/dist/memory-telemetry-metadata-CA7W8tK6.js +77 -0
- package/dist/memory-telemetry-outbox-ddTdImt7.d.ts +74 -0
- package/dist/memory-telemetry-receipts-MAJecvXQ.d.ts +34 -0
- package/dist/memory-telemetry-receipts-YsxbwOAf.js +91 -0
- package/dist/memory-telemetry-types-CufVmrCs.d.ts +14 -0
- package/dist/memory-temporality-classifier-BUjXG5o7.js +184 -0
- package/dist/memory-temporality-classifier-Brht5jyK.d.ts +43 -0
- package/dist/memory-tier-promoter-CqGxCkue.d.ts +43 -0
- package/dist/memory-tool-dependencies-CatGzI9R.d.ts +14 -0
- package/dist/memory-tool-dependencies-DjUoelnm.js +19 -0
- package/dist/model-call-table-CspopkBg.js +563 -0
- package/dist/model-reply-text-CKopStP2.js +334 -0
- package/dist/observable-embedder-CNNe9gkg.d.ts +17 -0
- package/dist/observable-llm-client-CRuKlefQ.d.ts +21 -0
- package/dist/observable-memory-store-CnGDpOY5.d.ts +73 -0
- package/dist/observable-retriever-Cooc62Qw.d.ts +23 -0
- package/dist/operation-cancellation-CTKWwNHk.js +81 -0
- package/dist/paths-qVF-5uBq.d.ts +1 -0
- package/dist/plugin-config-schema-C0UUbOmG.d.ts +413 -0
- package/dist/plugin-config-schema-YJLyIIcJ.js +361 -0
- package/dist/profile-TWPJ_myr.d.ts +13 -0
- package/dist/profile-section-writer-BhGKPBjw.js +2149 -0
- package/dist/provider-registration-CF1tg8Xy.js +721 -0
- package/dist/provider-runtime-types-DFhtdA6d.d.ts +134 -0
- package/dist/provider-types-CZGm6v88.d.ts +23 -0
- package/dist/redact-BTIZcHQL.d.ts +5 -0
- package/dist/reflection-command-hooks-ClUl-iv6.js +644 -0
- package/dist/reflection-command-hooks-G1-dI2Av.d.ts +32 -0
- package/dist/reflection-deps-Ccm2Jf5W.d.ts +19 -0
- package/dist/reflection-embedded-generator-BRvqV5N-.js +130 -0
- package/dist/reflection-embedded-generator-kfQfKEYV.d.ts +14 -0
- package/dist/reflection-injection-hooks-CS_uhjoD.d.ts +43 -0
- package/dist/reflection-lifecycle-hooks-CRSpUdLi.d.ts +27 -0
- package/dist/relation-dictionary-Cev1kyLe.js +4248 -0
- package/dist/release-download.d.ts +8 -0
- package/dist/release-download.js +32 -0
- package/dist/relevant-memories-context-m8nuFZcM.js +23 -0
- package/dist/rem-batch-executor-Dg2HgROM.js +2 -0
- package/dist/rem-batch-executor-DuC4nYyf.js +31640 -0
- package/dist/rem-consumer-retrieval-CR0dtcHR.js +246 -0
- package/dist/rem-trigger-Hn6od8IV.js +730 -0
- package/dist/resolver-Dy-hnjCR.js +103 -0
- package/dist/results-C3ZLroMb.js +140 -0
- package/dist/retrieval-gate-Bx2Zg7jD.d.ts +31 -0
- package/dist/retriever-Dxss5fRv.d.ts +469 -0
- package/dist/retriever-ZoLvPRHq.js +1757 -0
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/routes-DLHT__Ay.js +60 -0
- package/dist/runtime-audit-log-BCeujlEp.js +430 -0
- package/dist/runtime-audit-log-zpQiR9HT.d.ts +149 -0
- package/dist/scopes-CSOn6zdd.js +71 -0
- package/dist/scopes-CtrY-YQ3.d.ts +23 -0
- package/dist/server-CSvxchqg.js +1412 -0
- package/dist/session-registry-DBoE7AvZ.d.ts +14 -0
- package/dist/sidecar/main.d.ts +1 -0
- package/dist/sidecar/main.js +56 -0
- package/dist/signed-registry-constants-Bv0fgZ8Q.d.ts +12 -0
- package/dist/signed-registry-constants-yq3DlG3B.js +82 -0
- package/dist/sno-station-mem-runtime-dependencies-CoWqUMbK.js +30 -0
- package/dist/sno-station-mem-runtime-dependencies-DHESIuPn.d.ts +31 -0
- package/dist/sqlite-runtime-L_ywirTm.d.ts +58 -0
- package/dist/store-C8sUTssE.d.ts +27 -0
- package/dist/store-nPql26YM.js +5830 -0
- package/dist/strategy-hook-runner-Bxy851Xx.d.ts +16 -0
- package/dist/strategy-hook-runner-Djify5Rw.js +110 -0
- package/dist/token-counter-BD1f48Km.js +73 -0
- package/dist/trace-C1JxMfs-.d.ts +86 -0
- package/dist/types-CWdhXLxr.d.ts +477 -0
- package/dist/types-pVomjzqR.d.ts +132 -0
- package/dist/unplaced-candidate-migration-CbQHzcEM.js +940 -0
- package/dist/utils-Ctb9aevJ.d.ts +34 -0
- package/drizzle/0000_initial.sql +10 -0
- package/drizzle/0001_virtual_tables.sql +34 -0
- package/drizzle/0002_add_indexes.sql +11 -0
- package/drizzle/0003_content_hash_lookup_index.sql +2 -0
- package/drizzle/0004_chunk_swap.sql +60 -0
- package/drizzle/0005_drop_legacy_vec_fts.sql +10 -0
- package/drizzle/0006_fts_simple.sql +45 -0
- package/drizzle/0007_restore_simple_fts.sql +40 -0
- package/drizzle/0008_widen_memory_hash_unique_index.sql +4 -0
- package/drizzle/0009_memory_telemetry.sql +109 -0
- package/drizzle/0010_provider_mappings.sql +27 -0
- package/drizzle/0011_db_optimization.sql +82 -0
- package/drizzle/0012_b_profile_lanes.sql +9 -0
- package/drizzle/0013_extraction_timestamps.sql +6 -0
- package/drizzle/0014_extraction_timestamp_source.sql +3 -0
- package/drizzle/0015_task_lifecycle_state.sql +101 -0
- package/drizzle/0016_task_lifecycle_legacy_migration.sql +144 -0
- package/drizzle/0017_unplaced_candidates.sql +15 -0
- package/drizzle/0018_rem_batch_chassis.sql +71 -0
- package/drizzle/0019_profile_recovery_entries.sql +17 -0
- package/drizzle/0020_rem_scan_retry_progress.down.sql +14 -0
- package/drizzle/0020_rem_scan_retry_progress.sql +24 -0
- package/drizzle/0021_rem_two_facet_storage.down.sql +14 -0
- package/drizzle/0021_rem_two_facet_storage.sql +42 -0
- package/drizzle/0022_rem_facet_chunk_versions.down.sql +4 -0
- package/drizzle/0022_rem_facet_chunk_versions.sql +4 -0
- package/drizzle/0023_rem_defect_ledger.sql +40 -0
- package/drizzle/0024_rem_unbuilt_foundations.down.sql +13 -0
- package/drizzle/0024_rem_unbuilt_foundations.sql +65 -0
- package/drizzle/0025_rem_journal_operation_constraint.sql +28 -0
- package/drizzle/0026_rem_journal_detail.sql +1 -0
- package/drizzle/0027_legacy_nodix_namespace.sql +3 -0
- package/drizzle/0028_memory_timezone.sql +23 -0
- package/drizzle/0029_rem_write_hash_symmetry.sql +17 -0
- package/drizzle/0030_atomic_memory_additive.sql +105 -0
- package/drizzle/0031_atomic_extraction_ledger.sql +23 -0
- package/drizzle/0032_atomic_memory_entities.sql +12 -0
- package/drizzle/0033_todo_own_store.sql +99 -0
- package/drizzle/meta/0000_snapshot.json +87 -0
- package/drizzle/meta/_journal.json +244 -0
- package/generated/rem-operations.json +1 -0
- package/package.json +126 -4
- package/scripts/download-simple-tokenizer.mjs +254 -0
- package/settings.default.json +243 -0
- package/skills/extract-atomic-memory/SKILL.md +298 -0
- package/skills/extract-atomic-memory/references/account-for-turns.md +9 -0
- package/skills/extract-atomic-memory/references/calendar-meaning.md +64 -0
- package/skills/extract-atomic-memory/references/capture.md +120 -0
- package/skills/extract-atomic-memory/references/enrichment.md +92 -0
- package/skills/extract-atomic-memory/references/missing-durable-half.md +6 -0
- package/skills/extract-atomic-memory/references/progress-classification.md +21 -0
- package/skills/extract-atomic-memory/references/resolve-subject.md +19 -0
- package/skills/extract-atomic-memory/references/surrounding-context.md +10 -0
- package/skills/extract-atomic-memory/references/user-subject-guard.md +29 -0
- package/skills/judge-group-closure/SKILL.md +25 -0
- package/skills/judge-rem-memory-updates/SKILL.md +56 -0
- package/skills/judge-rem-memory-updates/agents/openai.yaml +4 -0
- package/skills/judge-retired-position/SKILL.md +25 -0
- package/skills/judge-task-lifecycle/SKILL.md +45 -0
- package/skills/key-state-attribute/SKILL.md +16 -0
- package/skills/resolve-entity-identity/SKILL.md +24 -0
- package/skills/resolve-relative-time/SKILL.md +22 -0
- package/sqlite-extensions/LICENSE-simple-tokenizer +28 -0
- package/sqlite-extensions/LICENSE-sqlite-vec +21 -0
- package/sqlite-extensions/linux-arm64/vec0.so +0 -0
- package/sqlite-extensions/linux-x64/vec0.so +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll as t };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//#region src/contract/routes.ts
|
|
2
|
+
const MEMORY_ROUTES = {
|
|
3
|
+
init: {
|
|
4
|
+
path: "/v1/init",
|
|
5
|
+
timeoutMs: 3e4
|
|
6
|
+
},
|
|
7
|
+
hostEvent: {
|
|
8
|
+
path: "/v1/host-event",
|
|
9
|
+
timeoutMs: 3e4
|
|
10
|
+
},
|
|
11
|
+
getRecall: {
|
|
12
|
+
path: "/v1/get-recall",
|
|
13
|
+
timeoutMs: 12e4
|
|
14
|
+
},
|
|
15
|
+
capture: {
|
|
16
|
+
path: "/v1/capture",
|
|
17
|
+
timeoutMs: 9e5
|
|
18
|
+
},
|
|
19
|
+
mutate: {
|
|
20
|
+
path: "/v1/mutate",
|
|
21
|
+
timeoutMs: 9e5
|
|
22
|
+
},
|
|
23
|
+
inspect: {
|
|
24
|
+
path: "/v1/inspect",
|
|
25
|
+
timeoutMs: 3e4
|
|
26
|
+
},
|
|
27
|
+
recordUsage: {
|
|
28
|
+
path: "/v1/record-usage",
|
|
29
|
+
timeoutMs: 3e4
|
|
30
|
+
},
|
|
31
|
+
onSessionEnd: {
|
|
32
|
+
path: "/v1/on-session-end",
|
|
33
|
+
timeoutMs: 9e5
|
|
34
|
+
},
|
|
35
|
+
staticBlock: {
|
|
36
|
+
path: "/v1/static-block",
|
|
37
|
+
timeoutMs: 3e4
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const MEMORY_BODY_LIMIT_BYTES = 8388608;
|
|
41
|
+
const MEMORY_SKIN_HEADER = "x-sno-station-mem-skin";
|
|
42
|
+
const REM_SIDECAR_TOKEN_HEADER = "x-sidecar-token";
|
|
43
|
+
function memoryMethod(pathname) {
|
|
44
|
+
return Object.keys(MEMORY_ROUTES).find((method) => MEMORY_ROUTES[method].path === pathname);
|
|
45
|
+
}
|
|
46
|
+
const MEMORY_ERROR_STATUS = {
|
|
47
|
+
"sidecar-unreachable": 503,
|
|
48
|
+
"sidecar-unresponsive": 503,
|
|
49
|
+
"principal-mismatch": 403,
|
|
50
|
+
"store-mismatch": 409,
|
|
51
|
+
"no-agent-endpoint": 503,
|
|
52
|
+
"invalid-input": 400,
|
|
53
|
+
timeout: 504,
|
|
54
|
+
"storage-unavailable": 503,
|
|
55
|
+
"engine-failed": 500
|
|
56
|
+
};
|
|
57
|
+
const MEMORY_RECONNECT_INTERVAL_MS = 1e3;
|
|
58
|
+
const MEMORY_DEFAULT_SKIN_ID = "default";
|
|
59
|
+
//#endregion
|
|
60
|
+
export { MEMORY_ROUTES as a, memoryMethod as c, MEMORY_RECONNECT_INTERVAL_MS as i, MEMORY_DEFAULT_SKIN_ID as n, MEMORY_SKIN_HEADER as o, MEMORY_ERROR_STATUS as r, REM_SIDECAR_TOKEN_HEADER as s, MEMORY_BODY_LIMIT_BYTES as t };
|
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import { redactSecrets } from "./internal/engine/security/redact.js";
|
|
2
|
+
import "./internal/engine/shared/paths.js";
|
|
3
|
+
import { createLogger } from "@snoai/utils/logger";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { appendFile } from "node:fs/promises";
|
|
6
|
+
import { randomUUID } from "node:crypto";
|
|
7
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
8
|
+
import { appendFileSync, createReadStream, existsSync, mkdirSync } from "node:fs";
|
|
9
|
+
import { createInterface } from "node:readline";
|
|
10
|
+
//#region src/engine/operations/jsonl-lines.ts
|
|
11
|
+
const log = createLogger("sno-station-mem:jsonl");
|
|
12
|
+
/** Preserve complete records without materializing an unbounded log as one string. */
|
|
13
|
+
async function* readJsonlLines(file) {
|
|
14
|
+
const stream = createReadStream(file, { encoding: "utf8" });
|
|
15
|
+
const lines = createInterface({
|
|
16
|
+
input: stream,
|
|
17
|
+
crlfDelay: Infinity
|
|
18
|
+
});
|
|
19
|
+
try {
|
|
20
|
+
for await (const line of lines) if (line.trim()) yield line;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") return;
|
|
23
|
+
log.error("jsonl.read.failed", {
|
|
24
|
+
file,
|
|
25
|
+
error
|
|
26
|
+
}, {
|
|
27
|
+
event_name: "memory.jsonl.read.failed",
|
|
28
|
+
file: "packages/memory/src/engine/operations/jsonl-lines.ts",
|
|
29
|
+
function: "readJsonlLines",
|
|
30
|
+
site_id: "memory.jsonl.read.failed"
|
|
31
|
+
});
|
|
32
|
+
} finally {
|
|
33
|
+
lines.close();
|
|
34
|
+
stream.destroy();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/engine/operations/runtime-audit-log.ts
|
|
39
|
+
/** @file runtime-audit-log.ts
|
|
40
|
+
* @purpose Records audit events for operational visibility and safety-sensitive actions.
|
|
41
|
+
* @boundary Plugin runtime events and filesystem-backed audit persistence.
|
|
42
|
+
* @see sno-station-mem-plugin-runtime.ts, memory-tool-registration.ts, errors.ts.
|
|
43
|
+
*/
|
|
44
|
+
const auditWriteQueues = /* @__PURE__ */ new Map();
|
|
45
|
+
const memoryAuditScope = new AsyncLocalStorage();
|
|
46
|
+
const mutationAttemptScope = new AsyncLocalStorage();
|
|
47
|
+
const mutationRecoveryPromises = /* @__PURE__ */ new Map();
|
|
48
|
+
const MEMORY_AUDIT_COMMON_KEYS = [
|
|
49
|
+
"operation",
|
|
50
|
+
"audit_phase",
|
|
51
|
+
"audit_operation_id"
|
|
52
|
+
];
|
|
53
|
+
const MUTATION_AUDIT_DETAIL_KEYS = [
|
|
54
|
+
"mutation_writer",
|
|
55
|
+
"mutation_subject",
|
|
56
|
+
"mutation_outcome",
|
|
57
|
+
"refusal_reason"
|
|
58
|
+
];
|
|
59
|
+
const MEMORY_AUDIT_ALLOWED_DETAIL_KEYS = {
|
|
60
|
+
memory_injected: /* @__PURE__ */ new Set([
|
|
61
|
+
...MEMORY_AUDIT_COMMON_KEYS,
|
|
62
|
+
"scope",
|
|
63
|
+
"category",
|
|
64
|
+
"lane",
|
|
65
|
+
"count",
|
|
66
|
+
"memory_ids",
|
|
67
|
+
"write_outcome",
|
|
68
|
+
"created_count",
|
|
69
|
+
"existing_count"
|
|
70
|
+
]),
|
|
71
|
+
memory_searched: /* @__PURE__ */ new Set([
|
|
72
|
+
...MEMORY_AUDIT_COMMON_KEYS,
|
|
73
|
+
"scope",
|
|
74
|
+
"query_kind",
|
|
75
|
+
"requested_count",
|
|
76
|
+
"result_count",
|
|
77
|
+
"memory_ids"
|
|
78
|
+
]),
|
|
79
|
+
memory_read: /* @__PURE__ */ new Set([
|
|
80
|
+
...MEMORY_AUDIT_COMMON_KEYS,
|
|
81
|
+
"scope",
|
|
82
|
+
"requested_count",
|
|
83
|
+
"result_count",
|
|
84
|
+
"memory_ids",
|
|
85
|
+
"requested_fact_id",
|
|
86
|
+
"resolved_fact_id",
|
|
87
|
+
"fact_ids",
|
|
88
|
+
"found",
|
|
89
|
+
"outcome"
|
|
90
|
+
]),
|
|
91
|
+
memory_updated: /* @__PURE__ */ new Set([
|
|
92
|
+
...MEMORY_AUDIT_COMMON_KEYS,
|
|
93
|
+
...MUTATION_AUDIT_DETAIL_KEYS,
|
|
94
|
+
"scope",
|
|
95
|
+
"requested_count",
|
|
96
|
+
"result_count",
|
|
97
|
+
"memory_ids",
|
|
98
|
+
"outcome",
|
|
99
|
+
"migration_status",
|
|
100
|
+
"rewritten_rows",
|
|
101
|
+
"checked_rows"
|
|
102
|
+
]),
|
|
103
|
+
memory_superseded: /* @__PURE__ */ new Set([
|
|
104
|
+
...MEMORY_AUDIT_COMMON_KEYS,
|
|
105
|
+
...MUTATION_AUDIT_DETAIL_KEYS,
|
|
106
|
+
"scope",
|
|
107
|
+
"replacement_memory_id",
|
|
108
|
+
"closed_memory_ids",
|
|
109
|
+
"write_outcome"
|
|
110
|
+
]),
|
|
111
|
+
memory_deleted: /* @__PURE__ */ new Set([
|
|
112
|
+
...MEMORY_AUDIT_COMMON_KEYS,
|
|
113
|
+
"scope",
|
|
114
|
+
"deleted_memory_ids",
|
|
115
|
+
"delete_reason",
|
|
116
|
+
"count",
|
|
117
|
+
"outcome",
|
|
118
|
+
"removed_files"
|
|
119
|
+
]),
|
|
120
|
+
memory_purged: /* @__PURE__ */ new Set([
|
|
121
|
+
...MEMORY_AUDIT_COMMON_KEYS,
|
|
122
|
+
"target_fact_id",
|
|
123
|
+
"purged_fact_ids",
|
|
124
|
+
"failed_fact_ids",
|
|
125
|
+
"status",
|
|
126
|
+
"blocked_reason"
|
|
127
|
+
])
|
|
128
|
+
};
|
|
129
|
+
/** Implements enqueue audit write as the local audit log state operation. */
|
|
130
|
+
function enqueueAuditWrite(auditPath, line) {
|
|
131
|
+
const next = (auditWriteQueues.get(auditPath) ?? Promise.resolve(true)).catch(() => void 0).then(async () => {
|
|
132
|
+
mkdirSync(path.dirname(auditPath), { recursive: true });
|
|
133
|
+
await appendFile(auditPath, line);
|
|
134
|
+
return true;
|
|
135
|
+
}).catch((error) => {
|
|
136
|
+
createLogger("sno-station-mem:audit").error("Audit entry append failed", { error }, {
|
|
137
|
+
event_name: "memory.audit.append.failed",
|
|
138
|
+
file: "packages/memory/src/engine/operations/runtime-audit-log.ts",
|
|
139
|
+
function: "enqueueAuditWrite",
|
|
140
|
+
site_id: "memory.audit.append.failed"
|
|
141
|
+
});
|
|
142
|
+
return false;
|
|
143
|
+
});
|
|
144
|
+
auditWriteQueues.set(auditPath, next);
|
|
145
|
+
next.finally(() => {
|
|
146
|
+
if (auditWriteQueues.get(auditPath) === next) auditWriteQueues.delete(auditPath);
|
|
147
|
+
});
|
|
148
|
+
return next;
|
|
149
|
+
}
|
|
150
|
+
/** Returns audit path from audit log state state without side effects. */
|
|
151
|
+
function getAuditPath(stateDir) {
|
|
152
|
+
return path.join(stateDir, "audit.jsonl");
|
|
153
|
+
}
|
|
154
|
+
/** Returns cost path from audit log state state without side effects. */
|
|
155
|
+
function getCostPath(stateDir) {
|
|
156
|
+
return path.join(stateDir, "cost.jsonl");
|
|
157
|
+
}
|
|
158
|
+
function isRecord(value) {
|
|
159
|
+
return typeof value === "object" && value !== null;
|
|
160
|
+
}
|
|
161
|
+
function isMemoryAuditEvent(event) {
|
|
162
|
+
return event.startsWith("memory_");
|
|
163
|
+
}
|
|
164
|
+
function redactAuditValue(value) {
|
|
165
|
+
if (typeof value === "string") return redactSecrets(value);
|
|
166
|
+
if (Array.isArray(value)) return value.map(redactAuditValue);
|
|
167
|
+
if (!isRecord(value)) return value;
|
|
168
|
+
const redacted = {};
|
|
169
|
+
for (const [key, child] of Object.entries(value)) redacted[key] = redactAuditValue(child);
|
|
170
|
+
return redacted;
|
|
171
|
+
}
|
|
172
|
+
function prepareAuditEntry(entry) {
|
|
173
|
+
if (!isMemoryAuditEvent(entry.event) || entry.details?.["audit_phase"] === void 0) return entry;
|
|
174
|
+
const allowed = MEMORY_AUDIT_ALLOWED_DETAIL_KEYS[entry.event];
|
|
175
|
+
const details = {};
|
|
176
|
+
for (const [key, value] of Object.entries(entry.details)) if (allowed.has(key)) details[key] = value;
|
|
177
|
+
else createLogger("sno-station-mem:audit").error("memory.audit.detail.unknown", {
|
|
178
|
+
event: entry.event,
|
|
179
|
+
key
|
|
180
|
+
}, {
|
|
181
|
+
event_name: "memory.audit.detail.unknown",
|
|
182
|
+
file: "packages/memory/src/engine/operations/runtime-audit-log.ts",
|
|
183
|
+
function: "prepareAuditEntry",
|
|
184
|
+
site_id: "memory.audit.detail.unknown"
|
|
185
|
+
});
|
|
186
|
+
return {
|
|
187
|
+
...entry,
|
|
188
|
+
...entry.scope === void 0 ? {} : { scope: redactSecrets(entry.scope) },
|
|
189
|
+
details: redactAuditValue(details)
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
/** Persists audit entry through the single audit log state write path. */
|
|
193
|
+
function appendAuditEntry(stateDir, entry) {
|
|
194
|
+
const auditPath = getAuditPath(stateDir);
|
|
195
|
+
const prepared = prepareAuditEntry(entry);
|
|
196
|
+
enqueueAuditWrite(auditPath, `${JSON.stringify({
|
|
197
|
+
...prepared,
|
|
198
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
199
|
+
})}\n`);
|
|
200
|
+
}
|
|
201
|
+
/** Waits for the audit append; failures are logged without blocking the operation. */
|
|
202
|
+
async function appendAuditEntryStrict(stateDir, entry) {
|
|
203
|
+
const auditPath = getAuditPath(stateDir);
|
|
204
|
+
const prepared = prepareAuditEntry(entry);
|
|
205
|
+
return enqueueAuditWrite(auditPath, `${JSON.stringify({
|
|
206
|
+
...prepared,
|
|
207
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
208
|
+
})}\n`);
|
|
209
|
+
}
|
|
210
|
+
/** Attempts a synchronous audit append and logs a failure. */
|
|
211
|
+
function appendAuditEntrySync(stateDir, entry) {
|
|
212
|
+
const auditPath = getAuditPath(stateDir);
|
|
213
|
+
const prepared = prepareAuditEntry(entry);
|
|
214
|
+
try {
|
|
215
|
+
mkdirSync(path.dirname(auditPath), { recursive: true });
|
|
216
|
+
appendFileSync(auditPath, `${JSON.stringify({
|
|
217
|
+
...prepared,
|
|
218
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
219
|
+
})}\n`);
|
|
220
|
+
} catch (error) {
|
|
221
|
+
createLogger("sno-station-mem:audit").error("memory.audit.append.failed", { error }, {
|
|
222
|
+
event_name: "memory.audit.append.failed",
|
|
223
|
+
file: "packages/memory/src/engine/operations/runtime-audit-log.ts",
|
|
224
|
+
function: "appendAuditEntrySync",
|
|
225
|
+
site_id: "memory.audit.sync.failed"
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function memoryAuditDetails(operation, phase, operationId, details) {
|
|
230
|
+
return {
|
|
231
|
+
...details,
|
|
232
|
+
operation,
|
|
233
|
+
audit_phase: phase,
|
|
234
|
+
audit_operation_id: operationId
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
/** Records the start and outcome without using audit availability as admission. */
|
|
238
|
+
async function runWithMemoryAudit(options) {
|
|
239
|
+
if (memoryAuditScope.getStore()) return options.run();
|
|
240
|
+
return memoryAuditScope.run(true, async () => {
|
|
241
|
+
const operationId = randomUUID();
|
|
242
|
+
await appendAuditEntryStrict(options.stateDir, {
|
|
243
|
+
event: options.event,
|
|
244
|
+
scope: options.scope,
|
|
245
|
+
resultStatus: "partial",
|
|
246
|
+
details: memoryAuditDetails(options.operation, "started", operationId, options.startedDetails)
|
|
247
|
+
});
|
|
248
|
+
let result;
|
|
249
|
+
try {
|
|
250
|
+
result = await options.run();
|
|
251
|
+
} catch (error) {
|
|
252
|
+
await appendAuditEntryStrict(options.stateDir, {
|
|
253
|
+
event: options.event,
|
|
254
|
+
scope: options.scope,
|
|
255
|
+
resultStatus: "error",
|
|
256
|
+
errorCode: "memory_operation_failed",
|
|
257
|
+
details: memoryAuditDetails(options.operation, "failed", operationId, options.startedDetails)
|
|
258
|
+
});
|
|
259
|
+
throw error;
|
|
260
|
+
}
|
|
261
|
+
await appendAuditEntryStrict(options.stateDir, {
|
|
262
|
+
event: options.event,
|
|
263
|
+
scope: options.scope,
|
|
264
|
+
resultStatus: "ok",
|
|
265
|
+
details: memoryAuditDetails(options.operation, "completed", operationId, options.completedDetails(result))
|
|
266
|
+
});
|
|
267
|
+
return result;
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
async function readOpenMutationAttempts(stateDir) {
|
|
271
|
+
const auditPath = getAuditPath(stateDir);
|
|
272
|
+
if (!existsSync(auditPath)) return [];
|
|
273
|
+
const openAttempts = /* @__PURE__ */ new Map();
|
|
274
|
+
for await (const line of readJsonlLines(auditPath)) {
|
|
275
|
+
if (!line.trim()) continue;
|
|
276
|
+
let parsed;
|
|
277
|
+
try {
|
|
278
|
+
parsed = JSON.parse(line);
|
|
279
|
+
} catch {
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
if (!isRecord(parsed) || !isRecord(parsed["details"])) continue;
|
|
283
|
+
const event = parsed["event"];
|
|
284
|
+
const decision = parsed["decision"];
|
|
285
|
+
const details = parsed["details"];
|
|
286
|
+
const attemptId = details["audit_operation_id"];
|
|
287
|
+
if (typeof attemptId !== "string") continue;
|
|
288
|
+
if (details["mutation_outcome"] !== void 0) {
|
|
289
|
+
openAttempts.delete(attemptId);
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
if (decision !== "mutation-attempt-open" || details["audit_phase"] !== "started" || event !== "memory_updated" && event !== "memory_superseded" || typeof details["operation"] !== "string" || details["mutation_writer"] !== "profile-section" && details["mutation_writer"] !== "task-lifecycle" && details["mutation_writer"] !== "legacy-profile-refusal") continue;
|
|
293
|
+
openAttempts.set(attemptId, {
|
|
294
|
+
event,
|
|
295
|
+
operation: details["operation"],
|
|
296
|
+
attemptId,
|
|
297
|
+
writer: details["mutation_writer"],
|
|
298
|
+
...typeof details["mutation_subject"] === "string" ? { subject: details["mutation_subject"] } : {}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
return [...openAttempts.values()];
|
|
302
|
+
}
|
|
303
|
+
function mutationAuditDetails(input) {
|
|
304
|
+
return {
|
|
305
|
+
operation: input.operation,
|
|
306
|
+
audit_phase: input.phase,
|
|
307
|
+
audit_operation_id: input.attemptId,
|
|
308
|
+
mutation_writer: input.writer,
|
|
309
|
+
...input.subject === void 0 ? {} : { mutation_subject: input.subject },
|
|
310
|
+
...input.outcome === void 0 ? {} : { mutation_outcome: input.outcome },
|
|
311
|
+
...input.refusalReason === void 0 ? {} : { refusal_reason: input.refusalReason }
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function mutationAuditStatus(outcome) {
|
|
315
|
+
if (outcome === "failed" || outcome === "interrupted-unknown") return "error";
|
|
316
|
+
if (outcome.startsWith("refused-")) return "skipped";
|
|
317
|
+
return "ok";
|
|
318
|
+
}
|
|
319
|
+
async function closeMutationAttempt(stateDir, attempt, completion) {
|
|
320
|
+
const phase = completion.outcome === "failed" || completion.outcome === "interrupted-unknown" ? "failed" : "completed";
|
|
321
|
+
await appendAuditEntryStrict(stateDir, {
|
|
322
|
+
event: attempt.event,
|
|
323
|
+
resultStatus: mutationAuditStatus(completion.outcome),
|
|
324
|
+
decision: completion.outcome,
|
|
325
|
+
details: mutationAuditDetails({
|
|
326
|
+
operation: attempt.operation,
|
|
327
|
+
phase,
|
|
328
|
+
attemptId: attempt.attemptId,
|
|
329
|
+
writer: attempt.writer,
|
|
330
|
+
...attempt.subject === void 0 ? {} : { subject: attempt.subject },
|
|
331
|
+
outcome: completion.outcome,
|
|
332
|
+
...completion.refusalReason === void 0 ? {} : { refusalReason: completion.refusalReason }
|
|
333
|
+
})
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
/** Closes mutation attempts whose process stopped before a terminal audit record was written. */
|
|
337
|
+
async function recoverInterruptedMutationAttempts(stateDir) {
|
|
338
|
+
const attempts = await readOpenMutationAttempts(stateDir);
|
|
339
|
+
for (const attempt of attempts) await closeMutationAttempt(stateDir, attempt, { outcome: "interrupted-unknown" });
|
|
340
|
+
return attempts.map((attempt) => attempt.attemptId);
|
|
341
|
+
}
|
|
342
|
+
function ensureMutationRecovery(stateDir) {
|
|
343
|
+
const existing = mutationRecoveryPromises.get(stateDir);
|
|
344
|
+
if (existing) return existing;
|
|
345
|
+
const recovery = recoverInterruptedMutationAttempts(stateDir).then(() => void 0);
|
|
346
|
+
mutationRecoveryPromises.set(stateDir, recovery);
|
|
347
|
+
return recovery;
|
|
348
|
+
}
|
|
349
|
+
/** Runs one mutation under a durable open record and exactly one terminal outcome. */
|
|
350
|
+
async function runWithMutationAttempt(options) {
|
|
351
|
+
if (mutationAttemptScope.getStore()) return options.run();
|
|
352
|
+
await ensureMutationRecovery(options.stateDir);
|
|
353
|
+
const attempt = {
|
|
354
|
+
event: options.event,
|
|
355
|
+
operation: options.operation,
|
|
356
|
+
attemptId: randomUUID(),
|
|
357
|
+
writer: options.writer,
|
|
358
|
+
...options.subject === void 0 ? {} : { subject: options.subject }
|
|
359
|
+
};
|
|
360
|
+
return mutationAttemptScope.run(attempt.attemptId, async () => {
|
|
361
|
+
await appendAuditEntryStrict(options.stateDir, {
|
|
362
|
+
event: options.event,
|
|
363
|
+
resultStatus: "partial",
|
|
364
|
+
decision: "mutation-attempt-open",
|
|
365
|
+
details: mutationAuditDetails({
|
|
366
|
+
operation: attempt.operation,
|
|
367
|
+
phase: "started",
|
|
368
|
+
attemptId: attempt.attemptId,
|
|
369
|
+
writer: attempt.writer,
|
|
370
|
+
...attempt.subject === void 0 ? {} : { subject: attempt.subject }
|
|
371
|
+
})
|
|
372
|
+
});
|
|
373
|
+
let result;
|
|
374
|
+
try {
|
|
375
|
+
result = await options.run();
|
|
376
|
+
} catch (error) {
|
|
377
|
+
await closeMutationAttempt(options.stateDir, attempt, options.failedOutcome?.(error) ?? { outcome: "failed" });
|
|
378
|
+
throw error;
|
|
379
|
+
}
|
|
380
|
+
await closeMutationAttempt(options.stateDir, attempt, options.completedOutcome(result));
|
|
381
|
+
return result;
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
/** Returns the durable identifier owned by the current mutation boundary. */
|
|
385
|
+
function currentMutationAttemptId() {
|
|
386
|
+
const attemptId = mutationAttemptScope.getStore();
|
|
387
|
+
if (!attemptId) throw new Error("mutation attempt identifier requested outside a mutation boundary");
|
|
388
|
+
return attemptId;
|
|
389
|
+
}
|
|
390
|
+
/** Runs a synchronous memory operation only after its durable start record is persisted. */
|
|
391
|
+
function runWithMemoryAuditSync(options) {
|
|
392
|
+
if (memoryAuditScope.getStore()) return options.run();
|
|
393
|
+
return memoryAuditScope.run(true, () => {
|
|
394
|
+
const operationId = randomUUID();
|
|
395
|
+
appendAuditEntrySync(options.stateDir, {
|
|
396
|
+
event: options.event,
|
|
397
|
+
scope: options.scope,
|
|
398
|
+
resultStatus: "partial",
|
|
399
|
+
details: memoryAuditDetails(options.operation, "started", operationId, options.startedDetails)
|
|
400
|
+
});
|
|
401
|
+
let result;
|
|
402
|
+
try {
|
|
403
|
+
result = options.run();
|
|
404
|
+
} catch (error) {
|
|
405
|
+
appendAuditEntrySync(options.stateDir, {
|
|
406
|
+
event: options.event,
|
|
407
|
+
scope: options.scope,
|
|
408
|
+
resultStatus: "error",
|
|
409
|
+
errorCode: "memory_operation_failed",
|
|
410
|
+
details: memoryAuditDetails(options.operation, "failed", operationId, options.startedDetails)
|
|
411
|
+
});
|
|
412
|
+
throw error;
|
|
413
|
+
}
|
|
414
|
+
appendAuditEntrySync(options.stateDir, {
|
|
415
|
+
event: options.event,
|
|
416
|
+
scope: options.scope,
|
|
417
|
+
resultStatus: "ok",
|
|
418
|
+
details: memoryAuditDetails(options.operation, "completed", operationId, options.completedDetails(result))
|
|
419
|
+
});
|
|
420
|
+
return result;
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
/** Implements flush audit writes as the local audit log state operation. */
|
|
424
|
+
async function flushAuditWrites() {
|
|
425
|
+
const pending = Array.from(auditWriteQueues.values());
|
|
426
|
+
if (pending.length === 0) return;
|
|
427
|
+
await Promise.allSettled(pending);
|
|
428
|
+
}
|
|
429
|
+
//#endregion
|
|
430
|
+
export { flushAuditWrites as a, recoverInterruptedMutationAttempts as c, runWithMutationAttempt as d, currentMutationAttemptId as i, runWithMemoryAudit as l, appendAuditEntryStrict as n, getAuditPath as o, appendAuditEntrySync as r, getCostPath as s, appendAuditEntry as t, runWithMemoryAuditSync as u };
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import "./paths-qVF-5uBq.js";
|
|
2
|
+
//#region src/engine/operations/runtime-audit-log.d.ts
|
|
3
|
+
type AuditEvent = "tool_call" | "hook_trigger" | "kill_switch" | "startup" | "error" | "auto_recall" | "ambient_learning" | "session_summary" | "envelope_strip" | "storage_integrity" | "memory_injected" | "memory_searched" | "memory_read" | "memory_updated" | "memory_superseded" | "memory_deleted" | "memory_purged" | "rem_trigger_evaluated" | "rem_triggered" | "rem_completed" | "rem_failed";
|
|
4
|
+
type AuditStatus = "ok" | "error" | "skipped" | "partial";
|
|
5
|
+
interface AuditEntry {
|
|
6
|
+
timestamp: string;
|
|
7
|
+
event: AuditEvent;
|
|
8
|
+
tool?: string;
|
|
9
|
+
hook?: string;
|
|
10
|
+
scope?: string;
|
|
11
|
+
resultStatus: AuditStatus;
|
|
12
|
+
errorCode?: string;
|
|
13
|
+
durationMs?: number;
|
|
14
|
+
decision?: string;
|
|
15
|
+
details?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
type MemoryAuditEvent = "memory_injected" | "memory_searched" | "memory_read" | "memory_updated" | "memory_superseded" | "memory_deleted" | "memory_purged";
|
|
18
|
+
type MemoryAuditPhase = "started" | "completed" | "failed";
|
|
19
|
+
type MemoryAuditDetailBase = {
|
|
20
|
+
operation: string;
|
|
21
|
+
audit_phase: MemoryAuditPhase;
|
|
22
|
+
audit_operation_id: string;
|
|
23
|
+
};
|
|
24
|
+
type MutationAttemptOutcome = "committed" | "preserved-without-adjudication" | "repaired-merge-text" | "refused-by-authority" | "failed" | "interrupted-unknown" | "no-mutation";
|
|
25
|
+
type MutationAttemptWriter = "profile-section" | "task-lifecycle" | "legacy-profile-refusal";
|
|
26
|
+
type MutationAuditDetail = {
|
|
27
|
+
mutation_writer?: MutationAttemptWriter;
|
|
28
|
+
mutation_subject?: string;
|
|
29
|
+
mutation_outcome?: MutationAttemptOutcome;
|
|
30
|
+
refusal_reason?: string;
|
|
31
|
+
};
|
|
32
|
+
interface MemoryAuditDetailsByEvent {
|
|
33
|
+
memory_injected: MemoryAuditDetailBase & {
|
|
34
|
+
scope?: string;
|
|
35
|
+
category?: string;
|
|
36
|
+
lane?: string;
|
|
37
|
+
count?: number;
|
|
38
|
+
memory_ids?: string[];
|
|
39
|
+
write_outcome?: "created" | "existing" | "mixed";
|
|
40
|
+
created_count?: number;
|
|
41
|
+
existing_count?: number;
|
|
42
|
+
};
|
|
43
|
+
memory_searched: MemoryAuditDetailBase & {
|
|
44
|
+
scope?: string | string[];
|
|
45
|
+
query_kind?: string;
|
|
46
|
+
requested_count?: number;
|
|
47
|
+
result_count?: number;
|
|
48
|
+
memory_ids?: string[];
|
|
49
|
+
};
|
|
50
|
+
memory_read: MemoryAuditDetailBase & {
|
|
51
|
+
scope?: string;
|
|
52
|
+
requested_count?: number;
|
|
53
|
+
result_count?: number;
|
|
54
|
+
memory_ids?: string[];
|
|
55
|
+
requested_fact_id?: string;
|
|
56
|
+
resolved_fact_id?: string;
|
|
57
|
+
fact_ids?: string[];
|
|
58
|
+
found?: boolean;
|
|
59
|
+
outcome?: string;
|
|
60
|
+
};
|
|
61
|
+
memory_updated: MemoryAuditDetailBase & MutationAuditDetail & {
|
|
62
|
+
scope?: string;
|
|
63
|
+
requested_count?: number;
|
|
64
|
+
result_count?: number;
|
|
65
|
+
memory_ids?: string[];
|
|
66
|
+
outcome?: string;
|
|
67
|
+
migration_status?: "migrated" | "noop";
|
|
68
|
+
rewritten_rows?: number;
|
|
69
|
+
checked_rows?: number;
|
|
70
|
+
};
|
|
71
|
+
memory_superseded: MemoryAuditDetailBase & MutationAuditDetail & {
|
|
72
|
+
scope?: string;
|
|
73
|
+
replacement_memory_id?: string;
|
|
74
|
+
closed_memory_ids?: string[];
|
|
75
|
+
write_outcome?: "created" | "existing";
|
|
76
|
+
};
|
|
77
|
+
memory_deleted: MemoryAuditDetailBase & {
|
|
78
|
+
scope?: string;
|
|
79
|
+
deleted_memory_ids?: string[];
|
|
80
|
+
delete_reason?: string;
|
|
81
|
+
count?: number;
|
|
82
|
+
outcome?: "deleted" | "noop";
|
|
83
|
+
removed_files?: number;
|
|
84
|
+
};
|
|
85
|
+
memory_purged: MemoryAuditDetailBase & {
|
|
86
|
+
target_fact_id?: string;
|
|
87
|
+
purged_fact_ids?: string[];
|
|
88
|
+
failed_fact_ids?: string[];
|
|
89
|
+
status?: "complete" | "partial" | "blocked";
|
|
90
|
+
blocked_reason?: string;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
type MemoryAuditDetailInput<E extends MemoryAuditEvent> = Partial<Omit<MemoryAuditDetailsByEvent[E], keyof MemoryAuditDetailBase>>;
|
|
94
|
+
interface MemoryAuditRunOptions<T, E extends MemoryAuditEvent> {
|
|
95
|
+
stateDir: string;
|
|
96
|
+
event: E;
|
|
97
|
+
operation: string;
|
|
98
|
+
scope?: string;
|
|
99
|
+
startedDetails?: MemoryAuditDetailInput<E>;
|
|
100
|
+
run: () => Promise<T>;
|
|
101
|
+
completedDetails: (result: T) => MemoryAuditDetailInput<E>;
|
|
102
|
+
}
|
|
103
|
+
interface MemoryAuditSyncRunOptions<T, E extends MemoryAuditEvent> {
|
|
104
|
+
stateDir: string;
|
|
105
|
+
event: E;
|
|
106
|
+
operation: string;
|
|
107
|
+
scope?: string;
|
|
108
|
+
startedDetails?: MemoryAuditDetailInput<E>;
|
|
109
|
+
run: () => T;
|
|
110
|
+
completedDetails: (result: T) => MemoryAuditDetailInput<E>;
|
|
111
|
+
}
|
|
112
|
+
interface MutationAttemptCompletion {
|
|
113
|
+
outcome: MutationAttemptOutcome;
|
|
114
|
+
refusalReason?: string;
|
|
115
|
+
}
|
|
116
|
+
interface MutationAttemptRunOptions<T> {
|
|
117
|
+
stateDir: string;
|
|
118
|
+
event: "memory_updated" | "memory_superseded";
|
|
119
|
+
operation: string;
|
|
120
|
+
writer: MutationAttemptWriter;
|
|
121
|
+
subject?: string;
|
|
122
|
+
run: () => Promise<T>;
|
|
123
|
+
completedOutcome: (result: T) => MutationAttemptCompletion;
|
|
124
|
+
failedOutcome?: (error: unknown) => MutationAttemptCompletion;
|
|
125
|
+
}
|
|
126
|
+
/** Returns audit path from audit log state state without side effects. */
|
|
127
|
+
declare function getAuditPath(stateDir: string): string;
|
|
128
|
+
/** Returns cost path from audit log state state without side effects. */
|
|
129
|
+
declare function getCostPath(stateDir: string): string;
|
|
130
|
+
/** Persists audit entry through the single audit log state write path. */
|
|
131
|
+
declare function appendAuditEntry(stateDir: string, entry: Omit<AuditEntry, "timestamp">): void;
|
|
132
|
+
/** Waits for the audit append; failures are logged without blocking the operation. */
|
|
133
|
+
declare function appendAuditEntryStrict(stateDir: string, entry: Omit<AuditEntry, "timestamp">): Promise<boolean>;
|
|
134
|
+
/** Attempts a synchronous audit append and logs a failure. */
|
|
135
|
+
declare function appendAuditEntrySync(stateDir: string, entry: Omit<AuditEntry, "timestamp">): void;
|
|
136
|
+
/** Records the start and outcome without using audit availability as admission. */
|
|
137
|
+
declare function runWithMemoryAudit<T, E extends MemoryAuditEvent>(options: MemoryAuditRunOptions<T, E>): Promise<T>;
|
|
138
|
+
/** Closes mutation attempts whose process stopped before a terminal audit record was written. */
|
|
139
|
+
declare function recoverInterruptedMutationAttempts(stateDir: string): Promise<string[]>;
|
|
140
|
+
/** Runs one mutation under a durable open record and exactly one terminal outcome. */
|
|
141
|
+
declare function runWithMutationAttempt<T>(options: MutationAttemptRunOptions<T>): Promise<T>;
|
|
142
|
+
/** Returns the durable identifier owned by the current mutation boundary. */
|
|
143
|
+
declare function currentMutationAttemptId(): string;
|
|
144
|
+
/** Runs a synchronous memory operation only after its durable start record is persisted. */
|
|
145
|
+
declare function runWithMemoryAuditSync<T, E extends MemoryAuditEvent>(options: MemoryAuditSyncRunOptions<T, E>): T;
|
|
146
|
+
/** Implements flush audit writes as the local audit log state operation. */
|
|
147
|
+
declare function flushAuditWrites(): Promise<void>;
|
|
148
|
+
//#endregion
|
|
149
|
+
export { runWithMutationAttempt as S, getAuditPath as _, MemoryAuditEvent as a, runWithMemoryAudit as b, MutationAttemptCompletion as c, MutationAttemptWriter as d, appendAuditEntry as f, flushAuditWrites as g, currentMutationAttemptId as h, MemoryAuditDetailsByEvent as i, MutationAttemptOutcome as l, appendAuditEntrySync as m, AuditEvent as n, MemoryAuditRunOptions as o, appendAuditEntryStrict as p, AuditStatus as r, MemoryAuditSyncRunOptions as s, AuditEntry as t, MutationAttemptRunOptions as u, getCostPath as v, runWithMemoryAuditSync as x, recoverInterruptedMutationAttempts as y };
|