@dikolab/kbdb 0.2.2 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -31
- package/dist/bench/constants/corpus-defaults.constant.d.ts +3 -0
- package/dist/bench/functions/format-report.function.d.ts +11 -0
- package/dist/bench/functions/generate-corpus.function.d.ts +12 -0
- package/dist/bench/functions/measure-operation.function.d.ts +14 -0
- package/dist/bench/functions/seeded-rng.function.d.ts +11 -0
- package/dist/bench/functions/zipf-word.function.d.ts +13 -0
- package/dist/bench/index.d.ts +10 -0
- package/dist/bench/typings/bench-result.interface.d.ts +11 -0
- package/dist/bench/typings/bench-suite-result.interface.d.ts +10 -0
- package/dist/bench/typings/corpus-config.interface.d.ts +11 -0
- package/dist/bench/typings/corpus-section.interface.d.ts +9 -0
- package/dist/cli.cjs +523 -80
- package/dist/cli.cjs.map +4 -4
- package/dist/cli.mjs +515 -72
- package/dist/cli.mjs.map +4 -4
- package/dist/kbdb-worker.cjs +395 -60
- package/dist/kbdb-worker.cjs.map +4 -4
- package/dist/mod.cjs +17 -0
- package/dist/mod.cjs.map +2 -2
- package/dist/mod.mjs +17 -0
- package/dist/mod.mjs.map +2 -2
- package/dist/src/shared/auto-capture/classes/auto-capture-controller.class.d.ts +33 -0
- package/dist/src/shared/auto-capture/constants/auto-capture-defaults.constant.d.ts +8 -0
- package/dist/src/shared/auto-capture/functions/build-capture-prompt.function.d.ts +11 -0
- package/dist/src/shared/auto-capture/functions/evaluate-trigger.function.d.ts +12 -0
- package/dist/src/shared/auto-capture/index.d.ts +7 -0
- package/dist/src/shared/auto-capture/typings/auto-capture-config.interface.d.ts +13 -0
- package/dist/src/shared/auto-capture/typings/auto-capture-state.interface.d.ts +13 -0
- package/dist/src/shared/auto-capture/typings/auto-capture-trigger.interface.d.ts +7 -0
- package/dist/src/shared/cli/constants/global-help.constant.d.ts +8 -0
- package/dist/src/shared/cli/constants/leaf-help.constant.d.ts +7 -0
- package/dist/src/shared/cli/constants/memory-protocol-body.constant.d.ts +7 -0
- package/dist/src/shared/cli/constants/query-guidance-body.constant.d.ts +7 -0
- package/dist/src/shared/cli/constants/subcommand-help.constant.d.ts +8 -0
- package/dist/src/shared/cli/functions/collect-files.function.d.ts +13 -0
- package/dist/src/shared/cli/functions/compute-section-kbid.function.d.ts +15 -0
- package/dist/src/shared/cli/functions/dispatch-command.function.d.ts +3 -1
- package/dist/src/shared/cli/functions/format-mcp-output.function.d.ts +9 -0
- package/dist/src/shared/cli/functions/format-text-output.function.d.ts +9 -0
- package/dist/src/shared/cli/functions/generate-group-help.function.d.ts +11 -0
- package/dist/src/shared/cli/functions/handle-data-command.function.d.ts +16 -0
- package/dist/src/shared/cli/functions/handle-mcp.function.d.ts +15 -0
- package/dist/src/shared/cli/functions/handle-migrate.function.d.ts +15 -0
- package/dist/src/shared/cli/functions/hydrate-search-previews.function.d.ts +14 -0
- package/dist/src/shared/cli/functions/install-default-skills.function.d.ts +12 -0
- package/dist/src/shared/cli/functions/resolve-skill-names.function.d.ts +16 -0
- package/dist/src/shared/cli/functions/run-check.function.d.ts +47 -5
- package/dist/src/shared/cli/functions/run-export.function.d.ts +34 -0
- package/dist/src/shared/cli/functions/run-gc.function.d.ts +6 -0
- package/dist/src/shared/cli/functions/run-learn.function.d.ts +35 -6
- package/dist/src/shared/cli/functions/run-recall.function.d.ts +45 -0
- package/dist/src/shared/cli/functions/run-search.function.d.ts +53 -15
- package/dist/src/shared/cli/functions/version-gate.function.d.ts +15 -0
- package/dist/src/shared/cli/functions/wrap-command.function.d.ts +15 -0
- package/dist/src/shared/cli/index.d.ts +4 -0
- package/dist/src/shared/cli/typings/agent-create-client.interface.d.ts +42 -0
- package/dist/src/shared/cli/typings/agent-get-client.interface.d.ts +36 -0
- package/dist/src/shared/cli/typings/check-client.interface.d.ts +58 -0
- package/dist/src/shared/cli/typings/cli-deps.interface.d.ts +48 -0
- package/dist/src/shared/cli/typings/cli-options.interface.d.ts +15 -0
- package/dist/src/shared/cli/typings/disconnectable-client.interface.d.ts +26 -0
- package/dist/src/shared/cli/typings/dispatch-client.type.d.ts +27 -0
- package/dist/src/shared/cli/typings/learn-client.interface.d.ts +52 -0
- package/dist/src/shared/cli/typings/learn-io.interface.d.ts +5 -0
- package/dist/src/shared/cli/typings/learn-result.model.d.ts +19 -0
- package/dist/src/shared/cli/typings/search-client.interface.d.ts +71 -0
- package/dist/src/shared/cli/typings/search-display.model.d.ts +18 -0
- package/dist/src/shared/embedding/classes/null-embedding-provider.class.d.ts +20 -0
- package/dist/src/shared/embedding/constants/near-duplicate-thresholds.constant.d.ts +15 -0
- package/dist/src/shared/embedding/functions/build-vector-index.function.d.ts +14 -0
- package/dist/src/shared/embedding/functions/cosine-similarity.function.d.ts +10 -0
- package/dist/src/shared/embedding/functions/detect-near-duplicates.function.d.ts +18 -0
- package/dist/src/shared/embedding/functions/jaccard-coefficient.function.d.ts +9 -0
- package/dist/src/shared/embedding/functions/read-vector-index-meta.function.d.ts +10 -0
- package/dist/src/shared/embedding/functions/rrf-fuse.function.d.ts +14 -0
- package/dist/src/shared/embedding/functions/search-vectors.function.d.ts +14 -0
- package/dist/src/shared/embedding/index.d.ts +16 -0
- package/dist/src/shared/embedding/typings/embedding-config.interface.d.ts +20 -0
- package/dist/src/shared/embedding/typings/embedding-provider.interface.d.ts +23 -0
- package/dist/src/shared/embedding/typings/near-duplicate-candidate.model.d.ts +23 -0
- package/dist/src/shared/embedding/typings/near-duplicate-result.model.d.ts +24 -0
- package/dist/src/shared/embedding/typings/vector-index-entry.model.d.ts +12 -0
- package/dist/src/shared/embedding/typings/vector-index-meta.model.d.ts +11 -0
- package/dist/src/shared/embedding/typings/vector-search-result.model.d.ts +7 -0
- package/dist/src/shared/mcp/classes/mcp-server.class.d.ts +8 -0
- package/dist/src/shared/mcp/constants/tool-agent-create.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-agent-delete.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-agent-get.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-agent-list.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-auto-capture-review.constant.d.ts +8 -0
- package/dist/src/shared/mcp/constants/tool-check.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-content.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-export.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-gc.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-learn.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-rebuild.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-recall.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-retrieve.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-search.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-skill-delete.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-skill-get.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-skill-learn.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-skill-list.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-status.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-unlearn.constant.d.ts +3 -0
- package/dist/src/shared/mcp/functions/as-boolean-or-undefined.function.d.ts +7 -0
- package/dist/src/shared/mcp/functions/as-string-array-or-undefined.function.d.ts +7 -0
- package/dist/src/shared/mcp/functions/as-string-array.function.d.ts +7 -0
- package/dist/src/shared/mcp/functions/as-string.function.d.ts +8 -0
- package/dist/src/shared/mcp/functions/build-skills-text.function.d.ts +18 -0
- package/dist/src/shared/mcp/functions/handle-agent-prompt.function.d.ts +14 -0
- package/dist/src/shared/mcp/functions/handle-mcp-request.function.d.ts +14 -0
- package/dist/src/shared/mcp/functions/handle-prompt-get.function.d.ts +4 -3
- package/dist/src/shared/mcp/functions/handle-skill-prompt.function.d.ts +16 -0
- package/dist/src/shared/mcp/functions/handle-tool-auto-capture-review.function.d.ts +12 -0
- package/dist/src/shared/mcp/functions/handle-tool-check.function.d.ts +11 -0
- package/dist/src/shared/mcp/functions/handle-tool-content.function.d.ts +12 -0
- package/dist/src/shared/mcp/functions/handle-tool-export.function.d.ts +12 -0
- package/dist/src/shared/mcp/functions/handle-tool-gc.function.d.ts +11 -0
- package/dist/src/shared/mcp/functions/handle-tool-learn.function.d.ts +12 -0
- package/dist/src/shared/mcp/functions/handle-tool-rebuild.function.d.ts +11 -0
- package/dist/src/shared/mcp/functions/handle-tool-retrieve.function.d.ts +12 -0
- package/dist/src/shared/mcp/functions/handle-tool-search.function.d.ts +13 -0
- package/dist/src/shared/mcp/functions/handle-tool-skill-delete.function.d.ts +12 -0
- package/dist/src/shared/mcp/functions/handle-tool-skill-get.function.d.ts +13 -0
- package/dist/src/shared/mcp/functions/handle-tool-skill-learn.function.d.ts +13 -0
- package/dist/src/shared/mcp/functions/handle-tool-skill-list.function.d.ts +11 -0
- package/dist/src/shared/mcp/functions/handle-tool-status.function.d.ts +11 -0
- package/dist/src/shared/mcp/functions/handle-tool-unlearn.function.d.ts +12 -0
- package/dist/src/shared/mcp/functions/parse-agent-meta.function.d.ts +14 -0
- package/dist/src/shared/mcp/functions/parse-skill-arguments.function.d.ts +11 -0
- package/dist/src/shared/mcp/functions/read-agent-meta.function.d.ts +17 -0
- package/dist/src/shared/mcp/functions/resolve-skill-refs.function.d.ts +23 -0
- package/dist/src/shared/mcp/functions/run-startup-health-check.function.d.ts +14 -0
- package/dist/src/shared/mcp/typings/mcp-capabilities.interface.d.ts +16 -0
- package/dist/src/shared/mcp/typings/mcp-client.interface.d.ts +45 -0
- package/dist/src/shared/mcp/typings/mcp-completion.interface.d.ts +43 -0
- package/dist/src/shared/mcp/typings/mcp-content-result.model.d.ts +9 -0
- package/dist/src/shared/mcp/typings/mcp-export-result.model.d.ts +11 -0
- package/dist/src/shared/mcp/typings/mcp-gc-result.model.d.ts +15 -0
- package/dist/src/shared/mcp/typings/mcp-integrity-check-result.model.d.ts +16 -0
- package/dist/src/shared/mcp/typings/mcp-integrity-error.model.d.ts +9 -0
- package/dist/src/shared/mcp/typings/mcp-notification.interface.d.ts +9 -0
- package/dist/src/shared/mcp/typings/mcp-rebuild-result.model.d.ts +9 -0
- package/dist/src/shared/mcp/typings/mcp-request.interface.d.ts +11 -0
- package/dist/src/shared/mcp/typings/mcp-resource-result.interface.d.ts +12 -0
- package/dist/src/shared/mcp/typings/mcp-resource-template.interface.d.ts +11 -0
- package/dist/src/shared/mcp/typings/mcp-response.interface.d.ts +18 -0
- package/dist/src/shared/mcp/typings/mcp-server-info.interface.d.ts +7 -0
- package/dist/src/shared/mcp/typings/mcp-server-state.interface.d.ts +16 -0
- package/dist/src/shared/mcp/typings/mcp-tool-annotations.interface.d.ts +32 -0
- package/dist/src/shared/mcp/typings/mcp-tool-definition.interface.d.ts +15 -0
- package/dist/src/shared/mcp/typings/mcp-tool-result.interface.d.ts +19 -0
- package/dist/src/shared/mcp/typings/mcp-worker-client.interface.d.ts +220 -0
- package/dist/src/shared/mcp/typings/tool-call-result.model.d.ts +17 -0
- package/dist/src/shared/sync/functions/build-import-report.function.d.ts +18 -0
- package/dist/src/shared/sync/functions/parse-export-entry.function.d.ts +11 -0
- package/dist/src/shared/sync/functions/resolve-conflict.function.d.ts +13 -0
- package/dist/src/shared/sync/functions/serialize-export-entry.function.d.ts +8 -0
- package/dist/src/shared/sync/index.d.ts +9 -0
- package/dist/src/shared/sync/typings/conflict-resolution.type.d.ts +8 -0
- package/dist/src/shared/sync/typings/export-entry.interface.d.ts +13 -0
- package/dist/src/shared/sync/typings/export-options.interface.d.ts +9 -0
- package/dist/src/shared/sync/typings/import-options.interface.d.ts +7 -0
- package/dist/src/shared/sync/typings/import-report.interface.d.ts +15 -0
- package/dist/src/shared/wasm-codec/functions/decode-add-section-result.function.d.ts +48 -0
- package/dist/src/shared/wasm-codec/functions/decode-one-recall-result.function.d.ts +14 -0
- package/dist/src/shared/wasm-codec/functions/decode-option-string.function.d.ts +12 -0
- package/dist/src/shared/wasm-codec/functions/decode-recall-document.function.d.ts +14 -0
- package/dist/src/shared/wasm-codec/functions/decode-recall-reference.function.d.ts +14 -0
- package/dist/src/shared/wasm-codec/functions/decode-recall-sibling.function.d.ts +13 -0
- package/dist/src/shared/wasm-codec/functions/decode-scored-results.function.d.ts +58 -0
- package/dist/src/shared/wasm-codec/functions/decode-section-match.function.d.ts +15 -0
- package/dist/src/shared/wasm-codec/functions/decode-section-record-trailing.function.d.ts +14 -0
- package/dist/src/shared/wasm-codec/functions/decode-section-record.function.d.ts +14 -0
- package/dist/src/shared/wasm-codec/functions/decode-section-records.function.d.ts +33 -0
- package/dist/src/shared/wasm-codec/functions/decode-section-type.function.d.ts +13 -0
- package/dist/src/shared/wasm-codec/functions/decode-wasm-list.function.d.ts +17 -0
- package/dist/src/shared/wasm-codec/functions/encode-add-section-params.function.d.ts +52 -0
- package/dist/src/shared/wasm-codec/index.d.ts +2 -0
- package/dist/src/shared/wasm-codec/typings/add-section-input.model.d.ts +45 -0
- package/dist/src/shared/wasm-codec/typings/add-section-result.model.d.ts +27 -0
- package/dist/src/shared/wasm-codec/typings/document-manifest.model.d.ts +19 -0
- package/dist/src/shared/wasm-codec/typings/document-section.model.d.ts +12 -0
- package/dist/src/shared/wasm-codec/typings/item-decoder.type.d.ts +6 -0
- package/dist/src/shared/wasm-codec/typings/near-duplicate.model.d.ts +16 -0
- package/dist/src/shared/wasm-codec/typings/paged-search-result.model.d.ts +21 -0
- package/dist/src/shared/wasm-codec/typings/section-match.model.d.ts +31 -0
- package/dist/src/shared/wasm-codec/typings/section-record-trailing.model.d.ts +38 -0
- package/dist/src/shared/wasm-codec/typings/section-record.model.d.ts +66 -0
- package/dist/src/shared/wasm-codec/typings/section-type-result.model.d.ts +12 -0
- package/dist/src/shared/worker-client/classes/worker-client.class.d.ts +16 -0
- package/dist/src/shared/worker-client/functions/handle-ipc-data.function.d.ts +16 -0
- package/dist/src/shared/worker-client/functions/send-ipc-request.function.d.ts +19 -0
- package/dist/src/shared/worker-client/index.d.ts +1 -1
- package/dist/src/shared/worker-client/typings/add-section-result.model.d.ts +31 -15
- package/dist/src/shared/worker-client/typings/export-result.model.d.ts +14 -0
- package/dist/src/shared/worker-client/typings/gc-result.model.d.ts +6 -0
- package/dist/src/shared/worker-client/typings/json-rpc-response.interface.d.ts +16 -0
- package/dist/src/shared/worker-client/typings/pending-call.interface.d.ts +7 -0
- package/dist/src/shared/worker-client/typings/recall-document.model.d.ts +16 -0
- package/dist/src/shared/worker-client/typings/recall-params.model.d.ts +15 -0
- package/dist/src/shared/worker-client/typings/recall-reference.model.d.ts +32 -0
- package/dist/src/shared/worker-client/typings/recall-sibling.model.d.ts +11 -0
- package/dist/src/shared/worker-client/typings/recall-single-result.model.d.ts +40 -0
- package/dist/src/shared/worker-client/typings/search-result.model.d.ts +12 -0
- package/dist/src/shared/worker-client/typings/section.model.d.ts +16 -0
- package/dist/src/shared/worker-daemon/classes/ipc-error.class.d.ts +17 -0
- package/dist/src/shared/worker-daemon/classes/worker-daemon.class.d.ts +35 -0
- package/dist/src/shared/worker-daemon/constants/wasm-method-map.constant.d.ts +16 -0
- package/dist/src/shared/worker-daemon/functions/build-ipc-error-response.function.d.ts +9 -0
- package/dist/src/shared/worker-daemon/functions/check-catalog-version.function.d.ts +9 -0
- package/dist/src/shared/worker-daemon/functions/check-preconditions.function.d.ts +10 -0
- package/dist/src/shared/worker-daemon/functions/detect-stale-pid.function.d.ts +15 -0
- package/dist/src/shared/worker-daemon/functions/dispatch-request.function.d.ts +35 -0
- package/dist/src/shared/worker-daemon/functions/handle-check-version.function.d.ts +23 -0
- package/dist/src/shared/worker-daemon/functions/handle-config-method.function.d.ts +11 -0
- package/dist/src/shared/worker-daemon/functions/handle-read-ops.function.d.ts +52 -0
- package/dist/src/shared/worker-daemon/functions/handle-write-ops.function.d.ts +44 -0
- package/dist/src/shared/worker-daemon/functions/parse-auto-capture-section.function.d.ts +14 -0
- package/dist/src/shared/worker-daemon/functions/parse-catalog-version.function.d.ts +10 -0
- package/dist/src/shared/worker-daemon/functions/parse-embedding-section.function.d.ts +13 -0
- package/dist/src/shared/worker-daemon/functions/parse-worker-toml.function.d.ts +11 -0
- package/dist/src/shared/worker-daemon/functions/run-startup-integrity-check.function.d.ts +18 -0
- package/dist/src/shared/worker-daemon/functions/scan-near-duplicates.function.d.ts +21 -0
- package/dist/src/shared/worker-daemon/functions/wasm-bridge.function.d.ts +51 -0
- package/dist/src/shared/worker-daemon/functions/wasm-memory-helpers.function.d.ts +22 -0
- package/dist/src/shared/worker-daemon/functions/write-lock.function.d.ts +32 -0
- package/dist/src/shared/worker-daemon/typings/allocator-ref.interface.d.ts +16 -0
- package/dist/src/shared/worker-daemon/typings/daemon-config.interface.d.ts +6 -0
- package/dist/src/shared/worker-daemon/typings/fs-adapter.interface.d.ts +22 -0
- package/dist/src/shared/worker-daemon/typings/handler-context.interface.d.ts +18 -0
- package/dist/src/shared/worker-daemon/typings/memory-ref.interface.d.ts +13 -0
- package/dist/src/shared/worker-daemon/typings/wasm-fn.type.d.ts +2 -0
- package/dist/src/shared/worker-daemon/typings/write-lock.interface.d.ts +15 -0
- package/dist/wasm/fs-database/kbdb_fs_database.d.ts +22 -1
- package/dist/wasm/fs-database/kbdb_fs_database.js +28 -1
- package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
- package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm.d.ts +1 -0
- package/dist/wasm/kb-worker/kbdb_worker.d.ts +48 -1
- package/dist/wasm/kb-worker/kbdb_worker.js +60 -1
- package/dist/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
- package/dist/wasm/kb-worker/kbdb_worker_bg.wasm.d.ts +2 -0
- package/dist/wasm/query-parser/kbdb_query_parser_bg.wasm +0 -0
- package/dist/worker.mjs +396 -60
- package/dist/worker.mjs.map +4 -4
- package/docs/details/cli.md +102 -15
- package/docs/details/library-api.md +55 -6
- package/docs/details/mcp-server.md +10 -4
- package/docs/details/search-and-ranking.md +63 -5
- package/docs/details/storage.md +2 -0
- package/docs/goals/auto-capture.md +378 -0
- package/docs/goals/benchmarking.md +296 -0
- package/docs/goals/cli.md +255 -14
- package/docs/goals/concurrency.md +259 -0
- package/docs/goals/database.md +244 -17
- package/docs/goals/document.md +1 -1
- package/docs/goals/hybrid-search.md +436 -0
- package/docs/goals/mcp.md +83 -14
- package/docs/goals/query-parser.md +98 -4
- package/docs/goals/query-result.md +177 -10
- package/docs/goals/semantic-dedup.md +229 -0
- package/docs/goals/skills.md +72 -0
- package/docs/goals/sync.md +217 -0
- package/docs/goals/worker-daemon.md +54 -7
- package/docs/modules/rust/fs-database/functions/integrity.md +11 -0
- package/docs/modules/rust/fs-database/functions/section.md +23 -6
- package/docs/modules/rust/fs-database/indexes/vectors.md +110 -0
- package/docs/modules/rust/fs-database/module.md +1 -0
- package/docs/modules/rust/fs-database/types/section.md +27 -1
- package/docs/modules/rust/overview.md +2 -1
- package/docs/modules/rust/query-parser/functions/module.md +2 -2
- package/docs/modules/rust/query-parser/functions/pipeline.md +44 -6
- package/docs/modules/rust/query-parser/module.md +5 -4
- package/docs/modules/rust/query-parser/types/keyphrase.md +11 -0
- package/docs/modules/rust/query-parser/types/module.md +3 -3
- package/docs/modules/typescript/shared/auto-capture/module.md +73 -0
- package/docs/modules/typescript/shared/cli/functions.md +68 -3
- package/docs/modules/typescript/shared/embedding/functions.md +94 -0
- package/docs/modules/typescript/shared/embedding/module.md +71 -0
- package/docs/modules/typescript/shared/embedding/typings.md +122 -0
- package/docs/overview.md +148 -166
- package/docs/release-notes/0.2.0.md +3 -3
- package/docs/release-notes/0.3.0.md +89 -0
- package/docs/release-notes/0.3.1.md +111 -0
- package/docs/release-notes/README.md +2 -0
- package/package.json +1 -1
- package/src/shared/auto-capture/classes/auto-capture-controller.class.ts +62 -0
- package/src/shared/auto-capture/constants/auto-capture-defaults.constant.ts +15 -0
- package/src/shared/auto-capture/functions/build-capture-prompt.function.ts +27 -0
- package/src/shared/auto-capture/functions/evaluate-trigger.function.ts +50 -0
- package/src/shared/auto-capture/index.ts +7 -0
- package/src/shared/auto-capture/typings/auto-capture-config.interface.ts +13 -0
- package/src/shared/auto-capture/typings/auto-capture-state.interface.ts +13 -0
- package/src/shared/auto-capture/typings/auto-capture-trigger.interface.ts +7 -0
- package/src/shared/cli/constants/global-help.constant.ts +73 -0
- package/src/shared/cli/constants/leaf-help.constant.ts +219 -0
- package/src/shared/cli/constants/memory-protocol-body.constant.ts +39 -0
- package/src/shared/cli/constants/query-guidance-body.constant.ts +37 -0
- package/src/shared/cli/constants/subcommand-help.constant.ts +195 -0
- package/src/shared/cli/functions/collect-files.function.ts +55 -0
- package/src/shared/cli/functions/compute-section-kbid.function.ts +49 -0
- package/src/shared/cli/functions/dispatch-command.function.ts +53 -1
- package/src/shared/cli/functions/format-mcp-output.function.ts +41 -0
- package/src/shared/cli/functions/format-output.function.ts +36 -12
- package/src/shared/cli/functions/format-text-output.function.ts +42 -0
- package/src/shared/cli/functions/generate-group-help.function.ts +41 -0
- package/src/shared/cli/functions/generate-help.function.ts +56 -1
- package/src/shared/cli/functions/handle-data-command.function.ts +67 -0
- package/src/shared/cli/functions/handle-mcp.function.ts +56 -0
- package/src/shared/cli/functions/handle-migrate.function.ts +64 -0
- package/src/shared/cli/functions/hydrate-search-previews.function.ts +29 -0
- package/src/shared/cli/functions/install-default-skills.function.ts +296 -0
- package/src/shared/cli/functions/parse-args.function.ts +16 -0
- package/src/shared/cli/functions/resolve-skill-names.function.ts +43 -0
- package/src/shared/cli/functions/run-check.function.ts +87 -6
- package/src/shared/cli/functions/run-export.function.ts +40 -0
- package/src/shared/cli/functions/run-gc.function.ts +6 -0
- package/src/shared/cli/functions/run-init.function.ts +2 -0
- package/src/shared/cli/functions/run-learn.function.ts +68 -16
- package/src/shared/cli/functions/run-recall.function.ts +66 -0
- package/src/shared/cli/functions/run-search.function.ts +60 -15
- package/src/shared/cli/functions/version-gate.function.ts +44 -0
- package/src/shared/cli/functions/wrap-command.function.ts +34 -0
- package/src/shared/cli/index.ts +4 -0
- package/src/shared/cli/typings/agent-create-client.interface.ts +47 -0
- package/src/shared/cli/typings/agent-get-client.interface.ts +39 -0
- package/src/shared/cli/typings/check-client.interface.ts +66 -0
- package/src/shared/cli/typings/cli-deps.interface.ts +54 -0
- package/src/shared/cli/typings/cli-options.interface.ts +15 -0
- package/src/shared/cli/typings/disconnectable-client.interface.ts +29 -0
- package/src/shared/cli/typings/dispatch-client.type.ts +46 -0
- package/src/shared/cli/typings/learn-client.interface.ts +53 -0
- package/src/shared/cli/typings/learn-io.interface.ts +5 -0
- package/src/shared/cli/typings/learn-result.model.ts +16 -0
- package/src/shared/cli/typings/search-client.interface.ts +73 -0
- package/src/shared/cli/typings/search-display.model.ts +18 -0
- package/src/shared/embedding/classes/null-embedding-provider.class.ts +29 -0
- package/src/shared/embedding/constants/near-duplicate-thresholds.constant.ts +17 -0
- package/src/shared/embedding/functions/build-vector-index.function.ts +79 -0
- package/src/shared/embedding/functions/cosine-similarity.function.ts +31 -0
- package/src/shared/embedding/functions/detect-near-duplicates.function.ts +69 -0
- package/src/shared/embedding/functions/jaccard-coefficient.function.ts +26 -0
- package/src/shared/embedding/functions/read-vector-index-meta.function.ts +44 -0
- package/src/shared/embedding/functions/rrf-fuse.function.ts +33 -0
- package/src/shared/embedding/functions/search-vectors.function.ts +59 -0
- package/src/shared/embedding/index.ts +20 -0
- package/src/shared/embedding/typings/embedding-config.interface.ts +23 -0
- package/src/shared/embedding/typings/embedding-provider.interface.ts +25 -0
- package/src/shared/embedding/typings/near-duplicate-candidate.model.ts +25 -0
- package/src/shared/embedding/typings/near-duplicate-result.model.ts +26 -0
- package/src/shared/embedding/typings/vector-index-entry.model.ts +13 -0
- package/src/shared/embedding/typings/vector-index-meta.model.ts +14 -0
- package/src/shared/embedding/typings/vector-search-result.model.ts +8 -0
- package/src/shared/mcp/classes/mcp-server.class.ts +36 -4
- package/src/shared/mcp/constants/tool-agent-create.constant.ts +39 -0
- package/src/shared/mcp/constants/tool-agent-delete.constant.ts +26 -0
- package/src/shared/mcp/constants/tool-agent-get.constant.ts +24 -0
- package/src/shared/mcp/constants/tool-agent-list.constant.ts +18 -0
- package/src/shared/mcp/constants/tool-auto-capture-review.constant.ts +32 -0
- package/src/shared/mcp/constants/tool-check.constant.ts +21 -0
- package/src/shared/mcp/constants/tool-content.constant.ts +29 -0
- package/src/shared/mcp/constants/tool-export.constant.ts +27 -0
- package/src/shared/mcp/constants/tool-gc.constant.ts +21 -0
- package/src/shared/mcp/constants/tool-learn.constant.ts +58 -0
- package/src/shared/mcp/constants/tool-rebuild.constant.ts +21 -0
- package/src/shared/mcp/constants/tool-recall.constant.ts +36 -0
- package/src/shared/mcp/constants/tool-retrieve.constant.ts +31 -0
- package/src/shared/mcp/constants/tool-search.constant.ts +51 -0
- package/src/shared/mcp/constants/tool-skill-delete.constant.ts +24 -0
- package/src/shared/mcp/constants/tool-skill-get.constant.ts +27 -0
- package/src/shared/mcp/constants/tool-skill-learn.constant.ts +37 -0
- package/src/shared/mcp/constants/tool-skill-list.constant.ts +18 -0
- package/src/shared/mcp/constants/tool-status.constant.ts +20 -0
- package/src/shared/mcp/constants/tool-unlearn.constant.ts +25 -0
- package/src/shared/mcp/functions/as-boolean-or-undefined.function.ts +11 -0
- package/src/shared/mcp/functions/as-string-array-or-undefined.function.ts +17 -0
- package/src/shared/mcp/functions/as-string-array.function.ts +15 -0
- package/src/shared/mcp/functions/as-string.function.ts +10 -0
- package/src/shared/mcp/functions/build-skills-text.function.ts +43 -0
- package/src/shared/mcp/functions/create-tool-definitions.function.ts +74 -5
- package/src/shared/mcp/functions/handle-agent-create.function.ts +1 -1
- package/src/shared/mcp/functions/handle-agent-prompt.function.ts +68 -0
- package/src/shared/mcp/functions/handle-mcp-request.function.ts +202 -0
- package/src/shared/mcp/functions/handle-prompt-get.function.ts +18 -12
- package/src/shared/mcp/functions/handle-skill-prompt.function.ts +44 -0
- package/src/shared/mcp/functions/handle-tool-auto-capture-review.function.ts +24 -0
- package/src/shared/mcp/functions/handle-tool-call.function.ts +88 -2
- package/src/shared/mcp/functions/handle-tool-check.function.ts +21 -0
- package/src/shared/mcp/functions/handle-tool-content.function.ts +23 -0
- package/src/shared/mcp/functions/handle-tool-export.function.ts +25 -0
- package/src/shared/mcp/functions/handle-tool-gc.function.ts +21 -0
- package/src/shared/mcp/functions/handle-tool-learn.function.ts +69 -0
- package/src/shared/mcp/functions/handle-tool-rebuild.function.ts +21 -0
- package/src/shared/mcp/functions/handle-tool-retrieve.function.ts +40 -0
- package/src/shared/mcp/functions/handle-tool-search.function.ts +47 -0
- package/src/shared/mcp/functions/handle-tool-skill-delete.function.ts +34 -0
- package/src/shared/mcp/functions/handle-tool-skill-get.function.ts +59 -0
- package/src/shared/mcp/functions/handle-tool-skill-learn.function.ts +61 -0
- package/src/shared/mcp/functions/handle-tool-skill-list.function.ts +39 -0
- package/src/shared/mcp/functions/handle-tool-status.function.ts +21 -0
- package/src/shared/mcp/functions/handle-tool-unlearn.function.ts +24 -0
- package/src/shared/mcp/functions/parse-agent-meta.function.ts +27 -0
- package/src/shared/mcp/functions/parse-skill-arguments.function.ts +36 -0
- package/src/shared/mcp/functions/read-agent-meta.function.ts +41 -0
- package/src/shared/mcp/functions/resolve-skill-refs.function.ts +50 -0
- package/src/shared/mcp/functions/run-startup-health-check.function.ts +34 -0
- package/src/shared/mcp/typings/mcp-capabilities.interface.ts +16 -0
- package/src/shared/mcp/typings/mcp-client.interface.ts +47 -0
- package/src/shared/mcp/typings/mcp-completion.interface.ts +45 -0
- package/src/shared/mcp/typings/mcp-content-result.model.ts +9 -0
- package/src/shared/mcp/typings/mcp-export-result.model.ts +11 -0
- package/src/shared/mcp/typings/mcp-gc-result.model.ts +15 -0
- package/src/shared/mcp/typings/mcp-integrity-check-result.model.ts +17 -0
- package/src/shared/mcp/typings/mcp-integrity-error.model.ts +15 -0
- package/src/shared/mcp/typings/mcp-notification.interface.ts +9 -0
- package/src/shared/mcp/typings/mcp-rebuild-result.model.ts +9 -0
- package/src/shared/mcp/typings/mcp-request.interface.ts +11 -0
- package/src/shared/mcp/typings/mcp-resource-result.interface.ts +12 -0
- package/src/shared/mcp/typings/mcp-resource-template.interface.ts +11 -0
- package/src/shared/mcp/typings/mcp-response.interface.ts +18 -0
- package/src/shared/mcp/typings/mcp-server-info.interface.ts +7 -0
- package/src/shared/mcp/typings/mcp-server-state.interface.ts +17 -0
- package/src/shared/mcp/typings/mcp-tool-annotations.interface.ts +32 -0
- package/src/shared/mcp/typings/mcp-tool-definition.interface.ts +16 -0
- package/src/shared/mcp/typings/mcp-tool-result.interface.ts +19 -0
- package/src/shared/mcp/typings/mcp-worker-client.interface.ts +243 -0
- package/src/shared/mcp/typings/tool-call-result.model.ts +18 -0
- package/src/shared/sync/functions/build-import-report.function.ts +40 -0
- package/src/shared/sync/functions/parse-export-entry.function.ts +45 -0
- package/src/shared/sync/functions/resolve-conflict.function.ts +31 -0
- package/src/shared/sync/functions/serialize-export-entry.function.ts +18 -0
- package/src/shared/sync/index.ts +9 -0
- package/src/shared/sync/typings/conflict-resolution.type.ts +8 -0
- package/src/shared/sync/typings/export-entry.interface.ts +13 -0
- package/src/shared/sync/typings/export-options.interface.ts +9 -0
- package/src/shared/sync/typings/import-options.interface.ts +7 -0
- package/src/shared/sync/typings/import-report.interface.ts +15 -0
- package/src/shared/wasm-codec/functions/decode-add-section-result.function.ts +112 -0
- package/src/shared/wasm-codec/functions/decode-one-recall-result.function.ts +86 -0
- package/src/shared/wasm-codec/functions/decode-option-string.function.ts +24 -0
- package/src/shared/wasm-codec/functions/decode-recall-document.function.ts +59 -0
- package/src/shared/wasm-codec/functions/decode-recall-reference.function.ts +52 -0
- package/src/shared/wasm-codec/functions/decode-recall-sibling.function.ts +43 -0
- package/src/shared/wasm-codec/functions/decode-scored-results.function.ts +86 -0
- package/src/shared/wasm-codec/functions/decode-section-match.function.ts +80 -0
- package/src/shared/wasm-codec/functions/decode-section-record-trailing.function.ts +75 -0
- package/src/shared/wasm-codec/functions/decode-section-record.function.ts +85 -0
- package/src/shared/wasm-codec/functions/decode-section-records.function.ts +87 -0
- package/src/shared/wasm-codec/functions/decode-section-type.function.ts +30 -0
- package/src/shared/wasm-codec/functions/decode-wasm-list.function.ts +31 -0
- package/src/shared/wasm-codec/functions/encode-add-section-params.function.ts +68 -0
- package/src/shared/wasm-codec/index.ts +5 -0
- package/src/shared/wasm-codec/typings/add-section-input.model.ts +45 -0
- package/src/shared/wasm-codec/typings/add-section-result.model.ts +28 -0
- package/src/shared/wasm-codec/typings/document-manifest.model.ts +20 -0
- package/src/shared/wasm-codec/typings/document-section.model.ts +12 -0
- package/src/shared/wasm-codec/typings/item-decoder.type.ts +10 -0
- package/src/shared/wasm-codec/typings/near-duplicate.model.ts +16 -0
- package/src/shared/wasm-codec/typings/paged-search-result.model.ts +22 -0
- package/src/shared/wasm-codec/typings/section-match.model.ts +31 -0
- package/src/shared/wasm-codec/typings/section-record-trailing.model.ts +38 -0
- package/src/shared/wasm-codec/typings/section-record.model.ts +66 -0
- package/src/shared/wasm-codec/typings/section-type-result.model.ts +12 -0
- package/src/shared/worker-client/classes/worker-client.class.ts +19 -0
- package/src/shared/worker-client/functions/handle-ipc-data.function.ts +49 -0
- package/src/shared/worker-client/functions/send-ipc-request.function.ts +39 -0
- package/src/shared/worker-client/index.ts +4 -1
- package/src/shared/worker-client/typings/add-section-result.model.ts +32 -15
- package/src/shared/worker-client/typings/export-result.model.ts +14 -0
- package/src/shared/worker-client/typings/gc-result.model.ts +6 -0
- package/src/shared/worker-client/typings/json-rpc-response.interface.ts +17 -0
- package/src/shared/worker-client/typings/pending-call.interface.ts +7 -0
- package/src/shared/worker-client/typings/recall-document.model.ts +16 -0
- package/src/shared/worker-client/typings/recall-params.model.ts +15 -0
- package/src/shared/worker-client/typings/recall-reference.model.ts +32 -0
- package/src/shared/worker-client/typings/recall-sibling.model.ts +11 -0
- package/src/shared/worker-client/typings/recall-single-result.model.ts +41 -0
- package/src/shared/worker-client/typings/search-result.model.ts +12 -0
- package/src/shared/worker-client/typings/section.model.ts +16 -0
- package/src/shared/worker-daemon/classes/ipc-error.class.ts +22 -0
- package/src/shared/worker-daemon/classes/worker-daemon.class.ts +315 -46
- package/src/shared/worker-daemon/constants/wasm-method-map.constant.ts +69 -0
- package/src/shared/worker-daemon/functions/build-ipc-error-response.function.ts +16 -0
- package/src/shared/worker-daemon/functions/check-catalog-version.function.ts +54 -0
- package/src/shared/worker-daemon/functions/check-preconditions.function.ts +28 -0
- package/src/shared/worker-daemon/functions/create-host-imports.function.ts +19 -4
- package/src/shared/worker-daemon/functions/create-ipc-server.function.ts +5 -1
- package/src/shared/worker-daemon/functions/detect-stale-pid.function.ts +33 -0
- package/src/shared/worker-daemon/functions/dispatch-request.function.ts +190 -0
- package/src/shared/worker-daemon/functions/handle-check-version.function.ts +74 -0
- package/src/shared/worker-daemon/functions/handle-config-method.function.ts +27 -0
- package/src/shared/worker-daemon/functions/handle-read-ops.function.ts +236 -0
- package/src/shared/worker-daemon/functions/handle-write-ops.function.ts +257 -0
- package/src/shared/worker-daemon/functions/parse-auto-capture-section.function.ts +51 -0
- package/src/shared/worker-daemon/functions/parse-catalog-version.function.ts +20 -0
- package/src/shared/worker-daemon/functions/parse-embedding-section.function.ts +38 -0
- package/src/shared/worker-daemon/functions/parse-worker-toml.function.ts +104 -0
- package/src/shared/worker-daemon/functions/run-startup-integrity-check.function.ts +55 -0
- package/src/shared/worker-daemon/functions/scan-near-duplicates.function.ts +92 -0
- package/src/shared/worker-daemon/functions/wasm-bridge.function.ts +144 -0
- package/src/shared/worker-daemon/functions/wasm-memory-helpers.function.ts +41 -0
- package/src/shared/worker-daemon/functions/write-lock.function.ts +49 -0
- package/src/shared/worker-daemon/typings/allocator-ref.interface.ts +16 -0
- package/src/shared/worker-daemon/typings/daemon-config.interface.ts +7 -0
- package/src/shared/worker-daemon/typings/fs-adapter.interface.ts +22 -0
- package/src/shared/worker-daemon/typings/handler-context.interface.ts +19 -0
- package/src/shared/worker-daemon/typings/memory-ref.interface.ts +13 -0
- package/src/shared/worker-daemon/typings/wasm-fn.type.ts +2 -0
- package/src/shared/worker-daemon/typings/write-lock.interface.ts +13 -0
- package/src/wasm/fs-database/kbdb_fs_database.d.ts +22 -1
- package/src/wasm/fs-database/kbdb_fs_database.js +28 -1
- package/src/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
- package/src/wasm/fs-database/kbdb_fs_database_bg.wasm.d.ts +1 -0
- package/src/wasm/kb-worker/kbdb_worker.d.ts +48 -1
- package/src/wasm/kb-worker/kbdb_worker.js +60 -1
- package/src/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
- package/src/wasm/kb-worker/kbdb_worker_bg.wasm.d.ts +2 -0
- package/src/wasm/query-parser/kbdb_query_parser_bg.wasm +0 -0
package/docs/goals/database.md
CHANGED
|
@@ -278,6 +278,40 @@ for storage. They are pre-computed once at insertion
|
|
|
278
278
|
time and reused on every search -- trading a small
|
|
279
279
|
write-time cost for significant query-time speed.
|
|
280
280
|
|
|
281
|
+
Additional metadata fields support truth maintenance
|
|
282
|
+
and provenance tracking:
|
|
283
|
+
|
|
284
|
+
- **`source_key`** -- Logical identity hash (16
|
|
285
|
+
lowercase hex characters). Derived from the source
|
|
286
|
+
file path and heading text:
|
|
287
|
+
`sha256("${source_path}\0${heading}")[..8]`. Used
|
|
288
|
+
for supersession -- matching existing sections when
|
|
289
|
+
content is re-learned. `null` for stdin input and
|
|
290
|
+
sections without a source path. See **Logical
|
|
291
|
+
Identity (Source Key)** below.
|
|
292
|
+
- **`source_path`** -- Absolute path of the file that
|
|
293
|
+
was learned. `null` for stdin input and
|
|
294
|
+
programmatic API calls. Stored for provenance
|
|
295
|
+
tracking and source-aware garbage collection.
|
|
296
|
+
- **`source_mtime`** -- ISO 8601 timestamp of the
|
|
297
|
+
source file's last modification time at learn time.
|
|
298
|
+
`null` when no source file exists. Allows staleness
|
|
299
|
+
detection: if the source file's mtime has changed
|
|
300
|
+
since this timestamp, the section may be outdated.
|
|
301
|
+
- **`updated_at`** -- ISO 8601 timestamp of the last
|
|
302
|
+
supersession. `null` on first creation. Set when a
|
|
303
|
+
section supersedes an existing one with the same
|
|
304
|
+
source key.
|
|
305
|
+
- **`tags`** -- Array of user-supplied string tags for
|
|
306
|
+
scoping and filtering. Empty array when no tags are
|
|
307
|
+
provided. Tags are not indexed for search -- they
|
|
308
|
+
are metadata for query-time filtering.
|
|
309
|
+
- **`supersedes`** -- The kbid of the section this one
|
|
310
|
+
replaced via supersession. `null` on first creation
|
|
311
|
+
and for non-superseding additions. Creates a
|
|
312
|
+
supersession chain that can be traversed to find
|
|
313
|
+
prior versions.
|
|
314
|
+
|
|
281
315
|
The `add_section` operation rejects requests with
|
|
282
316
|
`image/*` type that do not include a `title`. Text
|
|
283
317
|
and code sections may omit both fields.
|
|
@@ -322,6 +356,12 @@ body_token_count = 187
|
|
|
322
356
|
code_token_count = 0
|
|
323
357
|
created_at = "2026-06-15T10:00:00Z"
|
|
324
358
|
checksum = "sha256:abcdef..."
|
|
359
|
+
source_key = "a1b2c3d4e5f67890"
|
|
360
|
+
source_path = "/home/user/docs/architecture.md"
|
|
361
|
+
source_mtime = "2026-06-15T09:45:00Z"
|
|
362
|
+
updated_at = ""
|
|
363
|
+
tags = ["architecture", "overview"]
|
|
364
|
+
supersedes = ""
|
|
325
365
|
---
|
|
326
366
|
Section body text here.
|
|
327
367
|
|
|
@@ -347,6 +387,12 @@ body_token_count = 0
|
|
|
347
387
|
code_token_count = 22
|
|
348
388
|
created_at = "2026-06-15T10:15:00Z"
|
|
349
389
|
checksum = "sha256:1a2b3c..."
|
|
390
|
+
source_key = "f8e7d6c5b4a39281"
|
|
391
|
+
source_path = "/home/user/src/greet.ts"
|
|
392
|
+
source_mtime = "2026-06-15T10:10:00Z"
|
|
393
|
+
updated_at = ""
|
|
394
|
+
tags = ["api", "greeting"]
|
|
395
|
+
supersedes = ""
|
|
350
396
|
---
|
|
351
397
|
export function greet(name: string): string {
|
|
352
398
|
return `Hello, ${name}!`;
|
|
@@ -368,6 +414,12 @@ body_token_count = 3
|
|
|
368
414
|
code_token_count = 0
|
|
369
415
|
created_at = "2026-06-15T10:30:00Z"
|
|
370
416
|
checksum = "sha256:fedcba..."
|
|
417
|
+
source_key = "1029384756abcdef"
|
|
418
|
+
source_path = "/home/user/docs/arch-diagram.png"
|
|
419
|
+
source_mtime = "2026-06-15T10:25:00Z"
|
|
420
|
+
updated_at = ""
|
|
421
|
+
tags = ["diagram", "architecture"]
|
|
422
|
+
supersedes = ""
|
|
371
423
|
---
|
|
372
424
|
iVBORw0KGgoAAAANSUhEUgAA...base64 data...
|
|
373
425
|
```
|
|
@@ -463,6 +515,48 @@ Updating a section's content creates a new file with
|
|
|
463
515
|
a new kbid; the old file is eligible for garbage
|
|
464
516
|
collection.
|
|
465
517
|
|
|
518
|
+
#### Logical Identity (Source Key)
|
|
519
|
+
|
|
520
|
+
Content-addressing identifies *what a section
|
|
521
|
+
currently says*. The **source key** identifies *what
|
|
522
|
+
a section is about* -- it is a stable logical
|
|
523
|
+
identity that persists across content edits.
|
|
524
|
+
|
|
525
|
+
The source key is derived from the section's origin:
|
|
526
|
+
|
|
527
|
+
```
|
|
528
|
+
source_key = sha256("${source_path}\0${heading}")[..8]
|
|
529
|
+
→ 16 lowercase hex characters
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
- `source_path` -- the absolute path of the file that
|
|
533
|
+
was learned (normalized: resolved symlinks, no
|
|
534
|
+
trailing separator).
|
|
535
|
+
- `heading` -- the section's title text (or empty
|
|
536
|
+
string when no title is provided).
|
|
537
|
+
- `\0` -- a null byte separator.
|
|
538
|
+
|
|
539
|
+
The SHA-256 digest is truncated to 8 bytes (64 bits)
|
|
540
|
+
and hex-encoded to produce a 16-character identifier.
|
|
541
|
+
|
|
542
|
+
Source keys enable **supersession**: when content is
|
|
543
|
+
re-learned from the same source with the same
|
|
544
|
+
heading, the system can identify the existing section
|
|
545
|
+
and replace it rather than creating a sibling. This
|
|
546
|
+
prevents the brain from silently accumulating
|
|
547
|
+
contradictions when facts are corrected.
|
|
548
|
+
|
|
549
|
+
Source key is `null` for:
|
|
550
|
+
- Stdin input (`-`) -- no source path exists.
|
|
551
|
+
- Sections created without a source path (e.g.
|
|
552
|
+
programmatic API calls that omit it).
|
|
553
|
+
|
|
554
|
+
When `source_key` is `null`, supersession is not
|
|
555
|
+
available and the section behaves as a pure
|
|
556
|
+
content-addressed entry (current behavior).
|
|
557
|
+
|
|
558
|
+
See **Add section** below for supersession semantics.
|
|
559
|
+
|
|
466
560
|
### Documents (`documents/`)
|
|
467
561
|
|
|
468
562
|
One TOML file per document. A document groups sections
|
|
@@ -667,14 +761,15 @@ directly.
|
|
|
667
761
|
`fs-database.wasm`, which writes the TOML header
|
|
668
762
|
(kbid, docids, type, title, description, size,
|
|
669
763
|
token_count, heading_token_count, body_token_count,
|
|
670
|
-
code_token_count,
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
the
|
|
676
|
-
|
|
677
|
-
|
|
764
|
+
code_token_count, created_at, checksum, source_key,
|
|
765
|
+
source_path, source_mtime, updated_at, tags,
|
|
766
|
+
supersedes), the separator, and the content body
|
|
767
|
+
(preprocessed text for text and code sections,
|
|
768
|
+
base64 for image sections). Updates `catalog.toml`
|
|
769
|
+
counts. Updates the inverted index with per-field
|
|
770
|
+
term frequencies, the positional index with term
|
|
771
|
+
positions, and corpus statistics (including
|
|
772
|
+
per-field average lengths).
|
|
678
773
|
|
|
679
774
|
Image sections (`image/*` type) have their binary
|
|
680
775
|
content stored but not indexed. However, their
|
|
@@ -682,9 +777,50 @@ directly.
|
|
|
682
777
|
attributes are tokenized and indexed, making image
|
|
683
778
|
sections searchable via their metadata.
|
|
684
779
|
|
|
780
|
+
**Supersession:** When the `replace` flag is set
|
|
781
|
+
and the new section has a non-null `source_key`,
|
|
782
|
+
`fs-database.wasm` searches for an existing section
|
|
783
|
+
with the same `source_key`. If found:
|
|
784
|
+
|
|
785
|
+
- The new section's `supersedes` field is set to
|
|
786
|
+
the old section's kbid.
|
|
787
|
+
- The new section's `updated_at` is set to the
|
|
788
|
+
current timestamp.
|
|
789
|
+
- The old kbid is replaced with the new kbid in all
|
|
790
|
+
document manifests that reference it.
|
|
791
|
+
- The old section's `docids` array is emptied,
|
|
792
|
+
making it eligible for garbage collection.
|
|
793
|
+
- Index entries for the old section are removed and
|
|
794
|
+
replaced with entries for the new section.
|
|
795
|
+
|
|
796
|
+
When `replace` is not set, or `source_key` is
|
|
797
|
+
`null`, the add operation behaves as before (pure
|
|
798
|
+
content-addressed addition with deduplication).
|
|
799
|
+
|
|
800
|
+
**Near-duplicate detection:** After the kbid is
|
|
801
|
+
computed and deduplication is checked, the add
|
|
802
|
+
operation computes a Jaccard similarity coefficient
|
|
803
|
+
between the new section's stemmed term set and
|
|
804
|
+
existing sections' term sets. Sections exceeding a
|
|
805
|
+
similarity threshold of 0.85 are reported as
|
|
806
|
+
near-duplicates in the response
|
|
807
|
+
(`near_duplicates: [{kbid, similarity}]`). This is
|
|
808
|
+
advisory -- the section is still stored. The check
|
|
809
|
+
uses the inverted index for efficient comparison
|
|
810
|
+
without reading every section's content.
|
|
811
|
+
|
|
812
|
+
**Heading-less import warning:** Text and code
|
|
813
|
+
sections added without a `title` emit a warning in
|
|
814
|
+
the response: `heading_missing`. The heading field
|
|
815
|
+
carries 2.0x ranking weight; omitting it means the
|
|
816
|
+
section loses its strongest searchability signal.
|
|
817
|
+
The section is still stored -- this is a warning,
|
|
818
|
+
not an error.
|
|
819
|
+
|
|
685
820
|
**Validation:** requests with `image/*` type that
|
|
686
821
|
omit `title` are rejected with an error. Text and
|
|
687
|
-
code sections may omit `title
|
|
822
|
+
code sections may omit `title` (with the
|
|
823
|
+
heading-less warning above).
|
|
688
824
|
|
|
689
825
|
3. **Update section** -- Given a kb-id and new content,
|
|
690
826
|
replace the section's content. Since kb-ids are
|
|
@@ -795,12 +931,26 @@ directly.
|
|
|
795
931
|
sections (not referenced by any document),
|
|
796
932
|
orphaned documents (referencing missing sections),
|
|
797
933
|
broken embedding references -- markers whose
|
|
798
|
-
target does not exist or has the wrong type
|
|
934
|
+
target does not exist or has the wrong type,
|
|
799
935
|
circular reference chains in `$(text:)` and
|
|
800
|
-
`$(document:)` markers
|
|
936
|
+
`$(document:)` markers, and **divergent content**
|
|
937
|
+
-- multiple sections sharing the same `source_key`
|
|
938
|
+
(same origin) but with different content,
|
|
939
|
+
indicating contradictory knowledge that should
|
|
940
|
+
have been resolved by supersession.
|
|
801
941
|
13. **Garbage collection** -- Remove section files not
|
|
802
|
-
referenced by any document manifest.
|
|
803
|
-
|
|
942
|
+
referenced by any document manifest. Additionally
|
|
943
|
+
report `stale_sources` -- sections whose
|
|
944
|
+
`source_path` points to a file that no longer
|
|
945
|
+
contains their heading text. Stale sources are
|
|
946
|
+
advisory (not automatically removed) and surfaced
|
|
947
|
+
in the GC response for manual review.
|
|
948
|
+
14. **Export** -- Copy sections, documents, and
|
|
949
|
+
catalog to a self-contained output directory (no
|
|
950
|
+
indexes -- they are rebuildable). Provides a
|
|
951
|
+
portable, git-friendly snapshot of the knowledge
|
|
952
|
+
base for backup and versioning.
|
|
953
|
+
15. **Index rebuild** -- Reconstruct all index files
|
|
804
954
|
from sections and documents. Re-tokenizes all text
|
|
805
955
|
and code sections per field, recomputes per-field
|
|
806
956
|
term frequencies and token counts (updating
|
|
@@ -975,8 +1125,11 @@ Response per mode:
|
|
|
975
1125
|
"type": "text/markdown",
|
|
976
1126
|
"heading": "Section Heading",
|
|
977
1127
|
"score": 8.74,
|
|
1128
|
+
"confidence": 1.0,
|
|
978
1129
|
"snippet": "...matching context...",
|
|
979
|
-
"matched_terms": ["term1", "term2"]
|
|
1130
|
+
"matched_terms": ["term1", "term2"],
|
|
1131
|
+
"matched_fields": ["heading", "body"],
|
|
1132
|
+
"created_at": "2026-06-15T10:00:00Z"
|
|
980
1133
|
}
|
|
981
1134
|
],
|
|
982
1135
|
"total": 42,
|
|
@@ -1058,7 +1211,10 @@ Response per mode:
|
|
|
1058
1211
|
"type": "text/markdown",
|
|
1059
1212
|
"title": "Architecture Overview",
|
|
1060
1213
|
"description": "High-level overview",
|
|
1061
|
-
"docid": "<doc id>"
|
|
1214
|
+
"docid": "<doc id>",
|
|
1215
|
+
"source_path": "/home/user/docs/architecture.md",
|
|
1216
|
+
"tags": ["architecture", "overview"],
|
|
1217
|
+
"replace": false
|
|
1062
1218
|
}
|
|
1063
1219
|
|
|
1064
1220
|
// Response
|
|
@@ -1069,7 +1225,10 @@ Response per mode:
|
|
|
1069
1225
|
"description": "High-level overview",
|
|
1070
1226
|
"indexed_terms_count": 42,
|
|
1071
1227
|
"elapsed_ms": 15,
|
|
1072
|
-
"attached": false
|
|
1228
|
+
"attached": false,
|
|
1229
|
+
"superseded": null,
|
|
1230
|
+
"warnings": [],
|
|
1231
|
+
"near_duplicates": []
|
|
1073
1232
|
}
|
|
1074
1233
|
```
|
|
1075
1234
|
|
|
@@ -1302,6 +1461,10 @@ The integrity check verifies:
|
|
|
1302
1461
|
- **circular_reference** -- a `$(text:)` or
|
|
1303
1462
|
`$(document:)` marker chain loops back to an entity
|
|
1304
1463
|
already in the expansion path.
|
|
1464
|
+
- **divergent_content** -- two or more sections share
|
|
1465
|
+
the same `source_key` but have different content
|
|
1466
|
+
(different kbids). Indicates contradictory knowledge
|
|
1467
|
+
that should have been resolved by supersession.
|
|
1305
1468
|
|
|
1306
1469
|
When `ok` is `true`, the `errors` array is empty.
|
|
1307
1470
|
|
|
@@ -1315,6 +1478,7 @@ When `ok` is `true`, the `errors` array is empty.
|
|
|
1315
1478
|
{
|
|
1316
1479
|
"removed_sections": 3,
|
|
1317
1480
|
"removed_bytes": 15360,
|
|
1481
|
+
"stale_sources": 1,
|
|
1318
1482
|
"elapsed_ms": 25
|
|
1319
1483
|
}
|
|
1320
1484
|
```
|
|
@@ -1327,6 +1491,12 @@ remove documents, indexes, or the catalog. After
|
|
|
1327
1491
|
removal, all caches are invalidated to prevent stale
|
|
1328
1492
|
reads.
|
|
1329
1493
|
|
|
1494
|
+
`stale_sources` reports the number of sections whose
|
|
1495
|
+
`source_path` points to a file that no longer
|
|
1496
|
+
contains their heading text. These sections may be
|
|
1497
|
+
outdated but are not automatically removed -- they
|
|
1498
|
+
are reported for manual review.
|
|
1499
|
+
|
|
1330
1500
|
**Index rebuild:**
|
|
1331
1501
|
|
|
1332
1502
|
```json
|
|
@@ -1357,6 +1527,30 @@ entries). Equivalent to deleting `indexes/` and
|
|
|
1357
1527
|
re-adding every section. After rebuild, all caches
|
|
1358
1528
|
are invalidated.
|
|
1359
1529
|
|
|
1530
|
+
**Export:**
|
|
1531
|
+
|
|
1532
|
+
```json
|
|
1533
|
+
// Request
|
|
1534
|
+
{
|
|
1535
|
+
"path": "/home/user/backup/kbdb-export"
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
// Response
|
|
1539
|
+
{
|
|
1540
|
+
"path": "/home/user/backup/kbdb-export",
|
|
1541
|
+
"sections_exported": 42,
|
|
1542
|
+
"documents_exported": 5,
|
|
1543
|
+
"elapsed_ms": 120
|
|
1544
|
+
}
|
|
1545
|
+
```
|
|
1546
|
+
|
|
1547
|
+
Export copies sections, documents, and `catalog.toml`
|
|
1548
|
+
to the specified output directory. Indexes are not
|
|
1549
|
+
included -- they are derived data and can be rebuilt
|
|
1550
|
+
with `rebuild` after importing. The export directory
|
|
1551
|
+
is a self-contained, git-friendly snapshot suitable
|
|
1552
|
+
for backup, transfer, or version control.
|
|
1553
|
+
|
|
1360
1554
|
### Error Responses
|
|
1361
1555
|
|
|
1362
1556
|
Errors are returned as JSON-RPC 2.0 error objects:
|
|
@@ -1411,6 +1605,34 @@ See [Query Parser](query-parser.md) for full details.
|
|
|
1411
1605
|
| SHA-256 + Truncation + Base32 | SHA-256 of the typed header, truncated to 128 bits (16 bytes), base32 lowercase (no padding) -- 26 alphanumeric characters |
|
|
1412
1606
|
| Content Preprocessing | Text and code: BOM removal, `\r\n`/`\r` to `\n`, Unicode NFC, whitespace trimming. Images: base64 string used as-is |
|
|
1413
1607
|
|
|
1608
|
+
## Concurrent Write Behavior
|
|
1609
|
+
|
|
1610
|
+
The daemon serializes all write operations through a
|
|
1611
|
+
**single-writer lock**. The lock is an exclusive file
|
|
1612
|
+
lock on `kbdb-{ctx}.lock` in the OS temporary
|
|
1613
|
+
directory, keyed to the same context ID used for the
|
|
1614
|
+
PID file and IPC socket.
|
|
1615
|
+
|
|
1616
|
+
- **Reads** proceed without acquiring the lock. The
|
|
1617
|
+
daemon serves concurrent read requests from
|
|
1618
|
+
multiple worker client connections.
|
|
1619
|
+
- **Writes** (add section, update section, remove
|
|
1620
|
+
section, group/remove document, garbage collection,
|
|
1621
|
+
index rebuild, export) acquire the lock before
|
|
1622
|
+
modifying any file. If another write is in progress,
|
|
1623
|
+
the request queues behind the lock.
|
|
1624
|
+
- The lock is released after each write operation
|
|
1625
|
+
completes, not held across multiple operations.
|
|
1626
|
+
- CLI invocations sharing the same daemon are
|
|
1627
|
+
serialized automatically.
|
|
1628
|
+
- Direct file access to `.kbdb` outside the daemon is
|
|
1629
|
+
not supported and may cause corruption. All
|
|
1630
|
+
mutations must go through the daemon's IPC API.
|
|
1631
|
+
|
|
1632
|
+
This model is equivalent to SQLite's default locking:
|
|
1633
|
+
one writer at a time, concurrent readers, no external
|
|
1634
|
+
coordination required.
|
|
1635
|
+
|
|
1414
1636
|
## Design Constraints
|
|
1415
1637
|
|
|
1416
1638
|
- `fs-database.wasm` is the sole owner of `.kbdb` I/O.
|
|
@@ -1423,6 +1645,10 @@ See [Query Parser](query-parser.md) for full details.
|
|
|
1423
1645
|
their content hash. `fs-database.wasm` never modifies
|
|
1424
1646
|
a section file in place -- updates produce new files
|
|
1425
1647
|
with new kb-ids.
|
|
1648
|
+
- Source keys are advisory logical identity. The
|
|
1649
|
+
content hash (kbid) remains the primary identifier.
|
|
1650
|
+
Supersession is opt-in via the `replace` flag --
|
|
1651
|
+
default learn behavior is unchanged.
|
|
1426
1652
|
- Indexes are derived data. They can be rebuilt entirely
|
|
1427
1653
|
from sections and document manifests. Loss of index
|
|
1428
1654
|
files is recoverable.
|
|
@@ -1437,7 +1663,8 @@ See [Query Parser](query-parser.md) for full details.
|
|
|
1437
1663
|
- No external database process or server dependency.
|
|
1438
1664
|
- The database must support concurrent read access from
|
|
1439
1665
|
multiple CLI invocations via the shared daemon without
|
|
1440
|
-
corruption.
|
|
1666
|
+
corruption. Write operations are serialized through
|
|
1667
|
+
the daemon's single-writer lock.
|
|
1441
1668
|
- Garbage collection of unreferenced sections is
|
|
1442
1669
|
`fs-database.wasm`'s responsibility. Sections not
|
|
1443
1670
|
listed in any document manifest may be removed.
|
package/docs/goals/document.md
CHANGED
|
@@ -289,7 +289,7 @@ The tokenization pipeline removes them in Stage 1
|
|
|
289
289
|
search index.
|
|
290
290
|
|
|
291
291
|
See [Query Parser](query-parser.md) for the full
|
|
292
|
-
|
|
292
|
+
nine-stage tokenization pipeline and
|
|
293
293
|
[Content Parser](content-parser.md) for the marker
|
|
294
294
|
extraction functions used during stripping.
|
|
295
295
|
|