refactor(evidence): slice retained byte entropy pages directly (#16564)

* refactor(evidence): slice retained byte entropy pages directly

* docs(evidence): explain the byte entropy sample cap
This commit is contained in:
Vincent Koc authored and GitHub committed 2026-12-04 11:42:14 +08:00
1 parent 042f3308f6
commit 1de34cb530
1 file changed
+7 -13
+7 -13
View File
@@ -13,7 +13,6 @@ import {
completeWithinViewCoverage,
selectedViewPage,
} from "./analysisViewCoverage.js";
import { selectViewRows } from "./selectViewRows.js";
/** Runs the summary lists in offset order before the byte-entropy view pages the rest. */
export const SUMMARY_RUN_LIMIT = 64;
@@ -125,26 +124,21 @@ export const projectByteEntropyView = (
view,
summary: {
...context,
// The first page of the runs view; run_count tells whether more follow.
runs: selectViewRows(
report.runs,
{ offset: 0, limit: SUMMARY_RUN_LIMIT },
undefined,
(row) => row,
).rows,
// sample-cap: run_count reports the full total and the retained view pages the rest.
runs: report.runs.slice(0, SUMMARY_RUN_LIMIT),
top_runs: topRuns(report.runs),
},
coverage: completeWithinViewCoverage(report.blocks.length),
});
const selected =
view.collection === "blocks"
? selectViewRows(report.blocks, view, undefined, (row) => row)
: selectViewRows(report.runs, view, undefined, (row) => row);
const rows = report[view.collection];
return ok({
...shared,
kind: "byte-entropy" as const,
view,
entropy: context,
...selectedViewPage(view.offset, selected),
...selectedViewPage(view.offset, {
rows: rows.slice(view.offset, view.offset + view.limit),
total: rows.length,
}),
});
};