digdig 0.0.2 → 0.0.3
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 +12 -14
- package/digdig.config.example.json +0 -0
- package/dist/claims/deterministic-checks.d.ts +0 -0
- package/dist/claims/deterministic-checks.d.ts.map +0 -0
- package/dist/claims/deterministic-checks.js +0 -0
- package/dist/claims/deterministic-checks.js.map +0 -0
- package/dist/claims/policy.d.ts +0 -0
- package/dist/claims/policy.d.ts.map +0 -0
- package/dist/claims/policy.js +0 -0
- package/dist/claims/policy.js.map +0 -0
- package/dist/claims/store.d.ts +0 -0
- package/dist/claims/store.d.ts.map +0 -0
- package/dist/claims/store.js +0 -0
- package/dist/claims/store.js.map +0 -0
- package/dist/claims/types.d.ts +0 -0
- package/dist/claims/types.d.ts.map +0 -0
- package/dist/claims/types.js +0 -0
- package/dist/claims/types.js.map +0 -0
- package/dist/commands/claim.d.ts +0 -0
- package/dist/commands/claim.d.ts.map +0 -0
- package/dist/commands/claim.js +0 -0
- package/dist/commands/claim.js.map +0 -0
- package/dist/commands/coverage.d.ts +7 -0
- package/dist/commands/coverage.d.ts.map +1 -0
- package/dist/commands/coverage.js +78 -0
- package/dist/commands/coverage.js.map +1 -0
- package/dist/commands/doc-index.d.ts +0 -0
- package/dist/commands/doc-index.d.ts.map +0 -0
- package/dist/commands/doc-index.js +0 -0
- package/dist/commands/doc-index.js.map +0 -0
- package/dist/commands/doc-search.d.ts +0 -0
- package/dist/commands/doc-search.d.ts.map +0 -0
- package/dist/commands/doc-search.js +0 -0
- package/dist/commands/doc-search.js.map +0 -0
- package/dist/commands/evidence.d.ts +0 -0
- package/dist/commands/evidence.d.ts.map +0 -0
- package/dist/commands/evidence.js +0 -0
- package/dist/commands/evidence.js.map +0 -0
- package/dist/commands/extract.d.ts +0 -0
- package/dist/commands/extract.d.ts.map +0 -0
- package/dist/commands/extract.js +5 -5
- package/dist/commands/extract.js.map +1 -1
- package/dist/commands/graph-add.d.ts +0 -0
- package/dist/commands/graph-add.d.ts.map +0 -0
- package/dist/commands/graph-add.js +0 -0
- package/dist/commands/graph-add.js.map +1 -1
- package/dist/commands/graph-drill.d.ts +0 -0
- package/dist/commands/graph-drill.d.ts.map +0 -0
- package/dist/commands/graph-drill.js +0 -0
- package/dist/commands/graph-drill.js.map +0 -0
- package/dist/commands/graph-explore.d.ts +0 -0
- package/dist/commands/graph-explore.d.ts.map +0 -0
- package/dist/commands/graph-explore.js +0 -0
- package/dist/commands/graph-explore.js.map +0 -0
- package/dist/commands/graph-obfuscate.d.ts +0 -0
- package/dist/commands/graph-obfuscate.d.ts.map +0 -0
- package/dist/commands/graph-obfuscate.js +0 -0
- package/dist/commands/graph-obfuscate.js.map +0 -0
- package/dist/commands/graph-search.d.ts +0 -0
- package/dist/commands/graph-search.d.ts.map +0 -0
- package/dist/commands/graph-search.js +0 -0
- package/dist/commands/graph-search.js.map +0 -0
- package/dist/commands/graph-traverse.d.ts +0 -0
- package/dist/commands/graph-traverse.d.ts.map +0 -0
- package/dist/commands/graph-traverse.js +0 -0
- package/dist/commands/graph-traverse.js.map +0 -0
- package/dist/commands/json-input.d.ts +0 -0
- package/dist/commands/json-input.d.ts.map +0 -0
- package/dist/commands/json-input.js +0 -0
- package/dist/commands/json-input.js.map +0 -0
- package/dist/commands/query-graph.d.ts +0 -0
- package/dist/commands/query-graph.d.ts.map +0 -0
- package/dist/commands/query-graph.js +0 -0
- package/dist/commands/query-graph.js.map +0 -0
- package/dist/commands/results-add.d.ts +0 -0
- package/dist/commands/results-add.d.ts.map +0 -0
- package/dist/commands/results-add.js +0 -0
- package/dist/commands/results-add.js.map +0 -0
- package/dist/commands/review.d.ts +0 -0
- package/dist/commands/review.d.ts.map +0 -0
- package/dist/commands/review.js +0 -0
- package/dist/commands/review.js.map +0 -0
- package/dist/commands/session.d.ts +0 -0
- package/dist/commands/session.d.ts.map +0 -0
- package/dist/commands/session.js +0 -0
- package/dist/commands/session.js.map +0 -0
- package/dist/commands/verdict.d.ts +0 -0
- package/dist/commands/verdict.d.ts.map +0 -0
- package/dist/commands/verdict.js +0 -0
- package/dist/commands/verdict.js.map +0 -0
- package/dist/config.d.ts +0 -0
- package/dist/config.d.ts.map +0 -0
- package/dist/config.js +0 -0
- package/dist/config.js.map +0 -0
- package/dist/deep/co-occurrence.d.ts +0 -0
- package/dist/deep/co-occurrence.d.ts.map +0 -0
- package/dist/deep/co-occurrence.js +0 -0
- package/dist/deep/co-occurrence.js.map +0 -0
- package/dist/deep/coverage.d.ts +81 -0
- package/dist/deep/coverage.d.ts.map +1 -0
- package/dist/deep/coverage.js +183 -0
- package/dist/deep/coverage.js.map +1 -0
- package/dist/deep/dedupe.d.ts +9 -1
- package/dist/deep/dedupe.d.ts.map +1 -1
- package/dist/deep/dedupe.js +21 -2
- package/dist/deep/dedupe.js.map +1 -1
- package/dist/deep/degree-utils.d.ts +0 -0
- package/dist/deep/degree-utils.d.ts.map +0 -0
- package/dist/deep/degree-utils.js +0 -0
- package/dist/deep/degree-utils.js.map +0 -0
- package/dist/deep/extractor.d.ts +0 -0
- package/dist/deep/extractor.d.ts.map +0 -0
- package/dist/deep/extractor.js +0 -0
- package/dist/deep/extractor.js.map +0 -0
- package/dist/deep/fuse.d.ts +63 -0
- package/dist/deep/fuse.d.ts.map +1 -0
- package/dist/deep/fuse.js +108 -0
- package/dist/deep/fuse.js.map +1 -0
- package/dist/deep/graph-explore.d.ts +0 -0
- package/dist/deep/graph-explore.d.ts.map +0 -0
- package/dist/deep/graph-explore.js +0 -0
- package/dist/deep/graph-explore.js.map +0 -0
- package/dist/deep/graph-obfuscate.d.ts +0 -0
- package/dist/deep/graph-obfuscate.d.ts.map +0 -0
- package/dist/deep/graph-obfuscate.js +0 -0
- package/dist/deep/graph-obfuscate.js.map +0 -0
- package/dist/deep/graph-preprocess.d.ts +0 -0
- package/dist/deep/graph-preprocess.d.ts.map +0 -0
- package/dist/deep/graph-preprocess.js +0 -0
- package/dist/deep/graph-preprocess.js.map +0 -0
- package/dist/deep/graph-sampling.d.ts +0 -0
- package/dist/deep/graph-sampling.d.ts.map +0 -0
- package/dist/deep/graph-sampling.js +0 -0
- package/dist/deep/graph-sampling.js.map +0 -0
- package/dist/deep/graph.d.ts +0 -0
- package/dist/deep/graph.d.ts.map +0 -0
- package/dist/deep/graph.js +0 -0
- package/dist/deep/graph.js.map +0 -0
- package/dist/deep/index.d.ts +1 -1
- package/dist/deep/index.d.ts.map +0 -0
- package/dist/deep/index.js +1 -1
- package/dist/deep/index.js.map +0 -0
- package/dist/deep/iteration-data.d.ts +9 -13
- package/dist/deep/iteration-data.d.ts.map +1 -1
- package/dist/deep/iteration-data.js +12 -16
- package/dist/deep/iteration-data.js.map +1 -1
- package/dist/deep/local-doc/indexer.d.ts +0 -4
- package/dist/deep/local-doc/indexer.d.ts.map +1 -1
- package/dist/deep/local-doc/indexer.js +21 -3
- package/dist/deep/local-doc/indexer.js.map +1 -1
- package/dist/deep/local-doc/scanner.d.ts +0 -0
- package/dist/deep/local-doc/scanner.d.ts.map +0 -0
- package/dist/deep/local-doc/scanner.js +0 -0
- package/dist/deep/local-doc/scanner.js.map +0 -0
- package/dist/deep/local-doc/searcher.d.ts +0 -0
- package/dist/deep/local-doc/searcher.d.ts.map +1 -1
- package/dist/deep/local-doc/searcher.js +3 -4
- package/dist/deep/local-doc/searcher.js.map +1 -1
- package/dist/deep/local-doc/types.d.ts +0 -0
- package/dist/deep/local-doc/types.d.ts.map +0 -0
- package/dist/deep/local-doc/types.js +0 -0
- package/dist/deep/local-doc/types.js.map +0 -0
- package/dist/deep/path-extraction.d.ts +0 -0
- package/dist/deep/path-extraction.d.ts.map +0 -0
- package/dist/deep/path-extraction.js +0 -0
- package/dist/deep/path-extraction.js.map +0 -0
- package/dist/deep/pending-facts.d.ts +64 -0
- package/dist/deep/pending-facts.d.ts.map +1 -0
- package/dist/deep/pending-facts.js +74 -0
- package/dist/deep/pending-facts.js.map +1 -0
- package/dist/deep/query-redundancy.d.ts +0 -0
- package/dist/deep/query-redundancy.d.ts.map +0 -0
- package/dist/deep/query-redundancy.js +0 -0
- package/dist/deep/query-redundancy.js.map +0 -0
- package/dist/deep/query-suggest.d.ts +1 -3
- package/dist/deep/query-suggest.d.ts.map +1 -1
- package/dist/deep/query-suggest.js +3 -11
- package/dist/deep/query-suggest.js.map +1 -1
- package/dist/deep/rrf.d.ts +0 -0
- package/dist/deep/rrf.d.ts.map +0 -0
- package/dist/deep/rrf.js +0 -0
- package/dist/deep/rrf.js.map +0 -0
- package/dist/deep/search-strategy.d.ts +0 -0
- package/dist/deep/search-strategy.d.ts.map +0 -0
- package/dist/deep/search-strategy.js +0 -0
- package/dist/deep/search-strategy.js.map +0 -0
- package/dist/deep/session.d.ts +5 -3
- package/dist/deep/session.d.ts.map +1 -1
- package/dist/deep/session.js +29 -9
- package/dist/deep/session.js.map +1 -1
- package/dist/deep/simhash.d.ts +0 -0
- package/dist/deep/simhash.d.ts.map +0 -0
- package/dist/deep/simhash.js +0 -0
- package/dist/deep/simhash.js.map +0 -0
- package/dist/deep/tfidf.d.ts +0 -0
- package/dist/deep/tfidf.d.ts.map +0 -0
- package/dist/deep/tfidf.js +0 -0
- package/dist/deep/tfidf.js.map +0 -0
- package/dist/deepseek-service.d.ts +0 -0
- package/dist/deepseek-service.d.ts.map +1 -1
- package/dist/deepseek-service.js +7 -3
- package/dist/deepseek-service.js.map +1 -1
- package/dist/entry.d.ts +5 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +7 -2
- package/dist/entry.js.map +1 -1
- package/dist/errors.d.ts +76 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +117 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.d.ts.map +0 -0
- package/dist/index.js.map +0 -0
- package/dist/init.d.ts +0 -0
- package/dist/init.d.ts.map +0 -0
- package/dist/init.js +0 -0
- package/dist/init.js.map +0 -0
- package/dist/legacy.d.ts +0 -0
- package/dist/legacy.d.ts.map +0 -0
- package/dist/legacy.js +0 -0
- package/dist/legacy.js.map +0 -0
- package/dist/ollama-service.d.ts +0 -0
- package/dist/ollama-service.d.ts.map +1 -1
- package/dist/ollama-service.js +27 -6
- package/dist/ollama-service.js.map +1 -1
- package/dist/protocol.d.ts +0 -0
- package/dist/protocol.d.ts.map +0 -0
- package/dist/protocol.js +0 -0
- package/dist/protocol.js.map +0 -0
- package/dist/runCli.d.ts +1 -1
- package/dist/runCli.d.ts.map +1 -1
- package/dist/runCli.js +224 -432
- package/dist/runCli.js.map +1 -1
- package/dist/service.d.ts +10 -0
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +27 -21
- package/dist/service.js.map +1 -1
- package/dist/sxng.d.ts +0 -0
- package/dist/sxng.d.ts.map +0 -0
- package/dist/sxng.js.map +0 -0
- package/package.json +2 -2
- package/dist/commands/build-graph.d.ts +0 -8
- package/dist/commands/build-graph.d.ts.map +0 -1
- package/dist/commands/build-graph.js +0 -70
- package/dist/commands/build-graph.js.map +0 -1
- package/dist/commands/graph-add.d.ts.sync-conflict-20260629-232900-2SGIW5T.map +0 -1
- package/dist/commands/graph-add.js.sync-conflict-20260629-232916-2SGIW5T.map +0 -1
- package/dist/commands/graph-add.sync-conflict-20260629-232853-2SGIW5T.js +0 -163
- package/dist/commands/raw.d.ts +0 -14
- package/dist/commands/raw.d.ts.map +0 -1
- package/dist/commands/raw.js +0 -125
- package/dist/commands/raw.js.map +0 -1
- package/dist/deep/extractor.d.sync-conflict-20260629-232902-2SGIW5T.ts +0 -37
- package/dist/deep/extractor.d.ts.sync-conflict-20260629-232921-2SGIW5T.map +0 -1
- package/dist/deep/extractor.js.sync-conflict-20260629-232921-2SGIW5T.map +0 -1
- package/dist/deep/extractor.sync-conflict-20260629-232903-2SGIW5T.js +0 -203
- package/dist/deep/graph.d.sync-conflict-20260629-232917-2SGIW5T.ts +0 -78
- package/dist/deep/graph.d.ts.sync-conflict-20260629-232911-2SGIW5T.map +0 -1
- package/dist/deep/graph.js.sync-conflict-20260629-232855-2SGIW5T.map +0 -1
- package/dist/deep/graph.sync-conflict-20260629-232907-2SGIW5T.js +0 -194
- package/dist/deep/keywords.d.ts +0 -27
- package/dist/deep/keywords.d.ts.map +0 -1
- package/dist/deep/keywords.js +0 -293
- package/dist/deep/keywords.js.map +0 -1
- package/dist/deep/local-doc/searcher.sync-conflict-20260805-191858-2SGIW5T.d.ts +0 -38
- package/dist/deep/local-doc/searcher.sync-conflict-20260805-191858-2SGIW5T.d.ts.map +0 -1
- package/dist/deep/local-doc/searcher.sync-conflict-20260805-191858-2SGIW5T.js +0 -212
- package/dist/deep/local-doc/searcher.sync-conflict-20260805-191858-2SGIW5T.js.map +0 -1
- package/dist/deep/quality-assess.d.ts +0 -46
- package/dist/deep/quality-assess.d.ts.map +0 -1
- package/dist/deep/quality-assess.js +0 -122
- package/dist/deep/quality-assess.js.map +0 -1
- package/dist/deep/quality-assess.sync-conflict-20260728-195206-JAULAPO.d.ts +0 -46
- package/dist/deep/quality-assess.sync-conflict-20260728-195206-JAULAPO.d.ts.map +0 -1
- package/dist/deep/quality-assess.sync-conflict-20260728-195206-JAULAPO.js +0 -122
- package/dist/deep/quality-assess.sync-conflict-20260728-195206-JAULAPO.js.map +0 -1
- package/dist/deep/recovery-analysis.d.ts +0 -60
- package/dist/deep/recovery-analysis.d.ts.map +0 -1
- package/dist/deep/recovery-analysis.js +0 -185
- package/dist/deep/recovery-analysis.js.map +0 -1
- package/dist/deep/session.d.sync-conflict-20260629-232917-2SGIW5T.ts +0 -71
- package/dist/deep/session.d.ts.sync-conflict-20260629-232921-2SGIW5T.map +0 -1
- package/dist/deep/session.js.sync-conflict-20260629-232854-2SGIW5T.map +0 -1
- package/dist/runCli.d.ts.sync-conflict-20260629-232854-2SGIW5T.map +0 -1
- package/dist/runCli.js.sync-conflict-20260629-232857-2SGIW5T.map +0 -1
- package/dist/runCli.sync-conflict-20260629-232915-2SGIW5T.js +0 -1109
- package/dist/runCli.sync-conflict-20260629-233530-JAULAPO.d.ts +0 -8
- package/dist/runCli.sync-conflict-20260629-233530-JAULAPO.d.ts.map +0 -1
- package/dist/runCli.sync-conflict-20260629-233530-JAULAPO.js +0 -1111
- package/dist/runCli.sync-conflict-20260629-233530-JAULAPO.js.map +0 -1
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What this session has looked at, as countable facts.
|
|
3
|
+
*
|
|
4
|
+
* A search now shows only what it just found, so the shape of the whole session
|
|
5
|
+
* has to come from somewhere. It does not come from the knowledge graph: graph
|
|
6
|
+
* structure is built from *approved* results, so it is empty exactly while the
|
|
7
|
+
* decision is still open, and a session that is three rounds in but has not
|
|
8
|
+
* approved anything has no graph at all.
|
|
9
|
+
*
|
|
10
|
+
* It does not come from a topic model either. The judgement "these results
|
|
11
|
+
* cover four aspects and miss a fifth" is a judgement, and the cheap ways of
|
|
12
|
+
* automating it do not work at this scale: word-bag clustering cannot group two
|
|
13
|
+
* phrasings of one aspect (measured cosine 0.102 same-aspect against 0.012
|
|
14
|
+
* cross-aspect, and no pair cleared a 0.3 threshold), and a real embedding model
|
|
15
|
+
* is too heavy for a CLI. So this module reports only what can be counted, and
|
|
16
|
+
* the caller draws the conclusion.
|
|
17
|
+
*/
|
|
18
|
+
import { sourceKey } from './dedupe.js';
|
|
19
|
+
import { tokenize } from './tfidf.js';
|
|
20
|
+
const REPEATED_TITLES_PER_ROUND = 15;
|
|
21
|
+
/**
|
|
22
|
+
* Source types a deep question usually needs and a general web search rarely
|
|
23
|
+
* returns: papers, code, package registries, Q&A. Kept as a list rather than
|
|
24
|
+
* derived, because "is this a primary source for this question" is not
|
|
25
|
+
* something a hostname can answer.
|
|
26
|
+
*/
|
|
27
|
+
const SPECIALIZED_SOURCES = [
|
|
28
|
+
'arxiv.org',
|
|
29
|
+
'semanticscholar.org',
|
|
30
|
+
'github.com',
|
|
31
|
+
'stackoverflow.com',
|
|
32
|
+
'docs.rs',
|
|
33
|
+
'npmjs.com',
|
|
34
|
+
'pypi.org',
|
|
35
|
+
'crates.io',
|
|
36
|
+
'medium.com',
|
|
37
|
+
'dev.to',
|
|
38
|
+
'reddit.com',
|
|
39
|
+
'hackernews.com',
|
|
40
|
+
];
|
|
41
|
+
/**
|
|
42
|
+
* The round a result first appeared in.
|
|
43
|
+
*
|
|
44
|
+
* Exported because the pending-facts report needs the same fact, and a second
|
|
45
|
+
* implementation of "first sighting" would eventually disagree with this one.
|
|
46
|
+
*/
|
|
47
|
+
export function firstRound(result) {
|
|
48
|
+
let earliest;
|
|
49
|
+
for (const origin of result.origins ?? []) {
|
|
50
|
+
const round = origin.round;
|
|
51
|
+
if (!Number.isInteger(round))
|
|
52
|
+
continue;
|
|
53
|
+
if (earliest === undefined || round < earliest)
|
|
54
|
+
earliest = round;
|
|
55
|
+
}
|
|
56
|
+
return earliest;
|
|
57
|
+
}
|
|
58
|
+
/** Every round that produced this result, deduplicated and sorted. */
|
|
59
|
+
function roundsOf(result) {
|
|
60
|
+
const rounds = new Set();
|
|
61
|
+
for (const origin of result.origins ?? []) {
|
|
62
|
+
if (Number.isInteger(origin.round))
|
|
63
|
+
rounds.add(origin.round);
|
|
64
|
+
}
|
|
65
|
+
return [...rounds].sort((a, b) => a - b);
|
|
66
|
+
}
|
|
67
|
+
export function buildCoverage(results, rounds, options) {
|
|
68
|
+
const titlesPerRound = options?.titlesPerRound ?? REPEATED_TITLES_PER_ROUND;
|
|
69
|
+
const maxTerms = options?.maxTerms ?? 40;
|
|
70
|
+
const byRound = new Map();
|
|
71
|
+
const repeated = [];
|
|
72
|
+
const factsFor = (round) => {
|
|
73
|
+
const existing = byRound.get(round);
|
|
74
|
+
if (existing)
|
|
75
|
+
return existing;
|
|
76
|
+
const created = {
|
|
77
|
+
round, queries: [], engines: [], newResults: 0,
|
|
78
|
+
repeatedFromEarlier: 0, titles: [],
|
|
79
|
+
};
|
|
80
|
+
byRound.set(round, created);
|
|
81
|
+
return created;
|
|
82
|
+
};
|
|
83
|
+
for (const result of results) {
|
|
84
|
+
const seen = roundsOf(result);
|
|
85
|
+
if (seen.length > 1)
|
|
86
|
+
repeated.push({ url: result.url, rounds: seen });
|
|
87
|
+
const first = firstRound(result);
|
|
88
|
+
if (first === undefined)
|
|
89
|
+
continue;
|
|
90
|
+
// A result belongs to the round that first saw it. Counting it again in
|
|
91
|
+
// a later round would make a re-run look productive.
|
|
92
|
+
const home = factsFor(first);
|
|
93
|
+
home.newResults++;
|
|
94
|
+
if (result.title && home.titles.length < titlesPerRound)
|
|
95
|
+
home.titles.push(result.title);
|
|
96
|
+
// Every round that saw it still recorded a query, and a round whose
|
|
97
|
+
// results were all already known is what saturation looks like.
|
|
98
|
+
for (const round of seen) {
|
|
99
|
+
const facts = factsFor(round);
|
|
100
|
+
if (round > first)
|
|
101
|
+
facts.repeatedFromEarlier++;
|
|
102
|
+
for (const origin of result.origins ?? []) {
|
|
103
|
+
if (origin.round !== round)
|
|
104
|
+
continue;
|
|
105
|
+
if (origin.query && !facts.queries.includes(origin.query))
|
|
106
|
+
facts.queries.push(origin.query);
|
|
107
|
+
if (origin.engine && !facts.engines.includes(origin.engine))
|
|
108
|
+
facts.engines.push(origin.engine);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
rounds,
|
|
114
|
+
uniqueResults: results.length,
|
|
115
|
+
byRound: [...byRound.values()].sort((a, b) => a.round - b.round),
|
|
116
|
+
repeated: repeated.sort((a, b) => b.rounds.length - a.rounds.length || a.url.localeCompare(b.url)),
|
|
117
|
+
distinctiveTerms: distinctiveTermsOf(results, maxTerms),
|
|
118
|
+
...domainFactsOf(results),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Which hosts the session has drawn from, and which specialized ones it has not.
|
|
123
|
+
*
|
|
124
|
+
* A `file:` result is a local document; its source is its path, so it counts
|
|
125
|
+
* like any other source rather than vanishing under an empty hostname.
|
|
126
|
+
*/
|
|
127
|
+
function domainFactsOf(results) {
|
|
128
|
+
const counts = new Map();
|
|
129
|
+
for (const result of results) {
|
|
130
|
+
const source = sourceKey(result.url);
|
|
131
|
+
if (!source)
|
|
132
|
+
continue;
|
|
133
|
+
counts.set(source, (counts.get(source) ?? 0) + 1);
|
|
134
|
+
}
|
|
135
|
+
const domainsSeen = [...counts.entries()]
|
|
136
|
+
.map(([domain, count]) => ({ domain, results: count }))
|
|
137
|
+
.sort((a, b) => b.results - a.results || a.domain.localeCompare(b.domain));
|
|
138
|
+
const touched = new Set(domainsSeen.map(entry => entry.domain));
|
|
139
|
+
return {
|
|
140
|
+
domainsSeen,
|
|
141
|
+
untouchedSpecialized: SPECIALIZED_SOURCES.filter(source => !touched.has(source)),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/** Terms that name one round's subject rather than the session's. */
|
|
145
|
+
function distinctiveTermsOf(results, maxTerms) {
|
|
146
|
+
// term → the rounds that used it → how many results in that round used it
|
|
147
|
+
const uses = new Map();
|
|
148
|
+
for (const result of results) {
|
|
149
|
+
// At zero extraction a search result carries only its snippet, and the
|
|
150
|
+
// snippet is what the round actually returned. Extracted results carry
|
|
151
|
+
// the full body instead, so prefer that.
|
|
152
|
+
const text = result.content || result.excerpt;
|
|
153
|
+
if (!text && !result.title)
|
|
154
|
+
continue;
|
|
155
|
+
const round = firstRound(result);
|
|
156
|
+
if (round === undefined)
|
|
157
|
+
continue;
|
|
158
|
+
const seen = new Set(tokenize(`${result.title ?? ''} ${text ?? ''}`));
|
|
159
|
+
for (const term of seen) {
|
|
160
|
+
const byRoundCount = uses.get(term) ?? new Map();
|
|
161
|
+
byRoundCount.set(round, (byRoundCount.get(round) ?? 0) + 1);
|
|
162
|
+
uses.set(term, byRoundCount);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const terms = [];
|
|
166
|
+
for (const [term, byRoundCount] of uses) {
|
|
167
|
+
// Used in more than one round: it belongs to the shared subject, not to
|
|
168
|
+
// any single round's aspect.
|
|
169
|
+
if (byRoundCount.size !== 1)
|
|
170
|
+
continue;
|
|
171
|
+
const [round, count] = [...byRoundCount.entries()][0];
|
|
172
|
+
// Seen once is a stray token, not a pattern.
|
|
173
|
+
if (count < 2)
|
|
174
|
+
continue;
|
|
175
|
+
terms.push({ term, round, docFreq: count });
|
|
176
|
+
}
|
|
177
|
+
// Strongest within-round repetition first, then alphabetical so the output
|
|
178
|
+
// is stable across runs.
|
|
179
|
+
return terms
|
|
180
|
+
.sort((a, b) => b.docFreq - a.docFreq || a.round - b.round || a.term.localeCompare(b.term))
|
|
181
|
+
.slice(0, maxTerms);
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=coverage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage.js","sourceRoot":"","sources":["../../src/deep/coverage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA6CtC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAErC;;;;;GAKG;AACH,MAAM,mBAAmB,GAAG;IACxB,WAAW;IACX,qBAAqB;IACrB,YAAY;IACZ,mBAAmB;IACnB,SAAS;IACT,WAAW;IACX,UAAU;IACV,WAAW;IACX,YAAY;IACZ,QAAQ;IACR,YAAY;IACZ,gBAAgB;CACnB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,MAAqB;IAC5C,IAAI,QAA4B,CAAC;IACjC,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;QACxC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC;YAAE,SAAS;QACvC,IAAI,QAAQ,KAAK,SAAS,IAAI,KAAM,GAAG,QAAQ;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AG,EAAkB,CAAC;YACjE,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC5D,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QACjC,CAAC;IACL,CAAC;IAED,MAAM,KAAK,GAA4D,EAAE,CAAC;IAC1E,KAAK,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,IAAI,EAAE,CAAC;QACtC,wEAAwE;QACxE,6BAA6B;QAC7B,IAAI,YAAY,CAAC,IAAI,KAAK,CAAC;YAAE,SAAS;QACtC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACtD,6CAA6C;QAC7C,IAAI,KAAK,GAAG,CAAC;YAAE,SAAS;QACxB,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,2EAA2E;IAC3E,yBAAyB;IACzB,OAAO,KAAK;SACP,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;SAC1F,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC5B,CAAC"}
|
package/dist/deep/dedupe.d.ts
CHANGED
|
@@ -6,12 +6,20 @@ export interface DedupItem {
|
|
|
6
6
|
title: string;
|
|
7
7
|
content: string;
|
|
8
8
|
}
|
|
9
|
-
export declare function normalizeUrl(url: string): string;
|
|
10
9
|
/** Keep a local document's chunk fragment, while normalizing all other URLs. */
|
|
11
10
|
export declare function resultUrlKey(result: {
|
|
12
11
|
url: string;
|
|
13
12
|
source?: string;
|
|
14
13
|
}): string;
|
|
14
|
+
/**
|
|
15
|
+
* The source a result came from, for counting distinct sources.
|
|
16
|
+
*
|
|
17
|
+
* Distinct from `resultUrlKey`, which identifies the result itself. A `file:`
|
|
18
|
+
* URL has no host, and returning an empty string for it — as the hand-rolled
|
|
19
|
+
* copies of this logic variously did — made a pure local session report zero
|
|
20
|
+
* sources. A local document's source is its path.
|
|
21
|
+
*/
|
|
22
|
+
export declare function sourceKey(url: string): string | undefined;
|
|
15
23
|
export declare function dedupeByUrl<T extends DedupItem>(items: T[]): T[];
|
|
16
24
|
export declare function jaccardSimilarity(left: string, right: string): number;
|
|
17
25
|
export declare function dedupeByJaccard<T extends DedupItem>(items: T[], threshold?: number): T[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dedupe.d.ts","sourceRoot":"","sources":["../../src/deep/dedupe.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,SAAS;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACnB;
|
|
1
|
+
{"version":3,"file":"dedupe.d.ts","sourceRoot":"","sources":["../../src/deep/dedupe.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,SAAS;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACnB;AAeD,gFAAgF;AAChF,wBAAgB,YAAY,CAAC,MAAM,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAS7E;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQzD;AAED,wBAAgB,WAAW,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAWhE;AAiBD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAarE;AAQD,wBAAgB,eAAe,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,GAAE,MAAa,GAAG,CAAC,EAAE,CAsB9F;AAED,wBAAgB,MAAM,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,GAAE,MAAa,GAAG,CAAC,EAAE,CAGrF"}
|
package/dist/deep/dedupe.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Deduplication utilities for search results
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
function normalizeUrl(url) {
|
|
5
5
|
try {
|
|
6
6
|
const u = new URL(url);
|
|
7
7
|
// Remove trailing slash, sort params, strip fragments
|
|
@@ -26,10 +26,29 @@ export function resultUrlKey(result) {
|
|
|
26
26
|
return result.url;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* The source a result came from, for counting distinct sources.
|
|
31
|
+
*
|
|
32
|
+
* Distinct from `resultUrlKey`, which identifies the result itself. A `file:`
|
|
33
|
+
* URL has no host, and returning an empty string for it — as the hand-rolled
|
|
34
|
+
* copies of this logic variously did — made a pure local session report zero
|
|
35
|
+
* sources. A local document's source is its path.
|
|
36
|
+
*/
|
|
37
|
+
export function sourceKey(url) {
|
|
38
|
+
try {
|
|
39
|
+
const parsed = new URL(url);
|
|
40
|
+
if (parsed.protocol === 'file:')
|
|
41
|
+
return parsed.pathname || undefined;
|
|
42
|
+
return parsed.hostname.replace(/^www\./, '').toLowerCase() || undefined;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
29
48
|
export function dedupeByUrl(items) {
|
|
30
49
|
const seen = new Map();
|
|
31
50
|
for (const item of items) {
|
|
32
|
-
const norm =
|
|
51
|
+
const norm = resultUrlKey(item);
|
|
33
52
|
if (!seen.has(norm)) {
|
|
34
53
|
seen.set(norm, item);
|
|
35
54
|
}
|
package/dist/deep/dedupe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dedupe.js","sourceRoot":"","sources":["../../src/deep/dedupe.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,
|
|
1
|
+
{"version":3,"file":"dedupe.js","sourceRoot":"","sources":["../../src/deep/dedupe.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,SAAS,YAAY,CAAC,GAAW;IAC7B,IAAI,CAAC;QACD,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACvB,sDAAsD;QACtD,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;QAClD,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;QACZ,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;QACtB,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,GAAG,CAAC;IACf,CAAC;AACL,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,YAAY,CAAC,MAAwC;IACjE,MAAM,UAAU,GAAG,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5C,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,UAAU,CAAC;IAEpF,IAAI,CAAC;QACD,OAAO,GAAG,UAAU,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAA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MAAM,UAAU,eAAe,CAAsB,KAAU,EAAE,YAAoB,IAAI;IACrF,MAAM,IAAI,GAAQ,EAAE,CAAC;IACrB,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,gHAAgH;IAChH,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,WAAW,GAAG,KAAK,CAAC;QACxB,KAAK,MAAM,QAAQ,IAAI,QAAQ,EAAE,CAAC;YAC9B,IAAI,iBAAiB,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,gBAAgB,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,CAAC;gBACzF,WAAW,GAAG,IAAI,CAAC;gBACnB,MAAM;YACV,CAAC;QACL,CAAC;QAED,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAChB,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;IACL,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,MAAM,CAAsB,KAAU,EAAE,YAAoB,IAAI;IAC5E,MAAM,UAAU,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IACtC,OAAO,eAAe,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;AAClD,CAAC"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/deep/extractor.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/deep/extractor.js
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn one search invocation's raw provider responses into the single ordered
|
|
3
|
+
* result set the caller prints and stores.
|
|
4
|
+
*
|
|
5
|
+
* Both search paths used to do this inline and disagreed: one fused against the
|
|
6
|
+
* whole session (including the batch it had just written) and displayed every
|
|
7
|
+
* historical result, the other fused only this run and keyed on a different
|
|
8
|
+
* identity function. This module is the one place that decides order, so
|
|
9
|
+
* `queries.length === 1` is just the case where one response came back.
|
|
10
|
+
*/
|
|
11
|
+
import type { SearchResponse, SearchResult } from '../service.js';
|
|
12
|
+
import type { ResultOrigin } from './session.js';
|
|
13
|
+
export interface FusionInput {
|
|
14
|
+
/** Every response this invocation produced, each carrying its own query. */
|
|
15
|
+
responses: SearchResponse[];
|
|
16
|
+
/** Results imported from a `--merge` file; they rank like any other list. */
|
|
17
|
+
mergeResults?: SearchResult[];
|
|
18
|
+
/**
|
|
19
|
+
* Session contents read *before* this invocation writes anything.
|
|
20
|
+
*
|
|
21
|
+
* Only identities are read: history contributes a vote to the fusion and is
|
|
22
|
+
* never displayed, so the stored body, status and round on a `SessionResult`
|
|
23
|
+
* are irrelevant here and the type stays minimal.
|
|
24
|
+
*/
|
|
25
|
+
sessionSnapshot?: Array<{
|
|
26
|
+
url: string;
|
|
27
|
+
source?: string;
|
|
28
|
+
}>;
|
|
29
|
+
/** When true, only results this invocation produced are displayed. */
|
|
30
|
+
onlyCurrent: boolean;
|
|
31
|
+
limit: number;
|
|
32
|
+
/** Maps a result's engine to the tool that should be recorded as its origin. */
|
|
33
|
+
toolFor?: (engine: string) => string;
|
|
34
|
+
}
|
|
35
|
+
export interface FusionOutput {
|
|
36
|
+
/** What to print, already truncated to `limit`. */
|
|
37
|
+
display: SearchResult[];
|
|
38
|
+
/** The full fused ranking, untruncated — this is what `totalResults` means. */
|
|
39
|
+
fused: Array<{
|
|
40
|
+
id: string;
|
|
41
|
+
score: number;
|
|
42
|
+
}>;
|
|
43
|
+
/** Key → every origin this invocation recorded for that result. */
|
|
44
|
+
originsByKey: Map<string, ResultOrigin[]>;
|
|
45
|
+
/** Keys that this invocation produced (as opposed to history). */
|
|
46
|
+
currentKeys: Set<string>;
|
|
47
|
+
}
|
|
48
|
+
/** Attribute a result to the tool that produced it, for session origin records. */
|
|
49
|
+
export declare function originTool(engine: string, externalProviders: readonly string[]): string;
|
|
50
|
+
/**
|
|
51
|
+
* Fuse responses into one ranking.
|
|
52
|
+
*
|
|
53
|
+
* The order of the steps is the contract:
|
|
54
|
+
* 1. dedupe inside every ranking, so no id votes twice in the same list;
|
|
55
|
+
* 2. rank the extra lists (merge file, then the session snapshot);
|
|
56
|
+
* 3. fuse;
|
|
57
|
+
* 4. project — current results win over history for content, and truncation
|
|
58
|
+
* happens once, at the end.
|
|
59
|
+
*/
|
|
60
|
+
export declare function fuseResults(input: FusionInput): FusionOutput;
|
|
61
|
+
/** Merge envelope metadata, which no ranking participates in. */
|
|
62
|
+
export declare function mergeEnvelopeMetadata(responses: SearchResponse[], base: SearchResponse | null): Pick<SearchResponse, 'answers' | 'suggestions' | 'unresponsiveEngines'>;
|
|
63
|
+
//# sourceMappingURL=fuse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fuse.d.ts","sourceRoot":"","sources":["../../src/deep/fuse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,WAAW,WAAW;IACxB,4EAA4E;IAC5E,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,6EAA6E;IAC7E,YAAY,CAAC,EAAE,YAAY,EAAE,CAAC;IAC9B;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1D,sEAAsE;IACtE,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,gFAAgF;IAChF,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CACxC;AAED,MAAM,WAAW,YAAY;IACzB,mDAAmD;IACnD,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,+EAA+E;IAC/E,KAAK,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5C,mEAAmE;IACnE,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IAC1C,kEAAkE;IAClE,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC5B;AAED,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAEvF;AAgBD;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,CA4C5D;AAED,iEAAiE;AACjE,wBAAgB,qBAAqB,CACjC,SAAS,EAAE,cAAc,EAAE,EAC3B,IAAI,EAAE,cAAc,GAAG,IAAI,GAC5B,IAAI,CAAC,cAAc,EAAE,SAAS,GAAG,aAAa,GAAG,qBAAqB,CAAC,CAkBzE"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn one search invocation's raw provider responses into the single ordered
|
|
3
|
+
* result set the caller prints and stores.
|
|
4
|
+
*
|
|
5
|
+
* Both search paths used to do this inline and disagreed: one fused against the
|
|
6
|
+
* whole session (including the batch it had just written) and displayed every
|
|
7
|
+
* historical result, the other fused only this run and keyed on a different
|
|
8
|
+
* identity function. This module is the one place that decides order, so
|
|
9
|
+
* `queries.length === 1` is just the case where one response came back.
|
|
10
|
+
*/
|
|
11
|
+
import { resultUrlKey } from './dedupe.js';
|
|
12
|
+
import { rrf } from './rrf.js';
|
|
13
|
+
/** Attribute a result to the tool that produced it, for session origin records. */
|
|
14
|
+
export function originTool(engine, externalProviders) {
|
|
15
|
+
return externalProviders.includes(engine) ? engine : 'digdig';
|
|
16
|
+
}
|
|
17
|
+
function toRanking(results) {
|
|
18
|
+
// Within one ranking an id must be unique, or RRF counts it twice: it scores
|
|
19
|
+
// by array position, and the same id at two positions earns two terms.
|
|
20
|
+
const seen = new Set();
|
|
21
|
+
const ranking = [];
|
|
22
|
+
for (const result of results) {
|
|
23
|
+
const id = resultUrlKey(result);
|
|
24
|
+
if (seen.has(id))
|
|
25
|
+
continue;
|
|
26
|
+
seen.add(id);
|
|
27
|
+
ranking.push({ id });
|
|
28
|
+
}
|
|
29
|
+
return ranking;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Fuse responses into one ranking.
|
|
33
|
+
*
|
|
34
|
+
* The order of the steps is the contract:
|
|
35
|
+
* 1. dedupe inside every ranking, so no id votes twice in the same list;
|
|
36
|
+
* 2. rank the extra lists (merge file, then the session snapshot);
|
|
37
|
+
* 3. fuse;
|
|
38
|
+
* 4. project — current results win over history for content, and truncation
|
|
39
|
+
* happens once, at the end.
|
|
40
|
+
*/
|
|
41
|
+
export function fuseResults(input) {
|
|
42
|
+
const rankings = input.responses.map(response => toRanking(response.results));
|
|
43
|
+
if (input.mergeResults?.length)
|
|
44
|
+
rankings.push(toRanking(input.mergeResults));
|
|
45
|
+
if (input.sessionSnapshot?.length)
|
|
46
|
+
rankings.push(toRanking(input.sessionSnapshot));
|
|
47
|
+
const fused = rankings.length > 0 ? rrf(rankings) : [];
|
|
48
|
+
const originsByKey = new Map();
|
|
49
|
+
const currentKeys = new Set();
|
|
50
|
+
const current = new Map();
|
|
51
|
+
for (const response of input.responses) {
|
|
52
|
+
for (const result of response.results) {
|
|
53
|
+
const key = resultUrlKey(result);
|
|
54
|
+
currentKeys.add(key);
|
|
55
|
+
// First provider to return a URL supplies its body and its source score;
|
|
56
|
+
// the others still contribute an origin, and RRF weighs the repeat.
|
|
57
|
+
if (!current.has(key))
|
|
58
|
+
current.set(key, result);
|
|
59
|
+
const origins = originsByKey.get(key) ?? [];
|
|
60
|
+
origins.push({
|
|
61
|
+
tool: (input.toolFor ?? (() => 'digdig'))(result.engine),
|
|
62
|
+
engine: result.engine,
|
|
63
|
+
query: response.query,
|
|
64
|
+
});
|
|
65
|
+
originsByKey.set(key, origins);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Only a current result can be displayed, so only a current result needs a body.
|
|
69
|
+
for (const result of input.mergeResults ?? []) {
|
|
70
|
+
const key = resultUrlKey(result);
|
|
71
|
+
if (!current.has(key))
|
|
72
|
+
current.set(key, result);
|
|
73
|
+
}
|
|
74
|
+
const projected = [];
|
|
75
|
+
for (const item of fused) {
|
|
76
|
+
if (input.onlyCurrent && !currentKeys.has(item.id))
|
|
77
|
+
continue;
|
|
78
|
+
const original = current.get(item.id);
|
|
79
|
+
if (!original)
|
|
80
|
+
continue;
|
|
81
|
+
projected.push({ ...original, fusionScore: item.score });
|
|
82
|
+
}
|
|
83
|
+
const display = input.limit > 0 ? projected.slice(0, input.limit) : projected;
|
|
84
|
+
return { display, fused, originsByKey, currentKeys };
|
|
85
|
+
}
|
|
86
|
+
/** Merge envelope metadata, which no ranking participates in. */
|
|
87
|
+
export function mergeEnvelopeMetadata(responses, base) {
|
|
88
|
+
const answers = [];
|
|
89
|
+
const suggestions = [];
|
|
90
|
+
const unresponsiveEngines = [];
|
|
91
|
+
const add = (target, values) => {
|
|
92
|
+
for (const value of values)
|
|
93
|
+
if (!target.includes(value))
|
|
94
|
+
target.push(value);
|
|
95
|
+
};
|
|
96
|
+
for (const response of responses) {
|
|
97
|
+
add(answers, response.answers ?? []);
|
|
98
|
+
add(suggestions, response.suggestions ?? []);
|
|
99
|
+
add(unresponsiveEngines, (response.unresponsiveEngines ?? []).map(item => Array.isArray(item) ? item[0] : item));
|
|
100
|
+
}
|
|
101
|
+
if (base) {
|
|
102
|
+
add(answers, base.answers ?? []);
|
|
103
|
+
add(suggestions, base.suggestions ?? []);
|
|
104
|
+
add(unresponsiveEngines, (base.unresponsiveEngines ?? []).map(item => Array.isArray(item) ? item[0] : item));
|
|
105
|
+
}
|
|
106
|
+
return { answers, suggestions, unresponsiveEngines };
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=fuse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fuse.js","sourceRoot":"","sources":["../../src/deep/fuse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAgB,MAAM,UAAU,CAAC;AAmC7C,mFAAmF;AACnF,MAAM,UAAU,UAAU,CAAC,MAAc,EAAE,iBAAoC;IAC3E,OAAO,iBAAiB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;AAClE,CAAC;AAED,SAAS,SAAS,CAAC,OAAwD;IACvE,6EAA6E;IAC7E,uEAAuE;IACvE,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,OAAO,GAAmB,EAAE,CAAC;IACnC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC3B,MAAM,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QAChC,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,SAAS;QAC3B,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CAAC,KAAkB;IAC1C,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9E,IAAI,KAAK,CAAC,YAAY,EAAE,MAAM;QAAE,QAAQ,CAAC,IAAI,CA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AAM,CAAC,QAAQ,CAAC,KAAK,CAAC;gBAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChF,CAAC,CAAC;IACF,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QAC/B,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;QACrC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;QAC7C,GAAG,CAAC,mBAAmB,EAAE,CAAC,QAAQ,CAAC,mBAAmB,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACrH,CAAC;IACD,IAAI,IAAI,EAAE,CAAC;QACP,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;QACjC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;QACzC,GAAG,CAAC,mBAAmB,EAAE,CAAC,IAAI,CAAC,mBAAmB,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACjH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC;AACzD,CAAC"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/deep/graph.d.ts
CHANGED
|
File without changes
|
package/dist/deep/graph.d.ts.map
CHANGED
|
File without changes
|
package/dist/deep/graph.js
CHANGED
|
File without changes
|
package/dist/deep/graph.js.map
CHANGED
|
File without changes
|
package/dist/deep/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { rrf, RrfInputItem, RrfOutputItem } from './rrf.js';
|
|
5
5
|
export { SimHash } from './simhash.js';
|
|
6
|
-
export { dedupe, dedupeByUrl, dedupeByJaccard, jaccardSimilarity,
|
|
6
|
+
export { dedupe, dedupeByUrl, dedupeByJaccard, jaccardSimilarity, resultUrlKey, DedupItem } from './dedupe.js';
|
|
7
7
|
export { ContentExtractor, ExtractedContent } from './extractor.js';
|
|
8
8
|
export { createGraph, entityId, resultId, queryId, domainId, buildStructuralEdges, bfsSubgraph, serializeGraph, deserializeGraph, graphStats, GraphNodeAttrs, GraphEdgeAttrs } from './graph.js';
|
|
9
9
|
export { initSessionDir, resolveSessionPath, appendSessionResults, updateSessionGraph, loadSessionResults, mergeExtractedContent, SessionResult } from './session.js';
|
package/dist/deep/index.d.ts.map
CHANGED
|
File without changes
|
package/dist/deep/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { rrf } from './rrf.js';
|
|
5
5
|
export { SimHash } from './simhash.js';
|
|
6
|
-
export { dedupe, dedupeByUrl, dedupeByJaccard, jaccardSimilarity,
|
|
6
|
+
export { dedupe, dedupeByUrl, dedupeByJaccard, jaccardSimilarity, resultUrlKey } from './dedupe.js';
|
|
7
7
|
export { ContentExtractor } from './extractor.js';
|
|
8
8
|
export { createGraph, entityId, resultId, queryId, domainId, buildStructuralEdges, bfsSubgraph, serializeGraph, deserializeGraph, graphStats } from './graph.js';
|
|
9
9
|
export { initSessionDir, resolveSessionPath, appendSessionResults, updateSessionGraph, loadSessionResults, mergeExtractedContent } from './session.js';
|
package/dist/deep/index.js.map
CHANGED
|
File without changes
|
|
@@ -3,33 +3,29 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Composes the individual data modules into a single analysis call:
|
|
5
5
|
* - checkQueryRedundancy
|
|
6
|
-
* -
|
|
6
|
+
* - buildPendingReport
|
|
7
7
|
* - generateQuerySuggestions
|
|
8
|
-
* - analyzeRecoveryOptions
|
|
9
8
|
* - getStrategyInfo
|
|
10
9
|
*
|
|
11
|
-
* Agent can call getSessionAnalysis() to get a
|
|
12
|
-
*
|
|
10
|
+
* Agent can call getSessionAnalysis() to get a snapshot of the session state
|
|
11
|
+
* for decision-making. It reports what is there and what has been searched;
|
|
12
|
+
* it does not say whether that is enough.
|
|
13
13
|
*/
|
|
14
14
|
import { DirectedGraph } from 'graphology';
|
|
15
15
|
import { GraphNodeAttrs, GraphEdgeAttrs } from './graph.js';
|
|
16
16
|
import { SessionResult } from './session.js';
|
|
17
|
-
import {
|
|
17
|
+
import { PendingReport } from './pending-facts.js';
|
|
18
18
|
import { QuerySuggestionData } from './query-suggest.js';
|
|
19
19
|
import { StrategyConfig, StrategyInfo } from './search-strategy.js';
|
|
20
|
-
import { RecoveryAnalysis } from './recovery-analysis.js';
|
|
21
20
|
import { RedundancyConfig, RedundancyResult } from './query-redundancy.js';
|
|
22
21
|
export interface SessionAnalysis {
|
|
23
|
-
|
|
22
|
+
pending: PendingReport;
|
|
24
23
|
strategy: StrategyInfo;
|
|
25
24
|
suggestions: QuerySuggestionData;
|
|
26
|
-
recovery: RecoveryAnalysis;
|
|
27
25
|
}
|
|
28
|
-
/** Get a
|
|
29
|
-
* Combines
|
|
30
|
-
|
|
31
|
-
export declare function getSessionAnalysis(graph: DirectedGraph<GraphNodeAttrs, GraphEdgeAttrs>, sessionResults: SessionResult[], options?: {
|
|
32
|
-
qualityThresholds?: Partial<QualityThresholds>;
|
|
26
|
+
/** Get a snapshot of the current session state.
|
|
27
|
+
* Combines counted facts, strategy info, and query suggestions. */
|
|
28
|
+
export declare function getSessionAnalysis(graph: DirectedGraph<GraphNodeAttrs, GraphEdgeAttrs>, sessionResults: SessionResult[], pending: SessionResult[], options?: {
|
|
33
29
|
strategyConfig?: Partial<StrategyConfig>;
|
|
34
30
|
}): SessionAnalysis;
|
|
35
31
|
/** Check a new query for redundancy before execution.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iteration-data.d.ts","sourceRoot":"","sources":["../../src/deep/iteration-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"iteration-data.d.ts","sourceRoot":"","sources":["../../src/deep/iteration-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAsB,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAyC,MAAM,oBAAoB,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,YAAY,EAAmB,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAwB,MAAM,uBAAuB,CAAC;AAIjG,MAAM,WAAW,eAAe;IAC5B,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,YAAY,CAAC;IACvB,WAAW,EAAE,mBAAmB,CAAC;CACpC;AAID;oEACoE;AACpE,wBAAgB,kBAAkB,CAC9B,KAAK,EAAE,aAAa,CAAC,cAAc,EAAE,cAAc,CAAC,EACpD,cAAc,EAAE,aAAa,EAAE,EA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