@telorun/analyzer 0.71.0 → 0.73.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.
Files changed (139) hide show
  1. package/dist/analyzer.d.ts.map +1 -1
  2. package/dist/analyzer.js +92 -15
  3. package/dist/builtins.d.ts.map +1 -1
  4. package/dist/builtins.js +71 -97
  5. package/dist/catch-scope.d.ts +72 -0
  6. package/dist/catch-scope.d.ts.map +1 -0
  7. package/dist/catch-scope.js +102 -0
  8. package/dist/cel-scope-query.d.ts.map +1 -1
  9. package/dist/cel-scope-query.js +32 -11
  10. package/dist/cel-scope.d.ts.map +1 -1
  11. package/dist/cel-scope.js +1 -0
  12. package/dist/deprecation.d.ts +21 -0
  13. package/dist/deprecation.d.ts.map +1 -0
  14. package/dist/deprecation.js +26 -0
  15. package/dist/eval-paths.d.ts +36 -5
  16. package/dist/eval-paths.d.ts.map +1 -1
  17. package/dist/eval-paths.js +47 -6
  18. package/dist/extends-resolution.d.ts +12 -0
  19. package/dist/extends-resolution.d.ts.map +1 -1
  20. package/dist/extends-resolution.js +23 -0
  21. package/dist/index.d.ts +4 -2
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +3 -2
  24. package/dist/manifest-visitor.d.ts +17 -1
  25. package/dist/manifest-visitor.d.ts.map +1 -1
  26. package/dist/manifest-visitor.js +5 -1
  27. package/dist/migrations/report.d.ts +1 -1
  28. package/dist/migrations/report.d.ts.map +1 -1
  29. package/dist/migrations/report.js +5 -0
  30. package/dist/nearest-name.d.ts +22 -0
  31. package/dist/nearest-name.d.ts.map +1 -0
  32. package/dist/nearest-name.js +43 -0
  33. package/dist/ref-slot.d.ts +15 -0
  34. package/dist/ref-slot.d.ts.map +1 -1
  35. package/dist/ref-slot.js +7 -0
  36. package/dist/release/destinations.d.ts +59 -0
  37. package/dist/release/destinations.d.ts.map +1 -0
  38. package/dist/release/destinations.js +75 -0
  39. package/dist/release/index.d.ts +6 -2
  40. package/dist/release/index.d.ts.map +1 -1
  41. package/dist/release/index.js +3 -1
  42. package/dist/release/ledger.d.ts +20 -11
  43. package/dist/release/ledger.d.ts.map +1 -1
  44. package/dist/release/ledger.js +43 -14
  45. package/dist/release/release-plan.d.ts +3 -2
  46. package/dist/release/release-plan.d.ts.map +1 -1
  47. package/dist/release/release-plan.js +12 -19
  48. package/dist/release/workspace-config.d.ts +114 -34
  49. package/dist/release/workspace-config.d.ts.map +1 -1
  50. package/dist/release/workspace-config.js +322 -38
  51. package/dist/release/workspace-schema.d.ts +41 -0
  52. package/dist/release/workspace-schema.d.ts.map +1 -0
  53. package/dist/release/workspace-schema.js +77 -0
  54. package/dist/resolve-throws-union.d.ts +29 -1
  55. package/dist/resolve-throws-union.d.ts.map +1 -1
  56. package/dist/resolve-throws-union.js +111 -16
  57. package/dist/schema-compat.d.ts.map +1 -1
  58. package/dist/schema-compat.js +13 -1
  59. package/dist/schema-error-report.d.ts +7 -0
  60. package/dist/schema-error-report.d.ts.map +1 -1
  61. package/dist/schema-error-report.js +57 -8
  62. package/dist/schema-keywords.d.ts.map +1 -1
  63. package/dist/schema-keywords.js +3 -1
  64. package/dist/schema-walk.d.ts +27 -0
  65. package/dist/schema-walk.d.ts.map +1 -1
  66. package/dist/schema-walk.js +44 -0
  67. package/dist/telo-version.d.ts +1 -1
  68. package/dist/telo-version.js +1 -1
  69. package/dist/template-body.d.ts +10 -0
  70. package/dist/template-body.d.ts.map +1 -1
  71. package/dist/template-body.js +25 -0
  72. package/dist/types.d.ts +17 -0
  73. package/dist/types.d.ts.map +1 -1
  74. package/dist/types.js +11 -0
  75. package/dist/validate-cel-context.d.ts +23 -8
  76. package/dist/validate-cel-context.d.ts.map +1 -1
  77. package/dist/validate-cel-context.js +48 -16
  78. package/dist/validate-exports.d.ts +28 -0
  79. package/dist/validate-exports.d.ts.map +1 -0
  80. package/dist/validate-exports.js +146 -0
  81. package/dist/validate-extends.d.ts.map +1 -1
  82. package/dist/validate-extends.js +37 -1
  83. package/dist/validate-identifier-names.d.ts +2 -2
  84. package/dist/validate-identifier-names.d.ts.map +1 -1
  85. package/dist/validate-identifier-names.js +22 -7
  86. package/dist/validate-provider-coherence.d.ts +4 -8
  87. package/dist/validate-provider-coherence.d.ts.map +1 -1
  88. package/dist/validate-provider-coherence.js +12 -123
  89. package/dist/validate-ref-slots.d.ts +1 -1
  90. package/dist/validate-ref-slots.d.ts.map +1 -1
  91. package/dist/validate-ref-slots.js +34 -0
  92. package/dist/validate-references.d.ts.map +1 -1
  93. package/dist/validate-references.js +168 -63
  94. package/dist/validate-template-body.d.ts +36 -0
  95. package/dist/validate-template-body.d.ts.map +1 -0
  96. package/dist/validate-template-body.js +246 -0
  97. package/dist/validate-throws-coverage.d.ts.map +1 -1
  98. package/dist/validate-throws-coverage.js +236 -85
  99. package/package.json +3 -2
  100. package/src/analyzer.ts +118 -12
  101. package/src/builtins.ts +85 -97
  102. package/src/catch-scope.ts +157 -0
  103. package/src/cel-scope-query.ts +28 -9
  104. package/src/cel-scope.ts +1 -0
  105. package/src/deprecation.ts +36 -0
  106. package/src/eval-paths.ts +53 -6
  107. package/src/extends-resolution.ts +24 -0
  108. package/src/index.ts +9 -1
  109. package/src/manifest-visitor.ts +19 -2
  110. package/src/migrations/report.ts +5 -1
  111. package/src/nearest-name.ts +47 -0
  112. package/src/ref-slot.ts +19 -0
  113. package/src/release/destinations.ts +105 -0
  114. package/src/release/index.ts +33 -2
  115. package/src/release/ledger.ts +51 -21
  116. package/src/release/release-plan.ts +16 -26
  117. package/src/release/workspace-config.ts +483 -47
  118. package/src/release/workspace-schema.ts +99 -0
  119. package/src/resolve-throws-union.ts +139 -21
  120. package/src/schema-compat.ts +13 -0
  121. package/src/schema-error-report.ts +66 -10
  122. package/src/schema-keywords.ts +4 -1
  123. package/src/schema-walk.ts +56 -0
  124. package/src/telo-version.ts +1 -1
  125. package/src/template-body.ts +25 -0
  126. package/src/types.ts +18 -0
  127. package/src/validate-cel-context.ts +57 -16
  128. package/src/validate-exports.ts +185 -0
  129. package/src/validate-extends.ts +43 -0
  130. package/src/validate-identifier-names.ts +28 -9
  131. package/src/validate-provider-coherence.ts +17 -127
  132. package/src/validate-ref-slots.ts +41 -1
  133. package/src/validate-references.ts +174 -63
  134. package/src/validate-template-body.ts +274 -0
  135. package/src/validate-throws-coverage.ts +333 -92
  136. package/dist/validate-template-dispatch.d.ts +0 -27
  137. package/dist/validate-template-dispatch.d.ts.map +0 -1
  138. package/dist/validate-template-dispatch.js +0 -95
  139. package/src/validate-template-dispatch.ts +0 -99
@@ -1,64 +1,348 @@
1
1
  /**
2
- * `telo-workspace.yaml` — the release anchor.
2
+ * `telo-workspace.yaml` — the anchor.
3
3
  *
4
- * Every path the release system names a module key, a ledger entry, a
5
- * fragment's `modules:` is relative to this file's directory. That is the
6
- * whole of its job: **its location is the anchor**, and its one field names the
7
- * subtrees that may hold modules, which is not derivable (a whole-tree scan
8
- * would read every example and every cached `.telo/manifests` copy as a released
9
- * module).
4
+ * **Its location is the anchor, and every field lives in a block scoped to what
5
+ * it governs.** Every path the release system names a module key, a ledger
6
+ * entry, a fragment's `modules:` is relative to this file's directory, and so
7
+ * is the `.telo` cache. `release:` is what `telo release` reads; `env:` is what
8
+ * `telo run` reads when it resolves a manifest's environment.
10
9
  *
11
- * The file is **optional**, and everything reading it is harmless without one.
12
- * `telo release` requires one. `telo run` uses its LOCATION never `modules:`,
13
- * which is release scope as the bound on the walk-up that collects `.env` /
14
- * `.env.local`, and with no marker reads the manifest's own directory alone, as
15
- * it did before this file existed; a bound is what keeps that walk out of a
16
- * user's home directory. Nothing else not `check`, `publish`, `install`,
17
- * `upgrade`, `migrate`, `module`, and not the kernel — looks for it, so a
18
- * single-manifest repo, a bare `examples/` directory and a third-party module
19
- * checkout keep working with nothing added. Any field added later must be true
20
- * of the whole tree, not derivable from it, and harmless by its absence.
10
+ * That rule is why `modules:` sits under `release:` rather than at the top
11
+ * level. It is a release inventory, not an inventory of manifests: it exists so
12
+ * a whole-tree scan does not read every example and every cached
13
+ * `.telo/manifests` copy as something to version and publish, and nothing else
14
+ * consults it the env walk refuses to, which is why a manifest under
15
+ * `examples/`, in no release subtree, still gets the full walk.
21
16
  *
22
- * Parsing lives here, in the browser-safe half, because the editor answers
23
- * "what does changing this library bump?" from the same model. Finding the file
24
- * on disk is the CLI's half this side takes text.
17
+ * The file is **optional and every block in it is optional**. A marker whose
18
+ * whole content is comments is valid: it anchors the cache and bounds the env
19
+ * walk, which is exactly what a runner seeds one for.
20
+ *
21
+ * **The reader is lenient; the diagnostics are the strict half.** It returns
22
+ * everything it could read plus everything it found wrong, each anchored at a
23
+ * key path, because an editor wants all of them and a command wants to exit on
24
+ * the first. Which of them are fatal is the CALLER's policy, not the file's:
25
+ * `telo release` refuses on any error, while `telo run` consumes `env:` alone
26
+ * and prints the rest — aborting every app in a workspace over a release typo is
27
+ * not a trade to make silently.
28
+ *
29
+ * Parsing lives here, in the browser-safe half, because the editor answers "what
30
+ * does changing this library bump?" from the same model. Finding the file on
31
+ * disk is the CLI's half — this side takes text. Gitignore matching is INJECTED
32
+ * (`PatternMatch`) for the same reason: the grammar belongs to the glob package,
33
+ * which this half does not depend on.
25
34
  */
26
35
  import { parseDocument } from "yaml";
36
+ import { DEFAULT_ENV_FILES, DEFAULT_RELEASE_IGNORE, MODULE_ENTRY_KEYS, WORKSPACE_BLOCKS, WORKSPACE_SCHEMA, } from "./workspace-schema.js";
27
37
  export const WORKSPACE_FILENAME = "telo-workspace.yaml";
38
+ export { DEFAULT_ENV_FILES, DEFAULT_RELEASE_IGNORE };
28
39
  export class WorkspaceConfigError extends Error {
29
40
  }
41
+ const EMPTY = {};
30
42
  /**
31
- * Parse the marker file's text.
43
+ * Read the marker's text.
32
44
  *
33
- * Strict about its one field, because there is nothing here to be lenient with:
34
- * an empty or absent `modules:` names no subtree, so discovery would find no
35
- * module and every gate would silently pass over a whole repo.
45
+ * Never throws: unreadable YAML is itself a diagnostic, because the one caller
46
+ * that must not abort on it is the run path.
36
47
  */
37
- export function parseWorkspaceConfig(text, where) {
48
+ export function readWorkspaceConfig(text, where) {
49
+ const diagnostics = [];
50
+ const report = (code, message, path, severity = "error") => {
51
+ diagnostics.push({ code, severity, message, path });
52
+ };
38
53
  let value;
39
54
  try {
40
55
  value = parseDocument(text).toJSON();
41
56
  }
42
57
  catch (err) {
43
- throw new WorkspaceConfigError(`${where} is not valid YAML: ${err instanceof Error ? err.message : String(err)}`);
58
+ report("WORKSPACE_INVALID_VALUE", `${where} is not valid YAML: ${err instanceof Error ? err.message : String(err)}`, []);
59
+ return { config: EMPTY, diagnostics };
44
60
  }
45
- if (value === null || typeof value !== "object" || Array.isArray(value)) {
46
- throw new WorkspaceConfigError(`${where} must be a YAML mapping.`);
61
+ if (value === null || value === undefined)
62
+ return { config: EMPTY, diagnostics };
63
+ if (typeof value !== "object" || Array.isArray(value)) {
64
+ report("WORKSPACE_INVALID_VALUE", `${where} must be a YAML mapping.`, []);
65
+ return { config: EMPTY, diagnostics };
47
66
  }
48
67
  const record = value;
49
68
  for (const key of Object.keys(record)) {
50
- if (key !== "modules") {
51
- throw new WorkspaceConfigError(`${where}: unknown field '${key}'. The workspace marker carries only 'modules:' — ` +
52
- `the subtrees that may hold modules.`);
69
+ if (WORKSPACE_BLOCKS.includes(key))
70
+ continue;
71
+ if (key === "modules") {
72
+ report("WORKSPACE_MODULES_MOVED", `${where}: 'modules' moved under 'release:'. It is release scope — where modules live, ` +
73
+ `for versioning and publishing — and every field of this file now sits in the block ` +
74
+ `that governs it. Indent this list under a 'release:' key.`, ["modules"]);
75
+ continue;
76
+ }
77
+ // A near-miss of a block name is the typo whose settings would otherwise go
78
+ // silently unapplied; an unrecognized block is a version skew, so the next
79
+ // one ships without breaking today's runs.
80
+ const near = nearMiss(key, WORKSPACE_BLOCKS);
81
+ if (near) {
82
+ report("WORKSPACE_UNKNOWN_KEY", `${where}: unknown block '${key}'. Did you mean '${near}'?`, [key]);
83
+ }
84
+ else {
85
+ report("WORKSPACE_UNKNOWN_KEY", `${where}: unknown block '${key}', which nothing reads. This telo knows ${WORKSPACE_BLOCKS.map((b) => `'${b}'`).join(" and ")}.`, [key], "warning");
86
+ }
87
+ }
88
+ const release = readRelease(record.release, where, report);
89
+ const env = readEnv(record.env, where, report);
90
+ return {
91
+ config: { ...(release ? { release } : {}), ...(env ? { env } : {}) },
92
+ diagnostics,
93
+ };
94
+ }
95
+ function readRelease(raw, where, report) {
96
+ if (raw === undefined || raw === null)
97
+ return undefined;
98
+ if (typeof raw !== "object" || Array.isArray(raw)) {
99
+ report("WORKSPACE_INVALID_VALUE", `${where}: 'release' must be a mapping.`, ["release"]);
100
+ return undefined;
101
+ }
102
+ const block = raw;
103
+ const read = readBlock(block, WORKSPACE_SCHEMA.release.properties, where, ["release"], report);
104
+ return {
105
+ ...(read.registry !== undefined ? { registry: read.registry } : {}),
106
+ ...(read.ignore !== undefined ? { ignore: read.ignore } : {}),
107
+ modules: read.modules ?? [],
108
+ };
109
+ }
110
+ /**
111
+ * Read one block against its declared shape.
112
+ *
113
+ * The declared `type` is what DISPATCHES, so a new key is one entry in the
114
+ * schema and no change here. Reading the key names from the data while
115
+ * hand-writing every type check beside it would leave the half nothing reads
116
+ * free to drift from the half that decides — with the data half being the one no
117
+ * test would catch.
118
+ */
119
+ function readBlock(block, properties, where, at, report) {
120
+ reportUnknownKeys(block, properties, where, at, report);
121
+ const out = {};
122
+ for (const [name, schema] of Object.entries(properties)) {
123
+ const value = schema.type === "string"
124
+ ? readString(block[name], where, [...at, name], report)
125
+ : schema.type === "string[]"
126
+ ? readStringList(block[name], where, [...at, name], report)
127
+ : readModuleEntries(block[name], where, report);
128
+ if (value !== undefined)
129
+ out[name] = value;
130
+ }
131
+ return out;
132
+ }
133
+ function readModuleEntries(raw, where, report) {
134
+ if (raw === undefined || raw === null)
135
+ return [];
136
+ if (!Array.isArray(raw)) {
137
+ report("WORKSPACE_INVALID_VALUE", `${where}: 'release.modules' must be a list of path patterns, e.g. [modules/*, apps/*].`, ["release", "modules"]);
138
+ return [];
139
+ }
140
+ if (raw.length === 0) {
141
+ report("WORKSPACE_INVALID_VALUE", `${where}: 'release.modules' is empty, so no directory can ever be discovered as a module. ` +
142
+ `List the subtrees that hold them, e.g. [modules/*, apps/*].`, ["release", "modules"]);
143
+ return [];
144
+ }
145
+ const entries = [];
146
+ for (const [index, item] of raw.entries()) {
147
+ const at = ["release", "modules", index];
148
+ if (typeof item === "string") {
149
+ entries.push({ path: item });
150
+ continue;
151
+ }
152
+ if (item === null || typeof item !== "object" || Array.isArray(item)) {
153
+ report("WORKSPACE_INVALID_VALUE", `${where}: 'release.modules' entry ${index} must be a pattern string, or a mapping ` +
154
+ `carrying 'path:' plus the keys it overrides.`, at);
155
+ continue;
53
156
  }
157
+ const entry = item;
158
+ const read = readBlock(entry, MODULE_ENTRY_KEYS, where, at, report);
159
+ const path = read.path;
160
+ if (path === undefined) {
161
+ report("WORKSPACE_INVALID_VALUE", `${where}: 'release.modules' entry ${index} declares no 'path:', so it matches nothing.`, at);
162
+ continue;
163
+ }
164
+ entries.push({
165
+ path,
166
+ ...(read.registry !== undefined ? { registry: read.registry } : {}),
167
+ ...(read.ignore !== undefined ? { ignore: read.ignore } : {}),
168
+ });
54
169
  }
55
- const modules = record.modules;
56
- if (!Array.isArray(modules) || modules.some((entry) => typeof entry !== "string")) {
57
- throw new WorkspaceConfigError(`${where}: 'modules' must be a list of path patterns, e.g. [modules/*, apps/*].`);
170
+ return entries;
171
+ }
172
+ function readEnv(raw, where, report) {
173
+ if (raw === undefined || raw === null)
174
+ return undefined;
175
+ if (typeof raw !== "object" || Array.isArray(raw)) {
176
+ report("WORKSPACE_INVALID_VALUE", `${where}: 'env' must be a mapping.`, ["env"]);
177
+ return undefined;
58
178
  }
59
- if (modules.length === 0) {
60
- throw new WorkspaceConfigError(`${where}: 'modules' is empty, so no directory can ever be discovered as a module. ` +
61
- `List the subtrees that hold them, e.g. [modules/*, apps/*].`);
179
+ const block = raw;
180
+ const read = readBlock(block, WORKSPACE_SCHEMA.env.properties, where, ["env"], report);
181
+ const roots = read.roots;
182
+ const files = read.files;
183
+ if (files) {
184
+ for (const [index, name] of files.entries()) {
185
+ // A path would let one entry reach outside the bound `roots:` exists to
186
+ // state, so the list is filenames and the refusal is structural.
187
+ if (name.includes("/") || name.includes("\\") || name.includes("*")) {
188
+ report("WORKSPACE_INVALID_VALUE", `${where}: 'env.files' entry '${name}' is a path or a glob. It names a file collected in ` +
189
+ `each directory the walk visits, so it must be a bare filename — the walk's reach is ` +
190
+ `'env.roots'.`, ["env", "files", index]);
191
+ }
192
+ }
62
193
  }
63
- return { modules: modules };
194
+ return {
195
+ ...(roots !== undefined ? { roots } : {}),
196
+ ...(files !== undefined ? { files } : {}),
197
+ };
198
+ }
199
+ function reportUnknownKeys(block, known, where, at, report) {
200
+ const names = Object.keys(known);
201
+ for (const key of Object.keys(block)) {
202
+ if (names.includes(key))
203
+ continue;
204
+ const near = nearMiss(key, names);
205
+ report("WORKSPACE_UNKNOWN_KEY", `${where}: unknown key '${[...at, key].join(".")}'.` +
206
+ (near ? ` Did you mean '${near}'?` : ` Known keys: ${names.map((n) => `'${n}'`).join(", ")}.`), [...at, key]);
207
+ }
208
+ }
209
+ function readString(raw, where, at, report) {
210
+ if (raw === undefined || raw === null)
211
+ return undefined;
212
+ if (typeof raw !== "string") {
213
+ report("WORKSPACE_INVALID_VALUE", `${where}: '${at.join(".")}' must be a string.`, at);
214
+ return undefined;
215
+ }
216
+ if (raw === "") {
217
+ // Reported rather than read as an absence: an empty value would fall
218
+ // through to the next rung of the cascade and publish somewhere the author
219
+ // did not name, which is the one thing a declared destination must not do.
220
+ report("WORKSPACE_INVALID_VALUE", `${where}: '${at.join(".")}' is empty.`, at);
221
+ return undefined;
222
+ }
223
+ return raw;
224
+ }
225
+ function readStringList(raw, where, at, report) {
226
+ if (raw === undefined || raw === null)
227
+ return undefined;
228
+ if (!Array.isArray(raw)) {
229
+ report("WORKSPACE_INVALID_VALUE", `${where}: '${at.join(".")}' must be a list of strings.`, at);
230
+ return undefined;
231
+ }
232
+ const out = [];
233
+ for (const [index, item] of raw.entries()) {
234
+ if (typeof item !== "string") {
235
+ report("WORKSPACE_INVALID_VALUE", `${where}: '${at.join(".")}' entry ${index} must be a string.`, [
236
+ ...at,
237
+ index,
238
+ ]);
239
+ continue;
240
+ }
241
+ out.push(item);
242
+ }
243
+ return out;
244
+ }
245
+ /** One edit apart, case-insensitively — enough to separate a typo from a key
246
+ * this reader is simply too old to know. */
247
+ function nearMiss(key, known) {
248
+ const lower = key.toLowerCase();
249
+ return known.find((name) => name !== key && editDistanceAtMostOne(lower, name.toLowerCase()));
250
+ }
251
+ function editDistanceAtMostOne(a, b) {
252
+ if (a === b)
253
+ return true;
254
+ if (Math.abs(a.length - b.length) > 1)
255
+ return false;
256
+ let i = 0;
257
+ let j = 0;
258
+ let edits = 0;
259
+ while (i < a.length && j < b.length) {
260
+ if (a[i] === b[j]) {
261
+ i++;
262
+ j++;
263
+ continue;
264
+ }
265
+ if (++edits > 1)
266
+ return false;
267
+ if (a.length > b.length)
268
+ i++;
269
+ else if (a.length < b.length)
270
+ j++;
271
+ else {
272
+ i++;
273
+ j++;
274
+ }
275
+ }
276
+ return edits + (a.length - i) + (b.length - j) <= 1;
277
+ }
278
+ // ---------------------------------------------------------------------------
279
+ // Diagnostics as a caller's policy
280
+ // ---------------------------------------------------------------------------
281
+ /** The diagnostics anchored inside one top-level block, plus the ones anchored
282
+ * at the document itself (unreadable YAML, a non-mapping root) — those are
283
+ * every block's problem. */
284
+ export function diagnosticsFor(diagnostics, block) {
285
+ return diagnostics.filter((d) => d.path.length === 0 || d.path[0] === block);
286
+ }
287
+ export function hasError(diagnostics) {
288
+ return diagnostics.some((d) => d.severity === "error");
289
+ }
290
+ /**
291
+ * The release settings, or a throw naming what is missing.
292
+ *
293
+ * `telo release` is the one caller for which any error is fatal, and for which
294
+ * an absent block is itself one: a marker with no `release:` anchors a cache and
295
+ * declares no release scope, which is exactly the state a runner's seeded marker
296
+ * is in.
297
+ */
298
+ export function requireReleaseSettings(read, where) {
299
+ const first = read.diagnostics.find((d) => d.severity === "error");
300
+ if (first)
301
+ throw new WorkspaceConfigError(first.message);
302
+ if (!read.config.release || read.config.release.modules.length === 0) {
303
+ throw new WorkspaceConfigError(`${where} declares no 'release.modules', so no directory can be discovered as a module. ` +
304
+ `List the subtrees that hold them:\n\n release:\n modules:\n - modules/*\n - apps/*\n`);
305
+ }
306
+ return read.config.release;
307
+ }
308
+ /**
309
+ * Which entry claims `key`, and what it therefore settles.
310
+ *
311
+ * **The last matching entry supplies them** — the rule the list already has,
312
+ * since it is one gitignore-style list evaluated last-match-wins. A negation
313
+ * entry is an exclusion and therefore supplies nothing: a module the last match
314
+ * excludes is not a module of this workspace at all, which is why this returns
315
+ * `undefined` rather than a settings object for it.
316
+ *
317
+ * The cascade is key-wise and each key's value replaces whole, so an entry
318
+ * naming only `registry:` keeps the block's `ignore:`.
319
+ */
320
+ export function settingsForModule(release, key, match) {
321
+ const index = decidingIndex(key, release.modules.map((entry) => entry.path), match);
322
+ if (index < 0)
323
+ return undefined;
324
+ const entry = release.modules[index];
325
+ return {
326
+ entry: index,
327
+ ...(entry.registry ?? release.registry
328
+ ? { registry: entry.registry ?? release.registry }
329
+ : {}),
330
+ ignore: entry.ignore ?? release.ignore ?? DEFAULT_RELEASE_IGNORE,
331
+ };
332
+ }
333
+ /** Whether `path` is matched by an authored pattern list, negations honoured.
334
+ * `env.roots` and a resolved `ignore` list are both read through this. */
335
+ export function matchesPatterns(path, patterns, match) {
336
+ return decidingIndex(path, patterns, match) >= 0;
337
+ }
338
+ /**
339
+ * The index of the entry that CLAIMS `path`, or `-1`.
340
+ *
341
+ * The one place last-match-wins and the negation reading live: every pattern
342
+ * list in this file rests on that rule, and two derivations of it would be two
343
+ * answers to what a marker means.
344
+ */
345
+ function decidingIndex(path, patterns, match) {
346
+ const index = match(path, patterns);
347
+ return index >= 0 && patterns[index].startsWith("!") ? -1 : index;
64
348
  }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The shape of `telo-workspace.yaml`, declared as data.
3
+ *
4
+ * One declaration read by two consumers — the strict half that reports what a
5
+ * marker got wrong, and the editor's completion list. Two hand-maintained key
6
+ * lists drift, and the drift is silent in the worst direction: an editor
7
+ * offering a key the checker rejects.
8
+ *
9
+ * Written as JSON Schema because that is what the shape *is*, and because the
10
+ * `description` a completion item shows and the type a diagnostic names are the
11
+ * same two facts a schema already carries. It is not compiled by AJV — the
12
+ * strict half walks it, which is what lets a wrong value say `'registry' must be
13
+ * the publish destination base, as a string` instead of a keyword trace.
14
+ */
15
+ export interface WorkspaceKeySchema {
16
+ readonly type: "string" | "string[]" | "entry[]";
17
+ readonly description: string;
18
+ /** Values worth offering at this key when nothing better is known. */
19
+ readonly examples?: readonly string[];
20
+ }
21
+ export interface WorkspaceBlockSchema {
22
+ readonly description: string;
23
+ readonly properties: Readonly<Record<string, WorkspaceKeySchema>>;
24
+ }
25
+ /**
26
+ * Every block, and every key in it, is optional — a marker whose whole content
27
+ * is comments is valid, and is what a runner seeds for the cache anchor alone.
28
+ */
29
+ export declare const WORKSPACE_SCHEMA: Readonly<Record<string, WorkspaceBlockSchema>>;
30
+ /** Keys a `release.modules` entry may carry in its object form. `path` is the
31
+ * pattern; the rest override the block's own keys, key-wise. */
32
+ export declare const MODULE_ENTRY_KEYS: Readonly<Record<string, WorkspaceKeySchema>>;
33
+ export declare const WORKSPACE_BLOCKS: readonly string[];
34
+ /** Built-in when `release.ignore` is absent. Every pattern carries `**\/` — the
35
+ * anchoring at a module root is the defect this replaced, so anchoring some and
36
+ * not others would reproduce it partially. */
37
+ export declare const DEFAULT_RELEASE_IGNORE: readonly string[];
38
+ /** Built-in when `env.files` is absent — the pair the walk hardcoded before it
39
+ * was authorable, in the order it applied them. */
40
+ export declare const DEFAULT_ENV_FILES: readonly string[];
41
+ //# sourceMappingURL=workspace-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-schema.d.ts","sourceRoot":"","sources":["../../src/release/workspace-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;IACjD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;CACnE;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAuC3E,CAAC;AAEF;iEACiE;AACjE,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAO1E,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAAkC,CAAC;AAEjF;;+CAE+C;AAC/C,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAMnD,CAAC;AAEF;oDACoD;AACpD,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAA2B,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The shape of `telo-workspace.yaml`, declared as data.
3
+ *
4
+ * One declaration read by two consumers — the strict half that reports what a
5
+ * marker got wrong, and the editor's completion list. Two hand-maintained key
6
+ * lists drift, and the drift is silent in the worst direction: an editor
7
+ * offering a key the checker rejects.
8
+ *
9
+ * Written as JSON Schema because that is what the shape *is*, and because the
10
+ * `description` a completion item shows and the type a diagnostic names are the
11
+ * same two facts a schema already carries. It is not compiled by AJV — the
12
+ * strict half walks it, which is what lets a wrong value say `'registry' must be
13
+ * the publish destination base, as a string` instead of a keyword trace.
14
+ */
15
+ /**
16
+ * Every block, and every key in it, is optional — a marker whose whole content
17
+ * is comments is valid, and is what a runner seeds for the cache anchor alone.
18
+ */
19
+ export const WORKSPACE_SCHEMA = {
20
+ release: {
21
+ description: "How `telo release` behaves: where modules are, where they publish, and which of their paths are not release-relevant.",
22
+ properties: {
23
+ registry: {
24
+ type: "string",
25
+ description: "Publish destination base. A module's ref is `<registry>/<its own directory name>`. Omitted: --registry, then TELO_OCI_REGISTRY, then the base each module's own ledger entry recorded.",
26
+ examples: ["oci://ghcr.io/telorun"],
27
+ },
28
+ ignore: {
29
+ type: "string[]",
30
+ description: "Paths under a module whose changes are not release-relevant, so no changelog fragment is asked for. Module-relative, gitignore-style. Declaring it replaces the built-in default; [] ignores nothing.",
31
+ examples: ["**/tests/**", "**/docs/**", "**/plans/**", "**/README.md", "**/CHANGELOG.md"],
32
+ },
33
+ modules: {
34
+ type: "entry[]",
35
+ description: "The subtrees that may hold modules — a place to look, never a module: what makes a directory a module is its telo.yaml. Workspace-relative, gitignore-style, last match wins. A bare string is an entry with no overrides.",
36
+ },
37
+ },
38
+ },
39
+ env: {
40
+ description: "How `telo run` resolves a manifest's environment.",
41
+ properties: {
42
+ roots: {
43
+ type: "string[]",
44
+ description: "How far up the .env walk may climb. Workspace-relative, gitignore-style, matched against each ancestor directory; the nearest match stops the walk. Omitted: the walk stops at this file.",
45
+ },
46
+ files: {
47
+ type: "string[]",
48
+ description: "Which files are collected in each directory, later winning within one directory. Filenames only — a / or a glob is an error. Declaring it replaces the default; [] collects none.",
49
+ examples: [".env", ".env.local"],
50
+ },
51
+ },
52
+ },
53
+ };
54
+ /** Keys a `release.modules` entry may carry in its object form. `path` is the
55
+ * pattern; the rest override the block's own keys, key-wise. */
56
+ export const MODULE_ENTRY_KEYS = {
57
+ path: {
58
+ type: "string",
59
+ description: "The gitignore-style pattern this entry matches modules with.",
60
+ },
61
+ registry: WORKSPACE_SCHEMA.release.properties.registry,
62
+ ignore: WORKSPACE_SCHEMA.release.properties.ignore,
63
+ };
64
+ export const WORKSPACE_BLOCKS = Object.keys(WORKSPACE_SCHEMA);
65
+ /** Built-in when `release.ignore` is absent. Every pattern carries `**\/` — the
66
+ * anchoring at a module root is the defect this replaced, so anchoring some and
67
+ * not others would reproduce it partially. */
68
+ export const DEFAULT_RELEASE_IGNORE = [
69
+ "**/tests/**",
70
+ "**/docs/**",
71
+ "**/plans/**",
72
+ "**/README.md",
73
+ "**/CHANGELOG.md",
74
+ ];
75
+ /** Built-in when `env.files` is absent — the pair the walk hardcoded before it
76
+ * was authorable, in the order it applied them. */
77
+ export const DEFAULT_ENV_FILES = [".env", ".env.local"];
@@ -1,4 +1,4 @@
1
- import type { ResourceManifest } from "@telorun/sdk";
1
+ import type { ResourceDefinition, ResourceManifest } from "@telorun/sdk";
2
2
  import { type AliasResolver } from "./alias-resolver.js";
3
3
  import type { DefinitionRegistry } from "./definition-registry.js";
4
4
  export interface ThrowsCodeMeta {
@@ -61,4 +61,32 @@ export declare function createResolveCtx(allManifests: ResourceManifest[], defs:
61
61
  * unresolvable passthrough call sites. Cycles short-circuit to an empty
62
62
  * result so resolution always terminates. */
63
63
  export declare function resolveThrowsUnion(manifest: ResourceManifest, ctx: ResolveCtx): ThrowsUnion;
64
+ /**
65
+ * The union a SCOPE-LEVEL `catches:` list can be asked to render — everything
66
+ * the resource it is written on drives, transitively.
67
+ *
68
+ * `x-telo-catches-for: ""` is itself the claim that this is the denominator, so
69
+ * nothing is inferred from a kind that did not opt in, and no definition has to
70
+ * declare a `throws:` block to carry a catch scope (the kernel forbids one on a
71
+ * `Telo.Service` and a `Telo.Mount`, and rightly: what a router renders is not
72
+ * what a router THROWS).
73
+ *
74
+ * Three edges, three answers. A **step body** contributes its own traversal,
75
+ * subtraction included. A **control-transferring ref** contributes the target's
76
+ * own declared union — a route handler is a leaf here, and asking what IT drives
77
+ * would credit this scope with codes the handler catches internally. A
78
+ * **`throwsThrough` ref** recurses, because the target is another scope on the
79
+ * same ladder: a server renders what its mounts' routes throw, not what the
80
+ * mounts themselves declare.
81
+ */
82
+ export declare function resolveScopeUnion(manifest: ResourceManifest, definition: ResourceDefinition, ctx: ResolveCtx, seen?: Set<ResourceManifest>): ThrowsUnion;
83
+ /**
84
+ * The manifest a resolved reference value names, in either shape it arrives in —
85
+ * a `{kind, name}` pair, or a `!ref` still carrying its parse-time sentinel.
86
+ *
87
+ * Exported because the catch-scope enclosure walk asks the same question about
88
+ * the same values; resolving a name twice by two rules is how two passes end up
89
+ * disagreeing about which resource a slot points at.
90
+ */
91
+ export declare function resolveRefManifest(refValue: unknown, ctx: ResolveCtx, ownerModule: string | undefined): ResourceManifest | undefined;
64
92
  //# sourceMappingURL=resolve-throws-union.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-throws-union.d.ts","sourceRoot":"","sources":["../src/resolve-throws-union.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEzE,OAAO,EAA0B,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGjF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAGnE,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B;AAED;;gFAEgF;AAChF,eAAO,MAAM,gBAAgB,mBAAmB,CAAC;AAEjD,MAAM,WAAW,WAAW;IAC1B,gFAAgF;IAChF,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACnC;;;8EAG0E;IAC1E,SAAS,EAAE,OAAO,CAAC;IACnB;;;;gDAI4C;IAC5C,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,gBAAgB,EAAE,CAAC;IACjC,IAAI,EAAE,kBAAkB,CAAC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