@githolon/testing 0.46.0 → 0.48.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 +22 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@githolon/testing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.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
|
@@ -129,7 +129,8 @@ export async function createEngine({ wasmModule, bootstrapPkg, nomosPkg, replica
|
|
|
129
129
|
root.set("ws", new Directory(new Map()));
|
|
130
130
|
const preopen = new PreopenDirectory("/work", root);
|
|
131
131
|
const STDERR = [];
|
|
132
|
-
const
|
|
132
|
+
const pushStderr = (l) => { if (STDERR.length >= 500) STDERR.splice(0, STDERR.length - 499); STDERR.push(l); };
|
|
133
|
+
const fds = [new OpenFile(new File([])), ConsoleStdout.lineBuffered(() => {}), ConsoleStdout.lineBuffered(pushStderr), preopen];
|
|
133
134
|
const wasi = new WASI(["wasm_git_holon", "reactor"], [], fds, { debug: false });
|
|
134
135
|
const inst = await WebAssembly.instantiate(wasmModule, { wasi_snapshot_preview1: wasi.wasiImport });
|
|
135
136
|
const code = wasi.start(inst);
|
|
@@ -1003,6 +1004,9 @@ export async function admitIntentOffers(eng, ws, ledger, offers, { receiptFence
|
|
|
1003
1004
|
// BORN: the G3 birth offer-effect's child heads any `.births()` offer in this batch produced (the kernel
|
|
1004
1005
|
// surfaced them on the admit verdict). Accumulated across the batch and relayed out for the host to persist.
|
|
1005
1006
|
const born = [];
|
|
1007
|
+
// ...and their TYPED VERDICTS (born|deferred|failed|unwarranted-cert — typed_birth_outcomes.md §2),
|
|
1008
|
+
// accumulated beside `born` (never in place of; no custody bytes, no pack treatment).
|
|
1009
|
+
const birthOutcomes = [];
|
|
1006
1010
|
const timings = { spans: [], intents: 0, sessions: 0 };
|
|
1007
1011
|
// THE §5.2 SUMMARY CAPTURE on the OFFER LANE (offers are the only source of intents — this lane is the one
|
|
1008
1012
|
// admit, routed workspaces included). A shard (selfLabel set) with scoped reads captures the per-batch
|
|
@@ -1088,6 +1092,7 @@ export async function admitIntentOffers(eng, ws, ledger, offers, { receiptFence
|
|
|
1088
1092
|
rec.admitted.push({ oid, head: res.head });
|
|
1089
1093
|
admittedTotal += 1;
|
|
1090
1094
|
if (Array.isArray(res.born) && res.born.length) born.push(...res.born);
|
|
1095
|
+
if (Array.isArray(res.birthOutcomes) && res.birthOutcomes.length) birthOutcomes.push(...res.birthOutcomes);
|
|
1091
1096
|
if (cap) finishSummaryCapture(eng, ws, summaryCtx, cap, res.head, intentId);
|
|
1092
1097
|
} else {
|
|
1093
1098
|
const error = `${String(res.error || "").slice(0, 300)} — dead-lettered; fix the law (or the payload), then POST /v1/workspaces/${ws}/dead-letters/retry`;
|
|
@@ -1145,7 +1150,7 @@ export async function admitIntentOffers(eng, ws, ledger, offers, { receiptFence
|
|
|
1145
1150
|
// repos). Pack each born child's full chain BEFORE returning so the bytes ride out for the worker to persist
|
|
1146
1151
|
// to the child's own Artifacts repo (the host names nothing — it shuttles kernel-produced bytes keyed by ws).
|
|
1147
1152
|
const bornPacked = born.length ? packBornChildren(eng, born) : born;
|
|
1148
|
-
return { sessions: [...sessions.values()].map((s) => ({ ...s, ...(s.skipped.length ? {} : { skipped: undefined }) })), main: head, deadLetters, timings, ...(summary ? { summary } : {}), ...(bornPacked.length ? { born: bornPacked } : {}), ...(resultPackB64 ? { resultPackB64, resultBase: clientBase } : {}), ...(deferDurability && admittedTotal && head ? { deferred: true, head } : {}) };
|
|
1153
|
+
return { sessions: [...sessions.values()].map((s) => ({ ...s, ...(s.skipped.length ? {} : { skipped: undefined }) })), main: head, deadLetters, timings, ...(summary ? { summary } : {}), ...(bornPacked.length ? { born: bornPacked } : {}), ...(birthOutcomes.length ? { birthOutcomes } : {}), ...(resultPackB64 ? { resultPackB64, resultBase: clientBase } : {}), ...(deferDurability && admittedTotal && head ? { deferred: true, head } : {}) };
|
|
1149
1154
|
}
|
|
1150
1155
|
|
|
1151
1156
|
/**
|
|
@@ -1188,7 +1193,8 @@ export async function authorOn(eng, ws, ledger, domain, directiveId, payload, la
|
|
|
1188
1193
|
// author case → worker relays the bytes and the worker persists them to the child's OWN Artifacts repo. The
|
|
1189
1194
|
// PARENT's main was already pushed above; the child custody is a SEPARATE store the host must ship.
|
|
1190
1195
|
const bornPacked = Array.isArray(res.born) && res.born.length ? packBornChildren(eng, res.born) : res.born;
|
|
1191
|
-
|
|
1196
|
+
// birthOutcomes carries NO custody bytes — pass through verbatim (no packBornChildren treatment).
|
|
1197
|
+
return { ok: true, head: res.head, ...(bornPacked ? { born: bornPacked } : {}), ...(res.birthOutcomes ? { birthOutcomes: res.birthOutcomes } : {}) };
|
|
1192
1198
|
}
|
|
1193
1199
|
|
|
1194
1200
|
/**
|
|
@@ -1346,6 +1352,16 @@ export function currentLaw(eng, ws) {
|
|
|
1346
1352
|
return out.keyMap || {};
|
|
1347
1353
|
}
|
|
1348
1354
|
|
|
1355
|
+
/** INSTALLED-LAW META-READ — kernel-folded control-plane state, not tenant projection. */
|
|
1356
|
+
export function installedLaw(eng, ws) {
|
|
1357
|
+
return JSON.parse(call(eng.ex, "query", { repoArg: repoArgOf(ws), workspace: ws, queryBytes: b64Json({ op: "installedLaw" }), branch: BRANCH }, eng.STDERR));
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
/** INSTALLED PACKAGE META-READ — package bytes from folded policy/domain-installation state. */
|
|
1361
|
+
export function domainPackage(eng, ws, hash) {
|
|
1362
|
+
return JSON.parse(call(eng.ex, "query", { repoArg: repoArgOf(ws), workspace: ws, queryBytes: b64Json({ op: "domainPackage", hash }), branch: BRANCH }, eng.STDERR));
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1349
1365
|
/** THE CAPABILITY DECLARATION READ (Full-A — capability_marketplace.md §4): the holon
|
|
1350
1366
|
* surfaces every CURRENTLY-INSTALLED domain's `nomosCapabilities` law key (the impure-
|
|
1351
1367
|
* capability quartets sealed into the law). The deploy lane relays these as a "declared —
|
|
@@ -1474,9 +1490,10 @@ export function author(eng, ws, domain, directiveId, payload, controllerHash, op
|
|
|
1474
1490
|
writeWork(eng, `envelope-${seq}.json`, enc.encode(stringifyBig(envelope)));
|
|
1475
1491
|
v = offerOnce();
|
|
1476
1492
|
}
|
|
1477
|
-
// KEEP `born
|
|
1493
|
+
// KEEP `born` (+ `birthOutcomes`, the typed verdict vector beside it — typed_birth_outcomes.md §2):
|
|
1494
|
+
// the wasm offer ran the G3 birth offer-effect and surfaced the child heads; thread them
|
|
1478
1495
|
// through the normalized shape so the relay (container author case → worker out.born) sees them.
|
|
1479
|
-
const res = v.outcome === "admitted" ? { ok: true, head: v.head, intentOut: v.intentOut, ...(v.born ? { born: v.born } : {}) }
|
|
1496
|
+
const res = v.outcome === "admitted" ? { ok: true, head: v.head, intentOut: v.intentOut, ...(v.born ? { born: v.born } : {}), ...(v.birthOutcomes ? { birthOutcomes: v.birthOutcomes } : {}) }
|
|
1480
1497
|
: v.outcome === "refused" ? { ok: false, error: v.verdict?.reason ?? v.error }
|
|
1481
1498
|
: v; // defensive: a non-verdict shape passes through unchanged
|
|
1482
1499
|
if (defer && res.ok) (eng.pendingProjection ??= new Set()).add(ws);
|