@starci/hfs 4.0.10 → 4.2.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 +5 -1
- package/emit/operations.mjs +1 -1
- package/emit/type-schema.mjs +2 -1
- package/lint/run.mjs +65 -24
- package/package.json +1 -1
- package/report/order.mjs +2 -0
- package/runtime/config.example.yaml +194 -0
- package/runtime/engine/by-code-unit.mjs +12 -0
- package/runtime/engine/config.mjs +222 -239
- package/runtime/engine/invalid-config.mjs +5 -5
- package/runtime/engine/model-config.mjs +90 -0
- package/runtime/engine/orca-config.mjs +3 -1
- package/runtime/engine/release-config.mjs +28 -0
- package/runtime/engine/removed-vocabulary.mjs +28 -0
- package/runtime/engine/resources-config.mjs +52 -0
- package/runtime/engine/runtime-root.mjs +17 -0
- package/runtime/engine/secrets.mjs +35 -31
- package/runtime/engine/sonar-config.mjs +21 -0
- package/runtime/engine/temp-root.mjs +32 -0
- package/runtime/knowledge/hfs/canon-pins.yaml +14 -14
- package/runtime/knowledge/hfs/peer-integrations.yaml +2 -3
- package/runtime/knowledge/hfs/rules.yaml +161 -65
- package/runtime/knowledge/hfs/slots.yaml +11 -14
- package/runtime/knowledge/patterns/be/api.yaml +7 -24
- package/runtime/knowledge/patterns/be/cli.yaml +3 -12
- package/runtime/knowledge/patterns/be/realtime.yaml +1 -14
- package/runtime/knowledge/patterns/be/webhooks.yaml +0 -19
- package/runtime/modules/kernel/failure-codes.yaml +1 -41
- package/runtime/modules/kernel/removed-vocabulary.yaml +268 -0
- package/runtime/modules/models/registry.yaml +25 -359
- package/runtime/modules/models/runtimes.yaml +126 -265
- package/runtime/modules/models/tiers.yaml +66 -0
- package/runtime/scripts/api/fs/claim-file.mjs +30 -0
- package/runtime/scripts/api/fs/ensure-temp-root.mjs +27 -0
- package/runtime/scripts/api/fs/forbidden-root.mjs +2 -1
- package/runtime/scripts/api/fs/make-temp-dir.mjs +11 -0
- package/runtime/scripts/api/fs/safe-remove.mjs +52 -35
- package/runtime/scripts/api/git/lib.mjs +34 -1
- package/runtime/scripts/api/process/resolve-real-tool.mjs +14 -8
- package/runtime/scripts/api/process/run-program.mjs +2 -1
- package/runtime/scripts/api/sops/lib.mjs +198 -120
- package/runtime/scripts/hfs/allows.mjs +3 -3
- package/runtime/scripts/hfs/architecture/ast-walks.mjs +63 -50
- package/runtime/scripts/hfs/architecture/automatic-gates.mjs +96 -0
- package/runtime/scripts/hfs/architecture/backend.mjs +261 -175
- package/runtime/scripts/hfs/architecture/background-unowned.mjs +69 -34
- package/runtime/scripts/hfs/architecture/client-reaches-server.mjs +55 -54
- package/runtime/scripts/hfs/architecture/clones.mjs +179 -106
- package/runtime/scripts/hfs/architecture/config-unread.mjs +5 -22
- package/runtime/scripts/hfs/architecture/config.mjs +95 -80
- package/runtime/scripts/hfs/architecture/connection-map.mjs +233 -141
- package/runtime/scripts/hfs/architecture/constructor-deps.mjs +15 -9
- package/runtime/scripts/hfs/architecture/context-coupling.mjs +76 -52
- package/runtime/scripts/hfs/architecture/context-map.mjs +215 -141
- package/runtime/scripts/hfs/architecture/context-owner.mjs +39 -30
- package/runtime/scripts/hfs/architecture/context-platform-tables.mjs +31 -17
- package/runtime/scripts/hfs/architecture/context-transaction.mjs +38 -25
- package/runtime/scripts/hfs/architecture/contract-fixture-guard.mjs +86 -40
- package/runtime/scripts/hfs/architecture/contracts-readonly.mjs +342 -0
- package/runtime/scripts/hfs/architecture/contracts.mjs +263 -455
- package/runtime/scripts/hfs/architecture/cross-app-duplicate.mjs +43 -34
- package/runtime/scripts/hfs/architecture/dead-exports.mjs +201 -154
- package/runtime/scripts/hfs/architecture/default-deny.mjs +118 -93
- package/runtime/scripts/hfs/architecture/doc-language.mjs +2 -1
- package/runtime/scripts/hfs/architecture/entrypoint.mjs +45 -30
- package/runtime/scripts/hfs/architecture/error-codes.mjs +19 -12
- package/runtime/scripts/hfs/architecture/error-masked.mjs +39 -26
- package/runtime/scripts/hfs/architecture/fe-slot-allows.mjs +2 -1
- package/runtime/scripts/hfs/architecture/feature-shape.mjs +26 -20
- package/runtime/scripts/hfs/architecture/framework-pinned.mjs +1 -1
- package/runtime/scripts/hfs/architecture/frontend-grammar.mjs +190 -0
- package/runtime/scripts/hfs/architecture/frontend-routing.mjs +186 -0
- package/runtime/scripts/hfs/architecture/frontend-world-render.mjs +311 -0
- package/runtime/scripts/hfs/architecture/frontend-world.mjs +328 -0
- package/runtime/scripts/hfs/architecture/frontend.mjs +109 -829
- package/runtime/scripts/hfs/architecture/hfs-graph.mjs +14 -2
- package/runtime/scripts/hfs/architecture/hfs.mjs +120 -288
- package/runtime/scripts/hfs/architecture/hooks-are-hooks.mjs +46 -26
- package/runtime/scripts/hfs/architecture/i18n-keys.mjs +114 -76
- package/runtime/scripts/hfs/architecture/index.mjs +164 -104
- package/runtime/scripts/hfs/architecture/injection-token-exported.mjs +33 -28
- package/runtime/scripts/hfs/architecture/machine-ast.mjs +180 -144
- package/runtime/scripts/hfs/architecture/managed-scripts.mjs +8 -2
- package/runtime/scripts/hfs/architecture/module-per-transport.mjs +150 -101
- package/runtime/scripts/hfs/architecture/next-data-contract.mjs +51 -43
- package/runtime/scripts/hfs/architecture/next-data-key.mjs +338 -0
- package/runtime/scripts/hfs/architecture/next-data.mjs +179 -427
- package/runtime/scripts/hfs/architecture/owners.mjs +27 -13
- package/runtime/scripts/hfs/architecture/package-shape.mjs +51 -23
- package/runtime/scripts/hfs/architecture/presentation.mjs +165 -0
- package/runtime/scripts/hfs/architecture/reachability.mjs +127 -61
- package/runtime/scripts/hfs/architecture/register-once.mjs +112 -63
- package/runtime/scripts/hfs/architecture/registration.mjs +187 -110
- package/runtime/scripts/hfs/architecture/required-files.mjs +121 -70
- package/runtime/scripts/hfs/architecture/route-files-thin.mjs +83 -58
- package/runtime/scripts/hfs/architecture/schema-owner.mjs +182 -108
- package/runtime/scripts/hfs/architecture/source-names-shape.mjs +318 -0
- package/runtime/scripts/hfs/architecture/source-names.mjs +83 -248
- package/runtime/scripts/hfs/architecture/sql-owner.mjs +175 -118
- package/runtime/scripts/hfs/architecture/sql-returning.mjs +39 -28
- package/runtime/scripts/hfs/architecture/sql-tokens.mjs +302 -172
- package/runtime/scripts/hfs/architecture/supabase-ast.mjs +1 -1
- package/runtime/scripts/hfs/architecture/supabase-be.mjs +55 -45
- package/runtime/scripts/hfs/architecture/supabase-results.mjs +182 -0
- package/runtime/scripts/hfs/architecture/supabase-tables.mjs +20 -12
- package/runtime/scripts/hfs/architecture/supabase.mjs +191 -263
- package/runtime/scripts/hfs/architecture/symbols.mjs +175 -99
- package/runtime/scripts/hfs/architecture/test-world-files.mjs +82 -41
- package/runtime/scripts/hfs/architecture/tiers.mjs +120 -69
- package/runtime/scripts/hfs/architecture/transport-owner.mjs +84 -57
- package/runtime/scripts/hfs/architecture/type-context.mjs +282 -0
- package/runtime/scripts/hfs/architecture/typescript.mjs +116 -276
- package/runtime/scripts/hfs/architecture/unit-spec-providers.mjs +84 -62
- package/runtime/scripts/hfs/architecture.mjs +3 -4
- package/runtime/scripts/hfs/catalog-once.mjs +15 -0
- package/runtime/scripts/hfs/check.mjs +63 -71
- package/runtime/scripts/hfs/coverage-scope.mjs +84 -38
- package/runtime/scripts/hfs/declaration-shape.mjs +77 -36
- package/runtime/scripts/hfs/declaration-slots.mjs +1 -1
- package/runtime/scripts/hfs/edition-slots.mjs +5 -3
- package/runtime/scripts/hfs/linear-text.mjs +30 -0
- package/runtime/scripts/hfs/manifest-shape.mjs +164 -63
- package/runtime/scripts/hfs/path-findings.mjs +58 -38
- package/runtime/scripts/hfs/pin-findings.mjs +31 -0
- package/runtime/scripts/hfs/repo-identity.mjs +21 -4
- package/runtime/scripts/hfs/rule-catalog.mjs +194 -0
- package/runtime/scripts/hfs/rule-params-shape.mjs +33 -27
- package/runtime/scripts/hfs/rules/cli.mjs +5 -1
- package/runtime/scripts/hfs/rules/contract-compat.mjs +40 -22
- package/runtime/scripts/hfs/rules/contract.mjs +35 -27
- package/runtime/scripts/hfs/rules/database-config.mjs +57 -32
- package/runtime/scripts/hfs/rules/database-migrations.mjs +52 -31
- package/runtime/scripts/hfs/rules/database-plpgsql.mjs +106 -91
- package/runtime/scripts/hfs/rules/database-sql.mjs +254 -173
- package/runtime/scripts/hfs/rules/database.mjs +36 -23
- package/runtime/scripts/hfs/rules/deps.mjs +64 -32
- package/runtime/scripts/hfs/rules/docker.mjs +113 -65
- package/runtime/scripts/hfs/rules/edition.mjs +118 -111
- package/runtime/scripts/hfs/rules/event-bus.mjs +91 -45
- package/runtime/scripts/hfs/rules/fe-contract-documents.mjs +17 -16
- package/runtime/scripts/hfs/rules/fe-no-tests.mjs +36 -16
- package/runtime/scripts/hfs/rules/frontend-tree.mjs +4 -3
- package/runtime/scripts/hfs/rules/integration-specs.mjs +75 -41
- package/runtime/scripts/hfs/rules/kinds.mjs +59 -25
- package/runtime/scripts/hfs/rules/lint-suppression.mjs +9 -3
- package/runtime/scripts/hfs/rules/monorepo.mjs +82 -45
- package/runtime/scripts/hfs/rules/peer-integrations.mjs +24 -3
- package/runtime/scripts/hfs/rules/pipeline.mjs +58 -9
- package/runtime/scripts/hfs/rules/proof-commands.mjs +14 -8
- package/runtime/scripts/hfs/rules/repo-local-checks.mjs +11 -6
- package/runtime/scripts/hfs/rules/saga.mjs +128 -61
- package/runtime/scripts/hfs/rules/secrets.mjs +4 -3
- package/runtime/scripts/hfs/rules/services.mjs +34 -16
- package/runtime/scripts/hfs/rules/stacks.mjs +21 -14
- package/runtime/scripts/hfs/rules/supabase-secrets.mjs +32 -23
- package/runtime/scripts/hfs/rules/test-topology.mjs +25 -11
- package/runtime/scripts/hfs/secret.mjs +59 -48
- package/runtime/scripts/hfs/slot-app-view.mjs +102 -0
- package/runtime/scripts/hfs/slot-classify.mjs +65 -0
- package/runtime/scripts/hfs/slot-errors.mjs +11 -0
- package/runtime/scripts/hfs/slot-imports.mjs +76 -0
- package/runtime/scripts/hfs/slot-manifest-shape.mjs +73 -0
- package/runtime/scripts/hfs/slot-match.mjs +153 -0
- package/runtime/scripts/hfs/slot-path.mjs +8 -0
- package/runtime/scripts/hfs/slot-required.mjs +76 -0
- package/runtime/scripts/hfs/slot-semantic-problems.mjs +148 -0
- package/runtime/scripts/hfs/slot-side-problems.mjs +28 -0
- package/runtime/scripts/hfs/slots.mjs +74 -695
- package/runtime/scripts/hfs/sql/pg-parse.mjs +5 -2
- package/runtime/scripts/hfs/trailing-slashes.mjs +8 -0
- package/runtime/scripts/hfs/tree.mjs +19 -14
- package/runtime/scripts/hfs/typescript-programs.mjs +6 -4
- package/runtime/scripts/hfs/view.mjs +1 -1
- package/runtime/scripts/lib/dockerfile.mjs +56 -33
- package/runtime/scripts/lib/env.mjs +10 -0
- package/runtime/scripts/lib/event-contract.mjs +17 -13
- package/runtime/scripts/lib/git.mjs +2 -2
- package/runtime/scripts/lib/graphql-contract.mjs +158 -322
- package/runtime/scripts/lib/graphql-sdl.mjs +262 -0
- package/runtime/scripts/lib/i18n.mjs +3 -2
- package/runtime/scripts/lib/in-order.mjs +71 -0
- package/runtime/scripts/lib/language.mjs +3 -3
- package/runtime/scripts/lib/list.mjs +8 -1
- package/runtime/scripts/lib/path-key.mjs +38 -5
- package/runtime/scripts/lib/pid-alive.mjs +7 -0
- package/runtime/scripts/lib/regex.mjs +1 -1
- package/runtime/scripts/lib/same-text.mjs +1 -1
- package/runtime/scripts/lib/secret-patterns.mjs +6 -2
- package/runtime/scripts/lib/sleep-sync.mjs +2 -2
- package/runtime/scripts/lib/sops-envelope.mjs +95 -48
- package/runtime/scripts/lib/stack-services.mjs +1 -2
- package/runtime/scripts/lib/ts-ast.mjs +9 -0
- package/runtime/scripts/lib/walk.mjs +6 -1
- package/runtime/scripts/lib/yaml-cached.mjs +14 -0
- package/scaffold/add-cli-lite.mjs +2 -1
- package/scaffold/add-table.mjs +2 -2
- package/scaffold/add.mjs +3 -2
- package/scaffold/app.mjs +4 -2
- package/scaffold/edition-gate.mjs +25 -25
- package/scaffold/lite-exports.mjs +2 -1
- package/scaffold/service.mjs +5 -4
- package/sync/hygiene.mjs +15 -9
- package/sync/index.mjs +7 -3
- package/templates/app/ci-workflows/github/workflows/ci.yml +4 -4
- package/templates/app/ci-workflows/github/workflows/e2e.yml +3 -3
- package/templates/app/ci-workflows/github/workflows/images.yml +3 -3
- package/templates/app/ci-workflows/sonar-steps.yml +2 -2
- package/templates/app/ci-workflows-lite/github/workflows/ci.yml +6 -6
- package/templates/app/ci-workflows-lite/github/workflows/db-deploy.yml +3 -3
- package/templates/app/ci-workflows-lite/github/workflows/images.yml +3 -3
- package/templates/app/starciwork.gitignore +1 -1
- package/templates/be/image/api/Dockerfile +1 -1
- package/templates/be/image/cli/Dockerfile +1 -1
- package/templates/be/image/worker/Dockerfile +1 -1
- package/templates/be/patterns/cli/group.cli.spec.ts.tpl +1 -1
- package/templates/be/patterns/cli/group.cli.ts.tpl +2 -2
- package/templates/be/patterns/event-bus/platform/event-runner.service.spec.ts.tpl +13 -0
- package/templates/be/patterns/event-bus/platform/event-runner.service.ts.tpl +7 -2
- package/templates/be/patterns/event-bus/platform/event.policy.ts.tpl +4 -1
- package/templates/be/patterns/event-bus/platform/kafka-event-transport.client.ts.tpl +2 -1
- package/templates/be/patterns/outbox/platform/outbox-relay.policy.ts.tpl +24 -9
- package/templates/be/patterns/queues/platform/queue-relay.service.ts.tpl +3 -2
- package/templates/be/patterns/queues/platform/queue-worker.service.ts.tpl +8 -5
- package/templates/be/skeleton/src/features/cli/migrate/migrate.cli.spec.ts +1 -1
- package/templates/be/skeleton/src/features/cli/migrate/migrate.cli.ts +2 -2
- package/templates/be/skeleton/src/features/cli/seed/seed.cli.spec.ts +1 -1
- package/templates/be/skeleton/src/features/cli/seed/seed.cli.ts +2 -2
- package/templates/be/skeleton/src/modules/platform/database/migrate-connections.client.ts +3 -2
- package/templates/be/skeleton/src/modules/platform/database/seed-connections.client.ts +5 -4
- package/templates/be/skeleton/src/modules/platform/primitives/index.ts +1 -0
- package/templates/be/skeleton/src/modules/platform/primitives/sequence.policy.spec.ts +47 -0
- package/templates/be/skeleton/src/modules/platform/primitives/sequence.policy.ts +16 -0
- package/templates/be/skeleton-lite/apps/api/Dockerfile +1 -0
- package/templates/be/skeleton-lite/src/modules/platform/primitives/index.ts +2 -0
- package/templates/fe/image/next/Dockerfile +2 -1
- package/templates/fe/skeleton/apps/app/src/app/[locale]/page.tsx +2 -2
- package/templates/fe/skeleton/apps/landing/src/app/[locale]/page.tsx +2 -2
- package/templates/fe/skeleton/packages/__project__-i18n/src/index.ts +1 -2
- package/templates/fe/skeleton-lite/apps/web/src/app/[locale]/layout.tsx +1 -2
- package/templates/fe/skeleton-lite/apps/web/src/app/[locale]/page.tsx +2 -2
- package/templates/fe/skeleton-lite/apps/web/src/components/blocks/SignInForm/index.tsx +7 -1
- package/templates/fe/skeleton-lite/apps/web/src/modules/db/auth/write-sign-out.ts +1 -1
- package/templates/fe/skeleton-lite/apps/web/src/modules/db/validation/validation.mapper.ts +10 -2
- package/templates/fe/skeleton-lite/apps/web/src/modules/i18n/request.ts +10 -3
- package/upgrade/index.mjs +9 -2
- package/runtime/engine/admission.mjs +0 -308
- package/runtime/engine/canonical-json.mjs +0 -10
- package/runtime/engine/db/blob.mjs +0 -315
- package/runtime/engine/db/ledger-paths.mjs +0 -83
- package/runtime/engine/db/ledger.mjs +0 -1118
- package/runtime/engine/db/machine-connection.mjs +0 -135
- package/runtime/engine/db/machine-schema.mjs +0 -84
- package/runtime/engine/db/machine.mjs +0 -1367
- package/runtime/engine/db/migrations/machine/0001-init.sql +0 -924
- package/runtime/engine/db/migrations/runtime/0001-init.sql +0 -1108
- package/runtime/engine/db/provider-reservations.mjs +0 -101
- package/runtime/engine/digest.mjs +0 -16
- package/runtime/engine/refuse.mjs +0 -11
- package/runtime/modules/ops/_labels.yaml +0 -53
- package/runtime/scripts/api/node/lib.mjs +0 -14
- package/runtime/scripts/api/node/spawn-node.mjs +0 -6
- package/runtime/scripts/api/process/lib.mjs +0 -111
- package/runtime/scripts/api/process/owned-process.mjs +0 -78
- package/runtime/scripts/api/process/stop-owned-process.mjs +0 -9
- package/runtime/scripts/connectors/lib.mjs +0 -488
- package/runtime/scripts/lib/clip.mjs +0 -19
- package/runtime/scripts/lib/display-names.mjs +0 -259
- package/runtime/scripts/lib/example-refs.mjs +0 -158
- package/runtime/scripts/lib/json-schema.mjs +0 -52
- package/runtime/scripts/lib/process-identity.mjs +0 -6
- package/runtime/scripts/lib/read-yaml.mjs +0 -18
- package/runtime/scripts/lib/redact.mjs +0 -161
- package/runtime/scripts/lib/sleep.mjs +0 -7
- package/runtime/scripts/lib/source-phrases.mjs +0 -34
- package/runtime/scripts/lib/sqlite.mjs +0 -21
|
@@ -4,19 +4,20 @@ import { fileURLToPath } from 'node:url';
|
|
|
4
4
|
import {skillRoot} from './runtime-root.mjs';
|
|
5
5
|
import {parseYaml} from './yaml.mjs';
|
|
6
6
|
import {isPlainObject as plain} from './plain-object.mjs';
|
|
7
|
-
import {invalid,validateRoots} from './invalid-config.mjs';
|
|
8
|
-
import {
|
|
7
|
+
import {invalid,validateRoots,ROOT_KEYS} from './invalid-config.mjs';
|
|
8
|
+
import {validateSonar} from './sonar-config.mjs';
|
|
9
|
+
import {validateRelease,RELEASE_KEYS} from './release-config.mjs';
|
|
10
|
+
import {validateOrca,ORCA_KEYS} from './orca-config.mjs';
|
|
11
|
+
import {validateResources,RESOURCE_KEYS} from './resources-config.mjs';
|
|
9
12
|
import {ENV_NAME,secretEnv,connectorSecret} from './secrets.mjs';
|
|
13
|
+
import {byCodeUnit} from './by-code-unit.mjs';
|
|
14
|
+
import {EFFORT_LEVELS,MODELS_KEYS,validateModelsBlock,refuseRemovedKeys,shippedTiers} from './model-config.mjs';
|
|
15
|
+
const knownNames=names=>[...names].sort(byCodeUnit).join(', ');
|
|
10
16
|
export {readDotenv,connectorSecret} from './secrets.mjs';
|
|
11
17
|
|
|
12
18
|
export const configRoot=skillRoot;
|
|
13
|
-
export const NON_OPERATION_ROLES={planner:'plan',kernelManager:'decide',validator:'verify'};
|
|
14
|
-
export const DEFAULT_MODEL_POOLS={'sol-opus':['claude-agent','codex-agent']};
|
|
15
19
|
/** The owner-facing language when config.yaml `language` is absent — the one default every reader shares (scripts/lib/i18n.mjs ownerLanguage). A base-tier value: machine (home.mjs) re-exports it, not the reverse. */
|
|
16
20
|
export const DEFAULT_OWNER_LANGUAGE='en';
|
|
17
|
-
const ADAPTIVE_ALLOCATION_MODE='adaptive';
|
|
18
|
-
/** The effort vocabulary, ordered weakest to strongest — the only list of it. */
|
|
19
|
-
const EFFORT_LEVELS=['none','minimal','low','medium','high','xhigh','max','ultra'];
|
|
20
21
|
// Parsed once per file version (mtime + size) per process; each caller gets its own copy.
|
|
21
22
|
// The one runtimes.yaml loader: it throws on a missing or unparsable file, so no caller ever
|
|
22
23
|
// reasons on a silent empty document. The pool map (provider, roles, models, maxParallel)
|
|
@@ -26,13 +27,13 @@ let runtimeProfileCache=null;
|
|
|
26
27
|
export function runtimeProfile(){
|
|
27
28
|
const source=fileURLToPath(new URL('../modules/models/runtimes.yaml',import.meta.url));
|
|
28
29
|
const registryFile=fileURLToPath(new URL('../modules/models/registry.yaml',import.meta.url));
|
|
29
|
-
let stat;try{stat=fs.statSync(source);}catch{throw Error('Missing modules/models/runtimes.yaml');}
|
|
30
|
-
let rstat;try{rstat=fs.statSync(registryFile);}catch{throw Error('Missing modules/models/registry.yaml');}
|
|
30
|
+
let stat;try{stat=fs.statSync(source);}catch{throw new Error('Missing modules/models/runtimes.yaml');}
|
|
31
|
+
let rstat;try{rstat=fs.statSync(registryFile);}catch{throw new Error('Missing modules/models/registry.yaml');}
|
|
31
32
|
const version=`${stat.mtimeMs}:${stat.size}:${rstat.mtimeMs}:${rstat.size}`;
|
|
32
33
|
if(runtimeProfileCache?.version!==version){
|
|
33
34
|
const doc=parseYaml(fs.readFileSync(source,'utf8'));
|
|
34
35
|
const registry=parseYaml(fs.readFileSync(registryFile,'utf8'));
|
|
35
|
-
runtimeProfileCache={version,profile:{...
|
|
36
|
+
runtimeProfileCache={version,profile:{...doc,runtimes:registry?.pools??{},models:registry?.models??{}}};
|
|
36
37
|
}
|
|
37
38
|
return structuredClone(runtimeProfileCache.profile);
|
|
38
39
|
}
|
|
@@ -41,14 +42,17 @@ export function runtimeProfile(){
|
|
|
41
42
|
* TTL, the liveness and cadence windows, the slicing weights, the failure cooldowns. Code reads them from
|
|
42
43
|
* here; a literal copy of any of them in a source file would be a second authority.
|
|
43
44
|
*/
|
|
44
|
-
export function allocationSettings(){
|
|
45
|
+
export function allocationSettings(){
|
|
46
|
+
const allocation=runtimeProfile()?.allocation??{};
|
|
47
|
+
return allocation.admission?{...allocation,admission:{...allocation.admission,...shippedTiers().usage}}:allocation;
|
|
48
|
+
}
|
|
45
49
|
// These are current owner declarations, never a historical runtime owner's consent.
|
|
46
50
|
function validateOwnerProfile(value,name,pathsKey){
|
|
47
51
|
if(value===null)return;
|
|
48
52
|
const bad=invalid(name);
|
|
49
53
|
if(!plain(value))bad(' must be an owner approval mapping or null.');
|
|
50
|
-
const keys=['approvedBy','approvalRef',pathsKey,...(name==='launchTrust'?['profile']:[])];
|
|
51
|
-
for(const key of Object.keys(value))if(!keys.
|
|
54
|
+
const keys=new Set(['approvedBy','approvalRef',pathsKey,...(name==='launchTrust'?['profile']:[])]);
|
|
55
|
+
for(const key of Object.keys(value))if(!keys.has(key))bad(` has unknown key ${key}.`);
|
|
52
56
|
if(value.approvedBy!=='owner')bad('.approvedBy must be owner; adoption must come from the current owner.');
|
|
53
57
|
if(typeof value.approvalRef!=='string'||!value.approvalRef.trim())bad('.approvalRef must identify the current owner approval.');
|
|
54
58
|
if(name==='launchTrust'&&!['automatic','declined'].includes(value.profile))bad('.profile must be automatic or declined.');
|
|
@@ -69,7 +73,7 @@ export function workflowPurgeSettings(config=loadConfig()){
|
|
|
69
73
|
export function allocationMs(dotted){
|
|
70
74
|
const raw=dotted.split('.').reduce((node,key)=>(node==null?node:node[key]),allocationSettings());
|
|
71
75
|
const value=Number(raw);
|
|
72
|
-
if(!Number.isFinite(value)||value<=0)throw Error(`modules/models/runtimes.yaml allocation.${dotted} must declare a positive number of milliseconds`);
|
|
76
|
+
if(!Number.isFinite(value)||value<=0)throw new Error(`modules/models/runtimes.yaml allocation.${dotted} must declare a positive number of milliseconds`);
|
|
73
77
|
return value;
|
|
74
78
|
}
|
|
75
79
|
/**
|
|
@@ -80,7 +84,7 @@ export function allocationMs(dotted){
|
|
|
80
84
|
export function slicingGears(){
|
|
81
85
|
const gears=allocationSettings()?.slicing?.gears;
|
|
82
86
|
if(!Array.isArray(gears)||!gears.length||gears.some(value=>!Number.isInteger(value)||value<1))
|
|
83
|
-
throw Error('modules/models/runtimes.yaml allocation.slicing.gears must declare a non-empty list of positive integers');
|
|
87
|
+
throw new Error('modules/models/runtimes.yaml allocation.slicing.gears must declare a non-empty list of positive integers');
|
|
84
88
|
return [...gears];
|
|
85
89
|
}
|
|
86
90
|
/** The gear an absent `parallel` block means. The first declared gear, never a literal. */
|
|
@@ -107,79 +111,87 @@ export const CONNECTOR_DEFAULTS=Object.freeze({
|
|
|
107
111
|
});
|
|
108
112
|
const HOSTNAME=/^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/i;
|
|
109
113
|
const TUNNEL_REF=/^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$/;
|
|
110
|
-
const CHAT_ID=/^(?:-?\d{1,20}|@[A-Za-z]
|
|
111
|
-
const SECRET_KEYS=['token','tunnelToken','botToken','secret','apiToken','password'];
|
|
114
|
+
const CHAT_ID=/^(?:-?\d{1,20}|@[A-Za-z]\w{4,31})$/;
|
|
115
|
+
const SECRET_KEYS=new Set(['token','tunnelToken','botToken','secret','apiToken','password']);
|
|
116
|
+
const closedConnectorShape=(bad,node,where,keys)=>{
|
|
117
|
+
if(!plain(node))bad(`.${where} must be a mapping.`);
|
|
118
|
+
for(const key of Object.keys(node)){
|
|
119
|
+
if(SECRET_KEYS.has(key))bad(`.${where}.${key}: secrets never live in config.yaml — set the environment variable the *Env key names instead.`);
|
|
120
|
+
if(!keys.includes(key))bad(`.${where} has unknown key ${key} (allowed: ${keys.join(', ')}).`);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const connectorEnvName=(bad,where,value)=>{if(value!==undefined&&(typeof value!=='string'||!ENV_NAME.test(value)))bad(`.${where} must name an environment variable (UPPER_SNAKE), never hold the secret itself.`);};
|
|
124
|
+
const validateCloudflareMode=(cf,bad)=>{if(cf.mode!==undefined&&!CLOUDFLARE_MODES.includes(cf.mode))bad(`.cloudflare.mode must be one of ${CLOUDFLARE_MODES.join(' | ')}.`);};
|
|
125
|
+
const validateCloudflareDetails=(cf,bad)=>{
|
|
126
|
+
if(cf.hostname!==undefined&&cf.hostname!==null&&(typeof cf.hostname!=='string'||!HOSTNAME.test(cf.hostname)))bad('.cloudflare.hostname must be a bare hostname (no scheme, no path) or null.');
|
|
127
|
+
if(cf.access!==undefined&&typeof cf.access!=='boolean')bad('.cloudflare.access must be true or false.');
|
|
128
|
+
if(cf.tunnel!==undefined&&cf.tunnel!==null&&(typeof cf.tunnel!=='string'||!TUNNEL_REF.test(cf.tunnel)))bad('.cloudflare.tunnel must be the named tunnel UUID (or name) or null.');
|
|
129
|
+
if(cf.credentialsFile!==undefined&&cf.credentialsFile!==null&&(typeof cf.credentialsFile!=='string'||!cf.credentialsFile.trim()))bad('.cloudflare.credentialsFile must be the tunnel credentials JSON path or null.');
|
|
130
|
+
};
|
|
131
|
+
const validateCloudflareModeConstraints=(cf,bad)=>{if(cf.credentialsFile&&!cf.tunnel){bad('.cloudflare.credentialsFile needs cloudflare.tunnel (the tunnel UUID the credentials belong to).');}if(cf.mode==='named'&&!cf.hostname){bad('.cloudflare.mode named needs cloudflare.hostname (the public hostname routed to the gateway).');}if(cf.mode==='quick'&&(cf.tunnel||cf.credentialsFile)){bad('.cloudflare.mode quick runs no named tunnel; tunnel/credentialsFile are for mode named.');}if(cf.mode==='quick'&&cf.hostname){bad('.cloudflare.mode quick gets a random trycloudflare.com hostname; set hostname only for mode named.');}};
|
|
132
|
+
const validateCloudflareConnector=cf=>{
|
|
133
|
+
const bad=invalid('connectors');
|
|
134
|
+
closedConnectorShape(bad,cf,'cloudflare',['mode','tunnel','credentialsFile','tokenEnv','hostname','access']);
|
|
135
|
+
validateCloudflareMode(cf,bad);
|
|
136
|
+
connectorEnvName(bad,'cloudflare.tokenEnv',cf.tokenEnv);
|
|
137
|
+
validateCloudflareDetails(cf,bad);
|
|
138
|
+
validateCloudflareModeConstraints(cf,bad);
|
|
139
|
+
};
|
|
140
|
+
const validateTelegramConnector=tg=>{
|
|
141
|
+
const bad=invalid('connectors');
|
|
142
|
+
closedConnectorShape(bad,tg,'telegram',['enabled','botTokenEnv','chatId','exposeCredentialAsks']);
|
|
143
|
+
if(tg.enabled!==undefined&&typeof tg.enabled!=='boolean')bad('.telegram.enabled must be true or false.');
|
|
144
|
+
connectorEnvName(bad,'telegram.botTokenEnv',tg.botTokenEnv);
|
|
145
|
+
if(tg.chatId!==undefined&&tg.chatId!==null&&!((Number.isSafeInteger(tg.chatId))||(typeof tg.chatId==='string'&&CHAT_ID.test(tg.chatId))))
|
|
146
|
+
bad('.telegram.chatId must be a numeric chat id, an @channel name, or null.');
|
|
147
|
+
if(tg.exposeCredentialAsks!==undefined&&typeof tg.exposeCredentialAsks!=='boolean')bad('.telegram.exposeCredentialAsks must be true or false.');
|
|
148
|
+
if(tg.enabled===true&&(tg.chatId===undefined||tg.chatId===null))bad('.telegram.enabled needs telegram.chatId.');
|
|
149
|
+
};
|
|
112
150
|
function validateConnectors(connectors){
|
|
113
151
|
if(connectors===null)return;
|
|
114
152
|
const bad=invalid('connectors');
|
|
115
153
|
if(!plain(connectors))bad(' must be {repos?, gateway?, cloudflare?, telegram?} or null.');
|
|
116
|
-
|
|
117
|
-
if(!plain(node))bad(`.${where} must be a mapping.`);
|
|
118
|
-
for(const key of Object.keys(node)){
|
|
119
|
-
if(SECRET_KEYS.includes(key))bad(`.${where}.${key}: secrets never live in config.yaml — set the environment variable the *Env key names instead.`);
|
|
120
|
-
if(!keys.includes(key))bad(`.${where} has unknown key ${key} (allowed: ${keys.join(', ')}).`);
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
closed(connectors,'',['repos','gateway','cloudflare','telegram']);
|
|
154
|
+
closedConnectorShape(bad,connectors,'',['repos','gateway','cloudflare','telegram']);
|
|
124
155
|
if(connectors.repos!==undefined&&(!Array.isArray(connectors.repos)||connectors.repos.some(repo=>typeof repo!=='string'||!repo.trim())))bad('.repos must be a list of repository paths.');
|
|
125
156
|
if(connectors.gateway!==undefined){
|
|
126
|
-
|
|
157
|
+
closedConnectorShape(bad,connectors.gateway,'gateway',['port']);
|
|
127
158
|
const port=connectors.gateway.port;
|
|
128
159
|
if(port!==undefined&&(!Number.isInteger(port)||port<1024||port>65535||(port>=ASK_PORT_BAND[0]&&port<=ASK_PORT_BAND[1])))
|
|
129
160
|
bad(`.gateway.port must be an integer port in 1024..65535 outside the serve-ask band ${ASK_PORT_BAND.join('..')}.`);
|
|
130
161
|
}
|
|
131
|
-
|
|
132
|
-
if(connectors.
|
|
133
|
-
const cf=connectors.cloudflare;
|
|
134
|
-
closed(cf,'cloudflare',['mode','tunnel','credentialsFile','tokenEnv','hostname','access']);
|
|
135
|
-
if(cf.mode!==undefined&&!CLOUDFLARE_MODES.includes(cf.mode))bad(`.cloudflare.mode must be one of ${CLOUDFLARE_MODES.join(' | ')}.`);
|
|
136
|
-
envName('cloudflare.tokenEnv',cf.tokenEnv);
|
|
137
|
-
if(cf.hostname!==undefined&&cf.hostname!==null&&(typeof cf.hostname!=='string'||!HOSTNAME.test(cf.hostname)))bad('.cloudflare.hostname must be a bare hostname (no scheme, no path) or null.');
|
|
138
|
-
if(cf.access!==undefined&&typeof cf.access!=='boolean')bad('.cloudflare.access must be true or false.');
|
|
139
|
-
if(cf.tunnel!==undefined&&cf.tunnel!==null&&(typeof cf.tunnel!=='string'||!TUNNEL_REF.test(cf.tunnel)))bad('.cloudflare.tunnel must be the named tunnel UUID (or name) or null.');
|
|
140
|
-
if(cf.credentialsFile!==undefined&&cf.credentialsFile!==null&&(typeof cf.credentialsFile!=='string'||!cf.credentialsFile.trim()))bad('.cloudflare.credentialsFile must be the tunnel credentials JSON path or null.');
|
|
141
|
-
if(cf.credentialsFile&&!cf.tunnel)bad('.cloudflare.credentialsFile needs cloudflare.tunnel (the tunnel UUID the credentials belong to).');
|
|
142
|
-
if(cf.mode==='named'&&!cf.hostname)bad('.cloudflare.mode named needs cloudflare.hostname (the public hostname routed to the gateway).');
|
|
143
|
-
if(cf.mode==='quick'&&(cf.tunnel||cf.credentialsFile))bad('.cloudflare.mode quick runs no named tunnel; tunnel/credentialsFile are for mode named.');
|
|
144
|
-
if(cf.mode==='quick'&&cf.hostname)bad('.cloudflare.mode quick gets a random trycloudflare.com hostname; set hostname only for mode named.');
|
|
145
|
-
}
|
|
146
|
-
if(connectors.telegram!==undefined){
|
|
147
|
-
const tg=connectors.telegram;
|
|
148
|
-
closed(tg,'telegram',['enabled','botTokenEnv','chatId','exposeCredentialAsks']);
|
|
149
|
-
if(tg.enabled!==undefined&&typeof tg.enabled!=='boolean')bad('.telegram.enabled must be true or false.');
|
|
150
|
-
envName('telegram.botTokenEnv',tg.botTokenEnv);
|
|
151
|
-
if(tg.chatId!==undefined&&tg.chatId!==null&&!((Number.isSafeInteger(tg.chatId))||(typeof tg.chatId==='string'&&CHAT_ID.test(tg.chatId))))
|
|
152
|
-
bad('.telegram.chatId must be a numeric chat id, an @channel name, or null.');
|
|
153
|
-
if(tg.exposeCredentialAsks!==undefined&&typeof tg.exposeCredentialAsks!=='boolean')bad('.telegram.exposeCredentialAsks must be true or false.');
|
|
154
|
-
if(tg.enabled===true&&(tg.chatId===undefined||tg.chatId===null))bad('.telegram.enabled needs telegram.chatId.');
|
|
155
|
-
}
|
|
162
|
+
if(connectors.cloudflare!==undefined)validateCloudflareConnector(connectors.cloudflare);
|
|
163
|
+
if(connectors.telegram!==undefined)validateTelegramConnector(connectors.telegram);
|
|
156
164
|
}
|
|
157
165
|
/** Load connector credentials from the explicitly verified runtime main; never print the returned environment. */
|
|
158
|
-
export function connectorEnv(config,env=process.env,verifiedRuntimeRoot){return secretEnv(verifiedRuntimeRoot,env);}
|
|
166
|
+
export function connectorEnv(config,env=process.env,verifiedRuntimeRoot=undefined){return secretEnv(verifiedRuntimeRoot,env);}
|
|
159
167
|
/**
|
|
160
168
|
* The normalized `connectors` block: defaults filled in, the secrets' PRESENCE (booleans, never values),
|
|
161
169
|
* whether each connector is ready to run, and the owner-facing warnings the security posture earns.
|
|
162
170
|
*/
|
|
171
|
+
const connectorWarnings=(cloudflare,telegram)=>{
|
|
172
|
+
const warnings=[];
|
|
173
|
+
if(cloudflare.mode==='quick')warnings.push('cloudflare.mode quick: the ask link is public and unauthenticated — anyone holding the URL can open and answer the form; the hostname changes on every restart.');
|
|
174
|
+
if(cloudflare.mode==='named'&&!cloudflare.access)warnings.push(`cloudflare.access is false: ${cloudflare.hostname} is not fronted by Cloudflare Access, so the nonce URL is the only credential.`);
|
|
175
|
+
if(cloudflare.auth==='credentials-file'&&!cloudflare.credentialsPresent)warnings.push(`cloudflare.credentialsFile ${cloudflare.credentialsFile} does not exist.`);
|
|
176
|
+
if(cloudflare.auth==='token'&&!cloudflare.tokenPresent)warnings.push(`cloudflare.mode named: the tunnel token is not set — export ${cloudflare.tokenEnv} (or ${cloudflare.tokenEnv}_FILE).`);
|
|
177
|
+
if(telegram.enabled&&!telegram.botTokenPresent)warnings.push(`telegram.enabled: the bot token is not set — export ${telegram.botTokenEnv} (or ${telegram.botTokenEnv}_FILE).`);
|
|
178
|
+
if(telegram.exposeCredentialAsks)warnings.push('telegram.exposeCredentialAsks is true: credential asks are posted as public links; Telegram cloud chats are not end-to-end encrypted.');
|
|
179
|
+
return warnings;
|
|
180
|
+
};
|
|
163
181
|
export function connectorsConfig(config=loadConfig(),env=process.env,root=configRoot){
|
|
164
182
|
validateConfig(config);
|
|
165
183
|
const raw=plain(config?.connectors)?config.connectors:{},d=CONNECTOR_DEFAULTS;
|
|
166
|
-
const cloudflare={...d.cloudflare,...
|
|
184
|
+
const cloudflare={...d.cloudflare,...raw.cloudflare},telegram={...d.telegram,...raw.telegram};
|
|
167
185
|
if(cloudflare.credentialsFile)cloudflare.credentialsFile=path.resolve(root,cloudflare.credentialsFile.replace(/^~(?=[\\/])/,env.USERPROFILE??env.HOME??'~'));
|
|
168
186
|
cloudflare.tokenPresent=connectorSecret(cloudflare.tokenEnv,env)!==null;
|
|
169
187
|
cloudflare.credentialsPresent=Boolean(cloudflare.credentialsFile&&fs.existsSync(cloudflare.credentialsFile));
|
|
170
|
-
|
|
188
|
+
const namedAuth=cloudflare.credentialsFile?'credentials-file':'token';
|
|
189
|
+
cloudflare.auth=cloudflare.mode==='named'?namedAuth:null;
|
|
171
190
|
cloudflare.publicBase=cloudflare.mode==='named'?`https://${cloudflare.hostname}`:null;
|
|
172
191
|
telegram.chatId=telegram.chatId===null?null:String(telegram.chatId);
|
|
173
192
|
telegram.botTokenPresent=connectorSecret(telegram.botTokenEnv,env)!==null;
|
|
174
193
|
telegram.configured=telegram.enabled===true&&telegram.chatId!==null&&telegram.botTokenPresent;
|
|
175
|
-
|
|
176
|
-
if(cloudflare.mode==='quick')warnings.push('cloudflare.mode quick: the ask link is public and unauthenticated — anyone holding the URL can open and answer the form; the hostname changes on every restart.');
|
|
177
|
-
if(cloudflare.mode==='named'&&!cloudflare.access)warnings.push(`cloudflare.access is false: ${cloudflare.hostname} is not fronted by Cloudflare Access, so the nonce URL is the only credential.`);
|
|
178
|
-
if(cloudflare.auth==='credentials-file'&&!cloudflare.credentialsPresent)warnings.push(`cloudflare.credentialsFile ${cloudflare.credentialsFile} does not exist.`);
|
|
179
|
-
if(cloudflare.auth==='token'&&!cloudflare.tokenPresent)warnings.push(`cloudflare.mode named: the tunnel token is not set — export ${cloudflare.tokenEnv} (or ${cloudflare.tokenEnv}_FILE).`);
|
|
180
|
-
if(telegram.enabled&&!telegram.botTokenPresent)warnings.push(`telegram.enabled: the bot token is not set — export ${telegram.botTokenEnv} (or ${telegram.botTokenEnv}_FILE).`);
|
|
181
|
-
if(telegram.exposeCredentialAsks)warnings.push('telegram.exposeCredentialAsks is true: credential asks are posted as public links; Telegram cloud chats are not end-to-end encrypted.');
|
|
182
|
-
return {repos:[...(raw.repos??d.repos)],gateway:{...d.gateway,...(raw.gateway??{})},cloudflare,telegram,warnings};
|
|
194
|
+
return {repos:[...(raw.repos??d.repos)],gateway:{...d.gateway,...raw.gateway},cloudflare,telegram,warnings:connectorWarnings(cloudflare,telegram)};
|
|
183
195
|
}
|
|
184
196
|
/**
|
|
185
197
|
* config.yaml `asks` — whether an owner ask that carries a recommended option is answered with it
|
|
@@ -192,18 +204,19 @@ export function connectorsConfig(config=loadConfig(),env=process.env,root=config
|
|
|
192
204
|
export const ASK_KINDS=Object.freeze(['information','credential','account','access','consent','authority','business-decision','irreversible-confirmation']);
|
|
193
205
|
const ASK_EXCLUDE_CLASSES=Object.freeze([...ASK_KINDS,'handover','draw-review']);
|
|
194
206
|
export const ASKS_DEFAULTS=Object.freeze({autoAcceptRecommended:false,excludes:Object.freeze(['credential','irreversible-confirmation','handover'])});
|
|
207
|
+
const validateAskExcludes=(bad,excludes)=>{
|
|
208
|
+
if(!Array.isArray(excludes))bad(`.excludes must be a list of ask classes (${ASK_EXCLUDE_CLASSES.join(', ')}).`);
|
|
209
|
+
for(const entry of excludes)if(typeof entry!=='string'||!ASK_EXCLUDE_CLASSES.includes(entry))bad(`.excludes entry ${JSON.stringify(entry)} is not an ask class (${ASK_EXCLUDE_CLASSES.join(', ')}).`);
|
|
210
|
+
if(new Set(excludes).size!==excludes.length)bad('.excludes names each class once.');
|
|
211
|
+
};
|
|
195
212
|
function validateAsks(asks){
|
|
196
213
|
if(asks===null)return;
|
|
197
214
|
const bad=invalid('asks');
|
|
198
215
|
if(!plain(asks))bad(' must be {autoAcceptRecommended?, excludes?} or null.');
|
|
199
|
-
for(const key of Object.keys(asks))if(!
|
|
216
|
+
for(const key of Object.keys(asks))if(!CONFIG_KEY_TREE.asks.includes(key))bad(` has unknown key ${key} (allowed: ${CONFIG_KEY_TREE.asks.join(', ')}).`);
|
|
200
217
|
if(asks.autoAcceptRecommended!==undefined&&typeof asks.autoAcceptRecommended!=='boolean')bad('.autoAcceptRecommended must be true or false.');
|
|
201
218
|
const excludes=asks.excludes;
|
|
202
|
-
if(excludes!==undefined&&excludes!==null)
|
|
203
|
-
if(!Array.isArray(excludes))bad(`.excludes must be a list of ask classes (${ASK_EXCLUDE_CLASSES.join(', ')}).`);
|
|
204
|
-
for(const entry of excludes)if(typeof entry!=='string'||!ASK_EXCLUDE_CLASSES.includes(entry))bad(`.excludes entry ${JSON.stringify(entry)} is not an ask class (${ASK_EXCLUDE_CLASSES.join(', ')}).`);
|
|
205
|
-
if(new Set(excludes).size!==excludes.length)bad('.excludes names each class once.');
|
|
206
|
-
}
|
|
219
|
+
if(excludes!==undefined&&excludes!==null)validateAskExcludes(bad,excludes);
|
|
207
220
|
}
|
|
208
221
|
/**
|
|
209
222
|
* config.yaml `uat` — the machine-wide UAT ceiling: at most `maxConcurrent` UAT runs (browsers, players,
|
|
@@ -214,7 +227,7 @@ function validateUat(uat){
|
|
|
214
227
|
if(uat===null)return;
|
|
215
228
|
const bad=invalid('uat');
|
|
216
229
|
if(!plain(uat))bad(' must be {maxConcurrent?} or null.');
|
|
217
|
-
for(const key of Object.keys(uat))if(key
|
|
230
|
+
for(const key of Object.keys(uat))if(!CONFIG_KEY_TREE.uat.includes(key))bad(` has unknown key ${key} (allowed: ${CONFIG_KEY_TREE.uat.join(', ')}).`);
|
|
218
231
|
if(uat.maxConcurrent!==undefined&&uat.maxConcurrent!==null&&!(Number.isInteger(uat.maxConcurrent)&&uat.maxConcurrent>=1))bad('.maxConcurrent must be a positive integer (default 10) or null.');
|
|
219
232
|
}
|
|
220
233
|
/** The owner's UAT concurrency settings: {maxConcurrent, source}. An absent or null block is the default. */
|
|
@@ -224,189 +237,149 @@ export function uatSettings(config=loadConfig()){
|
|
|
224
237
|
return Number.isInteger(value)?{maxConcurrent:value,source:'uat'}:{maxConcurrent:UAT_DEFAULTS.maxConcurrent,source:'default'};
|
|
225
238
|
}
|
|
226
239
|
/**
|
|
227
|
-
* config.yaml `allocation`
|
|
228
|
-
* (
|
|
229
|
-
* policy: prefer-then-overflow (the runtimes.yaml default) | balanced — among the eligible pools, the one
|
|
230
|
-
* furthest below its target share of the recent dispatches wins.
|
|
231
|
-
* shares: {<runtime pool>: <weight >= 0>} — target shares, normalized over the named pools. Absent = equal.
|
|
232
|
-
* windowHours: how far back the recent dispatches are counted (default 24).
|
|
233
|
-
* grants: ['<pool>=<slots>@<role>+<role>'] — the owner's default grant, applied to every workflow, that opens
|
|
234
|
-
* a capacityAuthority explicit-workflow-quota pool (Devin) for those roles up to <slots> running jobs.
|
|
240
|
+
* config.yaml `allocation` — {grants?}: ['<pool>=<slots>@<role>+<role>'], the owner's default grant, applied to every
|
|
241
|
+
* workflow, that opens a capacityAuthority explicit-workflow-quota pool (Devin) for those roles up to <slots> running jobs.
|
|
235
242
|
*/
|
|
236
|
-
export const ALLOCATION_POLICIES=Object.freeze(['prefer-then-overflow','balanced']);
|
|
237
|
-
const ALLOCATION_KEYS=Object.freeze(['mode','preferredProvider','policy','shares','windowHours','grants']);
|
|
238
|
-
export const DEFAULT_ALLOCATION_WINDOW_HOURS=24;
|
|
239
243
|
const GRANT=/^([a-z0-9][a-z0-9.-]*)=(\d+)@([a-z]+(?:\+[a-z]+)*)$/;
|
|
240
244
|
/** One grant string `<pool>=<slots>@<role>+<role>` as {pool, slots, roles}, or null when it is not that shape. */
|
|
245
|
+
/** The closed set of top-level config.yaml blocks: the validator accepts these and refuses every other key. */
|
|
246
|
+
export const CONFIG_BLOCKS=Object.freeze(['language','model','effort','models','allocation','kernel','budgets','supervisor','parallel','delegation','connectors','asks','uat','specs','reconciler','debugLoop','orca','roots','resources','sonar','release','launchTrust','retention']);
|
|
241
247
|
export function parseAllocationGrant(text){
|
|
242
248
|
const m=typeof text==='string'?GRANT.exec(text.trim()):null;
|
|
243
249
|
return m?{pool:m[1],slots:Number(m[2]),roles:m[3].split('+')}:null;
|
|
244
250
|
}
|
|
245
|
-
|
|
246
|
-
const
|
|
247
|
-
if(
|
|
248
|
-
|
|
249
|
-
if(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
bad('windowHours must be a number of hours in (0, 720].');
|
|
260
|
-
if(allocation.grants!==undefined&&allocation.grants!==null){
|
|
261
|
-
if(!Array.isArray(allocation.grants))bad('grants must be a list of "<pool>=<slots>@<role>+<role>" strings.');
|
|
262
|
-
const seen=new Set();
|
|
263
|
-
for(const text of allocation.grants){
|
|
264
|
-
const grant=parseAllocationGrant(text);
|
|
265
|
-
if(!grant)bad(`grants entry ${JSON.stringify(text)} is not "<pool>=<slots>@<role>+<role>" (e.g. devin-agent=10@implement+verify+write).`);
|
|
266
|
-
const runtime=runtimes[grant.pool];
|
|
267
|
-
if(!plain(runtime))bad(`grants entry ${text}: ${grant.pool} is not a modules/models/registry.yaml pool.`);
|
|
268
|
-
if(seen.has(grant.pool))bad(`grants names ${grant.pool} more than once.`);
|
|
269
|
-
seen.add(grant.pool);
|
|
270
|
-
const max=Number(runtime.maxParallel);
|
|
271
|
-
if(!(grant.slots>=1&&(!Number.isFinite(max)||grant.slots<=max)))bad(`grants entry ${text}: slots must be 1..${Number.isFinite(max)?max:'maxParallel'} (registry.yaml maxParallel).`);
|
|
272
|
-
const unserved=grant.roles.filter(role=>!(runtime.roles??[]).includes(role));
|
|
273
|
-
if(unserved.length)bad(`grants entry ${text}: ${grant.pool} does not serve role ${unserved.join(', ')} (registry.yaml roles: ${(runtime.roles??[]).join(', ')}).`);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
/** Kernel and Supervisor seats share one authoritative pin/group grammar. */
|
|
251
|
+
const validateGrant=(bad,text,runtimes,seen)=>{
|
|
252
|
+
const grant=parseAllocationGrant(text);
|
|
253
|
+
if(!grant)bad(`grants entry ${JSON.stringify(text)} is not "<pool>=<slots>@<role>+<role>" (e.g. devin-agent=10@implement+verify+write).`);
|
|
254
|
+
const runtime=runtimes[grant.pool];
|
|
255
|
+
if(!plain(runtime))bad(`grants entry ${text}: ${grant.pool} is not a modules/models/registry.yaml pool.`);
|
|
256
|
+
if(seen.has(grant.pool)){bad(`grants names ${grant.pool} more than once.`);} seen.add(grant.pool);
|
|
257
|
+
const max=Number(runtime.maxParallel); if(!(grant.slots>=1&&(!Number.isFinite(max)||grant.slots<=max)))bad(`grants entry ${text}: slots must be 1..${Number.isFinite(max)?max:'maxParallel'} (registry.yaml maxParallel).`);
|
|
258
|
+
const unserved=grant.roles.filter(role=>!(runtime.roles??[]).includes(role)); if(unserved.length)bad(`grants entry ${text}: ${grant.pool} does not serve role ${unserved.join(', ')} (registry.yaml roles: ${(runtime.roles??[]).join(', ')}).`);
|
|
259
|
+
};
|
|
260
|
+
const validateGrants=(bad,grants,runtimes)=>{
|
|
261
|
+
if(!Array.isArray(grants))bad('grants must be a list of "<pool>=<slots>@<role>+<role>" strings.');
|
|
262
|
+
const seen=new Set();
|
|
263
|
+
for(const text of grants)validateGrant(bad,text,runtimes,seen);
|
|
264
|
+
};
|
|
278
265
|
function validateAgentSeat(seat,name,profile){
|
|
279
266
|
const runtimes=profile?.runtimes??{},knownProviders=new Set(Object.values(runtimes).map(runtime=>runtime?.provider).filter(Boolean));
|
|
280
|
-
if(plain(seat)
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
if(new Set(group.map(member=>member.agent)).size!==group.length)throw Error(`Invalid config.yaml: ${name}.group names each agent once — availability is per provider.`);
|
|
285
|
-
for(const {agent,model} of group){
|
|
286
|
-
if(!knownProviders.has(agent))throw Error(`Invalid config.yaml: ${name}.group agent ${agent} is not declared by a runtime (known: ${[...knownProviders].sort().join(', ')}).`);
|
|
287
|
-
if(typeof model==='string'&&profile.models?.[model]?.provider!==agent&&!Object.values(runtimes).some(runtime=>runtime?.provider===agent&&(runtime.target===model||Object.values(runtime.models??{}).includes(model))))
|
|
288
|
-
throw Error(`Invalid config.yaml: ${name}.group model ${model} is not declared by a ${agent} runtime.`);
|
|
289
|
-
}
|
|
290
|
-
}else{
|
|
291
|
-
if(!plain(seat)||Object.keys(seat).some(key=>!['agent','model','effort'].includes(key))||Object.values(seat).some(value=>value!==null&&(typeof value!=='string'||!value.trim())))
|
|
292
|
-
throw Error(`Invalid config.yaml: ${name} must be {agent?, model?, effort?} with string-or-null values, or {group: [{agent, model?}, ...], effort?}.`);
|
|
293
|
-
if(typeof seat.agent==='string'&&!knownProviders.has(seat.agent))throw Error(`Invalid config.yaml: ${name}.agent ${seat.agent} is not declared by a runtime (known: ${[...knownProviders].sort().join(', ')}).`);
|
|
294
|
-
}
|
|
295
|
-
if(seat.effort!==undefined&&seat.effort!==null&&!EFFORT_LEVELS.includes(seat.effort))throw Error(`Invalid config.yaml: ${name}.effort must use the effort vocabulary.`);
|
|
267
|
+
if(!plain(seat)||Object.keys(seat).some(key=>!SEAT_KEYS.includes(key))||Object.values(seat).some(value=>value!==null&&(typeof value!=='string'||!value.trim())))
|
|
268
|
+
throw new Error(`Invalid config.yaml: ${name} must be {agent?, model?, effort?} with string-or-null values (agent and model pin the seat: an \`only\` bias).`);
|
|
269
|
+
if(typeof seat.agent==='string'&&!knownProviders.has(seat.agent))throw new Error(`Invalid config.yaml: ${name}.agent ${seat.agent} is not declared by a runtime (known: ${knownNames(knownProviders)}).`);
|
|
270
|
+
if(seat.effort!==undefined&&seat.effort!==null&&!EFFORT_LEVELS.has(seat.effort))throw new Error(`Invalid config.yaml: ${name}.effort must use the effort vocabulary.`);
|
|
296
271
|
}
|
|
297
|
-
|
|
298
|
-
const
|
|
299
|
-
if(
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
if(
|
|
304
|
-
|
|
305
|
-
if(
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
272
|
+
const validateReconcilerBlock=r=>{
|
|
273
|
+
const ctl=r?.controllers;
|
|
274
|
+
if(!plain(r)||Object.keys(r).some(key=>!CONFIG_KEY_TREE.reconciler.includes(key))||(r.enabled!==undefined&&typeof r.enabled!=='boolean')||!(r.profile===undefined||r.profile===null||['operational','observe'].includes(r.profile))||!(ctl===undefined||ctl===null||(plain(ctl)&&Object.entries(ctl).every(([name,c])=>/^[a-z][a-z0-9-]*$/.test(name)&&plain(c)&&Object.keys(c).every(key=>key==='mode')&&['off','shadow','active'].includes(c.mode)))))
|
|
275
|
+
throw new Error('Invalid config.yaml: reconciler must be {enabled?: boolean, profile?: operational|observe, controllers?: {<name>: {mode: off|shadow|active}}}, or null.');
|
|
276
|
+
};
|
|
277
|
+
const validateAllocationBlock=(allocation,runtimes)=>{
|
|
278
|
+
if(!plain(allocation)||Object.keys(allocation).some(key=>!CONFIG_KEY_TREE.allocation.includes(key)))
|
|
279
|
+
throw new Error('Invalid config.yaml: allocation must be {grants?: [<pool>=<slots>@<role>+<role>]}.');
|
|
280
|
+
if(allocation.grants!==undefined&&allocation.grants!==null)validateGrants(invalid('allocation.'),allocation.grants,runtimes);
|
|
281
|
+
};
|
|
282
|
+
const validateParallelBlock=parallel=>{
|
|
283
|
+
const gears=slicingGears();
|
|
284
|
+
if(!plain(parallel)||Object.keys(parallel).some(key=>!CONFIG_KEY_TREE.parallel.includes(key))||!Number.isInteger(parallel.gear))
|
|
285
|
+
throw new Error('Invalid config.yaml: parallel must be {gear: <integer>}.');
|
|
286
|
+
if(!gears.includes(parallel.gear))
|
|
287
|
+
throw new Error(`Invalid config.yaml: parallel.gear ${parallel.gear} is not declared by modules/models/runtimes.yaml allocation.slicing.gears (known: ${gears.join(', ')}).`);
|
|
288
|
+
};
|
|
289
|
+
const validateSupervisorBlock=(supervisor,profile)=>{
|
|
290
|
+
const interval=supervisor?.pollIntervalMs,repos=supervisor?.repos,stall=supervisor?.stallMinutes;
|
|
291
|
+
if(!plain(supervisor)||Object.keys(supervisor).some(key=>!CONFIG_KEY_TREE.supervisor.includes(key))||!(interval===null||interval===undefined||(Number.isInteger(interval)&&interval>=60000)))
|
|
292
|
+
throw new Error('Invalid config.yaml: supervisor must be {mode?, pollIntervalMs?, repos?, stallMinutes?, kernel?, workers?, landGate?, frozenMinutes?} with an integer of at least 60000 ms, or null.');
|
|
293
|
+
// mode: where the Supervisor role runs (scripts/machine/home.mjs supervisorMode) - chat (default: the owner's desktop
|
|
294
|
+
// chat session owns channel 'main' and ticks itself) or kernel (the optional [Supervisor] Orca kernel, start-supervisor.mjs).
|
|
295
|
+
if(!(supervisor.mode===undefined||supervisor.mode===null||['chat','kernel'].includes(supervisor.mode)))
|
|
296
|
+
throw new Error('Invalid config.yaml: supervisor.mode must be chat or kernel, or null.');
|
|
297
|
+
// The [Supervisor] kernel seat (scripts/machine/home.mjs supervisorSettings): kernel {agent?, model?, effort?}
|
|
298
|
+
// pins its agent (default: the kernel pin), workers {base?, max?} its adaptive [Worker] cap (0 to 10; the shipped default is 0 fix workers),
|
|
299
|
+
// landGate {mode?: shared|exclusive} the land gate (scripts/supervisor/land.mjs).
|
|
300
|
+
const seat=supervisor.kernel,workers=supervisor.workers,gate=supervisor.landGate;
|
|
301
|
+
if(seat!==undefined&&seat!==null)validateAgentSeat(seat,'supervisor.kernel',profile);
|
|
302
|
+
if(!(workers===undefined||workers===null||(plain(workers)&&Object.keys(workers).every(key=>['base','max'].includes(key)&&Number.isInteger(workers[key])&&workers[key]>=0&&workers[key]<=10))))
|
|
303
|
+
throw new Error('Invalid config.yaml: supervisor.workers must be {base?, max?} integers from 0 to 10, or null.');
|
|
304
|
+
if(!(gate===undefined||gate===null||(plain(gate)&&Object.keys(gate).every(key=>key==='mode'&&['shared','exclusive'].includes(gate.mode)))))
|
|
305
|
+
throw new Error('Invalid config.yaml: supervisor.landGate must be {mode?: shared|exclusive}, or null.');
|
|
306
|
+
// stallMinutes: scripts/supervisor/stall.mjs calls a running workflow STALLED after this many minutes with no progress.
|
|
307
|
+
// frozenMinutes: scripts/supervisor/supervisor-watchdog.mjs reads a busy seat frame with no turn progress for this long as frozen.
|
|
308
|
+
const frozen=supervisor.frozenMinutes;
|
|
309
|
+
if(!(frozen===undefined||frozen===null||(Number.isInteger(frozen)&&frozen>=1)))
|
|
310
|
+
throw new Error('Invalid config.yaml: supervisor.frozenMinutes must be an integer of at least 1, or null.');
|
|
311
|
+
if(!(stall===undefined||stall===null||(Number.isInteger(stall)&&stall>=5)))
|
|
312
|
+
throw new Error('Invalid config.yaml: supervisor.stallMinutes must be an integer of at least 5, or null.');
|
|
313
|
+
if(!(repos===undefined||repos===null||(Array.isArray(repos)&&repos.every(repo=>typeof repo==='string'&&repo.trim()))))
|
|
314
|
+
throw new Error('Invalid config.yaml: supervisor.repos must be a list of ledger-owner repository paths, or null.');
|
|
315
|
+
};
|
|
316
|
+
const validateDelegationBlock=d=>{if(!plain(d)||Object.keys(d).some(key=>!CONFIG_KEY_TREE.delegation.includes(key))||typeof d.asks!=='string'||!d.asks.trim()||typeof d.until!=='string'||Number.isNaN(Date.parse(d.until))||(d.excludes!==undefined&&(!Array.isArray(d.excludes)||d.excludes.some(x=>typeof x!=='string'))))throw new Error('Invalid config.yaml: delegation must be {asks: <delegate>, until: <ISO time>, excludes?: [<class>], note?} or null.');};
|
|
317
|
+
const validateBudgetsBlock=budgets=>{if(!plain(budgets)||Object.keys(budgets).some(key=>!CONFIG_KEY_TREE.budgets.includes(key))||Object.values(budgets).some(value=>value!==null&&!(Number.isInteger(value)&&value>0)))throw new Error('Invalid config.yaml: budgets must be {maxOps?} with positive-integer-or-null values.');};
|
|
318
|
+
const validateRootKeys=(config)=>{
|
|
319
|
+
const allowed=new Set(CONFIG_BLOCKS);
|
|
320
|
+
if(!plain(config)||Object.keys(config).some(key=>!allowed.has(key))||typeof config.language!=='string'||!/^[a-z]{2,3}(?:-[A-Za-z0-9]+)*$/.test(config.language)||!(config.model===null||typeof config.model==='string'&&config.model.trim())||!EFFORT_LEVELS.has(config.effort))
|
|
321
|
+
throw new Error('Invalid config.yaml: expected language, model, effort and the closed set of config blocks.');
|
|
322
|
+
};
|
|
323
|
+
const validateEarlyConfigBlocks=(config)=>{
|
|
324
|
+
if(config?.launchTrust!==undefined){launchTrustSettings(config);} if(config?.retention!==undefined){workflowPurgeSettings(config);}
|
|
325
|
+
if(config?.connectors!==undefined){validateConnectors(config.connectors);} if(config?.asks!==undefined){validateAsks(config.asks);}
|
|
326
|
+
if(config?.uat!==undefined){validateUat(config.uat);} if(config?.debugLoop!==undefined){validateDebugLoop(config.debugLoop);}
|
|
327
|
+
if(config?.orca!==undefined){validateOrca(config.orca);} if(config?.roots!==undefined){validateRoots(config.roots);} if(config?.resources!==undefined){validateResources(config.resources);} if(config?.sonar!==undefined){validateSonar(config.sonar);} if(config?.release!==undefined){validateRelease(config.release);}
|
|
328
|
+
};
|
|
329
|
+
const validateConfigBlocks=(config,knownProviders,runtimes,profile)=>{
|
|
309
330
|
// specs (owner 2026-09-28): {harness?, unit?, e2e?} booleans - each family a boolean; absent = its default (SPEC_DEFAULTS: harness off, unit on, e2e off; specsSettings).
|
|
310
|
-
if(config?.specs!==undefined&&config.specs!==null&&(!plain(config.specs)||Object.keys(config.specs).some(key=>!
|
|
331
|
+
if(config?.specs!==undefined&&config.specs!==null&&(!plain(config.specs)||Object.keys(config.specs).some(key=>!CONFIG_KEY_TREE.specs.includes(key)||typeof config.specs[key]!=='boolean')))throw new Error(`Invalid config.yaml: specs must be {${SPEC_FAMILIES.map(k=>k+'?: boolean').join(', ')}}, or null.`);
|
|
311
332
|
// reconciler (scripts/reconciler/state.mjs reconcilerConfig): {enabled?: boolean, profile?: operational|observe, controllers?: {<name>: {mode: off|shadow|active}}}, or null.
|
|
312
|
-
if(config?.reconciler!==undefined&&config.reconciler!==null){
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
if(config?.kernel!==undefined)validateAgentSeat(config.kernel,'kernel',profile);
|
|
326
|
-
if(config?.parallel!==undefined){
|
|
327
|
-
const parallel=config.parallel,gears=slicingGears();
|
|
328
|
-
if(!plain(parallel)||Object.keys(parallel).some(key=>key!=='gear')||!Number.isInteger(parallel.gear))
|
|
329
|
-
throw Error('Invalid config.yaml: parallel must be {gear: <integer>}.');
|
|
330
|
-
if(!gears.includes(parallel.gear))
|
|
331
|
-
throw Error(`Invalid config.yaml: parallel.gear ${parallel.gear} is not declared by modules/models/runtimes.yaml allocation.slicing.gears (known: ${gears.join(', ')}).`);
|
|
332
|
-
}
|
|
333
|
-
if(config?.supervisor!==undefined){
|
|
334
|
-
const supervisor=config.supervisor,interval=supervisor?.pollIntervalMs,repos=supervisor?.repos,stall=supervisor?.stallMinutes;
|
|
335
|
-
if(!plain(supervisor)||Object.keys(supervisor).some(key=>!['mode','pollIntervalMs','repos','stallMinutes','kernel','workers','landGate','frozenMinutes'].includes(key))||!(interval===null||interval===undefined||(Number.isInteger(interval)&&interval>=60000)))
|
|
336
|
-
throw Error('Invalid config.yaml: supervisor must be {mode?, pollIntervalMs?, repos?, stallMinutes?, kernel?, workers?, landGate?, frozenMinutes?} with an integer of at least 60000 ms, or null.');
|
|
337
|
-
// mode: where the Supervisor role runs (scripts/machine/home.mjs supervisorMode) - chat (default: the owner's desktop
|
|
338
|
-
// chat session owns channel 'main' and ticks itself) or kernel (the optional [Supervisor] Orca kernel, start-supervisor.mjs).
|
|
339
|
-
if(!(supervisor.mode===undefined||supervisor.mode===null||['chat','kernel'].includes(supervisor.mode)))
|
|
340
|
-
throw Error('Invalid config.yaml: supervisor.mode must be chat or kernel, or null.');
|
|
341
|
-
// The [Supervisor] kernel seat (scripts/machine/home.mjs supervisorSettings): kernel {agent?, model?, effort?}
|
|
342
|
-
// pins its agent (default: the kernel pin), workers {base?, max?} its adaptive [Worker] cap (max <= 10),
|
|
343
|
-
// landGate {mode?: shared|exclusive, push?} the land gate (scripts/supervisor/land.mjs).
|
|
344
|
-
const seat=supervisor.kernel,workers=supervisor.workers,gate=supervisor.landGate;
|
|
345
|
-
if(seat!==undefined&&seat!==null)validateAgentSeat(seat,'supervisor.kernel',profile);
|
|
346
|
-
if(!(workers===undefined||workers===null||(plain(workers)&&Object.keys(workers).every(key=>['base','max'].includes(key)&&Number.isInteger(workers[key])&&workers[key]>=1&&workers[key]<=10))))
|
|
347
|
-
throw Error('Invalid config.yaml: supervisor.workers must be {base?, max?} integers from 1 to 10, or null.');
|
|
348
|
-
if(!(gate===undefined||gate===null||(plain(gate)&&Object.keys(gate).every(key=>(key==='mode'&&['shared','exclusive'].includes(gate.mode))||(key==='push'&&typeof gate.push==='boolean')))))
|
|
349
|
-
throw Error('Invalid config.yaml: supervisor.landGate must be {mode?: shared|exclusive, push?: boolean}, or null.');
|
|
350
|
-
// stallMinutes: scripts/supervisor/stall.mjs calls a running workflow STALLED after this many minutes with no progress.
|
|
351
|
-
// frozenMinutes: scripts/supervisor/supervisor-watchdog.mjs reads a busy seat frame with no turn progress for this long as frozen.
|
|
352
|
-
const frozen=supervisor.frozenMinutes;
|
|
353
|
-
if(!(frozen===undefined||frozen===null||(Number.isInteger(frozen)&&frozen>=1)))
|
|
354
|
-
throw Error('Invalid config.yaml: supervisor.frozenMinutes must be an integer of at least 1, or null.');
|
|
355
|
-
if(!(stall===undefined||stall===null||(Number.isInteger(stall)&&stall>=5)))
|
|
356
|
-
throw Error('Invalid config.yaml: supervisor.stallMinutes must be an integer of at least 5, or null.');
|
|
357
|
-
if(!(repos===undefined||repos===null||(Array.isArray(repos)&&repos.every(repo=>typeof repo==='string'&&repo.trim()))))
|
|
358
|
-
throw Error('Invalid config.yaml: supervisor.repos must be a list of ledger-owner repository paths, or null.');
|
|
359
|
-
}
|
|
360
|
-
if(config?.delegation!==undefined&&config.delegation!==null){
|
|
361
|
-
const d=config.delegation;
|
|
362
|
-
if(!plain(d)||Object.keys(d).some(key=>!['asks','until','excludes','note'].includes(key))||typeof d.asks!=='string'||!d.asks.trim()||typeof d.until!=='string'||Number.isNaN(Date.parse(d.until))||(d.excludes!==undefined&&(!Array.isArray(d.excludes)||d.excludes.some(x=>typeof x!=='string'))))
|
|
363
|
-
throw Error('Invalid config.yaml: delegation must be {asks: <delegate>, until: <ISO time>, excludes?: [<class>], note?} or null.');
|
|
364
|
-
}
|
|
365
|
-
if(config?.budgets!==undefined){
|
|
366
|
-
const budgets=config.budgets;
|
|
367
|
-
if(!plain(budgets)||Object.keys(budgets).some(key=>!['maxOps'].includes(key))||Object.values(budgets).some(value=>value!==null&&!(Number.isInteger(value)&&value>0)))
|
|
368
|
-
throw Error('Invalid config.yaml: budgets must be {maxOps?} with positive-integer-or-null values.');
|
|
369
|
-
}
|
|
370
|
-
if(!plain(config)||Object.keys(config).some(key=>!allowed.includes(key))||typeof config.language!=='string'||!/^[a-z]{2,3}(?:-[A-Za-z0-9]+)*$/.test(config.language)||!(config.model===null||typeof config.model==='string'&&config.model.trim())||!EFFORT_LEVELS.includes(config.effort)||!plain(models)||Object.keys(models).some(key=>!['pools','nonOperation','selection'].includes(key))||models.selection!=='quota-aware'||!plain(models.pools)||!plain(models.nonOperation)||Object.keys(models.pools).length!==Object.keys(DEFAULT_MODEL_POOLS).length||Object.keys(models.pools).some(key=>!Object.hasOwn(DEFAULT_MODEL_POOLS,key))||Object.keys(models.nonOperation).length!==Object.keys(NON_OPERATION_ROLES).length||Object.keys(models.nonOperation).some(key=>!Object.hasOwn(NON_OPERATION_ROLES,key)))throw Error('Invalid config.yaml: expected language, model, effort and the closed quota-aware model pools/non-operation role map.');
|
|
371
|
-
for(const [pool,members] of Object.entries(models.pools))if(!Array.isArray(members)||members.length!==2||new Set(members).size!==2||members.some(id=>typeof id!=='string'||!plain(runtimes[id]))||!(members.length===DEFAULT_MODEL_POOLS[pool].length&&members.every(id=>DEFAULT_MODEL_POOLS[pool].includes(id))))throw Error(`Invalid config.yaml: models.pools.${pool} must contain its canonical pair of two unique known runtime ids.`);
|
|
372
|
-
for(const [role,required] of Object.entries(NON_OPERATION_ROLES)){const pool=models.nonOperation[role],members=models.pools[pool];if(typeof pool!=='string'||!members||members.some(id=>!runtimes[id].roles?.includes(required)))throw Error(`Invalid config.yaml: models.nonOperation.${role} must name a pool whose members carry the ${required} role.`);}
|
|
333
|
+
if(config?.reconciler!==undefined&&config.reconciler!==null){validateReconcilerBlock(config.reconciler);} if(config?.allocation!==undefined){validateAllocationBlock(config.allocation,runtimes);}
|
|
334
|
+
if(config?.kernel!==undefined){validateAgentSeat(config.kernel,'kernel',profile);} if(config?.parallel!==undefined){validateParallelBlock(config.parallel);}
|
|
335
|
+
if(config?.supervisor!==undefined){validateSupervisorBlock(config.supervisor,profile);} if(config?.delegation!==undefined&&config.delegation!==null){validateDelegationBlock(config.delegation);} if(config?.budgets!==undefined){validateBudgetsBlock(config.budgets);}
|
|
336
|
+
};
|
|
337
|
+
export function validateConfig(config){
|
|
338
|
+
const profile=runtimeProfile(),runtimes=profile?.runtimes??{};
|
|
339
|
+
refuseRemovedKeys(config);
|
|
340
|
+
validateEarlyConfigBlocks(config);
|
|
341
|
+
const knownProviders=new Set(Object.values(runtimes).map(runtime=>runtime?.provider).filter(Boolean));
|
|
342
|
+
validateConfigBlocks(config,knownProviders,runtimes,profile);
|
|
343
|
+
validateRootKeys(config);
|
|
344
|
+
validateModelsBlock(config,profile);
|
|
373
345
|
return config;
|
|
374
346
|
}
|
|
375
|
-
export function effectiveNonOperationModels(config=loadConfig()){const models=validateConfig(config).models;return Object.fromEntries(Object.keys(NON_OPERATION_ROLES).map(role=>[role,{pool:models.nonOperation[role],runtimes:[...models.pools[models.nonOperation[role]]],selection:models.selection}]));}
|
|
376
347
|
/**
|
|
377
|
-
* The owner allocation control
|
|
378
|
-
*
|
|
348
|
+
* The owner allocation control: `allocation.grants` only. null = the owner declared no grants list: grant-gated pools
|
|
349
|
+
* keep their ungated routing; a declared list, even [], is the whole set of grants.
|
|
379
350
|
*/
|
|
380
351
|
export function configuredAllocationPolicy(config=loadConfig()){
|
|
381
352
|
validateConfig(config);
|
|
382
353
|
const allocation=plain(config.allocation)?config.allocation:null;
|
|
383
|
-
// null = the owner declared no grants list: grant-gated pools keep their pre-grant (ungated) routing.
|
|
384
|
-
// A declared list, even [], is the whole set of grants.
|
|
385
354
|
const grants=Array.isArray(allocation?.grants)
|
|
386
355
|
?Object.fromEntries(allocation.grants.map(parseAllocationGrant).map(({pool,slots,roles})=>[pool,{slots,roles}]))
|
|
387
356
|
:null;
|
|
388
|
-
return {
|
|
389
|
-
mode:ADAPTIVE_ALLOCATION_MODE,
|
|
390
|
-
preferredProvider:allocation?.preferredProvider??null,
|
|
391
|
-
// null = the runtimes.yaml allocation.policy default
|
|
392
|
-
policy:allocation?.policy??null,
|
|
393
|
-
shares:allocation?.shares?{...allocation.shares}:null,
|
|
394
|
-
windowHours:allocation?.windowHours??DEFAULT_ALLOCATION_WINDOW_HOURS,
|
|
395
|
-
grants,
|
|
396
|
-
source:allocation?'allocation':'default',
|
|
397
|
-
};
|
|
357
|
+
return {grants,source:allocation?'allocation':'default'};
|
|
398
358
|
}
|
|
399
|
-
|
|
359
|
+
/** The variable that confines the owner's `config.yaml` to a directory tree: set, an owner file is read only from under that directory (tests/setup/isolated-temp.mjs points it at a spec's own temp root). */
|
|
360
|
+
export const OWNER_CONFIG_WITHIN_ENV='STARCI_OWNER_CONFIG_WITHIN';
|
|
361
|
+
const foldPath=p=>process.platform==='win32'?path.resolve(p).toLowerCase():path.resolve(p);
|
|
362
|
+
/**
|
|
363
|
+
* Whether the owner's `config.yaml` under `root` is visible to this process. Unconfined (the variable unset) every owner file is visible; confined, only the files under the named
|
|
364
|
+
* directory, where a fixture wrote them, so the checkout's live file (roots.temp, supervisor.landGate, launch trust) never decides a result and a lane clone, the release host and a
|
|
365
|
+
* clean checkout run the same suite. The engine knows nothing of why a caller confines it: the spec preload sets the variable.
|
|
366
|
+
*/
|
|
367
|
+
const ownerFileVisible=(root,env=process.env)=>{
|
|
368
|
+
const within=env[OWNER_CONFIG_WITHIN_ENV];
|
|
369
|
+
if(!within)return true;
|
|
370
|
+
const rel=path.relative(foldPath(within),foldPath(root));
|
|
371
|
+
return !rel.startsWith('..')&&!path.isAbsolute(rel);
|
|
372
|
+
};
|
|
400
373
|
/** The validated config one yaml file holds, or null when the file is absent. */
|
|
401
374
|
const readYamlConfig=(root,name)=>{const yaml=path.join(root,name);return fs.existsSync(yaml)?validateConfig(parseYaml(fs.readFileSync(yaml,'utf8'))):null;};
|
|
402
|
-
function readExample(root=configRoot){const example=readYamlConfig(root,'config.example.yaml');if(example!==null)return example;throw Error('Missing config.example.yaml');}
|
|
375
|
+
function readExample(root=configRoot){const example=readYamlConfig(root,'config.example.yaml');if(example!==null){return example;}throw new Error('Missing config.example.yaml');}
|
|
403
376
|
/**
|
|
404
377
|
* The owner config reader: `config.yaml` is the per-project file (gitignored,
|
|
405
378
|
* seeded verbatim from `config.example.yaml` by the installer — comments and
|
|
406
379
|
* all). Returns the validated owner config, or null when that file does not
|
|
407
380
|
* exist; falling back to the example's defaults is `loadConfig`.
|
|
408
381
|
*/
|
|
409
|
-
function readOwnerConfig(root=configRoot){return readYamlConfig(root,'config.yaml');}
|
|
382
|
+
function readOwnerConfig(root=configRoot){return ownerFileVisible(root)?readYamlConfig(root,'config.yaml'):null;}
|
|
410
383
|
/**
|
|
411
384
|
* The tolerant read the kernel boot and the router share: an owner file that is absent, unparsable or
|
|
412
385
|
* short of the closed schema must never stop a workflow from routing. Returns
|
|
@@ -416,7 +389,7 @@ function readOwnerConfig(root=configRoot){return readYamlConfig(root,'config.yam
|
|
|
416
389
|
*/
|
|
417
390
|
export function inspectOwnerConfig(root=configRoot){
|
|
418
391
|
const file=path.join(root,'config.yaml');
|
|
419
|
-
if(!fs.existsSync(file))return {file,config:null,error:null,invalid:null};
|
|
392
|
+
if(!ownerFileVisible(root)||!fs.existsSync(file))return {file,config:null,error:null,invalid:null};
|
|
420
393
|
let parsed;
|
|
421
394
|
try{parsed=parseYaml(fs.readFileSync(file,'utf8'))??null;}
|
|
422
395
|
catch(error){return {file,config:null,error:`config.yaml unparsable: ${error.message}`,invalid:null};}
|
|
@@ -437,32 +410,42 @@ export function inspectOwnerConfig(root=configRoot){
|
|
|
437
410
|
* An absent, null or unreadable owner file reads as the defaults: harness off, unit on, e2e off.
|
|
438
411
|
*/
|
|
439
412
|
const SPEC_FAMILIES=Object.freeze(['harness','unit','e2e']);
|
|
413
|
+
const SEAT_KEYS=Object.freeze(['agent','model','effort']);
|
|
414
|
+
/** The keys each config block accepts directly under it (the validators read these lists; docs/config-format.md and the example are checked against them). Blocks whose keys are open or deeper than this are not listed. */
|
|
415
|
+
export const CONFIG_KEY_TREE=Object.freeze({
|
|
416
|
+
models:MODELS_KEYS,allocation:Object.freeze(['grants']),kernel:SEAT_KEYS,budgets:Object.freeze(['maxOps']),parallel:Object.freeze(['gear']),
|
|
417
|
+
supervisor:Object.freeze(['mode','pollIntervalMs','repos','stallMinutes','kernel','workers','landGate','frozenMinutes']),
|
|
418
|
+
delegation:Object.freeze(['asks','until','excludes','note']),asks:Object.freeze(['autoAcceptRecommended','excludes']),uat:Object.freeze(['maxConcurrent']),
|
|
419
|
+
specs:SPEC_FAMILIES,reconciler:Object.freeze(['enabled','profile','controllers']),debugLoop:Object.freeze(['interval','worktreeLimit']),
|
|
420
|
+
orca:ORCA_KEYS,roots:ROOT_KEYS,resources:RESOURCE_KEYS,release:RELEASE_KEYS,
|
|
421
|
+
});
|
|
440
422
|
export const SPEC_DEFAULTS=Object.freeze({harness:false,unit:true,e2e:false});
|
|
441
423
|
export function specsSettings(config){const specs=plain(config?.specs)?config.specs:{};return Object.fromEntries(SPEC_FAMILIES.map(key=>[key,typeof specs[key]==='boolean'?specs[key]:SPEC_DEFAULTS[key]]));}
|
|
442
424
|
/** specs.harness of the owner file under `root` (tolerant read: inspectOwnerConfig): true only when the owner opted in to `--specs all`. */
|
|
443
425
|
export function harnessSpecsEnabled(root=configRoot){return specsSettings(inspectOwnerConfig(root).config).harness;}
|
|
444
426
|
/**
|
|
445
|
-
* config.yaml `
|
|
446
|
-
* interval <n>s | <n>m | <n>h — the
|
|
427
|
+
* config.yaml `debugLoop` (skills/starci, scripts/debug/digest): {interval?, worktreeLimit?}, each optional.
|
|
428
|
+
* interval <n>s | <n>m | <n>h — the cadence of the chat /loop that runs `starci debug digest`.
|
|
447
429
|
* worktreeLimit integer >= 1 — more registered worktrees than this in one repository is a core-watch alert.
|
|
448
|
-
* Both keys are required when the block is present; code carries no default (config.example.yaml does).
|
|
449
430
|
*/
|
|
450
|
-
export const DURATION_PATTERN=/^(\d+)(
|
|
431
|
+
export const DURATION_PATTERN=/^(\d+)([smh])$/;
|
|
432
|
+
export const DEBUG_LOOP_DEFAULTS=Object.freeze({interval:'10m',worktreeLimit:40});
|
|
451
433
|
/** '10m' | '90s' | '1h' in milliseconds, or null for anything else (zero included). */
|
|
452
434
|
export function durationMs(text){const m=DURATION_PATTERN.exec(String(text??'').trim());const ms=m?Number(m[1])*{s:1000,m:60000,h:3600000}[m[2]]:0;return ms>0?ms:null;}
|
|
453
|
-
function
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
if(
|
|
435
|
+
function validateDebugLoop(block){
|
|
436
|
+
if(block===null)return;
|
|
437
|
+
const bad=invalid('debugLoop');
|
|
438
|
+
if(!plain(block))bad(' must be {interval?: <n>s|<n>m|<n>h, worktreeLimit?: <integer >= 1>} or null.');
|
|
439
|
+
for(const key of Object.keys(block))if(!CONFIG_KEY_TREE.debugLoop.includes(key))bad(` has unknown key ${key} (allowed: ${CONFIG_KEY_TREE.debugLoop.join(', ')}).`);
|
|
440
|
+
if(block.interval!==undefined&&durationMs(block.interval)===null)bad('.interval must be <n>s, <n>m or <n>h with n >= 1 (e.g. 10m).');
|
|
441
|
+
if(block.worktreeLimit!==undefined&&!(Number.isInteger(block.worktreeLimit)&&block.worktreeLimit>=1))bad('.worktreeLimit must be an integer >= 1.');
|
|
459
442
|
}
|
|
460
|
-
/** The owner's
|
|
461
|
-
export function
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
return {interval
|
|
443
|
+
/** The owner's debug-loop settings: {interval, intervalMs, worktreeLimit}; an absent block or key is the default. */
|
|
444
|
+
export function debugLoopSettings(config=loadConfig()){
|
|
445
|
+
validateDebugLoop(config?.debugLoop??null);
|
|
446
|
+
const block=plain(config?.debugLoop)?config.debugLoop:{};
|
|
447
|
+
const interval=block.interval??DEBUG_LOOP_DEFAULTS.interval;
|
|
448
|
+
return {interval,intervalMs:durationMs(interval),worktreeLimit:block.worktreeLimit??DEBUG_LOOP_DEFAULTS.worktreeLimit};
|
|
466
449
|
}
|
|
467
450
|
/** The owner config of `root` (config.yaml), else the shipped example. The installer seeds config.yaml (scripts/install/install.mjs seedConfig); this reader never writes. */
|
|
468
451
|
export function loadConfig(root=configRoot){
|
|
@@ -470,7 +453,7 @@ export function loadConfig(root=configRoot){
|
|
|
470
453
|
}
|
|
471
454
|
|
|
472
455
|
/** The owner's standing delegation of ask answers (config.yaml `delegation`), or null when absent or expired. */
|
|
473
|
-
export function activeDelegation(config=loadConfig(),now=Date.now()){const d=config?.delegation;if(!d||Date.parse(d.until)<=now)return null;return {asks:d.asks,until:d.until,excludes:d.excludes??[],note:d.note??null};}
|
|
456
|
+
export function activeDelegation(config=loadConfig(),now=Date.now()){const d=config?.delegation;if(!d||Date.parse(d.until)<=now){return null;}return {asks:d.asks,until:d.until,excludes:d.excludes??[],note:d.note??null};}
|
|
474
457
|
|
|
475
458
|
/**
|
|
476
459
|
* The owner's auto-accept policy for recommended asks (config.yaml `asks`): {autoAcceptRecommended,
|