githolon 0.93.0 → 0.94.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/dist/cli.mjs CHANGED
@@ -9,7 +9,7 @@ var __export = (target, all) => {
9
9
  __defProp(target, name, { get: all[name], enumerable: true });
10
10
  };
11
11
 
12
- // vendor/engine/git-fs.mjs
12
+ // vendor/engine/git-fs.ts
13
13
  function fsErr(code, p) {
14
14
  const e = new Error(`${code}: ${p}`);
15
15
  e.code = code;
@@ -17,7 +17,7 @@ function fsErr(code, p) {
17
17
  }
18
18
  function makeGitFs(preopen, mount, { File: File3, Directory: Directory3 }) {
19
19
  const root = preopen.dir;
20
- const isDir = (n) => n && n.contents instanceof Map;
20
+ const isDir = (n) => !!n && n.contents instanceof Map;
21
21
  function parts(p) {
22
22
  if (p === mount) return [];
23
23
  if (!p.startsWith(mount + "/")) throw fsErr("ENOENT", p);
@@ -107,14 +107,14 @@ function makeGitFs(preopen, mount, { File: File3, Directory: Directory3 }) {
107
107
  return { promises };
108
108
  }
109
109
  var init_git_fs = __esm({
110
- "vendor/engine/git-fs.mjs"() {
110
+ "vendor/engine/git-fs.ts"() {
111
111
  "use strict";
112
112
  }
113
113
  });
114
114
 
115
- // vendor/engine/tree.mjs
115
+ // vendor/engine/tree.ts
116
116
  function flatten(dir, prefix, out13) {
117
- for (const [name, inode] of dir.contents) {
117
+ for (const [name, inode] of dir.contents ?? /* @__PURE__ */ new Map()) {
118
118
  const path = prefix ? prefix + "/" + name : name;
119
119
  if (inode.contents instanceof Map) {
120
120
  out13.push({ path, dir: true });
@@ -153,14 +153,14 @@ function serializeTree(workTree) {
153
153
  }
154
154
  var enc, dec;
155
155
  var init_tree = __esm({
156
- "vendor/engine/tree.mjs"() {
156
+ "vendor/engine/tree.ts"() {
157
157
  "use strict";
158
158
  enc = new TextEncoder();
159
159
  dec = new TextDecoder();
160
160
  }
161
161
  });
162
162
 
163
- // vendor/engine/custody-transport.mjs
163
+ // vendor/engine/custody-transport.ts
164
164
  function concatBytes(chunks) {
165
165
  let n = 0;
166
166
  for (const c of chunks) n += c.length;
@@ -284,7 +284,7 @@ async function pushPack(remote, headers = {}, { updates = [], pack = null } = {}
284
284
  }
285
285
  var enc2, dec2, ZERO_OID, EMPTY_PACK, FLUSH;
286
286
  var init_custody_transport = __esm({
287
- "vendor/engine/custody-transport.mjs"() {
287
+ "vendor/engine/custody-transport.ts"() {
288
288
  "use strict";
289
289
  enc2 = new TextEncoder();
290
290
  dec2 = new TextDecoder();
@@ -329,7 +329,7 @@ var init_custody_transport = __esm({
329
329
  }
330
330
  });
331
331
 
332
- // vendor/engine/engine.mjs
332
+ // vendor/engine/engine.ts
333
333
  var engine_exports = {};
334
334
  __export(engine_exports, {
335
335
  NOMOS_SHARD_ROWS_READ: () => NOMOS_SHARD_ROWS_READ,
@@ -485,7 +485,7 @@ function call(ex, mode, fields, STDERR) {
485
485
  packed = ex.git_holon_call(reqPtr, req.length);
486
486
  } catch (e) {
487
487
  const tail = STDERR.length ? ` | stderr: ${STDERR.slice(-8).join(" / ")}` : "";
488
- throw new Error(`${String(e && e.stack || e)}${tail}`);
488
+ throw new Error(`${String(e?.stack || e)}${tail}`);
489
489
  }
490
490
  const { ptr, len } = unpack(packed);
491
491
  try {
@@ -516,9 +516,10 @@ async function createEngine({ wasmModule, bootstrapPkg, nomosPkg, replica, insta
516
516
  const inst = await WebAssembly.instantiate(wasmModule, { wasi_snapshot_preview1: wasi.wasiImport });
517
517
  const code = wasi.start(inst);
518
518
  if (code !== 0) throw new Error(`reactor init exited ${code}; stderr=${STDERR.join("\n")}`);
519
- for (const n of ["memory", "git_holon_alloc", "git_holon_dealloc", "git_holon_call"]) if (!inst.exports[n]) throw new Error(`missing export ${n}`);
519
+ const instExports = inst.exports;
520
+ for (const n of ["memory", "git_holon_alloc", "git_holon_dealloc", "git_holon_call"]) if (!instExports[n]) throw new Error(`missing export ${n}`);
520
521
  const eng = {
521
- ex: inst.exports,
522
+ ex: instExports,
522
523
  preopen,
523
524
  STDERR,
524
525
  seq: 0,
@@ -555,7 +556,7 @@ async function wrongHomeVerdict(shardRouting, route, payload) {
555
556
  const tag = routeTagHexOfMintedId(value);
556
557
  if (tag !== void 0) {
557
558
  for (const a of rows) {
558
- if (await routeTagHexOfHomeKey(a.homeKey) === tag) {
559
+ if (await routeTagHexOfHomeKey(String(a.homeKey)) === tag) {
559
560
  assignment = a;
560
561
  break;
561
562
  }
@@ -827,7 +828,7 @@ async function deriveSummarySuffix(eng, ws, fromOid) {
827
828
  touchedBuckets.add(ak);
828
829
  }
829
830
  for (const bk of touchedBuckets) {
830
- const ov = extRunning.has(bk) ? extRunning.get(bk) : null;
831
+ const ov = extRunning.has(bk) ? extRunning.get(bk) ?? null : null;
831
832
  const nv = recomputeExt(read, bk);
832
833
  if (nv === ov) continue;
833
834
  extRunning.set(bk, nv);
@@ -839,7 +840,7 @@ async function deriveSummarySuffix(eng, ws, fromOid) {
839
840
  }
840
841
  } else {
841
842
  for (const d of contributionDiff(read, before, after)) {
842
- bump(summaryKey(d.readId, d.group), d.delta);
843
+ bump(summaryKey(d.readId, d.group), d.delta ?? 0);
843
844
  deltas.push(d);
844
845
  }
845
846
  }
@@ -872,6 +873,7 @@ async function deriveSummarySuffix(eng, ws, fromOid) {
872
873
  }
873
874
  }
874
875
  if (!sawFrom) return { ok: false, error: `fromOid ${String(fromOid).slice(0, 12)} is not on this shard's main \u2014 cannot derive the suffix` };
876
+ if (!prevs) prevs = /* @__PURE__ */ new Map();
875
877
  const touched = /* @__PURE__ */ new Set();
876
878
  for (const ev of events) for (const d of ev.deltas) touched.add(summaryKey(d.readId, d.group));
877
879
  const subtotals = [];
@@ -1213,7 +1215,7 @@ async function admitIntentOffers(eng, ws, ledger, offers, { receiptFence = null,
1213
1215
  admittedTotal += 1;
1214
1216
  if (Array.isArray(res.born) && res.born.length) born.push(...res.born);
1215
1217
  if (Array.isArray(res.birthOutcomes) && res.birthOutcomes.length) birthOutcomes.push(...res.birthOutcomes);
1216
- if (cap2) finishSummaryCapture(eng, ws, summaryCtx, cap2, res.head, intentId);
1218
+ if (cap2) finishSummaryCapture(eng, ws, summaryCtx, cap2, res.head ?? "", intentId);
1217
1219
  } else {
1218
1220
  const error = `${String(res.error || "").slice(0, 300)} \u2014 dead-lettered; fix the law (or the payload), then POST /v1/workspaces/${ws}/dead-letters/retry`;
1219
1221
  rec.rejected.push({ oid, error, deadLettered: true });
@@ -1247,7 +1249,7 @@ async function admitIntentOffers(eng, ws, ledger, offers, { receiptFence = null,
1247
1249
  let resultPackB64 = null;
1248
1250
  if (admittedTotal && head && /^[0-9a-f]{40}$/i.test(clientBase || "") && clientBase !== head) {
1249
1251
  try {
1250
- const p = servePack(eng, ws, clientBase);
1252
+ const p = servePack(eng, ws, clientBase ?? "");
1251
1253
  if (p && p.packB64 && p.bytes && p.bytes <= RESULT_PACK_INLINE_MAX) resultPackB64 = p.packB64;
1252
1254
  } catch {
1253
1255
  }
@@ -1270,7 +1272,7 @@ async function authorOn(eng, ws, ledger, domain, directiveId, payload, lawHash,
1270
1272
  try {
1271
1273
  res = author(eng, ws, domain, directiveId, payload, lawHash, opts);
1272
1274
  } catch (e) {
1273
- return { ok: false, error: String(e && e.message || e).slice(0, 500) };
1275
+ return { ok: false, error: String(e?.message || e).slice(0, 500) };
1274
1276
  }
1275
1277
  if (res && res.ok === false) return { ok: false, error: String(res.error || "the law refused this intent").slice(0, 500) };
1276
1278
  await commitAndPush(eng, ws, ledger);
@@ -1322,7 +1324,7 @@ async function deepVerifyShard(eng, shardWs, shardLedger, coordinatorRows) {
1322
1324
  }
1323
1325
  function stageWorkspaceDir(eng, ws) {
1324
1326
  const wsContents = /* @__PURE__ */ new Map();
1325
- eng.preopen.dir.contents.get("ws").contents.set(ws, new Directory(wsContents));
1327
+ dirOf(eng.preopen.dir.contents.get("ws")).contents.set(ws, new Directory(wsContents));
1326
1328
  }
1327
1329
  async function mountWorkspace(eng, ws, ledger) {
1328
1330
  if (eng.mounted.has(ws)) return eng.mounted.get(ws);
@@ -1337,7 +1339,7 @@ async function mountWorkspace(eng, ws, ledger) {
1337
1339
  restored = true;
1338
1340
  }
1339
1341
  } catch (e) {
1340
- restoreError = String(e && e.stack || e).split("\n").slice(0, 5).join(" | ");
1342
+ restoreError = String(e?.stack || e).split("\n").slice(0, 5).join(" | ");
1341
1343
  }
1342
1344
  const m = { restored, remoteMain, restoreError };
1343
1345
  eng.mounted.set(ws, m);
@@ -1379,7 +1381,7 @@ async function queryEphemeral(eng, ws, mountOpts, queryId, paramsJson, principal
1379
1381
  function unmount(eng, ws) {
1380
1382
  eng.mounted.delete(ws);
1381
1383
  eng.mainIntents.delete(ws);
1382
- const wsRoot = eng.preopen.dir.contents.get("ws");
1384
+ const wsRoot = dirOf(eng.preopen.dir.contents.get("ws"));
1383
1385
  if (wsRoot) wsRoot.contents.delete(ws);
1384
1386
  }
1385
1387
  function writeWork(eng, name, bytes) {
@@ -1540,7 +1542,7 @@ async function readCheckpointBlob(eng, ws, commitOid) {
1540
1542
  let codec = "gzip";
1541
1543
  let stateRoot = null;
1542
1544
  try {
1543
- const m = JSON.parse(dec3.decode(kgit.readBlob(eng, gitdir, commitOid, "meta")));
1545
+ const m = JSON.parse(dec3.decode(kgit.readBlob(eng, gitdir, commitOid, "meta") ?? new Uint8Array()));
1544
1546
  codec = m.codec ?? "gzip";
1545
1547
  stateRoot = m.stateRoot ?? null;
1546
1548
  } catch {
@@ -1571,7 +1573,7 @@ async function lawParity(eng, ws, lawHash) {
1571
1573
  }
1572
1574
  async function pushCheckpoint(eng, ws, ledger, lawHash) {
1573
1575
  try {
1574
- lawHash = await lawParity(eng, ws, lawHash);
1576
+ lawHash = await lawParity(eng, ws, lawHash) ?? "";
1575
1577
  if (!lawHash) return { pushed: false, reason: "no-law" };
1576
1578
  const gitdir = gitdirOf(ws);
1577
1579
  const head = kgit.resolveRef(eng, gitdir, "refs/heads/main");
@@ -1588,12 +1590,12 @@ async function pushCheckpoint(eng, ws, ledger, lawHash) {
1588
1590
  eng._ckptPushed.set(ws, tag);
1589
1591
  return { pushed: true, cursor: ex.cursor, bytes: ex.bytes ?? 0 };
1590
1592
  } catch (e) {
1591
- return { pushed: false, reason: String(e && e.message || e).slice(0, 160) };
1593
+ return { pushed: false, reason: String(e?.message || e).slice(0, 160) };
1592
1594
  }
1593
1595
  }
1594
1596
  async function stageCheckpoint(eng, ws, lawHash) {
1595
1597
  try {
1596
- lawHash = await lawParity(eng, ws, lawHash);
1598
+ lawHash = await lawParity(eng, ws, lawHash) ?? "";
1597
1599
  if (!lawHash) return null;
1598
1600
  eng._ckptPushed ??= /* @__PURE__ */ new Map();
1599
1601
  const ex = exportCheckpoint(eng, ws);
@@ -1631,7 +1633,7 @@ async function restoreCheckpointFromCustody(eng, ws, ledger, lawHash) {
1631
1633
  if (mounted?.checkpoint?.restored) {
1632
1634
  return { restored: false, reason: "already-mounted-checkpoint" };
1633
1635
  }
1634
- lawHash = await lawParity(eng, ws, lawHash);
1636
+ lawHash = await lawParity(eng, ws, lawHash) ?? "";
1635
1637
  if (!lawHash) return { restored: false, reason: "no-law" };
1636
1638
  const ref = CKPT_REF(lawHash);
1637
1639
  const serverRefs = await custodyLsRefs(ledger, ref);
@@ -1646,7 +1648,7 @@ async function restoreCheckpointFromCustody(eng, ws, ledger, lawHash) {
1646
1648
  }
1647
1649
  return { restored: r && r.restored === true, frontierSeeded: r && r.frontierSeeded === true, cursor: r && r.cursor, reason: r && r.reason };
1648
1650
  } catch (e) {
1649
- return { restored: false, reason: String(e && e.message || e).slice(0, 160) };
1651
+ return { restored: false, reason: String(e?.message || e).slice(0, 160) };
1650
1652
  }
1651
1653
  }
1652
1654
  async function custodySkeleton(eng, gitdir) {
@@ -1655,7 +1657,7 @@ async function custodySkeleton(eng, gitdir) {
1655
1657
  try {
1656
1658
  await p.mkdir(`${gitdir}${d}`);
1657
1659
  } catch (e) {
1658
- if (e && e.code !== "EEXIST") throw e;
1660
+ if (e?.code !== "EEXIST") throw e;
1659
1661
  }
1660
1662
  }
1661
1663
  try {
@@ -1673,11 +1675,14 @@ async function custodyFetch(eng, ws, ledger, { remoteRef = "refs/heads/main", lo
1673
1675
  const refs = await custodyLsRefs(ledger, remoteRefFull);
1674
1676
  const tip = refs[remoteRefFull] || null;
1675
1677
  if (!tip) return null;
1676
- if (tip !== have) applyPackInto(eng, ws, await fetchPack(ledger.remote, ledger.headers || {}, { wants: [tip], haves: have ? [have] : [] }));
1678
+ if (tip !== have) {
1679
+ const pk = await fetchPack(ledger.remote, ledger.headers || {}, { wants: [tip], haves: have ? [have] : [] });
1680
+ if (pk) applyPackInto(eng, ws, pk);
1681
+ }
1677
1682
  kgit.writeRef(eng, gitdirOf(ws), fullRef(localRef || remoteRef), tip);
1678
1683
  return tip;
1679
1684
  }
1680
- async function custodyPush(eng, ws, ledger, { localRef = null, remoteRef, del = false, pointer = false, newOid = null } = {}) {
1685
+ async function custodyPush(eng, ws, ledger, { localRef = null, remoteRef, del = false, pointer = false, newOid = null }) {
1681
1686
  const headers = ledger.headers || {};
1682
1687
  const remoteRefFull = fullRef(remoteRef);
1683
1688
  const remote = await lsRefs(ledger.remote, headers, { service: "git-receive-pack", prefix: remoteRefFull });
@@ -1849,18 +1854,18 @@ async function ingestPackAsCustody(eng, ws, packBytes, head) {
1849
1854
  eng.mounted.set(ws, { restored: true, remoteMain: head, restoreError: null });
1850
1855
  return { ok: true, head: kgit.resolveRef(eng, gitdir, "refs/heads/main") };
1851
1856
  }
1852
- function offerIntent(eng, ws, bytes, opts) {
1857
+ function offerIntent(eng, ws, bytes, opts = {}) {
1853
1858
  const name = `offer-in-${eng.seq++}.json`;
1854
1859
  writeWork(eng, name, bytes);
1855
1860
  const deferProjection = !!(opts && opts.defer);
1856
1861
  const branch = opts && opts.branch || BRANCH;
1857
1862
  return JSON.parse(call(eng.ex, "offer", { repoArg: repoArgOf(ws), workspace: ws, intentFile: `/work/${name}`, branch, deferProjection }, eng.STDERR));
1858
1863
  }
1859
- function offerAdmit(eng, ws, bytes, opts) {
1864
+ function offerAdmit(eng, ws, bytes, opts = {}) {
1860
1865
  const v = offerIntent(eng, ws, bytes, opts);
1861
1866
  return v.outcome === "admitted" ? { ok: true, head: v.head, ...v.born ? { born: v.born } : {} } : { ok: false, error: v.verdict?.reason ?? v.error ?? "the offer was refused" };
1862
1867
  }
1863
- function applyIntentBytes(eng, ws, bytes, opts) {
1868
+ function applyIntentBytes(eng, ws, bytes, opts = {}) {
1864
1869
  return offerAdmit(eng, ws, bytes, opts);
1865
1870
  }
1866
1871
  async function mainIntentIds(eng, ws) {
@@ -1936,7 +1941,7 @@ async function admitAll(eng, ws, ledger, { receiptFence = null, shardRouting = n
1936
1941
  try {
1937
1942
  await custodyFetch(eng, ws, ledger, { remoteRef: ref, have: localMain });
1938
1943
  } catch (thinErr) {
1939
- log("thin-fetch-fallback", { ws, cid, error: String(thinErr && thinErr.message || thinErr).slice(0, 160) });
1944
+ log("thin-fetch-fallback", { ws, cid, error: String(thinErr?.message || thinErr).slice(0, 160) });
1940
1945
  await custodyFetch(eng, ws, ledger, { remoteRef: ref, have: null });
1941
1946
  }
1942
1947
  } finally {
@@ -1945,7 +1950,7 @@ async function admitAll(eng, ws, ledger, { receiptFence = null, shardRouting = n
1945
1950
  }
1946
1951
  const _walkDone = _span(`walk ${shortCid}`, "cwalk", 2, { client: cid });
1947
1952
  const main2 = await mainIntentIds(eng, ws);
1948
- const recent = kgit.intentsAbove(eng, gitdir, head, "", 100);
1953
+ const recent = kgit.intentsAbove(eng, gitdir, head ?? "", "", 100);
1949
1954
  const chain = [];
1950
1955
  for (let i = recent.length - 1; i >= 0; i--) {
1951
1956
  if (main2.oids.has(recent[i].oid)) break;
@@ -2034,7 +2039,7 @@ async function admitAll(eng, ws, ledger, { receiptFence = null, shardRouting = n
2034
2039
  main2.oids.add(res.head);
2035
2040
  main2.head = res.head;
2036
2041
  admitted.push({ oid: oid.slice(0, 10), head: res.head });
2037
- if (cap2) finishSummaryCapture(eng, ws, summaryCtx, cap2, res.head, intentId);
2042
+ if (cap2) finishSummaryCapture(eng, ws, summaryCtx, cap2, res.head ?? "", intentId);
2038
2043
  if (shardRouting && dirId) {
2039
2044
  const placement = placementDirectives(eng).get(dirId);
2040
2045
  if (placement) {
@@ -2043,7 +2048,7 @@ async function admitAll(eng, ws, ledger, { receiptFence = null, shardRouting = n
2043
2048
  p = JSON.parse(dec3.decode(blob)).payload?.payload ?? null;
2044
2049
  } catch {
2045
2050
  }
2046
- const homeKey = p ? p[placement.keyField] : void 0;
2051
+ const homeKey = p ? p[String(placement.keyField)] : void 0;
2047
2052
  if (typeof homeKey === "string" && typeof p?.shard === "string") {
2048
2053
  placements.push({ directive: dirId, homeKey, shard: p.shard, mapVersion: 1 });
2049
2054
  }
@@ -2171,7 +2176,7 @@ async function backupHead(eng, ws, ledger, head) {
2171
2176
  await custodyPush(eng, ws, ledger, { remoteRef: "refs/heads/main", newOid: head });
2172
2177
  return { ok: true, head };
2173
2178
  } catch (e) {
2174
- return { ok: false, error: String(e && e.message || e).slice(0, 200), head };
2179
+ return { ok: false, error: String(e?.message || e).slice(0, 200), head };
2175
2180
  }
2176
2181
  }
2177
2182
  async function backupToCustody(eng, ws, ledger, { consumed = [] } = {}) {
@@ -2227,7 +2232,7 @@ async function rebirthCompact(eng, ws, ledger, { reason = "", supersededAt = 0,
2227
2232
  return false;
2228
2233
  }
2229
2234
  };
2230
- const transformState = (sealedBytes) => sealedBytes;
2235
+ const transformState = (sealedBytes, _ctx) => sealedBytes;
2231
2236
  const carried = [];
2232
2237
  const parkedIntents = [];
2233
2238
  const parkedBlobs = [];
@@ -2322,7 +2327,7 @@ async function rebirthCompact(eng, ws, ledger, { reason = "", supersededAt = 0,
2322
2327
  unmount(eng, incWs);
2323
2328
  } catch {
2324
2329
  }
2325
- return { ok: false, error: String(e && e.message || e).slice(0, 300) };
2330
+ return { ok: false, error: String(e?.message || e).slice(0, 300) };
2326
2331
  }
2327
2332
  }
2328
2333
  async function archiveRefusedMain(eng, ws, ledger, label) {
@@ -2349,7 +2354,7 @@ async function writeRefusedRef(eng, ws, dl) {
2349
2354
  try {
2350
2355
  const prevOid = kgit.resolveRef(eng, gitdir, refForStamp);
2351
2356
  if (prevOid) {
2352
- const prev = JSON.parse(dec3.decode(kgit.readBlob(eng, gitdir, prevOid, "verdict.json")));
2357
+ const prev = JSON.parse(dec3.decode(kgit.readBlob(eng, gitdir, prevOid, "verdict.json") ?? new Uint8Array()));
2353
2358
  if (prev && typeof prev.parkedAt === "string") parkedAt = prev.parkedAt;
2354
2359
  }
2355
2360
  } catch {
@@ -2379,8 +2384,8 @@ async function listRefusedRefs(eng, ws) {
2379
2384
  const out13 = [];
2380
2385
  for (const { ref, oid } of refs) {
2381
2386
  try {
2382
- const vb = kgit.readBlob(eng, gitdir, oid, "verdict.json");
2383
- const ib = kgit.readBlob(eng, gitdir, oid, "intent.json");
2387
+ const vb = kgit.readBlob(eng, gitdir, oid, "verdict.json") ?? new Uint8Array();
2388
+ const ib = kgit.readBlob(eng, gitdir, oid, "intent.json") ?? new Uint8Array();
2384
2389
  const v = JSON.parse(dec3.decode(vb));
2385
2390
  out13.push({ ref, ...v, intentB64: b64Bytes(ib) });
2386
2391
  } catch {
@@ -2394,7 +2399,7 @@ async function refusedSummary(eng, ws) {
2394
2399
  let count2 = 0, latestParkedAt = null;
2395
2400
  for (const { oid } of refs) {
2396
2401
  try {
2397
- const v = JSON.parse(dec3.decode(kgit.readBlob(eng, gitdir, oid, "verdict.json")));
2402
+ const v = JSON.parse(dec3.decode(kgit.readBlob(eng, gitdir, oid, "verdict.json") ?? new Uint8Array()));
2398
2403
  count2++;
2399
2404
  if (v && typeof v.parkedAt === "string" && (!latestParkedAt || v.parkedAt > latestParkedAt)) latestParkedAt = v.parkedAt;
2400
2405
  } catch {
@@ -2532,7 +2537,7 @@ async function deploy(eng, ws, ledger, usda, domainHash, dispositions, opts = {}
2532
2537
  return { head: result.head, installation };
2533
2538
  }
2534
2539
  function snapshot(eng, ws) {
2535
- const wsDir = eng.preopen.dir.contents.get("ws").contents.get(ws);
2540
+ const wsDir = dirOf(eng.preopen.dir.contents.get("ws")).contents.get(ws);
2536
2541
  return serializeTree(wsDir);
2537
2542
  }
2538
2543
  function stats(eng) {
@@ -2562,7 +2567,7 @@ async function ledgerStats(eng, ws, ledger = null) {
2562
2567
  }
2563
2568
  if (!head) return { head: null, commits: 0 };
2564
2569
  const mounted = eng.mounted.get(ws);
2565
- if (mounted?.ledgerStats?.head === head) return mounted.ledgerStats;
2570
+ if (mounted && mounted.ledgerStats?.head === head) return mounted.ledgerStats;
2566
2571
  const commits = kgit.intentsAbove(eng, gitdir, head).length;
2567
2572
  const out13 = { head, commits };
2568
2573
  if (mounted) mounted.ledgerStats = out13;
@@ -2580,7 +2585,7 @@ async function countRemoteCommits(eng, ledger) {
2580
2585
  return { head, commits };
2581
2586
  } finally {
2582
2587
  try {
2583
- eng.preopen.dir.contents.get("ws").contents.delete(scratch);
2588
+ dirOf(eng.preopen.dir.contents.get("ws")).contents.delete(scratch);
2584
2589
  } catch {
2585
2590
  }
2586
2591
  }
@@ -2629,9 +2634,9 @@ function sealAttestationBatches(eng, ws, domain, controllerHash, opts = {}) {
2629
2634
  }
2630
2635
  return outcomes;
2631
2636
  }
2632
- var enc3, dec3, BRANCH, RESULT_PACK_INLINE_MAX, repoArgOf, gitdirOf, unpack, log, repoArgOfGitdir, bytesFromB64, kgit, installPayload, routeTagHexOfHomeKey, SUMMARY_SEP, summaryKey, splitSummaryKey, NOMOS_SHARD_ROWS_READ, groupOf, tallyOf, isExtremumRead, extremumMonotone, CKPT_REF, pushVia, fullRef, applyPackInto, custodyLsRefs, qById, query, check, expand, cryptoSealField, cryptoKeygen, authorKeygen, eraCertSign, delegationCertSign, attestationSign, attestedRead, certSign, cryptoWrapKey, cryptoUnwrapKey, readPosture, count, sum, pendingConflicts, spatialBboxParams, spatialWithin, extremum, nomosActive, refusedRefName, outboxRefName, projectionStats;
2637
+ var enc3, dec3, BRANCH, RESULT_PACK_INLINE_MAX, dirOf, repoArgOf, gitdirOf, unpack, log, repoArgOfGitdir, bytesFromB64, kgit, installPayload, routeTagHexOfHomeKey, SUMMARY_SEP, summaryKey, splitSummaryKey, NOMOS_SHARD_ROWS_READ, groupOf, tallyOf, isExtremumRead, extremumMonotone, CKPT_REF, pushVia, fullRef, applyPackInto, custodyLsRefs, qById, query, check, expand, cryptoSealField, cryptoKeygen, authorKeygen, eraCertSign, delegationCertSign, attestationSign, attestedRead, certSign, cryptoWrapKey, cryptoUnwrapKey, readPosture, count, sum, pendingConflicts, spatialBboxParams, spatialWithin, extremum, nomosActive, refusedRefName, outboxRefName, projectionStats;
2633
2638
  var init_engine = __esm({
2634
- "vendor/engine/engine.mjs"() {
2639
+ "vendor/engine/engine.ts"() {
2635
2640
  "use strict";
2636
2641
  init_git_fs();
2637
2642
  init_tree();
@@ -2640,6 +2645,7 @@ var init_engine = __esm({
2640
2645
  dec3 = new TextDecoder();
2641
2646
  BRANCH = "main";
2642
2647
  RESULT_PACK_INLINE_MAX = 256 * 1024;
2648
+ dirOf = (n) => n;
2643
2649
  repoArgOf = (ws) => `/work/ws/${ws}`;
2644
2650
  gitdirOf = (ws) => `/work/ws/${ws}/nomos.git`;
2645
2651
  unpack = (p) => {
@@ -2724,7 +2730,7 @@ var init_engine = __esm({
2724
2730
  certSign = (eng, { child, founder, verified, parentKey, parentId, epoch, secret }) => JSON.parse(call(eng.ex, "query", { queryBytes: b64Json({ op: "certSign", child, founder, verified, parentKey, parentId, epoch, secret }) }, eng.STDERR)).cert;
2725
2731
  cryptoWrapKey = (eng, { recipientPub, scopeKey }) => JSON.parse(call(eng.ex, "query", { queryBytes: b64Json({ op: "cryptoWrapKey", recipientPub, scopeKey }) }, eng.STDERR));
2726
2732
  cryptoUnwrapKey = (eng, { secret, hpkeEpk, ct }) => JSON.parse(call(eng.ex, "query", { queryBytes: b64Json({ op: "cryptoUnwrapKey", secret, hpkeEpk, ct }) }, eng.STDERR)).scopeKey;
2727
- readPosture = (eng, ws, principal = "") => JSON.parse(call(eng.ex, "query", { repoArg: repoArgOf(ws), workspace: ws, queryBytes: b64Json({ op: "readPosture" }), principal, branch: BRANCH }, eng.STDERR));
2733
+ readPosture = (eng, ws, principal = "", authToken = "", nowUnix = 0) => JSON.parse(call(eng.ex, "query", { repoArg: repoArgOf(ws), workspace: ws, queryBytes: b64Json({ op: "readPosture", authToken, nowUnix }), principal, branch: BRANCH }, eng.STDERR));
2728
2734
  count = (eng, ws, countId, groupKey, principal = "") => JSON.parse(call(eng.ex, "query", { repoArg: repoArgOf(ws), workspace: ws, queryBytes: b64Json({ op: "count", countId, groupKey }), principal, branch: BRANCH }, eng.STDERR));
2729
2735
  sum = (eng, ws, sumId, groupKey, principal = "") => JSON.parse(call(eng.ex, "query", { repoArg: repoArgOf(ws), workspace: ws, queryBytes: b64Json({ op: "sum", sumId, groupKey }), principal, branch: BRANCH }, eng.STDERR));
2730
2736
  pendingConflicts = (eng, ws, principal = "") => JSON.parse(call(eng.ex, "query", { repoArg: repoArgOf(ws), workspace: ws, queryBytes: b64Json({ op: "pendingConflicts" }), principal, branch: BRANCH }, eng.STDERR));
@@ -5373,9 +5379,10 @@ async function deploy2(ws, opts) {
5373
5379
  }
5374
5380
  deployedHash = targetHash2;
5375
5381
  } else {
5382
+ const presented = opts.principal ?? await sessionToken().catch(() => void 0) ?? activePrincipal();
5376
5383
  const r = await fetch(`${cloud}/v2/workspaces/${ws}/domains`, {
5377
5384
  method: "POST",
5378
- headers: { "content-type": "application/json" },
5385
+ headers: { "content-type": "application/json", ...presented !== void 0 ? principalHeaders(presented) : {} },
5379
5386
  body: readFileSync5(file, "utf8")
5380
5387
  });
5381
5388
  const d = await r.json().catch(() => void 0);
@@ -8548,23 +8555,21 @@ async function gitRemote(ws, name, opts) {
8548
8555
  }
8549
8556
  }
8550
8557
  const token = await sessionToken().catch(() => void 0);
8551
- if (token === void 0) {
8552
- const principal = loadCreds().principal;
8553
- if (principal === void 0) {
8554
- err6(
8555
- `remote '${name}' \u2192 ${url} is wired, but a BIRTH push needs a principal:
8558
+ const principal = currentPrincipal();
8559
+ if (principal === void 0) {
8560
+ err6(
8561
+ `remote '${name}' \u2192 ${url} is wired, but a BIRTH push needs a principal:
8556
8562
  githolon login --agent (then just push)
8557
8563
  \u2014 or re-run after githolon ws create/login so a principal is on file`
8558
- );
8559
- return 1;
8560
- }
8561
- if (git(["config", `http.${url}.extraHeader`, `x-nomos-principal: ${principal}`]) !== 0) {
8562
- err6("git config failed setting the principal header");
8563
- return 1;
8564
- }
8564
+ );
8565
+ return 1;
8566
+ }
8567
+ if (git(["config", `http.${url}.extraHeader`, `x-nomos-principal: ${principal}`]) !== 0) {
8568
+ err6("git config failed setting the principal header");
8569
+ return 1;
8565
8570
  }
8566
8571
  out6(`\u2713 remote '${name}' \u2192 ${url}`);
8567
- out6(` workspace secret on file; ${token !== void 0 ? "births ride your session (verified)" : "births ride x-nomos-principal (bare uid)"}`);
8572
+ out6(` workspace secret on file; ${token !== void 0 ? "births ride your session token (verified) + x-nomos-principal claim" : "births ride x-nomos-principal (bare uid)"}`);
8568
8573
  out6(` birth/deploy by push: git push ${name} main`);
8569
8574
  return 0;
8570
8575
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "githolon",
3
- "version": "0.93.0",
3
+ "version": "0.94.0",
4
4
  "type": "module",
5
5
  "description": "githolon — the Nomos developer CLI: Rails-style generators for @githolon/dsl domains + the package compiler. Kernel-independent.",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -29,8 +29,8 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@bjorn3/browser_wasi_shim": "0.4.2",
32
- "@githolon/client": "^0.93.0",
33
- "@githolon/dsl": "^0.93.0",
32
+ "@githolon/client": "^0.94.0",
33
+ "@githolon/dsl": "^0.94.0",
34
34
  "isomorphic-git": "^1.38.4"
35
35
  },
36
36
  "devDependencies": {