@starci/eslint-grammar-offset-pop 0.12.13 → 0.13.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 (43) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +4 -4
  3. package/config.mjs +2 -2
  4. package/index.d.ts +4 -4
  5. package/index.mjs +1 -1
  6. package/package.json +23 -15
  7. package/runtime/engine/by-code-unit.mjs +12 -0
  8. package/runtime/engine/config.mjs +461 -0
  9. package/runtime/engine/invalid-config.mjs +15 -0
  10. package/runtime/engine/model-config.mjs +90 -0
  11. package/runtime/engine/orca-config.mjs +29 -0
  12. package/runtime/engine/release-config.mjs +28 -0
  13. package/runtime/engine/removed-vocabulary.mjs +26 -0
  14. package/runtime/engine/resources-config.mjs +52 -0
  15. package/runtime/engine/secrets.mjs +134 -0
  16. package/runtime/engine/sonar-config.mjs +21 -0
  17. package/runtime/knowledge/hfs/canon-pins.yaml +19 -20
  18. package/runtime/modules/kernel/removed-vocabulary.yaml +458 -0
  19. package/runtime/modules/models/registry.yaml +221 -0
  20. package/runtime/modules/models/runtimes.yaml +556 -0
  21. package/runtime/modules/models/tiers.yaml +66 -0
  22. package/runtime/scripts/hfs/declaration-shape.mjs +157 -0
  23. package/runtime/scripts/hfs/declaration-slots.mjs +86 -0
  24. package/runtime/scripts/hfs/edition-slots.mjs +77 -0
  25. package/runtime/scripts/hfs/manifest-shape.mjs +435 -0
  26. package/runtime/scripts/hfs/param-names.mjs +18 -0
  27. package/runtime/scripts/hfs/rule-catalog.mjs +362 -0
  28. package/runtime/scripts/hfs/rule-params-shape.mjs +80 -0
  29. package/runtime/scripts/hfs/slot-app-view.mjs +102 -0
  30. package/runtime/scripts/hfs/slot-classify.mjs +65 -0
  31. package/runtime/scripts/hfs/slot-errors.mjs +11 -0
  32. package/runtime/scripts/hfs/slot-imports.mjs +91 -0
  33. package/runtime/scripts/hfs/slot-manifest-shape.mjs +73 -0
  34. package/runtime/scripts/hfs/slot-match.mjs +153 -0
  35. package/runtime/scripts/hfs/slot-path.mjs +8 -0
  36. package/runtime/scripts/hfs/slot-required.mjs +89 -0
  37. package/runtime/scripts/hfs/slot-semantic-problems.mjs +149 -0
  38. package/runtime/scripts/hfs/slot-side-problems.mjs +28 -0
  39. package/runtime/scripts/lib/i18n.mjs +85 -0
  40. package/runtime/scripts/lib/json-clone.mjs +61 -0
  41. package/runtime/scripts/lib/list.mjs +31 -0
  42. package/runtime/scripts/lib/regex.mjs +4 -0
  43. package/runtime/scripts/lib/yaml-cached.mjs +14 -0
@@ -0,0 +1,15 @@
1
+ import path from 'node:path';
2
+ import {isPlainObject as plain} from './plain-object.mjs';
3
+ /** The one `Invalid config.yaml:` raiser every section validator shares: bad('<rest>') throws it. */
4
+ export const invalid=section=>message=>{throw new Error(`Invalid config.yaml: ${section}${message}`);};
5
+
6
+ /** The host roots the owner may relocate (config.yaml `roots`): the archive root, the lanes root and the temp root. */
7
+ export const ROOT_KEYS=Object.freeze(['archive','lanes','temp']);
8
+ /** config.yaml `roots` - {archive?, lanes?, temp?}: absolute directories, or null; an absent key means <starciLocalRoot>/archive and the per-user lanes directory (scripts/machine/home.mjs lanesDefault). */
9
+ export function validateRoots(roots){
10
+ if(roots===null)return;
11
+ const bad=invalid('roots');
12
+ if(!plain(roots))bad(` must be {archive?: <absolute directory>, lanes?: <absolute directory>, temp?: <absolute directory>} or null.`);
13
+ for(const key of Object.keys(roots))if(!ROOT_KEYS.includes(key))bad(` has unknown key ${key} (allowed: ${ROOT_KEYS.join(', ')}).`);
14
+ for(const key of ROOT_KEYS)if(roots[key]!==undefined&&roots[key]!==null&&!(typeof roots[key]==='string'&&roots[key].trim()&&path.isAbsolute(roots[key])))bad(`.${key} must be an absolute directory path or null.`);
15
+ }
@@ -0,0 +1,90 @@
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
+
9
+ /** The effort vocabulary, ordered weakest to strongest — the only list of it. */
10
+ export const EFFORT_LEVELS=new Set(['none','minimal','low','medium','high','xhigh','max','ultra']);
11
+ const DIFFICULTIES=['easy','medium','hard','insane'];
12
+ export const MODELS_KEYS=['tiers','seats','balance','usage'];
13
+ const known=names=>[...names].sort(byCodeUnit).join(', ');
14
+
15
+ const hasPath=(root,dotted)=>dotted.split('.').reduce((node,key)=>(plain(node)&&Object.hasOwn(node,key)?node[key]:undefined),root)!==undefined;
16
+
17
+ /** Refuse an old-shape config (the removed keys of modules/kernel/removed-vocabulary.yaml), naming every removed key and where its meaning lives now. */
18
+ export function refuseRemovedKeys(config){
19
+ const found=removedOfKind('config-key').filter(({name})=>hasPath(config,name));
20
+ if(!found.length)return;
21
+ const removed=found.map(({name,use})=>`${name} is removed (${use})`).join('; ');
22
+ throw new Error(`Invalid config.yaml: ${removed}.`);
23
+ }
24
+
25
+ let shippedCache=null;
26
+ /** modules/models/tiers.yaml as shipped, parsed once per file version. */
27
+ export function shippedTiers(){
28
+ const file=fileURLToPath(new URL('../modules/models/tiers.yaml',import.meta.url));
29
+ let stat;try{stat=fs.statSync(file);}catch{throw new Error('Missing modules/models/tiers.yaml');}
30
+ const version=`${stat.mtimeMs}:${stat.size}`;
31
+ if(shippedCache?.version!==version)shippedCache={version,doc:parseYaml(fs.readFileSync(file,'utf8'))};
32
+ return structuredClone(shippedCache.doc);
33
+ }
34
+
35
+ function validateMember(bad,where,member,profile){
36
+ if(!plain(member)||Object.keys(member).some(key=>!['agent','model','effort'].includes(key))||typeof member.agent!=='string'||typeof member.model!=='string')
37
+ bad(`${where} must be {agent, model, effort?}.`);
38
+ if(profile.models?.[member.model]?.provider!==member.agent)bad(`${where}: model ${member.model} is not declared by agent ${member.agent} in modules/models/registry.yaml models.`);
39
+ if(member.effort!==undefined&&!EFFORT_LEVELS.has(member.effort))bad(`${where}.effort must use the effort vocabulary.`);
40
+ }
41
+
42
+ function validateChains(bad,tiers,profile){
43
+ for(const [name,chain] of Object.entries(tiers)){
44
+ if(!Array.isArray(chain)||!chain.length)bad(`.${name} must be a non-empty ordered list of {agent, model, effort?}.`);
45
+ chain.forEach((member,index)=>validateMember(bad,`.${name}[${index}]`,member,profile));
46
+ if(new Set(chain.map(member=>`${member.agent}/${member.model}`)).size!==chain.length)bad(`.${name} names each member once.`);
47
+ }
48
+ }
49
+
50
+ /** 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. */
51
+ function validateUse(bad,{doc,names,refs}){
52
+ const callTiers=new Set(Object.entries(doc.tierUse).filter(([,use])=>use==='call').map(([tier])=>tier));
53
+ for(const tier of Object.keys(doc.tierUse))if(!names.has(tier))bad(`: tierUse names tier ${tier} (known: ${known(names)}).`);
54
+ for(const [where,tier] of refs)if(callTiers.has(tier))bad(`: ${where} names tier ${tier}, a call tier (tierUse): a headless call is made on it, no seat or op is seated on it.`);
55
+ for(const [call,spec] of Object.entries(doc.calls))if(!callTiers.has(spec.tier))bad(`: calls.${call}.tier ${spec.tier} must be a tier whose tierUse is call.`);
56
+ }
57
+
58
+ /** The tier document the picker reads: the shipped tiers.yaml with config.yaml `models` laid over it. Validated. */
59
+ export function effectiveTiers(config,profile){
60
+ const doc=shippedTiers(),models=plain(config?.models)?config.models:{};
61
+ const bad=invalid('models');
62
+ const tiers={...doc.tiers,...models.tiers};
63
+ validateChains(bad,tiers,profile);
64
+ const seats={...doc.seats,...models.seats};
65
+ const balance={...doc.balance,...models.balance};
66
+ const usage={...doc.usage,...models.usage};
67
+ const names=new Set(Object.keys(tiers));
68
+ const refs=[...Object.entries(seats).map(([seat,tier])=>[`.seats.${seat}`,tier]),...DIFFICULTIES.map(level=>[`difficulty.${level}`,doc.difficulty[level]]),
69
+ ...Object.entries(doc.kindTiers).map(([kind,tier])=>[`kindTiers.${kind}`,tier]),...doc.tierOrder.map(tier=>['tierOrder',tier])];
70
+ for(const [where,tier] of refs)if(!names.has(tier))bad(`: ${where} names tier ${tier} (known: ${known(names)}).`);
71
+ validateUse(bad,{doc,names,refs});
72
+ if(!(Number.isInteger(balance.maxStreak)&&balance.maxStreak>=1))bad('.balance.maxStreak must be an integer >= 1.');
73
+ if(!(typeof balance.maxSharePercent==='number'&&balance.maxSharePercent>0&&balance.maxSharePercent<=100))bad('.balance.maxSharePercent must be a number in (0, 100].');
74
+ const {reservePercent,biasPercent,exhaustedPercent}=usage;
75
+ if(![reservePercent,biasPercent,exhaustedPercent].every(value=>typeof value==='number'&&value>=0&&value<=100)||!(reservePercent<=biasPercent&&biasPercent<exhaustedPercent))
76
+ bad('.usage must hold numbers with reservePercent <= biasPercent < exhaustedPercent, each within 0..100.');
77
+ return {...doc,tiers,seats,balance,usage};
78
+ }
79
+
80
+ /** config.yaml `models` — {tiers?, seats?, balance?, usage?}; the shipped defaults make every key optional. */
81
+ export function validateModelsBlock(config,profile){
82
+ refuseRemovedKeys(config);
83
+ const models=config?.models;
84
+ if(models===undefined||models===null)return;
85
+ const bad=invalid('models');
86
+ if(!plain(models)||Object.keys(models).some(key=>!MODELS_KEYS.includes(key)))bad(` must be {${MODELS_KEYS.map(key=>key+'?').join(', ')}} or null (unknown keys are refused).`);
87
+ if(models.tiers!==undefined&&!plain(models.tiers))bad('.tiers must map tier names to ordered member lists.');
88
+ for(const key of ['seats','balance','usage'])if(models[key]!==undefined&&!plain(models[key]))bad(`.${key} must be a mapping.`);
89
+ effectiveTiers(config,profile);
90
+ }
@@ -0,0 +1,29 @@
1
+ import {isPlainObject as plain} from './plain-object.mjs';
2
+ import {invalid} from './invalid-config.mjs';
3
+
4
+ /**
5
+ * config.yaml `orca` — the owner's Orca app settings the runtime must know. maxWorkerDepth is the deepest worker Orca
6
+ * lets start under the owner's chat (chat = depth 0, a Kernel or the [Supervisor] 1, an op or a [Worker] 2, the draw
7
+ * critic 3); a deeper worker-start is refused by Orca with nested_worker_depth_exceeded. Orca exposes no read of that
8
+ * setting, so it is declared here and MUST equal the Orca app setting: scripts/agent/lib.mjs spawnAgent refuses a launch
9
+ * deeper than it before worker-start (worker-depth-exceeded), and `start --check` with STARCI_ORCA_LIVE=1 compares it with
10
+ * a measured probe (scripts/agent/depth-probe.mjs).
11
+ */
12
+ export const ORCA_DEFAULTS=Object.freeze({maxWorkerDepth:4});
13
+ /** The keys of the orca block. */
14
+ export const ORCA_KEYS=Object.freeze(Object.keys(ORCA_DEFAULTS));
15
+ export const MAX_WORKER_DEPTH_CEILING=16;
16
+ export function validateOrca(orca){
17
+ if(orca===null)return;
18
+ const bad=invalid('orca');
19
+ if(!plain(orca))bad(' must be {maxWorkerDepth?} or null.');
20
+ for(const key of Object.keys(orca))if(!ORCA_KEYS.includes(key))bad(` has unknown key ${key} (allowed: ${ORCA_KEYS.join(', ')}).`);
21
+ const v=orca.maxWorkerDepth;
22
+ if(v!==undefined&&v!==null&&!(Number.isInteger(v)&&v>=1&&v<=MAX_WORKER_DEPTH_CEILING))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.`);
23
+ }
24
+ /** The owner's Orca settings: {maxWorkerDepth, source: 'orca'|'default'}. An absent or null block or key is the default. */
25
+ export function orcaSettings(config){
26
+ if(config?.orca!==undefined)validateOrca(config.orca);
27
+ const value=plain(config?.orca)?config.orca.maxWorkerDepth:null;
28
+ return Number.isInteger(value)?{maxWorkerDepth:value,source:'orca'}:{maxWorkerDepth:ORCA_DEFAULTS.maxWorkerDepth,source:'default'};
29
+ }
@@ -0,0 +1,28 @@
1
+ import {isPlainObject as plain} from './plain-object.mjs';
2
+ import {invalid} from './invalid-config.mjs';
3
+
4
+ /** The keys of the release block. */
5
+ export const RELEASE_KEYS=Object.freeze(['suite']);
6
+ /** 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). */
7
+ export const SUITE_MODES=Object.freeze(['local','ci']);
8
+ const RELEASE_DEFAULTS=Object.freeze({suite:'local'});
9
+
10
+ /**
11
+ * 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
12
+ * 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
13
+ * 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.
14
+ * `none` is refused: the suite does not vanish, it moves to CI, and the value says so.
15
+ */
16
+ export function validateRelease(release){
17
+ if(release===null)return;
18
+ const bad=invalid('release');
19
+ if(!plain(release))bad(` must be {suite?: ${SUITE_MODES.join(' | ')}} or null.`);
20
+ for(const key of Object.keys(release))if(!RELEASE_KEYS.includes(key))bad(` has unknown key ${key} (allowed: ${RELEASE_KEYS.join(', ')}).`);
21
+ const value=release.suite;
22
+ if(value===undefined||value===null)return;
23
+ if(value==='none')bad('.suite: "none" is not a mode: write "ci" (no local full suite, CI judges) or "local".');
24
+ if(!SUITE_MODES.includes(value))bad(`.suite must be ${SUITE_MODES.join(' or ')}, or null.`);
25
+ }
26
+
27
+ /** The suite mode a validated owner config names; an absent block or key is the shipped default. */
28
+ export const releaseSuiteMode=config=>config?.release?.suite??RELEASE_DEFAULTS.suite;
@@ -0,0 +1,26 @@
1
+ import fs from 'node:fs';
2
+ import {fileURLToPath} from 'node:url';
3
+ import {parseYaml} from './yaml.mjs';
4
+
5
+ const FILE=fileURLToPath(new URL('../modules/kernel/removed-vocabulary.yaml',import.meta.url));
6
+
7
+ let cache=null;
8
+ function loaded(){
9
+ let stat;try{stat=fs.statSync(FILE);}catch{throw new Error('Missing modules/kernel/removed-vocabulary.yaml');}
10
+ const version=`${stat.mtimeMs}:${stat.size}`;
11
+ if(cache?.version!==version)cache={version,doc:parseYaml(fs.readFileSync(FILE,'utf8'))};
12
+ return cache.doc;
13
+ }
14
+
15
+
16
+ /** modules/kernel/removed-vocabulary.yaml: the one list of spellings the runtime refuses, each with its replacement and the release that removed it. */
17
+ export const removedVocabulary=()=>loaded().removed;
18
+
19
+ /** The removed spellings of one kind. */
20
+ export const removedOfKind=kind=>removedVocabulary().filter(entry=>entry.kind===kind);
21
+
22
+ /** `<name> is removed (<replacement>)` for a removed spelling of the kind, or undefined when the name is not one. */
23
+ export function removedNotice(kind,name){
24
+ const entry=removedOfKind(kind).find(candidate=>candidate.name===name);
25
+ return entry?`${entry.name} is removed (${entry.use})`:undefined;
26
+ }
@@ -0,0 +1,52 @@
1
+ import {isPlainObject as plain} from './plain-object.mjs';
2
+ import {invalid} from './invalid-config.mjs';
3
+
4
+ /**
5
+ * config.yaml `resources` — the owner's host-capacity floors, which override the shipped numbers of
6
+ * modules/models/runtimes.yaml `allocation.resources`. minFreeDiskGb: the free space a drive holding the temp root or the
7
+ * repository must keep before `starci kernel dispatch --spawn` launches another worker. minFreeDiskPct: the same floor as a
8
+ * percentage of the drive's size; when both are set the larger requirement applies. minFreeRamPct: the free-RAM floor below
9
+ * which no new heavy op starts. A null or absent key leaves the shipped number.
10
+ */
11
+ const FLOOR_LIMITS=Object.freeze({minFreeDiskGb:Infinity,minFreeDiskPct:100,minFreeRamPct:100});
12
+ const inRange=(value,limit)=>typeof value==='number'&&Number.isFinite(value)&&value>0&&value<=limit;
13
+
14
+ /** The keys of the resources block. */
15
+ export const RESOURCE_KEYS=Object.freeze(Object.keys(FLOOR_LIMITS));
16
+
17
+ export function validateResources(resources){
18
+ if(resources===null)return;
19
+ const bad=invalid('resources');
20
+ const keys=RESOURCE_KEYS;
21
+ const shape=keys.map(key=>`${key}?`).join(', ');
22
+ if(!plain(resources))bad(` must be {${shape}} or null.`);
23
+ for(const key of Object.keys(resources))if(!keys.includes(key))bad(` has unknown key ${key} (allowed: ${keys.join(', ')}).`);
24
+ for(const key of keys){
25
+ const value=resources[key];
26
+ if(value!==undefined&&value!==null&&!inRange(value,FLOOR_LIMITS[key])){
27
+ const cap=FLOOR_LIMITS[key]===Infinity?'':` and at most ${FLOOR_LIMITS[key]}`;
28
+ bad(`.${key} must be a number above 0${cap}, or null.`);
29
+ }
30
+ }
31
+ }
32
+
33
+ const declared=(block,key,source)=>{
34
+ const value=block?.[key];
35
+ if(value===undefined||value===null)return null;
36
+ if(!inRange(value,FLOOR_LIMITS[key]))throw new Error(`${source}.${key} must be a number above 0 (at most ${FLOOR_LIMITS[key]})`);
37
+ return value;
38
+ };
39
+
40
+ /**
41
+ * The floors in force: the owner's `resources` (config.yaml) over the shipped `allocation.resources`.
42
+ * {minFreeDiskGb, minFreeDiskPct (null when unset), minFreeRamPct}. The shipped policy owns the default numbers: when it
43
+ * omits or misspells minFreeDiskGb or minFreeRamPct this refuses, there is no fallback constant.
44
+ */
45
+ export function hostFloors(shipped,owner=null){
46
+ const source='modules/models/runtimes.yaml allocation.resources';
47
+ const base={minFreeDiskGb:declared(shipped,'minFreeDiskGb',source),minFreeDiskPct:declared(shipped,'minFreeDiskPct',source),minFreeRamPct:declared(shipped,'minFreeRamPct',source)};
48
+ for(const key of ['minFreeDiskGb','minFreeRamPct'])if(base[key]===null)throw new Error(`${source}.${key} must declare a positive number`);
49
+ if(owner!==null&&owner!==undefined)validateResources(owner);
50
+ const pick=key=>declared(owner,key,'config.yaml resources')??base[key];
51
+ return {minFreeDiskGb:pick('minFreeDiskGb'),minFreeDiskPct:pick('minFreeDiskPct'),minFreeRamPct:pick('minFreeRamPct')};
52
+ }
@@ -0,0 +1,134 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+
4
+ /** The host-local credential filename, resolved only against a verified runtime main root. */
5
+ export const SECRET_ENV_FILE='secret.env';
6
+ /** The configured credential variable grammar shared by validation and secret resolution. */
7
+ export const ENV_NAME=/^[A-Z_][A-Z0-9_]{0,63}$/;
8
+ export const CREDENTIAL_FILE_MAX_BYTES=1024*1024;
9
+ const resolvedValues = new Set();
10
+ const remember = value => {
11
+ if (typeof value === 'string' && value.length >= 6) resolvedValues.add(value);
12
+ return value;
13
+ };
14
+
15
+ /** Filter credentials resolved by this process; the values never leave their resolution owner. */
16
+ export function redactResolvedSecrets(text) {
17
+ let clean = text;
18
+ for (const value of resolvedValues) if (clean.includes(value)) clean = clean.split(value).join('[redacted:resolved-secret]');
19
+ return clean;
20
+ }
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())return false;
25
+ return !/^(?:CHANGE_ME|REPLACE_ME|PLACEHOLDER|TODO|<[^>]*>|YOUR_[A-Z0-9_]+)$/i.test(value.trim());
26
+ }
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())throw new Error('credential file must be a regular file');
32
+ if(before.size>CREDENTIAL_FILE_MAX_BYTES)throw new Error('credential file exceeds the byte budget');
33
+ const fd=fs.openSync(file,fs.constants.O_RDONLY|(fs.constants.O_NOFOLLOW??0));
34
+ let bytes;
35
+ try{
36
+ const stat=fs.fstatSync(fd);
37
+ if(!stat.isFile()||stat.dev!==before.dev||stat.ino!==before.ino)throw new Error('credential file changed during resolution');
38
+ bytes=Buffer.alloc(CREDENTIAL_FILE_MAX_BYTES+1);
39
+ let count=0;
40
+ while(count<bytes.length){const n=fs.readSync(fd,bytes,count,bytes.length-count,null);if(n===0){break;}count+=n;}
41
+ if(count>CREDENTIAL_FILE_MAX_BYTES)throw new Error('credential file exceeds the byte budget');
42
+ return bytes.subarray(0,count);
43
+ }catch(error){bytes?.fill(0);throw error;}finally{fs.closeSync(fd);}
44
+ }
45
+
46
+ const readCredentialFile = file => { const bytes=readSecretBytes(file); try{return bytes.toString('utf8');}finally{bytes.fill(0);} };
47
+
48
+ 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*$`];
49
+ const DOTENV_LINE = new RegExp(DOTENV_LINE_PARTS.join(''));
50
+
51
+ /** Parse a dotenv file (KEY=VALUE lines, # comments, optional export/quotes). An absent file is {}. */
52
+ export function readDotenv(file){
53
+ let text='';try{text=readCredentialFile(file);}catch(error){if(error?.code==='ENOENT'){return {};}throw error;}
54
+ const out={};
55
+ for(const line of text.split(/\r?\n/)){
56
+ const m=DOTENV_LINE.exec(line);
57
+ if(!m)continue;
58
+ let value=m[2].trimEnd();
59
+ if(value.length>=2&&(value.startsWith('"')||value.startsWith("'"))&&value.at(-1)===value[0])value=value.slice(1,-1);
60
+ out[m[1]]=value;
61
+ }
62
+ return out;
63
+ }
64
+
65
+ /**
66
+ * Resolve a configured variable or its supported NAME_FILE custody pointer. An explicitly supplied
67
+ * blank variable disables the value; it must not resurrect a file value. Never print the result.
68
+ */
69
+ export function connectorSecret(name,env=process.env){
70
+ if(typeof name!=='string'||!ENV_NAME.test(name))return null;
71
+ if(Object.hasOwn(env,name))return typeof env[name]==='string'?remember(env[name].trim()||null):null;
72
+ const pointer=typeof env[`${name}_FILE`]==='string'?env[`${name}_FILE`].trim():'';
73
+ if(!pointer)return null;
74
+ try{const value=readCredentialFile(pointer).trim();return remember(value||null);}catch{return null;}
75
+ }
76
+
77
+ /**
78
+ * Load the verified runtime main's local credentials below the actual environment without mutating
79
+ * either input. The caller owns repository identity; this base-tier reader never infers a root from cwd.
80
+ * Absence is allowed so the action-specific gate can name only the credentials that action requires.
81
+ */
82
+ export function secretEnv(verifiedRuntimeRoot,env=process.env){
83
+ if(typeof verifiedRuntimeRoot!=='string'||!path.isAbsolute(verifiedRuntimeRoot))
84
+ throw new TypeError('secretEnv requires an absolute verified runtime root');
85
+ if(env===null||typeof env!=='object'||Array.isArray(env))throw new TypeError('secretEnv requires an environment mapping');
86
+ const root=fs.lstatSync(verifiedRuntimeRoot);
87
+ if(!root.isDirectory()||root.isSymbolicLink())throw new Error('secretEnv runtime root must be a regular directory');
88
+ const file=path.join(verifiedRuntimeRoot,SECRET_ENV_FILE);
89
+ let stat;
90
+ try{stat=fs.lstatSync(file);}catch(error){if(error?.code==='ENOENT'){return {...env};}throw error;}
91
+ if(!stat.isFile()||stat.isSymbolicLink())throw new Error('secret.env must be a regular file');
92
+ const local = readDotenv(file);
93
+ const resolved = {...local,...env};
94
+ for (const name of Object.keys(local)) if (typeof resolved[name] === 'string') remember(resolved[name]);
95
+ return resolved;
96
+ }
97
+
98
+ const sopsRefuse=(reason,message)=>{
99
+ const error=new Error(`SOPS identity [${reason}]: ${message}`);
100
+ error.name='SopsIdentityRefusal';error.identityRefusal=reason;
101
+ return {mode:'refused',env:null,error};
102
+ };
103
+ const sopsInlineIdentity=(env,name)=>{
104
+ if(!credentialPresent(env[name]))return sopsRefuse('disabled-inline','SOPS_AGE_KEY is explicitly empty or invalid');
105
+ remember(env[name].trim());
106
+ return {...sopsRefuse('inline-context-unqualified','the supplied SOPS_AGE_KEY awaits an owned selected-identity isolation capability; no SOPS process was launched'),inlineName:name};
107
+ };
108
+ const sopsFileIdentity=(env,file)=>{
109
+ if(!credentialPresent(file))return sopsRefuse('invalid-file','the original identity file selection is empty or invalid');
110
+ if(!path.isAbsolute(file))return sopsRefuse('identity-file-location-unqualified','select the original identity by its absolute path; caller and SOPS working directories may differ');
111
+ try{
112
+ const stat=fs.lstatSync(file);
113
+ if(!stat.isFile()||stat.isSymbolicLink())return sopsRefuse('identity-file-unavailable','the explicitly selected original identity must be a regular non-symlink file');
114
+ }catch{return sopsRefuse('identity-file-unavailable','the explicitly selected original identity file is unavailable');}
115
+ return {mode:'file',env:{...env,SOPS_AGE_KEY_FILE:file},error:null};
116
+ };
117
+ /** Select a supplied age identity without inventing custody or running a key tool. Inline execution awaits its owned isolation capability. */
118
+ export function sopsIdentityEnv(env,{identity=null,required=false,platform=process.platform}={}){
119
+ if(!env||typeof env!=='object'||Array.isArray(env))return sopsRefuse('invalid-environment','an environment mapping is required');
120
+ const names=name=>Object.keys(env).filter(key=>platform==='win32'?key.toUpperCase()===name:key===name);
121
+ const inline=names('SOPS_AGE_KEY'),files=names('SOPS_AGE_KEY_FILE');
122
+ if(inline.length>1||files.length>1)return sopsRefuse('ambiguous-environment','multiple Windows aliases select an age identity');
123
+ if(inline.length)return sopsInlineIdentity(env,inline[0]);
124
+ let file=identity;
125
+ if(files.length){
126
+ const value=env[files[0]];
127
+ if(!credentialPresent(value))return sopsRefuse('disabled-file','SOPS_AGE_KEY_FILE is explicitly empty or invalid');
128
+ if(identity!==null&&identity!==undefined&&identity!==value)return sopsRefuse('conflicting-files','two different original identity files were explicitly selected');
129
+ file=value;
130
+ }
131
+ if(file!==null&&file!==undefined)return sopsFileIdentity(env,file);
132
+ if(required)return sopsRefuse('identity-not-supplied','supply SOPS_AGE_KEY locally or select the original SOPS_AGE_KEY_FILE; no home default was inferred');
133
+ return {mode:'public-recipient',env:{...env},error:null};
134
+ }
@@ -0,0 +1,21 @@
1
+ import {isPlainObject as plain} from './plain-object.mjs';
2
+ import {invalid} from './invalid-config.mjs';
3
+
4
+ /** The keys of the sonar block. */
5
+ const SONAR_KEYS=Object.freeze(['organization']);
6
+ /** A SonarCloud organization key: lowercase letters, digits, hyphens and underscores, starting with a letter or a digit. */
7
+ const ORGANIZATION=/^[a-z0-9][a-z0-9_-]*$/;
8
+
9
+ /**
10
+ * config.yaml `sonar` - {organization?}: the key of the SonarCloud organization the release's Sonar proof of the example apps analyses in
11
+ * (the project key is <organization>_<key the example declares>). It is configuration, not a secret; the environment variable
12
+ * SONAR_ORGANIZATION wins over it, the repository variable of the same name is what CI reads. Null or absent means "not set yet".
13
+ */
14
+ export function validateSonar(sonar){
15
+ if(sonar===null)return;
16
+ const bad=invalid('sonar');
17
+ if(!plain(sonar))bad(' must be {organization?: <SonarCloud organization key>} or null.');
18
+ for(const key of Object.keys(sonar))if(!SONAR_KEYS.includes(key))bad(` has unknown key ${key} (allowed: ${SONAR_KEYS.join(', ')}).`);
19
+ const value=sonar.organization;
20
+ if(value!==undefined&&value!==null&&!(typeof value==='string'&&ORGANIZATION.test(value)))bad('.organization must be a SonarCloud organization key (lowercase letters, digits, - and _) or null.');
21
+ }
@@ -21,7 +21,7 @@ pins:
21
21
  install: registry
22
22
  side: fe
23
23
  source: packages/heroicons/package.json
24
- why: 'StarCi custom Heroicons-compatible cuts; eslint-grammar-starci (icon.mjs) admits @starci/heroicons/24/outline and /16/solid as icon sources, so an app that uses them gets this exact version.'
24
+ why: 'StarCi custom Heroicons-compatible cuts; eslint-grammar-core (icon.mjs) admits @starci/heroicons/24/outline and /16/solid as icon sources, so an app that uses them gets this exact version.'
25
25
  '@starci/event-stream':
26
26
  version: 0.1.0
27
27
  group: starci
@@ -30,61 +30,61 @@ pins:
30
30
  source: packages/event-stream/package.json
31
31
  why: 'the one server-sent-events client of every front end (fe-stack event-stream, owner:event-stream-package): the transport client layer (modules/api/sse/clients) creates one instance for the app with the bearer token source and the stream operations follow on it; it carries Last-Event-ID resume, the capped doubling backoff, the heartbeat timeout, the single 401 renewal and the useSWRSubscription adapter, so no app keeps a hand-written reader.'
32
32
  '@starci/grammar':
33
- version: 0.12.13
33
+ version: 0.13.0
34
34
  group: starci
35
35
  install: registry
36
36
  side: fe
37
37
  source: packages/grammar/package.json
38
38
  why: 'the grammar front ends read: the brand layer sets `--font-sans` and `--font-mono` and the grammar reads them; it carries the Input tel kind, the copyable and read-only Input, the IconButton disclosure props and count badge, ChatBubble, FillViewport, Textarea mentions and Enter-to-send, the leading PrimaryRailLayout rail, the plate-less Image, ListRow, the soft Alert, Progress steps, the floating primary IconButton, FlowGraph, the STATE-8 loading views and the bordered selectable TagGroup chips. The runtime source version wins for a @starci package.'
39
39
  '@starci/eslint-canon-be':
40
- version: 3.4.55
40
+ version: 3.4.57
41
41
  group: starci
42
42
  install: registry
43
43
  side: be
44
- source: packages/eslint/be/package.json
44
+ source: packages/eslint-canon-be/package.json
45
45
  why: 'the back-end ESLint canon: `loadHfs(import.meta.url)` of be/eslint.config.mjs finds the app-root hfs.json (kind app) and gives every linted file the view of the be side, and the project graph is built per side; its bundled runtime copies (slots, canon-pins, failure codes, the architecture machine) put .starcistacks and .sops.yaml at the app root; `starciBeConfig({ hfs: loadHfs(import.meta.url) })` is the typed factory and the BE-CONVENTION laws are its rules.'
46
46
  '@starci/eslint-canon-fe':
47
- version: 9.1.9
47
+ version: 9.2.0
48
48
  group: starci
49
49
  install: registry
50
50
  side: fe
51
- source: packages/eslint/fe/package.json
51
+ source: packages/eslint-canon-fe/package.json
52
52
  why: 'the front-end ESLint canon: `loadHfs(import.meta.url)` of fe/eslint.config.mjs finds the app-root hfs.json (kind app) and gives every linted file the view of the fe side, and the project graph is built per side; its bundled runtime copies (slots, canon-pins, failure codes, the architecture machine) put .starcistacks and .sops.yaml at the app root; the front end has no tests (FE_NO_TESTS R97 in hfs) and no-vietnamese-in-source (R91) applies.'
53
- '@starci/eslint-grammar-starci':
54
- version: 0.12.13
53
+ '@starci/eslint-grammar-core':
54
+ version: 0.13.0
55
55
  group: starci
56
56
  install: registry
57
57
  side: fe
58
- source: packages/eslint/grammar-starci/package.json
58
+ source: packages/eslint-grammar-core/package.json
59
59
  why: 'the StarCi Grammar component API lint, versioned with @starci/grammar; front ends compose this family package with the universal FE canon.'
60
60
  '@starci/eslint-grammar-offset-pop':
61
- version: 0.12.13
61
+ version: 0.13.0
62
62
  group: starci
63
63
  install: registry
64
64
  side: fe
65
- source: packages/eslint/grammar-offset-pop/package.json
65
+ source: packages/eslint-grammar-offset-pop/package.json
66
66
  why: 'the Offset Pop Grammar component API lint, versioned with @starci/grammar; its shared component contract comes from the StarCi family lint without copying rules.'
67
67
  '@starci/stylelint-canon':
68
- version: 2.0.13
68
+ version: 2.1.0
69
69
  group: starci
70
70
  install: registry
71
71
  side: fe
72
- source: packages/stylelint/package.json
72
+ source: packages/stylelint-canon/package.json
73
73
  why: 'the front-end stylelint canon: no-class-selector refuses a compound class selector (`div.card`); the brand layer accepts `--font-sans` and `--font-mono`; status-contrast measures the HeroUI soft pairs per theme; brand-layer-shape reads the shared :root,.light,.dark block and the info soft pair; appTokens come from loadAppTokens(import.meta.url) for the managed one-line stylelint.config.mjs.'
74
74
  '@starci/tsconfig':
75
- version: 2.0.7
75
+ version: 2.0.8
76
76
  group: starci
77
77
  install: registry
78
78
  side: both
79
79
  source: packages/tsconfig/package.json
80
80
  '@starci/prettier-config':
81
- version: 1.0.4
81
+ version: 1.0.5
82
82
  group: starci
83
83
  install: registry
84
84
  side: both
85
85
  source: packages/prettier-config/package.json
86
86
  '@starci/jest-preset':
87
- version: 2.3.6
87
+ version: 2.3.7
88
88
  group: starci
89
89
  install: registry
90
90
  side: be
@@ -98,14 +98,13 @@ pins:
98
98
  source: packages/test-world/package.json
99
99
  why: 'the shared e2e library of every back end (R47, R48), a devDependency of every back end: the warm stack behind toxiproxy, the network-edge fakes, the Nest boot, the typed useTestWorld handle, useSandbox for contract specs and the outage lock. Kafka is real own infra (the one digest-pinned apache/kafka KRaft image, a broker listener and proxy per slot, slot-prefixed topics, consumer groups and client ids) and Postgres is schema-per-context (a schema and a login role per context in a shared database). Each worker has its own data slot (<ns>_w<k>) with its own databases, Keycloak realm, leased Redis DB, bucket/collection/topic prefixes, fakes host, toxiproxy proxies and outage lock; a run provisions min(jest workers, workers cap, default 2) slots, and state file protocol 2 pairs exactly with @starci/jest-preset (TEST_WORLD_PAIR_MISMATCH otherwise). A modules world boots real peer apps beside its modules, world.apps.<name>.during(fn) is the outage of a peer app, w.keycloak.clientSecret(client) answers the run-generated secret of a confidential realm client, world.keycloak.events/sessions read the realm user events and live sessions, world.infra.postgresql.connection(name) takes one database connection down while the others serve, and world.resolve and scope.resolve take any Nest token. Every path a declaration names (`stack`, seeds, the realm, Dockerfiles) resolves from the app root (the directory of hfs.json); the globalSetup registers the path aliases as TypeScript resolves them. Its CLI main is exported at ./cli for starci app stack.'
100
100
  '@starci/cli':
101
- version: 1.7.46
101
+ version: 1.7.47
102
102
  group: starci
103
103
  install: registry
104
104
  side: both
105
- source: packages/cli/package.json
106
105
  why: 'the only StarCi command package; product repositories install it for starci app, while @starci/hfs remains its pinned transitive implementation.'
107
106
  '@starci/hfs':
108
- version: 4.7.46
107
+ version: 4.8.0
109
108
  group: starci
110
109
  install: registry
111
110
  side: both
@@ -406,7 +405,7 @@ pins:
406
405
  version: 2.2.0
407
406
  group: ui
408
407
  side: fe
409
- why: 'the base of the one application icon set (fe-stack icons, with @starci/heroicons for the glyphs it lacks); eslint-grammar-starci (icon.mjs) admits @heroicons/react/24/outline and /16/solid.'
408
+ why: 'the base of the one application icon set (fe-stack icons, with @starci/heroicons for the glyphs it lacks); eslint-grammar-core (icon.mjs) admits @heroicons/react/24/outline and /16/solid.'
410
409
  '@dicebear/core':
411
410
  version: 10.4.0
412
411
  group: ui