githolon 0.105.13 → 0.105.15

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/full-cli.mjs CHANGED
@@ -1055,9 +1055,9 @@ function activityKey(kind, slot) {
1055
1055
  return `activity.${kind}.${slot}`;
1056
1056
  }
1057
1057
  function templateVars(template) {
1058
- const out13 = [];
1059
- for (const m of template.matchAll(/\{([a-zA-Z0-9_]+)\}/g)) out13.push(m[1]);
1060
- return out13;
1058
+ const out14 = [];
1059
+ for (const m of template.matchAll(/\{([a-zA-Z0-9_]+)\}/g)) out14.push(m[1]);
1060
+ return out14;
1061
1061
  }
1062
1062
  function payloadFieldNames(schema) {
1063
1063
  const def = schema?._def ?? schema?.def;
@@ -2987,15 +2987,15 @@ var init_git_fs = __esm({
2987
2987
  });
2988
2988
 
2989
2989
  // ../cloud/web-client/src/_adapter/tree.ts
2990
- function flatten(dir, prefix, out13) {
2990
+ function flatten(dir, prefix, out14) {
2991
2991
  const children = [...(dir.contents ?? /* @__PURE__ */ new Map()).entries()].sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);
2992
2992
  for (const [name, inode] of children) {
2993
2993
  const path2 = prefix ? prefix + "/" + name : name;
2994
2994
  if (inode.contents instanceof Map) {
2995
- out13.push({ path: path2, dir: true });
2996
- flatten(inode, path2, out13);
2995
+ out14.push({ path: path2, dir: true });
2996
+ flatten(inode, path2, out14);
2997
2997
  } else {
2998
- out13.push({ path: path2, dir: false, bytes: inode.data ?? new Uint8Array(0) });
2998
+ out14.push({ path: path2, dir: false, bytes: inode.data ?? new Uint8Array(0) });
2999
2999
  }
3000
3000
  }
3001
3001
  }
@@ -3018,13 +3018,13 @@ function serializeTree(workTree) {
3018
3018
  }
3019
3019
  let total = 0;
3020
3020
  for (const c of chunks) total += c.length;
3021
- const out13 = new Uint8Array(total);
3021
+ const out14 = new Uint8Array(total);
3022
3022
  let off = 0;
3023
3023
  for (const c of chunks) {
3024
- out13.set(c, off);
3024
+ out14.set(c, off);
3025
3025
  off += c.length;
3026
3026
  }
3027
- return out13;
3027
+ return out14;
3028
3028
  }
3029
3029
  function deserializeTree(bytes, { File: File4, Directory: Directory4 }) {
3030
3030
  const u8 = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
@@ -4280,13 +4280,13 @@ var init_kernel_provider_wasm = __esm({
4280
4280
  function concatBytes(chunks) {
4281
4281
  let n = 0;
4282
4282
  for (const c of chunks) n += c.length;
4283
- const out13 = new Uint8Array(n);
4283
+ const out14 = new Uint8Array(n);
4284
4284
  let o = 0;
4285
4285
  for (const c of chunks) {
4286
- out13.set(c, o);
4286
+ out14.set(c, o);
4287
4287
  o += c.length;
4288
4288
  }
4289
- return out13;
4289
+ return out14;
4290
4290
  }
4291
4291
  function pkt(payload) {
4292
4292
  const body = typeof payload === "string" ? enc3.encode(payload) : payload;
@@ -4490,7 +4490,7 @@ function prepareManagedPromotion(report, candidateHash, domain, opts = {}) {
4490
4490
  domainHash: candidateHash,
4491
4491
  ...opts.replaces ? { replaces: opts.replaces } : {},
4492
4492
  retireReplaced: opts.retireReplaced ?? false,
4493
- ...opts.dispositions ? { dispositions: opts.dispositions } : {},
4493
+ ...report.dispositions ? { dispositions: report.dispositions } : {},
4494
4494
  preflight
4495
4495
  }
4496
4496
  };
@@ -4506,7 +4506,6 @@ function prepareManagedRestoration(report, currentHash, priorHash, domain, opts
4506
4506
  }
4507
4507
  const acceptanceReason = opts.acceptanceReason?.trim();
4508
4508
  const prepared = prepareManagedPromotion(report, priorHash, domain, {
4509
- dispositions: report.dispositions,
4510
4509
  ...acceptanceReason ? { acceptanceReason } : {}
4511
4510
  });
4512
4511
  if (!prepared.ok) {
@@ -4593,7 +4592,7 @@ function compatible(client, workspace) {
4593
4592
  return { ok: missing.length === 0 && incompatible.length === 0, missing, incompatible };
4594
4593
  }
4595
4594
  function memberVerdicts(client, workspace) {
4596
- const out13 = {};
4595
+ const out14 = {};
4597
4596
  const cDirs = client && client.directives || {};
4598
4597
  const wDirs = workspace && workspace.directives || {};
4599
4598
  const cAggs = client && client.aggregates || {};
@@ -4601,7 +4600,7 @@ function memberVerdicts(client, workspace) {
4601
4600
  for (const [did, cShape] of Object.entries(cDirs)) {
4602
4601
  const wShape = wDirs[did];
4603
4602
  if (!wShape) {
4604
- out13[did] = { ok: false, reason: `directive '${did}' is not installed on the workspace` };
4603
+ out14[did] = { ok: false, reason: `directive '${did}' is not installed on the workspace` };
4605
4604
  continue;
4606
4605
  }
4607
4606
  const cf = cShape.fields || {};
@@ -4616,13 +4615,13 @@ function memberVerdicts(client, workspace) {
4616
4615
  const w = wf[f];
4617
4616
  if (w && w.kind !== c.kind) reasons.push(`field '${f}' kind ${c.kind} \u2260 workspace ${w.kind}`);
4618
4617
  }
4619
- out13[did] = reasons.length ? { ok: false, reason: reasons.join("; ") } : { ok: true };
4618
+ out14[did] = reasons.length ? { ok: false, reason: reasons.join("; ") } : { ok: true };
4620
4619
  }
4621
4620
  for (const [sid, cAgg] of Object.entries(cAggs)) {
4622
4621
  const label = cAgg.label || sid;
4623
4622
  const wAgg = wAggs[sid];
4624
4623
  if (!wAgg) {
4625
- out13[label] = { ok: false, reason: `aggregate '${label}' is not served by the workspace` };
4624
+ out14[label] = { ok: false, reason: `aggregate '${label}' is not served by the workspace` };
4626
4625
  continue;
4627
4626
  }
4628
4627
  const cFields = cAgg.fields || {};
@@ -4633,9 +4632,9 @@ function memberVerdicts(client, workspace) {
4633
4632
  if (!w) reasons.push(`field '${label}.${c.label || fsid}' is not served`);
4634
4633
  else if (w.kind !== c.kind) reasons.push(`field '${label}.${c.label || fsid}' read kind ${c.kind} \u2260 workspace ${w.kind}`);
4635
4634
  }
4636
- out13[label] = reasons.length ? { ok: false, reason: reasons.join("; ") } : { ok: true };
4635
+ out14[label] = reasons.length ? { ok: false, reason: reasons.join("; ") } : { ok: true };
4637
4636
  }
4638
- return out13;
4637
+ return out14;
4639
4638
  }
4640
4639
  function interfaceDomains(byDomain) {
4641
4640
  const map = byDomain && typeof byDomain === "object" ? byDomain : {};
@@ -4645,17 +4644,17 @@ function interfaceDomains(byDomain) {
4645
4644
  );
4646
4645
  }
4647
4646
  function mergeDomainInterfaces(byDomain, onlyDomains) {
4648
- const out13 = { directives: {}, aggregates: {} };
4647
+ const out14 = { directives: {}, aggregates: {} };
4649
4648
  const map = byDomain && typeof byDomain === "object" ? byDomain : {};
4650
4649
  const entries = map.directives ? [[String(map.domain ?? "?"), map]] : Object.entries(map);
4651
4650
  for (const [domain, value] of entries) {
4652
4651
  if (onlyDomains !== void 0 && !onlyDomains.has(domain)) continue;
4653
4652
  if (!value || typeof value !== "object") continue;
4654
4653
  const di = value;
4655
- Object.assign(out13.directives, di.directives || {});
4656
- Object.assign(out13.aggregates, di.aggregates || {});
4654
+ Object.assign(out14.directives, di.directives || {});
4655
+ Object.assign(out14.aggregates, di.aggregates || {});
4657
4656
  }
4658
- return out13;
4657
+ return out14;
4659
4658
  }
4660
4659
  var init_shape_compat = __esm({
4661
4660
  "../cloud/web-client/src/shape_compat.ts"() {
@@ -5016,8 +5015,8 @@ function createGovernanceOffers(ctx) {
5016
5015
  },
5017
5016
  /**
5018
5017
  * PARENT-AUTHORITY POSTURE (read-only diagnostic): is `identity:<principal>#signer@key:<keyHash>`
5019
- * a LIVE tuple on `parent`'s chain? Reads the parent's declared `relationTuplesByObject` query over
5020
- * the open gateway — one O(1) relation read, no authoring. Returns
5018
+ * a LIVE tuple on `parent`'s chain? Reads the tuple's deterministic aggregate address over the
5019
+ * generic record lane — one O(1) read, no authoring and no ambiguous query alias in composed law. Returns
5021
5020
  * `{ parent, principal, keyHash, object, relation, enrolled, revoked, checkedAt }`.
5022
5021
  * `revoked: true` means the subject's leaf was flipped `status:revoked` (remove-wins — a lawful
5023
5022
  * re-enroll of the SAME key is refused; mint + enroll a new device key instead).
@@ -5031,12 +5030,13 @@ function createGovernanceOffers(ctx) {
5031
5030
  keyHash = await sha256hexBytes2(bytesUnb642(publicKey));
5032
5031
  }
5033
5032
  const object = signerObjectOf(p);
5033
+ const aggregateId = `reltuple-${object}-signer`;
5034
5034
  let rows;
5035
5035
  if (parent === workspace && !remote) {
5036
- rows = JSON.parse(call("query", { queryBytes: qBytes2({ kind: "query", queryId: "relationTuplesByObject", paramsJson: JSON.stringify({ object }) }) })) || [];
5036
+ rows = JSON.parse(call("query", { queryBytes: qBytes2({ op: "byId", aggregateId }) })) || [];
5037
5037
  } else {
5038
5038
  const headers = authToken ? { Authorization: `Bearer ${authToken}`, "x-nomos-auth": authToken } : authHeaders;
5039
- const r = await _fetch(`${base}/v2/workspaces/${parent}/relationTuplesByObject?object=${encodeURIComponent(object)}`, { headers });
5039
+ const r = await _fetch(`${base}/v2/workspaces/${parent}/aggregates/${encodeURIComponent(aggregateId)}`, { headers });
5040
5040
  const text = await r.text();
5041
5041
  let body;
5042
5042
  try {
@@ -5044,7 +5044,7 @@ function createGovernanceOffers(ctx) {
5044
5044
  } catch {
5045
5045
  body = text;
5046
5046
  }
5047
- if (!r.ok) throw new Error(`parentSignerEnrollment: reading ${parent}'s relationTuplesByObject failed (${r.status}): ${typeof body === "string" ? body.slice(0, 200) : JSON.stringify(body).slice(0, 200)}`);
5047
+ if (!r.ok) throw new Error(`parentSignerEnrollment: reading ${parent}'s signer tuple failed (${r.status}): ${typeof body === "string" ? body.slice(0, 200) : JSON.stringify(body).slice(0, 200)}`);
5048
5048
  rows = Array.isArray(body) ? body : body && Array.isArray(body.rows) ? body.rows : [];
5049
5049
  }
5050
5050
  let enrolled = false, revoked = false, verifiedVia;
@@ -5090,7 +5090,14 @@ function createGovernanceOffers(ctx) {
5090
5090
  rows = JSON.parse(call("query", { queryBytes: qBytes2({ kind: "query", queryId: "relationTuplesByObject", paramsJson: JSON.stringify({ object }) }) })) || [];
5091
5091
  } else {
5092
5092
  const headers = authToken ? { Authorization: `Bearer ${authToken}`, "x-nomos-auth": authToken } : authHeaders;
5093
- const r = await _fetch(`${base}/v2/workspaces/${ws}/relationTuplesByObject?object=${encodeURIComponent(object)}`, { headers });
5093
+ const route = await resolveFrameworkRoute({
5094
+ parent: ws,
5095
+ operationId: "relationTuplesByObject",
5096
+ method: "get",
5097
+ token: authToken,
5098
+ principal: subj
5099
+ });
5100
+ const r = await _fetch(`${base}/v2/workspaces/${ws}${route.path}?object=${encodeURIComponent(object)}`, { headers });
5094
5101
  const text = await r.text();
5095
5102
  let body;
5096
5103
  try {
@@ -5687,13 +5694,13 @@ async function actorForShareQuote(quote) {
5687
5694
  function osEntropyBuffer(n) {
5688
5695
  const bytes = new Uint8Array(n * 8);
5689
5696
  crypto.getRandomValues(bytes);
5690
- const out13 = new Array(n), T = 2 ** 53;
5697
+ const out14 = new Array(n), T = 2 ** 53;
5691
5698
  for (let i = 0; i < n; i++) {
5692
5699
  let z6 = 0n;
5693
5700
  for (let b = 7; b >= 0; b--) z6 = z6 << 8n | BigInt(bytes[i * 8 + b]);
5694
- out13[i] = Number(z6 >> 11n) / T;
5701
+ out14[i] = Number(z6 >> 11n) / T;
5695
5702
  }
5696
- return out13;
5703
+ return out14;
5697
5704
  }
5698
5705
  function stringifyBig(o) {
5699
5706
  return JSON.stringify(o, (_k, v) => typeof v === "bigint" ? `@@B:${v}@@` : v).replace(/"@@B:(\d+)@@"/g, "$1");
@@ -5708,14 +5715,14 @@ async function routeTagHexOfHomeKey(homeKey) {
5708
5715
  return (await sha256hex(`nomos-route:${homeKey}`)).slice(0, 12);
5709
5716
  }
5710
5717
  function installedLawOfRows(rows) {
5711
- const out13 = [];
5718
+ const out14 = [];
5712
5719
  for (const r of rows || []) {
5713
5720
  const d = r && r.data;
5714
5721
  if (!d || d["status.phase"] !== "Active") continue;
5715
5722
  const h = d["spec.domainHash"];
5716
- if (typeof h === "string" && h && !out13.includes(h)) out13.push(h);
5723
+ if (typeof h === "string" && h && !out14.includes(h)) out14.push(h);
5717
5724
  }
5718
- return out13;
5725
+ return out14;
5719
5726
  }
5720
5727
  function lawStatusOf(installed, clientHash) {
5721
5728
  const known = Array.isArray(installed);
@@ -5740,14 +5747,14 @@ function birthOutcomeFailure(birthOutcomes) {
5740
5747
  const first = bad[0];
5741
5748
  const list = bad.map((o) => `${o.workspace || "?"} [${o.status}${o.code ? `: ${o.code}` : ""}]${o.reason ? ` \u2014 ${o.reason}` : ""}`).join("; ");
5742
5749
  const lawUnavailable = bad.some((o) => o.code === "BirthLawPackageUnavailable");
5743
- const err13 = new Error(
5750
+ const err14 = new Error(
5744
5751
  `birth incomplete: ${bad.length} child workspace(s) did NOT come up \u2014 ${list}. The parent offer admitted, but the child was not fully born, so opening it would poll head:null until timeout. ` + (lawUnavailable ? `The child's law package is not resolvable from the parent's custody \u2014 deploy it to the parent (POST /v2/workspaces/<parent>/domains) BEFORE birthing.` : `See the outcome's reason/code for the cause.`) + ` [birth-failed]`
5745
5752
  );
5746
- err13.code = first.code || "BirthFailed";
5747
- err13.status = first.status;
5748
- err13.failedBirths = bad;
5749
- err13.birthOutcomes = birthOutcomes;
5750
- return err13;
5753
+ err14.code = first.code || "BirthFailed";
5754
+ err14.status = first.status;
5755
+ err14.failedBirths = bad;
5756
+ err14.birthOutcomes = birthOutcomes;
5757
+ return err14;
5751
5758
  }
5752
5759
  async function checkCompat(holon, nomosCompat) {
5753
5760
  if (!holon || !nomosCompat || typeof nomosCompat.lawHash !== "string") return null;
@@ -6334,15 +6341,15 @@ ${String(commit).toLowerCase()}`;
6334
6341
  typeof principal === "string" && principal ? principal : typeof tokenSubject === "string" ? tokenSubject : ""
6335
6342
  );
6336
6343
  const readAuthFields = (keys, p) => {
6337
- const out13 = { nowUnix: Math.floor(Date.now() / 1e3) };
6344
+ const out14 = { nowUnix: Math.floor(Date.now() / 1e3) };
6338
6345
  const pr = typeof p === "string" && p ? p : connectionPrincipal;
6339
- if (pr) out13.principal = pr;
6346
+ if (pr) out14.principal = pr;
6340
6347
  if (activeAuthToken) {
6341
- out13.authToken = activeAuthToken;
6348
+ out14.authToken = activeAuthToken;
6342
6349
  }
6343
- if (deviceSecret) out13.authorSecret = deviceSecret;
6344
- if (Array.isArray(keys) && keys.length) out13.keys = keys;
6345
- return out13;
6350
+ if (deviceSecret) out14.authorSecret = deviceSecret;
6351
+ if (Array.isArray(keys) && keys.length) out14.keys = keys;
6352
+ return out14;
6346
6353
  };
6347
6354
  let clientLawHash;
6348
6355
  let warnedDrift = false;
@@ -6719,9 +6726,9 @@ ${String(commit).toLowerCase()}`;
6719
6726
  } catch {
6720
6727
  }
6721
6728
  const missingObject = (text.match(/\b[0-9a-f]{40}\b/) || [null])[0];
6722
- const err13 = new Error(text);
6723
- err13.code = code;
6724
- err13.errorInfo = {
6729
+ const err14 = new Error(text);
6730
+ err14.code = code;
6731
+ err14.errorInfo = {
6725
6732
  code,
6726
6733
  message: text,
6727
6734
  component: "nomos.custody",
@@ -6739,7 +6746,7 @@ ${String(commit).toLowerCase()}`;
6739
6746
  "nomos.custody.recommended_action": source === "localSnapshot" ? "quarantineLocalSnapshotAndReclone" : "refetchFullHistoryAndRetry"
6740
6747
  }
6741
6748
  };
6742
- return err13;
6749
+ return err14;
6743
6750
  };
6744
6751
  if (ckptBlobStr || ckptFrontierStr || ckptStagedFrontierFile || ckptCursor) {
6745
6752
  const _ckptSpan = span("receive", restoreFrom ? "boot: restore folded state (snapshot)" : "boot: restore checkpoint", "boot");
@@ -7311,7 +7318,7 @@ ${String(commit).toLowerCase()}`;
7311
7318
  domain,
7312
7319
  candidateHash,
7313
7320
  atHash,
7314
- ...opts.dispositions ? { dispositions: opts.dispositions } : {}
7321
+ ackBy: connectionPrincipal
7315
7322
  })
7316
7323
  }));
7317
7324
  });
@@ -7324,8 +7331,7 @@ ${String(commit).toLowerCase()}`;
7324
7331
  }
7325
7332
  const prepared = prepareManagedPromotion(report, candidateHash, domain, {
7326
7333
  ...currentHash && currentHash !== candidateHash ? { replaces: currentHash } : {},
7327
- ...opts.because !== void 0 ? { acceptanceReason: opts.because } : {},
7328
- ...opts.dispositions ? { dispositions: opts.dispositions } : {}
7334
+ ...opts.because !== void 0 ? { acceptanceReason: opts.because } : {}
7329
7335
  });
7330
7336
  if (!prepared.ok) return prepared;
7331
7337
  try {
@@ -8140,7 +8146,7 @@ ${String(commit).toLowerCase()}`;
8140
8146
  if (!deviceSecret || !connectionPrincipal) {
8141
8147
  throw new Error("owned device recovery needs a signed-in session with its persisted device credential");
8142
8148
  }
8143
- const out13 = JSON.parse(call("query", {
8149
+ const out14 = JSON.parse(call("query", {
8144
8150
  queryBytes: qBytes({
8145
8151
  op: "cryptoOwnedDeviceRequest",
8146
8152
  authorSecret: deviceSecret,
@@ -8149,7 +8155,7 @@ ${String(commit).toLowerCase()}`;
8149
8155
  scope
8150
8156
  })
8151
8157
  }));
8152
- return String(out13.request || "");
8158
+ return String(out14.request || "");
8153
8159
  };
8154
8160
  const ownedRecoveryPolicyRaw = (owner) => ownedTupleData(ownedRecoveryPolicyId(owner));
8155
8161
  const ownedRecoveryOrdersRaw = async (recoveryPrincipal) => (await ownedQueryRows("nomosOwnedRecoveryOrdersByRecoveryPrincipal", { recoveryPrincipal })).map((row) => ({ id: String(row.id || ""), ...ownedRowData(row) }));
@@ -9491,11 +9497,11 @@ ${String(commit).toLowerCase()}`;
9491
9497
  await sleep(pollMs);
9492
9498
  }
9493
9499
  if (!sawDelegation) {
9494
- const err13 = new Error(
9500
+ const err14 = new Error(
9495
9501
  `receiving-group setup: parent '${parent}' still holds NO SignerDelegation for '${owner}' after ${pollTimeoutMs}ms. enrollFirstDevice seated the device SIGNER, but the home cert chain's links[1] (the platform-signed delegation) never surfaced \u2014 the birth would come up UNWARRANTED/headless (birth-cert-not-seeded). The enroll must record the keyless delegation (enrollFirstDevice.delegationCert) BEFORE birth. [ParentSignerDelegationMissing]`
9496
9502
  );
9497
- err13.code = "ParentSignerDelegationMissing";
9498
- throw err13;
9503
+ err14.code = "ParentSignerDelegationMissing";
9504
+ throw err14;
9499
9505
  }
9500
9506
  } finally {
9501
9507
  delegationSpan.end();
@@ -9728,10 +9734,10 @@ ${String(commit).toLowerCase()}`;
9728
9734
  const off = installedInterfaceInner();
9729
9735
  if (off === null && _lastInterfaceReadError) {
9730
9736
  const e = _lastInterfaceReadError;
9731
- const err13 = new Error(`projection read failed on workspace '${workspace}': ${e.message}`);
9732
- err13.code = "nomos.projection.read_failed";
9733
- err13.errorInfo = { code: "nomos.projection.read_failed", message: e.message, component: "nomos.projection", workspace, attributes: { "nomos.projection.workspace": workspace } };
9734
- throw err13;
9737
+ const err14 = new Error(`projection read failed on workspace '${workspace}': ${e.message}`);
9738
+ err14.code = "nomos.projection.read_failed";
9739
+ err14.errorInfo = { code: "nomos.projection.read_failed", message: e.message, component: "nomos.projection", workspace, attributes: { "nomos.projection.workspace": workspace } };
9740
+ throw err14;
9735
9741
  }
9736
9742
  return off;
9737
9743
  }),
@@ -11004,12 +11010,12 @@ function routedHolon(coordinator, { cloud, workspace, clientId, authToken, fetch
11004
11010
  }
11005
11011
  async function frontierMap() {
11006
11012
  const rows = await coordinator.query("aggregatesByType", { __type: "NomosSummaryFrontier" });
11007
- const out13 = {};
11013
+ const out14 = {};
11008
11014
  for (const r of rows || []) {
11009
11015
  const d = r.data || {};
11010
- if (typeof d.shard === "string" && typeof d.frontier === "string") out13[d.shard] = d.frontier;
11016
+ if (typeof d.shard === "string" && typeof d.frontier === "string") out14[d.shard] = d.frontier;
11011
11017
  }
11012
- return out13;
11018
+ return out14;
11013
11019
  }
11014
11020
  async function scopedValue(kind, readId, groupKey, opts = {}) {
11015
11021
  if (kind === "min" || kind === "max") {
@@ -11709,15 +11715,15 @@ var init_git_fs2 = __esm({
11709
11715
  });
11710
11716
 
11711
11717
  // vendor/engine/tree.ts
11712
- function flatten2(dir, prefix, out13) {
11718
+ function flatten2(dir, prefix, out14) {
11713
11719
  const children = [...(dir.contents ?? /* @__PURE__ */ new Map()).entries()].sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);
11714
11720
  for (const [name, inode] of children) {
11715
11721
  const path2 = prefix ? prefix + "/" + name : name;
11716
11722
  if (inode.contents instanceof Map) {
11717
- out13.push({ path: path2, dir: true });
11718
- flatten2(inode, path2, out13);
11723
+ out14.push({ path: path2, dir: true });
11724
+ flatten2(inode, path2, out14);
11719
11725
  } else {
11720
- out13.push({ path: path2, dir: false, bytes: inode.data ?? new Uint8Array(0) });
11726
+ out14.push({ path: path2, dir: false, bytes: inode.data ?? new Uint8Array(0) });
11721
11727
  }
11722
11728
  }
11723
11729
  }
@@ -11740,13 +11746,13 @@ function serializeTree2(workTree) {
11740
11746
  }
11741
11747
  let total = 0;
11742
11748
  for (const c of chunks) total += c.length;
11743
- const out13 = new Uint8Array(total);
11749
+ const out14 = new Uint8Array(total);
11744
11750
  let off = 0;
11745
11751
  for (const c of chunks) {
11746
- out13.set(c, off);
11752
+ out14.set(c, off);
11747
11753
  off += c.length;
11748
11754
  }
11749
- return out13;
11755
+ return out14;
11750
11756
  }
11751
11757
  var enc5, dec5;
11752
11758
  var init_tree2 = __esm({
@@ -11761,13 +11767,13 @@ var init_tree2 = __esm({
11761
11767
  function concatBytes2(chunks) {
11762
11768
  let n = 0;
11763
11769
  for (const c of chunks) n += c.length;
11764
- const out13 = new Uint8Array(n);
11770
+ const out14 = new Uint8Array(n);
11765
11771
  let o = 0;
11766
11772
  for (const c of chunks) {
11767
- out13.set(c, o);
11773
+ out14.set(c, o);
11768
11774
  o += c.length;
11769
11775
  }
11770
- return out13;
11776
+ return out14;
11771
11777
  }
11772
11778
  function pkt2(payload) {
11773
11779
  const body = typeof payload === "string" ? enc6.encode(payload) : payload;
@@ -12011,7 +12017,7 @@ function prepareManagedPromotion2(report, candidateHash, domain, opts = {}) {
12011
12017
  domainHash: candidateHash,
12012
12018
  ...opts.replaces ? { replaces: opts.replaces } : {},
12013
12019
  retireReplaced: opts.retireReplaced ?? false,
12014
- ...opts.dispositions ? { dispositions: opts.dispositions } : {},
12020
+ ...report.dispositions ? { dispositions: report.dispositions } : {},
12015
12021
  preflight
12016
12022
  }
12017
12023
  };
@@ -12027,7 +12033,6 @@ function prepareManagedRestoration2(report, currentHash, priorHash, domain, opts
12027
12033
  }
12028
12034
  const acceptanceReason = opts.acceptanceReason?.trim();
12029
12035
  const prepared = prepareManagedPromotion2(report, priorHash, domain, {
12030
- dispositions: report.dispositions,
12031
12036
  ...acceptanceReason ? { acceptanceReason } : {}
12032
12037
  });
12033
12038
  if (!prepared.ok) {
@@ -12136,6 +12141,8 @@ var init_kernel_pb2 = __esm({
12136
12141
  // vendor/engine/engine.ts
12137
12142
  var engine_exports = {};
12138
12143
  __export(engine_exports, {
12144
+ MAX_INLINE_INTENT_OFFER_BYTES: () => MAX_INLINE_INTENT_OFFER_BYTES,
12145
+ MAX_STAGED_INTENT_OFFER_BYTES: () => MAX_STAGED_INTENT_OFFER_BYTES,
12139
12146
  NOMOS_SHARD_ROWS_READ: () => NOMOS_SHARD_ROWS_READ,
12140
12147
  admitAll: () => admitAll,
12141
12148
  admitIntentOffers: () => admitIntentOffers,
@@ -12198,6 +12205,7 @@ __export(engine_exports, {
12198
12205
  ingestPackAsCustody: () => ingestPackAsCustody,
12199
12206
  installedLaw: () => installedLaw,
12200
12207
  intentOfferResidencies: () => intentOfferResidencies,
12208
+ intentOfferSizeRefusal: () => intentOfferSizeRefusal,
12201
12209
  isDirty: () => isDirty,
12202
12210
  isWarranted: () => isWarranted,
12203
12211
  kernelStamp: () => kernelStamp,
@@ -12285,13 +12293,13 @@ async function sha256hex2(t2) {
12285
12293
  function osEntropyBuffer2(n) {
12286
12294
  const bytes = new Uint8Array(n * 8);
12287
12295
  for (let o = 0; o < bytes.length; o += 65536) crypto.getRandomValues(bytes.subarray(o, Math.min(o + 65536, bytes.length)));
12288
- const out13 = new Array(n), T = 2 ** 53;
12296
+ const out14 = new Array(n), T = 2 ** 53;
12289
12297
  for (let i = 0; i < n; i++) {
12290
12298
  let z6 = 0n;
12291
12299
  for (let b = 7; b >= 0; b--) z6 = z6 << 8n | BigInt(bytes[i * 8 + b]);
12292
- out13[i] = Number(z6 >> 11n) / T;
12300
+ out14[i] = Number(z6 >> 11n) / T;
12293
12301
  }
12294
- return out13;
12302
+ return out14;
12295
12303
  }
12296
12304
  function callProto(ex, operation, STDERR) {
12297
12305
  const requestId = `adapter-${++protoRequestSequence2}`;
@@ -12985,15 +12993,15 @@ function contribution(read, cur) {
12985
12993
  return { group, value: typeof raw === "number" ? raw : 0 };
12986
12994
  }
12987
12995
  function contributionDiff(read, before, after) {
12988
- const out13 = [];
12996
+ const out14 = [];
12989
12997
  if (before && after && before.group === after.group) {
12990
12998
  const d = after.value - before.value;
12991
- if (d !== 0) out13.push({ readId: read.id, group: after.group, delta: d });
12992
- return out13;
12999
+ if (d !== 0) out14.push({ readId: read.id, group: after.group, delta: d });
13000
+ return out14;
12993
13001
  }
12994
- if (before) out13.push({ readId: read.id, group: before.group, delta: -before.value });
12995
- if (after) out13.push({ readId: read.id, group: after.group, delta: after.value });
12996
- return out13.filter((d) => d.delta !== 0);
13002
+ if (before) out14.push({ readId: read.id, group: before.group, delta: -before.value });
13003
+ if (after) out14.push({ readId: read.id, group: after.group, delta: after.value });
13004
+ return out14.filter((d) => d.delta !== 0);
12997
13005
  }
12998
13006
  function countTenantRows(eng, ws) {
12999
13007
  let total = 0;
@@ -13006,16 +13014,16 @@ async function countTenantRowsByHome(eng, ws, homeKeys) {
13006
13014
  const keySet = new Set(homeKeys);
13007
13015
  const tagOf = /* @__PURE__ */ new Map();
13008
13016
  for (const hk of homeKeys) tagOf.set(await routeTagHexOfHomeKey2(hk), hk);
13009
- const out13 = /* @__PURE__ */ new Map();
13010
- for (const hk of homeKeys) out13.set(hk, 0);
13017
+ const out14 = /* @__PURE__ */ new Map();
13018
+ for (const hk of homeKeys) out14.set(hk, 0);
13011
13019
  for (const type of tenantTypes(eng)) {
13012
13020
  for (const r of query2(eng, ws, "aggregatesByType", JSON.stringify({ __type: type }))) {
13013
13021
  const id = String(r.id || "");
13014
13022
  const hk = keySet.has(id) ? id : tagOf.get(routeTagHexOfMintedId(id) ?? "");
13015
- if (hk !== void 0) out13.set(hk, (out13.get(hk) ?? 0) + 1);
13023
+ if (hk !== void 0) out14.set(hk, (out14.get(hk) ?? 0) + 1);
13016
13024
  }
13017
13025
  }
13018
- return out13;
13026
+ return out14;
13019
13027
  }
13020
13028
  async function collectHomedIntents(eng, ws, homeKeys) {
13021
13029
  const routes = directiveRoutes(eng);
@@ -13040,7 +13048,7 @@ async function collectHomedIntents(eng, ws, homeKeys) {
13040
13048
  strikeParity.set(target, (strikeParity.get(target) ?? 0) + 1);
13041
13049
  }
13042
13050
  }
13043
- const out13 = [];
13051
+ const out14 = [];
13044
13052
  for (const { oid, blob, doc } of docs) {
13045
13053
  const id = doc && typeof doc.id === "string" ? doc.id : null;
13046
13054
  if (!id || (strikeParity.get(id) ?? 0) % 2 === 1) continue;
@@ -13056,9 +13064,9 @@ async function collectHomedIntents(eng, ws, homeKeys) {
13056
13064
  const tag = routeTagHexOfMintedId(value);
13057
13065
  homeKey = tag !== void 0 ? tagOf.get(tag) ?? null : null;
13058
13066
  }
13059
- if (homeKey !== null) out13.push({ oid, id, homeKey, blob });
13067
+ if (homeKey !== null) out14.push({ oid, id, homeKey, blob });
13060
13068
  }
13061
- return out13;
13069
+ return out14;
13062
13070
  }
13063
13071
  async function migrateHomes(eng, ws, ledger, sourceWs, homeKeys, { onlyIds = null } = {}) {
13064
13072
  const wanted = onlyIds ? new Set(onlyIds) : null;
@@ -13167,7 +13175,7 @@ async function collectGlobalIntents(eng, ws) {
13167
13175
  strikeParity.set(target, (strikeParity.get(target) ?? 0) + 1);
13168
13176
  }
13169
13177
  }
13170
- const out13 = [];
13178
+ const out14 = [];
13171
13179
  for (const { oid, blob, doc } of docs) {
13172
13180
  const id = doc && typeof doc.id === "string" ? doc.id : null;
13173
13181
  let touches = false;
@@ -13178,9 +13186,9 @@ async function collectGlobalIntents(eng, ws) {
13178
13186
  if (t2 !== void 0 && globals.has(t2)) touches = true;
13179
13187
  }
13180
13188
  if (!touches || !id || (strikeParity.get(id) ?? 0) % 2 === 1) continue;
13181
- out13.push({ oid, id, blob });
13189
+ out14.push({ oid, id, blob });
13182
13190
  }
13183
- return out13;
13191
+ return out14;
13184
13192
  }
13185
13193
  async function replicateIntents(eng, ws, ledger, intents, { push = true } = {}) {
13186
13194
  const main2 = await mainIntentIds(eng, ws);
@@ -13204,6 +13212,10 @@ async function replicateIntents(eng, ws, ledger, intents, { push = true } = {})
13204
13212
  log("replicate-globals", { ws, replicated: replicated.length, skipped: skipped.length, refused: refused.length });
13205
13213
  return { replicated, skipped, refused };
13206
13214
  }
13215
+ function intentOfferSizeRefusal(staged, byteLength) {
13216
+ const maxOfferBytes = staged ? MAX_STAGED_INTENT_OFFER_BYTES : MAX_INLINE_INTENT_OFFER_BYTES;
13217
+ return byteLength <= 0 || byteLength > maxOfferBytes ? `intent offer must carry changeB64 <= ${maxOfferBytes / (1024 * 1024)} MiB` : null;
13218
+ }
13207
13219
  async function admitIntentOffers(eng, ws, ledger, offers, { receiptFence = null, shardRouting = null, clientBase = null } = {}) {
13208
13220
  const main2 = await mainIntentIds(eng, ws);
13209
13221
  const sessions = /* @__PURE__ */ new Map();
@@ -13275,9 +13287,16 @@ async function admitIntentOffers(eng, ws, ledger, offers, { receiptFence = null,
13275
13287
  let blob = offer?.blob instanceof Uint8Array ? offer.blob : null;
13276
13288
  try {
13277
13289
  if (!blob && typeof offer?.changeB64 === "string") blob = Uint8Array.from(atob(offer.changeB64), (c) => c.charCodeAt(0));
13278
- const maxOfferBytes = offer?.staged ? 64 * 1024 * 1024 : 32 * 1024 * 1024;
13279
- if (!blob || blob.byteLength === 0 || blob.byteLength > maxOfferBytes) {
13280
- rec.rejected.push({ oid: String(offer?.oid || "").slice(0, 10), error: `intent offer must carry changeB64 <= ${maxOfferBytes / (1024 * 1024)} MiB` });
13290
+ if (!blob) {
13291
+ rec.rejected.push({
13292
+ oid: String(offer?.oid || "").slice(0, 10),
13293
+ error: intentOfferSizeRefusal(!!offer?.staged, 0)
13294
+ });
13295
+ continue;
13296
+ }
13297
+ const sizeRefusal = intentOfferSizeRefusal(!!offer?.staged, blob.byteLength);
13298
+ if (sizeRefusal !== null) {
13299
+ rec.rejected.push({ oid: String(offer?.oid || "").slice(0, 10), error: sizeRefusal });
13281
13300
  continue;
13282
13301
  }
13283
13302
  const inspected = kgit.inspectChange(eng, blob);
@@ -13537,7 +13556,7 @@ async function mountWorkspace(eng, ws, ledger) {
13537
13556
  throw new Error(`kernel refused restored main ${remoteMain}: ${JSON.stringify(mounted)}`);
13538
13557
  }
13539
13558
  restored = true;
13540
- if (!seeded?.seeded) {
13559
+ if (!seeded?.seeded && ledger.readOnly !== true) {
13541
13560
  void pushCheckpoint(eng, ws, ledger).catch(() => {
13542
13561
  });
13543
13562
  }
@@ -13609,8 +13628,8 @@ function stageLawClosure(eng, lawUsdz, label = "candidate-law") {
13609
13628
  }, "lawClosureInfo");
13610
13629
  }
13611
13630
  function currentLaw(eng, ws) {
13612
- const out13 = namedQueryProto(eng, ws, QueryOperation2.CURRENT_LAW);
13613
- return out13.keyMap || {};
13631
+ const out14 = namedQueryProto(eng, ws, QueryOperation2.CURRENT_LAW);
13632
+ return out14.keyMap || {};
13614
13633
  }
13615
13634
  function installedLaw(eng, ws) {
13616
13635
  return namedQueryProto(eng, ws, QueryOperation2.INSTALLED_LAW);
@@ -13622,8 +13641,8 @@ function kernelStamp(eng, ws) {
13622
13641
  return namedQueryProto(eng, ws, QueryOperation2.KERNEL_STAMP);
13623
13642
  }
13624
13643
  function declaredCapabilities(eng, ws) {
13625
- const out13 = namedQueryProto(eng, ws, QueryOperation2.DECLARED_CAPABILITIES);
13626
- return out13.capabilities || [];
13644
+ const out14 = namedQueryProto(eng, ws, QueryOperation2.DECLARED_CAPABILITIES);
13645
+ return out14.capabilities || [];
13627
13646
  }
13628
13647
  function outboundOffers(eng, ws, nowMillis = Date.now()) {
13629
13648
  const response = callProto(eng.ex, {
@@ -13664,8 +13683,8 @@ function evolveDryRun(eng, ws, lawUsdz, domainHash, dispositions2 = null) {
13664
13683
  return r.ok ? { admits: true } : { admits: false, detail: r.error };
13665
13684
  }
13666
13685
  function mintId(eng, typeTag) {
13667
- const out13 = namedQueryProto(eng, "root", QueryOperation2.MINT, { typeTag, nowMillis: Date.now() });
13668
- return out13.id;
13686
+ const out14 = namedQueryProto(eng, "root", QueryOperation2.MINT, { typeTag, nowMillis: Date.now() });
13687
+ return out14.id;
13669
13688
  }
13670
13689
  function author(eng, ws, domain, directiveId, payload, controllerHash, opts = {}) {
13671
13690
  const seq = eng.seq++;
@@ -13853,13 +13872,13 @@ async function streamAll(stream) {
13853
13872
  }
13854
13873
  let len = 0;
13855
13874
  for (const c of chunks) len += c.length;
13856
- const out13 = new Uint8Array(len);
13875
+ const out14 = new Uint8Array(len);
13857
13876
  let at = 0;
13858
13877
  for (const c of chunks) {
13859
- out13.set(c, at);
13878
+ out14.set(c, at);
13860
13879
  at += c.length;
13861
13880
  }
13862
- return out13;
13881
+ return out14;
13863
13882
  }
13864
13883
  async function gzip(bytes) {
13865
13884
  const cs = new CompressionStream("gzip");
@@ -14698,12 +14717,12 @@ async function verifyChain(eng, ws, ledger) {
14698
14717
  function verifyChainLocal(eng, ws) {
14699
14718
  return namedQueryProto(eng, ws, QueryOperation2.VERIFY_CHAIN);
14700
14719
  }
14701
- function historyPreflight(eng, ws, domain, candidateHash, atHash, dispositions2) {
14720
+ function historyPreflight(eng, ws, domain, candidateHash, atHash, actor = "") {
14702
14721
  return namedQueryProto(eng, ws, QueryOperation2.HISTORY_PREFLIGHT, {
14703
14722
  domain,
14704
14723
  candidateHash,
14705
14724
  atHash,
14706
- ...dispositions2 ? { dispositions: dispositions2 } : {}
14725
+ ...actor.trim() ? { ackBy: actor.trim() } : {}
14707
14726
  });
14708
14727
  }
14709
14728
  function historyRestorePreflight(eng, ws, domain, currentHash, priorHash, atHash, actor) {
@@ -14730,7 +14749,7 @@ function promotePreflighted(eng, ws, domain, candidateHash, opts = {}) {
14730
14749
  }
14731
14750
  let report;
14732
14751
  try {
14733
- report = historyPreflight(eng, ws, domain, candidateHash, atHash, opts.dispositions);
14752
+ report = historyPreflight(eng, ws, domain, candidateHash, atHash, actingPrincipal);
14734
14753
  } catch (error) {
14735
14754
  return { ok: false, stage: "preflight", error: String(error?.message || error) };
14736
14755
  }
@@ -14739,7 +14758,6 @@ function promotePreflighted(eng, ws, domain, candidateHash, opts = {}) {
14739
14758
  const {
14740
14759
  replaces: _replaces,
14741
14760
  retireReplaced: _retireReplaced,
14742
- dispositions: _dispositions,
14743
14761
  acceptanceReason: _acceptance,
14744
14762
  ...authorOpts
14745
14763
  } = opts;
@@ -15044,17 +15062,17 @@ async function writeRefusedRef(eng, ws, dl) {
15044
15062
  async function listRefusedRefs(eng, ws) {
15045
15063
  const gitdir = gitdirOf(ws);
15046
15064
  const refs = kgit.listRefs(eng, gitdir, "refs/heads/refused/");
15047
- const out13 = [];
15065
+ const out14 = [];
15048
15066
  for (const { ref, oid } of refs) {
15049
15067
  try {
15050
15068
  const vb = kgit.readBlob(eng, gitdir, oid, "verdict.usda") ?? new Uint8Array();
15051
15069
  const ib = kgit.readBlob(eng, gitdir, oid, "change.usda") ?? new Uint8Array();
15052
15070
  const v = kgit.inspectRefusalVerdict(eng, vb);
15053
- out13.push({ ref, ...v, verdict: { reason: v.reason }, changeB64: b64Bytes(ib) });
15071
+ out14.push({ ref, ...v, verdict: { reason: v.reason }, changeB64: b64Bytes(ib) });
15054
15072
  } catch {
15055
15073
  }
15056
15074
  }
15057
- return out13;
15075
+ return out14;
15058
15076
  }
15059
15077
  async function refusedSummary(eng, ws) {
15060
15078
  const gitdir = gitdirOf(ws);
@@ -15193,9 +15211,9 @@ async function ledgerStats(eng, ws, ledger = null) {
15193
15211
  const mounted = eng.mounted.get(ws);
15194
15212
  if (mounted && mounted.ledgerStats?.head === head) return mounted.ledgerStats;
15195
15213
  const commits = kgit.intentsAbove(eng, gitdir, head).length;
15196
- const out13 = { head, commits };
15197
- if (mounted) mounted.ledgerStats = out13;
15198
- return out13;
15214
+ const out14 = { head, commits };
15215
+ if (mounted) mounted.ledgerStats = out14;
15216
+ return out14;
15199
15217
  }
15200
15218
  async function countRemoteCommits(eng, ledger) {
15201
15219
  const head = (await custodyLsRefs(ledger, "refs/heads/main"))["refs/heads/main"] || null;
@@ -15229,7 +15247,7 @@ function warmKernelCaches(eng, opts = {}) {
15229
15247
  ...opts.interactiveOnly ? { interactiveOnly: true } : {}
15230
15248
  });
15231
15249
  }
15232
- var enc7, dec7, BRANCH2, PROTO_ABI_VERSION2, protoRequestSequence2, certificateBytes2, protoBirthCertificate2, RESULT_PACK_INLINE_MAX, dirOf, repoArgOf, gitdirOf, unpack2, unsignedWasiPointers2, log, protoTarget2, protoAuthority, repoArgOfGitdir, bytesFromB64, kgit, closureInstallPayload, routeTagHexOfHomeKey2, SUMMARY_SEP, summaryKey, splitSummaryKey, NOMOS_SHARD_ROWS_READ, groupOf, tallyOf, isExtremumRead, extremumMonotone, CKPT_REF, pushVia, fullRef, applyPackInto, importCustodyObjects, syncCandidate, custodyLsRefs, capturedReadUnix, queryArguments, queryAuthorityOptions, qById, query2, queryPage, queryProfile, authorizationAddress, authorizationSubject, currentAuthorizationFrontier, check, expand, cryptoSealField, cryptoOwnedScopeKey, cryptoOwnedDeviceRequest, cryptoOwnedPrepareApproval, cryptoOwnedPrepareRecovery, cryptoKeygen, authorKeygen, eraCertSign, delegationCertSign, attestationSign, certSign, cryptoWrapKey, cryptoUnwrapKey, readPosture, count, sum, pendingConflicts, pendingConflictSummary, spatialBboxParams, spatialWithin, extremum, nomosActive, refusedRefName, GENESIS_WARRANT_ID, isWarranted, projectionStats, memoryDropProbe, readiness;
15250
+ var enc7, dec7, BRANCH2, PROTO_ABI_VERSION2, protoRequestSequence2, certificateBytes2, protoBirthCertificate2, RESULT_PACK_INLINE_MAX, dirOf, repoArgOf, gitdirOf, unpack2, unsignedWasiPointers2, log, protoTarget2, protoAuthority, repoArgOfGitdir, bytesFromB64, kgit, closureInstallPayload, routeTagHexOfHomeKey2, SUMMARY_SEP, summaryKey, splitSummaryKey, NOMOS_SHARD_ROWS_READ, groupOf, tallyOf, isExtremumRead, extremumMonotone, MAX_INLINE_INTENT_OFFER_BYTES, MAX_STAGED_INTENT_OFFER_BYTES, CKPT_REF, pushVia, fullRef, applyPackInto, importCustodyObjects, syncCandidate, custodyLsRefs, capturedReadUnix, queryArguments, queryAuthorityOptions, qById, query2, queryPage, queryProfile, authorizationAddress, authorizationSubject, currentAuthorizationFrontier, check, expand, cryptoSealField, cryptoOwnedScopeKey, cryptoOwnedDeviceRequest, cryptoOwnedPrepareApproval, cryptoOwnedPrepareRecovery, cryptoKeygen, authorKeygen, eraCertSign, delegationCertSign, attestationSign, certSign, cryptoWrapKey, cryptoUnwrapKey, readPosture, count, sum, pendingConflicts, pendingConflictSummary, spatialBboxParams, spatialWithin, extremum, nomosActive, refusedRefName, GENESIS_WARRANT_ID, isWarranted, projectionStats, memoryDropProbe, readiness;
15233
15251
  var init_engine = __esm({
15234
15252
  "vendor/engine/engine.ts"() {
15235
15253
  "use strict";
@@ -15487,6 +15505,8 @@ var init_engine = __esm({
15487
15505
  tallyOf = (eng, ws, read, group) => read.kind === "count" ? count(eng, ws, read.id, group).count : read.kind === "sum" ? sum(eng, ws, read.id, group).sum : extremum(eng, ws, read.id, read.kind, group).value;
15488
15506
  isExtremumRead = (read) => read.kind === "min" || read.kind === "max";
15489
15507
  extremumMonotone = (read, prev, next) => next === null && prev === null || next !== null && (prev === null || (read.kind === "min" ? next <= prev : next >= prev));
15508
+ MAX_INLINE_INTENT_OFFER_BYTES = 32 * 1024 * 1024;
15509
+ MAX_STAGED_INTENT_OFFER_BYTES = 64 * 1024 * 1024;
15490
15510
  CKPT_REF = (lawHash) => `refs/meta/checkpoint/${lawHash}`;
15491
15511
  pushVia = (ledger, fn) => ledger && ledger.pushLane ? ledger.pushLane(fn) : fn();
15492
15512
  fullRef = (r) => r === "HEAD" || r.startsWith("refs/") ? r : `refs/heads/${r}`;
@@ -19563,7 +19583,7 @@ __export(mcp_exports, {
19563
19583
  toolEvolvePreview: () => toolEvolvePreview
19564
19584
  });
19565
19585
  import { spawnSync as spawnSync5 } from "node:child_process";
19566
- import { existsSync as existsSync11 } from "node:fs";
19586
+ import { existsSync as existsSync12 } from "node:fs";
19567
19587
  import { dirname as dirname7, isAbsolute as isAbsolute2, resolve as resolve4 } from "node:path";
19568
19588
  function resolveConfig(config) {
19569
19589
  const arg = config ?? "nomos.project.ts";
@@ -19642,7 +19662,7 @@ function extractDispositions(humanReport) {
19642
19662
  }
19643
19663
  function toolCheck(args) {
19644
19664
  const { configPath } = resolveConfig(args.config);
19645
- if (!existsSync11(configPath)) {
19665
+ if (!existsSync12(configPath)) {
19646
19666
  return { text: `nomos_check: config not found: ${configPath}`, isError: true };
19647
19667
  }
19648
19668
  const extra = args.against !== void 0 ? ["--against", args.against] : [];
@@ -19659,11 +19679,11 @@ ${JSON.stringify(payload, null, 2)}`, isError: false };
19659
19679
  }
19660
19680
  function toolEvolvePreview(args) {
19661
19681
  const { configPath } = resolveConfig(args.config);
19662
- if (!existsSync11(configPath)) {
19682
+ if (!existsSync12(configPath)) {
19663
19683
  return { text: `nomos_evolve_preview: config not found: ${configPath}`, isError: true };
19664
19684
  }
19665
19685
  const againstPath = isAbsolute2(args.against) ? args.against : resolve4(dirname7(configPath), args.against);
19666
- const priorArg = existsSync11(againstPath) ? againstPath : args.against;
19686
+ const priorArg = existsSync12(againstPath) ? againstPath : args.against;
19667
19687
  const jsonRun = runCheckJson(configPath, ["--against", priorArg]);
19668
19688
  if (jsonRun.error !== void 0) {
19669
19689
  return {
@@ -19826,7 +19846,7 @@ __export(test_exports, {
19826
19846
  runDartTests: () => runDartTests
19827
19847
  });
19828
19848
  import { spawnSync as spawnSync6 } from "node:child_process";
19829
- import { existsSync as existsSync12 } from "node:fs";
19849
+ import { existsSync as existsSync13 } from "node:fs";
19830
19850
  import { dirname as dirname8, resolve as resolve5 } from "node:path";
19831
19851
  import { fileURLToPath as fileURLToPath2 } from "node:url";
19832
19852
  function resolveTestCloudEntry(options = {}) {
@@ -19835,7 +19855,7 @@ function resolveTestCloudEntry(options = {}) {
19835
19855
  const explicit = environment.NOMOS_TEST_CLOUD_ENTRY;
19836
19856
  if (explicit !== void 0) {
19837
19857
  const candidate = resolve5(cwd, explicit);
19838
- if (!existsSync12(candidate)) {
19858
+ if (!existsSync13(candidate)) {
19839
19859
  throw new Error(`NOMOS_TEST_CLOUD_ENTRY does not exist: ${candidate}`);
19840
19860
  }
19841
19861
  return candidate;
@@ -19847,7 +19867,7 @@ function resolveTestCloudEntry(options = {}) {
19847
19867
  resolve5(here, "../../cloud/dev-server/server.ts"),
19848
19868
  resolve5(cwd, "cloud/dev-server/server.ts")
19849
19869
  ];
19850
- const server = candidates.find((candidate) => existsSync12(candidate));
19870
+ const server = candidates.find((candidate) => existsSync13(candidate));
19851
19871
  if (server === void 0) {
19852
19872
  throw new Error("the bundled local Nomos cloud is missing \u2014 rebuild or reinstall githolon");
19853
19873
  }
@@ -19894,8 +19914,8 @@ __export(harness_exports, {
19894
19914
  harnessInstall: () => harnessInstall,
19895
19915
  looksLikeStaleRuntime: () => looksLikeStaleRuntime
19896
19916
  });
19897
- import { existsSync as existsSync13, readFileSync as readFileSync11, writeFileSync as writeFileSync8 } from "node:fs";
19898
- import { join as join14 } from "node:path";
19917
+ import { existsSync as existsSync14, readFileSync as readFileSync11, writeFileSync as writeFileSync8 } from "node:fs";
19918
+ import { join as join15 } from "node:path";
19899
19919
  import { randomBytes as randomBytes3 } from "node:crypto";
19900
19920
  function looksLikeStaleRuntime(msg) {
19901
19921
  return /\bbbox param\b|missing.*param|non-numeric|unknown (op|query op)|unsupported op|unexpected (field|key)|no such op/i.test(
@@ -19905,14 +19925,14 @@ function looksLikeStaleRuntime(msg) {
19905
19925
  async function harnessInstall(opts) {
19906
19926
  const { law: lawPaths, workspace, out: outPath } = opts;
19907
19927
  if (lawPaths.length === 0) die("no --law .law.usdz path(s) given");
19908
- const runtimeDir = opts.runtime || process.env["NOMOS_CANDIDATE_RUNTIME"] || process.env["NOMOS_OFFLINE_RUNTIME"] || join14(configDir(), "runtime");
19928
+ const runtimeDir = opts.runtime || process.env["NOMOS_CANDIDATE_RUNTIME"] || process.env["NOMOS_OFFLINE_RUNTIME"] || join15(configDir(), "runtime");
19909
19929
  const refreshed = await refreshRuntimeDir(cloudBase(), runtimeDir);
19910
19930
  if (refreshed) process.stderr.write(`harness-install: refreshed runtime cache from the cloud \u2192 ${runtimeDir}
19911
19931
  `);
19912
- const wasmFile = join14(runtimeDir, "holon-testmint.wasm");
19913
- const bootstrapFile = join14(runtimeDir, "bootstrap.law.usdz");
19914
- const nomosFile = join14(runtimeDir, "nomos.law.usdz");
19915
- if (!existsSync13(wasmFile) || !existsSync13(bootstrapFile) || !existsSync13(nomosFile)) {
19932
+ const wasmFile = join15(runtimeDir, "holon-testmint.wasm");
19933
+ const bootstrapFile = join15(runtimeDir, "bootstrap.law.usdz");
19934
+ const nomosFile = join15(runtimeDir, "nomos.law.usdz");
19935
+ if (!existsSync14(wasmFile) || !existsSync14(bootstrapFile) || !existsSync14(nomosFile)) {
19916
19936
  die(
19917
19937
  `test runtime cache missing at ${runtimeDir} (holon-testmint.wasm + bootstrap.law.usdz + nomos.law.usdz). Warm it once with a \`githolon\` run (it fetches + caches the runtime), then re-run offline.`
19918
19938
  );
@@ -20051,23 +20071,23 @@ async function doctor(opts = {}) {
20051
20071
  const cloud = cloudBase(opts.cloud);
20052
20072
  const localLaw = await readLocalLaw(process.cwd(), cloud, opts.file);
20053
20073
  const report = await probeKernelCapabilities(cloud);
20054
- const out13 = [];
20055
- out13.push(`githolon doctor \u2014 release coherence`);
20056
- out13.push(` cloud : ${cloud}`);
20057
- out13.push(` local law : ${localLaw ? `${localLaw.identity.slice(0, 16)}\u2026 (${localLaw.domains.join(", ") || "no domains"})` : "(not admitted \u2014 run `githolon compile` or inspect the error with `githolon deploy`)"}`);
20058
- out13.push(` runner : cloud expects bundle version ${report?.expectedBundleVersion ?? "(not advertised)"}`);
20059
- out13.push(stampLine("prod kernel", report?.prod));
20060
- out13.push(stampLine("test kernel", report?.testmint));
20074
+ const out14 = [];
20075
+ out14.push(`githolon doctor \u2014 release coherence`);
20076
+ out14.push(` cloud : ${cloud}`);
20077
+ out14.push(` local law : ${localLaw ? `${localLaw.identity.slice(0, 16)}\u2026 (${localLaw.domains.join(", ") || "no domains"})` : "(not admitted \u2014 run `githolon compile` or inspect the error with `githolon deploy`)"}`);
20078
+ out14.push(` runner : cloud expects bundle version ${report?.expectedBundleVersion ?? "(not advertised)"}`);
20079
+ out14.push(stampLine("prod kernel", report?.prod));
20080
+ out14.push(stampLine("test kernel", report?.testmint));
20061
20081
  if (!localLaw) {
20062
- out13.push(``);
20063
- out13.push(` \u26A0 no local build found \u2014 cannot check the law\u2194kernel fit. Run \`githolon compile\` first.`);
20064
- process.stdout.write(out13.join("\n") + "\n");
20082
+ out14.push(``);
20083
+ out14.push(` \u26A0 no local build found \u2014 cannot check the law\u2194kernel fit. Run \`githolon compile\` first.`);
20084
+ process.stdout.write(out14.join("\n") + "\n");
20065
20085
  return report ? 0 : 1;
20066
20086
  }
20067
- out13.push(``);
20068
- out13.push(` \u2713 ARCHIVE COHERENT \u2014 the selected kernel admitted and composed ${localLaw.identity.slice(0, 16)}\u2026 directly from typed USDA.`);
20069
- out13.push(` Full schema/projection compatibility is enforced again by the ordinary install offer.`);
20070
- process.stdout.write(out13.join("\n") + "\n");
20087
+ out14.push(``);
20088
+ out14.push(` \u2713 ARCHIVE COHERENT \u2014 the selected kernel admitted and composed ${localLaw.identity.slice(0, 16)}\u2026 directly from typed USDA.`);
20089
+ out14.push(` Full schema/projection compatibility is enforced again by the ordinary install offer.`);
20090
+ process.stdout.write(out14.join("\n") + "\n");
20071
20091
  return 0;
20072
20092
  }
20073
20093
  var init_doctor = __esm({
@@ -20496,11 +20516,11 @@ function bareTypeLabel(t2) {
20496
20516
  return i > 0 && i < t2.length - 1 ? t2.slice(i + 1) : t2;
20497
20517
  }
20498
20518
  function geoFieldsOfInstalls(installs) {
20499
- const out13 = /* @__PURE__ */ new Map();
20519
+ const out14 = /* @__PURE__ */ new Map();
20500
20520
  const add2 = (type, field) => {
20501
- const set2 = out13.get(type) ?? /* @__PURE__ */ new Set();
20521
+ const set2 = out14.get(type) ?? /* @__PURE__ */ new Set();
20502
20522
  set2.add(field);
20503
- out13.set(type, set2);
20523
+ out14.set(type, set2);
20504
20524
  };
20505
20525
  for (const inst of installs) {
20506
20526
  for (const layer of inst.layers) {
@@ -20516,7 +20536,7 @@ function geoFieldsOfInstalls(installs) {
20516
20536
  }
20517
20537
  }
20518
20538
  }
20519
- return out13;
20539
+ return out14;
20520
20540
  }
20521
20541
  function pointOfOpValue(setOp) {
20522
20542
  let v = setOp["Json"];
@@ -21141,8 +21161,8 @@ var scene_exports = {};
21141
21161
  __export(scene_exports, {
21142
21162
  scene: () => scene
21143
21163
  });
21144
- import { existsSync as existsSync14, mkdirSync as mkdirSync6, writeFileSync as writeFileSync9 } from "node:fs";
21145
- import { join as join15, resolve as resolve6 } from "node:path";
21164
+ import { existsSync as existsSync15, mkdirSync as mkdirSync6, writeFileSync as writeFileSync9 } from "node:fs";
21165
+ import { join as join16, resolve as resolve6 } from "node:path";
21146
21166
  import { createHash as createHash5 } from "node:crypto";
21147
21167
  async function walkChain2(eng, ws) {
21148
21168
  const gitdir = gitdirOf(ws);
@@ -21157,8 +21177,8 @@ async function projectOnce(cloud, target, isDir, name) {
21157
21177
  const { eng } = await holonEngine(cloud, "githolon-scene");
21158
21178
  const SOURCE3 = "source";
21159
21179
  if (isDir) {
21160
- const gitDir = existsSync14(join15(target, ".git")) ? join15(target, ".git") : target;
21161
- if (!existsSync14(join15(gitDir, "HEAD"))) throw new Error(`${target} is not a git repo (no HEAD)`);
21180
+ const gitDir = existsSync15(join16(target, ".git")) ? join16(target, ".git") : target;
21181
+ if (!existsSync15(join16(gitDir, "HEAD"))) throw new Error(`${target} is not a git repo (no HEAD)`);
21162
21182
  await mountFresh(eng, SOURCE3);
21163
21183
  eng.preopen.dir.contents.get("ws").contents.get(SOURCE3).contents.set("nomos.git", readTreeFromDisk(gitDir));
21164
21184
  } else {
@@ -21217,44 +21237,44 @@ async function projectOnce(cloud, target, isDir, name) {
21217
21237
  }
21218
21238
  async function scene(target, opts) {
21219
21239
  const cloud = cloudBase(opts.cloud);
21220
- const isDir = existsSync14(target) || target.includes("/") || target.startsWith(".");
21240
+ const isDir = existsSync15(target) || target.includes("/") || target.startsWith(".");
21221
21241
  const name = isDir ? (resolve6(target).split("/").filter(Boolean).pop() ?? "scene").replace(/\.git$/, "") : target;
21222
- out11(`scene \u2014 ${name} (${isDir ? resolve6(target) : `${cloud} :: ${target}`})`);
21242
+ out12(`scene \u2014 ${name} (${isDir ? resolve6(target) : `${cloud} :: ${target}`})`);
21223
21243
  let first, second;
21224
21244
  try {
21225
21245
  first = await projectOnce(cloud, target, isDir, name);
21226
21246
  second = await projectOnce(cloud, target, isDir, name);
21227
21247
  } catch (e) {
21228
- err11(String(e.message ?? e));
21248
+ err12(String(e.message ?? e));
21229
21249
  return 1;
21230
21250
  }
21231
21251
  if (first.usda !== second.usda) {
21232
- err11(`two replays of the SAME chain emitted DIFFERENT bytes \u2014 the projector is nondeterministic (refusing to write)`);
21252
+ err12(`two replays of the SAME chain emitted DIFFERENT bytes \u2014 the projector is nondeterministic (refusing to write)`);
21233
21253
  return 1;
21234
21254
  }
21235
21255
  const violations = lintPortableProfile(first.usda);
21236
21256
  if (violations.length > 0) {
21237
- err11(`the emitted stage violates the portable profile: ${violations.join("; ")}`);
21257
+ err12(`the emitted stage violates the portable profile: ${violations.join("; ")}`);
21238
21258
  return 1;
21239
21259
  }
21240
- const outDir = resolve6(opts.out ?? join15("scene", name));
21260
+ const outDir = resolve6(opts.out ?? join16("scene", name));
21241
21261
  mkdirSync6(outDir, { recursive: true });
21242
- const usdaPath = join15(outDir, `${name}.usda`);
21243
- const usdzPath = join15(outDir, `${name}.usdz`);
21262
+ const usdaPath = join16(outDir, `${name}.usda`);
21263
+ const usdzPath = join16(outDir, `${name}.usdz`);
21244
21264
  const usdaBytes = new TextEncoder().encode(first.usda);
21245
21265
  writeFileSync9(usdaPath, usdaBytes);
21246
21266
  writeFileSync9(usdzPath, usdzPack([[`${name}.usda`, usdaBytes]]));
21247
21267
  const s = first.stats;
21248
- out11(` verify_chain ${s.verdictLine}`);
21249
- out11(` law canopy ${s.nodes} node(s), ${s.edges} edge(s) \u2014 from the chain's own installed packages`);
21250
- out11(` chain tier ${s.frames} frame(s), timeCodes 0..${s.endT} (timeCode = chain index)`);
21251
- out11(` determinism two fresh replays \u2192 BYTE-IDENTICAL sha256 ${sha256(first.usda).slice(0, 16)}\u2026`);
21252
- out11(` profile portable (Mesh-only, UsdPreviewSurface, translate/scale/visibility timeSamples)`);
21253
- out11(` \u2192 ${usdaPath} (${usdaBytes.length} bytes)`);
21254
- out11(` \u2192 ${usdzPath}`);
21268
+ out12(` verify_chain ${s.verdictLine}`);
21269
+ out12(` law canopy ${s.nodes} node(s), ${s.edges} edge(s) \u2014 from the chain's own installed packages`);
21270
+ out12(` chain tier ${s.frames} frame(s), timeCodes 0..${s.endT} (timeCode = chain index)`);
21271
+ out12(` determinism two fresh replays \u2192 BYTE-IDENTICAL sha256 ${sha256(first.usda).slice(0, 16)}\u2026`);
21272
+ out12(` profile portable (Mesh-only, UsdPreviewSurface, translate/scale/visibility timeSamples)`);
21273
+ out12(` \u2192 ${usdaPath} (${usdaBytes.length} bytes)`);
21274
+ out12(` \u2192 ${usdzPath}`);
21255
21275
  return s.verdictLine.startsWith("GREEN") ? 0 : 2;
21256
21276
  }
21257
- var out11, err11, sha256;
21277
+ var out12, err12, sha256;
21258
21278
  var init_scene = __esm({
21259
21279
  "src/scene.ts"() {
21260
21280
  "use strict";
@@ -21262,8 +21282,8 @@ var init_scene = __esm({
21262
21282
  init_cloud();
21263
21283
  init_local_holon();
21264
21284
  init_scene_projector();
21265
- out11 = (s) => void process.stdout.write(s + "\n");
21266
- err11 = (s) => void process.stderr.write("error: " + s + "\n");
21285
+ out12 = (s) => void process.stdout.write(s + "\n");
21286
+ err12 = (s) => void process.stderr.write("error: " + s + "\n");
21267
21287
  sha256 = (s) => createHash5("sha256").update(s).digest("hex");
21268
21288
  }
21269
21289
  });
@@ -21297,42 +21317,42 @@ async function dlqSweep(ws, opts = {}) {
21297
21317
  const res = await fetch(url);
21298
21318
  body = await res.json();
21299
21319
  if (body.ok !== true || body.root === void 0) {
21300
- err12(`dlq sweep refused: ${String(body.error ?? "no sweep in the response").slice(0, 300)}`);
21320
+ err13(`dlq sweep refused: ${String(body.error ?? "no sweep in the response").slice(0, 300)}`);
21301
21321
  return 1;
21302
21322
  }
21303
21323
  } catch (e) {
21304
- err12(`dlq sweep failed against ${cloud}: ${e.message}`);
21324
+ err13(`dlq sweep failed against ${cloud}: ${e.message}`);
21305
21325
  return 1;
21306
21326
  }
21307
21327
  if (opts.json === true) {
21308
- out12(JSON.stringify(body, null, 2));
21328
+ out13(JSON.stringify(body, null, 2));
21309
21329
  return body.jammed ? 2 : 0;
21310
21330
  }
21311
- out12(`DLQ sweep of '${ws}' \u2014 ${body.nodes} node(s), ${body.jammed} jammed`);
21312
- for (const line of renderSweepNode(body.root)) out12(line);
21331
+ out13(`DLQ sweep of '${ws}' \u2014 ${body.nodes} node(s), ${body.jammed} jammed`);
21332
+ for (const line of renderSweepNode(body.root)) out13(line);
21313
21333
  if (body.jammed) {
21314
- out12("");
21315
- out12("unjam: fix/deploy the law on the jammed workspace, then POST /v2/workspaces/<node>/dead-letters/retry");
21316
- out12(" (or from the app: holon.retryDeadLetter(id); discard is the app's explicit choice)");
21334
+ out13("");
21335
+ out13("unjam: fix/deploy the law on the jammed workspace, then POST /v2/workspaces/<node>/dead-letters/retry");
21336
+ out13(" (or from the app: holon.retryDeadLetter(id); discard is the app's explicit choice)");
21317
21337
  }
21318
21338
  return body.jammed ? 2 : 0;
21319
21339
  }
21320
- var out12, err12;
21340
+ var out13, err13;
21321
21341
  var init_dlq = __esm({
21322
21342
  "src/dlq.ts"() {
21323
21343
  "use strict";
21324
21344
  init_cloud();
21325
- out12 = (s) => void process.stdout.write(s + "\n");
21326
- err12 = (s) => void process.stderr.write("error: " + s + "\n");
21345
+ out13 = (s) => void process.stdout.write(s + "\n");
21346
+ err13 = (s) => void process.stderr.write("error: " + s + "\n");
21327
21347
  }
21328
21348
  });
21329
21349
 
21330
21350
  // src/cli.ts
21331
- import { existsSync as existsSync15, readdirSync as readdirSync6, readFileSync as readFileSync12 } from "node:fs";
21351
+ import { existsSync as existsSync16, readdirSync as readdirSync6, readFileSync as readFileSync12 } from "node:fs";
21332
21352
  import { spawn as spawn2, spawnSync as spawnSync7 } from "node:child_process";
21333
21353
  import { createHash as createHash6 } from "node:crypto";
21334
21354
  import { createRequire as createRequire3 } from "node:module";
21335
- import { dirname as dirname9, join as join16, resolve as resolve7 } from "node:path";
21355
+ import { dirname as dirname9, join as join17, resolve as resolve7 } from "node:path";
21336
21356
  import { pathToFileURL as pathToFileURL5, fileURLToPath as fileURLToPath3 } from "node:url";
21337
21357
 
21338
21358
  // src/generate.ts
@@ -23093,8 +23113,8 @@ function runRelationBootstrapLeg(eng, ws, lawHash, rb, reuseJourneyState = false
23093
23113
  const t0 = performance.now();
23094
23114
  const lines = [];
23095
23115
  const done = (ok, error) => ({ ok, ms: performance.now() - t0, legs: lines, ...error !== void 0 ? { error } : {} });
23096
- const ACTOR = journey.actor ?? "user:proof-conformance";
23097
- const BARE_ACTOR = ACTOR.replace(/^user:/, "");
23116
+ const ACTOR2 = journey.actor ?? "user:proof-conformance";
23117
+ const BARE_ACTOR = ACTOR2.replace(/^user:/, "");
23098
23118
  const stamp = (/* @__PURE__ */ new Date()).toISOString();
23099
23119
  const grantedRelation = rb.grantedRelation ?? rb.relation;
23100
23120
  const computed = grantedRelation !== rb.relation;
@@ -23105,12 +23125,12 @@ function runRelationBootstrapLeg(eng, ws, lawHash, rb, reuseJourneyState = false
23105
23125
  authorities.add(grantedRelation);
23106
23126
  };
23107
23127
  if (rb.bornContext !== void 0) {
23108
- return runBornContextLeg(eng, ws, lawHash, rb, ACTOR, stamp, reuseJourneyState, journey);
23128
+ return runBornContextLeg(eng, ws, lawHash, rb, ACTOR2, stamp, reuseJourneyState, journey);
23109
23129
  }
23110
23130
  if (reuseJourneyState && journey.domain === rb.domain && journey.workspace !== void 0) {
23111
23131
  ws = journey.workspace;
23112
23132
  }
23113
- const actorOpts = journey.authorSecret === void 0 ? { actor: ACTOR } : { actor: ACTOR, authorSecret: journey.authorSecret };
23133
+ const actorOpts = journey.authorSecret === void 0 ? { actor: ACTOR2 } : { actor: ACTOR2, authorSecret: journey.authorSecret };
23114
23134
  if (rb.via === "unrestricted") reuseJourneyState = true;
23115
23135
  if (reuseJourneyState) {
23116
23136
  let retainedPreconditionsReady = true;
@@ -23187,7 +23207,7 @@ function runRelationBootstrapLeg(eng, ws, lawHash, rb, reuseJourneyState = false
23187
23207
  ws,
23188
23208
  lawHash,
23189
23209
  rb.granterAuthority,
23190
- ACTOR,
23210
+ ACTOR2,
23191
23211
  stamp,
23192
23212
  lines,
23193
23213
  journey.authorSecret
@@ -23205,7 +23225,7 @@ function runRelationBootstrapLeg(eng, ws, lawHash, rb, reuseJourneyState = false
23205
23225
  const wrappedSet = new Set(wrapped);
23206
23226
  for (const k of Object.keys(payload)) {
23207
23227
  if (wrappedSet.has(k)) payload[k] = BARE_ACTOR;
23208
- else if (set2.has(k) || /^(subject|principal|grantedBy|grantee|member|user|owner|founder)$/i.test(k)) payload[k] = ACTOR;
23228
+ else if (set2.has(k) || /^(subject|principal|grantedBy|grantee|member|user|owner|founder)$/i.test(k)) payload[k] = ACTOR2;
23209
23229
  }
23210
23230
  };
23211
23231
  for (const seed of rb.prerequisiteSeeds ?? []) {
@@ -23222,7 +23242,7 @@ function runRelationBootstrapLeg(eng, ws, lawHash, rb, reuseJourneyState = false
23222
23242
  lines.push(`\u2013 relation-bootstrap leg SKIPPED (prerequisite-seed chain) \u2014 the prerequisite seed ${rb.domain}/${seed.directiveId} REFUSED with a synthesized payload (${seedRes.error ?? "refused"}); the granter ${rb.grantDirectiveId}'s prerequisite can't be established standalone \u2014 prove ${rb.gatedDirectiveId} via a birth genesis / by hand`);
23223
23243
  return done(true);
23224
23244
  }
23225
- lines.push(`\u2713 relation bootstrap (prerequisite) \u2014 ${rb.domain}/${seed.directiveId} established (as founder ${ACTOR}) before the grant`);
23245
+ lines.push(`\u2713 relation bootstrap (prerequisite) \u2014 ${rb.domain}/${seed.directiveId} established (as founder ${ACTOR2}) before the grant`);
23226
23246
  }
23227
23247
  const grantPayload = { ...rb.grantPayload };
23228
23248
  bindJourneyPrincipals(grantPayload, journey);
@@ -23240,7 +23260,7 @@ function runRelationBootstrapLeg(eng, ws, lawHash, rb, reuseJourneyState = false
23240
23260
  }
23241
23261
  return done(false, `relation bootstrap grant ${rb.domain}/${rb.grantDirectiveId} refused: ${grantRes.error ?? "unknown"} \u2014 the grant that should seat "${grantedRelation}" on the proof actor was rejected (is ${rb.grantDirectiveId} itself gated? add .grants("${grantedRelation}") + an ungated bootstrap, or prove by hand)`);
23242
23262
  }
23243
- const seatDesc = speculative ? `replayed the declared seed ${rb.domain}/${rb.grantDirectiveId} (seats [${(rb.seedWritesRelations ?? [grantedRelation]).join(", ")}]) on ${ACTOR} \u2014 deferring to the real gate to authorize "${rb.relation}"` : `${rb.domain}/${rb.grantDirectiveId} granted "${grantedRelation}" to ${ACTOR} (${rb.via})${computed ? ` \u21D2 satisfies "${rb.relation}" via the rewrite` : ``}`;
23263
+ const seatDesc = speculative ? `replayed the declared seed ${rb.domain}/${rb.grantDirectiveId} (seats [${(rb.seedWritesRelations ?? [grantedRelation]).join(", ")}]) on ${ACTOR2} \u2014 deferring to the real gate to authorize "${rb.relation}"` : `${rb.domain}/${rb.grantDirectiveId} granted "${grantedRelation}" to ${ACTOR2} (${rb.via})${computed ? ` \u21D2 satisfies "${rb.relation}" via the rewrite` : ``}`;
23244
23264
  lines.push(`\u2713 relation bootstrap (${speculative ? "seed" : "grant"}) \u2014 ${seatDesc}`);
23245
23265
  for (const setup of rb.preconditionSetups ?? []) {
23246
23266
  if (reusablePreconditionExists(eng, ws, rb.domain, setup)) {
@@ -23293,17 +23313,17 @@ function runRelationBootstrapLeg(eng, ws, lawHash, rb, reuseJourneyState = false
23293
23313
  const id = gatedPayload[field];
23294
23314
  if (typeof id !== "string") return [];
23295
23315
  const object = `${rb.domain}__${aggregate2}:${id}`;
23296
- const verdict = check(eng, ws, object, rb.relation, ACTOR);
23316
+ const verdict = check(eng, ws, object, rb.relation, ACTOR2);
23297
23317
  return [`${object}#${rb.relation}=${verdict.allowed === true ? "allowed" : `denied(${verdict.error ?? "no reason"})`}`];
23298
23318
  });
23299
- return done(false, `relation bootstrap prove ${rb.domain}/${rb.gatedDirectiveId} refused: ${gatedRes.error ?? "unknown"} \u2014 the gated write did NOT succeed even after granting "${grantedRelation}" to the actor${computed ? ` (which should satisfy "${rb.relation}" via the rewrite)` : ``} (the gate is not honoring the seeded relation, OR the grant did not seat it on ${ACTOR})${authorityChecks.length > 0 ? `; checks: ${authorityChecks.join(", ")}` : ""}${tracedProofPayload(eng, ws, rb.domain, gatedPayload, rb.gatedReferenceFields)}`);
23319
+ return done(false, `relation bootstrap prove ${rb.domain}/${rb.gatedDirectiveId} refused: ${gatedRes.error ?? "unknown"} \u2014 the gated write did NOT succeed even after granting "${grantedRelation}" to the actor${computed ? ` (which should satisfy "${rb.relation}" via the rewrite)` : ``} (the gate is not honoring the seeded relation, OR the grant did not seat it on ${ACTOR2})${authorityChecks.length > 0 ? `; checks: ${authorityChecks.join(", ")}` : ""}${tracedProofPayload(eng, ws, rb.domain, gatedPayload, rb.gatedReferenceFields)}`);
23300
23320
  }
23301
23321
  lines.push(speculative ? `\u2713 relation bootstrap (prove) \u2014 ${rb.domain}/${rb.gatedDirectiveId} authored under the replayed seed (gated write SUCCEEDS \u2014 the REAL kernel gate confirmed the replayed seed establishes authority for "${rb.relation}")` : `\u2713 relation bootstrap (prove) \u2014 ${rb.domain}/${rb.gatedDirectiveId} authored under the seeded holder of "${rb.relation}" (gated write SUCCEEDS once granted)`);
23302
23322
  retainAuthoredReferences(eng, ws, gatedRes, journey);
23303
23323
  retainAuthority();
23304
23324
  return done(true);
23305
23325
  }
23306
- function runBornContextLeg(eng, ws, lawHash, rb, ACTOR, stamp, reuseJourneyState, journey) {
23326
+ function runBornContextLeg(eng, ws, lawHash, rb, ACTOR2, stamp, reuseJourneyState, journey) {
23307
23327
  const t0 = performance.now();
23308
23328
  const lines = [];
23309
23329
  const done = (ok, error) => ({ ok, ms: performance.now() - t0, legs: lines, ...error !== void 0 ? { error } : {} });
@@ -23323,12 +23343,12 @@ function runBornContextLeg(eng, ws, lawHash, rb, ACTOR, stamp, reuseJourneyState
23323
23343
  const retainedWs = reuseJourneyState && journey.domain === rb.domain ? journey.workspace : void 0;
23324
23344
  const retainedSecret = reuseJourneyState && journey.domain === rb.domain ? journey.authorSecret : void 0;
23325
23345
  if (retainedWs !== void 0 && retainedSecret !== void 0) {
23326
- const actorOpts2 = { actor: ACTOR, authorSecret: retainedSecret };
23346
+ const actorOpts2 = { actor: ACTOR2, authorSecret: retainedSecret };
23327
23347
  for (const setup of rb.preconditionSetups ?? []) {
23328
23348
  if (reusablePreconditionExists(eng, retainedWs, rb.domain, setup)) continue;
23329
23349
  const setupPayload = { ...setup.payload };
23330
23350
  for (const key2 of Object.keys(setupPayload)) {
23331
- if (seatsProofActor(key2, setupPayload[key2])) setupPayload[key2] = ACTOR;
23351
+ if (seatsProofActor(key2, setupPayload[key2])) setupPayload[key2] = ACTOR2;
23332
23352
  }
23333
23353
  bindJourneyPrincipals(setupPayload, journey);
23334
23354
  for (const field of setup.autoStamped) setupPayload[field] = stamp;
@@ -23355,7 +23375,7 @@ function runBornContextLeg(eng, ws, lawHash, rb, ACTOR, stamp, reuseJourneyState
23355
23375
  }
23356
23376
  const payload = { ...rb.gatedPayload };
23357
23377
  for (const key2 of Object.keys(payload)) {
23358
- if (seatsProofActor(key2, payload[key2])) payload[key2] = ACTOR;
23378
+ if (seatsProofActor(key2, payload[key2])) payload[key2] = ACTOR2;
23359
23379
  }
23360
23380
  bindJourneyPrincipals(payload, journey);
23361
23381
  for (const field of rb.gatedAutoStamped) payload[field] = stamp;
@@ -23388,7 +23408,7 @@ function runBornContextLeg(eng, ws, lawHash, rb, ACTOR, stamp, reuseJourneyState
23388
23408
  lines.push(unrestricted ? `\u2713 generated business action \u2014 ${rb.domain}/${rb.gatedDirectiveId} reused ${retainedWs}, its typed records and enrolled device` : `\u2713 relation bootstrap (retained born-context) \u2014 ${rb.domain}/${rb.gatedDirectiveId} reused ${retainedWs}, its business records, authority and enrolled device`);
23389
23409
  return done(true);
23390
23410
  }
23391
- const founder = ACTOR && !SENTINEL_PRINCIPAL.test(ACTOR) ? ACTOR : "user:00000000-0000-4000-8000-000000000001";
23411
+ const founder = ACTOR2 && !SENTINEL_PRINCIPAL.test(ACTOR2) ? ACTOR2 : "user:00000000-0000-4000-8000-000000000001";
23392
23412
  const dev2 = journey.authorPublic !== void 0 && journey.authorSecret !== void 0 ? { public: journey.authorPublic, secret: journey.authorSecret } : authorKeygen(eng);
23393
23413
  const devKeyHash = keyHashOf(dev2.public);
23394
23414
  const identityProvider = journey.identityProvider ??= createOfflineProofIdentityProvider();
@@ -23441,7 +23461,7 @@ function runBornContextLeg(eng, ws, lawHash, rb, ACTOR, stamp, reuseJourneyState
23441
23461
  journey.actor = founder;
23442
23462
  journey.authorSecret = dev2.secret;
23443
23463
  journey.authorPublic = dev2.public;
23444
- lines.push(unrestricted ? `\u2713 generated business context \u2014 birthed ${bornWs} via ${rb.domain}/${bc.birthDirectiveId} and enrolled the signed-in owner's device` : `\u2713 relation bootstrap (born-context) \u2014 birthed ${bornWs} via ${rb.domain}/${bc.birthDirectiveId}; its genesis (${bc.seatsViaDirectiveId}) seated "${rb.relation}" for the owner ${ACTOR}`);
23464
+ lines.push(unrestricted ? `\u2713 generated business context \u2014 birthed ${bornWs} via ${rb.domain}/${bc.birthDirectiveId} and enrolled the signed-in owner's device` : `\u2713 relation bootstrap (born-context) \u2014 birthed ${bornWs} via ${rb.domain}/${bc.birthDirectiveId}; its genesis (${bc.seatsViaDirectiveId}) seated "${rb.relation}" for the owner ${ACTOR2}`);
23445
23465
  for (const setup of rb.preconditionSetups ?? []) {
23446
23466
  if (reusablePreconditionExists(eng, bornWs, rb.domain, setup)) continue;
23447
23467
  const setupPayload = { ...setup.payload };
@@ -23495,7 +23515,7 @@ function runBornContextLeg(eng, ws, lawHash, rb, ACTOR, stamp, reuseJourneyState
23495
23515
  if (source.line !== void 0) lines.push(source.line);
23496
23516
  const gatedRes = author(eng, bornWs, rb.domain, rb.gatedDirectiveId, gatedPayload, lawHash, source.opts);
23497
23517
  if (gatedRes.ok === false) {
23498
- lines.push(unrestricted ? `\u2013 generated business journey SKIPPED \u2014 ${rb.domain}/${rb.gatedDirectiveId} was refused inside the born ${bornWs} (${gatedRes.error ?? "refused"})` : `\u2013 relation-bootstrap leg SKIPPED (layer-4 born-context) \u2014 dispatching ${rb.domain}/${rb.gatedDirectiveId} .requires("${rb.relation}") inside the born ${bornWs} as ${ACTOR} was REFUSED on the real gate (${gatedRes.error ?? "refused"}); the born genesis did not establish the authority the gate needs`);
23518
+ lines.push(unrestricted ? `\u2013 generated business journey SKIPPED \u2014 ${rb.domain}/${rb.gatedDirectiveId} was refused inside the born ${bornWs} (${gatedRes.error ?? "refused"})` : `\u2013 relation-bootstrap leg SKIPPED (layer-4 born-context) \u2014 dispatching ${rb.domain}/${rb.gatedDirectiveId} .requires("${rb.relation}") inside the born ${bornWs} as ${ACTOR2} was REFUSED on the real gate (${gatedRes.error ?? "refused"}); the born genesis did not establish the authority the gate needs`);
23499
23519
  return done(true);
23500
23520
  }
23501
23521
  retainAuthoredReferences(eng, bornWs, gatedRes, journey);
@@ -23893,9 +23913,23 @@ var HELP = {
23893
23913
  examples: ["githolon compile", "githolon compile nomos.application.ts --require-usdcat"]
23894
23914
  },
23895
23915
  proof: {
23896
- usage: "githolon proof [build/<name>.proof.mts] [--live]",
23897
- what: "Run the application-wide proof GENERATED from your business law. By default it opens a blank\nlocal application through the same generated API tenant code uses, executes its business journey,\nsynchronizes, reopens, and reads the saved records back. --live runs that same business proof against\nNomos Cloud; identity, provisioning, persistence, and cleanup remain inside Nomos. ALL GREEN or it names the jam.",
23898
- examples: ["githolon proof", "githolon proof build/co2.proof.mts", "githolon proof --live"]
23916
+ usage: "githolon proof [build/<name>.proof.mts] [--live] | githolon proof --upgrade [<ws|dir>] [--file <law.usdz>]",
23917
+ what: "Run the application-wide proof GENERATED from your business law. By default it opens a blank\nlocal application through the same generated API tenant code uses, executes its business journey,\nsynchronizes, reopens, and reads the saved records back. --upgrade copies existing custody, replays the\ncandidate over its exact history, promotes only in memory, and cold-restarts it; the source stays read-only.\n--live runs the fresh proof against Nomos Cloud. ALL GREEN or it names the jam.",
23918
+ flags: [
23919
+ ["--upgrade [<ws|dir>]", "copy existing custody, replay the candidate over its exact history, promote only in memory, then cold-restart it"],
23920
+ ["--target <name>", "use a named workspace target from nomos.project.ts when --upgrade has no explicit source"],
23921
+ ["--file <law.usdz>", "candidate archive for --upgrade (default: the single build/*.law.usdz)"],
23922
+ ["--acceptance-reason <why>", "account for an intentional historical outcome change; never inferred or supplied by Nomos"],
23923
+ ["--live", "run the generated fresh-application proof against an isolated Nomos Cloud workspace"],
23924
+ ["--performance", "repeat the local fresh-application proof and enforce its runtime budgets"]
23925
+ ],
23926
+ examples: [
23927
+ "githolon proof",
23928
+ "githolon proof --upgrade",
23929
+ "githolon proof --upgrade ./custody",
23930
+ "githolon proof --upgrade --target prod",
23931
+ "githolon proof --live"
23932
+ ]
23899
23933
  },
23900
23934
  test: {
23901
23935
  usage: "githolon test [test-file-or-flutter-test-flags] [--diagnostics]",
@@ -24265,9 +24299,9 @@ function capJsonStrings(v, max = 2048) {
24265
24299
  if (typeof v === "string") return v.length > max ? `${v.slice(0, max)}\u2026(${v.length} chars)` : v;
24266
24300
  if (Array.isArray(v)) return v.map((x) => capJsonStrings(x, max));
24267
24301
  if (typeof v === "object" && v !== null) {
24268
- const out13 = {};
24269
- for (const [k, x] of Object.entries(v)) out13[k] = capJsonStrings(x, max);
24270
- return out13;
24302
+ const out14 = {};
24303
+ for (const [k, x] of Object.entries(v)) out14[k] = capJsonStrings(x, max);
24304
+ return out14;
24271
24305
  }
24272
24306
  return v;
24273
24307
  }
@@ -24630,6 +24664,267 @@ async function status(wsArg, opts) {
24630
24664
  return verdict.inSync ? 0 : 2;
24631
24665
  }
24632
24666
 
24667
+ // src/proof_upgrade.ts
24668
+ init_engine();
24669
+ init_cloud();
24670
+ init_local_holon();
24671
+ import { existsSync as existsSync11 } from "node:fs";
24672
+ import { join as join13 } from "node:path";
24673
+ var WORKSPACE = "upgrade-proof";
24674
+ var ACTOR = "githolon-upgrade-proof";
24675
+ var out11 = (message) => void process.stdout.write(message + "\n");
24676
+ var err11 = (message) => void process.stderr.write("error: " + message + "\n");
24677
+ function flagValue(args, name) {
24678
+ const exact = args.indexOf(name);
24679
+ if (exact >= 0) {
24680
+ const value = args[exact + 1];
24681
+ if (value === void 0 || value.startsWith("--")) {
24682
+ throw new Error(`${name} needs a value`);
24683
+ }
24684
+ return { value, indexes: [exact, exact + 1] };
24685
+ }
24686
+ const prefix = `${name}=`;
24687
+ const inline = args.findIndex((argument) => argument.startsWith(prefix));
24688
+ if (inline >= 0) {
24689
+ const value = args[inline].slice(prefix.length).trim();
24690
+ if (value.length === 0) throw new Error(`${name} needs a value`);
24691
+ return { value, indexes: [inline] };
24692
+ }
24693
+ return { indexes: [] };
24694
+ }
24695
+ function parseUpgradeProofArguments(args) {
24696
+ const upgradeIndex = args.findIndex((argument) => argument === "--upgrade" || argument.startsWith("--upgrade="));
24697
+ if (upgradeIndex < 0) {
24698
+ return { requested: false, consumed: /* @__PURE__ */ new Set() };
24699
+ }
24700
+ const consumed = /* @__PURE__ */ new Set([upgradeIndex]);
24701
+ let source;
24702
+ const upgrade = args[upgradeIndex];
24703
+ if (upgrade.startsWith("--upgrade=")) {
24704
+ source = upgrade.slice("--upgrade=".length).trim() || void 0;
24705
+ } else {
24706
+ const following = args[upgradeIndex + 1];
24707
+ if (following !== void 0 && !following.startsWith("--") && !following.endsWith(".proof.mts")) {
24708
+ source = following;
24709
+ consumed.add(upgradeIndex + 1);
24710
+ }
24711
+ }
24712
+ const target = flagValue(args, "--target");
24713
+ const acceptance = flagValue(args, "--acceptance-reason");
24714
+ const candidateFile = flagValue(args, "--file");
24715
+ for (const index of [...target.indexes, ...acceptance.indexes, ...candidateFile.indexes]) consumed.add(index);
24716
+ return {
24717
+ requested: true,
24718
+ ...source === void 0 ? {} : { source },
24719
+ ...target.value === void 0 ? {} : { target: target.value },
24720
+ ...acceptance.value === void 0 ? {} : { acceptanceReason: acceptance.value },
24721
+ ...candidateFile.value === void 0 ? {} : { candidateFile: candidateFile.value },
24722
+ consumed
24723
+ };
24724
+ }
24725
+ function isLocalLedger(target) {
24726
+ return existsSync11(target) || target.includes("/") || target.startsWith(".");
24727
+ }
24728
+ async function mountReadOnlyCopy(eng, source, cloud) {
24729
+ if (!isLocalLedger(source)) {
24730
+ const resident = /* @__PURE__ */ new Set();
24731
+ const mountWithDependencies = async (workspace, mountName, ancestry) => {
24732
+ if (resident.has(workspace)) return;
24733
+ const ledger = {
24734
+ remote: `${cloud}/v2/workspaces/${workspace}/git`,
24735
+ headers: {},
24736
+ readOnly: true
24737
+ };
24738
+ let mounted = await mountWorkspace(eng, mountName, ledger);
24739
+ if (mounted.restored !== true && (mounted.requiredResidencies?.length ?? 0) > 0) {
24740
+ for (const dependency of mounted.requiredResidencies ?? []) {
24741
+ if (ancestry.includes(dependency.workspace)) {
24742
+ throw new Error(`cyclic custody readiness while opening ${[...ancestry, dependency.workspace].join(" -> ")}`);
24743
+ }
24744
+ await mountWithDependencies(
24745
+ dependency.workspace,
24746
+ dependency.workspace,
24747
+ [...ancestry, dependency.workspace]
24748
+ );
24749
+ }
24750
+ mounted = await mountWorkspace(eng, mountName, ledger);
24751
+ }
24752
+ if (mounted.restored !== true) {
24753
+ throw new Error(
24754
+ `workspace '${workspace}' has no readable refs/heads/main on ${cloud}` + (mounted.restoreError ? ` (${String(mounted.restoreError).split(" | ")[0]})` : "")
24755
+ );
24756
+ }
24757
+ resident.add(workspace);
24758
+ };
24759
+ await mountWithDependencies(source, WORKSPACE, [source]);
24760
+ const dependencyCount = Math.max(0, resident.size - 1);
24761
+ return {
24762
+ location: `cloud custody${dependencyCount > 0 ? ` + ${dependencyCount} referenced workspace(s)` : ""}`,
24763
+ rawLocalCopy: false
24764
+ };
24765
+ }
24766
+ const gitDir = existsSync11(join13(source, ".git")) ? join13(source, ".git") : source;
24767
+ if (!existsSync11(join13(gitDir, "HEAD"))) {
24768
+ throw new Error(`${source} is not a GitHolon ledger (no HEAD)`);
24769
+ }
24770
+ await mountFresh(eng, WORKSPACE);
24771
+ const workspaceDir = eng.preopen.dir.contents.get("ws").contents.get(WORKSPACE);
24772
+ workspaceDir.contents.set("nomos.git", readTreeFromDisk(gitDir));
24773
+ const head = kgit.resolveRef(eng, gitdirOf(WORKSPACE), "refs/heads/main");
24774
+ if (!head) throw new Error(`${source} has no refs/heads/main`);
24775
+ return { location: "local custody copy", rawLocalCopy: true };
24776
+ }
24777
+ function tenantPredecessors(candidateDomains, current, frameworkHashes) {
24778
+ return [...new Set(candidateDomains.map((domain) => current[domain]).filter((hash) => typeof hash === "string" && !frameworkHashes.has(hash)))];
24779
+ }
24780
+ function printDifferences(report) {
24781
+ out11(` replayed ${report.replayedIntents} historical intent(s); ${report.candidateIntents} candidate action(s)`);
24782
+ for (const difference of report.divergences.slice(0, 12)) {
24783
+ const location = [difference.domain, difference.directiveId].filter(Boolean).join(".");
24784
+ out11(` changed ${difference.kind}${location ? ` at ${location}` : ""}: ${difference.detail}`);
24785
+ }
24786
+ if (report.divergences.length > 12) out11(` changed + ${report.divergences.length - 12} more difference(s)`);
24787
+ }
24788
+ function localAuthorIdentity() {
24789
+ const credentials = loadCreds();
24790
+ const actor = activePrincipal() ?? ACTOR;
24791
+ const device = getDeviceKey(actor);
24792
+ const session = credentials.session?.uid === actor ? credentials.session : void 0;
24793
+ return {
24794
+ actor,
24795
+ ...device?.secret ? { authorSecret: device.secret } : {},
24796
+ ...session?.accessToken ? { authToken: session.accessToken } : {}
24797
+ };
24798
+ }
24799
+ async function runUpgradeProof(sourceArg, lawUsdzPath, opts = {}) {
24800
+ const cloud = cloudBase(opts.cloud);
24801
+ let source;
24802
+ try {
24803
+ source = await resolveWorkspace(
24804
+ sourceArg,
24805
+ process.cwd(),
24806
+ opts.target,
24807
+ "githolon proof --upgrade <ws|dir>"
24808
+ );
24809
+ } catch (error) {
24810
+ err11(error.message);
24811
+ return 1;
24812
+ }
24813
+ try {
24814
+ const identity = localAuthorIdentity();
24815
+ const { eng: sourceEngine, runtime } = await holonEngine(cloud, identity.actor);
24816
+ const mounted = await mountReadOnlyCopy(sourceEngine, source, cloud);
24817
+ const sourceVerdict = verifyChainLocal(sourceEngine, WORKSPACE);
24818
+ if (sourceVerdict.valid !== true) {
24819
+ throw new Error(`source chain is invalid at ${String(sourceVerdict.check ?? "verify_chain")}: ${String(sourceVerdict.error ?? "unknown refusal")}`);
24820
+ }
24821
+ let eng = sourceEngine;
24822
+ if (mounted.rawLocalCopy) {
24823
+ const sourceHead = kgit.resolveRef(sourceEngine, gitdirOf(WORKSPACE), "refs/heads/main");
24824
+ if (!sourceHead) throw new Error("verified source custody has no main head");
24825
+ const sourcePack = packDelta(sourceEngine, WORKSPACE, "", sourceHead);
24826
+ if (!(sourcePack instanceof Uint8Array) || sourcePack.byteLength === 0) {
24827
+ throw new Error("kernel produced no pack from the verified source custody copy");
24828
+ }
24829
+ ({ eng } = await holonEngine(cloud, identity.actor, "production", runtime));
24830
+ await ingestPackAsCustody(eng, WORKSPACE, sourcePack, sourceHead);
24831
+ }
24832
+ const candidate = inspectLawArchive(eng, lawUsdzPath);
24833
+ if (candidate.domainKeys.length === 0) throw new Error("candidate law archive carries no business domains");
24834
+ const before = currentLaw(eng, WORKSPACE);
24835
+ const predecessors = tenantPredecessors(
24836
+ candidate.domainKeys,
24837
+ before,
24838
+ /* @__PURE__ */ new Set([eng.hashes.bootstrap, eng.hashes.nomos])
24839
+ );
24840
+ const alreadyCurrent = candidate.domainKeys.every((domain) => before[domain] === candidate.identity);
24841
+ if (alreadyCurrent) {
24842
+ out11(`githolon proof --upgrade \u2014 ${source} (${mounted.location})`);
24843
+ out11(`\u2713 candidate ${candidate.identity.slice(0, 16)}\u2026 is already current for ${candidate.domainKeys.join(", ")}`);
24844
+ } else {
24845
+ if (predecessors.length === 0) {
24846
+ throw new Error(
24847
+ `the source does not currently serve any of the candidate domains (${candidate.domainKeys.join(", ")}); this is a first installation, so use \`githolon proof\` rather than an upgrade proof`
24848
+ );
24849
+ }
24850
+ if (predecessors.length !== 1) {
24851
+ throw new Error(
24852
+ `candidate domains currently come from ${predecessors.length} different packages; Nomos will not guess which independent models this one package replaces`
24853
+ );
24854
+ }
24855
+ const predecessor = predecessors[0];
24856
+ const staged = author(
24857
+ eng,
24858
+ WORKSPACE,
24859
+ "nomos",
24860
+ "stageDomain",
24861
+ closureInstallPayload(candidate.identity, identity.actor, { supersedes: predecessor }),
24862
+ eng.hashes.nomos,
24863
+ { ...identity, lawUsdz: candidate.lawUsdz }
24864
+ );
24865
+ if (staged.ok === false) throw new Error(`candidate staging refused: ${staged.error ?? "unknown refusal"}`);
24866
+ const stagedHead = kgit.resolveRef(eng, gitdirOf(WORKSPACE), "refs/heads/main");
24867
+ if (!stagedHead) throw new Error("candidate staging produced no current head");
24868
+ const report = historyPreflight(
24869
+ eng,
24870
+ WORKSPACE,
24871
+ candidate.domainKeys[0],
24872
+ candidate.identity,
24873
+ stagedHead,
24874
+ identity.actor
24875
+ );
24876
+ out11(`githolon proof --upgrade \u2014 ${source} (${mounted.location}, never modified)`);
24877
+ out11(` current ${predecessor.slice(0, 16)}\u2026`);
24878
+ out11(` candidate ${candidate.identity.slice(0, 16)}\u2026 (${candidate.domainKeys.join(", ")})`);
24879
+ printDifferences(report);
24880
+ if (!report.sourceVerified || !report.complete || !report.evolve.ok) {
24881
+ throw new Error(
24882
+ !report.sourceVerified ? "the source history did not verify" : !report.complete ? "the candidate could not re-derive every historical premise" : `typed evolution refused: ${report.evolve.violations.map((violation) => violation.detail).join("; ")}`
24883
+ );
24884
+ }
24885
+ if (!report.promotable && !opts.acceptanceReason?.trim()) {
24886
+ throw new Error(
24887
+ 'the candidate deliberately changes historical business outcomes; review the differences above, then rerun with --acceptance-reason "why this change is correct"'
24888
+ );
24889
+ }
24890
+ const promoted = promotePreflighted(eng, WORKSPACE, candidate.domainKeys[0], candidate.identity, {
24891
+ ...identity,
24892
+ replaces: predecessor,
24893
+ retireReplaced: true,
24894
+ ...opts.acceptanceReason?.trim() ? { acceptanceReason: opts.acceptanceReason.trim() } : {}
24895
+ });
24896
+ if (!promoted.ok) throw new Error(`disposable promotion refused at ${promoted.stage}: ${promoted.error}`);
24897
+ const active = currentLaw(eng, WORKSPACE);
24898
+ for (const domain of candidate.domainKeys) {
24899
+ if (active[domain] !== candidate.identity) {
24900
+ throw new Error(`promotion completed but ${domain} does not resolve to the candidate model`);
24901
+ }
24902
+ }
24903
+ out11(`\u2713 exact-history promotion admitted in the disposable copy`);
24904
+ }
24905
+ const warmVerdict = verifyChainLocal(eng, WORKSPACE);
24906
+ if (warmVerdict.valid !== true) throw new Error(`promoted chain failed verification: ${String(warmVerdict.error ?? "unknown refusal")}`);
24907
+ const head = kgit.resolveRef(eng, gitdirOf(WORKSPACE), "refs/heads/main");
24908
+ if (!head) throw new Error("verified upgraded custody has no main head");
24909
+ const pack = packDelta(eng, WORKSPACE, "", head);
24910
+ if (!(pack instanceof Uint8Array) || pack.byteLength === 0) throw new Error("kernel produced no upgraded custody pack");
24911
+ const { eng: cold } = await holonEngine(cloud, identity.actor, "production", runtime);
24912
+ await ingestPackAsCustody(cold, WORKSPACE, pack, head);
24913
+ const coldVerdict = verifyChainLocal(cold, WORKSPACE);
24914
+ if (coldVerdict.valid !== true) throw new Error(`cold restart refused upgraded custody: ${String(coldVerdict.error ?? "unknown refusal")}`);
24915
+ const coldLaw = currentLaw(cold, WORKSPACE);
24916
+ for (const domain of candidate.domainKeys) {
24917
+ if (coldLaw[domain] !== candidate.identity) throw new Error(`cold restart did not serve ${domain} from the candidate model`);
24918
+ }
24919
+ out11(`\u2713 cold restart serves the candidate at ${head.slice(0, 12)}\u2026`);
24920
+ out11(`\u2713 UPGRADE PROOF GREEN \u2014 source custody was read-only; deployment may proceed through the ordinary offer lane`);
24921
+ return 0;
24922
+ } catch (error) {
24923
+ err11(`upgrade proof failed: ${error.message ?? error}`);
24924
+ return 1;
24925
+ }
24926
+ }
24927
+
24633
24928
  // src/cli.ts
24634
24929
  var KINDS = ["domain", "aggregate", "intent"];
24635
24930
  var DEFAULT_OUT = "domains";
@@ -24776,14 +25071,14 @@ function isKind(s) {
24776
25071
  function resolvedTsxCli() {
24777
25072
  const resolvePkgDir = (name, fromDir) => {
24778
25073
  try {
24779
- return dirname9(createRequire3(pathToFileURL5(join16(fromDir, "noop.js"))).resolve(`${name}/package.json`));
25074
+ return dirname9(createRequire3(pathToFileURL5(join17(fromDir, "noop.js"))).resolve(`${name}/package.json`));
24780
25075
  } catch {
24781
25076
  return void 0;
24782
25077
  }
24783
25078
  };
24784
25079
  const dslDir = (() => {
24785
25080
  try {
24786
- return dirname9(createRequire3(pathToFileURL5(join16(process.cwd(), "noop.js"))).resolve("@githolon/dsl/package.json"));
25081
+ return dirname9(createRequire3(pathToFileURL5(join17(process.cwd(), "noop.js"))).resolve("@githolon/dsl/package.json"));
24787
25082
  } catch {
24788
25083
  try {
24789
25084
  return dirname9(createRequire3(import.meta.url).resolve("@githolon/dsl/package.json"));
@@ -24794,13 +25089,13 @@ function resolvedTsxCli() {
24794
25089
  })();
24795
25090
  const tsxDir = resolvePkgDir("tsx", process.cwd()) ?? (dslDir !== void 0 ? resolvePkgDir("tsx", dslDir) : void 0);
24796
25091
  if (tsxDir === void 0) throw new Error("tsx not found \u2014 add @githolon/dsl to the project and npm install");
24797
- const tsxPkg = JSON.parse(readFileSync12(join16(tsxDir, "package.json"), "utf8"));
25092
+ const tsxPkg = JSON.parse(readFileSync12(join17(tsxDir, "package.json"), "utf8"));
24798
25093
  const tsxBinRel = typeof tsxPkg.bin === "string" ? tsxPkg.bin : tsxPkg.bin?.tsx;
24799
- return join16(tsxDir, tsxBinRel ?? "dist/cli.mjs");
25094
+ return join17(tsxDir, tsxBinRel ?? "dist/cli.mjs");
24800
25095
  }
24801
25096
  async function runGeneratedApplicationProofLocally(proofPath, onPerformance) {
24802
25097
  const lawUsdzPath = proofPath.replace(/\.proof\.mts$/, ".law.usdz");
24803
- if (lawUsdzPath === proofPath || !existsSync15(lawUsdzPath)) {
25098
+ if (lawUsdzPath === proofPath || !existsSync16(lawUsdzPath)) {
24804
25099
  throw new Error(`generated application proof needs its canonical sibling law archive: ${lawUsdzPath}`);
24805
25100
  }
24806
25101
  const here = dirname9(fileURLToPath3(import.meta.url));
@@ -24812,14 +25107,14 @@ async function runGeneratedApplicationProofLocally(proofPath, onPerformance) {
24812
25107
  resolve7(here, "dev-server.mjs"),
24813
25108
  resolve7(here, "../dist/dev-server.mjs")
24814
25109
  ];
24815
- const serverPath = serverCandidates.find((candidate) => existsSync15(candidate));
25110
+ const serverPath = serverCandidates.find((candidate) => existsSync16(candidate));
24816
25111
  if (serverPath === void 0) {
24817
25112
  throw new Error("the bundled local Nomos cloud is missing \u2014 rebuild or reinstall githolon");
24818
25113
  }
24819
25114
  const candidateRuntime = process.env.NOMOS_CANDIDATE_RUNTIME ?? process.env.NOMOS_OFFLINE_RUNTIME;
24820
- const candidateTestMint = candidateRuntime === void 0 ? void 0 : join16(candidateRuntime, "holon-testmint.wasm");
25115
+ const candidateTestMint = candidateRuntime === void 0 ? void 0 : join17(candidateRuntime, "holon-testmint.wasm");
24821
25116
  const priorLocalWasm = process.env.NOMOS_LOCAL_WASM;
24822
- if (candidateTestMint !== void 0 && existsSync15(candidateTestMint)) process.env.NOMOS_LOCAL_WASM = candidateTestMint;
25117
+ if (candidateTestMint !== void 0 && existsSync16(candidateTestMint)) process.env.NOMOS_LOCAL_WASM = candidateTestMint;
24823
25118
  const module = await import(pathToFileURL5(serverPath).href);
24824
25119
  if (typeof module.startGeneratedApplicationProofCloud !== "function") {
24825
25120
  throw new Error("the bundled local Nomos cloud predates generated application execution \u2014 rebuild githolon");
@@ -24899,6 +25194,12 @@ async function runProof(args) {
24899
25194
  };
24900
25195
  const live = args.includes("--live");
24901
25196
  const performance2 = args.includes("--performance");
25197
+ let upgrade;
25198
+ try {
25199
+ upgrade = parseUpgradeProofArguments(args);
25200
+ } catch (error) {
25201
+ return refuse(error.message);
25202
+ }
24902
25203
  const samplesFlag = args.findIndex((argument) => argument === "--samples");
24903
25204
  const samplesValueIdx = samplesFlag < 0 ? -1 : samplesFlag + 1;
24904
25205
  const performanceSamples = samplesFlag < 0 ? 5 : Number(args[samplesFlag + 1]);
@@ -24906,6 +25207,8 @@ async function runProof(args) {
24906
25207
  return refuse("--samples needs an integer from 1 to 20");
24907
25208
  }
24908
25209
  if (live && performance2) return refuse("--performance is a local release gate; use the production-configured app gate for live deployment evidence");
25210
+ if (upgrade.requested && live) return refuse("--upgrade proves copied existing custody locally; it cannot be combined with --live");
25211
+ if (upgrade.requested && performance2) return refuse("--performance measures the generated fresh journey; --upgrade instead proves the exact existing history");
24909
25212
  if (args.includes("--keep")) return refuse("--keep no longer applies: proof --live owns its isolated acceptance workspace and preserves its verified history");
24910
25213
  let domainValueIdx = -1;
24911
25214
  const di = args.findIndex((a) => a === "--domain" || a.startsWith("--domain="));
@@ -24914,14 +25217,36 @@ async function runProof(args) {
24914
25217
  if (!a.includes("=")) domainValueIdx = di + 1;
24915
25218
  return refuse("--domain has been removed: the generated proof exercises the whole application through its one business API");
24916
25219
  }
24917
- const explicit = args.find((a, i) => !a.startsWith("--") && i !== domainValueIdx && i !== samplesValueIdx);
25220
+ const explicit = args.find(
25221
+ (a, i) => !a.startsWith("--") && i !== domainValueIdx && i !== samplesValueIdx && !upgrade.consumed.has(i)
25222
+ );
25223
+ if (upgrade.requested) {
25224
+ let lawUsdzPath;
25225
+ try {
25226
+ if (explicit?.endsWith(".proof.mts")) {
25227
+ const explicitProof = resolve7(process.cwd(), explicit);
25228
+ lawUsdzPath = explicitProof.replace(/\.proof\.mts$/, ".law.usdz");
25229
+ if (!existsSync16(lawUsdzPath)) throw new Error(`generated proof has no canonical sibling law archive: ${lawUsdzPath}`);
25230
+ } else if (explicit !== void 0) {
25231
+ return refuse(`unexpected positional '${explicit}' \u2014 pass custody to --upgrade and candidate law with --file <law.usdz>`);
25232
+ } else {
25233
+ lawUsdzPath = discoverLawUsdz(process.cwd(), upgrade.candidateFile);
25234
+ }
25235
+ } catch (error) {
25236
+ return refuse(error.message);
25237
+ }
25238
+ return runUpgradeProof(upgrade.source, lawUsdzPath, {
25239
+ ...upgrade.target === void 0 ? {} : { target: upgrade.target },
25240
+ ...upgrade.acceptanceReason === void 0 ? {} : { acceptanceReason: upgrade.acceptanceReason }
25241
+ });
25242
+ }
24918
25243
  let proofPath;
24919
25244
  if (explicit !== void 0) {
24920
25245
  proofPath = resolve7(process.cwd(), explicit);
24921
- if (!existsSync15(proofPath)) return refuse(`proof not found: ${proofPath} \u2014 run \`githolon compile\` to (re)generate it`);
25246
+ if (!existsSync16(proofPath)) return refuse(`proof not found: ${proofPath} \u2014 run \`githolon compile\` to (re)generate it`);
24922
25247
  } else {
24923
- const buildDir = join16(process.cwd(), "build");
24924
- if (!existsSync15(buildDir)) {
25248
+ const buildDir = join17(process.cwd(), "build");
25249
+ if (!existsSync16(buildDir)) {
24925
25250
  return refuse("no build/ directory here \u2014 run `githolon compile` first (every compile generates build/<name>.proof.mts from your law)");
24926
25251
  }
24927
25252
  const proofs = readdirSync6(buildDir).filter((f) => f.endsWith(".proof.mts"));
@@ -24931,7 +25256,7 @@ async function runProof(args) {
24931
25256
  if (proofs.length > 1) {
24932
25257
  return refuse(`found ${proofs.length} proofs (${proofs.join(", ")}) \u2014 name one: githolon proof build/<name>.proof.mts`);
24933
25258
  }
24934
- proofPath = join16(buildDir, proofs[0]);
25259
+ proofPath = join17(buildDir, proofs[0]);
24935
25260
  }
24936
25261
  if (!live) {
24937
25262
  try {
@@ -25113,10 +25438,10 @@ async function main(argv) {
25113
25438
  };
25114
25439
  const lawArg = pull("--law");
25115
25440
  const workspace = pull("--workspace") ?? "test-ws";
25116
- const out13 = pull("--out");
25441
+ const out14 = pull("--out");
25117
25442
  const runtime = pull("--runtime");
25118
25443
  const law = (lawArg ?? "").split(",").map((s) => s.trim()).filter(Boolean);
25119
- if (law.length === 0 || out13 === void 0) {
25444
+ if (law.length === 0 || out14 === void 0) {
25120
25445
  process.stderr.write(
25121
25446
  `error: usage: githolon harness-install --law <law.usdz[,law.usdz...]> --workspace <ws> --out <snapshotPath> [--runtime <dir>]
25122
25447
  `
@@ -25124,7 +25449,7 @@ async function main(argv) {
25124
25449
  return 1;
25125
25450
  }
25126
25451
  const { harnessInstall: harnessInstall2 } = await Promise.resolve().then(() => (init_harness(), harness_exports));
25127
- return harnessInstall2({ law, workspace, out: out13, ...runtime !== void 0 ? { runtime } : {} });
25452
+ return harnessInstall2({ law, workspace, out: out14, ...runtime !== void 0 ? { runtime } : {} });
25128
25453
  }
25129
25454
  if (argv[0] === "dev") {
25130
25455
  const rest = argv.slice(1);
@@ -25190,7 +25515,7 @@ usage: githolon cloud dev [--port <n>] [--data <dir>] [--ephemeral]
25190
25515
  resolve7(here, "../../../cloud/dev-server/server.mjs"),
25191
25516
  resolve7(process.cwd(), "cloud/dev-server/server.mjs")
25192
25517
  ];
25193
- const serverPath = candidates.find((p) => existsSync15(p));
25518
+ const serverPath = candidates.find((p) => existsSync16(p));
25194
25519
  if (!serverPath) {
25195
25520
  process.stderr.write("error: dev-server not found \u2014 reinstall `githolon` or run `npm run build` in the cli package\n");
25196
25521
  return 1;
@@ -25647,8 +25972,8 @@ ${USAGE}`);
25647
25972
  let parsed;
25648
25973
  try {
25649
25974
  parsed = parseArgs(argv);
25650
- } catch (err13) {
25651
- process.stderr.write(`error: ${err13.message}
25975
+ } catch (err14) {
25976
+ process.stderr.write(`error: ${err14.message}
25652
25977
 
25653
25978
  ${USAGE}`);
25654
25979
  return 1;
@@ -25667,8 +25992,8 @@ ${USAGE}`);
25667
25992
  process.stdout.write(`created ${path2}
25668
25993
  `);
25669
25994
  return 0;
25670
- } catch (err13) {
25671
- process.stderr.write(`error: ${err13.message}
25995
+ } catch (err14) {
25996
+ process.stderr.write(`error: ${err14.message}
25672
25997
  `);
25673
25998
  return 1;
25674
25999
  }