githolon 0.101.6 → 0.102.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +24100 -8471
- package/dist/dev-server.mjs +153 -38
- package/dist/framework/domain_bootstrap.package.usda +11789 -6
- package/dist/framework/domain_nomos.package.usda +18377 -6
- package/package.json +2 -3
package/dist/dev-server.mjs
CHANGED
|
@@ -775,6 +775,14 @@ function currentLaw(eng, ws) {
|
|
|
775
775
|
function installedLaw(eng, ws) {
|
|
776
776
|
return JSON.parse(call(eng.ex, "query", { repoArg: repoArgOf(ws), workspace: ws, queryBytes: b64Json({ op: "installedLaw" }), branch: BRANCH }, eng.STDERR));
|
|
777
777
|
}
|
|
778
|
+
function kernelStamp(eng, ws) {
|
|
779
|
+
return JSON.parse(call(eng.ex, "query", {
|
|
780
|
+
repoArg: repoArgOf(ws),
|
|
781
|
+
workspace: ws,
|
|
782
|
+
queryBytes: b64Json({ op: "kernelStamp" }),
|
|
783
|
+
branch: BRANCH
|
|
784
|
+
}, eng.STDERR));
|
|
785
|
+
}
|
|
778
786
|
function domainPackage(eng, ws, hash) {
|
|
779
787
|
return JSON.parse(call(eng.ex, "query", { repoArg: repoArgOf(ws), workspace: ws, queryBytes: b64Json({ op: "domainPackage", hash }), branch: BRANCH }, eng.STDERR));
|
|
780
788
|
}
|
|
@@ -1422,7 +1430,8 @@ async function deploy(eng, ws, ledger, usda, domainHash, dispositions, opts = {}
|
|
|
1422
1430
|
const payload = upgrade ? stagePayload(domainHash, usda, eng.installedBy, supersedes) : installPayload(domainHash, usda, eng.installedBy, dispositions);
|
|
1423
1431
|
const result = author(eng, ws, "nomos", directiveId, payload, eng.hashes.nomos, {
|
|
1424
1432
|
actor: opts.actor ?? "",
|
|
1425
|
-
...opts.authToken ? { authToken: opts.authToken } : {}
|
|
1433
|
+
...opts.authToken ? { authToken: opts.authToken } : {},
|
|
1434
|
+
...opts.authorSecret ? { authorSecret: opts.authorSecret } : {}
|
|
1426
1435
|
});
|
|
1427
1436
|
if (result.ok === false) {
|
|
1428
1437
|
unmount(eng, ws);
|
|
@@ -1738,26 +1747,6 @@ async function bootstrapPlatform(dev, opts) {
|
|
|
1738
1747
|
}
|
|
1739
1748
|
log2(`platform '${platform}' genesis'd via the operator anchor lane (framework ${eng.hashes.nomos.slice(0, 12)})`);
|
|
1740
1749
|
});
|
|
1741
|
-
if (opts.deploy) {
|
|
1742
|
-
const body = JSON.parse(readFileSync(opts.deploy, "utf8"));
|
|
1743
|
-
const usda = body.packageUsda || body.usda;
|
|
1744
|
-
if (!usda) throw new Error(`--deploy ${opts.deploy} has no packageUsda (nothing to install)`);
|
|
1745
|
-
const deployErr = await serialize(async () => {
|
|
1746
|
-
const ledger = ledgerFor(platform);
|
|
1747
|
-
const domainHash = await sha256hex(usda);
|
|
1748
|
-
try {
|
|
1749
|
-
const out = await deploy(eng, platform, ledger, usda, domainHash, body.dispositions || null, { actor: "user:dev-admin" });
|
|
1750
|
-
if (out && out.ok === false) return String(out.error || "the law refused the platform package");
|
|
1751
|
-
log2(`platform law deployed: ${domainHash.slice(0, 12)} (head ${String(out.head).slice(0, 12)})`);
|
|
1752
|
-
return null;
|
|
1753
|
-
} catch (e) {
|
|
1754
|
-
return errMsg(e);
|
|
1755
|
-
}
|
|
1756
|
-
});
|
|
1757
|
-
if (deployErr) throw new Error(`platform law deploy REFUSED: ${deployErr.slice(0, 400)}`);
|
|
1758
|
-
} else {
|
|
1759
|
-
log2("no --deploy given; platform runs framework law only (deploy your platform package to enable births)");
|
|
1760
|
-
}
|
|
1761
1750
|
const testMint = isTestMint(eng);
|
|
1762
1751
|
if (!testMint) {
|
|
1763
1752
|
throw new Error(
|
|
@@ -1797,7 +1786,7 @@ async function bootstrapPlatform(dev, opts) {
|
|
|
1797
1786
|
// signed by S_root
|
|
1798
1787
|
});
|
|
1799
1788
|
const certChain = JSON.stringify({ links: [platformCert] });
|
|
1800
|
-
const homeDomain =
|
|
1789
|
+
const homeDomain = FRAMEWORK_HOME_DOMAIN;
|
|
1801
1790
|
const lawKeys = await serialize(async () => {
|
|
1802
1791
|
await mountWorkspace(eng, platform, ledgerFor(platform));
|
|
1803
1792
|
return currentLaw(eng, platform);
|
|
@@ -1880,6 +1869,31 @@ async function bootstrapPlatform(dev, opts) {
|
|
|
1880
1869
|
dev.homeDomain = homeDomain;
|
|
1881
1870
|
}
|
|
1882
1871
|
}
|
|
1872
|
+
if (opts.deploy) {
|
|
1873
|
+
const body = JSON.parse(readFileSync(opts.deploy, "utf8"));
|
|
1874
|
+
const usda = body.packageUsda || body.usda;
|
|
1875
|
+
if (!usda) throw new Error(`--deploy ${opts.deploy} has no packageUsda (nothing to install)`);
|
|
1876
|
+
const founderDevice = dev.operatorDevice;
|
|
1877
|
+
if (!founderDevice) throw new Error("platform law deploy needs the warranted founder device established by bootstrap");
|
|
1878
|
+
const deployErr = await serialize(async () => {
|
|
1879
|
+
const ledger = ledgerFor(platform);
|
|
1880
|
+
const domainHash = await sha256hex(usda);
|
|
1881
|
+
try {
|
|
1882
|
+
const out = await deploy(eng, platform, ledger, usda, domainHash, body.dispositions || null, {
|
|
1883
|
+
actor: "user:dev-operator",
|
|
1884
|
+
authorSecret: founderDevice.secret
|
|
1885
|
+
});
|
|
1886
|
+
if (out && out.ok === false) return String(out.error || "the law refused the platform package");
|
|
1887
|
+
log2(`platform law deployed: ${domainHash.slice(0, 12)} (head ${String(out.head).slice(0, 12)})`);
|
|
1888
|
+
return null;
|
|
1889
|
+
} catch (e) {
|
|
1890
|
+
return errMsg(e);
|
|
1891
|
+
}
|
|
1892
|
+
});
|
|
1893
|
+
if (deployErr) throw new Error(`platform law deploy REFUSED: ${deployErr.slice(0, 400)}`);
|
|
1894
|
+
} else {
|
|
1895
|
+
log2("no --deploy given; platform runs framework law only (deploy your platform package to enable births)");
|
|
1896
|
+
}
|
|
1883
1897
|
if (opts.authProvider || opts.firebaseProject) {
|
|
1884
1898
|
log2(`AuthProvider: ${opts.authProvider || `firebase:${opts.firebaseProject}`} \u2014 register it via the platform's setAuthProvider governance offer;`);
|
|
1885
1899
|
log2(" the kernel verifies x-nomos-auth JWTs against the law-declared key (host stays blind).");
|
|
@@ -1888,13 +1902,14 @@ async function bootstrapPlatform(dev, opts) {
|
|
|
1888
1902
|
log2(attested ? "bootstrap complete \u2014 platform law deployed + ROOT-ATTESTED (BirthAttestation certChain seeded; birthHome assembles a valid travelling cert)." : "bootstrap complete (platform law deployed; attested-birth legs gated as noted above \u2014 need the test-mint wasm).");
|
|
1889
1903
|
return { platform, testMint, attested };
|
|
1890
1904
|
}
|
|
1891
|
-
var log2;
|
|
1905
|
+
var log2, FRAMEWORK_HOME_DOMAIN;
|
|
1892
1906
|
var init_bootstrap = __esm({
|
|
1893
1907
|
"../cloud/dev-server/bootstrap.ts"() {
|
|
1894
1908
|
"use strict";
|
|
1895
1909
|
init_engine();
|
|
1896
1910
|
init_types();
|
|
1897
1911
|
log2 = (m) => console.log(`[bootstrap] ${m}`);
|
|
1912
|
+
FRAMEWORK_HOME_DOMAIN = "__nomos_application_home_v1";
|
|
1898
1913
|
}
|
|
1899
1914
|
});
|
|
1900
1915
|
|
|
@@ -1998,8 +2013,8 @@ function resolveGatewayOperation(spec, opName, method) {
|
|
|
1998
2013
|
|
|
1999
2014
|
// ../cloud/cloudflare-shell/src/kernel-registry.generated.ts
|
|
2000
2015
|
var DEPLOYED_KERNELS = [
|
|
2001
|
-
{ prefix: "
|
|
2002
|
-
{ prefix: "
|
|
2016
|
+
{ prefix: "bc52f7eb", hash: "bc52f7eb630bc5a9a03b4c62b9b7ab58c4b6f25e687ecd51c72f9251763593fc", version: "kernel-bc52f7eb", note: "production (this candidate)", features: ["compoundKeys", "capturedReads", "invariantGate", "surfacedMerge", "fieldProvenance", "nullSemantics", "attestedReads", "conflictSnapshots", "ownedAudience"] },
|
|
2017
|
+
{ prefix: "17d8f91b", hash: "17d8f91b661dc8c3a6dea72d699f9f5759ab5e6b4e3e3e5e90afceb3a7034154", version: "kernel-17d8f91b", note: "test-mint (this candidate) \u2014 feature-equivalent to production", features: ["compoundKeys", "capturedReads", "invariantGate", "surfacedMerge", "fieldProvenance", "nullSemantics", "attestedReads", "conflictSnapshots", "ownedAudience"] }
|
|
2003
2018
|
];
|
|
2004
2019
|
|
|
2005
2020
|
// ../cloud/cloudflare-shell/src/staged-intents.ts
|
|
@@ -2212,6 +2227,18 @@ var unb64 = (s) => new Uint8Array(Buffer.from(s, "base64"));
|
|
|
2212
2227
|
function configDir() {
|
|
2213
2228
|
return process.env.HOLON_CONFIG_DIR || path.join(os.homedir(), ".holon");
|
|
2214
2229
|
}
|
|
2230
|
+
function explicitRuntimeDir() {
|
|
2231
|
+
if (process.env.NOMOS_CANDIDATE_RUNTIME) {
|
|
2232
|
+
return { dir: process.env.NOMOS_CANDIDATE_RUNTIME, candidate: true };
|
|
2233
|
+
}
|
|
2234
|
+
if (process.env.NOMOS_OFFLINE_RUNTIME) {
|
|
2235
|
+
return { dir: process.env.NOMOS_OFFLINE_RUNTIME, candidate: false };
|
|
2236
|
+
}
|
|
2237
|
+
return null;
|
|
2238
|
+
}
|
|
2239
|
+
function selectedRuntimeDir() {
|
|
2240
|
+
return explicitRuntimeDir()?.dir ?? path.join(configDir(), "runtime");
|
|
2241
|
+
}
|
|
2215
2242
|
function firstExisting(...paths) {
|
|
2216
2243
|
for (const p of paths) {
|
|
2217
2244
|
if (p && existsSync2(p)) return p;
|
|
@@ -2257,21 +2284,39 @@ function capabilitiesForKernelHash(hash) {
|
|
|
2257
2284
|
}
|
|
2258
2285
|
var DEFAULT_KERNEL_SOURCE = "https://nomos.captainapp.co.uk";
|
|
2259
2286
|
async function resolveTestMintWasm(kernelSource) {
|
|
2260
|
-
const
|
|
2287
|
+
const explicitRuntime = explicitRuntimeDir();
|
|
2288
|
+
const runtimeCache = selectedRuntimeDir();
|
|
2261
2289
|
const cachePath = path.join(runtimeCache, "holon-testmint.wasm");
|
|
2290
|
+
if (explicitRuntime) {
|
|
2291
|
+
if (existsSync2(cachePath)) {
|
|
2292
|
+
const bytes = readFileSync2(cachePath);
|
|
2293
|
+
if (isTestMintBytes(bytes)) {
|
|
2294
|
+
return { wasmPath: cachePath, wasmBytes: bytes, kernelKind: "test-mint", kernelSource: "explicit-runtime" };
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
if (explicitRuntime.candidate || String(process.env.NOMOS_RUNTIME_REFRESH || "auto").toLowerCase() === "never") {
|
|
2298
|
+
throw new Error(
|
|
2299
|
+
`explicit runtime is missing a valid test-mint kernel at ${cachePath}; hydrate that exact runtime bundle before running the generated proof`
|
|
2300
|
+
);
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2262
2303
|
const local = process.env.NOMOS_LOCAL_WASM;
|
|
2263
|
-
if (local && existsSync2(local)) {
|
|
2304
|
+
if (!explicitRuntime && local && existsSync2(local)) {
|
|
2264
2305
|
const bytes = readFileSync2(local);
|
|
2265
2306
|
if (isTestMintBytes(bytes)) return { wasmPath: local, wasmBytes: bytes, kernelKind: "test-mint", kernelSource: "NOMOS_LOCAL_WASM" };
|
|
2266
2307
|
}
|
|
2267
2308
|
const bundled = path.join(DIR, "kernel-testmint.wasm");
|
|
2268
|
-
if (existsSync2(bundled)) {
|
|
2309
|
+
if (!explicitRuntime && existsSync2(bundled)) {
|
|
2269
2310
|
const bytes = readFileSync2(bundled);
|
|
2270
2311
|
if (isTestMintBytes(bytes)) return { wasmPath: bundled, wasmBytes: bytes, kernelKind: "test-mint", kernelSource: "bundled" };
|
|
2271
2312
|
}
|
|
2272
|
-
if (existsSync2(cachePath)) {
|
|
2313
|
+
if (!explicitRuntime && existsSync2(cachePath)) {
|
|
2273
2314
|
const bytes = readFileSync2(cachePath);
|
|
2274
|
-
|
|
2315
|
+
const sha = createHash2("sha256").update(bytes).digest("hex");
|
|
2316
|
+
const currentTestMint = DEPLOYED_KERNELS.find((entry) => /test-mint/i.test(entry.note));
|
|
2317
|
+
if (isTestMintBytes(bytes) && currentTestMint?.hash === sha) {
|
|
2318
|
+
return { wasmPath: cachePath, wasmBytes: bytes, kernelKind: "test-mint", kernelSource: "cache" };
|
|
2319
|
+
}
|
|
2275
2320
|
}
|
|
2276
2321
|
const src = String(kernelSource || process.env.NOMOS_KERNEL_SOURCE || DEFAULT_KERNEL_SOURCE).replace(/\/+$/, "");
|
|
2277
2322
|
const url = `${src}/v1/runtime/holon-testmint.wasm`;
|
|
@@ -2292,7 +2337,8 @@ async function resolveTestMintWasm(kernelSource) {
|
|
|
2292
2337
|
);
|
|
2293
2338
|
}
|
|
2294
2339
|
async function loadRuntime(opts = {}) {
|
|
2295
|
-
const
|
|
2340
|
+
const explicitRuntime = explicitRuntimeDir();
|
|
2341
|
+
const runtimeCache = selectedRuntimeDir();
|
|
2296
2342
|
const repoDomainsDir = path.join(REPO_ROOT, "cloud/cloudflare-shell/container/domains");
|
|
2297
2343
|
const vendoredFrameworkDir = path.join(DIR, "framework");
|
|
2298
2344
|
let wasmPath, wasmBytes, kernelKind, kernelSource;
|
|
@@ -2300,9 +2346,10 @@ async function loadRuntime(opts = {}) {
|
|
|
2300
2346
|
({ wasmPath, wasmBytes, kernelKind, kernelSource } = await resolveTestMintWasm(opts.kernelSource));
|
|
2301
2347
|
} else {
|
|
2302
2348
|
wasmPath = firstExisting(
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
path.join(
|
|
2349
|
+
explicitRuntime ? path.join(runtimeCache, "holon.wasm") : null,
|
|
2350
|
+
explicitRuntime ? null : process.env.NOMOS_LOCAL_WASM,
|
|
2351
|
+
explicitRuntime ? null : path.join(REPO_ROOT, "cloud/cloudflare-shell/container/vendor/wasm_git_holon.wasm"),
|
|
2352
|
+
explicitRuntime ? null : path.join(runtimeCache, "holon.wasm")
|
|
2306
2353
|
);
|
|
2307
2354
|
if (!wasmPath) {
|
|
2308
2355
|
throw new Error(
|
|
@@ -2316,7 +2363,16 @@ async function loadRuntime(opts = {}) {
|
|
|
2316
2363
|
const repoBootstrap = firstExisting(path.join(repoDomainsDir, "domain_bootstrap.package.usda"));
|
|
2317
2364
|
const repoNomos = firstExisting(path.join(repoDomainsDir, "domain_nomos.package.usda"));
|
|
2318
2365
|
let bootstrapPkg, nomosPkg;
|
|
2319
|
-
|
|
2366
|
+
const explicitPackages = explicitRuntime ? path.join(runtimeCache, "packages.json") : null;
|
|
2367
|
+
if (explicitPackages && existsSync2(explicitPackages)) {
|
|
2368
|
+
const pkgs = JSON.parse(readFileSync2(explicitPackages, "utf8"));
|
|
2369
|
+
bootstrapPkg = pkgs.bootstrap;
|
|
2370
|
+
nomosPkg = pkgs.nomos;
|
|
2371
|
+
} else if (explicitRuntime) {
|
|
2372
|
+
throw new Error(
|
|
2373
|
+
`explicit runtime is missing framework packages at ${explicitPackages}; hydrate that exact runtime bundle before starting the local Nomos cloud`
|
|
2374
|
+
);
|
|
2375
|
+
} else if (repoBootstrap && repoNomos) {
|
|
2320
2376
|
bootstrapPkg = readFileSync2(repoBootstrap, "utf8");
|
|
2321
2377
|
nomosPkg = readFileSync2(repoNomos, "utf8");
|
|
2322
2378
|
} else if (existsSync2(path.join(vendoredFrameworkDir, "domain_bootstrap.package.usda"))) {
|
|
@@ -2527,7 +2583,22 @@ async function startDevCloud(opts = {}) {
|
|
|
2527
2583
|
return res.end(Buffer.from(wasmBytes));
|
|
2528
2584
|
}
|
|
2529
2585
|
if (url.pathname === "/v1/runtime/capabilities") {
|
|
2530
|
-
|
|
2586
|
+
let stamp = capabilitiesForKernelHash(kernelSha);
|
|
2587
|
+
if (!stamp.known) {
|
|
2588
|
+
try {
|
|
2589
|
+
const observed = kernelStamp(eng, opts.platform || "root");
|
|
2590
|
+
if (typeof observed.version === "string" && Array.isArray(observed.features) && observed.features.every((feature) => typeof feature === "string")) {
|
|
2591
|
+
stamp = {
|
|
2592
|
+
hash: kernelSha,
|
|
2593
|
+
version: observed.version,
|
|
2594
|
+
note: "kernel self-attested local candidate",
|
|
2595
|
+
features: observed.features,
|
|
2596
|
+
known: true
|
|
2597
|
+
};
|
|
2598
|
+
}
|
|
2599
|
+
} catch {
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2531
2602
|
return sendJson(res, {
|
|
2532
2603
|
ok: true,
|
|
2533
2604
|
prod: stamp,
|
|
@@ -2976,10 +3047,52 @@ Sec-WebSocket-Accept: ${accept}\r
|
|
|
2976
3047
|
persistBorn,
|
|
2977
3048
|
// `--platform` requested ⇒ NOT ready until the boot-time ceremony completes (main flips it true).
|
|
2978
3049
|
...opts.platform ? { platformReady: false } : {},
|
|
2979
|
-
close: () => new Promise((resolve) =>
|
|
3050
|
+
close: () => new Promise((resolve) => {
|
|
3051
|
+
server.close(() => resolve());
|
|
3052
|
+
server.closeAllConnections?.();
|
|
3053
|
+
})
|
|
2980
3054
|
};
|
|
2981
3055
|
return devSelf;
|
|
2982
3056
|
}
|
|
3057
|
+
async function startGeneratedApplicationProofCloud(opts) {
|
|
3058
|
+
const probe = http.createServer();
|
|
3059
|
+
await new Promise((resolve, reject) => {
|
|
3060
|
+
probe.once("error", reject);
|
|
3061
|
+
probe.listen(0, "127.0.0.1", () => resolve());
|
|
3062
|
+
});
|
|
3063
|
+
const address = probe.address();
|
|
3064
|
+
const port = typeof address === "object" && address !== null ? address.port : 0;
|
|
3065
|
+
await new Promise((resolve) => probe.close(() => resolve()));
|
|
3066
|
+
if (port <= 0) throw new Error("could not allocate a local port for the generated application proof");
|
|
3067
|
+
const dev = await startDevCloud({
|
|
3068
|
+
port,
|
|
3069
|
+
ephemeral: true,
|
|
3070
|
+
attested: true,
|
|
3071
|
+
platform: opts.platform,
|
|
3072
|
+
deploy: opts.deploy
|
|
3073
|
+
});
|
|
3074
|
+
try {
|
|
3075
|
+
const { bootstrapPlatform: bootstrapPlatform2 } = await Promise.resolve().then(() => (init_bootstrap(), bootstrap_exports));
|
|
3076
|
+
await bootstrapPlatform2(dev, { platform: opts.platform, deploy: opts.deploy, attested: true });
|
|
3077
|
+
dev.platformReady = true;
|
|
3078
|
+
if (dev.operatorDevice === void 0) {
|
|
3079
|
+
throw new Error("the local proof cloud did not establish its private founding device");
|
|
3080
|
+
}
|
|
3081
|
+
const idp = dev.testIdP;
|
|
3082
|
+
if (idp === void 0) throw new Error("the local proof cloud did not establish its test identity provider");
|
|
3083
|
+
const proofUid = `proof-owner-${createHash2("sha256").update(opts.platform).digest("hex").slice(0, 16)}`;
|
|
3084
|
+
const principal = `user:${proofUid}`;
|
|
3085
|
+
dev.generatedApplicationProof = {
|
|
3086
|
+
principal,
|
|
3087
|
+
authToken: idp.mint({ sub: proofUid })
|
|
3088
|
+
};
|
|
3089
|
+
return dev;
|
|
3090
|
+
} catch (error) {
|
|
3091
|
+
await dev.close().catch(() => {
|
|
3092
|
+
});
|
|
3093
|
+
throw error;
|
|
3094
|
+
}
|
|
3095
|
+
}
|
|
2983
3096
|
function parseArgs(argv) {
|
|
2984
3097
|
const o = {};
|
|
2985
3098
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -3035,5 +3148,7 @@ if (import.meta.url === `file://${process.argv[1]}`) {
|
|
|
3035
3148
|
});
|
|
3036
3149
|
}
|
|
3037
3150
|
export {
|
|
3038
|
-
|
|
3151
|
+
resolveTestMintWasm,
|
|
3152
|
+
startDevCloud,
|
|
3153
|
+
startGeneratedApplicationProofCloud
|
|
3039
3154
|
};
|