@githolon/testing 0.18.0 → 0.20.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 +68 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@githolon/testing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.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
|
@@ -1137,7 +1137,11 @@ export async function admitIntentOffers(eng, ws, ledger, offers, { refuseDomains
|
|
|
1137
1137
|
} catch { /* fall back to the client's own GET /pack */ }
|
|
1138
1138
|
}
|
|
1139
1139
|
log("admit-intent-offers", { ws, sessions: sessions.size, admitted: admittedTotal, rejected: [...sessions.values()].reduce((n, s) => n + s.rejected.length, 0), resultPack: resultPackB64 ? "inline" : "none" });
|
|
1140
|
-
|
|
1140
|
+
// G3 COLD-STORAGE: a `.births()` offer in this batch produced child custody in this engine's FS (the sibling
|
|
1141
|
+
// repos). Pack each born child's full chain BEFORE returning so the bytes ride out for the worker to persist
|
|
1142
|
+
// to the child's own Artifacts repo (the host names nothing — it shuttles kernel-produced bytes keyed by ws).
|
|
1143
|
+
const bornPacked = born.length ? packBornChildren(eng, born) : born;
|
|
1144
|
+
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 } : {}) };
|
|
1141
1145
|
}
|
|
1142
1146
|
|
|
1143
1147
|
/**
|
|
@@ -1175,9 +1179,12 @@ export async function authorOn(eng, ws, ledger, domain, directiveId, payload, la
|
|
|
1175
1179
|
}
|
|
1176
1180
|
if (res && res.ok === false) return { ok: false, error: String(res.error || "the law refused this intent").slice(0, 500) };
|
|
1177
1181
|
await commitAndPush(eng, ws, ledger);
|
|
1178
|
-
//
|
|
1179
|
-
//
|
|
1180
|
-
|
|
1182
|
+
// G3 COLD-STORAGE: a `.births()` directive authored here ran the kernel birth offer-effect, which wrote each
|
|
1183
|
+
// child's custody to a sibling repo in this engine's FS. Pack each born child's full chain so the container
|
|
1184
|
+
// author case → worker relays the bytes and the worker persists them to the child's OWN Artifacts repo. The
|
|
1185
|
+
// PARENT's main was already pushed above; the child custody is a SEPARATE store the host must ship.
|
|
1186
|
+
const bornPacked = Array.isArray(res.born) && res.born.length ? packBornChildren(eng, res.born) : res.born;
|
|
1187
|
+
return { ok: true, head: res.head, ...(bornPacked ? { born: bornPacked } : {}) };
|
|
1181
1188
|
}
|
|
1182
1189
|
|
|
1183
1190
|
/**
|
|
@@ -1899,6 +1906,63 @@ export function servePack(eng, ws, base = "") {
|
|
|
1899
1906
|
if (!r || r.ok !== true || typeof r.packB64 !== "string") throw new Error("servePack: kernel produced no pack");
|
|
1900
1907
|
return { packB64: r.packB64, bytes: r.bytes };
|
|
1901
1908
|
}
|
|
1909
|
+
|
|
1910
|
+
// ── G3 COLD-STORAGE: SURFACE THE BORN CHILD'S CUSTODY BYTES (the host-bailiff persist lane) ──────────────
|
|
1911
|
+
// The kernel's birth offer-effect (`run_birth_effect`) wrote each born child's whole genesis→head custody to
|
|
1912
|
+
// a SIBLING repo IN THIS ENGINE'S FS — `sibling_repo_arg(parent_repo_arg, child)` == `/work/ws/<child>` ==
|
|
1913
|
+
// `repoArgOf(child)` (the kernel names no DO/container topology; it writes a path the host already keys by ws
|
|
1914
|
+
// name). That custody lives ONLY in the engine FS until the HOST ships it to the child's OWN custody store.
|
|
1915
|
+
// So pack each born child's FULL chain (base="" ⇒ genesis→head) straight from its sibling repo and carry the
|
|
1916
|
+
// bytes OUT on the born entry; the worker (which holds the Artifacts binding) creates the child repo + pushes
|
|
1917
|
+
// the pack to refs/heads/main. Host-pure: the adapter NAMES no domain, DECIDES nothing — it shuttles the
|
|
1918
|
+
// kernel-produced child custody keyed by the kernel-returned `{workspace, head}`. A child whose pack can't be
|
|
1919
|
+
// produced keeps its entry WITHOUT packB64 (+ logs) so the worker SURFACES the failure (the physical birth is
|
|
1920
|
+
// never silently dropped). Returns the born array with packB64 added where it could be packed.
|
|
1921
|
+
export function packBornChildren(eng, born) {
|
|
1922
|
+
if (!Array.isArray(born) || !born.length) return born;
|
|
1923
|
+
return born.map((b) => {
|
|
1924
|
+
const child = b && typeof b.workspace === "string" ? b.workspace : null;
|
|
1925
|
+
const head = b && typeof b.head === "string" ? b.head : null;
|
|
1926
|
+
if (!child || !/^[0-9a-f]{40}$/i.test(head || "")) {
|
|
1927
|
+
log("born-pack-skipped", { workspace: child, head, reason: "malformed born entry" });
|
|
1928
|
+
return b;
|
|
1929
|
+
}
|
|
1930
|
+
try {
|
|
1931
|
+
// base="" ⇒ the FULL pack of everything reachable from the child's head (genesis→head). The kernel
|
|
1932
|
+
// resolves the child's main itself from the sibling repo at repoArgOf(child).
|
|
1933
|
+
const pack = packDelta(eng, child, "", head);
|
|
1934
|
+
if (!pack || !pack.length) {
|
|
1935
|
+
log("born-pack-empty", { workspace: child, head });
|
|
1936
|
+
return b;
|
|
1937
|
+
}
|
|
1938
|
+
return { ...b, packB64: b64Bytes(pack), packBytes: pack.length };
|
|
1939
|
+
} catch (e) {
|
|
1940
|
+
log("born-pack-failed", { workspace: child, head, error: String(e).slice(0, 200) });
|
|
1941
|
+
return b;
|
|
1942
|
+
}
|
|
1943
|
+
});
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
// ── INGEST A CUSTODY PACK AS A WORKSPACE'S OWN STORE (the host-side twin of the worker's pushPack persist) ──
|
|
1947
|
+
// Stage a FRESH bare repo for `ws` in THIS engine's FS, ingest the kernel-built `packBytes` (apply_pack — the
|
|
1948
|
+
// inbound twin of pack_delta; objects land PACKED), then point refs/heads/main + HEAD at `head`. This is what
|
|
1949
|
+
// a peer/edge does on receiving a workspace's pack over the wire: it holds ONLY the pack, no parent FS. The
|
|
1950
|
+
// cross-workspace birth proof uses it to mount a born child from an INDEPENDENT custody store (not the parent
|
|
1951
|
+
// engine FS) — proving the host-bailiff persist is what makes the child servable on its own. `packBytes` is a
|
|
1952
|
+
// Uint8Array (the bytes packBornChildren / the worker's b64-decoded packB64 carry).
|
|
1953
|
+
export async function ingestPackAsCustody(eng, ws, packBytes, head) {
|
|
1954
|
+
if (!packBytes || !packBytes.length) throw new Error(`ingestPackAsCustody: empty pack for '${ws}'`);
|
|
1955
|
+
if (!/^[0-9a-f]{40}$/i.test(head || "")) throw new Error(`ingestPackAsCustody: bad head '${head}' for '${ws}'`);
|
|
1956
|
+
unmount(eng, ws);
|
|
1957
|
+
stageWorkspaceDir(eng, ws);
|
|
1958
|
+
const gitdir = gitdirOf(ws);
|
|
1959
|
+
await custodySkeleton(eng, gitdir);
|
|
1960
|
+
applyPackInto(eng, ws, packBytes); // kernel apply_pack — ingests the genesis→head objects
|
|
1961
|
+
kgit.writeRef(eng, gitdir, "refs/heads/main", head);
|
|
1962
|
+
kgit.writeRef(eng, gitdir, "HEAD", "ref: refs/heads/main");
|
|
1963
|
+
eng.mounted.set(ws, { restored: true, remoteMain: head, restoreError: null });
|
|
1964
|
+
return { ok: true, head: kgit.resolveRef(eng, gitdir, "refs/heads/main") };
|
|
1965
|
+
}
|
|
1902
1966
|
export const nomosActive = (eng, ws) => qById(eng, ws, `domain-installation:${eng.hashes.nomos}`).length > 0;
|
|
1903
1967
|
// E2E crypto linkage probe (the encryption arc): run the wrap→unwrap + field seal→open
|
|
1904
1968
|
// INSIDE the deployable wasm. Pure — no workspace, no chain. Returns {wrapHandoff, fieldAead}.
|