@ontrails/schema 1.0.0-beta.0 → 1.0.0-beta.1

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.
@@ -1,3 +1,3 @@
1
1
  $ oxlint ./src
2
2
  Found 0 warnings and 0 errors.
3
- Finished in 109ms on 10 files with 93 rules using 24 threads.
3
+ Finished in 42ms on 10 files with 93 rules using 24 threads.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @ontrails/schema
2
2
 
3
+ ## 1.0.0-beta.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix two blocking bugs from real-world migration:
8
+ - Published packages now resolve correctly (workspace:^ instead of workspace:\*)
9
+ - Error forwarding works across different success types (Err no longer carries phantom T)
10
+ - Updated dependencies
11
+ - @ontrails/core@1.0.0-beta.1
12
+
3
13
  ## 1.0.0-beta.0
4
14
 
5
15
  ### Minor Changes
package/README.md CHANGED
@@ -1,131 +1,63 @@
1
1
  # @ontrails/schema
2
2
 
3
- Surface maps, diffing, and lock files for Trails. The machine-readable contract for CI and governance.
3
+ Surface maps, hashing, and semantic diffing for Trails. Generate a machine-readable snapshot of your topo, hash it into a lock file, and detect breaking changes before they ship.
4
4
 
5
- ## Installation
6
-
7
- ```bash
8
- bun add -d @ontrails/schema
9
- ```
10
-
11
- Peer dependencies: `@ontrails/core`, `zod`.
12
-
13
- ## Quick Start
5
+ ## Usage
14
6
 
15
7
  ```typescript
16
- import {
17
- generateSurfaceMap,
18
- hashSurfaceMap,
19
- diffSurfaceMaps,
20
- } from '@ontrails/schema';
8
+ import { generateSurfaceMap, hashSurfaceMap, diffSurfaceMaps } from '@ontrails/schema';
21
9
 
22
- // Generate the surface map from the topo
23
- const surfaceMap = generateSurfaceMap(app);
10
+ const map = generateSurfaceMap(app);
11
+ const hash = hashSurfaceMap(map);
24
12
 
25
- // Hash it for the lock file
26
- const hash = hashSurfaceMap(surfaceMap);
13
+ // Later, after changes:
14
+ const newMap = generateSurfaceMap(app);
15
+ const diff = diffSurfaceMaps(map, newMap);
27
16
 
28
- // Diff two surface maps
29
- const diff = diffSurfaceMaps(previousMap, surfaceMap);
30
17
  if (diff.hasBreaking) {
31
- console.error('Breaking changes detected:', diff.breaking);
18
+ console.error('Breaking changes:', diff.breaking);
32
19
  }
33
20
  ```
34
21
 
35
- ## API Overview
36
-
37
- ### `generateSurfaceMap(topo)`
38
-
39
- Produces a deterministic manifest of every trail in the topo. Entries are sorted alphabetically by ID. Input and output schemas are converted to JSON Schema via `zodToJsonSchema()`.
40
-
41
- ```typescript
42
- const map = generateSurfaceMap(app);
43
- // {
44
- // version: "1.0",
45
- // generatedAt: "2026-03-25T10:00:00.000Z",
46
- // entries: [
47
- // { id: "entity.show", kind: "trail", input: {...}, readOnly: true, exampleCount: 2 },
48
- // { id: "search", kind: "trail", input: {...}, exampleCount: 1 },
49
- // ]
50
- // }
51
- ```
52
-
53
- Each `SurfaceMapEntry` includes:
54
-
55
- - `id`, `kind` (`"trail"` | `"hike"` | `"event"`)
56
- - `input` and `output` as JSON Schema
57
- - Safety markers: `readOnly`, `destructive`, `idempotent`
58
- - `deprecated`, `replacedBy`
59
- - `follows` (for hikes), `detours`
60
- - `exampleCount`, `description`
61
-
62
- ### `hashSurfaceMap(surfaceMap)`
22
+ The surface map captures every trail's input/output schemas (as JSON Schema), safety markers, follows graph, and example counts. The hash goes into `surface.lock` -- a single committed line that CI can check for drift.
63
23
 
64
- SHA-256 hash of the surface map content. Excludes `generatedAt` so the same topo always produces the same hash byte-for-byte.
24
+ ## API
65
25
 
66
- ```typescript
67
- const hash = hashSurfaceMap(map); // "a1b2c3d4..."
68
- ```
26
+ | Export | What it does |
27
+ | --- | --- |
28
+ | `generateSurfaceMap(topo)` | Deterministic manifest of every trail, sorted by ID |
29
+ | `hashSurfaceMap(map)` | SHA-256 hash, excluding timestamps for stability |
30
+ | `diffSurfaceMaps(prev, curr)` | Semantic diff with breaking/warning/info severity |
31
+ | `writeSurfaceMap(map, options?)` | Write `.trails/_surface.json` (gitignored detail file) |
32
+ | `readSurfaceMap(options?)` | Read it back |
33
+ | `writeSurfaceLock(hash, options?)` | Write `surface.lock` (committed, single hash line) |
34
+ | `readSurfaceLock(options?)` | Read the lock hash |
69
35
 
70
- ### `diffSurfaceMaps(prev, curr)`
36
+ See the [API Reference](../../docs/api-reference.md) for the full list.
71
37
 
72
- Semantic diff between two surface maps. Classifies every change by severity instead of producing raw JSON diffs.
38
+ ## Breaking change detection
73
39
 
74
- ```typescript
75
- const diff = diffSurfaceMaps(previousMap, currentMap);
76
-
77
- diff.entries; // All changes
78
- diff.breaking; // Breaking changes only
79
- diff.warnings; // Warnings only
80
- diff.info; // Informational changes
81
- diff.hasBreaking; // Quick check
82
- ```
40
+ The diff classifies every change by severity:
83
41
 
84
- **Breaking change detection:**
85
-
86
- | Change | Severity |
87
- | -------------------------- | -------- |
88
- | Trail removed | breaking |
42
+ | Change | Severity |
43
+ | --- | --- |
44
+ | Trail removed | breaking |
89
45
  | Required input field added | breaking |
90
- | Input field removed | breaking |
91
- | Output field removed | breaking |
92
- | Output field type changed | breaking |
93
- | Surface removed | breaking |
94
- | Safety marker changed | warning |
95
- | Trail deprecated | warning |
96
- | Follows changed | warning |
97
- | Trail added | info |
98
- | Optional input field added | info |
99
- | Output field added | info |
100
- | Surface added | info |
101
-
102
- ### Lock File I/O
103
-
104
- ```typescript
105
- import {
106
- writeSurfaceMap, // .trails/_surface.json (gitignored detail file)
107
- readSurfaceMap, // Read it back
108
- writeSurfaceLock, // surface.lock (committed, single hash line)
109
- readSurfaceLock, // Read the lock hash
110
- } from '@ontrails/schema';
111
- ```
46
+ | Input/output field removed | breaking |
47
+ | Output field type changed | breaking |
48
+ | Safety marker changed | warning |
49
+ | Trail deprecated | warning |
50
+ | Follows changed | warning |
51
+ | Trail added | info |
52
+ | Optional input field added | info |
53
+ | Output field added | info |
112
54
 
113
- Default directory: `.trails/`. Override with `{ dir: "./custom" }`.
114
-
115
- - `_surface.json` -- Full surface map, gitignored. For local inspection and debugging.
116
- - `surface.lock` -- Single-line SHA-256 hash, committed to the repo. Source of truth for drift detection.
117
-
118
- ## Usage with Warden
55
+ ## Drift detection with warden
119
56
 
120
57
  ```typescript
121
- import {
122
- generateSurfaceMap,
123
- hashSurfaceMap,
124
- readSurfaceLock,
125
- } from '@ontrails/schema';
58
+ import { generateSurfaceMap, hashSurfaceMap, readSurfaceLock } from '@ontrails/schema';
126
59
 
127
- const map = generateSurfaceMap(app);
128
- const current = hashSurfaceMap(map);
60
+ const current = hashSurfaceMap(generateSurfaceMap(app));
129
61
  const committed = await readSurfaceLock();
130
62
 
131
63
  if (committed !== current) {
@@ -133,7 +65,10 @@ if (committed !== current) {
133
65
  }
134
66
  ```
135
67
 
136
- ## Further Reading
68
+ The `@ontrails/warden` package wraps this into a `checkDrift()` call with CI integration.
69
+
70
+ ## Installation
137
71
 
138
- - [Architecture](../../docs/architecture.md)
139
- - [Testing Guide](../../docs/testing.md)
72
+ ```bash
73
+ bun add -d @ontrails/schema
74
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ontrails/schema",
3
- "version": "1.0.0-beta.0",
3
+ "version": "1.0.0-beta.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts",
@@ -14,7 +14,7 @@
14
14
  "clean": "rm -rf dist *.tsbuildinfo"
15
15
  },
16
16
  "peerDependencies": {
17
- "@ontrails/core": "workspace:*",
17
+ "@ontrails/core": "workspace:^",
18
18
  "zod": "catalog:"
19
19
  }
20
20
  }