mirror of
https://github.com/morluto/rea.git
synced 2026-12-01 02:49:12 +00:00
* feat(metadata)!: give NTFS, Maven report and NuGet budgets typed per-call controls inspect_ntfs_journal refused acquisitions above a fixed 64 MiB allowance; it now takes max_file_bytes (default 64 MiB) and re-admits a retained acquisition under the call's budget, so lowering it cannot reuse a larger cached read. inspect_maven_gradle_metadata refused at six fixed report allowances; they are now report_limits fields (CLI --report-limits JSON) with today's values as defaults. Maven max_file_bytes and NuGet max_file_bytes, max_entries and max_nuspec_bytes refusals now report details.limit from the same bounds objects the schemas use. The Ghidra installation-properties read allowance is registered as a protocol bound: it reads the provider's own short installation descriptor, not analysis input. BREAKING CHANGE: NTFS and Maven report refusals report details.limit instead of a fixed_ceiling refusal, and parseMavenGradleMetadata and the inspect_ntfs_journal input contract gain the new controls. * fix(metadata): keep omitted NTFS budgets omitted and type host and maximum recovery inspect_ntfs_journal recorded the default max_file_bytes as if the caller had chosen it; the field is now optional and resolved for execution only, so Evidence keeps omission. A host allocation failure while holding an admitted acquisition is reported as measured memory exhaustion instead of generic I/O. A Maven report refusal whose need exceeds the control's maximum no longer suggests raising it. A public CLI/MCP test covers report_limits refusal and recovery for a POM.
95 lines
2.6 KiB
TypeScript
95 lines
2.6 KiB
TypeScript
import { Budget } from "../domain/budget.js";
|
|
import {
|
|
MAVEN_GRADLE_REPORT_LIMIT_BOUNDS,
|
|
mavenPropertyOccurrences,
|
|
type MavenGradleUnresolved,
|
|
} from "../domain/java/mavenGradleMetadata.js";
|
|
import { metadataReportLimit } from "./MavenGradleMetadata.errors.js";
|
|
|
|
type FieldValue = readonly [MavenGradleUnresolved["field"], string | null];
|
|
|
|
/** One report-wide admission owner for references and missing-coordinate facts. */
|
|
export class MavenGradleUnresolvedCollector {
|
|
readonly #records: MavenGradleUnresolved[] = [];
|
|
readonly #budget: Budget;
|
|
|
|
constructor(
|
|
maximum: number = MAVEN_GRADLE_REPORT_LIMIT_BOUNDS.unresolved_records
|
|
.default_value,
|
|
) {
|
|
this.#budget = new Budget(maximum);
|
|
}
|
|
|
|
#reserve(): void {
|
|
this.#budget.charge(1, () =>
|
|
metadataReportLimit(
|
|
"unresolved_records",
|
|
this.#budget.maximum,
|
|
this.#budget.used + 1,
|
|
),
|
|
);
|
|
}
|
|
|
|
properties(
|
|
fields: readonly FieldValue[],
|
|
owner: MavenGradleUnresolved["owner"],
|
|
index: number | null,
|
|
): void {
|
|
for (const [field, value] of fields) {
|
|
const seen = new Set<string>();
|
|
for (const reference of mavenPropertyOccurrences(value)) {
|
|
if (seen.has(reference)) continue;
|
|
// Admit before retaining either the distinct reference or its record.
|
|
this.#reserve();
|
|
seen.add(reference);
|
|
this.#records.push({
|
|
kind: "property",
|
|
reference,
|
|
field,
|
|
owner,
|
|
index,
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
coordinates(
|
|
coordinates: {
|
|
readonly group_id: string | null;
|
|
readonly artifact_id: string | null;
|
|
readonly version: string | null;
|
|
},
|
|
owner: MavenGradleUnresolved["owner"],
|
|
index: number | null,
|
|
parentPresent: boolean,
|
|
): void {
|
|
const fields = [
|
|
["group_id", coordinates.group_id],
|
|
["artifact_id", coordinates.artifact_id],
|
|
["version", coordinates.version],
|
|
] as const;
|
|
for (const [field, value] of fields) {
|
|
if (value !== null) {
|
|
this.properties([[field, value]], owner, index);
|
|
continue;
|
|
}
|
|
// Maven's parent may supply group/version, but never the child's artifactId.
|
|
const inherited =
|
|
parentPresent && owner === "project" && field !== "artifact_id";
|
|
this.#reserve();
|
|
this.#records.push({
|
|
kind: inherited ? "parent-coordinate" : "missing-coordinate",
|
|
reference: inherited ? `parent.${field}` : `${owner}.${field}`,
|
|
field,
|
|
owner,
|
|
index,
|
|
});
|
|
}
|
|
}
|
|
|
|
/** Transfer the bounded records into the completed report. */
|
|
finish(): MavenGradleUnresolved[] {
|
|
return this.#records;
|
|
}
|
|
}
|