@idlekit/core 0.3.1 → 0.4.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.
Files changed (47) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +7 -0
  3. package/dist/index.js +7 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/scenario/compile.js +1 -0
  6. package/dist/scenario/compile.js.map +1 -1
  7. package/dist/scenario/scenarioContract.d.ts +30 -0
  8. package/dist/scenario/scenarioContract.js +35 -0
  9. package/dist/scenario/scenarioContract.js.map +1 -1
  10. package/dist/sim/advance.d.ts +198 -0
  11. package/dist/sim/advance.js +609 -0
  12. package/dist/sim/advance.js.map +1 -0
  13. package/dist/sim/analysis/checks.d.ts +260 -0
  14. package/dist/sim/analysis/checks.js +1442 -0
  15. package/dist/sim/analysis/checks.js.map +1 -0
  16. package/dist/sim/analysis/flow.d.ts +169 -0
  17. package/dist/sim/analysis/flow.js +1359 -0
  18. package/dist/sim/analysis/flow.js.map +1 -0
  19. package/dist/sim/analysis/jevAdvisory.d.ts +113 -0
  20. package/dist/sim/analysis/jevAdvisory.js +846 -0
  21. package/dist/sim/analysis/jevAdvisory.js.map +1 -0
  22. package/dist/sim/analysis/judge.d.ts +145 -0
  23. package/dist/sim/analysis/judge.js +1451 -0
  24. package/dist/sim/analysis/judge.js.map +1 -0
  25. package/dist/sim/analysis/registry.d.ts +9 -6
  26. package/dist/sim/analysis/registry.js +15 -2
  27. package/dist/sim/analysis/registry.js.map +1 -1
  28. package/dist/sim/executionBackend.d.ts +165 -0
  29. package/dist/sim/executionBackend.js +521 -0
  30. package/dist/sim/executionBackend.js.map +1 -0
  31. package/dist/sim/integrationMatrix.d.ts +52 -0
  32. package/dist/sim/integrationMatrix.js +68 -0
  33. package/dist/sim/integrationMatrix.js.map +1 -0
  34. package/dist/sim/observation.d.ts +11 -0
  35. package/dist/sim/observation.js +12 -0
  36. package/dist/sim/observation.js.map +1 -1
  37. package/dist/sim/offline.d.ts +2 -0
  38. package/dist/sim/offline.js +68 -1
  39. package/dist/sim/offline.js.map +1 -1
  40. package/dist/sim/simulator.d.ts +2 -0
  41. package/dist/sim/simulator.js +71 -1
  42. package/dist/sim/simulator.js.map +1 -1
  43. package/dist/sim/step.d.ts +10 -0
  44. package/dist/sim/step.js +10 -0
  45. package/dist/sim/step.js.map +1 -1
  46. package/dist/sim/types.d.ts +11 -0
  47. package/package.json +1 -1
@@ -0,0 +1,521 @@
1
+ import { canonicalJson, sha256Text } from "../scenario/scenarioContract";
2
+ import { logicalDrawSeed } from "./random";
3
+ /**
4
+ * Local execution backend.
5
+ * This module does not start a worker, open a file, or call the network.
6
+ * A Bun pool is a CLI adapter. The default batch is local.
7
+ */
8
+ /**
9
+ * @evidence docs/requirements/active/worker-execution-backend.md#req-dx05-local-default The default backend is local. Worker count is not selected here.
10
+ * @evidenceReview docs/requirements/active/worker-execution-backend.md#req-dx05-local-default #db57164 Re-read the section: maxWorkers 0 is the local default and there is no automatic worker selection.
11
+ */
12
+ export const executionLocalDefault = "local-default";
13
+ /**
14
+ * @evidence docs/requirements/active/worker-execution-backend.md#req-dx05-serializable-task A task is a plain JSON descriptor. The seed is the logical draw seed.
15
+ * @evidenceReview docs/requirements/active/worker-execution-backend.md#req-dx05-serializable-task #a0e348b Re-read the section: functions, class instances, cyclic payloads, and a bad step budget are refused before cost is measured, a shared reference is allowed, and the seed does not read a worker slot.
16
+ */
17
+ export const executionSerializableTask = "json-descriptor";
18
+ /**
19
+ * @evidence docs/requirements/active/worker-execution-backend.md#req-dx05-stable-reduction Outcomes are ordered by logical index. The money total is a decimal-string sum.
20
+ * @evidenceReview docs/requirements/active/worker-execution-backend.md#req-dx05-stable-reduction #855174a Re-read the section: completion order is not the addition order, Number() is not the sum, and a scientific amount is summed exactly.
21
+ */
22
+ export const executionStableReduction = "logical-index";
23
+ /**
24
+ * @evidence docs/requirements/active/worker-execution-backend.md#req-dx05-failure-boundary Failure, cancellation, and incomplete stays are distinct. A partial batch is not a full distribution.
25
+ * @evidenceReview docs/requirements/active/worker-execution-backend.md#req-dx05-failure-boundary #2262fcb Re-read the section: timeout and abort do not become a successful distribution, a retry keeps the same id and seed, the timeout is per task and per attempt, and a thrown runner is a failed task.
26
+ */
27
+ export const executionFailureBoundary = "not-a-partial-distribution";
28
+ /**
29
+ * @evidence docs/requirements/active/worker-execution-backend.md#req-dx05-local-default The local budget keeps maxWorkers at 0 and records spawn cost on the batch.
30
+ * @evidenceReview docs/requirements/active/worker-execution-backend.md#req-dx05-local-default #db57164 Re-read the section: a small batch does not choose a worker count.
31
+ */
32
+ export const defaultExecutionBudget = Object.freeze({
33
+ maxWorkers: 0,
34
+ queueBound: 64,
35
+ taskTimeoutMs: 30_000,
36
+ stepBudget: 100_000,
37
+ maxRetries: 0,
38
+ });
39
+ const DECIMAL = /^(-?)(\d+)(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/;
40
+ /*
41
+ * Two amounts whose exponents differ by more than this many digits are not summed exactly.
42
+ * Break-infinity end money such as 1e+400 sits well inside it.
43
+ */
44
+ const MAX_EXPONENT_SPAN = 100_000;
45
+ /** The largest delay a setTimeout honors. */
46
+ const MAX_TIMER_MS = 2_147_483_647;
47
+ function budgetOf(budget) {
48
+ // A frozen copy: a runner receives it as ctx.budget and cannot raise maxRetries after the check.
49
+ const chosen = Object.freeze({ ...(budget ?? defaultExecutionBudget) });
50
+ assertExecutionBudget(chosen);
51
+ return chosen;
52
+ }
53
+ /**
54
+ * Every budget field is a finite, non-negative integer, so a retry loop, a queue bound, or a step ceiling cannot be
55
+ * made endless or skipped by NaN or Infinity. Both backends check it before running anything.
56
+ *
57
+ * @evidence docs/requirements/active/worker-execution-backend.md#req-dx05-failure-boundary A budget with a non-finite or negative field is refused before any task runs.
58
+ * @evidenceReview docs/requirements/active/worker-execution-backend.md#req-dx05-failure-boundary #2262fcb Re-read the section: retries stop at maxRetries, which must therefore be finite.
59
+ */
60
+ export function assertExecutionBudget(budget) {
61
+ for (const field of ["maxWorkers", "queueBound", "taskTimeoutMs", "stepBudget", "maxRetries"]) {
62
+ const value = budget[field];
63
+ if (!Number.isSafeInteger(value) || value < 0)
64
+ throw new Error(`execution budget ${field} must be a finite integer >= 0`);
65
+ }
66
+ // A worker timer past this range fires after 1 ms instead, so a longer window is refused in both backends.
67
+ if (budget.taskTimeoutMs > MAX_TIMER_MS)
68
+ throw new Error(`execution budget taskTimeoutMs must be <= ${MAX_TIMER_MS}`);
69
+ }
70
+ function assertPlain(value, seen) {
71
+ if (value === null || typeof value === "string" || typeof value === "boolean")
72
+ return;
73
+ if (typeof value === "number") {
74
+ if (!Number.isFinite(value))
75
+ throw new Error("non-finite number");
76
+ return;
77
+ }
78
+ if (typeof value !== "object")
79
+ throw new Error("not serializable");
80
+ // `seen` holds only the objects on the current path. A shared, acyclic reference serializes fine.
81
+ if (seen.has(value))
82
+ throw new Error("cycle");
83
+ // Every own property must be plain data. A hidden toJSON, a getter, or a symbol key would let serialization
84
+ // differ from what was checked, so any of them is refused.
85
+ for (const key of Reflect.ownKeys(value)) {
86
+ if (Array.isArray(value) && key === "length")
87
+ continue;
88
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
89
+ if (typeof key !== "string" || !descriptor || !("value" in descriptor) || !descriptor.enumerable) {
90
+ throw new Error("not serializable");
91
+ }
92
+ }
93
+ seen.add(value);
94
+ try {
95
+ if (Array.isArray(value)) {
96
+ if (Object.getPrototypeOf(value) !== Array.prototype)
97
+ throw new Error("not a plain array");
98
+ // An array carries indexed items only. A named property such as an own toJSON is refused.
99
+ for (const key of Object.keys(value)) {
100
+ if (!/^(0|[1-9]\d*)$/.test(key) || Number(key) >= 4294967295)
101
+ throw new Error("not serializable");
102
+ }
103
+ for (const item of value)
104
+ assertPlain(item, seen);
105
+ return;
106
+ }
107
+ if (Object.getPrototypeOf(value) !== Object.prototype)
108
+ throw new Error("not a plain object");
109
+ for (const entry of Object.values(value))
110
+ assertPlain(entry, seen);
111
+ }
112
+ finally {
113
+ seen.delete(value);
114
+ }
115
+ }
116
+ export function assertSerializableTask(task) {
117
+ if (task.schemaVersion !== 1 || task.contract !== "idlekit.execution-task.v1") {
118
+ throw new Error("unsupported task contract");
119
+ }
120
+ if (task.kind !== "analysis-trial")
121
+ throw new Error("unsupported task kind");
122
+ if (!Number.isSafeInteger(task.logicalIndex) || task.logicalIndex < 0)
123
+ throw new Error("logical index");
124
+ if (!Number.isInteger(task.seed) || task.seed < 0 || task.seed > 4294967295)
125
+ throw new Error("seed");
126
+ if (typeof task.taskId !== "string" || task.taskId.length === 0)
127
+ throw new Error("task id");
128
+ if (!Number.isSafeInteger(task.stepBudget) || task.stepBudget < 0)
129
+ throw new Error("step budget");
130
+ assertPlain(task.payload, new WeakSet());
131
+ // The plugin containers keep their declared shapes. A string spread into characters is not a path list.
132
+ if (!Array.isArray(task.pluginPaths) || !task.pluginPaths.every((item) => typeof item === "string")) {
133
+ throw new Error("plugin paths");
134
+ }
135
+ if (!Array.isArray(task.pluginRoots) || !task.pluginRoots.every((item) => typeof item === "string")) {
136
+ throw new Error("plugin roots");
137
+ }
138
+ const digests = task.pluginDigests;
139
+ if (digests === null ||
140
+ typeof digests !== "object" ||
141
+ Array.isArray(digests) ||
142
+ Object.getPrototypeOf(digests) !== Object.prototype ||
143
+ !Object.values(digests).every((item) => typeof item === "string")) {
144
+ throw new Error("plugin digests");
145
+ }
146
+ // The descriptor itself is posted, so an extra own property such as a function is refused here too.
147
+ assertPlain(task, new WeakSet());
148
+ }
149
+ /** Logical draw seed. Worker count and completion order are not arguments. */
150
+ export function analysisTaskSeed(baseSeed, logicalIndex) {
151
+ return logicalDrawSeed(baseSeed, logicalIndex);
152
+ }
153
+ function parseDecimal(value) {
154
+ const match = DECIMAL.exec(value);
155
+ if (!match)
156
+ throw new Error("decimal required");
157
+ const [, sign = "", whole = "0", frac = "", exponentText] = match;
158
+ const exponent = exponentText === undefined ? 0n : BigInt(exponentText);
159
+ const magnitude = BigInt(`${whole}${frac}`);
160
+ return {
161
+ digits: sign === "-" ? -magnitude : magnitude,
162
+ exponent: exponent - BigInt(frac.length),
163
+ scientific: exponentText !== undefined,
164
+ };
165
+ }
166
+ function renderPlain(sum, scale) {
167
+ const negative = sum < 0n;
168
+ const abs = (negative ? -sum : sum).toString().padStart(scale + 1, "0");
169
+ const whole = scale === 0 ? abs : abs.slice(0, abs.length - scale);
170
+ const frac = scale === 0 ? "" : abs.slice(abs.length - scale).replace(/0+$/, "");
171
+ const text = frac.length > 0 ? `${whole}.${frac}` : whole.replace(/^0+(?=\d)/, "");
172
+ if (text === "0")
173
+ return "0";
174
+ return negative ? `-${text}` : text;
175
+ }
176
+ /** Exact scientific form: every significant digit stays, so no rounding happens here. */
177
+ function renderScientific(sum, exponent) {
178
+ if (sum === 0n)
179
+ return "0";
180
+ const negative = sum < 0n;
181
+ let digits = negative ? -sum : sum;
182
+ let power = exponent;
183
+ while (digits % 10n === 0n) {
184
+ digits /= 10n;
185
+ power += 1n;
186
+ }
187
+ const text = digits.toString();
188
+ const scientificExponent = power + BigInt(text.length - 1);
189
+ const mantissa = text.length > 1 ? `${text[0]}.${text.slice(1)}` : text;
190
+ return `${negative ? "-" : ""}${mantissa}e${scientificExponent >= 0n ? "+" : ""}${scientificExponent}`;
191
+ }
192
+ export function addDecimalStrings(left, right) {
193
+ const a = parseDecimal(left);
194
+ const b = parseDecimal(right);
195
+ const scientific = a.scientific || b.scientific;
196
+ // A zero term has no exponent to align, so a far exponent on zero does not widen the sum.
197
+ if (a.digits === 0n || b.digits === 0n) {
198
+ const only = a.digits === 0n ? b : a;
199
+ if (scientific)
200
+ return renderScientific(only.digits, only.exponent);
201
+ return renderPlain(only.digits, Number(only.exponent < 0n ? -only.exponent : 0n));
202
+ }
203
+ const low = a.exponent < b.exponent ? a.exponent : b.exponent;
204
+ const high = a.exponent < b.exponent ? b.exponent : a.exponent;
205
+ // Only the gap between the two exponents is expanded, so a huge exponent on both sides is still exact.
206
+ if (high - low > BigInt(MAX_EXPONENT_SPAN))
207
+ throw new Error("exponent span too wide for an exact sum");
208
+ const sum = a.digits * 10n ** (a.exponent - low) + b.digits * 10n ** (b.exponent - low);
209
+ // Plain inputs have exponent <= 0, so the plain form keeps the earlier output exactly.
210
+ if (scientific)
211
+ return renderScientific(sum, low);
212
+ return renderPlain(sum, Number(-low));
213
+ }
214
+ /** UTF-8 bytes of the JSON message that carries one task. JSON.stringify().length counts UTF-16 units instead. */
215
+ export function serializedTaskBytes(task) {
216
+ return new TextEncoder().encode(JSON.stringify(task)).byteLength;
217
+ }
218
+ /** The refusal reason for each task, in input order, or null for a task that may run. */
219
+ export function taskRefusals(tasks, budget = defaultExecutionBudget) {
220
+ return prepareTrialTasks(tasks, budget).map((prepared) => {
221
+ return prepared.ok ? null : prepared.reason;
222
+ });
223
+ }
224
+ /** Dense admission results; every repeated logical identity is refused before either backend runs it. */
225
+ export function prepareTrialTasks(tasks, budget = defaultExecutionBudget) {
226
+ const prepared = Array.from(tasks, (task) => prepareTrialTask(task, budget));
227
+ const identities = new Map();
228
+ prepared.forEach((snapshot, index) => {
229
+ if (!snapshot.ok)
230
+ return;
231
+ const key = JSON.stringify([snapshot.task.logicalIndex, snapshot.task.taskId]);
232
+ const indices = identities.get(key) ?? [];
233
+ indices.push(index);
234
+ identities.set(key, indices);
235
+ });
236
+ for (const indices of identities.values()) {
237
+ if (indices.length < 2)
238
+ continue;
239
+ for (const index of indices)
240
+ prepared[index] = { ok: false, reason: "duplicate-task-identity" };
241
+ }
242
+ return prepared;
243
+ }
244
+ /** Validate the actual JSON snapshot inside the per-task refusal boundary. */
245
+ export function prepareTrialTask(task, budget = defaultExecutionBudget) {
246
+ try {
247
+ assertSerializableTask(task);
248
+ if (task.stepBudget > budget.stepBudget)
249
+ return { ok: false, reason: "step budget exceeds the execution budget" };
250
+ const snapshot = JSON.parse(JSON.stringify(task));
251
+ assertSerializableTask(snapshot);
252
+ // The budget's step limit is a ceiling on every task, so a larger request is refused, not run.
253
+ if (snapshot.stepBudget > budget.stepBudget)
254
+ return { ok: false, reason: "step budget exceeds the execution budget" };
255
+ return { ok: true, task: deepFreeze(snapshot) };
256
+ }
257
+ catch (error) {
258
+ // Thrown objects can have a missing, non-string, or throwing message property.
259
+ try {
260
+ const message = error instanceof Error ? error.message : undefined;
261
+ return { ok: false, reason: typeof message === "string" && message.length > 0 ? message : "invalid-task" };
262
+ }
263
+ catch {
264
+ return { ok: false, reason: "invalid-task" };
265
+ }
266
+ }
267
+ }
268
+ function ownData(value, key) {
269
+ try {
270
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
271
+ return descriptor && "value" in descriptor ? descriptor.value : undefined;
272
+ }
273
+ catch {
274
+ return undefined;
275
+ }
276
+ }
277
+ /** Apply the same success contract in both backends, without invoking outcome accessors. */
278
+ export function readTrialOutcome(value, task) {
279
+ // Even Array.isArray throws for a revoked proxy; malformed outcomes stay inside their trial boundary.
280
+ try {
281
+ if (value === null || typeof value !== "object" || Array.isArray(value))
282
+ return null;
283
+ }
284
+ catch {
285
+ return null;
286
+ }
287
+ if (ownData(value, "taskId") !== task.taskId || ownData(value, "logicalIndex") !== task.logicalIndex || ownData(value, "seed") !== task.seed)
288
+ return null;
289
+ const status = ownData(value, "status");
290
+ const reason = ownData(value, "reason");
291
+ const attempts = ownData(value, "attempts");
292
+ const semanticDigest = ownData(value, "semanticDigest");
293
+ const endMoney = ownData(value, "endMoney");
294
+ if (status !== "ok" && status !== "failed" && status !== "cancelled" && status !== "incomplete")
295
+ return null;
296
+ if (typeof reason !== "string" || typeof attempts !== "number" || !Number.isSafeInteger(attempts) || attempts < 0)
297
+ return null;
298
+ if (semanticDigest !== null && typeof semanticDigest !== "string")
299
+ return null;
300
+ if (endMoney !== null && typeof endMoney !== "string")
301
+ return null;
302
+ if (status === "ok" && (semanticDigest === null || endMoney === null))
303
+ return null;
304
+ try {
305
+ if (endMoney !== null)
306
+ addDecimalStrings("0", endMoney);
307
+ }
308
+ catch {
309
+ return null;
310
+ }
311
+ return { taskId: task.taskId, logicalIndex: task.logicalIndex, seed: task.seed, status, reason, attempts, semanticDigest, endMoney };
312
+ }
313
+ /**
314
+ * The identity an outcome reports, read from own data properties only. A refused descriptor may carry getters;
315
+ * reading them again could throw, so a field that is not plain data falls back to "", -1, or 0.
316
+ *
317
+ * @evidence docs/requirements/active/worker-execution-backend.md#req-dx05-serializable-task A refused task is reported without invoking its accessors.
318
+ * @evidenceReview docs/requirements/active/worker-execution-backend.md#req-dx05-serializable-task #a0e348b Re-read the section: a refused task fails alone and its siblings still run.
319
+ */
320
+ export function taskIdentity(task) {
321
+ if (task === null || typeof task !== "object")
322
+ return { taskId: "", logicalIndex: -1, seed: 0 };
323
+ const taskId = ownData(task, "taskId");
324
+ const logicalIndex = ownData(task, "logicalIndex");
325
+ const seed = ownData(task, "seed");
326
+ return {
327
+ taskId: typeof taskId === "string" ? taskId : "",
328
+ logicalIndex: typeof logicalIndex === "number" && Number.isSafeInteger(logicalIndex) && logicalIndex >= 0 ? logicalIndex : -1,
329
+ seed: typeof seed === "number" && Number.isInteger(seed) && seed >= 0 && seed <= 4294967295 ? seed : 0,
330
+ };
331
+ }
332
+ function deepFreeze(value) {
333
+ if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
334
+ Object.freeze(value);
335
+ for (const item of Object.values(value))
336
+ deepFreeze(item);
337
+ }
338
+ return value;
339
+ }
340
+ function outcomeOf(task, status, reason, attempts) {
341
+ const identity = taskIdentity(task);
342
+ return {
343
+ taskId: identity.taskId,
344
+ logicalIndex: identity.logicalIndex,
345
+ seed: identity.seed,
346
+ status,
347
+ reason,
348
+ attempts,
349
+ semanticDigest: null,
350
+ endMoney: null,
351
+ };
352
+ }
353
+ function orderedTasks(tasks) {
354
+ return [...tasks].sort((leftTask, rightTask) => {
355
+ const left = taskIdentity(leftTask);
356
+ const right = taskIdentity(rightTask);
357
+ return left.logicalIndex - right.logicalIndex || (left.taskId < right.taskId ? -1 : left.taskId > right.taskId ? 1 : 0);
358
+ });
359
+ }
360
+ export function finalizeBatch(outcomes, cost) {
361
+ const sorted = [...outcomes].sort((left, right) => left.logicalIndex - right.logicalIndex || (left.taskId < right.taskId ? -1 : left.taskId > right.taskId ? 1 : 0));
362
+ const full = sorted.length > 0 && sorted.every((outcome) => outcome.status === "ok");
363
+ let endMoney = null;
364
+ if (full) {
365
+ try {
366
+ endMoney = sorted.reduce((sum, outcome) => {
367
+ if (sum === null || outcome.endMoney === null)
368
+ return null;
369
+ return addDecimalStrings(sum, outcome.endMoney);
370
+ }, "0");
371
+ }
372
+ catch {
373
+ endMoney = null;
374
+ }
375
+ }
376
+ return {
377
+ schemaVersion: 1,
378
+ contract: "idlekit.execution-batch.v1",
379
+ batchId: cost.batchId,
380
+ backend: cost.backend,
381
+ selection: cost.selection,
382
+ complete: true,
383
+ fullDistribution: full,
384
+ outcomes: sorted,
385
+ reduction: { order: "logical-index", endMoney },
386
+ cost: { workerSpawnMs: cost.workerSpawnMs, serializedBytes: cost.serializedBytes },
387
+ };
388
+ }
389
+ function isPromise(value) {
390
+ return typeof value === "object" && value !== null && typeof value.then === "function";
391
+ }
392
+ export function runLocalBatch(submittedTasks, runner, options) {
393
+ const budget = budgetOf(options?.budget);
394
+ const tasks = Array.from(submittedTasks);
395
+ const signal = options?.signal;
396
+ const batchId = options?.batchId ?? `local-${tasks.length}`;
397
+ const clock = options?.clock ?? { now: () => performance.now() };
398
+ const header = {
399
+ batchId,
400
+ backend: "local",
401
+ selection: "local-default",
402
+ workerSpawnMs: 0,
403
+ serializedBytes: 0,
404
+ };
405
+ // Admission comes first, as in the worker pool: an aborted or oversized batch is answered before any measuring.
406
+ if (tasks.length === 0)
407
+ return finalizeBatch([], header);
408
+ // An abort before submit outranks every other outcome, the queue bound included.
409
+ if (signal?.aborted)
410
+ return finalizeBatch(tasks.map((task) => outcomeOf(task, "cancelled", "abort", 0)), header);
411
+ if (tasks.length > budget.queueBound) {
412
+ return finalizeBatch(tasks.map((task) => outcomeOf(task, "incomplete", "queue-bound", 0)), header);
413
+ }
414
+ // Validate before measuring, so a cyclic payload fails its own task instead of throwing out of the batch.
415
+ const snapshots = prepareTrialTasks(tasks, budget);
416
+ const reasons = snapshots.map((snapshot) => snapshot.ok ? null : snapshot.reason);
417
+ // A valid task runs from a frozen snapshot, so a runner cannot change its id, seed, or budget for a retry,
418
+ // and a later change to the caller's object cannot reach it.
419
+ const prepared = tasks.map((task, index) => { const snapshot = snapshots[index]; return snapshot.ok ? snapshot.task : task; });
420
+ const refusals = new Map(prepared.map((task, index) => [task, reasons[index] ?? null]));
421
+ header.serializedBytes = prepared.reduce((sum, task) => (refusals.get(task) === null ? sum + serializedTaskBytes(task) : sum), 0);
422
+ // taskTimeoutMs bounds each task on its own, as in the worker pool. There is no batch-wide window.
423
+ const outcomes = [];
424
+ for (const task of orderedTasks(prepared)) {
425
+ if (signal?.aborted) {
426
+ outcomes.push(outcomeOf(task, "cancelled", "abort", 0));
427
+ continue;
428
+ }
429
+ const invalid = refusals.get(task) ?? null;
430
+ if (invalid) {
431
+ outcomes.push(outcomeOf(task, "failed", invalid, 0));
432
+ continue;
433
+ }
434
+ let attempt = 0;
435
+ let outcome = null;
436
+ while (outcome === null) {
437
+ if (signal?.aborted) {
438
+ outcome = outcomeOf(task, "cancelled", "abort", attempt);
439
+ break;
440
+ }
441
+ const started = clock.now();
442
+ let raw;
443
+ try {
444
+ raw = runner(task, { signal: signal ?? new AbortController().signal, attempt, budget });
445
+ }
446
+ catch {
447
+ // A thrown trial is a retryable failure of that task, as a crashed worker is. The batch keeps going.
448
+ raw = outcomeOf(task, "failed", "trial-failed", attempt + 1);
449
+ }
450
+ let asynchronous = false;
451
+ let checked = null;
452
+ try {
453
+ asynchronous = isPromise(raw);
454
+ if (!asynchronous)
455
+ checked = readTrialOutcome(raw, task);
456
+ }
457
+ catch {
458
+ // Reflection or a throwing then getter is a malformed result of this task.
459
+ }
460
+ if (asynchronous) {
461
+ throw new Error("local execution runner must be synchronous");
462
+ }
463
+ checked ??= outcomeOf(task, "failed", "trial-failed", attempt + 1);
464
+ const elapsed = clock.now() - started;
465
+ const next = {
466
+ ...checked,
467
+ taskId: task.taskId,
468
+ logicalIndex: task.logicalIndex,
469
+ seed: task.seed,
470
+ attempts: attempt + 1,
471
+ };
472
+ // Every attempt is bounded, whatever it returned. A worker attempt is cut at the same window.
473
+ if (elapsed >= budget.taskTimeoutMs) {
474
+ outcome = outcomeOf(task, "incomplete", "timeout", attempt + 1);
475
+ break;
476
+ }
477
+ if (next.status === "failed" && next.reason !== "plugin-trust" && attempt < budget.maxRetries) {
478
+ attempt += 1;
479
+ continue;
480
+ }
481
+ outcome = next;
482
+ }
483
+ outcomes.push(outcome);
484
+ }
485
+ return finalizeBatch(outcomes, header);
486
+ }
487
+ export function createLocalExecutionBackend(runner, budget = defaultExecutionBudget) {
488
+ const ownedBudget = budgetOf(budget);
489
+ const inflight = new Map();
490
+ return {
491
+ kind: executionLocalDefault,
492
+ budget: () => ownedBudget,
493
+ cancel(batchId) {
494
+ inflight.get(batchId)?.abort();
495
+ },
496
+ submit(tasks, options) {
497
+ const first = tasks[0];
498
+ const batchId = options?.batchId ?? `local-${tasks.length}-${first ? taskIdentity(first).taskId || "empty" : "empty"}`;
499
+ const controller = new AbortController();
500
+ const parent = options?.signal;
501
+ const onAbort = () => controller.abort();
502
+ // A signal that was aborted before submit fires no event, so carry it over now.
503
+ if (parent?.aborted)
504
+ controller.abort();
505
+ else
506
+ parent?.addEventListener("abort", onAbort);
507
+ inflight.set(batchId, controller);
508
+ try {
509
+ return runLocalBatch(tasks, runner, { budget: ownedBudget, signal: controller.signal, batchId, clock: options?.clock });
510
+ }
511
+ finally {
512
+ inflight.delete(batchId);
513
+ parent?.removeEventListener("abort", onAbort);
514
+ }
515
+ },
516
+ };
517
+ }
518
+ export function semanticDigest(value) {
519
+ return sha256Text(canonicalJson(value));
520
+ }
521
+ //# sourceMappingURL=executionBackend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executionBackend.js","source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,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACvB,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,SAAS,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YACvH,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;YACzC,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,CAAC;YAC/B,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YACzC,gFAAgF;YAChF,IAAI,MAAM,EAAE,OAAO;gBAAE,UAAU,CAAC,KAAK,EAAE,CAAC;;gBACnC,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAChD,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YAClC,IAAI,CAAC;gBACH,OAAO,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;YAC1H,CAAC;oBAAS,CAAC;gBACT,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBACzB,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Hand answers for the integration matrix.
3
+ * These formulas do not call the simulator. A matching run is checked separately.
4
+ * `breakEternity` is unsupported. Optional tracks stay out of the default path.
5
+ */
6
+ /**
7
+ * @evidence docs/requirements/active/analysis-integration-release-gates.md#req-pr20-integration-matrix The selected release includes the optional tracks without making them the default.
8
+ * @evidenceReview docs/requirements/active/analysis-integration-release-gates.md#req-pr20-integration-matrix #91abfb0 Re-read the section: flow, guarded advance, Jev, and workers are shipped as optional capabilities, and their tests still run in the publish preflight.
9
+ */
10
+ export declare const integrationReleaseScope: "selected-optional-tracks";
11
+ /**
12
+ * @evidence docs/requirements/active/analysis-integration-release-gates.md#req-pr20-integration-matrix breakEternity is not a supported engine in this release.
13
+ * @evidenceReview docs/requirements/active/analysis-integration-release-gates.md#req-pr20-integration-matrix #91abfb0 Re-read the section: the placeholder engine is not advertised as ready.
14
+ */
15
+ export declare const integrationUnsupportedEngine: "breakEternity";
16
+ /**
17
+ * @evidence docs/requirements/active/analysis-integration-release-gates.md#req-pr20-integration-matrix Constant income uses integer seconds, not a stored simulator snapshot.
18
+ * @evidenceReview docs/requirements/active/analysis-integration-release-gates.md#req-pr20-integration-matrix #91abfb0 Re-read the section: end money is initial plus income per second times duration.
19
+ */
20
+ export declare const integrationHandAnswer: "integer-income-times-duration";
21
+ /**
22
+ * End wallet for constant per-second income.
23
+ * A duration off the step grid ends on a shorter final tick, as `runScenario` does, so the
24
+ * ticks still cover every second and the answer is income times the whole duration.
25
+ */
26
+ export declare function expectedLinearEnd(args: {
27
+ initial: string;
28
+ incomePerSec: string;
29
+ stepSec: number;
30
+ durationSec: number;
31
+ }): string;
32
+ /** End wallet when `maxSteps` stops the run before the requested duration. */
33
+ export declare function expectedBudgetEnd(args: {
34
+ initial: string;
35
+ incomePerSec: string;
36
+ stepSec: number;
37
+ maxSteps: number;
38
+ }): string;
39
+ /** Wallet after one quoted bulk payment. The quote total is not `unitCost * size`. */
40
+ export declare function expectedQuotedWallet(start: string, quoteCost: string): string;
41
+ /**
42
+ * Declared prestige gain and the wallet the reset leaves behind.
43
+ * The carry wallet must differ from the pre-reset wallet.
44
+ */
45
+ export declare function expectedResetCarry(args: {
46
+ gain: string;
47
+ carryWallet: string;
48
+ initialWallet: string;
49
+ }): {
50
+ rewardDelta: string;
51
+ wallet: string;
52
+ };