mirror of
https://github.com/morluto/rea.git
synced 2026-11-15 11:13:21 +00:00
* refactor(errors): require a reason for every analysis cancellation Add cancelledBy, the one constructor for AnalysisCancelledError. Its reason argument is required: an aborted signal, an earlier cancellation, a reason carried from an inner failure, or an OwnerCancellation when REA closed the work's owner itself. Closed adb, apktool, firmware, sqlite, gdb, web-bundle analyzer and binary-session record owners now report OwnerCancellation.ownerClosed instead of an absent reason. Firmware's predecessor wait returns its cancellation as a Result, removing an unreachable reason-less fallback. An architecture guard rejects new direct constructions, with a counted per-file baseline that can only shrink. * refactor(errors): share one aborted-signal predicate with cancelledBy * refactor(process): return a departing caller's reason from a shared startup wait * refactor(providers): build decompiler-provider cancellations with a required reason (#10587) Migrate every AnalysisCancelledError construction under src/ghidra, src/ida, src/cutter, src/jeb and src/kuna to cancelledBy and lower the guard baseline from 671 to 572. Closed Kuna target commands report OwnerCancellation.ownerClosed instead of an absent reason, and Kuna and JEB close abort their lifetimes with that typed reason. * fix(errors): read the reason of any signal-shaped cancellation source * test(ci): cover the counted-baseline comparison behind the architecture guard
25 lines
957 B
JavaScript
25 lines
957 B
JavaScript
/**
|
|
* Compare observed per-file counts with a counted baseline. A file may not
|
|
* exceed its recorded count. A count below the baseline is stale; with
|
|
* `shrink`, the returned baseline lowers it (and drops zero entries) but never
|
|
* raises any count.
|
|
*/
|
|
export const compareCountedBaseline = (counts, baseline, shrink) => {
|
|
const grown = [];
|
|
const stale = [];
|
|
for (const [path, count] of counts) {
|
|
const allowed = baseline[path] ?? 0;
|
|
if (count > allowed) grown.push({ path, count, allowed });
|
|
}
|
|
for (const [path, allowed] of Object.entries(baseline)) {
|
|
const count = counts.get(path) ?? 0;
|
|
if (count < allowed) stale.push({ path, count, allowed });
|
|
}
|
|
if (!shrink || stale.length === 0) return { grown, stale, baseline };
|
|
const lowered = { ...baseline };
|
|
for (const { path, count } of stale)
|
|
if (count === 0) delete lowered[path];
|
|
else lowered[path] = count;
|
|
return { grown, stale: [], baseline: lowered };
|
|
};
|