@starci/eslint-canon-be 3.18.3 → 3.19.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 (208) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/comments.js +1 -1
  3. package/dist/explicit-surface.js +1 -1
  4. package/dist/index.js +1 -1
  5. package/dist/jwt-alg.js +1 -1
  6. package/dist/lib/edition.d.ts +1 -1
  7. package/dist/lib/edition.js +1 -1
  8. package/dist/lib/hfs.d.ts +0 -6
  9. package/dist/lib/hfs.js +7 -5
  10. package/dist/lib/runtime-root.d.ts +6 -1
  11. package/dist/lib/runtime-root.js +8 -2
  12. package/dist/lib/subject-values.js +1 -1
  13. package/dist/module-layering.js +2 -2
  14. package/dist/project-graph.js +1 -1
  15. package/dist/third-party-owner.js +1 -1
  16. package/package.json +3 -1
  17. package/runtime/bundle.json +1 -190
  18. package/runtime/scripts/api/git/recorded-lines.mjs +5 -5
  19. package/runtime/scripts/hfs/project-graph.mjs +6 -6
  20. package/runtime/scripts/hfs/project-rule.mjs +3 -3
  21. package/runtime/config.example.yaml +0 -194
  22. package/runtime/engine/by-code-unit.mjs +0 -12
  23. package/runtime/engine/config.mjs +0 -461
  24. package/runtime/engine/invalid-config.mjs +0 -15
  25. package/runtime/engine/model-config.mjs +0 -112
  26. package/runtime/engine/orca-config.mjs +0 -34
  27. package/runtime/engine/plain-object.mjs +0 -5
  28. package/runtime/engine/release-config.mjs +0 -32
  29. package/runtime/engine/removed-vocabulary.mjs +0 -27
  30. package/runtime/engine/resources-config.mjs +0 -59
  31. package/runtime/engine/runtime-root.mjs +0 -138
  32. package/runtime/engine/secrets.mjs +0 -202
  33. package/runtime/engine/sonar-config.mjs +0 -24
  34. package/runtime/engine/temp-root.mjs +0 -26
  35. package/runtime/engine/yaml.mjs +0 -161
  36. package/runtime/knowledge/grammars/index.yaml +0 -114
  37. package/runtime/knowledge/hfs/canon-pins.yaml +0 -716
  38. package/runtime/knowledge/hfs/fe-stack.yaml +0 -272
  39. package/runtime/knowledge/hfs/rules.yaml +0 -6760
  40. package/runtime/knowledge/hfs/slots.yaml +0 -2783
  41. package/runtime/knowledge/patterns/fe/folder.yaml +0 -425
  42. package/runtime/knowledge/sonar-gate.yaml +0 -151
  43. package/runtime/modules/kernel/removed-vocabulary.yaml +0 -458
  44. package/runtime/modules/models/registry.yaml +0 -221
  45. package/runtime/modules/models/runtimes.yaml +0 -556
  46. package/runtime/modules/models/tiers.yaml +0 -66
  47. package/runtime/scripts/api/git/cat-file.mjs +0 -4
  48. package/runtime/scripts/api/git/config-get.mjs +0 -9
  49. package/runtime/scripts/api/git/diff.mjs +0 -4
  50. package/runtime/scripts/api/git/lib.mjs +0 -80
  51. package/runtime/scripts/api/git/ls-files.mjs +0 -5
  52. package/runtime/scripts/api/git/ls-tree.mjs +0 -4
  53. package/runtime/scripts/api/git/merge-base.mjs +0 -8
  54. package/runtime/scripts/api/git/remote.mjs +0 -4
  55. package/runtime/scripts/api/git/rev-parse-query.mjs +0 -4
  56. package/runtime/scripts/api/git/show.mjs +0 -5
  57. package/runtime/scripts/api/git/tag.mjs +0 -4
  58. package/runtime/scripts/hfs/allows.mjs +0 -77
  59. package/runtime/scripts/hfs/architecture/ast-walks.mjs +0 -250
  60. package/runtime/scripts/hfs/architecture/automatic-gates.mjs +0 -103
  61. package/runtime/scripts/hfs/architecture/backend-app-files.mjs +0 -114
  62. package/runtime/scripts/hfs/architecture/backend.mjs +0 -462
  63. package/runtime/scripts/hfs/architecture/background-unowned.mjs +0 -254
  64. package/runtime/scripts/hfs/architecture/canon-clones.mjs +0 -291
  65. package/runtime/scripts/hfs/architecture/canon-jsx-clones.mjs +0 -224
  66. package/runtime/scripts/hfs/architecture/client-reaches-server.mjs +0 -102
  67. package/runtime/scripts/hfs/architecture/clones.mjs +0 -287
  68. package/runtime/scripts/hfs/architecture/component-tiers.mjs +0 -161
  69. package/runtime/scripts/hfs/architecture/config-unread.mjs +0 -16
  70. package/runtime/scripts/hfs/architecture/config.mjs +0 -407
  71. package/runtime/scripts/hfs/architecture/connection-map.mjs +0 -350
  72. package/runtime/scripts/hfs/architecture/constructor-deps.mjs +0 -115
  73. package/runtime/scripts/hfs/architecture/context-coupling.mjs +0 -117
  74. package/runtime/scripts/hfs/architecture/context-map.mjs +0 -355
  75. package/runtime/scripts/hfs/architecture/context-owner.mjs +0 -102
  76. package/runtime/scripts/hfs/architecture/context-platform-tables.mjs +0 -65
  77. package/runtime/scripts/hfs/architecture/context-transaction.mjs +0 -75
  78. package/runtime/scripts/hfs/architecture/contract-bounds.mjs +0 -72
  79. package/runtime/scripts/hfs/architecture/contract-fixture-guard.mjs +0 -177
  80. package/runtime/scripts/hfs/architecture/contracts-readonly.mjs +0 -360
  81. package/runtime/scripts/hfs/architecture/contracts.mjs +0 -489
  82. package/runtime/scripts/hfs/architecture/cross-app-duplicate.mjs +0 -81
  83. package/runtime/scripts/hfs/architecture/dead-exports-bindings.mjs +0 -173
  84. package/runtime/scripts/hfs/architecture/dead-exports.mjs +0 -420
  85. package/runtime/scripts/hfs/architecture/default-deny.mjs +0 -175
  86. package/runtime/scripts/hfs/architecture/doc-language.mjs +0 -45
  87. package/runtime/scripts/hfs/architecture/entity-registry.mjs +0 -51
  88. package/runtime/scripts/hfs/architecture/entrypoint.mjs +0 -75
  89. package/runtime/scripts/hfs/architecture/error-codes.mjs +0 -54
  90. package/runtime/scripts/hfs/architecture/error-masked.mjs +0 -78
  91. package/runtime/scripts/hfs/architecture/fe-slot-allows.mjs +0 -44
  92. package/runtime/scripts/hfs/architecture/feature-shape.mjs +0 -60
  93. package/runtime/scripts/hfs/architecture/framework-pinned.mjs +0 -41
  94. package/runtime/scripts/hfs/architecture/frontend-block-render.mjs +0 -112
  95. package/runtime/scripts/hfs/architecture/frontend-grammar.mjs +0 -193
  96. package/runtime/scripts/hfs/architecture/frontend-routing.mjs +0 -198
  97. package/runtime/scripts/hfs/architecture/frontend-world-render.mjs +0 -368
  98. package/runtime/scripts/hfs/architecture/frontend-world.mjs +0 -374
  99. package/runtime/scripts/hfs/architecture/frontend.mjs +0 -248
  100. package/runtime/scripts/hfs/architecture/function-spec-providers.mjs +0 -185
  101. package/runtime/scripts/hfs/architecture/hfs-graph.mjs +0 -77
  102. package/runtime/scripts/hfs/architecture/hfs.mjs +0 -394
  103. package/runtime/scripts/hfs/architecture/hooks-are-hooks.mjs +0 -118
  104. package/runtime/scripts/hfs/architecture/i18n-keys.mjs +0 -213
  105. package/runtime/scripts/hfs/architecture/identity.mjs +0 -121
  106. package/runtime/scripts/hfs/architecture/index.mjs +0 -402
  107. package/runtime/scripts/hfs/architecture/injection-token-exported.mjs +0 -69
  108. package/runtime/scripts/hfs/architecture/jwt-ast.mjs +0 -231
  109. package/runtime/scripts/hfs/architecture/machine-ast.mjs +0 -232
  110. package/runtime/scripts/hfs/architecture/managed-scripts.mjs +0 -32
  111. package/runtime/scripts/hfs/architecture/module-per-transport.mjs +0 -237
  112. package/runtime/scripts/hfs/architecture/next-data-contract.mjs +0 -126
  113. package/runtime/scripts/hfs/architecture/next-data-inference.mjs +0 -192
  114. package/runtime/scripts/hfs/architecture/next-data-key.mjs +0 -374
  115. package/runtime/scripts/hfs/architecture/next-data-symbols.mjs +0 -26
  116. package/runtime/scripts/hfs/architecture/next-data.mjs +0 -425
  117. package/runtime/scripts/hfs/architecture/operation-contract-roots.mjs +0 -55
  118. package/runtime/scripts/hfs/architecture/owners.mjs +0 -142
  119. package/runtime/scripts/hfs/architecture/package-shape.mjs +0 -92
  120. package/runtime/scripts/hfs/architecture/presentation.mjs +0 -173
  121. package/runtime/scripts/hfs/architecture/reachability.mjs +0 -330
  122. package/runtime/scripts/hfs/architecture/register-once.mjs +0 -212
  123. package/runtime/scripts/hfs/architecture/registration.mjs +0 -372
  124. package/runtime/scripts/hfs/architecture/render-graph.mjs +0 -449
  125. package/runtime/scripts/hfs/architecture/render-prop-across-server.mjs +0 -58
  126. package/runtime/scripts/hfs/architecture/required-files.mjs +0 -237
  127. package/runtime/scripts/hfs/architecture/root-packages.mjs +0 -78
  128. package/runtime/scripts/hfs/architecture/route-files-thin.mjs +0 -133
  129. package/runtime/scripts/hfs/architecture/schema-owner.mjs +0 -288
  130. package/runtime/scripts/hfs/architecture/server-action.mjs +0 -78
  131. package/runtime/scripts/hfs/architecture/side-boundary.mjs +0 -13
  132. package/runtime/scripts/hfs/architecture/source-names-shape.mjs +0 -320
  133. package/runtime/scripts/hfs/architecture/source-names.mjs +0 -393
  134. package/runtime/scripts/hfs/architecture/sql-keys.mjs +0 -344
  135. package/runtime/scripts/hfs/architecture/sql-owner.mjs +0 -291
  136. package/runtime/scripts/hfs/architecture/sql-returning.mjs +0 -76
  137. package/runtime/scripts/hfs/architecture/sql-token-forms.mjs +0 -117
  138. package/runtime/scripts/hfs/architecture/sql-tokens.mjs +0 -587
  139. package/runtime/scripts/hfs/architecture/staged-consumers.mjs +0 -42
  140. package/runtime/scripts/hfs/architecture/surface-nesting.mjs +0 -127
  141. package/runtime/scripts/hfs/architecture/surface.mjs +0 -88
  142. package/runtime/scripts/hfs/architecture/symbols.mjs +0 -273
  143. package/runtime/scripts/hfs/architecture/test-world-files.mjs +0 -263
  144. package/runtime/scripts/hfs/architecture/tiers.mjs +0 -256
  145. package/runtime/scripts/hfs/architecture/transport-owner.mjs +0 -248
  146. package/runtime/scripts/hfs/architecture/type-context.mjs +0 -335
  147. package/runtime/scripts/hfs/architecture/typescript.mjs +0 -477
  148. package/runtime/scripts/hfs/architecture/unit-spec-providers.mjs +0 -165
  149. package/runtime/scripts/hfs/declaration-shape.mjs +0 -196
  150. package/runtime/scripts/hfs/declaration-slots.mjs +0 -89
  151. package/runtime/scripts/hfs/edition-slots.mjs +0 -80
  152. package/runtime/scripts/hfs/explicit-surface-rule.mjs +0 -59
  153. package/runtime/scripts/hfs/linear-text.mjs +0 -30
  154. package/runtime/scripts/hfs/manifest-shape.mjs +0 -474
  155. package/runtime/scripts/hfs/param-names.mjs +0 -13
  156. package/runtime/scripts/hfs/path-findings.mjs +0 -167
  157. package/runtime/scripts/hfs/repo-identity.mjs +0 -89
  158. package/runtime/scripts/hfs/rule-catalog.mjs +0 -458
  159. package/runtime/scripts/hfs/rule-params-shape.mjs +0 -103
  160. package/runtime/scripts/hfs/rules/database-constants.mjs +0 -25
  161. package/runtime/scripts/hfs/rules/database-migrations.mjs +0 -684
  162. package/runtime/scripts/hfs/rules/fe-no-tests.mjs +0 -68
  163. package/runtime/scripts/hfs/rules/read.mjs +0 -45
  164. package/runtime/scripts/hfs/rules/secrets.mjs +0 -79
  165. package/runtime/scripts/hfs/rules/spec-placement.mjs +0 -28
  166. package/runtime/scripts/hfs/slot-app-view.mjs +0 -97
  167. package/runtime/scripts/hfs/slot-classify.mjs +0 -69
  168. package/runtime/scripts/hfs/slot-errors.mjs +0 -12
  169. package/runtime/scripts/hfs/slot-imports.mjs +0 -98
  170. package/runtime/scripts/hfs/slot-manifest-shape.mjs +0 -111
  171. package/runtime/scripts/hfs/slot-match.mjs +0 -164
  172. package/runtime/scripts/hfs/slot-path.mjs +0 -6
  173. package/runtime/scripts/hfs/slot-required.mjs +0 -95
  174. package/runtime/scripts/hfs/slot-semantic-problems.mjs +0 -175
  175. package/runtime/scripts/hfs/slot-side-problems.mjs +0 -32
  176. package/runtime/scripts/hfs/slots.mjs +0 -306
  177. package/runtime/scripts/hfs/test-world-slot.mjs +0 -5
  178. package/runtime/scripts/hfs/trailing-slashes.mjs +0 -8
  179. package/runtime/scripts/hfs/typescript-programs.mjs +0 -95
  180. package/runtime/scripts/hfs/view.mjs +0 -180
  181. package/runtime/scripts/lib/declaration-surface.mjs +0 -166
  182. package/runtime/scripts/lib/dockerfile.mjs +0 -164
  183. package/runtime/scripts/lib/env.mjs +0 -18
  184. package/runtime/scripts/lib/event-contract.mjs +0 -102
  185. package/runtime/scripts/lib/git-hooks-dir.mjs +0 -30
  186. package/runtime/scripts/lib/git.mjs +0 -35
  187. package/runtime/scripts/lib/glob.mjs +0 -32
  188. package/runtime/scripts/lib/grammar-lint.mjs +0 -57
  189. package/runtime/scripts/lib/i18n.mjs +0 -82
  190. package/runtime/scripts/lib/in-order.mjs +0 -90
  191. package/runtime/scripts/lib/json-clone.mjs +0 -70
  192. package/runtime/scripts/lib/json.mjs +0 -44
  193. package/runtime/scripts/lib/language.mjs +0 -233
  194. package/runtime/scripts/lib/list.mjs +0 -26
  195. package/runtime/scripts/lib/mutation-fence.mjs +0 -20
  196. package/runtime/scripts/lib/package-at.mjs +0 -62
  197. package/runtime/scripts/lib/path-key.mjs +0 -124
  198. package/runtime/scripts/lib/read-text.mjs +0 -47
  199. package/runtime/scripts/lib/regex.mjs +0 -3
  200. package/runtime/scripts/lib/rule-packs.mjs +0 -243
  201. package/runtime/scripts/lib/same-text.mjs +0 -4
  202. package/runtime/scripts/lib/secret-patterns.mjs +0 -230
  203. package/runtime/scripts/lib/sops-envelope.mjs +0 -212
  204. package/runtime/scripts/lib/stack-services.mjs +0 -191
  205. package/runtime/scripts/lib/ts-analysis.mjs +0 -39
  206. package/runtime/scripts/lib/ts-ast.mjs +0 -63
  207. package/runtime/scripts/lib/walk.mjs +0 -45
  208. package/runtime/scripts/lib/yaml-cached.mjs +0 -14
@@ -1,34 +0,0 @@
1
- import { isPlainObject as plain } from './plain-object.mjs';
2
- import { invalid } from './invalid-config.mjs';
3
- /**
4
- * config.yaml `orca` — the owner's Orca app settings the runtime must know. maxWorkerDepth is the deepest worker Orca
5
- * lets start under the owner's chat (chat = depth 0, a Kernel or the [Supervisor] 1, an op or a [Worker] 2, the draw
6
- * critic 3); a deeper worker-start is refused by Orca with nested_worker_depth_exceeded. Orca exposes no read of that
7
- * setting, so it is declared here and MUST equal the Orca app setting: scripts/agent/lib.mjs spawnAgent refuses a launch
8
- * deeper than it before worker-start (worker-depth-exceeded), and `start --check` with STARCI_ORCA_LIVE=1 compares it with
9
- * a measured probe (scripts/agent/depth-probe.mjs).
10
- */
11
- export const ORCA_DEFAULTS = Object.freeze({ maxWorkerDepth: 4 });
12
- /** The keys of the orca block. */
13
- export const ORCA_KEYS = Object.freeze(Object.keys(ORCA_DEFAULTS));
14
- export const MAX_WORKER_DEPTH_CEILING = 16;
15
- export function validateOrca(orca) {
16
- if (orca === null)
17
- return;
18
- const bad = invalid('orca');
19
- if (!plain(orca))
20
- return bad(' must be {maxWorkerDepth?} or null.');
21
- for (const key of Object.keys(orca))
22
- if (!ORCA_KEYS.includes(key))
23
- bad(` has unknown key ${key} (allowed: ${ORCA_KEYS.join(', ')}).`);
24
- const v = orca.maxWorkerDepth;
25
- if (v !== undefined && v !== null && !(typeof v === 'number' && Number.isInteger(v) && v >= 1 && v <= MAX_WORKER_DEPTH_CEILING))
26
- bad(`.maxWorkerDepth must be an integer from 1 to ${MAX_WORKER_DEPTH_CEILING} equal to the Orca app's worker depth setting (default ${ORCA_DEFAULTS.maxWorkerDepth}), or null.`);
27
- }
28
- /** The owner's Orca settings: {maxWorkerDepth, source: 'orca'|'default'}. An absent or null block or key is the default. */
29
- export function orcaSettings(config) {
30
- if (config?.orca !== undefined)
31
- validateOrca(config.orca);
32
- const value = plain(config?.orca) ? config.orca.maxWorkerDepth : null;
33
- return typeof value === 'number' && Number.isInteger(value) ? { maxWorkerDepth: value, source: 'orca' } : { maxWorkerDepth: ORCA_DEFAULTS.maxWorkerDepth, source: 'default' };
34
- }
@@ -1,5 +0,0 @@
1
- // plain-object.mjs — the one "is this a non-array object" predicate the runtime asks with.
2
- // A leaf beside digest.mjs: schema walkers, config readers and JSON consumers all mean the
3
- // same thing by "a mapping" - own object, never null, never an array - so they share it here.
4
- /** True for a non-null, non-array object. Does not check the prototype (a JSON.parse result). */
5
- export const isPlainObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
@@ -1,32 +0,0 @@
1
- import { isPlainObject as plain } from './plain-object.mjs';
2
- import { invalid } from './invalid-config.mjs';
3
- /** The keys of the release block. */
4
- export const RELEASE_KEYS = Object.freeze(['suite']);
5
- /** Where the full test suite of a release is judged: `local` (the release cut also runs the L4 rows before it tags, the shipped default) or `ci` (the GitHub workflows judge EVERY row on each push to main; the cut runs none). */
6
- export const SUITE_MODES = Object.freeze(['local', 'ci']);
7
- const RELEASE_DEFAULTS = Object.freeze({ suite: 'local' });
8
- /**
9
- * config.yaml `release` - {suite?: local | ci}: who judges the full suite of a release (docs/releasing.md "Where the suite runs"). `local` is the shipped default: `starci release cut` also runs the
10
- * L4 rows on this host before it tags. `ci` is the owner's recorded choice (2026-10-09, widened 2026-10-26 by push-main-after-scoped-check): the full suite runs on GitHub only, on every push
11
- * to main; the cut runs no row and the verdict is read with `starci release ci-status`. The push of main needs neither mode: it needs a green scoped check.
12
- * `none` is refused: the suite does not vanish, it moves to CI, and the value says so.
13
- */
14
- export function validateRelease(release) {
15
- if (release === null)
16
- return;
17
- const bad = invalid('release');
18
- if (!plain(release))
19
- return bad(` must be {suite?: ${SUITE_MODES.join(' | ')}} or null.`);
20
- for (const key of Object.keys(release))
21
- if (!RELEASE_KEYS.includes(key))
22
- bad(` has unknown key ${key} (allowed: ${RELEASE_KEYS.join(', ')}).`);
23
- const value = release.suite;
24
- if (value === undefined || value === null)
25
- return;
26
- if (value === 'none')
27
- bad('.suite: "none" is not a mode: write "ci" (no local full suite, CI judges) or "local".');
28
- if (typeof value !== 'string' || !SUITE_MODES.includes(value))
29
- bad(`.suite must be ${SUITE_MODES.join(' or ')}, or null.`);
30
- }
31
- /** The suite mode a validated owner config names; an absent block or key is the shipped default. */
32
- export const releaseSuiteMode = (config) => config?.release?.suite ?? RELEASE_DEFAULTS.suite;
@@ -1,27 +0,0 @@
1
- import fs from 'node:fs';
2
- import { fileURLToPath } from 'node:url';
3
- import { parseYaml } from './yaml.mjs';
4
- const FILE = fileURLToPath(new URL('../modules/kernel/removed-vocabulary.yaml', import.meta.url));
5
- let cache = null;
6
- function loaded() {
7
- let stat;
8
- try {
9
- stat = fs.statSync(FILE);
10
- }
11
- catch {
12
- throw new Error('Missing modules/kernel/removed-vocabulary.yaml');
13
- }
14
- const version = `${stat.mtimeMs}:${stat.size}`;
15
- if (cache?.version !== version)
16
- cache = { version, doc: parseYaml(fs.readFileSync(FILE, 'utf8')) };
17
- return cache.doc;
18
- }
19
- /** modules/kernel/removed-vocabulary.yaml: the one list of spellings the runtime refuses, each with its replacement and the release that removed it. */
20
- export const removedVocabulary = () => loaded().removed;
21
- /** The removed spellings of one kind. */
22
- export const removedOfKind = (kind) => removedVocabulary().filter(entry => entry.kind === kind);
23
- /** `<name> is removed (<replacement>)` for a removed spelling of the kind, or undefined when the name is not one. */
24
- export function removedNotice(kind, name) {
25
- const entry = removedOfKind(kind).find(candidate => candidate.name === name);
26
- return entry ? `${entry.name} is removed (${entry.use})` : undefined;
27
- }
@@ -1,59 +0,0 @@
1
- import { isPlainObject as plain } from './plain-object.mjs';
2
- import { invalid } from './invalid-config.mjs';
3
- /**
4
- * config.yaml `resources` — the owner's host-capacity floors, which override the shipped numbers of
5
- * modules/models/runtimes.yaml `allocation.resources`. minFreeDiskGb: the free space a drive holding the temp root or the
6
- * repository must keep before `starci kernel dispatch --spawn` launches another worker. minFreeDiskPct: the same floor as a
7
- * percentage of the drive's size; when both are set the larger requirement applies. minFreeRamPct: the free-RAM floor below
8
- * which no new heavy op starts. A null or absent key leaves the shipped number.
9
- */
10
- const FLOOR_LIMITS = Object.freeze({ minFreeDiskGb: Infinity, minFreeDiskPct: 100, minFreeRamPct: 100 });
11
- const inRange = (value, limit) => typeof value === 'number' && Number.isFinite(value) && value > 0 && value <= limit;
12
- /** The keys of the resources block. */
13
- export const RESOURCE_KEYS = Object.freeze(Object.keys(FLOOR_LIMITS));
14
- const isFloorKey = (key) => Object.hasOwn(FLOOR_LIMITS, key);
15
- export function validateResources(resources) {
16
- if (resources === null)
17
- return;
18
- const bad = invalid('resources');
19
- const keys = RESOURCE_KEYS;
20
- const shape = keys.map(key => `${key}?`).join(', ');
21
- if (!plain(resources))
22
- return bad(` must be {${shape}} or null.`);
23
- for (const key of Object.keys(resources))
24
- if (!keys.includes(key))
25
- bad(` has unknown key ${key} (allowed: ${keys.join(', ')}).`);
26
- for (const key of keys) {
27
- if (!isFloorKey(key))
28
- continue;
29
- const value = resources[key];
30
- if (value !== undefined && value !== null && !inRange(value, FLOOR_LIMITS[key])) {
31
- const cap = FLOOR_LIMITS[key] === Infinity ? '' : ` and at most ${FLOOR_LIMITS[key]}`;
32
- bad(`.${key} must be a number above 0${cap}, or null.`);
33
- }
34
- }
35
- }
36
- const declared = (block, key, source) => {
37
- const value = block?.[key];
38
- if (value === undefined || value === null)
39
- return null;
40
- if (!inRange(value, FLOOR_LIMITS[key]))
41
- throw new Error(`${source}.${key} must be a number above 0 (at most ${FLOOR_LIMITS[key]})`);
42
- return value;
43
- };
44
- /**
45
- * The floors in force: the owner's `resources` (config.yaml) over the shipped `allocation.resources`.
46
- * {minFreeDiskGb, minFreeDiskPct (null when unset), minFreeRamPct}. The shipped policy owns the default numbers: when it
47
- * omits or misspells minFreeDiskGb or minFreeRamPct this refuses, there is no fallback constant.
48
- */
49
- export function hostFloors(shipped, owner = null) {
50
- const source = 'modules/models/runtimes.yaml allocation.resources';
51
- const base = { minFreeDiskGb: declared(shipped, 'minFreeDiskGb', source), minFreeDiskPct: declared(shipped, 'minFreeDiskPct', source), minFreeRamPct: declared(shipped, 'minFreeRamPct', source) };
52
- for (const key of ['minFreeDiskGb', 'minFreeRamPct'])
53
- if (base[key] === null)
54
- throw new Error(`${source}.${key} must declare a positive number`);
55
- if (owner !== null && owner !== undefined)
56
- validateResources(owner);
57
- const pick = (key) => declared(owner, key, 'config.yaml resources') ?? base[key];
58
- return { minFreeDiskGb: pick('minFreeDiskGb'), minFreeDiskPct: pick('minFreeDiskPct'), minFreeRamPct: pick('minFreeRamPct') };
59
- }
@@ -1,138 +0,0 @@
1
- import fs from 'node:fs';
2
- import os from 'node:os';
3
- import path from 'node:path';
4
- import { fileURLToPath } from 'node:url';
5
- import { parseYaml } from './yaml.mjs';
6
- /**
7
- * Runtime root helper. The runtime reads this source tree directly. `skillRoot` is the
8
- * directory containing `package.json` (this module's parent) — the checkout, or the copy of it
9
- * an install placed on the host.
10
- *
11
- * Every workflow, op, schema, knowledge and model contract read at runtime is an authored YAML
12
- * file (or an authored JSON one where a document is stored that way). `readModuleJson` resolves a
13
- * path under `skillRoot` and parses the file by its extension.
14
- */
15
- const moduleRoot = path.dirname(fileURLToPath(new URL('../package.json', import.meta.url)));
16
- /** The runtime root: this source tree (or an immutable sealed payload of it). */
17
- export const skillRoot = moduleRoot;
18
- /**
19
- * The StarCi Source root (the host containing .claude and .workspaces): STARCI_SOURCE_ROOT overrides it, else the directory
20
- * holding this runtime checkout. Parameterized over `env`, so a spec can inject a fixture Source.
21
- */
22
- export const starciSourceRoot = (env = process.env) => (env.STARCI_SOURCE_ROOT ? path.resolve(env.STARCI_SOURCE_ROOT) : path.dirname(skillRoot));
23
- /** Overrides the per-host state base wholesale (debug probes, spec trees); the one seam starciLocalRoot reads. */
24
- export const LOCAL_ROOT_ENV = 'STARCI_LOCAL_ROOT';
25
- /** The host-data directory of a runtime root. Git-ignored and never packed; the example fixtures under examples/.runtimes are a separate, public exception. */
26
- export const RUNTIME_STATE_DIR = '.runtime';
27
- /**
28
- * <root>/.runtime, the state base of a runtime root that is a checkout (the harness repository, or a copy of it placed on the host).
29
- * An installed or locally sourced copy keeps none (see installedStateBase).
30
- */
31
- export const runtimeStateDir = (root = skillRoot) => path.join(root, RUNTIME_STATE_DIR);
32
- /** True when `root` is a copy an install or `starci deps source --local` placed below a node_modules folder, not a checkout. */
33
- export const installedRoot = (root = skillRoot) => path.resolve(root).split(/[\\/]/).includes('node_modules');
34
- /**
35
- * The per-user state base of an installed copy: LOCALAPPDATA (Windows), else XDG_STATE_HOME, else ~/.local/state, then
36
- * starci-harness/state. It lies outside every package and every product repository, so `npm ci` and a package copy never delete a
37
- * running stack's data, and every installed copy on the host shares one machine.sqlite and one stack/<project>/<env> per environment.
38
- */
39
- export const installedStateBase = (env = process.env) => path.join(env['LOCALAPPDATA'] || env['XDG_STATE_HOME'] || path.join(os.homedir(), '.local', 'state'), 'starci-harness', 'state');
40
- /**
41
- * The per-host state base, the one owner of every host-state location: machine.sqlite, projects/<ledger_id>/runtime.sqlite, archive/,
42
- * artifacts/ (the blob store), guards/, host-lock/, stack/<project>/<env>/ and the other process state sit under it. LOCAL_ROOT_ENV
43
- * replaces it wholesale; else a checkout keeps it in <runtime root>/.runtime and an installed copy in installedStateBase.
44
- */
45
- export const starciLocalRoot = (env = process.env, root = skillRoot) => {
46
- if (env[LOCAL_ROOT_ENV])
47
- return path.resolve(env[LOCAL_ROOT_ENV]);
48
- return installedRoot(root) ? installedStateBase(env) : runtimeStateDir(root);
49
- };
50
- /** The refusal of a legacy state base a running process still holds (a stack's bind mounts, an open log). */
51
- export class LegacyStateHeld extends Error {
52
- code = 'HFS_STATE_LEGACY_HELD';
53
- legacy;
54
- constructor(legacy, cause) {
55
- super(`${legacy} holds the state of a running stack and cannot move out of the package yet; run \`starci app stack down --env <env>\` for each running environment, then any \`starci app\` verb moves it`, { cause });
56
- this.legacy = legacy;
57
- }
58
- }
59
- const HELD = new Set(['EPERM', 'EBUSY', 'EACCES']);
60
- const isHeld = (error) => HELD.has(String(error?.code));
61
- /** Gives `to` and everything below it the mode, owner and group of the matching entry of `from` (a copy keeps neither on its own). */
62
- function keepOwnership(from, to) {
63
- const source = fs.lstatSync(from);
64
- const target = fs.lstatSync(to);
65
- if (!source.isSymbolicLink())
66
- fs.chmodSync(to, source.mode & 0o7777);
67
- if (source.uid !== target.uid || source.gid !== target.gid)
68
- fs.lchownSync(to, source.uid, source.gid);
69
- if (source.isDirectory())
70
- for (const name of fs.readdirSync(from))
71
- keepOwnership(path.join(from, name), path.join(to, name));
72
- }
73
- /** Moves one entry by rename, which keeps its owner and mode; across volumes (EXDEV) it is copied, its ownership restored, then removed. */
74
- function moveEntry(from, to) {
75
- try {
76
- fs.renameSync(from, to);
77
- return;
78
- }
79
- catch (error) {
80
- if (error?.code !== 'EXDEV')
81
- throw error;
82
- }
83
- fs.cpSync(from, to, { recursive: true, verbatimSymlinks: true, errorOnExist: true, force: false });
84
- keepOwnership(from, to);
85
- fs.rmSync(from, { recursive: true, force: true });
86
- }
87
- /**
88
- * Moves the state an installed copy kept inside itself (<copy>/.runtime, before installedStateBase) out to the state base, once: the
89
- * folder is first renamed to <copy>/.runtime.adopting (a rename a running stack's open files refuse, LegacyStateHeld), then each entry
90
- * is moved with its owner and mode (a bind folder a container user owns stays that user's) and the folder removed. An entry the state base already holds is kept beside it under legacy-<stamp>/, never overwritten. An
91
- * interrupted adoption resumes from .runtime.adopting. Null when there is nothing to adopt: a checkout, LOCAL_ROOT_ENV set, or no
92
- * legacy folder.
93
- */
94
- export function adoptLegacyState(env = process.env, root = skillRoot, now = () => new Date()) {
95
- if (env[LOCAL_ROOT_ENV] || !installedRoot(root))
96
- return null;
97
- const from = runtimeStateDir(root);
98
- const parked = `${from}.adopting`;
99
- if (!fs.existsSync(parked)) {
100
- if (!fs.existsSync(from))
101
- return null;
102
- try {
103
- fs.renameSync(from, parked);
104
- }
105
- catch (error) {
106
- if (isHeld(error))
107
- throw new LegacyStateHeld(from, error);
108
- throw error;
109
- }
110
- }
111
- const to = installedStateBase(env);
112
- const aside = path.join(to, `legacy-${now().toISOString().replace(/[^0-9]/g, '').slice(0, 14)}`);
113
- const moved = [];
114
- const kept = [];
115
- for (const name of fs.readdirSync(parked).sort()) {
116
- const taken = fs.existsSync(path.join(to, name));
117
- fs.mkdirSync(taken ? aside : to, { recursive: true });
118
- moveEntry(path.join(parked, name), path.join(taken ? aside : to, name));
119
- (taken ? kept : moved).push(name);
120
- }
121
- fs.rmSync(parked, { recursive: true, force: true });
122
- return { from, to, moved, kept };
123
- }
124
- /**
125
- * Read a runtime contract document. `parts` are path segments under `skillRoot`
126
- * (e.g. readModuleJson('modules', 'models', 'kinds.yaml')).
127
- */
128
- // reason: a parsed YAML/JSON contract document read from disk (parsed-input boundary); callers index into it by contract shape.
129
- export function readModuleJson(...parts) {
130
- const rel = parts.join('/');
131
- const file = path.join(skillRoot, rel);
132
- if (!(file.startsWith(skillRoot) && fs.existsSync(file) && fs.statSync(file).isFile()))
133
- throw new Error(`Required contract not found for ${rel} under ${skillRoot}`);
134
- const text = fs.readFileSync(file, 'utf8');
135
- if (/\.ya?ml$/i.test(file))
136
- return parseYaml(text);
137
- return JSON.parse(text);
138
- }
@@ -1,202 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- /** The host-local credential filename, resolved only against a verified runtime main root. */
4
- export const SECRET_ENV_FILE = 'secret.env';
5
- /** The configured credential variable grammar shared by validation and secret resolution. */
6
- export const ENV_NAME = /^[A-Z_][A-Z0-9_]{0,63}$/;
7
- export const CREDENTIAL_FILE_MAX_BYTES = 1024 * 1024;
8
- const resolvedValues = new Set();
9
- const remember = (value) => {
10
- if (typeof value === 'string' && value.length >= 6)
11
- resolvedValues.add(value);
12
- return value;
13
- };
14
- /** Filter credentials resolved by this process; the values never leave their resolution owner. */
15
- export function redactResolvedSecrets(text) {
16
- let clean = text;
17
- for (const value of resolvedValues)
18
- if (clean.includes(value))
19
- clean = clean.split(value).join('[redacted:resolved-secret]');
20
- return clean;
21
- }
22
- /** Check lexical availability only; blank and conventional template markers never prove provider validity. */
23
- export function credentialPresent(value) {
24
- if (typeof value !== 'string' || !value.trim())
25
- return false;
26
- return !/^(?:CHANGE_ME|REPLACE_ME|PLACEHOLDER|TODO|<[^>]*>|YOUR_[A-Z0-9_]+)$/i.test(value.trim());
27
- }
28
- /** Read one configured credential file with a finite byte budget; no effects beyond the read. */
29
- export function readSecretBytes(file) {
30
- const before = fs.lstatSync(file);
31
- if (!before.isFile() || before.isSymbolicLink())
32
- throw new Error('credential file must be a regular file');
33
- if (before.size > CREDENTIAL_FILE_MAX_BYTES)
34
- throw new Error('credential file exceeds the byte budget');
35
- const fd = fs.openSync(file, fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW ?? 0));
36
- let bytes;
37
- try {
38
- const stat = fs.fstatSync(fd);
39
- if (!stat.isFile() || stat.dev !== before.dev || stat.ino !== before.ino)
40
- throw new Error('credential file changed during resolution');
41
- bytes = Buffer.alloc(CREDENTIAL_FILE_MAX_BYTES + 1);
42
- let count = 0;
43
- while (count < bytes.length) {
44
- const n = fs.readSync(fd, bytes, count, bytes.length - count, null);
45
- if (n === 0) {
46
- break;
47
- }
48
- count += n;
49
- }
50
- if (count > CREDENTIAL_FILE_MAX_BYTES)
51
- throw new Error('credential file exceeds the byte budget');
52
- return bytes.subarray(0, count);
53
- }
54
- catch (error) {
55
- bytes?.fill(0);
56
- throw error;
57
- }
58
- finally {
59
- fs.closeSync(fd);
60
- }
61
- }
62
- const readCredentialFile = (file) => { const bytes = readSecretBytes(file); try {
63
- return bytes.toString('utf8');
64
- }
65
- finally {
66
- bytes.fill(0);
67
- } };
68
- const DOTENV_LINE_PARTS = [String.raw `^\s*`, String.raw `(?:export\s+)?`, String.raw `([A-Za-z_]\w*)`, String.raw `\s*=\s*`, String.raw `([^\r\n\u2028\u2029]*)`, String.raw `\s*$`];
69
- const DOTENV_LINE = new RegExp(DOTENV_LINE_PARTS.join(''));
70
- /** Parse a dotenv file (KEY=VALUE lines, # comments, optional export/quotes). An absent file is {}. */
71
- export function readDotenv(file) {
72
- let text = '';
73
- try {
74
- text = readCredentialFile(file);
75
- }
76
- catch (error) {
77
- if (error?.code === 'ENOENT') {
78
- return {};
79
- }
80
- throw error;
81
- }
82
- const out = {};
83
- for (const line of text.split(/\r?\n/)) {
84
- const m = DOTENV_LINE.exec(line);
85
- if (!m)
86
- continue;
87
- const name = m[1];
88
- let value = m[2].trimEnd();
89
- if (value.length >= 2 && (value.startsWith('"') || value.startsWith("'")) && value.at(-1) === value[0])
90
- value = value.slice(1, -1);
91
- out[name] = value;
92
- }
93
- return out;
94
- }
95
- /**
96
- * Resolve a configured variable or its supported NAME_FILE custody pointer. An explicitly supplied
97
- * blank variable disables the value; it must not resurrect a file value. Never print the result.
98
- */
99
- export function connectorSecret(name, env = process.env) {
100
- if (typeof name !== 'string' || !ENV_NAME.test(name))
101
- return null;
102
- const direct = env[name];
103
- if (Object.hasOwn(env, name))
104
- return typeof direct === 'string' ? remember(direct.trim() || null) : null;
105
- const filePointer = env[`${name}_FILE`];
106
- const pointer = typeof filePointer === 'string' ? filePointer.trim() : '';
107
- if (!pointer)
108
- return null;
109
- try {
110
- const value = readCredentialFile(pointer).trim();
111
- return remember(value || null);
112
- }
113
- catch {
114
- return null;
115
- }
116
- }
117
- /**
118
- * Load the verified runtime main's local credentials below the actual environment without mutating
119
- * either input. The caller owns repository identity; this base-tier reader never infers a root from cwd.
120
- * Absence is allowed so the action-specific gate can name only the credentials that action requires.
121
- */
122
- export function secretEnv(verifiedRuntimeRoot, env = process.env) {
123
- if (typeof verifiedRuntimeRoot !== 'string' || !path.isAbsolute(verifiedRuntimeRoot))
124
- throw new TypeError('secretEnv requires an absolute verified runtime root');
125
- if (env === null || typeof env !== 'object' || Array.isArray(env))
126
- throw new TypeError('secretEnv requires an environment mapping');
127
- const root = fs.lstatSync(verifiedRuntimeRoot);
128
- if (!root.isDirectory() || root.isSymbolicLink())
129
- throw new Error('secretEnv runtime root must be a regular directory');
130
- const file = path.join(verifiedRuntimeRoot, SECRET_ENV_FILE);
131
- let stat;
132
- try {
133
- stat = fs.lstatSync(file);
134
- }
135
- catch (error) {
136
- if (error?.code === 'ENOENT') {
137
- return { ...env };
138
- }
139
- throw error;
140
- }
141
- if (!stat.isFile() || stat.isSymbolicLink())
142
- throw new Error('secret.env must be a regular file');
143
- const local = readDotenv(file);
144
- const resolved = { ...local, ...env };
145
- for (const name of Object.keys(local))
146
- if (typeof resolved[name] === 'string')
147
- remember(resolved[name]);
148
- return resolved;
149
- }
150
- const sopsRefuse = (reason, message) => {
151
- const error = new Error(`SOPS identity [${reason}]: ${message}`);
152
- error.name = 'SopsIdentityRefusal';
153
- error.identityRefusal = reason;
154
- return { mode: 'refused', env: null, error };
155
- };
156
- const sopsInlineIdentity = (env, name) => {
157
- const inline = env[name];
158
- if (!credentialPresent(inline))
159
- return sopsRefuse('disabled-inline', 'SOPS_AGE_KEY is explicitly empty or invalid');
160
- remember(inline.trim());
161
- return { ...sopsRefuse('inline-context-unqualified', 'the supplied SOPS_AGE_KEY awaits an owned selected-identity isolation capability; no SOPS process was launched'), inlineName: name };
162
- };
163
- const sopsFileIdentity = (env, file) => {
164
- if (!credentialPresent(file))
165
- return sopsRefuse('invalid-file', 'the original identity file selection is empty or invalid');
166
- if (!path.isAbsolute(file))
167
- return sopsRefuse('identity-file-location-unqualified', 'select the original identity by its absolute path; caller and SOPS working directories may differ');
168
- try {
169
- const stat = fs.lstatSync(file);
170
- if (!stat.isFile() || stat.isSymbolicLink())
171
- return sopsRefuse('identity-file-unavailable', 'the explicitly selected original identity must be a regular non-symlink file');
172
- }
173
- catch {
174
- return sopsRefuse('identity-file-unavailable', 'the explicitly selected original identity file is unavailable');
175
- }
176
- return { mode: 'file', env: { ...env, SOPS_AGE_KEY_FILE: file }, error: null };
177
- };
178
- /** Select a supplied age identity without inventing custody or running a key tool. Inline execution awaits its owned isolation capability. */
179
- export function sopsIdentityEnv(env, { identity = null, required = false, platform = process.platform } = {}) {
180
- if (!env || typeof env !== 'object' || Array.isArray(env))
181
- return sopsRefuse('invalid-environment', 'an environment mapping is required');
182
- const names = (name) => Object.keys(env).filter(key => platform === 'win32' ? key.toUpperCase() === name : key === name);
183
- const inline = names('SOPS_AGE_KEY'), files = names('SOPS_AGE_KEY_FILE');
184
- if (inline.length > 1 || files.length > 1)
185
- return sopsRefuse('ambiguous-environment', 'multiple Windows aliases select an age identity');
186
- if (inline.length)
187
- return sopsInlineIdentity(env, inline[0]);
188
- let file = identity;
189
- if (files.length) {
190
- const value = env[files[0]];
191
- if (!credentialPresent(value))
192
- return sopsRefuse('disabled-file', 'SOPS_AGE_KEY_FILE is explicitly empty or invalid');
193
- if (identity !== null && identity !== undefined && identity !== value)
194
- return sopsRefuse('conflicting-files', 'two different original identity files were explicitly selected');
195
- file = value;
196
- }
197
- if (file !== null && file !== undefined)
198
- return sopsFileIdentity(env, file);
199
- if (required)
200
- return sopsRefuse('identity-not-supplied', 'supply SOPS_AGE_KEY locally or select the original SOPS_AGE_KEY_FILE; no home default was inferred');
201
- return { mode: 'public-recipient', env: { ...env }, error: null };
202
- }
@@ -1,24 +0,0 @@
1
- import { isPlainObject as plain } from './plain-object.mjs';
2
- import { invalid } from './invalid-config.mjs';
3
- /** The keys of the sonar block. */
4
- const SONAR_KEYS = Object.freeze(['organization']);
5
- /** A SonarCloud organization key: lowercase letters, digits, hyphens and underscores, starting with a letter or a digit. */
6
- const ORGANIZATION = /^[a-z0-9][a-z0-9_-]*$/;
7
- /**
8
- * config.yaml `sonar` - {organization?}: the key of the SonarCloud organization the release's Sonar proof of the example apps analyses in
9
- * (the project key is <organization>_<key the example declares>). It is configuration, not a secret; the environment variable
10
- * SONAR_ORGANIZATION wins over it, the repository variable of the same name is what CI reads. Null or absent means "not set yet".
11
- */
12
- export function validateSonar(sonar) {
13
- if (sonar === null)
14
- return;
15
- const bad = invalid('sonar');
16
- if (!plain(sonar))
17
- return bad(' must be {organization?: <SonarCloud organization key>} or null.');
18
- for (const key of Object.keys(sonar))
19
- if (!SONAR_KEYS.includes(key))
20
- bad(` has unknown key ${key} (allowed: ${SONAR_KEYS.join(', ')}).`);
21
- const value = sonar.organization;
22
- if (value !== undefined && value !== null && !(typeof value === 'string' && ORGANIZATION.test(value)))
23
- bad('.organization must be a SonarCloud organization key (lowercase letters, digits, - and _) or null.');
24
- }
@@ -1,26 +0,0 @@
1
- // temp-root.mjs — the one owner of where the runtime puts its temporary files.
2
- //
3
- // Every temp directory or file the runtime creates (spec fixtures, land scratch, gate staging, dispatch prompts, scan work
4
- // dirs) lives under tempRoot(): env STARCI_TEMP_ROOT (a spec, a one-off run), then the owner config `roots.temp`
5
- // (config.yaml, gitignored), else the OS temp directory of the process (TEMP / TMP / TMPDIR, then os.tmpdir()). The base tier
6
- // only resolves; the directory is made by scripts/api/fs/make-temp-dir.mjs, temp-path.mjs and ensure-temp-root.mjs. The
7
- // children the runtime starts get the same directory as TEMP / TMP / TMPDIR (tempChildEnv, applied by withTempEnv in every scripts/api/ spawn wrapper).
8
- import os from 'node:os';
9
- import path from 'node:path';
10
- import { loadConfig } from './config.mjs';
11
- export const TEMP_ROOT_ENV = 'STARCI_TEMP_ROOT';
12
- /** The owner's `roots.temp` (config.yaml, validated by engine/invalid-config.mjs), or null. `config` is the owner config (default: loadConfig(), whose error for an invalid config.yaml propagates: the OS directory never replaces a root the owner set wrongly). */
13
- const ownerTemp = (config) => (config === undefined ? loadConfig() : config)?.roots?.temp ?? null;
14
- /** The operating-system temp directory of `env`: TEMP, TMP, TMPDIR, else os.tmpdir(). */
15
- export const osTempDir = (env = process.env) => path.resolve(String(env?.TEMP || env?.TMP || env?.TMPDIR || os.tmpdir()));
16
- /** The one temp root: env STARCI_TEMP_ROOT, then the owner config `roots.temp`, else the OS temp directory. Resolved, not created. */
17
- export function tempRoot({ env = process.env, config = undefined } = {}) {
18
- return path.resolve(String(env?.[TEMP_ROOT_ENV] || ownerTemp(config) || osTempDir(env)));
19
- }
20
- /** `env` (default: the process environment) as a copy whose TEMP, TMP and TMPDIR name the temp root. */
21
- export function tempChildEnv(env = process.env) {
22
- const root = tempRoot({ env });
23
- return { ...env, TEMP: root, TMP: root, TMPDIR: root };
24
- }
25
- /** The spawn options with `env` replaced by tempChildEnv of the options' own env (default: the process environment). */
26
- export const withTempEnv = (options = {}) => ({ ...options, env: tempChildEnv(options.env ?? process.env) });