@demlik/tea 0.5.1 → 0.7.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 (122) hide show
  1. package/dist/agent/index.d.ts +6 -5
  2. package/dist/agent/index.js +10 -10
  3. package/dist/authed-call/index.d.ts +2 -2
  4. package/dist/authed-call/index.js +7 -7
  5. package/dist/await-terminal/index.d.ts +3 -2
  6. package/dist/await-terminal/index.js +2 -2
  7. package/dist/batch-window/index.d.ts +4 -3
  8. package/dist/batch-window/index.js +3 -3
  9. package/dist/cache/index.d.ts +2 -2
  10. package/dist/cache/index.js +4 -4
  11. package/dist/chart/index.d.ts +934 -0
  12. package/dist/chart/index.js +244 -0
  13. package/dist/chart/index.js.map +1 -0
  14. package/dist/{chunk-2UGTDYOK.js → chunk-3JU6657S.js} +3 -3
  15. package/dist/{chunk-2UGTDYOK.js.map → chunk-3JU6657S.js.map} +1 -1
  16. package/dist/{chunk-AZ3NHUPD.js → chunk-4KTWLPL5.js} +3 -3
  17. package/dist/{chunk-AZ3NHUPD.js.map → chunk-4KTWLPL5.js.map} +1 -1
  18. package/dist/{chunk-ZH454CR5.js → chunk-5EHLEUTL.js} +24 -4
  19. package/dist/chunk-5EHLEUTL.js.map +1 -0
  20. package/dist/{chunk-WF46FABO.js → chunk-7SVIRMC6.js} +3 -3
  21. package/dist/{chunk-WF46FABO.js.map → chunk-7SVIRMC6.js.map} +1 -1
  22. package/dist/{chunk-XMHZ44QC.js → chunk-7V4EVLZA.js} +4 -4
  23. package/dist/{chunk-XMHZ44QC.js.map → chunk-7V4EVLZA.js.map} +1 -1
  24. package/dist/{chunk-IVHQCVFX.js → chunk-A56OR5RF.js} +3 -3
  25. package/dist/{chunk-IVHQCVFX.js.map → chunk-A56OR5RF.js.map} +1 -1
  26. package/dist/{chunk-O7ED34JH.js → chunk-B5VXOFMZ.js} +47 -15
  27. package/dist/chunk-B5VXOFMZ.js.map +1 -0
  28. package/dist/{chunk-EC6FO42Q.js → chunk-EUF7XOEE.js} +6 -6
  29. package/dist/{chunk-EC6FO42Q.js.map → chunk-EUF7XOEE.js.map} +1 -1
  30. package/dist/{chunk-XOAP3LOT.js → chunk-I5OV65MS.js} +3 -3
  31. package/dist/{chunk-XOAP3LOT.js.map → chunk-I5OV65MS.js.map} +1 -1
  32. package/dist/{chunk-ASX7PL2K.js → chunk-JGVL3WPL.js} +3 -3
  33. package/dist/{chunk-ASX7PL2K.js.map → chunk-JGVL3WPL.js.map} +1 -1
  34. package/dist/{chunk-S6Y3RNX4.js → chunk-JP5D6GSL.js} +4 -4
  35. package/dist/{chunk-S6Y3RNX4.js.map → chunk-JP5D6GSL.js.map} +1 -1
  36. package/dist/{chunk-ERYY5P6W.js → chunk-ND3DH6KM.js} +3 -3
  37. package/dist/{chunk-ERYY5P6W.js.map → chunk-ND3DH6KM.js.map} +1 -1
  38. package/dist/{chunk-A7USKARI.js → chunk-SUST46KO.js} +3 -3
  39. package/dist/{chunk-A7USKARI.js.map → chunk-SUST46KO.js.map} +1 -1
  40. package/dist/{chunk-2KBEIGYP.js → chunk-TP5UPGLY.js} +3 -3
  41. package/dist/{chunk-2KBEIGYP.js.map → chunk-TP5UPGLY.js.map} +1 -1
  42. package/dist/{chunk-66S2KEQQ.js → chunk-WLGO64WC.js} +4 -4
  43. package/dist/{chunk-66S2KEQQ.js.map → chunk-WLGO64WC.js.map} +1 -1
  44. package/dist/{chunk-UV7VCTNC.js → chunk-ZF6WDK2D.js} +7 -7
  45. package/dist/{chunk-UV7VCTNC.js.map → chunk-ZF6WDK2D.js.map} +1 -1
  46. package/dist/{core-JPHsMZVB.d.ts → core-Bjc0bS8j.d.ts} +37 -1
  47. package/dist/deadline/index.d.ts +2 -2
  48. package/dist/deadline/index.js +3 -3
  49. package/dist/do/index.d.ts +7 -6
  50. package/dist/do/index.js +10 -10
  51. package/dist/{durable-effects-MRnCBCxV.d.ts → durable-effects-D8SqU_if.d.ts} +1 -1
  52. package/dist/extension/index.d.ts +3 -2
  53. package/dist/extension/index.js +3 -3
  54. package/dist/extension/react.js +3 -3
  55. package/dist/extension/subs/index.d.ts +2 -2
  56. package/dist/fan-out/index.d.ts +3 -2
  57. package/dist/idempotent-intake/index.d.ts +3 -2
  58. package/dist/index.d.ts +5 -4
  59. package/dist/index.js +2 -2
  60. package/dist/llm-call/index.d.ts +2 -2
  61. package/dist/llm-call/index.js +7 -7
  62. package/dist/{machine-nGXCMyHn.d.ts → machine-0OmPvsy_.d.ts} +1 -1
  63. package/dist/machine-viz/index.d.ts +1 -1
  64. package/dist/machine-viz/index.js +2 -2
  65. package/dist/mem/index.d.ts +3 -2
  66. package/dist/monitored-run/index.d.ts +4 -3
  67. package/dist/monitored-run/index.js +5 -5
  68. package/dist/node/index.d.ts +3 -2
  69. package/dist/paginated-walk/index.d.ts +2 -2
  70. package/dist/paginated-walk/index.js +7 -7
  71. package/dist/parity/index.d.ts +31 -2
  72. package/dist/parity/index.js +3 -3
  73. package/dist/parity/index.js.map +1 -1
  74. package/dist/pbt/arbitraries/index.d.ts +1 -1
  75. package/dist/pbt/index.d.ts +1 -1
  76. package/dist/pbt/index.js +3 -3
  77. package/dist/pbt/runners/index.d.ts +1 -1
  78. package/dist/pbt/runners/index.js +3 -3
  79. package/dist/poller/index.d.ts +28 -7
  80. package/dist/poller/index.js +3 -3
  81. package/dist/poller/index.js.map +1 -1
  82. package/dist/prediction/index.d.ts +1 -1
  83. package/dist/prediction/index.js +2 -2
  84. package/dist/pure/index.d.ts +1 -1
  85. package/dist/pure/index.js +2 -2
  86. package/dist/react/index.d.ts +3 -2
  87. package/dist/react/index.js +2 -2
  88. package/dist/reconciler/index.d.ts +2 -2
  89. package/dist/reconciler/index.js +7 -7
  90. package/dist/recorder/index.d.ts +3 -2
  91. package/dist/resilient-call/index.d.ts +2 -2
  92. package/dist/resilient-call/index.js +6 -6
  93. package/dist/{runtime-types-BbBq4LWo.d.ts → runtime-types-Bxc637bp.d.ts} +53 -2
  94. package/dist/saga/index.d.ts +3 -2
  95. package/dist/snapshot/index.d.ts +1 -1
  96. package/dist/snapshot/index.js +3 -3
  97. package/dist/subs/index.d.ts +4 -3
  98. package/dist/subs/index.js +3 -3
  99. package/dist/testing/index.d.ts +3 -2
  100. package/dist/testing/index.js +2 -2
  101. package/dist/throttled-input/index.d.ts +2 -2
  102. package/dist/throttled-input/index.js +6 -6
  103. package/dist/token-refresh/index.d.ts +1 -1
  104. package/dist/token-refresh/index.js +3 -3
  105. package/dist/trace-replay/index.d.ts +3 -2
  106. package/dist/trace-replay/index.js +3 -3
  107. package/dist/{types-BMZ7IMrd.d.ts → types-D7u9DkH7.d.ts} +1 -1
  108. package/dist/with-deadline/index.d.ts +1 -1
  109. package/dist/with-deadline/index.js +2 -2
  110. package/dist/with-resilience/index.d.ts +2 -2
  111. package/dist/with-resilience/index.js +6 -6
  112. package/dist/with-telemetry/index.d.ts +1 -1
  113. package/dist/with-telemetry/index.js +2 -2
  114. package/dist/work-queue/adapter.d.ts +3 -2
  115. package/dist/work-queue/index.d.ts +3 -2
  116. package/dist/work-queue/ops.d.ts +3 -2
  117. package/dist/workflow/index.d.ts +6 -4
  118. package/dist/workflow/index.js +1 -1
  119. package/dist/workflow/index.js.map +1 -1
  120. package/package.json +8 -1
  121. package/dist/chunk-O7ED34JH.js.map +0 -1
  122. package/dist/chunk-ZH454CR5.js.map +0 -1
@@ -20,10 +20,37 @@ declare function applyCell<S, M extends {
20
20
  update: object;
21
21
  __form?: UpdateForm;
22
22
  }, state: S, msg: M): readonly [S, readonly C[]];
23
+ declare function applyCellChecked<S, M extends {
24
+ type: string;
25
+ }, C extends Cmd>(machine: {
26
+ update: object;
27
+ __form?: UpdateForm;
28
+ }, state: S, msg: M): readonly [S, readonly C[]];
23
29
  declare function msgKeysOf(machine: {
24
30
  update: object;
25
31
  __form?: UpdateForm;
26
32
  }): readonly string[];
33
+ type MachineShape = {
34
+ readonly form: "reducer";
35
+ /** Every `Msg.type` the flat reducer has a cell for. */
36
+ readonly msgs: readonly string[];
37
+ } | {
38
+ readonly form: "transitions";
39
+ /** The union of every row's `Msg.type` keys (see `msgKeysOf`). */
40
+ readonly msgs: readonly string[];
41
+ /** Every `state.type` the table has a row for, in table order. */
42
+ readonly states: readonly string[];
43
+ /** `state.type` → the `Msg.type`s that state has a cell for. */
44
+ readonly accepts: Readonly<Record<string, readonly string[]>>;
45
+ };
46
+ declare function describeMachine(machine: {
47
+ update: object;
48
+ __form?: UpdateForm;
49
+ }): MachineShape;
50
+ declare function acceptsOf(machine: {
51
+ update: object;
52
+ __form?: UpdateForm;
53
+ }, stateType: string): readonly string[];
27
54
  type Reducer<S, M extends {
28
55
  type: string;
29
56
  }, C extends Cmd> = {
@@ -283,8 +310,17 @@ type Machine<S, M extends {
283
310
  subscriptions: (state: S) => readonly U[];
284
311
  subscribe: Subscribe<M, U, Ctx>;
285
312
  });
313
+ declare function foldUpdates<S, M extends {
314
+ type: string;
315
+ }, C extends Cmd>(machine: {
316
+ update: object;
317
+ __form?: UpdateForm;
318
+ }, initialState: S, msgs: readonly M[]): {
319
+ state: S;
320
+ cmds: C[];
321
+ };
286
322
  declare function foldMsgs<S, M extends {
287
323
  type: string;
288
324
  }, C extends Cmd, U extends Sub, Ctx>(machine: Machine<S, M, C, U, Ctx>, base: S, msgs: readonly M[]): S;
289
325
 
290
- export { Cmd as C, type DepKeyedSub as D, type Interpret as I, type Machine as M, NoCellError as N, type PortEmitter as P, type Reducer as R, type Sub as S, type Transitions as T, type UpdateForm as U, type Port as a, type SubId as b, type InterpretDetached as c, type ContextFree as d, type Dispose as e, type Identity as f, type NoCtx as g, type Subscribe as h, type SyncReturn as i, applyCell as j, detectUpdateForm as k, foldMsgs as l, formOf as m, msgKeysOf as n, subId as o, structuralHash as s };
326
+ export { Cmd as C, type DepKeyedSub as D, type Interpret as I, type Machine as M, NoCellError as N, type PortEmitter as P, type Reducer as R, type Sub as S, type Transitions as T, type UpdateForm as U, type Port as a, type SubId as b, type InterpretDetached as c, type ContextFree as d, type Dispose as e, type Identity as f, type MachineShape as g, type NoCtx as h, type Subscribe as i, type SyncReturn as j, acceptsOf as k, applyCell as l, applyCellChecked as m, describeMachine as n, detectUpdateForm as o, foldMsgs as p, foldUpdates as q, formOf as r, msgKeysOf as s, structuralHash as t, subId as u };
@@ -1,5 +1,5 @@
1
- import { S as Sub, b as SubId } from '../core-JPHsMZVB.js';
2
- import { S as SubscribeHandler } from '../types-BMZ7IMrd.js';
1
+ import { S as Sub, b as SubId } from '../core-Bjc0bS8j.js';
2
+ import { S as SubscribeHandler } from '../types-D7u9DkH7.js';
3
3
 
4
4
  /**
5
5
  * @demlik/tea/deadline — a one-shot Sub that fires when an ABSOLUTE wall-clock
@@ -1,6 +1,6 @@
1
- export { deadlineExceeded, deadlineSub, setTimeoutArmTimer, subscribeDeadline, subscribeWith } from '../chunk-ASX7PL2K.js';
1
+ export { deadlineExceeded, deadlineSub, setTimeoutArmTimer, subscribeDeadline, subscribeWith } from '../chunk-JGVL3WPL.js';
2
2
  import '../chunk-2YFLOCWX.js';
3
- import '../chunk-ZH454CR5.js';
4
- import '../chunk-O7ED34JH.js';
3
+ import '../chunk-5EHLEUTL.js';
4
+ import '../chunk-B5VXOFMZ.js';
5
5
  //# sourceMappingURL=index.js.map
6
6
  //# sourceMappingURL=index.js.map
@@ -1,13 +1,14 @@
1
- import { S as Store, R as Runtime, B as BootingRuntime } from '../runtime-types-BbBq4LWo.js';
2
- import { P as PendingEffectsRecorder, b as EffectOwed, a as EffectConfirmed } from '../durable-effects-MRnCBCxV.js';
3
- export { D as DeliveryId, E as EffectLedgerEvent, O as OwedEffect, c as PendingEffectsLedger, d as applyEffectEvent, e as emptyLedger, f as foldLedger, i as isOwed, p as pendingEffectsLedger, s as survivingEffects } from '../durable-effects-MRnCBCxV.js';
1
+ import { S as Store, R as Runtime, B as BootingRuntime } from '../runtime-types-Bxc637bp.js';
2
+ import { P as PendingEffectsRecorder, b as EffectOwed, a as EffectConfirmed } from '../durable-effects-D8SqU_if.js';
3
+ export { D as DeliveryId, E as EffectLedgerEvent, O as OwedEffect, c as PendingEffectsLedger, d as applyEffectEvent, e as emptyLedger, f as foldLedger, i as isOwed, p as pendingEffectsLedger, s as survivingEffects } from '../durable-effects-D8SqU_if.js';
4
4
  import { RetryPolicy, Rng } from '../retry-backoff/index.js';
5
- import { C as Cmd, S as Sub, M as Machine } from '../core-JPHsMZVB.js';
6
- import { k as AgentEvent, A as AgentTurn, s as AgentState, p as AgentMachineMsg, t as AgentStatus } from '../machine-nGXCMyHn.js';
5
+ import { C as Cmd, S as Sub, M as Machine } from '../core-Bjc0bS8j.js';
6
+ import { k as AgentEvent, A as AgentTurn, s as AgentState, p as AgentMachineMsg, t as AgentStatus } from '../machine-0OmPvsy_.js';
7
+ import 'better-result';
7
8
  import '../llm-call/index.js';
8
9
  import '../resilient-call/index.js';
9
10
  import '../cache/index.js';
10
- import '../types-BMZ7IMrd.js';
11
+ import '../types-D7u9DkH7.js';
11
12
  import '../circuit-breaker/index.js';
12
13
  import '../deadline/index.js';
13
14
  import '../protocol-B5YmJr0d.js';
package/dist/do/index.js CHANGED
@@ -1,27 +1,27 @@
1
- import { status, agentBootMsg, agentEvents } from '../chunk-UV7VCTNC.js';
1
+ import { status, agentBootMsg, agentEvents } from '../chunk-ZF6WDK2D.js';
2
2
  export { applyEffectEvent, emptyLedger, foldLedger, isOwed, pendingEffectsLedger, survivingEffects } from '../chunk-25LBDCBC.js';
3
- import '../chunk-66S2KEQQ.js';
4
- import '../chunk-ERYY5P6W.js';
5
- import '../chunk-XMHZ44QC.js';
6
- import '../chunk-EC6FO42Q.js';
3
+ import '../chunk-WLGO64WC.js';
4
+ import '../chunk-ND3DH6KM.js';
5
+ import '../chunk-7V4EVLZA.js';
6
+ import '../chunk-EUF7XOEE.js';
7
7
  import '../chunk-JELSZN25.js';
8
8
  import '../chunk-D736QUGF.js';
9
9
  import { createIntake } from '../chunk-ZVJZ72HY.js';
10
- import '../chunk-ASX7PL2K.js';
10
+ import '../chunk-JGVL3WPL.js';
11
11
  import { defaultRetryPolicy, initRetry, recordFailure, shouldRetry, nextDelayMs } from '../chunk-Q2UM7BXU.js';
12
12
  import '../chunk-S2EGRPCM.js';
13
13
  import '../chunk-BYQUGDD3.js';
14
14
  import '../chunk-K575PT4S.js';
15
15
  import '../chunk-UF4MZSLT.js';
16
- import '../chunk-WF46FABO.js';
16
+ import '../chunk-7SVIRMC6.js';
17
17
  import '../chunk-MU6MCIAC.js';
18
18
  import '../chunk-FV3Z5MBE.js';
19
- import '../chunk-2UGTDYOK.js';
19
+ import '../chunk-3JU6657S.js';
20
20
  import '../chunk-2YFLOCWX.js';
21
21
  import '../chunk-ZJ5AOYBH.js';
22
22
  import '../chunk-G5E74IJB.js';
23
- import { replay, run } from '../chunk-ZH454CR5.js';
24
- import '../chunk-O7ED34JH.js';
23
+ import { replay, run } from '../chunk-5EHLEUTL.js';
24
+ import '../chunk-B5VXOFMZ.js';
25
25
 
26
26
  // src/do/durable-timer.ts
27
27
  function durableTimer(config) {
@@ -1,4 +1,4 @@
1
- import { C as Cmd } from './core-JPHsMZVB.js';
1
+ import { C as Cmd } from './core-Bjc0bS8j.js';
2
2
 
3
3
  /**
4
4
  * @demlik/tea/do — the durable pending-effects ledger (substrate primitive #1).
@@ -1,5 +1,6 @@
1
- import { R as Runtime, S as Store } from '../runtime-types-BbBq4LWo.js';
2
- import '../core-JPHsMZVB.js';
1
+ import { R as Runtime, S as Store } from '../runtime-types-Bxc637bp.js';
2
+ import 'better-result';
3
+ import '../core-Bjc0bS8j.js';
3
4
 
4
5
  /**
5
6
  * Runtime bridge — expose a `@demlik/tea` runtime running in one chrome context
@@ -1,7 +1,7 @@
1
- export { bridgeClient, bridgeRuntime, bridgeTabClient, passThroughMsg } from '../chunk-IVHQCVFX.js';
1
+ export { bridgeClient, bridgeRuntime, bridgeTabClient, passThroughMsg } from '../chunk-A56OR5RF.js';
2
2
  import '../chunk-G5E74IJB.js';
3
- import '../chunk-ZH454CR5.js';
4
- import '../chunk-O7ED34JH.js';
3
+ import '../chunk-5EHLEUTL.js';
4
+ import '../chunk-B5VXOFMZ.js';
5
5
 
6
6
  // src/extension/index.ts
7
7
  var MALFORMED = "chromeStorageStore: stored value is not a string";
@@ -1,7 +1,7 @@
1
- import { bridgeClient, passThroughMsg } from '../chunk-IVHQCVFX.js';
1
+ import { bridgeClient, passThroughMsg } from '../chunk-A56OR5RF.js';
2
2
  import '../chunk-G5E74IJB.js';
3
- import '../chunk-ZH454CR5.js';
4
- import '../chunk-O7ED34JH.js';
3
+ import '../chunk-5EHLEUTL.js';
4
+ import '../chunk-B5VXOFMZ.js';
5
5
  import { useRef, useSyncExternalStore, useEffect, useCallback, createContext, useMemo, useContext } from 'react';
6
6
  import { jsx } from 'react/jsx-runtime';
7
7
 
@@ -1,5 +1,5 @@
1
- import { S as Sub } from '../../core-JPHsMZVB.js';
2
- import { S as SubscribeHandler } from '../../types-BMZ7IMrd.js';
1
+ import { S as Sub } from '../../core-Bjc0bS8j.js';
2
+ import { S as SubscribeHandler } from '../../types-D7u9DkH7.js';
3
3
 
4
4
  type AlarmSubData = {
5
5
  alarmName: string;
@@ -1,6 +1,7 @@
1
- import { C as Cmd, a as Port } from '../core-JPHsMZVB.js';
1
+ import { C as Cmd, a as Port } from '../core-Bjc0bS8j.js';
2
2
  import { QueueItem } from '../work-queue/index.js';
3
- import '../runtime-types-BbBq4LWo.js';
3
+ import '../runtime-types-Bxc637bp.js';
4
+ import 'better-result';
4
5
 
5
6
  /**
6
7
  * @demlik/tea/fan-out — scatter-gather over a bounded-concurrency work list.
@@ -1,7 +1,8 @@
1
1
  import { IdempotencyStore } from '../idempotency/index.js';
2
- import { C as Cmd } from '../core-JPHsMZVB.js';
2
+ import { C as Cmd } from '../core-Bjc0bS8j.js';
3
3
  import { QueueItem } from '../work-queue/index.js';
4
- import '../runtime-types-BbBq4LWo.js';
4
+ import '../runtime-types-Bxc637bp.js';
5
+ import 'better-result';
5
6
 
6
7
  /**
7
8
  * @demlik/tea/idempotent-intake — receive-once intake for webhooks / queue
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { B as BootingRuntime, C as CtxArg, S as Store, O as OnError, a as Supervision } from './runtime-types-BbBq4LWo.js';
2
- export { b as Branded, D as DispatchDiscardedError, c as DispatchSettle, d as DisposeTimeoutNotice, I as IdentityDropNotice, P as PortNameCollisionError, Q as QuiescenceTimeoutError, R as Runtime, e as RuntimeDiscardNotice, f as RuntimeDiscardedError, g as RuntimeErrorContext, h as RuntimeErrorPhase, i as RuntimeRef, j as Schema, k as SubIdCollisionError, l as SupervisionStrategy, _ as __resetPortRegistry, m as absurd, n as asReducer, o as defineMachine, p as definePort, q as noop, r as replay, s as schemaMigrate, t as tryInterpret, w as wrapDetached } from './runtime-types-BbBq4LWo.js';
3
- import { C as Cmd, S as Sub, M as Machine } from './core-JPHsMZVB.js';
4
- export { d as ContextFree, D as DepKeyedSub, e as Dispose, f as Identity, I as Interpret, c as InterpretDetached, N as NoCellError, g as NoCtx, a as Port, P as PortEmitter, R as Reducer, b as SubId, h as Subscribe, i as SyncReturn, T as Transitions, U as UpdateForm, j as applyCell, k as detectUpdateForm, l as foldMsgs, m as formOf, n as msgKeysOf, s as structuralHash, o as subId } from './core-JPHsMZVB.js';
1
+ import { B as BootingRuntime, C as CtxArg, S as Store, O as OnError, a as Supervision } from './runtime-types-Bxc637bp.js';
2
+ export { b as Branded, D as DispatchDiscardedError, c as DispatchSettle, d as DisposeTimeoutNotice, F as FoldRefusal, I as IdentityDropNotice, P as PortNameCollisionError, Q as QuiescenceTimeoutError, R as Runtime, e as RuntimeDiscardNotice, f as RuntimeDiscardedError, g as RuntimeErrorContext, h as RuntimeErrorPhase, i as RuntimeRef, j as Schema, k as SubIdCollisionError, l as SupervisionStrategy, _ as __resetPortRegistry, m as absurd, n as asReducer, o as defineMachine, p as definePort, q as noop, r as replay, s as schemaMigrate, t as tryApplyCell, u as tryFoldMsgs, v as tryInterpret, w as wrapDetached } from './runtime-types-Bxc637bp.js';
3
+ import { C as Cmd, S as Sub, M as Machine } from './core-Bjc0bS8j.js';
4
+ export { d as ContextFree, D as DepKeyedSub, e as Dispose, f as Identity, I as Interpret, c as InterpretDetached, g as MachineShape, N as NoCellError, h as NoCtx, a as Port, P as PortEmitter, R as Reducer, b as SubId, i as Subscribe, j as SyncReturn, T as Transitions, U as UpdateForm, k as acceptsOf, l as applyCell, m as applyCellChecked, n as describeMachine, o as detectUpdateForm, p as foldMsgs, q as foldUpdates, r as formOf, s as msgKeysOf, t as structuralHash, u as subId } from './core-Bjc0bS8j.js';
5
+ import 'better-result';
5
6
 
6
7
  interface HistoryTracker<S, M extends {
7
8
  type: string;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { DispatchDiscardedError, DisposeTimeoutNotice, IdentityDropNotice, PortNameCollisionError, QuiescenceTimeoutError, RuntimeDiscardNotice, RuntimeDiscardedError, SubIdCollisionError, __resetPortRegistry, absurd, asReducer, defineMachine, definePort, historyTracker, noop, replay, run, schemaMigrate, tryInterpret, wrapDetached } from './chunk-ZH454CR5.js';
2
- export { Cmd, NoCellError, applyCell, detectUpdateForm, foldMsgs, formOf, msgKeysOf, structuralHash, subId } from './chunk-O7ED34JH.js';
1
+ export { DispatchDiscardedError, DisposeTimeoutNotice, IdentityDropNotice, PortNameCollisionError, QuiescenceTimeoutError, RuntimeDiscardNotice, RuntimeDiscardedError, SubIdCollisionError, __resetPortRegistry, absurd, asReducer, defineMachine, definePort, historyTracker, noop, replay, run, schemaMigrate, tryApplyCell, tryFoldMsgs, tryInterpret, wrapDetached } from './chunk-5EHLEUTL.js';
2
+ export { Cmd, NoCellError, acceptsOf, applyCell, applyCellChecked, describeMachine, detectUpdateForm, foldMsgs, foldUpdates, formOf, msgKeysOf, structuralHash, subId } from './chunk-B5VXOFMZ.js';
3
3
  //# sourceMappingURL=index.js.map
4
4
  //# sourceMappingURL=index.js.map
@@ -1,10 +1,10 @@
1
- import { C as Cmd } from '../core-JPHsMZVB.js';
1
+ import { C as Cmd } from '../core-Bjc0bS8j.js';
2
2
  import { RunCmd, SucceedMsg, FailMsg, ResilientState } from '../resilient-call/index.js';
3
3
  import { RetryPolicy } from '../retry-backoff/index.js';
4
4
  import { DeadlineExceeded, DeadlineSub } from '../deadline/index.js';
5
5
  export { deadlineSub, subscribeDeadline } from '../deadline/index.js';
6
6
  import '../cache/index.js';
7
- import '../types-BMZ7IMrd.js';
7
+ import '../types-D7u9DkH7.js';
8
8
  import '../circuit-breaker/index.js';
9
9
  import '../protocol-B5YmJr0d.js';
10
10
  import '../rate-limit/index.js';
@@ -1,16 +1,16 @@
1
- export { createLlmCall, liftLlmCall } from '../chunk-ERYY5P6W.js';
2
- import '../chunk-EC6FO42Q.js';
1
+ export { createLlmCall, liftLlmCall } from '../chunk-ND3DH6KM.js';
2
+ import '../chunk-EUF7XOEE.js';
3
3
  import '../chunk-JELSZN25.js';
4
- export { deadlineSub, subscribeDeadline } from '../chunk-ASX7PL2K.js';
4
+ export { deadlineSub, subscribeDeadline } from '../chunk-JGVL3WPL.js';
5
5
  import '../chunk-Q2UM7BXU.js';
6
6
  import '../chunk-S2EGRPCM.js';
7
7
  import '../chunk-UF4MZSLT.js';
8
- import '../chunk-WF46FABO.js';
9
- import '../chunk-2UGTDYOK.js';
8
+ import '../chunk-7SVIRMC6.js';
9
+ import '../chunk-3JU6657S.js';
10
10
  import '../chunk-2YFLOCWX.js';
11
11
  import '../chunk-ZJ5AOYBH.js';
12
12
  import '../chunk-G5E74IJB.js';
13
- import '../chunk-ZH454CR5.js';
14
- import '../chunk-O7ED34JH.js';
13
+ import '../chunk-5EHLEUTL.js';
14
+ import '../chunk-B5VXOFMZ.js';
15
15
  //# sourceMappingURL=index.js.map
16
16
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { C as Cmd, I as Interpret, M as Machine } from './core-JPHsMZVB.js';
1
+ import { C as Cmd, I as Interpret, M as Machine } from './core-Bjc0bS8j.js';
2
2
  import { ModelFactory, Schema, MessageLoader, LlmCall, LlmOk, LlmErr, LlmRunCmd, LlmSucceedMsg, LlmFailMsg, LlmTimerMsg, LlmCallPorts } from './llm-call/index.js';
3
3
  import { MonitoredRunState, RunFailure, MonitoredRunCmd } from './monitored-run/index.js';
4
4
  import { M as MsgType } from './protocol-B5YmJr0d.js';
@@ -1,4 +1,4 @@
1
- import { C as Cmd, S as Sub, M as Machine } from '../core-JPHsMZVB.js';
1
+ import { C as Cmd, S as Sub, M as Machine } from '../core-Bjc0bS8j.js';
2
2
 
3
3
  /**
4
4
  * @demlik/tea/machine-viz — turn a `Machine` into a Mermaid diagram string.
@@ -1,5 +1,5 @@
1
- import '../chunk-ZH454CR5.js';
2
- import { formOf } from '../chunk-O7ED34JH.js';
1
+ import '../chunk-5EHLEUTL.js';
2
+ import { formOf } from '../chunk-B5VXOFMZ.js';
3
3
 
4
4
  // src/machine-viz/index.ts
5
5
  function safeId(raw) {
@@ -1,5 +1,6 @@
1
- import { S as Store } from '../runtime-types-BbBq4LWo.js';
2
- import '../core-JPHsMZVB.js';
1
+ import { S as Store } from '../runtime-types-Bxc637bp.js';
2
+ import 'better-result';
3
+ import '../core-Bjc0bS8j.js';
3
4
 
4
5
  /**
5
6
  * @packageDocumentation
@@ -1,10 +1,11 @@
1
1
  import { DeadlineExceeded, DeadlineSub } from '../deadline/index.js';
2
2
  export { deadlineSub, subscribeDeadline } from '../deadline/index.js';
3
- import { I as Interpret, C as Cmd } from '../core-JPHsMZVB.js';
3
+ import { I as Interpret, C as Cmd } from '../core-Bjc0bS8j.js';
4
4
  import { SnapshotWriteCmd, SnapshotState, SnapshotStore, SnapshotSavedMsg, SnapshotFailedMsg, SnapshotLoadedMsg, SnapshotLoadFailedMsg, SnapshotLoadCmd } from '../snapshot/index.js';
5
5
  import { QueueItem } from '../work-queue/index.js';
6
- import '../types-BMZ7IMrd.js';
7
- import '../runtime-types-BbBq4LWo.js';
6
+ import '../types-D7u9DkH7.js';
7
+ import '../runtime-types-Bxc637bp.js';
8
+ import 'better-result';
8
9
 
9
10
  /**
10
11
  * @demlik/tea/monitored-run — a long-running operation that is BOTH staged and
@@ -1,10 +1,10 @@
1
- export { createMonitoredRun, liftRun } from '../chunk-66S2KEQQ.js';
2
- import '../chunk-XMHZ44QC.js';
3
- export { deadlineSub, subscribeDeadline } from '../chunk-ASX7PL2K.js';
1
+ export { createMonitoredRun, liftRun } from '../chunk-WLGO64WC.js';
2
+ import '../chunk-7V4EVLZA.js';
3
+ export { deadlineSub, subscribeDeadline } from '../chunk-JGVL3WPL.js';
4
4
  import '../chunk-MU6MCIAC.js';
5
5
  import '../chunk-FV3Z5MBE.js';
6
6
  import '../chunk-2YFLOCWX.js';
7
- import '../chunk-ZH454CR5.js';
8
- import '../chunk-O7ED34JH.js';
7
+ import '../chunk-5EHLEUTL.js';
8
+ import '../chunk-B5VXOFMZ.js';
9
9
  //# sourceMappingURL=index.js.map
10
10
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,7 @@
1
1
  import WebSocket from 'ws';
2
- import { S as Store } from '../runtime-types-BbBq4LWo.js';
3
- import { S as Sub, b as SubId } from '../core-JPHsMZVB.js';
2
+ import { S as Store } from '../runtime-types-Bxc637bp.js';
3
+ import { S as Sub, b as SubId } from '../core-Bjc0bS8j.js';
4
+ import 'better-result';
4
5
 
5
6
  /**
6
7
  * @packageDocumentation
@@ -1,11 +1,11 @@
1
- import { C as Cmd } from '../core-JPHsMZVB.js';
1
+ import { C as Cmd } from '../core-Bjc0bS8j.js';
2
2
  import { PaginatorState } from '../paginator/index.js';
3
3
  import { RunCmd, FailMsg, SucceedMsg, CircuitConfig, RateLimitConfig, DeadlineConfig, ResilientPorts, ResilientState, ResilientTimerMsg } from '../resilient-call/index.js';
4
4
  import { RetryPolicy } from '../retry-backoff/index.js';
5
5
  import { DeadlineSub } from '../deadline/index.js';
6
6
  export { deadlineSub, subscribeDeadline } from '../deadline/index.js';
7
7
  import '../cache/index.js';
8
- import '../types-BMZ7IMrd.js';
8
+ import '../types-D7u9DkH7.js';
9
9
  import '../circuit-breaker/index.js';
10
10
  import '../protocol-B5YmJr0d.js';
11
11
  import '../rate-limit/index.js';
@@ -1,16 +1,16 @@
1
- export { PAGE_KEY, createPaginatedWalk, liftWalk } from '../chunk-XOAP3LOT.js';
1
+ export { PAGE_KEY, createPaginatedWalk, liftWalk } from '../chunk-I5OV65MS.js';
2
2
  import '../chunk-SINXE47Y.js';
3
- import '../chunk-EC6FO42Q.js';
3
+ import '../chunk-EUF7XOEE.js';
4
4
  import '../chunk-JELSZN25.js';
5
- export { deadlineSub, subscribeDeadline } from '../chunk-ASX7PL2K.js';
5
+ export { deadlineSub, subscribeDeadline } from '../chunk-JGVL3WPL.js';
6
6
  import '../chunk-Q2UM7BXU.js';
7
7
  import '../chunk-S2EGRPCM.js';
8
8
  import '../chunk-UF4MZSLT.js';
9
- import '../chunk-WF46FABO.js';
10
- import '../chunk-2UGTDYOK.js';
9
+ import '../chunk-7SVIRMC6.js';
10
+ import '../chunk-3JU6657S.js';
11
11
  import '../chunk-2YFLOCWX.js';
12
12
  import '../chunk-ZJ5AOYBH.js';
13
- import '../chunk-ZH454CR5.js';
14
- import '../chunk-O7ED34JH.js';
13
+ import '../chunk-5EHLEUTL.js';
14
+ import '../chunk-B5VXOFMZ.js';
15
15
  //# sourceMappingURL=index.js.map
16
16
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,35 @@
1
- import { B as BootingRuntime } from '../runtime-types-BbBq4LWo.js';
2
- import { C as Cmd, S as Sub, M as Machine } from '../core-JPHsMZVB.js';
1
+ import { B as BootingRuntime } from '../runtime-types-Bxc637bp.js';
2
+ import { C as Cmd, S as Sub, M as Machine } from '../core-Bjc0bS8j.js';
3
3
  import { Trace, RecorderOptions } from '../recorder/index.js';
4
+ import 'better-result';
5
+
6
+ /**
7
+ * the record → replay → normalized-diff go/no-go gate.
8
+ *
9
+ * The parity spike proved the mechanism already composes from in-tree
10
+ * primitives: `recorder` captures a run's Msg sequence (the recording), `replay`
11
+ * re-folds it purely, and `trace-replay`'s order-insensitive deep-equal diffs
12
+ * the result. Non-determinism is a RECORD-TIME property — ids/timestamps freeze
13
+ * into the recording, `replay` never re-mints them — so the same recording
14
+ * replays byte-identical every time.
15
+ *
16
+ * This module is the thin packaging over that substrate plus the one genuinely
17
+ * new helper, `normalizeForParity`: the finding-normalizer that strips
18
+ * record-time non-determinism (generated ids/timestamps) and stable-key-sorts
19
+ * collections, so an OLD-engine golden run and a NEW-engine run diff as equal
20
+ * exactly when they are behaviourally equivalent. Every domain (audit, auth,
21
+ * ingest, …) gets its old-vs-new parity check without reinventing the capture,
22
+ * the normalization, and the diff.
23
+ *
24
+ * ```text
25
+ * recordRun(runtime) → Recording // wraps the recorder
26
+ * goldenReplay(machine, rec) → State // wraps replay
27
+ * normalizeForParity(schema) → (finding) => norm // strip + stable-sort
28
+ * parityEqual(a, b) → boolean // normalized deep-equal
29
+ * ```
30
+ *
31
+ * @packageDocumentation
32
+ */
4
33
 
5
34
  /**
6
35
  * A live parity recording attached to a Runtime — the go/no-go gate's golden
@@ -1,8 +1,8 @@
1
1
  import { recorder } from '../chunk-MUUROGIH.js';
2
- import { deepEqual } from '../chunk-A7USKARI.js';
2
+ import { deepEqual } from '../chunk-SUST46KO.js';
3
3
  import '../chunk-EWJP3YYP.js';
4
- import { replay } from '../chunk-ZH454CR5.js';
5
- import '../chunk-O7ED34JH.js';
4
+ import { replay } from '../chunk-5EHLEUTL.js';
5
+ import '../chunk-B5VXOFMZ.js';
6
6
 
7
7
  // src/parity/index.ts
8
8
  function recordRun(runtime, opts) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/parity/index.ts"],"names":["key"],"mappings":";;;;;;;AA6DO,SAAS,SAAA,CACd,SACA,IAAA,EACiB;AACjB,EAAA,MAAM,GAAA,GAAM,QAAA,CAAS,OAAA,EAAS,IAAI,CAAA;AAClC,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,MAAM,GAAA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D,EAAA,OAAO,CAAA,GAAI,CAAA,GAAI,EAAA,GAAK,CAAA,GAAI,IAAI,CAAA,GAAI,CAAA;AAClC;AAEA,SAAS,cAAc,KAAA,EAAkD;AACvE,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;AASO,SAAS,WAAA,CAAY,GAAY,CAAA,EAAqB;AAC3D,EAAA,OAAO,SAAA,CAAU,GAAG,CAAC,CAAA;AACvB;AAOO,IAAM,IAAA,GAAO","file":"index.js","sourcesContent":["// ---------------------------------------------------------------------------\n// parity — the record → replay → normalized-diff go/no-go gate.\n//\n// The parity spike proved the mechanism already composes from in-tree\n// primitives: `recorder` captures a run's Msg sequence (the recording), `replay`\n// re-folds it purely, and `trace-replay`'s order-insensitive deep-equal diffs\n// the result. Non-determinism is a RECORD-TIME property — ids/timestamps freeze\n// into the recording, `replay` never re-mints them — so the same recording\n// replays byte-identical every time.\n//\n// This module is the thin packaging over that substrate plus the one genuinely\n// new helper, `normalizeForParity`: the finding-normalizer that strips\n// record-time non-determinism (generated ids/timestamps) and stable-key-sorts\n// collections, so an OLD-engine golden run and a NEW-engine run diff as equal\n// exactly when they are behaviourally equivalent. Every domain (audit, auth,\n// ingest, …) gets its old-vs-new parity check without reinventing the capture,\n// the normalization, and the diff.\n//\n// recordRun(runtime) → Recording // wraps the recorder\n// goldenReplay(machine, rec) → State // wraps replay\n// normalizeForParity(schema) → (finding) => norm // strip + stable-sort\n// parityEqual(a, b) → boolean // normalized deep-equal\n// ---------------------------------------------------------------------------\n\nimport type { BootingRuntime, Cmd, Machine, Sub } from \"../index\";\nimport { replay } from \"../index\";\nimport { type RecorderOptions, recorder, type Trace } from \"../recorder\";\nimport { deepEqual } from \"../trace-replay\";\n\n/**\n * A live parity recording attached to a Runtime — the go/no-go gate's golden\n * artifact. Wraps a {@link recorder}: drive the runtime, then snapshot with\n * {@link Recording.trace} (or hand the live `Recording` straight to\n * {@link goldenReplay}, which snapshots for you).\n *\n * @typeParam S - the machine's State type.\n * @typeParam M - the machine's Msg union.\n */\nexport interface Recording<S, M> {\n /**\n * Snapshot the recording so far as a replayable {@link Trace} — `loaded`\n * (boot state), the ordered non-null `msgs`, and `finalState`. Sufficient to\n * reproduce the run via {@link goldenReplay}. Fresh object each call.\n */\n trace(): Trace<S, M>;\n /** Serialize the recording as JSONL (see {@link recorder}'s `toJSONL`). */\n toJSONL(): string;\n /** Detach the underlying observer. Idempotent. */\n stop(): void;\n}\n\n/**\n * Attach a parity recording to a Runtime, reusing the `recorder`/`historyTracker`\n * capture (the boot observe for `loaded` + every non-null msg in order) rather\n * than a fresh observer path.\n *\n * Attach on the synchronous `run()` handle so the boot transition is captured\n * as `loaded`; drive the runtime; then `trace()` (or pass the handle to\n * {@link goldenReplay}). See {@link RecorderOptions} for `captureSteps` (needed\n * only for the per-step / resume-cache-prefix inspection, not for replay).\n */\nexport function recordRun<S, M extends { type: string }>(\n runtime: BootingRuntime<S, M>,\n opts?: RecorderOptions,\n): Recording<S, M> {\n const rec = recorder(runtime, opts);\n return {\n trace: () => rec.dump(),\n toJSONL: () => rec.toJSONL(),\n stop: () => rec.stop(),\n };\n}\n\n/**\n * Reproduce a recording's final state by folding its msgs through the pure\n * `replay` — `init(loaded, ctx)` then `update` per msg, never `interpret`,\n * never a `Store`, never a live subscription. Accepts a live {@link Recording}\n * (snapshotted here) or a bare {@link Trace}.\n *\n * `ctx` is the ENVIRONMENT supplied fresh at replay time (the trace is the\n * INPUT: `loaded` + `msgs`), mirroring `replayTrace`. It is optional so a\n * void-ctx machine can call `goldenReplay(machine, rec)`; a machine that reads\n * ctx passes it explicitly.\n */\nexport function goldenReplay<\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n Ctx,\n>(\n machine: Machine<S, M, C, U, Ctx>,\n recording: Recording<S, M> | Trace<S, M>,\n ctx?: Ctx,\n): S {\n const trace = asTrace(recording);\n const { state } = replay(machine, {\n msgs: trace.msgs,\n ctx: ctx as Ctx,\n loaded: trace.loaded,\n });\n return state;\n}\n\n/** Narrow a `Recording | Trace` to a `Trace`, snapshotting a live recording. */\nfunction asTrace<S, M>(recording: Recording<S, M> | Trace<S, M>): Trace<S, M> {\n return typeof (recording as Recording<S, M>).trace === \"function\"\n ? (recording as Recording<S, M>).trace()\n : (recording as Trace<S, M>);\n}\n\n/** Configuration for {@link normalizeForParity}. */\nexport interface ParitySchema {\n /**\n * Object keys stripped wherever they appear — the record-time\n * non-determinism `replay` never re-mints. Default: `id`, `runId`,\n * `timestamp`.\n */\n readonly stripKeys?: readonly string[];\n /**\n * Candidate keys used to stable-sort arrays of objects. For each array the\n * first candidate present (as a primitive) on the items decides the order;\n * arrays with no candidate fall back to canonical-JSON order. Default:\n * `ruleId`, `selector`, `url`.\n */\n readonly sortKeys?: readonly string[];\n}\n\n// Defaults proven by the spike: strip the generated id/runId/timestamp,\n// stable-key-sort by ruleId | selector | url. Fan-out ordering is already\n// deterministic on this substrate (array order); the sort only defends against\n// intra-effect concurrency (Promise.all / Set).\nconst DEFAULT_STRIP_KEYS: readonly string[] = [\"id\", \"runId\", \"timestamp\"];\nconst DEFAULT_SORT_KEYS: readonly string[] = [\"ruleId\", \"selector\", \"url\"];\n\n/**\n * Build a finding-normalizer: a pure `(value) => normalized` that strips the\n * schema's `stripKeys`, recursively sorts object keys, and stable-key-sorts\n * arrays by the schema's `sortKeys`. Two runs that differ only in generated\n * ids/timestamps or intra-effect ordering normalize to a byte-identical value,\n * so {@link parityEqual} on the normalized pair reflects behavioural (not incidental)\n * difference.\n */\nexport function normalizeForParity(\n schema?: ParitySchema,\n): (value: unknown) => unknown {\n const stripKeys = new Set(schema?.stripKeys ?? DEFAULT_STRIP_KEYS);\n const sortKeys = schema?.sortKeys ?? DEFAULT_SORT_KEYS;\n\n const normalize = (value: unknown): unknown => {\n if (Array.isArray(value)) {\n const items = value.map(normalize);\n // Decorate-sort-undecorate: primary key = first present sortKey value,\n // secondary = canonical JSON (items are already normalized so keys are\n // sorted), original index last for a stable total order.\n return items\n .map((item, index) => ({\n item,\n index,\n primary: primarySortKey(item, sortKeys),\n json: JSON.stringify(item) ?? \"\",\n }))\n .sort(\n (a, b) =>\n compareStrings(a.primary, b.primary) ||\n compareStrings(a.json, b.json) ||\n a.index - b.index,\n )\n .map((decorated) => decorated.item);\n }\n if (isPlainObject(value)) {\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(value)\n .filter((key) => !stripKeys.has(key))\n .sort()) {\n out[key] = normalize(value[key]);\n }\n return out;\n }\n return value;\n };\n\n return normalize;\n}\n\n/** The first present `sortKeys` candidate on `item` as a string, or `\"\"`. */\nfunction primarySortKey(item: unknown, sortKeys: readonly string[]): string {\n if (!isPlainObject(item)) return \"\";\n for (const key of sortKeys) {\n const candidate = item[key];\n if (\n typeof candidate === \"string\" ||\n typeof candidate === \"number\" ||\n typeof candidate === \"boolean\"\n ) {\n return String(candidate);\n }\n }\n return \"\";\n}\n\nfunction compareStrings(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * The parity verdict: `true` iff `a` and `b` are structurally equal. Reuses\n * `trace-replay`'s order-insensitive deep-equal (the comparator the\n * record/replay lane owns) rather than adding another boolean deep-compare —\n * feed it the pair produced by {@link normalizeForParity} for the\n * normalized-JSON equality the gate rests on.\n */\nexport function parityEqual(a: unknown, b: unknown): boolean {\n return deepEqual(a, b);\n}\n\n/**\n * @deprecated Inverted name — it returns `true` when the values are EQUAL, so\n * `if (diff(old, new))` reads backwards (#278). Use {@link parityEqual}.\n * Alias kept for one minor, then removed.\n */\nexport const diff = parityEqual;\n"]}
1
+ {"version":3,"sources":["../../src/parity/index.ts"],"names":["key"],"mappings":";;;;;;;AAiEO,SAAS,SAAA,CACd,SACA,IAAA,EACiB;AACjB,EAAA,MAAM,GAAA,G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,IACzB;AAAA,EACF;AACA,EAAA,OAAO,EAAA;AACT;AAEA,SAAS,cAAA,CAAe,GAAW,CAAA,EAAmB;AACpD,EAAA,OAAO,CAAA,GAAI,CAAA,GAAI,EAAA,GAAK,CAAA,GAAI,IAAI,CAAA,GAAI,CAAA;AAClC;AAEA,SAAS,cAAc,KAAA,EAAkD;AACvE,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;AASO,SAAS,WAAA,CAAY,GAAY,CAAA,EAAqB;AAC3D,EAAA,OAAO,SAAA,CAAU,GAAG,CAAC,CAAA;AACvB;AAOO,IAAM,IAAA,GAAO","file":"index.js","sourcesContent":["/**\n * the record → replay → normalized-diff go/no-go gate.\n *\n * The parity spike proved the mechanism already composes from in-tree\n * primitives: `recorder` captures a run's Msg sequence (the recording), `replay`\n * re-folds it purely, and `trace-replay`'s order-insensitive deep-equal diffs\n * the result. Non-determinism is a RECORD-TIME property — ids/timestamps freeze\n * into the recording, `replay` never re-mints them — so the same recording\n * replays byte-identical every time.\n *\n * This module is the thin packaging over that substrate plus the one genuinely\n * new helper, `normalizeForParity`: the finding-normalizer that strips\n * record-time non-determinism (generated ids/timestamps) and stable-key-sorts\n * collections, so an OLD-engine golden run and a NEW-engine run diff as equal\n * exactly when they are behaviourally equivalent. Every domain (audit, auth,\n * ingest, …) gets its old-vs-new parity check without reinventing the capture,\n * the normalization, and the diff.\n *\n * ```text\n * recordRun(runtime) → Recording // wraps the recorder\n * goldenReplay(machine, rec) → State // wraps replay\n * normalizeForParity(schema) → (finding) => norm // strip + stable-sort\n * parityEqual(a, b) → boolean // normalized deep-equal\n * ```\n *\n * @packageDocumentation\n */\n\nimport type { BootingRuntime, Cmd, Machine, Sub } from \"../index\";\nimport { replay } from \"../index\";\nimport { type RecorderOptions, recorder, type Trace } from \"../recorder\";\nimport { deepEqual } from \"../trace-replay\";\n\n/**\n * A live parity recording attached to a Runtime — the go/no-go gate's golden\n * artifact. Wraps a {@link recorder}: drive the runtime, then snapshot with\n * {@link Recording.trace} (or hand the live `Recording` straight to\n * {@link goldenReplay}, which snapshots for you).\n *\n * @typeParam S - the machine's State type.\n * @typeParam M - the machine's Msg union.\n */\nexport interface Recording<S, M> {\n /**\n * Snapshot the recording so far as a replayable {@link Trace} — `loaded`\n * (boot state), the ordered non-null `msgs`, and `finalState`. Sufficient to\n * reproduce the run via {@link goldenReplay}. Fresh object each call.\n */\n trace(): Trace<S, M>;\n /** Serialize the recording as JSONL (see {@link recorder}'s `toJSONL`). */\n toJSONL(): string;\n /** Detach the underlying observer. Idempotent. */\n stop(): void;\n}\n\n/**\n * Attach a parity recording to a Runtime, reusing the `recorder`/`historyTracker`\n * capture (the boot observe for `loaded` + every non-null msg in order) rather\n * than a fresh observer path.\n *\n * Attach on the synchronous `run()` handle so the boot transition is captured\n * as `loaded`; drive the runtime; then `trace()` (or pass the handle to\n * {@link goldenReplay}). See {@link RecorderOptions} for `captureSteps` (needed\n * only for the per-step / resume-cache-prefix inspection, not for replay).\n */\nexport function recordRun<S, M extends { type: string }>(\n runtime: BootingRuntime<S, M>,\n opts?: RecorderOptions,\n): Recording<S, M> {\n const rec = recorder(runtime, opts);\n return {\n trace: () => rec.dump(),\n toJSONL: () => rec.toJSONL(),\n stop: () => rec.stop(),\n };\n}\n\n/**\n * Reproduce a recording's final state by folding its msgs through the pure\n * `replay` — `init(loaded, ctx)` then `update` per msg, never `interpret`,\n * never a `Store`, never a live subscription. Accepts a live {@link Recording}\n * (snapshotted here) or a bare {@link Trace}.\n *\n * `ctx` is the ENVIRONMENT supplied fresh at replay time (the trace is the\n * INPUT: `loaded` + `msgs`), mirroring `replayTrace`. It is optional so a\n * void-ctx machine can call `goldenReplay(machine, rec)`; a machine that reads\n * ctx passes it explicitly.\n */\nexport function goldenReplay<\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n Ctx,\n>(\n machine: Machine<S, M, C, U, Ctx>,\n recording: Recording<S, M> | Trace<S, M>,\n ctx?: Ctx,\n): S {\n const trace = asTrace(recording);\n const { state } = replay(machine, {\n msgs: trace.msgs,\n ctx: ctx as Ctx,\n loaded: trace.loaded,\n });\n return state;\n}\n\n/** Narrow a `Recording | Trace` to a `Trace`, snapshotting a live recording. */\nfunction asTrace<S, M>(recording: Recording<S, M> | Trace<S, M>): Trace<S, M> {\n return typeof (recording as Recording<S, M>).trace === \"function\"\n ? (recording as Recording<S, M>).trace()\n : (recording as Trace<S, M>);\n}\n\n/** Configuration for {@link normalizeForParity}. */\nexport interface ParitySchema {\n /**\n * Object keys stripped wherever they appear — the record-time\n * non-determinism `replay` never re-mints. Default: `id`, `runId`,\n * `timestamp`.\n */\n readonly stripKeys?: readonly string[];\n /**\n * Candidate keys used to stable-sort arrays of objects. For each array the\n * first candidate present (as a primitive) on the items decides the order;\n * arrays with no candidate fall back to canonical-JSON order. Default:\n * `ruleId`, `selector`, `url`.\n */\n readonly sortKeys?: readonly string[];\n}\n\n// Defaults proven by the spike: strip the generated id/runId/timestamp,\n// stable-key-sort by ruleId | selector | url. Fan-out ordering is already\n// deterministic on this substrate (array order); the sort only defends against\n// intra-effect concurrency (Promise.all / Set).\nconst DEFAULT_STRIP_KEYS: readonly string[] = [\"id\", \"runId\", \"timestamp\"];\nconst DEFAULT_SORT_KEYS: readonly string[] = [\"ruleId\", \"selector\", \"url\"];\n\n/**\n * Build a finding-normalizer: a pure `(value) => normalized` that strips the\n * schema's `stripKeys`, recursively sorts object keys, and stable-key-sorts\n * arrays by the schema's `sortKeys`. Two runs that differ only in generated\n * ids/timestamps or intra-effect ordering normalize to a byte-identical value,\n * so {@link parityEqual} on the normalized pair reflects behavioural (not incidental)\n * difference.\n */\nexport function normalizeForParity(\n schema?: ParitySchema,\n): (value: unknown) => unknown {\n const stripKeys = new Set(schema?.stripKeys ?? DEFAULT_STRIP_KEYS);\n const sortKeys = schema?.sortKeys ?? DEFAULT_SORT_KEYS;\n\n const normalize = (value: unknown): unknown => {\n if (Array.isArray(value)) {\n const items = value.map(normalize);\n // Decorate-sort-undecorate: primary key = first present sortKey value,\n // secondary = canonical JSON (items are already normalized so keys are\n // sorted), original index last for a stable total order.\n return items\n .map((item, index) => ({\n item,\n index,\n primary: primarySortKey(item, sortKeys),\n json: JSON.stringify(item) ?? \"\",\n }))\n .sort(\n (a, b) =>\n compareStrings(a.primary, b.primary) ||\n compareStrings(a.json, b.json) ||\n a.index - b.index,\n )\n .map((decorated) => decorated.item);\n }\n if (isPlainObject(value)) {\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(value)\n .filter((key) => !stripKeys.has(key))\n .sort()) {\n out[key] = normalize(value[key]);\n }\n return out;\n }\n return value;\n };\n\n return normalize;\n}\n\n/** The first present `sortKeys` candidate on `item` as a string, or `\"\"`. */\nfunction primarySortKey(item: unknown, sortKeys: readonly string[]): string {\n if (!isPlainObject(item)) return \"\";\n for (const key of sortKeys) {\n const candidate = item[key];\n if (\n typeof candidate === \"string\" ||\n typeof candidate === \"number\" ||\n typeof candidate === \"boolean\"\n ) {\n return String(candidate);\n }\n }\n return \"\";\n}\n\nfunction compareStrings(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * The parity verdict: `true` iff `a` and `b` are structurally equal. Reuses\n * `trace-replay`'s order-insensitive deep-equal (the comparator the\n * record/replay lane owns) rather than adding another boolean deep-compare —\n * feed it the pair produced by {@link normalizeForParity} for the\n * normalized-JSON equality the gate rests on.\n */\nexport function parityEqual(a: unknown, b: unknown): boolean {\n return deepEqual(a, b);\n}\n\n/**\n * @deprecated Inverted name — it returns `true` when the values are EQUAL, so\n * `if (diff(old, new))` reads backwards (#278). Use {@link parityEqual}.\n * Alias kept for one minor, then removed.\n */\nexport const diff = parityEqual;\n"]}
@@ -1,5 +1,5 @@
1
1
  import * as fc from 'fast-check';
2
- import { C as Cmd, S as Sub, M as Machine } from '../../core-JPHsMZVB.js';
2
+ import { C as Cmd, S as Sub, M as Machine } from '../../core-Bjc0bS8j.js';
3
3
 
4
4
  /**
5
5
  * Build a Ctx value whose every property access throws. Use as the `ctx`
@@ -1,6 +1,6 @@
1
1
  export { MsgArbitraryTable, arbConstantMsg, arbGuidedSequence, arbMsg, arbMsgSequence, arbRecordMsg, stubCtxThrowingProxy } from './arbitraries/index.js';
2
2
  export { Step, foldEvents, propertyInvariant, propertyTerminates, propertyTrace } from './runners/index.js';
3
- import { C as Cmd, R as Reducer, T as Transitions, U as UpdateForm } from '../core-JPHsMZVB.js';
3
+ import { C as Cmd, R as Reducer, T as Transitions, U as UpdateForm } from '../core-Bjc0bS8j.js';
4
4
  import 'fast-check';
5
5
 
6
6
  /**
package/dist/pbt/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export { arbConstantMsg, arbGuidedSequence, arbMsg, arbMsgSequence, arbRecordMsg, stubCtxThrowingProxy } from '../chunk-AZZLE7XR.js';
2
- export { foldEvents, propertyInvariant, propertyTerminates, propertyTrace } from '../chunk-S6Y3RNX4.js';
3
- import '../chunk-ZH454CR5.js';
4
- import { msgKeysOf } from '../chunk-O7ED34JH.js';
2
+ export { foldEvents, propertyInvariant, propertyTerminates, propertyTrace } from '../chunk-JP5D6GSL.js';
3
+ import '../chunk-5EHLEUTL.js';
4
+ import { msgKeysOf } from '../chunk-B5VXOFMZ.js';
5
5
 
6
6
  // src/pbt/util/msg-keys.ts
7
7
  function msgTypeKeys(machine) {
@@ -1,5 +1,5 @@
1
1
  import * as fc from 'fast-check';
2
- import { C as Cmd, S as Sub, M as Machine } from '../../core-JPHsMZVB.js';
2
+ import { C as Cmd, S as Sub, M as Machine } from '../../core-Bjc0bS8j.js';
3
3
 
4
4
  /**
5
5
  * One unit in a fold trace — the four pieces of data a property
@@ -1,5 +1,5 @@
1
- export { foldEvents, propertyInvariant, propertyTerminates, propertyTrace } from '../../chunk-S6Y3RNX4.js';
2
- import '../../chunk-ZH454CR5.js';
3
- import '../../chunk-O7ED34JH.js';
1
+ export { foldEvents, propertyInvariant, propertyTerminates, propertyTrace } from '../../chunk-JP5D6GSL.js';
2
+ import '../../chunk-5EHLEUTL.js';
3
+ import '../../chunk-B5VXOFMZ.js';
4
4
  //# sourceMappingURL=index.js.map
5
5
  //# sourceMappingURL=index.js.map