@starci/eslint-canon-be 3.8.19 → 3.9.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 (164) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/package.json +1 -1
  3. package/runtime/bundle.json +192 -0
  4. package/runtime/engine/by-code-unit.mjs +6 -6
  5. package/runtime/engine/model-config.mjs +98 -76
  6. package/runtime/engine/orca-config.mjs +22 -17
  7. package/runtime/engine/release-config.mjs +22 -18
  8. package/runtime/engine/removed-vocabulary.mjs +21 -20
  9. package/runtime/engine/resources-config.mjs +42 -35
  10. package/runtime/engine/runtime-root.mjs +11 -13
  11. package/runtime/engine/secrets.mjs +170 -102
  12. package/runtime/engine/sonar-config.mjs +16 -13
  13. package/runtime/engine/temp-root.mjs +3 -9
  14. package/runtime/knowledge/hfs/canon-pins.yaml +10 -10
  15. package/runtime/knowledge/hfs/rules.yaml +6 -6
  16. package/runtime/knowledge/hfs/slots.yaml +2 -2
  17. package/runtime/knowledge/sonar-gate.yaml +1 -1
  18. package/runtime/packages/hfs/templates/app/package-scripts/package.json +1 -1
  19. package/runtime/scripts/api/git/cat-file.mjs +0 -1
  20. package/runtime/scripts/api/git/config-get.mjs +1 -2
  21. package/runtime/scripts/api/git/diff.mjs +0 -1
  22. package/runtime/scripts/api/git/lib.mjs +32 -32
  23. package/runtime/scripts/api/git/ls-files.mjs +0 -1
  24. package/runtime/scripts/api/git/ls-tree.mjs +0 -1
  25. package/runtime/scripts/api/git/merge-base.mjs +2 -3
  26. package/runtime/scripts/api/git/remote.mjs +0 -1
  27. package/runtime/scripts/api/git/rev-parse-query.mjs +0 -1
  28. package/runtime/scripts/api/git/show.mjs +0 -1
  29. package/runtime/scripts/hfs/allows.mjs +37 -38
  30. package/runtime/scripts/hfs/architecture/ast-walks.mjs +180 -163
  31. package/runtime/scripts/hfs/architecture/automatic-gates.mjs +80 -73
  32. package/runtime/scripts/hfs/architecture/backend-app-files.mjs +88 -77
  33. package/runtime/scripts/hfs/architecture/backend.mjs +378 -357
  34. package/runtime/scripts/hfs/architecture/background-unowned.mjs +201 -187
  35. package/runtime/scripts/hfs/architecture/canon-clones.mjs +260 -209
  36. package/runtime/scripts/hfs/architecture/canon-jsx-clones.mjs +149 -116
  37. package/runtime/scripts/hfs/architecture/client-reaches-server.mjs +72 -68
  38. package/runtime/scripts/hfs/architecture/clones.mjs +212 -217
  39. package/runtime/scripts/hfs/architecture/config-unread.mjs +7 -9
  40. package/runtime/scripts/hfs/architecture/config.mjs +302 -268
  41. package/runtime/scripts/hfs/architecture/connection-map.mjs +258 -225
  42. package/runtime/scripts/hfs/architecture/constructor-deps.mjs +80 -71
  43. package/runtime/scripts/hfs/architecture/context-coupling.mjs +82 -77
  44. package/runtime/scripts/hfs/architecture/context-map.mjs +267 -234
  45. package/runtime/scripts/hfs/architecture/context-owner.mjs +73 -61
  46. package/runtime/scripts/hfs/architecture/context-platform-tables.mjs +47 -43
  47. package/runtime/scripts/hfs/architecture/context-transaction.mjs +54 -52
  48. package/runtime/scripts/hfs/architecture/contract-fixture-guard.mjs +113 -104
  49. package/runtime/scripts/hfs/architecture/contracts-readonly.mjs +288 -270
  50. package/runtime/scripts/hfs/architecture/contracts.mjs +408 -393
  51. package/runtime/scripts/hfs/architecture/cross-app-duplicate.mjs +50 -51
  52. package/runtime/scripts/hfs/architecture/dead-exports-bindings.mjs +143 -119
  53. package/runtime/scripts/hfs/architecture/dead-exports.mjs +286 -228
  54. package/runtime/scripts/hfs/architecture/default-deny.mjs +129 -110
  55. package/runtime/scripts/hfs/architecture/doc-language.mjs +24 -19
  56. package/runtime/scripts/hfs/architecture/entity-registry.mjs +20 -22
  57. package/runtime/scripts/hfs/architecture/entrypoint.mjs +47 -45
  58. package/runtime/scripts/hfs/architecture/error-codes.mjs +37 -35
  59. package/runtime/scripts/hfs/architecture/error-masked.mjs +55 -59
  60. package/runtime/scripts/hfs/architecture/fe-slot-allows.mjs +24 -23
  61. package/runtime/scripts/hfs/architecture/feature-shape.mjs +40 -38
  62. package/runtime/scripts/hfs/architecture/framework-pinned.mjs +21 -21
  63. package/runtime/scripts/hfs/architecture/frontend-block-render.mjs +106 -98
  64. package/runtime/scripts/hfs/architecture/frontend-grammar.mjs +153 -150
  65. package/runtime/scripts/hfs/architecture/frontend-routing.mjs +161 -149
  66. package/runtime/scripts/hfs/architecture/frontend-world-render.mjs +343 -305
  67. package/runtime/scripts/hfs/architecture/frontend-world.mjs +340 -294
  68. package/runtime/scripts/hfs/architecture/frontend.mjs +174 -184
  69. package/runtime/scripts/hfs/architecture/function-spec-providers.mjs +124 -106
  70. package/runtime/scripts/hfs/architecture/hfs-graph.mjs +52 -48
  71. package/runtime/scripts/hfs/architecture/hooks-are-hooks.mjs +81 -71
  72. package/runtime/scripts/hfs/architecture/i18n-keys.mjs +155 -141
  73. package/runtime/scripts/hfs/architecture/identity.mjs +141 -125
  74. package/runtime/scripts/hfs/architecture/index.mjs +272 -272
  75. package/runtime/scripts/hfs/architecture/injection-token-exported.mjs +45 -43
  76. package/runtime/scripts/hfs/architecture/jwt-ast.mjs +195 -176
  77. package/runtime/scripts/hfs/architecture/machine-ast.mjs +163 -155
  78. package/runtime/scripts/hfs/architecture/managed-scripts.mjs +19 -20
  79. package/runtime/scripts/hfs/architecture/module-per-transport.mjs +177 -172
  80. package/runtime/scripts/hfs/architecture/next-data-contract.mjs +100 -78
  81. package/runtime/scripts/hfs/architecture/next-data-inference.mjs +170 -154
  82. package/runtime/scripts/hfs/architecture/next-data-key.mjs +311 -275
  83. package/runtime/scripts/hfs/architecture/next-data-symbols.mjs +17 -17
  84. package/runtime/scripts/hfs/architecture/next-data.mjs +351 -334
  85. package/runtime/scripts/hfs/architecture/operation-contract-roots.mjs +39 -37
  86. package/runtime/scripts/hfs/architecture/owners.mjs +97 -98
  87. package/runtime/scripts/hfs/architecture/package-shape.mjs +56 -55
  88. package/runtime/scripts/hfs/architecture/presentation.mjs +138 -130
  89. package/runtime/scripts/hfs/architecture/reachability.mjs +258 -241
  90. package/runtime/scripts/hfs/architecture/register-once.mjs +152 -139
  91. package/runtime/scripts/hfs/architecture/registration.mjs +301 -267
  92. package/runtime/scripts/hfs/architecture/required-files.mjs +172 -167
  93. package/runtime/scripts/hfs/architecture/route-files-thin.mjs +85 -77
  94. package/runtime/scripts/hfs/architecture/schema-owner.mjs +206 -181
  95. package/runtime/scripts/hfs/architecture/server-action.mjs +48 -48
  96. package/runtime/scripts/hfs/architecture/side-boundary.mjs +2 -5
  97. package/runtime/scripts/hfs/architecture/source-names-shape.mjs +261 -259
  98. package/runtime/scripts/hfs/architecture/source-names.mjs +304 -278
  99. package/runtime/scripts/hfs/architecture/sql-keys.mjs +277 -194
  100. package/runtime/scripts/hfs/architecture/sql-owner.mjs +236 -194
  101. package/runtime/scripts/hfs/architecture/sql-returning.mjs +46 -45
  102. package/runtime/scripts/hfs/architecture/sql-token-forms.mjs +86 -74
  103. package/runtime/scripts/hfs/architecture/sql-tokens.mjs +456 -341
  104. package/runtime/scripts/hfs/architecture/staged-consumers.mjs +35 -30
  105. package/runtime/scripts/hfs/architecture/surface.mjs +64 -74
  106. package/runtime/scripts/hfs/architecture/symbols.mjs +209 -216
  107. package/runtime/scripts/hfs/architecture/test-world-files.mjs +165 -155
  108. package/runtime/scripts/hfs/architecture/tiers.mjs +161 -154
  109. package/runtime/scripts/hfs/architecture/transport-owner.mjs +155 -149
  110. package/runtime/scripts/hfs/architecture/type-context.mjs +255 -250
  111. package/runtime/scripts/hfs/architecture/typescript.mjs +358 -318
  112. package/runtime/scripts/hfs/architecture/unit-spec-providers.mjs +110 -92
  113. package/runtime/scripts/hfs/declaration-shape.mjs +140 -103
  114. package/runtime/scripts/hfs/declaration-slots.mjs +64 -61
  115. package/runtime/scripts/hfs/edition-slots.mjs +43 -40
  116. package/runtime/scripts/hfs/linear-text.mjs +20 -20
  117. package/runtime/scripts/hfs/param-names.mjs +6 -11
  118. package/runtime/scripts/hfs/path-findings.mjs +120 -100
  119. package/runtime/scripts/hfs/repo-identity.mjs +55 -42
  120. package/runtime/scripts/hfs/rule-catalog.mjs +353 -257
  121. package/runtime/scripts/hfs/rule-params-shape.mjs +60 -47
  122. package/runtime/scripts/hfs/rules/database-migrations.mjs +428 -388
  123. package/runtime/scripts/hfs/rules/fe-no-tests.mjs +37 -36
  124. package/runtime/scripts/hfs/rules/read.mjs +19 -15
  125. package/runtime/scripts/hfs/rules/secrets.mjs +1 -1
  126. package/runtime/scripts/hfs/rules/spec-placement.mjs +12 -13
  127. package/runtime/scripts/hfs/slot-app-view.mjs +69 -74
  128. package/runtime/scripts/hfs/slot-classify.mjs +42 -38
  129. package/runtime/scripts/hfs/slot-errors.mjs +8 -7
  130. package/runtime/scripts/hfs/slot-imports.mjs +70 -63
  131. package/runtime/scripts/hfs/slot-manifest-shape.mjs +74 -52
  132. package/runtime/scripts/hfs/slot-match.mjs +122 -111
  133. package/runtime/scripts/hfs/slot-path.mjs +0 -2
  134. package/runtime/scripts/hfs/slot-required.mjs +65 -59
  135. package/runtime/scripts/hfs/slot-semantic-problems.mjs +138 -112
  136. package/runtime/scripts/hfs/slot-side-problems.mjs +23 -19
  137. package/runtime/scripts/hfs/slots.mjs +175 -152
  138. package/runtime/scripts/hfs/test-world-slot.mjs +0 -1
  139. package/runtime/scripts/hfs/trailing-slashes.mjs +4 -4
  140. package/runtime/scripts/hfs/typescript-programs.mjs +66 -69
  141. package/runtime/scripts/hfs/view.mjs +38 -40
  142. package/runtime/scripts/lib/dockerfile.mjs +131 -114
  143. package/runtime/scripts/lib/env.mjs +3 -6
  144. package/runtime/scripts/lib/event-contract.mjs +73 -78
  145. package/runtime/scripts/lib/git.mjs +15 -16
  146. package/runtime/scripts/lib/glob.mjs +23 -14
  147. package/runtime/scripts/lib/grammar-lint.mjs +33 -37
  148. package/runtime/scripts/lib/i18n.mjs +32 -35
  149. package/runtime/scripts/lib/in-order.mjs +57 -38
  150. package/runtime/scripts/lib/json-clone.mjs +45 -36
  151. package/runtime/scripts/lib/json.mjs +26 -14
  152. package/runtime/scripts/lib/language.mjs +133 -129
  153. package/runtime/scripts/lib/list.mjs +9 -14
  154. package/runtime/scripts/lib/mutation-fence.mjs +10 -5
  155. package/runtime/scripts/lib/path-key.mjs +53 -38
  156. package/runtime/scripts/lib/read-text.mjs +30 -17
  157. package/runtime/scripts/lib/regex.mjs +1 -2
  158. package/runtime/scripts/lib/same-text.mjs +0 -1
  159. package/runtime/scripts/lib/sops-envelope.mjs +148 -120
  160. package/runtime/scripts/lib/stack-services.mjs +128 -129
  161. package/runtime/scripts/lib/ts-analysis.mjs +28 -26
  162. package/runtime/scripts/lib/ts-ast.mjs +36 -42
  163. package/runtime/scripts/lib/walk.mjs +33 -27
  164. package/runtime/scripts/lib/yaml-cached.mjs +4 -4
@@ -1,86 +1,89 @@
1
- // declaration-slots.mjs - how an app declaration (hfs.json) switches on the opt-in slots of a side: by name (`optionalSlots`), by app kind
2
- // (a slot with `appKind`) and by declared pattern (a slot with `pattern: <name>` is enabled by `sides.<side>.patterns: [<name>]`, one
3
- // mechanism for pattern slots). A cross-cutting pattern can instead be owned by the side's canonical proof scenario catalog.
4
- // slots.mjs asks this file to judge a side's lists and to say whether a slot is enabled for a repository.
5
1
  import { judgedInEdition } from './edition-slots.mjs';
6
-
7
2
  /** The problems of a side's `optionalSlots` and `patterns` against the manifest. */
8
3
  export function optionalSlotProblems(manifest, side, s) {
9
- const bad = [];
10
- for (const id of s.optionalSlots ?? []) {
11
- const slot = manifest.slots.find((candidate) => candidate.id === id);
12
- if (!slot?.profiles.includes(side)) bad.push(`sides.${side}.optionalSlots names ${id}, which is not a ${side} slot`);
13
- else if (slot.presence !== 'opt-in') bad.push(`sides.${side}.optionalSlots names ${id}, which is ${slot.presence}, not opt-in`);
14
- else if (slot.appKind !== undefined) bad.push(`sides.${side}.optionalSlots names ${id}; an app of kind ${slot.appKind} enables it`);
15
- }
16
- for (const name of s.patterns ?? []) {
17
- const ownsSlot = manifest.slots.some((slot) => slot.profiles.includes(side) && slot.pattern === name);
18
- const ownsProof = Object.hasOwn(manifest.ruleParams?.[side]?.patternScenarios ?? {}, name);
19
- if (!ownsSlot && !ownsProof) bad.push(`sides.${side}.patterns names ${name}, which neither a ${side} slot nor its proof scenario catalog declares`);
20
- }
21
- if (s.kinds !== undefined && side !== 'be') bad.push(`sides.${side}.kinds belongs to the be side`);
22
- for (const kind of s.kinds ?? []) {
23
- if (!(manifest.triggerKinds ?? []).includes(kind)) bad.push(`sides.${side}.kinds names ${kind}, which is not one of triggerKinds (${(manifest.triggerKinds ?? []).join(', ')})`);
24
- }
25
- return bad;
4
+ const bad = [];
5
+ for (const id of s.optionalSlots ?? []) {
6
+ const slot = manifest.slots.find((candidate) => candidate.id === id);
7
+ if (!slot?.profiles.includes(side))
8
+ bad.push(`sides.${side}.optionalSlots names ${id}, which is not a ${side} slot`);
9
+ else if (slot.presence !== 'opt-in')
10
+ bad.push(`sides.${side}.optionalSlots names ${id}, which is ${slot.presence}, not opt-in`);
11
+ else if (slot.appKind !== undefined)
12
+ bad.push(`sides.${side}.optionalSlots names ${id}; an app of kind ${slot.appKind} enables it`);
13
+ }
14
+ for (const name of s.patterns ?? []) {
15
+ const ownsSlot = manifest.slots.some((slot) => slot.profiles.includes(side) && slot.pattern === name);
16
+ const ownsProof = Object.hasOwn(manifest.ruleParams?.[side]?.patternScenarios ?? {}, name);
17
+ if (!ownsSlot && !ownsProof)
18
+ bad.push(`sides.${side}.patterns names ${name}, which neither a ${side} slot nor its proof scenario catalog declares`);
19
+ }
20
+ if (s.kinds !== undefined && side !== 'be')
21
+ bad.push(`sides.${side}.kinds belongs to the be side`);
22
+ for (const kind of s.kinds ?? []) {
23
+ if (!(manifest.triggerKinds ?? []).includes(kind))
24
+ bad.push(`sides.${side}.kinds names ${kind}, which is not one of triggerKinds (${(manifest.triggerKinds ?? []).join(', ')})`);
25
+ }
26
+ return bad;
26
27
  }
27
-
28
28
  /** The problems of a side's `backing` list: every name is admitted by ruleParams.be.backing in this edition. */
29
29
  export function backingProblems(manifest, side, s, edition = 'full') {
30
- const services = Object.entries(manifest.ruleParams?.be?.backing ?? {})
31
- .filter(([, entry]) => judgedInEdition(entry, edition)).map(([name]) => name);
32
- return (s.backing ?? []).filter((name) => !services.includes(name))
33
- .map((name) => `sides.${side}.backing names ${name}, which is not admitted in edition ${edition} by ruleParams.be.backing (${services.join(', ')})`);
30
+ const services = Object.entries(manifest.ruleParams?.be?.backing ?? {})
31
+ .filter(([, entry]) => judgedInEdition(entry, edition)).map(([name]) => name);
32
+ return (s.backing ?? []).filter((name) => !services.includes(name))
33
+ .map((name) => `sides.${side}.backing names ${name}, which is not admitted in edition ${edition} by ruleParams.be.backing (${services.join(', ')})`);
34
34
  }
35
-
36
35
  /** The problems of the shape of a side's `patterns` list (a unique list of pattern names). */
37
36
  export function patternShapeProblems(s, at, namePattern) {
38
- const list = s.patterns;
39
- if (list === undefined) return [];
40
- return Array.isArray(list) && list.every((value) => namePattern.test(String(value))) && new Set(list).size === list.length ? [] : [`${at}.patterns must be a unique list of pattern names`];
37
+ const list = s.patterns;
38
+ if (list === undefined)
39
+ return [];
40
+ return Array.isArray(list) && list.every((value) => namePattern.test(String(value))) && new Set(list).size === list.length ? [] : [`${at}.patterns must be a unique list of pattern names`];
41
41
  }
42
-
43
42
  /** The problems of the shape of a side's `kinds` list (a unique list of trigger kind names). */
44
43
  export function kindShapeProblems(s, at, namePattern) {
45
- const list = s.kinds;
46
- if (list === undefined) return [];
47
- return Array.isArray(list) && list.every((value) => namePattern.test(String(value))) && new Set(list).size === list.length ? [] : [`${at}.kinds must be a unique list of trigger kind names`];
44
+ const list = s.kinds;
45
+ if (list === undefined)
46
+ return [];
47
+ return Array.isArray(list) && list.every((value) => namePattern.test(String(value))) && new Set(list).size === list.length ? [] : [`${at}.kinds must be a unique list of trigger kind names`];
48
48
  }
49
-
50
49
  /** The problems of `ruleParams.be.kindPatterns` (trigger kind -> patterns) and `ruleParams.be.addKinds` (starci app add noun -> {topic, variable, patterns, trigger?, needs?, also?, defaults?, wire?}). */
51
50
  export function kindParamProblems(be, triggerKinds) {
52
- const kebab = /^[a-z][a-z0-9-]*$/;
53
- const names = (list) => Array.isArray(list) && list.every((value) => kebab.test(String(value))) && new Set(list).size === list.length;
54
- const bad = [];
55
- const patterns = be.kindPatterns;
56
- if (patterns === null || typeof patterns !== 'object' || Array.isArray(patterns) || !Object.entries(patterns).every(([kind, list]) => (triggerKinds ?? []).includes(kind) && names(list))) bad.push('ruleParams.be.kindPatterns must map a trigger kind to a unique list of pattern names');
57
- const nouns = be.addKinds;
58
- const nounOk = (spec) => spec !== null && typeof spec === 'object' && kebab.test(String(spec.topic)) && kebab.test(String(spec.variable)) && names(spec.patterns) && (spec.trigger === undefined || kebab.test(String(spec.trigger))) && (spec.needs === undefined || names(spec.needs)) && (spec.also === undefined || names(spec.also)) && (spec.defaults === undefined || (typeof spec.defaults === 'object' && !Array.isArray(spec.defaults))) && (spec.wire === undefined || (spec.wire !== null && typeof spec.wire === 'object' && ['file', 'import', 'symbol'].every((key) => typeof spec.wire[key] === 'string' && spec.wire[key] !== '')));
59
- if (nouns === null || typeof nouns !== 'object' || Array.isArray(nouns) || !Object.entries(nouns).every(([noun, spec]) => kebab.test(noun) && nounOk(spec))) bad.push('ruleParams.be.addKinds must map a noun to {topic, variable, patterns, trigger?, needs?, also?, defaults?}');
60
- return bad;
51
+ const kebab = /^[a-z][a-z0-9-]*$/;
52
+ const names = (list) => Array.isArray(list) && list.every((value) => kebab.test(String(value))) && new Set(list).size === list.length;
53
+ const bad = [];
54
+ const patterns = be.kindPatterns;
55
+ if (patterns === null || typeof patterns !== 'object' || Array.isArray(patterns) || !Object.entries(patterns).every(([kind, list]) => (triggerKinds ?? []).includes(kind) && names(list)))
56
+ bad.push('ruleParams.be.kindPatterns must map a trigger kind to a unique list of pattern names');
57
+ const nouns = be.addKinds;
58
+ const nounOk = (spec) => spec !== null && typeof spec === 'object' && kebab.test(String(spec.topic)) && kebab.test(String(spec.variable)) && names(spec.patterns) && (spec.trigger === undefined || kebab.test(String(spec.trigger))) && (spec.needs === undefined || names(spec.needs)) && (spec.also === undefined || names(spec.also)) && (spec.defaults === undefined || (typeof spec.defaults === 'object' && !Array.isArray(spec.defaults))) && (spec.wire === undefined || (spec.wire !== null && typeof spec.wire === 'object' && ['file', 'import', 'symbol'].every((key) => typeof spec.wire[key] === 'string' && spec.wire[key] !== '')));
59
+ if (nouns === null || typeof nouns !== 'object' || Array.isArray(nouns) || !Object.entries(nouns).every(([noun, spec]) => kebab.test(noun) && nounOk(spec)))
60
+ bad.push('ruleParams.be.addKinds must map a noun to {topic, variable, patterns, trigger?, needs?, also?, defaults?}');
61
+ return bad;
61
62
  }
62
-
63
63
  /** The problems of `ruleParams.be.patternScenarios`: a pattern name to a non-empty list of unique kebab-case scenario ids. */
64
64
  export function scenarioProblem(scenarios) {
65
- const kebab = /^[a-z][a-z0-9-]*$/;
66
- const ok = scenarios !== null && typeof scenarios === 'object' && !Array.isArray(scenarios) && Object.entries(scenarios).every(([name, list]) => kebab.test(name) && Array.isArray(list) && list.length > 0 && list.every((id) => kebab.test(String(id))) && new Set(list).size === list.length);
67
- return ok ? [] : ['ruleParams.be.patternScenarios must map a pattern name to a non-empty list of unique kebab-case scenario ids'];
65
+ const kebab = /^[a-z][a-z0-9-]*$/;
66
+ const ok = scenarios !== null && typeof scenarios === 'object' && !Array.isArray(scenarios) && Object.entries(scenarios).every(([name, list]) => kebab.test(name) && Array.isArray(list) && list.length > 0 && list.every((id) => kebab.test(String(id))) && new Set(list).size === list.length);
67
+ return ok ? [] : ['ruleParams.be.patternScenarios must map a pattern name to a non-empty list of unique kebab-case scenario ids'];
68
68
  }
69
-
70
69
  /** The problems of the `trigger` of a slot against the manifest's `triggerKinds`: a known kind, on a feature-tier slot only. */
71
70
  export function triggerProblems(slot, triggerKinds) {
72
- if (slot.trigger === undefined) return [];
73
- const bad = [];
74
- if (!(triggerKinds ?? []).includes(slot.trigger)) bad.push(`slot ${slot.id}: trigger ${slot.trigger} is not one of triggerKinds`);
75
- if (slot.tier !== 'feature') bad.push(`slot ${slot.id}: a trigger belongs to a feature-tier slot`);
76
- return bad;
71
+ if (slot.trigger === undefined)
72
+ return [];
73
+ const bad = [];
74
+ if (!(triggerKinds ?? []).includes(slot.trigger))
75
+ bad.push(`slot ${slot.id}: trigger ${slot.trigger} is not one of triggerKinds`);
76
+ if (slot.tier !== 'feature')
77
+ bad.push(`slot ${slot.id}: a trigger belongs to a feature-tier slot`);
78
+ return bad;
77
79
  }
78
-
79
80
  /** Whether an opt-in slot is enabled for the repository: by its app kind, by a connection's provider, by name in optionalSlots, or by its declared pattern. */
80
81
  export function declaredSlotEnabled(slot, repo) {
81
- if (slot.appKind !== undefined) return repo.apps.some((app) => app.kind === slot.appKind);
82
- // A provider declared on any connection (be owns them all today) enables the provider slots of every profile: repo.providers
83
- // is the app-wide union the declaration resolver computed; a hand-built repo falls back to its own connections.
84
- if (slot.provider !== undefined) return (repo.providers ?? (repo.connections ?? []).map((connection) => connection.provider)).includes(slot.provider);
85
- return repo.optionalSlots.includes(slot.id) || (slot.pattern !== undefined && (repo.patterns ?? []).includes(slot.pattern));
82
+ if (slot.appKind !== undefined)
83
+ return repo.apps.some((app) => app.kind === slot.appKind);
84
+ // A provider declared on any connection (be owns them all today) enables the provider slots of every profile: repo.providers
85
+ // is the app-wide union the declaration resolver computed; a hand-built repo falls back to its own connections.
86
+ if (slot.provider !== undefined)
87
+ return (repo.providers ?? (repo.connections ?? []).map((connection) => connection.provider)).includes(slot.provider);
88
+ return repo.optionalSlots.includes(slot.id) || (slot.pattern !== undefined && (repo.patterns ?? []).includes(slot.pattern));
86
89
  }
@@ -4,74 +4,77 @@
4
4
  // Its overlays exclude the e2e world, and every slot keeps its own `tests`.
5
5
  import { isPlainObject } from '../../engine/plain-object.mjs';
6
6
  import { EDITIONS } from './manifest-shape.mjs';
7
-
8
7
  /** The presence of `slot` under edition lite for `profile`: `litePresence`, else the slot's own presence. */
9
8
  export function litePresenceOf(slot, profile) {
10
- const lp = slot.litePresence;
11
- if (lp === undefined) return slot.presence;
12
- return isPlainObject(lp) ? (lp[profile] ?? slot.presence) : lp;
9
+ const lp = slot.litePresence;
10
+ if (lp === undefined)
11
+ return slot.presence;
12
+ return isPlainObject(lp) ? (lp[profile] ?? slot.presence) : lp;
13
13
  }
14
-
15
14
  /** Whether `slot` exists under `edition` of `manifest` (default: the manifest's own editions). */
16
15
  export function slotInEdition(manifest, slot, edition) {
17
- return (slot.editions ?? manifest.editions ?? EDITIONS).includes(edition);
16
+ return (slot.editions ?? manifest.editions ?? EDITIONS).includes(edition);
18
17
  }
19
-
20
18
  /** The slot as `edition` sees it: lite overlays its data, presence and tracking; `tests` stays the slot's own (lite keeps the unit specs). */
21
19
  export function effectiveSlot(slot, profile, edition) {
22
- if (edition !== 'lite') return slot;
23
- const { lite, litePresence, ...base } = slot;
24
- const presence = litePresenceOf(slot, profile);
25
- let tracked = slot.tracked;
26
- if (presence === 'forbidden') tracked = 'external';
27
- else if (tracked === 'external') tracked = 'tracked';
28
- return { ...base, ...lite, presence, tracked };
20
+ if (edition !== 'lite')
21
+ return slot;
22
+ const { lite, litePresence, ...base } = slot;
23
+ const presence = litePresenceOf(slot, profile);
24
+ let tracked = slot.tracked;
25
+ if (presence === 'forbidden')
26
+ tracked = 'external';
27
+ else if (tracked === 'external')
28
+ tracked = 'tracked';
29
+ return { ...base, ...lite, presence, tracked };
29
30
  }
30
-
31
31
  /** The template group starci app sync renders `slot` from under `edition`: `liteManagedBy` (else `managedBy`) in lite, `managedBy` otherwise; undefined when unmanaged. */
32
32
  export function managedGroupOf(slot, edition) {
33
- return edition === 'lite' ? (slot.liteManagedBy ?? slot.managedBy) : slot.managedBy;
33
+ return edition === 'lite' ? (slot.liteManagedBy ?? slot.managedBy) : slot.managedBy;
34
34
  }
35
-
36
35
  /** The declared edition and the vocabulary against which it is validated. */
37
36
  export function declarationEdition(manifest, declaration) {
38
- const edition = declaration.edition === undefined ? 'full' : declaration.edition;
39
- const known = manifest.editions ?? EDITIONS;
40
- return { edition, known, valid: known.includes(edition) };
37
+ const edition = declaration.edition === undefined ? 'full' : declaration.edition;
38
+ const known = manifest.editions ?? EDITIONS;
39
+ return { edition, known, valid: known.includes(edition) };
41
40
  }
42
-
43
41
  /** Problems of an optional rule-catalog `editions` list, in the catalog schema's words. */
44
42
  export function ruleEditionProblems(rule, label) {
45
- if (rule.editions === undefined) return [];
46
- const bad = [];
47
- if (!Array.isArray(rule.editions) || !rule.editions.length) return [`${label}.editions must be a non-empty list`];
48
- for (const value of rule.editions) if (!EDITIONS.includes(value)) bad.push(`${label}.editions has ${JSON.stringify(value)}, not one of ${EDITIONS.join(', ')}`);
49
- if (new Set(rule.editions).size !== rule.editions.length) bad.push(`${label}.editions repeats a value`);
50
- return bad;
43
+ if (rule.editions === undefined)
44
+ return [];
45
+ const bad = [];
46
+ if (!Array.isArray(rule.editions) || !rule.editions.length)
47
+ return [`${label}.editions must be a non-empty list`];
48
+ for (const value of rule.editions)
49
+ if (!EDITIONS.includes(value))
50
+ bad.push(`${label}.editions has ${JSON.stringify(value)}, not one of ${EDITIONS.join(', ')}`);
51
+ if (new Set(rule.editions).size !== rule.editions.length)
52
+ bad.push(`${label}.editions repeats a value`);
53
+ return bad;
51
54
  }
52
-
53
55
  /** Whether a catalogued rule owner judges its finding under `edition`; uncatalogued codes always remain judged. */
54
56
  export function judgedInEdition(owner, edition = 'full') {
55
- return !owner?.editions || owner.editions.includes(edition);
57
+ return !owner?.editions || owner.editions.includes(edition);
56
58
  }
57
-
58
59
  /** Whether the enforcer `kind:id` of the catalog `rules` runs under `edition`: every rule listing it is judged there, and the enforcer row's own `editions` (a rule with several enforcers where only one is full-only) agrees. A lint rule no rule lists runs everywhere. */
59
60
  export function enforcerJudgedInEdition(rules, kind, id, edition = 'full') {
60
- const owners = rules.filter((rule) => rule.enforcers.some((enforcer) => enforcer.kind === kind && enforcer.id === id));
61
- return owners.every((rule) => judgedInEdition(rule, edition) && rule.enforcers.filter((enforcer) => enforcer.kind === kind && enforcer.id === id).every((enforcer) => judgedInEdition(enforcer, edition)));
61
+ const owners = rules.filter((rule) => rule.enforcers.some((enforcer) => enforcer.kind === kind && enforcer.id === id));
62
+ return owners.every((rule) => judgedInEdition(rule, edition) && rule.enforcers.filter((enforcer) => enforcer.kind === kind && enforcer.id === id).every((enforcer) => judgedInEdition(enforcer, edition)));
62
63
  }
63
-
64
64
  /**
65
65
  * A frozen copy of one profile's parameters, with its lite overrides applied only in the lite edition. A lite key whose base
66
66
  * value and override are both maps merges one level deep (lite.infraOwners restates only the specifiers whose owner changes);
67
67
  * any other value replaces the base.
68
68
  */
69
69
  export function editionRuleParams(params, edition) {
70
- const { lite, ...base } = params;
71
- const merged = edition === 'lite' && lite ? { ...base } : base;
72
- if (edition === 'lite' && lite) {
73
- for (const [key, value] of Object.entries(lite)) merged[key] = isPlainObject(value) && isPlainObject(base[key]) ? { ...base[key], ...value } : value;
74
- }
75
- const deepFreeze = (value) => { if (value && typeof value === 'object') { Object.values(value).forEach(deepFreeze); } return Object.freeze(value); };
76
- return deepFreeze(structuredClone(merged));
70
+ const { lite, ...base } = params;
71
+ const merged = edition === 'lite' && lite ? { ...base } : base;
72
+ if (edition === 'lite' && lite) {
73
+ for (const [key, value] of Object.entries(lite))
74
+ merged[key] = isPlainObject(value) && isPlainObject(base[key]) ? { ...base[key], ...value } : value;
75
+ }
76
+ const deepFreeze = (value) => { if (value && typeof value === 'object') {
77
+ Object.values(value).forEach(deepFreeze);
78
+ } return Object.freeze(value); };
79
+ return deepFreeze(structuredClone(merged));
77
80
  }
@@ -1,30 +1,30 @@
1
1
  // Linear-time text trimming and `<placeholder>` replacement for the HFS path and prose checks.
2
-
3
2
  /** `text` without its trailing characters that are in `chars`. */
4
3
  export function trimTrailingChars(text, chars) {
5
- let last = text.length - 1;
6
- while (last >= 0 && chars.includes(text[last])) last -= 1;
7
- return text.slice(0, last + 1);
4
+ let last = text.length - 1;
5
+ while (last >= 0 && chars.includes(text[last]))
6
+ last -= 1;
7
+ return text.slice(0, last + 1);
8
8
  }
9
-
10
9
  /** `text` with every `<name>` placeholder (a `<`, one or more characters other than `>`, a `>`) replaced by `replacement`. */
11
10
  export function replacePlaceholders(text, replacement) {
12
- let out = '';
13
- let from = 0;
14
- let open = text.indexOf('<');
15
- while (open >= 0) {
16
- const close = text.indexOf('>', open + 1);
17
- if (close < 0) break;
18
- if (close === open + 1) {
19
- open = text.indexOf('<', close);
20
- } else {
21
- out += text.slice(from, open) + replacement;
22
- from = close + 1;
23
- open = text.indexOf('<', from);
11
+ let out = '';
12
+ let from = 0;
13
+ let open = text.indexOf('<');
14
+ while (open >= 0) {
15
+ const close = text.indexOf('>', open + 1);
16
+ if (close < 0)
17
+ break;
18
+ if (close === open + 1) {
19
+ open = text.indexOf('<', close);
20
+ }
21
+ else {
22
+ out += text.slice(from, open) + replacement;
23
+ from = close + 1;
24
+ open = text.indexOf('<', from);
25
+ }
24
26
  }
25
- }
26
- return out + text.slice(from);
27
+ return out + text.slice(from);
27
28
  }
28
-
29
29
  /** Whether `text` holds a `<name>` placeholder. */
30
30
  export const hasPlaceholder = (text) => replacePlaceholders(text, '') !== text;
@@ -1,18 +1,13 @@
1
- // param-names.mjs - the one shape of `ruleParams.be.paramNames` of knowledge/hfs/slots.yaml (R85 injected-param-name): a non-empty list of unique
2
- // entries `{type | typeSuffix, names, nameSuffix?}`. The loader of scripts/hfs/slots.mjs calls it; the schema (modules/schemas/hfs-slots.schema.yaml)
3
- // states the same shape.
4
1
  import { isPlainObject } from '../../engine/plain-object.mjs';
5
-
6
2
  const UPPER = /^[A-Z][A-Za-z0-9]*$/u;
7
3
  const LOWER = /^[a-z][A-Za-z0-9]*$/u;
8
-
9
4
  const entryOk = (e) => isPlainObject(e) && ((e.type === undefined) !== (e.typeSuffix === undefined)) && UPPER.test(String(e.type ?? e.typeSuffix))
10
- && Array.isArray(e.names) && e.names.length > 0 && new Set(e.names).size === e.names.length && e.names.every((n) => LOWER.test(String(n)))
11
- && (e.nameSuffix === undefined || UPPER.test(String(e.nameSuffix))) && Object.keys(e).every((k) => ['type', 'typeSuffix', 'names', 'nameSuffix'].includes(k));
12
-
5
+ && Array.isArray(e.names) && e.names.length > 0 && new Set(e.names).size === e.names.length && e.names.every((n) => LOWER.test(String(n)))
6
+ && (e.nameSuffix === undefined || UPPER.test(String(e.nameSuffix))) && Object.keys(e).every((k) => ['type', 'typeSuffix', 'names', 'nameSuffix'].includes(k));
13
7
  /** True when `list` is a well-formed paramNames table. */
14
8
  export function paramNamesOk(list) {
15
- if (!Array.isArray(list) || list.length === 0 || !list.every(entryOk)) return false;
16
- const keys = list.map((e) => (e.type !== undefined ? `type:${e.type}` : `typeSuffix:${e.typeSuffix}`));
17
- return new Set(keys).size === keys.length;
9
+ if (!Array.isArray(list) || list.length === 0 || !list.every(entryOk))
10
+ return false;
11
+ const keys = list.map((e) => (e.type !== undefined ? `type:${e.type}` : `typeSuffix:${e.typeSuffix}`));
12
+ return new Set(keys).size === keys.length;
18
13
  }