@githolon/testing 0.47.0 → 0.48.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@githolon/testing",
3
- "version": "0.47.0",
3
+ "version": "0.48.1",
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",
@@ -1004,6 +1004,9 @@ export async function admitIntentOffers(eng, ws, ledger, offers, { receiptFence
1004
1004
  // BORN: the G3 birth offer-effect's child heads any `.births()` offer in this batch produced (the kernel
1005
1005
  // surfaced them on the admit verdict). Accumulated across the batch and relayed out for the host to persist.
1006
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 = [];
1007
1010
  const timings = { spans: [], intents: 0, sessions: 0 };
1008
1011
  // THE §5.2 SUMMARY CAPTURE on the OFFER LANE (offers are the only source of intents — this lane is the one
1009
1012
  // admit, routed workspaces included). A shard (selfLabel set) with scoped reads captures the per-batch
@@ -1089,6 +1092,7 @@ export async function admitIntentOffers(eng, ws, ledger, offers, { receiptFence
1089
1092
  rec.admitted.push({ oid, head: res.head });
1090
1093
  admittedTotal += 1;
1091
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);
1092
1096
  if (cap) finishSummaryCapture(eng, ws, summaryCtx, cap, res.head, intentId);
1093
1097
  } else {
1094
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`;
@@ -1146,7 +1150,7 @@ export async function admitIntentOffers(eng, ws, ledger, offers, { receiptFence
1146
1150
  // repos). Pack each born child's full chain BEFORE returning so the bytes ride out for the worker to persist
1147
1151
  // to the child's own Artifacts repo (the host names nothing — it shuttles kernel-produced bytes keyed by ws).
1148
1152
  const bornPacked = born.length ? packBornChildren(eng, born) : born;
1149
- 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 } : {}) };
1150
1154
  }
1151
1155
 
1152
1156
  /**
@@ -1189,7 +1193,8 @@ export async function authorOn(eng, ws, ledger, domain, directiveId, payload, la
1189
1193
  // author case → worker relays the bytes and the worker persists them to the child's OWN Artifacts repo. The
1190
1194
  // PARENT's main was already pushed above; the child custody is a SEPARATE store the host must ship.
1191
1195
  const bornPacked = Array.isArray(res.born) && res.born.length ? packBornChildren(eng, res.born) : res.born;
1192
- return { ok: true, head: res.head, ...(bornPacked ? { born: bornPacked } : {}) };
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 } : {}) };
1193
1198
  }
1194
1199
 
1195
1200
  /**
@@ -1485,9 +1490,10 @@ export function author(eng, ws, domain, directiveId, payload, controllerHash, op
1485
1490
  writeWork(eng, `envelope-${seq}.json`, enc.encode(stringifyBig(envelope)));
1486
1491
  v = offerOnce();
1487
1492
  }
1488
- // KEEP `born`: the wasm offer ran the G3 birth offer-effect and surfaced the child heads; thread them
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
1489
1495
  // through the normalized shape so the relay (container author case → worker out.born) sees them.
1490
- 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 } : {}) }
1491
1497
  : v.outcome === "refused" ? { ok: false, error: v.verdict?.reason ?? v.error }
1492
1498
  : v; // defensive: a non-verdict shape passes through unchanged
1493
1499
  if (defer && res.ok) (eng.pendingProjection ??= new Set()).add(ws);
@@ -1986,16 +1992,21 @@ export function packDelta(eng, ws, base, head) {
1986
1992
  // pack of all reachable from main (fresh clone); `base` = the client's known head ⇒ the incremental delta.
1987
1993
  // The kernel resolves main itself. Returns `{ packB64, bytes }` (base64 so it rides the container JSON op).
1988
1994
  export function servePack(eng, ws, base = "") {
1995
+ // `head`: the tip this pack reaches (resolved BEFORE packing, so it can only under-state, never
1996
+ // over-state, what the pack contains) — the cache-coherence anchor for the worker's short-TTL pack
1997
+ // cache: a cached pack is reusable ONLY while main still points at the head it was built from.
1998
+ let head = null;
1999
+ try { head = kgit.resolveRef(eng, gitdirOf(ws), BRANCH); } catch { /* diagnostics only */ }
1989
2000
  let r;
1990
2001
  try {
1991
2002
  r = JSON.parse(call(eng.ex, "pack_delta", { repoArg: repoArgOf(ws), workspace: ws, base, branch: BRANCH }, eng.STDERR));
1992
2003
  } catch (e) {
1993
2004
  // UP TO DATE: the client's `have` already IS main → nothing to send. A clean empty response, not an error.
1994
- if (/nothing to pack|head == base/.test(String(e))) return { packB64: "", bytes: 0, upToDate: true };
2005
+ if (/nothing to pack|head == base/.test(String(e))) return { packB64: "", bytes: 0, upToDate: true, ...(head ? { head } : {}) };
1995
2006
  throw e;
1996
2007
  }
1997
2008
  if (!r || r.ok !== true || typeof r.packB64 !== "string") throw new Error("servePack: kernel produced no pack");
1998
- return { packB64: r.packB64, bytes: r.bytes };
2009
+ return { packB64: r.packB64, bytes: r.bytes, ...(head ? { head } : {}) };
1999
2010
  }
2000
2011
 
2001
2012
  // ── G3 COLD-STORAGE: SURFACE THE BORN CHILD'S CUSTODY BYTES (the host-bailiff persist lane) ──────────────