mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 05:51:06 +00:00
* feat(gpu)!: add per-call object, work, report, metadata, structure, and parser budgets to inspect_gpu_code_objects Replace the pending GPU object and parser ceilings in GpuCodeObjectsProvider with domain-owned optional per-call parameters (max_object_bytes, max_work_bytes, max_report_bytes, max_metadata_bytes, max_structure_bytes, max_parser_entries, max_parser_visits, and max_token_bytes) reporting details.limit and adjustable_budget, remove superseded hardcoded constants, and register only the recursive container and AMDGPU MessagePack nesting caps as a fixed representation allowance. BREAKING CHANGE: inspect_gpu_code_objects adds optional per-call budget parameters and reports details.limit with details.refusal.kind "adjustable_budget" instead of "fixed_ceiling" on top-level object, work, report, metadata, structure, and parser budget refusals. * fix(gpu): clamp padding scans, classify multi-frame CCOB budget cuts, and keep max_work_bytes at 512 MiB * fix(gpu): align --max-work-bytes help text, release partial decode before refill, and admit floats under small token budgets * test(gpu): keep multi-frame CCOB v1 decoded size within cut budgets * fix(gpu): report decoder inputExhausted to refill and bound trailing Zstandard frames * fix(gpu): peek next Zstd frame, charge AMD structure reads to work budget, and keep 128-token PTX limit * fix(gpu): fix CCOB refill work double-charge, meter section reads, decouple non-GPU recognition, and align frame/recovery bounds * refactor(gpu): drop redundant lookahead on non-refill path and pin refill/readBounded regressions * fix(gpu): keep standalone PTX peak heap at 1x, use explicit scan reads, forward CUDA cancel signal, and report max_report_bytes required_value * fix(gpu): report lower-bound report bytes in reported_limits and enforce max_token_bytes on recognized PTX headers
97 lines
3.7 KiB
TypeScript
97 lines
3.7 KiB
TypeScript
import type { Logger } from "pino";
|
|
|
|
import { createGpuCodeObjectsService } from "../composition/gpu.js";
|
|
import { GPU_TOOL_CONTRACTS } from "../contracts/gpu/gpuToolContracts.js";
|
|
import { contractNamed } from "./contractCliDescription.js";
|
|
import { registerContractCommand } from "./contractCommand.js";
|
|
import { deliverWithService } from "./contractCommandRunners.js";
|
|
import type { CliInstance } from "./types.js";
|
|
|
|
/** One-shot summaries export the same complete observations used by MCP retained pages. */
|
|
export const registerGpuCommands = (cli: CliInstance, logger: Logger): void => {
|
|
const deliver = deliverWithService(
|
|
createGpuCodeObjectsService,
|
|
"gpu-code-objects",
|
|
);
|
|
registerContractCommand(
|
|
cli,
|
|
logger,
|
|
contractNamed(GPU_TOOL_CONTRACTS, "inspect_gpu_code_objects"),
|
|
{
|
|
description:
|
|
"Inspect embedded CUDA/HIP targets and selected static kernel metadata",
|
|
positionals: ["path"],
|
|
callerPaths: ["path"],
|
|
evidenceDelivery: true,
|
|
viewDelivery: {
|
|
invalidJson: "view must be valid JSON",
|
|
kind: "gpu-code-objects",
|
|
},
|
|
runtimeJson: {
|
|
object_ids: "object_ids must be valid JSON",
|
|
targets: "targets must be valid JSON",
|
|
},
|
|
fields: {
|
|
path: {
|
|
description: "Local ELF/PE, CUDA fatbin, CUBIN, PTX or HIP bundle",
|
|
},
|
|
analysis: {
|
|
description:
|
|
"Inventory GPU targets or decode selected kernel metadata",
|
|
},
|
|
expected_sha256: {
|
|
name: "expected_sha256",
|
|
description:
|
|
"Inventory SHA-256 as 64 lowercase hex digits; required with --object_ids",
|
|
},
|
|
object_ids: {
|
|
name: "object_ids",
|
|
description: "JSON array of exact object IDs to decode",
|
|
},
|
|
targets: {
|
|
description: "JSON array of exact target declarations to decode",
|
|
},
|
|
max_object_bytes: {
|
|
description:
|
|
"Maximum bytes per GPU object read or decoded buffer (default and maximum 134217728)",
|
|
},
|
|
max_work_bytes: {
|
|
description:
|
|
"Maximum aggregate payload input, decoded output, native-section, and AMDGPU note/structure bytes per inspection (default and maximum 536870912)",
|
|
},
|
|
max_report_bytes: {
|
|
description:
|
|
"Maximum bytes for retained GPU report facts, PTX text, Clang directories, and CUDA temporary indexes (default and maximum 16777216)",
|
|
},
|
|
max_metadata_bytes: {
|
|
description:
|
|
"Maximum AMDGPU ELF note and MessagePack metadata bytes (default and maximum 8388608)",
|
|
},
|
|
max_structure_bytes: {
|
|
description:
|
|
"Maximum bytes of one native ELF/PE section table or decoded section names (default 16777216, up to 536870912)",
|
|
},
|
|
max_parser_entries: {
|
|
description:
|
|
"Maximum entries per Clang bundle directory, PTX kernel/parameter list, or AMDGPU container (default and maximum 65536)",
|
|
},
|
|
max_parser_visits: {
|
|
description:
|
|
"Maximum aggregate CUDA record/symbol visits or AMDGPU MessagePack values per code object (default and maximum 262144)",
|
|
},
|
|
max_token_bytes: {
|
|
description:
|
|
"Maximum bytes per Clang bundle ID, PTX token, or AMDGPU MessagePack scalar (default and maximum 65536)",
|
|
},
|
|
view: {
|
|
description:
|
|
"JSON GPU object/kernel/PTX page selection; requires --detail summary and --evidence_output",
|
|
},
|
|
},
|
|
},
|
|
// The CLI delivers the summary itself, so the service returns complete
|
|
// Evidence; the contract's own default would retain a summary instead.
|
|
(input, context) => deliver({ ...input, detail: "complete" }, context),
|
|
);
|
|
};
|