* test(#3531): failing-first suite for routing_tier_defaults manifest merge * fix(#3531): merge routing_tier_defaults over manifest tier defaults * docs(#3531): document routing_tier_defaults merge-over-built-ins semantics * fix(#3531): correct test helper scope, update folded #443 expectations, guard merge keys * test(#3531): pin tiers in effort-sync and surface-axis fixtures post-merge * chore(#3531): backfill changeset pr number * fix(#3531): correct rebase resolution — keep both 3531 and 3533 test blocks intact * test(#3531): pin inherit/effort fixtures to the layer that reaches tiered agents --------- Co-authored-by: sim <sim@local>
This commit is contained in:
@@ -343,5 +343,36 @@ export function renderEffortForRuntime(runtime: string, universalEffort: string)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* #3531 (10c) — Merge a config `effort.routing_tier_defaults` block over the
|
||||
* manifest tier defaults instead of replacing them. A partial config must not
|
||||
* discard built-ins: per tier, a valid override value wins and an invalid one
|
||||
* is ignored so the manifest value for that tier surfaces (ADR-443 D1's
|
||||
* "invalid values fall through" holds within the merged layer).
|
||||
*
|
||||
* Pure: returns a new object and never mutates either input — the manifest
|
||||
* constants (`CANONICAL_CONFIG_DEFAULTS`, the catalog cache) stay frozen. The
|
||||
* validator is injected because `EFFORT_SET` lives in model-resolver, which
|
||||
* imports this leaf (a reverse import would be a cycle); both effort
|
||||
* resolvers pass their own `(v) => typeof v === 'string' && EFFORT_SET.has(v)`.
|
||||
*/
|
||||
export function mergeEffortTierDefaults(
|
||||
manifest: Record<string, string> | null | undefined,
|
||||
override: unknown,
|
||||
isValid: (v: unknown) => boolean,
|
||||
): Record<string, string> {
|
||||
const merged: Record<string, string> = { ...(manifest || {}) };
|
||||
if (override && typeof override === 'object' && !Array.isArray(override)) {
|
||||
for (const [tier, value] of Object.entries(override as Record<string, unknown>)) {
|
||||
// House pollution guard (mirrors _deepMergeConfig in config-loader): the
|
||||
// string-only validator already makes these inert, but an explicit skip
|
||||
// keeps this merge safe even if a caller's validator is ever relaxed.
|
||||
if (tier === '__proto__' || tier === 'constructor' || tier === 'prototype') continue;
|
||||
if (isValid(value)) merged[tier] = value as string;
|
||||
}
|
||||
}
|
||||
return merged;
|
||||
}
|
||||
|
||||
// ─── Fast mode propagation ───────────────────────────────────────────────────
|
||||
export const RUNTIMES_WITH_FAST_MODE: Set<string> = new Set(['api']);
|
||||
|
||||
Reference in New Issue
Block a user