@ontrails/core 1.0.0-beta.3 → 1.0.0-beta.30

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 (245) hide show
  1. package/CHANGELOG.md +305 -8
  2. package/README.md +114 -33
  3. package/package.json +11 -1
  4. package/src/activation-provenance.ts +111 -0
  5. package/src/activation-source-compatibility.ts +430 -0
  6. package/src/activation-source-projection.ts +221 -0
  7. package/src/activation-source.ts +91 -0
  8. package/src/blob-ref.ts +51 -0
  9. package/src/branded.ts +1 -1
  10. package/src/compose-batch.ts +69 -0
  11. package/src/compose-schema.ts +36 -0
  12. package/src/context.ts +44 -10
  13. package/src/contour.ts +346 -0
  14. package/src/derive.ts +241 -16
  15. package/src/detours.ts +8 -0
  16. package/src/draft.ts +342 -0
  17. package/src/error-projection.ts +51 -0
  18. package/src/errors.ts +335 -48
  19. package/src/execute.ts +1577 -0
  20. package/src/fire.ts +1169 -0
  21. package/src/index.ts +495 -34
  22. package/src/internal/fork-ctx.ts +69 -0
  23. package/src/layer-projection.ts +193 -0
  24. package/src/layer.ts +43 -6
  25. package/src/observe.ts +361 -0
  26. package/src/path-security.ts +1 -1
  27. package/src/permits.ts +12 -0
  28. package/src/redaction/patterns.ts +6 -3
  29. package/src/resilience.ts +11 -11
  30. package/src/resource-config.ts +792 -0
  31. package/src/resource.ts +194 -0
  32. package/src/result.ts +18 -0
  33. package/src/run.ts +76 -0
  34. package/src/schedule-runtime.ts +689 -0
  35. package/src/schedule.ts +326 -0
  36. package/src/serialization.ts +92 -55
  37. package/src/signal-diagnostics.ts +633 -0
  38. package/src/signal-ref.ts +87 -0
  39. package/src/signal.ts +104 -0
  40. package/src/store/accessor-protocol.ts +56 -0
  41. package/src/store/index.ts +4 -0
  42. package/src/structured-examples.ts +248 -0
  43. package/src/surface-derivation.ts +91 -0
  44. package/src/surface-filter.ts +176 -0
  45. package/src/surface-versioning.ts +42 -0
  46. package/src/topo.ts +769 -67
  47. package/src/tracing.ts +345 -0
  48. package/src/trail.ts +1168 -30
  49. package/src/trails/derive-trail.ts +842 -0
  50. package/src/trails/index.ts +9 -0
  51. package/src/trails/ingest.ts +139 -0
  52. package/src/trails-db.ts +206 -0
  53. package/src/transport-error-map.ts +174 -0
  54. package/src/type-utils.ts +87 -0
  55. package/src/types.ts +254 -12
  56. package/src/validate-established-topo.ts +69 -0
  57. package/src/validate-topo.ts +393 -45
  58. package/src/validation.ts +152 -4
  59. package/src/version-marker.ts +716 -0
  60. package/src/version-resolution.ts +308 -0
  61. package/src/version-runtime.ts +120 -0
  62. package/src/webhook.ts +278 -0
  63. package/src/workspace.ts +1 -1
  64. package/src/zod-wrappers.ts +72 -0
  65. package/.turbo/turbo-build.log +0 -1
  66. package/.turbo/turbo-lint.log +0 -3
  67. package/.turbo/turbo-typecheck.log +0 -1
  68. package/dist/adapters.d.ts +0 -39
  69. package/dist/adapters.d.ts.map +0 -1
  70. package/dist/adapters.js +0 -2
  71. package/dist/adapters.js.map +0 -1
  72. package/dist/blob-ref.d.ts +0 -20
  73. package/dist/blob-ref.d.ts.map +0 -1
  74. package/dist/blob-ref.js +0 -22
  75. package/dist/blob-ref.js.map +0 -1
  76. package/dist/branded.d.ts +0 -36
  77. package/dist/branded.d.ts.map +0 -1
  78. package/dist/branded.js +0 -89
  79. package/dist/branded.js.map +0 -1
  80. package/dist/collections.d.ts +0 -31
  81. package/dist/collections.d.ts.map +0 -1
  82. package/dist/collections.js +0 -60
  83. package/dist/collections.js.map +0 -1
  84. package/dist/context.d.ts +0 -10
  85. package/dist/context.d.ts.map +0 -1
  86. package/dist/context.js +0 -15
  87. package/dist/context.js.map +0 -1
  88. package/dist/derive.d.ts +0 -33
  89. package/dist/derive.d.ts.map +0 -1
  90. package/dist/derive.js +0 -125
  91. package/dist/derive.js.map +0 -1
  92. package/dist/errors.d.ts +0 -83
  93. package/dist/errors.d.ts.map +0 -1
  94. package/dist/errors.js +0 -142
  95. package/dist/errors.js.map +0 -1
  96. package/dist/event.d.ts +0 -45
  97. package/dist/event.d.ts.map +0 -1
  98. package/dist/event.js +0 -17
  99. package/dist/event.js.map +0 -1
  100. package/dist/fetch.d.ts +0 -15
  101. package/dist/fetch.d.ts.map +0 -1
  102. package/dist/fetch.js +0 -102
  103. package/dist/fetch.js.map +0 -1
  104. package/dist/guards.d.ts +0 -17
  105. package/dist/guards.d.ts.map +0 -1
  106. package/dist/guards.js +0 -25
  107. package/dist/guards.js.map +0 -1
  108. package/dist/health.d.ts +0 -18
  109. package/dist/health.d.ts.map +0 -1
  110. package/dist/health.js +0 -5
  111. package/dist/health.js.map +0 -1
  112. package/dist/hike.d.ts +0 -36
  113. package/dist/hike.d.ts.map +0 -1
  114. package/dist/hike.js +0 -20
  115. package/dist/hike.js.map +0 -1
  116. package/dist/index.d.ts +0 -36
  117. package/dist/index.d.ts.map +0 -1
  118. package/dist/index.js +0 -40
  119. package/dist/index.js.map +0 -1
  120. package/dist/job.d.ts +0 -24
  121. package/dist/job.d.ts.map +0 -1
  122. package/dist/job.js +0 -17
  123. package/dist/job.js.map +0 -1
  124. package/dist/layer.d.ts +0 -17
  125. package/dist/layer.d.ts.map +0 -1
  126. package/dist/layer.js +0 -21
  127. package/dist/layer.js.map +0 -1
  128. package/dist/path-security.d.ts +0 -28
  129. package/dist/path-security.d.ts.map +0 -1
  130. package/dist/path-security.js +0 -63
  131. package/dist/path-security.js.map +0 -1
  132. package/dist/patterns/bulk.d.ts +0 -15
  133. package/dist/patterns/bulk.d.ts.map +0 -1
  134. package/dist/patterns/bulk.js +0 -14
  135. package/dist/patterns/bulk.js.map +0 -1
  136. package/dist/patterns/change.d.ts +0 -10
  137. package/dist/patterns/change.d.ts.map +0 -1
  138. package/dist/patterns/change.js +0 -10
  139. package/dist/patterns/change.js.map +0 -1
  140. package/dist/patterns/date-range.d.ts +0 -10
  141. package/dist/patterns/date-range.d.ts.map +0 -1
  142. package/dist/patterns/date-range.js +0 -10
  143. package/dist/patterns/date-range.js.map +0 -1
  144. package/dist/patterns/index.d.ts +0 -9
  145. package/dist/patterns/index.d.ts.map +0 -1
  146. package/dist/patterns/index.js +0 -9
  147. package/dist/patterns/index.js.map +0 -1
  148. package/dist/patterns/pagination.d.ts +0 -18
  149. package/dist/patterns/pagination.d.ts.map +0 -1
  150. package/dist/patterns/pagination.js +0 -18
  151. package/dist/patterns/pagination.js.map +0 -1
  152. package/dist/patterns/progress.d.ts +0 -11
  153. package/dist/patterns/progress.d.ts.map +0 -1
  154. package/dist/patterns/progress.js +0 -11
  155. package/dist/patterns/progress.js.map +0 -1
  156. package/dist/patterns/sorting.d.ts +0 -13
  157. package/dist/patterns/sorting.d.ts.map +0 -1
  158. package/dist/patterns/sorting.js +0 -10
  159. package/dist/patterns/sorting.js.map +0 -1
  160. package/dist/patterns/status.d.ts +0 -15
  161. package/dist/patterns/status.d.ts.map +0 -1
  162. package/dist/patterns/status.js +0 -9
  163. package/dist/patterns/status.js.map +0 -1
  164. package/dist/patterns/timestamps.d.ts +0 -10
  165. package/dist/patterns/timestamps.d.ts.map +0 -1
  166. package/dist/patterns/timestamps.js +0 -10
  167. package/dist/patterns/timestamps.js.map +0 -1
  168. package/dist/redaction/index.d.ts +0 -4
  169. package/dist/redaction/index.d.ts.map +0 -1
  170. package/dist/redaction/index.js +0 -3
  171. package/dist/redaction/index.js.map +0 -1
  172. package/dist/redaction/patterns.d.ts +0 -9
  173. package/dist/redaction/patterns.d.ts.map +0 -1
  174. package/dist/redaction/patterns.js +0 -39
  175. package/dist/redaction/patterns.js.map +0 -1
  176. package/dist/redaction/redactor.d.ts +0 -27
  177. package/dist/redaction/redactor.d.ts.map +0 -1
  178. package/dist/redaction/redactor.js +0 -89
  179. package/dist/redaction/redactor.js.map +0 -1
  180. package/dist/resilience.d.ts +0 -34
  181. package/dist/resilience.d.ts.map +0 -1
  182. package/dist/resilience.js +0 -164
  183. package/dist/resilience.js.map +0 -1
  184. package/dist/result.d.ts +0 -57
  185. package/dist/result.d.ts.map +0 -1
  186. package/dist/result.js +0 -156
  187. package/dist/result.js.map +0 -1
  188. package/dist/serialization.d.ts +0 -27
  189. package/dist/serialization.d.ts.map +0 -1
  190. package/dist/serialization.js +0 -153
  191. package/dist/serialization.js.map +0 -1
  192. package/dist/topo.d.ts +0 -18
  193. package/dist/topo.d.ts.map +0 -1
  194. package/dist/topo.js +0 -80
  195. package/dist/topo.js.map +0 -1
  196. package/dist/trail.d.ts +0 -83
  197. package/dist/trail.d.ts.map +0 -1
  198. package/dist/trail.js +0 -16
  199. package/dist/trail.js.map +0 -1
  200. package/dist/types.d.ts +0 -46
  201. package/dist/types.d.ts.map +0 -1
  202. package/dist/types.js +0 -2
  203. package/dist/types.js.map +0 -1
  204. package/dist/validate-topo.d.ts +0 -24
  205. package/dist/validate-topo.d.ts.map +0 -1
  206. package/dist/validate-topo.js +0 -156
  207. package/dist/validate-topo.js.map +0 -1
  208. package/dist/validation.d.ts +0 -27
  209. package/dist/validation.d.ts.map +0 -1
  210. package/dist/validation.js +0 -134
  211. package/dist/validation.js.map +0 -1
  212. package/dist/workspace.d.ts +0 -25
  213. package/dist/workspace.d.ts.map +0 -1
  214. package/dist/workspace.js +0 -57
  215. package/dist/workspace.js.map +0 -1
  216. package/src/__tests__/blob-ref.test.ts +0 -103
  217. package/src/__tests__/branded.test.ts +0 -148
  218. package/src/__tests__/collections.test.ts +0 -126
  219. package/src/__tests__/context.test.ts +0 -66
  220. package/src/__tests__/derive.test.ts +0 -203
  221. package/src/__tests__/errors.test.ts +0 -309
  222. package/src/__tests__/event.test.ts +0 -82
  223. package/src/__tests__/fetch.test.ts +0 -217
  224. package/src/__tests__/guards.test.ts +0 -102
  225. package/src/__tests__/hike.test.ts +0 -117
  226. package/src/__tests__/job.test.ts +0 -98
  227. package/src/__tests__/layer.test.ts +0 -224
  228. package/src/__tests__/path-security.test.ts +0 -114
  229. package/src/__tests__/patterns.test.ts +0 -273
  230. package/src/__tests__/redaction.test.ts +0 -244
  231. package/src/__tests__/resilience.test.ts +0 -246
  232. package/src/__tests__/result.test.ts +0 -155
  233. package/src/__tests__/serialization.test.ts +0 -401
  234. package/src/__tests__/topo.test.ts +0 -220
  235. package/src/__tests__/trail.test.ts +0 -179
  236. package/src/__tests__/validate-topo.test.ts +0 -280
  237. package/src/__tests__/validation.test.ts +0 -283
  238. package/src/__tests__/workspace.test.ts +0 -183
  239. package/src/adapters.ts +0 -68
  240. package/src/event.ts +0 -77
  241. package/src/health.ts +0 -23
  242. package/src/hike.ts +0 -77
  243. package/src/job.ts +0 -20
  244. package/tsconfig.json +0 -9
  245. package/tsconfig.tsbuildinfo +0 -1
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  // Result
2
- export { Result } from './result.js';
2
+ export { Result, resultAccessorNames } from './result.js';
3
+ export type { ResultAccessorName } from './result.js';
3
4
 
4
5
  // Errors
5
6
  export {
@@ -8,78 +9,526 @@ export {
8
9
  AmbiguousError,
9
10
  AssertionError,
10
11
  NotFoundError,
12
+ VersionNotSupportedError,
11
13
  AlreadyExistsError,
12
14
  ConflictError,
13
15
  PermissionError,
16
+ PermitError,
14
17
  TimeoutError,
15
18
  RateLimitError,
16
19
  NetworkError,
20
+ WorkspaceShiftError,
17
21
  InternalError,
18
22
  AuthError,
19
23
  CancelledError,
24
+ DerivationError,
25
+ RecoverableCompletionError,
26
+ codesByCategory,
27
+ errorClasses,
28
+ errorCategories,
20
29
  exitCodeMap,
21
30
  statusCodeMap,
22
31
  jsonRpcCodeMap,
23
32
  retryableMap,
33
+ RetryExhaustedError,
24
34
  isRetryable,
25
35
  isTrailsError,
26
36
  } from './errors.js';
27
- export type { ErrorCategory } from './errors.js';
37
+ export type {
38
+ DynamicErrorClassRegistryEntry,
39
+ ErrorCategory,
40
+ ErrorCategoryCodes,
41
+ ErrorClassConstructor,
42
+ ErrorClassRegistryEntry,
43
+ FixedErrorClassRegistryEntry,
44
+ } from './errors.js';
45
+ export {
46
+ createSurfaceErrorMapper,
47
+ mapSurfaceError,
48
+ projectErrorClassSurface,
49
+ projectPublicSurfaceError,
50
+ projectSurfaceError,
51
+ surfaceErrorMap,
52
+ surfaceErrorRegistry,
53
+ surfaceNames,
54
+ } from './transport-error-map.js';
55
+ export type {
56
+ ErrorClassSurfaceProjection,
57
+ SurfaceErrorCode,
58
+ SurfaceErrorMapper,
59
+ SurfaceErrorMappings,
60
+ SurfaceErrorProjection,
61
+ SurfaceName,
62
+ } from './transport-error-map.js';
63
+ export {
64
+ INTERNAL_ERROR_PUBLIC_MESSAGE,
65
+ projectErrorDiagnostics,
66
+ redactErrorContext,
67
+ redactErrorStack,
68
+ redactErrorString,
69
+ } from './error-projection.js';
70
+ export type { ErrorDiagnosticsProjection } from './error-projection.js';
28
71
 
29
72
  // Types
30
73
  export type {
74
+ Detour,
75
+ DetourAttempt,
31
76
  Implementation,
32
77
  TrailContext,
33
- FollowFn,
78
+ TrailContextInit,
79
+ ComposeBatchOptions,
80
+ ComposeOptions,
81
+ ComposeFn,
82
+ FireFn,
83
+ LogLevel,
84
+ LogFormatter,
85
+ LogRecord,
86
+ LogSink,
87
+ PermitRequirement,
34
88
  ProgressCallback,
35
89
  ProgressEvent,
36
90
  Logger,
37
- Surface,
91
+ ResourceLookup,
92
+ } from './types.js';
93
+ export { basePermitSchema } from './permits.js';
94
+ export type { BasePermit } from './permits.js';
95
+ export {
96
+ LAYER_INPUTS_KEY,
97
+ SURFACE_KEY,
98
+ SURFACE_LAYER_NAMES_KEY,
38
99
  } from './types.js';
100
+ export {
101
+ ACTIVATION_PROVENANCE_KEY,
102
+ buildActivationProvenanceTraceAttrs,
103
+ getActivationProvenance,
104
+ withActivationProvenance,
105
+ } from './activation-provenance.js';
106
+ export type {
107
+ ActivationProvenance,
108
+ ActivationProvenanceCarrier,
109
+ ActivationProvenanceSource,
110
+ } from './activation-provenance.js';
39
111
 
40
112
  // Context factory
41
- export { createTrailContext } from './context.js';
113
+ export { createTrailContext, passthroughTrace } from './context.js';
114
+
115
+ // Resource
116
+ export {
117
+ createResourceLookup,
118
+ findDuplicateResourceId,
119
+ isResource,
120
+ resource,
121
+ } from './resource.js';
122
+ export { drainResources, resolveResourceConfig } from './resource-config.js';
123
+ export type {
124
+ ResourceConfigValues,
125
+ ResourceDrainReport,
126
+ } from './resource-config.js';
127
+ export type {
128
+ AnyResource,
129
+ Resource,
130
+ ResourceContext,
131
+ ResourceOverrideMap,
132
+ ResourceSpec,
133
+ ResourceUnmockable,
134
+ } from './resource.js';
42
135
 
43
136
  // Trail
44
- export { trail } from './trail.js';
45
- export type { AnyTrail, Trail, TrailSpec, TrailExample } from './trail.js';
137
+ export {
138
+ activationSourceKinds,
139
+ getActivationWherePredicate,
140
+ isActivationEntrySpec,
141
+ isActivationSource,
142
+ isKnownActivationSourceKind,
143
+ } from './activation-source.js';
144
+ export type {
145
+ ActivationEntry,
146
+ ActivationEntrySpec,
147
+ ActivationSource,
148
+ ActivationSourceKind,
149
+ ActivationSourceMeta,
150
+ ActivationSourceRef,
151
+ ActivationWhere,
152
+ ActivationWhereExample,
153
+ ActivationWherePredicate,
154
+ ActivationWhereSpec,
155
+ BuiltinActivationSourceKind,
156
+ } from './activation-source.js';
157
+ export {
158
+ activationSourceDeclarationSignature,
159
+ activationSourceKey,
160
+ projectActivationSourceDeclaration,
161
+ } from './activation-source-projection.js';
162
+ export type { ActivationSourceProjection } from './activation-source-projection.js';
163
+ export {
164
+ deriveSupportedTrailVersions,
165
+ getTrailVersionEntryKind,
166
+ hasDeprecatedTrailVersionGuidance,
167
+ intentValues,
168
+ isArchivedTrailVersionEntry,
169
+ isDeprecatedTrailVersionEntry,
170
+ isLiveTrailVersionEntry,
171
+ trail,
172
+ } from './trail.js';
173
+ export {
174
+ TRAIL_VERSION_MARKER_LENGTH,
175
+ TRAIL_VERSION_MARKER_MIN_PREFIX_LENGTH,
176
+ assertTrailVersionMarker,
177
+ assertUniqueTrailVersionMarkers,
178
+ canonicalizeTrailVersionMarkerContent,
179
+ deriveCurrentTrailVersionMarker,
180
+ deriveCurrentTrailVersionMarkerContent,
181
+ deriveShortestUnambiguousTrailVersionMarkerPrefix,
182
+ deriveTrailVersionEntryMarker,
183
+ deriveTrailVersionEntryMarkerContent,
184
+ deriveTrailVersionMarker,
185
+ deriveTrailVersionMarkers,
186
+ normalizeTrailVersionMarkerPrefix,
187
+ resolveTrailVersionMarkerPrefix,
188
+ } from './version-marker.js';
189
+ export {
190
+ parseTrailIdVersionReference,
191
+ resolveTrailVersion,
192
+ } from './version-resolution.js';
193
+ export type {
194
+ AnyTrail,
195
+ BlazeInput,
196
+ Intent,
197
+ Trail,
198
+ TrailVersionEntry,
199
+ TrailVersionEntryKind,
200
+ TrailVersionArchivedStatus,
201
+ TrailVersionDeprecatedStatus,
202
+ TrailVersionForkEntry,
203
+ TrailVersionRevisionEntry,
204
+ TrailVersions,
205
+ TrailVersionStatus,
206
+ TrailVersionTranspose,
207
+ TrailVersionTransposeInput,
208
+ TrailVersionTransposeOutput,
209
+ TrailSpec,
210
+ TrailExample,
211
+ TrailExampleSignalAssertion,
212
+ TrailVisibility,
213
+ VersionContract,
214
+ VersionEntry,
215
+ } from './trail.js';
216
+ export type {
217
+ TrailVersionMarkerBinding,
218
+ TrailVersionMarkerRecord,
219
+ TrailVersionMarkerResolution,
220
+ } from './version-marker.js';
221
+ export type {
222
+ ParsedTrailVersionReference,
223
+ ResolvedTrailVersion,
224
+ TrailVersionReference,
225
+ } from './version-resolution.js';
226
+ export {
227
+ filterSurfaceTrails,
228
+ matchesTrailPattern,
229
+ shouldIncludeTrailForSurface,
230
+ } from './surface-filter.js';
231
+ export type { SurfaceFilterOptions } from './surface-filter.js';
232
+ export { deriveSurfaceTrailVersionProjections } from './surface-versioning.js';
233
+ export type { SurfaceTrailVersionProjection } from './surface-versioning.js';
234
+ export {
235
+ shouldValidateSurfaceTopo,
236
+ validateSurfaceTopo,
237
+ withSurfaceLayerNames,
238
+ withSurfaceMarker,
239
+ } from './surface-derivation.js';
240
+ export type {
241
+ BaseSurfaceOptions,
242
+ SurfaceConfigValues,
243
+ SurfaceSelectionOptions,
244
+ SurfaceMarkedContext,
245
+ SurfaceValidationOptions,
246
+ } from './surface-derivation.js';
247
+ export {
248
+ deriveStructuredSignalExamples,
249
+ deriveStructuredTrailExamples,
250
+ } from './structured-examples.js';
251
+ export type {
252
+ StructuredSignalExample,
253
+ StructuredSignalExampleProvenance,
254
+ StructuredTrailExample,
255
+ StructuredTrailExampleKind,
256
+ StructuredTrailExampleProvenance,
257
+ StructuredTrailExampleSignalAssertion,
258
+ } from './structured-examples.js';
46
259
 
47
- // Hike
48
- export { hike } from './hike.js';
49
- export type { AnyHike, Hike, HikeSpec } from './hike.js';
260
+ // Type utilities
261
+ export type {
262
+ ComposeInput,
263
+ TrailInput,
264
+ TrailOutput,
265
+ TrailResult,
266
+ } from './type-utils.js';
267
+ export { inputOf, outputOf } from './type-utils.js';
268
+
269
+ // Signal
270
+ export { signal } from './signal.js';
271
+ export type { AnySignal, Signal, SignalSpec } from './signal.js';
272
+ export { schedule, validateScheduleSource } from './schedule.js';
273
+ export type {
274
+ ScheduleSource,
275
+ ScheduleSpec,
276
+ ScheduleValidationIssue,
277
+ } from './schedule.js';
278
+ export {
279
+ getWebhookHeader,
280
+ getWebhookHeaders,
281
+ validateWebhookSource,
282
+ verifyWebhookRequest,
283
+ webhook,
284
+ webhookMethods,
285
+ } from './webhook.js';
286
+ export type {
287
+ WebhookMethod,
288
+ WebhookMethodInput,
289
+ WebhookSource,
290
+ WebhookSpec,
291
+ WebhookValidationIssue,
292
+ WebhookVerify,
293
+ WebhookVerifyHeaders,
294
+ WebhookVerifyRequest,
295
+ } from './webhook.js';
296
+ export { createScheduleRuntime } from './schedule-runtime.js';
297
+ export type {
298
+ ScheduleCronFactory,
299
+ ScheduleCronHandler,
300
+ ScheduleCronJob,
301
+ ScheduleRuntime,
302
+ ScheduleRuntimeLogger,
303
+ ScheduleRuntimeOptions,
304
+ ScheduleRuntimeRegistrationReport,
305
+ ScheduleRuntimeRunRecord,
306
+ ScheduleRuntimeRunStatus,
307
+ ScheduleRuntimeSkipReason,
308
+ ScheduleRuntimeStartReport,
309
+ ScheduleRuntimeState,
310
+ ScheduleRuntimeStopReport,
311
+ ScheduleRuntimeWarning,
312
+ ScheduleRuntimeWarningCode,
313
+ } from './schedule-runtime.js';
314
+ export {
315
+ SIGNAL_DIAGNOSTICS_SINK_KEY,
316
+ SIGNAL_DIAGNOSTICS_STRICT_MODE_KEY,
317
+ createSignalFireSuppressedDiagnostic,
318
+ createSignalHandlerFailedDiagnostic,
319
+ createSignalHandlerRejectedDiagnostic,
320
+ createSignalInvalidDiagnostic,
321
+ createSignalPredicateFailedDiagnostic,
322
+ createSignalUnknownDiagnostic,
323
+ recordSignalDiagnostic,
324
+ shouldPromoteSignalDiagnostic,
325
+ signalDiagnosticDefinitions,
326
+ summarizeSignalPayload,
327
+ } from './signal-diagnostics.js';
328
+ export type {
329
+ CreateSignalFireSuppressedDiagnosticInput,
330
+ CreateSignalHandlerDiagnosticInput,
331
+ CreateSignalInvalidDiagnosticInput,
332
+ SignalDiagnostic,
333
+ SignalDiagnosticCategory,
334
+ SignalDiagnosticCause,
335
+ SignalDiagnosticCode,
336
+ SignalDiagnosticCommonInput,
337
+ SignalDiagnosticContext,
338
+ SignalDiagnosticLevel,
339
+ SignalDiagnosticPathSegment,
340
+ SignalDiagnosticRecordResult,
341
+ SignalDiagnosticSchemaIssue,
342
+ SignalDiagnosticSink,
343
+ SignalDiagnosticOrigin,
344
+ SignalDiagnosticSourceLocation,
345
+ SignalDiagnosticStrictMode,
346
+ SignalFireSuppressedDiagnostic,
347
+ SignalHandlerFailedDiagnostic,
348
+ SignalHandlerRejectedDiagnostic,
349
+ SignalInvalidDiagnostic,
350
+ SignalPredicateFailedDiagnostic,
351
+ SignalPayloadShape,
352
+ SignalPayloadSummary,
353
+ SignalUnknownDiagnostic,
354
+ } from './signal-diagnostics.js';
355
+ export {
356
+ attachLateBoundSignalRef,
357
+ cloneSignalWithId,
358
+ createLateBoundSignalMarker,
359
+ getLateBoundSignalRef,
360
+ parseLateBoundSignalMarker,
361
+ } from './signal-ref.js';
362
+ export type {
363
+ LateBoundSignalMarker,
364
+ LateBoundSignalRef,
365
+ } from './signal-ref.js';
50
366
 
51
- // Event
52
- export { event } from './event.js';
53
- export type { AnyEvent, Event, EventSpec } from './event.js';
367
+ // Contour
368
+ export { contour } from './contour.js';
369
+ export {
370
+ CONTOUR_ID_METADATA,
371
+ getContourIdMetadata,
372
+ getContourReferences,
373
+ } from './contour.js';
374
+ export type {
375
+ AnyContour,
376
+ Contour,
377
+ ContourIdBrand,
378
+ ContourIdMetadata,
379
+ ContourIdSchema,
380
+ ContourIdValue,
381
+ ContourOptions,
382
+ ContourReference,
383
+ } from './contour.js';
54
384
 
55
385
  // Topo
56
386
  export { topo } from './topo.js';
57
- export type { Topo } from './topo.js';
387
+ export type { Topo, TopoIdentity } from './topo.js';
388
+
389
+ // Generic trails-db helpers (shared framework infrastructure per ADR-0014).
390
+ // The topo-store public API that previously lived here moved to
391
+ // `@ontrails/topographer` per ADR-0042.
392
+ export {
393
+ deriveTrailsDbPath,
394
+ deriveTrailsDir,
395
+ deriveTrailsProjectKey,
396
+ deriveTrailsStateDir,
397
+ deriveTrailsStateHome,
398
+ ensureSubsystemSchema,
399
+ ensureTrailsWorkspace,
400
+ openReadTrailsDb,
401
+ openWriteTrailsDb,
402
+ WORKSPACE_GITIGNORE_CONTENT,
403
+ WORKSPACE_GITIGNORE_LINES,
404
+ } from './trails-db.js';
405
+ export type {
406
+ EnsureSubsystemSchemaOptions,
407
+ TrailsDbLocationOptions,
408
+ } from './trails-db.js';
409
+
410
+ // Draft state
411
+ export {
412
+ DRAFT_ID_PREFIX,
413
+ deriveDraftReport,
414
+ isDraftId,
415
+ validateDraftFreeTopo,
416
+ } from './draft.js';
417
+ export type {
418
+ DraftDependency,
419
+ DraftDependencyKind,
420
+ DraftFinding,
421
+ DraftReport,
422
+ } from './draft.js';
58
423
 
59
424
  // Topo validation
60
425
  export { validateTopo } from './validate-topo.js';
61
426
  export type { TopoIssue } from './validate-topo.js';
427
+ export { validateEstablishedTopo } from './validate-established-topo.js';
62
428
 
63
429
  // Layer
64
430
  export { composeLayers } from './layer.js';
65
- export type { Layer } from './layer.js';
431
+ export type { Layer, LayerInputSchema } from './layer.js';
432
+ export {
433
+ collectAttachedTypedLayers,
434
+ LAYER_FIELD_RESERVED_NAMES,
435
+ LAYER_FIELD_RESERVED_NAMES_KEBAB,
436
+ projectLayerFieldName,
437
+ } from './layer-projection.js';
438
+ export type {
439
+ AttachedLayerScope,
440
+ AttachedTypedLayer,
441
+ LayerFieldProjection,
442
+ LayerFieldRenameReason,
443
+ ProjectedLayerField,
444
+ RenamedLayerFieldProjection,
445
+ } from './layer-projection.js';
66
446
 
67
- // Health
68
- export type { HealthStatus, HealthResult } from './health.js';
447
+ // Derive
448
+ export {
449
+ deriveCliPath,
450
+ deriveFields,
451
+ deriveTrailCliCommandProjection,
452
+ normalizeCliCommandPath,
453
+ } from './derive.js';
454
+ export type {
455
+ CliCommandAliasInput,
456
+ CliCommandPathInput,
457
+ CliCommandRoute,
458
+ CliCommandRouteKind,
459
+ CliCommandRouteSource,
460
+ DeriveTrailCliCommandProjectionOptions,
461
+ Field,
462
+ FieldOverride,
463
+ TrailCliCommandProjection,
464
+ TrailCliProjection,
465
+ } from './derive.js';
466
+
467
+ // Compose schema
468
+ export { buildComposeValidationSchema } from './compose-schema.js';
469
+ export {
470
+ claimNextComposeBatchIndex,
471
+ createComposeBatchValidationResults,
472
+ normalizeComposeBatchConcurrency,
473
+ } from './compose-batch.js';
474
+
475
+ // Execute
476
+ export { DETOUR_MAX_ATTEMPTS_CAP } from './detours.js';
477
+ export { executeTrail } from './execute.js';
478
+ export type { ExecuteTrailOptions } from './execute.js';
69
479
 
70
- // Adapters
480
+ // Intrinsic tracing
481
+ export {
482
+ clearTraceSink,
483
+ createActivationTraceRecord,
484
+ createTraceRecord,
485
+ getTraceContext,
486
+ getTraceSink,
487
+ NOOP_SINK,
488
+ registerTraceSink,
489
+ TRACE_CONTEXT_KEY,
490
+ traceContextFromRecord,
491
+ writeActivationTraceRecord,
492
+ } from './tracing.js';
71
493
  export type {
72
- IndexAdapter,
73
- StorageAdapter,
74
- CacheAdapter,
75
- SearchOptions,
76
- SearchResult,
77
- StorageOptions,
78
- } from './adapters.js';
494
+ ActivationTraceRecordName,
495
+ SignalTraceRecordName,
496
+ TraceContext,
497
+ TraceRecord,
498
+ TraceSink,
499
+ } from './tracing.js';
500
+ export type { TraceFn } from './types.js';
79
501
 
80
- // Derive
81
- export { deriveFields } from './derive.js';
82
- export type { Field, FieldOverride } from './derive.js';
502
+ // Observe
503
+ export {
504
+ createObserveLogger,
505
+ isLogSink,
506
+ isLogger,
507
+ isObserveInput,
508
+ isTraceSink,
509
+ normalizeObserve,
510
+ } from './observe.js';
511
+ export type {
512
+ ObserveCapabilities,
513
+ ObserveConfig,
514
+ ObserveInput,
515
+ TopoOptions,
516
+ } from './observe.js';
517
+
518
+ // Run
519
+ export { run } from './run.js';
520
+ export type { RunOptions } from './run.js';
521
+
522
+ // Trail factories
523
+ export { deriveTrail, ingest } from './trails/index.js';
524
+ export type {
525
+ DeriveTrailInput,
526
+ DeriveTrailOperation,
527
+ DeriveTrailOutput,
528
+ DeriveTrailSpec,
529
+ IngestOptions,
530
+ IngestTransform,
531
+ } from './trails/index.js';
83
532
 
84
533
  // Validation
85
534
  export {
@@ -88,6 +537,10 @@ export {
88
537
  formatZodIssues,
89
538
  zodToJsonSchema,
90
539
  } from './validation.js';
540
+ export {
541
+ stripDefaultWrappers,
542
+ stripDefaultsFromShape,
543
+ } from './zod-wrappers.js';
91
544
 
92
545
  // Serialization
93
546
  export { serializeError, deserializeError } from './serialization.js';
@@ -98,7 +551,7 @@ export {
98
551
  retry,
99
552
  withTimeout,
100
553
  shouldRetry,
101
- getBackoffDelay,
554
+ deriveBackoffDelay,
102
555
  } from './resilience.js';
103
556
  export type { RetryOptions } from './resilience.js';
104
557
 
@@ -113,7 +566,7 @@ export {
113
566
  nonEmptyString,
114
567
  positiveInt,
115
568
  shortId,
116
- hashId,
569
+ deriveIdHash,
117
570
  } from './branded.js';
118
571
  export type {
119
572
  Branded,
@@ -124,18 +577,26 @@ export type {
124
577
  } from './branded.js';
125
578
 
126
579
  // Path Security
127
- export { securePath, isPathSafe, resolveSafePath } from './path-security.js';
580
+ export { securePath, isPathSafe, deriveSafePath } from './path-security.js';
128
581
 
129
582
  // Workspace
130
583
  export {
131
584
  findWorkspaceRoot,
132
585
  isInsideWorkspace,
133
- getRelativePath,
586
+ deriveRelativePath,
134
587
  } from './workspace.js';
135
588
 
136
589
  // Blob
137
- export { createBlobRef, isBlobRef } from './blob-ref.js';
138
- export type { BlobRef } from './blob-ref.js';
590
+ export {
591
+ BLOB_REF_SCHEMA_META_KEY,
592
+ blobRefDescriptorSchema,
593
+ blobRefJsonSchema,
594
+ blobRefSchema,
595
+ createBlobRef,
596
+ isBlobRef,
597
+ toBlobRefDescriptor,
598
+ } from './blob-ref.js';
599
+ export type { BlobRef, BlobRefDescriptor } from './blob-ref.js';
139
600
 
140
601
  // Guards
141
602
  export {
@@ -0,0 +1,69 @@
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 (`compose`,
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
+
24
+ import type { TrailContext, TrailContextInit } from '../types.js';
25
+
26
+ /** Keys cleared by default when forking a context. */
27
+ export type ForkCtxResetKey = 'compose' | 'fire' | 'resource';
28
+
29
+ /** Override fields callers are allowed to apply when forking a context. */
30
+ export type ForkCtxOverrides = Readonly<
31
+ Partial<Pick<TrailContext, 'env' | 'extensions' | 'logger'>>
32
+ >;
33
+
34
+ const DEFAULT_RESET_KEYS: readonly ForkCtxResetKey[] = [
35
+ 'compose',
36
+ 'fire',
37
+ 'resource',
38
+ ];
39
+
40
+ /**
41
+ * Fork a parent context into a child context.
42
+ *
43
+ * Spreads the parent, clears each reset key to `undefined`, and applies the
44
+ * supplied overrides last so callers may replace logger, env, and extensions
45
+ * with branch-local values.
46
+ *
47
+ * The generic parameter is constrained to the minimal shape the helper
48
+ * reads and writes. This lets the helper serve both `TrailContext`
49
+ * (executor scope) and `Partial<TrailContextInit>` (fire-consumer scope)
50
+ * without widening the public surface of either type.
51
+ */
52
+ export const forkCtx = <
53
+ TCtx extends Partial<
54
+ Pick<
55
+ TrailContextInit,
56
+ 'compose' | 'env' | 'extensions' | 'fire' | 'logger' | 'resource'
57
+ >
58
+ >,
59
+ >(
60
+ parentCtx: TCtx,
61
+ overrides: ForkCtxOverrides = {},
62
+ reset: readonly ForkCtxResetKey[] = DEFAULT_RESET_KEYS
63
+ ): TCtx => {
64
+ const forked: TCtx = { ...parentCtx };
65
+ for (const key of reset) {
66
+ forked[key as keyof TCtx] = undefined as TCtx[keyof TCtx];
67
+ }
68
+ return { ...forked, ...overrides };
69
+ };