@pulse-compute/wasm-compiler 1.0.0-beta.5 → 1.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,9 +8,9 @@
8
8
  > **Stability:** Internal compiler interface; no application-author compatibility guarantee.<br>
9
9
  > **npm:** [`@pulse-compute/wasm-compiler`](https://www.npmjs.com/package/@pulse-compute/wasm-compiler)<br>
10
10
  > **Canonical replacement:** `@pulse-compute/cli`<br>
11
- > **Canonical documentation:** [Package guide](https://pulsecompute.io/v1.0.0-beta.5/packages/implementation-packages/)
11
+ > **Canonical documentation:** [Package guide](https://pulsecompute.io/v1.0.0-beta.7/packages/implementation-packages/)
12
12
  >
13
- > This release-status block is generated from the synchronized `Pulse 1.0.0-beta.5` package policy.
13
+ > This release-status block is generated from the synchronized `Pulse 1.0.0-beta.7` package policy.
14
14
  <!-- pulse-package-status:end -->
15
15
 
16
16
  Whole-project compiler implementation used by the `pulse` workflow. Application projects should use `@pulse-compute/cli`, not import this package directly.
@@ -38,6 +38,17 @@ The compiler orchestrates contracts but does not own:
38
38
 
39
39
  Package-specific lowering belongs to the package owning the facade. Provider realization belongs to provider packages. Shared protocol vocabulary belongs to `@pulse-compute/wasm-contracts`.
40
40
 
41
+ Provider packages are not production dependencies of this compiler. Direct
42
+ compiler consumers supply the selected provider in their project context; the
43
+ product CLI owns its bundled Node/Fastly dependencies. Provider-neutral imports,
44
+ compilation and legacy executable help do not load providers. Legacy proof
45
+ commands load only their selected provider when invoked. Repository proof
46
+ scripts retain provider development dependencies.
47
+
48
+ The canonical API, Native-plan and Native-compiler facades use declared package
49
+ imports and surface missing or unexported dependencies without checkout-relative
50
+ recovery. Other historical loaders are outside this migration.
51
+
41
52
  ## Internal compiler spine
42
53
 
43
54
  The compiler connects root extraction, surface recognition, normalization, classification, validation, canonical IR, native lowering, provider realization, and artifact verification through a fixed package-internal pipeline. The pipeline is not exported and is not a plugin framework. Compiler refactors must preserve checked-in metadata, diagnostics, native-plan, and generated-Wasm evidence unless an explicit contract migration authorizes a difference.
@@ -52,4 +63,4 @@ The package exports its root implementation plus focused compiler, CLI, extracto
52
63
 
53
64
  Compiler changes should be covered by focused static/lowering tests, canonical project inspection, provider-plan parity, packed-package discovery where relevant, and the release documentation gates.
54
65
 
55
- See the installed [implementation package guide](https://pulsecompute.io/v1.0.0-beta.5/packages/implementation-packages/) and [compilation concepts](https://pulsecompute.io/v1.0.0-beta.5/concepts/compilation-and-lowering/).
66
+ See the installed [implementation package guide](https://pulsecompute.io/v1.0.0-beta.7/packages/implementation-packages/) and [compilation concepts](https://pulsecompute.io/v1.0.0-beta.7/concepts/compilation-and-lowering/).
@@ -1,34 +1,32 @@
1
1
  'use strict';
2
2
 
3
- const node = require('@pulse-compute/provider-node/compiler');
4
- const fastly = require('@pulse-compute/provider-fastly/compiler');
5
- const {
6
- buildNodeLiveOriginRouteHandlerEffectProof
7
- } = require('@pulse-compute/provider-node/compiler/route-handler-live-origin-proof');
8
- const {
9
- buildNodeCompiledRouteHandlerEffectBridge
10
- } = require('@pulse-compute/provider-node/compiler/route-handler-compiled-wasm-bridge');
11
- const {
12
- buildNodeBackendJsonRequestBodyProof
13
- } = require('@pulse-compute/provider-node/compiler/backend-json-request-body-proof');
3
+ const path = require('node:path');
4
+ const { createRequire } = require('node:module');
14
5
 
15
- module.exports = Object.freeze({
16
- buildNodeAdapter: node.buildNodeAdapter,
17
- buildNodeAssetsProviderProof: node.buildNodeAssetsProviderProof,
18
- buildNodeCompiledWasmAssetsLifecycleProof: node.buildNodeCompiledWasmAssetsLifecycleProof,
19
- buildNodeRouteHandlerEffectProof: node.buildNodeRouteHandlerEffectProof,
20
- buildNodeRequestJsonBodyProof: node.buildNodeRequestJsonBodyProof,
21
- buildNodeSchemaDecodeResultProof: node.buildNodeSchemaDecodeResultProof,
22
- buildNodeSchemaResponseCodecProof: node.buildNodeSchemaResponseCodecProof,
23
- buildNodeLiveOriginRouteHandlerEffectProof,
24
- buildNodeCompiledRouteHandlerEffectBridge,
25
- buildNodeBackendJsonRequestBodyProof,
26
- buildFastlyReadiness: fastly.buildFastlyReadiness,
27
- buildFastlyHostcallBinding: fastly.buildFastlyHostcallBinding,
28
- buildFastlyStreamHeaderAdapter: fastly.buildFastlyStreamHeaderAdapter,
29
- buildFastlyCommandEntry: fastly.buildFastlyCommandEntry,
30
- buildFastlyAssetsProviderProof: fastly.buildFastlyAssetsProviderProof,
31
- buildFastlyAssetsPackageOutParityProof: fastly.buildFastlyAssetsPackageOutParityProof,
32
- buildFastlyRouteHandlerEffectProof: fastly.buildFastlyRouteHandlerEffectProof,
33
- buildFastlyLifecycleParityProof: fastly.buildFastlyLifecycleParityProof
34
- });
6
+ // Compatibility proof commands are optional and never loaded by plain compile,
7
+ // help or version. The caller supplies its project/CLI composition root.
8
+ function createProviderProofs(root = process.cwd()) {
9
+ const load = createRequire(path.join(path.resolve(root), 'package.json'));
10
+ return Object.freeze({
11
+ buildNodeAdapter: (...args) => load('@pulse-compute/provider-node/compiler').buildNodeAdapter(...args),
12
+ buildNodeAssetsProviderProof: (...args) => load('@pulse-compute/provider-node/compiler').buildNodeAssetsProviderProof(...args),
13
+ buildNodeCompiledWasmAssetsLifecycleProof: (...args) => load('@pulse-compute/provider-node/compiler').buildNodeCompiledWasmAssetsLifecycleProof(...args),
14
+ buildNodeRouteHandlerEffectProof: (...args) => load('@pulse-compute/provider-node/compiler').buildNodeRouteHandlerEffectProof(...args),
15
+ buildNodeRequestJsonBodyProof: (...args) => load('@pulse-compute/provider-node/compiler').buildNodeRequestJsonBodyProof(...args),
16
+ buildNodeSchemaDecodeResultProof: (...args) => load('@pulse-compute/provider-node/compiler').buildNodeSchemaDecodeResultProof(...args),
17
+ buildNodeSchemaResponseCodecProof: (...args) => load('@pulse-compute/provider-node/compiler').buildNodeSchemaResponseCodecProof(...args),
18
+ buildFastlyReadiness: (...args) => load('@pulse-compute/provider-fastly/compiler').buildFastlyReadiness(...args),
19
+ buildFastlyHostcallBinding: (...args) => load('@pulse-compute/provider-fastly/compiler').buildFastlyHostcallBinding(...args),
20
+ buildFastlyStreamHeaderAdapter: (...args) => load('@pulse-compute/provider-fastly/compiler').buildFastlyStreamHeaderAdapter(...args),
21
+ buildFastlyCommandEntry: (...args) => load('@pulse-compute/provider-fastly/compiler').buildFastlyCommandEntry(...args),
22
+ buildFastlyAssetsProviderProof: (...args) => load('@pulse-compute/provider-fastly/compiler').buildFastlyAssetsProviderProof(...args),
23
+ buildFastlyAssetsPackageOutParityProof: (...args) => load('@pulse-compute/provider-fastly/compiler').buildFastlyAssetsPackageOutParityProof(...args),
24
+ buildFastlyRouteHandlerEffectProof: (...args) => load('@pulse-compute/provider-fastly/compiler').buildFastlyRouteHandlerEffectProof(...args),
25
+ buildFastlyLifecycleParityProof: (...args) => load('@pulse-compute/provider-fastly/compiler').buildFastlyLifecycleParityProof(...args),
26
+ buildNodeLiveOriginRouteHandlerEffectProof: (...args) => load('@pulse-compute/provider-node/compiler/route-handler-live-origin-proof').buildNodeLiveOriginRouteHandlerEffectProof(...args),
27
+ buildNodeCompiledRouteHandlerEffectBridge: (...args) => load('@pulse-compute/provider-node/compiler/route-handler-compiled-wasm-bridge').buildNodeCompiledRouteHandlerEffectBridge(...args),
28
+ buildNodeBackendJsonRequestBodyProof: (...args) => load('@pulse-compute/provider-node/compiler/backend-json-request-body-proof').buildNodeBackendJsonRequestBodyProof(...args),
29
+ });
30
+ }
31
+
32
+ module.exports = { createProviderProofs };
@@ -3,7 +3,7 @@
3
3
 
4
4
  const { runCli } = require('../src/cli.js');
5
5
  const { getDefaultArtifactsDir } = require('@pulse-compute/wasm-build-support/artifacts-dir');
6
- const providerProofs = require('./provider-proof-composition.js');
6
+ const providerProofs = require('./provider-proof-composition.js').createProviderProofs(process.cwd());
7
7
 
8
8
  runCli(process.argv.slice(2), {
9
9
  cwd: process.cwd(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pulse-compute/wasm-compiler",
3
- "version": "1.0.0-beta.5",
3
+ "version": "1.0.0-beta.7",
4
4
  "license": "Apache-2.0",
5
5
  "description": "PulseWasm compiler package inside the Pulse monorepo.",
6
6
  "type": "commonjs",
@@ -9,15 +9,13 @@
9
9
  "pulsewasm": "./bin/pulsewasm-extract.js"
10
10
  },
11
11
  "dependencies": {
12
- "@pulse-compute/provider-fastly": "1.0.0-beta.5",
13
- "@pulse-compute/provider-node": "1.0.0-beta.5",
14
- "@pulse-compute/wasm-build-support": "1.0.0-beta.5",
15
- "@pulse-compute/wasm-contracts": "1.0.0-beta.5",
16
- "@pulse-compute/wasm-guest-link": "1.0.0-beta.5",
17
- "@pulse-compute/wasm-host-runtime": "1.0.0-beta.5",
18
- "@pulse-compute/wasm-library-kit": "1.0.0-beta.5",
19
- "@pulse-compute/wasm-runtime-core-as": "1.0.0-beta.5",
20
- "@pulse-compute/wasm-schema-json": "1.0.0-beta.5",
12
+ "@pulse-compute/wasm-build-support": "1.0.0-beta.7",
13
+ "@pulse-compute/wasm-contracts": "1.0.0-beta.7",
14
+ "@pulse-compute/wasm-guest-link": "1.0.0-beta.7",
15
+ "@pulse-compute/wasm-host-runtime": "1.0.0-beta.7",
16
+ "@pulse-compute/wasm-library-kit": "1.0.0-beta.7",
17
+ "@pulse-compute/wasm-runtime-core-as": "1.0.0-beta.7",
18
+ "@pulse-compute/wasm-schema-json": "1.0.0-beta.7",
21
19
  "assemblyscript": "0.28.18",
22
20
  "json-as": "1.5.0",
23
21
  "typescript": "5.9.3"
@@ -58,7 +56,7 @@
58
56
  "url": "git+https://github.com/pulse-compute/pulse.git",
59
57
  "directory": "wasm/packages/compiler"
60
58
  },
61
- "homepage": "https://pulsecompute.io/v1.0.0-beta.5/packages/implementation-packages/",
59
+ "homepage": "https://pulsecompute.io/v1.0.0-beta.7/packages/implementation-packages/",
62
60
  "bugs": {
63
61
  "url": "https://github.com/pulse-compute/pulse/issues"
64
62
  },
@@ -22,15 +22,7 @@ const {
22
22
  CanonicalCompileError
23
23
  } = require('./spine/plain-handler-frontend.js');
24
24
 
25
- function loadCanonicalRuntimeContract() {
26
- try { return require('@pulse-compute/wasm-contracts/handler/canonical-runtime'); }
27
- catch (error) {
28
- if (error && ['MODULE_NOT_FOUND', 'ERR_PACKAGE_PATH_NOT_EXPORTED'].includes(error.code)) return require('../../contracts/src/handler/canonical-runtime.js');
29
- throw error;
30
- }
31
- }
32
-
33
- const canonicalRuntimeContract = loadCanonicalRuntimeContract();
25
+ const canonicalRuntimeContract = require('@pulse-compute/wasm-contracts/handler/canonical-runtime');
34
26
 
35
27
  const CANONICAL_API_COMPILER_VERSION = 'pulse.canonical-api-compiler.v7';
36
28
 
@@ -17,60 +17,14 @@ const {
17
17
  PACKAGE_REALIZATION_ARTIFACT_SET_VERSION
18
18
  } = require('@pulse-compute/wasm-contracts/package/package-contract');
19
19
 
20
- function loadNativePlanCompiler() {
21
- try { return require('@pulse-compute/wasm-compiler/canonical-native-plan'); }
22
- catch (error) {
23
- if (error && ['MODULE_NOT_FOUND', 'ERR_PACKAGE_PATH_NOT_EXPORTED'].includes(error.code)) return require('./canonical-native-plan.js');
24
- throw error;
25
- }
26
- }
27
-
28
- function loadRuntimeCore() {
29
- try { return require('@pulse-compute/wasm-runtime-core-as/compiler/canonical-native'); }
30
- catch (error) {
31
- if (error && ['MODULE_NOT_FOUND', 'ERR_PACKAGE_PATH_NOT_EXPORTED'].includes(error.code)) return require('../../runtime-core-as/src/compiler/canonical-native.js');
32
- throw error;
33
- }
34
- }
35
-
36
- function loadRuntimeContract() {
37
- try { return require('@pulse-compute/wasm-contracts/handler/canonical-native-runtime'); }
38
- catch (error) {
39
- if (error && ['MODULE_NOT_FOUND', 'ERR_PACKAGE_PATH_NOT_EXPORTED'].includes(error.code)) return require('../../contracts/src/handler/canonical-native-runtime.js');
40
- throw error;
41
- }
42
- }
43
-
44
- function loadEventContract() {
45
- try { return require('@pulse-compute/wasm-contracts/events'); }
46
- catch (error) {
47
- if (error && ['MODULE_NOT_FOUND', 'ERR_PACKAGE_PATH_NOT_EXPORTED'].includes(error.code)) return require('../../contracts/src/events/contracts.js');
48
- throw error;
49
- }
50
- }
51
-
52
- function loadBuildSupport() {
53
- try { return require('@pulse-compute/wasm-build-support/assemblyscript-compile'); }
54
- catch (error) {
55
- if (error && ['MODULE_NOT_FOUND', 'ERR_PACKAGE_PATH_NOT_EXPORTED'].includes(error.code)) return require('../../build-support/src/assemblyscript-compile.js');
56
- throw error;
57
- }
58
- }
59
-
60
- const nativePlanCompiler = loadNativePlanCompiler();
61
- const runtimeCore = loadRuntimeCore();
62
- const runtimeContract = loadRuntimeContract();
63
- const eventContract = loadEventContract();
64
- const { resolveAsc } = loadBuildSupport();
65
- const { memoryAbi } = (() => {
66
- try {
67
- return require('@pulse-compute/wasm-guest-link');
68
- } catch (error) {
69
- if (error && error.code === 'MODULE_NOT_FOUND') return require('../../wasm-guest-link/src/index.js');
70
- throw error;
71
- }
72
- })();
20
+ const nativePlanCompiler = require('./canonical-native-plan.js');
21
+ const runtimeCore = require('@pulse-compute/wasm-runtime-core-as/compiler/canonical-native');
22
+ const runtimeContract = require('@pulse-compute/wasm-contracts/handler/canonical-native-runtime');
23
+ const eventContract = require('@pulse-compute/wasm-contracts/events');
24
+ const { resolveAsc } = require('@pulse-compute/wasm-build-support/assemblyscript-compile');
25
+ const { memoryAbi } = require('@pulse-compute/wasm-guest-link');
73
26
  const {
27
+ prepareReportCapture,
74
28
  appendAssemblyScriptOptimizationArgs,
75
29
  resolveNativeOptimization
76
30
  } = require('@pulse-compute/wasm-build-support/native-optimization');
@@ -182,7 +136,13 @@ function realizeCanonicalNativePlan(plan, options = {}, providerRequirements) {
182
136
  const compilerPackageRoot = path.resolve(__dirname, '..');
183
137
  const asc = resolveAsc(cwd) || resolveAsc(compilerPackageRoot);
184
138
  if (!asc) throw new CanonicalNativeCompileError('AssemblyScript compiler dependency was not found.', { cwd, remediation: 'Install the lockfile-pinned AssemblyScript dependency before compiling native Wasm.' });
185
- const generated = runtimeCore.generateCanonicalNativeAssemblyScript(plan, options);
139
+ const application = plan.packages && plan.packages.application;
140
+ const source = application && application.source + `\nconst __pulse_application_plan_hash: string = ${JSON.stringify(plan.planHash)}\n`;
141
+ const generated = application ? Object.freeze({
142
+ source, sourceHash: sha256(source), manifest: Object.freeze({
143
+ ...application.manifest, planVersion: plan.version, planHash: plan.planHash, sourceHash: sha256(source)
144
+ })
145
+ }) : runtimeCore.generateCanonicalNativeAssemblyScript(plan, options);
186
146
  const schemaCodecsActive = generated.manifest.schemaCodecs && generated.manifest.schemaCodecs.active === true;
187
147
  let jsonAs;
188
148
  if (schemaCodecsActive) {
@@ -209,6 +169,8 @@ function realizeCanonicalNativePlan(plan, options = {}, providerRequirements) {
209
169
  }
210
170
  jsonAs = Object.freeze({ transform, packageRoot, dependencyRoot, version: packageJson.version });
211
171
  }
172
+ if (options.emitWat !== undefined && typeof options.emitWat !== 'boolean') throw new TypeError('emitWat must be a boolean.');
173
+ const emitWat = options.emitWat === true;
212
174
  const stagingDir = fs.mkdtempSync(path.join(os.tmpdir(), 'pulse-canonical-native-'));
213
175
  const requestedOutDir = options.outDir ? path.resolve(options.outDir) : undefined;
214
176
  const outputDir = requestedOutDir || stagingDir;
@@ -216,6 +178,7 @@ function realizeCanonicalNativePlan(plan, options = {}, providerRequirements) {
216
178
  const sourceFile = path.join(stagingDir, 'canonical-native.as.ts');
217
179
  const wasmFile = path.join(outputDir, options.wasmFile || 'canonical-native.wasm');
218
180
  const watFile = path.join(outputDir, options.watFile || 'canonical-native.wat');
181
+ if (!emitWat) fs.rmSync(watFile, { force: true });
219
182
  try {
220
183
  fs.writeFileSync(sourceFile, generated.source, 'utf8');
221
184
  // Compile from a stable, relative entry name so AssemblyScript's name section and
@@ -224,19 +187,25 @@ function realizeCanonicalNativePlan(plan, options = {}, providerRequirements) {
224
187
  asc.script,
225
188
  path.basename(sourceFile),
226
189
  '--outFile', wasmFile,
227
- '--textFile', watFile,
228
190
  '--runtime', schemaCodecsActive ? 'incremental' : 'stub',
229
191
  '--noAssert',
230
192
  '--optimize'
231
193
  ];
232
- const optimization = appendAssemblyScriptOptimizationArgs(args, options.nativeOptimization);
194
+ if (emitWat) args.push('--textFile', watFile);
195
+ const optimization = appendAssemblyScriptOptimizationArgs(args, options.nativeOptimization, {
196
+ guestLinked: guestUnits.length > 0
197
+ });
233
198
  // The text capacity profile bounds each Native module to 256 MiB.
234
199
  // Linked guests retain their separately owned fixed-memory ABI.
235
- if (guestUnits.length === 0 && plan.effects.some(effect => effect.kind === 'crypto.digestText' || effect.kind.startsWith('s3.'))) {
236
- args.push('--maximumMemory', '4096');
200
+ if (guestUnits.length === 0 && (runtimeContract.hasBoundedReadLoop(plan) || plan.capabilities.includes('response.output') || plan.capabilities.includes('request.body.transform') || plan.effects.some(effect => effect.kind === 'crypto.digestText' || effect.kind.startsWith('s3.')))) {
201
+ args.push('--maximumMemory', String(runtimeContract.CANONICAL_NATIVE_READ_LOOP_MEMORY.maximumMemoryPages));
237
202
  }
203
+ if (guestUnits.length > 0 && (plan.capabilities.includes('response.output') || plan.capabilities.includes('request.body.transform'))) throw new CanonicalNativeCompileError('Generated output with linked guests requires separate memory qualification.');
238
204
  if (guestUnits.length > 0) {
239
205
  args.push(
206
+ '--disable', 'bulk-memory',
207
+ '--disable', 'nontrapping-f2i',
208
+ '--disable', 'sign-extension',
240
209
  '--importMemory',
241
210
  '--noExportMemory',
242
211
  '--initialMemory', String(memoryAbi.minimumPages),
@@ -252,6 +221,8 @@ function realizeCanonicalNativePlan(plan, options = {}, providerRequirements) {
252
221
  '--path', jsonAs.dependencyRoot
253
222
  );
254
223
  }
224
+ const readReportCapture = options.reportCapture === false ? () => null : prepareReportCapture(args, stagingDir, generated.manifest,
225
+ require(path.join(asc.packageRoot, 'package.json')).version, 'canonical-native.as/');
255
226
  const startedAt = Date.now();
256
227
  const result = spawnSync(asc.executable, args, {
257
228
  cwd: stagingDir,
@@ -274,19 +245,22 @@ function realizeCanonicalNativePlan(plan, options = {}, providerRequirements) {
274
245
  durationMs
275
246
  });
276
247
  }
248
+ const wasm = fs.readFileSync(wasmFile);
277
249
  return Object.freeze({
278
250
  plan,
279
251
  validation,
280
252
  realizationArtifacts,
281
253
  guestUnits,
282
254
  generated,
283
- wasm: fs.readFileSync(wasmFile),
284
- wat: fs.existsSync(watFile) ? fs.readFileSync(watFile, 'utf8') : '',
255
+ reportAttribution: readReportCapture(wasm),
256
+ wasm,
257
+ wat: emitWat ? fs.readFileSync(watFile, 'utf8') : '',
258
+ textEmitted: emitWat,
285
259
  assemblyScriptVersion: require(path.join(asc.packageRoot, 'package.json')).version,
286
260
  jsonAsVersion: jsonAs && jsonAs.version,
287
261
  optimization,
288
262
  durationMs,
289
- output: requestedOutDir ? Object.freeze({ outDir: outputDir, wasmFile, watFile }) : undefined
263
+ output: requestedOutDir ? Object.freeze({ outDir: outputDir, wasmFile, watFile: emitWat ? watFile : null }) : undefined
290
264
  });
291
265
  } finally {
292
266
  fs.rmSync(stagingDir, { recursive: true, force: true });
@@ -316,7 +290,9 @@ function verifyCanonicalNativeRealization(realization) {
316
290
  ? Object.freeze({ package: 'json-as', version: realization.jsonAsVersion, transform: true, strict: true, mode: 'NAIVE', fastPath: false })
317
291
  : null,
318
292
  wasm: Object.freeze({ bytes: inspection.bytes, sha256: inspection.sha256, magic: inspection.magic }),
319
- wat: Object.freeze({ bytes: Buffer.byteLength(realization.wat), sha256: sha256(realization.wat) }),
293
+ wat: Object.freeze(realization.textEmitted
294
+ ? { emitted: true, bytes: Buffer.byteLength(realization.wat), sha256: sha256(realization.wat) }
295
+ : { emitted: false, bytes: 0, sha256: null }),
320
296
  importModules: inspection.importModules,
321
297
  imports: inspection.imports,
322
298
  exports: inspection.exports,
@@ -327,13 +303,14 @@ function verifyCanonicalNativeRealization(realization) {
327
303
  finalWasmAudit: realization.guestLink.audit,
328
304
  providerPackaging: realization.guestLink.providerPackaging
329
305
  } : {}),
330
- policy: runtimeContract.CANONICAL_NATIVE_POLICY
306
+ policy: realization.generated.manifest.policy
331
307
  });
332
308
  return Object.freeze({
333
309
  version: runtimeContract.CANONICAL_NATIVE_WASM_VERSION,
334
310
  compilerVersion: runtimeContract.CANONICAL_NATIVE_COMPILER_VERSION,
335
311
  plan: realization.plan,
336
312
  validation: realization.validation,
313
+ reportAttribution: realization.reportAttribution && realization.reportAttribution.artifactSha256 === sha256(realization.wasm) ? realization.reportAttribution : null,
337
314
  generated: realization.generated,
338
315
  source: realization.generated.source,
339
316
  sourceHash: realization.generated.sourceHash,
@@ -381,7 +358,9 @@ function writeCanonicalNativeModule(compiled, outDir, options = {}) {
381
358
  : undefined;
382
359
  fs.writeFileSync(sourceFile, compiled.source, 'utf8');
383
360
  fs.writeFileSync(wasmFile, compiled.wasm);
384
- fs.writeFileSync(watFile, compiled.wat, 'utf8');
361
+ const emitWat = compiled.manifest.wat.emitted !== false;
362
+ if (emitWat) fs.writeFileSync(watFile, compiled.wat, 'utf8');
363
+ else fs.rmSync(watFile, { force: true });
385
364
  fs.writeFileSync(planFile, `${nativePlanCompiler.stableStringify(compiled.plan, 2)}\n`, 'utf8');
386
365
  fs.writeFileSync(manifestFile, `${stableStringify(compiled.manifest, 2)}\n`, 'utf8');
387
366
  if (realizationArtifactsFile) {
@@ -394,7 +373,7 @@ function writeCanonicalNativeModule(compiled, outDir, options = {}) {
394
373
  target,
395
374
  sourceFile,
396
375
  wasmFile,
397
- watFile,
376
+ watFile: emitWat ? watFile : null,
398
377
  planFile,
399
378
  manifestFile,
400
379
  realizationArtifactsFile,