opencode-model-router 2.9.1 → 2.11.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 (59) hide show
  1. package/CHANGELOG.md +482 -0
  2. package/README.md +4 -2
  3. package/package.json +12 -5
  4. package/src/compat/background.ts +56 -19
  5. package/src/compat/child-history.ts +134 -0
  6. package/src/compat/child-report.ts +185 -0
  7. package/src/compat/child-session.ts +10 -0
  8. package/src/compat/session-lookup.ts +21 -0
  9. package/src/compat/v2-client.ts +124 -6
  10. package/src/compat/v2-hooks.ts +525 -203
  11. package/src/compat/v2-observations.ts +1 -0
  12. package/src/compat/v2-vocabulary.ts +14 -0
  13. package/src/executor/create.ts +47 -28
  14. package/src/executor/git.ts +226 -30
  15. package/src/executor/integrate/checks.ts +29 -11
  16. package/src/executor/integrate/land.ts +32 -2
  17. package/src/executor/integrate/queue.ts +95 -13
  18. package/src/executor/ledger.ts +16 -12
  19. package/src/executor/lfs-restore.ts +492 -0
  20. package/src/executor/paths.ts +7 -2
  21. package/src/executor/recovery.ts +2 -1
  22. package/src/executor/runtime.ts +1062 -243
  23. package/src/executor/slots/pool.ts +120 -19
  24. package/src/executor/slots/provision.ts +111 -23
  25. package/src/executor/slots/root.ts +81 -0
  26. package/src/executor/types.ts +28 -2
  27. package/src/executor/unattended.ts +6 -1
  28. package/src/executor/verify-trees.ts +507 -0
  29. package/src/guard/enforce.ts +2 -1
  30. package/src/guard/fingerprint.ts +9 -0
  31. package/src/guard/guards.ts +7 -1
  32. package/src/index.ts +191 -31
  33. package/src/router/answer-dedup.ts +198 -0
  34. package/src/router/common-dir.ts +241 -0
  35. package/src/router/config.ts +228 -40
  36. package/src/router/diff-handles.ts +322 -0
  37. package/src/router/diff-summary.ts +318 -0
  38. package/src/router/git-metadata-guard.ts +317 -0
  39. package/src/router/git-tools.ts +1136 -49
  40. package/src/router/read-only.ts +37 -13
  41. package/src/router/role-agents.ts +100 -36
  42. package/src/router/run-summary.ts +253 -0
  43. package/src/router/run-tools.ts +177 -25
  44. package/src/router/sessions.ts +23 -1
  45. package/src/router/tool-paths.ts +62 -4
  46. package/src/routing/classify/rules.ts +93 -14
  47. package/src/routing/roles/read-set.ts +10 -1
  48. package/src/routing/roles/work-root.ts +20 -3
  49. package/src/routing/wire/hint.ts +9 -2
  50. package/src/v2.ts +3 -1
  51. package/src/verify/exec.ts +454 -2
  52. package/src/verify/head.ts +6 -1
  53. package/src/verify/pending.ts +14 -1
  54. package/src/verify/plan-task.ts +86 -26
  55. package/src/verify/reference.ts +60 -7
  56. package/src/verify/runner.ts +14 -6
  57. package/src/verify/tree.ts +34 -10
  58. package/src/verify/types.ts +44 -0
  59. package/src/verify/wiring.ts +134 -22
@@ -573,6 +573,20 @@ export function setConfigNoticeHost(host: RouterHost | undefined): void {
573
573
  configNoticeHost = host;
574
574
  }
575
575
 
576
+ /** The host the configs of this process are built for (#80); `undefined` until the v2 entry sets it, built as on v1. */
577
+ let configBuildHost: RouterHost | undefined;
578
+
579
+ /**
580
+ * #80: set by the OpenCode v2 entry (src/v2.ts) before its first loadConfig(). On `v2` a `null` inside an override layer's
581
+ * `presets` removes the inherited key (see {@link mergeLayerData}); otherwise, as on v1, that `null` is a value, which
582
+ * validation refuses and the key-path drop removes with a notice. A change marks every cached config stale.
583
+ */
584
+ export function setConfigBuildHost(host: RouterHost | undefined): void {
585
+ if (host === configBuildHost) return;
586
+ configBuildHost = host;
587
+ invalidateConfigCache();
588
+ }
589
+
576
590
  /**
577
591
  * The notices of the config last built for `dir` (default: the working
578
592
  * directory): keys dropped from the project layer, unknown `routing` keys, and
@@ -1960,11 +1974,13 @@ function tolerantRange(
1960
1974
  }
1961
1975
 
1962
1976
  /**
1963
- * Repo-independent rules for `routing.executor.slotsDir`: an absolute drive path (`C:\…`), not a
1964
- * drive root, not UNC / device, and free of `*`. Returns the problem, or `undefined` when valid.
1965
- * The repository-relative rules are {@link validateSlotsDir}.
1977
+ * Repo-independent rules for `routing.executor.slotsDir` on `platform`. win32: an absolute drive path
1978
+ * (`C:\…`), not a drive root, not UNC / device, and free of `*`. POSIX (#192): an absolute path, not `/`,
1979
+ * without `//`, `*`, a `.`/`..` segment or a control character. Returns the problem, or `undefined`
1980
+ * when valid. The repository-relative rules are {@link validateSlotsDir}.
1966
1981
  */
1967
- export function slotsDirProblem(value: string): string | undefined {
1982
+ export function slotsDirProblem(value: string, platform: NodeJS.Platform): string | undefined {
1983
+ if (platform !== "win32") return posixSlotsDirProblem(value);
1968
1984
  if (value.includes("*")) return "must not contain '*'";
1969
1985
  if (/^[\\/]{2}/.test(value)) return "must not be a UNC or device path";
1970
1986
  if (!/^[A-Za-z]:[\\/]/.test(value)) return "must be an absolute path on a drive (like C:\\.omr-slots)";
@@ -1977,6 +1993,22 @@ export function slotsDirProblem(value: string): string | undefined {
1977
1993
  return undefined;
1978
1994
  }
1979
1995
 
1996
+ /** #192: the stored text of a `slotsDir`: on POSIX without a trailing `/` (`/` itself is kept); win32 as written. */
1997
+ export function slotsDirText(value: string, platform: NodeJS.Platform): string {
1998
+ return platform === "win32" ? value : value.replace(/^(.+?)\/+$/, "$1");
1999
+ }
2000
+
2001
+ /** The POSIX rules of {@link slotsDirProblem} (as the text rules of a work root, `rootTextProblem`). */
2002
+ function posixSlotsDirProblem(value: string): string | undefined {
2003
+ if (value.includes("*")) return "must not contain '*'";
2004
+ if (/[\u0000-\u001f\u007f]/.test(value)) return "must not contain a control character";
2005
+ if (!value.startsWith("/")) return "must be an absolute path (like /home/me/.omr-slots)";
2006
+ if (value.includes("//")) return "must not contain '//'";
2007
+ if (value === "/") return "must not be the filesystem root";
2008
+ if (value.split("/").some((s) => s === "." || s === "..")) return "must not have a '.' or '..' segment";
2009
+ return undefined;
2010
+ }
2011
+
1980
2012
  /**
1981
2013
  * Resolve links of the longest existing prefix of `p`; the missing tail is appended unchanged.
1982
2014
  * `realpathSync.native` (QA-4.1-4): on win32 it also resolves junctions and 8.3 short names.
@@ -2006,7 +2038,7 @@ export type SlotsDirCheck = { readonly ok: true } | { readonly ok: false; readon
2006
2038
  * realpaths (junctions, 8.3 names resolved) are compared, case-insensitively on win32.
2007
2039
  */
2008
2040
  export function validateSlotsDir(slotsDir: string, toplevel: string): SlotsDirCheck {
2009
- const base = slotsDirProblem(slotsDir);
2041
+ const base = slotsDirProblem(slotsDir, process.platform);
2010
2042
  if (base !== undefined) return { ok: false, reason: base };
2011
2043
  const fold = (p: string): string => (process.platform === "win32" ? p.toLowerCase() : p);
2012
2044
  const pathApi = process.platform === "win32" ? win32 : posix;
@@ -2081,11 +2113,13 @@ function sanitizeExecutor(value: unknown): TolerantBlock<ExecutorOverrides> {
2081
2113
  const land = tolerantEnum(value, "land", p, EXECUTOR_LAND_MODES, d.land, issues);
2082
2114
  if (land !== undefined) out.land = land;
2083
2115
 
2084
- const slotsDir = value.slotsDir;
2085
- if (slotsDir !== undefined) {
2086
- const problem = slotsDir === null ? undefined : typeof slotsDir !== "string" ? "must be a string or null" : slotsDirProblem(slotsDir);
2116
+ const rawSlotsDir = value.slotsDir;
2117
+ if (rawSlotsDir !== undefined) {
2118
+ // #192: on POSIX a trailing `/` is dropped before the rules and storage, so the pool and the role-agent grant see one name.
2119
+ const slotsDir = typeof rawSlotsDir === "string" ? slotsDirText(rawSlotsDir, process.platform) : rawSlotsDir;
2120
+ const problem = slotsDir === null ? undefined : typeof slotsDir !== "string" ? "must be a string or null" : slotsDirProblem(slotsDir, process.platform);
2087
2121
  if (problem === undefined) out.slotsDir = slotsDir as string | null;
2088
- else issues.push(`${p}.slotsDir ${problem} (got ${showTolerant(slotsDir)}); using ${d.slotsDir}`);
2122
+ else issues.push(`${p}.slotsDir ${problem} (got ${showTolerant(rawSlotsDir)}); using ${d.slotsDir}`);
2089
2123
  }
2090
2124
 
2091
2125
  const checks = value.integrationChecks;
@@ -2538,9 +2572,12 @@ export function validateConfig(raw: unknown): RouterConfig {
2538
2572
  * Recursively merge `override` onto `base`. Plain objects merge key-by-key;
2539
2573
  * arrays and scalars are replaced wholesale (so e.g. an overridden `rules` or
2540
2574
  * `whenToUse` list replaces rather than appends). `undefined` values in the
2541
- * override are skipped so they never blow away a base value.
2575
+ * override are skipped so they never blow away a base value. With
2576
+ * `nullRemoves` (#80), a `null` in the override removes the key from the
2577
+ * result instead, at every depth, and one with nothing to remove leaves no
2578
+ * trace; an array is still replaced as a whole, `null` entries included.
2542
2579
  */
2543
- export function deepMerge(base: unknown, override: unknown): unknown {
2580
+ export function deepMerge(base: unknown, override: unknown, options: { nullRemoves?: boolean } = {}): unknown {
2544
2581
  if (!isPlainObject(base) || !isPlainObject(override)) {
2545
2582
  return override;
2546
2583
  }
@@ -2553,6 +2590,14 @@ export function deepMerge(base: unknown, override: unknown): unknown {
2553
2590
  // already do worse, so this is tidiness rather than a boundary, but a merge
2554
2591
  // helper should not be the thing that reparents an object.
2555
2592
  if (key === "__proto__" || key === "constructor") continue;
2593
+ if (options.nullRemoves === true) {
2594
+ const inherited = Object.hasOwn(result, key) ? result[key] : undefined;
2595
+ if (value === null) delete result[key];
2596
+ // An object with nothing to merge into is merged into `{}`, so a `null` inside it is dropped as well.
2597
+ else if (isPlainObject(value)) result[key] = deepMerge(isPlainObject(inherited) ? inherited : {}, value, options);
2598
+ else result[key] = value;
2599
+ continue;
2600
+ }
2556
2601
  result[key] =
2557
2602
  key in result && isPlainObject(result[key]) && isPlainObject(value)
2558
2603
  ? deepMerge(result[key], value)
@@ -3253,9 +3298,23 @@ function boundProjectExecutor(
3253
3298
  return out;
3254
3299
  }
3255
3300
 
3301
+ /**
3302
+ * #80: `data` deep-merged onto `lower`. On OpenCode v2 ({@link setConfigBuildHost}) a `null` inside the layer's `presets` (a
3303
+ * preset, a tier, a tier key, at any depth) removes that key from the result, so a layer can drop what it inherits
3304
+ * (`"effort": null` on a bundled tier); validation and the key-path drop then judge the result like any other. Outside
3305
+ * `presets`, and on v1, a `null` is a value as before: several keys take `null` as a setting
3306
+ * (`enforcement.maxDelegationDepth`, `enforcement.verify.graderTemperature`, …), and inside `presets` no key does.
3307
+ */
3308
+ function mergeLayerData(lower: unknown, data: Record<string, unknown>): unknown {
3309
+ const merged = deepMerge(lower, data);
3310
+ if (configBuildHost !== "v2" || !isPlainObject(merged) || !isPlainObject(data.presets)) return merged;
3311
+ const lowerPresets = isPlainObject(lower) ? lower.presets : undefined;
3312
+ return { ...merged, presets: deepMerge(isPlainObject(lowerPresets) ? lowerPresets : {}, data.presets, { nullRemoves: true }) };
3313
+ }
3314
+
3256
3315
  /** Merge an override while keeping project classifier budgets and executor keys within the lower layers' bounds. */
3257
3316
  function mergeOverrideLayer(lower: unknown, layer: OverrideLayer, notices: ConfigNotice[]): unknown {
3258
- const merged = deepMerge(lower, layer.data);
3317
+ const merged = mergeLayerData(lower, layer.data);
3259
3318
  if (!layer.project || !isPlainObject(merged) || !isPlainObject(merged.routing)) return merged;
3260
3319
  const projectRouting = layer.data.routing;
3261
3320
  const lowerRouting = isPlainObject(lower) ? lower.routing : undefined;
@@ -3295,6 +3354,100 @@ function boundProjectClassifier(merged: Record<string, unknown>, lower: unknown,
3295
3354
  return { ...merged, routing: { ...merged.routing, classifier: bounded } };
3296
3355
  }
3297
3356
 
3357
+ /** A key path dropped from an override layer (#80), with the validation error that kept it out. */
3358
+ interface DroppedKeyPath {
3359
+ path: readonly string[];
3360
+ reason: string;
3361
+ }
3362
+
3363
+ /**
3364
+ * #80: the dropped key paths split further before giving up on them: `presets`, one preset, one
3365
+ * preset tier. Every other top-level key is kept or dropped as a whole.
3366
+ */
3367
+ function refinableKeyPath(path: readonly string[], value: unknown): value is Record<string, unknown> {
3368
+ return path[0] === "presets" && path.length <= 3 && isPlainObject(value) && Object.keys(value).length > 0;
3369
+ }
3370
+
3371
+ /** The value at `path` in `obj` (own keys only), or `undefined`. */
3372
+ function valueAtKeyPath(obj: unknown, path: readonly string[]): unknown {
3373
+ let current = obj;
3374
+ for (const key of path) {
3375
+ if (!isPlainObject(current) || !Object.hasOwn(current, key)) return undefined;
3376
+ current = current[key];
3377
+ }
3378
+ return current;
3379
+ }
3380
+
3381
+ /**
3382
+ * `obj` without the key at `path`. An object the removal leaves empty goes too, so dropping every
3383
+ * key of a block is the same as dropping the block. Copies along `path` only; never mutates `obj`.
3384
+ */
3385
+ function withoutKeyPath(obj: Record<string, unknown>, path: readonly string[]): Record<string, unknown> {
3386
+ const [head, ...rest] = path;
3387
+ if (head === undefined || !Object.hasOwn(obj, head)) return obj;
3388
+ let replacement: Record<string, unknown> | undefined; // undefined: the key goes
3389
+ if (rest.length > 0) {
3390
+ const value = obj[head];
3391
+ if (!isPlainObject(value)) return obj;
3392
+ const pruned = withoutKeyPath(value, rest);
3393
+ if (pruned === value) return obj;
3394
+ replacement = Object.keys(pruned).length > 0 ? pruned : undefined;
3395
+ }
3396
+ // Object.fromEntries defines each key, so an own `__proto__` key stays a key and reparents nothing.
3397
+ return Object.fromEntries(
3398
+ Object.entries(obj).flatMap(([key, value]): Array<[string, unknown]> => {
3399
+ if (key !== head) return [[key, value]];
3400
+ return replacement === undefined ? [] : [[key, replacement]];
3401
+ }),
3402
+ );
3403
+ }
3404
+
3405
+ /**
3406
+ * #80: the key paths of an override layer to drop so that the config validates, instead of the
3407
+ * whole layer. `errorWith(data)` validates the config with the layer's data replaced by `data` and
3408
+ * returns the error message, or `undefined` when it is valid; the caller has checked that the
3409
+ * layer's absence (`{}`) is valid. Deterministic, in file order: every top-level key starts out
3410
+ * dropped and comes back when the config still validates with it; a `presets` block that cannot
3411
+ * come back is split into its presets, a preset into its tiers, a tier into its keys, each restored
3412
+ * the same way; a last pass restores a key that only failed because of one dropped later (an
3413
+ * `activePreset` naming a preset whose bad tier key came out after it). One validation per key
3414
+ * tried, plus that pass.
3415
+ */
3416
+ function isolateInvalidKeys(
3417
+ data: Record<string, unknown>,
3418
+ errorWith: (pruned: Record<string, unknown>) => string | undefined,
3419
+ ): { data: Record<string, unknown>; dropped: DroppedKeyPath[] } {
3420
+ let dropped: DroppedKeyPath[] = Object.keys(data).map((key) => ({ path: [key], reason: "" }));
3421
+ const pruned = (entries: readonly DroppedKeyPath[]): Record<string, unknown> =>
3422
+ entries.reduce((acc, entry) => withoutKeyPath(acc, entry.path), data);
3423
+ /** Restore `entry` when the config validates with it; otherwise record why it stays dropped. */
3424
+ const tryRestore = (entry: DroppedKeyPath): boolean => {
3425
+ const rest = dropped.filter((other) => other !== entry);
3426
+ const error = errorWith(pruned(rest));
3427
+ if (error === undefined) {
3428
+ dropped = rest;
3429
+ return true;
3430
+ }
3431
+ entry.reason = error;
3432
+ return false;
3433
+ };
3434
+ for (const entry of [...dropped]) tryRestore(entry);
3435
+ for (let i = 0; i < dropped.length; i++) {
3436
+ const entry = dropped[i]!;
3437
+ const value = valueAtKeyPath(data, entry.path);
3438
+ if (!refinableKeyPath(entry.path, value)) continue;
3439
+ const children = Object.keys(value).map((key) => ({ path: [...entry.path, key], reason: entry.reason }));
3440
+ dropped.splice(i, 1, ...children);
3441
+ for (const child of children) tryRestore(child);
3442
+ i--; // position i now holds the first child still dropped, or the next entry: visit it
3443
+ }
3444
+ for (let restored = true; restored;) {
3445
+ restored = false;
3446
+ for (const entry of [...dropped]) if (tryRestore(entry)) restored = true;
3447
+ }
3448
+ return { data: pruned(dropped), dropped };
3449
+ }
3450
+
3298
3451
  /**
3299
3452
  * Build a fresh config from tiers.json + override layers + persisted state.
3300
3453
  * Throws only when tiers.json itself is unreadable/invalid. Override and state
@@ -3329,14 +3482,17 @@ function buildConfig(
3329
3482
  rawUsed = merged;
3330
3483
  notices.push(...attemptNotices);
3331
3484
  } catch (err) {
3332
- // A bad override must never brick startup, and one broken file must not
3333
- // discard a good one. Fall back to one layer that validates on its own,
3334
- // else the bundled defaults. QA-4.1-21: the global layer is tried first, so
3335
- // a project file cannot force a conflict with a value valid on its own and
3336
- // so drop the user's whole global layer; a broken global file still lets a
3337
- // project file apply.
3485
+ // A bad override must never brick startup, and one bad value must not discard the
3486
+ // rest of its file, let alone a good file (#80). The layers are settled one at a
3487
+ // time, each on top of those already settled. QA-4.1-21: the global layer goes
3488
+ // first, so a project file cannot force a conflict with a value valid on its own
3489
+ // and so drop the user's global keys; a broken global file still lets a project
3490
+ // file apply. A layer that validates whole is kept whole. Otherwise only the key
3491
+ // paths that keep it from validating are dropped, each with a notice
3492
+ // (isolateInvalidKeys); when every top-level key of the layer has to go, the layer
3493
+ // is dropped as a whole, with the log lines it always had.
3338
3494
  console.warn(
3339
- `[model-router] combined overrides are invalid (${(err as Error).message}); dropping conflicting layer(s)`,
3495
+ `[model-router] combined overrides are invalid (${(err as Error).message}); dropping the invalid keys or layer(s)`,
3340
3496
  );
3341
3497
  const layerPaths = layers.map((l) => l.path).join(" + ");
3342
3498
  failures.push({
@@ -3347,31 +3503,63 @@ function buildConfig(
3347
3503
  ...layers.map((_, i) => i).filter((i) => !layers[i]!.project).reverse(),
3348
3504
  ...layers.map((_, i) => i).filter((i) => layers[i]!.project === true).reverse(),
3349
3505
  ];
3350
- for (const i of order) {
3506
+ /** The layers settled so far, in priority order, with layer `i` as `layer`. */
3507
+ const settledWith = (kept: ReadonlyArray<OverrideLayer | undefined>, i: number, layer: OverrideLayer): OverrideLayer[] =>
3508
+ kept.map((l, j) => (j === i ? layer : l)).filter((l): l is OverrideLayer => l !== undefined);
3509
+ const validationError = (raw: unknown): string | undefined => {
3351
3510
  try {
3352
- const attemptNotices: ConfigNotice[] = [];
3353
- const single = merge([layers[i]!], attemptNotices);
3354
- cfg = validateConfig(single);
3355
- rawUsed = single;
3356
- notices.push(...attemptNotices);
3357
- for (let j = 0; j < layers.length; j++) {
3358
- if (j !== i) {
3359
- console.warn(`[model-router] dropped override layer ${layers[j]!.path}`);
3360
- }
3511
+ validateConfig(raw);
3512
+ return undefined;
3513
+ } catch (validationErr) {
3514
+ return (validationErr as Error).message;
3515
+ }
3516
+ };
3517
+ // The merge notices (A18 clamps) of a trial merge are not reported: only the final merge's are.
3518
+ const errorWith = (kept: ReadonlyArray<OverrideLayer | undefined>, i: number, layer: OverrideLayer): string | undefined =>
3519
+ validationError(merge(settledWith(kept, i, layer), []));
3520
+ const kept: Array<OverrideLayer | undefined> = layers.map(() => undefined);
3521
+ const droppedWhole: number[] = [];
3522
+ for (const i of order) {
3523
+ const layer = layers[i]!;
3524
+ if (errorWith(kept, i, layer) === undefined) {
3525
+ kept[i] = layer;
3526
+ continue;
3527
+ }
3528
+ const isolated = isolateInvalidKeys(layer.data, (data) => errorWith(kept, i, { ...layer, data }));
3529
+ const keptSomeKey = Object.keys(layer.data).some(
3530
+ (key) => !isolated.dropped.some((d) => d.path.length === 1 && d.path[0] === key),
3531
+ );
3532
+ if (keptSomeKey && errorWith(kept, i, { ...layer, data: isolated.data }) === undefined) {
3533
+ kept[i] = { ...layer, data: isolated.data };
3534
+ for (const { path, reason } of isolated.dropped) {
3535
+ const keyPath = path.join(".");
3536
+ console.warn(`[model-router] ignoring ${keyPath} from ${layer.path}: ${reason}`);
3537
+ notices.push({
3538
+ source: layer.path,
3539
+ message: `ignoring ${keyPath} from ${layer.path}: ${reason}; the rest of the file applies`,
3540
+ });
3361
3541
  }
3362
- break;
3363
- } catch (singleErr) {
3364
- console.warn(
3365
- `[model-router] ignoring ${layers[i]!.path}: ${(singleErr as Error).message}`,
3366
- );
3367
- failures.push({
3368
- source: layers[i]!.path,
3369
- message: `${layers[i]!.path}: ${(singleErr as Error).message}`,
3370
- });
3371
- cfg = validateConfig(base);
3372
- rawUsed = base;
3542
+ continue;
3543
+ }
3544
+ // Not isolated: the layer goes as a whole, as before #80.
3545
+ droppedWhole.push(i);
3546
+ const aloneError = validationError(merge([layer], []));
3547
+ if (aloneError !== undefined) {
3548
+ console.warn(`[model-router] ignoring ${layer.path}: ${aloneError}`);
3549
+ failures.push({ source: layer.path, message: `${layer.path}: ${aloneError}` });
3550
+ }
3551
+ }
3552
+ if (kept.some((l) => l !== undefined)) {
3553
+ for (const i of droppedWhole.sort((a, b) => a - b)) {
3554
+ console.warn(`[model-router] dropped override layer ${layers[i]!.path}`);
3373
3555
  }
3374
3556
  }
3557
+ const used = kept.filter((l): l is OverrideLayer => l !== undefined);
3558
+ const attemptNotices: ConfigNotice[] = [];
3559
+ const settled = used.length > 0 ? merge(used, attemptNotices) : base;
3560
+ cfg = validateConfig(settled);
3561
+ rawUsed = settled;
3562
+ notices.push(...attemptNotices);
3375
3563
  }
3376
3564
  }
3377
3565