githolon 0.54.0 → 0.54.2

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 +46 -6
  2. package/package.json +3 -3
package/dist/cli.mjs CHANGED
@@ -1891,7 +1891,7 @@ function parseAttestedReadNeed(error) {
1891
1891
  function verifyChainLocal(eng, ws) {
1892
1892
  return JSON.parse(call(eng.ex, "query", { repoArg: repoArgOf(ws), workspace: ws, queryBytes: b64Json({ op: "verifyChain" }), branch: BRANCH }, eng.STDERR));
1893
1893
  }
1894
- var enc3, dec3, BRANCH, RESULT_PACK_INLINE_MAX, repoArgOf, gitdirOf, unpack, repoArgOfGitdir, bytesFromB64, kgit, installPayload, fullRef, applyPackInto, custodyLsRefs, qById, query, attestedRead, cryptoUnwrapKey, count, sum, spatialWithin;
1894
+ var enc3, dec3, BRANCH, RESULT_PACK_INLINE_MAX, repoArgOf, gitdirOf, unpack, repoArgOfGitdir, bytesFromB64, kgit, installPayload, fullRef, applyPackInto, custodyLsRefs, qById, query, attestedRead, cryptoUnwrapKey, count, sum, spatialBboxParams, spatialWithin;
1895
1895
  var init_engine = __esm({
1896
1896
  "vendor/engine/engine.mjs"() {
1897
1897
  "use strict";
@@ -1957,7 +1957,11 @@ var init_engine = __esm({
1957
1957
  cryptoUnwrapKey = (eng, { secret, hpkeEpk, ct }) => JSON.parse(call(eng.ex, "query", { queryBytes: b64Json({ op: "cryptoUnwrapKey", secret, hpkeEpk, ct }) }, eng.STDERR)).scopeKey;
1958
1958
  count = (eng, ws, countId, groupKey, principal = "") => JSON.parse(call(eng.ex, "query", { repoArg: repoArgOf(ws), workspace: ws, queryBytes: b64Json({ op: "count", countId, groupKey }), principal, branch: BRANCH }, eng.STDERR));
1959
1959
  sum = (eng, ws, sumId, groupKey, principal = "") => JSON.parse(call(eng.ex, "query", { repoArg: repoArgOf(ws), workspace: ws, queryBytes: b64Json({ op: "sum", sumId, groupKey }), principal, branch: BRANCH }, eng.STDERR));
1960
- spatialWithin = (eng, ws, spatialId, bbox, principal = "") => JSON.parse(call(eng.ex, "query", { repoArg: repoArgOf(ws), workspace: ws, queryBytes: b64Json({ op: "spatial", spatialId, minX: bbox.minX ?? bbox.minLng, minY: bbox.minY ?? bbox.minLat, maxX: bbox.maxX ?? bbox.maxLng, maxY: bbox.maxY ?? bbox.maxLat }), principal, branch: BRANCH }, eng.STDERR));
1960
+ spatialBboxParams = (bbox) => {
1961
+ const minX = bbox.minX ?? bbox.minLng, minY = bbox.minY ?? bbox.minLat, maxX = bbox.maxX ?? bbox.maxLng, maxY = bbox.maxY ?? bbox.maxLat;
1962
+ return { minX, minY, maxX, maxY, minLng: minX, minLat: minY, maxLng: maxX, maxLat: maxY };
1963
+ };
1964
+ spatialWithin = (eng, ws, spatialId, bbox, principal = "") => JSON.parse(call(eng.ex, "query", { repoArg: repoArgOf(ws), workspace: ws, queryBytes: b64Json({ op: "spatial", spatialId, ...spatialBboxParams(bbox) }), principal, branch: BRANCH }, eng.STDERR));
1961
1965
  }
1962
1966
  });
1963
1967
 
@@ -2002,6 +2006,22 @@ async function fetchRuntime(cloud) {
2002
2006
  const packages = await fetchJsonCached(`${cloud}/v1/runtime/packages`, join5(cache, "packages.json"));
2003
2007
  return { wasmBytes, packages };
2004
2008
  }
2009
+ async function refreshRuntimeDir(cloud, runtimeDir) {
2010
+ try {
2011
+ const r = await fetch(`${cloud}/v1/runtime/holon.wasm`);
2012
+ if (!r.ok) throw new Error(`runtime wasm \u2192 ${r.status}`);
2013
+ const wasmBytes = new Uint8Array(await r.arrayBuffer());
2014
+ const pkgs = await fetch(`${cloud}/v1/runtime/packages`);
2015
+ if (!pkgs.ok) throw new Error(`runtime packages \u2192 ${pkgs.status}`);
2016
+ const pkgText = await pkgs.text();
2017
+ mkdirSync4(runtimeDir, { recursive: true });
2018
+ writeFileSync5(join5(runtimeDir, "holon.wasm"), wasmBytes);
2019
+ writeFileSync5(join5(runtimeDir, "packages.json"), pkgText, "utf8");
2020
+ return true;
2021
+ } catch {
2022
+ return false;
2023
+ }
2024
+ }
2005
2025
  function writeTreeToDisk(dir, diskPath) {
2006
2026
  mkdirSync4(diskPath, { recursive: true });
2007
2027
  for (const [name, inode] of dir.contents) {
@@ -2764,15 +2784,25 @@ var init_mcp = __esm({
2764
2784
  // src/harness.ts
2765
2785
  var harness_exports = {};
2766
2786
  __export(harness_exports, {
2767
- harnessInstall: () => harnessInstall
2787
+ STALE_RUNTIME_HINT: () => STALE_RUNTIME_HINT,
2788
+ harnessInstall: () => harnessInstall,
2789
+ looksLikeStaleRuntime: () => looksLikeStaleRuntime
2768
2790
  });
2769
2791
  import { existsSync as existsSync11, readFileSync as readFileSync12, writeFileSync as writeFileSync7 } from "node:fs";
2770
2792
  import { join as join12 } from "node:path";
2771
2793
  import { randomBytes as randomBytes3 } from "node:crypto";
2794
+ function looksLikeStaleRuntime(msg) {
2795
+ return /\bbbox param\b|missing.*param|non-numeric|unknown (op|query op)|unsupported op|unexpected (field|key)|no such op/i.test(
2796
+ msg
2797
+ );
2798
+ }
2772
2799
  async function harnessInstall(opts) {
2773
2800
  const { deploy: deployPaths, workspace, out: outPath } = opts;
2774
2801
  if (deployPaths.length === 0) die("no --deploy JSON path(s) given");
2775
2802
  const runtimeDir = opts.runtime || process.env["NOMOS_OFFLINE_RUNTIME"] || join12(configDir(), "runtime");
2803
+ const refreshed = await refreshRuntimeDir(cloudBase(), runtimeDir);
2804
+ if (refreshed) process.stderr.write(`harness-install: refreshed runtime cache from the cloud \u2192 ${runtimeDir}
2805
+ `);
2776
2806
  const wasmFile = join12(runtimeDir, "holon.wasm");
2777
2807
  const pkgsFile = join12(runtimeDir, "packages.json");
2778
2808
  if (!existsSync11(wasmFile) || !existsSync11(pkgsFile)) {
@@ -2782,6 +2812,15 @@ async function harnessInstall(opts) {
2782
2812
  }
2783
2813
  const wasm = readFileSync12(wasmFile);
2784
2814
  const pkgs = JSON.parse(readFileSync12(pkgsFile, "utf8"));
2815
+ const guarded = async (fn) => {
2816
+ try {
2817
+ return await fn();
2818
+ } catch (e) {
2819
+ const msg = e instanceof Error ? e.message : String(e);
2820
+ if (looksLikeStaleRuntime(msg)) throw new Error(`${msg} \u2014 ${STALE_RUNTIME_HINT}`);
2821
+ throw e;
2822
+ }
2823
+ };
2785
2824
  const replica = BigInt(`0x${randomBytes3(8).toString("hex")}`) & (1n << 63n) - 1n;
2786
2825
  const eng = await createEngine({
2787
2826
  wasmModule: await WebAssembly.compile(wasm),
@@ -2791,7 +2830,7 @@ async function harnessInstall(opts) {
2791
2830
  installedBy: "nomos-test-harness"
2792
2831
  });
2793
2832
  await mountFresh(eng, workspace);
2794
- author(eng, workspace, "bootstrap", "installDomain", installPayload(eng.hashes.nomos, eng.nomosPkg, "nomos-test-harness"), "");
2833
+ await guarded(() => author(eng, workspace, "bootstrap", "installDomain", installPayload(eng.hashes.nomos, eng.nomosPkg, "nomos-test-harness"), ""));
2795
2834
  const lawHashes = [];
2796
2835
  for (const p of deployPaths) {
2797
2836
  if (!existsSync11(p)) die(`deploy JSON not found: ${p} \u2014 run \`npx githolon compile\` first`);
@@ -2799,7 +2838,7 @@ async function harnessInstall(opts) {
2799
2838
  const usda = deploy2.packageUsda;
2800
2839
  if (typeof usda !== "string" || !usda.startsWith("#usda")) die(`${p} has no #usda packageUsda`);
2801
2840
  const lawHash = await sha256hex(usda);
2802
- author(eng, workspace, "nomos", "installDomain", installPayload(lawHash, usda, "nomos-test-harness"), eng.hashes.nomos);
2841
+ await guarded(() => author(eng, workspace, "nomos", "installDomain", installPayload(lawHash, usda, "nomos-test-harness"), eng.hashes.nomos));
2803
2842
  lawHashes.push(lawHash);
2804
2843
  process.stderr.write(`harness-install: installed ${p} (law ${lawHash.slice(0, 12)}\u2026)
2805
2844
  `);
@@ -2813,7 +2852,7 @@ async function harnessInstall(opts) {
2813
2852
  process.stdout.write(JSON.stringify({ ok: true, snapshot: outPath, workspace, lawHashes }) + "\n");
2814
2853
  return 0;
2815
2854
  }
2816
- var die;
2855
+ var STALE_RUNTIME_HINT, die;
2817
2856
  var init_harness = __esm({
2818
2857
  "src/harness.ts"() {
2819
2858
  "use strict";
@@ -2821,6 +2860,7 @@ var init_harness = __esm({
2821
2860
  init_tree();
2822
2861
  init_local_holon();
2823
2862
  init_cloud();
2863
+ STALE_RUNTIME_HINT = "your cached kernel runtime may be stale \u2014 rm -rf ~/.holon/runtime and re-run (it re-fetches from the cloud)";
2824
2864
  die = (msg) => {
2825
2865
  process.stderr.write(`harness-install: ${msg}
2826
2866
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "githolon",
3
- "version": "0.54.0",
3
+ "version": "0.54.2",
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.54.0",
33
- "@githolon/dsl": "^0.54.0",
32
+ "@githolon/client": "^0.54.2",
33
+ "@githolon/dsl": "^0.54.2",
34
34
  "isomorphic-git": "^1.38.4"
35
35
  },
36
36
  "devDependencies": {