mirror of
https://github.com/morluto/rea.git
synced 2026-11-21 22:15:50 +00:00
test: restore audited startup, launcher, and BEAM contracts (#12884)
This commit is contained in:
1 parent
87940b192c
commit
6cd055bfca
4 files changed
+65
-24
No files matched your search
@@ -11,16 +11,18 @@ import {
|
||||
|
||||
it("resolves default budgets with the launch setting for each startup phase", () => {
|
||||
const budgets = resolveMcpStartupBudgets({});
|
||||
expect(budgets).toMatchObject({
|
||||
initialize: { setting: "REA_MCP_INITIALIZE_BUDGET_MS" },
|
||||
toolsList: { setting: "REA_MCP_TOOLS_LIST_BUDGET_MS" },
|
||||
firstCatalog: { setting: "REA_MCP_FIRST_CATALOG_BUDGET_MS" },
|
||||
doctor: { setting: "REA_MCP_DOCTOR_DEADLINE_MS" },
|
||||
});
|
||||
for (const budget of Object.values(budgets))
|
||||
expect(budget.milliseconds, budget.setting).toBe(
|
||||
budget.defaultMilliseconds,
|
||||
);
|
||||
for (const [phase, setting, milliseconds] of [
|
||||
["initialize", "REA_MCP_INITIALIZE_BUDGET_MS", 15_000],
|
||||
["toolsList", "REA_MCP_TOOLS_LIST_BUDGET_MS", 5_000],
|
||||
["firstCatalog", "REA_MCP_FIRST_CATALOG_BUDGET_MS", 20_000],
|
||||
["doctor", "REA_MCP_DOCTOR_DEADLINE_MS", 30_000],
|
||||
] as const)
|
||||
expect(budgets[phase]).toMatchObject({
|
||||
setting,
|
||||
milliseconds,
|
||||
defaultMilliseconds: milliseconds,
|
||||
source: "default",
|
||||
});
|
||||
});
|
||||
|
||||
it("admits distinct overrides for all four startup phases", () => {
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
AnalysisAccessDeniedError,
|
||||
AnalysisInputError,
|
||||
AnalysisResourceConstraintError,
|
||||
type ResourceConstraintRecovery,
|
||||
} from "../domain/analysisErrorCore.js";
|
||||
import {
|
||||
MAX_INSPECT_ERLANG_BEAM_ATOMS,
|
||||
@@ -27,6 +28,7 @@ import {
|
||||
type InspectErlangBeamInput,
|
||||
} from "../domain/erlang/beam.js";
|
||||
import { err, ok } from "../domain/result.js";
|
||||
import { fixedAllowanceOptions } from "../domain/fixedAllowanceRemediation.js";
|
||||
import type { LimitRef } from "../domain/parseFailure.js";
|
||||
import {
|
||||
isParseLimit,
|
||||
@@ -93,8 +95,6 @@ const parserBudgetRemediation = ({ name, maximum }: LimitRef) => {
|
||||
return maximum >= MAX_INSPECT_ERLANG_BEAM_ATOMS
|
||||
? `The file exceeds the ${String(MAX_INSPECT_ERLANG_BEAM_ATOMS)}-atom ceiling this operation accepts; select a smaller artifact.`
|
||||
: `Raise max_atoms above ${String(maximum)} or select a smaller artifact; the limit is the caller-selected atom budget.`;
|
||||
case "max_table_rows":
|
||||
return `The file exceeds the ${String(maximum)}-row ceiling this operation accepts; select a smaller artifact.`;
|
||||
case "max_chunks":
|
||||
return maximum >= MAX_INSPECT_ERLANG_BEAM_CHUNKS
|
||||
? `The file exceeds the ${String(MAX_INSPECT_ERLANG_BEAM_CHUNKS)}-chunk ceiling this operation accepts; select a smaller artifact.`
|
||||
@@ -122,11 +122,20 @@ const beamFailurePrimary = (
|
||||
if (origin === "owned-or-classified" && isParseLimit(cause, "beam")) {
|
||||
const { limit } = cause.failure;
|
||||
const remediationAction = parserBudgetRemediation(limit);
|
||||
const recovery: ResourceConstraintRecovery =
|
||||
limit.name === "max_table_rows"
|
||||
? fixedAllowanceOptions("BEAM table row ceiling", "parser", {
|
||||
limit: limit.maximum,
|
||||
unit: "rows",
|
||||
})
|
||||
: remediationAction === undefined
|
||||
? {}
|
||||
: { remediationAction };
|
||||
return parseLimitConstraint(OPERATION, "capacity", cause, {
|
||||
reportedLimitContext: reportedLimits,
|
||||
legacyMaximumKey: limit.name,
|
||||
...(remediationAction === undefined ? {} : { remediationAction }),
|
||||
retryable: false,
|
||||
...recovery,
|
||||
});
|
||||
}
|
||||
if (
|
||||
|
||||
Reference in new issue
Block a user