@pulse-compute/runtime 0.0.0 → 1.0.0-beta.2

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
@@ -1,3 +1,127 @@
1
- # @pulse-compute/runtime
1
+ # `@pulse-compute/runtime`
2
2
 
3
- This is an inert namespace-bootstrap package. It contains no executable code.
3
+ <!-- pulse-package-status:start -->
4
+ > **Support tier:** Canonical application surface<br>
5
+ > **Audience:** Pulse application authors and library authors who type portable handlers and static routers.<br>
6
+ > **Install directly:** Yes. Install it in every Pulse application.<br>
7
+ > **Supported entry points:** `@pulse-compute/runtime`<br>
8
+ > **Stability:** Supported application authoring and execution contract.<br>
9
+ > **npm:** [`@pulse-compute/runtime`](https://www.npmjs.com/package/@pulse-compute/runtime)<br>
10
+ > **Canonical documentation:** [Package guide](https://pulsecompute.io/v1.0.0-beta.2/packages/runtime/)
11
+ >
12
+ > This release-status block is generated from the synchronized `Pulse 1.0.0-beta.2` package policy.
13
+ <!-- pulse-package-status:end -->
14
+
15
+ `@pulse-compute/runtime` is the low-level, provider-neutral Pulse application contract.
16
+
17
+ ```ts
18
+ import { Router } from '@pulse-compute/runtime'
19
+
20
+ const app = new Router()
21
+
22
+ app.get('/health', async (ctx) => {
23
+ return ctx.json({ ok: true })
24
+ })
25
+
26
+ export default app
27
+ ```
28
+
29
+ The source grammar distinguishes:
30
+
31
+ - synchronous metadata, route parameters, response construction, and `ctx.state`;
32
+ - awaited request-body and capability effects;
33
+ - terminal unawaited `return next()` and `return next(error)` transfers.
34
+
35
+ `ctx.state` is a request-local string map exposed through `get` and `set`. Canonical Node and native Wasm execution preserve it across effect continuation resume and isolate it between requests.
36
+
37
+ ## TypeScript semantic authority
38
+
39
+ The package-internal JavaScript dispatcher and the native compiler implement the
40
+ same public authoring contract. The public root does not publish `handle()`,
41
+ lifecycle, raw host access, or provider authority. Both realizations retain route
42
+ ordering, path/mount behavior, request-local state sharing, Web Request/Response
43
+ boundaries, and error recovery under the current contracts:
44
+
45
+ - `next()` is terminal and forward-only;
46
+ - authored throws and implicit fallthrough remain rejected;
47
+ - lifecycle belongs to providers;
48
+ - dynamic context decoration and generic session/gateway state do not return to
49
+ the portable core;
50
+ - effects, package operations, and provider requirements remain owned by their
51
+ sealed contracts.
52
+
53
+ The active package remains the one core type authority. Pulse-prefixed handler
54
+ aliases refer to the existing handler algebra rather than introducing parallel
55
+ interfaces.
56
+
57
+
58
+ ## Package-internal JavaScript realization
59
+
60
+ The package contains a live Router/context implementation used by package-local
61
+ contract tests and the explicit Node and Fastly JavaScript targets. It supports registration,
62
+ scoped middleware, mounts, parameters, terminal forward transfer, error recovery,
63
+ request-local string state, response helpers, and provider-injected effects.
64
+
65
+ This is deliberately not a new public application execution method. `Router` still
66
+ exposes only the portable authoring surface, and providers remain responsible for
67
+ request adaptation, lifecycle, and capability injection.
68
+
69
+ The provider-maintainer subpath `@pulse-compute/runtime/host` validates and executes
70
+ a Router, Pulse application, or managed handler without adding `handle`, `bind`,
71
+ `listen`, or `serve` to the application object. JavaScript providers plan and
72
+ load source applications, adapt their request boundary, and own their development
73
+ lifecycle. The runtime root still exposes no lifecycle methods.
74
+
75
+
76
+ ## Synchronous logging
77
+
78
+ Every context exposes string-only `ctx.log.error`, `warn`, `info`, and `debug`
79
+ methods. The flat profile `reporting` threshold defaults to `info`. Native
80
+ lowering removes disabled calls and emits enabled messages through `pulse_log`;
81
+ JavaScript targets filter through the same level contract at runtime. Logging is
82
+ not an effect, never suspends a handler, and a provider sink failure does not fail
83
+ the request. Known request secrets are redacted before managed emission.
84
+
85
+
86
+ ## Shared effect adapter and portable concurrency
87
+
88
+ JavaScript host operations route through one request-owned effect adapter. The
89
+ adapter owns deterministic request-local identities, cancellation,
90
+ settlement, pending-work containment, bounded observations, and one-time cleanup.
91
+ Provider and package implementations use this internal boundary; applications do
92
+ not import it.
93
+
94
+ Use a fixed keyed object with `ctx.parallel({ ... })` when concurrency itself is
95
+ portable application behavior:
96
+
97
+ ```ts
98
+ const { profile, flags } = await ctx.parallel({
99
+ profile: ctx.fetch('https://api.example.test/profile').json<Profile>(),
100
+ flags: ctx.fetch('https://api.example.test/flags').json<Flags>(),
101
+ })
102
+ ```
103
+
104
+ The initial contract requires a nonempty inline object literal with fixed,
105
+ non-index string keys and Pulse effect expressions as values. Property order owns
106
+ dispatch identity, result reconstruction, trace order, and deterministic primary
107
+ failure selection. Every member settles before continuation. Arrays, spreads,
108
+ computed keys, methods, accessors, dynamic records, arbitrary promises, reused
109
+ effect roots, and nested groups are outside the portable shape.
110
+
111
+ Separate JavaScript awaits retain ordinary sequential JavaScript behavior. Native
112
+ lowering may still group adjacent eligible effects for performance; that implicit
113
+ grouping is not the portable concurrency contract. General JavaScript target
114
+ availability is owned by the explicit target-support gates.
115
+
116
+ ## Provider-maintainer host bridge
117
+
118
+ `@pulse-compute/runtime/host` is a non-root provider-maintainer subpath. It
119
+ validates managed application exports and executes the same live
120
+ Router implementation through Web `Request`/`Response` boundaries. The root
121
+ runtime export remains unchanged, and application objects still expose no
122
+ `handle`, `bind`, `listen`, or `serve` methods.
123
+
124
+ The host bridge is substrate for provider realizations. It is not a public
125
+ application lifecycle API. Node and Fastly request adapters and provider-owned
126
+ development servers use it under the current four-mode parity and target-support
127
+ gates.