githolon 0.18.0 → 0.19.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 +105 -23
  2. package/package.json +3 -3
package/dist/cli.mjs CHANGED
@@ -1133,6 +1133,7 @@ var init_local_holon = __esm({
1133
1133
  var proof_offline_exports = {};
1134
1134
  __export(proof_offline_exports, {
1135
1135
  parseOfflineLegs: () => parseOfflineLegs,
1136
+ runChildBirthLeg: () => runChildBirthLeg,
1136
1137
  runOfflineLegs: () => runOfflineLegs,
1137
1138
  runOfflineProofStandalone: () => runOfflineProofStandalone
1138
1139
  });
@@ -1186,7 +1187,7 @@ function parseOfflineLegs(proofSource) {
1186
1187
  ...countLeg !== void 0 ? { count: countLeg } : {}
1187
1188
  };
1188
1189
  }
1189
- function runOfflineLegs(eng, ws, lawHash, legs) {
1190
+ function runOfflineLegs(eng, ws, lawHash, legs, frameworkHash) {
1190
1191
  const t0 = performance.now();
1191
1192
  const done = (ok, lines2, error) => ({
1192
1193
  ok,
@@ -1195,33 +1196,108 @@ function runOfflineLegs(eng, ws, lawHash, legs) {
1195
1196
  ...error !== void 0 ? { error } : {}
1196
1197
  });
1197
1198
  const lines = [];
1198
- const payload = { ...legs.payload };
1199
- const stamp = (/* @__PURE__ */ new Date()).toISOString();
1200
- for (const f of legs.autoStamped) payload[f] = stamp;
1201
- if (legs.mintField !== void 0 && legs.aggregateId !== void 0) {
1202
- payload[legs.mintField] = mintId(eng, legs.aggregateId);
1199
+ const kinds = legs.legs ?? (legs.directiveId !== void 0 ? ["standalone-provable"] : []);
1200
+ if (legs.directiveId !== void 0) {
1201
+ const payload = { ...legs.payload };
1202
+ const stamp = (/* @__PURE__ */ new Date()).toISOString();
1203
+ for (const f of legs.autoStamped ?? []) payload[f] = stamp;
1204
+ if (legs.mintField !== void 0 && legs.aggregateId !== void 0) {
1205
+ payload[legs.mintField] = mintId(eng, legs.aggregateId);
1206
+ }
1207
+ const res = author(eng, ws, legs.domain, legs.directiveId, payload, lawHash);
1208
+ if (res.ok === false) {
1209
+ return done(false, lines, `dispatch ${legs.domain}/${legs.directiveId} refused: ${res.error ?? "unknown"} \u2014 the law itself rejected its own synthesized sample; check the directive's plan/payload schema`);
1210
+ }
1211
+ const createdId = (sealedIntentOf(eng, ws, res)?.events ?? []).find((e) => e.marker === "Create")?.aggregate;
1212
+ lines.push(`\u2713 dispatch ${legs.domain}/${legs.directiveId} \u2014 offline write under the new law${createdId !== void 0 ? ` (${createdId.slice(0, 28)}\u2026)` : ""}`);
1213
+ if (legs.query !== void 0) {
1214
+ const rows = query(eng, ws, legs.query.id, JSON.stringify(legs.query.params));
1215
+ if (rows.length !== 1 || createdId !== void 0 && rows[0].id !== createdId) {
1216
+ return done(false, lines, `declared query ${legs.query.id} expected the 1 created row, got ${JSON.stringify(rows.map((r) => r.id))} \u2014 check the query's key fields against the directive's payload`);
1217
+ }
1218
+ lines.push(`\u2713 declared query ${legs.query.id} answers locally \u2014 1 row`);
1219
+ }
1220
+ if (legs.count !== void 0) {
1221
+ const c = count(eng, ws, legs.count.id, legs.count.group).count;
1222
+ if (c !== 1) {
1223
+ return done(false, lines, `declared count ${legs.count.id}(${JSON.stringify(legs.count.group)}) expected 1, got ${c} \u2014 check the count's grouping against the created row`);
1224
+ }
1225
+ lines.push(`\u2713 declared count ${legs.count.id}(${JSON.stringify(legs.count.group)}) = 1 locally`);
1226
+ }
1227
+ }
1228
+ if (legs.childBirth !== void 0) {
1229
+ const v = runChildBirthLeg(eng, ws, lawHash, legs.childBirth, frameworkHash);
1230
+ lines.push(...v.legs);
1231
+ if (!v.ok) return done(false, lines, v.error);
1232
+ }
1233
+ if (legs.directiveId === void 0 && legs.childBirth === void 0) {
1234
+ lines.push(`\u2713 ${legs.domain} \u2014 compile-valid (the law compiled; no standalone create or .births() to prove a write)${kinds.length ? ` [${kinds.join(", ")}]` : ""}`);
1203
1235
  }
1204
- const res = author(eng, ws, legs.domain, legs.directiveId, payload, lawHash);
1236
+ return done(true, lines);
1237
+ }
1238
+ function runChildBirthLeg(eng, ws, lawHash, cb, frameworkHash) {
1239
+ const t0 = performance.now();
1240
+ const lines = [];
1241
+ const done = (ok, error) => ({ ok, ms: performance.now() - t0, legs: lines, ...error !== void 0 ? { error } : {} });
1242
+ const fw = frameworkHash ?? eng.hashes?.nomos;
1243
+ const payload = { ...cb.birthPayload };
1244
+ if (cb.frameworkHashField !== void 0) payload[cb.frameworkHashField] = fw;
1245
+ if (cb.lawHashField !== void 0) payload[cb.lawHashField] = lawHash;
1246
+ const stamp = (/* @__PURE__ */ new Date()).toISOString();
1247
+ for (const f of cb.birthAutoStamped) payload[f] = stamp;
1248
+ const res = author(eng, ws, cb.parentDomain, cb.birthDirectiveId, payload, lawHash);
1205
1249
  if (res.ok === false) {
1206
- return done(false, lines, `dispatch ${legs.domain}/${legs.directiveId} refused: ${res.error ?? "unknown"} \u2014 the law itself rejected its own synthesized sample; check the directive's plan/payload schema`);
1250
+ 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)`);
1251
+ }
1252
+ const childWs = (res.born ?? []).map((b) => b?.workspace).find((w) => typeof w === "string" && w.length > 0);
1253
+ if (childWs === void 0) {
1254
+ return done(false, `child birth ${cb.parentDomain}/${cb.birthDirectiveId} admitted but the offer-effect spawned no child (born=${JSON.stringify(res.born ?? [])}) \u2014 the run_birth_effect did not fold a child (is the vendored kernel current? does the recipe carry a genesis chain?)`);
1207
1255
  }
1208
- const createdId = (sealedIntentOf(eng, ws, res)?.events ?? []).find((e) => e.marker === "Create")?.aggregate;
1209
- lines.push(`\u2713 dispatch ${legs.domain}/${legs.directiveId} \u2014 offline write under the new law${createdId !== void 0 ? ` (${createdId.slice(0, 28)}\u2026)` : ""}`);
1210
- if (legs.query !== void 0) {
1211
- const rows = query(eng, ws, legs.query.id, JSON.stringify(legs.query.params));
1212
- if (rows.length !== 1 || createdId !== void 0 && rows[0].id !== createdId) {
1213
- return done(false, lines, `declared query ${legs.query.id} expected the 1 created row, got ${JSON.stringify(rows.map((r) => r.id))} \u2014 check the query's key fields against the directive's payload`);
1256
+ lines.push(`\u2713 child birth ${cb.parentDomain}/${cb.birthDirectiveId} \u2014 ${childWs} born (the offer-effect folded the child genesis through the child's OWN gate)`);
1257
+ const installed = (hash) => {
1258
+ try {
1259
+ return qById(eng, childWs, `domain-installation:${hash}`).length > 0;
1260
+ } catch {
1261
+ return false;
1214
1262
  }
1215
- lines.push(`\u2713 declared query ${legs.query.id} answers locally \u2014 1 row`);
1263
+ };
1264
+ if (fw !== void 0 && !installed(fw)) {
1265
+ return done(false, `the born child ${childWs} did not install the framework controller in-chain (domain-installation:${String(fw).slice(0, 12)}\u2026 absent) \u2014 the genesis bootstrap/installDomain did not fold`);
1266
+ }
1267
+ if (!installed(lawHash)) {
1268
+ return done(false, `the born child ${childWs} did not install the child law in-chain (domain-installation:${lawHash.slice(0, 12)}\u2026 absent) \u2014 the genesis nomos/installDomain did not fold (by-hash byte routing failed: does the parent fold this law?)`);
1216
1269
  }
1217
- if (legs.count !== void 0) {
1218
- const c = count(eng, ws, legs.count.id, legs.count.group).count;
1219
- if (c !== 1) {
1220
- return done(false, lines, `declared count ${legs.count.id}(${JSON.stringify(legs.count.group)}) expected 1, got ${c} \u2014 check the count's grouping against the created row`);
1270
+ lines.push(`\u2713 the born child installed the framework + child law IN-CHAIN (the genesis installDomain\xD72 folded)`);
1271
+ let seedRows = [];
1272
+ if (cb.childSeedInstanceId !== void 0) {
1273
+ try {
1274
+ seedRows = qById(eng, childWs, cb.childSeedInstanceId);
1275
+ } catch (e) {
1276
+ return done(false, `reading the child seed (${cb.childSeedInstanceId}) failed: ${e.message}`);
1277
+ }
1278
+ } else if (cb.childQuery !== void 0) {
1279
+ const params = Object.fromEntries(cb.childQuery.key.map((k) => [k, payload[k] ?? ""]));
1280
+ try {
1281
+ seedRows = query(eng, childWs, cb.childQuery.id, JSON.stringify(params));
1282
+ } catch (e) {
1283
+ return done(false, `the child declared query ${cb.childQuery.id} failed: ${e.message}`);
1221
1284
  }
1222
- lines.push(`\u2713 declared count ${legs.count.id}(${JSON.stringify(legs.count.group)}) = 1 locally`);
1223
1285
  }
1224
- return done(true, lines);
1286
+ if ((cb.childSeedInstanceId !== void 0 || cb.childQuery !== void 0) && seedRows.length < 1) {
1287
+ return done(false, `the born child ${childWs} did not seed ${cb.childSeedAggregateId ?? "its genesis record"} (${cb.childSeedDirectiveId} produced no readable row) \u2014 the child genesis seed did not run`);
1288
+ }
1289
+ lines.push(`\u2713 the born child's genesis seed ran \u2014 ${cb.childSeedDirectiveId} produced ${seedRows.length} readable ${cb.childSeedAggregateId ?? "row"}(s) in ${childWs}`);
1290
+ let verdict;
1291
+ try {
1292
+ verdict = verifyChainLocal(eng, childWs);
1293
+ } catch (e) {
1294
+ return done(false, `verify_chain on the born child ${childWs} threw: ${e.message}`);
1295
+ }
1296
+ if (verdict.valid !== true) {
1297
+ 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`);
1298
+ }
1299
+ 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)`);
1300
+ return done(true);
1225
1301
  }
1226
1302
  async function runOfflineProofStandalone(proofPath, cloud, domain) {
1227
1303
  const src = readFileSync3(proofPath, "utf8");
@@ -1240,7 +1316,13 @@ async function runOfflineProofStandalone(proofPath, cloud, domain) {
1240
1316
  throw new Error(`no provable domain '${chosen}' in this package \u2014 it proves: ${keys.join(", ")} (pick one: githolon proof --domain <key>)`);
1241
1317
  }
1242
1318
  legs = index.domains[chosen];
1243
- if (keys.length > 1) console.log(`githolon proof \u2014 domain '${chosen}' (of ${keys.length}: ${keys.join(", ")}; --domain <key> to switch)`);
1319
+ if (keys.length > 1) {
1320
+ console.log(`githolon proof \u2014 domain '${chosen}' (of ${keys.length}; --domain <key> to switch):`);
1321
+ for (const k of keys) {
1322
+ const kk = index.domains[k].legs ?? (index.domains[k].directiveId !== void 0 ? ["standalone-provable"] : ["compile-valid"]);
1323
+ console.log(` ${k === chosen ? "\u25B8" : " "} ${k.padEnd(20)} ${kk.join(", ")}`);
1324
+ }
1325
+ }
1244
1326
  } else {
1245
1327
  if (domain !== void 0) throw new Error(`--domain needs a per-domain legs index (build/${packageName}.proof-legs.json) \u2014 recompile with \`githolon compile\` to emit it`);
1246
1328
  legs = parseOfflineLegs(src);
@@ -1253,7 +1335,7 @@ async function runOfflineProofStandalone(proofPath, cloud, domain) {
1253
1335
  await mountFresh(eng, ws);
1254
1336
  author(eng, ws, "bootstrap", "installDomain", installPayload(eng.hashes.nomos, eng.nomosPkg, "githolon-proof"), "");
1255
1337
  author(eng, ws, "nomos", "installDomain", installPayload(lawHash, deployBody.packageUsda, "githolon-proof"), eng.hashes.nomos);
1256
- const v = runOfflineLegs(eng, ws, lawHash, legs);
1338
+ const v = runOfflineLegs(eng, ws, lawHash, legs, eng.hashes.nomos);
1257
1339
  for (const l of v.legs) console.log(l);
1258
1340
  if (!v.ok) {
1259
1341
  console.error(`\u2717 ${v.error}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "githolon",
3
- "version": "0.18.0",
3
+ "version": "0.19.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",
@@ -27,8 +27,8 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@bjorn3/browser_wasi_shim": "0.4.2",
30
- "@githolon/client": "^0.18.0",
31
- "@githolon/dsl": "^0.18.0",
30
+ "@githolon/client": "^0.19.0",
31
+ "@githolon/dsl": "^0.19.0",
32
32
  "isomorphic-git": "^1.38.4"
33
33
  },
34
34
  "devDependencies": {