async-bulkhead-llm 3.6.0 → 3.8.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/README.md +149 -5
- package/dist/cjs/adaptive.cjs +128 -0
- package/dist/cjs/adaptive.cjs.map +1 -0
- package/dist/cjs/bulkhead.cjs +838 -0
- package/dist/cjs/bulkhead.cjs.map +1 -0
- package/dist/cjs/dedup.cjs +111 -0
- package/dist/cjs/dedup.cjs.map +1 -0
- package/dist/cjs/errors.cjs +16 -0
- package/dist/cjs/errors.cjs.map +1 -0
- package/dist/cjs/estimators.cjs +205 -0
- package/dist/cjs/estimators.cjs.map +1 -0
- package/dist/cjs/index.cjs +27 -1028
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/profiles.cjs +16 -0
- package/dist/cjs/profiles.cjs.map +1 -0
- package/dist/cjs/types.cjs +3 -0
- package/dist/cjs/types.cjs.map +1 -0
- package/dist/cjs/validation.cjs +39 -0
- package/dist/cjs/validation.cjs.map +1 -0
- package/dist/esm/adaptive.js +125 -0
- package/dist/esm/adaptive.js.map +1 -0
- package/dist/esm/bulkhead.js +835 -0
- package/dist/esm/bulkhead.js.map +1 -0
- package/dist/esm/dedup.js +106 -0
- package/dist/esm/dedup.js.map +1 -0
- package/dist/esm/errors.js +12 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/estimators.js +200 -0
- package/dist/esm/estimators.js.map +1 -0
- package/dist/esm/index.js +19 -1022
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/profiles.js +13 -0
- package/dist/esm/profiles.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/validation.js +32 -0
- package/dist/esm/validation.js.map +1 -0
- package/dist/types/adaptive.d.ts +109 -0
- package/dist/types/adaptive.d.ts.map +1 -0
- package/dist/types/bulkhead.d.ts +59 -0
- package/dist/types/bulkhead.d.ts.map +1 -0
- package/dist/types/dedup.d.ts +32 -0
- package/dist/types/dedup.d.ts.map +1 -0
- package/dist/types/errors.d.ts +9 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/estimators.d.ts +91 -0
- package/dist/types/estimators.d.ts.map +1 -0
- package/dist/types/index.d.ts +27 -578
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/profiles.d.ts +11 -0
- package/dist/types/profiles.d.ts.map +1 -0
- package/dist/types/types.d.ts +566 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/validation.d.ts +12 -0
- package/dist/types/validation.d.ts.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,17 +13,21 @@ Designed for services that need to enforce **cost ceilings, concurrency limits,
|
|
|
13
13
|
- ✅ **Token refund** — reclaim unused budget capacity from actual usage post-completion
|
|
14
14
|
- ✅ **Model-aware estimation** — per-model character ratios for known providers
|
|
15
15
|
- ✅ **Per-request model** — mixed-model routing through a single bulkhead
|
|
16
|
-
- ✅ **Multimodal content** — text blocks counted
|
|
16
|
+
- ✅ **Multimodal content** — text blocks counted; opaque blocks ignored by default or charged a configurable per-block reservation (`opaqueBlockTokens`)
|
|
17
|
+
- ✅ **Full-request estimation** — `system` prompts counted natively; `extraInputTokens` carries caller-computed costs (tool schemas, provider-priced media)
|
|
18
|
+
- ✅ **Per-call reservation override** — gateways with their own estimate can bypass the estimator via `reservation` on `acquire()`/`run()`/`wouldAdmit()`
|
|
17
19
|
- ✅ **Fail-fast by default** — shed load early, never silently queue
|
|
18
20
|
- ✅ **Opinionated profiles** — `'interactive'` and `'batch'` presets with escape hatch
|
|
19
21
|
- ✅ **In-flight deduplication** — identical requests share one LLM call; hashed keys, whole-request equality
|
|
20
22
|
- ✅ **Custom dedup key + per-tenant scope** — bring your own equivalence function; `dedupScope` isolates tenants
|
|
21
23
|
- ✅ **Streaming-safe deduplication** — single-consumer results are never silently shared; `shareResult` fan-out hook + per-call `dedup: false` opt-out
|
|
22
|
-
- ✅ **Exact reservation preview** — `estimate()` exposes the reservation admission will use
|
|
24
|
+
- ✅ **Exact reservation preview** — `estimate()` exposes the reservation admission will use, and its result can be passed back verbatim as the per-call `reservation`
|
|
25
|
+
- ✅ **Adaptive estimation** — `createAdaptiveTokenEstimator()` self-calibrates per-model input estimates from observed usage
|
|
26
|
+
- ✅ **Advisory capacity snapshots** — `wouldAdmit(request, { detail: true })` returns the same capacity numbers rejections carry
|
|
23
27
|
- ✅ **Stable admission IDs** — correlate gateway requests, traces, usage, and release
|
|
24
28
|
- ✅ **Ordered usage events** — sequence-numbered hold changes for external coordinators
|
|
25
29
|
- ✅ **Event hooks** — `on('admit' | 'reject' | 'usage' | 'release' | 'dedup', fn)`
|
|
26
|
-
- ✅ **Graceful shutdown** — `close()` + `drain()`
|
|
30
|
+
- ✅ **Graceful shutdown** — `close()` + `drain()`, with an optional bounded wait: `drain({ timeoutMs })`
|
|
27
31
|
- ✅ Optional **AbortSignal** and **timeout** cancellation
|
|
28
32
|
- ✅ `bulkhead.run(request, fn)` — acquire + release handled automatically
|
|
29
33
|
- ✅ Zero dependencies beyond `async-bulkhead-ts`
|
|
@@ -126,6 +130,103 @@ const result = await bulkhead.run(request, async () => {
|
|
|
126
130
|
|
|
127
131
|
---
|
|
128
132
|
|
|
133
|
+
## What's New in v3.8 — Feedback and shutdown ergonomics
|
|
134
|
+
|
|
135
|
+
### Bounded drain
|
|
136
|
+
|
|
137
|
+
`drain()` without arguments is unchanged (`Promise<void>`). With a deadline,
|
|
138
|
+
it always *resolves* — never rejects — with what happened:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
bulkhead.close();
|
|
142
|
+
const result = await bulkhead.drain({ timeoutMs: 10_000 });
|
|
143
|
+
if (!result.drained) {
|
|
144
|
+
log.warn("abandoning shutdown wait", {
|
|
145
|
+
inFlight: result.inFlight,
|
|
146
|
+
pending: result.pending,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
The deadline never cancels or interrupts in-flight work and leaves the
|
|
152
|
+
bulkhead's accounting untouched — work that finishes later still releases
|
|
153
|
+
normally. It exists so a shutdown path can log what it is abandoning and
|
|
154
|
+
proceed, instead of parking forever behind one stuck upstream stream.
|
|
155
|
+
`timeoutMs: 0` is an immediate "is it drained right now?" snapshot.
|
|
156
|
+
|
|
157
|
+
### Capacity detail from `wouldAdmit()`
|
|
158
|
+
|
|
159
|
+
Routing layers choosing between pools want the numbers, not just the boolean:
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
const { admit, reason, detail } = bulkhead.wouldAdmit(request, {
|
|
163
|
+
detail: true,
|
|
164
|
+
});
|
|
165
|
+
// detail is the same LLMRejectDetail snapshot real rejections carry,
|
|
166
|
+
// present on admit: true as well (detail.tokenBudget.requested is the
|
|
167
|
+
// reservation this request needs).
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Omitted by default, so existing callers see the exact v3.7 result shape.
|
|
171
|
+
|
|
172
|
+
### `estimate()` round-trips as the reservation override
|
|
173
|
+
|
|
174
|
+
The frozen object returned by `estimate()` can now be passed straight back:
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
const preview = bulkhead.estimate(request);
|
|
178
|
+
await bulkhead.run(request, fn, {
|
|
179
|
+
...(preview !== null ? { reservation: preview } : {}),
|
|
180
|
+
});
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
When the override carries a `reserved` field it is validated as a
|
|
184
|
+
consistency check (`reserved === input + maxOutput`), catching hand-built
|
|
185
|
+
overrides whose cached total drifted from edited parts. Plain
|
|
186
|
+
`{ input, maxOutput }` overrides are unchanged.
|
|
187
|
+
|
|
188
|
+
### Adaptive estimation
|
|
189
|
+
|
|
190
|
+
Character-ratio estimation is ±15% at best and drifts with content mix and
|
|
191
|
+
tokenizer changes. `createAdaptiveTokenEstimator()` closes the loop:
|
|
192
|
+
|
|
193
|
+
```ts
|
|
194
|
+
import {
|
|
195
|
+
createAdaptiveTokenEstimator,
|
|
196
|
+
createLLMBulkhead,
|
|
197
|
+
} from "async-bulkhead-llm";
|
|
198
|
+
|
|
199
|
+
const adaptive = createAdaptiveTokenEstimator({
|
|
200
|
+
defaultModel: "claude-sonnet-4-5",
|
|
201
|
+
opaqueBlockTokens: 2_048,
|
|
202
|
+
// smoothing: 0.2, minSamples: 5,
|
|
203
|
+
// minCorrection: 0.5, maxCorrection: 2, maxModels: 64,
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
const bulkhead = createLLMBulkhead({
|
|
207
|
+
model: "claude-sonnet-4-5",
|
|
208
|
+
maxConcurrent: 8,
|
|
209
|
+
tokenBudget: { budget: 200_000, estimator: adaptive.estimator },
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
// Close the loop from actual usage:
|
|
213
|
+
bulkhead.on("release", (e) => {
|
|
214
|
+
if (e.usage) adaptive.observe(e.request, e.usage);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
adaptive.corrections(); // per-model { samples, factor, applied } for /stats
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
It maintains a per-model EWMA of `actual input / estimated input` and
|
|
221
|
+
multiplies future *input* estimates by that factor — clamped, and only
|
|
222
|
+
after `minSamples` observations. Output reservations are never corrected
|
|
223
|
+
(`max_tokens` is a ceiling, not an estimate). Observations always measure
|
|
224
|
+
against the *uncorrected* base estimate, so the loop cannot compound
|
|
225
|
+
through its own corrections. Calibration is in-memory, per-instance, and
|
|
226
|
+
bounded to `maxModels` tracked models.
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
129
230
|
## What's New in v3.6 — Gateway coordination seams
|
|
130
231
|
|
|
131
232
|
### Exact reservation preview
|
|
@@ -478,6 +579,7 @@ const bulkhead = createLLMBulkhead({
|
|
|
478
579
|
import {
|
|
479
580
|
naiveTokenEstimator,
|
|
480
581
|
createModelAwareTokenEstimator,
|
|
582
|
+
createAdaptiveTokenEstimator,
|
|
481
583
|
extractTextLength,
|
|
482
584
|
} from 'async-bulkhead-llm';
|
|
483
585
|
|
|
@@ -496,6 +598,13 @@ const estimate = createModelAwareTokenEstimator(
|
|
|
496
598
|
|
|
497
599
|
// Utility for multimodal content
|
|
498
600
|
const charCount = extractTextLength(message.content);
|
|
601
|
+
|
|
602
|
+
// Self-calibrating wrapper (v3.8) — see "What's New in v3.8"
|
|
603
|
+
const adaptive = createAdaptiveTokenEstimator({ defaultModel: 'gpt-4o' });
|
|
604
|
+
adaptive.estimator; // pass as tokenBudget.estimator
|
|
605
|
+
adaptive.observe(request, usage); // feed actual usage (release event)
|
|
606
|
+
adaptive.corrections(); // per-model calibration snapshot
|
|
607
|
+
adaptive.reset(); // clear calibration
|
|
499
608
|
```
|
|
500
609
|
|
|
501
610
|
### Runtime Budget Adjustment
|
|
@@ -891,7 +1000,22 @@ See [Runtime Budget Adjustment](#runtime-budget-adjustment) for full semantics.
|
|
|
891
1000
|
### `bulkhead.close()`
|
|
892
1001
|
|
|
893
1002
|
|
|
894
|
-
### `bulkhead.drain()`
|
|
1003
|
+
### `bulkhead.drain(opts?)`
|
|
1004
|
+
|
|
1005
|
+
```ts
|
|
1006
|
+
drain(): Promise<void>;
|
|
1007
|
+
drain(opts: { timeoutMs: number }): Promise<LLMDrainResult>;
|
|
1008
|
+
|
|
1009
|
+
type LLMDrainResult = {
|
|
1010
|
+
drained: boolean; // true: everything completed within the deadline
|
|
1011
|
+
inFlight: number; // outstanding at the deadline (0 when drained)
|
|
1012
|
+
pending: number; // queued waiters at the deadline (0 when drained)
|
|
1013
|
+
};
|
|
1014
|
+
```
|
|
1015
|
+
|
|
1016
|
+
Resolves when all in-flight work and pending waiters have completed. With
|
|
1017
|
+
`timeoutMs`, always resolves (never rejects) by the deadline with an
|
|
1018
|
+
`LLMDrainResult`; the deadline does not cancel in-flight work.
|
|
895
1019
|
|
|
896
1020
|
### `bulkhead.on(event, listener)`
|
|
897
1021
|
|
|
@@ -977,6 +1101,26 @@ See [CHANGELOG](./CHANGELOG.md) for the v2 migration guide.
|
|
|
977
1101
|
|
|
978
1102
|
---
|
|
979
1103
|
|
|
1104
|
+
## Source Layout
|
|
1105
|
+
|
|
1106
|
+
The implementation is split into focused modules under `src/`; the package
|
|
1107
|
+
entry point (`src/index.ts`) is a barrel that re-exports the public API.
|
|
1108
|
+
Deep-importing the internal modules is not supported — the package
|
|
1109
|
+
`exports` map exposes only the entry point.
|
|
1110
|
+
|
|
1111
|
+
| Module | Contents |
|
|
1112
|
+
|---|---|
|
|
1113
|
+
| `types.ts` | Public request, result, options, stats, and event types (declarations only) |
|
|
1114
|
+
| `errors.ts` | `LLMBulkheadRejectedError` |
|
|
1115
|
+
| `profiles.ts` | `PROFILES` presets + `LLMBulkheadPreset` |
|
|
1116
|
+
| `estimators.ts` | `naiveTokenEstimator`, `createModelAwareTokenEstimator`, `opaqueBlockTokens` handling, `extractTextLength`, built-in ratio table |
|
|
1117
|
+
| `adaptive.ts` | `createAdaptiveTokenEstimator` (v3.8 self-calibration) |
|
|
1118
|
+
| `dedup.ts` | Deduplication internals: default whole-request key, scope-aware hashing, single-consumer result detection |
|
|
1119
|
+
| `validation.ts` | Internal numeric/estimate/usage guards (not re-exported) |
|
|
1120
|
+
| `bulkhead.ts` | `createLLMBulkhead`: admission, token budget + refund accounting, streaming usage reports, events, stats, shutdown |
|
|
1121
|
+
|
|
1122
|
+
---
|
|
1123
|
+
|
|
980
1124
|
## Design Notes
|
|
981
1125
|
|
|
982
1126
|
This library enforces backpressure at the boundary of your LLM calls. It does not replace higher-level concerns:
|
|
@@ -999,4 +1143,4 @@ Token estimation is deliberately approximate. The refund mechanism improves budg
|
|
|
999
1143
|
|
|
1000
1144
|
## License
|
|
1001
1145
|
|
|
1002
|
-
Apache License 2.0 © 2026
|
|
1146
|
+
Apache License 2.0 © 2026
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAdaptiveTokenEstimator = createAdaptiveTokenEstimator;
|
|
4
|
+
const estimators_js_1 = require("./estimators.cjs");
|
|
5
|
+
const validation_js_1 = require("./validation.cjs");
|
|
6
|
+
/**
|
|
7
|
+
* A self-calibrating wrapper around `createModelAwareTokenEstimator`
|
|
8
|
+
* (v3.8).
|
|
9
|
+
*
|
|
10
|
+
* Character-ratio estimation is ±15% at best and drifts with content
|
|
11
|
+
* mix (code vs prose vs CJK) and provider tokenizer changes. This
|
|
12
|
+
* estimator closes the loop: feed it actual usage from completed calls
|
|
13
|
+
* via `observe()`, and it maintains a per-model EWMA of
|
|
14
|
+
* `actual input / estimated input`, multiplying future *input*
|
|
15
|
+
* estimates by that factor (clamped, and only after `minSamples`
|
|
16
|
+
* observations). Output reservations are never corrected —
|
|
17
|
+
* `max_tokens` / `outputCap` is a ceiling, not an estimate.
|
|
18
|
+
*
|
|
19
|
+
* The correction applies to the **whole** input estimate, including
|
|
20
|
+
* any `opaqueBlockTokens` surcharge and `extraInputTokens` — the
|
|
21
|
+
* observed ratio necessarily includes those components too, so scaling
|
|
22
|
+
* the total is the self-consistent choice (the fixed point is
|
|
23
|
+
* "corrected estimate ≈ actual"). If your `extraInputTokens` values
|
|
24
|
+
* are exact, expect the factor to settle slightly differently than a
|
|
25
|
+
* pure-prose deployment; the clamps bound the damage either way.
|
|
26
|
+
*
|
|
27
|
+
* `observe()` always measures against the *uncorrected* base estimate,
|
|
28
|
+
* so feedback does not compound: an already-corrected estimator does
|
|
29
|
+
* not drag its own factor back toward 1.
|
|
30
|
+
*
|
|
31
|
+
* Not distributed and not persisted — calibration lives in this
|
|
32
|
+
* instance. Share one instance per bulkhead (create it, pass
|
|
33
|
+
* `.estimator` into `tokenBudget`, and subscribe `.observe` to the
|
|
34
|
+
* same bulkhead's `release` events).
|
|
35
|
+
*/
|
|
36
|
+
function createAdaptiveTokenEstimator(opts = {}) {
|
|
37
|
+
const smoothing = opts.smoothing ?? 0.2;
|
|
38
|
+
if (typeof smoothing !== "number" ||
|
|
39
|
+
!Number.isFinite(smoothing) ||
|
|
40
|
+
smoothing <= 0 ||
|
|
41
|
+
smoothing > 1) {
|
|
42
|
+
throw new Error("smoothing must be a finite number in (0, 1]");
|
|
43
|
+
}
|
|
44
|
+
const minSamples = opts.minSamples ?? 5;
|
|
45
|
+
(0, validation_js_1.assertPositiveInteger)(minSamples, "minSamples");
|
|
46
|
+
const minCorrection = opts.minCorrection ?? 0.5;
|
|
47
|
+
if (typeof minCorrection !== "number" ||
|
|
48
|
+
!Number.isFinite(minCorrection) ||
|
|
49
|
+
minCorrection <= 0) {
|
|
50
|
+
throw new Error("minCorrection must be a finite number > 0");
|
|
51
|
+
}
|
|
52
|
+
const maxCorrection = opts.maxCorrection ?? 2;
|
|
53
|
+
if (typeof maxCorrection !== "number" ||
|
|
54
|
+
!Number.isFinite(maxCorrection) ||
|
|
55
|
+
maxCorrection < minCorrection) {
|
|
56
|
+
throw new Error("maxCorrection must be a finite number >= minCorrection");
|
|
57
|
+
}
|
|
58
|
+
const maxModels = opts.maxModels ?? 64;
|
|
59
|
+
(0, validation_js_1.assertPositiveInteger)(maxModels, "maxModels");
|
|
60
|
+
const base = (0, estimators_js_1.createModelAwareTokenEstimator)(opts.overrides, {
|
|
61
|
+
defaultModel: opts.defaultModel,
|
|
62
|
+
outputCap: opts.outputCap,
|
|
63
|
+
onUnknownModel: opts.onUnknownModel,
|
|
64
|
+
opaqueBlockTokens: opts.opaqueBlockTokens,
|
|
65
|
+
});
|
|
66
|
+
/** Insertion-ordered; oldest-inserted evicted at capacity. */
|
|
67
|
+
const models = new Map();
|
|
68
|
+
const modelKey = (request) => (request.model ?? opts.defaultModel ?? "").toLowerCase();
|
|
69
|
+
const appliedFactor = (state) => {
|
|
70
|
+
if (state === undefined || state.samples < minSamples)
|
|
71
|
+
return 1;
|
|
72
|
+
return Math.min(maxCorrection, Math.max(minCorrection, state.factor));
|
|
73
|
+
};
|
|
74
|
+
const estimator = (request) => {
|
|
75
|
+
const e = base(request);
|
|
76
|
+
const factor = appliedFactor(models.get(modelKey(request)));
|
|
77
|
+
if (factor === 1)
|
|
78
|
+
return e;
|
|
79
|
+
return {
|
|
80
|
+
input: Math.ceil(e.input * factor),
|
|
81
|
+
maxOutput: e.maxOutput,
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
function observe(request, usage) {
|
|
85
|
+
const valid = (0, validation_js_1.validateTokenUsage)(usage);
|
|
86
|
+
// Always ratio against the *uncorrected* base estimate so the
|
|
87
|
+
// feedback loop does not compound through its own corrections.
|
|
88
|
+
const baseInput = base(request).input;
|
|
89
|
+
if (baseInput <= 0)
|
|
90
|
+
return;
|
|
91
|
+
const observed = valid.input / baseInput;
|
|
92
|
+
const key = modelKey(request);
|
|
93
|
+
const state = models.get(key);
|
|
94
|
+
if (state === undefined) {
|
|
95
|
+
while (models.size >= maxModels) {
|
|
96
|
+
const oldest = models.keys().next().value;
|
|
97
|
+
if (oldest === undefined)
|
|
98
|
+
break;
|
|
99
|
+
models.delete(oldest);
|
|
100
|
+
}
|
|
101
|
+
models.set(key, { samples: 1, factor: observed });
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
state.factor += smoothing * (observed - state.factor);
|
|
105
|
+
state.samples++;
|
|
106
|
+
}
|
|
107
|
+
function corrections() {
|
|
108
|
+
const out = [];
|
|
109
|
+
for (const [model, state] of models) {
|
|
110
|
+
out.push({
|
|
111
|
+
model,
|
|
112
|
+
samples: state.samples,
|
|
113
|
+
factor: state.factor,
|
|
114
|
+
applied: appliedFactor(state),
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return out;
|
|
118
|
+
}
|
|
119
|
+
function reset(model) {
|
|
120
|
+
if (model === undefined) {
|
|
121
|
+
models.clear();
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
models.delete(model.toLowerCase());
|
|
125
|
+
}
|
|
126
|
+
return { estimator, observe, corrections, reset };
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=adaptive.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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