@jfrz38/adaptive-admission-node 0.0.0-stage → 0.2.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 +60 -0
- package/README.md +200 -2
- package/component/COMPONENT.json +44 -0
- package/component/SHA256SUMS +5 -0
- package/component/adaptive-admission-build-v0.1.0.json +36 -0
- package/component/adaptive-admission-component-v0.1.0.wasm +0 -0
- package/component/adaptive-admission-conformance-v0.1.0.tar.gz +0 -0
- package/component/adaptive-admission-release-v0.1.0.json +34 -0
- package/component/adaptive-admission-world-v0.1.0.wit +193 -0
- package/dist/component-runtime.d.ts +13 -0
- package/dist/component-runtime.js +26 -0
- package/dist/configuration.d.ts +4 -0
- package/dist/configuration.js +81 -0
- package/dist/controller.d.ts +48 -0
- package/dist/controller.js +330 -0
- package/dist/errors.d.ts +38 -0
- package/dist/errors.js +68 -0
- package/dist/generated/adaptive-admission.core.wasm +0 -0
- package/dist/generated/adaptive-admission.core2.wasm +0 -0
- package/dist/generated/adaptive-admission.core3.wasm +0 -0
- package/dist/generated/adaptive-admission.d.ts +57 -0
- package/dist/generated/adaptive-admission.js +5869 -0
- package/dist/generated/interfaces/jfrz38-adaptive-admission-controller.d.ts +258 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/priority.d.ts +12 -0
- package/dist/priority.js +30 -0
- package/dist/types.d.ts +76 -0
- package/dist/types.js +1 -0
- package/package.json +56 -4
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.2.0`, Express `0.2.1`, Fastify `0.1.0`, and NestJS `0.3.0` are published successfully
|
|
55
|
+
from `main`, the 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,201 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Adaptive Admission Controller for Node.js
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@jfrz38/adaptive-admission-node)
|
|
4
|
+
[](https://github.com/jfrz38/rate-limit-pid-controller/actions/workflows/build-adaptive-admission-node.yml)
|
|
5
|
+
[](https://www.npmjs.com/package/@jfrz38/adaptive-admission-node)
|
|
6
|
+
[](https://github.com/jfrz38/rate-limit-pid-controller/blob/main/LICENSE)
|
|
7
|
+
[](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
|
+
## Separate admission from completion
|
|
54
|
+
|
|
55
|
+
Framework integrations that begin and finish work in different lifecycle hooks can acquire an
|
|
56
|
+
admission permit directly:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
const abortController = new AbortController();
|
|
60
|
+
const permit = await controller.acquire(
|
|
61
|
+
Priority.fromTier(1, 0),
|
|
62
|
+
{ signal: abortController.signal },
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
await performWork();
|
|
67
|
+
} catch (error) {
|
|
68
|
+
permit.complete('failure');
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
permit.complete('success');
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`acquire()` resolves only when the component starts the work. Every acquired permit must be
|
|
75
|
+
completed exactly once with `success` or `failure`; a second completion throws an error. Aborting
|
|
76
|
+
the signal cancels only work that is still queued. Once acquired, a permit remains valid and must
|
|
77
|
+
be completed even if the signal is aborted or the controller begins shutdown.
|
|
78
|
+
|
|
79
|
+
`run()` is implemented using the same permit lifecycle and remains the simpler API when one
|
|
80
|
+
callback can represent the complete lifetime of the work.
|
|
81
|
+
|
|
82
|
+
## Priorities
|
|
83
|
+
|
|
84
|
+
Priorities range from `0` (most important) to `767` (least important). Work waiting for capacity is
|
|
85
|
+
ordered by priority and FIFO within the same priority.
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
Priority.fromValue(10);
|
|
89
|
+
Priority.fromTier(2, 42); // Six tiers, each with 128 cohorts.
|
|
90
|
+
Priority.default(); // Tier 5 with a random cohort.
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Cancellation
|
|
94
|
+
|
|
95
|
+
Pass an `AbortSignal` as a run option:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
const abortController = new AbortController();
|
|
99
|
+
const result = controller.run(
|
|
100
|
+
() => performWork(),
|
|
101
|
+
Priority.fromValue(100),
|
|
102
|
+
{ signal: abortController.signal },
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
abortController.abort();
|
|
106
|
+
await result;
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
An already-aborted signal prevents submission. Aborting queued work removes it from the component
|
|
110
|
+
queue and rejects with `CancelledRequestError`. JavaScript work that has already started cannot be
|
|
111
|
+
interrupted by the controller and is allowed to finish.
|
|
112
|
+
|
|
113
|
+
## Configuration
|
|
114
|
+
|
|
115
|
+
Omitted values use the defaults defined by the pinned Rust component.
|
|
116
|
+
|
|
117
|
+
| Option | Default | Purpose |
|
|
118
|
+
| --- | ---: | --- |
|
|
119
|
+
| `initialThreshold` | `768` | Initial admission boundary; priorities below it are admitted. |
|
|
120
|
+
| `maxConcurrentRequests` | `10` | Initial number of tasks allowed to run concurrently. |
|
|
121
|
+
| `maxQueuedRequests` | `1000` | Maximum number of tasks waiting for capacity. |
|
|
122
|
+
| `queueTimeoutMs` | `500` | Initial queue deadline in milliseconds. |
|
|
123
|
+
| `queueTimeoutRatio` | `0.33` | Ratio used to adapt queue deadlines from observed latency. |
|
|
124
|
+
| `statistics.minWindowMs` | `2000` | Minimum statistics window duration. |
|
|
125
|
+
| `statistics.maxWindowMs` | `30000` | Maximum statistics window duration. |
|
|
126
|
+
| `statistics.minSamples` | `250` | Successful samples needed to close a ready window. |
|
|
127
|
+
| `statistics.minPercentileSamples` | `250` | Priority samples needed for percentile decisions. |
|
|
128
|
+
| `statistics.maxSamples` | `1000` | Maximum samples retained per window. |
|
|
129
|
+
| `statistics.latencyPercentile` | `90` | Latency percentile used by adaptive control. |
|
|
130
|
+
| `pid.proportionalGain` | `0.2` | PID proportional gain. |
|
|
131
|
+
| `pid.integralGain` | `0.5` | PID integral gain. |
|
|
132
|
+
| `pid.derivativeGain` | `0` | PID derivative gain. |
|
|
133
|
+
| `pid.intervalMs` | `500` | PID evaluation interval. |
|
|
134
|
+
| `pid.maxDeltaPercentage` | `10` | Maximum threshold change per PID update. |
|
|
135
|
+
| `pid.integralDecay` | `0.5` | Decay applied to accumulated integral error. |
|
|
136
|
+
|
|
137
|
+
Integer fields represented as WIT `u64` accept a safe JavaScript integer or `bigint`. Invalid host
|
|
138
|
+
values throw `RangeError`; values rejected by the component throw `ConfigurationError`.
|
|
139
|
+
|
|
140
|
+
## Errors
|
|
141
|
+
|
|
142
|
+
| Error | Meaning |
|
|
143
|
+
| --- | --- |
|
|
144
|
+
| `AdmissionRequestError` | Base class for request rejection, eviction, cancellation, and shutdown errors. |
|
|
145
|
+
| `ThresholdRejectedError` | Priority was outside the current admission threshold. |
|
|
146
|
+
| `QueueFullError` | The bounded waiting queue was full. |
|
|
147
|
+
| `EvictedRequestError` | Queued work exceeded its deadline. |
|
|
148
|
+
| `CancelledRequestError` | Queued work was explicitly cancelled. |
|
|
149
|
+
| `ControllerShutdownError` | Work was queued or submitted after shutdown. |
|
|
150
|
+
| `ConfigurationError` | Rust rejected the supplied configuration. |
|
|
151
|
+
| `ControllerProtocolError` | The component detected an invalid lifecycle transition. |
|
|
152
|
+
|
|
153
|
+
All package errors extend `AdaptiveAdmissionError`. Request lifecycle errors extend
|
|
154
|
+
`AdmissionRequestError`; configuration and protocol failures do not. Errors thrown by the user's
|
|
155
|
+
task remain distinct and are preserved unchanged.
|
|
156
|
+
|
|
157
|
+
## Lifecycle and shutdown
|
|
158
|
+
|
|
159
|
+
Each controller owns independent queue, PID, statistics, and timer state. Call `shutdown()` during
|
|
160
|
+
service teardown. It is idempotent, rejects new work, cancels queued work, clears unnecessary
|
|
161
|
+
deadlines, and allows already-started JavaScript tasks to finish.
|
|
162
|
+
|
|
163
|
+
One controller limits only its current Node.js process or worker. Instances do not coordinate
|
|
164
|
+
limits across workers, processes, containers, or hosts.
|
|
165
|
+
|
|
166
|
+
## Diagnostics
|
|
167
|
+
|
|
168
|
+
Operational tools can subscribe to low-volume events:
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
const unsubscribe = controller.onDiagnostic((event) => {
|
|
172
|
+
console.log(event);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
unsubscribe();
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Events include `threshold-changed`, `concurrency-changed`, `statistics-published`, and
|
|
179
|
+
`controller-diagnostics`. Listener failures are isolated and cannot change admission decisions or
|
|
180
|
+
task outcomes. Diagnostics are intended for observability and simulations, not admission logic.
|
|
181
|
+
|
|
182
|
+
`latestStatistics()` returns the latest completed statistics window, while
|
|
183
|
+
`priorityPercentile(percentile)` queries recently observed priorities.
|
|
184
|
+
|
|
185
|
+
## Component provenance
|
|
186
|
+
|
|
187
|
+
Builds read `component/COMPONENT.json`, validate every artifact checksum, compare the embedded WIT
|
|
188
|
+
export with the checked-in contract, and verify both upstream release and local build provenance
|
|
189
|
+
before transpilation. `make verify-node-component` rebuilds the committed artifact from the exact
|
|
190
|
+
crates.io package, locked transitive dependencies, and pinned toolchain. Generated JavaScript and
|
|
191
|
+
WebAssembly modules are included in the npm tarball, so consumers do not need Cargo or Rust.
|
|
192
|
+
|
|
193
|
+
## More information
|
|
194
|
+
|
|
195
|
+
For an overview of the PID-based admission-control strategy, motivation, and references, see the
|
|
196
|
+
[main project documentation](https://github.com/jfrz38/rate-limit-pid-controller).
|
|
197
|
+
|
|
198
|
+
## License
|
|
199
|
+
|
|
200
|
+
Distributed under the
|
|
201
|
+
[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
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -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;
|