@avantf/dsh-mem 0.6.4 → 0.8.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 +19 -10
- package/lib/client.js +1665 -3466
- package/lib/dsh-build.json +6 -5
- package/lib/engine/graph-recall/in-memory.d.ts +93 -0
- package/lib/engine/graph-recall/index.d.ts +22 -0
- package/lib/engine/graph-recall/traverse.d.ts +119 -0
- package/lib/engine/graph-recall/types.d.ts +188 -0
- package/lib/engine/mem/config/config_files.d.ts +1 -1
- package/lib/engine/mem/config/loader.d.ts +2 -3
- package/lib/engine/mem/config/paths.d.ts +2 -13
- package/lib/engine/mem/db/dao/contradictions.d.ts +4 -22
- package/lib/engine/mem/db/dao/entities.d.ts +80 -7
- package/lib/engine/mem/db/dao/fact_sources.d.ts +3 -13
- package/lib/engine/mem/db/dao/facts.d.ts +311 -56
- package/lib/engine/mem/db/dao/triples.d.ts +1 -26
- package/lib/engine/mem/db/graph.d.ts +249 -0
- package/lib/engine/mem/db/journal_notes.d.ts +35 -0
- package/lib/engine/mem/db/migrations.d.ts +9 -0
- package/lib/engine/mem/db/port.d.ts +22 -3
- package/lib/engine/mem/db/schema.d.ts +119 -0
- package/lib/engine/mem/db/tokenizer.d.ts +9 -0
- package/lib/engine/mem/dbdrivers/fake/driver.d.ts +75 -0
- package/lib/engine/mem/dbdrivers/fake/index.d.ts +7 -0
- package/lib/engine/mem/dbdrivers/fake/surface.d.ts +34 -0
- package/lib/engine/mem/dbdrivers/fake/transport.d.ts +61 -0
- package/lib/engine/mem/dbdrivers/sqlite/connection.d.ts +14 -0
- package/lib/engine/mem/dbdrivers/sqlite/contradictions.d.ts +35 -0
- package/lib/engine/mem/dbdrivers/sqlite/dao/index.d.ts +16 -0
- package/lib/engine/mem/dbdrivers/sqlite/driver.d.ts +54 -0
- package/lib/engine/mem/dbdrivers/sqlite/facts.d.ts +117 -0
- package/lib/engine/mem/dbdrivers/sqlite/index.d.ts +6 -0
- package/lib/engine/mem/dbdrivers/sqlite/migrations.d.ts +15 -0
- package/lib/engine/mem/dbdrivers/sqlite/relations.d.ts +62 -0
- package/lib/engine/mem/dbdrivers/sqlite/search.d.ts +56 -0
- package/lib/engine/mem/dbdrivers/sqlite/sources.d.ts +37 -0
- package/lib/engine/mem/defaults.d.ts +3 -4
- package/lib/engine/mem/dispatch.d.ts +7 -32
- package/lib/engine/mem/entities/extract.d.ts +44 -47
- package/lib/engine/mem/eval/derived_runner.d.ts +6 -1
- package/lib/engine/mem/eval/relation_gold.d.ts +251 -0
- package/lib/engine/mem/eval/write_metrics.d.ts +1 -1
- package/lib/engine/mem/facts_io.d.ts +328 -0
- package/lib/engine/mem/index.d.ts +10 -2
- package/lib/engine/mem/interfaces/capabilities.d.ts +30 -0
- package/lib/engine/mem/interfaces/common.d.ts +11 -0
- package/lib/engine/mem/interfaces/errors.d.ts +65 -0
- package/lib/engine/mem/interfaces/index.d.ts +18 -0
- package/lib/engine/mem/interfaces/migrations.d.ts +21 -0
- package/lib/engine/mem/interfaces/repositories.d.ts +471 -0
- package/lib/engine/mem/interfaces/search_index.d.ts +113 -0
- package/lib/engine/mem/interfaces/storage_backend.d.ts +84 -0
- package/lib/engine/mem/interfaces/storage_driver.d.ts +43 -0
- package/lib/engine/mem/interfaces/version.d.ts +34 -0
- package/lib/engine/mem/lifecycle/contradiction.d.ts +2 -2
- package/lib/engine/mem/maintenance_paths.d.ts +41 -0
- package/lib/engine/mem/modelBootstrap.d.ts +1 -1
- package/lib/engine/mem/relations/confidence.d.ts +39 -0
- package/lib/engine/mem/relations/extract.d.ts +128 -0
- package/lib/engine/mem/relations/index.d.ts +32 -0
- package/lib/engine/mem/relations/name-quality.d.ts +78 -0
- package/lib/engine/mem/relations/normalize.d.ts +275 -0
- package/lib/engine/mem/relations/patterns.d.ts +67 -0
- package/lib/engine/mem/relations/statement.d.ts +88 -0
- package/lib/engine/mem/relations/types.d.ts +79 -0
- package/lib/engine/mem/runtime.d.ts +117 -90
- package/lib/engine/mem/storage/create.d.ts +42 -0
- package/lib/engine/mem/storage/errors.d.ts +65 -0
- package/lib/engine/mem/storage/index.d.ts +15 -0
- package/lib/engine/mem/storage/ports.d.ts +472 -0
- package/lib/engine/mem/storage/registry.d.ts +37 -0
- package/lib/engine/mem/storage/sqlite.d.ts +28 -0
- package/lib/engine/mem/store/common.d.ts +1 -1
- package/lib/engine/mem/store/entity_leg.d.ts +59 -2
- package/lib/engine/mem/store/entity_sweep.d.ts +4 -3
- package/lib/engine/mem/store/explicit_relations.d.ts +52 -0
- package/lib/engine/mem/store/facts_restore.d.ts +124 -0
- package/lib/engine/mem/store/floors.d.ts +4 -1
- package/lib/engine/mem/store/graph_reader.d.ts +146 -0
- package/lib/engine/mem/store/hybrid.d.ts +50 -13
- package/lib/engine/mem/store/kinds.d.ts +47 -0
- package/lib/engine/mem/store/legs.d.ts +24 -29
- package/lib/engine/mem/store/lexical.d.ts +36 -45
- package/lib/engine/mem/store/memory.d.ts +486 -82
- package/lib/engine/mem/store/recall_policy.d.ts +49 -0
- package/lib/engine/mem/store/relation_backfill.d.ts +210 -0
- package/lib/engine/mem/store/relation_planner.d.ts +191 -0
- package/lib/engine/mem/store/secret_guard.d.ts +0 -1
- package/lib/engine/mem/store/self_query.d.ts +4 -2
- package/lib/engine/mem/store/time_filter.d.ts +121 -0
- package/lib/engine/mem/store/titles.d.ts +52 -0
- package/lib/engine/mem/store/vector_repair.d.ts +44 -54
- package/lib/engine/mem-contract/config.d.ts +44 -38
- package/lib/engine/mem-contract/text.d.ts +1 -1
- package/lib/engine/mem-contract/tools.d.ts +184 -117
- package/lib/engine/mem-contract/types.d.ts +364 -288
- package/lib/index.js +13898 -11500
- package/lib/interface-version.json +1 -1
- package/lib/types/client/index.d.ts +2 -2
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/paging.d.ts +3 -12
- package/lib/types/client/paging.d.ts.map +1 -1
- package/lib/types/client/summarize.d.ts.map +1 -1
- package/lib/types/command.d.ts +61 -0
- package/lib/types/command.d.ts.map +1 -0
- package/lib/types/envinit-bootstrap.d.ts +1 -1
- package/lib/types/envinit.d.ts +2 -6
- package/lib/types/envinit.d.ts.map +1 -1
- package/lib/types/hints.d.ts +28 -24
- package/lib/types/hints.d.ts.map +1 -1
- package/lib/types/index.d.ts +21 -40
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/inject.d.ts +3 -2
- package/lib/types/inject.d.ts.map +1 -1
- package/lib/types/interface_gate.d.ts +9 -9
- package/lib/types/prompt.d.ts +17 -41
- package/lib/types/prompt.d.ts.map +1 -1
- package/lib/types/provision.d.ts +3 -0
- package/lib/types/provision.d.ts.map +1 -1
- package/lib/types/remote.d.ts +23 -9
- package/lib/types/remote.d.ts.map +1 -1
- package/lib/types/render.d.ts +3 -3
- package/lib/types/tool_schema.d.ts +4 -0
- package/lib/types/tool_schema.d.ts.map +1 -1
- package/lib/types/vectorMigration.d.ts +5 -7
- package/lib/types/vectorMigration.d.ts.map +1 -1
- package/package.json +16 -15
- package/lib/engine/mem/config/domains.d.ts +0 -20
- package/lib/engine/mem/db/dao/chunks.d.ts +0 -231
- package/lib/engine/mem/db/dao/documents.d.ts +0 -51
- package/lib/engine/mem/db/hash.d.ts +0 -2
- package/lib/engine/mem/db/knowledge.d.ts +0 -17
- package/lib/engine/mem/eval/index.d.ts +0 -4
- package/lib/engine/mem/git.d.ts +0 -73
- package/lib/engine/mem/router.d.ts +0 -51
- package/lib/engine/mem/store/doc_files.d.ts +0 -125
- package/lib/engine/mem/store/document_text.d.ts +0 -47
- package/lib/engine/mem/store/ingest_guard.d.ts +0 -25
- package/lib/engine/mem/store/knowledge.d.ts +0 -598
- package/lib/engine/mem/store/source_picker.d.ts +0 -43
- package/lib/engine/mem-retrieval/adapters/local_reranker.d.ts +0 -52
- package/lib/engine/mem-retrieval/adapters/none_reranker.d.ts +0 -10
- package/lib/engine/mem-retrieval/rerank.d.ts +0 -13
- package/lib/types/client/domains.d.ts +0 -53
- package/lib/types/client/domains.d.ts.map +0 -1
- package/lib/types/client/ingest.d.ts +0 -24
- package/lib/types/client/ingest.d.ts.map +0 -1
- package/lib/types/open.d.ts +0 -77
- package/lib/types/open.d.ts.map +0 -1
- package/lib/types/reconcile.d.ts +0 -64
- package/lib/types/reconcile.d.ts.map +0 -1
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
2
|
+
* The LEXICAL TERM SET and its term-count probe.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* it stays SILENT when unsure, and the always-on usage sections remain the fallback that tells the
|
|
12
|
-
* model to query anyway.
|
|
4
|
+
* NOT the hint's decision any more. The conditional hint is `AvantfRuntime.wouldFind`, which runs
|
|
5
|
+
* the SAME retrieval pipeline as the tools and answers "would it return a hit?" (DESIGN §12). This
|
|
6
|
+
* module used to be that decision's cheap first half; it now provides the term definition the
|
|
7
|
+
* retrieval legs and floors consume ({@link relevanceTerms} / {@link gradedTerms} /
|
|
8
|
+
* {@link substringTerms}) plus a diagnostic term-count probe ({@link looksRelevant} /
|
|
9
|
+
* {@link probeStoreTerms}) that the regression test uses to show what the OLD hint would have
|
|
10
|
+
* answered (`test/retrieve.spec.ts`, shape B: lexical hit blocked by `min_score`).
|
|
13
11
|
*
|
|
14
12
|
* THE BAR, AND HOW IT WAS MEASURED. Terms are latin/digit words of >= 5 chars plus every CJK
|
|
15
13
|
* 3-gram (the FTS tables are trigram-tokenised, so a 2-char CJK term cannot be expressed and a
|
|
@@ -24,36 +22,27 @@
|
|
|
24
22
|
* would not have saved it; BOTH the floor and the two-term bar are load-bearing. Hence
|
|
25
23
|
* `matched >= 2`, with the margin between 2 and 1 rather than a tuned threshold inside a
|
|
26
24
|
* continuum. A single-word query (`cgroup`) scores 1 and stays silent on purpose: one term is not
|
|
27
|
-
* evidence.
|
|
25
|
+
* evidence. The numbers stay here as the record of that calibration; the hint no longer branches
|
|
26
|
+
* on them.
|
|
28
27
|
*
|
|
29
|
-
* THE SHORT-CJK FALLBACK
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
28
|
+
* THE SHORT-CJK FALLBACK. The trigram index has no term shorter than three characters — measured on
|
|
29
|
+
* the live store: `fts5vocab` over `facts_fts` holds 27906 distinct terms and EVERY one is 3
|
|
30
|
+
* characters (and a 2-char `MATCH` returns nothing, even as a prefix query). So a 2-char CJK query
|
|
31
|
+
* produces no FTS term at all and that leg is empty by construction. The FTS LEG therefore falls
|
|
32
|
+
* back to the one finer predicate the FTS5 trigram TABLE does expose: `content LIKE '%…%'`, which
|
|
33
|
+
* matches a 2-char run by scanning (no index can serve a 2-char pattern). See
|
|
34
|
+
* {@link substringTerms} / {@link gradedTerms}.
|
|
36
35
|
*
|
|
37
|
-
* The
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* path. Behaviour is unchanged there: a 2-char query scored 0 matched terms before and still does
|
|
41
|
-
* (`{terms: 0, matched: 0}`), so the hint stays silent exactly as it did.
|
|
36
|
+
* The term-count probe keeps the index-expressible terms only: it is a bounded number of
|
|
37
|
+
* `LIMIT 1` index lookups, never an O(corpus) scan — there is no prompt-path budget reason for that
|
|
38
|
+
* any more, but it is still the right cost for a diagnostic.
|
|
42
39
|
*/
|
|
43
|
-
import {
|
|
40
|
+
import type { Awaitable } from '../interfaces/common.js';
|
|
44
41
|
/** How many of an input's terms a store holds. `terms === 0` means the input had nothing to test. */
|
|
45
42
|
export interface LexicalProbe {
|
|
46
43
|
terms: number;
|
|
47
44
|
matched: number;
|
|
48
45
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Which stores hold something relevant — the ONE answer the plugin's hint layer consumes.
|
|
51
|
-
*
|
|
52
|
-
* A boolean on purpose: `kb_query` retrieves from BOTH stores, so the hint only has to decide
|
|
53
|
-
* "worth mentioning or not". Which store matched is nobody's business downstream — and asking for
|
|
54
|
-
* it cost a distinction the probe would have to keep alive in two places.
|
|
55
|
-
*/
|
|
56
|
-
export type RelevanceHit = boolean;
|
|
57
46
|
/**
|
|
58
47
|
* The distinct terms of `text` that the FTS tables can express.
|
|
59
48
|
*
|
|
@@ -92,28 +81,30 @@ export declare function substringTerms(text: string, cap?: number): string[];
|
|
|
92
81
|
*/
|
|
93
82
|
export declare function gradedTerms(text: string, cap?: number): string[];
|
|
94
83
|
/**
|
|
95
|
-
* The
|
|
84
|
+
* The old hint's bar, kept as the lexical ORACLE the regression test compares against: does this
|
|
85
|
+
* store hold at least two of the text's distinct terms?
|
|
96
86
|
*
|
|
97
87
|
* Two distinct terms is the measured bar (see the module comment). Deliberately not "at least one"
|
|
98
88
|
* — a single hit is what a common word produces — and deliberately not a score threshold, because
|
|
99
89
|
* bm25 sums over OR'd terms and therefore rewards a long question for merely containing many
|
|
100
|
-
* 3-grams.
|
|
90
|
+
* 3-grams. NOTHING on the retrieval or hint path branches on this: `wouldFind` asks the retrieval
|
|
91
|
+
* pipeline itself, and a lexical hit that cannot reach `min_score` must NOT fire the hint.
|
|
101
92
|
*/
|
|
102
93
|
export declare function looksRelevant(probe: LexicalProbe): boolean;
|
|
103
94
|
/**
|
|
104
95
|
* Count how many of `text`'s terms ONE store holds.
|
|
105
96
|
*
|
|
106
|
-
* The loop both stores used to carry verbatim. `holds` is handed the raw TERM
|
|
107
|
-
* expression
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
97
|
+
* The loop both stores used to carry verbatim. `holds` is handed the raw TERM: turning a term into
|
|
98
|
+
* an index expression depends on the backend and its tokenizer, which is the backend's business
|
|
99
|
+
* (DB-3 made that explicit — the adapter owns the query builder). Each store asks its own index
|
|
100
|
+
* with `LIMIT 1` — the question is whether a term exists at all, not where it ranks. `stopAt` lets a
|
|
101
|
+
* caller that only asks "≥ 2?" stop early; the default keeps an exact count for the calibration
|
|
102
|
+
* recorded above.
|
|
111
103
|
*/
|
|
112
|
-
export declare function probeTerms(text: string, holds: (term: string) => boolean
|
|
104
|
+
export declare function probeTerms(text: string, holds: (term: string) => Awaitable<boolean>, stopAt?: number): Promise<LexicalProbe>;
|
|
113
105
|
/**
|
|
114
|
-
* The store probe both stores' `lexicalProbe` used to spell out verbatim:
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* one part that has to differ, which is now a single `holds` closure per store.
|
|
106
|
+
* The store probe both stores' `lexicalProbe` used to spell out verbatim: ask THIS store's index
|
|
107
|
+
* whether anything holds a term. `probeTerms` owns the term set and the counting; this owns the one
|
|
108
|
+
* part that has to differ, which is now a single `holds` closure per store.
|
|
118
109
|
*/
|
|
119
|
-
export declare function probeStoreTerms(text: string,
|
|
110
|
+
export declare function probeStoreTerms(text: string, holds: (term: string) => Awaitable<boolean>, stopAt?: number): Promise<LexicalProbe>;
|