@starci/eslint-grammar-offset-pop 0.22.0 → 0.24.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.
- package/CHANGELOG.md +12 -0
- package/package.json +6 -5
- package/runtime/bundle.json +2 -51
- package/runtime/engine/by-code-unit.mjs +0 -12
- package/runtime/engine/config.mjs +0 -461
- package/runtime/engine/invalid-config.mjs +0 -15
- package/runtime/engine/model-config.mjs +0 -112
- package/runtime/engine/orca-config.mjs +0 -34
- package/runtime/engine/plain-object.mjs +0 -5
- package/runtime/engine/release-config.mjs +0 -32
- package/runtime/engine/removed-vocabulary.mjs +0 -27
- package/runtime/engine/resources-config.mjs +0 -59
- package/runtime/engine/runtime-root.mjs +0 -138
- package/runtime/engine/secrets.mjs +0 -202
- package/runtime/engine/sonar-config.mjs +0 -24
- package/runtime/engine/yaml.mjs +0 -161
- package/runtime/knowledge/hfs/canon-pins.yaml +0 -720
- package/runtime/knowledge/hfs/slots.yaml +0 -2783
- package/runtime/modules/kernel/removed-vocabulary.yaml +0 -458
- package/runtime/modules/models/registry.yaml +0 -221
- package/runtime/modules/models/runtimes.yaml +0 -556
- package/runtime/modules/models/tiers.yaml +0 -66
- package/runtime/scripts/hfs/allows.mjs +0 -77
- package/runtime/scripts/hfs/architecture/root-packages.mjs +0 -78
- package/runtime/scripts/hfs/declaration-shape.mjs +0 -196
- package/runtime/scripts/hfs/declaration-slots.mjs +0 -89
- package/runtime/scripts/hfs/edition-slots.mjs +0 -80
- package/runtime/scripts/hfs/manifest-shape.mjs +0 -474
- package/runtime/scripts/hfs/param-names.mjs +0 -13
- package/runtime/scripts/hfs/rule-catalog.mjs +0 -458
- package/runtime/scripts/hfs/rule-params-shape.mjs +0 -103
- package/runtime/scripts/hfs/slot-app-view.mjs +0 -97
- package/runtime/scripts/hfs/slot-classify.mjs +0 -69
- package/runtime/scripts/hfs/slot-errors.mjs +0 -12
- package/runtime/scripts/hfs/slot-imports.mjs +0 -98
- package/runtime/scripts/hfs/slot-manifest-shape.mjs +0 -111
- package/runtime/scripts/hfs/slot-match.mjs +0 -164
- package/runtime/scripts/hfs/slot-path.mjs +0 -6
- package/runtime/scripts/hfs/slot-required.mjs +0 -95
- package/runtime/scripts/hfs/slot-semantic-problems.mjs +0 -175
- package/runtime/scripts/hfs/slot-side-problems.mjs +0 -32
- package/runtime/scripts/hfs/slots.mjs +0 -306
- package/runtime/scripts/hfs/view.mjs +0 -180
- package/runtime/scripts/lib/glob.mjs +0 -32
- package/runtime/scripts/lib/i18n.mjs +0 -82
- package/runtime/scripts/lib/json-clone.mjs +0 -70
- package/runtime/scripts/lib/list.mjs +0 -26
- package/runtime/scripts/lib/path-key.mjs +0 -124
- package/runtime/scripts/lib/regex.mjs +0 -3
- package/runtime/scripts/lib/yaml-cached.mjs +0 -14
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
-
import { parseYaml } from './yaml.mjs';
|
|
4
|
-
import { isPlainObject as plain } from './plain-object.mjs';
|
|
5
|
-
import { invalid } from './invalid-config.mjs';
|
|
6
|
-
import { byCodeUnit } from './by-code-unit.mjs';
|
|
7
|
-
import { removedOfKind } from './removed-vocabulary.mjs';
|
|
8
|
-
/** The effort vocabulary, ordered weakest to strongest — the only list of it. */
|
|
9
|
-
export const EFFORT_LEVELS = new Set(['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'ultra']);
|
|
10
|
-
const DIFFICULTIES = ['easy', 'medium', 'hard', 'insane'];
|
|
11
|
-
export const MODELS_KEYS = ['tiers', 'seats', 'balance', 'usage'];
|
|
12
|
-
const known = (names) => [...names].sort(byCodeUnit).join(', ');
|
|
13
|
-
const hasPath = (root, dotted) => dotted.split('.').reduce((node, key) => (plain(node) && Object.hasOwn(node, key) ? node[key] : undefined), root) !== undefined;
|
|
14
|
-
/** Refuse an old-shape config (the removed keys of modules/kernel/removed-vocabulary.yaml), naming every removed key and where its meaning lives now. */
|
|
15
|
-
export function refuseRemovedKeys(config) {
|
|
16
|
-
const found = removedOfKind('config-key').filter(({ name }) => hasPath(config, name));
|
|
17
|
-
if (!found.length)
|
|
18
|
-
return;
|
|
19
|
-
const removed = found.map(({ name, use }) => `${name} is removed (${use})`).join('; ');
|
|
20
|
-
throw new Error(`Invalid config.yaml: ${removed}.`);
|
|
21
|
-
}
|
|
22
|
-
let shippedCache = null;
|
|
23
|
-
/** modules/models/tiers.yaml as shipped, parsed once per file version. */
|
|
24
|
-
export function shippedTiers() {
|
|
25
|
-
const file = fileURLToPath(new URL('../modules/models/tiers.yaml', import.meta.url));
|
|
26
|
-
let stat;
|
|
27
|
-
try {
|
|
28
|
-
stat = fs.statSync(file);
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
31
|
-
throw new Error('Missing modules/models/tiers.yaml');
|
|
32
|
-
}
|
|
33
|
-
const version = `${stat.mtimeMs}:${stat.size}`;
|
|
34
|
-
if (shippedCache?.version !== version)
|
|
35
|
-
shippedCache = { version, doc: parseYaml(fs.readFileSync(file, 'utf8')) };
|
|
36
|
-
return structuredClone(shippedCache.doc);
|
|
37
|
-
}
|
|
38
|
-
function validateMember(bad, where, member, profile) {
|
|
39
|
-
if (!plain(member) || Object.keys(member).some(key => !['agent', 'model', 'effort'].includes(key)) || typeof member.agent !== 'string' || typeof member.model !== 'string')
|
|
40
|
-
return bad(`${where} must be {agent, model, effort?}.`);
|
|
41
|
-
if (profile.models?.[member.model]?.provider !== member.agent)
|
|
42
|
-
bad(`${where}: model ${member.model} is not declared by agent ${member.agent} in modules/models/registry.yaml models.`);
|
|
43
|
-
if (member.effort !== undefined && !(typeof member.effort === 'string' && EFFORT_LEVELS.has(member.effort)))
|
|
44
|
-
bad(`${where}.effort must use the effort vocabulary.`);
|
|
45
|
-
}
|
|
46
|
-
function validateChains(bad, tiers, profile) {
|
|
47
|
-
for (const [name, chain] of Object.entries(tiers)) {
|
|
48
|
-
if (!Array.isArray(chain) || !chain.length)
|
|
49
|
-
return bad(`.${name} must be a non-empty ordered list of {agent, model, effort?}.`);
|
|
50
|
-
chain.forEach((member, index) => validateMember(bad, `.${name}[${index}]`, member, profile));
|
|
51
|
-
// validateMember refused every member that is not a {agent, model, effort?} record above.
|
|
52
|
-
const members = chain;
|
|
53
|
-
if (new Set(members.map(member => `${member.agent}/${member.model}`)).size !== chain.length)
|
|
54
|
-
bad(`.${name} names each member once.`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/** A call tier is taken by a headless call only: no seat, difficulty, kind, order or caller reference may name it, and every call names one. */
|
|
58
|
-
function validateUse(bad, { doc, names, refs }) {
|
|
59
|
-
const callTiers = new Set(Object.entries(doc.tierUse).filter(([, use]) => use === 'call').map(([tier]) => tier));
|
|
60
|
-
for (const tier of Object.keys(doc.tierUse))
|
|
61
|
-
if (!names.has(tier))
|
|
62
|
-
bad(`: tierUse names tier ${tier} (known: ${known(names)}).`);
|
|
63
|
-
for (const [where, tier] of refs)
|
|
64
|
-
if (callTiers.has(tier))
|
|
65
|
-
bad(`: ${where} names tier ${tier}, a call tier (tierUse): a headless call is made on it, no seat or op is seated on it.`);
|
|
66
|
-
for (const [call, spec] of Object.entries(doc.calls))
|
|
67
|
-
if (!callTiers.has(spec.tier))
|
|
68
|
-
bad(`: calls.${call}.tier ${spec.tier} must be a tier whose tierUse is call.`);
|
|
69
|
-
}
|
|
70
|
-
/** The tier document the picker reads: the shipped tiers.yaml with config.yaml `models` laid over it. Validated. */
|
|
71
|
-
export function effectiveTiers(config, profile) {
|
|
72
|
-
const doc = shippedTiers(), models = plain(config?.models) ? config.models : {};
|
|
73
|
-
const bad = invalid('models');
|
|
74
|
-
const merged = { ...doc.tiers, ...models.tiers };
|
|
75
|
-
validateChains(bad, merged, profile);
|
|
76
|
-
// validateChains refused every chain that is not a non-empty list of {agent, model, effort?} members.
|
|
77
|
-
const tiers = merged;
|
|
78
|
-
const seats = { ...doc.seats, ...models.seats };
|
|
79
|
-
const balance = { ...doc.balance, ...models.balance };
|
|
80
|
-
const usage = { ...doc.usage, ...models.usage };
|
|
81
|
-
const names = new Set(Object.keys(tiers));
|
|
82
|
-
const refs = [...Object.entries(seats).map(([seat, tier]) => [`.seats.${seat}`, tier]), ...DIFFICULTIES.map(level => [`difficulty.${level}`, doc.difficulty[level]]),
|
|
83
|
-
...Object.entries(doc.kindTiers).map(([kind, tier]) => [`kindTiers.${kind}`, tier]), ...doc.tierOrder.map(tier => ['tierOrder', tier])];
|
|
84
|
-
for (const [where, tier] of refs)
|
|
85
|
-
if (!names.has(tier))
|
|
86
|
-
bad(`: ${where} names tier ${tier} (known: ${known(names)}).`);
|
|
87
|
-
validateUse(bad, { doc, names, refs });
|
|
88
|
-
if (!(Number.isInteger(balance.maxStreak) && balance.maxStreak >= 1))
|
|
89
|
-
bad('.balance.maxStreak must be an integer >= 1.');
|
|
90
|
-
if (!(typeof balance.maxSharePercent === 'number' && balance.maxSharePercent > 0 && balance.maxSharePercent <= 100))
|
|
91
|
-
bad('.balance.maxSharePercent must be a number in (0, 100].');
|
|
92
|
-
const { reservePercent, biasPercent, exhaustedPercent } = usage;
|
|
93
|
-
if (![reservePercent, biasPercent, exhaustedPercent].every(value => typeof value === 'number' && value >= 0 && value <= 100) || !(reservePercent <= biasPercent && biasPercent < exhaustedPercent))
|
|
94
|
-
bad('.usage must hold numbers with reservePercent <= biasPercent < exhaustedPercent, each within 0..100.');
|
|
95
|
-
return { ...doc, tiers, seats, balance, usage };
|
|
96
|
-
}
|
|
97
|
-
/** config.yaml `models` — {tiers?, seats?, balance?, usage?}; the shipped defaults make every key optional. */
|
|
98
|
-
export function validateModelsBlock(config, profile) {
|
|
99
|
-
refuseRemovedKeys(config);
|
|
100
|
-
const models = config?.models;
|
|
101
|
-
if (models === undefined || models === null)
|
|
102
|
-
return;
|
|
103
|
-
const bad = invalid('models');
|
|
104
|
-
if (!plain(models) || Object.keys(models).some(key => !MODELS_KEYS.includes(key)))
|
|
105
|
-
return bad(` must be {${MODELS_KEYS.map(key => key + '?').join(', ')}} or null (unknown keys are refused).`);
|
|
106
|
-
if (models.tiers !== undefined && !plain(models.tiers))
|
|
107
|
-
bad('.tiers must map tier names to ordered member lists.');
|
|
108
|
-
for (const key of ['seats', 'balance', 'usage'])
|
|
109
|
-
if (models[key] !== undefined && !plain(models[key]))
|
|
110
|
-
bad(`.${key} must be a mapping.`);
|
|
111
|
-
effectiveTiers(config, profile);
|
|
112
|
-
}
|
|
@@ -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
|
-
}
|