fix(analysis-view): return continuation for GPU pages at the byte limit (#15206)

* fix(analysis-view): return continuation for GPU pages at the byte limit

* test(analysis-view): admit GPU pagination requests through the schema

* fix(analysis-view): reuse shared byte-bounded GPU pagination
This commit is contained in:
ShuaixinHuang authored and GitHub committed 2026-11-30 19:09:46 +08:00
1 parent 6ec105be6d
commit 81657ccede
3 files changed
+147 -49

No files matched your search

@@ -5,6 +5,7 @@ import { gpuCodeObjectsSchema } from "../gpu/gpuCodeObjects.js";
import type { AnalysisViewParent } from "./analysisViewParent.js";
import {
gpuCodeObjectsItemsSchema,
gpuCodeObjectsViewRequestSchema,
projectGpuCodeObjectsView,
} from "./gpuCodeObjectsView.js";
@@ -106,3 +107,84 @@ it("preserves omitted AMD metadata columns instead of inventing null metadata",
];
expect(gpuCodeObjectsItemsSchema.parse(items)).toEqual(items);
});
it("pages GPU rows at the byte allowance in filtered order", () => {
const location = {
container_id: null,
offset: 0,
size: 0,
section_index: null,
section_name: null,
};
const source = gpuCodeObjectsSchema.parse({
...report(),
objects: ["first", "excluded", "second", "oversized"].map((id) => ({
id,
parent_id: null,
kind: "ptx",
target: null,
payload_target: null,
cuda_target_header: null,
amd_target_metadata: null,
amd_pal_metadata: null,
target_consistency: "unexamined",
bundle_id: null,
compression: "none",
compression_id: null,
encoded_size: 0,
decoded_size: 0,
sha256: null,
raw_flags: null,
location,
metadata_location: location,
inspection: "inventory",
limitations: ["x".repeat(id === "oversized" ? 1_100_000 : 550_000)],
})),
});
const input = parent(source);
const view = {
kind: "gpu-code-objects",
collection: "objects",
ids: ["second", "first"],
offset: 0,
limit: 2,
} as const;
const page = (request: unknown) =>
projectGpuCodeObjectsView(
input,
gpuCodeObjectsViewRequestSchema.parse(request),
);
const first = page(view);
expect(first).toMatchObject({
ok: true,
value: {
items: [{ id: "first" }],
coverage: { examined: 1, total: 2, next_offset: 1 },
},
});
if (!first.ok) throw first.error;
const second = page({
...view,
offset: first.value.coverage.next_offset!,
});
expect(second).toMatchObject({
ok: true,
value: {
items: [{ id: "second" }],
coverage: { examined: 1, total: 2, next_offset: null },
},
});
const oversized = { ...view, ids: ["oversized"] };
expect(page(oversized)).toMatchObject({
ok: false,
error: { _tag: "AnalysisResourceConstraintError" },
});
expect(page({ ...oversized, fields: ["id"] })).toMatchObject({
ok: true,
value: {
items: [{ id: "oversized" }],
coverage: { examined: 1, total: 1, next_offset: null },
},
});
});