@seanhogg/builderforce-memory 2026.10.71 → 2026.10.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/knowledge/coChange.d.ts +3 -1
- package/dist/knowledge/coChange.d.ts.map +1 -1
- package/dist/knowledge/coChange.js +24 -12
- package/dist/knowledge/coChange.js.map +1 -1
- package/dist/knowledge/extractFile.d.ts +10 -0
- package/dist/knowledge/extractFile.d.ts.map +1 -1
- package/dist/knowledge/extractFile.js +16 -5
- package/dist/knowledge/extractFile.js.map +1 -1
- package/dist/knowledge/extractJob.d.ts +18 -1
- package/dist/knowledge/extractJob.d.ts.map +1 -1
- package/dist/knowledge/extractJob.js +10 -4
- package/dist/knowledge/extractJob.js.map +1 -1
- package/dist/knowledge/facts/extractorVersion.d.ts +45 -0
- package/dist/knowledge/facts/extractorVersion.d.ts.map +1 -0
- package/dist/knowledge/facts/extractorVersion.js +56 -0
- package/dist/knowledge/facts/extractorVersion.js.map +1 -0
- package/dist/knowledge/facts/fileFacts.d.ts +166 -0
- package/dist/knowledge/facts/fileFacts.d.ts.map +1 -0
- package/dist/knowledge/facts/fileFacts.js +156 -0
- package/dist/knowledge/facts/fileFacts.js.map +1 -0
- package/dist/knowledge/findings.d.ts +17 -14
- package/dist/knowledge/findings.d.ts.map +1 -1
- package/dist/knowledge/findings.js +29 -129
- package/dist/knowledge/findings.js.map +1 -1
- package/dist/knowledge/index.d.ts +13 -1
- package/dist/knowledge/index.d.ts.map +1 -1
- package/dist/knowledge/index.js +8 -1
- package/dist/knowledge/index.js.map +1 -1
- package/dist/knowledge/model.d.ts +6 -0
- package/dist/knowledge/model.d.ts.map +1 -1
- package/dist/knowledge/owedFiles.d.ts +14 -4
- package/dist/knowledge/owedFiles.d.ts.map +1 -1
- package/dist/knowledge/owedFiles.js +30 -8
- package/dist/knowledge/owedFiles.js.map +1 -1
- package/dist/knowledge/plan.d.ts +10 -1
- package/dist/knowledge/plan.d.ts.map +1 -1
- package/dist/knowledge/plan.js +9 -4
- package/dist/knowledge/plan.js.map +1 -1
- package/dist/knowledge/review.js +1 -0
- package/dist/knowledge/review.js.map +1 -1
- package/dist/knowledge/reviewContext.d.ts.map +1 -1
- package/dist/knowledge/reviewContext.js +5 -2
- package/dist/knowledge/reviewContext.js.map +1 -1
- package/dist/knowledge/reviewFinish.d.ts.map +1 -1
- package/dist/knowledge/reviewFinish.js +3 -1
- package/dist/knowledge/reviewFinish.js.map +1 -1
- package/dist/knowledge/reviewModel.d.ts +12 -0
- package/dist/knowledge/reviewModel.d.ts.map +1 -1
- package/dist/knowledge/reviewPrefetch.d.ts +2 -0
- package/dist/knowledge/reviewPrefetch.d.ts.map +1 -1
- package/dist/knowledge/reviewPrefetch.js +1 -0
- package/dist/knowledge/reviewPrefetch.js.map +1 -1
- package/dist/knowledge/rules/cloneGroup.d.ts +10 -0
- package/dist/knowledge/rules/cloneGroup.d.ts.map +1 -0
- package/dist/knowledge/rules/cloneGroup.js +46 -0
- package/dist/knowledge/rules/cloneGroup.js.map +1 -0
- package/dist/knowledge/rules/components.d.ts +8 -0
- package/dist/knowledge/rules/components.d.ts.map +1 -0
- package/dist/knowledge/rules/components.js +34 -0
- package/dist/knowledge/rules/components.js.map +1 -0
- package/dist/knowledge/rules/cycle.d.ts +7 -0
- package/dist/knowledge/rules/cycle.d.ts.map +1 -0
- package/dist/knowledge/rules/cycle.js +18 -0
- package/dist/knowledge/rules/cycle.js.map +1 -0
- package/dist/knowledge/rules/duplicateCopy.d.ts +7 -0
- package/dist/knowledge/rules/duplicateCopy.d.ts.map +1 -0
- package/dist/knowledge/rules/duplicateCopy.js +18 -0
- package/dist/knowledge/rules/duplicateCopy.js.map +1 -0
- package/dist/knowledge/rules/evaluateRules.d.ts +60 -0
- package/dist/knowledge/rules/evaluateRules.d.ts.map +1 -0
- package/dist/knowledge/rules/evaluateRules.js +164 -0
- package/dist/knowledge/rules/evaluateRules.js.map +1 -0
- package/dist/knowledge/rules/factGraph.d.ts +51 -0
- package/dist/knowledge/rules/factGraph.d.ts.map +1 -0
- package/dist/knowledge/rules/factGraph.js +77 -0
- package/dist/knowledge/rules/factGraph.js.map +1 -0
- package/dist/knowledge/rules/factRule.d.ts +56 -0
- package/dist/knowledge/rules/factRule.d.ts.map +1 -0
- package/dist/knowledge/rules/factRule.js +46 -0
- package/dist/knowledge/rules/factRule.js.map +1 -0
- package/dist/knowledge/rules/godModule.d.ts +8 -0
- package/dist/knowledge/rules/godModule.d.ts.map +1 -0
- package/dist/knowledge/rules/godModule.js +16 -0
- package/dist/knowledge/rules/godModule.js.map +1 -0
- package/dist/knowledge/rules/knowledgeInput.d.ts +35 -0
- package/dist/knowledge/rules/knowledgeInput.d.ts.map +1 -0
- package/dist/knowledge/rules/knowledgeInput.js +33 -0
- package/dist/knowledge/rules/knowledgeInput.js.map +1 -0
- package/dist/knowledge/rules/nearDuplicate.d.ts +7 -0
- package/dist/knowledge/rules/nearDuplicate.d.ts.map +1 -0
- package/dist/knowledge/rules/nearDuplicate.js +20 -0
- package/dist/knowledge/rules/nearDuplicate.js.map +1 -0
- package/dist/knowledge/rules/partitionViolation.d.ts +10 -0
- package/dist/knowledge/rules/partitionViolation.d.ts.map +1 -0
- package/dist/knowledge/rules/partitionViolation.js +27 -0
- package/dist/knowledge/rules/partitionViolation.js.map +1 -0
- package/dist/knowledge/rules/possibleSame.d.ts +7 -0
- package/dist/knowledge/rules/possibleSame.d.ts.map +1 -0
- package/dist/knowledge/rules/possibleSame.js +15 -0
- package/dist/knowledge/rules/possibleSame.js.map +1 -0
- package/dist/knowledge/rules/stale.d.ts +7 -0
- package/dist/knowledge/rules/stale.d.ts.map +1 -0
- package/dist/knowledge/rules/stale.js +28 -0
- package/dist/knowledge/rules/stale.js.map +1 -0
- package/dist/knowledge/rules/unpartitioned.d.ts +7 -0
- package/dist/knowledge/rules/unpartitioned.d.ts.map +1 -0
- package/dist/knowledge/rules/unpartitioned.js +26 -0
- package/dist/knowledge/rules/unpartitioned.js.map +1 -0
- package/dist/knowledge/sources.d.ts +13 -0
- package/dist/knowledge/sources.d.ts.map +1 -1
- package/dist/knowledge/sources.js +14 -0
- package/dist/knowledge/sources.js.map +1 -1
- package/dist/retrieval/knowledge-index/sha256.d.ts.map +1 -1
- package/dist/retrieval/knowledge-index/sha256.js +2 -2
- package/dist/retrieval/knowledge-index/sha256.js.map +1 -1
- package/dist/stats/distributions.d.ts +17 -1
- package/dist/stats/distributions.d.ts.map +1 -1
- package/dist/stats/distributions.js +26 -1
- package/dist/stats/distributions.js.map +1 -1
- package/dist/stats/fitting.d.ts.map +1 -1
- package/dist/stats/fitting.js +1 -6
- package/dist/stats/fitting.js.map +1 -1
- package/dist/stats/index.d.ts +10 -3
- package/dist/stats/index.d.ts.map +1 -1
- package/dist/stats/index.js +10 -3
- package/dist/stats/index.js.map +1 -1
- package/dist/stats/logistic.d.ts +30 -0
- package/dist/stats/logistic.d.ts.map +1 -0
- package/dist/stats/logistic.js +43 -0
- package/dist/stats/logistic.js.map +1 -0
- package/dist/stats/multivariate.d.ts +8 -13
- package/dist/stats/multivariate.d.ts.map +1 -1
- package/dist/stats/multivariate.js +7 -53
- package/dist/stats/multivariate.js.map +1 -1
- package/dist/stats/policies.d.ts.map +1 -1
- package/dist/stats/policies.js +4 -22
- package/dist/stats/policies.js.map +1 -1
- package/package.json +4 -3
- package/src/contract/exports.snapshot.json +37 -1
- package/src/contract/regression.extractorKey.test.ts +202 -0
- package/src/contract/regression.statsEngineFree.test.ts +70 -0
- package/src/contract/regression.thompsonDeterminism.test.ts +23 -0
- package/src/contract/types.contract.test.ts +59 -2
- package/src/knowledge/coChange.test.ts +15 -2
- package/src/knowledge/coChange.ts +22 -10
- package/src/knowledge/extractFile.ts +27 -5
- package/src/knowledge/extractJob.ts +24 -5
- package/src/knowledge/facts/extractorVersion.ts +73 -0
- package/src/knowledge/facts/fileFacts.test.ts +157 -0
- package/src/knowledge/facts/fileFacts.ts +305 -0
- package/src/knowledge/findings.ts +30 -127
- package/src/knowledge/index.ts +19 -0
- package/src/knowledge/model.ts +6 -0
- package/src/knowledge/owedFiles.ts +36 -8
- package/src/knowledge/plan.ts +16 -4
- package/src/knowledge/review.ts +1 -0
- package/src/knowledge/reviewContext.ts +5 -2
- package/src/knowledge/reviewFinish.ts +3 -1
- package/src/knowledge/reviewModel.ts +12 -0
- package/src/knowledge/reviewPrefetch.ts +3 -0
- package/src/knowledge/rules/cloneGroup.ts +45 -0
- package/src/knowledge/rules/components.ts +31 -0
- package/src/knowledge/rules/cycle.ts +20 -0
- package/src/knowledge/rules/duplicateCopy.ts +22 -0
- package/src/knowledge/rules/evaluateRules.test.ts +172 -0
- package/src/knowledge/rules/evaluateRules.ts +186 -0
- package/src/knowledge/rules/factGraph.oracle.test.ts +174 -0
- package/src/knowledge/rules/factGraph.ts +107 -0
- package/src/knowledge/rules/factRule.ts +74 -0
- package/src/knowledge/rules/godModule.ts +18 -0
- package/src/knowledge/rules/knowledgeInput.ts +60 -0
- package/src/knowledge/rules/knowledgeRules.test.ts +78 -0
- package/src/knowledge/rules/nearDuplicate.ts +22 -0
- package/src/knowledge/rules/partitionViolation.ts +31 -0
- package/src/knowledge/rules/possibleSame.ts +17 -0
- package/src/knowledge/rules/rules.testkit.test-util.ts +78 -0
- package/src/knowledge/rules/stale.ts +31 -0
- package/src/knowledge/rules/unpartitioned.ts +27 -0
- package/src/knowledge/sources.ts +16 -0
- package/src/retrieval/knowledge-index/sha256.test.ts +25 -0
- package/src/retrieval/knowledge-index/sha256.ts +2 -1
- package/src/stats/distributions.ts +29 -2
- package/src/stats/fitting.ts +1 -6
- package/src/stats/index.ts +12 -2
- package/src/stats/logistic.test.ts +89 -0
- package/src/stats/logistic.ts +49 -0
- package/src/stats/multivariate.ts +8 -59
- package/src/stats/policies.ts +4 -24
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/rules/factGraph.ts — the content-addressed fact graph in memory (PRD 41 §B1, §B8.6): the
|
|
3
|
+
* manifest (path → content hash, facts hash, kind hashes), the facts objects by facts hash, and the
|
|
4
|
+
* derived rule rows with their traces. Pure and immutable: an update returns a new graph.
|
|
5
|
+
*
|
|
6
|
+
* {@link factGraphDump} is the canonical dump the determinism oracle compares: sorted canonical JSON of
|
|
7
|
+
* the manifest, the referenced objects and the derived rows — never a trace outcome, a time or an order of
|
|
8
|
+
* arrival. An incremental graph and a from-scratch build of the same files dump to the same bytes.
|
|
9
|
+
* A durable host persists the same three tables behind its store; this module does no I/O.
|
|
10
|
+
*/
|
|
11
|
+
import type { Finding } from '../findingModel.js';
|
|
12
|
+
import { type FactKind, type FileFacts } from '../facts/fileFacts.js';
|
|
13
|
+
import type { FactRule } from './factRule.js';
|
|
14
|
+
import { type DerivedRows, type RuleTraceEntry, type RuleWorld } from './evaluateRules.js';
|
|
15
|
+
export interface FactManifestEntry {
|
|
16
|
+
contentHash: string;
|
|
17
|
+
factsHash: string;
|
|
18
|
+
kinds: Readonly<Record<FactKind, string>>;
|
|
19
|
+
}
|
|
20
|
+
export interface FactGraph {
|
|
21
|
+
manifest: ReadonlyMap<string, FactManifestEntry>;
|
|
22
|
+
/** Facts by facts hash — only those the manifest references. */
|
|
23
|
+
objects: ReadonlyMap<string, FileFacts>;
|
|
24
|
+
derived: DerivedRows;
|
|
25
|
+
}
|
|
26
|
+
/** One file's new facts, or `null` when it was deleted. A rename is a delete plus an add. */
|
|
27
|
+
export interface FactChange {
|
|
28
|
+
path: string;
|
|
29
|
+
facts: FileFacts | null;
|
|
30
|
+
}
|
|
31
|
+
export type FactGraphOptions<X> = Pick<RuleWorld<X>, 'neighbours' | 'extra' | 'extraHashes'>;
|
|
32
|
+
export interface FactGraphUpdate {
|
|
33
|
+
graph: FactGraph;
|
|
34
|
+
trace: RuleTraceEntry[];
|
|
35
|
+
findings: Finding[];
|
|
36
|
+
/** Paths whose facts hash changed (added, edited or deleted), sorted. Empty ⇒ every rule row was reused (early cutoff). */
|
|
37
|
+
changed: string[];
|
|
38
|
+
}
|
|
39
|
+
/** The current dump format. */
|
|
40
|
+
export declare const FACT_GRAPH_DUMP_VERSION = 1;
|
|
41
|
+
export declare const emptyFactGraph: () => FactGraph;
|
|
42
|
+
/**
|
|
43
|
+
* Applies `changes` (the last change of a path wins) and re-evaluates `rules`, reusing every derived row whose
|
|
44
|
+
* trace still holds. Unreferenced objects are dropped, so the graph never depends on its history.
|
|
45
|
+
*/
|
|
46
|
+
export declare function updateFactGraph<X>(graph: FactGraph, changes: readonly FactChange[], rules: readonly FactRule<X>[], opts?: FactGraphOptions<X>): FactGraphUpdate;
|
|
47
|
+
/** A from-scratch build: every file added to an empty graph. */
|
|
48
|
+
export declare function buildFactGraph<X>(files: Iterable<readonly [string, FileFacts]>, rules: readonly FactRule<X>[], opts?: FactGraphOptions<X>): FactGraphUpdate;
|
|
49
|
+
/** The canonical dump: sorted canonical JSON of the manifest, the referenced objects and the derived rows. */
|
|
50
|
+
export declare function factGraphDump(graph: FactGraph): string;
|
|
51
|
+
//# sourceMappingURL=factGraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factGraph.d.ts","sourceRoot":"","sources":["../../../src/knowledge/rules/factGraph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAiD,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACrH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAiB,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE1G,MAAM,WAAW,iBAAiB;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC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wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAQtD"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/rules/factGraph.ts — the content-addressed fact graph in memory (PRD 41 §B1, §B8.6): the
|
|
3
|
+
* manifest (path → content hash, facts hash, kind hashes), the facts objects by facts hash, and the
|
|
4
|
+
* derived rule rows with their traces. Pure and immutable: an update returns a new graph.
|
|
5
|
+
*
|
|
6
|
+
* {@link factGraphDump} is the canonical dump the determinism oracle compares: sorted canonical JSON of
|
|
7
|
+
* the manifest, the referenced objects and the derived rows — never a trace outcome, a time or an order of
|
|
8
|
+
* arrival. An incremental graph and a from-scratch build of the same files dump to the same bytes.
|
|
9
|
+
* A durable host persists the same three tables behind its store; this module does no I/O.
|
|
10
|
+
*/
|
|
11
|
+
import { canonicalJson, compareStr, isRootFilePath, normalizePath } from '../refs.js';
|
|
12
|
+
import { canonicalFileFacts, factKindHashes, factsHash } from '../facts/fileFacts.js';
|
|
13
|
+
import { evaluateRules } from './evaluateRules.js';
|
|
14
|
+
/** The current dump format. */
|
|
15
|
+
export const FACT_GRAPH_DUMP_VERSION = 1;
|
|
16
|
+
export const emptyFactGraph = () => ({ manifest: new Map(), objects: new Map(), derived: new Map() });
|
|
17
|
+
/** The ONE path form of the graph (§B8.1); throws `fact_graph_bad_path` for a path outside the root. */
|
|
18
|
+
function pathOf(raw) {
|
|
19
|
+
const p = normalizePath(raw);
|
|
20
|
+
if (!isRootFilePath(p))
|
|
21
|
+
throw new Error(`fact_graph_bad_path:${raw}`);
|
|
22
|
+
return p;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Applies `changes` (the last change of a path wins) and re-evaluates `rules`, reusing every derived row whose
|
|
26
|
+
* trace still holds. Unreferenced objects are dropped, so the graph never depends on its history.
|
|
27
|
+
*/
|
|
28
|
+
export function updateFactGraph(graph, changes, rules, opts = {}) {
|
|
29
|
+
const manifest = new Map(graph.manifest);
|
|
30
|
+
const objects = new Map(graph.objects);
|
|
31
|
+
const touched = new Set();
|
|
32
|
+
for (const c of changes) {
|
|
33
|
+
const path = pathOf(c.path);
|
|
34
|
+
touched.add(path);
|
|
35
|
+
if (c.facts === null) {
|
|
36
|
+
manifest.delete(path);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
// Canonical facts are deep-frozen: the stored object can never be mutated under its hash.
|
|
40
|
+
const facts = canonicalFileFacts(c.facts);
|
|
41
|
+
const hash = factsHash(facts);
|
|
42
|
+
if (manifest.get(path)?.factsHash === hash)
|
|
43
|
+
continue;
|
|
44
|
+
if (!objects.has(hash))
|
|
45
|
+
objects.set(hash, facts);
|
|
46
|
+
manifest.set(path, { contentHash: facts.contentHash, factsHash: hash, kinds: factKindHashes(objects.get(hash)) });
|
|
47
|
+
}
|
|
48
|
+
// Against the PRE-batch manifest, so a path edited and reverted (or added and deleted) in one batch is no change.
|
|
49
|
+
const changed = [...touched].filter((p) => graph.manifest.get(p)?.factsHash !== manifest.get(p)?.factsHash);
|
|
50
|
+
const live = new Set([...manifest.values()].map((e) => e.factsHash));
|
|
51
|
+
for (const h of [...objects.keys()])
|
|
52
|
+
if (!live.has(h))
|
|
53
|
+
objects.delete(h);
|
|
54
|
+
const files = new Map([...manifest].map(([p, e]) => [p, objects.get(e.factsHash)]));
|
|
55
|
+
const result = evaluateRules(rules, { files, ...opts }, graph.derived);
|
|
56
|
+
return {
|
|
57
|
+
graph: { manifest, objects, derived: result.rows },
|
|
58
|
+
trace: result.trace,
|
|
59
|
+
findings: result.findings,
|
|
60
|
+
changed: changed.sort(compareStr),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** A from-scratch build: every file added to an empty graph. */
|
|
64
|
+
export function buildFactGraph(files, rules, opts = {}) {
|
|
65
|
+
return updateFactGraph(emptyFactGraph(), [...files].map(([path, facts]) => ({ path, facts })), rules, opts);
|
|
66
|
+
}
|
|
67
|
+
/** The canonical dump: sorted canonical JSON of the manifest, the referenced objects and the derived rows. */
|
|
68
|
+
export function factGraphDump(graph) {
|
|
69
|
+
const sortedEntries = (m) => [...m].sort((a, b) => compareStr(a[0], b[0]));
|
|
70
|
+
return canonicalJson({
|
|
71
|
+
version: FACT_GRAPH_DUMP_VERSION,
|
|
72
|
+
manifest: sortedEntries(graph.manifest).map(([path, e]) => ({ path, ...e })),
|
|
73
|
+
objects: sortedEntries(graph.objects).map(([hash, facts]) => ({ hash, facts })),
|
|
74
|
+
derived: sortedEntries(graph.derived).map(([, row]) => row),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=factGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factGraph.js","sourceRoot":"","sources":["../../../src/knowledge/rules/factGraph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEtF,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,SAAS,EAAiC,MAAM,uBAAuB,CAAC;AAErH,OAAO,EAAE,aAAa,EAAyD,MAAM,oBAAoB,CAAC;AA+B1G,+BAA+B;AAC/B,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAEzC,MAAM,CAAC,MAAM,cAAc,GAAG,GAAc,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC,CAAC;AAEjH,wGAAwG;AACxG,SAAS,MAAM,CAAC,GAAW;IACvB,MAAM,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,EAAE,CAAC,CAAC;IACtE,OAAO,CAAC,C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AE,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AAChH,CAAC;AAED,8GAA8G;AAC9G,MAAM,UAAU,aAAa,CAAC,KAAgB;IAC1C,MAAM,aAAa,GAAG,CAAI,CAAyB,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtG,OAAO,aAAa,CAAC;QACjB,OAAO,EAAE,uBAAuB;QAChC,QAAQ,EAAE,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5E,OAAO,EAAE,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/E,OAAO,EAAE,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC;KAC9D,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/rules/factRule.ts — the FactRule contract (PRD 41 §B5): derived knowledge as rules over facts.
|
|
3
|
+
*
|
|
4
|
+
* A rule declares what it READS (fact kinds, and optionally named non-fact inputs such as the knowledge
|
|
5
|
+
* graph), its SCOPE, and for a neighbourhood rule its HOPS. The evaluator (evaluateRules.ts) uses exactly
|
|
6
|
+
* those declarations as the rule's dependency trace: a rule reruns only when one of its read inputs changed
|
|
7
|
+
* (Build Systems à la Carte: verifying traces + early cutoff). So `derive` must read nothing else — the
|
|
8
|
+
* determinism oracle (factGraph.oracle.test.ts) catches a rule that does.
|
|
9
|
+
*
|
|
10
|
+
* - `file`: one evaluation per file, reading that file's facts.
|
|
11
|
+
* - `neighbourhood`: one per file, reading the file plus its import neighbours up to `hops` (default 1,
|
|
12
|
+
* max 2), plus — with `readsGuardChain` — the guard-chain files of its entry points.
|
|
13
|
+
* - `global`: one evaluation, reading every file.
|
|
14
|
+
*
|
|
15
|
+
* One rule per file under knowledge/rules/, registered as data (findings.ts is the generic registry).
|
|
16
|
+
*/
|
|
17
|
+
import type { Finding } from '../findingModel.js';
|
|
18
|
+
import type { FactKind, FileFacts } from '../facts/fileFacts.js';
|
|
19
|
+
export type RuleScope = 'file' | 'neighbourhood' | 'global';
|
|
20
|
+
export declare const DEFAULT_RULE_HOPS = 1;
|
|
21
|
+
/** The C2 impact-set bound: a neighbourhood never reaches further than this. */
|
|
22
|
+
export declare const MAX_RULE_HOPS = 2;
|
|
23
|
+
/** What one evaluation of a rule sees. */
|
|
24
|
+
export interface RuleInput<X = Record<never, never>> {
|
|
25
|
+
scope: RuleScope;
|
|
26
|
+
/** `file` / `neighbourhood`: the file the evaluation is for. Absent for `global`. */
|
|
27
|
+
focus?: string;
|
|
28
|
+
/** The facts in scope, by root-relative path (iterate in sorted order): the focus; the focus plus its neighbourhood; every file. */
|
|
29
|
+
files: ReadonlyMap<string, FileFacts>;
|
|
30
|
+
/** The named non-fact inputs the host supplies (only those the rule declares in `extraInputs` are part of its trace). */
|
|
31
|
+
extra: X;
|
|
32
|
+
}
|
|
33
|
+
export interface FactRule<X = Record<never, never>> {
|
|
34
|
+
/** 'cycle', 'partition-violation', 'unused-export', 'io-in-loop', … */
|
|
35
|
+
id: string;
|
|
36
|
+
/** Bump whenever `derive` can return different findings for the same inputs: it is part of the cache key. */
|
|
37
|
+
version: number;
|
|
38
|
+
/** The fact kinds it consumes — its dependency trace. Empty only for a global rule reading extra inputs alone. */
|
|
39
|
+
reads: readonly FactKind[];
|
|
40
|
+
scope: RuleScope;
|
|
41
|
+
/** Neighbourhood rules: import hops to read around the focus (1 or 2). */
|
|
42
|
+
hops?: number;
|
|
43
|
+
/** Neighbourhood rules: also read the facts of the guard-chain files of the focus's entry points. */
|
|
44
|
+
readsGuardChain?: boolean;
|
|
45
|
+
/** Names of `extra` inputs `derive` reads; each needs a hash from the host (`RuleWorld.extraHashes`). */
|
|
46
|
+
extraInputs?: readonly (keyof X & string)[];
|
|
47
|
+
/** Pure. Findings sorted by id (the evaluator sorts again). */
|
|
48
|
+
derive(input: RuleInput<X>): Finding[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Validates and freezes a rule: a non-empty id, an integer version ≥ 1, known `reads` — empty only for a global rule
|
|
52
|
+
* that reads extra inputs alone (it then sees no files) — and `hops` only on a neighbourhood rule and within
|
|
53
|
+
* 1..{@link MAX_RULE_HOPS}. Throws `fact_rule_invalid:<id>:<why>`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function defineRule<X = Record<never, never>>(rule: FactRule<X>): FactRule<X>;
|
|
56
|
+
//# sourceMappingURL=factRule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factRule.d.ts","sourceRoot":"","sources":["../../../src/knowledge/rules/factRule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGjE,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,eAAe,GAAG,QAAQ,CAAC;AAE5D,eAAO,MAAM,iBAA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* A rule declares what it READS (fact kinds, and optionally named non-fact inputs such as the knowledge
|
|
5
|
+
* graph), its SCOPE, and for a neighbourhood rule its HOPS. The evaluator (evaluateRules.ts) uses exactly
|
|
6
|
+
* those declarations as the rule's dependency trace: a rule reruns only when one of its read inputs changed
|
|
7
|
+
* (Build Systems à la Carte: verifying traces + early cutoff). So `derive` must read nothing else — the
|
|
8
|
+
* determinism oracle (factGraph.oracle.test.ts) catches a rule that does.
|
|
9
|
+
*
|
|
10
|
+
* - `file`: one evaluation per file, reading that file's facts.
|
|
11
|
+
* - `neighbourhood`: one per file, reading the file plus its import neighbours up to `hops` (default 1,
|
|
12
|
+
* max 2), plus — with `readsGuardChain` — the guard-chain files of its entry points.
|
|
13
|
+
* - `global`: one evaluation, reading every file.
|
|
14
|
+
*
|
|
15
|
+
* One rule per file under knowledge/rules/, registered as data (findings.ts is the generic registry).
|
|
16
|
+
*/
|
|
17
|
+
import { FACT_KINDS } from '../facts/fileFacts.js';
|
|
18
|
+
export const DEFAULT_RULE_HOPS = 1;
|
|
19
|
+
/** The C2 impact-set bound: a neighbourhood never reaches further than this. */
|
|
20
|
+
export const MAX_RULE_HOPS = 2;
|
|
21
|
+
/**
|
|
22
|
+
* Validates and freezes a rule: a non-empty id, an integer version ≥ 1, known `reads` — empty only for a global rule
|
|
23
|
+
* that reads extra inputs alone (it then sees no files) — and `hops` only on a neighbourhood rule and within
|
|
24
|
+
* 1..{@link MAX_RULE_HOPS}. Throws `fact_rule_invalid:<id>:<why>`.
|
|
25
|
+
*/
|
|
26
|
+
export function defineRule(rule) {
|
|
27
|
+
const fail = (why) => { throw new Error(`fact_rule_invalid:${rule.id}:${why}`); };
|
|
28
|
+
if (!rule.id)
|
|
29
|
+
fail('id');
|
|
30
|
+
if (!Number.isInteger(rule.version) || rule.version < 1)
|
|
31
|
+
fail('version');
|
|
32
|
+
if (rule.reads.some((k) => !FACT_KINDS.includes(k)))
|
|
33
|
+
fail('reads');
|
|
34
|
+
if (rule.reads.length === 0 && (rule.scope !== 'global' || (rule.extraInputs ?? []).length === 0))
|
|
35
|
+
fail('reads');
|
|
36
|
+
if (rule.hops !== undefined) {
|
|
37
|
+
if (rule.scope !== 'neighbourhood')
|
|
38
|
+
fail('hops-outside-neighbourhood');
|
|
39
|
+
if (!Number.isInteger(rule.hops) || rule.hops < 1 || rule.hops > MAX_RULE_HOPS)
|
|
40
|
+
fail('hops');
|
|
41
|
+
}
|
|
42
|
+
if (rule.readsGuardChain && rule.scope !== 'neighbourhood')
|
|
43
|
+
fail('guard-chain-outside-neighbourhood');
|
|
44
|
+
return Object.freeze({ ...rule, reads: Object.freeze([...new Set(rule.reads)].sort()) });
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=factRule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factRule.js","sourceRoot":"","sources":["../../../src/knowledge/rules/factRule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAInD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AACnC,gFAAgF;AAChF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AA+B/B;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAA2B,IAAiB;IAClE,MAAM,IAAI,GAAG,CAAC,GAAW,EAAS,EAAE,GAAG,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACjG,IAAI,CAAC,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,GAAG,CAAC;QAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACzE,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACnE,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;QAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACjH,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC1B,IAAI,IAAI,CAAC,KAAK,KAAK,eAAe;YAAE,IAAI,CAAC,4BAA4B,CAAC,CAAC;QACvE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,GAAG,aAAa;YAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACjG,CAAC;IACD,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,KAAK,KAAK,eAAe;QAAE,IAAI,CAAC,mCAAmC,CAAC,CAAC;IACtG,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;AAC7F,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/rules/godModule.ts — `god-module` as a rule: the detector and its limits stay in
|
|
3
|
+
* knowledge/godModule.ts (the code pack imports the limits from there); this registers it.
|
|
4
|
+
* Reads the lines, exports and worst-function complexity badges of the file nodes of the knowledge input.
|
|
5
|
+
*/
|
|
6
|
+
import type { KnowledgeRuleExtra } from './knowledgeInput.js';
|
|
7
|
+
export declare const godModuleRule: import("./factRule.js").FactRule<KnowledgeRuleExtra>;
|
|
8
|
+
//# sourceMappingURL=godModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"godModule.d.ts","sourceRoot":"","sources":["../../../src/knowledge/rules/godModule.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,eAAO,MAAM,aAAa,sDAOxB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/rules/godModule.ts — `god-module` as a rule: the detector and its limits stay in
|
|
3
|
+
* knowledge/godModule.ts (the code pack imports the limits from there); this registers it.
|
|
4
|
+
* Reads the lines, exports and worst-function complexity badges of the file nodes of the knowledge input.
|
|
5
|
+
*/
|
|
6
|
+
import { godModuleFindings, GOD_MODULE_KIND } from '../godModule.js';
|
|
7
|
+
import { defineRule } from './factRule.js';
|
|
8
|
+
export const godModuleRule = defineRule({
|
|
9
|
+
id: GOD_MODULE_KIND,
|
|
10
|
+
version: 1,
|
|
11
|
+
reads: [], // the knowledge graph only (the measures are file-node badges)
|
|
12
|
+
scope: 'global',
|
|
13
|
+
extraInputs: ['knowledge'],
|
|
14
|
+
derive: ({ extra: { knowledge: k } }) => godModuleFindings(k.graph),
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=godModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"godModule.js","sourceRoot":"","sources":["../../../src/knowledge/rules/godModule.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAqB;IACxD,EAAE,EAAE,eAAe;IACnB,OAAO,EAAE,CAAC;IACV,KAAK,EAAE,EAAE,EAAE,+DAA+D;IAC1E,KAAK,EAAE,QAAQ;IACf,WAAW,EAAE,CAAC,WAAW,CAAC;IAC1B,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC;CACtE,CAAC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/rules/knowledgeInput.ts — the non-fact input of the generic finding rules ported from
|
|
3
|
+
* findings.ts (PRD 41 §B5): the built knowledge graph plus the partition registries and near-duplicate
|
|
4
|
+
* pairs. These rules are `global` with `reads: []` and `extraInputs: ['knowledge']`, so in an incremental
|
|
5
|
+
* evaluation they rerun exactly when {@link knowledgeInputHash} of this input moves.
|
|
6
|
+
*/
|
|
7
|
+
import type { SimilarPair } from '../../retrieval/knowledge-index/types.js';
|
|
8
|
+
import type { Finding } from '../findingModel.js';
|
|
9
|
+
import type { KNode, KnowledgeGraph, NodeRef, PartitionRegistry } from '../model.js';
|
|
10
|
+
import type { FactRule } from './factRule.js';
|
|
11
|
+
export interface KnowledgeFacts {
|
|
12
|
+
graph: KnowledgeGraph;
|
|
13
|
+
byRef: ReadonlyMap<NodeRef, KNode>;
|
|
14
|
+
registries: ReadonlyMap<string, PartitionRegistry>;
|
|
15
|
+
nearDuplicates: readonly SimilarPair[];
|
|
16
|
+
}
|
|
17
|
+
export interface KnowledgeRuleExtra {
|
|
18
|
+
knowledge: KnowledgeFacts;
|
|
19
|
+
}
|
|
20
|
+
/** A rule over the knowledge graph. */
|
|
21
|
+
export type KnowledgeRule = FactRule<KnowledgeRuleExtra>;
|
|
22
|
+
/** The extra input name the knowledge rules declare. */
|
|
23
|
+
export declare const KNOWLEDGE_INPUT = "knowledge";
|
|
24
|
+
export declare function knowledgeFacts(graph: KnowledgeGraph, registries: ReadonlyMap<string, PartitionRegistry>, nearDuplicates?: readonly SimilarPair[]): KnowledgeFacts;
|
|
25
|
+
/**
|
|
26
|
+
* THE hash a host passes as `extraHashes.knowledge`: sha256 over the canonical JSON of the graph digest, the partition
|
|
27
|
+
* registries (sorted by pack) and the near-duplicate pairs (sorted). The graph digest alone misses a registry edit
|
|
28
|
+
* (`unpartitioned`) or pairs passed beside the graph (`possible-same`).
|
|
29
|
+
*/
|
|
30
|
+
export declare function knowledgeInputHash(k: KnowledgeFacts): string;
|
|
31
|
+
/** The pack of a ref's node, else the fallback pack. */
|
|
32
|
+
export declare const packOfRef: (k: KnowledgeFacts, ref: NodeRef) => string;
|
|
33
|
+
/** Runs knowledge rules once, in registry order, non-incrementally (the `computeFindings` path). */
|
|
34
|
+
export declare function runKnowledgeRules(rules: readonly KnowledgeRule[], knowledge: KnowledgeFacts): Finding[];
|
|
35
|
+
//# sourceMappingURL=knowledgeInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledgeInput.d.ts","sourceRoot":"","sources":["../../../src/knowledge/rules/knowledgeInput.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,WAAW,cAAc;IAC3B,KAAK,EAAE,cAAc,CAAC;IACtB,KAAK,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACnC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACnD,cAAc,EAAE,SAAS,WAAW,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,kBAAkB;IAC/B,SAAS,EAAE,cAAc,CAAC;CAC7B;AAED,uCAAuC;AACvC,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,kBAAkB,CAAC,CAAC;AAEzD,wDAAwD;AACxD,eAAO,MAAM,eAAe,cAAc,CAAC;AAE3C,wBAAgB,cAAc,CAC1B,KAAK,EAAE,cAAc,EACrB,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,EAClD,cAAc,GAAE,SAAS,WAAW,EAAO,GAC5C,cAAc,CAEhB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,cAAc,GAAG,MAAM,CAM5D;AAED,wDAAwD;AACxD,eAAO,MAAM,SAAS,MAAO,cAAc,OAAO,OAAO,KAAG,MAAoD,CAAC;AAEjH,oGAAoG;AACpG,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,EAAE,SAAS,EAAE,cAAc,GAAG,OAAO,EAAE,CAGvG"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/rules/knowledgeInput.ts — the non-fact input of the generic finding rules ported from
|
|
3
|
+
* findings.ts (PRD 41 §B5): the built knowledge graph plus the partition registries and near-duplicate
|
|
4
|
+
* pairs. These rules are `global` with `reads: []` and `extraInputs: ['knowledge']`, so in an incremental
|
|
5
|
+
* evaluation they rerun exactly when {@link knowledgeInputHash} of this input moves.
|
|
6
|
+
*/
|
|
7
|
+
import { canonicalJson, compareStr, FALLBACK_PACK_ID } from '../refs.js';
|
|
8
|
+
import { sha256Hex } from '../../retrieval/knowledge-index/sha256.js';
|
|
9
|
+
/** The extra input name the knowledge rules declare. */
|
|
10
|
+
export const KNOWLEDGE_INPUT = 'knowledge';
|
|
11
|
+
export function knowledgeFacts(graph, registries, nearDuplicates = []) {
|
|
12
|
+
return { graph, byRef: new Map(graph.nodes.map((n) => [n.ref, n])), registries, nearDuplicates };
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* THE hash a host passes as `extraHashes.knowledge`: sha256 over the canonical JSON of the graph digest, the partition
|
|
16
|
+
* registries (sorted by pack) and the near-duplicate pairs (sorted). The graph digest alone misses a registry edit
|
|
17
|
+
* (`unpartitioned`) or pairs passed beside the graph (`possible-same`).
|
|
18
|
+
*/
|
|
19
|
+
export function knowledgeInputHash(k) {
|
|
20
|
+
return sha256Hex(canonicalJson({
|
|
21
|
+
digest: k.graph.scope.digest,
|
|
22
|
+
registries: [...k.registries].sort((a, b) => compareStr(a[0], b[0])),
|
|
23
|
+
nearDuplicates: k.nearDuplicates.map((p) => canonicalJson(p)).sort(compareStr),
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
/** The pack of a ref's node, else the fallback pack. */
|
|
27
|
+
export const packOfRef = (k, ref) => k.byRef.get(ref)?.pack ?? FALLBACK_PACK_ID;
|
|
28
|
+
/** Runs knowledge rules once, in registry order, non-incrementally (the `computeFindings` path). */
|
|
29
|
+
export function runKnowledgeRules(rules, knowledge) {
|
|
30
|
+
const files = new Map();
|
|
31
|
+
return rules.flatMap((r) => r.derive({ scope: r.scope, files, extra: { knowledge } }));
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=knowledgeInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledgeInput.js","sourceRoot":"","sources":["../../../src/knowledge/rules/knowledgeInput.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAiBtE,wDAAwD;AACxD,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC;AAE3C,MAAM,UAAU,cAAc,CAC1B,KAAqB,EACrB,UAAkD,EAClD,cAAc,GAA2B,EAAE;IAE3C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,GAAG,CAAC,KAA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/**
|
|
2
|
+
* knowledge/rules/nearDuplicate.ts — `near-duplicate`: one finding per near-duplicate edge.
|
|
3
|
+
* Anchor (PRD 41 §C3): the sorted-first ref of the pair.
|
|
4
|
+
*/
|
|
5
|
+
import { type KnowledgeRuleExtra } from './knowledgeInput.js';
|
|
6
|
+
export declare const nearDuplicateRule: import("./factRule.js").FactRule<KnowledgeRuleExtra>;
|
|
7
|
+
//# sourceMappingURL=nearDuplicate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nearDuplicate.d.ts","sourceRoot":"","sources":["../../../src/knowledge/rules/nearDuplicate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAa,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzE,eAAO,MAAM,iBAAiB,sDAW5B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/rules/nearDuplicate.ts — `near-duplicate`: one finding per near-duplicate edge.
|
|
3
|
+
* Anchor (PRD 41 §C3): the sorted-first ref of the pair.
|
|
4
|
+
*/
|
|
5
|
+
import { finding, refAnchor } from '../findingBuilder.js';
|
|
6
|
+
import { compareStr, round6 } from '../refs.js';
|
|
7
|
+
import { defineRule } from './factRule.js';
|
|
8
|
+
import { packOfRef } from './knowledgeInput.js';
|
|
9
|
+
export const nearDuplicateRule = defineRule({
|
|
10
|
+
id: 'near-duplicate',
|
|
11
|
+
version: 1,
|
|
12
|
+
reads: [], // the knowledge graph only
|
|
13
|
+
scope: 'global',
|
|
14
|
+
extraInputs: ['knowledge'],
|
|
15
|
+
derive: ({ extra: { knowledge: k } }) => k.graph.edges.filter((e) => e.kind === 'near-duplicate').map((e) => {
|
|
16
|
+
const first = compareStr(e.from, e.to) <= 0 ? e.from : e.to;
|
|
17
|
+
return finding('near-duplicate', packOfRef(k, e.from), [e.from, e.to], 'info', { similarity: round6(e.weight) }, undefined, refAnchor(first));
|
|
18
|
+
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E,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAClJ,CAAC,CAAC;CACT,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/rules/partitionViolation.ts — `partition-violation`: an edge whose layer verdict is `upward`
|
|
3
|
+
* (error) or `skips` (warn). Anchor (PRD 41 §C3): the from→to layer pair at the from FILE.
|
|
4
|
+
*/
|
|
5
|
+
import type { EdgeVerdict, Finding } from '../model.js';
|
|
6
|
+
import { type KnowledgeRuleExtra } from './knowledgeInput.js';
|
|
7
|
+
/** A partition violation's severity: an upward edge is an error, a skipped layer a warning. */
|
|
8
|
+
export declare function partitionSeverity(verdict: EdgeVerdict): Finding['severity'];
|
|
9
|
+
export declare const partitionViolationRule: import("./factRule.js").FactRule<KnowledgeRuleExtra>;
|
|
10
|
+
//# sourceMappingURL=partitionViolation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"partitionViolation.d.ts","sourceRoot":"","sources":["../../../src/knowledge/rules/partitionViolation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGxD,OAAO,EAAa,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzE,+FAA+F;AAC/F,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAE3E;AAED,eAAO,MAAM,sBAAsB,sDAcjC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/rules/partitionViolation.ts — `partition-violation`: an edge whose layer verdict is `upward`
|
|
3
|
+
* (error) or `skips` (warn). Anchor (PRD 41 §C3): the from→to layer pair at the from FILE.
|
|
4
|
+
*/
|
|
5
|
+
import { finding } from '../findingBuilder.js';
|
|
6
|
+
import { fileRefOf } from '../refs.js';
|
|
7
|
+
import { defineRule } from './factRule.js';
|
|
8
|
+
import { packOfRef } from './knowledgeInput.js';
|
|
9
|
+
/** A partition violation's severity: an upward edge is an error, a skipped layer a warning. */
|
|
10
|
+
export function partitionSeverity(verdict) {
|
|
11
|
+
return verdict === 'upward' ? 'error' : 'warn';
|
|
12
|
+
}
|
|
13
|
+
export const partitionViolationRule = defineRule({
|
|
14
|
+
id: 'partition-violation',
|
|
15
|
+
version: 1,
|
|
16
|
+
reads: [], // the knowledge graph only
|
|
17
|
+
scope: 'global',
|
|
18
|
+
extraInputs: ['knowledge'],
|
|
19
|
+
derive: ({ extra: { knowledge: k } }) => k.graph.edges.filter((e) => e.verdict === 'upward' || e.verdict === 'skips').map((e) => {
|
|
20
|
+
const from = k.byRef.get(e.from), to = k.byRef.get(e.to);
|
|
21
|
+
const layers = `${from?.partition ?? ''}->${to?.partition ?? ''}`;
|
|
22
|
+
return finding('partition-violation', packOfRef(k, e.from), [e.from, e.to], partitionSeverity(e.verdict), {
|
|
23
|
+
verdict: e.verdict, from: from?.partition ?? '', to: to?.partition ?? '', kind: e.kind,
|
|
24
|
+
}, undefined, { anchor: `${layers}@${fileRefOf(e.from)}`, anchorKind: 'file' });
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=partitionViolation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"partitionViolation.js","sourceRoot":"","sources":["../../../src/knowledge/rules/partitionViolation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,SAAS,EAA2B,MAAM,qBAAqB,CAAC;AAEzE,+FAA+F;AAC/F,MAAM,UAAU,i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E,CAAC,CAAC,IAAI;SAC1F,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;IACpF,CAAC,CAAC;CACT,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/rules/possibleSame.ts — `possible-same` as a rule: two entities the index found near-duplicate
|
|
3
|
+
* whose names do not normalize equal. The finding producer stays in resolve.ts beside entity resolution.
|
|
4
|
+
*/
|
|
5
|
+
import type { KnowledgeRuleExtra } from './knowledgeInput.js';
|
|
6
|
+
export declare const possibleSameRule: import("./factRule.js").FactRule<KnowledgeRuleExtra>;
|
|
7
|
+
//# sourceMappingURL=possibleSame.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"possibleSame.d.ts","sourceRoot":"","sources":["../../../src/knowledge/rules/possibleSame.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,eAAO,MAAM,gBAAgB,sDAO3B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/rules/possibleSame.ts — `possible-same` as a rule: two entities the index found near-duplicate
|
|
3
|
+
* whose names do not normalize equal. The finding producer stays in resolve.ts beside entity resolution.
|
|
4
|
+
*/
|
|
5
|
+
import { possibleSameFindings } from '../resolve.js';
|
|
6
|
+
import { defineRule } from './factRule.js';
|
|
7
|
+
export const possibleSameRule = defineRule({
|
|
8
|
+
id: 'possible-same',
|
|
9
|
+
version: 1,
|
|
10
|
+
reads: [], // the near-duplicate pairs of the knowledge input only
|
|
11
|
+
scope: 'global',
|
|
12
|
+
extraInputs: ['knowledge'],
|
|
13
|
+
derive: ({ extra: { knowledge: k } }) => possibleSameFindings(k.nearDuplicates),
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=possibleSame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"possibleSame.js","sourceRoot":"","sources":["../../../src/knowledge/rules/possibleSame.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAqB;IAC3D,EAAE,EAAE,eAAe;IACnB,OAAO,EAAE,CAAC;IACV,KAAK,EAAE,EAAE,EAAE,uDAAuD;IAClE,KAAK,EAAE,QAAQ;IACf,WAAW,EAAE,CAAC,WAAW,CAAC;IAC1B,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC,cAAc,CAAC;CAClF,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/rules/stale.ts — `stale`: one finding per source whose stored knowledge went stale (an
|
|
3
|
+
* unanchored stale node counts as its own source). Anchor (PRD 41 §C3): the stale source.
|
|
4
|
+
*/
|
|
5
|
+
import type { KnowledgeRuleExtra } from './knowledgeInput.js';
|
|
6
|
+
export declare const staleRule: import("./factRule.js").FactRule<KnowledgeRuleExtra>;
|
|
7
|
+
//# sourceMappingURL=stale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stale.d.ts","sourceRoot":"","sources":["../../../src/knowledge/rules/stale.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,eAAO,MAAM,SAAS,sDAmBpB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/rules/stale.ts — `stale`: one finding per source whose stored knowledge went stale (an
|
|
3
|
+
* unanchored stale node counts as its own source). Anchor (PRD 41 §C3): the stale source.
|
|
4
|
+
*/
|
|
5
|
+
import { finding, refAnchor } from '../findingBuilder.js';
|
|
6
|
+
import { aboutTargets, FALLBACK_PACK_ID } from '../refs.js';
|
|
7
|
+
import { defineRule } from './factRule.js';
|
|
8
|
+
export const staleRule = defineRule({
|
|
9
|
+
id: 'stale',
|
|
10
|
+
version: 1,
|
|
11
|
+
reads: [], // the knowledge graph only (stale flags)
|
|
12
|
+
scope: 'global',
|
|
13
|
+
extraInputs: ['knowledge'],
|
|
14
|
+
derive: ({ extra: { knowledge: k } }) => {
|
|
15
|
+
const about = aboutTargets(k.graph.edges);
|
|
16
|
+
const bySource = new Map();
|
|
17
|
+
for (const n of k.graph.nodes) {
|
|
18
|
+
if (!n.stale)
|
|
19
|
+
continue;
|
|
20
|
+
const target = about.get(n.ref) ?? n.ref;
|
|
21
|
+
const list = bySource.get(target) ?? [];
|
|
22
|
+
list.push(n.ref);
|
|
23
|
+
bySource.set(target, list);
|
|
24
|
+
}
|
|
25
|
+
return [...bySource].map(([source, refs]) => finding('stale', k.byRef.get(source)?.pack ?? FALLBACK_PACK_ID, [source, ...refs], 'warn', { count: refs.length }, undefined, refAnchor(source)));
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=stale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stale.js","sourceRoot":"","sources":["../../../src/knowledge/rules/stale.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAqB;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
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/rules/unpartitioned.ts — `unpartitioned`: per pack with an `allow` registry, the share of its
|
|
3
|
+
* files no partition matched. Anchor (PRD 41 §C3): the pack.
|
|
4
|
+
*/
|
|
5
|
+
import type { KnowledgeRuleExtra } from './knowledgeInput.js';
|
|
6
|
+
export declare const unpartitionedRule: import("./factRule.js").FactRule<KnowledgeRuleExtra>;
|
|
7
|
+
//# sourceMappingURL=unpartitioned.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unpartitioned.d.ts","sourceRoot":"","sources":["../../../src/knowledge/rules/unpartitioned.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,eAAO,MAAM,iBAAiB,sDAgB5B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/rules/unpartitioned.ts — `unpartitioned`: per pack with an `allow` registry, the share of its
|
|
3
|
+
* files no partition matched. Anchor (PRD 41 §C3): the pack.
|
|
4
|
+
*/
|
|
5
|
+
import { finding } from '../findingBuilder.js';
|
|
6
|
+
import { compareStr } from '../refs.js';
|
|
7
|
+
import { defineRule } from './factRule.js';
|
|
8
|
+
export const unpartitionedRule = defineRule({
|
|
9
|
+
id: 'unpartitioned',
|
|
10
|
+
version: 1,
|
|
11
|
+
reads: [], // the knowledge graph and partition registries only
|
|
12
|
+
scope: 'global',
|
|
13
|
+
extraInputs: ['knowledge'],
|
|
14
|
+
derive: ({ extra: { knowledge: k } }) => [...k.registries].sort((a, b) => compareStr(a[0], b[0])).flatMap(([pack, reg]) => {
|
|
15
|
+
if (!reg.allow)
|
|
16
|
+
return [];
|
|
17
|
+
const files = k.graph.nodes.filter((n) => n.pack === pack && n.kind === 'file');
|
|
18
|
+
const loose = files.filter((n) => n.partition === undefined).map((n) => n.ref);
|
|
19
|
+
if (loose.length === 0)
|
|
20
|
+
return [];
|
|
21
|
+
return [finding('unpartitioned', pack, loose, 'info', {
|
|
22
|
+
count: loose.length, total: files.length, share: Math.round((loose.length / files.length) * 100),
|
|
23
|
+
}, undefined, { anchor: `pack:${pack}`, anchorKind: 'group' })];
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=unpartitioned.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unpartitioned.js","sourceRoot":"","sources":["../../../src/knowledge/rules/unpartitioned.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAqB;IAC5D,EAAE,EAAE,eAAe;IACnB,OAAO,EAAE,CAAC;IACV,KAAK,EAAE,EAAE,EAAE,oDAAoD;IAC/D,KAAK,EAAE,QAAQ;IACf,WAAW,EAAE,CAAC,WAAW,CAAC;IAC1B,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CACpC,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE;QAC7E,IAAI,CAAC,GAAG,CAAC,KAAK;YAAE,OAAO,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;QAChF,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAC/E,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QAClC,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;gBAClD,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC;aACnG,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,QAAQ,IAAI,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IACpE,CAAC,CAAC;CACT,CAAC,CAAC"}
|
|
@@ -16,6 +16,19 @@ export declare const DEFAULT_MAX_FILE_BYTES: number;
|
|
|
16
16
|
* owedFiles.ts for how an unfinished one is carried to the next review).
|
|
17
17
|
*/
|
|
18
18
|
export declare const EXTRACTOR_VERSION = 6;
|
|
19
|
+
/**
|
|
20
|
+
* THE test of "this extract (or this root's extractor entry) was made by today's extractor": today's
|
|
21
|
+
* {@link EXTRACTOR_VERSION}, and the same caller-supplied extractor key (`extractorKey`: an input the host's extractors
|
|
22
|
+
* read besides the file's bytes, e.g. a digest of the tsconfig path aliases). An absent or empty key equals only an
|
|
23
|
+
* absent or empty key, so a caller that passes none behaves as before keys existed and old records still match it.
|
|
24
|
+
* The extract cache (extractFile.ts) and the owed state (owedFiles.ts) both decide by this one comparison.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isCurrentExtractor(recorded: {
|
|
27
|
+
version: number | undefined;
|
|
28
|
+
key: string | undefined;
|
|
29
|
+
}, keyNow: string | undefined): boolean;
|
|
30
|
+
/** THE key comparison (inside {@link isCurrentExtractor}; the owed estimate also needs it alone): absent and '' both mean "no key". */
|
|
31
|
+
export declare function sameExtractorKey(a: string | undefined, b: string | undefined): boolean;
|
|
19
32
|
export declare const extOf: (path: string) => string;
|
|
20
33
|
/** The ONE media-type lookup: the table, else `application/octet-stream` for a binary extension, else `text/plain`. */
|
|
21
34
|
export declare function mediaTypeOfPath(path: string): string;
|