@ontrails/core 1.0.0-beta.12 → 1.0.0-beta.14
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.
- package/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +65 -35
- package/README.md +21 -20
- package/dist/context.d.ts +1 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +5 -4
- package/dist/context.js.map +1 -1
- package/dist/derive.d.ts +14 -3
- package/dist/derive.d.ts.map +1 -1
- package/dist/derive.js +36 -12
- package/dist/derive.js.map +1 -1
- package/dist/draft.d.ts +28 -0
- package/dist/draft.d.ts.map +1 -0
- package/dist/draft.js +156 -0
- package/dist/draft.js.map +1 -0
- package/dist/event.d.ts +4 -41
- package/dist/event.d.ts.map +1 -1
- package/dist/event.js +4 -14
- package/dist/event.js.map +1 -1
- package/dist/execute.d.ts +10 -10
- package/dist/execute.d.ts.map +1 -1
- package/dist/execute.js +35 -28
- package/dist/execute.js.map +1 -1
- package/dist/gate.d.ts +17 -0
- package/dist/gate.d.ts.map +1 -0
- package/dist/gate.js +21 -0
- package/dist/gate.js.map +1 -0
- package/dist/index.d.ts +16 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -9
- package/dist/index.js.map +1 -1
- package/dist/internal/topo-saves.d.ts +47 -0
- package/dist/internal/topo-saves.d.ts.map +1 -0
- package/dist/internal/topo-saves.js +310 -0
- package/dist/internal/topo-saves.js.map +1 -0
- package/dist/internal/topo-store-read.d.ts +67 -0
- package/dist/internal/topo-store-read.d.ts.map +1 -0
- package/dist/internal/topo-store-read.js +222 -0
- package/dist/internal/topo-store-read.js.map +1 -0
- package/dist/internal/topo-store.d.ts +12 -0
- package/dist/internal/topo-store.d.ts.map +1 -0
- package/dist/internal/topo-store.js +571 -0
- package/dist/internal/topo-store.js.map +1 -0
- package/dist/internal/trails-db.d.ts +16 -0
- package/dist/internal/trails-db.d.ts.map +1 -0
- package/dist/internal/trails-db.js +118 -0
- package/dist/internal/trails-db.js.map +1 -0
- package/dist/layer.d.ts +5 -16
- package/dist/layer.d.ts.map +1 -1
- package/dist/layer.js +3 -20
- package/dist/layer.js.map +1 -1
- package/dist/provision-config.d.ts +22 -0
- package/dist/provision-config.d.ts.map +1 -0
- package/dist/provision-config.js +210 -0
- package/dist/provision-config.js.map +1 -0
- package/dist/provision.d.ts +71 -0
- package/dist/provision.d.ts.map +1 -0
- package/dist/provision.js +56 -0
- package/dist/provision.js.map +1 -0
- package/dist/run.d.ts +27 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +34 -0
- package/dist/run.js.map +1 -0
- package/dist/service-config.d.ts +7 -7
- package/dist/service-config.d.ts.map +1 -1
- package/dist/service-config.js +75 -73
- package/dist/service-config.js.map +1 -1
- package/dist/service.d.ts +32 -36
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +21 -21
- package/dist/service.js.map +1 -1
- package/dist/signal.d.ts +33 -0
- package/dist/signal.d.ts.map +1 -0
- package/dist/signal.js +17 -0
- package/dist/signal.js.map +1 -0
- package/dist/topo-store.d.ts +48 -0
- package/dist/topo-store.d.ts.map +1 -0
- package/dist/topo-store.js +175 -0
- package/dist/topo-store.js.map +1 -0
- package/dist/topo.d.ts +10 -10
- package/dist/topo.d.ts.map +1 -1
- package/dist/topo.js +48 -35
- package/dist/topo.js.map +1 -1
- package/dist/trail.d.ts +16 -16
- package/dist/trail.d.ts.map +1 -1
- package/dist/trail.js +5 -4
- package/dist/trail.js.map +1 -1
- package/dist/types.d.ts +10 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -2
- package/dist/types.js.map +1 -1
- package/dist/validate-established-topo.d.ts +76 -0
- package/dist/validate-established-topo.d.ts.map +1 -0
- package/dist/validate-established-topo.js +43 -0
- package/dist/validate-established-topo.js.map +1 -0
- package/dist/validate-topo.d.ts +2 -2
- package/dist/validate-topo.d.ts.map +1 -1
- package/dist/validate-topo.js +34 -32
- package/dist/validate-topo.js.map +1 -1
- package/package.json +4 -1
- package/src/__tests__/context.test.ts +8 -8
- package/src/__tests__/derive.test.ts +58 -1
- package/src/__tests__/execute.test.ts +124 -122
- package/src/__tests__/{layer.test.ts → gate.test.ts} +26 -26
- package/src/__tests__/{dispatch.test.ts → run.test.ts} +39 -39
- package/src/__tests__/service-config.test.ts +41 -37
- package/src/__tests__/service.test.ts +71 -71
- package/src/__tests__/{event.test.ts → signal.test.ts} +15 -15
- package/src/__tests__/topo-store-read.test.ts +251 -0
- package/src/__tests__/topo-store.test.ts +469 -0
- package/src/__tests__/topo.test.ts +54 -54
- package/src/__tests__/trail-permit.test.ts +4 -4
- package/src/__tests__/trail.test.ts +58 -58
- package/src/__tests__/trails-db.test.ts +191 -0
- package/src/__tests__/type-utils.test.ts +3 -3
- package/src/__tests__/validate-topo.test.ts +205 -38
- package/src/context.ts +5 -4
- package/src/derive.ts +47 -16
- package/src/draft.ts +334 -0
- package/src/event.ts +11 -73
- package/src/execute.ts +56 -40
- package/src/{layer.ts → gate.ts} +13 -13
- package/src/index.ts +54 -23
- package/src/internal/topo-saves.ts +429 -0
- package/src/internal/topo-store-read.ts +473 -0
- package/src/internal/topo-store.ts +1087 -0
- package/src/internal/trails-db.ts +189 -0
- package/src/{service-config.ts → provision-config.ts} +124 -105
- package/src/provision.ts +148 -0
- package/src/{dispatch.ts → run.ts} +8 -8
- package/src/signal.ts +65 -0
- package/src/topo-store.ts +301 -0
- package/src/topo.ts +74 -52
- package/src/trail.ts +23 -22
- package/src/types.ts +11 -11
- package/src/validate-established-topo.ts +63 -0
- package/src/validate-topo.ts +38 -34
- package/tsconfig.tsbuildinfo +1 -1
- package/src/service.ts +0 -145
package/.turbo/turbo-lint.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,35 +1,65 @@
|
|
|
1
1
|
# @ontrails/core
|
|
2
2
|
|
|
3
|
-
## 1.0.0-beta.
|
|
3
|
+
## 1.0.0-beta.14
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 69057e9: Add hierarchical CLI command trees and structured input, enforce established-only topo exports across trailheads, move developer topo and tracker state onto shared `trails.db` with pins and maintenance flows, and ship schema-derived stores through `@ontrails/store` and its Drizzle runtime.
|
|
8
|
+
|
|
9
|
+
## 1.0.0-beta.13
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Trail-native vocabulary cutover. Breaking API field renames across all packages:
|
|
14
|
+
|
|
15
|
+
- Trail spec: `run:` → `blaze:`, `follow:` → `crosses:`, `services:` → `provisions:`, `metadata:` → `meta:`, `emits:` → `signals:`
|
|
16
|
+
- Runtime: `ctx.follow()` → `ctx.cross()`, `ctx.emit()` → `ctx.signal()`, `ctx.signal` (abort) → `ctx.abortSignal`
|
|
17
|
+
- Entry points: `blaze(app)` → `trailhead(app)`
|
|
18
|
+
- Package rename: `@ontrails/crumbs` → `@ontrails/tracker`
|
|
19
|
+
- Wrapper types: `Layer` → `Gate`, `layers`/`middleware` → `gates`
|
|
20
|
+
- Transport: `surface` → `trailhead`, `adapter` → `connector`
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
6
23
|
|
|
7
|
-
- Complete trifecta for config, permits, and
|
|
24
|
+
- 6944147: Complete trifecta for config, permits, and tracker (formerly tracks)
|
|
8
25
|
|
|
9
|
-
- **config**: Add `
|
|
26
|
+
- **config**: Add `configProvision`, `configGate`, `config.trail`, and `config.workspace` trails with full `defineConfig`, `resolve`, `describe`, `explain`, `doctor`, and code generation support
|
|
10
27
|
- **permits**: Add `authService` and `auth.verify` trail for runtime authorization checks
|
|
11
|
-
- **
|
|
28
|
+
- **tracker**: Rename tracks to tracker; add `trackerProvision` and `tracker.status` trail for structured signal tracking
|
|
29
|
+
- **cli**: Fix build flag handling and improve bootstrap scaffolding
|
|
30
|
+
- **testing**: Expand test context helpers and example-based testing utilities
|
|
31
|
+
- **core/mcp/http**: Internal alignment for provision and composition updates
|
|
32
|
+
|
|
33
|
+
## 1.0.0-beta.12
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Complete trifecta for config, permits, and tracker (formerly tracks)
|
|
38
|
+
|
|
39
|
+
- **config**: Add `configProvision`, `config.gate`, `config.trail`, and `config.workspace` trails with full `defineConfig`, `resolve`, `describe`, `explain`, `doctor`, and code generation support
|
|
40
|
+
- **permits**: Add `authProvision` and `auth.verify` trail for runtime authorization checks
|
|
41
|
+
- **tracker**: Rename tracks to tracker; add `trackerProvision` and `tracker.status` trail for structured event tracking
|
|
12
42
|
- **cli**: Fix build flag handling and improve bootstrap scaffolding
|
|
13
43
|
- **testing**: Expand test context helpers and example-based testing utilities
|
|
14
|
-
- **core/mcp/http**: Internal alignment for
|
|
44
|
+
- **core/mcp/http**: Internal alignment for provision and composition updates
|
|
15
45
|
|
|
16
46
|
## 1.0.0-beta.11
|
|
17
47
|
|
|
18
48
|
### Minor Changes
|
|
19
49
|
|
|
20
|
-
- Add
|
|
50
|
+
- Add provisions as a first-class primitive.
|
|
21
51
|
|
|
22
|
-
|
|
52
|
+
Provisions make infrastructure dependencies declarative, injectable, and governable. Define a provision with `provision()`, declare it on a trail with `provisions: [db]`, and access it with `db.from(ctx)` or `ctx.provision()`.
|
|
23
53
|
|
|
24
|
-
**Core:** `
|
|
54
|
+
**Core:** `provision()` factory, `ProvisionSpec<T>`, `ProvisionContext`, singleton resolution in `executeTrail`, in-flight creation dedup, `isProvision` guard, `findDuplicateProvisionId`, topo provision discovery and validation, `provisions` field on trail specs.
|
|
25
55
|
|
|
26
|
-
**Testing:** Auto-resolution of `mock` factories in `testAll`, `testExamples`, `testContracts`, and `
|
|
56
|
+
**Testing:** Auto-resolution of `mock` factories in `testAll`, `testExamples`, `testContracts`, and `testCrosses`. Explicit `services` overrides with correct precedence (`explicit > ctx.extensions > auto-mock`). Service mock propagation through crossing graphs.
|
|
27
57
|
|
|
28
|
-
**Warden:** `
|
|
58
|
+
**Warden:** `provision-declarations` rule validates `db.from(ctx)` and `ctx.provision()` usage matches declared `provisions: [...]`. `provision-exists` rule validates declared provision IDs resolve in project context. Scope-aware AST walking skips nested function boundaries.
|
|
29
59
|
|
|
30
|
-
**
|
|
60
|
+
**Trailheads:** Provision overrides thread through `run` and `trailhead` on CLI, MCP, and HTTP.
|
|
31
61
|
|
|
32
|
-
**Introspection:** Survey and
|
|
62
|
+
**Introspection:** Survey and trailhead map outputs include provision graph. Topo exposes `.provisions`, `.getProvision()`, `.hasProvision()`, `.listProvisions()`, `.provisionIds()`, `.provisionCount`.
|
|
33
63
|
|
|
34
64
|
**Docs:** ADR-009 accepted. Unified services guide, updated vocabulary, getting-started, architecture, and package READMEs.
|
|
35
65
|
|
|
@@ -39,13 +69,13 @@
|
|
|
39
69
|
|
|
40
70
|
- Cleanup and hardening pass across all packages.
|
|
41
71
|
|
|
42
|
-
**core**: Deduplicate `
|
|
72
|
+
**core**: Deduplicate `RunOptions` as type alias of `ExecuteTrailOptions`. Replace `TrailContext` index signature with typed `extensions` field for type safety. Deep-merge `extensions` in `executeTrail` context resolution. Remove unused `Trailhead` type, `connectors.ts`, `health.ts`, and `job.ts` proof-of-concept from published package.
|
|
43
73
|
|
|
44
|
-
**cli**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `
|
|
74
|
+
**cli**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `trailhead()` with opt-out via `validate: false`.
|
|
45
75
|
|
|
46
|
-
**http**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `
|
|
76
|
+
**http**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `trailhead()` with opt-out.
|
|
47
77
|
|
|
48
|
-
**mcp**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `
|
|
78
|
+
**mcp**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `trailhead()` with opt-out.
|
|
49
79
|
|
|
50
80
|
**warden**: Project-aware rule context preserved in trail wrappers.
|
|
51
81
|
|
|
@@ -53,9 +83,9 @@
|
|
|
53
83
|
|
|
54
84
|
### Minor Changes
|
|
55
85
|
|
|
56
|
-
- Consolidated improvements across all
|
|
86
|
+
- Consolidated improvements across all trailhead packages.
|
|
57
87
|
|
|
58
|
-
**core**: Add `TrailResult<T>` utility type, `topo.ids()` and `topo.count` accessors, `
|
|
88
|
+
**core**: Add `TrailResult<T>` utility type, `topo.ids()` and `topo.count` accessors, `run()` for headless trail execution, and extract shared `executeTrail` pipeline used by CLI/MCP/HTTP.
|
|
59
89
|
|
|
60
90
|
**http**: Detect route path collisions and return `Result` from `buildHttpRoutes()`, wire request `AbortSignal` through to trail context, and make write → POST mapping explicit in intent-to-method lookup.
|
|
61
91
|
|
|
@@ -63,7 +93,7 @@
|
|
|
63
93
|
|
|
64
94
|
**cli**: Verify exception catching via centralized `executeTrail`.
|
|
65
95
|
|
|
66
|
-
**testing**:
|
|
96
|
+
**testing**: Cross-context awareness improvements.
|
|
67
97
|
|
|
68
98
|
**warden**: Refactor rules as composable trails with examples.
|
|
69
99
|
|
|
@@ -77,21 +107,21 @@
|
|
|
77
107
|
|
|
78
108
|
### Patch Changes
|
|
79
109
|
|
|
80
|
-
- Fix Codex review findings on type-utils and
|
|
110
|
+
- Fix Codex review findings on type-utils and cross-declarations.
|
|
81
111
|
|
|
82
112
|
**core**: `inputOf()`/`outputOf()` now preserve the exact Zod schema subtype instead of widening to `z.ZodType`.
|
|
83
113
|
|
|
84
|
-
**warden**: `
|
|
114
|
+
**warden**: `cross-declarations` rule now recognizes single-object trail overload, detects any context parameter name (not just `ctx`), matches destructured `cross()` calls, resolves const identifiers in `crosses` arrays, and restricts blaze body extraction to top-level config properties.
|
|
85
115
|
|
|
86
116
|
## 1.0.0-beta.5
|
|
87
117
|
|
|
88
118
|
### Minor Changes
|
|
89
119
|
|
|
90
|
-
- Type utilities and
|
|
120
|
+
- Type utilities and cross-declarations warden rule.
|
|
91
121
|
|
|
92
122
|
**core**: Add `TrailInput<T>`, `TrailOutput<T>` utility types and `inputOf()`, `outputOf()` runtime schema accessors.
|
|
93
123
|
|
|
94
|
-
**warden**: Add `
|
|
124
|
+
**warden**: Add `cross-declarations` rule — statically analyzes `ctx.cross()` calls against declared `crosses: [...]` arrays. Errors on undeclared calls, warns on unused declarations.
|
|
95
125
|
|
|
96
126
|
## 1.0.0-beta.4
|
|
97
127
|
|
|
@@ -101,29 +131,29 @@
|
|
|
101
131
|
|
|
102
132
|
**BREAKING CHANGES:**
|
|
103
133
|
|
|
104
|
-
- `hike()` removed — use `trail()` with optional `
|
|
105
|
-
- `follows` renamed to `
|
|
134
|
+
- `hike()` removed — use `trail()` with optional `crosses: [...]` field
|
|
135
|
+
- `follows` renamed to `crosses` (matching `ctx.cross()`)
|
|
106
136
|
- `topo.hikes` removed — single `topo.trails` map
|
|
107
137
|
- `kind: 'hike'` removed — everything is `kind: 'trail'`
|
|
108
138
|
- `readOnly`/`destructive` booleans replaced by `intent: 'read' | 'write' | 'destroy'`
|
|
109
139
|
- `implementation` field renamed to `run`
|
|
110
140
|
- `markers` field renamed to `metadata`
|
|
111
|
-
- `testHike` renamed to `
|
|
112
|
-
- `
|
|
141
|
+
- `testHike` renamed to `testCrosses`, `HikeScenario` to `CrossScenario`
|
|
142
|
+
- `trailhead()` now returns the trailhead handle (`Command` for CLI, `Server` for MCP)
|
|
113
143
|
|
|
114
144
|
## 1.0.0-beta.3
|
|
115
145
|
|
|
116
146
|
### Minor Changes
|
|
117
147
|
|
|
118
|
-
- Bug fixes across all
|
|
148
|
+
- Bug fixes across all trailhead packages found via parallel Codex review.
|
|
119
149
|
|
|
120
150
|
**core**: Fix Result.toJson false circular detection on DAGs, deserializeError subclass round-trip, topo cross-kind ID collisions, validateTopo multi-node cycle detection, error example input validation bypass, and deriveFields array type collapse.
|
|
121
151
|
|
|
122
|
-
**cli**: Switch
|
|
152
|
+
**cli**: Switch trailhead to parseAsync for proper async error handling, add boolean flag negation (--no-flag), and strict number parsing that rejects partial input.
|
|
123
153
|
|
|
124
154
|
**mcp**: Align BlobRef with core (including ReadableStream support) and detect tool-name collisions after normalization.
|
|
125
155
|
|
|
126
|
-
**testing**: Include hikes in testContracts validation, with
|
|
156
|
+
**testing**: Include hikes in testContracts validation, with cross-context awareness.
|
|
127
157
|
|
|
128
158
|
**warden**: Collect hike detour targets, validate detour refs in hike specs, and stop implementation-returns-result from walking into nested function bodies.
|
|
129
159
|
|
|
@@ -149,9 +179,9 @@
|
|
|
149
179
|
- Initial v1 beta release of the Trails framework.
|
|
150
180
|
|
|
151
181
|
- **@ontrails/core** — Result type, error taxonomy, trail/hike/event/topo, validateTopo, validateInput/Output, deriveFields, patterns, redaction, branded types, resilience
|
|
152
|
-
- **@ontrails/cli** — CLI
|
|
153
|
-
- **@ontrails/mcp** — MCP
|
|
154
|
-
- **@ontrails/logging** — Structured logging, sinks, formatters, LogTape
|
|
155
|
-
- **@ontrails/testing** — testAll, testExamples, testTrail, testHike, testContracts, testDetours,
|
|
182
|
+
- **@ontrails/cli** — CLI trailhead connector, Commander integration, flag derivation, gates
|
|
183
|
+
- **@ontrails/mcp** — MCP trailhead connector, tool generation, annotations, progress bridge
|
|
184
|
+
- **@ontrails/logging** — Structured logging, sinks, formatters, LogTape connector
|
|
185
|
+
- **@ontrails/testing** — testAll, testExamples, testTrail, testHike, testContracts, testDetours, trailhead harnesses
|
|
156
186
|
- **@ontrails/warden** — AST-based code convention rules via oxc-parser, drift detection, CI formatters
|
|
157
|
-
- **@ontrails/schema** —
|
|
187
|
+
- **@ontrails/schema** — Trailhead map generation, hashing, semantic diffing
|
package/README.md
CHANGED
|
@@ -15,20 +15,20 @@ const greet = trail('greet', {
|
|
|
15
15
|
examples: [
|
|
16
16
|
{ name: 'Hello', input: { name: 'World' }, expected: { message: 'Hello, World!' } },
|
|
17
17
|
],
|
|
18
|
-
|
|
18
|
+
blaze: (input) => Result.ok({ message: `Hello, ${input.name}!` }),
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
const app = topo('myapp', { greet });
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
Trails compose other trails through `
|
|
24
|
+
Trails compose other trails through `crosses` and `ctx.cross()`:
|
|
25
25
|
|
|
26
26
|
```typescript
|
|
27
27
|
const onboard = trail('entity.onboard', {
|
|
28
|
-
|
|
28
|
+
crosses: ['entity.add', 'entity.relate'],
|
|
29
29
|
input: z.object({ name: z.string(), type: z.string() }),
|
|
30
|
-
|
|
31
|
-
const added = await ctx.
|
|
30
|
+
blaze: async (input, ctx) => {
|
|
31
|
+
const added = await ctx.cross('entity.add', input);
|
|
32
32
|
if (added.isErr()) return added;
|
|
33
33
|
return Result.ok({ entity: added.value });
|
|
34
34
|
},
|
|
@@ -41,25 +41,25 @@ const onboard = trail('entity.onboard', {
|
|
|
41
41
|
|
|
42
42
|
| Export | What it does |
|
|
43
43
|
| --- | --- |
|
|
44
|
-
| `trail(id, spec)` | Define a unit of work with typed input and `Result` output; use `
|
|
45
|
-
| `
|
|
46
|
-
| `
|
|
44
|
+
| `trail(id, spec)` | Define a unit of work with typed input and `Result` output; use `crosses` for composition |
|
|
45
|
+
| `signal(id, spec)` | Define a server-originated notification with a typed data schema |
|
|
46
|
+
| `provision(id, spec)` | Define an infrastructure dependency with `create`, `dispose`, and optional `mock` |
|
|
47
47
|
| `topo(name, ...modules)` | Collect trail modules into a queryable topology |
|
|
48
|
-
| `validateTopo(topo)` | Structural validation:
|
|
48
|
+
| `validateTopo(topo)` | Structural validation: cross targets exist, no cycles, examples parse, output schemas present |
|
|
49
49
|
|
|
50
50
|
### Execution
|
|
51
51
|
|
|
52
52
|
| Export | What it does |
|
|
53
53
|
| --- | --- |
|
|
54
|
-
| `executeTrail(trail, rawInput, options?)` | Centralized execution pipeline: validates input, builds context, composes
|
|
55
|
-
| `
|
|
54
|
+
| `executeTrail(trail, rawInput, options?)` | Centralized execution pipeline: validates input, builds context, composes gates, runs the implementation. Never throws -- exceptions become `Result.err(InternalError)`. |
|
|
55
|
+
| `run(topo, id, input, options?)` | Headless trail execution by ID. Looks up the trail in the topo, then delegates to `executeTrail`. Returns `Result.err(NotFoundError)` if the ID is not registered. |
|
|
56
56
|
|
|
57
57
|
```typescript
|
|
58
|
-
// executeTrail —
|
|
58
|
+
// executeTrail — trailheads use this directly
|
|
59
59
|
const result = await executeTrail(greet, { name: 'Alice' });
|
|
60
60
|
|
|
61
|
-
//
|
|
62
|
-
const result = await
|
|
61
|
+
// run — no-trailhead execution by trail ID
|
|
62
|
+
const result = await run(app, 'greet', { name: 'Alice' });
|
|
63
63
|
if (result.isOk()) console.log(result.value);
|
|
64
64
|
```
|
|
65
65
|
|
|
@@ -89,8 +89,8 @@ Beyond the `trail(id, spec)` builder, `Topo` exposes these accessors:
|
|
|
89
89
|
|
|
90
90
|
| Type | What it describes |
|
|
91
91
|
| --- | --- |
|
|
92
|
-
| `ExecuteTrailOptions` | Options for `executeTrail`: `ctx`, `
|
|
93
|
-
| `
|
|
92
|
+
| `ExecuteTrailOptions` | Options for `executeTrail`: `ctx`, `abortSignal`, `gates`, `createContext` |
|
|
93
|
+
| `RunOptions` | Same shape as `ExecuteTrailOptions`; forwarded by `run` |
|
|
94
94
|
|
|
95
95
|
### Result
|
|
96
96
|
|
|
@@ -112,7 +112,7 @@ result.unwrapOr(fallback); // Value or fallback
|
|
|
112
112
|
|
|
113
113
|
### Error taxonomy
|
|
114
114
|
|
|
115
|
-
13 error classes across 10 categories. Each maps deterministically to exit codes, HTTP status, and JSON-RPC codes on every
|
|
115
|
+
13 error classes across 10 categories. Each maps deterministically to exit codes, HTTP status, and JSON-RPC codes on every trailhead.
|
|
116
116
|
|
|
117
117
|
| Category | Classes | HTTP | Retryable |
|
|
118
118
|
| --- | --- | --- | --- |
|
|
@@ -127,16 +127,17 @@ result.unwrapOr(fallback); // Value or fallback
|
|
|
127
127
|
| `auth` | `AuthError` | 401 | No |
|
|
128
128
|
| `cancelled` | `CancelledError` | 499 | No |
|
|
129
129
|
|
|
130
|
-
The developer returns `Result.err(new NotFoundError(...))`. The framework maps it to the right code on every
|
|
130
|
+
The developer returns `Result.err(new NotFoundError(...))`. The framework maps it to the right code on every trailhead.
|
|
131
131
|
|
|
132
132
|
### Other exports
|
|
133
133
|
|
|
134
|
-
- **Schema derivation** -- `deriveFields(schema)` extracts
|
|
134
|
+
- **Schema derivation** -- `deriveFields(schema)` extracts faithfully
|
|
135
|
+
representable field metadata from Zod for prompts and forms
|
|
135
136
|
- **Validation** -- `validateInput`, `formatZodIssues`, `zodToJsonSchema`
|
|
136
137
|
- **Resilience** -- `retry`, `withTimeout`, `shouldRetry`, `getBackoffDelay`
|
|
137
138
|
- **Serialization** -- `serializeError`, `deserializeError`
|
|
138
139
|
- **Branded types** -- `uuid`, `email`, `nonEmptyString`, `positiveInt`
|
|
139
|
-
- **
|
|
140
|
+
- **Gates** -- cross-cutting gates via `composeGates`
|
|
140
141
|
- **Guards and collections** -- `isDefined`, `chunk`, `dedupe`, `groupBy`, `sortBy`
|
|
141
142
|
- **Patterns** (`@ontrails/core/patterns`) -- reusable Zod schemas for pagination, bulk ops, timestamps, sorting
|
|
142
143
|
- **Redaction** (`@ontrails/core/redaction`) -- strip sensitive data before logging
|
package/dist/context.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { TrailContext, TrailContextInit } from './types.js';
|
|
|
3
3
|
* Create a TrailContext with sensible defaults.
|
|
4
4
|
*
|
|
5
5
|
* - `requestId` defaults to `Bun.randomUUIDv7()` (sortable v7 UUID)
|
|
6
|
-
* - `
|
|
6
|
+
* - `abortSignal` defaults to a fresh, non-aborted `AbortSignal`
|
|
7
7
|
* - All other fields come from `overrides`
|
|
8
8
|
*/
|
|
9
9
|
export declare const createTrailContext: (overrides?: Partial<TrailContextInit>) => TrailContext;
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAMjE;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,YAAY,OAAO,CAAC,gBAAgB,CAAC,KACpC,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAMjE;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,YAAY,OAAO,CAAC,gBAAgB,CAAC,KACpC,YAWF,CAAC"}
|
package/dist/context.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createProvisionLookup } from './provision.js';
|
|
2
2
|
/**
|
|
3
3
|
* Create a TrailContext with sensible defaults.
|
|
4
4
|
*
|
|
5
5
|
* - `requestId` defaults to `Bun.randomUUIDv7()` (sortable v7 UUID)
|
|
6
|
-
* - `
|
|
6
|
+
* - `abortSignal` defaults to a fresh, non-aborted `AbortSignal`
|
|
7
7
|
* - All other fields come from `overrides`
|
|
8
8
|
*/
|
|
9
9
|
export const createTrailContext = (overrides) => {
|
|
10
10
|
const ctx = {
|
|
11
|
+
abortSignal: new AbortController().signal,
|
|
11
12
|
cwd: process.cwd(),
|
|
12
13
|
env: process.env,
|
|
13
14
|
requestId: Bun.randomUUIDv7(),
|
|
14
|
-
signal: new AbortController().signal,
|
|
15
15
|
...overrides,
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
const lookup = overrides?.provision ?? createProvisionLookup(() => ctx);
|
|
18
|
+
ctx.provision = lookup;
|
|
18
19
|
return ctx;
|
|
19
20
|
};
|
|
20
21
|
//# sourceMappingURL=context.js.map
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAOvD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,SAAqC,EACvB,EAAE;IAChB,MAAM,GAAG,GAAG;QACV,WAAW,EAAE,IAAI,eAAe,EAAE,CAAC,MAAM;QACzC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;QAClB,GAAG,EAAE,OAAO,CAAC,GAAyC;QACtD,SAAS,EAAE,GAAG,CAAC,YAAY,EAAE;QAC7B,GAAG,SAAS;KACU,CAAC;IACzB,MAAM,MAAM,GAAG,SAAS,EAAE,SAAS,IAAI,qBAAqB,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;IACxE,GAAG,CAAC,SAAS,GAAG,MAAM,CAAC;IACvB,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
package/dist/derive.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Schema-driven field derivation for @ontrails/core
|
|
3
3
|
*
|
|
4
|
-
* Introspects Zod v4 schemas to produce a
|
|
5
|
-
* that UI
|
|
4
|
+
* Introspects Zod v4 schemas to produce a runtime-agnostic Field[] descriptor
|
|
5
|
+
* that UI consumers (CLI prompts, web forms, etc.) can consume.
|
|
6
6
|
*/
|
|
7
7
|
import type { z } from 'zod';
|
|
8
|
-
/** A
|
|
8
|
+
/** A runtime-agnostic field descriptor derived from a Zod schema. */
|
|
9
9
|
export interface Field {
|
|
10
10
|
readonly name: string;
|
|
11
11
|
readonly type: 'string' | 'number' | 'boolean' | 'enum' | 'multiselect' | 'string[]' | 'number[]';
|
|
@@ -29,5 +29,16 @@ export interface FieldOverride {
|
|
|
29
29
|
hint?: string | undefined;
|
|
30
30
|
}[] | undefined;
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Derive the canonical ordered CLI path from a trail ID.
|
|
34
|
+
*
|
|
35
|
+
* @throws {ValidationError} if the trail ID contains empty segments (e.g. consecutive dots).
|
|
36
|
+
*/
|
|
37
|
+
export declare const deriveCliPath: (trailId: string) => string[];
|
|
38
|
+
/**
|
|
39
|
+
* Derive a runtime-agnostic Field[] from a Zod object schema.
|
|
40
|
+
*
|
|
41
|
+
* Uses Zod v4's `_zod.def` for introspection. Returns fields sorted by name.
|
|
42
|
+
*/
|
|
32
43
|
export declare const deriveFields: (schema: z.ZodType, overrides?: Record<string, FieldOverride>) => Field[];
|
|
33
44
|
//# sourceMappingURL=derive.d.ts.map
|
package/dist/derive.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derive.d.ts","sourceRoot":"","sources":["../src/derive.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"derive.d.ts","sourceRoot":"","sources":["../src/derive.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQ7B,qEAAqE;AACrE,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EACT,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,MAAM,GACN,aAAa,GACb,UAAU,GACV,UAAU,CAAC;IACf,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,OAAO,CAAC,EACb,SAAS;QACP,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC3B,EAAE,GACH,SAAS,CAAC;CACf;AAED,qDAAqD;AACrD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,OAAO,CAAC,EACb,SAAS;QACP,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC3B,EAAE,GACH,SAAS,CAAC;CACf;AAsJD;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,KAAG,MAAM,EASrD,CAAC;AAwBF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GACvB,QAAQ,CAAC,CAAC,OAAO,EACjB,YAAY,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,KACxC,KAAK,EAiBP,CAAC"}
|
package/dist/derive.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Schema-driven field derivation for @ontrails/core
|
|
3
3
|
*
|
|
4
|
-
* Introspects Zod v4 schemas to produce a
|
|
5
|
-
* that UI
|
|
4
|
+
* Introspects Zod v4 schemas to produce a runtime-agnostic Field[] descriptor
|
|
5
|
+
* that UI consumers (CLI prompts, web forms, etc.) can consume.
|
|
6
6
|
*/
|
|
7
|
+
import { ValidationError } from './errors.js';
|
|
7
8
|
// ---------------------------------------------------------------------------
|
|
8
9
|
// Helpers
|
|
9
10
|
// ---------------------------------------------------------------------------
|
|
@@ -55,11 +56,15 @@ const unwrap = (s) => {
|
|
|
55
56
|
const fieldTypeByDef = {
|
|
56
57
|
array: (s) => {
|
|
57
58
|
const element = s._zod.def['element'];
|
|
58
|
-
const
|
|
59
|
+
const { inner } = unwrap(element);
|
|
60
|
+
const elementType = inner._zod.def['type'];
|
|
59
61
|
if (elementType === 'enum') {
|
|
60
|
-
const entries =
|
|
62
|
+
const entries = inner._zod.def['entries'];
|
|
61
63
|
return { options: Object.values(entries), type: 'multiselect' };
|
|
62
64
|
}
|
|
65
|
+
if (elementType !== 'number' && elementType !== 'string') {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
63
68
|
return {
|
|
64
69
|
options: undefined,
|
|
65
70
|
type: elementType === 'number' ? 'number[]' : 'string[]',
|
|
@@ -77,7 +82,7 @@ const fieldTypeByDef = {
|
|
|
77
82
|
const deriveFieldType = (s) => {
|
|
78
83
|
const defType = s._zod.def['type'];
|
|
79
84
|
const derive = fieldTypeByDef[defType];
|
|
80
|
-
return derive ? derive(s) :
|
|
85
|
+
return derive ? derive(s) : null;
|
|
81
86
|
};
|
|
82
87
|
/** Build options array, merging with overrides when present. */
|
|
83
88
|
const buildOptions = (rawOptions, overrideOptions) => {
|
|
@@ -93,23 +98,40 @@ const buildOptions = (rawOptions, overrideOptions) => {
|
|
|
93
98
|
return ov ? { hint: ov.hint, label: ov.label, value: v } : { value: v };
|
|
94
99
|
});
|
|
95
100
|
};
|
|
96
|
-
// ---------------------------------------------------------------------------
|
|
97
|
-
// Public API
|
|
98
|
-
// ---------------------------------------------------------------------------
|
|
99
101
|
/**
|
|
100
|
-
* Derive
|
|
102
|
+
* Derive the canonical ordered CLI path from a trail ID.
|
|
101
103
|
*
|
|
102
|
-
*
|
|
104
|
+
* @throws {ValidationError} if the trail ID contains empty segments (e.g. consecutive dots).
|
|
103
105
|
*/
|
|
106
|
+
export const deriveCliPath = (trailId) => {
|
|
107
|
+
const segments = trailId.split('.');
|
|
108
|
+
const emptyIndex = segments.findIndex((s) => s.length === 0);
|
|
109
|
+
if (emptyIndex !== -1) {
|
|
110
|
+
throw new ValidationError(`Trail ID "${trailId}" contains an empty segment at position ${emptyIndex}`);
|
|
111
|
+
}
|
|
112
|
+
return segments;
|
|
113
|
+
};
|
|
114
|
+
// ---------------------------------------------------------------------------
|
|
115
|
+
// Public API
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
104
117
|
/** Derive a single field from a shape entry. */
|
|
105
118
|
const deriveField = (key, value, overrides) => {
|
|
106
119
|
const { inner, required, defaultValue, description } = unwrap(value);
|
|
107
|
-
const
|
|
120
|
+
const derived = deriveFieldType(inner);
|
|
121
|
+
if (!derived) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
const { type, options: rawOptions } = derived;
|
|
108
125
|
const override = overrides?.[key];
|
|
109
126
|
const label = override?.label ?? description ?? humanize(key);
|
|
110
127
|
const options = buildOptions(rawOptions, override?.options);
|
|
111
128
|
return { default: defaultValue, label, name: key, options, required, type };
|
|
112
129
|
};
|
|
130
|
+
/**
|
|
131
|
+
* Derive a runtime-agnostic Field[] from a Zod object schema.
|
|
132
|
+
*
|
|
133
|
+
* Uses Zod v4's `_zod.def` for introspection. Returns fields sorted by name.
|
|
134
|
+
*/
|
|
113
135
|
export const deriveFields = (schema, overrides) => {
|
|
114
136
|
const s = schema;
|
|
115
137
|
if (s._zod.def['type'] !== 'object') {
|
|
@@ -120,6 +142,8 @@ export const deriveFields = (schema, overrides) => {
|
|
|
120
142
|
return [];
|
|
121
143
|
}
|
|
122
144
|
const fields = Object.entries(shape).map(([key, value]) => deriveField(key, value, overrides));
|
|
123
|
-
return fields
|
|
145
|
+
return fields
|
|
146
|
+
.filter((field) => field !== null)
|
|
147
|
+
.toSorted((a, b) => a.name.localeCompare(b.name));
|
|
124
148
|
};
|
|
125
149
|
//# sourceMappingURL=derive.js.map
|
package/dist/derive.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derive.js","sourceRoot":"","sources":["../src/derive.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"derive.js","sourceRoot":"","sources":["../src/derive.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAuD9C,8EA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CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACtD,CAAC,CAAC"}
|
package/dist/draft.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ValidationError } from './errors.js';
|
|
2
|
+
import { Result } from './result.js';
|
|
3
|
+
import type { Topo } from './topo.js';
|
|
4
|
+
export declare const DRAFT_ID_PREFIX = "_draft.";
|
|
5
|
+
export type DraftDependencyKind = 'cross' | 'detour' | 'provision' | 'replaced-by' | 'signal-from';
|
|
6
|
+
export interface DraftDependency {
|
|
7
|
+
readonly fromId: string;
|
|
8
|
+
readonly kind: DraftDependencyKind;
|
|
9
|
+
readonly toId: string;
|
|
10
|
+
}
|
|
11
|
+
export interface DraftFinding {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly kind: 'provision' | 'signal' | 'trail' | 'unknown';
|
|
14
|
+
readonly message: string;
|
|
15
|
+
readonly rule: 'draft-contamination' | 'draft-id';
|
|
16
|
+
readonly via?: DraftDependencyKind | undefined;
|
|
17
|
+
readonly dependsOn?: string | undefined;
|
|
18
|
+
}
|
|
19
|
+
export interface DraftStateAnalysis {
|
|
20
|
+
readonly contaminatedIds: ReadonlySet<string>;
|
|
21
|
+
readonly declaredDraftIds: ReadonlySet<string>;
|
|
22
|
+
readonly dependencies: readonly DraftDependency[];
|
|
23
|
+
readonly findings: readonly DraftFinding[];
|
|
24
|
+
}
|
|
25
|
+
export declare const isDraftId: (id: string) => boolean;
|
|
26
|
+
export declare const analyzeDraftState: (topo: Topo) => DraftStateAnalysis;
|
|
27
|
+
export declare const validateEstablishedTopo: (topo: Topo) => Result<void, ValidationError>;
|
|
28
|
+
//# sourceMappingURL=draft.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draft.d.ts","sourceRoot":"","sources":["../src/draft.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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