@githolon/dsl 0.3.0 → 0.5.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.
- package/package.json +2 -1
- package/src/build_package.ts +4 -0
- package/src/capability_exports.ts +55 -0
- package/src/codegen_dart.ts +9 -0
- package/src/codegen_proof.ts +72 -11
- package/src/compile_package_main.ts +262 -17
- package/src/directive.ts +35 -10
- package/src/engine_entry.ts +5 -1
- package/src/framework/capability.ts +215 -0
- package/src/framework/impure_capability.ts +25 -3
- package/src/framework/workspaces.ts +129 -0
- package/src/index.ts +9 -0
- package/src/manifest.ts +114 -2
- package/src/read.ts +29 -0
- package/src/stable_ids.ts +226 -0
- package/src/stable_ids_types.ts +40 -0
- package/src/usd.ts +54 -0
- package/src/usd_layers.ts +65 -1
- package/src/wire_encode.ts +15 -0
- package/src/workspace_sharding.ts +123 -18
- package/src/workspace_type.ts +7 -5
- package/dart/.dart_tool/package_config.json +0 -328
- package/dart/.dart_tool/package_graph.json +0 -485
- package/dart/.dart_tool/pub/bin/test/test.dart-3.11.5.snapshot +0 -0
- package/dart/.dart_tool/test/incremental_kernel.Ly9AZGFydD0zLjU= +0 -0
- package/dart/.dart_tool/version +0 -1
- package/dart/build/native_assets/macos/native_assets.json +0 -1
- package/dart/build/test_cache/build/89a6598c8854ed031dfc25d83c80860e.cache.dill.track.dill +0 -0
- package/dart/build/unit_test_assets/AssetManifest.bin +0 -0
- package/dart/build/unit_test_assets/FontManifest.json +0 -1
- package/dart/build/unit_test_assets/NOTICES.Z +0 -0
- package/dart/build/unit_test_assets/NativeAssetsManifest.json +0 -1
- package/dart/build/unit_test_assets/shaders/ink_sparkle.frag +0 -0
- package/dart/build/unit_test_assets/shaders/stretch_effect.frag +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@githolon/dsl",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Nomos 2 domain-authoring DSL: aggregates + directives in TS, executed and encoded to the Rust kernel's wire shapes.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"exports": {
|
|
18
18
|
".": "./src/index.ts",
|
|
19
19
|
"./manifest": "./src/manifest.ts",
|
|
20
|
+
"./stable-ids": "./src/stable_ids.ts",
|
|
20
21
|
"./compose": "./src/compose.ts",
|
|
21
22
|
"./usd": "./src/usd.ts",
|
|
22
23
|
"./usd-layers": "./src/usd_layers.ts",
|
package/src/build_package.ts
CHANGED
|
@@ -54,6 +54,7 @@ import type { WorkspaceTypeDecl } from "./workspace_type.js";
|
|
|
54
54
|
import type { WorkspaceInvariantDecl } from "./framework/workspace_invariant.js";
|
|
55
55
|
import { domainHash, emitManifestBytes } from "./manifest.js";
|
|
56
56
|
import { emitUsd } from "./usd.js";
|
|
57
|
+
import { expandCapabilityExports } from "./capability_exports.js";
|
|
57
58
|
|
|
58
59
|
// ─────────────────────────────────────────────────────────────────────────────────
|
|
59
60
|
// composeDomainModule — the named-keys `module(...)`
|
|
@@ -134,6 +135,9 @@ export interface DomainModuleSpec {
|
|
|
134
135
|
export function composeDomainModule(spec: DomainModuleSpec): DomainModule {
|
|
135
136
|
let merged: Mod = {};
|
|
136
137
|
for (const m of spec.modules) merged = { ...merged, ...m };
|
|
138
|
+
// `capability()` bundles expand into discoverable entries (the package plane's
|
|
139
|
+
// merge point) — the quartet validation below then passes without re-exports.
|
|
140
|
+
merged = expandCapabilityExports(merged);
|
|
137
141
|
|
|
138
142
|
const byId = new Map<string, AggregateHandle>();
|
|
139
143
|
for (const a of [...aggregatesOf(merged), ...(spec.extraAggregates ?? [])]) byId.set(a.id, a);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// NOMOS — Nomos Sovereign: participants act · verify · remember LOCALLY; hosted
|
|
2
|
+
// remotes are replaceable custody/transport, not truth. ⇒ ONE Nomos GitHolon
|
|
3
|
+
// wasm32-wasip1 artifact {kernel · projection · embedded
|
|
4
|
+
// QuickJS engine} on V8 + WASI-shim, byte-identical everywhere. V8 = portability; the one
|
|
5
|
+
// wasm = determinism. No native, no wasmtime, no 2nd artifact, no domain-JS on bare V8.
|
|
6
|
+
// If a file isn't this / hosting this / authoring for this / proving this — it's gone.
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* capability_exports.ts — the ONE-EXPORT expansion for `capability()` bundles
|
|
10
|
+
* (`architecture/capability_marketplace.md` §4, ruling M2 — "the domain dev
|
|
11
|
+
* declares ONE thing").
|
|
12
|
+
*
|
|
13
|
+
* Every module-exports walk in the house scans TOP-LEVEL exports by shape
|
|
14
|
+
* (aggregates, directives, queries…). A `capability()` declaration is one
|
|
15
|
+
* export holding a task aggregate + the five lifecycle directives as
|
|
16
|
+
* properties — invisible to those walks. This helper, applied at each plane's
|
|
17
|
+
* merge point (the engine lump's `mergeModules`, the package composer's merge,
|
|
18
|
+
* the compile CLI's merge), ADDS the bundle's pieces to the exports bag under
|
|
19
|
+
* synthetic names (`<export>$aggregate`, `<export>$order`, …) so every
|
|
20
|
+
* existing shape-walk discovers them with ZERO new walk semantics. The
|
|
21
|
+
* original bundle export stays (config-named lanes still resolve it); the
|
|
22
|
+
* walks ignore its unmatched shape exactly as before.
|
|
23
|
+
*
|
|
24
|
+
* ZERO imports on purpose: this file is bundled into the sealed engine lump
|
|
25
|
+
* (engine_entry.ts) — it must drag nothing with it.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/** Duck-type guard: a `capability()` return (the tag is set by the factory). */
|
|
29
|
+
export function isCapabilityDecl(v: unknown): v is Record<string, unknown> {
|
|
30
|
+
return (
|
|
31
|
+
typeof v === "object" &&
|
|
32
|
+
v !== null &&
|
|
33
|
+
(v as { __isCapabilityDecl?: boolean }).__isCapabilityDecl === true
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const PIECES = ["aggregate", "order", "complete", "fail", "block", "deadLetter", "tasks"] as const;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Expand every `capability()` bundle in an exports bag into discoverable
|
|
41
|
+
* top-level entries. Pure; returns the SAME object when nothing expands (the
|
|
42
|
+
* common case stays allocation-free and referentially stable).
|
|
43
|
+
*/
|
|
44
|
+
export function expandCapabilityExports<M extends Record<string, unknown>>(mod: M): M {
|
|
45
|
+
let out: Record<string, unknown> | null = null;
|
|
46
|
+
for (const [k, v] of Object.entries(mod)) {
|
|
47
|
+
if (!isCapabilityDecl(v)) continue;
|
|
48
|
+
out ??= { ...mod };
|
|
49
|
+
for (const piece of PIECES) {
|
|
50
|
+
const member = (v as Record<string, unknown>)[piece];
|
|
51
|
+
if (member !== undefined) out[`${k}$${piece}`] = member;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return (out ?? mod) as M;
|
|
55
|
+
}
|
package/src/codegen_dart.ts
CHANGED
|
@@ -2322,6 +2322,15 @@ export interface DomainModule {
|
|
|
2322
2322
|
domain?: string;
|
|
2323
2323
|
aggregates: AggregateHandle[];
|
|
2324
2324
|
directives: AnyDirective[];
|
|
2325
|
+
/**
|
|
2326
|
+
* STABLE-ID CONTINUITY (#58 — names are labels, identity is minted). When present
|
|
2327
|
+
* (attached by `nomos-compile` from the PRIOR build's identity manifests), the
|
|
2328
|
+
* canonical manifest's `stableIds` block carries these sids/lineages forward instead
|
|
2329
|
+
* of minting at first appearance — a renamed entity keeps its identity. Keyed by
|
|
2330
|
+
* CURRENT names (the compiler resolves renames BEFORE attaching). Absent ⇒ every
|
|
2331
|
+
* sid mints deterministically at first appearance.
|
|
2332
|
+
*/
|
|
2333
|
+
stableIdContinuity?: import("./stable_ids_types.js").StableIds;
|
|
2325
2334
|
/**
|
|
2326
2335
|
* The domain's NAMED, INDEXED read declarations (read-side closure step 1).
|
|
2327
2336
|
* ADDITIVE + OPTIONAL: a domain that declares no query omits this entirely and is
|
package/src/codegen_proof.ts
CHANGED
|
@@ -41,6 +41,7 @@ import type { Directive } from "./directive.js";
|
|
|
41
41
|
import type { DomainModule } from "./codegen_dart.js";
|
|
42
42
|
import type { QueryDecl } from "./query.js";
|
|
43
43
|
import { finishCount } from "./count.js";
|
|
44
|
+
import { mintedCreateField } from "./workspace_routing.js";
|
|
44
45
|
import {
|
|
45
46
|
autoStampFields,
|
|
46
47
|
tsClientFactoryName,
|
|
@@ -211,10 +212,21 @@ export function generateTsProof(modules: readonly DomainModule[], opts: TsProofO
|
|
|
211
212
|
}
|
|
212
213
|
const synth = synthesizePayload(createDir.payloadSchema as z.ZodTypeAny, `${domain}/${createDir.id}`);
|
|
213
214
|
|
|
215
|
+
// THE MINTED-ID RULE (the gate's `check_create_ids`): a `.creates` payload field
|
|
216
|
+
// that IS the target's own id must be KERNEL-MINTED — a hand-written sample id
|
|
217
|
+
// refuses typed at admission (`NotMinted`). The marker-driven trace names the
|
|
218
|
+
// field (never name-guessed); the generated proof MINTS it at runtime
|
|
219
|
+
// (`holon.mint`) instead of synthesizing a sample, so the proof admits
|
|
220
|
+
// everywhere the law does.
|
|
221
|
+
const mintField = mintedCreateField(createDir, agg);
|
|
222
|
+
const baseValue: Record<string, unknown> = { ...synth.value };
|
|
223
|
+
if (mintField !== undefined) delete baseValue[mintField];
|
|
224
|
+
|
|
214
225
|
// The first declared query that can READ BACK the create: returns the created
|
|
215
|
-
// aggregate and every key field has a synthesized payload value to probe with
|
|
226
|
+
// aggregate and every key field has a synthesized payload value to probe with
|
|
227
|
+
// (a query keyed on the MINTED field is skipped — its value exists only at runtime).
|
|
216
228
|
const query = ((mod.queries ?? []) as QueryDecl[]).find(
|
|
217
|
-
(q) => q.returns === agg.id && q.key.length > 0 && q.key.every((k) => !k.includes(".") &&
|
|
229
|
+
(q) => q.returns === agg.id && q.key.length > 0 && q.key.every((k) => !k.includes(".") && baseValue[k] !== undefined),
|
|
218
230
|
);
|
|
219
231
|
|
|
220
232
|
// The first declared count the create moves: counts the created aggregate,
|
|
@@ -226,7 +238,7 @@ export function generateTsProof(modules: readonly DomainModule[], opts: TsProofO
|
|
|
226
238
|
(c) =>
|
|
227
239
|
c.of === agg.id &&
|
|
228
240
|
(c as { where?: unknown }).where == null &&
|
|
229
|
-
(c.by == null ||
|
|
241
|
+
(c.by == null || baseValue[c.by] !== undefined),
|
|
230
242
|
);
|
|
231
243
|
|
|
232
244
|
const concurrency = findConcurrencyLeg(mod.directives as Directive<unknown>[], agg);
|
|
@@ -239,10 +251,27 @@ export function generateTsProof(modules: readonly DomainModule[], opts: TsProofO
|
|
|
239
251
|
.replace(/^-+|-+$/g, "")
|
|
240
252
|
.slice(0, 24) || "domain";
|
|
241
253
|
|
|
242
|
-
const payloadLit =
|
|
243
|
-
|
|
254
|
+
const payloadLit =
|
|
255
|
+
mintField !== undefined
|
|
256
|
+
? `{ ...${JSON.stringify(baseValue)}, ${JSON.stringify(mintField)}: __minted }`
|
|
257
|
+
: JSON.stringify(baseValue);
|
|
258
|
+
const queryParamsObj = query ? Object.fromEntries(query.key.map((k) => [k, baseValue[k]])) : undefined;
|
|
259
|
+
const queryParams = queryParamsObj ? JSON.stringify(queryParamsObj) : "";
|
|
244
260
|
const listAccessor = `list${agg.id}s`;
|
|
245
261
|
|
|
262
|
+
// THE MACHINE-READABLE LEGS (parsed by `githolon`'s offline proof runner —
|
|
263
|
+
// cli/src/proof_offline.ts — instead of regex-scraping the generated source).
|
|
264
|
+
const legsMarker = JSON.stringify({
|
|
265
|
+
domain,
|
|
266
|
+
directiveId: createDir.id,
|
|
267
|
+
aggregateId: agg.id,
|
|
268
|
+
payload: baseValue,
|
|
269
|
+
autoStamped: synth.autoStamped,
|
|
270
|
+
...(mintField !== undefined ? { mintField } : {}),
|
|
271
|
+
...(query && queryParamsObj ? { query: { id: query.id, params: queryParamsObj } } : {}),
|
|
272
|
+
...(count ? { count: { id: count.id, group: count.by != null ? String(baseValue[count.by]) : "" } } : {}),
|
|
273
|
+
});
|
|
274
|
+
|
|
246
275
|
let step = 0;
|
|
247
276
|
const n = () => ++step;
|
|
248
277
|
const out: string[] = [];
|
|
@@ -256,6 +285,7 @@ export function generateTsProof(modules: readonly DomainModule[], opts: TsProofO
|
|
|
256
285
|
`//`,
|
|
257
286
|
`// The flow mirrors the scaffold's test/e2e.mts (docs/ in a scaffolded app explains`,
|
|
258
287
|
`// every call — start at docs/01-mental-model.md). Regenerated on every compile; do not edit.`,
|
|
288
|
+
`// @nomos-proof-legs ${legsMarker}`,
|
|
259
289
|
`import { readFileSync } from "node:fs";`,
|
|
260
290
|
`import { connect } from "@githolon/client";`,
|
|
261
291
|
`import { ${factory}, ${hashConst} } from "./${opts.packageName}.client.ts";`,
|
|
@@ -266,18 +296,25 @@ export function generateTsProof(modules: readonly DomainModule[], opts: TsProofO
|
|
|
266
296
|
`// IDENTITY NOTE: this proof uses the bare x-nomos-principal lane so it is`,
|
|
267
297
|
`// SELF-CONTAINED (a throwaway workspace, no stored credentials). Real apps use`,
|
|
268
298
|
`// \`githolon login --agent\` (a VERIFIED identity) + \`githolon ws create/deploy\`.`,
|
|
269
|
-
`const fail: (m: string) => never = (m) => {
|
|
299
|
+
`const fail: (m: string) => never = (m) => { throw new Error(m); };`,
|
|
270
300
|
`const ok = (m: string) => console.log("✓ " + m);`,
|
|
271
301
|
``,
|
|
272
302
|
`const deploy = JSON.parse(readFileSync(new URL(${JSON.stringify(`./${opts.packageName}.deploy.json`)}, import.meta.url), "utf8"));`,
|
|
273
303
|
``,
|
|
304
|
+
`// CLEANUP CONTRACT: the throwaway workspace is RETIRED on every exit (green or`,
|
|
305
|
+
`// jammed) — a proof never leaves orphans. PROOF_KEEP=1 (githolon proof --live --keep)`,
|
|
306
|
+
`// keeps it and prints the FULL secret once, with the persist command.`,
|
|
307
|
+
`let SECRET = "";`,
|
|
308
|
+
`let runError: unknown = null;`,
|
|
309
|
+
`try {`,
|
|
310
|
+
``,
|
|
274
311
|
`// ${n()}. a throwaway workspace (the ONE-TIME secret comes back on create)`,
|
|
275
312
|
`let r = await fetch(\`\${CLOUD}/v1/workspaces/\${WS}\`, { method: "POST", headers: { "x-nomos-principal": "githolon-proof" } });`,
|
|
276
313
|
`let d = await r.json();`,
|
|
277
314
|
`if (!d.ok) fail(\`create workspace: \${JSON.stringify(d)}\`);`,
|
|
278
|
-
`
|
|
315
|
+
`SECRET = d.workspaceSecret;`,
|
|
279
316
|
`if (!SECRET?.startsWith("nws_v1_")) fail(\`no workspaceSecret returned: \${JSON.stringify(d)}\`);`,
|
|
280
|
-
`ok(\`workspace \${WS} created
|
|
317
|
+
`ok(\`workspace \${WS} created (one-time secret held for cleanup — PROOF_KEEP=1 keeps the workspace and prints it)\`);`,
|
|
281
318
|
``,
|
|
282
319
|
`// ${n()}. deploy YOUR compiled law (build/${opts.packageName}.deploy.json) WITH the secret`,
|
|
283
320
|
`r = await fetch(\`\${CLOUD}/v1/workspaces/\${WS}/domains\`, { method: "POST", headers: { "content-type": "application/json", authorization: \`Bearer \${SECRET}\` }, body: JSON.stringify(deploy) });`,
|
|
@@ -297,8 +334,16 @@ export function generateTsProof(modules: readonly DomainModule[], opts: TsProofO
|
|
|
297
334
|
`const realFetch = globalThis.fetch;`,
|
|
298
335
|
`globalThis.fetch = (() => { throw new Error("OFFLINE PROOF VIOLATED: local authoring touched the network"); }) as typeof fetch;`,
|
|
299
336
|
``,
|
|
337
|
+
...(mintField !== undefined
|
|
338
|
+
? [
|
|
339
|
+
`// the target's own id is KERNEL-MINTED (never hand-written — the gate's`,
|
|
340
|
+
`// check_create_ids refuses sample ids typed): the local wasm mints, the id`,
|
|
341
|
+
`// rides the payload, replay reads the capture.`,
|
|
342
|
+
`const __minted = await holon.mint(${JSON.stringify(agg.id)});`,
|
|
343
|
+
]
|
|
344
|
+
: []),
|
|
300
345
|
`await app.${createDir.id}(${payloadLit});`,
|
|
301
|
-
`ok("dispatch ${domain}/${createDir.id} — offline write under the pulled law (payload synthesized from YOUR schema)");`,
|
|
346
|
+
`ok("dispatch ${domain}/${createDir.id} — offline write under the pulled law (payload synthesized from YOUR schema${mintField !== undefined ? `; \`${mintField}\` kernel-minted` : ``})");`,
|
|
302
347
|
``,
|
|
303
348
|
);
|
|
304
349
|
|
|
@@ -326,7 +371,7 @@ export function generateTsProof(modules: readonly DomainModule[], opts: TsProofO
|
|
|
326
371
|
|
|
327
372
|
if (count) {
|
|
328
373
|
const accessor = lcFirst(camel(count.id));
|
|
329
|
-
const callArg = count.by != null ? JSON.stringify(String(
|
|
374
|
+
const callArg = count.by != null ? JSON.stringify(String(baseValue[count.by])) : "";
|
|
330
375
|
out.push(
|
|
331
376
|
`// ${n()}. the first declared count — the maintained O(1) tally, locally`,
|
|
332
377
|
`const localCount = await app.${accessor}(${callArg});`,
|
|
@@ -370,7 +415,7 @@ export function generateTsProof(modules: readonly DomainModule[], opts: TsProofO
|
|
|
370
415
|
if (count) {
|
|
371
416
|
out.push(
|
|
372
417
|
`// ${n()}. the EDGE maintains the same count (same wasm, same law)`,
|
|
373
|
-
`d = await (await fetch(\`\${CLOUD}/v1/workspaces/\${WS}/counts/${count.id}${count.by != null ? `?group=\${encodeURIComponent(${JSON.stringify(String(
|
|
418
|
+
`d = await (await fetch(\`\${CLOUD}/v1/workspaces/\${WS}/counts/${count.id}${count.by != null ? `?group=\${encodeURIComponent(${JSON.stringify(String(baseValue[count.by]))})}` : ``}\`)).json();`,
|
|
374
419
|
`if (!(d.ok && d.count === 1)) fail(\`cloud count ${count.id}: \${JSON.stringify(d)}\`);`,
|
|
375
420
|
`ok("cloud count ${count.id} = 1 — the O(1) maintained read, at the edge too");`,
|
|
376
421
|
``,
|
|
@@ -424,6 +469,22 @@ export function generateTsProof(modules: readonly DomainModule[], opts: TsProofO
|
|
|
424
469
|
``,
|
|
425
470
|
`console.log(\`\\nALL GREEN — generated proof for "${opts.packageName}": deploy → offline write → local reads → admission → cloud reads${concurrency ? ` → AddWins merge` : ``} → convergence (\${WS})\`);`,
|
|
426
471
|
``,
|
|
472
|
+
`} catch (e) {`,
|
|
473
|
+
` runError = e;`,
|
|
474
|
+
` console.error("✗ " + ((e as Error)?.message ?? e));`,
|
|
475
|
+
`} finally {`,
|
|
476
|
+
` // THE CLEANUP CONTRACT: never an orphaned cloud workspace. Retired on every`,
|
|
477
|
+
` // exit path; PROOF_KEEP=1 keeps it and prints the FULL secret exactly once.`,
|
|
478
|
+
` if (SECRET && process.env.PROOF_KEEP === "1") {`,
|
|
479
|
+
` console.log(\`workspace \${WS} KEPT — secret \${SECRET}\`);`,
|
|
480
|
+
` console.log(\` persist it: githolon secret set \${WS} <the secret above> (then: githolon ws retire \${WS} when done)\`);`,
|
|
481
|
+
` } else if (SECRET) {`,
|
|
482
|
+
` const rr = await fetch(\`\${CLOUD}/v1/workspaces/\${WS}/retire\`, { method: "POST", headers: { authorization: \`Bearer \${SECRET}\` } }).then((x) => x.json()).catch(() => ({}));`,
|
|
483
|
+
` console.log(\` retired \${WS}: \${(rr as { ok?: boolean }).ok === true}\`);`,
|
|
484
|
+
` }`,
|
|
485
|
+
` process.exit(runError ? 1 : 0);`,
|
|
486
|
+
`}`,
|
|
487
|
+
``,
|
|
427
488
|
);
|
|
428
489
|
|
|
429
490
|
return out.join("\n");
|