causantic 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -66
- package/config.schema.json +12 -87
- package/dist/cli/commands/archive.d.ts.map +1 -1
- package/dist/cli/commands/archive.js.map +1 -1
- package/dist/cli/commands/benchmark-collection.d.ts.map +1 -1
- package/dist/cli/commands/benchmark-collection.js.map +1 -1
- package/dist/cli/commands/encryption.d.ts.map +1 -1
- package/dist/cli/commands/encryption.js.map +1 -1
- package/dist/cli/commands/hook.d.ts.map +1 -1
- package/dist/cli/commands/hook.js +8 -2
- package/dist/cli/commands/hook.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +39 -32
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/maintenance.d.ts.map +1 -1
- package/dist/cli/commands/maintenance.js +10 -3
- package/dist/cli/commands/maintenance.js.map +1 -1
- package/dist/cli/commands/serve.d.ts.map +1 -1
- package/dist/cli/commands/serve.js +3 -3
- package/dist/cli/commands/serve.js.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/skill-templates.d.ts.map +1 -1
- package/dist/cli/skill-templates.js +223 -153
- package/dist/cli/skill-templates.js.map +1 -1
- package/dist/cli/uninstall.d.ts.map +1 -1
- package/dist/cli/uninstall.js +4 -1
- package/dist/cli/uninstall.js.map +1 -1
- package/dist/clusters/cluster-manager.d.ts +23 -0
- package/dist/clusters/cluster-manager.d.ts.map +1 -1
- package/dist/clusters/cluster-manager.js +69 -2
- package/dist/clusters/cluster-manager.js.map +1 -1
- package/dist/clusters/cluster-refresh.d.ts.map +1 -1
- package/dist/clusters/cluster-refresh.js +5 -1
- package/dist/clusters/cluster-refresh.js.map +1 -1
- package/dist/clusters/hdbscan/cluster-extraction.d.ts.map +1 -1
- package/dist/clusters/hdbscan/cluster-extraction.js +1 -2
- package/dist/clusters/hdbscan/cluster-extraction.js.map +1 -1
- package/dist/clusters/hdbscan/hierarchy.d.ts.map +1 -1
- package/dist/clusters/hdbscan/hierarchy.js +1 -3
- package/dist/clusters/hdbscan/hierarchy.js.map +1 -1
- package/dist/clusters/hdbscan/incremental.d.ts.map +1 -1
- package/dist/clusters/hdbscan/incremental.js.map +1 -1
- package/dist/clusters/hdbscan/probabilities.d.ts +1 -1
- package/dist/clusters/hdbscan/probabilities.d.ts.map +1 -1
- package/dist/clusters/hdbscan/probabilities.js +1 -1
- package/dist/clusters/hdbscan/probabilities.js.map +1 -1
- package/dist/clusters/hdbscan.d.ts.map +1 -1
- package/dist/clusters/hdbscan.js +3 -5
- package/dist/clusters/hdbscan.js.map +1 -1
- package/dist/config/loader.d.ts +10 -15
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +40 -71
- package/dist/config/loader.js.map +1 -1
- package/dist/config/memory-config.d.ts +2 -45
- package/dist/config/memory-config.d.ts.map +1 -1
- package/dist/config/memory-config.js +6 -109
- package/dist/config/memory-config.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/lexical-features.d.ts.map +1 -1
- package/dist/core/lexical-features.js +141 -20
- package/dist/core/lexical-features.js.map +1 -1
- package/dist/dashboard/client/assets/index-DdImwNQ0.css +1 -0
- package/dist/dashboard/client/assets/index-Ofx8zngH.js +166 -0
- package/dist/dashboard/client/index.html +2 -2
- package/dist/dashboard/routes/benchmark-collection.d.ts.map +1 -1
- package/dist/dashboard/routes/benchmark-collection.js +2 -6
- package/dist/dashboard/routes/benchmark-collection.js.map +1 -1
- package/dist/dashboard/routes/chain.d.ts +3 -0
- package/dist/dashboard/routes/chain.d.ts.map +1 -0
- package/dist/dashboard/routes/chain.js +74 -0
- package/dist/dashboard/routes/chain.js.map +1 -0
- package/dist/dashboard/routes/chunks.d.ts.map +1 -1
- package/dist/dashboard/routes/chunks.js +16 -1
- package/dist/dashboard/routes/chunks.js.map +1 -1
- package/dist/dashboard/routes/graph.d.ts.map +1 -1
- package/dist/dashboard/routes/graph.js.map +1 -1
- package/dist/dashboard/routes/search.d.ts.map +1 -1
- package/dist/dashboard/routes/search.js.map +1 -1
- package/dist/dashboard/routes/stats.d.ts.map +1 -1
- package/dist/dashboard/routes/stats.js +8 -6
- package/dist/dashboard/routes/stats.js.map +1 -1
- package/dist/dashboard/routes/timeline.d.ts +3 -0
- package/dist/dashboard/routes/timeline.d.ts.map +1 -0
- package/dist/dashboard/routes/timeline.js +90 -0
- package/dist/dashboard/routes/timeline.js.map +1 -0
- package/dist/dashboard/server.d.ts.map +1 -1
- package/dist/dashboard/server.js +4 -0
- package/dist/dashboard/server.js.map +1 -1
- package/dist/eval/annotation-schema.d.ts.map +1 -1
- package/dist/eval/annotation-schema.js +2 -5
- package/dist/eval/annotation-schema.js.map +1 -1
- package/dist/eval/benchmark-runner.d.ts.map +1 -1
- package/dist/eval/benchmark-runner.js +2 -2
- package/dist/eval/benchmark-runner.js.map +1 -1
- package/dist/eval/cluster-evaluator.d.ts.map +1 -1
- package/dist/eval/cluster-evaluator.js.map +1 -1
- package/dist/eval/collection-benchmark/chain-quality.d.ts +15 -0
- package/dist/eval/collection-benchmark/chain-quality.d.ts.map +1 -0
- package/dist/eval/collection-benchmark/chain-quality.js +60 -0
- package/dist/eval/collection-benchmark/chain-quality.js.map +1 -0
- package/dist/eval/collection-benchmark/health.d.ts.map +1 -1
- package/dist/eval/collection-benchmark/health.js +2 -2
- package/dist/eval/collection-benchmark/health.js.map +1 -1
- package/dist/eval/collection-benchmark/history.d.ts.map +1 -1
- package/dist/eval/collection-benchmark/history.js +14 -11
- package/dist/eval/collection-benchmark/history.js.map +1 -1
- package/dist/eval/collection-benchmark/latency.d.ts.map +1 -1
- package/dist/eval/collection-benchmark/latency.js +14 -11
- package/dist/eval/collection-benchmark/latency.js.map +1 -1
- package/dist/eval/collection-benchmark/reporter.d.ts.map +1 -1
- package/dist/eval/collection-benchmark/reporter.js +18 -28
- package/dist/eval/collection-benchmark/reporter.js.map +1 -1
- package/dist/eval/collection-benchmark/retrieval.d.ts.map +1 -1
- package/dist/eval/collection-benchmark/retrieval.js +14 -8
- package/dist/eval/collection-benchmark/retrieval.js.map +1 -1
- package/dist/eval/collection-benchmark/runner.d.ts +3 -3
- package/dist/eval/collection-benchmark/runner.d.ts.map +1 -1
- package/dist/eval/collection-benchmark/runner.js +46 -37
- package/dist/eval/collection-benchmark/runner.js.map +1 -1
- package/dist/eval/collection-benchmark/sampler.d.ts.map +1 -1
- package/dist/eval/collection-benchmark/sampler.js +14 -12
- package/dist/eval/collection-benchmark/sampler.js.map +1 -1
- package/dist/eval/collection-benchmark/tuning.d.ts.map +1 -1
- package/dist/eval/collection-benchmark/tuning.js +56 -71
- package/dist/eval/collection-benchmark/tuning.js.map +1 -1
- package/dist/eval/collection-benchmark/types.d.ts +12 -24
- package/dist/eval/collection-benchmark/types.d.ts.map +1 -1
- package/dist/eval/corpus-builder.d.ts.map +1 -1
- package/dist/eval/corpus-builder.js.map +1 -1
- package/dist/eval/experiments/boilerplate-filter.d.ts.map +1 -1
- package/dist/eval/experiments/boilerplate-filter.js.map +1 -1
- package/dist/eval/experiments/cluster-threshold/run-threshold-sweep.d.ts.map +1 -1
- package/dist/eval/experiments/cluster-threshold/run-threshold-sweep.js +3 -5
- package/dist/eval/experiments/cluster-threshold/run-threshold-sweep.js.map +1 -1
- package/dist/eval/experiments/code-focused-mode.d.ts.map +1 -1
- package/dist/eval/experiments/code-focused-mode.js +1 -1
- package/dist/eval/experiments/code-focused-mode.js.map +1 -1
- package/dist/eval/experiments/edge-decay/decay-curves.d.ts +25 -19
- package/dist/eval/experiments/edge-decay/decay-curves.d.ts.map +1 -1
- package/dist/eval/experiments/edge-decay/decay-curves.js +47 -40
- package/dist/eval/experiments/edge-decay/decay-curves.js.map +1 -1
- package/dist/eval/experiments/edge-decay/index.d.ts +6 -4
- package/dist/eval/experiments/edge-decay/index.d.ts.map +1 -1
- package/dist/eval/experiments/edge-decay/index.js +5 -3
- package/dist/eval/experiments/edge-decay/index.js.map +1 -1
- package/dist/eval/experiments/edge-decay/presets.d.ts +14 -4
- package/dist/eval/experiments/edge-decay/presets.d.ts.map +1 -1
- package/dist/eval/experiments/edge-decay/presets.js +73 -68
- package/dist/eval/experiments/edge-decay/presets.js.map +1 -1
- package/dist/eval/experiments/edge-decay/reference-extractor.d.ts +2 -1
- package/dist/eval/experiments/edge-decay/reference-extractor.d.ts.map +1 -1
- package/dist/eval/experiments/edge-decay/reference-extractor.js +26 -40
- package/dist/eval/experiments/edge-decay/reference-extractor.js.map +1 -1
- package/dist/eval/experiments/edge-decay/reference-types.d.ts +24 -17
- package/dist/eval/experiments/edge-decay/reference-types.d.ts.map +1 -1
- package/dist/eval/experiments/edge-decay/reference-types.js +3 -0
- package/dist/eval/experiments/edge-decay/reference-types.js.map +1 -1
- package/dist/eval/experiments/edge-decay/retrieval-ranking.d.ts +8 -8
- package/dist/eval/experiments/edge-decay/retrieval-ranking.d.ts.map +1 -1
- package/dist/eval/experiments/edge-decay/retrieval-ranking.js +77 -133
- package/dist/eval/experiments/edge-decay/retrieval-ranking.js.map +1 -1
- package/dist/eval/experiments/edge-decay/run-experiments.d.ts +7 -3
- package/dist/eval/experiments/edge-decay/run-experiments.d.ts.map +1 -1
- package/dist/eval/experiments/edge-decay/run-experiments.js +71 -52
- package/dist/eval/experiments/edge-decay/run-experiments.js.map +1 -1
- package/dist/eval/experiments/edge-decay/simulate.d.ts +1 -1
- package/dist/eval/experiments/edge-decay/simulate.d.ts.map +1 -1
- package/dist/eval/experiments/edge-decay/simulate.js +7 -19
- package/dist/eval/experiments/edge-decay/simulate.js.map +1 -1
- package/dist/eval/experiments/hdbscan-sweep.d.ts.map +1 -1
- package/dist/eval/experiments/hdbscan-sweep.js +2 -6
- package/dist/eval/experiments/hdbscan-sweep.js.map +1 -1
- package/dist/eval/experiments/single-model-run.d.ts.map +1 -1
- package/dist/eval/experiments/single-model-run.js +2 -2
- package/dist/eval/experiments/single-model-run.js.map +1 -1
- package/dist/eval/experiments/thinking-ablation.d.ts.map +1 -1
- package/dist/eval/experiments/thinking-ablation.js +1 -1
- package/dist/eval/experiments/thinking-ablation.js.map +1 -1
- package/dist/eval/experiments/topic-continuity/hybrid-classifier.d.ts.map +1 -1
- package/dist/eval/experiments/topic-continuity/hybrid-classifier.js +54 -6
- package/dist/eval/experiments/topic-continuity/hybrid-classifier.js.map +1 -1
- package/dist/eval/experiments/topic-continuity/labeler.d.ts.map +1 -1
- package/dist/eval/experiments/topic-continuity/labeler.js +1 -4
- package/dist/eval/experiments/topic-continuity/labeler.js.map +1 -1
- package/dist/eval/experiments/topic-continuity/run-experiment.d.ts.map +1 -1
- package/dist/eval/experiments/topic-continuity/run-experiment.js +5 -13
- package/dist/eval/experiments/topic-continuity/run-experiment.js.map +1 -1
- package/dist/eval/experiments/truncation.d.ts.map +1 -1
- package/dist/eval/experiments/truncation.js.map +1 -1
- package/dist/eval/experiments/types.d.ts.map +1 -1
- package/dist/eval/experiments/types.js.map +1 -1
- package/dist/eval/metrics.d.ts.map +1 -1
- package/dist/eval/metrics.js.map +1 -1
- package/dist/hooks/claudemd-generator.d.ts.map +1 -1
- package/dist/hooks/claudemd-generator.js +3 -4
- package/dist/hooks/claudemd-generator.js.map +1 -1
- package/dist/hooks/hook-utils.d.ts +16 -0
- package/dist/hooks/hook-utils.d.ts.map +1 -1
- package/dist/hooks/hook-utils.js +51 -2
- package/dist/hooks/hook-utils.js.map +1 -1
- package/dist/hooks/index.d.ts +4 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +3 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/pre-compact.d.ts.map +1 -1
- package/dist/hooks/pre-compact.js +6 -51
- package/dist/hooks/pre-compact.js.map +1 -1
- package/dist/hooks/session-end.d.ts +58 -0
- package/dist/hooks/session-end.d.ts.map +1 -0
- package/dist/hooks/session-end.js +82 -0
- package/dist/hooks/session-end.js.map +1 -0
- package/dist/hooks/session-start.d.ts.map +1 -1
- package/dist/hooks/session-start.js +3 -5
- package/dist/hooks/session-start.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/ingest/batch-ingest.d.ts.map +1 -1
- package/dist/ingest/batch-ingest.js.map +1 -1
- package/dist/ingest/brief-debrief-detector.d.ts +6 -13
- package/dist/ingest/brief-debrief-detector.d.ts.map +1 -1
- package/dist/ingest/brief-debrief-detector.js +9 -16
- package/dist/ingest/brief-debrief-detector.js.map +1 -1
- package/dist/ingest/cross-session-linker.d.ts +2 -1
- package/dist/ingest/cross-session-linker.d.ts.map +1 -1
- package/dist/ingest/cross-session-linker.js +17 -7
- package/dist/ingest/cross-session-linker.js.map +1 -1
- package/dist/ingest/edge-creator.d.ts +14 -40
- package/dist/ingest/edge-creator.d.ts.map +1 -1
- package/dist/ingest/edge-creator.js +34 -132
- package/dist/ingest/edge-creator.js.map +1 -1
- package/dist/ingest/edge-detector.d.ts +27 -12
- package/dist/ingest/edge-detector.d.ts.map +1 -1
- package/dist/ingest/edge-detector.js +68 -200
- package/dist/ingest/edge-detector.js.map +1 -1
- package/dist/ingest/index.d.ts +3 -3
- package/dist/ingest/index.d.ts.map +1 -1
- package/dist/ingest/index.js +3 -3
- package/dist/ingest/index.js.map +1 -1
- package/dist/ingest/ingest-session.d.ts +1 -8
- package/dist/ingest/ingest-session.d.ts.map +1 -1
- package/dist/ingest/ingest-session.js +54 -107
- package/dist/ingest/ingest-session.js.map +1 -1
- package/dist/ingest/rebuild-edges.d.ts +17 -0
- package/dist/ingest/rebuild-edges.d.ts.map +1 -0
- package/dist/ingest/rebuild-edges.js +97 -0
- package/dist/ingest/rebuild-edges.js.map +1 -0
- package/dist/maintenance/scheduler.d.ts +2 -3
- package/dist/maintenance/scheduler.d.ts.map +1 -1
- package/dist/maintenance/scheduler.js +14 -23
- package/dist/maintenance/scheduler.js.map +1 -1
- package/dist/maintenance/tasks/cleanup-vectors.d.ts +3 -1
- package/dist/maintenance/tasks/cleanup-vectors.d.ts.map +1 -1
- package/dist/maintenance/tasks/cleanup-vectors.js +6 -4
- package/dist/maintenance/tasks/cleanup-vectors.js.map +1 -1
- package/dist/maintenance/tasks/index.d.ts +0 -1
- package/dist/maintenance/tasks/index.d.ts.map +1 -1
- package/dist/maintenance/tasks/index.js +0 -1
- package/dist/maintenance/tasks/index.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +9 -8
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools.d.ts +5 -5
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +42 -36
- package/dist/mcp/tools.js.map +1 -1
- package/dist/models/device-detector.d.ts.map +1 -1
- package/dist/models/device-detector.js +20 -10
- package/dist/models/device-detector.js.map +1 -1
- package/dist/models/embedder.d.ts.map +1 -1
- package/dist/models/embedder.js +5 -2
- package/dist/models/embedder.js.map +1 -1
- package/dist/models/model-registry.d.ts.map +1 -1
- package/dist/models/model-registry.js.map +1 -1
- package/dist/parser/chunker.d.ts +5 -40
- package/dist/parser/chunker.d.ts.map +1 -1
- package/dist/parser/chunker.js +5 -111
- package/dist/parser/chunker.js.map +1 -1
- package/dist/parser/session-reader.d.ts.map +1 -1
- package/dist/parser/session-reader.js +3 -6
- package/dist/parser/session-reader.js.map +1 -1
- package/dist/parser/turn-assembler.d.ts.map +1 -1
- package/dist/parser/turn-assembler.js +0 -1
- package/dist/parser/turn-assembler.js.map +1 -1
- package/dist/parser/types.d.ts.map +1 -1
- package/dist/report/reporter.d.ts.map +1 -1
- package/dist/report/reporter.js +1 -3
- package/dist/report/reporter.js.map +1 -1
- package/dist/retrieval/chain-assembler.d.ts +58 -0
- package/dist/retrieval/chain-assembler.d.ts.map +1 -0
- package/dist/retrieval/chain-assembler.js +126 -0
- package/dist/retrieval/chain-assembler.js.map +1 -0
- package/dist/retrieval/chain-walker.d.ts +57 -0
- package/dist/retrieval/chain-walker.d.ts.map +1 -0
- package/dist/retrieval/chain-walker.js +121 -0
- package/dist/retrieval/chain-walker.js.map +1 -0
- package/dist/retrieval/cluster-expander.d.ts.map +1 -1
- package/dist/retrieval/cluster-expander.js +3 -3
- package/dist/retrieval/cluster-expander.js.map +1 -1
- package/dist/retrieval/context-assembler.d.ts +13 -36
- package/dist/retrieval/context-assembler.d.ts.map +1 -1
- package/dist/retrieval/context-assembler.js +50 -287
- package/dist/retrieval/context-assembler.js.map +1 -1
- package/dist/retrieval/index.d.ts +8 -4
- package/dist/retrieval/index.d.ts.map +1 -1
- package/dist/retrieval/index.js +7 -3
- package/dist/retrieval/index.js.map +1 -1
- package/dist/retrieval/rrf.d.ts.map +1 -1
- package/dist/retrieval/rrf.js +4 -2
- package/dist/retrieval/rrf.js.map +1 -1
- package/dist/retrieval/search-assembler.d.ts +59 -0
- package/dist/retrieval/search-assembler.d.ts.map +1 -0
- package/dist/retrieval/search-assembler.js +209 -0
- package/dist/retrieval/search-assembler.js.map +1 -0
- package/dist/retrieval/session-reconstructor.d.ts.map +1 -1
- package/dist/retrieval/session-reconstructor.js +9 -7
- package/dist/retrieval/session-reconstructor.js.map +1 -1
- package/dist/storage/archive.d.ts +0 -2
- package/dist/storage/archive.d.ts.map +1 -1
- package/dist/storage/archive.js +18 -12
- package/dist/storage/archive.js.map +1 -1
- package/dist/storage/checkpoint-store.d.ts +0 -1
- package/dist/storage/checkpoint-store.d.ts.map +1 -1
- package/dist/storage/checkpoint-store.js +5 -7
- package/dist/storage/checkpoint-store.js.map +1 -1
- package/dist/storage/chunk-store.d.ts.map +1 -1
- package/dist/storage/chunk-store.js +15 -17
- package/dist/storage/chunk-store.js.map +1 -1
- package/dist/storage/cluster-store.d.ts.map +1 -1
- package/dist/storage/cluster-store.js.map +1 -1
- package/dist/storage/db.d.ts.map +1 -1
- package/dist/storage/db.js.map +1 -1
- package/dist/storage/edge-store.d.ts +17 -30
- package/dist/storage/edge-store.d.ts.map +1 -1
- package/dist/storage/edge-store.js +43 -123
- package/dist/storage/edge-store.js.map +1 -1
- package/dist/storage/embedding-cache.d.ts.map +1 -1
- package/dist/storage/embedding-cache.js +1 -3
- package/dist/storage/embedding-cache.js.map +1 -1
- package/dist/storage/encryption.d.ts.map +1 -1
- package/dist/storage/encryption.js +4 -15
- package/dist/storage/encryption.js.map +1 -1
- package/dist/storage/index.d.ts +1 -4
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +1 -5
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/keyword-store.d.ts.map +1 -1
- package/dist/storage/keyword-store.js +11 -7
- package/dist/storage/keyword-store.js.map +1 -1
- package/dist/storage/migrations.d.ts.map +1 -1
- package/dist/storage/migrations.js +56 -4
- package/dist/storage/migrations.js.map +1 -1
- package/dist/storage/schema.sql +8 -20
- package/dist/storage/types.d.ts +12 -26
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/types.js +1 -2
- package/dist/storage/types.js.map +1 -1
- package/dist/storage/vector-store.d.ts +9 -15
- package/dist/storage/vector-store.d.ts.map +1 -1
- package/dist/storage/vector-store.js +64 -43
- package/dist/storage/vector-store.js.map +1 -1
- package/dist/utils/angular-distance.d.ts.map +1 -1
- package/dist/utils/angular-distance.js.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/secret-store.d.ts.map +1 -1
- package/dist/utils/secret-store.js +17 -13
- package/dist/utils/secret-store.js.map +1 -1
- package/dist/utils/secure-buffer.d.ts.map +1 -1
- package/dist/utils/secure-buffer.js.map +1 -1
- package/package.json +7 -6
- package/src/dashboard/client/package-lock.json +3 -3
- package/src/dashboard/client/package.json +3 -3
- package/dist/dashboard/client/assets/index-CMUKy4f9.css +0 -1
- package/dist/dashboard/client/assets/index-esv8TpCN.js +0 -168
- package/dist/eval/collection-benchmark/graph-value.d.ts +0 -16
- package/dist/eval/collection-benchmark/graph-value.d.ts.map +0 -1
- package/dist/eval/collection-benchmark/graph-value.js +0 -162
- package/dist/eval/collection-benchmark/graph-value.js.map +0 -1
- package/dist/eval/experiments/vector-decay-shapes/curve-shapes-experiment.d.ts +0 -10
- package/dist/eval/experiments/vector-decay-shapes/curve-shapes-experiment.d.ts.map +0 -1
- package/dist/eval/experiments/vector-decay-shapes/curve-shapes-experiment.js +0 -229
- package/dist/eval/experiments/vector-decay-shapes/curve-shapes-experiment.js.map +0 -1
- package/dist/eval/experiments/vector-decay-shapes/graph-range-experiment.d.ts +0 -12
- package/dist/eval/experiments/vector-decay-shapes/graph-range-experiment.d.ts.map +0 -1
- package/dist/eval/experiments/vector-decay-shapes/graph-range-experiment.js +0 -316
- package/dist/eval/experiments/vector-decay-shapes/graph-range-experiment.js.map +0 -1
- package/dist/eval/experiments/vector-decay-shapes/hop-decay.d.ts +0 -19
- package/dist/eval/experiments/vector-decay-shapes/hop-decay.d.ts.map +0 -1
- package/dist/eval/experiments/vector-decay-shapes/hop-decay.js +0 -127
- package/dist/eval/experiments/vector-decay-shapes/hop-decay.js.map +0 -1
- package/dist/eval/experiments/vector-decay-shapes/index.d.ts +0 -11
- package/dist/eval/experiments/vector-decay-shapes/index.d.ts.map +0 -1
- package/dist/eval/experiments/vector-decay-shapes/index.js +0 -11
- package/dist/eval/experiments/vector-decay-shapes/index.js.map +0 -1
- package/dist/eval/experiments/vector-decay-shapes/path-traversal-experiment.d.ts +0 -14
- package/dist/eval/experiments/vector-decay-shapes/path-traversal-experiment.d.ts.map +0 -1
- package/dist/eval/experiments/vector-decay-shapes/path-traversal-experiment.js +0 -274
- package/dist/eval/experiments/vector-decay-shapes/path-traversal-experiment.js.map +0 -1
- package/dist/eval/experiments/vector-decay-shapes/presets.d.ts +0 -36
- package/dist/eval/experiments/vector-decay-shapes/presets.d.ts.map +0 -1
- package/dist/eval/experiments/vector-decay-shapes/presets.js +0 -157
- package/dist/eval/experiments/vector-decay-shapes/presets.js.map +0 -1
- package/dist/eval/experiments/vector-decay-shapes/run-experiment.d.ts +0 -20
- package/dist/eval/experiments/vector-decay-shapes/run-experiment.d.ts.map +0 -1
- package/dist/eval/experiments/vector-decay-shapes/run-experiment.js +0 -504
- package/dist/eval/experiments/vector-decay-shapes/run-experiment.js.map +0 -1
- package/dist/eval/experiments/vector-decay-shapes/types.d.ts +0 -111
- package/dist/eval/experiments/vector-decay-shapes/types.d.ts.map +0 -1
- package/dist/eval/experiments/vector-decay-shapes/types.js +0 -15
- package/dist/eval/experiments/vector-decay-shapes/types.js.map +0 -1
- package/dist/eval/experiments/vector-decay-sweep/index.d.ts +0 -7
- package/dist/eval/experiments/vector-decay-sweep/index.d.ts.map +0 -1
- package/dist/eval/experiments/vector-decay-sweep/index.js +0 -7
- package/dist/eval/experiments/vector-decay-sweep/index.js.map +0 -1
- package/dist/eval/experiments/vector-decay-sweep/run-sweep.d.ts +0 -30
- package/dist/eval/experiments/vector-decay-sweep/run-sweep.d.ts.map +0 -1
- package/dist/eval/experiments/vector-decay-sweep/run-sweep.js +0 -378
- package/dist/eval/experiments/vector-decay-sweep/run-sweep.js.map +0 -1
- package/dist/eval/experiments/vector-decay-sweep/types.d.ts +0 -109
- package/dist/eval/experiments/vector-decay-sweep/types.d.ts.map +0 -1
- package/dist/eval/experiments/vector-decay-sweep/types.js +0 -16
- package/dist/eval/experiments/vector-decay-sweep/types.js.map +0 -1
- package/dist/maintenance/tasks/prune-graph.d.ts +0 -12
- package/dist/maintenance/tasks/prune-graph.d.ts.map +0 -1
- package/dist/maintenance/tasks/prune-graph.js +0 -23
- package/dist/maintenance/tasks/prune-graph.js.map +0 -1
- package/dist/retrieval/traverser.d.ts +0 -66
- package/dist/retrieval/traverser.d.ts.map +0 -1
- package/dist/retrieval/traverser.js +0 -160
- package/dist/retrieval/traverser.js.map +0 -1
- package/dist/storage/clock-store.d.ts +0 -80
- package/dist/storage/clock-store.d.ts.map +0 -1
- package/dist/storage/clock-store.js +0 -155
- package/dist/storage/clock-store.js.map +0 -1
- package/dist/storage/decay.d.ts +0 -125
- package/dist/storage/decay.d.ts.map +0 -1
- package/dist/storage/decay.js +0 -276
- package/dist/storage/decay.js.map +0 -1
- package/dist/storage/pruner.d.ts +0 -111
- package/dist/storage/pruner.d.ts.map +0 -1
- package/dist/storage/pruner.js +0 -280
- package/dist/storage/pruner.js.map +0 -1
- package/dist/temporal/clock-compactor.d.ts +0 -65
- package/dist/temporal/clock-compactor.d.ts.map +0 -1
- package/dist/temporal/clock-compactor.js +0 -157
- package/dist/temporal/clock-compactor.js.map +0 -1
- package/dist/temporal/index.d.ts +0 -6
- package/dist/temporal/index.d.ts.map +0 -1
- package/dist/temporal/index.js +0 -6
- package/dist/temporal/index.js.map +0 -1
- package/dist/temporal/vector-clock.d.ts +0 -143
- package/dist/temporal/vector-clock.d.ts.map +0 -1
- package/dist/temporal/vector-clock.js +0 -231
- package/dist/temporal/vector-clock.js.map +0 -1
- package/dist/utils/keychain.d.ts +0 -43
- package/dist/utils/keychain.d.ts.map +0 -1
- package/dist/utils/keychain.js +0 -82
- package/dist/utils/keychain.js.map +0 -1
package/dist/storage/decay.js
DELETED
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Decay weight calculation for edges.
|
|
3
|
-
* Supports both time-based decay (legacy) and vector clock-based decay.
|
|
4
|
-
*/
|
|
5
|
-
import { hopCount, deserialize } from '../temporal/vector-clock.js';
|
|
6
|
-
/**
|
|
7
|
-
* Backward hop decay: Linear (dies@10)
|
|
8
|
-
* Optimal for retrieving causally-related context 4-20 hops back.
|
|
9
|
-
* MRR=0.688 (+35% vs exponential 0.80)
|
|
10
|
-
*/
|
|
11
|
-
export const BACKWARD_HOP_DECAY = {
|
|
12
|
-
type: 'linear',
|
|
13
|
-
decayPerHop: 0.1, // weight = max(0, 1 - hops * 0.1), dies at 10 hops
|
|
14
|
-
minWeight: 0.01,
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Forward hop decay: Delayed linear (5-hop hold, dies@20)
|
|
18
|
-
* Optimal for predicting future context 1-20 hops forward.
|
|
19
|
-
* MRR=0.849 (+271% vs exponential 0.80)
|
|
20
|
-
*/
|
|
21
|
-
export const FORWARD_HOP_DECAY = {
|
|
22
|
-
type: 'delayed-linear',
|
|
23
|
-
holdHops: 5, // Full weight for first 5 hops
|
|
24
|
-
decayPerHop: 0.067, // Then linear decay, dies at ~20 hops
|
|
25
|
-
minWeight: 0.01,
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Default vector decay configuration (legacy exponential).
|
|
29
|
-
* @deprecated Use BACKWARD_HOP_DECAY or FORWARD_HOP_DECAY instead.
|
|
30
|
-
*/
|
|
31
|
-
export const DEFAULT_VECTOR_DECAY = {
|
|
32
|
-
weightPerHop: 0.80,
|
|
33
|
-
minWeight: 0.01,
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Calculate hop-based decay weight using direction-specific curves.
|
|
37
|
-
*
|
|
38
|
-
* @param hops - Number of hops from reference point
|
|
39
|
-
* @param config - Hop decay configuration
|
|
40
|
-
* @returns Weight value (0 to 1), or 0 if below minWeight
|
|
41
|
-
*/
|
|
42
|
-
export function calculateHopDecayWeight(hops, config) {
|
|
43
|
-
let weight;
|
|
44
|
-
switch (config.type) {
|
|
45
|
-
case 'exponential': {
|
|
46
|
-
const wph = config.weightPerHop ?? 0.80;
|
|
47
|
-
weight = Math.pow(wph, hops);
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
case 'linear': {
|
|
51
|
-
const rate = config.decayPerHop ?? 0.1;
|
|
52
|
-
weight = Math.max(0, 1 - hops * rate);
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
case 'delayed-linear': {
|
|
56
|
-
const hold = config.holdHops ?? 0;
|
|
57
|
-
const rate = config.decayPerHop ?? 0.067;
|
|
58
|
-
if (hops < hold) {
|
|
59
|
-
weight = 1;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
weight = Math.max(0, 1 - (hops - hold) * rate);
|
|
63
|
-
}
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
default:
|
|
67
|
-
weight = 1;
|
|
68
|
-
}
|
|
69
|
-
return weight >= config.minWeight ? weight : 0;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Calculate decay weight for an edge based on direction.
|
|
73
|
-
*
|
|
74
|
-
* @param edgeClock - Vector clock stamped on the edge
|
|
75
|
-
* @param referenceClock - Current reference clock for the project
|
|
76
|
-
* @param direction - Edge direction ('backward' or 'forward')
|
|
77
|
-
* @returns Weight value (0 to 1), or 0 if below minWeight
|
|
78
|
-
*/
|
|
79
|
-
export function calculateDirectionalDecayWeight(edgeClock, referenceClock, direction) {
|
|
80
|
-
const hops = hopCount(edgeClock, referenceClock);
|
|
81
|
-
const config = direction === 'backward' ? BACKWARD_HOP_DECAY : FORWARD_HOP_DECAY;
|
|
82
|
-
return calculateHopDecayWeight(hops, config);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Calculate decay weight based on vector clock hop count.
|
|
86
|
-
* @deprecated Use calculateDirectionalDecayWeight for direction-specific curves.
|
|
87
|
-
*
|
|
88
|
-
* @param edgeClock - Vector clock stamped on the edge
|
|
89
|
-
* @param referenceClock - Current reference clock for the project
|
|
90
|
-
* @param config - Vector decay configuration
|
|
91
|
-
* @returns Weight value (0 to 1), or 0 if below minWeight
|
|
92
|
-
*/
|
|
93
|
-
export function calculateVectorDecayWeight(edgeClock, referenceClock, config = DEFAULT_VECTOR_DECAY) {
|
|
94
|
-
const hops = hopCount(edgeClock, referenceClock);
|
|
95
|
-
const weight = Math.pow(config.weightPerHop, hops);
|
|
96
|
-
return weight >= config.minWeight ? weight : 0;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Calculate decay weight with fallback for legacy edges.
|
|
100
|
-
* Uses vector clock decay if available, falls back to time-based decay.
|
|
101
|
-
*
|
|
102
|
-
* @param edgeClockJson - JSON serialized vector clock (may be null for legacy edges)
|
|
103
|
-
* @param referenceClock - Current reference clock for the project
|
|
104
|
-
* @param direction - Edge direction for curve selection
|
|
105
|
-
* @param createdAtMs - Edge creation time in milliseconds (for fallback)
|
|
106
|
-
* @param queryTimeMs - Query time in milliseconds (for fallback)
|
|
107
|
-
* @param timeConfig - Time-based decay configuration (for fallback)
|
|
108
|
-
* @returns Computed weight value
|
|
109
|
-
*/
|
|
110
|
-
export function calculateDecayWeightWithFallback(edgeClockJson, referenceClock, direction, createdAtMs, queryTimeMs, timeConfig) {
|
|
111
|
-
// Try vector clock decay first
|
|
112
|
-
if (edgeClockJson) {
|
|
113
|
-
const edgeClock = deserialize(edgeClockJson);
|
|
114
|
-
if (Object.keys(edgeClock).length > 0) {
|
|
115
|
-
return calculateDirectionalDecayWeight(edgeClock, referenceClock, direction);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
// Fallback to time-based decay
|
|
119
|
-
return calculateDecayWeight(timeConfig, queryTimeMs - createdAtMs);
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* @deprecated Use calculateDecayWeightWithFallback with direction parameter.
|
|
123
|
-
*/
|
|
124
|
-
export function calculateDecayWeightWithFallbackLegacy(edgeClockJson, referenceClock, vectorConfig, createdAtMs, queryTimeMs, timeConfig) {
|
|
125
|
-
if (edgeClockJson) {
|
|
126
|
-
const edgeClock = deserialize(edgeClockJson);
|
|
127
|
-
if (Object.keys(edgeClock).length > 0) {
|
|
128
|
-
return calculateVectorDecayWeight(edgeClock, referenceClock, vectorConfig);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return calculateDecayWeight(timeConfig, queryTimeMs - createdAtMs);
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Calculate boosted weight for edges with multiple links.
|
|
135
|
-
* Edges that have been created multiple times (same source/target pair)
|
|
136
|
-
* get a boost to resist decay.
|
|
137
|
-
*
|
|
138
|
-
* @param baseWeight - Base weight after decay
|
|
139
|
-
* @param linkCount - Number of times this edge was created
|
|
140
|
-
* @returns Boosted weight
|
|
141
|
-
*/
|
|
142
|
-
export function applyLinkBoost(baseWeight, linkCount) {
|
|
143
|
-
if (linkCount <= 1)
|
|
144
|
-
return baseWeight;
|
|
145
|
-
// Logarithmic boost: 5 links = ~1.16x, 10 links = ~1.23x
|
|
146
|
-
const boostFactor = 1 + Math.log(linkCount) * 0.1;
|
|
147
|
-
return baseWeight * boostFactor;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Calculate the decay weight at a given age.
|
|
151
|
-
* @param config - Decay model configuration
|
|
152
|
-
* @param ageMs - Age of the edge in milliseconds
|
|
153
|
-
* @returns Weight value (0 to initialWeight)
|
|
154
|
-
*/
|
|
155
|
-
export function calculateDecayWeight(config, ageMs) {
|
|
156
|
-
if (ageMs < 0) {
|
|
157
|
-
return config.initialWeight ?? 1.0;
|
|
158
|
-
}
|
|
159
|
-
switch (config.type) {
|
|
160
|
-
case 'linear':
|
|
161
|
-
return calculateLinear(config, ageMs);
|
|
162
|
-
case 'delayed-linear':
|
|
163
|
-
return calculateDelayedLinear(config, ageMs);
|
|
164
|
-
case 'multi-linear':
|
|
165
|
-
return calculateMultiLinear(config, ageMs);
|
|
166
|
-
case 'exponential':
|
|
167
|
-
return calculateExponential(config, ageMs);
|
|
168
|
-
case 'power-law':
|
|
169
|
-
return calculatePowerLaw(config, ageMs);
|
|
170
|
-
default:
|
|
171
|
-
return config.initialWeight ?? 1.0;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Simple linear decay: w(t) = w0 - rate * t
|
|
176
|
-
*/
|
|
177
|
-
function calculateLinear(config, ageMs) {
|
|
178
|
-
const w0 = config.initialWeight ?? 1.0;
|
|
179
|
-
const rate = config.decayRate ?? 0;
|
|
180
|
-
const weight = w0 - rate * ageMs;
|
|
181
|
-
return Math.max(0, weight);
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Delayed linear: hold at w0 for holdPeriod, then linear decay.
|
|
185
|
-
* w(t) = w0 if t < hold, else w0 - rate * (t - hold)
|
|
186
|
-
*/
|
|
187
|
-
function calculateDelayedLinear(config, ageMs) {
|
|
188
|
-
const w0 = config.initialWeight ?? 1.0;
|
|
189
|
-
const hold = config.holdPeriodMs ?? 0;
|
|
190
|
-
const rate = config.decayRate ?? 0;
|
|
191
|
-
if (ageMs < hold) {
|
|
192
|
-
return w0;
|
|
193
|
-
}
|
|
194
|
-
const decayTime = ageMs - hold;
|
|
195
|
-
const weight = w0 - rate * decayTime;
|
|
196
|
-
return Math.max(0, weight);
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Multi-linear: sum of multiple decay tiers.
|
|
200
|
-
* Each tier has its own hold period and decay rate.
|
|
201
|
-
*/
|
|
202
|
-
function calculateMultiLinear(config, ageMs) {
|
|
203
|
-
const tiers = config.tiers ?? [];
|
|
204
|
-
let totalWeight = 0;
|
|
205
|
-
for (const tier of tiers) {
|
|
206
|
-
if (ageMs < tier.holdPeriodMs) {
|
|
207
|
-
totalWeight += tier.initialWeight;
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
const decayTime = ageMs - tier.holdPeriodMs;
|
|
211
|
-
const weight = tier.initialWeight - tier.decayRatePerMs * decayTime;
|
|
212
|
-
totalWeight += Math.max(0, weight);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
return totalWeight;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Exponential decay: w(t) = w0 * e^(-rate * t)
|
|
219
|
-
*/
|
|
220
|
-
function calculateExponential(config, ageMs) {
|
|
221
|
-
const w0 = config.initialWeight ?? 1.0;
|
|
222
|
-
const rate = config.decayRate ?? 0;
|
|
223
|
-
return w0 * Math.exp(-rate * ageMs);
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Power law decay: w(t) = w0 / (1 + k*t)^alpha
|
|
227
|
-
*/
|
|
228
|
-
function calculatePowerLaw(config, ageMs) {
|
|
229
|
-
const w0 = config.initialWeight ?? 1.0;
|
|
230
|
-
const k = config.decayRate ?? 0;
|
|
231
|
-
const alpha = config.powerExponent ?? 1.0;
|
|
232
|
-
return w0 / Math.pow(1 + k * ageMs, alpha);
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Calculate the time when weight reaches zero (or null if asymptotic).
|
|
236
|
-
*/
|
|
237
|
-
export function getDeathTime(config) {
|
|
238
|
-
switch (config.type) {
|
|
239
|
-
case 'linear': {
|
|
240
|
-
const w0 = config.initialWeight ?? 1.0;
|
|
241
|
-
const rate = config.decayRate ?? 0;
|
|
242
|
-
if (rate <= 0)
|
|
243
|
-
return null;
|
|
244
|
-
return w0 / rate;
|
|
245
|
-
}
|
|
246
|
-
case 'delayed-linear': {
|
|
247
|
-
const w0 = config.initialWeight ?? 1.0;
|
|
248
|
-
const hold = config.holdPeriodMs ?? 0;
|
|
249
|
-
const rate = config.decayRate ?? 0;
|
|
250
|
-
if (rate <= 0)
|
|
251
|
-
return null;
|
|
252
|
-
return hold + w0 / rate;
|
|
253
|
-
}
|
|
254
|
-
case 'multi-linear': {
|
|
255
|
-
const tiers = config.tiers ?? [];
|
|
256
|
-
if (tiers.length === 0)
|
|
257
|
-
return 0;
|
|
258
|
-
// Find the tier that dies last
|
|
259
|
-
let maxDeathTime = 0;
|
|
260
|
-
for (const tier of tiers) {
|
|
261
|
-
if (tier.decayRatePerMs <= 0)
|
|
262
|
-
return null;
|
|
263
|
-
const deathTime = tier.holdPeriodMs + tier.initialWeight / tier.decayRatePerMs;
|
|
264
|
-
maxDeathTime = Math.max(maxDeathTime, deathTime);
|
|
265
|
-
}
|
|
266
|
-
return maxDeathTime;
|
|
267
|
-
}
|
|
268
|
-
case 'exponential':
|
|
269
|
-
case 'power-law':
|
|
270
|
-
// Asymptotic - never reaches exactly zero
|
|
271
|
-
return null;
|
|
272
|
-
default:
|
|
273
|
-
return null;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
//# sourceMappingURL=decay.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decay.js","sourceRoot":"","sources":["../../src/storage/decay.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAoB,QAAQ,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AA+BtF;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAmB;IAChD,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,GAAG,EAAE,mDAAmD;IACrE,SAAS,EAAE,IAAI;CAChB,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAmB;IAC/C,IAAI,EAAE,gBAAgB;IACtB,QAAQ,EAAE,CAAC,EAAE,+BAA+B;IAC5C,WAAW,EAAE,KAAK,EAAE,sCAAsC;IAC1D,SAAS,EAAE,IAAI;CAChB,CAAC;AAaF;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAsB;IACrD,YAAY,EAAE,IAAI;IAClB,SAAS,EAAE,IAAI;CAChB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAY,EAAE,MAAsB;IAC1E,IAAI,MAAc,CAAC;IAEnB,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,IAAI,IAAI,CAAC;YACxC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAC7B,MAAM;QACR,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,IAAI,GAAG,CAAC;YACvC,MAAM,GAAG,IAAI,CAAC,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,IAAI,YAAY,GAAG,CAAC,CAAC;YACrB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,IAAI,IAAI,CAAC,cAAc,IAAI,CAAC;oBAAE,OAAO,IAAI,CAAC;gBAC1C,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC;gBAC/E,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;YACnD,CAAC;YACD,OAAO,YAAY,CAAC;QACtB,CAAC;QACD,KAAK,aAAa,CAAC;QACnB,KAAK,WAAW;YACd,0CAA0C;YAC1C,OAAO,IAAI,CAAC;QACd;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
|
package/dist/storage/pruner.d.ts
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lazy pruning system for dead edges.
|
|
3
|
-
* Edges with weight <= 0 at query time are queued for async deletion.
|
|
4
|
-
* Chunks that lose all edges are marked for TTL-based cleanup (not deleted).
|
|
5
|
-
*
|
|
6
|
-
* Two pruning modes:
|
|
7
|
-
* 1. Lazy: Queued during traversal, flushed after debounce
|
|
8
|
-
* 2. Full: Background scan on startup, removes all dead edges
|
|
9
|
-
*
|
|
10
|
-
* Chunks remain in the database after losing edges so they can still be
|
|
11
|
-
* found via vector and keyword search. Their vectors are marked orphaned
|
|
12
|
-
* to start the TTL countdown; the cleanup-vectors task handles eventual
|
|
13
|
-
* deletion of both vector and chunk after TTL expires.
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* Pruner class for managing lazy deletion of dead edges.
|
|
17
|
-
* Chunks that lose all edges are marked for TTL cleanup, not deleted.
|
|
18
|
-
*/
|
|
19
|
-
declare class Pruner {
|
|
20
|
-
private pendingEdges;
|
|
21
|
-
private isRunning;
|
|
22
|
-
private flushTimeout;
|
|
23
|
-
private flushDelayMs;
|
|
24
|
-
/**
|
|
25
|
-
* Queue an edge for pruning.
|
|
26
|
-
* Called during edge traversal when weight <= 0.
|
|
27
|
-
*/
|
|
28
|
-
queueEdgePrune(edgeId: string): void;
|
|
29
|
-
/**
|
|
30
|
-
* Queue multiple edges for pruning.
|
|
31
|
-
*/
|
|
32
|
-
queueEdgePruneBatch(edgeIds: string[]): void;
|
|
33
|
-
/**
|
|
34
|
-
* Get count of pending edges.
|
|
35
|
-
*/
|
|
36
|
-
getPendingCount(): number;
|
|
37
|
-
/**
|
|
38
|
-
* Force immediate flush (for testing or shutdown).
|
|
39
|
-
*/
|
|
40
|
-
flushNow(): Promise<PruneResult>;
|
|
41
|
-
/**
|
|
42
|
-
* Schedule a debounced flush.
|
|
43
|
-
*/
|
|
44
|
-
private scheduleFlush;
|
|
45
|
-
/**
|
|
46
|
-
* Execute the pruning operation.
|
|
47
|
-
*/
|
|
48
|
-
private flush;
|
|
49
|
-
/**
|
|
50
|
-
* Set flush delay (for testing).
|
|
51
|
-
*/
|
|
52
|
-
setFlushDelay(ms: number): void;
|
|
53
|
-
/**
|
|
54
|
-
* Check if pruner is currently running.
|
|
55
|
-
*/
|
|
56
|
-
isActive(): boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Clear pending queue without flushing (for testing).
|
|
59
|
-
*/
|
|
60
|
-
clearPending(): void;
|
|
61
|
-
private fullPruneRunning;
|
|
62
|
-
private fullPruneProgress;
|
|
63
|
-
/**
|
|
64
|
-
* Start a full background prune (non-blocking).
|
|
65
|
-
* Scans all edges, removes dead ones, marks orphaned chunks for TTL.
|
|
66
|
-
* Idempotent - if already running, returns existing progress.
|
|
67
|
-
*/
|
|
68
|
-
startBackgroundPrune(): FullPruneProgress;
|
|
69
|
-
/**
|
|
70
|
-
* Get current full prune progress (null if never started).
|
|
71
|
-
*/
|
|
72
|
-
getFullPruneProgress(): FullPruneProgress | null;
|
|
73
|
-
/**
|
|
74
|
-
* Check if full prune is currently running.
|
|
75
|
-
*/
|
|
76
|
-
isFullPruneRunning(): boolean;
|
|
77
|
-
/**
|
|
78
|
-
* Run the full prune operation.
|
|
79
|
-
* Scans all edges, calculates weights, removes dead edges, and marks
|
|
80
|
-
* chunks that lose all edges for TTL cleanup.
|
|
81
|
-
*/
|
|
82
|
-
private runFullPrune;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Result of a prune operation.
|
|
86
|
-
*/
|
|
87
|
-
export interface PruneResult {
|
|
88
|
-
edgesDeleted: number;
|
|
89
|
-
chunksOrphaned: number;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Progress of a full background prune.
|
|
93
|
-
*/
|
|
94
|
-
export interface FullPruneProgress {
|
|
95
|
-
status: 'running' | 'completed' | 'error';
|
|
96
|
-
edgesScanned: number;
|
|
97
|
-
edgesDeleted: number;
|
|
98
|
-
chunksScanned: number;
|
|
99
|
-
chunksOrphaned: number;
|
|
100
|
-
startedAt: number;
|
|
101
|
-
completedAt: number | null;
|
|
102
|
-
error: string | null;
|
|
103
|
-
}
|
|
104
|
-
export { Pruner };
|
|
105
|
-
export declare const pruner: Pruner;
|
|
106
|
-
/**
|
|
107
|
-
* Start background pruning on module load if environment variable is set.
|
|
108
|
-
* This allows the MCP server or CLI to trigger startup pruning.
|
|
109
|
-
*/
|
|
110
|
-
export declare function initStartupPrune(): FullPruneProgress;
|
|
111
|
-
//# sourceMappingURL=pruner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pruner.d.ts","sourceRoot":"","sources":["../../src/storage/pruner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAWH;;;GAGG;AACH,cAAM,MAAM;IACV,OAAO,CAAC,YAAY,CAA0B;IAC9C,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,YAAY,CAA8C;IAClE,OAAO,CAAC,YAAY,CAAQ;IAE5B;;;OAGG;IACH,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;I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|
-
/**
|
|
2
|
-
* Lazy pruning system for dead edges.
|
|
3
|
-
* Edges with weight <= 0 at query time are queued for async deletion.
|
|
4
|
-
* Chunks that lose all edges are marked for TTL-based cleanup (not deleted).
|
|
5
|
-
*
|
|
6
|
-
* Two pruning modes:
|
|
7
|
-
* 1. Lazy: Queued during traversal, flushed after debounce
|
|
8
|
-
* 2. Full: Background scan on startup, removes all dead edges
|
|
9
|
-
*
|
|
10
|
-
* Chunks remain in the database after losing edges so they can still be
|
|
11
|
-
* found via vector and keyword search. Their vectors are marked orphaned
|
|
12
|
-
* to start the TTL countdown; the cleanup-vectors task handles eventual
|
|
13
|
-
* deletion of both vector and chunk after TTL expires.
|
|
14
|
-
*/
|
|
15
|
-
import { deleteEdge, hasAnyEdges, getAllEdges } from './edge-store.js';
|
|
16
|
-
import { vectorStore } from './vector-store.js';
|
|
17
|
-
import { getReferenceClock } from './clock-store.js';
|
|
18
|
-
import { calculateDirectionalDecayWeight } from './decay.js';
|
|
19
|
-
import { deserialize } from '../temporal/vector-clock.js';
|
|
20
|
-
import { createLogger } from '../utils/logger.js';
|
|
21
|
-
const log = createLogger('pruner');
|
|
22
|
-
/**
|
|
23
|
-
* Pruner class for managing lazy deletion of dead edges.
|
|
24
|
-
* Chunks that lose all edges are marked for TTL cleanup, not deleted.
|
|
25
|
-
*/
|
|
26
|
-
class Pruner {
|
|
27
|
-
pendingEdges = new Set();
|
|
28
|
-
isRunning = false;
|
|
29
|
-
flushTimeout = null;
|
|
30
|
-
flushDelayMs = 1000;
|
|
31
|
-
/**
|
|
32
|
-
* Queue an edge for pruning.
|
|
33
|
-
* Called during edge traversal when weight <= 0.
|
|
34
|
-
*/
|
|
35
|
-
queueEdgePrune(edgeId) {
|
|
36
|
-
this.pendingEdges.add(edgeId);
|
|
37
|
-
this.scheduleFlush();
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Queue multiple edges for pruning.
|
|
41
|
-
*/
|
|
42
|
-
queueEdgePruneBatch(edgeIds) {
|
|
43
|
-
for (const id of edgeIds) {
|
|
44
|
-
this.pendingEdges.add(id);
|
|
45
|
-
}
|
|
46
|
-
this.scheduleFlush();
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Get count of pending edges.
|
|
50
|
-
*/
|
|
51
|
-
getPendingCount() {
|
|
52
|
-
return this.pendingEdges.size;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Force immediate flush (for testing or shutdown).
|
|
56
|
-
*/
|
|
57
|
-
async flushNow() {
|
|
58
|
-
if (this.flushTimeout) {
|
|
59
|
-
clearTimeout(this.flushTimeout);
|
|
60
|
-
this.flushTimeout = null;
|
|
61
|
-
}
|
|
62
|
-
return this.flush();
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Schedule a debounced flush.
|
|
66
|
-
*/
|
|
67
|
-
scheduleFlush() {
|
|
68
|
-
if (this.flushTimeout) {
|
|
69
|
-
return; // Already scheduled
|
|
70
|
-
}
|
|
71
|
-
this.flushTimeout = setTimeout(() => {
|
|
72
|
-
this.flushTimeout = null;
|
|
73
|
-
this.flush().catch((err) => {
|
|
74
|
-
log.error('Pruner flush error', { error: err instanceof Error ? err.message : String(err) });
|
|
75
|
-
});
|
|
76
|
-
}, this.flushDelayMs);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Execute the pruning operation.
|
|
80
|
-
*/
|
|
81
|
-
async flush() {
|
|
82
|
-
if (this.isRunning || this.pendingEdges.size === 0) {
|
|
83
|
-
return { edgesDeleted: 0, chunksOrphaned: 0 };
|
|
84
|
-
}
|
|
85
|
-
this.isRunning = true;
|
|
86
|
-
const result = { edgesDeleted: 0, chunksOrphaned: 0 };
|
|
87
|
-
try {
|
|
88
|
-
const edgeIds = [...this.pendingEdges];
|
|
89
|
-
this.pendingEdges.clear();
|
|
90
|
-
// Track chunks that might lose all edges
|
|
91
|
-
const chunkIdsToCheck = new Set();
|
|
92
|
-
for (const edgeId of edgeIds) {
|
|
93
|
-
// Get edge info before deleting (we need source/target)
|
|
94
|
-
const { getEdgeById } = await import('./edge-store.js');
|
|
95
|
-
const edge = getEdgeById(edgeId);
|
|
96
|
-
if (!edge) {
|
|
97
|
-
continue; // Already deleted
|
|
98
|
-
}
|
|
99
|
-
// Delete the edge
|
|
100
|
-
const deleted = deleteEdge(edgeId);
|
|
101
|
-
if (deleted) {
|
|
102
|
-
result.edgesDeleted++;
|
|
103
|
-
chunkIdsToCheck.add(edge.sourceChunkId);
|
|
104
|
-
chunkIdsToCheck.add(edge.targetChunkId);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
// Mark chunks that lost all edges for TTL cleanup
|
|
108
|
-
for (const chunkId of chunkIdsToCheck) {
|
|
109
|
-
if (!hasAnyEdges(chunkId)) {
|
|
110
|
-
await vectorStore.markOrphaned(chunkId);
|
|
111
|
-
result.chunksOrphaned++;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
finally {
|
|
116
|
-
this.isRunning = false;
|
|
117
|
-
}
|
|
118
|
-
return result;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Set flush delay (for testing).
|
|
122
|
-
*/
|
|
123
|
-
setFlushDelay(ms) {
|
|
124
|
-
this.flushDelayMs = ms;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Check if pruner is currently running.
|
|
128
|
-
*/
|
|
129
|
-
isActive() {
|
|
130
|
-
return this.isRunning;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Clear pending queue without flushing (for testing).
|
|
134
|
-
*/
|
|
135
|
-
clearPending() {
|
|
136
|
-
this.pendingEdges.clear();
|
|
137
|
-
if (this.flushTimeout) {
|
|
138
|
-
clearTimeout(this.flushTimeout);
|
|
139
|
-
this.flushTimeout = null;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
// ─── Full Background Prune ────────────────────────────────────────
|
|
143
|
-
fullPruneRunning = false;
|
|
144
|
-
fullPruneProgress = null;
|
|
145
|
-
/**
|
|
146
|
-
* Start a full background prune (non-blocking).
|
|
147
|
-
* Scans all edges, removes dead ones, marks orphaned chunks for TTL.
|
|
148
|
-
* Idempotent - if already running, returns existing progress.
|
|
149
|
-
*/
|
|
150
|
-
startBackgroundPrune() {
|
|
151
|
-
if (this.fullPruneProgress && this.fullPruneRunning) {
|
|
152
|
-
return this.fullPruneProgress;
|
|
153
|
-
}
|
|
154
|
-
this.fullPruneProgress = {
|
|
155
|
-
status: 'running',
|
|
156
|
-
edgesScanned: 0,
|
|
157
|
-
edgesDeleted: 0,
|
|
158
|
-
chunksScanned: 0,
|
|
159
|
-
chunksOrphaned: 0,
|
|
160
|
-
startedAt: Date.now(),
|
|
161
|
-
completedAt: null,
|
|
162
|
-
error: null,
|
|
163
|
-
};
|
|
164
|
-
// Run in background - don't await
|
|
165
|
-
this.runFullPrune().catch((err) => {
|
|
166
|
-
if (this.fullPruneProgress) {
|
|
167
|
-
this.fullPruneProgress.status = 'error';
|
|
168
|
-
this.fullPruneProgress.error = err.message;
|
|
169
|
-
this.fullPruneProgress.completedAt = Date.now();
|
|
170
|
-
}
|
|
171
|
-
log.error('Full prune error', { error: err instanceof Error ? err.message : String(err) });
|
|
172
|
-
});
|
|
173
|
-
return this.fullPruneProgress;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Get current full prune progress (null if never started).
|
|
177
|
-
*/
|
|
178
|
-
getFullPruneProgress() {
|
|
179
|
-
return this.fullPruneProgress;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Check if full prune is currently running.
|
|
183
|
-
*/
|
|
184
|
-
isFullPruneRunning() {
|
|
185
|
-
return this.fullPruneRunning;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Run the full prune operation.
|
|
189
|
-
* Scans all edges, calculates weights, removes dead edges, and marks
|
|
190
|
-
* chunks that lose all edges for TTL cleanup.
|
|
191
|
-
*/
|
|
192
|
-
async runFullPrune() {
|
|
193
|
-
if (this.fullPruneRunning) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
this.fullPruneRunning = true;
|
|
197
|
-
const progress = this.fullPruneProgress;
|
|
198
|
-
try {
|
|
199
|
-
// Build reference clocks for all projects
|
|
200
|
-
const refClocks = new Map();
|
|
201
|
-
// Get all edges
|
|
202
|
-
const edges = getAllEdges();
|
|
203
|
-
const deadEdgeIds = [];
|
|
204
|
-
const chunkIdsToCheck = new Set();
|
|
205
|
-
// Scan edges and identify dead ones
|
|
206
|
-
for (const edge of edges) {
|
|
207
|
-
progress.edgesScanned++;
|
|
208
|
-
// Get reference clock for this edge's project (lazy load)
|
|
209
|
-
let refClock = refClocks.get(edge.sourceChunkId);
|
|
210
|
-
if (!refClock) {
|
|
211
|
-
// Try to get from chunk's session
|
|
212
|
-
const { getChunkById } = await import('./chunk-store.js');
|
|
213
|
-
const chunk = getChunkById(edge.sourceChunkId);
|
|
214
|
-
if (chunk) {
|
|
215
|
-
refClock = getReferenceClock(chunk.sessionSlug);
|
|
216
|
-
refClocks.set(edge.sourceChunkId, refClock);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
// Calculate weight
|
|
220
|
-
let weight = edge.initialWeight;
|
|
221
|
-
if (refClock && edge.vectorClock) {
|
|
222
|
-
const edgeClock = deserialize(edge.vectorClock);
|
|
223
|
-
const direction = edge.edgeType === 'forward' ? 'forward' : 'backward';
|
|
224
|
-
weight = edge.initialWeight * calculateDirectionalDecayWeight(edgeClock, refClock, direction);
|
|
225
|
-
}
|
|
226
|
-
// Queue dead edges
|
|
227
|
-
if (weight <= 0) {
|
|
228
|
-
deadEdgeIds.push(edge.id);
|
|
229
|
-
chunkIdsToCheck.add(edge.sourceChunkId);
|
|
230
|
-
chunkIdsToCheck.add(edge.targetChunkId);
|
|
231
|
-
}
|
|
232
|
-
// Yield periodically to avoid blocking
|
|
233
|
-
if (progress.edgesScanned % 500 === 0) {
|
|
234
|
-
await new Promise((resolve) => setImmediate(resolve));
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
// Delete dead edges in batches
|
|
238
|
-
const batchSize = 100;
|
|
239
|
-
for (let i = 0; i < deadEdgeIds.length; i += batchSize) {
|
|
240
|
-
const batch = deadEdgeIds.slice(i, i + batchSize);
|
|
241
|
-
for (const edgeId of batch) {
|
|
242
|
-
if (deleteEdge(edgeId)) {
|
|
243
|
-
progress.edgesDeleted++;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
// Yield after each batch
|
|
247
|
-
await new Promise((resolve) => setImmediate(resolve));
|
|
248
|
-
}
|
|
249
|
-
// Mark chunks that lost all edges for TTL cleanup
|
|
250
|
-
for (const chunkId of chunkIdsToCheck) {
|
|
251
|
-
progress.chunksScanned++;
|
|
252
|
-
if (!hasAnyEdges(chunkId)) {
|
|
253
|
-
await vectorStore.markOrphaned(chunkId);
|
|
254
|
-
progress.chunksOrphaned++;
|
|
255
|
-
}
|
|
256
|
-
// Yield periodically
|
|
257
|
-
if (progress.chunksScanned % 100 === 0) {
|
|
258
|
-
await new Promise((resolve) => setImmediate(resolve));
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
progress.status = 'completed';
|
|
262
|
-
progress.completedAt = Date.now();
|
|
263
|
-
}
|
|
264
|
-
finally {
|
|
265
|
-
this.fullPruneRunning = false;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
// Export class for testing (allows creating fresh instances)
|
|
270
|
-
export { Pruner };
|
|
271
|
-
// Singleton instance for production use
|
|
272
|
-
export const pruner = new Pruner();
|
|
273
|
-
/**
|
|
274
|
-
* Start background pruning on module load if environment variable is set.
|
|
275
|
-
* This allows the MCP server or CLI to trigger startup pruning.
|
|
276
|
-
*/
|
|
277
|
-
export function initStartupPrune() {
|
|
278
|
-
return pruner.startBackgroundPrune();
|
|
279
|
-
}
|
|
280
|
-
//# sourceMappingURL=pruner.js.map
|