@pbuilder/sdk 0.17.0 → 0.18.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 (45) hide show
  1. package/README.md +26 -3
  2. package/dist/bin/pbuilder-conformance.d.ts +2 -0
  3. package/dist/bin/pbuilder-conformance.js +26 -0
  4. package/dist/bounded-contexts/authoring/application/usecases/run-factory/context.d.ts +7 -1
  5. package/dist/bounded-contexts/authoring/application/usecases/run-factory/context.js +2 -1
  6. package/dist/bounded-contexts/authoring/application/usecases/scaffold/expander.js +4 -4
  7. package/dist/bounded-contexts/authoring/domain/aggregates/session/session.d.ts +1 -0
  8. package/dist/bounded-contexts/authoring/domain/aggregates/session/session.js +54 -4
  9. package/dist/bounded-contexts/authoring/domain/entities/dialect-handle.d.ts +2 -1
  10. package/dist/bounded-contexts/authoring/domain/entities/dialect-handle.js +108 -30
  11. package/dist/bounded-contexts/authoring/domain/services/define-dialect.d.ts +48 -10
  12. package/dist/bounded-contexts/authoring/domain/services/define-dialect.js +37 -9
  13. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/angular/index.js +2 -2
  14. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/aspnet/index.d.ts +8 -5
  15. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/aspnet/index.js +7 -4
  16. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/aspnet/ops.d.ts +1 -1
  17. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/aspnet/ops.js +20 -7
  18. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/msbuild/index.d.ts +20 -2
  19. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/msbuild/index.js +19 -3
  20. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/msbuild/ops.d.ts +5 -0
  21. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/msbuild/ops.js +89 -20
  22. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/nestjs/index.js +2 -2
  23. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/ast.d.ts +2 -0
  24. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/ast.js +4 -0
  25. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/index.js +3 -3
  26. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/typescript/ast.d.ts +2 -0
  27. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/typescript/ast.js +4 -0
  28. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/typescript/index.js +2 -2
  29. package/dist/bounded-contexts/authoring/testing/conformance/index.d.ts +10 -12
  30. package/dist/bounded-contexts/authoring/testing/conformance/index.js +17 -2
  31. package/dist/bounded-contexts/authoring/testing/conformance/run-package.d.ts +20 -0
  32. package/dist/bounded-contexts/authoring/testing/conformance/run-package.js +129 -0
  33. package/dist/bounded-contexts/authoring/testing/harness/index.d.ts +3 -0
  34. package/dist/bounded-contexts/authoring/testing/harness/index.js +5 -1
  35. package/dist/bounded-contexts/runner-hosting/infrastructure/in/bootstrap-bridge.d.ts +3 -0
  36. package/dist/bounded-contexts/runner-hosting/infrastructure/in/bootstrap-bridge.js +2 -0
  37. package/dist/bounded-contexts/runner-hosting/infrastructure/in/runner.js +42 -3
  38. package/dist/bounded-contexts/runner-hosting/infrastructure/in/single-instance-probe.d.ts +13 -0
  39. package/dist/bounded-contexts/runner-hosting/infrastructure/in/single-instance-probe.js +25 -1
  40. package/dist/conformance/index.d.ts +1 -0
  41. package/dist/conformance/index.js +1 -0
  42. package/dist/dialect/index.d.ts +2 -0
  43. package/dist/dialect/index.js +3 -0
  44. package/dist/runner-manifest.json +6 -6
  45. package/package.json +8 -2
@@ -61,7 +61,7 @@ async function runExercise(dialect, exercise, opts) {
61
61
  }
62
62
  }
63
63
  await handle;
64
- });
64
+ }, { declaredDialects: dialect.name === undefined ? [] : [dialect.name] });
65
65
  await runner(undefined, { client });
66
66
  const directives = emitted.flatMap((b) => b.instructions);
67
67
  const modifies = directives
@@ -150,6 +150,19 @@ function runRoundTripProbe(dialectAst, samples, label) {
150
150
  * Requires runtime library exports matching independent adapter evidence, then exercises
151
151
  * the actual module's `find().modify()` through a real run with byte-exact emitted output.
152
152
  */
153
+ function probeStaleNode(ast, staleNode) {
154
+ const old = ast.parse(staleNode.seed);
155
+ const node = staleNode.keep(old);
156
+ ast.parse(staleNode.seed);
157
+ ast.retire?.(old);
158
+ try {
159
+ staleNode.use(node);
160
+ }
161
+ catch {
162
+ return;
163
+ }
164
+ throw new Error("testDialect: A-11 stale node — a node kept from before a re-parse is still usable; give the dialect's ast a retire(ast) that makes the old tree's nodes fail");
165
+ }
153
166
  export async function testDialect(fixture) {
154
167
  const module = fixture.module;
155
168
  if (!module || typeof module.find !== "function") {
@@ -170,6 +183,8 @@ export async function testDialect(fixture) {
170
183
  }
171
184
  const samples = [...fixture.samples, ...mandatoryAdversarialSamples(fixture.libraryExercise.seed)];
172
185
  runRoundTripProbe(fixture.dialect.ast, samples, "testDialect");
186
+ if (fixture.staleNode !== undefined)
187
+ probeStaleNode(fixture.dialect.ast, fixture.staleNode);
173
188
  const exercise = fixture.libraryExercise;
174
189
  const { client, emitted } = createRunVehicle({ [exercise.path]: exercise.seed });
175
190
  // A-11: `find` must reject an extension the dialect does not declare. Probed inside the run,
@@ -184,7 +199,7 @@ export async function testDialect(fixture) {
184
199
  acceptedUndeclared = false;
185
200
  }
186
201
  await module.find(exercise.path).modify((ast) => exercise.modify(ast, module.astLibrary));
187
- });
202
+ }, { declaredDialects: fixture.dialect.name === undefined ? [] : [fixture.dialect.name] });
188
203
  await run(undefined, { client });
189
204
  if (acceptedUndeclared) {
190
205
  throw new Error(`testDialect: find accepted "${undeclaredPath}", an undeclared extension (A-11)`);
@@ -0,0 +1,20 @@
1
+ export interface ConformanceFailure {
2
+ case: string;
3
+ reason: string;
4
+ }
5
+ export interface ConformanceReport {
6
+ passed: boolean;
7
+ dialect: string;
8
+ version: string;
9
+ failures: ConformanceFailure[];
10
+ }
11
+ /**
12
+ * Loads the fixture of the dialect package in `dir` and runs it. Throws only when the fixture
13
+ * cannot run: the package.json is unreadable or has no name, or a module the fixture imports
14
+ * cannot be resolved. Every finding about the dialect is a failure in the report.
15
+ *
16
+ * @example
17
+ * const report = await checkDialectPackage("/cache/npm/@company/ini-dialect/1.0.0/package");
18
+ * if (!report.passed) console.log(report.failures.map((failure) => failure.case));
19
+ */
20
+ export declare function checkDialectPackage(dir: string): Promise<ConformanceReport>;
@@ -0,0 +1,129 @@
1
+ // CA-13 / A-16: runs the conformance fixture a dialect package ships as `<pkg>/conformance`. The
2
+ // report names each broken check by a fixed case and reason, never by the fixture's own message,
3
+ // which may carry the author's samples or the text of an error their code threw (A-87).
4
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
5
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
6
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
7
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
8
+ });
9
+ }
10
+ return path;
11
+ };
12
+ import { readFileSync } from "node:fs";
13
+ import { isAbsolute, join, relative, resolve } from "node:path";
14
+ import { pathToFileURL } from "node:url";
15
+ import { testDialect } from "./index.js";
16
+ const FIXTURE_MISSING = {
17
+ case: "fixture_missing",
18
+ reason: "CA-13: the package exports no ./conformance fixture",
19
+ };
20
+ const FIXTURE_INVALID = {
21
+ case: "fixture_invalid",
22
+ reason: "CA-13: the default export of ./conformance is not a DialectFixture",
23
+ };
24
+ const NAME_MISMATCH = {
25
+ case: "name_mismatch",
26
+ reason: "A-16: the dialect's name is not the name of its package",
27
+ };
28
+ // Matched against testDialect's own message text, first match wins.
29
+ const CHECKS = [
30
+ ["REQ-DC-08", { case: "real_parse", reason: "A-11: parse must return an AST distinct from the source" }],
31
+ ["REQ-DC-01", { case: "round_trip", reason: "A-11: print(parse(source)) must give back the source byte for byte" }],
32
+ ["stale node", { case: "stale_node", reason: "A-11: a node kept from before a re-parse must fail when used" }],
33
+ ["undeclared extension", { case: "undeclared_extension", reason: "A-11: find must reject an extension the dialect does not declare" }],
34
+ ["library exercise", { case: "library_exercise", reason: "A-11: the library exercise must emit exactly the expected modify" }],
35
+ ["testDialect: module must", { case: "module_shape", reason: "A-11: the module must expose a callable find and its runtime astLibrary" }],
36
+ ["expectedAstLibrary", { case: "module_shape", reason: "A-11: the module must expose a callable find and its runtime astLibrary" }],
37
+ ["astLibrary runtime library mismatch", { case: "module_shape", reason: "A-11: the module's astLibrary must be the adapter's own library" }],
38
+ ];
39
+ const FIXTURE_THREW = { case: "fixture_threw", reason: "A-11: the fixture's own code threw while it ran" };
40
+ function classify(err) {
41
+ const message = err instanceof Error ? err.message : "";
42
+ return CHECKS.find(([marker]) => message.includes(marker))?.[1] ?? FIXTURE_THREW;
43
+ }
44
+ function conformanceTarget(exports) {
45
+ if (typeof exports !== "object" || exports === null)
46
+ return undefined;
47
+ const entry = exports["./conformance"];
48
+ if (typeof entry === "string")
49
+ return entry;
50
+ if (typeof entry !== "object" || entry === null)
51
+ return undefined;
52
+ const conditions = entry;
53
+ const target = conditions.bun ?? conditions.import ?? conditions.default;
54
+ return typeof target === "string" ? target : undefined;
55
+ }
56
+ // A resolution failure says the install is incomplete, not that the dialect is wrong.
57
+ function isUnresolvedModule(err) {
58
+ if (typeof err !== "object" || err === null)
59
+ return false;
60
+ const { code, name, message } = err;
61
+ return (code === "ERR_MODULE_NOT_FOUND" ||
62
+ name === "ResolveMessage" ||
63
+ (typeof message === "string" && /Cannot find (module|package)/.test(message)));
64
+ }
65
+ function isInside(dir, file) {
66
+ const path = relative(dir, file);
67
+ return path !== "" && !path.startsWith("..") && !isAbsolute(path);
68
+ }
69
+ function isFixture(value) {
70
+ if (typeof value !== "object" || value === null)
71
+ return false;
72
+ const fixture = value;
73
+ return typeof fixture.dialect === "object" && fixture.dialect !== null && Array.isArray(fixture.samples);
74
+ }
75
+ /**
76
+ * Loads the fixture of the dialect package in `dir` and runs it. Throws only when the fixture
77
+ * cannot run: the package.json is unreadable or has no name, or a module the fixture imports
78
+ * cannot be resolved. Every finding about the dialect is a failure in the report.
79
+ *
80
+ * @example
81
+ * const report = await checkDialectPackage("/cache/npm/@company/ini-dialect/1.0.0/package");
82
+ * if (!report.passed) console.log(report.failures.map((failure) => failure.case));
83
+ */
84
+ export async function checkDialectPackage(dir) {
85
+ const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf-8"));
86
+ if (typeof pkg.name !== "string" || pkg.name.length === 0) {
87
+ throw new Error(`pbuilder-conformance: the package.json in --dialect has no name`);
88
+ }
89
+ const report = {
90
+ passed: false,
91
+ dialect: pkg.name,
92
+ version: typeof pkg.version === "string" ? pkg.version : "",
93
+ failures: [],
94
+ };
95
+ const target = conformanceTarget(pkg.exports);
96
+ if (target === undefined) {
97
+ report.failures.push(FIXTURE_MISSING);
98
+ return report;
99
+ }
100
+ const file = resolve(dir, target);
101
+ if (!isInside(dir, file)) {
102
+ report.failures.push(FIXTURE_INVALID);
103
+ return report;
104
+ }
105
+ let fixture;
106
+ try {
107
+ fixture = (await import(__rewriteRelativeImportExtension(pathToFileURL(file).href))).default;
108
+ }
109
+ catch (err) {
110
+ if (isUnresolvedModule(err))
111
+ throw new Error("pbuilder-conformance: a module the fixture imports could not be resolved");
112
+ report.failures.push(FIXTURE_THREW);
113
+ return report;
114
+ }
115
+ if (!isFixture(fixture)) {
116
+ report.failures.push(FIXTURE_INVALID);
117
+ return report;
118
+ }
119
+ if (fixture.dialect.name !== pkg.name)
120
+ report.failures.push(NAME_MISMATCH);
121
+ try {
122
+ await testDialect(fixture);
123
+ }
124
+ catch (err) {
125
+ report.failures.push(classify(err));
126
+ }
127
+ report.passed = report.failures.length === 0;
128
+ return report;
129
+ }
@@ -57,6 +57,8 @@ export type { Batch, Directive };
57
57
  * against an adjacent `schema.json` (pass `import.meta.dir`, never `import.meta.url`); when
58
58
  * absent the run is the untyped, unvalidated tier, byte-identical to a run with no
59
59
  * `packageDir` at all.
60
+ * @param options.declaredDialects - the names of the author-defined dialects the schematic's
61
+ * library declares in its Manifest; a handle of any other named dialect fails the run (A-16).
60
62
  *
61
63
  * @example
62
64
  * import { runFactoryForTest } from "@pbuilder/sdk/testing";
@@ -86,4 +88,5 @@ export type { Batch, Directive };
86
88
  export declare function runFactoryForTest<O>(fn: (input: O) => void | Promise<void>, input: O, options?: {
87
89
  seed?: Record<string, string>;
88
90
  packageDir?: string | URL;
91
+ declaredDialects?: readonly string[];
89
92
  }): Promise<RunResult>;
@@ -27,6 +27,8 @@ import { nodePackageFiles } from "../../infrastructure/out/fs/package-files.js";
27
27
  * against an adjacent `schema.json` (pass `import.meta.dir`, never `import.meta.url`); when
28
28
  * absent the run is the untyped, unvalidated tier, byte-identical to a run with no
29
29
  * `packageDir` at all.
30
+ * @param options.declaredDialects - the names of the author-defined dialects the schematic's
31
+ * library declares in its Manifest; a handle of any other named dialect fails the run (A-16).
30
32
  *
31
33
  * @example
32
34
  * import { runFactoryForTest } from "@pbuilder/sdk/testing";
@@ -73,7 +75,9 @@ export async function runFactoryForTest(fn, input, options) {
73
75
  return fake.discard();
74
76
  },
75
77
  };
76
- const run = defineFactory(fn, options?.packageDir !== undefined ? { packageDir: options.packageDir, packageFiles: nodePackageFiles } : undefined);
78
+ const run = defineFactory(fn, options?.packageDir !== undefined
79
+ ? { packageDir: options.packageDir, packageFiles: nodePackageFiles, declaredDialects: options.declaredDialects }
80
+ : { declaredDialects: options?.declaredDialects });
77
81
  let error;
78
82
  try {
79
83
  await run(input, { client });
@@ -1,3 +1,4 @@
1
+ import type { DeclaredDialect } from "./single-instance-probe.ts";
1
2
  import { type RunnerIo } from "./runner.ts";
2
3
  export declare class BridgeVersionMismatchError extends Error {
3
4
  constructor(expected: number, actual: number);
@@ -12,6 +13,8 @@ export type BridgeInput = {
12
13
  export interface BridgeParams {
13
14
  factory: string;
14
15
  input: BridgeInput;
16
+ /** The Frame's declared dialects (A-16, CA-5); absent means none. */
17
+ dialects?: readonly DeclaredDialect[];
15
18
  }
16
19
  export interface BridgeIo {
17
20
  input: RunnerIo["input"];
@@ -44,6 +44,8 @@ function toArgv(params) {
44
44
  argv.push("--input", params.input.json);
45
45
  else
46
46
  argv.push("--input-file", params.input.path);
47
+ if (params.dialects !== undefined)
48
+ argv.push("--dialects", JSON.stringify(params.dialects));
47
49
  return argv;
48
50
  }
49
51
  /**
@@ -30,7 +30,7 @@ import { WIRE_PROTOCOL_VERSION, isStructurallyValidGreeting, versionMatches } fr
30
30
  import { StdioEngineClient, TransportFault, IntentRejectedError, OverlappingRunError, } from "../../../../acl/irwire/stdio-engine-client.js";
31
31
  import { boundMessage, composeWithToken, scrubAbsolutePaths, toProjectRelativePath } from "../../../../platform/error-text.js";
32
32
  import { parseFactoryPointer, validateFactoryUrl, resolveFactoryExport } from "./factory-pointer.js";
33
- import { probeSingleInstance } from "./single-instance-probe.js";
33
+ import { probeDeclaredDialects, probeSingleInstance } from "./single-instance-probe.js";
34
34
  import { classifyExitCode } from "./exit-codes.js";
35
35
  import { nodePackageFiles } from "../../../authoring/infrastructure/out/fs/package-files.js";
36
36
  /** The greeting's own bound: the client's per-call timeout only exists once the greeting is in. */
@@ -42,12 +42,35 @@ export const INPUT_FILE_SIZE_CAP_BYTES = 10 * 1024 * 1024; // 10 MiB
42
42
  function note(io, text) {
43
43
  io.writeStderr(`${boundMessage(text)}\n`);
44
44
  }
45
+ const DIALECTS_SHAPE = "pbuilder-runner: --dialects must be a JSON array of {name, version, root} strings";
46
+ // A-16 / CA-5: the dialects the Frame's library declares, as the engine read them from the Lock.
47
+ // The value is never echoed: it holds absolute paths.
48
+ function parseDialects(value) {
49
+ let parsed;
50
+ try {
51
+ parsed = JSON.parse(value);
52
+ }
53
+ catch {
54
+ return undefined;
55
+ }
56
+ if (!Array.isArray(parsed))
57
+ return undefined;
58
+ const isEntry = (entry) => typeof entry === "object" &&
59
+ entry !== null &&
60
+ ["name", "version", "root"].every((key) => {
61
+ const field = entry[key];
62
+ return typeof field === "string" && field !== "";
63
+ });
64
+ return parsed.every(isEntry) ? parsed.map(({ name, version, root }) => ({ name, version, root })) : undefined;
65
+ }
45
66
  // REQ-RUN-01: `--factory <url>#<export>` required; exactly one of `--input <json>` XOR
46
- // `--input-file <path>`; any unrecognized flag fails closed.
67
+ // `--input-file <path>`; `--dialects <json>` optional, absent meaning none declared; any
68
+ // unrecognized flag fails closed.
47
69
  function parseArgv(argv) {
48
70
  let factory;
49
71
  let inputJson;
50
72
  let inputFile;
73
+ let dialects = [];
51
74
  for (let i = 0; i < argv.length; i += 2) {
52
75
  const flag = argv[i];
53
76
  const value = argv[i + 1];
@@ -60,6 +83,12 @@ function parseArgv(argv) {
60
83
  inputJson = value;
61
84
  else if (flag === "--input-file")
62
85
  inputFile = value;
86
+ else if (flag === "--dialects") {
87
+ const declared = parseDialects(value);
88
+ if (declared === undefined)
89
+ return { error: DIALECTS_SHAPE };
90
+ dialects = declared;
91
+ }
63
92
  else
64
93
  return { error: composeWithToken("pbuilder-runner: unrecognized flag ", flag) };
65
94
  }
@@ -73,6 +102,7 @@ function parseArgv(argv) {
73
102
  }
74
103
  return {
75
104
  factory,
105
+ dialects,
76
106
  input: inputJson !== undefined ? { kind: "inline", json: inputJson } : { kind: "file", path: inputFile },
77
107
  };
78
108
  }
@@ -262,6 +292,11 @@ async function runRunnerBody(argv, io, opened) {
262
292
  note(io, `pbuilder-runner: ${probe.message}`);
263
293
  return 1;
264
294
  }
295
+ const dialectProbe = probeDeclaredDialects(moduleUrl, parsed.dialects);
296
+ if (!dialectProbe.ok) {
297
+ note(io, `pbuilder-runner: ${dialectProbe.message}`);
298
+ return 1;
299
+ }
265
300
  let moduleNamespace;
266
301
  try {
267
302
  // SANCTIONED-FACTORY-IMPORT — the ONE dynamic import() Constraint 2 permits in the runner
@@ -299,7 +334,11 @@ async function runRunnerBody(argv, io, opened) {
299
334
  // the factory's own directory — schema-derived validation and reserved-name checks apply
300
335
  // identically on both vehicles.
301
336
  const packageDir = dirname(fileURLToPath(new URL(moduleUrl)));
302
- const run = defineFactory(exportResolution.fn, { packageDir, packageFiles: nodePackageFiles });
337
+ const run = defineFactory(exportResolution.fn, {
338
+ packageDir,
339
+ packageFiles: nodePackageFiles,
340
+ declaredDialects: parsed.dialects.map(({ name }) => name),
341
+ });
303
342
  const channel = {
304
343
  write: io.writeFrame,
305
344
  writeStderr: io.writeStderr,
@@ -21,3 +21,16 @@ export type SingleInstanceProbeResult = {
21
21
  * with the REAL default resolver in the split/unresolvable test cases.
22
22
  */
23
23
  export declare function probeSingleInstance(factoryUrl: string, resolveSpecifier?: (specifier: string, anchorUrl: string) => string): SingleInstanceProbeResult;
24
+ /** One dialect the Frame's library declares, with the root of the copy the Lock pins (CA-5). */
25
+ export interface DeclaredDialect {
26
+ name: string;
27
+ version: string;
28
+ root: string;
29
+ }
30
+ /**
31
+ * A-16 / A-4: before the factory starts, resolves each declared dialect's name from the factory's
32
+ * location, the same resolution its own `import` gets, and requires the real path inside the copy
33
+ * the Lock pins. It keeps the dialect that runs the pinned one; it is no security boundary.
34
+ * Resolution-only, like `probeSingleInstance`; an unresolvable name fails the same way.
35
+ */
36
+ export declare function probeDeclaredDialects(factoryUrl: string, dialects: readonly DeclaredDialect[], resolveSpecifier?: (specifier: string, anchorUrl: string) => string): SingleInstanceProbeResult;
@@ -30,7 +30,7 @@
30
30
  import { existsSync, realpathSync } from "node:fs";
31
31
  import { createRequire } from "node:module";
32
32
  import { fileURLToPath } from "node:url";
33
- import { dirname, join } from "node:path";
33
+ import { dirname, isAbsolute, join, relative } from "node:path";
34
34
  import { toProjectRelativePath } from "../../../../platform/error-text.js";
35
35
  const SDK_SPECIFIER = "@pbuilder/sdk";
36
36
  // Resolution-only: never `import()`s the target, only locates it.
@@ -117,3 +117,27 @@ export function probeSingleInstance(factoryUrl, resolveSpecifier = resolveSpecif
117
117
  return { ok: true };
118
118
  return { ok: false, message: splitMessage(runnerRoot, factoryRoot) };
119
119
  }
120
+ function resolvesInside(name, root, factoryUrl, resolveSpecifier) {
121
+ try {
122
+ const path = relative(realpathSync(root), realpathSync(resolveSpecifier(name, factoryUrl)));
123
+ return path !== "" && !path.startsWith("..") && !isAbsolute(path);
124
+ }
125
+ catch {
126
+ return false;
127
+ }
128
+ }
129
+ /**
130
+ * A-16 / A-4: before the factory starts, resolves each declared dialect's name from the factory's
131
+ * location, the same resolution its own `import` gets, and requires the real path inside the copy
132
+ * the Lock pins. It keeps the dialect that runs the pinned one; it is no security boundary.
133
+ * Resolution-only, like `probeSingleInstance`; an unresolvable name fails the same way.
134
+ */
135
+ export function probeDeclaredDialects(factoryUrl, dialects, resolveSpecifier = resolveSpecifierPath) {
136
+ const outside = dialects.find(({ name, root }) => !resolvesInside(name, root, factoryUrl, resolveSpecifier));
137
+ if (outside === undefined)
138
+ return { ok: true };
139
+ return {
140
+ ok: false,
141
+ message: `the factory does not start because the dialect "${outside.name}" resolves outside the package the Lock pins`,
142
+ };
143
+ }
@@ -1 +1,2 @@
1
1
  export * from "../bounded-contexts/authoring/testing/conformance/index.ts";
2
+ export { checkDialectPackage, type ConformanceFailure, type ConformanceReport, } from "../bounded-contexts/authoring/testing/conformance/run-package.ts";
@@ -1 +1,2 @@
1
1
  export * from "../bounded-contexts/authoring/testing/conformance/index.js";
2
+ export { checkDialectPackage, } from "../bounded-contexts/authoring/testing/conformance/run-package.js";
@@ -0,0 +1,2 @@
1
+ export { defineAuthorDialect as defineDialect, defineOpPack, withOps, withoutOps, overrideOps, byExtension, query, } from "../bounded-contexts/authoring/domain/services/define-dialect.ts";
2
+ export type { Dialect, DialectAst, DialectDescriptor, ExtensionRouter, Handle, Op, OpPack, Query, } from "../bounded-contexts/authoring/domain/services/define-dialect.ts";
@@ -0,0 +1,3 @@
1
+ // The author-facing dialect kit (A-16): the one part of the core kit that leaves the ADR-0009
2
+ // boundary, so an author can build, compose and route a Dialect of their own.
3
+ export { defineAuthorDialect as defineDialect, defineOpPack, withOps, withoutOps, overrideOps, byExtension, query, } from "../bounded-contexts/authoring/domain/services/define-dialect.js";
@@ -2,7 +2,7 @@
2
2
  "manifestVersion": 1,
3
3
  "algorithm": "sha256",
4
4
  "entry": "dist/bin/pbuilder-runner.js",
5
- "packageVersion": "0.17.0",
5
+ "packageVersion": "0.18.0",
6
6
  "files": [
7
7
  {
8
8
  "path": "dist/acl/irwire/frame-reader.js",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  {
20
20
  "path": "dist/bounded-contexts/authoring/application/usecases/run-factory/context.js",
21
- "sha256": "cbc476d322490393fb20524017748ec2392c30b3f19208c07f0dbc80e04c5903"
21
+ "sha256": "363592971cf1d5869c7dd8eab70771bc2e7c91cde323a914f18853f674f38d72"
22
22
  },
23
23
  {
24
24
  "path": "dist/bounded-contexts/authoring/application/usecases/run-factory/driving.js",
@@ -26,7 +26,7 @@
26
26
  },
27
27
  {
28
28
  "path": "dist/bounded-contexts/authoring/domain/aggregates/session/session.js",
29
- "sha256": "6d38cebbed54516ad508eb096e7248a53da911e5b1dbad9e7118d93541712cf2"
29
+ "sha256": "69a87a7bc1ce590ad62fde300e1a8037f51ed53a249f337038fe638730327a5c"
30
30
  },
31
31
  {
32
32
  "path": "dist/bounded-contexts/authoring/domain/ports/emit-rejection.js",
@@ -94,11 +94,11 @@
94
94
  },
95
95
  {
96
96
  "path": "dist/bounded-contexts/runner-hosting/infrastructure/in/runner.js",
97
- "sha256": "7cbd24c7cd55f307ed6a99281973a67d964f2ed56890422a17477a1e2f80ce73"
97
+ "sha256": "07124a37f04a2062349b1f9e404ece9cc146d84e47669be08ece8ff86a85b0c3"
98
98
  },
99
99
  {
100
100
  "path": "dist/bounded-contexts/runner-hosting/infrastructure/in/single-instance-probe.js",
101
- "sha256": "345639841efda1cb206951bc8c6c251bc0d5c17451d22a22210cc8e80dff06b5"
101
+ "sha256": "7d3faa7c91cdbbe3f1d3fe7f375b69f638153dce71bb69c3f884d3d1f815d85b"
102
102
  },
103
103
  {
104
104
  "path": "dist/platform/error-text.js",
@@ -122,7 +122,7 @@
122
122
  },
123
123
  {
124
124
  "path": "package.json",
125
- "sha256": "3eb04bed3bfdd43ea2f25b0c13267688c052056eddc410ec6cfc0b7f0f7df927"
125
+ "sha256": "ab6875d331619b35f4778ce07e9611a90a868d2350688bb54ffc467e01965ae6"
126
126
  }
127
127
  ]
128
128
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pbuilder/sdk",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "The public TypeScript/Bun authoring layer for Project Builder schematics. Authors file mutations (create, replaceContent, remove, rename, move, copy, copyIn), lowers them to IR, and talks to the Project Builder engine over framed stdio (see docs/engine-sdk-wire-spec.md).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -34,7 +34,8 @@
34
34
  "schemas"
35
35
  ],
36
36
  "bin": {
37
- "pbuilder-codegen": "dist/bin/pbuilder-codegen.js"
37
+ "pbuilder-codegen": "dist/bin/pbuilder-codegen.js",
38
+ "pbuilder-conformance": "dist/bin/pbuilder-conformance.js"
38
39
  },
39
40
  "main": "./dist/index.js",
40
41
  "exports": {
@@ -53,6 +54,11 @@
53
54
  "import": "./dist/conformance/index.js",
54
55
  "default": "./dist/conformance/index.js"
55
56
  },
57
+ "./dialect": {
58
+ "types": "./dist/dialect/index.d.ts",
59
+ "import": "./dist/dialect/index.js",
60
+ "default": "./dist/dialect/index.js"
61
+ },
56
62
  "./testing": {
57
63
  "types": "./dist/testing/index.d.ts",
58
64
  "import": "./dist/testing/index.js",