@ontrails/warden 1.0.0-beta.0 → 1.0.0-beta.2
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 +21 -0
- package/README.md +35 -76
- package/package.json +4 -4
package/.turbo/turbo-lint.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @ontrails/warden
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix workspace dependency resolution in published packages. Now using bun publish
|
|
8
|
+
which correctly replaces workspace:^ with actual version numbers.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @ontrails/core@1.0.0-beta.2
|
|
11
|
+
- @ontrails/schema@1.0.0-beta.2
|
|
12
|
+
|
|
13
|
+
## 1.0.0-beta.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Fix two blocking bugs from real-world migration:
|
|
18
|
+
- Published packages now resolve correctly (workspace:^ instead of workspace:\*)
|
|
19
|
+
- Error forwarding works across different success types (Err no longer carries phantom T)
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
- @ontrails/core@1.0.0-beta.1
|
|
22
|
+
- @ontrails/schema@1.0.0-beta.1
|
|
23
|
+
|
|
3
24
|
## 1.0.0-beta.0
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
# @ontrails/warden
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
AST-based code convention rules for Trails. 10 lint rules that catch contract violations at development time, plus surface lock drift detection and CI formatters.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Structural checks (follows existence, recursive follows, example schema validation) live in `validateTopo()` from `@ontrails/core`. Warden handles the code-level rules that need AST analysis.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
bun add -d @ontrails/warden
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Peer dependencies: `@ontrails/core`, `@ontrails/schema`.
|
|
12
|
-
|
|
13
|
-
## Quick Start
|
|
7
|
+
## Usage
|
|
14
8
|
|
|
15
9
|
From the Trails CLI:
|
|
16
10
|
|
|
@@ -30,62 +24,22 @@ const report = await runWarden(app, { exitCode: true });
|
|
|
30
24
|
console.log(formatWardenReport(report));
|
|
31
25
|
```
|
|
32
26
|
|
|
33
|
-
##
|
|
34
|
-
|
|
35
|
-
10 built-in rules under the `trails/` namespace:
|
|
27
|
+
## Rules
|
|
36
28
|
|
|
37
29
|
| Rule | Severity | What it catches |
|
|
38
30
|
| --- | --- | --- |
|
|
39
|
-
| `no-throw-in-implementation` | error | `throw`
|
|
40
|
-
| `
|
|
41
|
-
| `
|
|
42
|
-
| `
|
|
31
|
+
| `no-throw-in-implementation` | error | `throw` inside implementation bodies |
|
|
32
|
+
| `implementation-returns-result` | error | Implementations returning raw values instead of `Result` |
|
|
33
|
+
| `context-no-surface-types` | error | Surface type imports (`Request`, `McpSession`) in trail files |
|
|
34
|
+
| `no-sync-result-assumption` | error | Missing `await` on implementation results |
|
|
43
35
|
| `valid-detour-refs` | error | Detour targets that do not exist in the topo |
|
|
44
|
-
| `no-
|
|
45
|
-
| `no-
|
|
46
|
-
| `implementation-returns-result` | error | Implementations that return raw values instead of `Result` |
|
|
47
|
-
| `no-throw-in-detour-target` | error | `throw` inside trails that serve as detour targets |
|
|
36
|
+
| `no-throw-in-detour-target` | error | `throw` inside detour target trails |
|
|
37
|
+
| `no-direct-implementation-call` | warn | Direct `.implementation()` calls bypassing `ctx.follow()` |
|
|
48
38
|
| `no-direct-impl-in-route` | warn | Direct `.implementation()` calls inside hike bodies |
|
|
39
|
+
| `prefer-schema-inference` | warn | Redundant field overrides already derivable from the schema |
|
|
40
|
+
| `valid-describe-refs` | warn | `@see` refs in `.describe()` that do not resolve |
|
|
49
41
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
### Configuration
|
|
53
|
-
|
|
54
|
-
Add to `.oxlintrc.json`:
|
|
55
|
-
|
|
56
|
-
```json
|
|
57
|
-
{
|
|
58
|
-
"plugins": ["trails"],
|
|
59
|
-
"rules": {
|
|
60
|
-
"trails/no-throw-in-implementation": "error",
|
|
61
|
-
"trails/context-no-surface-types": "error",
|
|
62
|
-
"trails/valid-describe-refs": "warn",
|
|
63
|
-
"trails/valid-detour-refs": "error",
|
|
64
|
-
"trails/no-sync-result-assumption": "error",
|
|
65
|
-
"trails/implementation-returns-result": "error",
|
|
66
|
-
"trails/no-throw-in-detour-target": "error",
|
|
67
|
-
"trails/no-direct-implementation-call": "warn",
|
|
68
|
-
"trails/no-direct-impl-in-route": "warn",
|
|
69
|
-
"trails/prefer-schema-inference": "warn"
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### Key Rules
|
|
75
|
-
|
|
76
|
-
**`no-throw-in-implementation`** -- Implementations return `Result.err()`, never `throw`. Flags `ThrowStatement` nodes inside `implementation` function bodies.
|
|
77
|
-
|
|
78
|
-
**`context-no-surface-types`** -- Implementations are pure functions. Importing `Request`, `Response`, `McpSession`, or other surface types couples domain logic to a transport.
|
|
79
|
-
|
|
80
|
-
**`prefer-schema-inference`** -- `fields` is for enrichment, not repetition. If a label or enum options are already derivable from the Zod schema, remove the redundant override and let `derive()` supply it.
|
|
81
|
-
|
|
82
|
-
**`no-direct-implementation-call`** -- Direct `.implementation()` calls bypass validation, tracing, and layers. Application code should use `ctx.follow()` instead.
|
|
83
|
-
|
|
84
|
-
**`no-sync-result-assumption`** -- Trail implementations normalize to `Promise<Result>`, even when the author wrote a sync body. Callers must `await` before using `.isOk()`, `.value`, or other `Result` APIs.
|
|
85
|
-
|
|
86
|
-
**`valid-describe-refs`** -- `@see` tags inside schema `.describe()` strings are part of the contract surface. Warden warns when those references drift away from the actual topo.
|
|
87
|
-
|
|
88
|
-
## Drift Detection
|
|
42
|
+
## Drift detection
|
|
89
43
|
|
|
90
44
|
Warden integrates with `@ontrails/schema` to detect when the topo has changed without updating `surface.lock`:
|
|
91
45
|
|
|
@@ -94,20 +48,15 @@ import { checkDrift } from '@ontrails/warden';
|
|
|
94
48
|
|
|
95
49
|
const drift = await checkDrift(app);
|
|
96
50
|
if (drift.stale) {
|
|
97
|
-
console.log(
|
|
98
|
-
'surface.lock is stale -- regenerate with `trails survey generate`'
|
|
99
|
-
);
|
|
51
|
+
console.log('surface.lock is stale -- regenerate with `trails survey generate`');
|
|
100
52
|
}
|
|
101
53
|
```
|
|
102
54
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
## CI Integration
|
|
55
|
+
## CI integration
|
|
106
56
|
|
|
107
57
|
Add to lefthook for pre-push enforcement:
|
|
108
58
|
|
|
109
59
|
```yaml
|
|
110
|
-
# lefthook.yml
|
|
111
60
|
pre-push:
|
|
112
61
|
commands:
|
|
113
62
|
warden:
|
|
@@ -115,18 +64,28 @@ pre-push:
|
|
|
115
64
|
tags: governance
|
|
116
65
|
```
|
|
117
66
|
|
|
118
|
-
|
|
67
|
+
CI formatters for structured output:
|
|
119
68
|
|
|
120
69
|
```typescript
|
|
121
|
-
import {
|
|
122
|
-
runWarden,
|
|
123
|
-
formatWardenReport,
|
|
124
|
-
checkDrift,
|
|
125
|
-
wardenRules,
|
|
126
|
-
} from '@ontrails/warden';
|
|
70
|
+
import { formatGitHubAnnotations, formatJson, formatSummary } from '@ontrails/warden';
|
|
127
71
|
```
|
|
128
72
|
|
|
129
|
-
##
|
|
73
|
+
## API
|
|
74
|
+
|
|
75
|
+
| Export | What it does |
|
|
76
|
+
| --- | --- |
|
|
77
|
+
| `runWarden(app, options?)` | Run all rules and drift checks, return a report |
|
|
78
|
+
| `formatWardenReport(report)` | Human-readable report |
|
|
79
|
+
| `checkDrift(app)` | Check if `surface.lock` matches the current topo |
|
|
80
|
+
| `wardenRules` | Registry of all built-in rules |
|
|
81
|
+
| `formatGitHubAnnotations(report)` | GitHub Actions annotation format |
|
|
82
|
+
| `formatJson(report)` | Machine-readable JSON |
|
|
83
|
+
| `formatSummary(report)` | Compact summary line |
|
|
130
84
|
|
|
131
|
-
|
|
132
|
-
|
|
85
|
+
See the [API Reference](../../docs/api-reference.md) for the full list.
|
|
86
|
+
|
|
87
|
+
## Installation
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
bun add -d @ontrails/warden
|
|
91
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ontrails/warden",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./src/index.ts",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@oxc-project/types": "^0.122.0",
|
|
18
18
|
"oxc-parser": "^0.121.0",
|
|
19
|
-
"zod": "
|
|
19
|
+
"zod": "^4.3.5"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@ontrails/core": "
|
|
23
|
-
"@ontrails/schema": "
|
|
22
|
+
"@ontrails/core": "^1.0.0-beta.0",
|
|
23
|
+
"@ontrails/schema": "^1.0.0-beta.0"
|
|
24
24
|
}
|
|
25
25
|
}
|