behavior-contracts 0.8.7 → 0.8.9

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 (52) hide show
  1. package/cli-contract.yaml +189 -0
  2. package/dist/behavior.d.ts +12 -0
  3. package/dist/behavior.d.ts.map +1 -1
  4. package/dist/behavior.js +60 -41
  5. package/dist/behavior.js.map +1 -1
  6. package/dist/cli.d.ts +3 -0
  7. package/dist/cli.d.ts.map +1 -0
  8. package/dist/cli.js +76 -0
  9. package/dist/cli.js.map +1 -0
  10. package/dist/commands/codegen.d.ts +6 -0
  11. package/dist/commands/codegen.d.ts.map +1 -0
  12. package/dist/commands/codegen.js +39 -0
  13. package/dist/commands/codegen.js.map +1 -0
  14. package/dist/generated/commands.d.ts +8 -0
  15. package/dist/generated/commands.d.ts.map +1 -0
  16. package/dist/generated/commands.js +55 -0
  17. package/dist/generated/commands.js.map +1 -0
  18. package/dist/generated/contract.d.ts +3 -0
  19. package/dist/generated/contract.d.ts.map +1 -0
  20. package/dist/generated/contract.js +5 -0
  21. package/dist/generated/contract.js.map +1 -0
  22. package/dist/generated/index.d.ts +7 -0
  23. package/dist/generated/index.d.ts.map +1 -0
  24. package/dist/generated/index.js +7 -0
  25. package/dist/generated/index.js.map +1 -0
  26. package/dist/generated/program.d.ts +17 -0
  27. package/dist/generated/program.d.ts.map +1 -0
  28. package/dist/generated/program.js +117 -0
  29. package/dist/generated/program.js.map +1 -0
  30. package/dist/generated/schemas.d.ts +2 -0
  31. package/dist/generated/schemas.d.ts.map +1 -0
  32. package/dist/generated/schemas.js +3 -0
  33. package/dist/generated/schemas.js.map +1 -0
  34. package/dist/generated/types.d.ts +35 -0
  35. package/dist/generated/types.d.ts.map +1 -0
  36. package/dist/generated/types.js +3 -0
  37. package/dist/generated/types.js.map +1 -0
  38. package/dist/generator/core.d.ts.map +1 -1
  39. package/dist/generator/core.js +6 -0
  40. package/dist/generator/core.js.map +1 -1
  41. package/dist/generator/emit-shared-typescript.d.ts.map +1 -1
  42. package/dist/generator/emit-shared-typescript.js +37 -4
  43. package/dist/generator/emit-shared-typescript.js.map +1 -1
  44. package/dist/generator/typed.d.ts +4 -2
  45. package/dist/generator/typed.d.ts.map +1 -1
  46. package/dist/generator/typed.js +4 -2
  47. package/dist/generator/typed.js.map +1 -1
  48. package/dist/index.d.ts +1 -1
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +1 -1
  51. package/dist/index.js.map +1 -1
  52. package/package.json +12 -2
@@ -0,0 +1,39 @@
1
+ // ════════════════════════════════════════════════════════════════════════════
2
+ // codegen — the pure core behind `bc generate` / `bc check`.
3
+ //
4
+ // A thin wrapper over the EXISTING public API (../index.ts): NO emit logic is
5
+ // reimplemented here. `generateFromDoc` runs the SAME `loadCompiledIR` →
6
+ // `generateModule` path the in-process API runs, so the CLI emits the exact
7
+ // module the in-process API does from the same doc.
8
+ //
9
+ // Pure (throws on error, no process/stream side effects) so it is unit-testable
10
+ // in-process; the cli.ts handlers add I/O + exit semantics around it.
11
+ // ════════════════════════════════════════════════════════════════════════════
12
+ import { readFileSync } from "node:fs";
13
+ import { loadCompiledIR, generateModule, registeredLanguages, } from "../index.js";
14
+ /** A serialized IR doc → the native module source (same path as the in-process API). */
15
+ export function generateFromDoc(doc, language, runtimeImport) {
16
+ if (!registeredLanguages().includes(language)) {
17
+ throw new Error(`--lang '${language}' is not a registered emitter (registered: ${registeredLanguages().join(", ")})`);
18
+ }
19
+ const compiled = loadCompiledIR(doc); // adopt the unbranded doc (recomputes + mints the provenance token)
20
+ const module = generateModule(compiled, runtimeImport === undefined ? { language } : { language, runtimeImport });
21
+ return module.code;
22
+ }
23
+ /** Read + parse a serialized ComponentGraphIRDoc from disk. */
24
+ export function readDoc(inPath) {
25
+ let raw;
26
+ try {
27
+ raw = readFileSync(inPath, "utf8");
28
+ }
29
+ catch {
30
+ throw new Error(`cannot read --in '${inPath}'`);
31
+ }
32
+ try {
33
+ return JSON.parse(raw);
34
+ }
35
+ catch (e) {
36
+ throw new Error(`--in '${inPath}' is not valid JSON: ${e instanceof Error ? e.message : String(e)}`);
37
+ }
38
+ }
39
+ //# sourceMappingURL=codegen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../src/commands/codegen.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,6DAA6D;AAC7D,EAAE;AACF,8EAA8E;AAC9E,yEAAyE;AACzE,4EAA4E;AAC5E,oDAAoD;AACpD,EAAE;AACF,gFAAgF;AAChF,sEAAsE;AACtE,+EAA+E;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EACL,cAAc,EACd,cAAc,EACd,mBAAmB,GAEpB,MAAM,aAAa,CAAC;AAErB,wFAAwF;AACxF,MAAM,UAAU,eAAe,CAC7B,GAAwB,EACxB,QAAgB,EAChB,aAAsB;IAEtB,IAAI,CAAC,mBAAmB,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CACb,WAAW,QAAQ,8CAA8C,mBAAmB,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACrG,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,oEAAoE;IAC1G,MAAM,MAAM,GAAG,cAAc,CAC3B,QAAQ,EACR,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,CACzE,CAAC;IACF,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,OAAO,CAAC,MAAc;IACpC,IAAI,GAAW,CAAC;IAChB,IAAI,CAAC;QACH,GAAG,GAAG,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,qBAAqB,MAAM,GAAG,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAwB,CAAC;IAChD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,SAAS,MAAM,wBAAwB,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACvG,CAAC;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ export interface ExecResult {
2
+ exitCode: number;
3
+ stdout: string;
4
+ stderr: string;
5
+ }
6
+ export declare function bcGenerate(executable: string, options?: Partial<import("./types.js").GenerateOptions>): Promise<ExecResult>;
7
+ export declare function bcCheck(executable: string, options?: Partial<import("./types.js").CheckOptions>): Promise<ExecResult>;
8
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/generated/commands.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,YAAY,EAAE,eAAe,CAAC,GACtD,OAAO,CAAC,UAAU,CAAC,CAoBrB;AAED,wBAAsB,OAAO,CAC3B,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,YAAY,EAAE,YAAY,CAAC,GACnD,OAAO,CAAC,UAAU,CAAC,CAoBrB"}
@@ -0,0 +1,55 @@
1
+ // Auto-generated by cli-contracts. Do not edit.
2
+ import { execFile } from "node:child_process";
3
+ import { promisify } from "node:util";
4
+ const execFileAsync = promisify(execFile);
5
+ export async function bcGenerate(executable, options) {
6
+ const cmdArgs = ["generate"];
7
+ if (options) {
8
+ if (options.lang !== undefined)
9
+ cmdArgs.push("--lang", String(options.lang));
10
+ if (options.in !== undefined)
11
+ cmdArgs.push("--in", String(options.in));
12
+ if (options.out !== undefined)
13
+ cmdArgs.push("--out", String(options.out));
14
+ if (options.runtimeImport !== undefined)
15
+ cmdArgs.push("--runtime-import", String(options.runtimeImport));
16
+ }
17
+ try {
18
+ const result = await execFileAsync(executable, cmdArgs);
19
+ return { exitCode: 0, stdout: result.stdout, stderr: result.stderr };
20
+ }
21
+ catch (err) {
22
+ const e = err;
23
+ return {
24
+ exitCode: typeof e.code === 'number' ? e.code : 1,
25
+ stdout: e.stdout ?? '',
26
+ stderr: e.stderr ?? '',
27
+ };
28
+ }
29
+ }
30
+ export async function bcCheck(executable, options) {
31
+ const cmdArgs = ["check"];
32
+ if (options) {
33
+ if (options.lang !== undefined)
34
+ cmdArgs.push("--lang", String(options.lang));
35
+ if (options.in !== undefined)
36
+ cmdArgs.push("--in", String(options.in));
37
+ if (options.out !== undefined)
38
+ cmdArgs.push("--out", String(options.out));
39
+ if (options.runtimeImport !== undefined)
40
+ cmdArgs.push("--runtime-import", String(options.runtimeImport));
41
+ }
42
+ try {
43
+ const result = await execFileAsync(executable, cmdArgs);
44
+ return { exitCode: 0, stdout: result.stdout, stderr: result.stderr };
45
+ }
46
+ catch (err) {
47
+ const e = err;
48
+ return {
49
+ exitCode: typeof e.code === 'number' ? e.code : 1,
50
+ stdout: e.stdout ?? '',
51
+ stderr: e.stderr ?? '',
52
+ };
53
+ }
54
+ }
55
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/generated/commands.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,M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EAAE;YACtB,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,EAAE;SACvB,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const CONTRACT_YAML: string;
2
+ export declare const CONTRACT_JSON_STR: string;
3
+ //# sourceMappingURL=contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/generated/contract.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,EAAE,MAA6tM,CAAC;AAE1vM,eAAO,MAAM,iBAAiB,EAAE,MAAqiQ,CAAC"}
@@ -0,0 +1,5 @@
1
+ // Auto-generated by cli-contracts. Do not edit.
2
+ // Embedded contract for the extract subcommand.
3
+ export const CONTRACT_YAML = "# yaml-language-server: $schema=./node_modules/cli-contracts/schemas/cli-contract.schema.json\ncli_contracts: 0.1.0\n\ninfo:\n title: behavior-contracts CLI\n version: 0.1.0\n description: >-\n bc — the build-time codegen CLI over behavior-contracts' public API.\n Reads a serialized ComponentGraphIRDoc (the unbranded JSON IR), adopts it\n via loadCompiledIR, and runs the same generateModule the in-process API runs\n to emit a runtime-free native module (data baked as literals). The IR doc is\n a build-time input only; nothing reads it at runtime.\n license:\n name: MIT\n contact:\n name: foo-ogawa\n url: https://github.com/foo-ogawa/behavior-contracts\n\nartifact_slots:\n ir-doc:\n direction: read\n description: Serialized ComponentGraphIRDoc (unbranded JSON IR) — the codegen input.\n generated-module:\n direction: write\n description: Generated native module source (baked-literal, runtime-free).\n\ncommand_sets:\n bc:\n summary: build-time codegen CLI over behavior-contracts' public API.\n executable: bc\n\n global_options:\n - name: version\n aliases: [V]\n description: Print version and exit.\n schema:\n type: boolean\n\n - name: help\n aliases: [h]\n description: Show help and exit.\n schema:\n type: boolean\n\n commands:\n # ── generate ─────────────────────────────────────────\n generate:\n summary: Emit a native module from a serialized IR doc.\n description: >-\n Reads the --in ComponentGraphIRDoc, adopts it via loadCompiledIR, and\n runs generateModule for the --lang emitter. Writes the module source\n to --out if given, else to stdout. Rejects an unregistered --lang.\n usage:\n - bc generate --lang rust-typed-native --in ir-doc.json\n - bc generate --lang go-typed-native --in ir-doc.json --out gen.go\n - bc generate --lang typescript-typed --in ir-doc.json --runtime-import ./runtime.js\n\n options:\n - name: lang\n required: true\n description: >-\n Target emitter (must be a registered language, e.g.\n rust-typed-native, go-typed-native, typescript-typed).\n value_name: emitter\n schema:\n type: string\n\n - name: in\n required: true\n description: Path to the serialized ComponentGraphIRDoc JSON file.\n value_name: ir-doc.json\n schema:\n type: string\n file:\n mode: read\n exists: true\n media_type: application/json\n encoding: utf-8\n\n - name: out\n required: false\n description: Write the generated module here instead of stdout.\n value_name: file\n schema:\n type: string\n file:\n mode: write\n\n - name: runtime-import\n required: false\n description: Override the runtime import specifier baked into the module.\n value_name: spec\n schema:\n type: string\n\n exits:\n '0':\n description: Module generated (written to --out, or printed to stdout).\n stdout:\n format: text\n '1':\n description: >-\n Generation failed (unreadable/invalid --in, or --lang is not a\n registered emitter).\n stderr:\n format: text\n '2':\n description: Usage error — a required option (--lang or --in) was omitted.\n stderr:\n format: text\n\n x-agent:\n riskLevel: low\n requiresConfirmation: false\n idempotent: true\n sideEffects:\n - file_write\n sideEffectNote: >-\n Writes to the filesystem only when --out is specified; otherwise\n output goes to stdout.\n\n # ── check ────────────────────────────────────────────\n check:\n summary: Verify a committed module matches a fresh generation (drift gate).\n description: >-\n Regenerates the module from --in for --lang and byte-compares it\n against the committed --out file. Exits non-zero on drift. This is the\n build's codegen drift gate.\n usage:\n - bc check --lang rust-typed-native --in ir-doc.json --out gen.rs\n\n options:\n - name: lang\n required: true\n description: Target emitter (must be a registered language).\n value_name: emitter\n schema:\n type: string\n\n - name: in\n required: true\n description: Path to the serialized ComponentGraphIRDoc JSON file.\n value_name: ir-doc.json\n schema:\n type: string\n file:\n mode: read\n exists: true\n media_type: application/json\n encoding: utf-8\n\n - name: out\n required: true\n description: The committed module file to diff a fresh generation against.\n value_name: file\n schema:\n type: string\n file:\n mode: read\n exists: true\n\n - name: runtime-import\n required: false\n description: Override the runtime import specifier baked into the module.\n value_name: spec\n schema:\n type: string\n\n exits:\n '0':\n description: Up to date — the committed --out matches a fresh generation.\n stdout:\n format: text\n '1':\n description: >-\n Drift detected (--out differs or does not exist), or generation\n failed (unreadable/invalid --in, or unregistered --lang).\n stderr:\n format: text\n '2':\n description: Usage error — a required option (--lang or --in) was omitted.\n stderr:\n format: text\n\n x-agent:\n riskLevel: low\n requiresConfirmation: false\n idempotent: true\n sideEffects: []\n";
4
+ export const CONTRACT_JSON_STR = "{\n \"cli_contracts\": \"0.1.0\",\n \"info\": {\n \"title\": \"behavior-contracts CLI\",\n \"version\": \"0.1.0\",\n \"description\": \"bc — the build-time codegen CLI over behavior-contracts' public API. Reads a serialized ComponentGraphIRDoc (the unbranded JSON IR), adopts it via loadCompiledIR, and runs the same generateModule the in-process API runs to emit a runtime-free native module (data baked as literals). The IR doc is a build-time input only; nothing reads it at runtime.\",\n \"license\": {\n \"name\": \"MIT\"\n },\n \"contact\": {\n \"name\": \"foo-ogawa\",\n \"url\": \"https://github.com/foo-ogawa/behavior-contracts\"\n }\n },\n \"artifact_slots\": {\n \"ir-doc\": {\n \"direction\": \"read\",\n \"description\": \"Serialized ComponentGraphIRDoc (unbranded JSON IR) — the codegen input.\"\n },\n \"generated-module\": {\n \"direction\": \"write\",\n \"description\": \"Generated native module source (baked-literal, runtime-free).\"\n }\n },\n \"command_sets\": {\n \"bc\": {\n \"summary\": \"build-time codegen CLI over behavior-contracts' public API.\",\n \"executable\": \"bc\",\n \"global_options\": [\n {\n \"name\": \"version\",\n \"aliases\": [\n \"V\"\n ],\n \"description\": \"Print version and exit.\",\n \"schema\": {\n \"type\": \"boolean\"\n }\n },\n {\n \"name\": \"help\",\n \"aliases\": [\n \"h\"\n ],\n \"description\": \"Show help and exit.\",\n \"schema\": {\n \"type\": \"boolean\"\n }\n }\n ],\n \"commands\": {\n \"generate\": {\n \"summary\": \"Emit a native module from a serialized IR doc.\",\n \"description\": \"Reads the --in ComponentGraphIRDoc, adopts it via loadCompiledIR, and runs generateModule for the --lang emitter. Writes the module source to --out if given, else to stdout. Rejects an unregistered --lang.\",\n \"usage\": [\n \"bc generate --lang rust-typed-native --in ir-doc.json\",\n \"bc generate --lang go-typed-native --in ir-doc.json --out gen.go\",\n \"bc generate --lang typescript-typed --in ir-doc.json --runtime-import ./runtime.js\"\n ],\n \"options\": [\n {\n \"name\": \"lang\",\n \"required\": true,\n \"description\": \"Target emitter (must be a registered language, e.g. rust-typed-native, go-typed-native, typescript-typed).\",\n \"value_name\": \"emitter\",\n \"schema\": {\n \"type\": \"string\"\n }\n },\n {\n \"name\": \"in\",\n \"required\": true,\n \"description\": \"Path to the serialized ComponentGraphIRDoc JSON file.\",\n \"value_name\": \"ir-doc.json\",\n \"schema\": {\n \"type\": \"string\"\n },\n \"file\": {\n \"mode\": \"read\",\n \"exists\": true,\n \"media_type\": \"application/json\",\n \"encoding\": \"utf-8\"\n }\n },\n {\n \"name\": \"out\",\n \"required\": false,\n \"description\": \"Write the generated module here instead of stdout.\",\n \"value_name\": \"file\",\n \"schema\": {\n \"type\": \"string\"\n },\n \"file\": {\n \"mode\": \"write\"\n }\n },\n {\n \"name\": \"runtime-import\",\n \"required\": false,\n \"description\": \"Override the runtime import specifier baked into the module.\",\n \"value_name\": \"spec\",\n \"schema\": {\n \"type\": \"string\"\n }\n }\n ],\n \"exits\": {\n \"0\": {\n \"description\": \"Module generated (written to --out, or printed to stdout).\",\n \"stdout\": {\n \"format\": \"text\"\n }\n },\n \"1\": {\n \"description\": \"Generation failed (unreadable/invalid --in, or --lang is not a registered emitter).\",\n \"stderr\": {\n \"format\": \"text\"\n }\n },\n \"2\": {\n \"description\": \"Usage error — a required option (--lang or --in) was omitted.\",\n \"stderr\": {\n \"format\": \"text\"\n }\n }\n },\n \"x-agent\": {\n \"riskLevel\": \"low\",\n \"requiresConfirmation\": false,\n \"idempotent\": true,\n \"sideEffects\": [\n \"file_write\"\n ],\n \"sideEffectNote\": \"Writes to the filesystem only when --out is specified; otherwise output goes to stdout.\"\n }\n },\n \"check\": {\n \"summary\": \"Verify a committed module matches a fresh generation (drift gate).\",\n \"description\": \"Regenerates the module from --in for --lang and byte-compares it against the committed --out file. Exits non-zero on drift. This is the build's codegen drift gate.\",\n \"usage\": [\n \"bc check --lang rust-typed-native --in ir-doc.json --out gen.rs\"\n ],\n \"options\": [\n {\n \"name\": \"lang\",\n \"required\": true,\n \"description\": \"Target emitter (must be a registered language).\",\n \"value_name\": \"emitter\",\n \"schema\": {\n \"type\": \"string\"\n }\n },\n {\n \"name\": \"in\",\n \"required\": true,\n \"description\": \"Path to the serialized ComponentGraphIRDoc JSON file.\",\n \"value_name\": \"ir-doc.json\",\n \"schema\": {\n \"type\": \"string\"\n },\n \"file\": {\n \"mode\": \"read\",\n \"exists\": true,\n \"media_type\": \"application/json\",\n \"encoding\": \"utf-8\"\n }\n },\n {\n \"name\": \"out\",\n \"required\": true,\n \"description\": \"The committed module file to diff a fresh generation against.\",\n \"value_name\": \"file\",\n \"schema\": {\n \"type\": \"string\"\n },\n \"file\": {\n \"mode\": \"read\",\n \"exists\": true\n }\n },\n {\n \"name\": \"runtime-import\",\n \"required\": false,\n \"description\": \"Override the runtime import specifier baked into the module.\",\n \"value_name\": \"spec\",\n \"schema\": {\n \"type\": \"string\"\n }\n }\n ],\n \"exits\": {\n \"0\": {\n \"description\": \"Up to date — the committed --out matches a fresh generation.\",\n \"stdout\": {\n \"format\": \"text\"\n }\n },\n \"1\": {\n \"description\": \"Drift detected (--out differs or does not exist), or generation failed (unreadable/invalid --in, or unregistered --lang).\",\n \"stderr\": {\n \"format\": \"text\"\n }\n },\n \"2\": {\n \"description\": \"Usage error — a required option (--lang or --in) was omitted.\",\n \"stderr\": {\n \"format\": \"text\"\n }\n }\n },\n \"x-agent\": {\n \"riskLevel\": \"low\",\n \"requiresConfirmation\": false,\n \"idempotent\": true,\n \"sideEffects\": []\n }\n }\n }\n }\n }\n}";
5
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/generated/contract.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,gDAAgD;AAEhD,MAAM,CAAC,MAAM,aAAa,GAAW,otMAAotM,CAAC;AAE1vM,MAAM,CAAC,MAAM,iBAAiB,GAAW,4hQAA4hQ,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from "./types.js";
2
+ export * from "./commands.js";
3
+ export * from "./schemas.js";
4
+ export { createProgram } from "./program.js";
5
+ export type { CommandHandlers } from "./program.js";
6
+ export { CONTRACT_YAML, CONTRACT_JSON_STR } from "./contract.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generated/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,7 @@
1
+ // Auto-generated by cli-contracts. Do not edit.
2
+ export * from "./types.js";
3
+ export * from "./commands.js";
4
+ export * from "./schemas.js";
5
+ export { createProgram } from "./program.js";
6
+ export { CONTRACT_YAML, CONTRACT_JSON_STR } from "./contract.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generated/index.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Command } from "commander";
2
+ export interface CommandHandlers {
3
+ generate: (options: {
4
+ lang?: string;
5
+ in?: string;
6
+ out?: string;
7
+ runtimeImport?: string;
8
+ }, parentOpts: Record<string, unknown>) => Promise<void>;
9
+ check: (options: {
10
+ lang?: string;
11
+ in?: string;
12
+ out?: string;
13
+ runtimeImport?: string;
14
+ }, parentOpts: Record<string, unknown>) => Promise<void>;
15
+ }
16
+ export declare function createProgram(handlers: CommandHandlers, version: string): Command;
17
+ //# sourceMappingURL=program.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../src/generated/program.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,CAAC,OAAO,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChJ,KAAK,EAAE,CAAC,OAAO,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9I;AAED,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,GACd,OAAO,CAmHT"}
@@ -0,0 +1,117 @@
1
+ // Auto-generated by cli-contracts. Do not edit.
2
+ import { Command } from "commander";
3
+ import { CONTRACT_YAML, CONTRACT_JSON_STR } from "./contract.js";
4
+ export function createProgram(handlers, version) {
5
+ const program = new Command();
6
+ program
7
+ .name("bc")
8
+ .version(version, "-V, --version")
9
+ .description("build-time codegen CLI over behavior-contracts' public API.");
10
+ program
11
+ .command("generate")
12
+ .description("Emit a native module from a serialized IR doc.")
13
+ .option("--lang <emitter>", "Target emitter (must be a registered language, e.g. rust-typed-native, go-typed-native, typescript-typed).")
14
+ .option("--in <ir-doc.json>", "Path to the serialized ComponentGraphIRDoc JSON file.")
15
+ .option("--out <file>", "Write the generated module here instead of stdout.")
16
+ .option("--runtime-import <spec>", "Override the runtime import specifier baked into the module.")
17
+ .action(async (opts, cmd) => {
18
+ await handlers.generate(opts, cmd.optsWithGlobals());
19
+ });
20
+ program
21
+ .command("check")
22
+ .description("Verify a committed module matches a fresh generation (drift gate).")
23
+ .option("--lang <emitter>", "Target emitter (must be a registered language).")
24
+ .option("--in <ir-doc.json>", "Path to the serialized ComponentGraphIRDoc JSON file.")
25
+ .option("--out <file>", "The committed module file to diff a fresh generation against.")
26
+ .option("--runtime-import <spec>", "Override the runtime import specifier baked into the module.")
27
+ .action(async (opts, cmd) => {
28
+ await handlers.check(opts, cmd.optsWithGlobals());
29
+ });
30
+ // Built-in extract command (auto-injected by cli-contracts)
31
+ program
32
+ .command("extract")
33
+ .description("Extract contract specification for this CLI tool.")
34
+ .argument("[commands...]", "Command IDs to extract. Use dot notation.")
35
+ .option("-a, --all", "Extract all commands.", false)
36
+ .option("--include-meta", "Include extraction metadata.", true)
37
+ .option("-F, --format <format>", "Output format (yaml or json).", "yaml")
38
+ .action(async (commands, opts, cmd) => {
39
+ if (commands.length === 0 && !opts.all) {
40
+ process.stderr.write(JSON.stringify({ code: "INVALID_ARGS", message: "Specify command IDs or use --all" }) + "\n");
41
+ process.exit(2);
42
+ }
43
+ const format = opts.format || "yaml";
44
+ const doc = JSON.parse(CONTRACT_JSON_STR);
45
+ const cmdIds = opts.all ? [] : commands;
46
+ if (cmdIds.length === 0) {
47
+ // --all: output full contract
48
+ if (format === "json") {
49
+ const out = {};
50
+ if (opts.includeMeta) {
51
+ out._meta = {
52
+ source: "embedded",
53
+ type: "cli-contracts/extract",
54
+ extractedAt: new Date().toISOString(),
55
+ specVersion: doc.cli_contracts ?? "0.1.0",
56
+ commands: ["bc.generate", "bc.check"],
57
+ };
58
+ }
59
+ Object.assign(out, doc);
60
+ process.stdout.write(JSON.stringify(out, null, 2) + "\n");
61
+ }
62
+ else {
63
+ // YAML output
64
+ const yamlLines = [];
65
+ yamlLines.push("# bc extract");
66
+ yamlLines.push("# source: embedded");
67
+ yamlLines.push("# type: cli-contracts/command-extract");
68
+ if (opts.includeMeta) {
69
+ yamlLines.push("---");
70
+ yamlLines.push("source: embedded");
71
+ yamlLines.push("type: cli-contracts/command-extract");
72
+ yamlLines.push("extractedAt: " + new Date().toISOString());
73
+ yamlLines.push("spec_version: " + (doc.cli_contracts ?? "0.1.0"));
74
+ yamlLines.push("commands:");
75
+ for (const id of ["bc.generate", "bc.check"]) {
76
+ yamlLines.push(" - " + id);
77
+ }
78
+ }
79
+ yamlLines.push("---");
80
+ yamlLines.push(CONTRACT_YAML);
81
+ process.stdout.write(yamlLines.join("\n") + "\n");
82
+ }
83
+ }
84
+ else {
85
+ // Filter specific commands
86
+ const filtered = {
87
+ cli_contracts: doc.cli_contracts,
88
+ info: doc.info,
89
+ command_sets: {},
90
+ };
91
+ const fcs = filtered.command_sets;
92
+ for (const [setId, cs] of Object.entries(doc.command_sets ?? {})) {
93
+ const cmds = cs.commands;
94
+ if (!cmds)
95
+ continue;
96
+ const matched = {};
97
+ for (const [cmdId, cmdDef] of Object.entries(cmds)) {
98
+ const fullId = setId + "." + cmdId;
99
+ if (cmdIds.some((id) => id === cmdId || id === fullId || cmdId.startsWith(id + "."))) {
100
+ matched[cmdId] = cmdDef;
101
+ }
102
+ }
103
+ if (Object.keys(matched).length > 0) {
104
+ const setCopy = { ...cs };
105
+ setCopy.commands = matched;
106
+ fcs[setId] = setCopy;
107
+ }
108
+ }
109
+ if (doc.components)
110
+ filtered.components = doc.components;
111
+ process.stdout.write(JSON.stringify(filtered, null, 2) + "\n");
112
+ }
113
+ process.exit(0);
114
+ });
115
+ return program;
116
+ }
117
+ //# sourceMappingURL=program.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program.js","sourceRoot":"","sources":["../../src/generated/program.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAOjE,MAAM,UAAU,aAAa,CAC3B,QAAyB,EACzB,OAAe;IAEf,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,OAAO;SACJ,IAAI,CAAC,IAAI,CAAC;SACV,OAAO,CAAC,OAAO,EAAE,eAAe,CAAC;SACjC,WAAW,CAAC,6DAA6D,CAAC,CAAC;IAG9E,OAAO;SACJ,OAAO,CAAC,UAAU,CAAC;SACnB,WAAW,CAAC,gDAAgD,CAAC;SAC7D,MAAM,CAAC,kBAAkB,EAAE,4GAA4G,CAAC;SACxI,MAAM,CAAC,oBAAoB,EAAE,uDAAuD,CAAC;SACrF,MAAM,CAAC,cAAc,EAAE,oDAAoD,CAAC;SAC5E,MAAM,CAAC,yBAAyB,EAAE,8DAA8D,CAAC;SACjG,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAC1B,MAAM,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,eAAe,EAAE,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEL,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,oEAAoE,CAAC;SACjF,MAAM,CAAC,kBAAkB,EAAE,iDAAiD,CAAC;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AAC,EAAE,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC;wBACrF,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;oBAC1B,CAAC;gBACH,CAAC;gBACD,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACpC,MAAM,OAAO,GAAG,EAAE,GAAI,EAA8B,EAAE,CAAC;oBACvD,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC;oBAC3B,GAAG,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;gBACvB,CAAC;YACH,CAAC;YACD,IAAI,GAAG,CAAC,UAAU;gBAAE,QAAQ,CAAC,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC;YACzD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IACL,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/generated/schemas.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ // Auto-generated by cli-contracts. Do not edit.
2
+ export {};
3
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/generated/schemas.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAEhD,OAAO,EAAE,CAAC"}
@@ -0,0 +1,35 @@
1
+ export interface GenerateOptions {
2
+ lang: string;
3
+ in: string;
4
+ out?: string;
5
+ runtimeImport?: string;
6
+ }
7
+ export type GenerateExitCode = 0 | 1 | 2;
8
+ export type GenerateExitResult = {
9
+ exitCode: 0;
10
+ stdout: unknown;
11
+ } | {
12
+ exitCode: 1;
13
+ stderr: unknown;
14
+ } | {
15
+ exitCode: 2;
16
+ stderr: unknown;
17
+ };
18
+ export interface CheckOptions {
19
+ lang: string;
20
+ in: string;
21
+ out: string;
22
+ runtimeImport?: string;
23
+ }
24
+ export type CheckExitCode = 0 | 1 | 2;
25
+ export type CheckExitResult = {
26
+ exitCode: 0;
27
+ stdout: unknown;
28
+ } | {
29
+ exitCode: 1;
30
+ stderr: unknown;
31
+ } | {
32
+ exitCode: 2;
33
+ stderr: unknown;
34
+ };
35
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/generated/types.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEzC,MAAM,MAAM,kBAAkB,GAC5B;IAAE,QAAQ,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAC9B;IAAE,QAAQ,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAChC;IAAE,QAAQ,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC;AAErC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEtC,MAAM,MAAM,eAAe,GACzB;IAAE,QAAQ,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAC9B;IAAE,QAAQ,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAChC;IAAE,QAAQ,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ // Auto-generated by cli-contracts. Do not edit.
2
+ export {};
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/generated/types.ts"],"names":[],"mappings":"AAAA,gDAAgD"}
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/generator/core.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG;IAAE,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAEzF;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAGD,MAAM,MAAM,oBAAoB,GAC5B,uBAAuB,GACvB,wBAAwB,GACxB,0BAA0B,GAC1B,UAAU,GACV,qBAAqB,GACrB,kBAAkB,GAClB,+BAA+B,CAAC;AAEpC,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,IAAI,EAAE,oBAAoB,CAAC;gBACf,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM;CAKxD;AAOD,0CAA0C;AAC1C,MAAM,WAAW,WAAW;IAC1B,mCAAmC;IACnC,EAAE,EAAE,gBAAg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AAW,eAAe;IAC9B,YAAY;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,2BAA2B;IAC3B,YAAY,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACrE,uCAAuC;IACvC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,8CAA8C;IAC9C,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,eAAe,CAsCrF"}
@@ -26,6 +26,7 @@ import { SPEC_VERSIONS } from "../index.js";
26
26
  import { assertPortableComponentGraph } from "../guard.js";
27
27
  import { fingerprintComponentGraph } from "./fingerprint.js";
28
28
  import { assertCompiled } from "../provenance.js";
29
+ import { assertAllNodeTypesDetermined } from "../type-gate.js";
29
30
  export class GeneratorFailure extends Error {
30
31
  code;
31
32
  constructor(code, message) {
@@ -100,6 +101,11 @@ export function generateModule(ir, options) {
100
101
  gfail("UNKNOWN_LANGUAGE", `no emitter registered for language '${options.language}' (registered: ${registeredLanguages().join(", ")}) (fail-closed)`);
101
102
  assertCompiled(ir); // SA3/SA7 出自ゲート: codegen 入力も無 token/改竄 IR は NON_COMPILED_IR で fail-closed
102
103
  const validated = validateGeneratorInput(ir);
104
+ // SA5 / SCP-only end-state: 全ノードの出力型が確定していること(未確定は fail-closed UNTYPED_NODE)を
105
+ // codegen 入口で強制する。authoring path(authoring.ts)と同一の SSoT ゲートを消費する(型 walk を
106
+ // 重複させない)。untyped straight-line フォールバックは存在しない — 型未確定 IR は compile-time エラー。
107
+ for (const comp of validated.components)
108
+ assertAllNodeTypesDetermined(comp);
103
109
  const fingerprint = fingerprintComponentGraph(validated);
104
110
  const specVersions = {
105
111
  behavior: SPEC_VERSIONS.behavior,
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/generator/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AA6ClD,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,IAAI,CAAuB;IAC3B,YAAY,IAA0B,EAAE,OAAe;QACrD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AAED,SAAS,KAAK,CAAC,IAA0B,EAAE,OAAe;IACxD,MAAM,IAAI,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAoED,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;AAElD;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,MAAqB;IACnD,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AACxC,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,mBAAmB;IACjC,OAAO,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AACrC,CAAC;AAED,uEAAuE;AACvE;;;;GAIG;AACH,SAAS,sBAAsB,CAAC,EAAW;IACzC,IAAI,EAAE,KAAK,IAAI,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5D,KAAK,CACH,uBAAuB,E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AC,IAAI,CAAC,GAAG,CAAC;QACtB,WAAW;QACX,YAAY;QACZ,cAAc;QACd,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,sBAAsB,MAAM,CAAC,aAAa,EAAE;KAClF,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"emit-shared-typescript.d.ts","sourceRoot":"","sources":["../../src/generator/emit-shared-typescript.ts"],"names":[],"mappings":"AAmCA,OAAO,EASL,KAAK,mBAAmB,EAEzB,MAAM,mBAAmB,CAAC;AA8qC3B;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,mBAA6B,CAAC;AAClE,oFAAoF;AACpF,eAAO,MAAM,QAAQ,YAAQ,CAAC;AAC9B,uDAAuD;AACvD,eAAO,MAAM,YAAY,aAAY,CAAC"}
1
+ {"version":3,"file":"emit-shared-typescript.d.ts","sourceRoot":"","sources":["../../src/generator/emit-shared-typescript.ts"],"names":[],"mappings":"AAmCA,OAAO,EASL,KAAK,mBAAmB,EAEzB,MAAM,mBAAmB,CAAC;AAktC3B;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,mBAA6B,CAAC;AAClE,oFAAoF;AACpF,eAAO,MAAM,QAAQ,YAAQ,CAAC;AAC9B,uDAAuD;AACvD,eAAO,MAAM,YAAY,aAAY,CAAC"}
@@ -93,6 +93,7 @@ const usage = {
93
93
  planTypes: false, // Exec/AsyncExec/OpSpec/RelationKind(RunPlan 経路のみ)
94
94
  handlerType: false, // Handler/AsyncHandler(handler を呼ぶ component の run_* param 型)
95
95
  fanoutDedupDrop: false, // #135: fanout の dedup/drop SSoT(fanoutDedupDrop)を import する
96
+ conformOutType: false, // node 結果を宣言 outType へ正規化する SSoT(conformResultToOutType)を import する
96
97
  };
97
98
  function resetUsage() {
98
99
  for (const k of Object.keys(usage))
@@ -337,13 +338,25 @@ function emitSeqOpExec(op, plan, ctx, hvars, aw, lines, indent, bindVar, bindRea
337
338
  const canSkip = meta.canSkip || meta.alwaysSkip;
338
339
  const inner = [];
339
340
  const bodyIndent = bindVar ? indent + " " : indent;
341
+ // node 結果は宣言 outType へ正規化してから格納する(run_behavior の wrappedExec と同一の SSoT
342
+ // = conformResultToOutType: int→float widen / 欠落 opt→null。型消去の TS でも runtime でこの
343
+ // 正規化を行うことで straight-line 生成 ≡ runBehavior が値レベルで保たれる)。outType 無しは素通し。
344
+ const nodeOut = plan.component.body[i].outType;
345
+ const isMapNode = "map" in plan.component.body[i];
346
+ const conform = (valueExpr) => nodeOut === undefined
347
+ ? valueExpr
348
+ : (() => {
349
+ usage.conformOutType = true;
350
+ return `conformResultToOutType(${JSON.stringify(id)}, ${valueExpr}, ${JSON.stringify(nodeOut)}, ${isMapNode})`;
351
+ })();
340
352
  // 成功時の格納(ローカル + 進行形 scope)。
341
353
  const store = (valueExpr, ind, target) => {
354
+ const stored = conform(valueExpr);
342
355
  if (canSkip) {
343
- target.push(`${ind}${local} = ${valueExpr};`, `${ind}${ctx.okFlag.get(id)} = true;`);
356
+ target.push(`${ind}${local} = ${stored};`, `${ind}${ctx.okFlag.get(id)} = true;`);
344
357
  }
345
358
  else {
346
- target.push(`${ind}const ${local}: Value = ${valueExpr};`);
359
+ target.push(`${ind}const ${local}: Value = ${stored};`);
347
360
  }
348
361
  if (ctx.scopeVar)
349
362
  target.push(`${ind}${ctx.scopeVar}[${JSON.stringify(id)}] = ${local};`);
@@ -826,6 +839,16 @@ function emitPlanDrivenFn(plan, aw) {
826
839
  const planLiteral = plan.component.plan ? emitDocLiteral(plan.component.plan, "ts", 1) : "null";
827
840
  const output = emitExpr(plan.component.output, SCOPE);
828
841
  const relationKinds = plan.opsLiteral.map((o) => (o.relationKind === "connection" ? "connection" : "single"));
842
+ // node 結果 → 宣言 outType の正規化表(id → {t, m})。exec が outcome.ok をこの SSoT で正規化する
843
+ // (逐次経路の store と同一・run_behavior の wrappedExec と同一)。outType 無しノードは表に載らない。
844
+ const outTypeEntries = plan.opsLiteral
845
+ .map((o, i) => {
846
+ const ot = plan.component.body[i].outType;
847
+ return ot === undefined ? null : ` ${JSON.stringify(o.id)}: { t: ${JSON.stringify(ot)}, m: ${"map" in plan.component.body[i]} },`;
848
+ })
849
+ .filter((x) => x !== null);
850
+ if (outTypeEntries.length > 0)
851
+ usage.conformOutType = true;
829
852
  const fns = plan.ops
830
853
  .map((o) => ` ${JSON.stringify(o.id)}: ${aw === "" ? "" : "async "}()${aw === "" ? ": ExecOutcome" : ": Promise<ExecOutcome>"} => {
831
854
  ${emitExecFn(o, aw, hvars)}
@@ -835,7 +858,9 @@ ${emitExecFn(o, aw, hvars)}
835
858
  const ops: OpSpec[] = ${emitOpsLiteral(plan)};
836
859
  const results: Record<string, Value> = {};
837
860
  const scope = (): Scope => ({ ...input, ...results });
838
- const relationKinds: (RelationKind | undefined)[] = ${JSON.stringify(relationKinds)};
861
+ const relationKinds: (RelationKind | undefined)[] = ${JSON.stringify(relationKinds)};${outTypeEntries.length > 0
862
+ ? `\n const outTypes: Record<string, { t: PortableType; m: boolean }> = {\n${outTypeEntries.join("\n")}\n };`
863
+ : ""}
839
864
  // per-op exec は事前解決した関数表で引く(線形 ID 探索は無い — bc#75)。
840
865
  const execs: Record<string, ${aw === "" ? "() => ExecOutcome" : "() => Promise<ExecOutcome>"}> = {
841
866
  ${fns}
@@ -844,7 +869,10 @@ ${fns}
844
869
  const f = execs[op.id];
845
870
  if (!f) throw new BehaviorFailure("UNKNOWN_NODE_KIND", \`op '\${op.id}' has no generated exec arm (fail-closed)\`);
846
871
  const outcome = ${aw}f();
847
- if ("ok" in outcome) results[op.id] = outcome.ok;
872
+ if ("ok" in outcome) {${outTypeEntries.length > 0
873
+ ? `\n const ot = outTypes[op.id];\n results[op.id] = ot === undefined ? outcome.ok : conformResultToOutType(op.id, outcome.ok, ot.t, ot.m);`
874
+ : `\n results[op.id] = outcome.ok;`}
875
+ }
848
876
  return outcome;
849
877
  };
850
878
  const run = ${aw}${aw === "" ? "runPlan" : "runPlanAsync"}(${planLiteral}, ops, exec);
@@ -968,6 +996,8 @@ function emitModule(plans, ctx) {
968
996
  valueImports.push(`codegenPrimitives as ${CGP}`);
969
997
  if (usage.fanoutDedupDrop)
970
998
  valueImports.push("fanoutDedupDrop"); // #135: fanout dedup/drop SSoT
999
+ if (usage.conformOutType)
1000
+ valueImports.push("conformResultToOutType"); // node 結果 → 宣言 outType 正規化 SSoT
971
1001
  if (usage.runPlan)
972
1002
  valueImports.push("runPlan");
973
1003
  if (usage.runPlanAsync)
@@ -982,6 +1012,9 @@ function emitModule(plans, ctx) {
982
1012
  typeImports.push("Handler", "AsyncHandler");
983
1013
  if (usage.planTypes)
984
1014
  typeImports.push("AsyncExec", "Exec", "ExecOutcome", "OpSpec", "RelationKind");
1015
+ // RunPlan 経路で outType 正規化表を持つときだけ PortableType 型を使う(逐次経路は値の直呼びのみ)。
1016
+ if (usage.conformOutType && (usage.runPlan || usage.runPlanAsync))
1017
+ typeImports.push("PortableType");
985
1018
  typeImports.sort();
986
1019
  return `// GENERATED by behavior-contracts common generator (bc#37/#42/#75, straight-line) — DO NOT EDIT.
987
1020
  // Input: portable component-graph IR only (scp-ir-architecture.md §5/§7.4).