Skip to content

fix(model): count GGUF nesting frames instead of total value depth - #10497

Open
LexLuthorPrimero wants to merge 1 commit into
morluto:mainfrom
LexLuthorPrimero:fix/gguf-nesting-guard
Open

LexLuthorPrimero wants to merge 1 commit into
morluto:mainfrom
LexLuthorPrimero:fix/gguf-nesting-guard

Conversation

@LexLuthorPrimero

@LexLuthorPrimero LexLuthorPrimero commented Nov 14, 2026 •

Copy link
Copy Markdown

Summary

Fixes #7312.

The GGUF metadata nesting cap (MODEL_METADATA_NESTING = 32) was documented as "array frames" but enforced as depth of every recursive value, counting the depth of scalar leaves (and any non-array object) toward the cap. That meant an advertised-contract combination — 33 nested arrays ending with a scalar — tripped the cap, while a 33-nested but empty-final-array case slipped through. Test expectations were inconsistent with both contracts.

Change and scope

  • src/model/GgufHeader.ts: the capacity throw fires only on nested array (type === 9) values at depth >= MODEL_METADATA_NESTING — i.e., 32 ARRAY frames in, the 33rd depth-32 frame is rejected; scalar leaves at depth 32 parse normally; non-array terminals at any legal depth are not refused. The IEC Decoder capacity ("metadata-nesting") reference stays 32 array frames; from the inside out, no nesting at which a scalar leaf is reachable is bounded.
  • Tests: an additional 32-frame custom.nested fixture (32 nested arrays with a UINT8 scalar leaf at maximum depth) is added, exercising the documented contract exactly: 32-array controls parse, deeper arrays and scalar-bearing ones do not.
  • Re-ran the entire model boundary suites — 139/139 passed; 33 nested exact-frame refusal now matches the advertised contract.

Evidence

  • npx vitest run src/model tests/boundary/model — 146 passed (incl. the new bounded-frame fixture).
  • npm run typecheck, npm run format:check, npm run lint — passed.

Known gaps / honest limitations

  • The new fixture uses synthetic small custom.nested buffers of ≤32 frames, with frame 0 → 0x00 (UINT8) as the outer-optional grammar convention matching the existing nesting 33 frames fixture. Not an across-the-board GGUF conformance claim.
  • This sharpens the parser to match its documented contract — it does not broaden compatibility beyond the contract; it reduces it to exactly 32 array frames.
  • No Windows or macOS runtime check; this host is Linux x86_64 with Node 24.22.1 only.

Compatibility

Breaking changes: none for compliant artifacts — artifacts that previously parsed still parse; artifacts that previously hit the capacity failure at the scalar leaf of depth 32 (but were not actually exceeding 32 array frames) now parse.

Author readiness

Human owner: @LexLuthorPrimero

  • 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.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-14T08:19:18.169330Z
We couldn’t complete this review. Comment @codex review to try again.
a81e799 PR opened
ℹ️ 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

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Low impact] The PR's reach is limited to deeply nested metadata during GGUF model inspection.

The implementation appears safe to merge, with a non-blocking gap in regression coverage.

Findings

  1. P2 Changed boundary lacks test coverage ▶
Fix with agent prompt
### Issue 1
tests/boundary/model/modelArtifact.test.ts:406-414
The new 32-array scalar test passes with the old guard too: its scalar reaches depth 32, while the old guard rejected only depths above 32. The existing 33-array scalar test also passes with the old guard because its scalar reaches depth 33.

Add a 33-frame case whose innermost array is empty, and assert the `metadata-nesting` capacity failure. That covers the changed behavior; reverting this fix currently leaves both nesting tests passing.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

GgufHeader now enforces the advertised limit of 32 array frames.

  • GGUF inspection accepts scalar leaves after 32 nested arrays.

No security defect was identified. Review was source-based; tests were not run. Whether this PR is superseded could not be checked because GitHub access required authentication.

Reviews (1) · Last reviewed commit: "fix(model): count GGUF nesting frames in..." · Reviewed by Greptile

This branch has not been deployed

No deployments
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.

[Bug] GGUF accepts 33 nested array frames while advertising a maximum of 32

1 participant