@remnic/core 9.66.0 → 9.66.2
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-admin-ops-surface.d.ts +11 -11
- package/dist/access-admin-ops-surface.js +31 -31
- package/dist/access-audit.js +2 -2
- package/dist/access-authorization-probe.d.ts +11 -11
- package/dist/access-authorization-probe.js +32 -32
- package/dist/access-boundary.d.ts +11 -11
- package/dist/access-boundary.js +31 -31
- package/dist/access-cli.js +105 -101
- package/dist/access-cli.js.map +1 -1
- package/dist/access-coding-context-resolution.d.ts +1 -1
- package/dist/access-extraction-force-flush.d.ts +11 -11
- package/dist/access-extraction-force-flush.js +31 -31
- package/dist/access-health-types.d.ts +1 -1
- package/dist/access-http-lcm-compaction.d.ts +11 -11
- package/dist/access-http-lifecycle-flush.d.ts +11 -11
- package/dist/access-http-offline-stream.d.ts +11 -11
- package/dist/access-http-query.d.ts +2 -2
- package/dist/access-http-query.js +33 -33
- package/dist/access-http.d.ts +12 -12
- package/dist/access-http.js +48 -48
- package/dist/access-identity-continuity-surface.d.ts +9 -9
- package/dist/access-identity-continuity-surface.js +31 -31
- package/dist/access-lcm-surface.d.ts +11 -11
- package/dist/access-lcm-surface.js +31 -31
- package/dist/access-mcp.d.ts +11 -11
- package/dist/access-mcp.js +39 -39
- package/dist/access-memory-search-fanout.d.ts +2 -2
- package/dist/{access-namespace-preflight-CLWUoMyW.d.ts → access-namespace-preflight-50VIkPhB.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +31 -31
- package/dist/access-observe-write-surface.d.ts +11 -11
- package/dist/access-observe-write-surface.js +31 -31
- package/dist/access-offline-manifest.d.ts +9 -9
- package/dist/access-operations-batch.js +34 -34
- package/dist/access-operations.d.ts +11 -11
- package/dist/access-operations.js +38 -38
- package/dist/access-recall-concurrency.d.ts +11 -11
- package/dist/access-recall-concurrency.js +31 -31
- package/dist/access-recall-response.d.ts +11 -11
- package/dist/access-recall-response.js +31 -31
- package/dist/access-recall-surface.d.ts +11 -11
- package/dist/access-recall-surface.js +31 -31
- package/dist/access-schema.js +3 -3
- package/dist/{access-service-CEUE1Isj.d.ts → access-service-Dz6I9AZ-.d.ts} +13 -13
- package/dist/access-service-helpers.d.ts +11 -11
- package/dist/access-service.d.ts +11 -11
- package/dist/access-service.js +31 -31
- package/dist/access-surface-catalog.d.ts +11 -11
- package/dist/access-surface-catalog.js +33 -33
- package/dist/access-wearables-meetings-surface.d.ts +3 -3
- package/dist/action-confidence.d.ts +1 -1
- package/dist/active-memory-bridge.d.ts +1 -1
- package/dist/active-recall.d.ts +1 -1
- package/dist/active-recall.js +4 -4
- package/dist/adapters/index.js +4 -4
- package/dist/adapters/registry.js +2 -2
- package/dist/ambient-provenance.d.ts +1 -1
- package/dist/artifact-search.d.ts +1 -1
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +9 -9
- package/dist/briefing-window.d.ts +2 -2
- package/dist/briefing.d.ts +2 -2
- package/dist/briefing.js +10 -10
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer-turn-helpers.d.ts +1 -1
- package/dist/buffer.d.ts +2 -2
- package/dist/buffer.js +4 -4
- package/dist/bulk-import/index.d.ts +3 -3
- package/dist/calibration.d.ts +1 -1
- package/dist/capabilities.d.ts +1 -1
- package/dist/{catalog-D1HgugTA.d.ts → catalog-C2jA-gLm.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-behavior.js +2 -2
- package/dist/causal-chain.js +2 -2
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-consolidation.js +13 -13
- package/dist/causal-retrieval.js +2 -2
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/causal-trajectory-graph.js +2 -2
- package/dist/causal-trajectory.js +1 -1
- package/dist/{chunk-EZSCW4EM.js → chunk-25OLNWYG.js} +2 -2
- package/dist/{chunk-2LBAFHOQ.js → chunk-2QSGJTDG.js} +10 -10
- package/dist/{chunk-7UTDHQZ5.js → chunk-2VZHB5US.js} +2 -2
- package/dist/{chunk-VQNRICAQ.js → chunk-36HJ36FK.js} +3 -3
- package/dist/{chunk-XKNHFDTT.js → chunk-3A2Z4OOS.js} +2 -2
- package/dist/{chunk-KODXCHXJ.js → chunk-46XR5FNZ.js} +39 -3
- package/dist/chunk-46XR5FNZ.js.map +1 -0
- package/dist/{chunk-56IV4J5W.js → chunk-47WWTCJY.js} +1384 -99
- package/dist/chunk-47WWTCJY.js.map +1 -0
- package/dist/{chunk-RDGKVH6T.js → chunk-4NKIGSJM.js} +2 -2
- package/dist/{chunk-EFQCDJZ2.js → chunk-4PG2CKI6.js} +2 -2
- package/dist/{chunk-HJXA6ZM7.js → chunk-6545JDIM.js} +2 -2
- package/dist/{chunk-J3OND5QT.js → chunk-65HXVEVG.js} +2 -2
- package/dist/{chunk-HNPE66LB.js → chunk-6BYJQ3L2.js} +8 -8
- package/dist/{chunk-ZW4VXELZ.js → chunk-6PUF7LUO.js} +2 -2
- package/dist/{chunk-TVVEYCNW.js → chunk-7K5Q6COX.js} +4 -4
- package/dist/{chunk-MN5NOOI7.js → chunk-AI5M4FVQ.js} +2 -2
- package/dist/{chunk-IHGMRDEE.js → chunk-B4B3QDV3.js} +235 -151
- package/dist/chunk-B4B3QDV3.js.map +1 -0
- package/dist/{chunk-YMOPYG3K.js → chunk-BIJAWZYW.js} +6 -6
- package/dist/{chunk-I5VB44ZK.js → chunk-BLHKR4GJ.js} +2 -2
- package/dist/chunk-BLUYQFRH.js +36 -0
- package/dist/chunk-BLUYQFRH.js.map +1 -0
- package/dist/{chunk-CEH2AFXG.js → chunk-C24UZSFW.js} +6 -6
- package/dist/{chunk-MJRGVXPQ.js → chunk-C3ZYZKDJ.js} +2 -2
- package/dist/{chunk-QCRJMU5V.js → chunk-CDLPF3PX.js} +2 -2
- package/dist/{chunk-23CVL7HS.js → chunk-CQ6IWZDI.js} +2 -2
- package/dist/{chunk-KWIGDKM2.js → chunk-D2YNNDML.js} +2 -2
- package/dist/{chunk-FTTJRVB7.js → chunk-D3DUA64S.js} +2 -2
- package/dist/{chunk-7XOG75AU.js → chunk-D6Q5EPOV.js} +2 -2
- package/dist/{chunk-GEJKYA7D.js → chunk-DSEHPUID.js} +6 -6
- package/dist/chunk-E4X2YX2F.js +22 -0
- package/dist/chunk-E4X2YX2F.js.map +1 -0
- package/dist/{chunk-PEBH5DCK.js → chunk-EH7BNIUN.js} +101 -19
- package/dist/chunk-EH7BNIUN.js.map +1 -0
- package/dist/{chunk-OAJMQKQR.js → chunk-EQRD4NMH.js} +2 -2
- package/dist/{chunk-H7VDIF2V.js → chunk-ER2UPUMG.js} +2 -2
- package/dist/{chunk-4FHRZD5T.js → chunk-F2JXJABQ.js} +2 -2
- package/dist/{chunk-FKKGCGYL.js → chunk-F4W5HTED.js} +2 -2
- package/dist/{chunk-DMEHOEC7.js → chunk-FFWONAAW.js} +3 -3
- package/dist/chunk-FYDW33ZB.js +13 -0
- package/dist/chunk-FYDW33ZB.js.map +1 -0
- package/dist/{chunk-TNGH4ZYI.js → chunk-GNWLTCKC.js} +2 -2
- package/dist/{chunk-CFVTRUR3.js → chunk-H6RSANGQ.js} +2 -2
- package/dist/chunk-HVAEXYPL.js +98 -0
- package/dist/chunk-HVAEXYPL.js.map +1 -0
- package/dist/{chunk-CTCGHNWN.js → chunk-J2R275FN.js} +4 -4
- package/dist/{chunk-IVIAHQBR.js → chunk-JJ6ZEFXC.js} +2 -2
- package/dist/{chunk-KXIXO76C.js → chunk-JMXHVJ2V.js} +14 -14
- package/dist/{chunk-7LCGFUMB.js → chunk-KQAFEZQX.js} +4 -4
- package/dist/{chunk-NACLNNFQ.js → chunk-KSZKQTZS.js} +2 -2
- package/dist/{chunk-NPIBN2VL.js → chunk-LK4TOYPU.js} +2 -2
- package/dist/{chunk-K66OY4EI.js → chunk-LSR5LQXN.js} +2 -2
- package/dist/chunk-MAG6M3B6.js +51 -0
- package/dist/chunk-MAG6M3B6.js.map +1 -0
- package/dist/{chunk-6CEGSTBD.js → chunk-NTFXBILO.js} +5 -5
- package/dist/{chunk-2PSX5BJU.js → chunk-NZPFCP5A.js} +2 -2
- package/dist/{chunk-FYWLSFFS.js → chunk-OERZXNSK.js} +2 -2
- package/dist/{chunk-ZJPM7GZ3.js → chunk-OIDICRH7.js} +2 -2
- package/dist/{chunk-LTBKKSCX.js → chunk-OLBZ2WGG.js} +2 -2
- package/dist/{chunk-PD66CVSD.js → chunk-OUKBMQ2O.js} +2 -2
- package/dist/{chunk-GPFZFCRN.js → chunk-PP7R754B.js} +1 -1
- package/dist/{chunk-GX6FTSYH.js → chunk-PRRUK2ZH.js} +2 -2
- package/dist/{chunk-MAH64N55.js → chunk-PW3GKWH3.js} +4 -4
- package/dist/chunk-Q3SHEAXR.js +80 -0
- package/dist/chunk-Q3SHEAXR.js.map +1 -0
- package/dist/{chunk-33MFRY25.js → chunk-R2Q6FTOX.js} +2 -2
- package/dist/{chunk-VCKWULAK.js → chunk-RCPKBW7K.js} +5 -5
- package/dist/{chunk-CN4VKV3S.js → chunk-RH3XLQG4.js} +2 -2
- package/dist/{chunk-2QSZNTDO.js → chunk-RKNJBZ55.js} +4 -4
- package/dist/{chunk-YXFCALVT.js → chunk-U4HZEW2B.js} +8 -8
- package/dist/{chunk-RZ3IZIJG.js → chunk-UHQE37NI.js} +2 -2
- package/dist/{chunk-Z3YEGSR4.js → chunk-UMZUKOJU.js} +4 -4
- package/dist/{chunk-72OIT7KS.js → chunk-UVYL5G7A.js} +3 -3
- package/dist/{chunk-4STAANV7.js → chunk-VKDBDJIX.js} +3 -3
- package/dist/{chunk-WKJFIMVN.js → chunk-VSMSYDIH.js} +2 -2
- package/dist/{chunk-GSKINLAK.js → chunk-W5IYHQA5.js} +3 -3
- package/dist/{chunk-FESUGFIL.js → chunk-WKWY7YF3.js} +2 -2
- package/dist/{chunk-UNUMFURP.js → chunk-X5PIDJ3L.js} +3 -3
- package/dist/{chunk-MINHJ55X.js → chunk-XXW32OL7.js} +1 -1
- package/dist/{chunk-MINHJ55X.js.map → chunk-XXW32OL7.js.map} +1 -1
- package/dist/{chunk-6RUHELWR.js → chunk-Y2YM4C75.js} +2 -2
- package/dist/{chunk-L4X4PJYK.js → chunk-YZ5VC2JJ.js} +2 -2
- package/dist/{chunk-VQ4AMTGZ.js → chunk-ZBIEX4XN.js} +1 -1
- package/dist/{chunk-O57GM3FR.js → chunk-ZMVW2HJJ.js} +2 -2
- package/dist/{chunk-6QDXA26G.js → chunk-ZXROBS53.js} +68 -68
- package/dist/{cli-BEkm2MEf.d.ts → cli-BOuEb4Ia.d.ts} +5 -5
- package/dist/cli.d.ts +13 -13
- package/dist/cli.js +76 -76
- package/dist/coding/export-okf-codegraph.d.ts +1 -1
- package/dist/coding/export-okf-codegraph.js +10 -10
- package/dist/coding/pre-action-gate.d.ts +1 -1
- package/dist/coding/pre-action-gate.js +2 -2
- package/dist/compounding/engine.d.ts +2 -2
- package/dist/compounding/engine.js +10 -10
- 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 -4
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +10 -10
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +10 -10
- package/dist/consolidation-provenance-check.d.ts +2 -2
- package/dist/consolidation-undo.d.ts +2 -2
- package/dist/contradiction/index.d.ts +3 -3
- package/dist/converge-config.d.ts +1 -1
- package/dist/convergence-refresh.d.ts +2 -2
- package/dist/convergence-refresh.js +12 -12
- 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/corpus-watermark.d.ts +1 -1
- package/dist/corpus-watermark.js +12 -12
- package/dist/cross-lingual-recall.d.ts +1 -1
- package/dist/day-summary.d.ts +1 -1
- package/dist/delinearize.d.ts +1 -1
- package/dist/dependency-propagation-config.d.ts +1 -1
- package/dist/{dependency-propagation-delivery-BCpeo14F.d.ts → dependency-propagation-delivery-D4WMbOwA.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-origin-fields.d.ts +1 -1
- package/dist/entity-retrieval.d.ts +2 -2
- package/dist/entity-retrieval.js +10 -10
- package/dist/entity-schema.d.ts +1 -1
- package/dist/episodic-context.d.ts +1 -1
- package/dist/eval-trajectory-contracts.d.ts +1 -1
- package/dist/eval-trajectory-store.d.ts +1 -1
- package/dist/eval-trajectory.d.ts +1 -1
- package/dist/explicit-capture.d.ts +9 -9
- package/dist/external-wiki-access.d.ts +11 -11
- package/dist/external-wiki-access.js +32 -32
- package/dist/external-wiki-collection-registration.d.ts +1 -1
- package/dist/external-wiki-collection.d.ts +1 -1
- package/dist/external-wiki-mcp-tools.d.ts +11 -11
- package/dist/extraction-error-classification.d.ts +1 -1
- 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-liveness.d.ts +1 -1
- package/dist/extraction-normalization.d.ts +1 -1
- package/dist/extraction-prompt.d.ts +1 -1
- package/dist/extraction-source-grounding-rules.d.ts +1 -1
- package/dist/extraction-source-grounding.d.ts +1 -1
- package/dist/extraction-span-wire.d.ts +17 -0
- package/dist/extraction-span-wire.js +13 -0
- package/dist/extraction-span-wire.js.map +1 -0
- package/dist/extraction-span.d.ts +17 -0
- package/dist/extraction-span.js +8 -0
- package/dist/extraction.d.ts +1 -1
- package/dist/extraction.js +13 -13
- package/dist/fallback-llm.d.ts +1 -1
- package/dist/graph-dashboard-diff.d.ts +1 -1
- package/dist/graph-dashboard-key.d.ts +1 -1
- package/dist/graph-dashboard-parser.d.ts +1 -1
- package/dist/{graph-edge-decay-A4SDFMMS.js → graph-edge-decay-FXGELBFA.js} +4 -4
- package/dist/graph-edge-decay-FXGELBFA.js.map +1 -0
- package/dist/graph-edge-reinforcement.d.ts +1 -1
- package/dist/graph-path-reconstruction.d.ts +1 -1
- package/dist/graph-path-scoring.d.ts +1 -1
- package/dist/graph-snapshot.d.ts +1 -1
- package/dist/graph-snapshot.js +3 -3
- package/dist/graph.d.ts +1 -1
- package/dist/graph.js +3 -3
- package/dist/harmonic-retrieval.js +1 -1
- package/dist/importance.d.ts +1 -1
- package/dist/importers/index.d.ts +1 -1
- package/dist/in-flight-reads.d.ts +1 -1
- package/dist/{index-D_pyMUaP.d.ts → index-DuJnzwHv.d.ts} +2 -2
- package/dist/index.d.ts +341 -26
- package/dist/index.js +195 -114
- package/dist/intent.d.ts +1 -1
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/engine.js +2 -2
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/index.js +7 -7
- 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/local-model-endpoint.d.ts +1 -1
- package/dist/location/index.d.ts +3 -3
- package/dist/location/index.js +12 -12
- package/dist/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/memory-governance.js +10 -10
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +10 -10
- package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-projection.js +11 -11
- package/dist/{maintenance-DDUX9d6D.d.ts → maintenance-BBeaeYRR.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +11 -11
- package/dist/memory-action-policy.d.ts +1 -1
- package/dist/memory-cache.d.ts +1 -1
- package/dist/memory-controller.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-snapshot.d.ts +1 -1
- package/dist/memory-subject-cli.d.ts +11 -11
- package/dist/memory-subject.d.ts +11 -11
- package/dist/memory-worth-outcomes.d.ts +2 -2
- package/dist/models-json.d.ts +1 -1
- package/dist/namespaces/migrate.d.ts +3 -3
- package/dist/namespaces/migrate.js +11 -11
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/search.js +6 -6
- package/dist/namespaces/storage.d.ts +3 -3
- package/dist/namespaces/storage.js +10 -10
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/offline-sync-impression-drain.d.ts +1 -1
- package/dist/operator-doctor-corpus.d.ts +1 -1
- package/dist/operator-doctor-corpus.js +13 -13
- package/dist/operator-doctor-replica.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +3 -3
- package/dist/operator-toolkit.js +24 -24
- package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
- package/dist/orchestration/maintenance.d.ts +4 -4
- package/dist/orchestration/maintenance.js +19 -19
- package/dist/{orchestrator-3F4jihCo.d.ts → orchestrator-CaqnwNwM.d.ts} +8 -8
- package/dist/orchestrator.d.ts +9 -9
- package/dist/orchestrator.js +105 -101
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-CB1dj6Uh.d.ts → pipeline-CrxVjlJr.d.ts} +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/proactive-contention.d.ts +1 -1
- package/dist/provenance.d.ts +1 -1
- package/dist/{public-http-34-JIAGQ.d.ts → public-http-CmQRjQCD.d.ts} +1 -1
- package/dist/{qmd-edLLZXc5.d.ts → qmd-BZgbJm0g.d.ts} +1 -1
- package/dist/qmd-preflight.d.ts +2 -2
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +2 -2
- package/dist/qmd.js +4 -4
- package/dist/recall-concurrency-config.d.ts +1 -1
- package/dist/recall-deep-access.d.ts +30 -0
- package/dist/recall-deep-access.js +50 -0
- package/dist/recall-deep-access.js.map +1 -0
- package/dist/recall-deep-render.d.ts +11 -0
- package/dist/recall-deep-render.js +28 -0
- package/dist/recall-deep-render.js.map +1 -0
- package/dist/recall-deep.d.ts +37 -0
- package/dist/recall-deep.js +14 -0
- package/dist/recall-deep.js.map +1 -0
- 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-memory-map.d.ts +1 -1
- package/dist/recall-navigate.d.ts +70 -0
- package/dist/recall-navigate.js +15 -0
- package/dist/recall-navigate.js.map +1 -0
- package/dist/recall-planner-llm.d.ts +1 -1
- package/dist/recall-state-view-render.d.ts +18 -0
- package/dist/recall-state-view-render.js +22 -0
- package/dist/recall-state-view-render.js.map +1 -0
- package/dist/recall-state-view-widen.d.ts +13 -0
- package/dist/recall-state-view-widen.js +11 -0
- package/dist/recall-state-view-widen.js.map +1 -0
- package/dist/recall-state-view-wire.d.ts +13 -0
- package/dist/recall-state-view-wire.js +12 -0
- package/dist/recall-state-view-wire.js.map +1 -0
- package/dist/recall-state-view.d.ts +25 -0
- package/dist/recall-state-view.js +22 -0
- package/dist/recall-state-view.js.map +1 -0
- package/dist/recall-state.d.ts +1 -1
- package/dist/recall-tag-filter.d.ts +1 -1
- package/dist/recall-timings.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/reconcile/cursor.d.ts +1 -1
- package/dist/reconcile/manifest.d.ts +1 -1
- package/dist/reconcile/plan.d.ts +1 -1
- package/dist/replay/normalizers/chatgpt.d.ts +1 -1
- package/dist/replay/normalizers/claude.d.ts +1 -1
- package/dist/replay/normalizers/openclaw.d.ts +1 -1
- package/dist/replay/normalizers/shared.d.ts +1 -1
- package/dist/replay/runner.d.ts +1 -1
- package/dist/replay/types.d.ts +1 -1
- package/dist/replica-divergence.d.ts +1 -1
- package/dist/replica-peers-config.d.ts +1 -1
- package/dist/resolve-auth-token.d.ts +1 -1
- package/dist/resume-bundles.js +5 -5
- package/dist/retrieval-agents.d.ts +2 -2
- 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/salvage-envelope.d.ts +1 -1
- package/dist/schemas.d.ts +42 -42
- package/dist/{scope-profiles-BF2lu81V.d.ts → scope-profiles-DFaojvoP.d.ts} +1 -1
- package/dist/search/embed-helper.d.ts +1 -1
- package/dist/search/factory.d.ts +1 -1
- package/dist/search/factory.js +5 -5
- package/dist/search/index.d.ts +1 -1
- package/dist/search/index.js +9 -9
- 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-5OuWXBRt.d.ts → semantic-consolidation-BiX68wZA.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +11 -11
- package/dist/semantic-rule-promotion.js +10 -10
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +10 -10
- package/dist/{service-CrqEhLXD.d.ts → service-D5h2zZ0M.d.ts} +2 -2
- 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 +1 -1
- package/dist/signal.d.ts +1 -1
- package/dist/source-agent-qualifier.d.ts +1 -1
- package/dist/source-agent-qualifier.js +12 -12
- package/dist/{storage-BQn-xnxm.d.ts → storage-CtsaojWD.d.ts} +1 -1
- package/dist/storage.d.ts +2 -2
- package/dist/storage.js +9 -9
- package/dist/subject-config.d.ts +1 -1
- package/dist/summarizer.d.ts +1 -1
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/support-passport/index.d.ts +14 -14
- package/dist/support-passport/index.js +34 -34
- package/dist/temporal-supersession.d.ts +2 -2
- package/dist/temporal-timeline-recall.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 +2 -2
- 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/capsule-export.js +2 -2
- package/dist/transfer/capsule-import.js +2 -2
- package/dist/transfer/export-okf.d.ts +1 -1
- package/dist/transfer/export-okf.js +11 -11
- package/dist/transfer/types.d.ts +12 -12
- package/dist/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/{types-BRpcNjHZ.d.ts → types-CIpfYz1I.d.ts} +16 -11
- 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 +10 -10
- package/dist/who-knows-cli.d.ts +11 -11
- package/dist/who-knows-cli.js +11 -11
- package/dist/who-knows.d.ts +11 -11
- package/dist/who-knows.js +10 -10
- package/dist/write-envelope.d.ts +1 -1
- package/package.json +2 -2
- package/src/activity/config.test.ts +1 -1
- package/src/activity/config.ts +48 -3
- package/src/activity/index.ts +5 -0
- package/src/activity/journal-vault-read.test.ts +153 -0
- package/src/activity/journal-vault-read.ts +214 -0
- package/src/activity/journal.test.ts +97 -0
- package/src/activity/journal.ts +113 -0
- package/src/activity/privacy.test.ts +53 -0
- package/src/activity/privacy.ts +80 -0
- package/src/activity/timeline/analysis-batch.test.ts +56 -0
- package/src/activity/timeline/analysis-batch.ts +45 -0
- package/src/activity/timeline/analysis.test.ts +413 -0
- package/src/activity/timeline/analysis.ts +362 -0
- package/src/activity/timeline/index.ts +7 -0
- package/src/activity/timeline/journal-recap-persist.test.ts +148 -0
- package/src/activity/timeline/journal-recap-persist.ts +37 -0
- package/src/activity/timeline/journal-recap.test.ts +113 -0
- package/src/activity/timeline/journal-recap.ts +130 -0
- package/src/activity/timeline/query.test.ts +198 -0
- package/src/activity/timeline/query.ts +313 -0
- package/src/activity/timeline/weekly-persist.test.ts +121 -0
- package/src/activity/timeline/weekly-persist.ts +103 -0
- package/src/activity/timeline/weekly.test.ts +215 -0
- package/src/activity/timeline/weekly.ts +234 -0
- package/src/activity/types.ts +14 -0
- package/src/activity/vault-path.test.ts +38 -0
- package/src/activity/vault-path.ts +59 -0
- package/src/activity/vault-publish.test.ts +268 -0
- package/src/activity/vault-publish.ts +180 -0
- package/src/config.test.ts +1 -1
- package/src/config.ts +2 -22
- package/src/dedup/merge-on-write-wire.test.ts +101 -0
- package/src/dedup/merge-on-write-wire.ts +34 -0
- package/src/dedup/merge-on-write.test.ts +91 -0
- package/src/dedup/merge-on-write.ts +75 -0
- package/src/dedup/novelty-gate.test.ts +143 -0
- package/src/dedup/novelty-gate.ts +163 -0
- package/src/extraction-span-wire.test.ts +20 -0
- package/src/extraction-span-wire.ts +17 -0
- package/src/extraction-span.test.ts +59 -0
- package/src/extraction-span.ts +39 -0
- package/src/index.ts +1 -0
- package/src/location/recall-exclusion.test.ts +1 -0
- package/src/orchestration/extraction-persist.ts +22 -23
- package/src/orchestration/generic-recall-paths.ts +11 -0
- package/src/orchestration/recall-entry.ts +8 -3
- package/src/recall-deep-access.test.ts +58 -0
- package/src/recall-deep-access.ts +71 -0
- package/src/recall-deep-render.test.ts +68 -0
- package/src/recall-deep-render.ts +32 -0
- package/src/recall-deep.test.ts +72 -0
- package/src/recall-deep.ts +113 -0
- package/src/recall-navigate.test.ts +84 -0
- package/src/recall-navigate.ts +100 -0
- package/src/recall-state-view-render.test.ts +94 -0
- package/src/recall-state-view-render.ts +24 -0
- package/src/recall-state-view-widen.test.ts +66 -0
- package/src/recall-state-view-widen.ts +49 -0
- package/src/recall-state-view-wire.test.ts +35 -0
- package/src/recall-state-view-wire.ts +18 -0
- package/src/recall-state-view.test.ts +131 -0
- package/src/recall-state-view.ts +138 -0
- package/src/shared-context/governance.test.ts +53 -0
- package/src/shared-context/governance.ts +86 -0
- package/src/shared-context/staleness.test.ts +36 -0
- package/src/shared-context/staleness.ts +38 -0
- package/src/shared-context/trajectories.test.ts +77 -0
- package/src/shared-context/trajectories.ts +49 -0
- package/src/types.ts +3 -10
- package/dist/chunk-56IV4J5W.js.map +0 -1
- package/dist/chunk-IHGMRDEE.js.map +0 -1
- package/dist/chunk-KODXCHXJ.js.map +0 -1
- package/dist/chunk-PEBH5DCK.js.map +0 -1
- /package/dist/{chunk-EZSCW4EM.js.map → chunk-25OLNWYG.js.map} +0 -0
- /package/dist/{chunk-2LBAFHOQ.js.map → chunk-2QSGJTDG.js.map} +0 -0
- /package/dist/{chunk-7UTDHQZ5.js.map → chunk-2VZHB5US.js.map} +0 -0
- /package/dist/{chunk-VQNRICAQ.js.map → chunk-36HJ36FK.js.map} +0 -0
- /package/dist/{chunk-XKNHFDTT.js.map → chunk-3A2Z4OOS.js.map} +0 -0
- /package/dist/{chunk-RDGKVH6T.js.map → chunk-4NKIGSJM.js.map} +0 -0
- /package/dist/{chunk-EFQCDJZ2.js.map → chunk-4PG2CKI6.js.map} +0 -0
- /package/dist/{chunk-HJXA6ZM7.js.map → chunk-6545JDIM.js.map} +0 -0
- /package/dist/{chunk-J3OND5QT.js.map → chunk-65HXVEVG.js.map} +0 -0
- /package/dist/{chunk-HNPE66LB.js.map → chunk-6BYJQ3L2.js.map} +0 -0
- /package/dist/{chunk-ZW4VXELZ.js.map → chunk-6PUF7LUO.js.map} +0 -0
- /package/dist/{chunk-TVVEYCNW.js.map → chunk-7K5Q6COX.js.map} +0 -0
- /package/dist/{chunk-MN5NOOI7.js.map → chunk-AI5M4FVQ.js.map} +0 -0
- /package/dist/{chunk-YMOPYG3K.js.map → chunk-BIJAWZYW.js.map} +0 -0
- /package/dist/{chunk-I5VB44ZK.js.map → chunk-BLHKR4GJ.js.map} +0 -0
- /package/dist/{chunk-CEH2AFXG.js.map → chunk-C24UZSFW.js.map} +0 -0
- /package/dist/{chunk-MJRGVXPQ.js.map → chunk-C3ZYZKDJ.js.map} +0 -0
- /package/dist/{chunk-QCRJMU5V.js.map → chunk-CDLPF3PX.js.map} +0 -0
- /package/dist/{chunk-23CVL7HS.js.map → chunk-CQ6IWZDI.js.map} +0 -0
- /package/dist/{chunk-KWIGDKM2.js.map → chunk-D2YNNDML.js.map} +0 -0
- /package/dist/{chunk-FTTJRVB7.js.map → chunk-D3DUA64S.js.map} +0 -0
- /package/dist/{chunk-7XOG75AU.js.map → chunk-D6Q5EPOV.js.map} +0 -0
- /package/dist/{chunk-GEJKYA7D.js.map → chunk-DSEHPUID.js.map} +0 -0
- /package/dist/{chunk-OAJMQKQR.js.map → chunk-EQRD4NMH.js.map} +0 -0
- /package/dist/{chunk-H7VDIF2V.js.map → chunk-ER2UPUMG.js.map} +0 -0
- /package/dist/{chunk-4FHRZD5T.js.map → chunk-F2JXJABQ.js.map} +0 -0
- /package/dist/{chunk-FKKGCGYL.js.map → chunk-F4W5HTED.js.map} +0 -0
- /package/dist/{chunk-DMEHOEC7.js.map → chunk-FFWONAAW.js.map} +0 -0
- /package/dist/{chunk-TNGH4ZYI.js.map → chunk-GNWLTCKC.js.map} +0 -0
- /package/dist/{chunk-CFVTRUR3.js.map → chunk-H6RSANGQ.js.map} +0 -0
- /package/dist/{chunk-CTCGHNWN.js.map → chunk-J2R275FN.js.map} +0 -0
- /package/dist/{chunk-IVIAHQBR.js.map → chunk-JJ6ZEFXC.js.map} +0 -0
- /package/dist/{chunk-KXIXO76C.js.map → chunk-JMXHVJ2V.js.map} +0 -0
- /package/dist/{chunk-7LCGFUMB.js.map → chunk-KQAFEZQX.js.map} +0 -0
- /package/dist/{chunk-NACLNNFQ.js.map → chunk-KSZKQTZS.js.map} +0 -0
- /package/dist/{chunk-NPIBN2VL.js.map → chunk-LK4TOYPU.js.map} +0 -0
- /package/dist/{chunk-K66OY4EI.js.map → chunk-LSR5LQXN.js.map} +0 -0
- /package/dist/{chunk-6CEGSTBD.js.map → chunk-NTFXBILO.js.map} +0 -0
- /package/dist/{chunk-2PSX5BJU.js.map → chunk-NZPFCP5A.js.map} +0 -0
- /package/dist/{chunk-FYWLSFFS.js.map → chunk-OERZXNSK.js.map} +0 -0
- /package/dist/{chunk-ZJPM7GZ3.js.map → chunk-OIDICRH7.js.map} +0 -0
- /package/dist/{chunk-LTBKKSCX.js.map → chunk-OLBZ2WGG.js.map} +0 -0
- /package/dist/{chunk-PD66CVSD.js.map → chunk-OUKBMQ2O.js.map} +0 -0
- /package/dist/{chunk-GPFZFCRN.js.map → chunk-PP7R754B.js.map} +0 -0
- /package/dist/{chunk-GX6FTSYH.js.map → chunk-PRRUK2ZH.js.map} +0 -0
- /package/dist/{chunk-MAH64N55.js.map → chunk-PW3GKWH3.js.map} +0 -0
- /package/dist/{chunk-33MFRY25.js.map → chunk-R2Q6FTOX.js.map} +0 -0
- /package/dist/{chunk-VCKWULAK.js.map → chunk-RCPKBW7K.js.map} +0 -0
- /package/dist/{chunk-CN4VKV3S.js.map → chunk-RH3XLQG4.js.map} +0 -0
- /package/dist/{chunk-2QSZNTDO.js.map → chunk-RKNJBZ55.js.map} +0 -0
- /package/dist/{chunk-YXFCALVT.js.map → chunk-U4HZEW2B.js.map} +0 -0
- /package/dist/{chunk-RZ3IZIJG.js.map → chunk-UHQE37NI.js.map} +0 -0
- /package/dist/{chunk-Z3YEGSR4.js.map → chunk-UMZUKOJU.js.map} +0 -0
- /package/dist/{chunk-72OIT7KS.js.map → chunk-UVYL5G7A.js.map} +0 -0
- /package/dist/{chunk-4STAANV7.js.map → chunk-VKDBDJIX.js.map} +0 -0
- /package/dist/{chunk-WKJFIMVN.js.map → chunk-VSMSYDIH.js.map} +0 -0
- /package/dist/{chunk-GSKINLAK.js.map → chunk-W5IYHQA5.js.map} +0 -0
- /package/dist/{chunk-FESUGFIL.js.map → chunk-WKWY7YF3.js.map} +0 -0
- /package/dist/{chunk-UNUMFURP.js.map → chunk-X5PIDJ3L.js.map} +0 -0
- /package/dist/{chunk-6RUHELWR.js.map → chunk-Y2YM4C75.js.map} +0 -0
- /package/dist/{chunk-L4X4PJYK.js.map → chunk-YZ5VC2JJ.js.map} +0 -0
- /package/dist/{chunk-VQ4AMTGZ.js.map → chunk-ZBIEX4XN.js.map} +0 -0
- /package/dist/{chunk-O57GM3FR.js.map → chunk-ZMVW2HJJ.js.map} +0 -0
- /package/dist/{chunk-6QDXA26G.js.map → chunk-ZXROBS53.js.map} +0 -0
- /package/dist/{graph-edge-decay-A4SDFMMS.js.map → extraction-span.js.map} +0 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only vault daily-note journal section (issue #1987 first slice).
|
|
3
|
+
*
|
|
4
|
+
* Pure: file text in, journal body out. Never writes. Strips Remnic-owned
|
|
5
|
+
* marker regions and publisher-owned headings so published timeline text
|
|
6
|
+
* cannot re-enter the journal. Path templates stay in vault-publish.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export interface ReadVaultJournalInput {
|
|
10
|
+
fileText: string | null | undefined;
|
|
11
|
+
journalSection: string;
|
|
12
|
+
publishSectionNames?: readonly string[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type ReadVaultJournalResult =
|
|
16
|
+
| { ok: true; exists: false; reason: "missing_file" | "missing_heading" }
|
|
17
|
+
| { ok: true; exists: true; text: string; heading: string; warnings: readonly string[] }
|
|
18
|
+
| { ok: false; reason: "duplicate_heading"; lines: readonly number[] };
|
|
19
|
+
|
|
20
|
+
const REMNIC_OPEN = "<!-- remnic:";
|
|
21
|
+
|
|
22
|
+
export function readVaultJournal(input: ReadVaultJournalInput): ReadVaultJournalResult {
|
|
23
|
+
if (input.fileText === null || input.fileText === undefined) {
|
|
24
|
+
return { ok: true, exists: false, reason: "missing_file" };
|
|
25
|
+
}
|
|
26
|
+
if (input.journalSection.length === 0) {
|
|
27
|
+
return { ok: true, exists: false, reason: "missing_heading" };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const lines = splitFileLines(input.fileText);
|
|
31
|
+
const hits: number[] = [];
|
|
32
|
+
const levels: number[] = [];
|
|
33
|
+
for (let i = 0; i < lines.length; i++) {
|
|
34
|
+
const heading = parseAtxHeading(lines[i]!);
|
|
35
|
+
if (heading && heading.text === input.journalSection) {
|
|
36
|
+
hits.push(i + 1);
|
|
37
|
+
levels.push(heading.level);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (hits.length === 0) return { ok: true, exists: false, reason: "missing_heading" };
|
|
41
|
+
if (hits.length > 1) return { ok: false, reason: "duplicate_heading", lines: hits };
|
|
42
|
+
|
|
43
|
+
const headingIndex = hits[0]! - 1;
|
|
44
|
+
const level = levels[0]!;
|
|
45
|
+
let endIndex = lines.length;
|
|
46
|
+
for (let i = headingIndex + 1; i < lines.length; i++) {
|
|
47
|
+
const heading = parseAtxHeading(lines[i]!);
|
|
48
|
+
if (heading && heading.level <= level) {
|
|
49
|
+
endIndex = i;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const body = lines.slice(headingIndex + 1, endIndex).join("\n");
|
|
55
|
+
const stripped = stripRemnicOwnedRegions(body, input.publishSectionNames ?? []);
|
|
56
|
+
return {
|
|
57
|
+
ok: true,
|
|
58
|
+
exists: true,
|
|
59
|
+
text: trimNewlines(stripped.text),
|
|
60
|
+
heading: input.journalSection,
|
|
61
|
+
warnings: stripped.warnings,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Remove Remnic marker pairs and publisher-owned heading sections. */
|
|
66
|
+
export function stripRemnicOwnedRegions(
|
|
67
|
+
text: string,
|
|
68
|
+
publishSectionNames: readonly string[] = [],
|
|
69
|
+
): { text: string; warnings: readonly string[] } {
|
|
70
|
+
const marked = cutIntervals(text, remnicIntervals(text));
|
|
71
|
+
return {
|
|
72
|
+
text: stripPublishHeadings(marked.text, publishSectionNames),
|
|
73
|
+
warnings: marked.warnings,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function splitFileLines(fileText: string): string[] {
|
|
78
|
+
const lines = fileText.split("\n");
|
|
79
|
+
for (let i = 0; i < lines.length; i++) {
|
|
80
|
+
const line = lines[i]!;
|
|
81
|
+
if (line.endsWith("\r")) lines[i] = line.slice(0, -1);
|
|
82
|
+
}
|
|
83
|
+
return lines;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function parseAtxHeading(line: string): { level: number; text: string } | null {
|
|
87
|
+
let level = 0;
|
|
88
|
+
while (level < line.length && level < 6 && line[level] === "#") level++;
|
|
89
|
+
if (level === 0) return null;
|
|
90
|
+
const after = line[level];
|
|
91
|
+
if (after !== " " && after !== "\t") return null;
|
|
92
|
+
|
|
93
|
+
let start = level + 1;
|
|
94
|
+
let end = line.length;
|
|
95
|
+
while (start < end && (line[start] === " " || line[start] === "\t")) start++;
|
|
96
|
+
while (end > start && (line[end - 1] === " " || line[end - 1] === "\t")) end--;
|
|
97
|
+
|
|
98
|
+
let hashEnd = end;
|
|
99
|
+
while (hashEnd > start && line[hashEnd - 1] === "#") hashEnd--;
|
|
100
|
+
if (hashEnd < end && hashEnd > start && (line[hashEnd - 1] === " " || line[hashEnd - 1] === "\t")) {
|
|
101
|
+
end = hashEnd;
|
|
102
|
+
while (end > start && (line[end - 1] === " " || line[end - 1] === "\t")) end--;
|
|
103
|
+
}
|
|
104
|
+
return { level, text: line.slice(start, end) };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function remnicIntervals(text: string): {
|
|
108
|
+
intervals: Array<{ start: number; end: number }>;
|
|
109
|
+
warnings: string[];
|
|
110
|
+
} {
|
|
111
|
+
const starts: Array<{ name: string; start: number; after: number }> = [];
|
|
112
|
+
const ends: Array<{ name: string; start: number; end: number }> = [];
|
|
113
|
+
|
|
114
|
+
let from = 0;
|
|
115
|
+
while (from < text.length) {
|
|
116
|
+
const open = text.indexOf(REMNIC_OPEN, from);
|
|
117
|
+
if (open === -1) break;
|
|
118
|
+
const afterOpen = open + REMNIC_OPEN.length;
|
|
119
|
+
const commentEnd = text.indexOf("-->", afterOpen);
|
|
120
|
+
if (commentEnd === -1) break;
|
|
121
|
+
const inner = text.slice(afterOpen, commentEnd).trim();
|
|
122
|
+
if (inner.endsWith(":start")) {
|
|
123
|
+
const name = inner.slice(0, -":start".length);
|
|
124
|
+
if (name.length > 0) starts.push({ name, start: open, after: commentEnd + 3 });
|
|
125
|
+
} else if (inner.endsWith(":end")) {
|
|
126
|
+
const name = inner.slice(0, -":end".length);
|
|
127
|
+
if (name.length > 0) ends.push({ name, start: open, end: commentEnd + 3 });
|
|
128
|
+
}
|
|
129
|
+
from = commentEnd + 3;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const usedEnds = new Set<number>();
|
|
133
|
+
const intervals: Array<{ start: number; end: number }> = [];
|
|
134
|
+
const warnings: string[] = [];
|
|
135
|
+
|
|
136
|
+
for (const start of starts) {
|
|
137
|
+
const match = ends.find((end) => end.name === start.name && end.start >= start.after && !usedEnds.has(end.start));
|
|
138
|
+
if (match) {
|
|
139
|
+
usedEnds.add(match.start);
|
|
140
|
+
intervals.push({ start: start.start, end: eatTrailingNewline(text, match.end) });
|
|
141
|
+
} else {
|
|
142
|
+
intervals.push({ start: start.start, end: text.length });
|
|
143
|
+
warnings.push(`unclosed remnic region "${start.name}"`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
for (const end of ends) {
|
|
148
|
+
if (usedEnds.has(end.start)) continue;
|
|
149
|
+
const startBefore = starts.some((start) => start.start < end.start);
|
|
150
|
+
if (!startBefore) intervals.push({ start: 0, end: eatTrailingNewline(text, end.end) });
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return { intervals: mergeIntervals(intervals), warnings };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function eatTrailingNewline(text: string, index: number): number {
|
|
157
|
+
if (text[index] === "\n") return index + 1;
|
|
158
|
+
if (text[index] === "\r" && text[index + 1] === "\n") return index + 2;
|
|
159
|
+
if (text[index] === "\r") return index + 1;
|
|
160
|
+
return index;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function mergeIntervals(items: Array<{ start: number; end: number }>): Array<{ start: number; end: number }> {
|
|
164
|
+
if (items.length === 0) return [];
|
|
165
|
+
const sorted = items.slice().sort((a, b) => a.start - b.start || a.end - b.end);
|
|
166
|
+
const out = [{ start: sorted[0]!.start, end: sorted[0]!.end }];
|
|
167
|
+
for (let i = 1; i < sorted.length; i++) {
|
|
168
|
+
const cur = sorted[i]!;
|
|
169
|
+
const last = out[out.length - 1]!;
|
|
170
|
+
if (cur.start <= last.end) last.end = Math.max(last.end, cur.end);
|
|
171
|
+
else out.push({ start: cur.start, end: cur.end });
|
|
172
|
+
}
|
|
173
|
+
return out;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function cutIntervals(
|
|
177
|
+
text: string,
|
|
178
|
+
found: { intervals: Array<{ start: number; end: number }>; warnings: string[] },
|
|
179
|
+
): { text: string; warnings: string[] } {
|
|
180
|
+
let out = "";
|
|
181
|
+
let pos = 0;
|
|
182
|
+
for (const interval of found.intervals) {
|
|
183
|
+
if (interval.start > pos) out += text.slice(pos, interval.start);
|
|
184
|
+
pos = Math.max(pos, interval.end);
|
|
185
|
+
}
|
|
186
|
+
if (pos < text.length) out += text.slice(pos);
|
|
187
|
+
return { text: out, warnings: found.warnings };
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function stripPublishHeadings(text: string, names: readonly string[]): string {
|
|
191
|
+
if (names.length === 0 || text.length === 0) return text;
|
|
192
|
+
const lines = text.split("\n");
|
|
193
|
+
const keep = lines.map(() => true);
|
|
194
|
+
for (let i = 0; i < lines.length; i++) {
|
|
195
|
+
if (!keep[i]) continue;
|
|
196
|
+
const heading = parseAtxHeading(lines[i]!);
|
|
197
|
+
if (!heading || !names.includes(heading.text)) continue;
|
|
198
|
+
keep[i] = false;
|
|
199
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
200
|
+
const next = parseAtxHeading(lines[j]!);
|
|
201
|
+
if (next && next.level <= heading.level) break;
|
|
202
|
+
keep[j] = false;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return lines.filter((_, i) => keep[i]).join("\n");
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function trimNewlines(text: string): string {
|
|
209
|
+
let start = 0;
|
|
210
|
+
let end = text.length;
|
|
211
|
+
while (start < end && (text[start] === "\n" || text[start] === "\r")) start++;
|
|
212
|
+
while (end > start && (text[end - 1] === "\n" || text[end - 1] === "\r")) end--;
|
|
213
|
+
return text.slice(start, end);
|
|
214
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import test from "node:test";
|
|
6
|
+
|
|
7
|
+
import { isSearchExcludedPath } from "../orchestration/generic-recall-paths.js";
|
|
8
|
+
import { ALL_CATEGORY_DIRS, RECALL_FALLBACK_DIRS } from "../utils/category-dir.js";
|
|
9
|
+
import { parseActivityConfig } from "./config.js";
|
|
10
|
+
import { isJournalDayPath, journalPath, seedJournal } from "./journal.js";
|
|
11
|
+
|
|
12
|
+
const DATE = "2026-08-17";
|
|
13
|
+
|
|
14
|
+
function withMemoryDir(fn: (memoryDir: string) => void): void {
|
|
15
|
+
const memoryDir = mkdtempSync(path.join(tmpdir(), "remnic-journal-"));
|
|
16
|
+
try {
|
|
17
|
+
fn(memoryDir);
|
|
18
|
+
} finally {
|
|
19
|
+
rmSync(memoryDir, { recursive: true, force: true });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
test("activity.timeline.journal.enabled defaults off", () => {
|
|
24
|
+
assert.equal(parseActivityConfig(undefined).timeline.journal.enabled, false);
|
|
25
|
+
assert.equal(
|
|
26
|
+
parseActivityConfig({ timeline: { journal: { enabled: true } } }).timeline.journal.enabled,
|
|
27
|
+
true,
|
|
28
|
+
);
|
|
29
|
+
assert.throws(
|
|
30
|
+
() => parseActivityConfig({ timeline: { journal: "on" } }),
|
|
31
|
+
/activity\.timeline\.journal must be an object/,
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test("seed is a hard no-op without force", () => {
|
|
36
|
+
withMemoryDir((memoryDir) => {
|
|
37
|
+
const first = seedJournal({
|
|
38
|
+
memoryDir,
|
|
39
|
+
date: DATE,
|
|
40
|
+
cards: [{ title: "Write seed", startUtc: "2026-08-17T14:00:00.000Z", endUtc: "2026-08-17T14:45:00.000Z" }],
|
|
41
|
+
});
|
|
42
|
+
assert.equal(first.wrote, true);
|
|
43
|
+
assert.equal(first.path, journalPath(memoryDir, DATE));
|
|
44
|
+
const original = readFileSync(first.path);
|
|
45
|
+
const second = seedJournal({
|
|
46
|
+
memoryDir,
|
|
47
|
+
date: DATE,
|
|
48
|
+
cards: [{ title: "Different card", startUtc: "2026-08-17T15:00:00.000Z", endUtc: "2026-08-17T16:00:00.000Z" }],
|
|
49
|
+
});
|
|
50
|
+
assert.equal(second.wrote, false);
|
|
51
|
+
assert.deepEqual(readFileSync(second.path), original);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("seed with force overwrites the existing file", () => {
|
|
56
|
+
withMemoryDir((memoryDir) => {
|
|
57
|
+
seedJournal({ memoryDir, date: DATE });
|
|
58
|
+
const original = readFileSync(journalPath(memoryDir, DATE), "utf8");
|
|
59
|
+
const forced = seedJournal({
|
|
60
|
+
memoryDir,
|
|
61
|
+
date: DATE,
|
|
62
|
+
force: true,
|
|
63
|
+
cards: [{ title: "Forced rewrite", startUtc: "2026-08-17T10:00:00.000Z", endUtc: "2026-08-17T11:30:00.000Z" }],
|
|
64
|
+
});
|
|
65
|
+
assert.equal(forced.wrote, true);
|
|
66
|
+
const next = readFileSync(forced.path, "utf8");
|
|
67
|
+
assert.notEqual(next, original);
|
|
68
|
+
assert.match(next, /# Journal — 2026-08-17/);
|
|
69
|
+
assert.match(next, /## Day at a glance/);
|
|
70
|
+
assert.match(next, /- 90m Forced rewrite/);
|
|
71
|
+
assert.match(next, /## Notes/);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("journal day files sit outside scan roots and generic search", () => {
|
|
76
|
+
assert.equal(ALL_CATEGORY_DIRS.includes("journal"), false);
|
|
77
|
+
assert.equal(RECALL_FALLBACK_DIRS.includes("journal"), false);
|
|
78
|
+
assert.equal(isJournalDayPath("journal/2026-08-17.md"), true);
|
|
79
|
+
assert.equal(
|
|
80
|
+
isJournalDayPath("facts/journal/2026-08-17.md", "/tmp/remnic-fixture-memory"),
|
|
81
|
+
false,
|
|
82
|
+
"nested stays recallable",
|
|
83
|
+
);
|
|
84
|
+
assert.equal(isSearchExcludedPath("journal/2026-08-17.md"), true);
|
|
85
|
+
assert.equal(
|
|
86
|
+
isSearchExcludedPath("facts/journal/2026-08-17.md", { memoryDir: "/tmp/remnic-fixture-memory" }),
|
|
87
|
+
false,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
withMemoryDir((memoryDir) => {
|
|
91
|
+
const result = seedJournal({ memoryDir, date: DATE });
|
|
92
|
+
const relative = path.relative(memoryDir, result.path).replace(/\\/g, "/");
|
|
93
|
+
assert.equal(relative, "journal/2026-08-17.md");
|
|
94
|
+
assert.equal(isSearchExcludedPath(relative), true);
|
|
95
|
+
assert.equal(isSearchExcludedPath(result.path, { memoryDir }), true);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User-owned daily journal (issue #1984 PR1).
|
|
3
|
+
*
|
|
4
|
+
* Files live at `<memoryDir>/journal/<YYYY-MM-DD>.md` — inside the memory
|
|
5
|
+
* directory but outside scan roots, same placement as activity digests.
|
|
6
|
+
* Once written, Remnic never rewrites the file except `seed` with force.
|
|
7
|
+
* All writes go through writeJournalFile, which stats first.
|
|
8
|
+
*/
|
|
9
|
+
import { mkdirSync, statSync, writeFileSync } from "node:fs";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
|
|
12
|
+
import { isValidActivityDate } from "./digest.js";
|
|
13
|
+
|
|
14
|
+
export const JOURNAL_DIR_NAME = "journal";
|
|
15
|
+
|
|
16
|
+
/** Minimal card shape the seed renderer needs. TimelineCard is assignable. */
|
|
17
|
+
export interface JournalSeedCard {
|
|
18
|
+
title: string;
|
|
19
|
+
startUtc: string;
|
|
20
|
+
endUtc: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface SeedJournalInput {
|
|
24
|
+
memoryDir: string;
|
|
25
|
+
date: string;
|
|
26
|
+
cards?: readonly JournalSeedCard[];
|
|
27
|
+
force?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface SeedJournalResult {
|
|
31
|
+
path: string;
|
|
32
|
+
wrote: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const JOURNAL_DAY_TOPLEVEL = /^journal[\\/]\d{4}-\d{2}-\d{2}\.md$/i;
|
|
36
|
+
const JOURNAL_DAY_ANYWHERE = /(?:^|[\\/])journal[\\/]\d{4}-\d{2}-\d{2}\.md$/i;
|
|
37
|
+
|
|
38
|
+
export function journalPath(memoryDir: string, date: string): string {
|
|
39
|
+
if (!isValidActivityDate(date)) {
|
|
40
|
+
throw new RangeError(`Invalid journal date "${date}"; expected YYYY-MM-DD.`);
|
|
41
|
+
}
|
|
42
|
+
return path.join(memoryDir, JOURNAL_DIR_NAME, `${date}.md`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Root-aware journal day-file check. With a memory root, only the top-level
|
|
47
|
+
* `journal/<date>.md` matches so a nested `facts/journal/<date>.md` stays
|
|
48
|
+
* recallable. Without a root, fall back to the day-file shape anywhere.
|
|
49
|
+
*/
|
|
50
|
+
export function isJournalDayPath(filePath: string, memoryRoot?: string): boolean {
|
|
51
|
+
if (memoryRoot !== undefined && memoryRoot.length > 0) {
|
|
52
|
+
const relative = path.relative(memoryRoot, path.resolve(memoryRoot, filePath));
|
|
53
|
+
return JOURNAL_DAY_TOPLEVEL.test(relative);
|
|
54
|
+
}
|
|
55
|
+
return JOURNAL_DAY_ANYWHERE.test(filePath);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function todayJournalDate(now: Date = new Date()): string {
|
|
59
|
+
const year = now.getFullYear();
|
|
60
|
+
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
61
|
+
const day = String(now.getDate()).padStart(2, "0");
|
|
62
|
+
return `${year}-${month}-${day}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function formatCardDuration(card: JournalSeedCard): string {
|
|
66
|
+
const start = Date.parse(card.startUtc);
|
|
67
|
+
const end = Date.parse(card.endUtc);
|
|
68
|
+
const minutes =
|
|
69
|
+
Number.isFinite(start) && Number.isFinite(end) && end > start
|
|
70
|
+
? Math.round((end - start) / 60_000)
|
|
71
|
+
: 0;
|
|
72
|
+
return `${minutes}m`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function renderJournalSeed(date: string, cards: readonly JournalSeedCard[]): string {
|
|
76
|
+
const ordered = [...cards].sort((left, right) => {
|
|
77
|
+
const byStart = left.startUtc.localeCompare(right.startUtc);
|
|
78
|
+
return byStart !== 0 ? byStart : left.title.localeCompare(right.title);
|
|
79
|
+
});
|
|
80
|
+
const glance =
|
|
81
|
+
ordered.length === 0
|
|
82
|
+
? ["_No cards._"]
|
|
83
|
+
: ordered.map((card) => `- ${formatCardDuration(card)} ${card.title}`);
|
|
84
|
+
return [`# Journal — ${date}`, "", "## Day at a glance", "", ...glance, "", "## Notes", "", ""].join(
|
|
85
|
+
"\n",
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The only journal write. Stats first; existing files are a no-op unless force. */
|
|
90
|
+
export function writeJournalFile(filePath: string, content: string, force: boolean): boolean {
|
|
91
|
+
let exists = false;
|
|
92
|
+
try {
|
|
93
|
+
statSync(filePath);
|
|
94
|
+
exists = true;
|
|
95
|
+
} catch (err) {
|
|
96
|
+
const code = (err as NodeJS.ErrnoException).code;
|
|
97
|
+
if (code !== "ENOENT") throw err;
|
|
98
|
+
}
|
|
99
|
+
if (exists && !force) return false;
|
|
100
|
+
mkdirSync(path.dirname(filePath), { recursive: true });
|
|
101
|
+
writeFileSync(filePath, content);
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function seedJournal(input: SeedJournalInput): SeedJournalResult {
|
|
106
|
+
const filePath = journalPath(input.memoryDir, input.date);
|
|
107
|
+
const wrote = writeJournalFile(
|
|
108
|
+
filePath,
|
|
109
|
+
renderJournalSeed(input.date, input.cards ?? []),
|
|
110
|
+
input.force === true,
|
|
111
|
+
);
|
|
112
|
+
return { path: filePath, wrote };
|
|
113
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
MS_PER_DAY,
|
|
6
|
+
observationsForExport,
|
|
7
|
+
parseActivityPrivacy,
|
|
8
|
+
shouldRetain,
|
|
9
|
+
} from "./privacy.js";
|
|
10
|
+
|
|
11
|
+
test("retentionDays 0 keeps forever", () => {
|
|
12
|
+
const policy = parseActivityPrivacy({ enabled: true, retentionDays: 0 });
|
|
13
|
+
assert.equal(policy.retentionDays, 0);
|
|
14
|
+
const now = 1_700_000_000_000;
|
|
15
|
+
assert.equal(shouldRetain(now - 400 * MS_PER_DAY, now, policy.retentionDays), true);
|
|
16
|
+
assert.equal(shouldRetain(now, now, 0), true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("negative retentionDays throws", () => {
|
|
20
|
+
assert.throws(() => parseActivityPrivacy({ retentionDays: -1 }), /non-negative integer/);
|
|
21
|
+
assert.throws(() => parseActivityPrivacy({ retentionDays: -30 }), /non-negative integer/);
|
|
22
|
+
assert.throws(() => shouldRetain(0, 0, -1), /non-negative integer/);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("exact expiry boundary is half-open", () => {
|
|
26
|
+
const now = 1_700_000_000_000;
|
|
27
|
+
const days = 30;
|
|
28
|
+
const captured = now - days * MS_PER_DAY;
|
|
29
|
+
assert.equal(shouldRetain(captured, now, days), false);
|
|
30
|
+
assert.equal(shouldRetain(captured + 1, now, days), true);
|
|
31
|
+
assert.equal(shouldRetain(captured - 1, now, days), false);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("disabled master denies retain and empties export", () => {
|
|
35
|
+
const policy = parseActivityPrivacy({
|
|
36
|
+
enabled: false,
|
|
37
|
+
retentionDays: 0,
|
|
38
|
+
exportIncludeObservations: true,
|
|
39
|
+
});
|
|
40
|
+
assert.equal(policy.enabled, false);
|
|
41
|
+
assert.equal(shouldRetain(1_700_000_000_000, 1_700_000_000_000, policy.retentionDays, policy.enabled), false);
|
|
42
|
+
assert.deepEqual(observationsForExport(["obs"], policy), []);
|
|
43
|
+
assert.equal(parseActivityPrivacy(undefined).enabled, false);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("exportIncludeObservations defaults false", () => {
|
|
47
|
+
assert.equal(parseActivityPrivacy(undefined).exportIncludeObservations, false);
|
|
48
|
+
assert.equal(parseActivityPrivacy({ enabled: true }).exportIncludeObservations, false);
|
|
49
|
+
const policy = parseActivityPrivacy({ enabled: true });
|
|
50
|
+
assert.deepEqual(observationsForExport(["obs"], policy), []);
|
|
51
|
+
const included = parseActivityPrivacy({ enabled: true, exportIncludeObservations: true });
|
|
52
|
+
assert.deepEqual(observationsForExport(["obs"], included), ["obs"]);
|
|
53
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activity retention and export policy (issue #2053 first slice).
|
|
3
|
+
*
|
|
4
|
+
* Pure helpers. Surfaces and parseConfig wiring wait for a later PR.
|
|
5
|
+
* Master `activity.enabled` false denies retain and empties export.
|
|
6
|
+
*/
|
|
7
|
+
import { coerceBooleanLike, coerceNumber } from "../connectors/coerce.js";
|
|
8
|
+
|
|
9
|
+
export const MS_PER_DAY = 86_400_000;
|
|
10
|
+
|
|
11
|
+
export interface ActivityPrivacyPolicy {
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
/** `0` keeps forever. */
|
|
14
|
+
retentionDays: number;
|
|
15
|
+
exportIncludeObservations: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function asRecord(value: unknown, name: string): Record<string, unknown> {
|
|
19
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
20
|
+
throw new TypeError(`${name} must be an object`);
|
|
21
|
+
}
|
|
22
|
+
return value as Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function parseGate(value: unknown, key: string, fallback: boolean): boolean {
|
|
26
|
+
if (value === undefined) return fallback;
|
|
27
|
+
const parsed = coerceBooleanLike(value, key);
|
|
28
|
+
if (parsed === undefined) throw new TypeError(`${key} must be a boolean`);
|
|
29
|
+
return parsed;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Parse retention and export knobs. Independent of timeline/journal/weekly blocks. */
|
|
33
|
+
export function parseActivityPrivacy(raw?: unknown): ActivityPrivacyPolicy {
|
|
34
|
+
if (raw === undefined || raw === null) {
|
|
35
|
+
return { enabled: false, retentionDays: 0, exportIncludeObservations: false };
|
|
36
|
+
}
|
|
37
|
+
const config = asRecord(raw, "activity");
|
|
38
|
+
const enabled = parseGate(config.enabled, "activity.enabled", false);
|
|
39
|
+
let retentionDays = 0;
|
|
40
|
+
if (config.retentionDays !== undefined) {
|
|
41
|
+
const parsed = coerceNumber(config.retentionDays, "activity.retentionDays");
|
|
42
|
+
if (parsed === undefined || !Number.isInteger(parsed) || parsed < 0) {
|
|
43
|
+
throw new RangeError("activity.retentionDays must be a non-negative integer");
|
|
44
|
+
}
|
|
45
|
+
retentionDays = parsed;
|
|
46
|
+
}
|
|
47
|
+
const exportIncludeObservations = parseGate(
|
|
48
|
+
config.exportIncludeObservations,
|
|
49
|
+
"activity.exportIncludeObservations",
|
|
50
|
+
false,
|
|
51
|
+
);
|
|
52
|
+
return { enabled, retentionDays, exportIncludeObservations };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Half-open retain window: keep when age is in `[0, retentionDays)`.
|
|
57
|
+
* `retentionDays === 0` keeps forever. Master off denies.
|
|
58
|
+
*/
|
|
59
|
+
export function shouldRetain(
|
|
60
|
+
capturedAtMs: number,
|
|
61
|
+
nowMs: number,
|
|
62
|
+
retentionDays: number,
|
|
63
|
+
enabled = true,
|
|
64
|
+
): boolean {
|
|
65
|
+
if (!enabled) return false;
|
|
66
|
+
if (retentionDays < 0 || !Number.isInteger(retentionDays)) {
|
|
67
|
+
throw new RangeError("activity.retentionDays must be a non-negative integer");
|
|
68
|
+
}
|
|
69
|
+
if (retentionDays === 0) return true;
|
|
70
|
+
return nowMs - capturedAtMs < retentionDays * MS_PER_DAY;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Export payload. Master off or the export gate off returns empty. */
|
|
74
|
+
export function observationsForExport<T>(
|
|
75
|
+
observations: readonly T[],
|
|
76
|
+
policy: Pick<ActivityPrivacyPolicy, "enabled" | "exportIncludeObservations">,
|
|
77
|
+
): readonly T[] {
|
|
78
|
+
if (!policy.enabled || !policy.exportIncludeObservations) return [];
|
|
79
|
+
return observations;
|
|
80
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
|
|
4
|
+
import { batchObservations } from "./analysis-batch.js";
|
|
5
|
+
import type { TimelineBatchObservation } from "./analysis-batch.js";
|
|
6
|
+
|
|
7
|
+
function obs(id: number, capturedAtUtc: string): TimelineBatchObservation {
|
|
8
|
+
return { id, capturedAtUtc };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
test("empty observations return no batches", () => {
|
|
12
|
+
assert.deepEqual(batchObservations([], { maxBatch: 3, overlap: 1 }), []);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("maxBatch 0 returns no batches", () => {
|
|
16
|
+
assert.deepEqual(
|
|
17
|
+
batchObservations([obs(1, "2026-08-17T10:00:00.000Z")], { maxBatch: 0, overlap: 0 }),
|
|
18
|
+
[],
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("overlap shares the trailing window with the next batch", () => {
|
|
23
|
+
const items = [1, 2, 3, 4, 5].map((id) => obs(id, `2026-08-17T10:0${id}:00.000Z`));
|
|
24
|
+
const batches = batchObservations(items, { maxBatch: 3, overlap: 1 });
|
|
25
|
+
assert.deepEqual(
|
|
26
|
+
batches.map((batch) => batch.map((item) => item.id)),
|
|
27
|
+
[
|
|
28
|
+
[1, 2, 3],
|
|
29
|
+
[3, 4, 5],
|
|
30
|
+
],
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("order is capturedAtUtc then id, not input order", () => {
|
|
35
|
+
const items = [
|
|
36
|
+
obs(3, "2026-08-17T12:00:00.000Z"),
|
|
37
|
+
obs(2, "2026-08-17T10:00:00.000Z"),
|
|
38
|
+
obs(1, "2026-08-17T10:00:00.000Z"),
|
|
39
|
+
];
|
|
40
|
+
const batches = batchObservations(items, { maxBatch: 3, overlap: 0 });
|
|
41
|
+
assert.deepEqual(
|
|
42
|
+
batches.map((batch) => batch.map((item) => item.id)),
|
|
43
|
+
[[1, 2, 3]],
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("maxBatch below 1 is rejected except 0", () => {
|
|
48
|
+
assert.throws(() => batchObservations([], { maxBatch: -1, overlap: 0 }), RangeError);
|
|
49
|
+
assert.throws(() => batchObservations([], { maxBatch: 0.5, overlap: 0 }), RangeError);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("negative overlap and overlap covering the batch are rejected", () => {
|
|
53
|
+
assert.throws(() => batchObservations([], { maxBatch: 3, overlap: -1 }), RangeError);
|
|
54
|
+
assert.throws(() => batchObservations([], { maxBatch: 3, overlap: 3 }), RangeError);
|
|
55
|
+
assert.throws(() => batchObservations([], { maxBatch: 3, overlap: 4 }), RangeError);
|
|
56
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded overlapping observation batches for timeline analysis (issue #2050).
|
|
3
|
+
*/
|
|
4
|
+
import type { TimelineObservation } from "./types.js";
|
|
5
|
+
|
|
6
|
+
export type TimelineBatchObservation = Pick<TimelineObservation, "id" | "capturedAtUtc">;
|
|
7
|
+
|
|
8
|
+
export interface BatchObservationsOptions {
|
|
9
|
+
maxBatch: number;
|
|
10
|
+
overlap: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function compareObservations(a: TimelineBatchObservation, b: TimelineBatchObservation): number {
|
|
14
|
+
const time = Date.parse(a.capturedAtUtc) - Date.parse(b.capturedAtUtc);
|
|
15
|
+
if (time !== 0) return time;
|
|
16
|
+
return a.id - b.id;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Split observations into overlapping windows. Order is capturedAtUtc, then id. */
|
|
20
|
+
export function batchObservations<T extends TimelineBatchObservation>(
|
|
21
|
+
observations: readonly T[],
|
|
22
|
+
options: BatchObservationsOptions,
|
|
23
|
+
): T[][] {
|
|
24
|
+
const { maxBatch, overlap } = options;
|
|
25
|
+
if (!Number.isInteger(overlap) || overlap < 0) {
|
|
26
|
+
throw new RangeError("overlap must be a non-negative integer");
|
|
27
|
+
}
|
|
28
|
+
if (maxBatch === 0) return [];
|
|
29
|
+
if (!Number.isInteger(maxBatch) || maxBatch < 1) {
|
|
30
|
+
throw new RangeError("maxBatch must be 0 or a positive integer");
|
|
31
|
+
}
|
|
32
|
+
if (overlap >= maxBatch) {
|
|
33
|
+
throw new RangeError("overlap must be less than maxBatch");
|
|
34
|
+
}
|
|
35
|
+
if (observations.length === 0) return [];
|
|
36
|
+
|
|
37
|
+
const ordered = [...observations].sort(compareObservations);
|
|
38
|
+
const step = maxBatch - overlap;
|
|
39
|
+
const batches: T[][] = [];
|
|
40
|
+
for (let start = 0; start < ordered.length; start += step) {
|
|
41
|
+
batches.push(ordered.slice(start, start + maxBatch));
|
|
42
|
+
if (start + maxBatch >= ordered.length) break;
|
|
43
|
+
}
|
|
44
|
+
return batches;
|
|
45
|
+
}
|