@jfrz38/adaptive-admission-node 0.0.0-stage → 0.1.0

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/COMPONENT.md ADDED
@@ -0,0 +1,60 @@
1
+ # Embedded stable component
2
+
3
+ The npm package embeds a WebAssembly component built from an exact crates.io dependency. Installing
4
+ or using the package does not require Cargo or a Rust toolchain.
5
+
6
+ | Field | Value |
7
+ | --- | --- |
8
+ | Registry | `https://crates.io` |
9
+ | Crate | `adaptive-admission-core` |
10
+ | Crate version | `0.1.0` |
11
+ | Crate owner | `jfrz38` |
12
+ | Crate checksum | `823b1ca077228a3fd229aad05e958e585663072571f0f7709bdbfb70f28dab90` |
13
+ | Upstream repository | `https://github.com/jfrz38/adaptive-admission-controller` |
14
+ | Upstream commit | `b821533645e6dfbfb611b9459345d0e5030bf83a` |
15
+ | WIT world | `jfrz38:adaptive-admission/adaptive-admission@0.1.0` |
16
+ | Rust | `rustc 1.99.0 (b940084d7 2026-09-28)` |
17
+ | Cargo | `cargo 1.99.0 (5f94df478 2026-08-27)` |
18
+ | wasm-tools | `1.262.0` |
19
+ | wit-bindgen | `0.63.0` |
20
+ | jco-transpile | `0.20.0` |
21
+
22
+ The resulting component SHA-256 is:
23
+
24
+ ```text
25
+ cbb610c98d9a53efa04379bfc9cb21bd8acbcfe9680c3f052daa4082e496fd6a
26
+ ```
27
+
28
+ `component/COMPONENT.json` relates the crate, build manifest, upstream release manifest, WIT,
29
+ conformance suite, toolchain, and generated artifact. Host generation fails before transpilation if
30
+ any checksum or required contract operation differs. `make verify-node-component` additionally
31
+ rebuilds and validates the component, then checks its exact SHA-256 against the value recorded for
32
+ the current build host. Rust/LLVM can emit different Wasm bytes on Windows and Linux even for the
33
+ same `wasm32-unknown-unknown` inputs, so both host-specific reproducible hashes are recorded in the
34
+ build manifest. The committed npm artifact's exact checksum is always verified separately.
35
+
36
+ ## Updating the component
37
+
38
+ 1. Confirm the new `adaptive-admission-core` version, owner, checksum, release commit, and WIT.
39
+ 2. Set an exact `=X.Y.Z` dependency in `component-build/Cargo.toml` and update the WIT package
40
+ version when required.
41
+ 3. Run `cargo update --manifest-path code/hosts/node/component-build/Cargo.toml -p
42
+ adaptive-admission-core --precise X.Y.Z` so Cargo records the registry checksum.
43
+ 4. Build with the pinned Rust and wasm-tools versions, validate the component, and replace the
44
+ versioned artifact under `component/`.
45
+ 5. Update `adaptive-admission-build-vX.Y.Z.json`, `COMPONENT.json`, `SHA256SUMS`, and this document.
46
+ 6. Run `make verify-node-component`, `make validate-node`, and `make test-consumer-packages`.
47
+
48
+ There is no fallback to a Git branch. A rollback repeats this procedure with a previously published
49
+ exact crate version and produces a new npm package release; mutable Git references are never used as
50
+ the component source.
51
+
52
+ ## Retiring the TypeScript package
53
+
54
+ After Node `0.1.0`, Express `0.2.0`, and NestJS `0.2.0` are published successfully from `main`, the
55
+ old package can be marked deprecated without deleting its existing versions:
56
+
57
+ ```bash
58
+ npm deprecate '@jfrz38/pid-controller-core@*' \
59
+ 'Deprecated: use @jfrz38/adaptive-admission-node or the Express/NestJS adapters.'
60
+ ```
package/README.md CHANGED
@@ -1,3 +1,172 @@
1
- # Temporary Holding Version
1
+ # Adaptive Admission Controller for Node.js
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/@jfrz38/adaptive-admission-node)](https://www.npmjs.com/package/@jfrz38/adaptive-admission-node)
4
+ [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/jfrz38/rate-limit-pid-controller/build-adaptive-admission-node.yml)](https://github.com/jfrz38/rate-limit-pid-controller/actions/workflows/build-adaptive-admission-node.yml)
5
+ [![types](https://img.shields.io/npm/types/@jfrz38/adaptive-admission-node)](https://www.npmjs.com/package/@jfrz38/adaptive-admission-node)
6
+ [![license](https://img.shields.io/npm/l/@jfrz38/adaptive-admission-node)](https://github.com/jfrz38/rate-limit-pid-controller/blob/main/LICENSE)
7
+ [![NPM Downloads](https://img.shields.io/npm/dm/@jfrz38/adaptive-admission-node)](https://www.npmjs.com/package/@jfrz38/adaptive-admission-node)
8
+
9
+ ESM-only Node.js host for the portable
10
+ [`adaptive-admission-controller`](https://github.com/jfrz38/adaptive-admission-controller)
11
+ WebAssembly component. Node.js 24 or newer is required.
12
+
13
+ The component owns admission, priority queueing, concurrency, statistics, PID feedback, adaptive
14
+ timeouts, and automatic tuning. This package owns JavaScript tasks, promises, monotonic time, and
15
+ the timer that drives component deadlines.
16
+
17
+ The embedded component is built reproducibly from the exact crates.io dependency recorded in
18
+ [COMPONENT.md](./COMPONENT.md).
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ pnpm add @jfrz38/adaptive-admission-node
24
+ ```
25
+
26
+ The package is ESM-only:
27
+
28
+ ```ts
29
+ import { AdaptiveAdmissionController, Priority } from '@jfrz38/adaptive-admission-node';
30
+ ```
31
+
32
+ CommonJS `require()` is not supported.
33
+
34
+ ## Execute work
35
+
36
+ ```ts
37
+ const controller = new AdaptiveAdmissionController();
38
+
39
+ try {
40
+ const result = await controller.run(
41
+ async () => performWork(),
42
+ Priority.fromTier(1, 0),
43
+ );
44
+ console.log(result);
45
+ } finally {
46
+ controller.shutdown();
47
+ }
48
+ ```
49
+
50
+ Synchronous return values and promises are supported. If the task throws or rejects, its original
51
+ error is preserved after the component records the failed outcome.
52
+
53
+ ## Priorities
54
+
55
+ Priorities range from `0` (most important) to `767` (least important). Work waiting for capacity is
56
+ ordered by priority and FIFO within the same priority.
57
+
58
+ ```ts
59
+ Priority.fromValue(10);
60
+ Priority.fromTier(2, 42); // Six tiers, each with 128 cohorts.
61
+ Priority.default(); // Tier 5 with a random cohort.
62
+ ```
63
+
64
+ ## Cancellation
65
+
66
+ Pass an `AbortSignal` as a run option:
67
+
68
+ ```ts
69
+ const abortController = new AbortController();
70
+ const result = controller.run(
71
+ () => performWork(),
72
+ Priority.fromValue(100),
73
+ { signal: abortController.signal },
74
+ );
75
+
76
+ abortController.abort();
77
+ await result;
78
+ ```
79
+
80
+ An already-aborted signal prevents submission. Aborting queued work removes it from the component
81
+ queue and rejects with `CancelledRequestError`. JavaScript work that has already started cannot be
82
+ interrupted by the controller and is allowed to finish.
83
+
84
+ ## Configuration
85
+
86
+ Omitted values use the defaults defined by the pinned Rust component.
87
+
88
+ | Option | Default | Purpose |
89
+ | --- | ---: | --- |
90
+ | `initialThreshold` | `768` | Initial admission boundary; priorities below it are admitted. |
91
+ | `maxConcurrentRequests` | `10` | Initial number of tasks allowed to run concurrently. |
92
+ | `maxQueuedRequests` | `1000` | Maximum number of tasks waiting for capacity. |
93
+ | `queueTimeoutMs` | `500` | Initial queue deadline in milliseconds. |
94
+ | `queueTimeoutRatio` | `0.33` | Ratio used to adapt queue deadlines from observed latency. |
95
+ | `statistics.minWindowMs` | `2000` | Minimum statistics window duration. |
96
+ | `statistics.maxWindowMs` | `30000` | Maximum statistics window duration. |
97
+ | `statistics.minSamples` | `250` | Successful samples needed to close a ready window. |
98
+ | `statistics.minPercentileSamples` | `250` | Priority samples needed for percentile decisions. |
99
+ | `statistics.maxSamples` | `1000` | Maximum samples retained per window. |
100
+ | `statistics.latencyPercentile` | `90` | Latency percentile used by adaptive control. |
101
+ | `pid.proportionalGain` | `0.2` | PID proportional gain. |
102
+ | `pid.integralGain` | `0.5` | PID integral gain. |
103
+ | `pid.derivativeGain` | `0` | PID derivative gain. |
104
+ | `pid.intervalMs` | `500` | PID evaluation interval. |
105
+ | `pid.maxDeltaPercentage` | `10` | Maximum threshold change per PID update. |
106
+ | `pid.integralDecay` | `0.5` | Decay applied to accumulated integral error. |
107
+
108
+ Integer fields represented as WIT `u64` accept a safe JavaScript integer or `bigint`. Invalid host
109
+ values throw `RangeError`; values rejected by the component throw `ConfigurationError`.
110
+
111
+ ## Errors
112
+
113
+ | Error | Meaning |
114
+ | --- | --- |
115
+ | `AdmissionRequestError` | Base class for request rejection, eviction, cancellation, and shutdown errors. |
116
+ | `ThresholdRejectedError` | Priority was outside the current admission threshold. |
117
+ | `QueueFullError` | The bounded waiting queue was full. |
118
+ | `EvictedRequestError` | Queued work exceeded its deadline. |
119
+ | `CancelledRequestError` | Queued work was explicitly cancelled. |
120
+ | `ControllerShutdownError` | Work was queued or submitted after shutdown. |
121
+ | `ConfigurationError` | Rust rejected the supplied configuration. |
122
+ | `ControllerProtocolError` | The component detected an invalid lifecycle transition. |
123
+
124
+ All package errors extend `AdaptiveAdmissionError`. Request lifecycle errors extend
125
+ `AdmissionRequestError`; configuration and protocol failures do not. Errors thrown by the user's
126
+ task remain distinct and are preserved unchanged.
127
+
128
+ ## Lifecycle and shutdown
129
+
130
+ Each controller owns independent queue, PID, statistics, and timer state. Call `shutdown()` during
131
+ service teardown. It is idempotent, rejects new work, cancels queued work, clears unnecessary
132
+ deadlines, and allows already-started JavaScript tasks to finish.
133
+
134
+ One controller limits only its current Node.js process or worker. Instances do not coordinate
135
+ limits across workers, processes, containers, or hosts.
136
+
137
+ ## Diagnostics
138
+
139
+ Operational tools can subscribe to low-volume events:
140
+
141
+ ```ts
142
+ const unsubscribe = controller.onDiagnostic((event) => {
143
+ console.log(event);
144
+ });
145
+
146
+ unsubscribe();
147
+ ```
148
+
149
+ Events include `threshold-changed`, `concurrency-changed`, `statistics-published`, and
150
+ `controller-diagnostics`. Listener failures are isolated and cannot change admission decisions or
151
+ task outcomes. Diagnostics are intended for observability and simulations, not admission logic.
152
+
153
+ `latestStatistics()` returns the latest completed statistics window, while
154
+ `priorityPercentile(percentile)` queries recently observed priorities.
155
+
156
+ ## Component provenance
157
+
158
+ Builds read `component/COMPONENT.json`, validate every artifact checksum, compare the embedded WIT
159
+ export with the checked-in contract, and verify both upstream release and local build provenance
160
+ before transpilation. `make verify-node-component` rebuilds the committed artifact from the exact
161
+ crates.io package, locked transitive dependencies, and pinned toolchain. Generated JavaScript and
162
+ WebAssembly modules are included in the npm tarball, so consumers do not need Cargo or Rust.
163
+
164
+ ## More information
165
+
166
+ For an overview of the PID-based admission-control strategy, motivation, and references, see the
167
+ [main project documentation](https://github.com/jfrz38/rate-limit-pid-controller).
168
+
169
+ ## License
170
+
171
+ Distributed under the
172
+ [MIT License](https://github.com/jfrz38/rate-limit-pid-controller/blob/main/LICENSE).
@@ -0,0 +1,44 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "source": {
4
+ "type": "crates-io",
5
+ "registry": "https://crates.io",
6
+ "crate": "adaptive-admission-core",
7
+ "version": "0.1.0",
8
+ "checksum": "823b1ca077228a3fd229aad05e958e585663072571f0f7709bdbfb70f28dab90",
9
+ "owner": "jfrz38",
10
+ "repository": "https://github.com/jfrz38/adaptive-admission-controller",
11
+ "commit": "b821533645e6dfbfb611b9459345d0e5030bf83a"
12
+ },
13
+ "component": {
14
+ "version": "0.1.0",
15
+ "package": "jfrz38:adaptive-admission@0.1.0",
16
+ "world": "adaptive-admission",
17
+ "artifact": "adaptive-admission-component-v0.1.0.wasm",
18
+ "sha256": "cbb610c98d9a53efa04379bfc9cb21bd8acbcfe9680c3f052daa4082e496fd6a"
19
+ },
20
+ "wit": {
21
+ "artifact": "adaptive-admission-world-v0.1.0.wit",
22
+ "sha256": "703d66043f9e2d2bedf92ef97a9ef2618eed1b25eef5c68e2e53fa35d9ca81da"
23
+ },
24
+ "conformance": {
25
+ "artifact": "adaptive-admission-conformance-v0.1.0.tar.gz",
26
+ "sha256": "391fe104d81802338abe060dcb58e9977c586a292617ac1813bad74863fd855c"
27
+ },
28
+ "upstreamRelease": {
29
+ "artifact": "adaptive-admission-release-v0.1.0.json",
30
+ "sha256": "a084431091a1262202dc19883b67acbe39aa17bd3cf726bcffff9cc64581ddd2"
31
+ },
32
+ "buildManifest": {
33
+ "artifact": "adaptive-admission-build-v0.1.0.json",
34
+ "sha256": "1eb7005a204f0911c2d1bfe38edcaac1a5542fc63355ea30ceb7092c8b7a7981"
35
+ },
36
+ "toolchain": {
37
+ "rust": "rustc 1.99.0 (b940084d7 2026-09-28)",
38
+ "cargo": "cargo 1.99.0 (5f94df478 2026-08-27)",
39
+ "wasmTools": "wasm-tools 1.262.0",
40
+ "witBindgen": "0.63.0",
41
+ "jcoTranspile": "0.20.0"
42
+ },
43
+ "publishable": true
44
+ }
@@ -0,0 +1,5 @@
1
+ cbb610c98d9a53efa04379bfc9cb21bd8acbcfe9680c3f052daa4082e496fd6a *adaptive-admission-component-v0.1.0.wasm
2
+ 703d66043f9e2d2bedf92ef97a9ef2618eed1b25eef5c68e2e53fa35d9ca81da *adaptive-admission-world-v0.1.0.wit
3
+ 391fe104d81802338abe060dcb58e9977c586a292617ac1813bad74863fd855c *adaptive-admission-conformance-v0.1.0.tar.gz
4
+ a084431091a1262202dc19883b67acbe39aa17bd3cf726bcffff9cc64581ddd2 *adaptive-admission-release-v0.1.0.json
5
+ 1eb7005a204f0911c2d1bfe38edcaac1a5542fc63355ea30ceb7092c8b7a7981 *adaptive-admission-build-v0.1.0.json
@@ -0,0 +1,36 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "source": {
4
+ "registry": "https://crates.io",
5
+ "crate": "adaptive-admission-core",
6
+ "version": "0.1.0",
7
+ "checksum": "823b1ca077228a3fd229aad05e958e585663072571f0f7709bdbfb70f28dab90",
8
+ "owner": "jfrz38",
9
+ "repository": "https://github.com/jfrz38/adaptive-admission-controller",
10
+ "commit": "b821533645e6dfbfb611b9459345d0e5030bf83a"
11
+ },
12
+ "wrapper": {
13
+ "upstreamCommit": "b821533645e6dfbfb611b9459345d0e5030bf83a",
14
+ "manifestSha256": "33e9fabd95792ea4233b5adcf2b041e52fb0b49837a801dd794b55863a8b8e9b",
15
+ "cargoLockSha256": "13ae2c79f61c6e45585e61578e31dcb358a90437aed90384c8a4f36a1baa5c8c",
16
+ "sourceSha256": "cfb85affd709c29d4b39afd2f76064f9acc60e94a0a48efd6d261d9ca6dec6e9",
17
+ "witSha256": "703d66043f9e2d2bedf92ef97a9ef2618eed1b25eef5c68e2e53fa35d9ca81da"
18
+ },
19
+ "component": {
20
+ "package": "jfrz38:adaptive-admission@0.1.0",
21
+ "world": "adaptive-admission",
22
+ "target": "wasm32-unknown-unknown",
23
+ "artifact": "adaptive-admission-component-v0.1.0.wasm",
24
+ "sha256": "cbb610c98d9a53efa04379bfc9cb21bd8acbcfe9680c3f052daa4082e496fd6a",
25
+ "rebuildSha256ByHost": {
26
+ "linux-x64": "152016fa6371f97deb124937fd477fb5bc122bdf5510a630ceef661fc4c4bd9b",
27
+ "win32-x64": "cbb610c98d9a53efa04379bfc9cb21bd8acbcfe9680c3f052daa4082e496fd6a"
28
+ }
29
+ },
30
+ "toolchain": {
31
+ "rust": "rustc 1.99.0 (b940084d7 2026-09-28)",
32
+ "cargo": "cargo 1.99.0 (5f94df478 2026-08-27)",
33
+ "wasmTools": "wasm-tools 1.262.0",
34
+ "witBindgen": "0.63.0"
35
+ }
36
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "version": "0.1.0",
4
+ "tag": "v0.1.0",
5
+ "source": {
6
+ "repository": "https://github.com/jfrz38/adaptive-admission-controller",
7
+ "commit": "b821533645e6dfbfb611b9459345d0e5030bf83a",
8
+ "treeDirty": false
9
+ },
10
+ "rustCrate": {
11
+ "name": "adaptive-admission-core",
12
+ "version": "0.1.0"
13
+ },
14
+ "component": {
15
+ "package": "jfrz38:adaptive-admission@0.1.0",
16
+ "world": "adaptive-admission",
17
+ "target": "wasm32-unknown-unknown",
18
+ "artifact": "adaptive-admission-component-v0.1.0.wasm",
19
+ "sha256": "f15826063850c2963a64481695f8550d295dd776e871de439b2d74c0de9bb7a5",
20
+ "ociReference": "ghcr.io/jfrz38/adaptive-admission:0.1.0"
21
+ },
22
+ "wit": {
23
+ "artifact": "adaptive-admission-world-v0.1.0.wit",
24
+ "sha256": "703d66043f9e2d2bedf92ef97a9ef2618eed1b25eef5c68e2e53fa35d9ca81da"
25
+ },
26
+ "conformance": {
27
+ "artifact": "adaptive-admission-conformance-v0.1.0.tar.gz",
28
+ "sha256": "391fe104d81802338abe060dcb58e9977c586a292617ac1813bad74863fd855c"
29
+ },
30
+ "toolchain": {
31
+ "rust": "rustc 1.99.0 (b940084d7 2026-09-28)",
32
+ "wasmTools": "wasm-tools 1.262.0"
33
+ }
34
+ }
@@ -0,0 +1,193 @@
1
+ package jfrz38:adaptive-admission@0.1.0;
2
+
3
+ interface controller {
4
+ record statistics-config {
5
+ min-window-ms: u64,
6
+ max-window-ms: u64,
7
+ min-samples: u64,
8
+ min-percentile-samples: u64,
9
+ max-samples: u64,
10
+ latency-percentile: u8,
11
+ }
12
+
13
+ record pid-config {
14
+ proportional-gain: f64,
15
+ integral-gain: f64,
16
+ derivative-gain: f64,
17
+ interval-ms: u64,
18
+ max-delta-percentage: f64,
19
+ integral-decay: f64,
20
+ }
21
+
22
+ record config {
23
+ initial-threshold: u16,
24
+ max-concurrent-requests: u64,
25
+ max-queued-requests: u64,
26
+ queue-timeout-ms: u64,
27
+ queue-timeout-ratio: f64,
28
+ statistics: statistics-config,
29
+ pid: pid-config,
30
+ }
31
+
32
+ record statistics-window-order {
33
+ minimum-ms: u64,
34
+ maximum-ms: u64,
35
+ }
36
+
37
+ record statistics-sample-limit {
38
+ maximum: u64,
39
+ required: u64,
40
+ }
41
+
42
+ enum pid-gain {
43
+ proportional,
44
+ integral,
45
+ derivative,
46
+ }
47
+
48
+ variant config-error {
49
+ threshold-out-of-range(u16),
50
+ zero-concurrency,
51
+ zero-queue-timeout,
52
+ queue-timeout-ratio-out-of-range,
53
+ zero-statistics-min-window,
54
+ statistics-window-order(statistics-window-order),
55
+ zero-statistics-min-samples,
56
+ zero-statistics-percentile-samples,
57
+ statistics-sample-limit-too-small(statistics-sample-limit),
58
+ statistics-percentile-out-of-range(u8),
59
+ invalid-pid-gain(pid-gain),
60
+ zero-pid-interval,
61
+ pid-delta-out-of-range,
62
+ pid-decay-out-of-range,
63
+ numeric-overflow(string),
64
+ }
65
+
66
+ record threshold-rejection {
67
+ priority: u16,
68
+ threshold: u16,
69
+ }
70
+
71
+ variant rejection-reason {
72
+ threshold(threshold-rejection),
73
+ queue-full,
74
+ shutdown,
75
+ }
76
+
77
+ enum eviction-reason {
78
+ queue-timeout,
79
+ }
80
+
81
+ enum cancellation-reason {
82
+ requested,
83
+ shutdown,
84
+ }
85
+
86
+ record threshold-change {
87
+ previous: u16,
88
+ current: u16,
89
+ }
90
+
91
+ record concurrency-change {
92
+ previous: u64,
93
+ current: u64,
94
+ }
95
+
96
+ record rejected-request {
97
+ request-id: u64,
98
+ reason: rejection-reason,
99
+ }
100
+
101
+ record evicted-request {
102
+ request-id: u64,
103
+ reason: eviction-reason,
104
+ }
105
+
106
+ record cancelled-request {
107
+ request-id: u64,
108
+ reason: cancellation-reason,
109
+ }
110
+
111
+ variant action {
112
+ threshold-changed(threshold-change),
113
+ concurrency-changed(concurrency-change),
114
+ start(u64),
115
+ reject(rejected-request),
116
+ evict(evicted-request),
117
+ cancel(cancelled-request),
118
+ }
119
+
120
+ record submission {
121
+ request-id: u64,
122
+ actions: list<action>,
123
+ }
124
+
125
+ enum outcome {
126
+ success,
127
+ failure,
128
+ }
129
+
130
+ record time-regression {
131
+ previous-ms: u64,
132
+ received-ms: u64,
133
+ }
134
+
135
+ record invalid-transition {
136
+ request-id: u64,
137
+ operation: string,
138
+ state: string,
139
+ }
140
+
141
+ variant controller-error {
142
+ time-regression(time-regression),
143
+ unknown-request(u64),
144
+ invalid-transition(invalid-transition),
145
+ request-id-exhausted,
146
+ sequence-exhausted,
147
+ deadline-overflow,
148
+ }
149
+
150
+ variant submit-error {
151
+ priority-out-of-range(u16),
152
+ controller(controller-error),
153
+ }
154
+
155
+ record statistics-snapshot {
156
+ id: u64,
157
+ started-at-ms: u64,
158
+ ended-at-ms: u64,
159
+ percentile-latency-ms: u64,
160
+ minimum-latency-ms: u64,
161
+ average-latency-ms: f64,
162
+ successful-requests: u64,
163
+ throughput-per-second: f64,
164
+ max-in-flight: u64,
165
+ }
166
+
167
+ record controller-diagnostics {
168
+ threshold: u16,
169
+ concurrency-limit: u64,
170
+ queue-timeout-ms: u64,
171
+ target-latency-ms: f64,
172
+ aggregated-latency-ms: option<f64>,
173
+ }
174
+
175
+ resource admission-controller {
176
+ submit: func(priority: u16, now-ms: u64) -> result<submission, submit-error>;
177
+ complete: func(request-id: u64, outcome: outcome, now-ms: u64) -> result<list<action>, controller-error>;
178
+ cancel: func(request-id: u64, now-ms: u64) -> result<list<action>, controller-error>;
179
+ advance-time: func(now-ms: u64) -> result<list<action>, controller-error>;
180
+ shutdown: func(now-ms: u64) -> result<list<action>, controller-error>;
181
+ next-deadline: func() -> option<u64>;
182
+ latest-statistics: func() -> option<statistics-snapshot>;
183
+ latest-diagnostics: func() -> controller-diagnostics;
184
+ priority-percentile: func(percentile: u8) -> option<u16>;
185
+ }
186
+
187
+ default-config: func() -> config;
188
+ create: func(configuration: config) -> result<admission-controller, config-error>;
189
+ }
190
+
191
+ world adaptive-admission {
192
+ export controller;
193
+ }
@@ -0,0 +1,13 @@
1
+ import type { Action, AdmissionController as GeneratedController, Config, ControllerDiagnostics, ControllerError, Outcome, StatisticsSnapshot, Submission, SubmitError } from './generated/interfaces/jfrz38-adaptive-admission-controller.js';
2
+ export type ComponentAction = Action;
3
+ export type ComponentConfig = Config;
4
+ export type ComponentControllerDiagnostics = ControllerDiagnostics;
5
+ export type ComponentControllerError = ControllerError;
6
+ export type ComponentOutcome = Outcome;
7
+ export type ComponentStatisticsSnapshot = StatisticsSnapshot;
8
+ export type ComponentSubmission = Submission;
9
+ export type ComponentSubmitError = SubmitError;
10
+ export declare function defaultComponentConfig(): ComponentConfig;
11
+ export declare function createComponentController(configuration: ComponentConfig): GeneratedController;
12
+ export declare function latestComponentDiagnostics(controller: GeneratedController): ComponentControllerDiagnostics;
13
+ export declare function componentErrorPayload(error: unknown): unknown;
@@ -0,0 +1,26 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { instantiate } from './generated/adaptive-admission.js';
3
+ function getCoreModule(path) {
4
+ const bytes = readFileSync(new URL(`./generated/${path}`, import.meta.url));
5
+ return new WebAssembly.Module(bytes);
6
+ }
7
+ const root = instantiate(getCoreModule, {});
8
+ const component = root.controller;
9
+ export function defaultComponentConfig() {
10
+ return component.defaultConfig();
11
+ }
12
+ export function createComponentController(configuration) {
13
+ return component.create(configuration);
14
+ }
15
+ export function latestComponentDiagnostics(controller) {
16
+ return controller.latestDiagnostics();
17
+ }
18
+ export function componentErrorPayload(error) {
19
+ if (typeof error === 'object' && error !== null && 'payload' in error) {
20
+ return error.payload;
21
+ }
22
+ if (typeof error === 'object' && error !== null && 'tag' in error) {
23
+ return error;
24
+ }
25
+ return undefined;
26
+ }
@@ -0,0 +1,4 @@
1
+ import { type ComponentConfig } from './component-runtime.js';
2
+ import type { ControllerOptions } from './types.js';
3
+ export declare function resolveConfiguration(options?: ControllerOptions): ComponentConfig;
4
+ export declare function createValidatedComponentController(options?: ControllerOptions): import("./generated/interfaces/jfrz38-adaptive-admission-controller.js").AdmissionController;