@pi-unipi/background-tasks 2.6.2 → 2.6.4

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 (59) hide show
  1. package/package.json +3 -2
  2. package/src/tools.ts +3 -1
  3. package/src/__tests__/anthropic-attribution.test.ts +0 -195
  4. package/src/__tests__/config.test.ts +0 -137
  5. package/src/__tests__/core.test.ts +0 -493
  6. package/src/__tests__/delegate-artifacts.test.ts +0 -528
  7. package/src/__tests__/delegate-budget.test.ts +0 -456
  8. package/src/__tests__/delegate-launch.test.ts +0 -676
  9. package/src/__tests__/delegate-result-package.test.ts +0 -350
  10. package/src/__tests__/delegate-seed.test.ts +0 -392
  11. package/src/__tests__/durable-fs.test.ts +0 -559
  12. package/src/__tests__/extension-api.test.ts +0 -579
  13. package/src/__tests__/fusion-artifacts.test.ts +0 -1039
  14. package/src/__tests__/fusion-budget.test.ts +0 -1356
  15. package/src/__tests__/fusion-claude-cache.test.ts +0 -320
  16. package/src/__tests__/fusion-config.test.ts +0 -335
  17. package/src/__tests__/fusion-context-prompts.test.ts +0 -670
  18. package/src/__tests__/fusion-evaluation.test.ts +0 -315
  19. package/src/__tests__/fusion-extraction-equivalence.test.ts +0 -58
  20. package/src/__tests__/fusion-golden-bytes.test.ts +0 -35
  21. package/src/__tests__/fusion-high-cardinality.test.ts +0 -192
  22. package/src/__tests__/fusion-model-selector.test.ts +0 -205
  23. package/src/__tests__/fusion-orchestrator.test.ts +0 -1194
  24. package/src/__tests__/fusion-rpc.test.ts +0 -369
  25. package/src/__tests__/fusion-sdk.test.ts +0 -1226
  26. package/src/__tests__/fusion-v5-core.test.ts +0 -219
  27. package/src/__tests__/fusion-validate-orchestrator.test.ts +0 -240
  28. package/src/__tests__/fusion-web-fetch.test.ts +0 -485
  29. package/src/__tests__/fusion-workflows.test.ts +0 -59
  30. package/src/__tests__/helpers/delegate-deterministic-seed.ts +0 -109
  31. package/src/__tests__/helpers/delegate-seed-subprocess.ts +0 -10
  32. package/src/__tests__/helpers/fusion-canonical-subprocess.ts +0 -21
  33. package/src/__tests__/helpers/fusion-canonical.ts +0 -140
  34. package/src/__tests__/helpers/fusion-fake-pi.ts +0 -279
  35. package/src/__tests__/helpers/fusion-golden-corpus.ts +0 -500
  36. package/src/__tests__/helpers/fusion-high-cardinality.ts +0 -140
  37. package/src/__tests__/helpers/normalize.ts +0 -22
  38. package/src/__tests__/helpers/pi-hook-contract-evidence.json +0 -18
  39. package/src/__tests__/pi-launch.test.ts +0 -202
  40. package/src/__tests__/registry.test.ts +0 -1580
  41. package/src/__tests__/scripted-provider/delegate-ambient-provider.test.ts +0 -130
  42. package/src/__tests__/scripted-provider/delegate-child-guard.test.ts +0 -631
  43. package/src/__tests__/scripted-provider/delegate-guard-provider.ts +0 -403
  44. package/src/__tests__/scripted-provider/follow-up.test.ts +0 -448
  45. package/src/__tests__/scripted-provider/fusion-output-recovery.test.ts +0 -132
  46. package/src/__tests__/scripted-provider/fusion-reason.test.ts +0 -310
  47. package/src/__tests__/scripted-provider/fusion-runtime-guard.test.ts +0 -163
  48. package/src/__tests__/scripted-provider/hook-contract-provider.ts +0 -179
  49. package/src/__tests__/scripted-provider/hook-probe-a.ts +0 -3
  50. package/src/__tests__/scripted-provider/hook-probe-b.ts +0 -3
  51. package/src/__tests__/scripted-provider/hook-probe-extension.ts +0 -126
  52. package/src/__tests__/scripted-provider/output-recovery-provider.ts +0 -153
  53. package/src/__tests__/scripted-provider/pi-hook-contract-evidence.json +0 -18
  54. package/src/__tests__/scripted-provider/pi-hook-contract.test.ts +0 -477
  55. package/src/__tests__/scripted-provider/runtime-guard-probe.ts +0 -28
  56. package/src/__tests__/scripted-provider/runtime-guard-provider.ts +0 -49
  57. package/src/__tests__/scripted-provider/scripted-provider-extension.ts +0 -408
  58. package/src/__tests__/task-manager.test.ts +0 -479
  59. package/src/__tests__/windows-taskkill.test.ts +0 -161
@@ -1,456 +0,0 @@
1
- import { describe, it } from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import { readFileSync } from 'node:fs';
4
- import {
5
- DELEGATE_FRAMING_RESERVE_TOKENS,
6
- DELEGATE_INLINE_ANSWER_BYTES,
7
- DELEGATE_MIN_CONTEXT_WINDOW_TOKENS,
8
- DELEGATE_MIN_USABLE_INPUT_TOKENS,
9
- DELEGATE_RESERVED_OUTPUT_TOKENS,
10
- DELEGATE_SAFETY_RESERVE_TOKENS,
11
- assertDelegateAdmission,
12
- delegateAllowedInputTokens,
13
- evaluateDelegateRuntimeBudget,
14
- planDelegateAdmission,
15
- resolveDelegateLimits,
16
- } from '../delegate/budget.js';
17
- import { DelegateError, type DelegatePinnedRoute } from '../delegate/types.js';
18
- import {
19
- TOKEN_BUDGET_AFFINE_F_TOKENS,
20
- TOKEN_BUDGET_FAMILY_CALIBRATIONS,
21
- TOKEN_BUDGET_PROVABLE_RATE_X100,
22
- estimateInputTokens,
23
- maxKnownTextBytesForTokens,
24
- } from '../context-token-budget.js';
25
-
26
- function route(
27
- contextWindow: number,
28
- provider = 'openai-codex',
29
- model = 'gpt-5.5',
30
- ): DelegatePinnedRoute {
31
- return {
32
- provider,
33
- model,
34
- qualified_id: `${provider}/${model}`,
35
- context_window_tokens: contextWindow,
36
- thinking_level: 'medium',
37
- origin: 'explicit',
38
- };
39
- }
40
-
41
- const INCIDENT = JSON.parse(
42
- readFileSync(new URL('../fixtures/delegate-context-incident.json', import.meta.url), 'utf8'),
43
- ) as Record<string, unknown>;
44
-
45
- function incidentNumber(key: string): number {
46
- const value = INCIDENT[key];
47
- if (typeof value !== 'number') throw new Error(`incident fixture ${key} must be numeric`);
48
- return value;
49
- }
50
-
51
- const LIMITS = {
52
- max_turns: 24,
53
- max_tool_calls: 120,
54
- timeout_seconds: 900,
55
- max_tool_result_bytes: 65_536,
56
- max_total_tool_output_bytes: 67_108_864,
57
- max_answer_bytes: 4_194_304,
58
- allowed_input_tokens: 0,
59
- };
60
-
61
- function maxDelegateKnownBytes(pinnedRoute: DelegatePinnedRoute): number {
62
- const allowed = delegateAllowedInputTokens(pinnedRoute);
63
- const probe = planDelegateAdmission({
64
- route: pinnedRoute,
65
- childPrompt: 'x '.repeat(30_000),
66
- childSystemPrompt: '',
67
- limits: LIMITS,
68
- });
69
- const rate = probe.route.rate_source;
70
- return Math.floor(
71
- ((allowed - rate.affine_f_tokens) * rate.effective_rate_bytes_per_token_x100) /
72
- 100,
73
- );
74
- }
75
-
76
- function normalText(bytes: number): string {
77
- return `${'x '.repeat(Math.floor(bytes / 2))}${bytes % 2 === 0 ? '' : 'x'}`;
78
- }
79
-
80
- function delegateTokenForecast(bytes: number, allowedInputTokens: number): number {
81
- return estimateInputTokens({
82
- family: 'openai-codex',
83
- allowedInputTokens,
84
- scope: 'delegate_launch',
85
- segments: [{ kind: 'known_text', bytes, multibyteBytes: 0, denseBytes: 0 }],
86
- }).tokens;
87
- }
88
-
89
- void describe('delegate route capacity', () => {
90
- void it('subtracts every documented reserve from the context window', () => {
91
- const window = 200_000;
92
- assert.equal(
93
- delegateAllowedInputTokens(route(window)),
94
- window -
95
- DELEGATE_RESERVED_OUTPUT_TOKENS -
96
- DELEGATE_FRAMING_RESERVE_TOKENS -
97
- DELEGATE_SAFETY_RESERVE_TOKENS,
98
- );
99
- });
100
-
101
- void it('accepts exactly the documented minimum window and rejects one token below', () => {
102
- assert.equal(
103
- delegateAllowedInputTokens(route(DELEGATE_MIN_CONTEXT_WINDOW_TOKENS)),
104
- DELEGATE_MIN_USABLE_INPUT_TOKENS,
105
- );
106
- assert.throws(
107
- () => delegateAllowedInputTokens(route(DELEGATE_MIN_CONTEXT_WINDOW_TOKENS - 1)),
108
- (error: unknown) =>
109
- error instanceof DelegateError &&
110
- error.code === 'route_capacity_unknown' &&
111
- error.childCreated === false,
112
- );
113
- });
114
-
115
- void it('never assumes a default window for unusable capacity', () => {
116
- for (const window of [0, -1, Number.NaN, Number.POSITIVE_INFINITY, 1.5]) {
117
- assert.throws(
118
- () => delegateAllowedInputTokens(route(window)),
119
- (error: unknown) =>
120
- error instanceof DelegateError && error.code === 'route_capacity_unknown',
121
- `window ${String(window)} must be refused, not defaulted`,
122
- );
123
- }
124
- });
125
- });
126
-
127
- void describe('delegate launch admission', () => {
128
- void it('fits when the seed is comfortably under the route allowance', () => {
129
- const pinnedRoute = route(200_000);
130
- const plan = planDelegateAdmission({
131
- route: pinnedRoute,
132
- childPrompt: 'x'.repeat(1000),
133
- childSystemPrompt: 'y'.repeat(500),
134
- limits: LIMITS,
135
- });
136
- assert.equal(plan.fits, true);
137
- assert.equal(plan.schema_version, 'pi-background-tasks.delegate-budget-plan.v3');
138
- assert.equal(plan.policy.id, 'delegate-budget-policy-v3');
139
- assert.equal(plan.child_prompt_utf8_bytes, 1000);
140
- assert.equal(plan.system_prompt_utf8_bytes, 500);
141
- assert.equal(plan.launch_utf8_bytes, 1500);
142
- assert.equal(plan.launch_input_tokens_upper_bound, plan.estimate.tokens);
143
- assert.equal(plan.route.family, 'openai-codex');
144
- assert.equal(plan.route.rate_source.source, 'delegate_conservative');
145
- assert.doesNotThrow(() => {
146
- assertDelegateAdmission(plan);
147
- });
148
- });
149
-
150
- void it('accepts exactly at the affine boundary and rejects one byte past it', () => {
151
- const pinnedRoute = route(200_000);
152
- const exactBytes = maxDelegateKnownBytes(pinnedRoute);
153
- const atLimit = planDelegateAdmission({
154
- route: pinnedRoute,
155
- childPrompt: normalText(exactBytes),
156
- childSystemPrompt: '',
157
- limits: LIMITS,
158
- });
159
- assert.equal(atLimit.fits, true);
160
- assert.equal(atLimit.signed_headroom_tokens, 0);
161
- assert.doesNotThrow(() => {
162
- assertDelegateAdmission(atLimit);
163
- });
164
-
165
- const overLimit = planDelegateAdmission({
166
- route: pinnedRoute,
167
- childPrompt: normalText(exactBytes + 1),
168
- childSystemPrompt: '',
169
- limits: LIMITS,
170
- });
171
- assert.equal(overLimit.fits, false);
172
- assert.throws(
173
- () => {
174
- assertDelegateAdmission(overLimit);
175
- },
176
- (error: unknown) =>
177
- error instanceof DelegateError &&
178
- error.code === 'seed_budget_exceeded' &&
179
- error.childCreated === false,
180
- );
181
- });
182
-
183
- void it('counts the child system prompt as input, not as free framing', () => {
184
- const pinnedRoute = route(200_000);
185
- const seedBytes = maxDelegateKnownBytes(pinnedRoute);
186
- const plan = planDelegateAdmission({
187
- route: pinnedRoute,
188
- childPrompt: normalText(seedBytes),
189
- childSystemPrompt: 'y ',
190
- limits: LIMITS,
191
- });
192
- assert.equal(plan.fits, false, 'the system prompt must consume the same allowance');
193
- });
194
-
195
- void it('measures multi-byte UTF-8 by bytes and persists the provable advisory ceiling', () => {
196
- const emoji = '👩‍👩‍👧‍👦';
197
- const plan = planDelegateAdmission({
198
- route: route(200_000),
199
- childPrompt: emoji.repeat(100),
200
- childSystemPrompt: '',
201
- limits: LIMITS,
202
- });
203
- assert.equal(plan.child_prompt_utf8_bytes, Buffer.byteLength(emoji.repeat(100), 'utf8'));
204
- assert.ok(plan.child_prompt_utf8_bytes > emoji.repeat(100).length);
205
- assert.equal(plan.estimate.byte_class_breakdown.multibyte_bytes, plan.child_prompt_utf8_bytes);
206
- assert.equal(plan.estimate.perSegment[0]?.multibyte_provable_tokens, plan.child_prompt_utf8_bytes);
207
- assert.ok((plan.estimate.perSegment[0]?.multibyte_tokens ?? 0) < plan.child_prompt_utf8_bytes);
208
- assert.equal(plan.dominant_byte_class, 'multibyte');
209
- });
210
-
211
- void it('scope guard refuses the codex 23,674-byte delegate floor case', () => {
212
- const pinnedRoute = route(DELEGATE_MIN_CONTEXT_WINDOW_TOKENS, 'openai-codex', 'gpt-5.5');
213
- assert.equal(delegateAllowedInputTokens(pinnedRoute), 8192);
214
- const plan = planDelegateAdmission({
215
- route: pinnedRoute,
216
- childPrompt: 'x'.repeat(23_674),
217
- childSystemPrompt: '',
218
- limits: LIMITS,
219
- });
220
- assert.equal(plan.route.rate_source.source, 'delegate_conservative');
221
- assert.equal(plan.fits, false);
222
- assert.throws(
223
- () => assertDelegateAdmission(plan),
224
- (error: unknown) => error instanceof DelegateError && error.code === 'seed_budget_exceeded',
225
- );
226
- });
227
-
228
- void it('scope guard refuses the anthropic 13,286-byte delegate zero-headroom case', () => {
229
- const pinnedRoute = route(DELEGATE_MIN_CONTEXT_WINDOW_TOKENS, 'anthropic', 'claude-opus-5');
230
- assert.equal(delegateAllowedInputTokens(pinnedRoute), 8192);
231
- const beforeAnthropicForecast = estimateInputTokens({
232
- family: 'anthropic',
233
- allowedInputTokens: 8192,
234
- scope: 'fusion',
235
- segments: [{ kind: 'known_text', bytes: 13_286, multibyteBytes: 0, denseBytes: 0 }],
236
- }).tokens;
237
- assert.equal(beforeAnthropicForecast, 8_192);
238
- const plan = planDelegateAdmission({
239
- route: pinnedRoute,
240
- childPrompt: 'x'.repeat(13_286),
241
- childSystemPrompt: '',
242
- limits: LIMITS,
243
- });
244
- assert.equal(plan.route.rate_source.source, 'delegate_conservative');
245
- assert.equal(plan.route.rate_source.backed, true);
246
- assert.equal(plan.route.rate_source.effective_rate_bytes_per_token_x100, TOKEN_BUDGET_PROVABLE_RATE_X100);
247
- assert.equal(plan.launch_input_tokens_upper_bound, 13_798);
248
- assert.equal(plan.fits, false);
249
- assert.throws(
250
- () => assertDelegateAdmission(plan),
251
- (error: unknown) => {
252
- assert.ok(error instanceof DelegateError);
253
- assert.equal(error.code, 'seed_budget_exceeded');
254
- assert.equal(error.budget?.rate_source.source, 'delegate_conservative');
255
- assert.equal(error.budget?.backed, true);
256
- assert.equal(error.budget?.dominant_byte_class, 'normal');
257
- assert.match(error.message, /backed=true/);
258
- assert.match(error.message, /dominant_byte_class=normal/);
259
- return true;
260
- },
261
- );
262
- });
263
-
264
- void it('replays the incident byte-class contract with calibrated runway and a provable counter-forecast', () => {
265
- const promptBytes = incidentNumber('child_prompt_utf8_bytes');
266
- const multibyteBytes = incidentNumber('launch_multibyte_bytes');
267
- assert.equal(multibyteBytes % Buffer.byteLength('€', 'utf8'), 0);
268
- const childPrompt = `${normalText(promptBytes - multibyteBytes)}${'€'.repeat(multibyteBytes / 3)}`;
269
- const childSystemPrompt = normalText(incidentNumber('system_prompt_utf8_bytes'));
270
- assert.equal(Buffer.byteLength(childPrompt, 'utf8'), promptBytes);
271
- const pinnedRoute = route(
272
- incidentNumber('context_window_tokens'),
273
- 'openai-codex',
274
- 'gpt-5.6-sol',
275
- );
276
- const plan = planDelegateAdmission({
277
- route: pinnedRoute,
278
- childPrompt,
279
- childSystemPrompt,
280
- limits: LIMITS,
281
- });
282
- assert.equal(plan.launch_utf8_bytes, incidentNumber('launch_utf8_bytes'));
283
- assert.equal(plan.byte_class_breakdown.normal_bytes, incidentNumber('launch_normal_bytes'));
284
- assert.equal(plan.byte_class_breakdown.multibyte_bytes, multibyteBytes);
285
- assert.equal(plan.route.allowed_input_tokens, incidentNumber('allowed_input_tokens'));
286
- assert.equal(plan.route.rate_source.source, 'calibrated_large_window');
287
- assert.equal(
288
- plan.route.rate_source.effective_rate_bytes_per_token_x100,
289
- incidentNumber('calibrated_rate_bytes_per_token_x100'),
290
- );
291
- assert.equal(plan.fits, true);
292
- assert.ok(plan.launch_input_tokens_upper_bound < 70_000);
293
- assert.equal(
294
- plan.conservative_estimate.tokens,
295
- incidentNumber('old_one_byte_normal_two_byte_multibyte_forecast'),
296
- );
297
- assert.equal(
298
- plan.conservative_launch_input_tokens,
299
- incidentNumber('provable_one_byte_per_token_forecast'),
300
- );
301
- assert.equal(plan.conservative_launch_fits, true);
302
- assert.ok(plan.retained_growth_budget_tokens > 240_000);
303
- assert.equal(
304
- plan.finalization_input_reserve_tokens,
305
- incidentNumber('finalization_reserve_tokens'),
306
- );
307
- });
308
-
309
- void it('publishes the provable ceiling for multibyte-heavy conservative forecasts', () => {
310
- const pinnedRoute = route(128_672, 'openai-codex', 'gpt-5.6-sol');
311
- const plan = planDelegateAdmission({
312
- route: pinnedRoute,
313
- childPrompt: '€'.repeat(40_000),
314
- childSystemPrompt: '',
315
- limits: LIMITS,
316
- });
317
- assert.equal(plan.route.allowed_input_tokens, 100_000);
318
- assert.ok(
319
- plan.conservative_estimate.tokens < plan.route.allowed_input_tokens,
320
- 'the legacy 2 B/token multibyte diagnostic demonstrates the original false fit',
321
- );
322
- assert.equal(plan.conservative_launch_input_tokens, 120_512);
323
- assert.equal(plan.conservative_launch_fits, false);
324
- });
325
-
326
- void it('unknown family is loud and no looser than calibrated families', () => {
327
- const unknownRoute = route(200_000, 'mystery-provider', 'mystery-model');
328
- const plan = planDelegateAdmission({
329
- route: unknownRoute,
330
- childPrompt: 'x',
331
- childSystemPrompt: '',
332
- limits: LIMITS,
333
- });
334
- const calibratedRates = Object.values(TOKEN_BUDGET_FAMILY_CALIBRATIONS)
335
- .filter((entry) => entry.provenance.backed)
336
- .map((entry) => entry.rate_bytes_per_token_x100);
337
- assert.equal(plan.route.family, 'unknown');
338
- assert.equal(plan.route.rate_source.backed, false);
339
- assert.ok(plan.route.rate_source.warning?.includes('unknown provider'));
340
- assert.ok(
341
- plan.route.rate_source.effective_rate_bytes_per_token_x100 <= Math.min(...calibratedRates),
342
- );
343
- const oversized = planDelegateAdmission({
344
- route: unknownRoute,
345
- childPrompt: 'x'.repeat(delegateAllowedInputTokens(unknownRoute)),
346
- childSystemPrompt: '',
347
- limits: LIMITS,
348
- });
349
- assert.throws(
350
- () => assertDelegateAdmission(oversized),
351
- (error: unknown) => {
352
- assert.ok(error instanceof DelegateError);
353
- assert.match(error.message, /unknown provider/);
354
- return true;
355
- },
356
- );
357
- });
358
-
359
- void it('states what was preserved and how to remediate, and never clamps', () => {
360
- const pinnedRoute = route(200_000);
361
- const plan = planDelegateAdmission({
362
- route: pinnedRoute,
363
- childPrompt: 'x'.repeat(maxDelegateKnownBytes(pinnedRoute) * 2),
364
- childSystemPrompt: '',
365
- limits: LIMITS,
366
- });
367
- try {
368
- assertDelegateAdmission(plan);
369
- assert.fail('oversized admission must throw');
370
- } catch (error) {
371
- assert.ok(error instanceof DelegateError);
372
- assert.equal(error.code, 'seed_budget_exceeded');
373
- assert.equal(error.childCreated, false);
374
- assert.match(error.message, /No child process, child session, or artifact was created/);
375
- assert.match(error.message, /Nothing was clipped, dropped, or substituted/);
376
- assert.ok(error.remediation.length > 0);
377
- assert.match(error.describe(), /Child process created: no/);
378
- }
379
- });
380
- });
381
-
382
- void describe('delegate runtime governor', () => {
383
- void it('is total and never throws from inside a hook', () => {
384
- const pinnedRoute = route(200_000);
385
- for (const bytes of [0, 1, 10_000, 10_000_000]) {
386
- const verdict = evaluateDelegateRuntimeBudget(
387
- { retainedInputBytes: bytes, retainedInputMultibyteBytes: 0, retainedInputDenseBytes: 0 },
388
- 5_000,
389
- pinnedRoute,
390
- );
391
- assert.equal(verdict.measuredTokens, delegateTokenForecast(bytes, 5_000));
392
- assert.equal(verdict.allowedTokens, 5_000);
393
- }
394
- });
395
-
396
- void it('permits exactly the allowance and refuses one token past it', () => {
397
- const allowed = 1_000;
398
- const pinnedRoute = route(allowed + 28_672);
399
- const exactBytes = maxKnownTextBytesForTokens({
400
- family: 'openai-codex',
401
- allowedInputTokens: allowed,
402
- scope: 'delegate_launch',
403
- });
404
- const exact = evaluateDelegateRuntimeBudget(
405
- {
406
- retainedInputBytes: exactBytes,
407
- retainedInputMultibyteBytes: 0,
408
- retainedInputDenseBytes: 0,
409
- },
410
- allowed,
411
- pinnedRoute,
412
- );
413
- assert.equal(exact.withinBudget, true);
414
- assert.equal(exact.overageTokens, 0);
415
-
416
- const over = evaluateDelegateRuntimeBudget(
417
- {
418
- retainedInputBytes: exactBytes + 1,
419
- retainedInputMultibyteBytes: 0,
420
- retainedInputDenseBytes: 0,
421
- },
422
- allowed,
423
- pinnedRoute,
424
- );
425
- assert.equal(over.withinBudget, false);
426
- assert.equal(over.overageTokens, 1);
427
- });
428
- });
429
-
430
- void describe('delegate limits', () => {
431
- void it('applies documented defaults and derives the route allowance', () => {
432
- const limits = resolveDelegateLimits(route(200_000));
433
- assert.equal(limits.max_turns, 24);
434
- assert.equal(limits.max_tool_calls, 120);
435
- assert.equal(limits.timeout_seconds, 1200);
436
- assert.equal(limits.allowed_input_tokens, delegateAllowedInputTokens(route(200_000)));
437
- });
438
-
439
- void it('rejects non-positive and non-integer overrides loudly', () => {
440
- for (const value of [0, -1, 1.5, Number.NaN]) {
441
- assert.throws(
442
- () => resolveDelegateLimits(route(200_000), { maxTurns: value }),
443
- (error: unknown) => error instanceof DelegateError && error.code === 'invalid_arguments',
444
- );
445
- }
446
- });
447
-
448
- void it('keeps the inline answer cap strictly below the answer capture cap', () => {
449
- const limits = resolveDelegateLimits(route(200_000));
450
- assert.ok(
451
- DELEGATE_INLINE_ANSWER_BYTES < limits.max_answer_bytes,
452
- 'an answer must be capturable even when it is too large to inline',
453
- );
454
- assert.equal(TOKEN_BUDGET_AFFINE_F_TOKENS, 512);
455
- });
456
- });