@telorun/analyzer 0.38.0 → 0.40.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 (50) hide show
  1. package/dist/analyzer.d.ts.map +1 -1
  2. package/dist/analyzer.js +17 -0
  3. package/dist/builtins.d.ts.map +1 -1
  4. package/dist/builtins.js +146 -0
  5. package/dist/import-resolution-diagnostics.d.ts +20 -0
  6. package/dist/import-resolution-diagnostics.d.ts.map +1 -0
  7. package/dist/import-resolution-diagnostics.js +59 -0
  8. package/dist/index.d.ts +4 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +3 -0
  11. package/dist/inline-imports.d.ts.map +1 -1
  12. package/dist/inline-imports.js +1 -0
  13. package/dist/loaded-types.d.ts +12 -1
  14. package/dist/loaded-types.d.ts.map +1 -1
  15. package/dist/manifest-loader.d.ts.map +1 -1
  16. package/dist/manifest-loader.js +11 -1
  17. package/dist/normalize-inline-resources.d.ts.map +1 -1
  18. package/dist/normalize-inline-resources.js +20 -1
  19. package/dist/redaction-path.d.ts +49 -0
  20. package/dist/redaction-path.d.ts.map +1 -0
  21. package/dist/redaction-path.js +133 -0
  22. package/dist/reference-field-map.d.ts +12 -0
  23. package/dist/reference-field-map.d.ts.map +1 -1
  24. package/dist/reference-field-map.js +9 -0
  25. package/dist/schema-compat.d.ts.map +1 -1
  26. package/dist/schema-compat.js +8 -0
  27. package/dist/sources/local-path-ref.d.ts +4 -0
  28. package/dist/sources/local-path-ref.d.ts.map +1 -0
  29. package/dist/sources/local-path-ref.js +5 -0
  30. package/dist/validate-extends.d.ts +0 -20
  31. package/dist/validate-extends.d.ts.map +1 -1
  32. package/dist/validate-extends.js +7 -1
  33. package/dist/validate-logging.d.ts +22 -0
  34. package/dist/validate-logging.d.ts.map +1 -0
  35. package/dist/validate-logging.js +116 -0
  36. package/package.json +2 -2
  37. package/src/analyzer.ts +18 -0
  38. package/src/builtins.ts +152 -0
  39. package/src/import-resolution-diagnostics.ts +66 -0
  40. package/src/index.ts +8 -0
  41. package/src/inline-imports.ts +1 -0
  42. package/src/loaded-types.ts +12 -1
  43. package/src/manifest-loader.ts +11 -1
  44. package/src/normalize-inline-resources.ts +20 -1
  45. package/src/redaction-path.ts +142 -0
  46. package/src/reference-field-map.ts +20 -0
  47. package/src/schema-compat.ts +7 -0
  48. package/src/sources/local-path-ref.ts +5 -0
  49. package/src/validate-extends.ts +8 -1
  50. package/src/validate-logging.ts +136 -0
@@ -1 +1 @@
1
- {"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAKzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAoB9B,OAAO,EAAsB,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAuxB/F,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAEzB,OAAO,GAAE,qBAA0B;IAI/C;;;;;;;;;;;;;;OAcG;IACH,OAAO,CACL,SAAS,EAAE,gBAAgB,EAAE,EAC7B,OAAO,CAAC,EAAE,eAAe,EACzB,QAAQ,CAAC,EAAE,gBAAgB,GAC1B,kBAAkB,EAAE;IAm1BvB,aAAa,CACX,SAAS,EAAE,gBAAgB,EAAE,EAC7B,OAAO,CAAC,EAAE,eAAe,EACzB,QAAQ,CAAC,EAAE,gBAAgB,GAC1B,kBAAkB,EAAE;IAMvB,SAAS,CACP,SAAS,EAAE,gBAAgB,EAAE,EAC7B,QAAQ,EAAE,gBAAgB,EAI1B,kBAAkB,CAAC,EAAE,gBAAgB,EAAE,GACtC,gBAAgB,EAAE;IAmBr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AkB,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE;CAsB5F"}
package/dist/analyzer.js CHANGED
@@ -20,6 +20,7 @@ import { DiagnosticSeverity } from "./types.js";
20
20
  import { extractCelRegionScopes, extractContextsFromSchema, getManifestItem, pathMatchesScope, resolveContextAnnotations, resolveTypeFieldToSchema, } from "./validate-cel-context.js";
21
21
  import { buildEvalPaths, evalPathsCover } from "./eval-paths.js";
22
22
  import { validateExtends } from "./validate-extends.js";
23
+ import { validateLogging } from "./validate-logging.js";
23
24
  import { validateBaseMapping } from "./validate-base-mapping.js";
24
25
  import { validateNestedInlineResources } from "./validate-nested-inline.js";
25
26
  import { validateProviderCoherence } from "./validate-provider-coherence.js";
@@ -339,11 +340,16 @@ function buildStepContextSchema(manifest, defSchema, allManifests, defs, aliases
339
340
  * handler dispatched directly, e.g. `Lambda.Function`), so it can't be rejected
340
341
  * statically without false positives. This is the sound subset of the runtime rule.
341
342
  */
343
+ /** The built-in namespace: globally resolvable, crossing no import boundary. */
344
+ const TELO_BUILTIN_MODULE = "Telo";
342
345
  const NON_INVOKABLE_CAPABILITIES = new Set([
343
346
  "Telo.Provider",
344
347
  "Telo.Mount",
345
348
  "Telo.Type",
346
349
  "Telo.Template",
350
+ // A sink is written to through a direct contract on the controller instance,
351
+ // never dispatched — so invoking one is statically wrong.
352
+ "Telo.Sink",
347
353
  ]);
348
354
  /**
349
355
  * Validate `x-telo-step-context` step `invoke` references (e.g. `Run.Sequence`
@@ -698,6 +704,12 @@ export class StaticAnalyzer {
698
704
  // so state builds up across successive calls (e.g. incremental editor validation).
699
705
  const ctx = registry?._context();
700
706
  const aliases = ctx?.aliases ?? new AliasResolver();
707
+ // `Telo` crosses no import boundary — the kernel built-ins are globally
708
+ // resolvable, which is what lets `kind: Telo.ConsoleSink` and
709
+ // `extends: Telo.LogSink` work with no `imports:` entry (§10.2). The kernel
710
+ // registers the same ungated alias at boot; registering it here keeps the
711
+ // static and runtime halves agreeing.
712
+ aliases.registerUngatedAlias(TELO_BUILTIN_MODULE, TELO_BUILTIN_MODULE);
701
713
  const defs = ctx?.definitions ?? new DefinitionRegistry();
702
714
  // Register module identities and aliases.
703
715
  // The root module doc (Telo.Application or Telo.Library) provides its own
@@ -748,6 +760,7 @@ export class StaticAnalyzer {
748
760
  let libResolver = aliasesByModule.get(moduleName);
749
761
  if (!libResolver) {
750
762
  libResolver = new AliasResolver();
763
+ libResolver.registerUngatedAlias(TELO_BUILTIN_MODULE, TELO_BUILTIN_MODULE);
751
764
  aliasesByModule.set(moduleName, libResolver);
752
765
  }
753
766
  libResolver.registerUngatedAlias("Self", moduleName);
@@ -834,6 +847,7 @@ export class StaticAnalyzer {
834
847
  let libResolver = aliasesByModule.get(ownModule);
835
848
  if (!libResolver) {
836
849
  libResolver = new AliasResolver();
850
+ libResolver.registerUngatedAlias(TELO_BUILTIN_MODULE, TELO_BUILTIN_MODULE);
837
851
  aliasesByModule.set(ownModule, libResolver);
838
852
  }
839
853
  if (!libResolver.hasAlias("Self")) {
@@ -903,6 +917,9 @@ export class StaticAnalyzer {
903
917
  }
904
918
  if (!options?.skipValidation) {
905
919
  diagnostics.push(...validateSchemaTypeRefs(allManifests, defs, aliases, aliasesByModule, rootModules));
920
+ // §14.1 / §10.3: redaction paths and `on_full: block` are statically
921
+ // detectable, so they fail `telo check` rather than only at boot.
922
+ diagnostics.push(...validateLogging(allManifests, defs, aliases, aliasesByModule));
906
923
  }
907
924
  resolveSchemaTypeRefs(allManifests, aliases, aliasesByModule);
908
925
  // Trusted-input fast path: when the caller has already attested that
@@ -1 +1 @@
1
- {"version":3,"file":"builtins.d.ts","sourceRoot":"","sources":["../src/builtins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAwBvD,eAAO,MAAM,eAAe,EAAE,kBAAkB,EAyjB/C,CAAC"}
1
+ {"version":3,"file":"builtins.d.ts","sourceRoot":"","sources":["../src/builtins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AA2GvD,eAAO,MAAM,eAAe,EAAE,kBAAkB,EA8nB/C,CAAC"}
package/dist/builtins.js CHANGED
@@ -19,6 +19,83 @@ const PROVENANCE_METADATA = {
19
19
  license: { type: "string" },
20
20
  documentation: { type: "string" },
21
21
  };
22
+ /** The six named levels of `kernel/specs/logging.md` §5.1. The full 1–24 OTel
23
+ * range stays valid on the wire; only these are nameable in a manifest. */
24
+ const LOG_LEVEL_ENUM = ["trace", "debug", "info", "warn", "error", "fatal"];
25
+ const DURATION_PATTERN = "^\\s*\\d+(\\.\\d+)?\\s*(ms|s|m|h)\\s*$";
26
+ /** Fields every sink kind inherits from `Telo.LogSink` (§12.1). A concrete sink
27
+ * kind may narrow a default but must not remove a field — a buffering policy
28
+ * that cannot be configured from the only permitted configuration source is
29
+ * not a policy. */
30
+ const LOG_SINK_COMMON_PROPERTIES = {
31
+ level: { type: "string", enum: LOG_LEVEL_ENUM },
32
+ buffer: { type: "integer", minimum: 1 },
33
+ on_full: { type: "string", enum: ["block", "drop_new", "drop_old"] },
34
+ flush_interval: { type: "string", pattern: DURATION_PATTERN },
35
+ };
36
+ /** Threshold / redaction / sampling — the fields an `imports:` entry may
37
+ * override for its subtree (§12.2). Deliberately excludes `sinks`: sinks are
38
+ * process-level I/O and belong to the root Application that owns the process,
39
+ * so an imported library can never open a log file on its importer's behalf. */
40
+ const LOGGING_SCOPE_PROPERTIES = {
41
+ level: { type: "string", enum: LOG_LEVEL_ENUM },
42
+ attributes: { type: "object" },
43
+ redact: {
44
+ type: "object",
45
+ properties: {
46
+ paths: { type: "array", items: { type: "string" } },
47
+ censor: { type: "string" },
48
+ // Deletion destroys schema stability and hides that a field was present
49
+ // at all, so §14 offers this but never as the default.
50
+ remove: { type: "boolean" },
51
+ },
52
+ additionalProperties: false,
53
+ },
54
+ sampling: {
55
+ type: "object",
56
+ properties: {
57
+ first: { type: "integer", minimum: 0 },
58
+ thereafter: { type: "integer", minimum: 0 },
59
+ tick: { type: "string", pattern: DURATION_PATTERN },
60
+ sampleErrors: { type: "boolean" },
61
+ },
62
+ additionalProperties: false,
63
+ },
64
+ };
65
+ /** The per-import `logging:` override. */
66
+ const IMPORT_LOGGING_SCHEMA = {
67
+ type: "object",
68
+ "x-telo-eval": "compile",
69
+ properties: LOGGING_SCOPE_PROPERTIES,
70
+ additionalProperties: false,
71
+ };
72
+ /** The root Application's `logging:` block — the scope fields plus `sinks`.
73
+ *
74
+ * `x-telo-eval: compile` covers the whole block: every value resolves once at
75
+ * load, which is what lets a level come from the host environment through a
76
+ * `variables:` entry read with `!cel` rather than through a parallel
77
+ * `TELO_LOG_*` path that would be invisible to the analyzer and the editor
78
+ * (§12.3, D6). */
79
+ const ROOT_LOGGING_SCHEMA = {
80
+ type: "object",
81
+ "x-telo-eval": "compile",
82
+ properties: {
83
+ ...LOGGING_SCOPE_PROPERTIES,
84
+ // A list rather than a keyed map because sinks are root-only and therefore
85
+ // never merged; with no merge to disambiguate, a list matches how Telo
86
+ // spells every other ref-or-inline collection. `x-telo-inline` opts this one
87
+ // slot into inline-resource extraction — see normalize-inline-resources.ts.
88
+ sinks: {
89
+ type: "array",
90
+ items: {
91
+ type: "object",
92
+ "x-telo-ref": "telo#LogSink",
93
+ "x-telo-inline": true,
94
+ },
95
+ },
96
+ },
97
+ additionalProperties: false,
98
+ };
22
99
  export const KERNEL_BUILTINS = [
23
100
  { kind: "Telo.Abstract", metadata: { name: "Template", module: "Telo" } },
24
101
  { kind: "Telo.Abstract", metadata: { name: "Runnable", module: "Telo" } },
@@ -31,6 +108,59 @@ export const KERNEL_BUILTINS = [
31
108
  metadata: { name: "Provider", module: "Telo" },
32
109
  schema: { "x-telo-eval": "compile" },
33
110
  },
111
+ // The sink lifecycle role: attach, write a record, flush, detach. Deliberately
112
+ // payload-opaque — it carries no filtering and no encoding — so a future
113
+ // `Telo.TraceSink` reuses the same capability with a different record type.
114
+ // Scoped to record-stream sinks; metrics aggregate rather than stream and are
115
+ // not covered. See kernel/specs/logging.md §10.
116
+ { kind: "Telo.Abstract", metadata: { name: "Sink", module: "Telo" } },
117
+ // The abstract every *log* sink kind extends, carrying the log-specific
118
+ // configuration. A kernel built-in resolvable without an import, so a sink
119
+ // author depends on the kernel contract rather than on a standard-library
120
+ // module version and kernel↔module skew never becomes a compatibility surface
121
+ // for "where do logs go".
122
+ {
123
+ kind: "Telo.Abstract",
124
+ metadata: { name: "LogSink", module: "Telo" },
125
+ capability: "Telo.Sink",
126
+ schema: {
127
+ type: "object",
128
+ properties: LOG_SINK_COMMON_PROPERTIES,
129
+ additionalProperties: true,
130
+ },
131
+ },
132
+ {
133
+ kind: "Telo.Definition",
134
+ metadata: { name: "ConsoleSink", module: "Telo" },
135
+ capability: "Telo.Sink",
136
+ extends: "Telo.LogSink",
137
+ schema: {
138
+ type: "object",
139
+ properties: {
140
+ ...LOG_SINK_COMMON_PROPERTIES,
141
+ destination: { type: "string", enum: ["stderr", "stdout"] },
142
+ encoding: { type: "string", enum: ["auto", "pretty", "json"] },
143
+ color: { type: "string", enum: ["auto", "always", "never"] },
144
+ },
145
+ additionalProperties: false,
146
+ },
147
+ },
148
+ {
149
+ kind: "Telo.Definition",
150
+ metadata: { name: "FileSink", module: "Telo" },
151
+ capability: "Telo.Sink",
152
+ extends: "Telo.LogSink",
153
+ schema: {
154
+ type: "object",
155
+ properties: {
156
+ ...LOG_SINK_COMMON_PROPERTIES,
157
+ destination: { type: "string" },
158
+ encoding: { type: "string", enum: ["json", "pretty"] },
159
+ },
160
+ required: ["destination"],
161
+ additionalProperties: false,
162
+ },
163
+ },
34
164
  {
35
165
  kind: "Telo.Definition",
36
166
  metadata: { name: "Abstract", module: "Telo" },
@@ -270,6 +400,7 @@ export const KERNEL_BUILTINS = [
270
400
  { type: "array", items: { type: "string" } },
271
401
  ],
272
402
  },
403
+ logging: IMPORT_LOGGING_SCHEMA,
273
404
  },
274
405
  required: ["metadata", "source"],
275
406
  additionalProperties: false,
@@ -428,6 +559,11 @@ export const KERNEL_BUILTINS = [
428
559
  { type: "array", items: { type: "string" } },
429
560
  ],
430
561
  },
562
+ // Threshold / redaction / sampling override for this import's
563
+ // subtree. Attached to the import rather than to a map keyed
564
+ // by module name because an alias is already uniqueness-
565
+ // enforced, while module names collide (§12.2, D9).
566
+ logging: IMPORT_LOGGING_SCHEMA,
431
567
  },
432
568
  additionalProperties: false,
433
569
  },
@@ -497,6 +633,11 @@ export const KERNEL_BUILTINS = [
497
633
  additionalProperties: false,
498
634
  },
499
635
  },
636
+ // Structured logging configuration. The manifest is the only
637
+ // configuration source — there is no TELO_LOG_* variable and no logging
638
+ // CLI flag — so a level derived from the host environment goes through a
639
+ // `variables:` entry read with `!cel`. See kernel/specs/logging.md §12.
640
+ logging: ROOT_LOGGING_SCHEMA,
500
641
  },
501
642
  required: ["metadata"],
502
643
  additionalProperties: false,
@@ -562,6 +703,11 @@ export const KERNEL_BUILTINS = [
562
703
  { type: "array", items: { type: "string" } },
563
704
  ],
564
705
  },
706
+ // Threshold / redaction / sampling override for this import's
707
+ // subtree. Attached to the import rather than to a map keyed
708
+ // by module name because an alias is already uniqueness-
709
+ // enforced, while module names collide (§12.2, D9).
710
+ logging: IMPORT_LOGGING_SCHEMA,
565
711
  },
566
712
  additionalProperties: false,
567
713
  },
@@ -0,0 +1,20 @@
1
+ import type { LoadedGraph } from "./loaded-types.js";
2
+ import { type AnalysisDiagnostic } from "./types.js";
3
+ /**
4
+ * Convert a graph's import-resolution failures (`graph.errors`) into structured,
5
+ * coded diagnostics. This is the single source of truth for surfacing a broken
6
+ * import — every host (CLI, VS Code, telo-editor) routes these instead of each
7
+ * re-deriving the channel and drifting (the VS Code extension used to drop it
8
+ * entirely, showing nothing for a broken import).
9
+ *
10
+ * The analyzer owns only this raw channel conversion; the *presentation* policy
11
+ * — which analysis cascade to hold back for a compromised file — lives in
12
+ * `@telorun/ide-support`'s `assembleGraphDiagnostics`.
13
+ *
14
+ * Each diagnostic adopts the same `data` shape as version-reconciliation
15
+ * diagnostics — `{ filePath, path: "imports.<alias>" }` — so the shared
16
+ * `findPositions` / `resolveRange` routing anchors it on the offending import
17
+ * line with no host-specific code.
18
+ */
19
+ export declare function importResolutionDiagnostics(graph: LoadedGraph): AnalysisDiagnostic[];
20
+ //# sourceMappingURL=import-resolution-diagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-resolution-diagnostics.d.ts","sourceRoot":"","sources":["../src/import-resolution-diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrE,OAAO,EAAsB,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AA8BzE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,WAAW,GAAG,kBAAkB,EAAE,CAepF"}
@@ -0,0 +1,59 @@
1
+ import { isLocalPathSource } from "./sources/local-path-ref.js";
2
+ import { isRegistryRef } from "./sources/module-ref.js";
3
+ import { isOciRef } from "./sources/oci-ref.js";
4
+ import { DiagnosticSeverity } from "./types.js";
5
+ const SOURCE = "telo-analyzer";
6
+ /** True when `source` is a shape some transport claims — a registry ref, an OCI
7
+ * ref, an HTTP(S) URL, or a relative/absolute path. A source matching none of
8
+ * these is malformed (no transport can ever resolve it), which we report
9
+ * differently from a well-formed ref that simply failed to fetch. */
10
+ function isRecognizedSourceShape(source) {
11
+ return (isRegistryRef(source) ||
12
+ isOciRef(source) ||
13
+ source.startsWith("http://") ||
14
+ source.startsWith("https://") ||
15
+ isLocalPathSource(source));
16
+ }
17
+ function messageFor(e, malformed) {
18
+ const authored = e.source ?? e.url;
19
+ const via = e.alias ? `import '${e.alias}' → '${authored}'` : `'${authored}'`;
20
+ if (malformed) {
21
+ return (`Cannot resolve ${via}: not a recognized module reference. Expected ` +
22
+ `'namespace/name@version', 'oci://host/repo@tag', 'https://…', or a relative path.`);
23
+ }
24
+ return `Cannot resolve ${via}: ${e.error.message}`;
25
+ }
26
+ /**
27
+ * Convert a graph's import-resolution failures (`graph.errors`) into structured,
28
+ * coded diagnostics. This is the single source of truth for surfacing a broken
29
+ * import — every host (CLI, VS Code, telo-editor) routes these instead of each
30
+ * re-deriving the channel and drifting (the VS Code extension used to drop it
31
+ * entirely, showing nothing for a broken import).
32
+ *
33
+ * The analyzer owns only this raw channel conversion; the *presentation* policy
34
+ * — which analysis cascade to hold back for a compromised file — lives in
35
+ * `@telorun/ide-support`'s `assembleGraphDiagnostics`.
36
+ *
37
+ * Each diagnostic adopts the same `data` shape as version-reconciliation
38
+ * diagnostics — `{ filePath, path: "imports.<alias>" }` — so the shared
39
+ * `findPositions` / `resolveRange` routing anchors it on the offending import
40
+ * line with no host-specific code.
41
+ */
42
+ export function importResolutionDiagnostics(graph) {
43
+ return graph.errors.map((e) => {
44
+ const filePath = e.fromSource ?? graph.entry.owner.source;
45
+ const malformed = !isRecognizedSourceShape(e.source ?? e.url);
46
+ const data = { filePath };
47
+ if (e.alias)
48
+ data.path = `imports.${e.alias}`;
49
+ if (e.sourceLine !== undefined)
50
+ data.sourceLine = e.sourceLine;
51
+ return {
52
+ severity: DiagnosticSeverity.Error,
53
+ code: malformed ? "INVALID_IMPORT_SOURCE" : "IMPORT_UNRESOLVED",
54
+ source: SOURCE,
55
+ message: messageFor(e, malformed),
56
+ data,
57
+ };
58
+ });
59
+ }
package/dist/index.d.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  export { AnalysisRegistry } from "./analysis-registry.js";
2
2
  export type { RefFieldInfo } from "./analysis-registry.js";
3
3
  export { StaticAnalyzer } from "./analyzer.js";
4
+ export { importResolutionDiagnostics } from "./import-resolution-diagnostics.js";
4
5
  export type { GraphLoadError, ImportEdge, LoadedFile, LoadedGraph, LoadedModule, ParseError, } from "./loaded-types.js";
5
6
  export { flattenForAnalyzer, flattenLoadedModule, forwardReExportManifests, parseExportEntry, reExportSpecsFromExports, resolveExportedKinds, selectModuleManifestsForAnalysis, stampExportedKinds, stampReExportedKinds, type ParsedExportEntry, type ReExportSpec, } from "./flatten-for-analyzer.js";
6
7
  export { buildEvalPaths, evalPathCovers } from "./eval-paths.js";
7
8
  export { ancestorChain, controllerBearingAncestor, effectiveAuthorSchema, hasOwnControllerOrTemplate, inheritedCapability, isInheritedDelegation, resolveParent, } from "./extends-resolution.js";
8
9
  export type { DefResolver } from "./extends-resolution.js";
10
+ export { hasIntermediateWildcard, parseRedactionPath, RedactionPathError, } from "./redaction-path.js";
11
+ export type { RedactionSegment } from "./redaction-path.js";
9
12
  export { buildReferenceFieldMap, isRefEntry, isScopeEntry } from "./reference-field-map.js";
10
13
  export type { ReferenceFieldMap, RefFieldEntry } from "./reference-field-map.js";
11
14
  export { visitManifest } from "./manifest-visitor.js";
@@ -30,6 +33,7 @@ export { parseModuleRef, isRegistryRef } from "./sources/module-ref.js";
30
33
  export type { ParsedModuleRef } from "./sources/module-ref.js";
31
34
  export { OCI_SCHEME, isOciRef, parseOciRef } from "./sources/oci-ref.js";
32
35
  export type { ParsedOciRef } from "./sources/oci-ref.js";
36
+ export { isLocalPathSource } from "./sources/local-path-ref.js";
33
37
  export { MANIFEST_CACHE_BASE_URL, ManifestCacheSource, isHttpsModuleRef, manifestCacheKey, manifestCacheUrl, ociManifestCacheCoords, urlManifestCacheCoords, } from "./sources/manifest-cache.js";
34
38
  export type { ManifestCacheCoords } from "./sources/manifest-cache.js";
35
39
  export { withSyntheticPositions } from "./with-synthetic-positions.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC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C;AAC/D,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACzE,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC3E,YAAY,EACR,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,QAAQ,EACR,aAAa,EACb,KAAK,EACR,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  export { AnalysisRegistry } from "./analysis-registry.js";
2
2
  export { StaticAnalyzer } from "./analyzer.js";
3
+ export { importResolutionDiagnostics } from "./import-resolution-diagnostics.js";
3
4
  export { flattenForAnalyzer, flattenLoadedModule, forwardReExportManifests, parseExportEntry, reExportSpecsFromExports, resolveExportedKinds, selectModuleManifestsForAnalysis, stampExportedKinds, stampReExportedKinds, } from "./flatten-for-analyzer.js";
4
5
  export { buildEvalPaths, evalPathCovers } from "./eval-paths.js";
5
6
  export { ancestorChain, controllerBearingAncestor, effectiveAuthorSchema, hasOwnControllerOrTemplate, inheritedCapability, isInheritedDelegation, resolveParent, } from "./extends-resolution.js";
7
+ export { hasIntermediateWildcard, parseRedactionPath, RedactionPathError, } from "./redaction-path.js";
6
8
  export { buildReferenceFieldMap, isRefEntry, isScopeEntry } from "./reference-field-map.js";
7
9
  export { visitManifest } from "./manifest-visitor.js";
8
10
  export { Loader } from "./manifest-loader.js";
@@ -18,6 +20,7 @@ export { defaultSources } from "./sources/default-sources.js";
18
20
  export { splitIntegrity, foldIntegrity, verifyIntegrity, verifiedFetch, sha256Base64Url, IntegrityError, } from "./sources/integrity.js";
19
21
  export { parseModuleRef, isRegistryRef } from "./sources/module-ref.js";
20
22
  export { OCI_SCHEME, isOciRef, parseOciRef } from "./sources/oci-ref.js";
23
+ export { isLocalPathSource } from "./sources/local-path-ref.js";
21
24
  export { MANIFEST_CACHE_BASE_URL, ManifestCacheSource, isHttpsModuleRef, manifestCacheKey, manifestCacheUrl, ociManifestCacheCoords, urlManifestCacheCoords, } from "./sources/manifest-cache.js";
22
25
  export { withSyntheticPositions } from "./with-synthetic-positions.js";
23
26
  export { DEFAULT_MANIFEST_FILENAME, DiagnosticSeverity } from "./types.js";
@@ -1 +1 @@
1
- {"version":3,"file":"inline-imports.d.ts","sourceRoot":"","sources":["../src/inline-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D;;6CAE6C;AAC7C,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACnC,cAAc,EAAE,gBAAgB,EAChC,cAAc,EAAE,gBAAgB,GAAG,SAAS,GAC3C,eAAe,EAAE,CA+BnB;AAED;;;;;;;iFAOiF;AACjF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAmB9D"}
1
+ {"version":3,"file":"inline-imports.d.ts","sourceRoot":"","sources":["../src/inline-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D;;6CAE6C;AAC7C,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACnC,cAAc,EAAE,gBAAgB,EAChC,cAAc,EAAE,gBAAgB,GAAG,SAAS,GAC3C,eAAe,EAAE,CAgCnB;AAED;;;;;;;iFAOiF;AACjF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAmB9D"}
@@ -38,6 +38,7 @@ export function inlineImportManifests(moduleManifest, modulePosition) {
38
38
  ...(entry.variables !== undefined ? { variables: entry.variables } : {}),
39
39
  ...(entry.secrets !== undefined ? { secrets: entry.secrets } : {}),
40
40
  ...(entry.runtime !== undefined ? { runtime: entry.runtime } : {}),
41
+ ...(entry.logging !== undefined ? { logging: entry.logging } : {}),
41
42
  };
42
43
  out.push({ manifest, position: synthPosition(modulePosition, alias, scalar) });
43
44
  }
@@ -90,10 +90,21 @@ export interface LoadedGraph {
90
90
  errors: GraphLoadError[];
91
91
  }
92
92
  export interface GraphLoadError {
93
- /** URL of the file that failed to load. */
93
+ /** URL of the file that failed to load (resolved — may be a `file://` URL for
94
+ * a relative import). */
94
95
  url: string;
96
+ /** The import source string exactly as authored (`./lib`, `std/x@1.0.0`),
97
+ * before relative-path resolution. Preferred over `url` for classification
98
+ * and display, so a diagnostic quotes what the author wrote. */
99
+ source?: string;
95
100
  /** Source of the import that triggered the load, or null for the entry. */
96
101
  fromSource: string | null;
102
+ /** Import alias the failed source was bound to in `fromSource`'s `imports:`
103
+ * map, when the failure is a transitive import (absent for an entry-load
104
+ * failure). Lets a consumer anchor the diagnostic at `imports.<alias>`. */
105
+ alias?: string;
106
+ /** Line of the `Telo.Import` doc in `fromSource`, for position fallback. */
107
+ sourceLine?: number;
97
108
  error: Error;
98
109
  }
99
110
  //# sourceMappingURL=loaded-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loaded-types.d.ts","sourceRoot":"","sources":["../src/loaded-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAE5D;;;;4EAI4E;AAC5E,MAAM,WAAW,UAAU;IACzB;+DAC2D;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf;gEAC4D;IAC5D,YAAY,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,6EAA6E;IAC7E,SAAS,EAAE,KAAK,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IAC1C,0EAA0E;IAC1E,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,0EAA0E;IAC1E,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,UAAU;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED;mCACmC;AACnC,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,UAAU,CAAC;IAClB;oEACgE;IAChE,QAAQ,EAAE,UAAU,EAAE,CAAC;CACxB;AAED;;;;;2EAK2E;AAC3E,MAAM,WAAW,UAAU;IACzB,mEAAmE;IACnE,YAAY,EAAE,MAAM,CAAC;IACrB;6EAC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0B5D"}
@@ -215,7 +215,10 @@ export class Loader {
215
215
  catch (err) {
216
216
  errors.push({
217
217
  url: importSource,
218
+ source: importSource,
218
219
  fromSource: file.source,
220
+ alias,
221
+ sourceLine,
219
222
  error: err instanceof Error ? err : new Error(String(err)),
220
223
  });
221
224
  continue;
@@ -243,7 +246,14 @@ export class Loader {
243
246
  catch (err) {
244
247
  const e = err instanceof Error ? err : new Error(String(err));
245
248
  e.sourceLine = sourceLine;
246
- errors.push({ url: resolvedTarget, fromSource: file.source, error: e });
249
+ errors.push({
250
+ url: resolvedTarget,
251
+ source: importSource,
252
+ fromSource: file.source,
253
+ alias,
254
+ sourceLine,
255
+ error: e,
256
+ });
247
257
  continue;
248
258
  }
249
259
  }
@@ -1 +1 @@
1
- {"version":3,"file":"normalize-inline-resources.d.ts","sourceRoot":"","sources":["../src/normalize-inline-resources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AA8BzD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,gBAAgB,EAAE,EAC7B,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,CAAC,EAAE,aAAa,EACvB,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,GAC3C,gBAAgB,EAAE,CAsEpB"}
1
+ {"version":3,"file":"normalize-inline-resources.d.ts","sourceRoot":"","sources":["../src/normalize-inline-resources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AA6CzD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,gBAAgB,EAAE,EAC7B,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,CAAC,EAAE,aAAa,EACvB,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,GAC3C,gBAAgB,EAAE,CA0EpB"}
@@ -5,6 +5,20 @@ const SYSTEM_KINDS = new Set([
5
5
  "Telo.Library",
6
6
  "Telo.Import",
7
7
  ]);
8
+ /**
9
+ * System kinds are excluded from inline extraction by default, but a single slot
10
+ * may opt back in with `x-telo-inline: true` — `Telo.Application.logging.sinks`
11
+ * is the case this exists for.
12
+ *
13
+ * The opt-in is per slot rather than per kind because this pass runs *upstream*
14
+ * of schema validation on both the analyzer and runtime paths. Admitting the
15
+ * whole Application document would rewrite an inline `{kind, ...}` in `targets`
16
+ * into a valid `{kind, name}` before AJV ever saw it, silently converting a
17
+ * deliberate rejection into a working feature.
18
+ */
19
+ function acceptsInline(resourceKind, entry) {
20
+ return !SYSTEM_KINDS.has(resourceKind) || entry.inline === true;
21
+ }
8
22
  /** Replaces characters outside [a-zA-Z0-9_] with underscores. */
9
23
  function sanitizeName(raw) {
10
24
  return raw.replace(/[^a-zA-Z0-9_]/g, "_");
@@ -55,7 +69,10 @@ export function normalizeInlineResources(resources, registry, aliases, aliasesBy
55
69
  const result = resources.map(cloneForMutation);
56
70
  // Queue: all non-system resources with a name. Extracted resources are appended.
57
71
  // Filter the CLONES (not the originals) so traversal mutates copies.
58
- const queue = result.filter((r) => typeof r.metadata?.name === "string" && !!r.kind && !SYSTEM_KINDS.has(r.kind));
72
+ // System kinds join the queue too: their inline-accepting slots are filtered
73
+ // per entry below, so a system document is walked but only its opted-in slots
74
+ // are extracted from.
75
+ const queue = result.filter((r) => typeof r.metadata?.name === "string" && !!r.kind);
59
76
  let i = 0;
60
77
  while (i < queue.length) {
61
78
  const resource = queue[i++];
@@ -82,6 +99,8 @@ export function normalizeInlineResources(resources, registry, aliases, aliasesBy
82
99
  for (const [fieldPath, entry] of fieldMap) {
83
100
  if (!isRefEntry(entry))
84
101
  continue;
102
+ if (!acceptsInline(resource.kind, entry))
103
+ continue;
85
104
  const inScope = scopePrefixes.some((prefix) => fieldPath === prefix ||
86
105
  fieldPath.startsWith(prefix + ".") ||
87
106
  fieldPath.startsWith(prefix + "["));
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The redaction path grammar of `kernel/specs/logging.md` §14 — a hand-written
3
+ * parser over a closed grammar.
4
+ *
5
+ * §14.1 makes this a security requirement rather than a style preference. The
6
+ * implementation this syntax is borrowed from compiles paths through the
7
+ * `Function` constructor and validates them by "evaluate it and see whether it
8
+ * parses", which is exactly why that implementation must forbid user input. A
9
+ * real parser removes the injection surface entirely and, as a bonus, makes
10
+ * paths statically checkable by `telo check`.
11
+ *
12
+ * Browser-safe by construction: this module is imported by both the analyzer's
13
+ * static check and the kernel's runtime redaction pass, so the grammar has one
14
+ * definition rather than two that can drift.
15
+ *
16
+ * Grammar:
17
+ *
18
+ * path := segment ( "." segment | bracket )*
19
+ * segment := bareKey | "*"
20
+ * bracket := "[" ( quoted | integer | "*" ) "]"
21
+ * quoted := '"' ... '"' | "'" ... "'"
22
+ *
23
+ * More than one wildcard per path is supported — `items[*].tokens[*].value` is
24
+ * valid. The one-wildcard limit in the best-known implementation is an artifact
25
+ * of how it compiles accessors, not a property of the grammar.
26
+ */
27
+ export type RedactionSegment = {
28
+ kind: "key";
29
+ name: string;
30
+ } | {
31
+ kind: "wildcard";
32
+ };
33
+ export declare class RedactionPathError extends Error {
34
+ readonly code = "INVALID_REDACTION_PATH";
35
+ readonly path: string;
36
+ readonly offset: number;
37
+ constructor(path: string, offset: number, detail: string);
38
+ }
39
+ /**
40
+ * Parse a redaction path into its segments. Throws {@link RedactionPathError}
41
+ * with the offending offset so `telo check` can point at the character rather
42
+ * than the whole path.
43
+ */
44
+ export declare function parseRedactionPath(path: string): RedactionSegment[];
45
+ /** `true` when the path contains a wildcard anywhere but its last segment.
46
+ * §14.2 measures intermediate wildcards at 25–55% over plain serialization,
47
+ * against 1–2% for explicit paths, so a runtime may warn when one is used. */
48
+ export declare function hasIntermediateWildcard(segments: readonly RedactionSegment[]): boolean;
49
+ //# sourceMappingURL=redaction-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redaction-path.d.ts","sourceRoot":"","sources":["../src/redaction-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;AAEpF,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,4BAA4B;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAMzD;AAID;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAyCnE;AA2CD;;+EAE+E;AAC/E,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,GAAG,OAAO,CAKtF"}