@seanhogg/builderforce-memory 2026.10.45 → 2026.10.47
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 +21 -0
- package/dist/knowledge/build.d.ts.map +1 -1
- package/dist/knowledge/build.js +13 -7
- package/dist/knowledge/build.js.map +1 -1
- package/dist/knowledge/extractFile.d.ts +9 -1
- package/dist/knowledge/extractFile.d.ts.map +1 -1
- package/dist/knowledge/extractFile.js +25 -5
- package/dist/knowledge/extractFile.js.map +1 -1
- package/dist/knowledge/extractJob.d.ts +30 -5
- package/dist/knowledge/extractJob.d.ts.map +1 -1
- package/dist/knowledge/extractJob.js +9 -1
- package/dist/knowledge/extractJob.js.map +1 -1
- package/dist/knowledge/index.d.ts +5 -3
- package/dist/knowledge/index.d.ts.map +1 -1
- package/dist/knowledge/index.js +2 -1
- package/dist/knowledge/index.js.map +1 -1
- package/dist/knowledge/jobDeadline.d.ts +17 -0
- package/dist/knowledge/jobDeadline.d.ts.map +1 -0
- package/dist/knowledge/jobDeadline.js +46 -0
- package/dist/knowledge/jobDeadline.js.map +1 -0
- package/dist/knowledge/judgeCalls.d.ts +16 -0
- package/dist/knowledge/judgeCalls.d.ts.map +1 -1
- package/dist/knowledge/judgeCalls.js +20 -1
- package/dist/knowledge/judgeCalls.js.map +1 -1
- package/dist/knowledge/judgePriority.d.ts +22 -0
- package/dist/knowledge/judgePriority.d.ts.map +1 -0
- package/dist/knowledge/judgePriority.js +28 -0
- package/dist/knowledge/judgePriority.js.map +1 -0
- package/dist/knowledge/pack/crc32.d.ts +7 -0
- package/dist/knowledge/pack/crc32.d.ts.map +1 -0
- package/dist/knowledge/pack/crc32.js +22 -0
- package/dist/knowledge/pack/crc32.js.map +1 -0
- package/dist/knowledge/pack/decode.d.ts +14 -0
- package/dist/knowledge/pack/decode.d.ts.map +1 -0
- package/dist/knowledge/pack/decode.js +66 -0
- package/dist/knowledge/pack/decode.js.map +1 -0
- package/dist/knowledge/pack/deflate.d.ts +9 -0
- package/dist/knowledge/pack/deflate.d.ts.map +1 -0
- package/dist/knowledge/pack/deflate.js +45 -0
- package/dist/knowledge/pack/deflate.js.map +1 -0
- package/dist/knowledge/pack/encode.d.ts +26 -0
- package/dist/knowledge/pack/encode.d.ts.map +1 -0
- package/dist/knowledge/pack/encode.js +86 -0
- package/dist/knowledge/pack/encode.js.map +1 -0
- package/dist/knowledge/pack/extrDiff.d.ts +26 -0
- package/dist/knowledge/pack/extrDiff.d.ts.map +1 -0
- package/dist/knowledge/pack/extrDiff.js +129 -0
- package/dist/knowledge/pack/extrDiff.js.map +1 -0
- package/dist/knowledge/pack/frame.d.ts +45 -0
- package/dist/knowledge/pack/frame.d.ts.map +1 -0
- package/dist/knowledge/pack/frame.js +101 -0
- package/dist/knowledge/pack/frame.js.map +1 -0
- package/dist/knowledge/pack/hex.d.ts +7 -0
- package/dist/knowledge/pack/hex.d.ts.map +1 -0
- package/dist/knowledge/pack/hex.js +17 -0
- package/dist/knowledge/pack/hex.js.map +1 -0
- package/dist/knowledge/pack/index.d.ts +19 -0
- package/dist/knowledge/pack/index.d.ts.map +1 -0
- package/dist/knowledge/pack/index.js +17 -0
- package/dist/knowledge/pack/index.js.map +1 -0
- package/dist/knowledge/pack/jsonSize.d.ts +5 -0
- package/dist/knowledge/pack/jsonSize.d.ts.map +1 -0
- package/dist/knowledge/pack/jsonSize.js +8 -0
- package/dist/knowledge/pack/jsonSize.js.map +1 -0
- package/dist/knowledge/pack/manifest.d.ts +66 -0
- package/dist/knowledge/pack/manifest.d.ts.map +1 -0
- package/dist/knowledge/pack/manifest.js +104 -0
- package/dist/knowledge/pack/manifest.js.map +1 -0
- package/dist/knowledge/pack/sections/columns.d.ts +32 -0
- package/dist/knowledge/pack/sections/columns.d.ts.map +1 -0
- package/dist/knowledge/pack/sections/columns.js +53 -0
- package/dist/knowledge/pack/sections/columns.js.map +1 -0
- package/dist/knowledge/pack/sections/extr.d.ts +8 -0
- package/dist/knowledge/pack/sections/extr.d.ts.map +1 -0
- package/dist/knowledge/pack/sections/extr.js +99 -0
- package/dist/knowledge/pack/sections/extr.js.map +1 -0
- package/dist/knowledge/pack/sections/extrLists.d.ts +23 -0
- package/dist/knowledge/pack/sections/extrLists.d.ts.map +1 -0
- package/dist/knowledge/pack/sections/extrLists.js +200 -0
- package/dist/knowledge/pack/sections/extrLists.js.map +1 -0
- package/dist/knowledge/pack/sections/facts.d.ts +8 -0
- package/dist/knowledge/pack/sections/facts.d.ts.map +1 -0
- package/dist/knowledge/pack/sections/facts.js +172 -0
- package/dist/knowledge/pack/sections/facts.js.map +1 -0
- package/dist/knowledge/pack/sections/index.d.ts +6 -0
- package/dist/knowledge/pack/sections/index.d.ts.map +1 -0
- package/dist/knowledge/pack/sections/index.js +9 -0
- package/dist/knowledge/pack/sections/index.js.map +1 -0
- package/dist/knowledge/pack/sections/rows.d.ts +31 -0
- package/dist/knowledge/pack/sections/rows.d.ts.map +1 -0
- package/dist/knowledge/pack/sections/rows.js +227 -0
- package/dist/knowledge/pack/sections/rows.js.map +1 -0
- package/dist/knowledge/pack/strings.d.ts +43 -0
- package/dist/knowledge/pack/strings.d.ts.map +1 -0
- package/dist/knowledge/pack/strings.js +117 -0
- package/dist/knowledge/pack/strings.js.map +1 -0
- package/dist/knowledge/pack/types.d.ts +118 -0
- package/dist/knowledge/pack/types.d.ts.map +1 -0
- package/dist/knowledge/pack/types.js +17 -0
- package/dist/knowledge/pack/types.js.map +1 -0
- package/dist/knowledge/pack/varint.d.ts +57 -0
- package/dist/knowledge/pack/varint.d.ts.map +1 -0
- package/dist/knowledge/pack/varint.js +145 -0
- package/dist/knowledge/pack/varint.js.map +1 -0
- package/dist/knowledge/partitions.d.ts +1 -1
- package/dist/knowledge/partitions.d.ts.map +1 -1
- package/dist/knowledge/partitions.js +6 -1
- package/dist/knowledge/partitions.js.map +1 -1
- package/dist/knowledge/review.d.ts.map +1 -1
- package/dist/knowledge/review.js +58 -16
- package/dist/knowledge/review.js.map +1 -1
- package/dist/knowledge/reviewJudge.d.ts +8 -1
- package/dist/knowledge/reviewJudge.d.ts.map +1 -1
- package/dist/knowledge/reviewJudge.js +14 -8
- package/dist/knowledge/reviewJudge.js.map +1 -1
- package/dist/knowledge/reviewModel.d.ts +41 -1
- package/dist/knowledge/reviewModel.d.ts.map +1 -1
- package/dist/knowledge/reviewPrefetch.d.ts +10 -2
- package/dist/knowledge/reviewPrefetch.d.ts.map +1 -1
- package/dist/knowledge/reviewPrefetch.js +60 -25
- package/dist/knowledge/reviewPrefetch.js.map +1 -1
- package/dist/knowledge/reviewRun.d.ts +15 -3
- package/dist/knowledge/reviewRun.d.ts.map +1 -1
- package/dist/knowledge/reviewRun.js +19 -2
- package/dist/knowledge/reviewRun.js.map +1 -1
- package/dist/knowledge/reviewRunModel.d.ts +8 -1
- package/dist/knowledge/reviewRunModel.d.ts.map +1 -1
- package/dist/knowledge/reviewRunModel.js.map +1 -1
- package/dist/knowledge/stores/localSnapshotStore.d.ts +72 -6
- package/dist/knowledge/stores/localSnapshotStore.d.ts.map +1 -1
- package/dist/knowledge/stores/localSnapshotStore.js +279 -75
- package/dist/knowledge/stores/localSnapshotStore.js.map +1 -1
- package/package.json +8 -3
- package/src/contract/dist.contract.test.ts +44 -0
- package/src/contract/exports.contract.test.ts +90 -0
- package/src/contract/exports.snapshot.json +605 -0
- package/src/contract/pack.contract.test.ts +31 -0
- package/src/contract/regression.review.test.ts +236 -0
- package/src/contract/regression.store.test.ts +84 -0
- package/src/contract/types.contract.test.ts +183 -0
- package/src/knowledge/build.ts +11 -5
- package/src/knowledge/extractFile.ts +28 -6
- package/src/knowledge/extractJob.ts +26 -7
- package/src/knowledge/index.ts +5 -3
- package/src/knowledge/jobDeadline.ts +43 -0
- package/src/knowledge/judgeCalls.ts +19 -2
- package/src/knowledge/judgePriority.ts +36 -0
- package/src/knowledge/pack/crc32.ts +21 -0
- package/src/knowledge/pack/decode.ts +60 -0
- package/src/knowledge/pack/deflate.ts +43 -0
- package/src/knowledge/pack/encode.ts +89 -0
- package/src/knowledge/pack/extrDiff.ts +116 -0
- package/src/knowledge/pack/frame.ts +94 -0
- package/src/knowledge/pack/hex.ts +17 -0
- package/src/knowledge/pack/index.ts +26 -0
- package/src/knowledge/pack/jsonSize.ts +11 -0
- package/src/knowledge/pack/manifest.ts +128 -0
- package/src/knowledge/pack/pack.guards.test.ts +109 -0
- package/src/knowledge/pack/pack.reconcile.test.ts +96 -0
- package/src/knowledge/pack/pack.roundtrip.test.ts +50 -0
- package/src/knowledge/pack/pack.size.test.ts +22 -0
- package/src/knowledge/pack/pack.testkit.test-util.ts +90 -0
- package/src/knowledge/pack/sections/columns.ts +61 -0
- package/src/knowledge/pack/sections/extr.ts +90 -0
- package/src/knowledge/pack/sections/extrLists.ts +151 -0
- package/src/knowledge/pack/sections/facts.ts +126 -0
- package/src/knowledge/pack/sections/index.ts +13 -0
- package/src/knowledge/pack/sections/rows.ts +184 -0
- package/src/knowledge/pack/strings.ts +126 -0
- package/src/knowledge/pack/types.ts +97 -0
- package/src/knowledge/pack/varint.ts +145 -0
- package/src/knowledge/partitions.test.ts +4 -0
- package/src/knowledge/partitions.ts +3 -1
- package/src/knowledge/review.throughput.test.ts +122 -0
- package/src/knowledge/review.ts +54 -16
- package/src/knowledge/review.twoPass.test.ts +224 -0
- package/src/knowledge/reviewJudge.ts +19 -8
- package/src/knowledge/reviewModel.ts +38 -1
- package/src/knowledge/reviewPrefetch.ts +60 -24
- package/src/knowledge/reviewRun.test.ts +20 -3
- package/src/knowledge/reviewRun.ts +33 -6
- package/src/knowledge/reviewRunModel.ts +4 -1
- package/src/knowledge/stores/localSnapshotStore.batched.test.ts +25 -3
- package/src/knowledge/stores/localSnapshotStore.extractedLog.test.ts +280 -0
- package/src/knowledge/stores/localSnapshotStore.ts +283 -76
- package/src/knowledge/systems.test.ts +12 -0
- package/src/knowledge/testkit.test-util.ts +13 -2
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/pack/extrDiff.ts — within-file diff (PRD 41 A11 rule 2): a re-extracted file sends the
|
|
3
|
+
* nodes, edges and keys that changed against the acknowledged prior extraction of the same source,
|
|
4
|
+
* plus the identities that vanished, instead of its whole extraction.
|
|
5
|
+
*
|
|
6
|
+
* Lossless by construction: `applyEntryDiff(prior, diffEntry(prior, next))` deep-equals `next`
|
|
7
|
+
* (order included). `diffEntry` returns undefined when it cannot promise that — an identity that
|
|
8
|
+
* repeats within a list, or surviving items that changed relative order — and the caller sends the whole entry.
|
|
9
|
+
*
|
|
10
|
+
* A diff arrives from an untrusted pack: `applyEntryDiff` validates it (positions integer, strictly increasing,
|
|
11
|
+
* inside the rebuilt list) and throws on a malformed one.
|
|
12
|
+
*/
|
|
13
|
+
export function deepEqual(a, b) {
|
|
14
|
+
if (a === b)
|
|
15
|
+
return true;
|
|
16
|
+
if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null)
|
|
17
|
+
return Object.is(a, b);
|
|
18
|
+
if (Array.isArray(a) !== Array.isArray(b))
|
|
19
|
+
return false;
|
|
20
|
+
if (Array.isArray(a))
|
|
21
|
+
return a.length === b.length && a.every((x, i) => deepEqual(x, b[i]));
|
|
22
|
+
const ka = Object.keys(a).filter((k) => a[k] !== undefined);
|
|
23
|
+
const kb = Object.keys(b).filter((k) => b[k] !== undefined);
|
|
24
|
+
return ka.length === kb.length && ka.every((k) => deepEqual(a[k], b[k]));
|
|
25
|
+
}
|
|
26
|
+
function diffList(prior, next, id, same = deepEqual) {
|
|
27
|
+
const before = new Map();
|
|
28
|
+
for (const p of prior) {
|
|
29
|
+
const k = id(p);
|
|
30
|
+
if (before.has(k))
|
|
31
|
+
return undefined;
|
|
32
|
+
before.set(k, p);
|
|
33
|
+
}
|
|
34
|
+
const seen = new Set();
|
|
35
|
+
for (const n of next) {
|
|
36
|
+
const k = id(n);
|
|
37
|
+
if (seen.has(k))
|
|
38
|
+
return undefined;
|
|
39
|
+
seen.add(k);
|
|
40
|
+
}
|
|
41
|
+
const survives = (n) => before.has(id(n)) && same(before.get(id(n)), n);
|
|
42
|
+
const survivorsNext = next.filter(survives).map(id);
|
|
43
|
+
const after = new Map(next.map((n) => [id(n), n]));
|
|
44
|
+
const survivorsPrior = prior.filter((p) => after.has(id(p)) && same(p, after.get(id(p)))).map(id);
|
|
45
|
+
if (survivorsNext.length !== survivorsPrior.length || survivorsNext.some((k, i) => k !== survivorsPrior[i]))
|
|
46
|
+
return undefined;
|
|
47
|
+
const keep = new Set(survivorsNext);
|
|
48
|
+
return {
|
|
49
|
+
remove: prior.map(id).filter((k) => !keep.has(k)),
|
|
50
|
+
add: next.flatMap((item, at) => (keep.has(id(item)) ? [] : [{ at, item }])),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function applyList(prior, diff, id, restamp = (x) => x) {
|
|
54
|
+
const gone = new Set(diff.remove);
|
|
55
|
+
const kept = prior.filter((p) => !gone.has(id(p))).map(restamp);
|
|
56
|
+
const total = kept.length + diff.add.length;
|
|
57
|
+
let last = -1;
|
|
58
|
+
for (const a of diff.add) {
|
|
59
|
+
if (!Number.isInteger(a.at) || a.at <= last || a.at >= total)
|
|
60
|
+
throw new Error('malformed diff: add position out of order or out of range');
|
|
61
|
+
last = a.at;
|
|
62
|
+
}
|
|
63
|
+
const out = new Array(total);
|
|
64
|
+
for (const a of diff.add)
|
|
65
|
+
out[a.at] = a.item;
|
|
66
|
+
let k = 0;
|
|
67
|
+
for (let i = 0; i < total; i++)
|
|
68
|
+
if (!(i in out))
|
|
69
|
+
out[i] = kept[k++];
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
const nodeId = (n) => n.ref;
|
|
73
|
+
/**
|
|
74
|
+
* A node carries its file's hash as `sourceHash`, so every node of a changed file differs from its prior by that
|
|
75
|
+
* field alone. Compared with it replaced by a marker, a node that changed in nothing else survives, and is re-stamped
|
|
76
|
+
* with the new entry's hash on apply.
|
|
77
|
+
*/
|
|
78
|
+
const stamped = (n, entryHash) => (n.sourceHash === entryHash ? { ...n, sourceHash: '\u0000entry' } : n);
|
|
79
|
+
const edgeId = (e) => `${e.from}\u0000${e.to}\u0000${e.kind}`;
|
|
80
|
+
const keyId = (k) => `${k.ref}\u0000${k.key}`;
|
|
81
|
+
export function diffEntry(prior, next) {
|
|
82
|
+
if (prior.sourceRef !== next.sourceRef)
|
|
83
|
+
return undefined;
|
|
84
|
+
const nodes = diffList(prior.nodes, next.nodes, nodeId, (p, n) => deepEqual(stamped(p, prior.sourceHash), stamped(n, next.sourceHash)));
|
|
85
|
+
const edges = diffList(prior.edges, next.edges, edgeId);
|
|
86
|
+
const keys = diffList(prior.keys, next.keys, keyId);
|
|
87
|
+
if (!nodes || !edges || !keys)
|
|
88
|
+
return undefined;
|
|
89
|
+
return {
|
|
90
|
+
sourceRef: next.sourceRef, sourceHash: next.sourceHash,
|
|
91
|
+
...(next.extractorVersion !== undefined ? { extractorVersion: next.extractorVersion } : {}),
|
|
92
|
+
nodes, edges, keys,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export function applyEntryDiff(prior, diff) {
|
|
96
|
+
return {
|
|
97
|
+
sourceRef: diff.sourceRef, sourceHash: diff.sourceHash,
|
|
98
|
+
...(diff.extractorVersion !== undefined ? { extractorVersion: diff.extractorVersion } : {}),
|
|
99
|
+
nodes: applyList(prior.nodes, diff.nodes, nodeId, (n) => (n.sourceHash === prior.sourceHash ? { ...n, sourceHash: diff.sourceHash } : n)),
|
|
100
|
+
edges: applyList(prior.edges, diff.edges, edgeId),
|
|
101
|
+
keys: applyList(prior.keys, diff.keys, keyId),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The entries of `next` as diffs against the entries of `prior` with the same `sourceRef`, or undefined
|
|
106
|
+
* when any entry has no usable prior (then the hash is sent whole). A diff only pays when it is smaller:
|
|
107
|
+
* the caller compares sizes if it cares; this decides only what is possible.
|
|
108
|
+
*/
|
|
109
|
+
export function diffEntries(prior, next) {
|
|
110
|
+
const out = [];
|
|
111
|
+
for (const n of next) {
|
|
112
|
+
const p = prior.find((x) => x.sourceRef === n.sourceRef);
|
|
113
|
+
const d = p && diffEntry(p, n);
|
|
114
|
+
if (!d)
|
|
115
|
+
return undefined;
|
|
116
|
+
out.push(d);
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
/** Rebuilds a hash's entries from its diffs and the prior hash's entries; throws when a prior entry is missing or a diff is malformed. */
|
|
121
|
+
export function applyEntryDiffs(prior, diffs) {
|
|
122
|
+
return diffs.map((d) => {
|
|
123
|
+
const p = prior.find((x) => x.sourceRef === d.sourceRef);
|
|
124
|
+
if (!p)
|
|
125
|
+
throw new Error(`no prior extraction for ${d.sourceRef}`);
|
|
126
|
+
return applyEntryDiff(p, d);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=extrDiff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extrDiff.js","sourceRoot":"","sources":["../../../src/knowledge/pack/extrDiff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,MAAM,UAAU,SAAS,CAAC,CAAU,EAAE,CAAU;IAC5C,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACvG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IACxD,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC,MAAM,KAAM,CAAe,CAAC,MAAM,IAAI,CAAC,CAAC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· rootId · baseGeneration varint ·
|
|
5
|
+
* targetDigest (32 raw bytes) · body · trailer: CRC-32 (u32 LE) of the DECODED body
|
|
6
|
+
*
|
|
7
|
+
* The body is sections `{ tag u8, length varint, bytes }`; an unknown tag is skipped.
|
|
8
|
+
* Also: the multi-part split a large pack travels in.
|
|
9
|
+
*/
|
|
10
|
+
import { ByteWriter } from './varint.js';
|
|
11
|
+
export declare const MAGIC: readonly [66, 70, 75, 80];
|
|
12
|
+
export declare const VERSION = 1;
|
|
13
|
+
export declare const FLAG_DEFLATED = 1;
|
|
14
|
+
export declare const KPACK_CONTENT_TYPE = "application/vnd.builderforce.kpack";
|
|
15
|
+
/** A compressed pack larger than this travels as several parts. */
|
|
16
|
+
export declare const MAX_PART_BYTES: number;
|
|
17
|
+
export interface FrameHeader {
|
|
18
|
+
flags: number;
|
|
19
|
+
rootId: string;
|
|
20
|
+
baseGeneration: number;
|
|
21
|
+
targetDigest: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The CRC-32 in the trailer covers the HEADER (magic through digest) and the DECODED body, so a flipped
|
|
25
|
+
* root id, generation or digest fails the same check a flipped row does.
|
|
26
|
+
*/
|
|
27
|
+
export declare function writeFrame(h: FrameHeader, body: Uint8Array, storedBody: Uint8Array): Uint8Array;
|
|
28
|
+
/**
|
|
29
|
+
* Splits a frame into header fields, the stored (possibly deflated) body, the header's bytes, and the CRC the
|
|
30
|
+
* trailer claims. The caller checks `crc32(decodedBody, crc32(headerBytes)) === crc` once it has inflated.
|
|
31
|
+
*/
|
|
32
|
+
export declare function readFrame(bytes: Uint8Array): {
|
|
33
|
+
header: FrameHeader;
|
|
34
|
+
headerBytes: Uint8Array;
|
|
35
|
+
stored: Uint8Array;
|
|
36
|
+
crc: number;
|
|
37
|
+
};
|
|
38
|
+
export declare function writeSection(w: ByteWriter, tag: number, bytes: Uint8Array): void;
|
|
39
|
+
/** The sections of a decoded body by tag (a repeated tag keeps the last); unknown tags are returned too, for the caller to skip. */
|
|
40
|
+
export declare function readSections(body: Uint8Array): Map<number, Uint8Array>;
|
|
41
|
+
/** Cuts a pack into ordered parts of at most `max` bytes. A pack within `max` is one part. */
|
|
42
|
+
export declare function splitParts(pack: Uint8Array, max?: number): Uint8Array[];
|
|
43
|
+
/** The inverse of {@link splitParts}. */
|
|
44
|
+
export declare function joinParts(parts: readonly Uint8Array[]): Uint8Array;
|
|
45
|
+
//# sourceMappingURL=frame.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../../../src/knowledge/pack/frame.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAc,UAAU,EAAmB,MAAM,aAAa,CAAC;AAEtE,eAAO,MAAM,KAAK,YAAI,EAAI,EAAE,EAAI,EAAE,EAAI,EAAE,EAAI,CAAU,CAAC;AACvD,eAAO,MAAM,OAAO,IAAI,CAAC;AACzB,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,kBAAkB,uCAAuC,CAAC;AACvE,mEAAmE;AACnE,eAAO,MAAM,cAAc,QAAkB,CAAC;AAE9C,MAAM,WAAW,WAAW;IAAG,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE;AAE5G;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,GAAG,UAAU,CAe/F;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAc9H;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAIhF;AAED,oIAAoI;AACpI,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAKtE;AAED,8FAA8F;AAC9F,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,GAAE,MAAuB,GAAG,UAAU,EAAE,CAKvF;AAED,yCAAyC;AACzC,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,GAAG,UAAU,CAMlE"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/pack/frame.ts — the BFKP v1 frame (PRD 41 A11):
|
|
3
|
+
*
|
|
4
|
+
* magic "BFKP" · version u8 · flags u8 (bit 0 = body deflated) · rootId · baseGeneration varint ·
|
|
5
|
+
* targetDigest (32 raw bytes) · body · trailer: CRC-32 (u32 LE) of the DECODED body
|
|
6
|
+
*
|
|
7
|
+
* The body is sections `{ tag u8, length varint, bytes }`; an unknown tag is skipped.
|
|
8
|
+
* Also: the multi-part split a large pack travels in.
|
|
9
|
+
*/
|
|
10
|
+
import { crc32 } from './crc32.js';
|
|
11
|
+
import { fromHex64, HEX64, toHex } from './hex.js';
|
|
12
|
+
import { ByteReader, ByteWriter, PackFormatError } from './varint.js';
|
|
13
|
+
export const MAGIC = [0x42, 0x46, 0x4b, 0x50]; // "BFKP"
|
|
14
|
+
export const VERSION = 1;
|
|
15
|
+
export const FLAG_DEFLATED = 1;
|
|
16
|
+
export const KPACK_CONTENT_TYPE = 'application/vnd.builderforce.kpack';
|
|
17
|
+
/** A compressed pack larger than this travels as several parts. */
|
|
18
|
+
export const MAX_PART_BYTES = 8 * 1024 * 1024;
|
|
19
|
+
/**
|
|
20
|
+
* The CRC-32 in the trailer covers the HEADER (magic through digest) and the DECODED body, so a flipped
|
|
21
|
+
* root id, generation or digest fails the same check a flipped row does.
|
|
22
|
+
*/
|
|
23
|
+
export function writeFrame(h, body, storedBody) {
|
|
24
|
+
if (!HEX64.test(h.targetDigest))
|
|
25
|
+
throw new PackFormatError('targetDigest is 64 lowercase hex characters');
|
|
26
|
+
const w = new ByteWriter();
|
|
27
|
+
for (const m of MAGIC)
|
|
28
|
+
w.u8(m);
|
|
29
|
+
w.u8(VERSION);
|
|
30
|
+
w.u8(h.flags);
|
|
31
|
+
w.str(h.rootId);
|
|
32
|
+
w.varint(h.baseGeneration);
|
|
33
|
+
w.bytes(fromHex64(h.targetDigest));
|
|
34
|
+
const head = w.finish();
|
|
35
|
+
const out = new ByteWriter();
|
|
36
|
+
out.bytes(head);
|
|
37
|
+
out.bytes(storedBody);
|
|
38
|
+
out.u32le(crc32(body, crc32(head)));
|
|
39
|
+
return out.finish();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Splits a frame into header fields, the stored (possibly deflated) body, the header's bytes, and the CRC the
|
|
43
|
+
* trailer claims. The caller checks `crc32(decodedBody, crc32(headerBytes)) === crc` once it has inflated.
|
|
44
|
+
*/
|
|
45
|
+
export function readFrame(bytes) {
|
|
46
|
+
if (bytes.length < 4 + 2 + 1 + 1 + 32 + 4)
|
|
47
|
+
throw new PackFormatError('truncated frame');
|
|
48
|
+
const r = new ByteReader(bytes);
|
|
49
|
+
for (const m of MAGIC)
|
|
50
|
+
if (r.u8() !== m)
|
|
51
|
+
throw new PackFormatError('not a BFKP pack (bad magic)');
|
|
52
|
+
const version = r.u8();
|
|
53
|
+
if (version !== VERSION)
|
|
54
|
+
throw new PackFormatError(`unsupported BFKP version ${version}`);
|
|
55
|
+
const flags = r.u8();
|
|
56
|
+
const rootId = r.str();
|
|
57
|
+
const baseGeneration = r.varint();
|
|
58
|
+
const targetDigest = toHex(r.bytes(32));
|
|
59
|
+
const headerBytes = bytes.subarray(0, r.offset);
|
|
60
|
+
if (r.remaining < 4)
|
|
61
|
+
throw new PackFormatError('truncated frame');
|
|
62
|
+
const stored = r.bytes(r.remaining - 4);
|
|
63
|
+
return { header: { flags, rootId, baseGeneration, targetDigest }, headerBytes, stored, crc: r.u32le() };
|
|
64
|
+
}
|
|
65
|
+
export function writeSection(w, tag, bytes) {
|
|
66
|
+
w.u8(tag);
|
|
67
|
+
w.varint(bytes.length);
|
|
68
|
+
w.bytes(bytes);
|
|
69
|
+
}
|
|
70
|
+
/** The sections of a decoded body by tag (a repeated tag keeps the last); unknown tags are returned too, for the caller to skip. */
|
|
71
|
+
export function readSections(body) {
|
|
72
|
+
const r = new ByteReader(body);
|
|
73
|
+
const out = new Map();
|
|
74
|
+
while (!r.done) {
|
|
75
|
+
const tag = r.u8();
|
|
76
|
+
out.set(tag, r.bytes(r.varint()));
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
/** Cuts a pack into ordered parts of at most `max` bytes. A pack within `max` is one part. */
|
|
81
|
+
export function splitParts(pack, max = MAX_PART_BYTES) {
|
|
82
|
+
if (pack.length <= max)
|
|
83
|
+
return [pack];
|
|
84
|
+
const parts = [];
|
|
85
|
+
for (let at = 0; at < pack.length; at += max)
|
|
86
|
+
parts.push(pack.subarray(at, Math.min(at + max, pack.length)));
|
|
87
|
+
return parts;
|
|
88
|
+
}
|
|
89
|
+
/** The inverse of {@link splitParts}. */
|
|
90
|
+
export function joinParts(parts) {
|
|
91
|
+
if (parts.length === 1)
|
|
92
|
+
return parts[0];
|
|
93
|
+
const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));
|
|
94
|
+
let at = 0;
|
|
95
|
+
for (const p of parts) {
|
|
96
|
+
out.set(p, at);
|
|
97
|
+
at += p.length;
|
|
98
|
+
}
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=frame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame.js","sourceRoot":"","sources":["../../../src/knowledge/pack/frame.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;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I,GAAG;QAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7G,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,yCAAyC;AACzC,MAAM,UAAU,SAAS,CAAC,KAA4B;IAClD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,CAAC,CAAE,CAAC;IACzC,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IACpE,IAAI,EAAE,GAAG,CAAC,CAAC;IACX,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAAC,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC;IAAC,CAAC;IAC1D,OAAO,GAAG,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** knowledge/pack/hex.ts — the ONE hex helper of the codec (PRD 41 A11): 64-hex digests and hashes as raw 32 bytes and back. */
|
|
2
|
+
export declare const HEX64: RegExp;
|
|
3
|
+
/** Lowercase hex of `bytes`. */
|
|
4
|
+
export declare function toHex(bytes: Uint8Array): string;
|
|
5
|
+
/** The 32 raw bytes of a 64-character lowercase hex string. */
|
|
6
|
+
export declare function fromHex64(hex: string): Uint8Array;
|
|
7
|
+
//# sourceMappingURL=hex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../../../src/knowledge/pack/hex.ts"],"names":[],"mappings":"AAAA,gIAAgI;AAEhI,eAAO,MAAM,KAAK,QAAmB,CAAC;AAEtC,gCAAgC;AAChC,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAI/C;AAED,+DAA+D;AAC/D,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAIjD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** knowledge/pack/hex.ts — the ONE hex helper of the codec (PRD 41 A11): 64-hex digests and hashes as raw 32 bytes and back. */
|
|
2
|
+
export const HEX64 = /^[0-9a-f]{64}$/;
|
|
3
|
+
/** Lowercase hex of `bytes`. */
|
|
4
|
+
export function toHex(bytes) {
|
|
5
|
+
let s = '';
|
|
6
|
+
for (const b of bytes)
|
|
7
|
+
s += (b < 16 ? '0' : '') + b.toString(16);
|
|
8
|
+
return s;
|
|
9
|
+
}
|
|
10
|
+
/** The 32 raw bytes of a 64-character lowercase hex string. */
|
|
11
|
+
export function fromHex64(hex) {
|
|
12
|
+
const raw = new Uint8Array(32);
|
|
13
|
+
for (let i = 0; i < 32; i++)
|
|
14
|
+
raw[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
15
|
+
return raw;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=hex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex.js","sourceRoot":"","sources":["../../../src/knowledge/pack/hex.ts"],"names":[],"mappings":"AAAA,gIAAgI;AAEhI,MAAM,CAAC,MAAM,KAAK,GAAG,gBAAgB,CAAC;AAEtC,gCAAgC;AAChC,MAAM,UAAU,KAAK,CAAC,KAAiB;IACnC,IAAI,CAAC,GAAG,EAAE,CAAC;IACX,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACjE,OAAO,CAAC,CAAC;AACb,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,SAAS,CAAC,GAAW;IACjC,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE;QAAE,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChF,OAAO,GAAG,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@seanhogg/builderforce-memory/knowledge/pack` — BFKP v1, "Builderforce Knowledge Pack" (PRD 41 A11):
|
|
3
|
+
* the one compact, lossless wire format a client syncs to the server in, and the server expands.
|
|
4
|
+
*
|
|
5
|
+
* Pure TypeScript with no Node APIs (`CompressionStream` is the only runtime dependency): the VS Code
|
|
6
|
+
* host and the API Worker run this same module. There is no second copy of the codec.
|
|
7
|
+
*/
|
|
8
|
+
export { encodePack, normalizePack, type EncodeOptions } from './encode.js';
|
|
9
|
+
export { decodePack, peekPack } from './decode.js';
|
|
10
|
+
export { KPACK_CONTENT_TYPE, MAX_PART_BYTES, splitParts, joinParts } from './frame.js';
|
|
11
|
+
export { PackFormatError } from './varint.js';
|
|
12
|
+
export { crc32 } from './crc32.js';
|
|
13
|
+
export { ZERO_DIGEST, DEFAULT_PACK_LIMITS, PackTooLargeError, } from './types.js';
|
|
14
|
+
export type { Pack, PackBody, PackFileRow, PackStaleRow, PackDeletes, RelationId, PackExtr, ExtrEntryDiff, ListDiff, ManifestLeaf, PackLimits, } from './types.js';
|
|
15
|
+
export { diffEntries, applyEntryDiffs, diffEntry, applyEntryDiff, deepEqual } from './extrDiff.js';
|
|
16
|
+
export { MANIFEST_BUCKETS, manifestTree, bucketOf, keyHash, differingBuckets, leafDelta, rootLeaves, rootDigestOf, fileLeafKey, factLeafKey, relationLeafKey, factDigest, relationDigest, } from './manifest.js';
|
|
17
|
+
export type { ManifestTree, LeafDelta, RootRows } from './manifest.js';
|
|
18
|
+
export { jsonBytesOf } from './jsonSize.js';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/knowledge/pack/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACH,WAAW,EAAE,mBAAmB,EAAE,iBAAiB,GACtD,MAAM,YAAY,CAAC;AACpB,YAAY,EACR,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,GAClI,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACnG,OAAO,EACH,gBAAgB,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EACxG,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,cAAc,GACxE,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@seanhogg/builderforce-memory/knowledge/pack` — BFKP v1, "Builderforce Knowledge Pack" (PRD 41 A11):
|
|
3
|
+
* the one compact, lossless wire format a client syncs to the server in, and the server expands.
|
|
4
|
+
*
|
|
5
|
+
* Pure TypeScript with no Node APIs (`CompressionStream` is the only runtime dependency): the VS Code
|
|
6
|
+
* host and the API Worker run this same module. There is no second copy of the codec.
|
|
7
|
+
*/
|
|
8
|
+
export { encodePack, normalizePack } from './encode.js';
|
|
9
|
+
export { decodePack, peekPack } from './decode.js';
|
|
10
|
+
export { KPACK_CONTENT_TYPE, MAX_PART_BYTES, splitParts, joinParts } from './frame.js';
|
|
11
|
+
export { PackFormatError } from './varint.js';
|
|
12
|
+
export { crc32 } from './crc32.js';
|
|
13
|
+
export { ZERO_DIGEST, DEFAULT_PACK_LIMITS, PackTooLargeError, } from './types.js';
|
|
14
|
+
export { diffEntries, applyEntryDiffs, diffEntry, applyEntryDiff, deepEqual } from './extrDiff.js';
|
|
15
|
+
export { MANIFEST_BUCKETS, manifestTree, bucketOf, keyHash, differingBuckets, leafDelta, rootLeaves, rootDigestOf, fileLeafKey, factLeafKey, relationLeafKey, factDigest, relationDigest, } from './manifest.js';
|
|
16
|
+
export { jsonBytesOf } from './jsonSize.js';
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/knowledge/pack/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAsB,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACH,WAAW,EAAE,mBAAmB,EAAE,iBAAiB,GACtD,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACnG,OAAO,EACH,gBAAgB,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EACxG,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,cAAc,GACxE,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** knowledge/pack/jsonSize.ts — the bytes the same rows would take as JSON: the baseline a pack's size is shown against (PRD 41 A11 rule 6). */
|
|
2
|
+
import type { Pack } from './types.js';
|
|
3
|
+
/** UTF-8 bytes of the pack's rows as JSON (frame fields and manifest sections excluded). */
|
|
4
|
+
export declare function jsonBytesOf(pack: Pack): number;
|
|
5
|
+
//# sourceMappingURL=jsonSize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonSize.d.ts","sourceRoot":"","sources":["../../../src/knowledge/pack/jsonSize.ts"],"names":[],"mappings":"AAAA,gJAAgJ;AAEhJ,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAIvC,4FAA4F;AAC5F,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAG9C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** knowledge/pack/jsonSize.ts — the bytes the same rows would take as JSON: the baseline a pack's size is shown against (PRD 41 A11 rule 6). */
|
|
2
|
+
const ENCODER = new TextEncoder();
|
|
3
|
+
/** UTF-8 bytes of the pack's rows as JSON (frame fields and manifest sections excluded). */
|
|
4
|
+
export function jsonBytesOf(pack) {
|
|
5
|
+
const { files, extracted, facts, relations, stale, deletes, scope, analysis } = pack;
|
|
6
|
+
return ENCODER.encode(JSON.stringify({ files, extracted, facts, relations, stale, deletes, scope, analysis })).length;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=jsonSize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonSize.js","sourceRoot":"","sources":["../../../src/knowledge/pack/jsonSize.ts"],"names":[],"mappings":"AAAA,gJAAgJ;AAIhJ,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,4FAA4F;AAC5F,MAAM,UAAU,WAAW,CAAC,IAAU;IAClC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IACrF,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AAC1H,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/pack/manifest.ts — `manifestTree`, the ONE function both sides use to find a delta
|
|
3
|
+
* (PRD 41 A11 rule 2, the reconcile path).
|
|
4
|
+
*
|
|
5
|
+
* Leaves are `(key, contentDigest)` for every file, fact and relation of a root, grouped into 4,096
|
|
6
|
+
* buckets by a stable hash of the key. A bucket's digest is the hash of its sorted leaves; the root
|
|
7
|
+
* digest is the hash of the bucket digests. Two sides with equal root digests hold equal state; with
|
|
8
|
+
* unequal ones, only the buckets whose digests differ need their leaves compared.
|
|
9
|
+
*
|
|
10
|
+
* What counts as "a leaf of the root" is decided HERE ({@link rootLeaves}), so the client's local rows
|
|
11
|
+
* and the server's stored rows are cut the same way and a digest means the same on both.
|
|
12
|
+
*/
|
|
13
|
+
import type { ManifestLeaf, StoredFact, StoredRelation } from './types.js';
|
|
14
|
+
export declare const MANIFEST_BUCKETS = 4096;
|
|
15
|
+
/** FNV-1a (32-bit) over the key's UTF-16 code units: stable across runtimes and releases. */
|
|
16
|
+
export declare function keyHash(key: string): number;
|
|
17
|
+
export declare const bucketOf: (key: string) => number;
|
|
18
|
+
export interface ManifestTree {
|
|
19
|
+
root: string;
|
|
20
|
+
/** `MANIFEST_BUCKETS` bucket digests, hex. */
|
|
21
|
+
buckets: string[];
|
|
22
|
+
/** The leaves of each non-empty bucket, sorted by key. */
|
|
23
|
+
leaves: Map<number, ManifestLeaf[]>;
|
|
24
|
+
}
|
|
25
|
+
export declare function manifestTree(leaves: readonly ManifestLeaf[]): ManifestTree;
|
|
26
|
+
/** The bucket ids whose digests differ (or are missing on one side). */
|
|
27
|
+
export declare function differingBuckets(a: readonly string[], b: readonly string[]): number[];
|
|
28
|
+
/** A source's leaf key: its path, or `~tag|path` for a root-level output (the blob store's own source identity). */
|
|
29
|
+
export declare function fileLeafKey(path: string, hash: string): string;
|
|
30
|
+
export declare const factLeafKey: (key: string) => string;
|
|
31
|
+
export declare const relationLeafKey: (r: {
|
|
32
|
+
from: string;
|
|
33
|
+
to: string;
|
|
34
|
+
kind: string;
|
|
35
|
+
}) => string;
|
|
36
|
+
/** The digest of what a fact says: its key, text and provenance kind. Importance and timestamps are the server's to score. */
|
|
37
|
+
export declare const factDigest: (f: Pick<StoredFact, 'key' | 'content' | 'origin'>) => string;
|
|
38
|
+
export declare const relationDigest: (r: Pick<StoredRelation, 'weight' | 'origin' | 'confidence' | 'sourceHash'>) => string;
|
|
39
|
+
export interface RootRows {
|
|
40
|
+
files: ReadonlyArray<{
|
|
41
|
+
path: string;
|
|
42
|
+
hash: string;
|
|
43
|
+
}>;
|
|
44
|
+
facts: readonly StoredFact[];
|
|
45
|
+
relations: readonly StoredRelation[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The leaves of a root. A fact belongs to the root when it is anchored to one of its files; a relation
|
|
49
|
+
* when either end is one of its sources (`src:<root>::…`) or one of those facts.
|
|
50
|
+
*
|
|
51
|
+
* Only the review's own judgements count (`origin: 'model'`): a person's note or an agent's fact can be
|
|
52
|
+
* written on the server by someone else, so it never makes two sides "differ"; those rows travel by the
|
|
53
|
+
* dirty set when their writer changes them.
|
|
54
|
+
*/
|
|
55
|
+
export declare function rootLeaves(rootId: string, rows: RootRows): ManifestLeaf[];
|
|
56
|
+
/** The root digest of a root's rows: what a pack asserts as its `targetDigest`. */
|
|
57
|
+
export declare const rootDigestOf: (rootId: string, rows: RootRows) => string;
|
|
58
|
+
export interface LeafDelta {
|
|
59
|
+
/** Keys the remote lacks or holds with another digest. */
|
|
60
|
+
upsert: string[];
|
|
61
|
+
/** Keys the remote holds that the local side does not. */
|
|
62
|
+
remove: string[];
|
|
63
|
+
}
|
|
64
|
+
/** Compares local leaves with the remote's leaves of the differing buckets; only those buckets are considered. */
|
|
65
|
+
export declare function leafDelta(local: ManifestTree, remote: readonly ManifestLeaf[], buckets: readonly number[]): LeafDelta;
|
|
66
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/knowledge/pack/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE3E,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC,6FAA6F;AAC7F,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI3C;AAED,eAAO,MAAM,QAAQ,QA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ACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,YAAY,EAAE,CAWzE;AAED,mFAAmF;AACnF,eAAO,MAAM,YAAY,WAAY,MAAM,QAAQ,QAAQ,KAAG,MAAqD,CAAC;AAEpH,MAAM,WAAW,SAAS;IACtB,0DAA0D;IAC1D,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,0DAA0D;IAC1D,MAAM,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,kHAAkH;AAClH,wBAAgB,SAAS,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,YAAY,EAAE,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAUrH"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/pack/manifest.ts — `manifestTree`, the ONE function both sides use to find a delta
|
|
3
|
+
* (PRD 41 A11 rule 2, the reconcile path).
|
|
4
|
+
*
|
|
5
|
+
* Leaves are `(key, contentDigest)` for every file, fact and relation of a root, grouped into 4,096
|
|
6
|
+
* buckets by a stable hash of the key. A bucket's digest is the hash of its sorted leaves; the root
|
|
7
|
+
* digest is the hash of the bucket digests. Two sides with equal root digests hold equal state; with
|
|
8
|
+
* unequal ones, only the buckets whose digests differ need their leaves compared.
|
|
9
|
+
*
|
|
10
|
+
* What counts as "a leaf of the root" is decided HERE ({@link rootLeaves}), so the client's local rows
|
|
11
|
+
* and the server's stored rows are cut the same way and a digest means the same on both.
|
|
12
|
+
*/
|
|
13
|
+
import { sha256Hex } from '../../retrieval/knowledge-index/sha256.js';
|
|
14
|
+
export const MANIFEST_BUCKETS = 4096;
|
|
15
|
+
/** FNV-1a (32-bit) over the key's UTF-16 code units: stable across runtimes and releases. */
|
|
16
|
+
export function keyHash(key) {
|
|
17
|
+
let h = 0x811c9dc5;
|
|
18
|
+
for (let i = 0; i < key.length; i++) {
|
|
19
|
+
h ^= key.charCodeAt(i);
|
|
20
|
+
h = Math.imul(h, 0x01000193) >>> 0;
|
|
21
|
+
}
|
|
22
|
+
return h >>> 0;
|
|
23
|
+
}
|
|
24
|
+
export const bucketOf = (key) => keyHash(key) % MANIFEST_BUCKETS;
|
|
25
|
+
const EMPTY_BUCKET = sha256Hex('');
|
|
26
|
+
const cmp = (a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0);
|
|
27
|
+
export function manifestTree(leaves) {
|
|
28
|
+
const grouped = new Map();
|
|
29
|
+
for (const l of leaves) {
|
|
30
|
+
const b = bucketOf(l.key);
|
|
31
|
+
const list = grouped.get(b);
|
|
32
|
+
if (list)
|
|
33
|
+
list.push(l);
|
|
34
|
+
else
|
|
35
|
+
grouped.set(b, [l]);
|
|
36
|
+
}
|
|
37
|
+
const buckets = new Array(MANIFEST_BUCKETS);
|
|
38
|
+
for (let b = 0; b < MANIFEST_BUCKETS; b++) {
|
|
39
|
+
const list = grouped.get(b);
|
|
40
|
+
if (!list) {
|
|
41
|
+
buckets[b] = EMPTY_BUCKET;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
list.sort(cmp);
|
|
45
|
+
buckets[b] = sha256Hex(list.map((l) => `${l.key}\u0000${l.digest}\n`).join(''));
|
|
46
|
+
}
|
|
47
|
+
return { root: sha256Hex(buckets.join('')), buckets, leaves: grouped };
|
|
48
|
+
}
|
|
49
|
+
/** The bucket ids whose digests differ (or are missing on one side). */
|
|
50
|
+
export function differingBuckets(a, b) {
|
|
51
|
+
const out = [];
|
|
52
|
+
for (let i = 0; i < MANIFEST_BUCKETS; i++)
|
|
53
|
+
if (a[i] !== b[i])
|
|
54
|
+
out.push(i);
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
/** A source's leaf key: its path, or `~tag|path` for a root-level output (the blob store's own source identity). */
|
|
58
|
+
export function fileLeafKey(path, hash) {
|
|
59
|
+
if (!hash.startsWith('~'))
|
|
60
|
+
return `f:${path}`;
|
|
61
|
+
const colon = hash.indexOf(':');
|
|
62
|
+
return `f:${colon > 0 ? hash.slice(0, colon) : hash}|${path}`;
|
|
63
|
+
}
|
|
64
|
+
export const factLeafKey = (key) => `a:${key}`;
|
|
65
|
+
export const relationLeafKey = (r) => `r:${r.from}\u0000${r.to}\u0000${r.kind}`;
|
|
66
|
+
/** The digest of what a fact says: its key, text and provenance kind. Importance and timestamps are the server's to score. */
|
|
67
|
+
export const factDigest = (f) => sha256Hex(JSON.stringify([f.key, f.content, f.origin]));
|
|
68
|
+
export const relationDigest = (r) => sha256Hex(`${r.weight.toFixed(3)}|${r.origin}|${r.confidence === undefined ? '' : r.confidence.toFixed(3)}|${r.sourceHash ?? ''}`);
|
|
69
|
+
/**
|
|
70
|
+
* The leaves of a root. A fact belongs to the root when it is anchored to one of its files; a relation
|
|
71
|
+
* when either end is one of its sources (`src:<root>::…`) or one of those facts.
|
|
72
|
+
*
|
|
73
|
+
* Only the review's own judgements count (`origin: 'model'`): a person's note or an agent's fact can be
|
|
74
|
+
* written on the server by someone else, so it never makes two sides "differ"; those rows travel by the
|
|
75
|
+
* dirty set when their writer changes them.
|
|
76
|
+
*/
|
|
77
|
+
export function rootLeaves(rootId, rows) {
|
|
78
|
+
const paths = new Set(rows.files.map((f) => f.path));
|
|
79
|
+
const facts = rows.facts.filter((f) => f.origin === 'model' && f.fileAnchors.some((a) => paths.has(a.path)));
|
|
80
|
+
const factRefs = new Set(facts.map((f) => `fact:${f.key}`));
|
|
81
|
+
const prefix = `src:${rootId}::`;
|
|
82
|
+
const touches = (ref) => ref.startsWith(prefix) || factRefs.has(ref);
|
|
83
|
+
return [
|
|
84
|
+
...rows.files.map((f) => ({ key: fileLeafKey(f.path, f.hash), digest: f.hash })),
|
|
85
|
+
...facts.map((f) => ({ key: factLeafKey(f.key), digest: factDigest(f) })),
|
|
86
|
+
...rows.relations.filter((r) => r.origin === 'model' && (touches(r.from) || touches(r.to))).map((r) => ({ key: relationLeafKey(r), digest: relationDigest(r) })),
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
/** The root digest of a root's rows: what a pack asserts as its `targetDigest`. */
|
|
90
|
+
export const rootDigestOf = (rootId, rows) => manifestTree(rootLeaves(rootId, rows)).root;
|
|
91
|
+
/** Compares local leaves with the remote's leaves of the differing buckets; only those buckets are considered. */
|
|
92
|
+
export function leafDelta(local, remote, buckets) {
|
|
93
|
+
const remoteByKey = new Map(remote.map((l) => [l.key, l.digest]));
|
|
94
|
+
const upsert = [], seen = new Set();
|
|
95
|
+
for (const b of buckets) {
|
|
96
|
+
for (const l of local.leaves.get(b) ?? []) {
|
|
97
|
+
seen.add(l.key);
|
|
98
|
+
if (remoteByKey.get(l.key) !== l.digest)
|
|
99
|
+
upsert.push(l.key);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return { upsert, remove: remote.map((l) => l.key).filter((k) => !seen.has(k)) };
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../../src/knowledge/pack/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAGtE,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAErC,6FAA6F;AAC7F,MAAM,UAAU,OAAO,CAAC,GAAW;IAC/B,IAAI,CAAC,GAAG,UAAU,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAAC,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IAAC,CAAC;IACpG,OAAO,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC;AAED,MAAM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