githolon 0.98.3 → 0.99.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.mjs +114 -20
  2. package/package.json +3 -3
package/dist/cli.mjs CHANGED
@@ -2819,10 +2819,12 @@ async function fetchJsonCached(url, cacheFile) {
2819
2819
  throw e;
2820
2820
  }
2821
2821
  }
2822
- async function fetchRuntime(cloud) {
2822
+ async function fetchRuntime(cloud, kind = "production") {
2823
2823
  const cache = join2(configDir(), "runtime");
2824
2824
  let wasmBytes;
2825
- const wasmCache = join2(cache, "holon.wasm");
2825
+ const wasmName = kind === "test-mint" ? "holon-testmint.wasm" : "holon.wasm";
2826
+ const wasmUrl = kind === "test-mint" ? "holon-testmint.wasm" : "holon.wasm";
2827
+ const wasmCache = join2(cache, wasmName);
2826
2828
  const localWasm = process.env["NOMOS_LOCAL_WASM"];
2827
2829
  if (localWasm) {
2828
2830
  const bytes = readFileSync(localWasm);
@@ -2830,7 +2832,7 @@ async function fetchRuntime(cloud) {
2830
2832
  return { wasmBytes: bytes, packages: packages2 };
2831
2833
  }
2832
2834
  try {
2833
- const r = await fetch(`${cloud}/v1/runtime/holon.wasm`);
2835
+ const r = await fetch(`${cloud}/v1/runtime/${wasmUrl}`);
2834
2836
  if (!r.ok) throw new Error(`runtime wasm \u2192 ${r.status}`);
2835
2837
  wasmBytes = new Uint8Array(await r.arrayBuffer());
2836
2838
  mkdirSync2(cache, { recursive: true });
@@ -2896,8 +2898,8 @@ function readTreeFromDisk(diskPath) {
2896
2898
  }
2897
2899
  return new Directory2(contents);
2898
2900
  }
2899
- async function holonEngine(cloud, overlay, installedBy) {
2900
- const runtime = await fetchRuntime(cloud);
2901
+ async function holonEngine(cloud, overlay, installedBy, runtimeKind = "production") {
2902
+ const runtime = await fetchRuntime(cloud, runtimeKind);
2901
2903
  const replica = BigInt(`0x${randomBytes(8).toString("hex")}`) & (1n << 63n) - 1n;
2902
2904
  const eng = await createEngine({
2903
2905
  wasmModule: await WebAssembly.compile(runtime.wasmBytes),
@@ -5844,7 +5846,7 @@ async function runOfflineLegs(eng, ws, lawHash, legs, frameworkHash, deployUsda)
5844
5846
  if (i > 0 && deployUsda !== void 0) {
5845
5847
  cbWs = await mountIsolatedProofWs(eng, ws, lawHash, deployUsda);
5846
5848
  }
5847
- const v = runChildBirthLeg(eng, cbWs, lawHash, birthLeg, frameworkHash);
5849
+ const v = await runChildBirthLeg(eng, cbWs, lawHash, birthLeg, frameworkHash);
5848
5850
  lines.push(...v.legs);
5849
5851
  if (!v.ok) return done(false, lines, v.error);
5850
5852
  }
@@ -5872,25 +5874,72 @@ function warrantParentForBirth(eng, parentWs, parentDomain, lawHash, genesisOwne
5872
5874
  return { ok: false, error: `no directive registered for '${directiveId}' under '${parentDomain}' or 'nomos'` };
5873
5875
  };
5874
5876
  for (const principal of birthActor === genesisOwner ? [genesisOwner] : [genesisOwner, birthActor]) {
5875
- const en = authorFrameworkAs("enrollSigner", { keyHash: keyHashOf(dev2.public), grantedBy: principal, grantedAt: 1 }, principal);
5877
+ const en = authorFrameworkAs("enrollSigner", {
5878
+ keyHash: keyHashOf(dev2.public),
5879
+ grantedBy: principal,
5880
+ grantedAt: 1,
5881
+ // The offline harness runs the explicit test-mint kernel. Give its synthetic founder the same
5882
+ // on-chain provenance a real login's IdP-backed enrollment carries, so a child law that correctly
5883
+ // requires a VERIFIED parent attestation can be proven without weakening that production rule.
5884
+ verifiedVia: OFFLINE_PROOF_VERIFIER
5885
+ }, principal);
5876
5886
  if (en.ok === false && !/already|create-once|enrolled/i.test(en.error ?? "")) return { ok: false, error: `enrollSigner(${principal}) refused: ${en.error}` };
5877
5887
  }
5878
- const cert = certSign(eng, { child: parentWs, founder: genesisOwner, verified: false, parentKey: dev2.public, parentId: parentWs, epoch: 0, secret: dev2.secret });
5888
+ const root = authorKeygen(eng);
5889
+ setTestKRoot(eng, root.public);
5890
+ const parentCert = certSign(eng, {
5891
+ child: parentWs,
5892
+ founder: genesisOwner,
5893
+ verified: true,
5894
+ parentKey: dev2.public,
5895
+ parentId: "root",
5896
+ epoch: 0,
5897
+ secret: dev2.secret
5898
+ });
5899
+ const rootDelegation = certSign(eng, {
5900
+ child: parentWs,
5901
+ founder: genesisOwner,
5902
+ verified: true,
5903
+ parentKey: dev2.public,
5904
+ parentId: "root",
5905
+ epoch: 0,
5906
+ secret: root.secret
5907
+ });
5908
+ const childDelegation = certSign(eng, {
5909
+ child: parentWs,
5910
+ founder: birthActor,
5911
+ verified: true,
5912
+ parentKey: dev2.public,
5913
+ parentId: parentWs,
5914
+ epoch: 0,
5915
+ secret: dev2.secret
5916
+ });
5917
+ const ed = authorFrameworkAs("enrollDelegation", {
5918
+ user: birthActor,
5919
+ deviceKey: dev2.public,
5920
+ certJson: JSON.stringify(childDelegation),
5921
+ enrolledAt: stamp
5922
+ }, birthActor);
5923
+ const hasDelegation = !(ed.ok === false && /no directive registered/i.test(ed.error ?? ""));
5924
+ if (ed.ok === false && !/already|create-once|enrolled|no directive registered/i.test(ed.error ?? "")) {
5925
+ return { ok: false, error: `enrollDelegation(${birthActor}) refused: ${ed.error}` };
5926
+ }
5879
5927
  const sba = authorFrameworkAs("seedBirthAttestation", {
5880
5928
  child: parentWs,
5881
5929
  founder: genesisOwner,
5882
- verified: "false",
5930
+ verified: "true",
5883
5931
  parentId: parentWs,
5884
5932
  parentKey: dev2.public,
5885
5933
  epoch: 0,
5886
- certChain: JSON.stringify({ links: [cert] })
5934
+ certChain: JSON.stringify({ links: [parentCert, rootDelegation] })
5887
5935
  }, genesisOwner);
5888
- if (sba.ok === false && !/already|create-once|attest/i.test(sba.error ?? "")) return { ok: false, error: `seedBirthAttestation refused: ${sba.error}` };
5936
+ const hasParentAttestation = !(sba.ok === false && /no directive registered/i.test(sba.error ?? ""));
5937
+ if (sba.ok === false && !/already|create-once|attest|no directive registered/i.test(sba.error ?? "")) return { ok: false, error: `seedBirthAttestation refused: ${sba.error}` };
5889
5938
  const sg = authorFrameworkAs("seedGenesis", { principal: genesisOwner, workspaceId: parentWs, bornAt: stamp }, genesisOwner);
5890
5939
  if (sg.ok === false && !/already|create-once|warrant/i.test(sg.error ?? "")) return { ok: false, error: `seedGenesis refused: ${sg.error}` };
5891
- return { ok: true };
5940
+ return { ok: true, attestationVerified: hasDelegation && hasParentAttestation };
5892
5941
  }
5893
- function attestedBirthOffer(eng, parentWs, parentDomain, directiveId, payloadNoCert, lawHash, founder, dev2) {
5942
+ function attestedBirthOffer(eng, parentWs, parentDomain, directiveId, payloadNoCert, lawHash, founder, dev2, verified = true) {
5894
5943
  const probe = author(eng, parentWs, parentDomain, directiveId, payloadNoCert, lawHash, { actor: founder });
5895
5944
  if (probe.ok !== false) {
5896
5945
  return { res: probe };
@@ -5903,7 +5952,7 @@ function attestedBirthOffer(eng, parentWs, parentDomain, directiveId, payloadNoC
5903
5952
  const signed = certSign(eng, {
5904
5953
  child: childName,
5905
5954
  founder,
5906
- verified: false,
5955
+ verified,
5907
5956
  parentKey: dev2.public,
5908
5957
  parentId: parentWs,
5909
5958
  epoch: 0,
@@ -5913,7 +5962,7 @@ function attestedBirthOffer(eng, parentWs, parentDomain, directiveId, payloadNoC
5913
5962
  const res = author(eng, parentWs, parentDomain, directiveId, payload, lawHash, { actor: founder, authorSecret: dev2.secret });
5914
5963
  return { res, childName };
5915
5964
  }
5916
- function runChildBirthLeg(eng, ws, lawHash, cb, frameworkHash) {
5965
+ async function runChildBirthLeg(eng, ws, lawHash, cb, frameworkHash) {
5917
5966
  const t0 = performance.now();
5918
5967
  const lines = [];
5919
5968
  const done = (ok, error) => ({ ok, ms: performance.now() - t0, legs: lines, ...error !== void 0 ? { error } : {} });
@@ -5973,7 +6022,8 @@ function runChildBirthLeg(eng, ws, lawHash, cb, frameworkHash) {
5973
6022
  setupPayload,
5974
6023
  lawHash,
5975
6024
  founder,
5976
- dev2
6025
+ dev2,
6026
+ true
5977
6027
  );
5978
6028
  if (setupRes.ok === false) {
5979
6029
  return done(false, `parent setup ${setup.parentDomain}/${setup.birthDirectiveId} refused: ${setupErr ?? setupRes.error ?? "unknown"} \u2014 the proof could not birth the parent workspace needed before gated child birth`);
@@ -5993,7 +6043,17 @@ function runChildBirthLeg(eng, ws, lawHash, cb, frameworkHash) {
5993
6043
  return done(true);
5994
6044
  }
5995
6045
  }
5996
- const { res } = attestedBirthOffer(eng, parentWs, cb.parentDomain, cb.birthDirectiveId, payload, lawHash, founder, dev2);
6046
+ const { res } = attestedBirthOffer(
6047
+ eng,
6048
+ parentWs,
6049
+ cb.parentDomain,
6050
+ cb.birthDirectiveId,
6051
+ payload,
6052
+ lawHash,
6053
+ founder,
6054
+ dev2,
6055
+ cb.parentSetup === void 0 || warrant.attestationVerified === true
6056
+ );
5997
6057
  if (res.ok === false) {
5998
6058
  return done(false, `child birth ${cb.parentDomain}/${cb.birthDirectiveId} refused: ${res.error ?? "unknown"} \u2014 the parent's own gate rejected the birth offer (check the .births() plan + payload)`);
5999
6059
  }
@@ -6067,6 +6127,28 @@ function runChildBirthLeg(eng, ws, lawHash, cb, frameworkHash) {
6067
6127
  return done(false, `the born child ${childWs} FAILED verify_chain at ${verdict.check ?? "?"}${verdict.atIndex !== void 0 ? ` (intent ${verdict.atIndex})` : ""}: ${verdict.error ?? "invalid"} \u2014 the child's own gate refused its genesis`);
6068
6128
  }
6069
6129
  lines.push(`\u2713 verify_chain GREEN on the born child ${childWs} (${verdict.plansRerun ?? "?"} plans re-run \u2014 it self-validates from intent 0 through its OWN gate)`);
6130
+ const bornEntry = (res.born ?? []).find((b) => b?.workspace === childWs);
6131
+ const packed = packBornChildren(eng, bornEntry === void 0 ? [] : [bornEntry]);
6132
+ const childPack = packed.find((b) => b.workspace === childWs);
6133
+ if (!childPack?.packB64 || !childPack.head) {
6134
+ return done(false, `the born child ${childWs} could not be packed for its own custody \u2014 persistence would be masked by the parent engine`);
6135
+ }
6136
+ try {
6137
+ await ingestPackAsCustody(eng, childWs, new Uint8Array(Buffer.from(childPack.packB64, "base64")), childPack.head);
6138
+ } catch (e) {
6139
+ return done(false, `recovering ${childWs} from its custody pack failed: ${e.message}`);
6140
+ }
6141
+ const recoveredVerify = verifyChainLocal(eng, childWs);
6142
+ if (recoveredVerify.valid !== true) {
6143
+ return done(false, `the recovered child ${childWs} FAILED verify_chain from its own custody: ${recoveredVerify.error ?? "invalid"}`);
6144
+ }
6145
+ if (cb.childSeedInstanceId !== void 0) {
6146
+ const recoveredRows = qById(eng, childWs, cb.childSeedInstanceId);
6147
+ if (recoveredRows.length < 1) {
6148
+ return done(false, `the recovered child ${childWs} verified but its business root ${cb.childSeedInstanceId} was missing`);
6149
+ }
6150
+ }
6151
+ lines.push(`\u2713 persistence + recovery \u2014 child custody packed, resident copy discarded, verify_chain GREEN and ${cb.childSeedInstanceId ?? cb.childSeedAggregateId ?? "the business root"} readable after reopen`);
6070
6152
  return done(true);
6071
6153
  }
6072
6154
  function seatRelationAuthority(eng, ws, lawHash, rb, actor, stamp, lines, authorSecret, subjectActor = actor) {
@@ -6236,7 +6318,17 @@ function runBornContextLeg(eng, ws, lawHash, rb, ACTOR, stamp) {
6236
6318
  if (bc.frameworkHashField !== void 0) birthPayload[bc.frameworkHashField] = fw;
6237
6319
  if (bc.lawHashField !== void 0) birthPayload[bc.lawHashField] = lawHash;
6238
6320
  for (const f of bc.birthAutoStamped) birthPayload[f] = stamp;
6239
- const { res: birthRes } = attestedBirthOffer(eng, ws, rb.domain, bc.birthDirectiveId, birthPayload, lawHash, founder, dev2);
6321
+ const { res: birthRes } = attestedBirthOffer(
6322
+ eng,
6323
+ ws,
6324
+ rb.domain,
6325
+ bc.birthDirectiveId,
6326
+ birthPayload,
6327
+ lawHash,
6328
+ founder,
6329
+ dev2,
6330
+ true
6331
+ );
6240
6332
  if (birthRes.ok === false) {
6241
6333
  lines.push(`\u2013 relation-bootstrap leg SKIPPED (layer-4 born-context) \u2014 the self-birth ${rb.domain}/${bc.birthDirectiveId} refused (${birthRes.error ?? "refused"}); could not establish born-genesis authority for "${rb.relation}"`);
6242
6334
  return done(true);
@@ -6297,7 +6389,8 @@ async function runOfflineProofStandalone(proofPath, cloud, domain) {
6297
6389
  const deployBody = JSON.parse(readFileSync7(deployFile, "utf8"));
6298
6390
  const lawHash = await sha256hex(deployBody.packageUsda);
6299
6391
  console.log(`githolon proof \u2014 OFFLINE legs on a local holon (the cloud loop: githolon proof --live)`);
6300
- const { eng } = await holonEngine(cloud, deployBody, "githolon-proof");
6392
+ const runtimeKind = legs.childBirth !== void 0 || (legs.childBirths?.length ?? 0) > 0 ? "test-mint" : "production";
6393
+ const { eng } = await holonEngine(cloud, deployBody, "githolon-proof", runtimeKind);
6301
6394
  const ws = "proof-offline";
6302
6395
  await mountFresh(eng, ws);
6303
6396
  author(eng, ws, "bootstrap", "installDomain", installPayload(eng.hashes.nomos, eng.nomosPkg, "githolon-proof"), "");
@@ -6313,13 +6406,14 @@ OFFLINE PROOF GREEN (${Math.round(v.ms)}ms) \u2014 the same legs rerun on every
6313
6406
  console.log(`Deploy with confidence when ready: githolon ws create <ws> && githolon deploy <ws> (or the full cloud proof: githolon proof --live)`);
6314
6407
  return 0;
6315
6408
  }
6316
- var keyHashOf;
6409
+ var keyHashOf, OFFLINE_PROOF_VERIFIER;
6317
6410
  var init_proof_offline = __esm({
6318
6411
  "src/proof_offline.ts"() {
6319
6412
  "use strict";
6320
6413
  init_engine();
6321
6414
  init_local_holon();
6322
6415
  keyHashOf = (pubB64) => createHash4("sha256").update(Buffer.from(pubB64, "base64")).digest("hex");
6416
+ OFFLINE_PROOF_VERIFIER = "nomos:test-mint";
6323
6417
  }
6324
6418
  });
6325
6419
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "githolon",
3
- "version": "0.98.3",
3
+ "version": "0.99.0",
4
4
  "type": "module",
5
5
  "description": "githolon — the Nomos developer CLI: Rails-style generators for @githolon/dsl domains + the package compiler. Kernel-independent.",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -29,8 +29,8 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@bjorn3/browser_wasi_shim": "0.4.2",
32
- "@githolon/client": "^0.98.3",
33
- "@githolon/dsl": "^0.98.3",
32
+ "@githolon/client": "^0.99.0",
33
+ "@githolon/dsl": "^0.99.0",
34
34
  "isomorphic-git": "^1.38.4"
35
35
  },
36
36
  "devDependencies": {