@telorun/analyzer 0.37.0 → 0.39.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 (40) hide show
  1. package/dist/analysis-registry.d.ts +14 -0
  2. package/dist/analysis-registry.d.ts.map +1 -1
  3. package/dist/analysis-registry.js +17 -0
  4. package/dist/analyzer.d.ts.map +1 -1
  5. package/dist/analyzer.js +17 -0
  6. package/dist/builtins.d.ts.map +1 -1
  7. package/dist/builtins.js +169 -0
  8. package/dist/index.d.ts +2 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +1 -0
  11. package/dist/inline-imports.d.ts.map +1 -1
  12. package/dist/inline-imports.js +1 -0
  13. package/dist/normalize-inline-resources.d.ts.map +1 -1
  14. package/dist/normalize-inline-resources.js +20 -1
  15. package/dist/redaction-path.d.ts +49 -0
  16. package/dist/redaction-path.d.ts.map +1 -0
  17. package/dist/redaction-path.js +133 -0
  18. package/dist/reference-field-map.d.ts +12 -0
  19. package/dist/reference-field-map.d.ts.map +1 -1
  20. package/dist/reference-field-map.js +9 -0
  21. package/dist/schema-compat.d.ts.map +1 -1
  22. package/dist/schema-compat.js +8 -0
  23. package/dist/validate-extends.d.ts +0 -20
  24. package/dist/validate-extends.d.ts.map +1 -1
  25. package/dist/validate-extends.js +7 -1
  26. package/dist/validate-logging.d.ts +22 -0
  27. package/dist/validate-logging.d.ts.map +1 -0
  28. package/dist/validate-logging.js +116 -0
  29. package/package.json +2 -2
  30. package/src/analysis-registry.ts +20 -0
  31. package/src/analyzer.ts +18 -0
  32. package/src/builtins.ts +176 -0
  33. package/src/index.ts +6 -0
  34. package/src/inline-imports.ts +1 -0
  35. package/src/normalize-inline-resources.ts +20 -1
  36. package/src/redaction-path.ts +142 -0
  37. package/src/reference-field-map.ts +20 -0
  38. package/src/schema-compat.ts +7 -0
  39. package/src/validate-extends.ts +8 -1
  40. package/src/validate-logging.ts +136 -0
@@ -96,6 +96,20 @@ export declare class AnalysisRegistry {
96
96
  */
97
97
  builtinDefinitions(): ResourceDefinition[];
98
98
  resolveDefinition(kind: string): ResourceDefinition | undefined;
99
+ /** A resolver scoped to `def`'s OWN module, for resolving that definition's
100
+ * `extends` target.
101
+ *
102
+ * `extends` aliases are lexically scoped to the declaring library — a library
103
+ * writes `extends: Cache.Store` against its own import map, and `Self.Host`
104
+ * against its own module name. The global alias table knows neither, so
105
+ * {@link resolveDefinition} silently returns undefined for them and callers
106
+ * fall back to an un-inherited view. Mirrors the module-scope selection in
107
+ * `expandedFieldMapForResource`. */
108
+ resolverForDefinition(def: {
109
+ metadata?: {
110
+ module?: string;
111
+ };
112
+ }): (kind: string) => ResourceDefinition | undefined;
99
113
  /** Canonical kinds (`module.Name`) of every definition that extends the given
100
114
  * abstract kind — the concrete implementations a caller may instantiate in
101
115
  * its place. Empty when `kind` is not an abstract or has no implementations. */
@@ -1 +1 @@
1
- {"version":3,"file":"analysis-registry.d.ts","sourceRoot":"","sources":["../src/analysis-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAKzE,OAAO,EAAqC,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEhG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD;;wDAEwD;AACxD,MAAM,WAAW,YAAY;IAC3B;0CACsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,OAAO,EAAE,OAAO,CAAC;IACjB,uEAAuE;IACvE,IAAI,EAAE,MAAM,EAAE,CAAC;IACf;;;8EAG0E;IAC1E,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA4B;IACjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuB;IAC/C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA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,EAAE,gBAAgB,EAAE,EAC7B,OAAO,EAAE,eAAe,EACxB,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,kBAAkB,CAAC,EAAE,OAAO,CAAA;KAAE,GACzF,IAAI;IAQP;;;;OAIG;IACH,kBAAkB,IAAI,kBAAkB,EAAE;IAI1C,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAM/D;;;;;;;;yCAQqC;IACrC,qBAAqB,CAAC,GAAG,EAAE;QACzB,QAAQ,CAAC,EAAE;YAAE,MAAM,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KAChC,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,kBAAkB,GAAG,SAAS;IASpD;;qFAEiF;IACjF,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;IAUzC,QAAQ,IAAI,MAAM,EAAE;IAIpB;mEAC+D;IAC/D,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE;IAIxC;;;gCAG4B;IAC5B,oBAAoB,IAAI,MAAM,EAAE;IAIhC;wEACoE;IACpE,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIhD;;;;;;;;iDAQ6C;IAC7C,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,SAAS;IAqB9D;;;;;gEAK4D;IAC5D,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS;IAiB7D,qFAAqF;IACrF,QAAQ,IAAI,eAAe;CAG5B"}
@@ -178,6 +178,23 @@ export class AnalysisRegistry {
178
178
  const resolved = ctx.aliases?.resolveKind(kind);
179
179
  return ctx.definitions?.resolve(kind) ?? (resolved ? ctx.definitions?.resolve(resolved) : undefined);
180
180
  }
181
+ /** A resolver scoped to `def`'s OWN module, for resolving that definition's
182
+ * `extends` target.
183
+ *
184
+ * `extends` aliases are lexically scoped to the declaring library — a library
185
+ * writes `extends: Cache.Store` against its own import map, and `Self.Host`
186
+ * against its own module name. The global alias table knows neither, so
187
+ * {@link resolveDefinition} silently returns undefined for them and callers
188
+ * fall back to an un-inherited view. Mirrors the module-scope selection in
189
+ * `expandedFieldMapForResource`. */
190
+ resolverForDefinition(def) {
191
+ const ownModule = def?.metadata?.module;
192
+ const scope = (ownModule ? this.aliasesByModule.get(ownModule) : undefined) ?? this.aliases;
193
+ return (kind) => {
194
+ const canonical = scope.resolveKind(kind);
195
+ return this.defs.resolve(kind) ?? (canonical ? this.defs.resolve(canonical) : undefined);
196
+ };
197
+ }
181
198
  /** Canonical kinds (`module.Name`) of every definition that extends the given
182
199
  * abstract kind — the concrete implementations a caller may instantiate in
183
200
  * its place. Empty when `kind` is not an abstract or has no implementations. */
@@ -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;I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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;IAmBrB,OAAO,CACL,SAAS,EAAE,gBAAgB,EAAE,EAC7B,QAAQ,EAAE,gBAAgB,GACzB;QAAE,WAAW,EAAE,kBAAkB,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;AAEvD,eAAO,MAAM,eAAe,EAAE,kBAAkB,EAujB/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
@@ -1,3 +1,101 @@
1
+ /** Descriptive provenance a module declares about itself, shared by
2
+ * `Telo.Application` and `Telo.Library`.
3
+ *
4
+ * These are *descriptive*, never *addressing* — nothing resolves, fetches,
5
+ * caches, or publishes based on them, so they do not conflict with
6
+ * identity-is-the-ref (which bans metadata from determining an artifact's
7
+ * location). `repository` is the location of the module's **source code**, in
8
+ * the same spirit as npm's `repository` / `license` / `homepage`. It is named
9
+ * `repository` rather than `source` because `source:` already means "where to
10
+ * fetch a dependency from" in the `imports` map.
11
+ *
12
+ * A publish transport projects these into whatever its backend surfaces —
13
+ * OCI maps them onto the standard `org.opencontainers.image.*` annotations;
14
+ * the HTTP registry stores the manifest verbatim, so they are preserved as
15
+ * declared with nothing to translate. */
16
+ const PROVENANCE_METADATA = {
17
+ description: { type: "string" },
18
+ repository: { type: "string" },
19
+ license: { type: "string" },
20
+ documentation: { type: "string" },
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
+ };
1
99
  export const KERNEL_BUILTINS = [
2
100
  { kind: "Telo.Abstract", metadata: { name: "Template", module: "Telo" } },
3
101
  { kind: "Telo.Abstract", metadata: { name: "Runnable", module: "Telo" } },
@@ -10,6 +108,59 @@ export const KERNEL_BUILTINS = [
10
108
  metadata: { name: "Provider", module: "Telo" },
11
109
  schema: { "x-telo-eval": "compile" },
12
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
+ },
13
164
  {
14
165
  kind: "Telo.Definition",
15
166
  metadata: { name: "Abstract", module: "Telo" },
@@ -249,6 +400,7 @@ export const KERNEL_BUILTINS = [
249
400
  { type: "array", items: { type: "string" } },
250
401
  ],
251
402
  },
403
+ logging: IMPORT_LOGGING_SCHEMA,
252
404
  },
253
405
  required: ["metadata", "source"],
254
406
  additionalProperties: false,
@@ -269,6 +421,7 @@ export const KERNEL_BUILTINS = [
269
421
  version: { type: "string" },
270
422
  source: { type: "string" },
271
423
  module: { type: "string" },
424
+ ...PROVENANCE_METADATA,
272
425
  },
273
426
  required: ["name"],
274
427
  additionalProperties: true,
@@ -406,6 +559,11 @@ export const KERNEL_BUILTINS = [
406
559
  { type: "array", items: { type: "string" } },
407
560
  ],
408
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,
409
567
  },
410
568
  additionalProperties: false,
411
569
  },
@@ -475,6 +633,11 @@ export const KERNEL_BUILTINS = [
475
633
  additionalProperties: false,
476
634
  },
477
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,
478
641
  },
479
642
  required: ["metadata"],
480
643
  additionalProperties: false,
@@ -495,6 +658,7 @@ export const KERNEL_BUILTINS = [
495
658
  version: { type: "string" },
496
659
  source: { type: "string" },
497
660
  module: { type: "string" },
661
+ ...PROVENANCE_METADATA,
498
662
  },
499
663
  required: ["name"],
500
664
  additionalProperties: true,
@@ -539,6 +703,11 @@ export const KERNEL_BUILTINS = [
539
703
  { type: "array", items: { type: "string" } },
540
704
  ],
541
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,
542
711
  },
543
712
  additionalProperties: false,
544
713
  },
package/dist/index.d.ts CHANGED
@@ -6,6 +6,8 @@ export { flattenForAnalyzer, flattenLoadedModule, forwardReExportManifests, pars
6
6
  export { buildEvalPaths, evalPathCovers } from "./eval-paths.js";
7
7
  export { ancestorChain, controllerBearingAncestor, effectiveAuthorSchema, hasOwnControllerOrTemplate, inheritedCapability, isInheritedDelegation, resolveParent, } from "./extends-resolution.js";
8
8
  export type { DefResolver } from "./extends-resolution.js";
9
+ export { hasIntermediateWildcard, parseRedactionPath, RedactionPathError, } from "./redaction-path.js";
10
+ export type { RedactionSegment } from "./redaction-path.js";
9
11
  export { buildReferenceFieldMap, isRefEntry, isScopeEntry } from "./reference-field-map.js";
10
12
  export type { ReferenceFieldMap, RefFieldEntry } from "./reference-field-map.js";
11
13
  export { visitManifest } from "./manifest-visitor.js";
@@ -1 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e,EACf,aAAa,EACb,eAAe,EACf,cAAc,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACzE,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,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
@@ -3,6 +3,7 @@ export { StaticAnalyzer } from "./analyzer.js";
3
3
  export { flattenForAnalyzer, flattenLoadedModule, forwardReExportManifests, parseExportEntry, reExportSpecsFromExports, resolveExportedKinds, selectModuleManifestsForAnalysis, stampExportedKinds, stampReExportedKinds, } from "./flatten-for-analyzer.js";
4
4
  export { buildEvalPaths, evalPathCovers } from "./eval-paths.js";
5
5
  export { ancestorChain, controllerBearingAncestor, effectiveAuthorSchema, hasOwnControllerOrTemplate, inheritedCapability, isInheritedDelegation, resolveParent, } from "./extends-resolution.js";
6
+ export { hasIntermediateWildcard, parseRedactionPath, RedactionPathError, } from "./redaction-path.js";
6
7
  export { buildReferenceFieldMap, isRefEntry, isScopeEntry } from "./reference-field-map.js";
7
8
  export { visitManifest } from "./manifest-visitor.js";
8
9
  export { Loader } from "./manifest-loader.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
  }
@@ -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"}
@@ -0,0 +1,133 @@
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 class RedactionPathError extends Error {
28
+ code = "INVALID_REDACTION_PATH";
29
+ path;
30
+ offset;
31
+ constructor(path, offset, detail) {
32
+ super(`Invalid redaction path "${path}" at position ${offset}: ${detail}`);
33
+ this.name = "RedactionPathError";
34
+ this.path = path;
35
+ this.offset = offset;
36
+ }
37
+ }
38
+ const BARE_KEY_TERMINATORS = new Set([".", "[", "]"]);
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 function parseRedactionPath(path) {
45
+ if (path.length === 0)
46
+ throw new RedactionPathError(path, 0, "path is empty");
47
+ const segments = [];
48
+ let index = 0;
49
+ let expectSegment = true;
50
+ while (index < path.length) {
51
+ const char = path[index];
52
+ if (char === "[") {
53
+ index = parseBracket(path, index, segments);
54
+ expectSegment = false;
55
+ continue;
56
+ }
57
+ if (char === ".") {
58
+ if (expectSegment) {
59
+ throw new RedactionPathError(path, index, "expected a key before '.'");
60
+ }
61
+ index += 1;
62
+ expectSegment = true;
63
+ continue;
64
+ }
65
+ if (char === "]") {
66
+ throw new RedactionPathError(path, index, "unmatched ']'");
67
+ }
68
+ const start = index;
69
+ while (index < path.length && !BARE_KEY_TERMINATORS.has(path[index]))
70
+ index += 1;
71
+ const raw = path.slice(start, index);
72
+ if (raw.length === 0)
73
+ throw new RedactionPathError(path, start, "empty key");
74
+ segments.push(raw === "*" ? { kind: "wildcard" } : { kind: "key", name: raw });
75
+ expectSegment = false;
76
+ }
77
+ if (expectSegment) {
78
+ throw new RedactionPathError(path, path.length, "path ends with a trailing '.'");
79
+ }
80
+ return segments;
81
+ }
82
+ function parseBracket(path, open, segments) {
83
+ let index = open + 1;
84
+ if (index >= path.length)
85
+ throw new RedactionPathError(path, open, "unterminated '['");
86
+ const quote = path[index];
87
+ if (quote === '"' || quote === "'") {
88
+ index += 1;
89
+ const start = index;
90
+ while (index < path.length && path[index] !== quote)
91
+ index += 1;
92
+ if (index >= path.length) {
93
+ throw new RedactionPathError(path, start, `unterminated ${quote} quoted key`);
94
+ }
95
+ const name = path.slice(start, index);
96
+ if (name.length === 0)
97
+ throw new RedactionPathError(path, start, "empty quoted key");
98
+ index += 1;
99
+ if (path[index] !== "]") {
100
+ throw new RedactionPathError(path, index, "expected ']' after quoted key");
101
+ }
102
+ segments.push({ kind: "key", name });
103
+ return index + 1;
104
+ }
105
+ const start = index;
106
+ while (index < path.length && path[index] !== "]")
107
+ index += 1;
108
+ if (index >= path.length)
109
+ throw new RedactionPathError(path, open, "unterminated '['");
110
+ const raw = path.slice(start, index);
111
+ if (raw.length === 0)
112
+ throw new RedactionPathError(path, start, "empty '[]'");
113
+ if (raw === "*") {
114
+ segments.push({ kind: "wildcard" });
115
+ }
116
+ else if (/^\d+$/.test(raw)) {
117
+ segments.push({ kind: "key", name: raw });
118
+ }
119
+ else {
120
+ throw new RedactionPathError(path, start, `expected a quoted key, an integer index, or '*', got "${raw}" — quote it as ["${raw}"]`);
121
+ }
122
+ return index + 1;
123
+ }
124
+ /** `true` when the path contains a wildcard anywhere but its last segment.
125
+ * §14.2 measures intermediate wildcards at 25–55% over plain serialization,
126
+ * against 1–2% for explicit paths, so a runtime may warn when one is used. */
127
+ export function hasIntermediateWildcard(segments) {
128
+ for (let i = 0; i < segments.length - 1; i += 1) {
129
+ if (segments[i].kind === "wildcard")
130
+ return true;
131
+ }
132
+ return false;
133
+ }