@githolon/testing 0.35.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/vendor/engine/engine.mjs +50 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@githolon/testing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "@githolon/testing — law TDD for Nomos domains: boot the REAL engine plane in-process (the exact machinery every cloud DO, heavy container and web client runs), dispatch directives, assert rows, assert TYPED REFUSALS, fork for what-ifs — fully offline inside vitest.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
package/vendor/engine/engine.mjs
CHANGED
|
@@ -1465,6 +1465,9 @@ export function author(eng, ws, domain, directiveId, payload, controllerHash, op
|
|
|
1465
1465
|
const served = attestedRead(eng, need.from, {
|
|
1466
1466
|
queryId: need.queryId, paramsJson: JSON.stringify(need.args), attestorSecret: secret,
|
|
1467
1467
|
nowMs: opts.attestNowMs ?? Date.now(),
|
|
1468
|
+
// K3 (§1.5.3): colocated custody is in-memory — always ask for the carried enrollment
|
|
1469
|
+
// proof; the kernel produces-or-omits under its own bounds (the adapter decides nothing).
|
|
1470
|
+
includeRosterProof: true,
|
|
1468
1471
|
});
|
|
1469
1472
|
if (!served || served.ok !== true) break; // the kernel's original instruction stands for the caller
|
|
1470
1473
|
envelope.attestations = [...(envelope.attestations ?? []), { queryId: need.queryId, result: served.rows, attestation: served.attestation }];
|
|
@@ -1908,10 +1911,10 @@ export const attestationSign = (eng, { secret, asserterWorkspace, object, relati
|
|
|
1908
1911
|
// secret (the `attestationSign` pattern — never persisted). The adapter/host transports the secret and
|
|
1909
1912
|
// relays the returned `{rows, attestation, leafCount}` OPAQUE — it never constructs, inspects, or
|
|
1910
1913
|
// modifies the envelope (the bailiff line). `nowMs` = the source clock at serve, injected by the caller.
|
|
1911
|
-
export const attestedRead = (eng, ws, { queryId, paramsJson, attestorSecret, nowMs }) =>
|
|
1914
|
+
export const attestedRead = (eng, ws, { queryId, paramsJson, attestorSecret, nowMs, includeRosterProof }) =>
|
|
1912
1915
|
JSON.parse(call(eng.ex, "query", {
|
|
1913
1916
|
repoArg: repoArgOf(ws), workspace: ws, branch: BRANCH,
|
|
1914
|
-
queryBytes: b64Json({ op: "attestedRead", queryId, paramsJson: paramsJson || "{}", attestorSecret, nowMs: nowMs ?? Date.now(), sourceWorkspace: ws }),
|
|
1917
|
+
queryBytes: b64Json({ op: "attestedRead", queryId, paramsJson: paramsJson || "{}", attestorSecret, nowMs: nowMs ?? Date.now(), sourceWorkspace: ws, ...(includeRosterProof ? { includeRosterProof: true } : {}) }),
|
|
1915
1918
|
}, eng.STDERR));
|
|
1916
1919
|
|
|
1917
1920
|
// THE KERNEL-INSTRUCTED MISSING-EVIDENCE PARSE (stage 2 §4.1): the one gate's typed
|
|
@@ -2816,3 +2819,48 @@ export function warmEngine(eng) {
|
|
|
2816
2819
|
// not a top-level adapter verb. Still post-ack (the adapter calls warmEngine off the write critical path).
|
|
2817
2820
|
return JSON.parse(call(eng.ex, "query", { repoArg: "/work", workspace: "root", queryBytes: b64Json({ op: "warm" }), branch: BRANCH }, eng.STDERR));
|
|
2818
2821
|
}
|
|
2822
|
+
|
|
2823
|
+
/**
|
|
2824
|
+
* ATTESTED READS §5.2 (stage 3) — THE BATCH-SEAL DRIVER. The adapter's ONLY roles here are
|
|
2825
|
+
* SCHEDULING (when to ask) and TRANSPORT (carrying the kernel's own snapshot back as an offer)
|
|
2826
|
+
* — the debounced-admission-alarm precedent: the kernel decides WHAT a seal is (the
|
|
2827
|
+
* `attestationOpenBatch` snapshot + `shouldSeal` verdict + the gate's Merkle-root demand);
|
|
2828
|
+
* this function decides nothing. Call it on a timer / after serves / on unmount
|
|
2829
|
+
* (`{unmounting: true}` forces pending batches to seal — a batch never dies silently).
|
|
2830
|
+
* A failed seal offer LEAVES the accumulator intact (retry next tick, never a silent drop);
|
|
2831
|
+
* only an ADMITTED seal clears the sealed snapshot (`attestationBatchClear`).
|
|
2832
|
+
*
|
|
2833
|
+
* `domain` names the installed law that exports `recordAttestationBatch` (the framework
|
|
2834
|
+
* directive rides the composing law); `controllerHash` is that law's content hash. The offer
|
|
2835
|
+
* is authored AS `workspace:read-attestor` (the enrolled signer — §1.2's "one key, two
|
|
2836
|
+
* duties"); on a warranted workspace pass `opts.authorOpts` with the signing material.
|
|
2837
|
+
*/
|
|
2838
|
+
export function sealAttestationBatches(eng, ws, domain, controllerHash, opts = {}) {
|
|
2839
|
+
const snap = JSON.parse(call(eng.ex, "query", {
|
|
2840
|
+
repoArg: repoArgOf(ws), workspace: ws, branch: BRANCH,
|
|
2841
|
+
queryBytes: b64Json({ op: "attestationOpenBatch", repoArg: repoArgOf(ws), nowMs: opts.nowMs ?? Date.now(), unmounting: !!opts.unmounting }),
|
|
2842
|
+
}, eng.STDERR));
|
|
2843
|
+
const outcomes = [];
|
|
2844
|
+
for (const b of snap.batches ?? []) {
|
|
2845
|
+
if (b.leafCount === 0) continue;
|
|
2846
|
+
if (!(b.shouldSeal || opts.force)) continue;
|
|
2847
|
+
const payload = {
|
|
2848
|
+
batchId: b.batchId, batchRoot: b.batchRoot, leafCount: b.leafCount, leaves: b.leaves,
|
|
2849
|
+
firstAt: b.firstAt, lastAt: b.lastAt, headAtSeal: b.headAtSeal,
|
|
2850
|
+
foldRootAtSeal: b.foldRootAtSeal, signerKeyHash: b.signerKeyHash,
|
|
2851
|
+
};
|
|
2852
|
+
const r = author(eng, ws, domain, "recordAttestationBatch", payload, controllerHash, {
|
|
2853
|
+
actor: "workspace:read-attestor", ...(opts.authorOpts ?? {}),
|
|
2854
|
+
});
|
|
2855
|
+
if (!r.ok) {
|
|
2856
|
+
outcomes.push({ batchId: b.batchId, ok: false, error: r.error }); // retained — retries next call
|
|
2857
|
+
continue;
|
|
2858
|
+
}
|
|
2859
|
+
JSON.parse(call(eng.ex, "query", {
|
|
2860
|
+
repoArg: repoArgOf(ws), workspace: ws, branch: BRANCH,
|
|
2861
|
+
queryBytes: b64Json({ op: "attestationBatchClear", batchId: b.batchId, leafCount: b.leafCount }),
|
|
2862
|
+
}, eng.STDERR));
|
|
2863
|
+
outcomes.push({ batchId: b.batchId, ok: true, leafCount: b.leafCount, intent: r.intentOut });
|
|
2864
|
+
}
|
|
2865
|
+
return outcomes;
|
|
2866
|
+
}
|