feat(errors): type refusals at the producer with a total recovery (#10577)

* feat(errors): type refusals at the producer with a total recovery

A resource refusal without authored text fell back to resource-kind advice:
a fixed parser ceiling reported as memory told the caller to add host
memory, an upstream IDA reply ceiling pointed at REA's MCP transport, and a
fixed Kuna text ceiling reported as capacity was marked retryable. An
ambiguous selector was reported as invalid input that pointed at the schema.

Add AnalysisRefusal with three variants built from facts producers already
own: fixed_ceiling (FixedAllowance, now with limit, unit and narrowing),
adjustable_budget (AnalysisSettingLimit) and ambiguous_selector (new
AnalysisInputError option). Each variant is attributed to the error's
operation and projected under details.refusal. Presentation is a total
switch over the variants, and authored text still takes precedence.

Migrate the first producers. GraphQL nesting, Playwright trace input, the
Kuna function text and the IDA upstream reply become fixed ceilings. jadx
overloads and Kuna ambiguous names become ambiguous selectors, replacing the
two Kuna-specific ambiguity texts. Seven occupied admissions declare
measuredExhaustion. The rea/typed-resource-refusal lint rule rejects new
untyped resource constraints, and the remaining 24 are counted in a baseline
that can only shrink.

* fix(errors): honor refusal recovery ownership
This commit is contained in:
morluto authored and GitHub committed 2026-11-14 14:36:14 -05:00
1 parent a0d9025202
commit e83e3fa8a0
31 files changed
+896 -57

No files matched your search

+11
View File
@@ -16,6 +16,7 @@ import {
AnalysisCancelledError,
AnalysisResourceConstraintError,
} from "../domain/analysisErrorCore.js";
import { fixedAllowanceOptions } from "../domain/fixedAllowanceRemediation.js";
import { ProviderAdapterError } from "../domain/providerAdapterError.js";
import { ProviderCleanupError } from "../domain/providerCleanupError.js";
import { err, ok, type Result } from "../domain/result.js";
@@ -96,6 +97,16 @@ const readSpan = async (
file: path,
byte_offset: offset,
},
fixedAllowanceOptions(
`Kuna's buffered function-text allowance of ${String(KUNA_FUNCTION_TEXT_BYTES)} bytes`,
"bytes",
{
limit: KUNA_FUNCTION_TEXT_BYTES,
unit: "bytes",
narrowing:
"Read the complete export locally at details.reported_limits.file from details.reported_limits.byte_offset.",
},
),
),
);
const callerAborted = (): AbortSignal | undefined =>
+1
View File
@@ -247,6 +247,7 @@ export class KunaReferenceQueries {
"capacity",
"The session's native reference-query queue is full; await an existing query before starting another.",
{ limit_queries: PENDING_XREF_QUERIES },
{ measuredExhaustion: true },
),
);
pending = this.work.start<KunaIncomingReferences>(
-7
View File
@@ -2,19 +2,12 @@
export const KUNA_XREF_MISSING_NAME_REMEDIATION =
"Inspect target symbols or exports where available, verify address coordinates, and call xrefs with an address. Absence from Kuna's inventory does not establish absence from the target.";
/** Recovery for a name with multiple observed inventory entries. */
export const KUNA_XREF_AMBIGUOUS_NAME_REMEDIATION =
"Select one of the reported addresses and call xrefs again.";
export const KUNA_PROCEDURE_MISSING_NAME_REMEDIATION =
"Use search_procedures or list_procedures to inspect Kuna's current inventory. An absent name does not establish that the function is absent from the target.";
export const KUNA_PROCEDURE_MISSING_ADDRESS_REMEDIATION =
"Use list_procedures or search_procedures to inspect Kuna's current inventory and verify the selected address. An absent entry does not establish that the function is absent from the target; REA cannot use it as a Kuna procedure in this session.";
export const KUNA_PROCEDURE_AMBIGUOUS_NAME_REMEDIATION =
"Select one of the reported exact addresses and retry the operation.";
export const missingKunaXrefNameMessage = (selector: string): string =>
`Kuna found no inventory entry named ${selector}.`;
+14 -8
View File
@@ -108,10 +108,8 @@ import { KunaStringQueries } from "./KunaStringQueries.js";
import { normalizeKunaAddress } from "./KunaAddress.js";
import {
ambiguousKunaNameMessage,
KUNA_PROCEDURE_AMBIGUOUS_NAME_REMEDIATION,
KUNA_PROCEDURE_MISSING_ADDRESS_REMEDIATION,
KUNA_PROCEDURE_MISSING_NAME_REMEDIATION,
KUNA_XREF_AMBIGUOUS_NAME_REMEDIATION,
KUNA_XREF_MISSING_NAME_REMEDIATION,
missingKunaXrefNameMessage,
} from "./KunaSelectorGuidance.js";
@@ -1344,15 +1342,15 @@ export class KunaSessionClient implements AnalysisClient {
selector,
matches.map(({ address }) => address),
);
const remediationAction =
field === "address"
// An ambiguous name is a typed selector refusal; its recovery is derived.
const remediationAction = ambiguous
? undefined
: field === "address"
? missing
? KUNA_XREF_MISSING_NAME_REMEDIATION
: KUNA_XREF_AMBIGUOUS_NAME_REMEDIATION
: "Select one of the reported addresses and call xrefs again."
: procedureLookupFailure
? missing
? KUNA_PROCEDURE_MISSING_NAME_REMEDIATION
: KUNA_PROCEDURE_AMBIGUOUS_NAME_REMEDIATION
? KUNA_PROCEDURE_MISSING_NAME_REMEDIATION
: matches.length === 0
? "Inspect the data addresses with address_name or xrefs, or select a procedure entry from list_procedures. Do not repeat the unchanged call."
: undefined;
@@ -1364,6 +1362,14 @@ export class KunaSessionClient implements AnalysisClient {
...(remediationAction === undefined
? {}
: { remediationAction, conformsToInputContract: true }),
...(ambiguous
? {
ambiguousSelector: {
field: [field],
candidates: matches.map(({ address }) => address),
},
}
: {}),
},
procedureLookupFailure
? [