@pulse-compute/cli 0.0.0 → 1.0.0-beta.1

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 (190) hide show
  1. package/API.md +539 -0
  2. package/CHANGELOG.md +47 -0
  3. package/README.md +70 -1
  4. package/bin/pulse.js +15 -0
  5. package/bin/pulsewasm-extract.js +22 -0
  6. package/cli-spec.json +575 -0
  7. package/completions/_pulse +106 -0
  8. package/completions/pulse.bash +31 -0
  9. package/completions/pulse.fish +76 -0
  10. package/docs/README.md +77 -0
  11. package/docs/architecture/current-contracts.md +381 -0
  12. package/docs/architecture/overview.md +93 -0
  13. package/docs/architecture/vision.md +515 -0
  14. package/docs/concepts/bodies.md +186 -0
  15. package/docs/concepts/compilation-and-lowering.md +496 -0
  16. package/docs/concepts/contracts-and-providers.md +158 -0
  17. package/docs/concepts/effects-and-continuations.md +243 -0
  18. package/docs/concepts/entities-and-adapters.md +71 -0
  19. package/docs/concepts/package-owned-lowering.md +175 -0
  20. package/docs/concepts/targets-and-hosts.md +62 -0
  21. package/docs/contributing/README.md +38 -0
  22. package/docs/contributing/adding-core-provider.md +315 -0
  23. package/docs/contributing/adding-first-party-lowerer.md +327 -0
  24. package/docs/contributing/entities-lowering.md +91 -0
  25. package/docs/contributing/package-lowerer-contract.md +383 -0
  26. package/docs/contributing/pulse-aware-packages.md +149 -0
  27. package/docs/examples.md +112 -0
  28. package/docs/fixtures/inspect-fetch-composition.selected.json +181 -0
  29. package/docs/getting-started.md +128 -0
  30. package/docs/guides/compatibility-imports.md +60 -0
  31. package/docs/guides/deploying-fastly.md +188 -0
  32. package/docs/guides/deploying-node.md +143 -0
  33. package/docs/guides/events.md +233 -0
  34. package/docs/guides/fastly-capabilities.md +153 -0
  35. package/docs/guides/fetching-and-composition.md +101 -0
  36. package/docs/guides/grip.md +94 -0
  37. package/docs/guides/json-schemas.md +233 -0
  38. package/docs/guides/migrating-from-express.md +192 -0
  39. package/docs/guides/project-lifecycle.md +143 -0
  40. package/docs/guides/routing.md +184 -0
  41. package/docs/guides/troubleshooting.md +47 -0
  42. package/docs/maintainers/README.md +60 -0
  43. package/docs/maintainers/codex-maintainer.md +71 -0
  44. package/docs/maintainers/documentation-deployment.md +147 -0
  45. package/docs/maintainers/documentation-system.md +58 -0
  46. package/docs/maintainers/documentation-versioning.md +65 -0
  47. package/docs/maintainers/maintainer-charter.md +84 -0
  48. package/docs/maintainers/maintenance-policy.json +778 -0
  49. package/docs/maintainers/maintenance-policy.md +124 -0
  50. package/docs/maintainers/npm-publishing.md +154 -0
  51. package/docs/maintainers/plugin-readiness.json +19 -0
  52. package/docs/maintainers/plugin-readiness.md +31 -0
  53. package/docs/maintainers/public-site.md +158 -0
  54. package/docs/maintainers/release-acceptance.md +250 -0
  55. package/docs/maintainers/release-manifest.md +88 -0
  56. package/docs/maintainers/repository-setup.md +145 -0
  57. package/docs/maintainers/scope-policy.md +93 -0
  58. package/docs/maintainers/support-and-triage.md +74 -0
  59. package/docs/maintainers/testing.md +288 -0
  60. package/docs/packages/README.md +59 -0
  61. package/docs/packages/assets.md +85 -0
  62. package/docs/packages/cli.md +190 -0
  63. package/docs/packages/crypto.md +71 -0
  64. package/docs/packages/entities.md +129 -0
  65. package/docs/packages/grip.md +82 -0
  66. package/docs/packages/implementation-packages.md +113 -0
  67. package/docs/packages/jwt.md +55 -0
  68. package/docs/packages/provider-fastly.md +217 -0
  69. package/docs/packages/pulse.md +159 -0
  70. package/docs/packages/runtime.md +256 -0
  71. package/docs/preview-scope.md +142 -0
  72. package/docs/reference/README.md +33 -0
  73. package/docs/reference/cli-spec.json +575 -0
  74. package/docs/reference/cli.md +457 -0
  75. package/docs/reference/compatibility-matrix.md +169 -0
  76. package/docs/reference/diagnostics.md +1872 -0
  77. package/docs/reference/documentation-versions.json +14 -0
  78. package/docs/reference/environment.md +347 -0
  79. package/docs/reference/handler-authoring.md +264 -0
  80. package/docs/reference/project-config.md +554 -0
  81. package/docs/reference/project-config.schema.json +918 -0
  82. package/docs/reference/release-manifest.json +427 -0
  83. package/docs/reference/shell-completion.md +23 -0
  84. package/documentation-site.json +661 -0
  85. package/documentation-versions.json +14 -0
  86. package/examples/01-hello-json/.pulse/.gitignore +3 -0
  87. package/examples/01-hello-json/.pulse/config.ts +16 -0
  88. package/examples/01-hello-json/README.md +119 -0
  89. package/examples/01-hello-json/package.json +20 -0
  90. package/examples/01-hello-json/src/index.ts +9 -0
  91. package/examples/01-hello-json/tests/pulse.harness.ts +22 -0
  92. package/examples/01-hello-json/tsconfig.json +14 -0
  93. package/examples/02-request-schema/.pulse/.gitignore +3 -0
  94. package/examples/02-request-schema/.pulse/config.ts +17 -0
  95. package/examples/02-request-schema/README.md +145 -0
  96. package/examples/02-request-schema/package.json +20 -0
  97. package/examples/02-request-schema/src/index.ts +18 -0
  98. package/examples/02-request-schema/src/schemas.ts +20 -0
  99. package/examples/02-request-schema/tests/pulse.harness.ts +37 -0
  100. package/examples/02-request-schema/tsconfig.json +14 -0
  101. package/examples/03-fetch-composition/.pulse/.gitignore +3 -0
  102. package/examples/03-fetch-composition/.pulse/config.ts +31 -0
  103. package/examples/03-fetch-composition/README.md +210 -0
  104. package/examples/03-fetch-composition/package.json +20 -0
  105. package/examples/03-fetch-composition/src/index.ts +60 -0
  106. package/examples/03-fetch-composition/tests/pulse.harness.ts +47 -0
  107. package/examples/03-fetch-composition/tsconfig.json +14 -0
  108. package/examples/05-fastly-capabilities/.pulse/.gitignore +3 -0
  109. package/examples/05-fastly-capabilities/.pulse/config.ts +57 -0
  110. package/examples/05-fastly-capabilities/README.md +257 -0
  111. package/examples/05-fastly-capabilities/package.json +22 -0
  112. package/examples/05-fastly-capabilities/src/index.ts +55 -0
  113. package/examples/05-fastly-capabilities/tests/pulse.harness.ts +66 -0
  114. package/examples/05-fastly-capabilities/tsconfig.json +14 -0
  115. package/examples/07-opaque-proxy/.pulse/.gitignore +3 -0
  116. package/examples/07-opaque-proxy/.pulse/config.ts +38 -0
  117. package/examples/07-opaque-proxy/README.md +150 -0
  118. package/examples/07-opaque-proxy/package.json +21 -0
  119. package/examples/07-opaque-proxy/src/index.ts +9 -0
  120. package/examples/07-opaque-proxy/tests/pulse.harness.ts +25 -0
  121. package/examples/07-opaque-proxy/tsconfig.json +14 -0
  122. package/examples/09-router-lowering/.pulse/.gitignore +3 -0
  123. package/examples/09-router-lowering/.pulse/config.ts +22 -0
  124. package/examples/09-router-lowering/README.md +287 -0
  125. package/examples/09-router-lowering/package.json +22 -0
  126. package/examples/09-router-lowering/src/index.ts +65 -0
  127. package/examples/09-router-lowering/tests/pulse.harness.ts +91 -0
  128. package/examples/09-router-lowering/tsconfig.json +14 -0
  129. package/examples/10-entities-tools/.pulse/.gitignore +4 -0
  130. package/examples/10-entities-tools/.pulse/config.ts +23 -0
  131. package/examples/10-entities-tools/README.md +165 -0
  132. package/examples/10-entities-tools/package.json +21 -0
  133. package/examples/10-entities-tools/src/handlers.ts +15 -0
  134. package/examples/10-entities-tools/src/index.ts +31 -0
  135. package/examples/10-entities-tools/src/schemas.ts +18 -0
  136. package/examples/10-entities-tools/tests/pulse.harness.ts +40 -0
  137. package/examples/10-entities-tools/tools-facade.cjs +158 -0
  138. package/examples/10-entities-tools/tsconfig.json +14 -0
  139. package/examples/11-events/.pulse/.gitignore +4 -0
  140. package/examples/11-events/.pulse/config.ts +24 -0
  141. package/examples/11-events/README.md +194 -0
  142. package/examples/11-events/package.json +20 -0
  143. package/examples/11-events/src/index.ts +27 -0
  144. package/examples/11-events/src/schemas.ts +19 -0
  145. package/examples/11-events/tests/pulse.harness.ts +34 -0
  146. package/examples/11-events/tsconfig.json +15 -0
  147. package/examples/12-mcp-proxy/.pulse/.gitignore +3 -0
  148. package/examples/12-mcp-proxy/.pulse/config.ts +25 -0
  149. package/examples/12-mcp-proxy/README.md +149 -0
  150. package/examples/12-mcp-proxy/package.json +20 -0
  151. package/examples/12-mcp-proxy/src/index.ts +17 -0
  152. package/examples/12-mcp-proxy/tests/pulse.harness.ts +29 -0
  153. package/examples/12-mcp-proxy/tsconfig.json +14 -0
  154. package/examples/13-jwt-es256/.pulse/config.ts +19 -0
  155. package/examples/13-jwt-es256/README.md +195 -0
  156. package/examples/13-jwt-es256/package.json +21 -0
  157. package/examples/13-jwt-es256/src/index.ts +21 -0
  158. package/examples/13-jwt-es256/tests/pulse.harness.ts +54 -0
  159. package/examples/13-jwt-es256/tsconfig.json +14 -0
  160. package/examples/README.md +36 -0
  161. package/package.json +66 -6
  162. package/project-config.schema.json +918 -0
  163. package/release-manifest.json +427 -0
  164. package/src/command-spec.js +279 -0
  165. package/src/completion.js +113 -0
  166. package/src/diagnostics.js +350 -0
  167. package/src/documentation.js +45 -0
  168. package/src/index.d.ts +133 -0
  169. package/src/index.js +15 -0
  170. package/src/internal/command-executor.d.ts +29 -0
  171. package/src/internal/command-executor.js +143 -0
  172. package/src/internal/command-plan.d.ts +9 -0
  173. package/src/internal/command-plan.js +73 -0
  174. package/src/internal/command-reporter.d.ts +15 -0
  175. package/src/internal/command-reporter.js +133 -0
  176. package/src/internal/command-request.d.ts +35 -0
  177. package/src/internal/command-request.js +154 -0
  178. package/src/internal/node-http.js +54 -0
  179. package/src/internal/project-context.d.ts +66 -0
  180. package/src/internal/project-context.js +175 -0
  181. package/src/project-config-reference.js +4 -0
  182. package/src/project-config-schema.d.ts +23 -0
  183. package/src/project-config-schema.js +271 -0
  184. package/src/project-config.js +724 -0
  185. package/src/project-execution.js +2930 -0
  186. package/src/provider-drivers.js +3 -0
  187. package/src/target-support.js +3 -0
  188. package/src/typescript-module-loader.js +269 -0
  189. package/src/workflow.js +78 -0
  190. package/src/workspace.js +82 -0
@@ -0,0 +1,91 @@
1
+ <!-- pulse-doc-meta:start
2
+ owner: docs-platform
3
+ status: active
4
+ last-reviewed: 2026-07-16
5
+ review-by: 2027-01-16
6
+ pulse-doc-meta:end -->
7
+
8
+ # Entities lowering maintainer reference
9
+
10
+ `@pulse-compute/entities` uses a synchronized, trusted first-party package
11
+ lowerer. This page records the package-specific boundary; the general protocol
12
+ remains authoritative in [Package lowerer contract](./package-lowerer-contract.md).
13
+
14
+ The package is part of the synchronized Beta release. Changes here do not alter
15
+ release membership, publish it, or make its internal toolchain subpaths a
16
+ public extension API.
17
+
18
+ ## Synchronized surfaces
19
+
20
+ | Surface | Authority |
21
+ |---|---|
22
+ | `packages/entities/pulse.package.json` | Product status, root symbols, target policy, provider requirements |
23
+ | `packages/entities/pulsewasm.manifest.cjs` | Trusted first-party manifest and compiler entry |
24
+ | `packages/entities/pulsewasm.compiler.cjs` | Static extraction, plan/catalog/inspection, managed-handler descriptors |
25
+ | `packages/entities/pulsewasm.native.cjs` | Package-owned bounded Native dispatcher source |
26
+ | `packages/entities/as/index.as.ts` | Native source template/contract input |
27
+ | `wasm/packages/contracts/src/entities/` | Versioned shared normalization, limits, JSON-RPC, catalog, and plan contracts |
28
+ | `packages/entities/conformance/i9.json` | Shared four-mode corpus/evidence declaration |
29
+
30
+ Keep product metadata, manifest exports, compiler output versions, Native
31
+ source expectations, and conformance evidence synchronized. The manifest and
32
+ compiler subpaths under the package's `pulsewasm` namespace, plus the
33
+ `./pulsewasm-native` export, are for the trusted toolchain only.
34
+
35
+ ## Static extraction contract
36
+
37
+ The lowerer may inspect source and declared schema metadata; it must not execute
38
+ application code. It accepts one module-level `const` `EntityRouter`, an inline
39
+ `jsonRpc` adapter, standalone module-level registrations, literal
40
+ discriminators, literal schema IDs or `null`, bounded static metadata,
41
+ resolvable named handlers, and one terminal request binding.
42
+
43
+ Every rejected form needs a deterministic `PULSE_ENTITIES_*` diagnostic with a
44
+ specific remediation. Never recover by evaluating dynamic source, discovering
45
+ dependencies at runtime, scanning arbitrary installed packages, or changing
46
+ the selected target.
47
+
48
+ ## Managed handlers and schemas
49
+
50
+ Each registration becomes one managed-handler descriptor. The descriptor owns
51
+ the declared input/result shape and points to one reachable named handler. The
52
+ normal reachable-graph compiler owns effects and continuations. The package
53
+ lowerer must report redacted summaries and provider requirements without
54
+ copying runtime values, raw payloads, request IDs, resolved secrets, or provider
55
+ objects into plans or inspection.
56
+
57
+ Schema codecs remain private request-bound capabilities. The adapter can decode
58
+ only the selected registration's input schema and encode only its output schema.
59
+ Do not expose codec objects, registry enumeration, raw body access, or a second
60
+ body consumer to package code.
61
+
62
+ ## Native realization
63
+
64
+ The package-owned Native source must preserve the JavaScript runtime semantics:
65
+ one bounded envelope scan, selection before schema decoding, one handler
66
+ invocation, stable failure categories, output validation, JSON-RPC framing, and
67
+ synchronous `204` notification acknowledgement. It may use only the provider
68
+ requirements declared by the package contract.
69
+
70
+ Native status remains `provider-dependent`. Node Native uses the canonical
71
+ package source. Fastly Native evidence uses an explicit provider-owned adapter
72
+ over the exact package source. Do not wire that adapter into the ordinary
73
+ Fastly project build or change the product status as part of a documentation or
74
+ candidate-seal change. Any such integration is a separately classified product
75
+ unit with provider ownership and focused tests.
76
+
77
+ ## Catalog and evidence invariants
78
+
79
+ - Catalog ordering and hashes are checkout-independent and deterministic.
80
+ - Declaration, eligibility, measured execution, and release assignment are
81
+ separate claims.
82
+ - Fastly execution evidence must name the external engine and run the generated
83
+ artifacts; compile-only evidence is insufficient.
84
+ - Every target keeps `automaticFallback: false`.
85
+ - A tools/MCP facade may consume the static catalog but does not add protocol
86
+ lifecycle state or direct handler access to Pulse runtime core.
87
+
88
+ Run the focused Entities tasks, the package/tarball clean-consumer candidate
89
+ seal, affected H5 authority gate, executable docs, aggregate profiles, and
90
+ external Viceroy evidence before recording a candidate decision. A seal may
91
+ record a blocker; it must not fix an unrelated product problem in place.
@@ -0,0 +1,383 @@
1
+ <!-- pulse-doc-meta:start
2
+ owner: docs-platform
3
+ status: active
4
+ last-reviewed: 2026-07-25
5
+ review-by: 2027-01-25
6
+ pulse-doc-meta:end -->
7
+
8
+ # Package lowerer contract reference
9
+
10
+ This reference describes the internal first-party lowerer protocol used by the
11
+ synchronized `1.0.0-beta.1` release. It documents current repository
12
+ interfaces; it is not a third-party plugin compatibility promise. Package
13
+ availability remains owned by the release catalog.
14
+
15
+ Use [Pulse-aware package authoring](./pulse-aware-packages.md) first. This
16
+ protocol is necessary only when the synchronized release deliberately adds a
17
+ bounded Native subset to an ordinary package-root JavaScript API.
18
+
19
+ ## Application promise versus internal protocol
20
+
21
+ Do not treat every file in this pipeline as one compatibility surface:
22
+
23
+ | Surface | Audience | Compatibility meaning |
24
+ |---|---|---|
25
+ | Package-root exports and documented JavaScript behavior | Application authors | The supported package API for the declared JavaScript targets. |
26
+ | Documented package-root Native subset | Application authors | A source eligibility promise backed by provider/target conformance. |
27
+ | `pulse.package.json` product metadata | Release and compiler tooling | Static synchronized-release classification; it cannot execute code. |
28
+ | `pulsewasm.manifest.cjs` and compiler builder | First-party package/compiler maintainers | An internal version-locked protocol that may change with the synchronized compiler. |
29
+ | Canonical package effects and shared feature contracts | Compiler and provider maintainers | Provider-neutral operation semantics inside the synchronized release. |
30
+ | Provider plans, bindings, and target output | Provider maintainers and deployers | Host realization, not an application import surface. |
31
+
32
+ Only explicitly documented package-root facades carry the application support
33
+ promise. Resolving a manifest, builder export, sidecar symbol, internal contract
34
+ module, or provider lowering name does not make it a public extension API.
35
+
36
+ ## Canonical owner map
37
+
38
+ The present-tense owner for each stage is:
39
+
40
+ | Concern | Canonical repository owner |
41
+ |---|---|
42
+ | Product role, target modes, and conformance IDs | `packages/<feature>/pulse.package.json` |
43
+ | Application API and JavaScript implementation | `packages/<feature>/src/` and its package exports |
44
+ | First-party manifest and builder entry | `packages/<feature>/pulsewasm.manifest.cjs` and `packages/<feature>/pulsewasm.compiler.cjs` |
45
+ | Manifest validation and trust contract | `wasm/packages/contracts/src/library/manifest.js` |
46
+ | Manifest discovery and trusted builder loading | `wasm/packages/library-kit/src/compiler/handler-library-contracts.js` |
47
+ | Reachable package/symbol ownership | `wasm/packages/compiler/src/project/package-reachability.js` |
48
+ | Per-module syntax recognition | Trusted `packages/<feature>/pulsewasm.compiler.cjs` builder |
49
+ | Builder invocation/result envelopes | `wasm/packages/contracts/src/package/package-contract.js` and `wasm/packages/library-kit/src/compiler/handler-library-contracts.js` |
50
+ | Canonical package operation, lowering bundle, and provider-requirement record | `wasm/packages/contracts/src/package/package-contract.js` |
51
+ | Recognition and whole-project orchestration | `wasm/packages/compiler/src/spine/package-operation-seam.js` |
52
+ | Feature operation and payload vocabulary | `wasm/packages/contracts/src/<feature>/contracts.js` |
53
+ | Provider-neutral whole-project composition | `wasm/packages/compiler/src/canonical-project-compiler.js` |
54
+ | Provider capability and target realization | `packages/provider-<id>/src/` |
55
+ | Public support and package availability | `release/pulse-release-manifest.json` |
56
+
57
+ Assets and GRIP are synchronized release references:
58
+ `packages/assets/pulse.package.json`,
59
+ `packages/assets/pulsewasm.manifest.cjs`,
60
+ `packages/assets/pulsewasm.compiler.cjs`,
61
+ `wasm/packages/contracts/src/assets/contracts.js`,
62
+ `packages/grip/pulse.package.json`,
63
+ `packages/grip/pulsewasm.manifest.cjs`,
64
+ `packages/grip/pulsewasm.compiler.cjs`, and
65
+ `wasm/packages/contracts/src/grip/contracts.js`.
66
+
67
+ JWT is the current cryptographic-composition reference:
68
+ `packages/jwt/pulse.package.json`,
69
+ `packages/jwt/pulsewasm.manifest.cjs`,
70
+ `packages/jwt/pulsewasm.compiler.cjs`, and
71
+ `wasm/packages/contracts/src/jwt/contracts.js`. It composes HS256 and ES256
72
+ through `@pulse-compute/crypto`; this does not make the internal protocol
73
+ independently version-compatible.
74
+
75
+ This owner map is the detailed package-lowering companion to
76
+ [Current architecture contracts](../architecture/current-contracts.md). Update
77
+ the owning source, conformance, and this reference together when the protocol
78
+ changes.
79
+
80
+ ## Contract pipeline
81
+
82
+ ```text
83
+ reachable module graph
84
+ → package binding and contract selection
85
+ → trusted manifest discovery
86
+ → package-owned static recognition
87
+ → canonical package operations
88
+ → whole-project capability envelope
89
+ → provider plan and binding validation
90
+ → JavaScript execution or Native target realization
91
+ ```
92
+
93
+ The reachable graph chooses participating package contracts and attributes
94
+ their imported symbols. Recognition then runs per reachable project module.
95
+ Manifest discovery may resolve a synchronized workspace package or an exact
96
+ installed package, but it does not make every dependency reachable and it does
97
+ not enable third-party self-registration.
98
+
99
+ ## Protocol constants
100
+
101
+ | Contract | Value |
102
+ |---|---|
103
+ | Manifest version | `pulsewasm.lowerable-library-manifest.v2` |
104
+ | Manifest kind | `pulsewasm.lowerable-library-manifest` |
105
+ | Builder protocol | `pulsewasm.lowerable-compiler-builder.v1` |
106
+ | Builder invocation | `pulse.package-builder-invocation.v1` |
107
+ | Builder result | `pulse.package-builder-result.v1` |
108
+ | Canonical package operation | `pulse.canonical-package-operation.v1` |
109
+ | Package lowering bundle | `pulse.package-lowering-bundle.v1` |
110
+ | Provider requirement record | `pulse.provider-requirement-record.v1` |
111
+ | Required trust | `first-party` |
112
+ | Canonical provider plan | `pulse.canonical-provider-plan.v1` |
113
+ | Canonical provider contract | `pulse.canonical-provider-contract.v1` |
114
+
115
+ Package-specific contract, plan, artifact, and payload versions are owned by their corresponding shared contract modules.
116
+
117
+ ## Package discovery declaration
118
+
119
+ A lowerable package declares the manifest path in `package.json`:
120
+
121
+ ```json
122
+ {
123
+ "pulsewasm": {
124
+ "manifest": "./pulsewasm.manifest.cjs"
125
+ }
126
+ }
127
+ ```
128
+
129
+ The manifest file, compiler builder, built facade, and sidecar must be included by `package.json.files` and available from an extracted npm tarball.
130
+
131
+ ## Required manifest fields
132
+
133
+ The validator requires these paths:
134
+
135
+ | Field | Meaning |
136
+ |---|---|
137
+ | `version` | Locked manifest schema version. |
138
+ | `contractId` | Stable feature contract identity. |
139
+ | `npmPackage` | Package that owns the facade and builder. |
140
+ | `lowerableSubpath` | Exact application import recognized by the compiler. |
141
+ | `facade.namespace` | Canonical namespace used by the facade. |
142
+ | `facade.symbols` | Non-empty static symbol list. |
143
+ | `modes.typescript.entry` | Normal package TypeScript/JavaScript entry. |
144
+ | `modes.jsEngine.entry` | Manual JavaScript engine entry. |
145
+ | `modes.wasm.sidecar` | Package-owned AssemblyScript sidecar path. |
146
+ | `modes.wasm.lowerings` | Non-empty facade-symbol to sidecar-symbol mappings. |
147
+ | `compiler.version` | Builder protocol version. |
148
+ | `compiler.entry` | Package-relative CommonJS builder module. |
149
+ | `compiler.export` | Exported builder function name. |
150
+ | `compiler.builderOwner` | Must equal `npmPackage`. |
151
+ | `compiler.trust` | Must be `first-party`. |
152
+
153
+ The manifest may also document public runtime symbols, compiler inputs, artifact filename, host capabilities, protocol owner, and feature policy.
154
+
155
+ ## Representative manifest
156
+
157
+ ```js
158
+ 'use strict'
159
+
160
+ module.exports = Object.freeze({
161
+ version: 'pulsewasm.lowerable-library-manifest.v2',
162
+ kind: 'pulsewasm.lowerable-library-manifest',
163
+ contractId: 'pulse.example',
164
+ npmPackage: '@pulse-compute/example',
165
+ lowerableSubpath: '@pulse-compute/example',
166
+ facade: Object.freeze({
167
+ namespace: 'example',
168
+ import: '@pulse-compute/example',
169
+ symbols: Object.freeze(['emit']),
170
+ }),
171
+ compiler: Object.freeze({
172
+ version: 'pulsewasm.lowerable-compiler-builder.v1',
173
+ entry: './pulsewasm.compiler.cjs',
174
+ export: 'buildExampleLoweringPlan',
175
+ artifact: 'example-lowering-plan.json',
176
+ builderOwner: '@pulse-compute/example',
177
+ trust: 'first-party',
178
+ }),
179
+ modes: Object.freeze({
180
+ typescript: Object.freeze({ entry: './dist/index.js' }),
181
+ jsEngine: Object.freeze({ entry: './dist/index.js' }),
182
+ wasm: Object.freeze({
183
+ mode: 'wasm-sidecar',
184
+ sidecar: './as/index.as.ts',
185
+ lowerings: Object.freeze([
186
+ Object.freeze({
187
+ tsSymbol: 'example.emit',
188
+ asSymbol: 'pulse_example_emit',
189
+ callShape: 'literal-topic-message',
190
+ hostCapabilities: Object.freeze(['example']),
191
+ }),
192
+ ]),
193
+ hostCapabilities: Object.freeze(['example']),
194
+ }),
195
+ }),
196
+ })
197
+ ```
198
+
199
+ ## Validation rules
200
+
201
+ The manifest validator additionally enforces:
202
+
203
+ - non-empty string identities and paths;
204
+ - a valid facade symbol array;
205
+ - static `tsSymbol` and `asSymbol` values for each lowering;
206
+ - valid optional public API symbol arrays;
207
+ - owner equality between `npmPackage` and `compiler.builderOwner`;
208
+ - first-party trust;
209
+ - normalization of TypeScript, JavaScript-engine, and Wasm mode objects.
210
+
211
+ A manifest validation error prevents builder execution.
212
+
213
+ ## Builder resolution
214
+
215
+ The generic library kit resolves:
216
+
217
+ 1. the package manifest record;
218
+ 2. its package-relative compiler entry;
219
+ 3. the named export;
220
+ 4. the trust and owner declaration;
221
+ 5. shared library contracts.
222
+
223
+ It invokes the builder with this exact shared field set:
224
+
225
+ ```js
226
+ {
227
+ version,
228
+ cwd,
229
+ workspaceRoot,
230
+ sourcePath,
231
+ sourceText,
232
+ sourceFile,
233
+ typescript,
234
+ manifest,
235
+ libraryContracts,
236
+ packageCompilerBuilder: {
237
+ owner,
238
+ entry,
239
+ export,
240
+ trust,
241
+ },
242
+ generatedBy,
243
+ routePlan,
244
+ schemaBundle,
245
+ }
246
+ ```
247
+
248
+ The top-level envelope and normalized data values are immutable. `sourceFile`
249
+ and `typescript` are the only compiler-owned syntax references; no `Program`,
250
+ type checker, language service, cache, CLI configuration, provider object,
251
+ target descriptor, runtime object, or resolved secret crosses the seam.
252
+ Builders should tolerate either `sourceText`/`sourcePath` or the supplied
253
+ `sourceFile` according to their maintained tests.
254
+
255
+ ## Builder result
256
+
257
+ A successful package invocation is normalized before compiler orchestration:
258
+
259
+ ```js
260
+ {
261
+ version: 'pulse.package-builder-result.v1',
262
+ contractId: 'pulse.example',
263
+ npmPackage: '@pulse-compute/example',
264
+ lowerableSubpath: '@pulse-compute/example',
265
+ artifact: { /* package-owned, versioned, owner-checked */ },
266
+ contributions: {
267
+ canonicalEffects: [],
268
+ canonicalIntrinsics: [],
269
+ resultAdapters: [],
270
+ schemaReferences: [],
271
+ cryptoRequirements: [],
272
+ realizationArtifacts: [],
273
+ guestUnits: [],
274
+ },
275
+ diagnostics: [],
276
+ warnings: [],
277
+ hasErrors: false,
278
+ }
279
+ ```
280
+
281
+ Exact artifact fields beyond shared ownership/status metadata remain
282
+ package-contract-owned. Compiler orchestration consumes only the normalized
283
+ `contributions` fields; it does not fall back to package artifact entries.
284
+ Unknown result fields, owner/version mismatches, provider/compiler object
285
+ bleed, and disagreement between diagnostics and `hasErrors` fail at this
286
+ receiving boundary.
287
+
288
+ ## Canonical package effect
289
+
290
+ A package effect passed into provider planning has this conceptual shape:
291
+
292
+ ```js
293
+ {
294
+ version: 'pulse.canonical-package-effect.v1',
295
+ contractId: 'pulse.example',
296
+ package: '@pulse-compute/example',
297
+ import: '@pulse-compute/example',
298
+ kind: 'example.emit',
299
+ providerKind: 'example',
300
+ operation: 'emit',
301
+ capability: 'example.emit',
302
+ result: 'ack',
303
+ placement: 'statement',
304
+ resource: { kind: 'literal', value: 'updates' },
305
+ payload: { topic: 'updates', message: 'ready' },
306
+ range: { start: 100, end: 142 },
307
+ loc: { file: 'src/index.ts', line: 5, column: 3 },
308
+ }
309
+ ```
310
+
311
+ Required semantics:
312
+
313
+ - the effect uses the shared canonical-effect version and exact allowed fields;
314
+ - `contractId`, `package`, and `import` exactly match the selected manifest;
315
+ - `kind`, `operation`, and `capability` agree with contract vocabulary;
316
+ - `resource` and `payload` contain normalized, serializable data;
317
+ - `result` identifies the normalized result class;
318
+ - source range/location points to the author call;
319
+ - no provider-specific object or lowering name appears in the effect.
320
+
321
+ The shared package contract converts this effect into the exact versioned
322
+ canonical operation, derives deterministic identity/order, sorts capability
323
+ sets, clones immutable data, and rejects unknown fields. The compiler
324
+ orchestrates that normalizer; it does not redefine the operation, lowering
325
+ bundle, catalog, or provider-requirement identities.
326
+
327
+ ## Diagnostics
328
+
329
+ Package builders use source-located internal diagnostics for unsupported facade syntax. The contract module should own stable internal code names and payload status vocabulary.
330
+
331
+ When a package failure is surfaced through the public CLI, the CLI wraps it in [`PULSE_PACKAGE_LOWERING_FAILED`](../reference/diagnostics.md#pulse-package-lowering-failed). Provider-visible missing capability or binding failures use their corresponding public `PULSE_*` entries.
332
+
333
+ Do not publish internal `PULSEWASM_*` proof codes as stable public diagnostic URLs unless they are deliberately promoted into the public catalog.
334
+
335
+ ## Sidecar lowering declaration
336
+
337
+ Each `modes.wasm.lowerings[]` entry binds a TypeScript facade symbol to a stable AssemblyScript export:
338
+
339
+ ```js
340
+ {
341
+ tsSymbol: 'example.emit',
342
+ asSymbol: 'pulse_example_emit',
343
+ callShape: 'literal-topic-message',
344
+ hostCapabilities: ['example'],
345
+ }
346
+ ```
347
+
348
+ The sidecar should expose the declared `asSymbol`, call stable named host imports, and remain free of application-level discovery or provider SDK logic.
349
+
350
+ ## Compiler-core separation
351
+
352
+ The generic loader may contain protocol terms such as manifest, builder, trust, and contract. It must not contain feature strings such as `grip.hold`, `assets.lookup`, or the example package import.
353
+
354
+ A release test should inspect generic loader/compiler source to enforce that separation for each new lowerer.
355
+
356
+ The late package-operation seam receives canonical operations, not a
357
+ package-specific source AST or source text. Package-specific syntax recognition
358
+ belongs to the trusted builder before provider planning; provider-specific
359
+ lowering belongs after the complete capability envelope is known.
360
+
361
+ ## Provider contract
362
+
363
+ Package effects emit provider-neutral requirements. After the complete
364
+ reachable program exists, compiler/provider eligibility validates those
365
+ requirements through the canonical provider descriptor. The provider must map
366
+ every required capability, plus any result capability such as
367
+ `opaque.pass-through`.
368
+
369
+ Package lowerer code must not choose `node.*`, `fastly.*`, backend names, store names, or deployment resources. Those belong to the provider plan.
370
+
371
+ ## Compatibility status
372
+
373
+ This protocol is synchronized inside the `1.0.0-beta.1` release set. It can change with compiler implementation needs. Only explicitly documented application facades carry the package support promise.
374
+
375
+ A public external lowerer API would require a new contract that addresses trust, sandboxing, provenance, protocol negotiation, resource limits, lifecycle support, and semver compatibility.
376
+
377
+ ## Related documentation
378
+
379
+ - [Pulse-aware package authoring](./pulse-aware-packages.md)
380
+ - [Package-owned lowering concept](../concepts/package-owned-lowering.md)
381
+ - [Add a first-party package-owned lowerer](./adding-first-party-lowerer.md)
382
+ - [Package support policy](../packages/README.md)
383
+ - [Implementation packages](../packages/implementation-packages.md)
@@ -0,0 +1,149 @@
1
+ <!-- pulse-doc-meta:start
2
+ owner: docs-platform
3
+ status: active
4
+ last-reviewed: 2026-07-25
5
+ review-by: 2027-01-25
6
+ pulse-doc-meta:end -->
7
+
8
+ # Pulse-aware package authoring
9
+
10
+ A Pulse-aware package begins as an ordinary JavaScript package with a real
11
+ package-root API. Native lowering is an additional bounded realization, not a
12
+ second application-facing facade and not a requirement for JavaScript use.
13
+
14
+ ```text
15
+ ordinary package API
16
+ + real JavaScript implementation
17
+ + bounded Native-lowerable subset
18
+ + package contract
19
+ + trusted compiler builder
20
+ + provider requirements
21
+ + cross-target conformance
22
+ ```
23
+
24
+ ## Choose the extension boundary
25
+
26
+ | Goal | Current boundary |
27
+ |---|---|
28
+ | Provide ordinary library behavior on JavaScript targets | Publish a normal target-compatible JavaScript package API. |
29
+ | Add package-root Native lowering to the synchronized Pulse release | Use the trusted first-party package-lowerer contract and release process. |
30
+ | Add a project-owned execution provider | Export the versioned provider `./toolchain` contract from an exact scoped package. |
31
+ | Load an arbitrary npm compiler plugin or lowerer | Not supported. |
32
+ | Self-register a provider by scanning dependencies or package metadata | Not supported. |
33
+
34
+ Provider toolchains and package lowerers are separate extension systems. A
35
+ provider realizes canonical capabilities and target artifacts. A package
36
+ lowerer recognizes a bounded package-root call and emits canonical package
37
+ effects. Neither mechanism grants provider SDK access to handlers.
38
+
39
+ ## 1. Design the package root first
40
+
41
+ The package root owns the application API:
42
+
43
+ ```ts
44
+ import { feature } from '@example/pulse-feature'
45
+ ```
46
+
47
+ For JavaScript targets, ship a real implementation with ordinary types,
48
+ runtime code, tests, and target-compatible dependencies. Pulse's Node and
49
+ Fastly JavaScript packagers include reachable dependencies, but each runtime
50
+ still has its own platform constraints. A Node-specific package is not
51
+ automatically Fastly-compatible.
52
+
53
+ Keep authority explicit:
54
+
55
+ - accept `ctx` only when the operation needs a request-owned Pulse effect;
56
+ - keep pure framing and result adapters independent of ambient state;
57
+ - do not read provider SDK objects, `process.env`, global network authority, or
58
+ mutable request globals from canonical APIs;
59
+ - document which JavaScript targets the implementation actually supports.
60
+
61
+ Independent packages may stop here. They do not need a compiler builder merely
62
+ to work on an explicitly selected compatible JavaScript target.
63
+
64
+ ## 2. Define the Native subset separately
65
+
66
+ If the synchronized Pulse release needs Native support, define a smaller static
67
+ subset of the same package-root API:
68
+
69
+ - exact package-root import and symbol identities;
70
+ - supported call placement;
71
+ - literal or statically bounded arguments;
72
+ - canonical operation, payload, result, and capability vocabulary;
73
+ - source-located diagnostics for unsupported shapes;
74
+ - provider requirements and result ownership;
75
+ - optional sidecar ABI symbols.
76
+
77
+ The JavaScript implementation may remain broader. Unsupported Native shapes
78
+ make that project ineligible for Native selection; they do not trigger target
79
+ fallback.
80
+
81
+ ## 3. Keep contract and execution owners distinct
82
+
83
+ | Concern | Owner |
84
+ |---|---|
85
+ | Public package-root API and JavaScript implementation | Feature package |
86
+ | Operation, payload, result, and diagnostic vocabulary | Shared package contract |
87
+ | Native call-shape recognition | Package-owned compiler builder |
88
+ | Manifest discovery and trusted builder loading | Generic library kit |
89
+ | Whole-project effect and continuation composition | Canonical compiler |
90
+ | Capability and binding realization | Selected provider |
91
+ | Product support, packing, docs, and acceptance | Synchronized release |
92
+
93
+ Compiler core may combine package effects but must not absorb package-specific
94
+ symbol names, payload rules, or provider lowering names.
95
+
96
+ ## 4. Understand the trust boundary
97
+
98
+ Package-root Native lowering is a real executable compiler contract inside the
99
+ synchronized release. The builder runs as trusted build code, so the Developer
100
+ Preview requires:
101
+
102
+ - `compiler.trust: 'first-party'`;
103
+ - builder ownership equal to the npm package owner;
104
+ - exact versioned manifest and builder protocols;
105
+ - checked-in synchronized source and release evidence;
106
+ - packed-package discovery and conformance tests.
107
+
108
+ This is not a public third-party plugin API. Arbitrary lowerer loading would
109
+ need discovery, provenance, isolation, resource limits, protocol negotiation,
110
+ compatibility, and failure-containment design.
111
+
112
+ The provider-toolchain boundary is different. A project may name an exact scoped provider package
113
+ whose versioned `./toolchain` export Pulse loads directly.
114
+ That package also executes as trusted project build code. It does not
115
+ self-register, create a public lowerer, or enter handler source.
116
+
117
+ ## 5. Prove each advertised target
118
+
119
+ For each claimed mode, test the layer that actually executes:
120
+
121
+ - package-root JavaScript behavior on Node and/or Fastly;
122
+ - positive and negative Native static shapes;
123
+ - direct await and `ctx.parallel` for request-bound package effects;
124
+ - package contract and manifest validation;
125
+ - provider capability and binding behavior;
126
+ - structured or opaque result ownership;
127
+ - cross-target semantic conformance;
128
+ - deterministic source and target packaging;
129
+ - isolated packed dependency discovery;
130
+ - explicit unsupported-form diagnostics.
131
+
132
+ Do not infer a support claim from a resolvable export or an SDK feature.
133
+
134
+ ## Existing first-party patterns
135
+
136
+ Assets demonstrates a package-root JavaScript implementation, Native lookup
137
+ lowering, and opaque response adoption. GRIP demonstrates pure package-root
138
+ framing, request-bound broadcast, provider requirements, and bounded Native
139
+ lowering. Compatibility-only `/pulsewasm` imports remain isolated in the
140
+ [migration guide](../guides/compatibility-imports.md).
141
+
142
+ Continue with:
143
+
144
+ - [Package lowerer contract reference](./package-lowerer-contract.md);
145
+ - [Add a first-party package-owned lowerer](./adding-first-party-lowerer.md);
146
+ - [Add a provider toolchain](./adding-core-provider.md);
147
+ - [Package-owned lowering](../concepts/package-owned-lowering.md);
148
+ - [Managed handler TypeScript and JavaScript](../reference/handler-authoring.md);
149
+ - [Provider and target compatibility](../reference/compatibility-matrix.md).