Skip to content

feat(gpu)!: add per-call object, work, report, metadata, structure, and parser budgets to inspect_gpu_code_objects - #14882

Merged
morluto merged 10 commits into
morluto:mainfrom
Plastic-time:rrfz/gpu-code-object-budgets
Nov 27, 2026
Merged

morluto merged 10 commits into
morluto:mainfrom
Plastic-time:rrfz/gpu-code-object-budgets

Conversation

@Plastic-time

@Plastic-time Plastic-time commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Addresses Issue 14235. inspect_gpu_code_objects previously bounded object reads/decodes, aggregate work, retained reports, AMDGPU metadata, native ELF/PE section directories, parser entries, parser visits, and token/ID lengths with hardcoded ceilings that reported fixed_ceiling refusals without caller control.

This PR adds eight optional per-call budgets to inspect_gpu_code_objects (max_object_bytes, max_work_bytes, max_report_bytes, max_metadata_bytes, max_structure_bytes, max_parser_entries, max_parser_visits, max_token_bytes) while keeping every heap-bound maximum at main's existing ceiling. Top-level refusals report typed details.limit (adjustable_budget) with adapter-spelled recovery (cli_flag on CLI only); per-object inspection: "capacity" limitations inside multi-object containers append (parameter: <name>). Genuine nesting caps (gpu-container-nesting-depth = 8, amdgpu-metadata-depth = 32) and the 128-token PTX single-parameter syntax cap stay fixed, superseded hardcoded ceiling constants are removed, and both pending entries for src/gpu/GpuCodeObjectsProvider.ts are removed from scripts/verify/fixed-ceiling-registry.json.

Problem and expected behavior

Before this change:

  • src/gpu/GpuCodeObjectsProvider.ts and its parsers (GpuSource.ts, GpuPayloadCodec.ts, ClangOffloadBundle.ts, CudaInfo.ts, AmdGpuMetadata.ts, PtxKernels.ts, GpuElfKernels.ts, GpuInventory.ts) enforced hardcoded ceilings (GPU_OBJECT_BYTES, GPU_REPORT_BYTES, AMD_METADATA_BYTES, CLANG_BUNDLE_MAX_*, AMD_METADATA_VALUES, AMD_METADATA_CONTAINER_ENTRIES, AMD_METADATA_VALUE_BYTES, and hardcoded work/PTX/CUDA counts) and mapped every BinaryResourceFailure to fixed_ceiling ("The GPU inspection allowance" / "The GPU object allowance").

Expected behavior:

  • inspect_gpu_code_objects accepts eight optional per-call budgets (CLI --max-object-bytes, --max-work-bytes, --max-report-bytes, --max-metadata-bytes, --max-structure-bytes, --max-parser-entries, --max-parser-visits, --max-token-bytes), keeping existing defaults when omitted and preserving omission in Evidence.parameters:
    • max_object_bytes: default 134217728 (128 MiB), range 1..134217728 (128 MiB)
    • max_work_bytes: default 536870912 (512 MiB), range 1..536870912 (512 MiB; covers payload input, decoded output, native-section reads, and AMDGPU note/structure reads)
    • max_report_bytes: default 16777216 (16 MiB), range 1..16777216 (16 MiB)
    • max_metadata_bytes: default 8388608 (8 MiB), range 1..8388608 (8 MiB)
    • max_structure_bytes: default 16777216 (16 MiB), range 64..536870912 (512 MiB) via shared maxStructureBytesSchema
    • max_parser_entries: default 65536, range 1..65536
    • max_parser_visits: default 262144, range 1..262144
    • max_token_bytes: default 65536, range 1..65536
  • Heap-bound ceilings stay anchored to main's existing maxima (max_work_bytes <= 512 MiB, max_object_bytes <= 128 MiB, max_report_bytes <= 16 MiB, max_metadata_bytes <= 8 MiB, plus shared max_structure_bytes up to 512 MiB when explicitly raised). Full-file SHA-256 streams fixed 1 MiB chunks independently of max_object_bytes, container padding scans clamp reads to min(64 KiB, max_object_bytes), and standalone PTX format recognition confirms .version <major>.<minor> before applying max_object_bytes or max_token_bytes so non-GPU inputs fail with unsupported_target.
  • Top-level budget refusals fail with code: "resource_constraint", details.limit (control_kind: "parameter", parameter, effective_value, minimum, maximum, default_value, unit, applies_at: "next_call", plus required_value when known and cli_flag on CLI only), and details.refusal.kind: "adjustable_budget", retaining partial observations when available.
  • Per-object capacity refusals inside multi-object containers retain sibling objects with inspection: "capacity" and append (parameter: <name>) to the object's limitation note. Multi-frame and trailing zero-output Zstandard CCOB v1 streams stopped at a frame boundary or partial next-frame magic verify whether another Zstandard/skippable frame follows (checking zstd.max_frames first, refilling cached windows once without double-charging declaredDecodedSize, or reporting max_object_bytes capacity) before publishing an extent.
  • Genuine recursion/nesting limits (gpu-container-nesting-depth = 8 levels, amdgpu-metadata-depth = 32 levels) remain "The GPU nesting allowance", and unmapped parser syntax limits (such as 128 tokens per PTX parameter declaration) remain fixed "The GPU parser syntax allowance" (representation) without escaping Result.

Change and scope

  • src/domain/gpu/gpuCodeObjectsBudgets.ts (new): owns GPU budget defaults, ceilings, Zod fields, resolution, formatGpuByteBudget, gpuBudgetParameterForLimit, gpuCodeObjectsBudgetLimit, and GPU limit name constants.
  • src/domain/gpu/gpuCodeObjects.ts and src/domain/gpu/gpuCodeObjectsEvidence.ts: wire ...gpuCodeObjectsBudgetFields into inspectGpuCodeObjectsInputSchema / GpuCodeObjectsInput and record caller-supplied budgets in Evidence.parameters while omitting unspecified ones.
  • src/domain/compression/zstandardFrameWire.ts and src/domain/compression/zstandardExactFrame.ts: export ZSTANDARD_TRUNCATION_REASONS, isZstandardTruncationReason, and zstandardFrameMagicStatus; surface inputExhausted and frameAllowanceReached on ZstandardFrameSuccess when prefix framing stops at an exact frame boundary or 1-3 byte next-frame magic prefix.
  • src/gpu/GpuSource.ts, src/gpu/GpuPayloadCodec.ts, and src/gpu/CudaFatbinary.ts: thread GpuCodeObjectsBudgets; export shared CONTAINER_SCAN_CHUNK_BYTES (64 KiB) for nextGpuContainerOffset, CCOB recovery, and PTX recognition; forward signal to nextGpuContainerOffset in CudaFatbinary.ts; keep GpuFileSource.digest() streaming 1 MiB chunks; route native ELF/PE directory reads through readBounded under maxStructureBytes; enforce expected > maxObjectBytes before decode and re-tag LZ4 limits as GPU_OBJECT_BYTES_LIMIT; carry optional lower-bound minimumReportBytes on GpuReportCapacityFailure (kept out of details.limit.required_value and reported in details.reported_limits.minimum_report_bytes); export isTruncatedGpuPayloadFailure and surface inputExhausted / frameAllowanceReached from decodeGpuPayloadStream.
  • src/gpu/GpuInventory.ts, src/gpu/ClangOffloadBundle.ts, src/gpu/PtxKernels.ts, src/gpu/AmdGpuMetadata.ts, src/gpu/CudaInfo.ts, src/gpu/GpuElfKernels.ts:
    • Remove superseded hardcoded ceiling constants (GPU_OBJECT_BYTES, GPU_REPORT_BYTES, AMD_METADATA_BYTES, CLANG_BUNDLE_MAX_*, AMD_METADATA_VALUES, AMD_METADATA_CONTAINER_ENTRIES, AMD_METADATA_VALUE_BYTES).
    • Meter native-section sectionSource and #amdPayload child reads against max_work_bytes (#budgetWork for object reads, #reserveWork for NATIVE_STRUCTURE_LIMIT and explicit readWorkOnly recognition reads) while tracking #meteredSources (!parentMetered and #reserveReadWork) to prevent double-charging; share #checkObjectBytes across #budgetWork and metered standalone PTX probes.
    • Charge declaredDecodedSize once on CCOB v1 cached-window refill (readWindow(false)), peek 4 bytes past consumedBytes when inputExhausted to check zstd.max_frames, refill, or report ccobWindowLimit(), and extend findLegacyCcobRecoveryTotal read end by 4 bytes so corrupt v1 extents equal to max_object_bytes still recover an immediately following CCOB marker starting at <= base + max_object_bytes.
    • Add incremental createPtxVersionScanner() (matching ptxVersion's safe-integer digit rules without retaining scanned chunks, so peak standalone PTX heap stays at 1x probeSize with zero Buffer.concat copies) and defer max_token_bytes in readPtxTarget until .version <major>.<minor> is confirmed — then validate both recognized header tokens against max_token_bytes — so non-GPU inputs fail with unsupported_target while recognized PTX headers remain bounded in both inventory and kernels modes; keep the 128-token PTX single-parameter syntax limit fixed with its own message (PtxKernels.ts:432 and :491); exempt fixed-width MsgPack float32/float64 scalars (0xca/0xcb) from maxTokenBytes; enforce the 1024-byte baseline report reservation with minimum_report_bytes in details.reported_limits and preserve whole-MiB "512 MiB per inspection" wording.
  • src/gpu/GpuCodeObjectsProvider.ts and scripts/verify/fixed-ceiling-registry.json: map each adjustable GPU limit via gpuBudgetParameterForLimit (surfacing minimum_report_bytes in details.reported_limits while omitting required_value on lower-bound report refusals) / nativeStructureLimit, retain "The GPU nesting allowance" for container/AMDGPU depth, and map unmapped fixed parser limits to "The GPU parser syntax allowance" (both registered as "representation"; both pending entries removed).
  • src/cli/gpuCommands.ts: expose all eight --max-* CLI flags and forward only caller-supplied values.
  • scripts/verify/advertised-schemas/tools/inspect_gpu_code_objects.json: update advertised schema summary (input compact: "48e65025c05627f4").
  • Docs: update docs/reference/limits-and-recovery.md, docs/reference/rea-limit-inventory.md, and docs/gpu-code-objects.md (including max_report_bytes scan wording, native-section/AMDGPU structure reads under max_work_bytes, and the fixed 128-token PTX parameter row).
  • Tests: update src/domain/compression/zstandardExactFrame.test.ts, src/gpu/GpuPayloadCodec.test.ts, src/gpu/AmdGpuMetadata.test.ts, src/gpu/PtxKernels.test.ts, tests/boundary/gpu/codeObjects.test.ts, and tests/acceptance/gpuCodeObjectsCli.test.ts.

Contribution scope: not applicable (per-call budget controls replacing two tracked pending fixed ceilings on an existing read-only GPU code object reader; no new provider, execution, injection, or mutation).

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/domain/gpu/gpuCodeObjectsBudgets.ts owns all GPU-specific budget bounds, Zod fields, resolution, and LimitRef construction (max_structure_bytes reuses src/domain/native/nativeStructureBudget.ts); gpuCodeObjects.ts, gpuCodeObjectsEvidence.ts, src/cli/gpuCommands.ts, and src/gpu/* consume them directly. Superseded ceiling constants are removed.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract: BREAKING CHANGE — inspect_gpu_code_objects adds eight optional per-call budget parameters (--max-object-bytes, --max-work-bytes, --max-report-bytes, --max-metadata-bytes, --max-structure-bytes, --max-parser-entries, --max-parser-visits, --max-token-bytes), and top-level GPU budget refusals now report details.limit and details.refusal.kind: "adjustable_budget" instead of fixed_ceiling. Per-object inspection: "capacity" limitations inside multi-object containers append (parameter: <name>). Omitted budgets remain omitted in Evidence.parameters.
  • Provider, bridge, target-format, or platform compatibility: portable offline GPU code object reader; no external tool, driver, or GPU hardware dependency changed.
  • Evidence, artifact, provenance, or reconstruction contract: partial observations on budget refusal preserve completed declarations and unverified root digest semantics; caller-selected budgets appear in Evidence.parameters only when explicitly supplied.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): file-limit and descriptor-close failures continue to preserve max_object_bytes as primary alongside cleanup facts and retained partial observations.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: updated scripts/verify/advertised-schemas/tools/inspect_gpu_code_objects.json (POSIX summary).

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated:
    • tests/boundary/gpu/codeObjects.test.ts:
      • enforces per-call GPU budgets and recovers when raised: exercises all eight budgets with typed details.limit / per-object (parameter: ...) capacity limitations and retry recovery.
      • respects max_object_bytes during container scanning and full-file digesting: spies on GpuSource.readBounded during nextGpuContainerOffset (size and limit <= 512) and verifies 32 KiB full-file SHA-256 streams independently of max_object_bytes: 1.
      • keeps PTX single-parameter 128-token ceiling fixed independently of max_parser_entries: pins main's existing fixed 128-token syntax cap on entry parameter lists and PTX 1.3 body .param declarations (with its fixed syntax message and no (parameter: max_parser_entries)), while verifying max_parser_entries: 4 still accepts a normal single-parameter kernel.
      • keeps corrupt CCOB v1 recovery distinct from max_object_bytes window truncation: covers corrupt v1 malformed recovery of a later v2 sibling, stored zlib truncation (ccobWindowLimit()), multi-frame Zstd (+0/+1/+2/+3) with decoded <= budget < encoded, trailing zero-output Zstd (skippable and empty frames) at +0/+1/+2/+3/header/body plus cached-window refill, exact-fit Zstd followed by NUL or __CLANG_OFFLOAD_BUNDLE__ ('_' = 0x5f) without false refusals or double-charged refills, 40 aliased 32-section AMDGPU entries under max_work_bytes: 16_384 (recovering at 512 KiB), and max_work_bytes <= 512 MiB schema enforcement.
      • does not double-charge work on CCOB v1 refill, bounds aliased sections, keeps non-GPU inputs unsupported, and aligns zstd.max_frames and recovery bounds: covers single-charged declaredDecodedSize on cached refill, post-refill second hasFollowingZstandardFrame before trailing NUL, 40 aliased .hip_fatbin sections pointing to a 3,860-byte PTX payload under max_work_bytes: 16_384 (exact 4 complete, 36 capacity), single .hip_fatbin 6,060-byte PTX under max_work_bytes: 6100 (complete) and max_object_bytes: 4096 (capacity), single-charged work across metered CCOB v2, nested .hip_fatbin ELF sections, and nested .hip_fatbin AMDGPU ELF, non-GPU plain text under lowered max_object_bytes (512, 1) and max_token_bytes (16), recognized PTX .version header enforcement under analysis: "inventory", max_token_bytes: 7 and 70,000-byte zero-padded version under default max_token_bytes: 65_536, zstd.max_frames: 1 precedence at +0..+4, corrupt CCOB v1 recovery when total length equals max_object_bytes (vs max_object_bytes + 1), and CudaFatbinary cancellation during NUL padding scan.
      • applies max_structure_bytes independently of max_object_bytes and covers PE, CUBIN, and report baseline: covers max_object_bytes < max_structure_bytes ELF reading, constructor baseline max_report_bytes: 500 refusal omitting details.limit.required_value while reporting details.reported_limits.minimum_report_bytes (and succeeding on empty ELF when retried with that bound), PE max_structure_bytes, and CUBIN max_parser_visits.
      • Updates reports aggregate Clang directory capacity when every ID fits to verify typed details.limit (max_report_bytes, adjustable_budget).
    • src/domain/compression/zstandardExactFrame.test.ts: pins inputExhausted across frame-boundary EOF, 1-3 byte Zstandard/skippable magic prefixes (true), and definite non-frame suffixes (false), including cooperative decode and allowance(1, "runtime") prefix mode.
    • src/gpu/GpuPayloadCodec.test.ts: pins inputExhausted and isTruncatedGpuPayloadFailure across truncated, corrupt, and output-overflow zlib and Zstandard streams.
    • src/gpu/PtxKernels.test.ts: verifies readPtxTarget does not preempt non-PTX text with max_token_bytes: 16, enforces max_token_bytes on recognized .version (max_token_bytes: 7) and 70,000-byte zero-padded version tokens as well as subsequent tokens, and verifies createPtxVersionScanner agrees with readPtxTarget on >32-byte leading-zero version literals.
    • src/gpu/AmdGpuMetadata.test.ts: verifies a MsgPack float64 scalar (0xcb) is not falsely rejected when maxTokenBytes is 4.
    • tests/acceptance/gpuCodeObjectsCli.test.ts: verifies CLI --max-report-bytes refusal (cli_flag, maximum: 16777216, adjustable_budget) and recovery (Evidence.parameters), MCP max_report_bytes refusal (no cli_flag), and omitted-budget preservation.
  • Base reproduction, heap measurement, and targeted mutation evidence:
    • Base 366e1d98c: running the original six new/updated budget tests failed 6 failed | 150 skipped (156). After restoring the fixed 128-token PTX single-parameter cap to match base, keeps PTX single-parameter 128-token ceiling fixed independently of max_parser_entries intentionally pins base behavior (green on base, fails if widened back to Math.max(128, maxParserEntries)).
    • Peak standalone PTX ArrayBuffer heap (probe-mem.mts, 12 MiB PTX, Node --expose-gc):
      • Base 366e1d98c: inventory 10.84 MiB (bigConcats: []), kernels 11.98 MiB (bigConcats: []).
      • Prior head 5fb97d906 (retained scannedChunks + Buffer.concat): inventory 23.94 MiB, kernels 24.00 MiB (bigConcats: [12582912]).
      • Head a855caa51 (unchanged in 00e8705aa, streaming recognition without retaining chunks): inventory 12.00 MiB (bigConcats: []), kernels 12.00 MiB (bigConcats: []).
    • Prior PR heads:
      • c77939148: respects max_object_bytes|keeps corrupt CCOB v1 failed 2 failed | 154 skipped (156).
      • 937081dc0: trailing skippable and empty Zstandard frames after a complete data frame failed 8/8 (+0/+1/+2/+3) with Unexpected bytes between Clang offload bundles.
      • b3394fc9f: standalone probe of 40 aliased 64-section (4,096-byte section table) AMDGPU entries under max_work_bytes: 32_768 reported capacityCount: 0 (vs capacityCount: 33 with (parameter: max_work_bytes) after the #reserveWork fix).
      • b262e3c15: standalone probes reproduced CCOB v1 cached-refill work double-charge (max_work_bytes: 883 -> capacity vs ["complete", "complete"]), 40 aliased .hip_fatbin sections pointing to 4,860-byte PTX under max_work_bytes: 16_384 (bytesRead: 198,503, capacityCount: 0 vs bytesRead: 18,683, capacityCount: 37), non-GPU 1,200-byte text with max_object_bytes: 512 and 59-byte text with max_token_bytes: 16 (AnalysisResourceConstraintError vs unsupported_target), [skippable, data] + zstd.max_frames: 1 at +0..+3 (max_object_bytes capacity vs zstd.max_frames), and corrupt CCOB v1 of length 200 === max_object_bytes before valid v2 (["capacity"] vs ["malformed", "complete"]).
    • Targeted mutations:
      • On 5fb97d906 (9/9 killed): readWindow(true) double-charge, removing sectionSource work metering, bypassing incremental PTX recognition with direct source.read, enforcing max_token_bytes before .version in readPtxTarget, removing the post-refill second hasFollowingZstandardFrame check, removing frameAllowanceReached precedence, shrinking findLegacyCcobRecoveryTotal searchEnd back to maxStart, and widening either PTX 128-token guard (PtxKernels.ts:432 and :491) to Math.max(128, maxParserEntries).
      • On a855caa51 (6/6 killed): disabling #reserveReadWork's metered branch, removing #checkObjectBytes(probeSize) on metered standalone PTX probes, removing !parentMetered on sectionSource.readWorkOnly, removing !parentMetered on #amdPayload child.readBounded, dropping signal from CudaFatbinary nextGpuContainerOffset, and omitting the baseline bound from GpuReportCapacityFailure.
      • On 00e8705aa (3/3 killed, clean restore): dropping the post-recognition length check on first.value (.version), dropping the post-recognition length check on declaredVersion.value, and passing minimumReportBytes back into BinaryResourceFailure's limit.required.
  • User-visible CLI/MCP output (if applicable): rea inspect-gpu-code-objects <sample.ptx> --analysis kernels --max-report-bytes 64 --json exits 1 with code: "resource_constraint", details.limit (control_kind: "parameter", parameter: "max_report_bytes", cli_flag: "--max-report-bytes", effective_value: 64, minimum: 1, maximum: 16777216, default_value: 16777216, unit: "bytes", applies_at: "next_call", omitting required_value because it is a lower bound), details.reported_limits.minimum_report_bytes, details.refusal.kind: "adjustable_budget", and remediation.action naming --max-report-bytes; retrying with --max-report-bytes 1048576 exits 0 and records max_report_bytes: 1048576 in Evidence.parameters. MCP inspect_gpu_code_objects omits cli_flag and preserves omitted budgets in Evidence.parameters.
  • Remaining proof gaps: npm run check:pr was not run locally; advertised schema summary for inspect_gpu_code_objects was verified on Windows via in-process POSIX platform preload ({"tools":241,"same":241,"differ":[],"missing":[]}) and Linux CI will confirm verify:advertised-schemas.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

Executed on Windows (Node.js v24.22.1, base 366e1d98c, head 00e8705aa):

  • npm run build:cached — passed
  • POSIX advertised-schema summary check — {"tools":241,"same":241,"differ":[],"missing":[]} (scripts/verify/advertised-schemas/tools/inspect_gpu_code_objects.json, input compact: "48e65025c05627f4")
  • npx vitest run --cache=false src/gpu/PtxKernels.test.ts tests/acceptance/gpuCodeObjectsCli.test.ts — 63 passed (PtxKernels.test.ts 40/40, gpuCodeObjectsCli.test.ts 23/23); full 10-file unit/process-global/CLI/MCP suite passed 140/140 on a855caa51
  • npx vitest run --cache=false tests/boundary/gpu/codeObjects.test.ts -t "does not double-charge work|applies max_structure_bytes|enforces per-call GPU budgets" — 3 passed | 154 skipped (157) (full 10-case targeted boundary suite passed 10/10 on a855caa51)
  • node scripts/verify/fixed-ceilings.mjs — passed (Fixed ceilings: 66 declarations registered; 29 pending a control. Authored-only refusals: 57.)
  • npx knip (uncached) — passed (0 errors)
  • npm run check:fast — passed (typecheck, lint, verify:architecture-guards across 3240 source files)

Compatibility, safety, and release

  • Breaking changes or migration steps: BREAKING CHANGE: inspect_gpu_code_objects adds eight optional per-call budget parameters (max_object_bytes, max_work_bytes, max_report_bytes, max_metadata_bytes, max_structure_bytes, max_parser_entries, max_parser_visits, max_token_bytes) and reports details.limit + adjustable_budget instead of fixed_ceiling on top-level GPU budget refusals. Under default budgets, large non-GPU inputs that previously hit the standalone PTX scan ceiling now fail with unsupported_target once incremental format recognition confirms the first module token is not .version <major>.<minor>. All defaults match previous behavior when omitted. Migration: callers matching details.refusal.kind === "fixed_ceiling" on GPU budget refusals should read details.limit (adjustable_budget) and retry with a larger budget within the documented ceiling.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (offline binary/text GPU code object parser; verified locally through CLI, MCP, process-global, and provider tests).
  • Package or release metadata impact: scripts/verify/advertised-schemas/tools/inspect_gpu_code_objects.json updated.
  • Security, privacy, process, or containment review: read-only bounded file/container/metadata/PTX inspection with all heap-bound maxima kept at main's existing ceilings (max_work_bytes <= 512 MiB, max_object_bytes <= 128 MiB, max_report_bytes <= 16 MiB, max_metadata_bytes <= 8 MiB), native-section and AMDGPU structure reads metered under max_work_bytes, and fixed nesting/syntax caps (8 container levels, 32 AMDGPU metadata levels, 128 tokens per PTX parameter declaration); no execution, filesystem writes, or network access.

Author readiness

Human owner: @Plastic-time

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Author checklist (completed by the PR author before requesting review)

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.
  • I ran every test, build, or measurement needed to validate this change, reported a browser, GPU, or environment gap only when that runtime or hardware is unavailable, and reported the checks I ran and their results without presenting inferred correctness or speedups as measured.
  • Comments explain constraints or non-obvious decisions; task history and conversations stay out of code and docs.
  • Documentation is concise and factual, without punchy slogans or promotional language.
  • This change fixes the root cause and follows the engineering rules in AGENTS.md.
  • Formatted input is interpreted once at the owning boundary, and consumers use the owner's parsed facts. See Interpret boundary facts once.
  • Combined failures preserve partial observations, remaining resources, and cleanup facts. See Own the lifecycle.
  • A hardcoded limit is an REA_ runtime setting with a default, floor, and maximum, unless a fixed ceiling has a stated reason. See Adding a runtime setting.

…nd 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.
@greptile-apps

greptile-apps Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; both prior findings are fixed and no new blocking issue was found.RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; both prior findings are fixed and no new blocking issue was found.

Summary

Adds eight per-call budgets to inspect_gpu_code_objects, with typed recovery and named per-object limits.

  • GPU inspection calls can set eight bounded budgets.
  • GPU readers apply caller budgets across payloads and metadata.
  • Standalone PTX checks confirm a version header before applying token limits.
  • CCOB v1 checks for more Zstandard frames before recording a payload end.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[CLI or MCP request] --> B[Resolve caller budgets and defaults]
  B --> C[Inspect GPU objects]
  C --> D{Budget exceeded?}
  D -->|No| E[Return observations]
  D -->|Report or top-level limit| F[Return typed resource refusal]
  D -->|Individual object limit| G[Mark object capacity and retain siblings]
  G --> E
  F --> H[Keep partial byte needs separate from required_value]
Loading

Reviews (6) · Last reviewed commit: "fix(gpu): report lower-bound report byte..." · Reviewed by Greptile

Comment thread src/gpu/GpuSource.ts Resolved
Comment thread src/gpu/GpuInventory.ts Resolved
Comment thread src/domain/gpu/gpuCodeObjectsBudgets.ts Resolved
Comment thread tests/boundary/gpu/codeObjects.test.ts Resolved
@Plastic-time
Plastic-time marked this pull request as ready for review November 27, 2026 12:25
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T16:15:09.603025Z 00e8705 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 937081dc0b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/gpu/GpuInventory.ts Resolved
Comment thread src/gpu/GpuInventory.ts Resolved
Comment thread src/gpu/PtxKernels.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a855caa517

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/gpu/PtxKernels.ts Resolved
…rce max_token_bytes on recognized PTX headers
@morluto
morluto enabled auto-merge (squash) November 27, 2026 16:13
@morluto
morluto merged commit 2e59f08 into morluto:main Nov 27, 2026
41 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 00e8705aa2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/gpu/GpuInventory.ts
Comment on lines 320 to +323
const directory = await readGpuNativeDirectory(
source,
elf
? readElfSectionDirectory(source.size)
: readPeSectionDirectory(source.size),
? readElfSectionDirectory(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Meter standalone AMDGPU directory reads against max_work_bytes

For a standalone AMDGPU ELF inspected with analysis: "inventory", this directory read uses the unmetered root GpuFileSource; #amdPayload subsequently reuses the directory and skips its metered parsing path. Consequently, the advertised aggregate budget does not cover standalone AMDGPU structure reads: an isolated file-source probe fully read a 6,528-byte section table with max_work_bytes: 1024 without reporting capacity, whereas the identical ELF inside a Clang bundle correctly hit that limit. Reserve aggregate work before these initial directory reads so standalone inputs cannot bypass the caller's admission budget.

AGENTS.md reference: AGENTS.md:L70-L70

Useful? React with 👍 / 👎.

vincentkoc added a commit that referenced this pull request Nov 27, 2026
…pgp-633-20261127

* commit '3097263763611eb0c32c502d5a222060cf02f468':
  fix(cli): describe universal Mach-O slice selection without a single-dash flag (#14912)
  fix(iso9660): read Joliet trees whose .. records name their own directory (#14817)
  feat(gpu)!: add per-call object, work, report, metadata, structure, and parser budgets to inspect_gpu_code_objects (#14882)
  fix(macho)!: select arm64e.x1 slices of universal Mach-O files by exact subtype (#14881)
  refactor(views): share bounded parent and report limitations (#14902)
  refactor(desktop): share XML parent pointers in task drafts (#14905)
  feat(ghidra): define function-pointer members and typedefs (#14889)
  refactor(setup): share publication destination checks (#14904)
  perf(ci): skip unused test runtime uploads (#14903)
  fix(nuget): preserve explicitly spaced publisher metadata (#14906)
  fix(artifacts): keep uImage coverage unknown when bytes follow the declared payload (#14896)
  fix(artifacts): report incomplete Android sparse coverage (#14883)
  fix(tar): require both end-of-archive blocks for complete coverage (#14884)
  refactor(views): centralize indexed row paging (#14878)
  refactor(views): reuse optional filters in report projections (#14877)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants