@sublang/slc 0.21.0 → 0.23.0-rc.13

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 (71) hide show
  1. package/README.md +47 -48
  2. package/dist/app.d.ts +1 -0
  3. package/dist/app.d.ts.map +1 -1
  4. package/dist/app.js +14 -3
  5. package/dist/app.js.map +1 -1
  6. package/dist/check-report.d.ts +4 -0
  7. package/dist/check-report.d.ts.map +1 -0
  8. package/dist/check-report.js +35 -0
  9. package/dist/check-report.js.map +1 -0
  10. package/dist/cli.js +45 -1
  11. package/dist/cli.js.map +1 -1
  12. package/dist/cligent-agent.d.ts.map +1 -1
  13. package/dist/cligent-agent.js +37 -1
  14. package/dist/cligent-agent.js.map +1 -1
  15. package/dist/compilation-audit.d.ts +14 -0
  16. package/dist/compilation-audit.d.ts.map +1 -0
  17. package/dist/compilation-audit.js +67 -0
  18. package/dist/compilation-audit.js.map +1 -0
  19. package/dist/compiled-executor.js +1 -1
  20. package/dist/compiled-executor.js.map +1 -1
  21. package/dist/compiler-identity.d.ts +7 -0
  22. package/dist/compiler-identity.d.ts.map +1 -0
  23. package/dist/compiler-identity.js +48 -0
  24. package/dist/compiler-identity.js.map +1 -0
  25. package/dist/config.d.ts.map +1 -1
  26. package/dist/config.js +36 -13
  27. package/dist/config.js.map +1 -1
  28. package/dist/entry-module.d.ts.map +1 -1
  29. package/dist/entry-module.js +72 -3
  30. package/dist/entry-module.js.map +1 -1
  31. package/dist/errors.d.ts.map +1 -1
  32. package/dist/errors.js +6 -0
  33. package/dist/errors.js.map +1 -1
  34. package/dist/execution.d.ts +2 -0
  35. package/dist/execution.d.ts.map +1 -1
  36. package/dist/execution.js.map +1 -1
  37. package/dist/interpreter.d.ts +2 -0
  38. package/dist/interpreter.d.ts.map +1 -1
  39. package/dist/interpreter.js +1 -1
  40. package/dist/interpreter.js.map +1 -1
  41. package/dist/isolated-check.d.ts +3 -0
  42. package/dist/isolated-check.d.ts.map +1 -0
  43. package/dist/isolated-check.js +160 -0
  44. package/dist/isolated-check.js.map +1 -0
  45. package/dist/managed-compilation.d.ts +4 -0
  46. package/dist/managed-compilation.d.ts.map +1 -0
  47. package/dist/managed-compilation.js +385 -0
  48. package/dist/managed-compilation.js.map +1 -0
  49. package/dist/runner.d.ts +15 -6
  50. package/dist/runner.d.ts.map +1 -1
  51. package/dist/runner.js +106 -46
  52. package/dist/runner.js.map +1 -1
  53. package/dist/verification-worker.d.ts +2 -0
  54. package/dist/verification-worker.d.ts.map +1 -0
  55. package/dist/verification-worker.js +223 -0
  56. package/dist/verification-worker.js.map +1 -0
  57. package/dist/verify-coverage.d.ts +3 -0
  58. package/dist/verify-coverage.d.ts.map +1 -1
  59. package/dist/verify-coverage.js +461 -71
  60. package/dist/verify-coverage.js.map +1 -1
  61. package/dist/verify-source.d.ts +2 -0
  62. package/dist/verify-source.d.ts.map +1 -1
  63. package/dist/verify-source.js +55 -0
  64. package/dist/verify-source.js.map +1 -1
  65. package/dist/verify-typescript.js +2 -0
  66. package/dist/verify-typescript.js.map +1 -1
  67. package/dist/verify.d.ts +15 -1
  68. package/dist/verify.d.ts.map +1 -1
  69. package/dist/verify.js +382 -94
  70. package/dist/verify.js.map +1 -1
  71. package/package.json +5 -5
package/dist/runner.d.ts CHANGED
@@ -29,15 +29,25 @@ export interface SlcDeps {
29
29
  cwd?: string;
30
30
  signal?: AbortSignal;
31
31
  coverage?: CoverageBudget;
32
+ /** Non-secret effective CLI selections for managed invocation provenance. */
33
+ auditConfiguration?: unknown;
32
34
  /**
33
35
  * Receives phase start/finish/failure events with elapsed times as the run
34
36
  * progresses (DR-019, cli-32). Absent for hosts that want a quiet run.
35
37
  */
36
38
  progress?: ProgressSink;
39
+ /** Final managed-bundle acceptance before incremental success publication. */
40
+ finalize?: (result: SlcResult) => Promise<SlcResult>;
41
+ /** Recheck retained bytes after compiler/runtime identity changes. */
42
+ revalidateReuse?: boolean;
37
43
  }
38
44
  /** The outcome of an `slc` run. */
39
45
  export interface SlcResult {
40
46
  ok: boolean;
47
+ cause?: {
48
+ category: import('./check-report.js').CheckFailureCategory;
49
+ source: 'compiler-diagnostic';
50
+ };
41
51
  /** Artifact paths written, in order. */
42
52
  outputs: string[];
43
53
  /** Diagnostics: agent summaries on success, or the failure report. */
@@ -46,12 +56,11 @@ export interface SlcResult {
46
56
  outcome?: 'up-to-date' | 'clarification-required';
47
57
  clarification?: ClarificationReport;
48
58
  }
49
- /**
50
- * Parses argv and runs the requested pipeline, phase, or link end-to-end.
51
- * Never rejects: malformed invocations, refusals, and phase failures all return
52
- * `{ ok: false }` with diagnostics.
53
- */
54
- export declare function runSlc(argv: readonly string[], deps: SlcDeps): Promise<SlcResult>;
55
59
  /** Resolves the built-in pipeline-agnostic normalize definition (DR-013). */
56
60
  export declare function normalizeDefinitionPath(): string;
61
+ /** Reuses the emitted GEARS-to-FSM suite before accepting its input (DR-033). */
62
+ export declare function fsmConformanceFindings(source: string, target: string, linkTarget?: string, signal?: AbortSignal, coverage?: CoverageBudget): Promise<readonly string[]>;
63
+ export declare function fsmContinuationFindings(source: string, linkTarget?: string, signal?: AbortSignal, coverage?: CoverageBudget): Promise<readonly string[]>;
64
+ /** Public compiler boundary with workflow-owned environment and invocation evidence. */
65
+ export declare function runSlc(argv: readonly string[], deps: SlcDeps): Promise<SlcResult>;
57
66
  //# sourceMappingURL=runner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAuBA,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,oBAAoB,CAAC;AAiB5B,OAAO,EAKL,KAAK,aAAa,EAMnB,MAAM,gBAAgB,CAAC;AAgBxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,WAAW,CAAC;AAEnB,OAAO,EAEL,KAAK,gBAAgB,EAGtB,MAAM,eAAe,CAAC;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E;QACN,QAAQ,EAAE,OAAO,mBAAmB,EAAE,oBAAoB,CAAC;QAC3D,MAAM,EAAE,qBAAqB,CAAC;KAC/B,CAAC;IACF,wCAAwC;IACxC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,sEAAsE;IACtE,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,uEAAuE;IACvE,OAAO,CAAC,EAAE,YAAY,GAAG,wBAAwB,CAAC;IAClD,aAAa,CAAC,EAAE,mBAAmB,CAAC;CACrC;AAg/BD,6EAA6E;AAC7E,wBAAgB,uBAAuB,IAAI,MAAM,CAEhD;AA8RD,iFAAiF;AACjF,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,WAAW,EACpB,QAAQ,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAuC5B;AAoBD,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,WAAW,EACpB,QAAQ,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAuB5B;AA2tCD,wFAAwF;AACxF,wBAAsB,MAAM,CAC1B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,SAAS,CAAC,CAEpB"}
package/dist/runner.js CHANGED
@@ -16,6 +16,7 @@ import { artifactDir, planArtifacts, parseSource, } from './artifacts.js';
16
16
  import { formatClarificationReport, } from './clarification.js';
17
17
  import { encodeLocator, invalidateBuildHistory, loadBuildHistory, recordBuild, verifiedInput, } from './build-history.js';
18
18
  import { emitEntryModule } from './entry-module.js';
19
+ import { managedCompilation } from './managed-compilation.js';
19
20
  import { linkObjectEdges, reconcileLinkObjectImportSpecifiers, unresolvableRelativeImports, } from './emitted-imports.js';
20
21
  import { messageOf } from './errors.js';
21
22
  import { assertSafeTarget, formatFailureReport, phaseProtectedPaths, pathsAlias, runPhase, watchProtectedPaths, } from './execution.js';
@@ -31,17 +32,19 @@ import { PINS_FILE, PinError, loadPinFile, } from './pins.js';
31
32
  import { loadPipeline, resolvePipeline, } from './pipeline.js';
32
33
  import { RESERVED_SLC_PIPELINE, defaultPlaybookLinkTarget, isReservedPipeline, } from './resolver.js';
33
34
  import { readPlaybookRuntimeDeclaration, } from './runtime-contract.js';
34
- import { resolveCoverageBudget, artifactSchemaForPlaybookProvenance, checkFsmContinuationInputs, checkFsmChildSuspension, checkFsmCoverage, checkGearsActorContract, checkGearsFsmArtifact, checkGearsResultContract, checkLinkedModuleContract, emitFsmCoverageTest, FsmCoverageDeadlineError, emitFsmIntrospectionTest, emitGearsFsmConformanceTest, emitPromptContractTest, inspectGearsRoleContract, findMachineConfig, loadFsmModule, loadLinkedModuleForVerification, playbookProvenanceForLinkTarget, resolveArtifactSchemaForVerification, } from './verify.js';
35
+ import { resolveCoverageBudget, artifactSchemaForPlaybookProvenance, checkFsmContinuationInputs, checkFsmChildSuspension, checkFsmCoverage, checkGearsActorContract, checkGearsPackageContract, checkGearsFsmArtifact, checkGearsResultContract, emitFsmCoverageTest, FsmCoverageDeadlineError, emitFsmIntrospectionTest, emitGearsFsmConformanceTest, emitPromptContractTest, inspectGearsRoleContract, findMachineConfig, loadFsmModule, loadLinkedModuleForVerification, playbookProvenanceForLinkTarget, resolveArtifactSchemaForVerification, } from './verify.js';
35
36
  import { VERIFIER_SUPPORT_MODULE, emitVerifierSupport, verifierSupportFiles, } from './verify-support.js';
36
- import { checkSourceGearsContract, checkSourceRoles } from './verify-source.js';
37
+ import { checkSourceGearsContract, checkSourceRoles, checkSourceReturnContracts, } from './verify-source.js';
37
38
  import { checkFsmTypeScript } from './verify-typescript.js';
39
+ import { isolatedCheck } from './isolated-check.js';
40
+ import { auditEvent } from './compilation-audit.js';
38
41
  import { checkEntryOptions, ENTRY_OPTIONS_CONTRACT, linkedOptionsValidator, } from './entry-options.js';
39
42
  /**
40
43
  * Parses argv and runs the requested pipeline, phase, or link end-to-end.
41
44
  * Never rejects: malformed invocations, refusals, and phase failures all return
42
45
  * `{ ok: false }` with diagnostics.
43
46
  */
44
- export async function runSlc(argv, deps) {
47
+ async function runSlcCore(argv, deps) {
45
48
  let invocation;
46
49
  let coverage;
47
50
  try {
@@ -266,7 +269,7 @@ async function runFullLink(invocation, deps, coverage) {
266
269
  const entryCandidate = invocation.pipeline === 'playbook' &&
267
270
  invocation.output === null &&
268
271
  gearsPlan !== undefined
269
- ? resolve(cwd, `${basename}.ts`)
272
+ ? resolve(cwd, `${basename}.mjs`)
270
273
  : null;
271
274
  const entryAliasesSource = entryCandidate !== null && (await pathsAlias(entryCandidate, source));
272
275
  const entryPath = entryAliasesSource ? null : entryCandidate;
@@ -324,6 +327,7 @@ async function runFullLink(invocation, deps, coverage) {
324
327
  pipeline: invocation.pipeline,
325
328
  gearsPath: gearsPlan.path,
326
329
  textPath,
330
+ artifactDir: artDir,
327
331
  });
328
332
  const missing = await unresolvableRelativeImports(entryPath);
329
333
  if (missing.length > 0) {
@@ -376,7 +380,7 @@ async function runCompletion(invocation, deps, coverage) {
376
380
  link.target.ext !== '.ts')
377
381
  return failure('completion requires the text/GEARS/TypeScript-FSM/Playbook canonical pipeline formats');
378
382
  const linked = join(artDir, `${basename}.playbook.ts`);
379
- const entryPath = join(cwd, `${basename}.ts`);
383
+ const entryPath = join(cwd, `${basename}.mjs`);
380
384
  const linkTarget = invocation.linkTarget === null
381
385
  ? defaultPlaybookLinkTarget()
382
386
  : resolve(cwd, invocation.linkTarget);
@@ -426,7 +430,8 @@ async function runCompletion(invocation, deps, coverage) {
426
430
  ...definitions,
427
431
  ...declared.paths,
428
432
  ...pinInputs,
429
- join(artDir, '.slc'),
433
+ join(artDir, '.slc', 'latest'),
434
+ join(artDir, '.slc', 'builds'),
430
435
  ...targets.flatMap((target) => target.protectedInputs ?? []),
431
436
  ]),
432
437
  ];
@@ -467,13 +472,9 @@ async function runCompletion(invocation, deps, coverage) {
467
472
  ...(await checkFsmTypeScript(fsm.path, deps.signal)),
468
473
  ];
469
474
  if (findings.length === 0)
470
- findings = await fsmConformanceFindings(gears.path, fsm.path, linkTarget, deps.signal, coverage);
475
+ findings = await isolatedCheck('fsm', [gears.path, fsm.path, linkTarget, coverage], deps.signal);
471
476
  if (findings.length === 0) {
472
- const config = findMachineConfig(await loadFsmModule(fsm.path));
473
- findings = [
474
- ...checkFsmChildSuspension(config),
475
- ...(await linkFidelityFindings(linked, fsm.path)),
476
- ];
477
+ findings = await isolatedCheck('linked', [linked, fsm.path, false], deps.signal);
477
478
  }
478
479
  if (findings.length === 0) {
479
480
  const module = (await loadLinkedModuleForVerification({
@@ -835,14 +836,7 @@ function compileStep(pipeline, phase, source, target, sourceFidelity, linkTarget
835
836
  phase.source.format === 'text' &&
836
837
  phase.target.format === 'gears';
837
838
  const fsmConformance = phase.source.format === 'gears' && phase.target.format === 'fsm'
838
- ? async () => {
839
- if (phase.target.ext === '.ts') {
840
- const findings = await checkFsmTypeScript(target, signal);
841
- if (findings.length > 0)
842
- return findings;
843
- }
844
- return fsmConformanceFindings(source, target, linkTarget, signal, coverage);
845
- }
839
+ ? () => isolatedCheck('fsm', [source, target, linkTarget, coverage], signal)
846
840
  : undefined;
847
841
  const checks = [
848
842
  ...(gated ? [() => sourceFidelityFindings(source, target)] : []),
@@ -862,6 +856,15 @@ function compileStep(pipeline, phase, source, target, sourceFidelity, linkTarget
862
856
  target,
863
857
  ...(mechanicalReview === undefined ? {} : { mechanicalReview }),
864
858
  },
859
+ ...(phase.target.format === 'fsm'
860
+ ? {
861
+ outputContract: async () => compilerCheckInstruction('fsm', [
862
+ source,
863
+ target,
864
+ ...(linkTarget ? [linkTarget] : []),
865
+ ]),
866
+ }
867
+ : {}),
865
868
  phase: phase.name,
866
869
  pinKey: phase.name,
867
870
  targetExt: phase.target.ext,
@@ -877,7 +880,7 @@ function compileStep(pipeline, phase, source, target, sourceFidelity, linkTarget
877
880
  : {}),
878
881
  ...(phase.source.format === 'fsm'
879
882
  ? {
880
- fsmSourceContinuation: () => fsmContinuationFindings(source, linkTarget, signal, coverage),
883
+ fsmSourceContinuation: () => isolatedCheck('continuation', [source, linkTarget, coverage], signal),
881
884
  }
882
885
  : {}),
883
886
  };
@@ -889,6 +892,7 @@ async function gearsContractFindings(path) {
889
892
  return [
890
893
  ...checkGearsResultContract(gears),
891
894
  ...checkGearsActorContract(gears),
895
+ ...checkGearsPackageContract(gears),
892
896
  ];
893
897
  }
894
898
  catch (error) {
@@ -934,14 +938,26 @@ async function sourceFidelityFindings(source, target) {
934
938
  return [];
935
939
  }
936
940
  try {
937
- return checkSourceGearsContract(sourceText, gearsText);
941
+ const findings = [
942
+ ...checkSourceGearsContract(sourceText, gearsText),
943
+ ...checkSourceReturnContracts(sourceText, gearsText),
944
+ ];
945
+ await auditEvent('source-gears-check', {
946
+ source,
947
+ target,
948
+ sourceDigest: hashBytes(Buffer.from(sourceText)),
949
+ targetDigest: hashBytes(Buffer.from(gearsText)),
950
+ method: 'deterministic authored fragments and explicit terminal-return spans',
951
+ findings,
952
+ });
953
+ return findings;
938
954
  }
939
955
  catch (error) {
940
956
  return [`Source fidelity could not be checked: ${messageOf(error)}`];
941
957
  }
942
958
  }
943
959
  /** Reuses the emitted GEARS-to-FSM suite before accepting its input (DR-033). */
944
- async function fsmConformanceFindings(source, target, linkTarget, signal, coverage) {
960
+ export async function fsmConformanceFindings(source, target, linkTarget, signal, coverage) {
945
961
  signal?.throwIfAborted();
946
962
  try {
947
963
  await stat(target);
@@ -1000,7 +1016,7 @@ async function fsmSchema(config, linkTarget) {
1000
1016
  ...(runtimeDeclaration === undefined ? {} : { runtimeDeclaration }),
1001
1017
  });
1002
1018
  }
1003
- async function fsmContinuationFindings(source, linkTarget, signal, coverage) {
1019
+ export async function fsmContinuationFindings(source, linkTarget, signal, coverage) {
1004
1020
  signal?.throwIfAborted();
1005
1021
  const fsm = await loadFsmModule(source);
1006
1022
  const config = findMachineConfig(fsm);
@@ -1037,16 +1053,7 @@ function linkStep(opts) {
1037
1053
  inspectGearsRoleContract(await readFile(opts.entryGearsPath, 'utf8'))
1038
1054
  .generation === 'schema-3';
1039
1055
  const gated = link.target.format === PLAYBOOK_LINKED_FORMAT && fsmObjects.length === 1
1040
- ? async () => [
1041
- ...(await linkFidelityFindings(opts.linked, fsmObjects[0])),
1042
- ...((await entryRequired())
1043
- ? await checkEntryOptions({
1044
- linkedPath: opts.linked,
1045
- fsmPath: fsmObjects[0],
1046
- signal: opts.signal,
1047
- })
1048
- : []),
1049
- ]
1056
+ ? async () => isolatedCheck('linked', [opts.linked, fsmObjects[0], await entryRequired()], opts.signal)
1050
1057
  : undefined;
1051
1058
  return {
1052
1059
  request: {
@@ -1060,7 +1067,10 @@ function linkStep(opts) {
1060
1067
  },
1061
1068
  ...(gated !== undefined && opts.entryGearsPath !== undefined
1062
1069
  ? {
1063
- outputContract: async () => (await entryRequired()) ? ENTRY_OPTIONS_CONTRACT : undefined,
1070
+ outputContract: async () => [
1071
+ (await entryRequired()) ? ENTRY_OPTIONS_CONTRACT : '',
1072
+ compilerCheckInstruction('link', [opts.linked, fsmObjects[0]]),
1073
+ ].join('\n'),
1064
1074
  }
1065
1075
  : {}),
1066
1076
  phase: 'link',
@@ -1076,7 +1086,7 @@ function linkStep(opts) {
1076
1086
  : {}),
1077
1087
  ...(gated !== undefined && link.source.format === 'fsm'
1078
1088
  ? {
1079
- fsmSourceContinuation: () => fsmContinuationFindings(fsmObjects[0], opts.linkTarget, opts.signal, opts.coverage),
1089
+ fsmSourceContinuation: () => isolatedCheck('continuation', [fsmObjects[0], opts.linkTarget, opts.coverage], opts.signal),
1080
1090
  }
1081
1091
  : {}),
1082
1092
  };
@@ -1088,14 +1098,6 @@ function linkStep(opts) {
1088
1098
  * and an unexpected failure becomes a finding, so the gate never throws into
1089
1099
  * the executor it guards.
1090
1100
  */
1091
- async function linkFidelityFindings(linked, fsmPath) {
1092
- try {
1093
- return await checkLinkedModuleContract({ linkedPath: linked, fsmPath });
1094
- }
1095
- catch (error) {
1096
- return [`link fidelity could not be checked: ${messageOf(error)}`];
1097
- }
1098
- }
1099
1101
  /**
1100
1102
  * Runs steps in order, selecting interpreted or compiled execution per phase from
1101
1103
  * the pin index and stopping at the first failure with its report (phase-execution-9,
@@ -1240,6 +1242,35 @@ async function executeSteps(steps, pipeline, deps, opts = {}) {
1240
1242
  diagnostics.push(formatFailureReport({ phase: step.phase, target, reasons }));
1241
1243
  return stopped(index);
1242
1244
  }
1245
+ if (deps.revalidateReuse) {
1246
+ const checks = [
1247
+ step.sourceRoles,
1248
+ step.gearsSourceContract,
1249
+ step.fsmSourceTypecheck,
1250
+ step.fsmSourceContinuation,
1251
+ step.compileFidelity,
1252
+ step.linkFidelity,
1253
+ ].filter((check) => check !== undefined);
1254
+ const checkProtected = await watchProtectedPaths(protectedInputs);
1255
+ let findings = [];
1256
+ for (const check of checks) {
1257
+ findings = await check();
1258
+ if (findings.length)
1259
+ break;
1260
+ }
1261
+ findings = [...findings, ...(await checkProtected())];
1262
+ if (findings.length) {
1263
+ diagnostics.push(formatFailureReport({
1264
+ phase: step.phase,
1265
+ target,
1266
+ reasons: [
1267
+ 'retained artifact revalidation failed; review findings or run --rebuild to regenerate',
1268
+ ...findings,
1269
+ ],
1270
+ }));
1271
+ return stopped(index);
1272
+ }
1273
+ }
1243
1274
  deps.progress?.({
1244
1275
  kind: 'status',
1245
1276
  text: `reusing ${step.phase} → ${target}`,
@@ -1268,7 +1299,7 @@ async function executeSteps(steps, pipeline, deps, opts = {}) {
1268
1299
  update: { priorInput: mode.priorInput, diff: mode.diff },
1269
1300
  }
1270
1301
  : step.request;
1271
- if (request.kind === 'link' && step.outputContract !== undefined) {
1302
+ if (step.outputContract !== undefined) {
1272
1303
  const outputContract = await step.outputContract();
1273
1304
  if (outputContract !== undefined)
1274
1305
  request = { ...request, outputContract };
@@ -1526,7 +1557,8 @@ async function executeSteps(steps, pipeline, deps, opts = {}) {
1526
1557
  ? { outcome: 'up-to-date' }
1527
1558
  : {}),
1528
1559
  };
1529
- const completed = await complete(selected, guardCompletionTarget, pinFile);
1560
+ const candidate = await complete(selected, guardCompletionTarget, pinFile);
1561
+ const completed = deps.finalize ? await deps.finalize(candidate) : candidate;
1530
1562
  return state === undefined
1531
1563
  ? completed
1532
1564
  : publishIncremental(completed, state, steps);
@@ -1989,4 +2021,32 @@ async function revalidateChain(dir) {
1989
2021
  function failure(message) {
1990
2022
  return { ok: false, outputs: [], diagnostics: [message] };
1991
2023
  }
2024
+ /** Public compiler boundary with workflow-owned environment and invocation evidence. */
2025
+ export async function runSlc(argv, deps) {
2026
+ return managedCompilation(argv, deps, runSlcCore);
2027
+ }
2028
+ function compilerCheckInstruction(kind, paths) {
2029
+ return [
2030
+ 'Compiler-owned verification operation (run after writing the target):',
2031
+ (process.platform === 'win32' ? '& ' : '') +
2032
+ [
2033
+ process.execPath,
2034
+ fileURLToPath(new URL('./cli.js', import.meta.url)),
2035
+ 'check',
2036
+ kind,
2037
+ ...paths,
2038
+ ]
2039
+ .map(shellArgument)
2040
+ .join(' '),
2041
+ 'Use this operation instead of a project or global tsc command. Its toolchain and Node typings are supplied by SLC; do not install dependencies or create a project package.json/tsconfig.',
2042
+ 'The compiler reruns this gate. Agent summaries or unavailable alternative checks do not decide acceptance.',
2043
+ 'Treat bounded search exhaustion as unverified; public JSON coverageWitnesses may supply legal inputs, never patch private context or weaken guards.',
2044
+ ].join('\n');
2045
+ }
2046
+ /** Shell syntax is selected for the platform, independent of JSON quoting. */
2047
+ function shellArgument(value) {
2048
+ return process.platform === 'win32'
2049
+ ? "'" + value.replaceAll("'", "''") + "'"
2050
+ : "'" + value.replaceAll("'", "'\"'\"'") + "'";
2051
+ }
1992
2052
  //# sourceMappingURL=runner.js.map