@ontrails/core 1.0.0-beta.13 → 1.0.0-beta.15

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 (287) hide show
  1. package/.turbo/turbo-lint.log +1 -1
  2. package/CHANGELOG.md +17 -0
  3. package/README.md +19 -14
  4. package/dist/branded.d.ts +1 -1
  5. package/dist/branded.d.ts.map +1 -1
  6. package/dist/branded.js +1 -1
  7. package/dist/branded.js.map +1 -1
  8. package/dist/context.d.ts +13 -1
  9. package/dist/context.d.ts.map +1 -1
  10. package/dist/context.js +19 -3
  11. package/dist/context.js.map +1 -1
  12. package/dist/contour.d.ts +81 -0
  13. package/dist/contour.d.ts.map +1 -0
  14. package/dist/contour.js +176 -0
  15. package/dist/contour.js.map +1 -0
  16. package/dist/cross-schema.d.ts +18 -0
  17. package/dist/cross-schema.d.ts.map +1 -0
  18. package/dist/cross-schema.js +29 -0
  19. package/dist/cross-schema.js.map +1 -0
  20. package/dist/derive.d.ts +6 -0
  21. package/dist/derive.d.ts.map +1 -1
  22. package/dist/derive.js +29 -5
  23. package/dist/derive.js.map +1 -1
  24. package/dist/draft.d.ts +28 -0
  25. package/dist/draft.d.ts.map +1 -0
  26. package/dist/draft.js +157 -0
  27. package/dist/draft.js.map +1 -0
  28. package/dist/errors.d.ts +62 -4
  29. package/dist/errors.d.ts.map +1 -1
  30. package/dist/errors.js +44 -1
  31. package/dist/errors.js.map +1 -1
  32. package/dist/execute.d.ts +26 -9
  33. package/dist/execute.d.ts.map +1 -1
  34. package/dist/execute.js +441 -20
  35. package/dist/execute.js.map +1 -1
  36. package/dist/fire.d.ts +43 -0
  37. package/dist/fire.d.ts.map +1 -0
  38. package/dist/fire.js +185 -0
  39. package/dist/fire.js.map +1 -0
  40. package/dist/index.d.ts +33 -17
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +26 -12
  43. package/dist/index.js.map +1 -1
  44. package/dist/internal/cross-batch.d.ts +44 -0
  45. package/dist/internal/cross-batch.d.ts.map +1 -0
  46. package/dist/internal/cross-batch.js +58 -0
  47. package/dist/internal/cross-batch.js.map +1 -0
  48. package/dist/internal/fork-ctx.d.ts +41 -0
  49. package/dist/internal/fork-ctx.d.ts.map +1 -0
  50. package/dist/internal/fork-ctx.js +47 -0
  51. package/dist/internal/fork-ctx.js.map +1 -0
  52. package/dist/internal/signal-ref.d.ts +15 -0
  53. package/dist/internal/signal-ref.d.ts.map +1 -0
  54. package/dist/internal/signal-ref.js +41 -0
  55. package/dist/internal/signal-ref.js.map +1 -0
  56. package/dist/internal/topo-saves.d.ts +53 -0
  57. package/dist/internal/topo-saves.d.ts.map +1 -0
  58. package/dist/internal/topo-saves.js +449 -0
  59. package/dist/internal/topo-saves.js.map +1 -0
  60. package/dist/internal/topo-snapshots.d.ts +57 -0
  61. package/dist/internal/topo-snapshots.d.ts.map +1 -0
  62. package/dist/internal/topo-snapshots.js +372 -0
  63. package/dist/internal/topo-snapshots.js.map +1 -0
  64. package/dist/internal/topo-store-read.d.ts +70 -0
  65. package/dist/internal/topo-store-read.d.ts.map +1 -0
  66. package/dist/internal/topo-store-read.js +221 -0
  67. package/dist/internal/topo-store-read.js.map +1 -0
  68. package/dist/internal/topo-store.d.ts +26 -0
  69. package/dist/internal/topo-store.d.ts.map +1 -0
  70. package/dist/internal/topo-store.js +621 -0
  71. package/dist/internal/topo-store.js.map +1 -0
  72. package/dist/internal/tracing.d.ts +98 -0
  73. package/dist/internal/tracing.d.ts.map +1 -0
  74. package/dist/internal/tracing.js +102 -0
  75. package/dist/internal/tracing.js.map +1 -0
  76. package/dist/internal/trails-db.d.ts +16 -0
  77. package/dist/internal/trails-db.d.ts.map +1 -0
  78. package/dist/internal/trails-db.js +118 -0
  79. package/dist/internal/trails-db.js.map +1 -0
  80. package/dist/internal/zod-wrappers.d.ts +40 -0
  81. package/dist/internal/zod-wrappers.d.ts.map +1 -0
  82. package/dist/internal/zod-wrappers.js +59 -0
  83. package/dist/internal/zod-wrappers.js.map +1 -0
  84. package/dist/layer.d.ts +22 -5
  85. package/dist/layer.d.ts.map +1 -1
  86. package/dist/layer.js +20 -3
  87. package/dist/layer.js.map +1 -1
  88. package/dist/path-security.d.ts +1 -1
  89. package/dist/path-security.d.ts.map +1 -1
  90. package/dist/path-security.js +1 -1
  91. package/dist/path-security.js.map +1 -1
  92. package/dist/resilience.d.ts +1 -1
  93. package/dist/resilience.d.ts.map +1 -1
  94. package/dist/resilience.js +3 -3
  95. package/dist/resilience.js.map +1 -1
  96. package/dist/resource-config.d.ts +22 -0
  97. package/dist/resource-config.d.ts.map +1 -0
  98. package/dist/resource-config.js +210 -0
  99. package/dist/resource-config.js.map +1 -0
  100. package/dist/resource.d.ts +74 -0
  101. package/dist/resource.d.ts.map +1 -0
  102. package/dist/resource.js +61 -0
  103. package/dist/resource.js.map +1 -0
  104. package/dist/run.d.ts +4 -3
  105. package/dist/run.d.ts.map +1 -1
  106. package/dist/run.js +5 -4
  107. package/dist/run.js.map +1 -1
  108. package/dist/serialization.d.ts.map +1 -1
  109. package/dist/serialization.js +2 -1
  110. package/dist/serialization.js.map +1 -1
  111. package/dist/store/accessor-protocol.d.ts +51 -0
  112. package/dist/store/accessor-protocol.d.ts.map +1 -0
  113. package/dist/store/accessor-protocol.js +2 -0
  114. package/dist/store/accessor-protocol.js.map +1 -0
  115. package/dist/store/index.d.ts +2 -0
  116. package/dist/store/index.d.ts.map +1 -0
  117. package/dist/store/index.js +2 -0
  118. package/dist/store/index.js.map +1 -0
  119. package/dist/surface-filter.d.ts +13 -0
  120. package/dist/surface-filter.d.ts.map +1 -0
  121. package/dist/surface-filter.js +76 -0
  122. package/dist/surface-filter.js.map +1 -0
  123. package/dist/topo-store.d.ts +62 -0
  124. package/dist/topo-store.d.ts.map +1 -0
  125. package/dist/topo-store.js +319 -0
  126. package/dist/topo-store.js.map +1 -0
  127. package/dist/topo.d.ts +23 -9
  128. package/dist/topo.d.ts.map +1 -1
  129. package/dist/topo.js +175 -46
  130. package/dist/topo.js.map +1 -1
  131. package/dist/trail.d.ts +86 -19
  132. package/dist/trail.d.ts.map +1 -1
  133. package/dist/trail.js +59 -4
  134. package/dist/trail.js.map +1 -1
  135. package/dist/trails/derive-trail.d.ts +66 -0
  136. package/dist/trails/derive-trail.d.ts.map +1 -0
  137. package/dist/trails/derive-trail.js +378 -0
  138. package/dist/trails/derive-trail.js.map +1 -0
  139. package/dist/trails/index.d.ts +5 -0
  140. package/dist/trails/index.d.ts.map +1 -0
  141. package/dist/trails/index.js +3 -0
  142. package/dist/trails/index.js.map +1 -0
  143. package/dist/trails/ingest.d.ts +24 -0
  144. package/dist/trails/ingest.d.ts.map +1 -0
  145. package/dist/trails/ingest.js +63 -0
  146. package/dist/trails/ingest.js.map +1 -0
  147. package/dist/transport-error-map.d.ts +106 -0
  148. package/dist/transport-error-map.d.ts.map +1 -0
  149. package/dist/transport-error-map.js +24 -0
  150. package/dist/transport-error-map.js.map +1 -0
  151. package/dist/type-checks.test-d.d.ts +71 -0
  152. package/dist/type-checks.test-d.d.ts.map +1 -0
  153. package/dist/type-checks.test-d.js +12 -0
  154. package/dist/type-checks.test-d.js.map +1 -0
  155. package/dist/type-utils.d.ts +11 -2
  156. package/dist/type-utils.d.ts.map +1 -1
  157. package/dist/type-utils.js.map +1 -1
  158. package/dist/types.d.ts +113 -7
  159. package/dist/types.d.ts.map +1 -1
  160. package/dist/types.js.map +1 -1
  161. package/dist/validate-established-topo.d.ts +76 -0
  162. package/dist/validate-established-topo.d.ts.map +1 -0
  163. package/dist/validate-established-topo.js +43 -0
  164. package/dist/validate-established-topo.js.map +1 -0
  165. package/dist/validate-topo.d.ts.map +1 -1
  166. package/dist/validate-topo.js +27 -8
  167. package/dist/validate-topo.js.map +1 -1
  168. package/dist/workspace.d.ts +1 -1
  169. package/dist/workspace.d.ts.map +1 -1
  170. package/dist/workspace.js +1 -1
  171. package/dist/workspace.js.map +1 -1
  172. package/package.json +10 -1
  173. package/src/__tests__/branded.test.ts +5 -5
  174. package/src/__tests__/context.test.ts +3 -3
  175. package/src/__tests__/contour.test.ts +263 -0
  176. package/src/__tests__/derive-trail.test.ts +668 -0
  177. package/src/__tests__/derive.test.ts +58 -1
  178. package/src/__tests__/errors.test.ts +118 -0
  179. package/src/__tests__/execute.test.ts +1179 -141
  180. package/src/__tests__/fire.test.ts +1056 -0
  181. package/src/__tests__/fork-ctx.test.ts +83 -0
  182. package/src/__tests__/ingest.test.ts +191 -0
  183. package/src/__tests__/{gate.test.ts → layer.test.ts} +21 -21
  184. package/src/__tests__/path-security.test.ts +7 -7
  185. package/src/__tests__/resilience.test.ts +8 -8
  186. package/src/__tests__/resource.test.ts +204 -0
  187. package/src/__tests__/run.test.ts +13 -13
  188. package/src/__tests__/service-config.test.ts +28 -32
  189. package/src/__tests__/surface-filter.test.ts +196 -0
  190. package/src/__tests__/topo-store-read.test.ts +256 -0
  191. package/src/__tests__/topo-store.test.ts +869 -0
  192. package/src/__tests__/topo.test.ts +350 -54
  193. package/src/__tests__/trail.test.ts +189 -24
  194. package/src/__tests__/trails-db.test.ts +198 -0
  195. package/src/__tests__/transport-error-map.test.ts +82 -0
  196. package/src/__tests__/type-utils.test.ts +29 -1
  197. package/src/__tests__/validate-topo.test.ts +305 -16
  198. package/src/__tests__/workspace.test.ts +6 -6
  199. package/src/__tests__/zod-wrappers.test.ts +62 -0
  200. package/src/branded.ts +1 -1
  201. package/src/context.ts +24 -4
  202. package/src/contour.ts +344 -0
  203. package/src/cross-schema.ts +36 -0
  204. package/src/derive.ts +39 -8
  205. package/src/draft.ts +338 -0
  206. package/src/errors.ts +62 -18
  207. package/src/execute.ts +840 -29
  208. package/src/fire.ts +295 -0
  209. package/src/index.ts +142 -26
  210. package/src/internal/cross-batch.ts +77 -0
  211. package/src/internal/fork-ctx.ts +69 -0
  212. package/src/internal/signal-ref.ts +87 -0
  213. package/src/internal/topo-snapshots.ts +517 -0
  214. package/src/internal/topo-store-read.ts +481 -0
  215. package/src/internal/topo-store.ts +1192 -0
  216. package/src/internal/tracing.ts +187 -0
  217. package/src/internal/trails-db.ts +187 -0
  218. package/src/internal/zod-wrappers.ts +78 -0
  219. package/src/layer.ts +50 -0
  220. package/src/path-security.ts +1 -1
  221. package/src/resilience.ts +3 -3
  222. package/src/{provision-config.ts → resource-config.ts} +109 -123
  223. package/src/resource.ts +155 -0
  224. package/src/run.ts +5 -4
  225. package/src/serialization.ts +2 -0
  226. package/src/store/accessor-protocol.ts +56 -0
  227. package/src/store/index.ts +4 -0
  228. package/src/surface-filter.ts +182 -0
  229. package/src/topo-store.ts +510 -0
  230. package/src/topo.ts +328 -57
  231. package/src/trail.ts +199 -31
  232. package/src/trails/derive-trail.ts +842 -0
  233. package/src/trails/index.ts +9 -0
  234. package/src/trails/ingest.ts +146 -0
  235. package/src/transport-error-map.ts +56 -0
  236. package/src/type-checks.test-d.ts +106 -0
  237. package/src/type-utils.ts +17 -2
  238. package/src/types.ts +148 -11
  239. package/src/validate-established-topo.ts +63 -0
  240. package/src/validate-topo.ts +37 -9
  241. package/src/workspace.ts +1 -1
  242. package/tsconfig.tests.json +10 -0
  243. package/tsconfig.tsbuildinfo +1 -1
  244. package/dist/adapters.d.ts +0 -39
  245. package/dist/adapters.d.ts.map +0 -1
  246. package/dist/adapters.js +0 -2
  247. package/dist/adapters.js.map +0 -1
  248. package/dist/dispatch.d.ts +0 -27
  249. package/dist/dispatch.d.ts.map +0 -1
  250. package/dist/dispatch.js +0 -34
  251. package/dist/dispatch.js.map +0 -1
  252. package/dist/event.d.ts +0 -8
  253. package/dist/event.d.ts.map +0 -1
  254. package/dist/event.js +0 -7
  255. package/dist/event.js.map +0 -1
  256. package/dist/gate.d.ts +0 -17
  257. package/dist/gate.d.ts.map +0 -1
  258. package/dist/gate.js +0 -21
  259. package/dist/gate.js.map +0 -1
  260. package/dist/health.d.ts +0 -18
  261. package/dist/health.d.ts.map +0 -1
  262. package/dist/health.js +0 -5
  263. package/dist/health.js.map +0 -1
  264. package/dist/job.d.ts +0 -24
  265. package/dist/job.d.ts.map +0 -1
  266. package/dist/job.js +0 -17
  267. package/dist/job.js.map +0 -1
  268. package/dist/provision-config.d.ts +0 -22
  269. package/dist/provision-config.d.ts.map +0 -1
  270. package/dist/provision-config.js +0 -210
  271. package/dist/provision-config.js.map +0 -1
  272. package/dist/provision.d.ts +0 -71
  273. package/dist/provision.d.ts.map +0 -1
  274. package/dist/provision.js +0 -56
  275. package/dist/provision.js.map +0 -1
  276. package/dist/service-config.d.ts +0 -22
  277. package/dist/service-config.d.ts.map +0 -1
  278. package/dist/service-config.js +0 -210
  279. package/dist/service-config.js.map +0 -1
  280. package/dist/service.d.ts +0 -71
  281. package/dist/service.d.ts.map +0 -1
  282. package/dist/service.js +0 -56
  283. package/dist/service.js.map +0 -1
  284. package/src/__tests__/service.test.ts +0 -197
  285. package/src/event.ts +0 -15
  286. package/src/gate.ts +0 -44
  287. package/src/provision.ts +0 -148
package/dist/fire.js ADDED
@@ -0,0 +1,185 @@
1
+ /**
2
+ * Signal emission and auto-activation.
3
+ *
4
+ * `createFireFn(topo, producerCtx?, executor)` returns a `FireFn` bound to
5
+ * a topo. Calling `fire(signalId, payload)` looks up the signal, validates
6
+ * the payload against its schema, finds every trail with the signal in its
7
+ * `on:` array, and invokes each consumer via the supplied executor.
8
+ *
9
+ * The `executor` parameter is an indirection that lets `execute.ts` pass in
10
+ * `executeTrail` without `fire.ts` importing it directly — keeping the two
11
+ * modules dependency-cycle-free.
12
+ *
13
+ * Consumer contexts inherit the producer's full ctx (logger, extensions,
14
+ * resources, abortSignal, requestId, env, workspaceRoot, permit) with
15
+ * `fire` rebound to the same closure so consumers can fan out further.
16
+ * Each consumer gets its own derived context so sibling fan-out branches do
17
+ * not share mutable top-level state. The consumer logger is derived from the
18
+ * producer logger as a child tagged with `signalId` and `consumerId` when
19
+ * `logger.child` exists.
20
+ *
21
+ * Error semantics match the fire-and-forget framing: producers get
22
+ * `Result.ok(undefined)` unless the signal id is unknown or the payload
23
+ * fails schema validation. Consumer errors are logged via the producer's
24
+ * logger but do NOT propagate back to the producer. Consumers that need
25
+ * transactional coupling should use `crosses:`.
26
+ */
27
+ import { NotFoundError, ValidationError } from './errors.js';
28
+ import { forkCtx } from './internal/fork-ctx.js';
29
+ import { Result } from './result.js';
30
+ const FIRE_STACK_KEY = '__trails_fire_stack';
31
+ /**
32
+ * Maximum depth for signal fan-out chains.
33
+ *
34
+ * Cycle detection catches re-entrant fires of the same signal ID (A→B→A),
35
+ * but a chain of distinct signals (A→B→C→D→...) bypasses it. This limit
36
+ * prevents runaway fan-out in pathological topologies.
37
+ */
38
+ const MAX_FIRE_DEPTH = 16;
39
+ const getFireStack = (ctx) => {
40
+ const value = ctx?.extensions?.[FIRE_STACK_KEY];
41
+ return Array.isArray(value) ? value : [];
42
+ };
43
+ const deriveConsumerLogger = (producerCtx, signalId, consumerId) => producerCtx?.logger?.child?.({ consumerId, signalId }) ?? producerCtx?.logger;
44
+ const deriveConsumerEnv = (producerCtx) => producerCtx?.env ? { ...producerCtx.env } : undefined;
45
+ const deriveConsumerExtensions = (producerCtx, signalId) => ({
46
+ ...producerCtx?.extensions,
47
+ [FIRE_STACK_KEY]: [...getFireStack(producerCtx), signalId],
48
+ });
49
+ const deriveConsumerCtx = (producerCtx, signalId, consumerId) => producerCtx
50
+ ? forkCtx(producerCtx, {
51
+ env: deriveConsumerEnv(producerCtx),
52
+ extensions: deriveConsumerExtensions(producerCtx, signalId),
53
+ logger: deriveConsumerLogger(producerCtx, signalId, consumerId),
54
+ })
55
+ : {};
56
+ /**
57
+ * Fan out a validated signal payload to its consumer trails.
58
+ *
59
+ * @remarks
60
+ * Consumers fan out in parallel by design. Signal delivery is fire-and-forget
61
+ * notification, not ordered orchestration; if one consumer depends on another,
62
+ * the dependency belongs in `crosses:` instead of sibling signal sequencing.
63
+ *
64
+ * `Promise.allSettled` preserves failure isolation and waits for every branch
65
+ * to settle. Each consumer gets its own derived context so sibling branches do
66
+ * not share mutable top-level state while they overlap. Re-entrant suppression
67
+ * elsewhere in this module is still based on signal-id membership in the
68
+ * current fire stack: it prevents infinite loops, but it can over-suppress
69
+ * legitimate diamond re-fires. Per-path provenance is a documented future
70
+ * direction rather than part of the pre-v1 runtime contract.
71
+ */
72
+ const fanOutToConsumers = async (consumers, payload, signalId, producerCtx, bindFire, executor, logger) => {
73
+ const settled = await Promise.allSettled(consumers.map(async (consumer) => {
74
+ const consumerCtx = bindFire(deriveConsumerCtx(producerCtx, signalId, consumer.id));
75
+ const consumerResult = await executor(consumer, payload, consumerCtx);
76
+ if (consumerResult.isErr()) {
77
+ (consumerCtx.logger ?? logger)?.warn('Signal consumer failed', {
78
+ consumerId: consumer.id,
79
+ error: consumerResult.error.message,
80
+ signalId,
81
+ });
82
+ }
83
+ return consumer.id;
84
+ }));
85
+ for (const [index, entry] of settled.entries()) {
86
+ if (entry.status !== 'rejected') {
87
+ continue;
88
+ }
89
+ // `executeTrail` normalizes throws into `Result.err`, so reaching this
90
+ // branch means the executor (or the warn call above) rejected
91
+ // unexpectedly. Log at debug to preserve provenance without propagating
92
+ // the failure to the producer (fire-and-forget semantics).
93
+ logger?.debug('Signal consumer rejected unexpectedly', {
94
+ consumerId: consumers[index]?.id,
95
+ error: entry.reason instanceof Error
96
+ ? entry.reason.message
97
+ : String(entry.reason),
98
+ signalId,
99
+ });
100
+ }
101
+ };
102
+ const resolveFireDispatch = (topo, signalId, payload) => {
103
+ const signal = topo.signals.get(signalId);
104
+ if (signal === undefined) {
105
+ return Result.err(new NotFoundError(`Signal "${signalId}" not found in topo "${topo.name}"`));
106
+ }
107
+ const parsed = signal.payload.safeParse(payload);
108
+ if (!parsed.success) {
109
+ return Result.err(new ValidationError(`Invalid payload for signal "${signalId}": ${parsed.error.message}`));
110
+ }
111
+ return Result.ok({
112
+ consumers: topo.list().filter((trail) => trail.on.includes(signalId)),
113
+ payload: parsed.data,
114
+ });
115
+ };
116
+ const resolveSignalId = (signalOrId) => {
117
+ if (typeof signalOrId === 'string') {
118
+ return Result.ok(signalOrId);
119
+ }
120
+ if (typeof signalOrId === 'object' &&
121
+ signalOrId !== null &&
122
+ 'id' in signalOrId &&
123
+ typeof signalOrId.id === 'string') {
124
+ return Result.ok(signalOrId.id);
125
+ }
126
+ return Result.err(new ValidationError('ctx.fire() requires a signal id string or a Signal value'));
127
+ };
128
+ /**
129
+ * Build a `FireFn` closure bound to a topo.
130
+ *
131
+ * When `producerCtx` is provided, consumer trails activated via `on:`
132
+ * inherit the producer's logger, extensions, resources, abortSignal,
133
+ * requestId, env, workspaceRoot, and permit. `ctx.fire` on the consumer
134
+ * is rebound to the same closure so consumers can emit downstream
135
+ * signals naturally.
136
+ */
137
+ export const createFireFn = (topo, producerCtx, executor) => {
138
+ const bindConsumerFire = (consumerCtx) => ({
139
+ ...consumerCtx,
140
+ // Pre-bind fire on the consumer ctx as a safety net for direct
141
+ // executeTrail calls that skip the topo-aware path. In the normal
142
+ // fan-out flow below, bindFireToCtx in execute.ts rebinds fire to
143
+ // the fully-traced ctx before the blaze runs, so this assignment
144
+ // is superseded — but keeping it makes consumerCtx self-sufficient
145
+ // for any caller that inspects it pre-execution.
146
+ fire: createFireFn(topo, consumerCtx, executor),
147
+ });
148
+ const dispatchFire = async (signalId, payload) => {
149
+ const dispatch = resolveFireDispatch(topo, signalId, payload);
150
+ if (dispatch.isErr()) {
151
+ return Result.err(dispatch.error);
152
+ }
153
+ await fanOutToConsumers(dispatch.value.consumers, dispatch.value.payload, signalId, producerCtx, bindConsumerFire, executor, producerCtx?.logger);
154
+ return Result.ok();
155
+ };
156
+ /** Return an early Result if the fire should be suppressed, or null to proceed. */
157
+ const guardFire = (signalId, stack) => {
158
+ if (stack.length >= MAX_FIRE_DEPTH) {
159
+ producerCtx?.logger?.warn('Signal fan-out depth limit reached — skipping fire', { depth: stack.length, signalId });
160
+ return Result.ok();
161
+ }
162
+ if (stack.includes(signalId)) {
163
+ producerCtx?.logger?.debug('Signal fan-out suppressed due to cycle', {
164
+ fireStack: [...stack],
165
+ signalId,
166
+ });
167
+ producerCtx?.logger?.warn('Signal cycle detected — skipping re-entrant fire', { fireStack: [...stack], signalId });
168
+ return Result.ok();
169
+ }
170
+ return null;
171
+ };
172
+ const fireImpl = async (signalOrId, payload) => {
173
+ const resolved = resolveSignalId(signalOrId);
174
+ if (resolved.isErr()) {
175
+ return Result.err(resolved.error);
176
+ }
177
+ const suppressed = guardFire(resolved.value, getFireStack(producerCtx));
178
+ if (suppressed) {
179
+ return suppressed;
180
+ }
181
+ return await dispatchFire(resolved.value, payload);
182
+ };
183
+ return fireImpl;
184
+ };
185
+ //# sourceMappingURL=fire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fire.js","sourceRoot":"","sources":["../src/fire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAgBrC,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,MAAM,YAAY,GAAG,CACnB,GAAqD,EAClC,EAAE;IACrB,MAAM,KAAK,GAAG,GAAG,EAAE,UAAU,EAAE,CAAC,cAAc,CAAC,CAAC;IAChD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,KAA2B,CAAC,CAAC,CAAC,EAAE,CAAC;AAClE,CAAC,CAAC;AAOF,MAAM,oBAAoB,GAAG,CAC3B,WAAyC,EACzC,QAAgB,EAChB,UAAkB,EACE,EAAE,CACtB,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,IAAI,WAAW,EAAE,MAAM,CAAC;AAEhF,MAAM,iBAAiB,GAAG,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AC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,MAAM,QAAQ,GAAW,KAAK,EAC5B,UAAmB,EACnB,OAAgB,EACc,EAAE;QAChC,MAAM,QAAQ,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC;YACrB,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC;QACD,MAAM,UAAU,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC;QACxE,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,UAAU,CAAC;QACpB,CAAC;QACD,OAAO,MAAM,YAAY,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC,CAAC;IACF,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,40 +1,56 @@
1
1
  export { Result } from './result.js';
2
- export { TrailsError, ValidationError, AmbiguousError, AssertionError, NotFoundError, AlreadyExistsError, ConflictError, PermissionError, TimeoutError, RateLimitError, NetworkError, InternalError, AuthError, CancelledError, exitCodeMap, statusCodeMap, jsonRpcCodeMap, retryableMap, isRetryable, isTrailsError, } from './errors.js';
2
+ export { TrailsError, ValidationError, AmbiguousError, AssertionError, NotFoundError, AlreadyExistsError, ConflictError, PermissionError, TimeoutError, RateLimitError, NetworkError, InternalError, AuthError, CancelledError, DerivationError, errorCategories, exitCodeMap, statusCodeMap, jsonRpcCodeMap, retryableMap, RetryExhaustedError, isRetryable, isTrailsError, } from './errors.js';
3
3
  export type { ErrorCategory } from './errors.js';
4
- export type { Implementation, TrailContext, TrailContextInit, CrossFn, BasePermit, PermitRequirement, ProgressCallback, ProgressEvent, Logger, ProvisionLookup, } from './types.js';
4
+ export { createTransportErrorMapper, mapTransportError, transportErrorMap, transportErrorRegistry, transportNames, } from './transport-error-map.js';
5
+ export type { TransportErrorCode, TransportErrorMapper, TransportErrorMappings, TransportName, } from './transport-error-map.js';
6
+ export type { Detour, DetourAttempt, Implementation, TrailContext, TrailContextInit, CrossBatchOptions, CrossFn, FireFn, BasePermit, PermitRequirement, ProgressCallback, ProgressEvent, Logger, ResourceLookup, } from './types.js';
5
7
  export { TRAILHEAD_KEY } from './types.js';
6
- export { createTrailContext } from './context.js';
7
- export { createProvisionLookup, findDuplicateProvisionId, isProvision, provision, } from './provision.js';
8
- export type { AnyProvision, Provision, ProvisionContext, ProvisionOverrideMap, ProvisionSpec, } from './provision.js';
8
+ export { createTrailContext, passthroughTrace } from './context.js';
9
+ export { createResourceLookup, findDuplicateResourceId, isResource, resource, } from './resource.js';
10
+ export type { AnyResource, Resource, ResourceContext, ResourceOverrideMap, ResourceSpec, } from './resource.js';
9
11
  export { trail } from './trail.js';
10
- export type { AnyTrail, Intent, Trail, TrailSpec, TrailExample, } from './trail.js';
11
- export type { TrailInput, TrailOutput, TrailResult } from './type-utils.js';
12
+ export type { AnyTrail, BlazeInput, Intent, Trail, TrailSpec, TrailExample, TrailVisibility, } from './trail.js';
13
+ export { filterSurfaceTrails, matchesTrailPattern, shouldIncludeTrailForSurface, } from './surface-filter.js';
14
+ export type { SurfaceFilterOptions } from './surface-filter.js';
15
+ export type { CrossInput, TrailInput, TrailOutput, TrailResult, } from './type-utils.js';
12
16
  export { inputOf, outputOf } from './type-utils.js';
13
17
  export { signal } from './signal.js';
14
18
  export type { AnySignal, Signal, SignalSpec } from './signal.js';
15
- export { event } from './event.js';
16
- export type { AnyEvent, Event, EventSpec } from './event.js';
19
+ export { contour } from './contour.js';
20
+ export { CONTOUR_ID_METADATA, getContourIdMetadata, getContourReferences, } from './contour.js';
21
+ export type { AnyContour, Contour, ContourIdBrand, ContourIdMetadata, ContourIdSchema, ContourIdValue, ContourOptions, ContourReference, } from './contour.js';
17
22
  export { topo } from './topo.js';
18
- export type { Topo } from './topo.js';
23
+ export type { Topo, TopoIdentity } from './topo.js';
24
+ export { createTopoSnapshot, createMockTopoStore, createTopoStore, listTopoSnapshots, pinTopoSnapshot, topoStore, unpinTopoSnapshot, } from './topo-store.js';
25
+ export type { CreateTopoSnapshotInput, ListTopoSnapshotsOptions, MockTopoStoreSeed, ReadOnlyTopoStore, TopoSnapshot, TopoStoreExportRecord, TopoStoreResourceRecord, TopoStoreRef, TopoStoreTrailDetailRecord, TopoStoreTrailRecord, } from './topo-store.js';
26
+ export { DRAFT_ID_PREFIX, deriveDraftReport, isDraftId, validateDraftFreeTopo, } from './draft.js';
27
+ export type { DraftDependency, DraftDependencyKind, DraftFinding, DraftReport, } from './draft.js';
19
28
  export { validateTopo } from './validate-topo.js';
20
29
  export type { TopoIssue } from './validate-topo.js';
21
- export { composeGates } from './gate.js';
22
- export type { Gate } from './gate.js';
23
- export { deriveFields } from './derive.js';
30
+ export { validateEstablishedTopo } from './validate-established-topo.js';
31
+ export { composeLayers } from './layer.js';
32
+ export type { Layer } from './layer.js';
33
+ export { deriveCliPath, deriveFields } from './derive.js';
24
34
  export type { Field, FieldOverride } from './derive.js';
35
+ export { buildCrossValidationSchema } from './cross-schema.js';
25
36
  export { executeTrail } from './execute.js';
26
37
  export type { ExecuteTrailOptions } from './execute.js';
38
+ export { clearTraceSink, createTraceRecord, getTraceContext, getTraceSink, NOOP_SINK, registerTraceSink, TRACE_CONTEXT_KEY, } from './internal/tracing.js';
39
+ export type { TraceContext, TraceRecord, TraceSink, } from './internal/tracing.js';
40
+ export type { TraceFn } from './types.js';
27
41
  export { run } from './run.js';
28
42
  export type { RunOptions } from './run.js';
43
+ export { deriveTrail, ingest } from './trails/index.js';
44
+ export type { DeriveTrailInput, DeriveTrailOperation, DeriveTrailOutput, DeriveTrailSpec, IngestOptions, IngestTransform, } from './trails/index.js';
29
45
  export { validateInput, validateOutput, formatZodIssues, zodToJsonSchema, } from './validation.js';
30
46
  export { serializeError, deserializeError } from './serialization.js';
31
47
  export type { SerializedError } from './serialization.js';
32
- export { retry, withTimeout, shouldRetry, getBackoffDelay, } from './resilience.js';
48
+ export { retry, withTimeout, shouldRetry, deriveBackoffDelay, } from './resilience.js';
33
49
  export type { RetryOptions } from './resilience.js';
34
- export { brand, unbrand, uuid, email, nonEmptyString, positiveInt, shortId, hashId, } from './branded.js';
50
+ export { brand, unbrand, uuid, email, nonEmptyString, positiveInt, shortId, deriveIdHash, } from './branded.js';
35
51
  export type { Branded, UUID, Email, NonEmptyString, PositiveInt, } from './branded.js';
36
- export { securePath, isPathSafe, resolveSafePath } from './path-security.js';
37
- export { findWorkspaceRoot, isInsideWorkspace, getRelativePath, } from './workspace.js';
52
+ export { securePath, isPathSafe, deriveSafePath } from './path-security.js';
53
+ export { findWorkspaceRoot, isInsideWorkspace, deriveRelativePath, } from './workspace.js';
38
54
  export { createBlobRef, isBlobRef } from './blob-ref.js';
39
55
  export type { BlobRef } from './blob-ref.js';
40
56
  export { isDefined, isNonEmptyString, isPlainObject, hasProperty, assertNever, } from './guards.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EACL,WAAW,EACX,eAAe,EACf,cAAc,EACd,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,aAAa,EACb,SAAS,EACT,cAAc,EACd,WAAW,EACX,aAAa,EACb,cAAc,EACd,YAAY,EACZ,WAAW,EACX,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,YAAY,EACV,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,MAAM,EACN,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,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AU,GACX,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EACL,WAAW,EACX,eAAe,EACf,cAAc,EACd,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,aAAa,EACb,SAAS,EACT,cAAc,EACd,eAAe,EACf,eAAe,EACf,WAAW,EACX,aAAa,EACb,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,GACf,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,aAAa,GACd,MAAM,0BAA0B,CAAC;AAGlC,YAAY,EACV,MAAM,EACN,aAAa,EACb,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,OAAO,EACP,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,MAAM,EACN,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGpE,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,UAAU,EACV,QAAQ,GACT,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,WAAW,EACX,QAAQ,EACR,eAAe,EACf,mBAAmB,EACnB,YAAY,GACb,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAA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,EACf,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG1D,OAAO,EACL,KAAK,EACL,WAAW,EACX,WAAW,EACX,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAKpD,OAAO,EACL,KAAK,EACL,OAAO,EACP,IAAI,EACJ,KAAK,EACL,cAAc,EACd,WAAW,EACX,OAAO,EACP,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,OAAO,EACP,IAAI,EACJ,KAAK,EACL,cAAc,EACd,WAAW,GACZ,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAG5E,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACzD,YAAY,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,WAAW,GACZ,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,KAAK,EACL,MAAM,EACN,OAAO,EACP,MAAM,EACN,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,aAAa,EACb,WAAW,EACX,QAAQ,EACR,UAAU,GACX,MAAM,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -1,43 +1,57 @@
1
1
  // Result
2
2
  export { Result } from './result.js';
3
3
  // Errors
4
- export { TrailsError, ValidationError, AmbiguousError, AssertionError, NotFoundError, AlreadyExistsError, ConflictError, PermissionError, TimeoutError, RateLimitError, NetworkError, InternalError, AuthError, CancelledError, exitCodeMap, statusCodeMap, jsonRpcCodeMap, retryableMap, isRetryable, isTrailsError, } from './errors.js';
4
+ export { TrailsError, ValidationError, AmbiguousError, AssertionError, NotFoundError, AlreadyExistsError, ConflictError, PermissionError, TimeoutError, RateLimitError, NetworkError, InternalError, AuthError, CancelledError, DerivationError, errorCategories, exitCodeMap, statusCodeMap, jsonRpcCodeMap, retryableMap, RetryExhaustedError, isRetryable, isTrailsError, } from './errors.js';
5
+ export { createTransportErrorMapper, mapTransportError, transportErrorMap, transportErrorRegistry, transportNames, } from './transport-error-map.js';
5
6
  export { TRAILHEAD_KEY } from './types.js';
6
7
  // Context factory
7
- export { createTrailContext } from './context.js';
8
- // Provision
9
- export { createProvisionLookup, findDuplicateProvisionId, isProvision, provision, } from './provision.js';
8
+ export { createTrailContext, passthroughTrace } from './context.js';
9
+ // Resource
10
+ export { createResourceLookup, findDuplicateResourceId, isResource, resource, } from './resource.js';
10
11
  // Trail
11
12
  export { trail } from './trail.js';
13
+ export { filterSurfaceTrails, matchesTrailPattern, shouldIncludeTrailForSurface, } from './surface-filter.js';
12
14
  export { inputOf, outputOf } from './type-utils.js';
13
15
  // Signal
14
16
  export { signal } from './signal.js';
15
- export { event } from './event.js';
17
+ // Contour
18
+ export { contour } from './contour.js';
19
+ export { CONTOUR_ID_METADATA, getContourIdMetadata, getContourReferences, } from './contour.js';
16
20
  // Topo
17
21
  export { topo } from './topo.js';
22
+ export { createTopoSnapshot, createMockTopoStore, createTopoStore, listTopoSnapshots, pinTopoSnapshot, topoStore, unpinTopoSnapshot, } from './topo-store.js';
23
+ // Draft state
24
+ export { DRAFT_ID_PREFIX, deriveDraftReport, isDraftId, validateDraftFreeTopo, } from './draft.js';
18
25
  // Topo validation
19
26
  export { validateTopo } from './validate-topo.js';
20
- // Gate
21
- export { composeGates } from './gate.js';
27
+ export { validateEstablishedTopo } from './validate-established-topo.js';
28
+ // Layer
29
+ export { composeLayers } from './layer.js';
22
30
  // Derive
23
- export { deriveFields } from './derive.js';
31
+ export { deriveCliPath, deriveFields } from './derive.js';
32
+ // Cross schema
33
+ export { buildCrossValidationSchema } from './cross-schema.js';
24
34
  // Execute
25
35
  export { executeTrail } from './execute.js';
36
+ // Intrinsic tracing
37
+ export { clearTraceSink, createTraceRecord, getTraceContext, getTraceSink, NOOP_SINK, registerTraceSink, TRACE_CONTEXT_KEY, } from './internal/tracing.js';
26
38
  // Run
27
39
  export { run } from './run.js';
40
+ // Trail factories
41
+ export { deriveTrail, ingest } from './trails/index.js';
28
42
  // Validation
29
43
  export { validateInput, validateOutput, formatZodIssues, zodToJsonSchema, } from './validation.js';
30
44
  // Serialization
31
45
  export { serializeError, deserializeError } from './serialization.js';
32
46
  // Resilience
33
- export { retry, withTimeout, shouldRetry, getBackoffDelay, } from './resilience.js';
47
+ export { retry, withTimeout, shouldRetry, deriveBackoffDelay, } from './resilience.js';
34
48
  // Fetch — fromFetch is available as Result.fromFetch()
35
49
  // Branded types
36
- export { brand, unbrand, uuid, email, nonEmptyString, positiveInt, shortId, hashId, } from './branded.js';
50
+ export { brand, unbrand, uuid, email, nonEmptyString, positiveInt, shortId, deriveIdHash, } from './branded.js';
37
51
  // Path Security
38
- export { securePath, isPathSafe, resolveSafePath } from './path-security.js';
52
+ export { securePath, isPathSafe, deriveSafePath } from './path-security.js';
39
53
  // Workspace
40
- export { findWorkspaceRoot, isInsideWorkspace, getRelativePath, } from './workspace.js';
54
+ export { findWorkspaceRoot, isInsideWorkspace, deriveRelativePath, } from './workspace.js';
41
55
  // Blob
42
56
  export { createBlobRef, isBlobRef } from './blob-ref.js';
43
57
  // Guards
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,SAAS;AACT,OAAO,EACL,WAAW,EACX,eAAe,EACf,cAAc,EACd,cAAc,EACd,aAAa,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X,WAAW,EACX,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAGzB,uDAAuD;AAEvD,gBAAgB;AAChB,OAAO,EACL,KAAK,EACL,OAAO,EACP,IAAI,EACJ,KAAK,EACL,cAAc,EACd,WAAW,EACX,OAAO,EACP,MAAM,GACP,MAAM,cAAc,CAAC;AAStB,gBAAgB;AAChB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE7E,YAAY;AACZ,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAExB,OAAO;AACP,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGzD,SAAS;AACT,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,cAAc;AACd,OAAO,EACL,KAAK,EACL,MAAM,EACN,OAAO,EACP,MAAM,EACN,eAAe,GAChB,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,SAAS;AACT,OAAO,EACL,WAAW,EACX,eAAe,EACf,cAAc,EACd,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,aAAa,EACb,SAAS,EACT,cAAc,EACd,eAAe,EACf,eAAe,EACf,WAAW,EACX,aAAa,EACb,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,GACf,MAAM,0BAA0B,CAAC;AAyBlC,OAAO,EAAE,aAAa,EAAE,MAA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+ * Shared helpers for `ctx.cross([...])` batch execution.
3
+ *
4
+ * These helpers normalize batch options, produce validation results, and
5
+ * implement the unlimited/limited worker-pool execution strategies used by
6
+ * both the real executor (`packages/core/src/execute.ts`) and the scenario
7
+ * runner in `@ontrails/testing`. Extracting them here keeps the validation
8
+ * rule, error message, and worker-pool semantics authored in one place so
9
+ * the two call sites cannot drift.
10
+ *
11
+ * @internal
12
+ */
13
+ import { Result } from '../result.js';
14
+ import type { CrossBatchOptions } from '../types.js';
15
+ /**
16
+ * Validate the `concurrency` option on a batch `ctx.cross()` call.
17
+ *
18
+ * Returns `Ok(undefined)` when no limit is requested, `Ok(n)` when a
19
+ * positive integer is supplied, and `Err(ValidationError)` for any other
20
+ * value. The error message is load-bearing: callers and tests depend on
21
+ * the exact string.
22
+ *
23
+ * @internal
24
+ */
25
+ export declare const normalizeCrossBatchConcurrency: (options: CrossBatchOptions | undefined) => Result<number | undefined, Error>;
26
+ /**
27
+ * Produce one validation-error result per call, preserving the original
28
+ * call order. Used when `normalizeCrossBatchConcurrency` fails so the caller
29
+ * can surface a uniform batch shape to the trail implementation.
30
+ *
31
+ * @internal
32
+ */
33
+ export declare const createCrossBatchValidationResults: <TCall>(calls: readonly TCall[], error: Error) => Result<unknown, Error>[];
34
+ /**
35
+ * Claim the next branch index from a shared counter. Safe to call from
36
+ * multiple worker coroutines because JavaScript is single-threaded between
37
+ * awaits — the read/increment pair runs without interleaving.
38
+ *
39
+ * @internal
40
+ */
41
+ export declare const claimNextCrossBatchIndex: <TCall>(nextIndex: {
42
+ value: number;
43
+ }, calls: readonly TCall[]) => number | undefined;
44
+ //# sourceMappingURL=cross-batch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cross-batch.d.ts","sourceRoot":"","sources":["../../src/internal/cross-batch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD;;;;;;;;;GASG;AACH,eAAO,MAAM,8BAA8B,GACzC,SAAS,iBAAiB,GAAG,SAAS,KACrC,MAAM,CAAC,MAAM,GAAG,SAAS,EAAE,KAAK,CAelC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,GAAI,KAAK,EACrD,OAAO,SAAS,KAAK,EAAE,EACvB,OAAO,KAAK,KACX,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,EAAwC,CAAC;AAElE;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GAAI,KAAK,EAC5C,WAAW;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EAC5B,OAAO,SAAS,KAAK,EAAE,KACtB,MAAM,GAAG,SAQX,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Shared helpers for `ctx.cross([...])` batch execution.
3
+ *
4
+ * These helpers normalize batch options, produce validation results, and
5
+ * implement the unlimited/limited worker-pool execution strategies used by
6
+ * both the real executor (`packages/core/src/execute.ts`) and the scenario
7
+ * runner in `@ontrails/testing`. Extracting them here keeps the validation
8
+ * rule, error message, and worker-pool semantics authored in one place so
9
+ * the two call sites cannot drift.
10
+ *
11
+ * @internal
12
+ */
13
+ import { ValidationError } from '../errors.js';
14
+ import { Result } from '../result.js';
15
+ /**
16
+ * Validate the `concurrency` option on a batch `ctx.cross()` call.
17
+ *
18
+ * Returns `Ok(undefined)` when no limit is requested, `Ok(n)` when a
19
+ * positive integer is supplied, and `Err(ValidationError)` for any other
20
+ * value. The error message is load-bearing: callers and tests depend on
21
+ * the exact string.
22
+ *
23
+ * @internal
24
+ */
25
+ export const normalizeCrossBatchConcurrency = (options) => {
26
+ const concurrency = options?.concurrency;
27
+ if (concurrency === undefined) {
28
+ return Result.ok();
29
+ }
30
+ if (!Number.isInteger(concurrency) || concurrency < 1) {
31
+ return Result.err(new ValidationError('ctx.cross() batch concurrency must be a positive integer'));
32
+ }
33
+ return Result.ok(concurrency);
34
+ };
35
+ /**
36
+ * Produce one validation-error result per call, preserving the original
37
+ * call order. Used when `normalizeCrossBatchConcurrency` fails so the caller
38
+ * can surface a uniform batch shape to the trail implementation.
39
+ *
40
+ * @internal
41
+ */
42
+ export const createCrossBatchValidationResults = (calls, error) => calls.map(() => Result.err(error));
43
+ /**
44
+ * Claim the next branch index from a shared counter. Safe to call from
45
+ * multiple worker coroutines because JavaScript is single-threaded between
46
+ * awaits — the read/increment pair runs without interleaving.
47
+ *
48
+ * @internal
49
+ */
50
+ export const claimNextCrossBatchIndex = (nextIndex, calls) => {
51
+ if (nextIndex.value >= calls.length) {
52
+ return undefined;
53
+ }
54
+ const branchIndex = nextIndex.value;
55
+ nextIndex.value += 1;
56
+ return branchIndex;
57
+ };
58
+ //# sourceMappingURL=cross-batch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cross-batch.js","sourceRoot":"","sources":["../../src/internal/cross-batch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,OAAsC,EACH,EAAE;IACrC,MAAM,WAAW,GAAG,OAAO,EAAE,WAAW,CAAC;IACzC,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,EAAE,EAAE,CAAC;IACrB,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;QACtD,OAAO,MAAM,CAAC,GAAG,CACf,IAAI,eAAe,CACjB,0DAA0D,CAC3D,CACF,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAC/C,KAAuB,EACvB,KAAY,EACc,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAElE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,SAA4B,EAC5B,KAAuB,EACH,EAAE;IACtB,IAAI,SAAS,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QACpC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,WAAW,GAAG,SAAS,CAAC,KAAK,CAAC;IACpC,SAAS,CAAC,KAAK,IAAI,CAAC,CAAC;IACrB,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Internal helper for "forking" a trail context.
3
+ *
4
+ * Several execution sites need to derive a child context from a parent
5
+ * context while **resetting** a well-known set of bound closures (`cross`,
6
+ * `fire`, `resource`). Those closures capture the parent scope, so reusing
7
+ * them on the child would re-enter execution with the wrong attribution,
8
+ * the wrong resource scope, or the wrong fan-out identity. The reset list
9
+ * is the same at every fork site.
10
+ *
11
+ * Codifying the reset list in one helper keeps that contract in a single
12
+ * place. Callers supply the overrides they need (typically `env`,
13
+ * `extensions`, and `logger`) and let the helper handle the reset.
14
+ *
15
+ * This module is internal — do not export it from the package entry point.
16
+ *
17
+ * @remarks
18
+ * The helper is intentionally generic over the concrete context shape. Some
19
+ * callers work with the fully-resolved `TrailContext` produced inside the
20
+ * executor; others work with `Partial<TrailContextInit>` during consumer
21
+ * context derivation in `fire.ts`. Both shapes share the same reset keys.
22
+ */
23
+ import type { TrailContext, TrailContextInit } from '../types.js';
24
+ /** Keys cleared by default when forking a context. */
25
+ export type ForkCtxResetKey = 'cross' | 'fire' | 'resource';
26
+ /** Override fields callers are allowed to apply when forking a context. */
27
+ export type ForkCtxOverrides = Readonly<Partial<Pick<TrailContext, 'env' | 'extensions' | 'logger'>>>;
28
+ /**
29
+ * Fork a parent context into a child context.
30
+ *
31
+ * Spreads the parent, clears each reset key to `undefined`, and applies the
32
+ * supplied overrides last so callers may replace logger, env, and extensions
33
+ * with branch-local values.
34
+ *
35
+ * The generic parameter is constrained to the minimal shape the helper
36
+ * reads and writes. This lets the helper serve both `TrailContext`
37
+ * (executor scope) and `Partial<TrailContextInit>` (fire-consumer scope)
38
+ * without widening the public surface of either type.
39
+ */
40
+ export declare const forkCtx: <TCtx extends Partial<Pick<TrailContextInit, "cross" | "env" | "extensions" | "fire" | "logger" | "resource">>>(parentCtx: TCtx, overrides?: ForkCtxOverrides, reset?: readonly ForkCtxResetKey[]) => TCtx;
41
+ //# sourceMappingURL=fork-ctx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fork-ctx.d.ts","sourceRoot":"","sources":["../../src/internal/fork-ctx.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAElE,sDAAsD;AACtD,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,CAAC;AAE5D,2EAA2E;AAC3E,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CACrC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,GAAG,YAAY,GAAG,QAAQ,CAAC,CAAC,CAC7D,CAAC;AAQF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,OAAO,GAClB,IAAI,SAAS,OAAO,CAClB,IAAI,CACF,gBAAgB,EAChB,OAAO,GAAG,KAAK,GAAG,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,CAChE,CACF,EAED,WAAW,IAAI,EACf,YAAW,gBAAqB,EAChC,QAAO,SAAS,eAAe,EAAuB,KACrD,IAMF,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Internal helper for "forking" a trail context.
3
+ *
4
+ * Several execution sites need to derive a child context from a parent
5
+ * context while **resetting** a well-known set of bound closures (`cross`,
6
+ * `fire`, `resource`). Those closures capture the parent scope, so reusing
7
+ * them on the child would re-enter execution with the wrong attribution,
8
+ * the wrong resource scope, or the wrong fan-out identity. The reset list
9
+ * is the same at every fork site.
10
+ *
11
+ * Codifying the reset list in one helper keeps that contract in a single
12
+ * place. Callers supply the overrides they need (typically `env`,
13
+ * `extensions`, and `logger`) and let the helper handle the reset.
14
+ *
15
+ * This module is internal — do not export it from the package entry point.
16
+ *
17
+ * @remarks
18
+ * The helper is intentionally generic over the concrete context shape. Some
19
+ * callers work with the fully-resolved `TrailContext` produced inside the
20
+ * executor; others work with `Partial<TrailContextInit>` during consumer
21
+ * context derivation in `fire.ts`. Both shapes share the same reset keys.
22
+ */
23
+ const DEFAULT_RESET_KEYS = [
24
+ 'cross',
25
+ 'fire',
26
+ 'resource',
27
+ ];
28
+ /**
29
+ * Fork a parent context into a child context.
30
+ *
31
+ * Spreads the parent, clears each reset key to `undefined`, and applies the
32
+ * supplied overrides last so callers may replace logger, env, and extensions
33
+ * with branch-local values.
34
+ *
35
+ * The generic parameter is constrained to the minimal shape the helper
36
+ * reads and writes. This lets the helper serve both `TrailContext`
37
+ * (executor scope) and `Partial<TrailContextInit>` (fire-consumer scope)
38
+ * without widening the public surface of either type.
39
+ */
40
+ export const forkCtx = (parentCtx, overrides = {}, reset = DEFAULT_RESET_KEYS) => {
41
+ const forked = { ...parentCtx };
42
+ for (const key of reset) {
43
+ forked[key] = undefined;
44
+ }
45
+ return { ...forked, ...overrides };
46
+ };
47
+ //# sourceMappingURL=fork-ctx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fork-ctx.js","sourceRoot":"","sources":["../../src/internal/fork-ctx.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAYH,MAAM,kBAAkB,GAA+B;IACrD,OAAO;IACP,MAAM;IACN,UAAU;CACX,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAQrB,SAAe,EACf,YAA8B,EAAE,EAChC,QAAoC,kBAAkB,EAChD,EAAE;IACR,MAAM,MAAM,GAAS,EAAE,GAAG,SAAS,EAAE,CAAC;IACtC,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,MAAM,CAAC,GAAiB,CAAC,GAAG,SAA6B,CAAC;IAC5D,CAAC;IACD,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,SAAS,EAAE,CAAC;AACrC,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { AnySignal, Signal } from '../signal.js';
2
+ export interface LateBoundSignalRef {
3
+ readonly kind: 'store-derived';
4
+ readonly token: string;
5
+ }
6
+ export interface LateBoundSignalMarker {
7
+ readonly displayId: string;
8
+ readonly token: string;
9
+ }
10
+ export declare const getLateBoundSignalRef: (signal: Pick<AnySignal, "id"> | undefined) => LateBoundSignalRef | undefined;
11
+ export declare const attachLateBoundSignalRef: <T>(signal: Signal<T>, ref: LateBoundSignalRef) => Signal<T>;
12
+ export declare const cloneSignalWithId: <T>(signal: Signal<T>, id: string) => Signal<T>;
13
+ export declare const createLateBoundSignalMarker: (ref: LateBoundSignalRef, displayId: string) => string;
14
+ export declare const parseLateBoundSignalMarker: (value: string) => LateBoundSignalMarker | null;
15
+ //# sourceMappingURL=signal-ref.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signal-ref.d.ts","sourceRoot":"","sources":["../../src/internal/signal-ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAkBD,eAAO,MAAM,qBAAqB,GAChC,QAAQ,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,SAAS,KACxC,kBAAkB,GAAG,SAKJ,CAAC;AAErB,eAAO,MAAM,wBAAwB,GAAI,CAAC,EACxC,QAAQ,MAAM,CAAC,CAAC,CAAC,EACjB,KAAK,kBAAkB,KACtB,MAAM,CAAC,CAAC,CAQK,CAAC;AAEjB,eAAO,MAAM,iBAAiB,GAAI,CAAC,EACjC,QAAQ,MAAM,CAAC,CAAC,CAAC,EACjB,IAAI,MAAM,KACT,MAAM,CAAC,CAAC,CASV,CAAC;AAEF,eAAO,MAAM,2BAA2B,GACtC,KAAK,kBAAkB,EACvB,WAAW,MAAM,KAChB,MAAuE,CAAC;AAE3E,eAAO,MAAM,0BAA0B,GACrC,OAAO,MAAM,KACZ,qBAAqB,GAAG,IAe1B,CAAC"}