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

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