@@ -304,14 +304,22 @@ export function evaluatePolicyProfile(
304304 const excludedByUnknown = unknown && profile . unknownEvidence . capability === "exclude" ;
305305 const costLimit = profile . limits . maxEstimatedCostUsd ;
306306 const estimatedCost = evidence . cost ?. estimatedUsd ;
307+ // A hard ceiling requires evidence that the request fits below it. Routing
308+ // with an unknown estimate would otherwise turn the ceiling into the
309+ // profile's (permissive by default) unknown-cost scoring preference.
310+ const unknownCostAtLimit = costLimit !== undefined
311+ && ( typeof estimatedCost !== "number" || ! Number . isFinite ( estimatedCost ) ) ;
307312 const overCostLimit = costLimit !== undefined
308313 && typeof estimatedCost === "number"
309314 && Number . isFinite ( estimatedCost )
310315 && estimatedCost > costLimit ;
316+ if ( unknownCostAtLimit ) {
317+ exclusions . push ( { code : "unknown-price" , detail : "maxEstimatedCostUsd" } ) ;
318+ }
311319 if ( overCostLimit ) {
312320 exclusions . push ( { code : "cost-limit" , detail : "maxEstimatedCostUsd" } ) ;
313321 }
314- let eligible = ! unsatisfied && ! excludedByUnknown && ! overCostLimit ;
322+ let eligible = ! unsatisfied && ! excludedByUnknown && ! unknownCostAtLimit && ! overCostLimit ;
315323
316324 // Health scoring (RI-06): live hard cooldown is authoritative and
317325 // excludes; unknown health follows the profile's unknownEvidence policy;
@@ -349,7 +357,7 @@ export function evaluatePolicyProfile(
349357 // above; unknown cost follows the profile's unknownEvidence policy.
350358 const cost = evidence . cost ;
351359 let costValue = cost ? costScore ( cost ) : null ;
352- if ( costValue === null && profile . unknownEvidence . cost === "exclude" ) {
360+ if ( costValue === null && profile . unknownEvidence . cost === "exclude" && ! unknownCostAtLimit ) {
353361 exclusions . push ( { code : "unknown-price" } ) ;
354362 eligible = false ;
355363 } else if ( costValue === null && profile . unknownEvidence . cost === "penalize" ) {
0 commit comments