mirror of
https://github.com/morluto/rea.git
synced 2026-12-01 00:29:08 +00:00
* fix(limits): make the IL2CPP pointer index adjustable and name ELF note budgets in details.limit inspect_il2cpp_metadata accepts max_native_index_bytes (default 1 GiB, needs binary_path) for the estimated ELF virtual pointer index. The index refusal now carries its own limit name (virtual-pointer-index-bytes) and a details.limit naming the parameter, its effective value, default and range, instead of a fixed ceiling with no override. The binary file allowance and the loader's fixed capacities are unchanged. inspect_elf_notes and inspect_elf_debug_link refusals for max_file_bytes, the decoded section-name budget and max_entries now set details.limit. One domain-owned bounds object per operation feeds both the schema and the limit. Two guards keep new in-code refusal limits owned: - scripts/verify/fixed-ceilings.mjs (run by npm run lint) requires every fixedAllowanceOptions, fixedProducerInputAllowance, artifactFixedLimitFailure or inline fixedAllowance declaration to be listed in fixed-ceiling-registry.json with its class (format, protocol, representation, derived, forwarding, or pending with an issue) and reason, and fails on stale entries. - The untyped-budget-refusal architecture guard counts refusals whose only recovery is an authored remediationAction, with a shrink-only baseline. Fixes #14175 Part of #14234 BREAKING CHANGE: an inspect_il2cpp_metadata refusal at the ELF pointer index reports reported_limits.boundary "virtual-pointer-index-bytes" and details.limit for max_native_index_bytes, and no longer carries a details.refusal fixed_ceiling. * fix(limits): track IL2CPP's remaining fixed allowances with the native readers * fix(limits): run the authored-only refusal count from lint, where TypeScript is installed The architecture guards run before npm ci in CI and must stay dependency-free, so the AST-based count moves into fixed-ceilings.mjs with its own shrink-only baseline and --shrink-baselines. * fix(limits): register producer and native wrapper ceilings by the allowance they name fixedProducerInputAllowance names its allowance in its second argument, and fixedNativeAllowance forwards its first, so the guard now reads each helper's allowance argument and checks the callers of both. * fix(limits): delete the authored-only baseline when its last count is removed reconcileBaselineFile returns delete once no count remains, but the verifier ignored it and the next run read the file unconditionally, so --shrink-baselines could not finish. An absent baseline now reads as empty and shrinking removes the file. * fix(limits): record the advertised IL2CPP input schema with max_native_index_bytes
117 lines
3.9 KiB
TypeScript
117 lines
3.9 KiB
TypeScript
import { ParseFailureError } from "../domain/parseFailure.js";
|
|
|
|
/**
|
|
* Selected-binary file allowance. The ELF pointer index has its own per-call
|
|
* control, `max_native_index_bytes`.
|
|
*/
|
|
export const IL2CPP_BINARY_BYTES = 1024 * 1024 * 1024;
|
|
|
|
export const IL2CPP_BINARY_FAILURE_REASONS = {
|
|
unsupported: [
|
|
"unsupported-container",
|
|
"unsupported-pointer-encoding",
|
|
"unsupported-type-kind",
|
|
"generic-methods-unsupported",
|
|
],
|
|
capacity: [
|
|
"native-index-capacity",
|
|
"type-nesting-capacity",
|
|
"native-type-text-capacity",
|
|
],
|
|
/** The binary's own container bytes break their format's rules. */
|
|
malformed: ["malformed-container"],
|
|
/**
|
|
* The binary's container parsed, but its registration, pointers, tokens or
|
|
* types do not agree with the metadata. The pair may come from different
|
|
* builds, either file may be damaged, or the registration layout may be
|
|
* outside coverage, so no single file is established as at fault.
|
|
*/
|
|
linkConflict: [
|
|
"code-gen-modules-not-found",
|
|
"ambiguous-code-gen-module",
|
|
"code-registration-not-found",
|
|
"invalid-method-pointer",
|
|
"invalid-method-token",
|
|
"metadata-registration-not-found",
|
|
"invalid-type",
|
|
"generic-method-registration-not-found",
|
|
"ambiguous-generic-method-registration",
|
|
],
|
|
} as const;
|
|
|
|
export type Il2cppBinaryFailureReason =
|
|
(typeof IL2CPP_BINARY_FAILURE_REASONS)[keyof typeof IL2CPP_BINARY_FAILURE_REASONS][number];
|
|
/** A named workspace budget; the parse stopped without showing the input invalid. */
|
|
export type Il2cppBinaryCapacityReason =
|
|
(typeof IL2CPP_BINARY_FAILURE_REASONS.capacity)[number];
|
|
type Il2cppBinaryFormatReason = Exclude<
|
|
Il2cppBinaryFailureReason,
|
|
Il2cppBinaryCapacityReason
|
|
>;
|
|
|
|
/** What a native-link budget counts, so its maximum is reported with its unit. */
|
|
export type NativeBudgetUnit = "entries" | "bytes" | "frames";
|
|
|
|
/** The ParseFailure format of a native image linked against IL2CPP metadata. */
|
|
export const IL2CPP_BINARY_FORMAT = "il2cpp-binary";
|
|
|
|
const isUnsupported = (reason: Il2cppBinaryFormatReason) =>
|
|
(IL2CPP_BINARY_FAILURE_REASONS.unsupported as readonly string[]).includes(
|
|
reason,
|
|
);
|
|
|
|
/** Whether a link failure is a disagreement between the two files, not one file's bytes. */
|
|
export const isIl2cppLinkConflict = (reason: Il2cppBinaryFailureReason) =>
|
|
(IL2CPP_BINARY_FAILURE_REASONS.linkConflict as readonly string[]).includes(
|
|
reason,
|
|
);
|
|
|
|
/**
|
|
* A native image REA cannot link, either outside coverage or inconsistent
|
|
* with the metadata. The stable `reason` names the IL2CPP rule; a capacity
|
|
* reason is a ParseFailure `limit` carrying the exceeded maximum.
|
|
*/
|
|
export class Il2cppBinaryFormatFailure extends ParseFailureError<
|
|
"malformed" | "unsupported" | "limit"
|
|
> {
|
|
/** What the exceeded maximum counts; set only for a capacity reason. */
|
|
readonly unit: NativeBudgetUnit | undefined;
|
|
constructor(reason: Il2cppBinaryFormatReason, message: string);
|
|
constructor(
|
|
reason: Il2cppBinaryCapacityReason,
|
|
message: string,
|
|
maximum: number,
|
|
unit: NativeBudgetUnit,
|
|
limitName?: string,
|
|
);
|
|
constructor(
|
|
readonly reason: Il2cppBinaryFailureReason,
|
|
message: string,
|
|
maximum?: number,
|
|
unit?: NativeBudgetUnit,
|
|
/** The exceeded budget's name; defaults to the reason for a fixed budget. */
|
|
limitName: string = reason,
|
|
) {
|
|
const detail = `${reason}: ${message}`;
|
|
super(
|
|
maximum !== undefined
|
|
? {
|
|
kind: "limit",
|
|
format: IL2CPP_BINARY_FORMAT,
|
|
detail,
|
|
limit: { name: limitName, maximum },
|
|
}
|
|
: isUnsupported(reason as Il2cppBinaryFormatReason)
|
|
? {
|
|
kind: "unsupported",
|
|
format: IL2CPP_BINARY_FORMAT,
|
|
detail,
|
|
undecodedContent: false,
|
|
}
|
|
: { kind: "malformed", format: IL2CPP_BINARY_FORMAT, detail },
|
|
);
|
|
this.unit = unit;
|
|
this.name = "Il2cppBinaryFormatFailure";
|
|
}
|
|
}
|