mirror of
https://github.com/morluto/rea.git
synced 2026-11-18 20:53:00 +00:00
* feat(artifacts): project fixed reader ceilings as typed refusals
ArtifactReaderFailure('limit') carried fixed reader ceilings only as
remediation prose: artifactFixedLimitFailure and six Deno reader sites wrote
fixedAllowanceRemediation into the message, so CLI/MCP had no details.refusal
and the value was only in text. The failure now carries a typed fixedAllowance
(name, kind, limit, unit) that survives rebuilds (primaryFacts) and
translateArtifactFailure, and ArtifactOperationError projects it as a
fixed_ceiling refusal whose remediation derives from the allowance. The message
states only what exceeded the ceiling.
Refs #10508
* test(artifacts): keep a fixed reader ceiling's refusal through cleanup wrapping
59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
import {
|
|
AnalysisInputError,
|
|
AnalysisResourceConstraintError,
|
|
} from "./analysisErrorCore.js";
|
|
import type { AnalysisError } from "./analysisErrorBase.js";
|
|
import type { AnalysisRefusal } from "./analysisRefusal.js";
|
|
import { ArtifactOperationError } from "./artifactOperationError.js";
|
|
|
|
/**
|
|
* The typed refusal an error carries, attributed to the error's operation so
|
|
* a re-attributed error names the request that was refused. Occupied capacity
|
|
* keeps its wait-and-retry recovery even when a setting bounds it.
|
|
*/
|
|
export const analysisErrorRefusal = (
|
|
error: AnalysisError,
|
|
): AnalysisRefusal | undefined => {
|
|
if (error instanceof AnalysisResourceConstraintError) {
|
|
if (error.fixedAllowance !== undefined)
|
|
return {
|
|
kind: "fixed_ceiling",
|
|
operation: error.operation,
|
|
ceiling: error.fixedAllowance,
|
|
};
|
|
if (
|
|
error.limit !== undefined &&
|
|
!("control_kind" in error.limit) &&
|
|
!(
|
|
"measuredExhaustion" in error.recovery &&
|
|
error.recovery.measuredExhaustion === true
|
|
)
|
|
)
|
|
return {
|
|
kind: "adjustable_budget",
|
|
operation: error.operation,
|
|
budget: error.limit,
|
|
};
|
|
return undefined;
|
|
}
|
|
if (
|
|
error instanceof ArtifactOperationError &&
|
|
error.fixedAllowance !== undefined
|
|
)
|
|
return {
|
|
kind: "fixed_ceiling",
|
|
operation: error.operation,
|
|
ceiling: error.fixedAllowance,
|
|
};
|
|
if (
|
|
error instanceof AnalysisInputError &&
|
|
error.ambiguousSelector !== undefined
|
|
)
|
|
return {
|
|
kind: "ambiguous_selector",
|
|
operation: error.operation,
|
|
selector: error.ambiguousSelector,
|
|
};
|
|
return undefined;
|
|
};
|