@ontrails/core 1.0.0-beta.2 → 1.0.0-beta.21

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 +283 -5
  2. package/README.md +113 -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 +59 -18
  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 +309 -48
  19. package/src/execute.ts +1577 -0
  20. package/src/fire.ts +1169 -0
  21. package/src/index.ts +477 -32
  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 +36 -4
  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 +119 -39
  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 -57
  47. package/src/tracing.ts +345 -0
  48. package/src/trail.ts +1161 -29
  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 +208 -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 +442 -35
  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 -122
  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 -34
  117. package/dist/index.d.ts.map +0 -1
  118. package/dist/index.js +0 -38
  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 -145
  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 -115
  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 -74
  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 -108
  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 -159
  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 -236
  234. package/src/__tests__/topo.test.ts +0 -184
  235. package/src/__tests__/trail.test.ts +0 -179
  236. package/src/__tests__/validate-topo.test.ts +0 -201
  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/adapters.ts DELETED
@@ -1,68 +0,0 @@
1
- import type { Result } from './result.js';
2
-
3
- // ---------------------------------------------------------------------------
4
- // Shared option types
5
- // ---------------------------------------------------------------------------
6
-
7
- /** Options for search queries */
8
- export interface SearchOptions {
9
- readonly limit?: number | undefined;
10
- readonly offset?: number | undefined;
11
- readonly filters?: Readonly<Record<string, unknown>> | undefined;
12
- }
13
-
14
- /** A single search hit */
15
- export interface SearchResult {
16
- readonly id: string;
17
- readonly score: number;
18
- readonly document: Readonly<Record<string, unknown>>;
19
- }
20
-
21
- /** Options for storage writes */
22
- export interface StorageOptions {
23
- /** Time-to-live in milliseconds */
24
- readonly ttl?: number | undefined;
25
- }
26
-
27
- // ---------------------------------------------------------------------------
28
- // Adapter port interfaces
29
- // ---------------------------------------------------------------------------
30
-
31
- /** Full-text / vector index adapter */
32
- export interface IndexAdapter {
33
- index(
34
- id: string,
35
- document: Readonly<Record<string, unknown>>
36
- ): Promise<Result<void, Error>>;
37
-
38
- search(
39
- query: string,
40
- options?: SearchOptions
41
- ): Promise<Result<readonly SearchResult[], Error>>;
42
-
43
- remove(id: string): Promise<Result<void, Error>>;
44
- }
45
-
46
- /** Key-value storage adapter */
47
- export interface StorageAdapter {
48
- get(key: string): Promise<Result<unknown, Error>>;
49
- set(
50
- key: string,
51
- value: unknown,
52
- options?: StorageOptions
53
- ): Promise<Result<void, Error>>;
54
- delete(key: string): Promise<Result<void, Error>>;
55
- has(key: string): Promise<Result<boolean, Error>>;
56
- }
57
-
58
- /** Cache adapter with typed get/set and bulk clear */
59
- export interface CacheAdapter {
60
- get<T>(key: string): Promise<Result<T | undefined, Error>>;
61
- set<T>(
62
- key: string,
63
- value: T,
64
- options?: StorageOptions
65
- ): Promise<Result<void, Error>>;
66
- delete(key: string): Promise<Result<void, Error>>;
67
- clear(): Promise<Result<void, Error>>;
68
- }
package/src/event.ts DELETED
@@ -1,77 +0,0 @@
1
- /**
2
- * Event — a named payload schema with optional provenance metadata.
3
- */
4
-
5
- import type { z } from 'zod';
6
-
7
- // ---------------------------------------------------------------------------
8
- // Spec (input to the factory)
9
- // ---------------------------------------------------------------------------
10
-
11
- export interface EventSpec<T> {
12
- readonly payload: z.ZodType<T>;
13
- readonly description?: string | undefined;
14
- readonly markers?: Readonly<Record<string, unknown>> | undefined;
15
- /** Trail IDs that produce this event (e.g. the trails it originates from). */
16
- readonly from?: readonly string[] | undefined;
17
- }
18
-
19
- // ---------------------------------------------------------------------------
20
- // Shape (output of the factory)
21
- // ---------------------------------------------------------------------------
22
-
23
- export interface Event<T> {
24
- readonly id: string;
25
- readonly kind: 'event';
26
- readonly payload: z.ZodType<T>;
27
- readonly description?: string | undefined;
28
- readonly markers?: Readonly<Record<string, unknown>> | undefined;
29
- /** Trail IDs that produce this event (e.g. the trails it originates from). */
30
- readonly from?: readonly string[] | undefined;
31
- }
32
-
33
- // ---------------------------------------------------------------------------
34
- // Factory
35
- // ---------------------------------------------------------------------------
36
-
37
- /**
38
- * Create an event definition.
39
- *
40
- * An event is a named payload schema describing something that happened.
41
- * Returns a frozen object with `kind: "event"` and all spec fields.
42
- *
43
- * @example
44
- * ```typescript
45
- * // ID as first argument
46
- * const updated = event("entity.updated", {
47
- * payload: EntityUpdatedSchema,
48
- * from: ["entity.add", "entity.update"],
49
- * });
50
- *
51
- * // Full spec object (programmatic)
52
- * const updated = event({ id: "entity.updated", payload: ..., from: [...] });
53
- * ```
54
- */
55
- export function event<T>(id: string, spec: EventSpec<T>): Event<T>;
56
- export function event<T>(
57
- spec: EventSpec<T> & { readonly id: string }
58
- ): Event<T>;
59
- export function event<T>(
60
- idOrSpec: string | (EventSpec<T> & { readonly id: string }),
61
- maybeSpec?: EventSpec<T>
62
- ): Event<T> {
63
- const resolvedId = typeof idOrSpec === 'string' ? idOrSpec : idOrSpec.id;
64
- // oxlint-disable-next-line no-non-null-assertion -- overload guarantees maybeSpec when idOrSpec is string
65
- const resolvedSpec = typeof idOrSpec === 'string' ? maybeSpec! : idOrSpec;
66
- return Object.freeze({
67
- description: resolvedSpec.description,
68
- from: resolvedSpec.from ? Object.freeze([...resolvedSpec.from]) : undefined,
69
- id: resolvedId,
70
- kind: 'event' as const,
71
- markers: resolvedSpec.markers,
72
- payload: resolvedSpec.payload,
73
- });
74
- }
75
-
76
- /** Existential type for heterogeneous event collections */
77
- export type AnyEvent = Event<unknown>;
package/src/health.ts DELETED
@@ -1,23 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // Health check types
3
- // ---------------------------------------------------------------------------
4
-
5
- /** Aggregate health status */
6
- export type HealthStatus = 'healthy' | 'degraded' | 'unhealthy';
7
-
8
- /** Individual component check result */
9
- export interface HealthCheck {
10
- readonly status: HealthStatus;
11
- readonly message?: string | undefined;
12
- /** Latency in milliseconds */
13
- readonly latency?: number | undefined;
14
- }
15
-
16
- /** Full health report returned by a health endpoint */
17
- export interface HealthResult {
18
- readonly status: HealthStatus;
19
- readonly checks: Readonly<Record<string, HealthCheck>>;
20
- readonly version?: string | undefined;
21
- /** Uptime in seconds */
22
- readonly uptime?: number | undefined;
23
- }
package/src/hike.ts DELETED
@@ -1,77 +0,0 @@
1
- /**
2
- * Hike — a composition that follows trails.
3
- */
4
-
5
- import type { Trail, TrailSpec } from './trail.js';
6
- import type { TrailContext } from './types.js';
7
-
8
- // ---------------------------------------------------------------------------
9
- // Spec (input to the factory)
10
- // ---------------------------------------------------------------------------
11
-
12
- export interface HikeSpec<I, O> extends TrailSpec<I, O> {
13
- readonly follows: readonly string[];
14
- }
15
-
16
- // ---------------------------------------------------------------------------
17
- // Shape (output of the factory)
18
- // ---------------------------------------------------------------------------
19
-
20
- export interface Hike<I, O> extends Omit<Trail<I, O>, 'kind'> {
21
- readonly kind: 'hike';
22
- readonly follows: readonly string[];
23
- }
24
-
25
- // ---------------------------------------------------------------------------
26
- // Factory
27
- // ---------------------------------------------------------------------------
28
-
29
- /**
30
- * Create a hike definition.
31
- *
32
- * A hike is a composition that declares which trails it follows.
33
- * Returns a frozen object with `kind: "hike"` and all spec fields.
34
- *
35
- * @example
36
- * ```typescript
37
- * // ID as first argument
38
- * const onboard = hike("entity.onboard", {
39
- * follows: ["entity.add", "entity.relate"],
40
- * input: z.object({ name: z.string() }),
41
- * implementation: (input, ctx) => Result.ok(...),
42
- * });
43
- *
44
- * // Full spec object (programmatic)
45
- * const onboard = hike({ id: "entity.onboard", follows: [...], ... });
46
- * ```
47
- */
48
- export function hike<I, O>(id: string, spec: HikeSpec<I, O>): Hike<I, O>;
49
- export function hike<I, O>(
50
- spec: HikeSpec<I, O> & { readonly id: string }
51
- ): Hike<I, O>;
52
- export function hike<I, O>(
53
- idOrSpec: string | (HikeSpec<I, O> & { readonly id: string }),
54
- maybeSpec?: HikeSpec<I, O>
55
- ): Hike<I, O> {
56
- const resolved =
57
- typeof idOrSpec === 'string'
58
- ? { id: idOrSpec, spec: maybeSpec }
59
- : { id: idOrSpec.id, spec: idOrSpec };
60
-
61
- if (!resolved.spec) {
62
- throw new TypeError('hike() requires a spec when an id is provided');
63
- }
64
-
65
- const { follows, implementation, ...rest } = resolved.spec;
66
- return Object.freeze({
67
- ...rest,
68
- follows: Object.freeze([...follows]),
69
- id: resolved.id,
70
- implementation: async (input: I, ctx: TrailContext) =>
71
- await implementation(input, ctx),
72
- kind: 'hike' as const,
73
- });
74
- }
75
-
76
- // oxlint-disable-next-line no-explicit-any -- existential type; see AnyTrail
77
- export type AnyHike = Hike<any, any>;
package/src/job.ts DELETED
@@ -1,20 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- import { progressFields } from './patterns/progress.js';
4
- import { statusFields } from './patterns/status.js';
5
-
6
- /**
7
- * Proof: job-style output schema composes from existing pattern helpers.
8
- * No dedicated `kind: "job"` needed — regular trails with status+progress output work.
9
- */
10
- export const jobOutputSchema = z.object({
11
- ...progressFields().shape,
12
- ...statusFields().shape,
13
- completedAt: z.string().optional(),
14
- error: z.string().optional(),
15
- jobId: z.string(),
16
- result: z.unknown().optional(),
17
- startedAt: z.string().optional(),
18
- });
19
-
20
- export type JobOutput = z.infer<typeof jobOutputSchema>;
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- "rootDir": "src"
6
- },
7
- "include": ["src"],
8
- "exclude": ["**/__tests__/**", "**/*.test.ts", "dist"]
9
- }
@@ -1 +0,0 @@
1
- {"root":["./src/adapters.ts","./src/blob-ref.ts","./src/branded.ts","./src/collections.ts","./src/context.ts","./src/derive.ts","./src/errors.ts","./src/event.ts","./src/fetch.ts","./src/guards.ts","./src/health.ts","./src/hike.ts","./src/index.ts","./src/job.ts","./src/layer.ts","./src/path-security.ts","./src/resilience.ts","./src/result.ts","./src/serialization.ts","./src/topo.ts","./src/trail.ts","./src/types.ts","./src/validate-topo.ts","./src/validation.ts","./src/workspace.ts","./src/patterns/bulk.ts","./src/patterns/change.ts","./src/patterns/date-range.ts","./src/patterns/index.ts","./src/patterns/pagination.ts","./src/patterns/progress.ts","./src/patterns/sorting.ts","./src/patterns/status.ts","./src/patterns/timestamps.ts","./src/redaction/index.ts","./src/redaction/patterns.ts","./src/redaction/redactor.ts"],"version":"5.9.3"}