@telorun/analyzer 0.64.0 → 0.66.0
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/dist/analyzer.d.ts +1 -1
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/analyzer.js +175 -65
- package/dist/call-graph.d.ts.map +1 -1
- package/dist/call-graph.js +7 -1
- package/dist/cel-environment.d.ts +12 -0
- package/dist/cel-environment.d.ts.map +1 -1
- package/dist/cel-environment.js +35 -19
- package/dist/cel-scope.d.ts.map +1 -1
- package/dist/cel-scope.js +24 -4
- package/dist/definition-registry.d.ts +47 -6
- package/dist/definition-registry.d.ts.map +1 -1
- package/dist/definition-registry.js +82 -13
- package/dist/eval-paths.d.ts +68 -0
- package/dist/eval-paths.d.ts.map +1 -1
- package/dist/eval-paths.js +138 -0
- package/dist/flatten-for-analyzer.d.ts +1 -1
- package/dist/flatten-for-analyzer.js +1 -1
- package/dist/import-resolution-diagnostics.d.ts +1 -1
- package/dist/import-resolution-diagnostics.js +1 -1
- package/dist/index.d.ts +13 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -6
- package/dist/manifest-visitor.d.ts.map +1 -1
- package/dist/manifest-visitor.js +8 -1
- package/dist/migrations/entries/index.d.ts.map +1 -1
- package/dist/migrations/entries/index.js +2 -0
- package/dist/migrations/entries/schema-prepare-bucket.json +27 -0
- package/dist/peer-binding.d.ts +232 -0
- package/dist/peer-binding.d.ts.map +1 -0
- package/dist/peer-binding.js +418 -0
- package/dist/ref-slot.d.ts +13 -0
- package/dist/ref-slot.d.ts.map +1 -1
- package/dist/ref-slot.js +26 -0
- package/dist/reference-field-map.d.ts +28 -0
- package/dist/reference-field-map.d.ts.map +1 -1
- package/dist/reference-field-map.js +25 -0
- package/dist/referrer-rule.d.ts +17 -0
- package/dist/referrer-rule.d.ts.map +1 -1
- package/dist/referrer-rule.js +4 -1
- package/dist/release/index.d.ts +1 -1
- package/dist/release/index.js +1 -1
- package/dist/resource-rule.d.ts +40 -27
- package/dist/resource-rule.d.ts.map +1 -1
- package/dist/resource-rule.js +61 -7
- package/dist/rule-condition.d.ts +11 -0
- package/dist/rule-condition.d.ts.map +1 -1
- package/dist/rule-condition.js +13 -0
- package/dist/schema-compat.d.ts +59 -22
- package/dist/schema-compat.d.ts.map +1 -1
- package/dist/schema-compat.js +60 -75
- package/dist/schema-error-report.d.ts +68 -0
- package/dist/schema-error-report.d.ts.map +1 -0
- package/dist/schema-error-report.js +356 -0
- package/dist/schema-projection.d.ts +106 -4
- package/dist/schema-projection.d.ts.map +1 -1
- package/dist/schema-projection.js +206 -18
- package/dist/telo-version.d.ts +1 -1
- package/dist/telo-version.js +1 -1
- package/dist/validate-cel-context.d.ts +1 -17
- package/dist/validate-cel-context.d.ts.map +1 -1
- package/dist/validate-cel-context.js +5 -70
- package/dist/validate-nested-inline.d.ts +22 -1
- package/dist/validate-nested-inline.d.ts.map +1 -1
- package/dist/validate-nested-inline.js +17 -9
- package/dist/validate-reference-forms.d.ts +10 -0
- package/dist/validate-reference-forms.d.ts.map +1 -1
- package/dist/validate-reference-forms.js +23 -0
- package/dist/validate-references.d.ts.map +1 -1
- package/dist/validate-references.js +9 -2
- package/dist/validate-referrer-rules.d.ts +38 -4
- package/dist/validate-referrer-rules.d.ts.map +1 -1
- package/dist/validate-referrer-rules.js +139 -31
- package/dist/validate-resource-rules.d.ts +11 -2
- package/dist/validate-resource-rules.d.ts.map +1 -1
- package/dist/validate-resource-rules.js +18 -12
- package/dist/validate-schema-projection.d.ts.map +1 -1
- package/dist/validate-schema-projection.js +33 -2
- package/dist/validate-step-inputs.js +11 -3
- package/dist/with-synthetic-positions.d.ts +1 -1
- package/dist/with-synthetic-positions.js +1 -1
- package/package.json +3 -3
- package/src/analyzer.ts +211 -68
- package/src/call-graph.ts +7 -1
- package/src/cel-environment.ts +48 -19
- package/src/cel-scope.ts +24 -6
- package/src/definition-registry.ts +90 -11
- package/src/eval-paths.ts +152 -0
- package/src/flatten-for-analyzer.ts +1 -1
- package/src/import-resolution-diagnostics.ts +1 -1
- package/src/index.ts +55 -6
- package/src/manifest-visitor.ts +8 -1
- package/src/migrations/entries/index.ts +2 -0
- package/src/migrations/entries/schema-prepare-bucket.json +27 -0
- package/src/peer-binding.ts +641 -0
- package/src/ref-slot.ts +36 -0
- package/src/reference-field-map.ts +42 -0
- package/src/referrer-rule.ts +20 -1
- package/src/release/index.ts +1 -1
- package/src/resource-rule.ts +69 -7
- package/src/rule-condition.ts +15 -0
- package/src/schema-compat.ts +92 -79
- package/src/schema-error-report.ts +417 -0
- package/src/schema-projection.ts +283 -20
- package/src/telo-version.ts +1 -1
- package/src/validate-cel-context.ts +6 -71
- package/src/validate-nested-inline.ts +35 -14
- package/src/validate-reference-forms.ts +22 -0
- package/src/validate-references.ts +15 -2
- package/src/validate-referrer-rules.ts +215 -28
- package/src/validate-resource-rules.ts +26 -12
- package/src/validate-schema-projection.ts +50 -1
- package/src/validate-step-inputs.ts +10 -4
- package/src/with-synthetic-positions.ts +1 -1
|
@@ -8,10 +8,19 @@ import {
|
|
|
8
8
|
isSchemaFromEntry,
|
|
9
9
|
type ReferenceFieldMap,
|
|
10
10
|
} from "./reference-field-map.js";
|
|
11
|
-
import { createAjv,
|
|
11
|
+
import { createAjv, navigateJsonPointer } from "./schema-compat.js";
|
|
12
|
+
import {
|
|
13
|
+
formatSingleError,
|
|
14
|
+
reduceSchemaErrors,
|
|
15
|
+
schemaIssues,
|
|
16
|
+
type SchemaIssue,
|
|
17
|
+
} from "./schema-error-report.js";
|
|
12
18
|
import { effectiveAuthorSchema } from "./extends-resolution.js";
|
|
13
19
|
|
|
14
20
|
/** Pure kind → ResourceDefinition map. No controller loading, no lifecycle. */
|
|
21
|
+
/** What `ajv.compile` hands back: a predicate carrying its own `errors`. */
|
|
22
|
+
type CompiledValidator = ((data: unknown) => boolean) & { errors?: any[] | null };
|
|
23
|
+
|
|
15
24
|
export class DefinitionRegistry {
|
|
16
25
|
constructor() {
|
|
17
26
|
for (const def of KERNEL_BUILTINS) this.register(def);
|
|
@@ -22,6 +31,7 @@ export class DefinitionRegistry {
|
|
|
22
31
|
* across analyze() calls and no unbounded growth across the process lifetime. */
|
|
23
32
|
private readonly ajv = createAjv();
|
|
24
33
|
private readonly registeredSchemaIds = new Set<string>();
|
|
34
|
+
private readonly compiledValidators = new WeakMap<Record<string, any>, CompiledValidator>();
|
|
25
35
|
/** The subset of `registeredSchemaIds` claimed by a kind's schema. Kinds and
|
|
26
36
|
* named `Telo.Type`s share one `telo://<module>/<Name>` id space, so this is
|
|
27
37
|
* what lets a colliding type name be reported instead of silently dropped. */
|
|
@@ -31,6 +41,9 @@ export class DefinitionRegistry {
|
|
|
31
41
|
private readonly fieldMaps = new Map<string, ReferenceFieldMap>();
|
|
32
42
|
/** Reverse inheritance index: parent kind → direct child kinds. */
|
|
33
43
|
private readonly extendedBy = new Map<string, string[]>();
|
|
44
|
+
/** Memoized inheritance-resolved schemas. `null` records "resolved to
|
|
45
|
+
* nothing", so a kind with no schema is not re-walked on every resource. */
|
|
46
|
+
private readonly effectiveSchemas = new Map<string, Record<string, unknown> | null>();
|
|
34
47
|
/** DEPRECATED module identity table: identity string → canonical module name
|
|
35
48
|
* ("std/pipeline" → "pipeline"). Serves only the legacy
|
|
36
49
|
* `<namespace>/<module>#<Kind>` form of `x-telo-ref`, kept resolvable for
|
|
@@ -47,6 +60,7 @@ export class DefinitionRegistry {
|
|
|
47
60
|
// so any already-computed map recomputes against the now-larger def set; the
|
|
48
61
|
// maps rebuild lazily on first `getFieldMap` (after all defs are registered).
|
|
49
62
|
this.fieldMaps.clear();
|
|
63
|
+
this.effectiveSchemas.clear();
|
|
50
64
|
// `capability` populates extendedBy for backward-compat with the legacy pattern where
|
|
51
65
|
// a concrete definition overloaded `capability: <AbstractKind>` to mean "implements
|
|
52
66
|
// this abstract." The canonical pattern is `extends` (below). Both populate the index,
|
|
@@ -162,20 +176,47 @@ export class DefinitionRegistry {
|
|
|
162
176
|
return schema && typeof schema === "object" ? (schema as Record<string, any>) : undefined;
|
|
163
177
|
}
|
|
164
178
|
|
|
165
|
-
/**
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
179
|
+
/**
|
|
180
|
+
* Validates a resource's configuration against its kind's schema, with the
|
|
181
|
+
* offending field's path — what a `SCHEMA_VIOLATION` diagnostic is built from.
|
|
182
|
+
*
|
|
183
|
+
* On THIS registry's AJV, which is the point: it holds every registered
|
|
184
|
+
* definition schema and every named `Telo.Type`, so a kind whose schema
|
|
185
|
+
* references a shape declared elsewhere is checked rather than skipped. The
|
|
186
|
+
* module-level instance this used to run on had none of them registered, so
|
|
187
|
+
* such a schema failed to compile and the failure was swallowed — a resource
|
|
188
|
+
* could be arbitrarily wrong and `telo check` reported nothing, while the
|
|
189
|
+
* kernel (whose validator does resolve the reference) rejected it at boot.
|
|
190
|
+
* Two AJVs answering one question is what made that possible; there is now
|
|
191
|
+
* one, and it is the same one `schemaCompileError` reports through.
|
|
192
|
+
*/
|
|
170
193
|
validateWithRefs(data: unknown, schema: Record<string, any>): string[] {
|
|
171
|
-
|
|
194
|
+
const validate = this.compiledFor(schema);
|
|
195
|
+
if (!validate || validate(data)) return [];
|
|
196
|
+
return reduceSchemaErrors(validate.errors).map(formatSingleError);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** {@link validateWithRefs}, with the path each issue is anchored at. */
|
|
200
|
+
validateResourceConfig(data: unknown, schema: Record<string, any>): SchemaIssue[] {
|
|
201
|
+
const validate = this.compiledFor(schema);
|
|
202
|
+
if (!validate || validate(data)) return [];
|
|
203
|
+
return schemaIssues(validate.errors);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** Memoized per schema OBJECT — the analyzer validates every resource of a
|
|
207
|
+
* kind against the same one, and this runs at keystroke time in an editor.
|
|
208
|
+
* A schema AJV refuses compiles to `undefined`; that is reported once,
|
|
209
|
+
* anchored on the owning definition, by `schemaCompileError`. */
|
|
210
|
+
private compiledFor(schema: Record<string, any>): CompiledValidator | undefined {
|
|
211
|
+
const cached = this.compiledValidators.get(schema);
|
|
212
|
+
if (cached) return cached;
|
|
172
213
|
try {
|
|
173
|
-
validate = this.ajv.compile(schema);
|
|
214
|
+
const validate = this.ajv.compile(schema);
|
|
215
|
+
this.compiledValidators.set(schema, validate);
|
|
216
|
+
return validate;
|
|
174
217
|
} catch {
|
|
175
|
-
return
|
|
218
|
+
return undefined;
|
|
176
219
|
}
|
|
177
|
-
if (validate(data)) return [];
|
|
178
|
-
return (validate.errors ?? []).map(formatSingleError);
|
|
179
220
|
}
|
|
180
221
|
|
|
181
222
|
/** Returns the AJV compile error for `schema`, or `undefined` when it compiles.
|
|
@@ -248,6 +289,44 @@ export class DefinitionRegistry {
|
|
|
248
289
|
return this.defs.get(kind);
|
|
249
290
|
}
|
|
250
291
|
|
|
292
|
+
/**
|
|
293
|
+
* The kind's AUTHOR-FACING schema — its own merged with everything it
|
|
294
|
+
* inherits along `extends` — memoized per kind.
|
|
295
|
+
*
|
|
296
|
+
* This is what every consumer reading a kind's schema to interpret an
|
|
297
|
+
* INSTANCE must use, because that is the schema the instance was authored
|
|
298
|
+
* against and the one the kernel stamps at definition registration. Reading
|
|
299
|
+
* `resolve(kind).schema` instead sees only what the leaf declared, so an
|
|
300
|
+
* annotation on a parent — a CEL context region, a step body, an error
|
|
301
|
+
* context — is invisible on every child, silently and per consumer. Sharing
|
|
302
|
+
* one memo is what keeps those consumers from drifting apart.
|
|
303
|
+
*
|
|
304
|
+
* Lazy for the same reason `getFieldMap` is: a child registered before its
|
|
305
|
+
* parent still sees the inherited half once both are present.
|
|
306
|
+
*/
|
|
307
|
+
effectiveSchema(kind: string): Record<string, unknown> | undefined {
|
|
308
|
+
const cached = this.effectiveSchemas.get(kind);
|
|
309
|
+
if (cached !== undefined) return cached ?? undefined;
|
|
310
|
+
const def = this.defs.get(kind);
|
|
311
|
+
if (!def) return undefined;
|
|
312
|
+
const schema = effectiveAuthorSchema(def, (k) => this.resolve(k)) as
|
|
313
|
+
| Record<string, unknown>
|
|
314
|
+
| undefined;
|
|
315
|
+
this.effectiveSchemas.set(kind, schema ?? null);
|
|
316
|
+
return schema;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** The effective schema for a definition, by the kind it is registered under.
|
|
320
|
+
* Falls back to the definition's own schema when it is not in this registry
|
|
321
|
+
* (a synthesized or not-yet-registered kind), which is the pre-inheritance
|
|
322
|
+
* behaviour and the safe direction: it types less, never wrongly. */
|
|
323
|
+
effectiveSchemaOf(definition: ResourceDefinition | undefined): Record<string, unknown> | undefined {
|
|
324
|
+
if (!definition) return undefined;
|
|
325
|
+
const { name, module: mod } = definition.metadata;
|
|
326
|
+
const resolved = this.effectiveSchema(mod ? `${mod}.${name}` : name);
|
|
327
|
+
return resolved ?? (definition.schema as Record<string, unknown> | undefined);
|
|
328
|
+
}
|
|
329
|
+
|
|
251
330
|
/** Returns the reference field map for the given kind, computed lazily from the
|
|
252
331
|
* kind's AUTHOR-FACING (inheritance-resolved) schema and memoized. Lazy so a
|
|
253
332
|
* child registered before its parent still sees the parent's inherited ref
|
package/src/eval-paths.ts
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WHERE IS CEL EVALUATED — the one reader, and the one decision built on it.
|
|
3
|
+
*
|
|
4
|
+
* Two independent ways a value is evaluated, and every consumer needs both:
|
|
5
|
+
* `x-telo-eval` names a field directly, while a REGION annotation
|
|
6
|
+
* (`x-telo-context` / `x-telo-step-context` / `x-telo-error-context`, or a step
|
|
7
|
+
* body) covers everything beneath it — which is how `Run.Choice`'s rows and an
|
|
8
|
+
* `Http.Api` route's `returns:` entries hold expressions while declaring no
|
|
9
|
+
* annotation of their own.
|
|
10
|
+
*
|
|
11
|
+
* The consumers are on both sides of the runtime: `telo check` decides whether a
|
|
12
|
+
* `!cel` here is live (`CEL_IN_NON_EVAL_FIELD`) or resolved at startup
|
|
13
|
+
* (`OBSERVED_STATE_IN_STARTUP_FIELD`), the kernel decides what to expand, and
|
|
14
|
+
* the editor decides whether to offer an expression at all. The editor's answer
|
|
15
|
+
* is a CLAIM that `telo check` will accept what it writes, so a second
|
|
16
|
+
* implementation there is a promise nothing keeps — it read `x-telo-eval` alone
|
|
17
|
+
* and left every predicate inside a region as a bare checkbox, with no way to
|
|
18
|
+
* write the expression the field exists to hold.
|
|
19
|
+
*
|
|
20
|
+
* Browser-safe: no Node built-ins.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { isStepSlot } from "./step-slot.js";
|
|
24
|
+
|
|
1
25
|
/**
|
|
2
26
|
* The single containment rule for `x-telo-eval` paths, shared by every matcher so
|
|
3
27
|
* the analyzer's coverage decision and the kernel's expansion/exclusion can't
|
|
@@ -66,3 +90,131 @@ function collectEvalPathsNode(
|
|
|
66
90
|
}
|
|
67
91
|
}
|
|
68
92
|
}
|
|
93
|
+
|
|
94
|
+
/** Schema keys that declare a CEL-bearing region: a field carrying any of these
|
|
95
|
+
* is evaluated at runtime, so a `!cel` inside it (or a descendant) is live. A
|
|
96
|
+
* STEP BODY is one too, and says so through the grammar its items point at
|
|
97
|
+
* rather than through a key — {@link isStepSlot} reads either spelling. */
|
|
98
|
+
const CEL_REGION_KEYS = [
|
|
99
|
+
"x-telo-context",
|
|
100
|
+
"x-telo-step-context",
|
|
101
|
+
"x-telo-error-context",
|
|
102
|
+
] as const;
|
|
103
|
+
|
|
104
|
+
/** True when this schema node declares a CEL-bearing region. Node-level, so a
|
|
105
|
+
* consumer holding one schema (an editor rendering one field) asks it directly
|
|
106
|
+
* rather than deriving scopes it would then have to match against. */
|
|
107
|
+
export function declaresCelRegion(schema: unknown): boolean {
|
|
108
|
+
if (!schema || typeof schema !== "object") return false;
|
|
109
|
+
const node = schema as Record<string, unknown>;
|
|
110
|
+
return CEL_REGION_KEYS.some((key) => node[key] !== undefined) || isStepSlot(node);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Walk a JSON Schema tree and collect the JSONPath scopes of every field that
|
|
115
|
+
* declares a CEL-bearing region (`x-telo-context` / `x-telo-step-context` /
|
|
116
|
+
* `x-telo-error-context`). Used — alongside `x-telo-eval` paths — to decide
|
|
117
|
+
* whether a `!cel` expression sits in a slot the runtime actually evaluates.
|
|
118
|
+
* Scopes use the same `$.a.b[*]` form as `extractContextsFromSchema`, matched
|
|
119
|
+
* against expression paths with `pathMatchesScope`.
|
|
120
|
+
*/
|
|
121
|
+
export function extractCelRegionScopes(schema: Record<string, any>, path = "$"): string[] {
|
|
122
|
+
if (!schema || typeof schema !== "object") return [];
|
|
123
|
+
const out: string[] = [];
|
|
124
|
+
|
|
125
|
+
if (declaresCelRegion(schema)) out.push(path);
|
|
126
|
+
|
|
127
|
+
if (schema.properties) {
|
|
128
|
+
for (const [key, value] of Object.entries(schema.properties as Record<string, any>)) {
|
|
129
|
+
out.push(...extractCelRegionScopes(value, `${path}.${key}`));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (schema.items && typeof schema.items === "object") {
|
|
133
|
+
out.push(...extractCelRegionScopes(schema.items, `${path}[*]`));
|
|
134
|
+
}
|
|
135
|
+
for (const key of ["oneOf", "anyOf", "allOf"] as const) {
|
|
136
|
+
if (Array.isArray(schema[key])) {
|
|
137
|
+
for (const subschema of schema[key]) out.push(...extractCelRegionScopes(subschema, path));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return out;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Returns true when a CEL expression path (from walkCelExpressions, e.g. "routes[0].inputs.q")
|
|
146
|
+
* falls within the scope of a context (e.g. "$.routes[*].inputs").
|
|
147
|
+
*
|
|
148
|
+
* The scope is matched directly (no sibling sharing): a context at "$.routes[*].inputs" only
|
|
149
|
+
* applies to expressions whose path starts with "routes[N].inputs", not to other sibling fields.
|
|
150
|
+
*/
|
|
151
|
+
export function pathMatchesScope(exprPath: string, scope: string): boolean {
|
|
152
|
+
const stripped = scope.startsWith("$.") ? scope.slice(2) : scope;
|
|
153
|
+
if (!stripped) return false;
|
|
154
|
+
|
|
155
|
+
// Split on wildcard array segments; each [*] must match a concrete [N] in exprPath
|
|
156
|
+
const parts = stripped.split("[*]");
|
|
157
|
+
let remaining = exprPath;
|
|
158
|
+
for (let i = 0; i < parts.length; i++) {
|
|
159
|
+
const part = parts[i]!;
|
|
160
|
+
if (!remaining.startsWith(part)) return false;
|
|
161
|
+
remaining = remaining.slice(part.length);
|
|
162
|
+
if (i < parts.length - 1) {
|
|
163
|
+
// Expect a concrete array index like [0], [12], ...
|
|
164
|
+
const m = remaining.match(/^\[\d+\]/);
|
|
165
|
+
if (!m) return false;
|
|
166
|
+
remaining = remaining.slice(m[0].length);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// Expression must end here or continue into a child path
|
|
170
|
+
return remaining === "" || remaining[0] === "." || remaining[0] === "[";
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** Every place a schema says its values are evaluated: the `x-telo-eval` paths,
|
|
174
|
+
* by mode, plus the scopes of the regions that cover their contents. */
|
|
175
|
+
export interface CelEvalSites {
|
|
176
|
+
compile: readonly string[];
|
|
177
|
+
runtime: readonly string[];
|
|
178
|
+
regions: readonly string[];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export const NO_CEL_EVAL_SITES: CelEvalSites = { compile: [], runtime: [], regions: [] };
|
|
182
|
+
|
|
183
|
+
export function celEvalSites(schema: Record<string, any> | undefined): CelEvalSites {
|
|
184
|
+
if (!schema) return NO_CEL_EVAL_SITES;
|
|
185
|
+
const { compile, runtime } = buildEvalPaths(schema);
|
|
186
|
+
return { compile, runtime, regions: extractCelRegionScopes(schema) };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** The union of several schemas' sites — a kind's own and its capability
|
|
190
|
+
* abstract's, which is how a `Telo.Provider`'s implicit compile-eval reaches
|
|
191
|
+
* fields the provider never annotated. */
|
|
192
|
+
export function mergeCelEvalSites(...sites: CelEvalSites[]): CelEvalSites {
|
|
193
|
+
return {
|
|
194
|
+
compile: sites.flatMap((s) => s.compile),
|
|
195
|
+
runtime: sites.flatMap((s) => s.runtime),
|
|
196
|
+
regions: sites.flatMap((s) => s.regions),
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Whether the value at `path` is evaluated, and when — null for a field whose
|
|
202
|
+
* value is read as a literal.
|
|
203
|
+
*
|
|
204
|
+
* `compile` wins over `runtime`, and both win over a region: a field's own
|
|
205
|
+
* annotation is more specific than the region it sits in, which is the same
|
|
206
|
+
* precedence a nested annotation has over an enclosing one. A region resolves to
|
|
207
|
+
* `runtime` because that is what a region IS — a per-invocation scope naming
|
|
208
|
+
* what its expressions can read.
|
|
209
|
+
*
|
|
210
|
+
* `path` is the `walkCelExpressions` spelling (`routes[0].returns[1].when`).
|
|
211
|
+
*/
|
|
212
|
+
export function celEvalModeAt(
|
|
213
|
+
sites: CelEvalSites,
|
|
214
|
+
path: string,
|
|
215
|
+
): "compile" | "runtime" | null {
|
|
216
|
+
if (evalPathsCover(sites.compile, path)) return "compile";
|
|
217
|
+
if (evalPathsCover(sites.runtime, path)) return "runtime";
|
|
218
|
+
if (sites.regions.some((scope) => pathMatchesScope(path, scope))) return "runtime";
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
@@ -23,7 +23,7 @@ export function parseExportEntry(entry: string): ParsedExportEntry {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/** The import-boundary forwarding rule, shared by `flattenForAnalyzer` (the
|
|
26
|
-
* CLI / kernel loader path) and
|
|
26
|
+
* CLI / kernel loader path) and telo studio's workspace projection so the
|
|
27
27
|
* two cannot drift. Given one module's stamped manifests and whether that
|
|
28
28
|
* module is the analysis entry (root), returns the manifests that cross into
|
|
29
29
|
* the consumer's flat analysis list:
|
|
@@ -46,7 +46,7 @@ function messageFor(e: GraphLoadError, code: ReturnType<typeof classify>): strin
|
|
|
46
46
|
/**
|
|
47
47
|
* Convert a graph's import failures (`graph.errors`) into structured, coded
|
|
48
48
|
* diagnostics. This is the single source of truth for surfacing a broken
|
|
49
|
-
* import — every host (CLI, VS Code, telo
|
|
49
|
+
* import — every host (CLI, VS Code, telo studio) routes these instead of each
|
|
50
50
|
* re-deriving the channel and drifting (the VS Code extension used to drop it
|
|
51
51
|
* entirely, showing nothing for a broken import).
|
|
52
52
|
*
|
package/src/index.ts
CHANGED
|
@@ -24,7 +24,16 @@ export {
|
|
|
24
24
|
type ParsedExportEntry,
|
|
25
25
|
type ReExportSpec,
|
|
26
26
|
} from "./flatten-for-analyzer.js";
|
|
27
|
-
export {
|
|
27
|
+
export {
|
|
28
|
+
buildEvalPaths,
|
|
29
|
+
celEvalModeAt,
|
|
30
|
+
celEvalSites,
|
|
31
|
+
declaresCelRegion,
|
|
32
|
+
evalPathCovers,
|
|
33
|
+
mergeCelEvalSites,
|
|
34
|
+
NO_CEL_EVAL_SITES,
|
|
35
|
+
} from "./eval-paths.js";
|
|
36
|
+
export type { CelEvalSites } from "./eval-paths.js";
|
|
28
37
|
export {
|
|
29
38
|
BINDINGS_ANNOTATION,
|
|
30
39
|
bindingContextProperties,
|
|
@@ -96,8 +105,17 @@ export type {
|
|
|
96
105
|
ResourceGraphNode,
|
|
97
106
|
StepGraphNode,
|
|
98
107
|
} from "./call-graph.js";
|
|
99
|
-
export {
|
|
100
|
-
|
|
108
|
+
export {
|
|
109
|
+
buildReferenceFieldMap,
|
|
110
|
+
isRefEntry,
|
|
111
|
+
isScopeEntry,
|
|
112
|
+
satisfiesValueBranch,
|
|
113
|
+
} from "./reference-field-map.js";
|
|
114
|
+
export type {
|
|
115
|
+
ReferenceFieldMap,
|
|
116
|
+
RefFieldEntry,
|
|
117
|
+
ValueBranchValidator,
|
|
118
|
+
} from "./reference-field-map.js";
|
|
101
119
|
export {
|
|
102
120
|
hasDeclaredUse,
|
|
103
121
|
isRefSlot,
|
|
@@ -181,6 +199,8 @@ export {
|
|
|
181
199
|
readRawResourceRules,
|
|
182
200
|
resolveRuleSubjects,
|
|
183
201
|
findDynamicLeaf,
|
|
202
|
+
dynamicNode,
|
|
203
|
+
type DynamicLeaf,
|
|
184
204
|
type ResourceRule,
|
|
185
205
|
type ResourceRuleSeverity,
|
|
186
206
|
type RuleSubject,
|
|
@@ -211,11 +231,32 @@ export {
|
|
|
211
231
|
type ReferrerRuleIssue,
|
|
212
232
|
type ReferrerRuleFinding,
|
|
213
233
|
type ReferrerRuleDiagnostic,
|
|
234
|
+
type ReferrerRuleContext,
|
|
235
|
+
type ReferrerRuleDeclarationContext,
|
|
214
236
|
} from "./validate-referrer-rules.js";
|
|
215
|
-
export {
|
|
237
|
+
export {
|
|
238
|
+
PeerBinder,
|
|
239
|
+
analyzerPeerBinder,
|
|
240
|
+
analyzerPeersTarget,
|
|
241
|
+
entryBoundary,
|
|
242
|
+
navigatePath,
|
|
243
|
+
referenceValueOf,
|
|
244
|
+
shapeMatches,
|
|
245
|
+
type DeclarationLookup,
|
|
246
|
+
type PeerAliasScope,
|
|
247
|
+
type PeerBinderEnv,
|
|
248
|
+
type PeerBinderRegistry,
|
|
249
|
+
type PeerBinding,
|
|
250
|
+
type PeerBindingFailure,
|
|
251
|
+
type PeerBindingResult,
|
|
252
|
+
type PeersTarget,
|
|
253
|
+
} from "./peer-binding.js";
|
|
254
|
+
export { RULE_BUDGET_MS, UNTAGGED_CONDITION } from "./rule-condition.js";
|
|
216
255
|
export {
|
|
217
256
|
readSchemaProjection,
|
|
257
|
+
type ProjectionReference,
|
|
218
258
|
readSchemaMap,
|
|
259
|
+
schemaMapBranch,
|
|
219
260
|
readProjectionFrom,
|
|
220
261
|
readProjectionRef,
|
|
221
262
|
manifestListScope,
|
|
@@ -247,8 +288,16 @@ export { validateDynamicSelectors, validateRefSlotDeclarations } from "./validat
|
|
|
247
288
|
export type { RefSlotIssue } from "./validate-ref-slots.js";
|
|
248
289
|
export { validateValueTypeSlots } from "./validate-value-type-slots.js";
|
|
249
290
|
export type { ValueTypeSlotIssue } from "./validate-value-type-slots.js";
|
|
250
|
-
export { checkSchemaCompatibility, selectUnionBranch } from "./schema-compat.js";
|
|
251
|
-
export type { CompatibilityResult } from "./schema-compat.js";
|
|
291
|
+
export { checkSchemaCompatibility, resolveRefIn, selectUnionBranch } from "./schema-compat.js";
|
|
292
|
+
export type { CompatibilityResult, ExternalSchemaResolver } from "./schema-compat.js";
|
|
293
|
+
export {
|
|
294
|
+
ajvErrorToPath,
|
|
295
|
+
formatAjvErrors,
|
|
296
|
+
formatSingleError,
|
|
297
|
+
reduceSchemaErrors,
|
|
298
|
+
schemaIssues,
|
|
299
|
+
} from "./schema-error-report.js";
|
|
300
|
+
export type { AjvErrorLike, SchemaIssue } from "./schema-error-report.js";
|
|
252
301
|
export { visitManifest } from "./manifest-visitor.js";
|
|
253
302
|
export type {
|
|
254
303
|
CelSiteEvent,
|
package/src/manifest-visitor.ts
CHANGED
|
@@ -359,7 +359,14 @@ export function visitManifest(
|
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
if (wantsCel) {
|
|
362
|
-
|
|
362
|
+
// The INHERITANCE-RESOLVED schema: an `extends` child is authored against
|
|
363
|
+
// merge(parent, own), so a context region the parent declares is in force
|
|
364
|
+
// on the child. Reading the child's own schema typed the region on
|
|
365
|
+
// whichever kind happened to declare it and left every descendant's
|
|
366
|
+
// expressions unchecked — silently, which for a typing rule means the
|
|
367
|
+
// check simply stops existing.
|
|
368
|
+
const authorSchema = registry.effectiveSchemaOf(definition);
|
|
369
|
+
const contexts = authorSchema ? extractContextsFromSchema(authorSchema) : [];
|
|
363
370
|
walkCelExpressions(r, "", (expr, path, engineName, surface) => {
|
|
364
371
|
let contextSchema: Record<string, any> | undefined;
|
|
365
372
|
let matchedScope: string | undefined;
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
// Source: analyzer/migrations/*.json (lexically ordered).
|
|
3
3
|
import e0 from "./normalize-value-types.json" with { type: "json" };
|
|
4
4
|
import e1 from "./ref-slot-scalar-type.json" with { type: "json" };
|
|
5
|
+
import e2 from "./schema-prepare-bucket.json" with { type: "json" };
|
|
5
6
|
|
|
6
7
|
/** Every entry file, in the order the driver applies them. */
|
|
7
8
|
export const MIGRATION_ENTRY_FILES: ReadonlyArray<readonly [file: string, data: unknown]> = [
|
|
8
9
|
["normalize-value-types.json", e0],
|
|
9
10
|
["ref-slot-scalar-type.json", e1],
|
|
11
|
+
["schema-prepare-bucket.json", e2],
|
|
10
12
|
];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "`inKind` names the two backend schema kinds by their canonical `<module>.<Kind>` spelling, which is what a document's `kind:` carries after alias resolution. `under` is the key itself: the bucket is a top-level field of the resource, so the region and the match are the same node \u2014 the tightest containment this vocabulary can state. NAMING A MODULE'S KIND FROM A CORE ENTRY IS A DEBT, not a pattern: it is the one place the analyzer knows a standard-library kind by name. It is contained because `inKind` is a filter \u2014 an entry naming an absent kind matches nothing \u2014 and it MOVES into `modules/postgres` and `modules/sqlite` when the module-migration surface lands. Do not add another; see analyzer/migrations/README.md.",
|
|
3
|
+
"id": "schema-prepare-bucket",
|
|
4
|
+
"code": "SQL_BEFORE_MIGRATIONS_RENAMED",
|
|
5
|
+
"severity": "warning",
|
|
6
|
+
"reason": "`beforeMigrations:` is now `prepare:`. Every documented use of it was data preparation for a narrowing the reconciliation pass is about to attempt \u2014 backfill before NOT NULL, make values fit before a length reduction, convert before a non-widening type change \u2014 and each is what a refusal already tells the author to write. The old name said where it ran relative to the OTHER bucket; the new one says what it is for, which is what those refusals need to name. Nothing re-runs: the ledger stores the migration key alone, so moving an entry between the two maps changes no history.",
|
|
7
|
+
"rules": [
|
|
8
|
+
{
|
|
9
|
+
"match": {
|
|
10
|
+
"key": "beforeMigrations",
|
|
11
|
+
"inKind": [
|
|
12
|
+
"Postgres.Schema",
|
|
13
|
+
"SQLite.Schema"
|
|
14
|
+
],
|
|
15
|
+
"under": [
|
|
16
|
+
"beforeMigrations"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"patch": [
|
|
20
|
+
{
|
|
21
|
+
"op": "rename-key",
|
|
22
|
+
"to": "prepare"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|