Bound what a document expands into, not only what it weighs - #121
Merged
Conversation
A YAML file of 772 bytes took the process down with a fatal error. Anchors and aliases expand inside the parser, before any budget measures anything, and the byte budget measures the file; the reference resolver's own budget counts the nodes it descends into, and since the third wave it rightly does not descend into data — `enum`, `example`, `default`, `const` — which is exactly where an alias is as welcome as anywhere else. Both behaviours are right on their own; together they left an unbounded path, and the fail-closed encodability check was the amplifier that turned it into 800 MB of JSON. Documents are now measured by what they expand into: a node budget on `Limits`, counted iteratively at every entry point and shared across a multi-file graph the way the byte budget already is. Counting stops at the budget, so refusing an oversized document costs the budget rather than its size. The message-reading trait was in no `#[Covers]`, so it produced no mutants at all — the body reading loop was outside the gate, byte-budget comparison included. Adding it raised the mutant count by 76; the ten that escape are classified in AGENTS.md rather than left unexplained.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: Warning Your free Security trial is over. An organization admin can upgrade to Advanced for continuous pull request security review or dismiss this notice. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #120
Found by the first full-cycle review (
docs/reviews/review-openapi-contract-2026-09-06-full-cycle.md, findings A-1 and A-2).A-1. A YAML document of 772 bytes exhausted memory and died with a fatal error — not an
InvalidContract, so a caller could not catch it.The mechanism sits between two earlier waves, which is why no single-axis pass could see it: the third wave correctly stopped the reference resolver from descending into data (
enum,example,default,const), which also removed the node budget from those keywords; the first wave addedassertEncodable(), whichjson_encodes a schema whole to detect NAN/INF. The bomb lives in anenum, so nothing counted it, and the encodability check turned 387 million nodes into an ~800 MB string.Documents are now measured by what they expand into —
Limits::$documentNodes, default 5 000 000, counted iteratively (the structure being measured must not exhaust the stack either), applied infromArray()(whichfromJson()delegates to) and per file in aDocumentGraph, sharing one budget across the graph as the byte budget already does. The default sits above what any document withindocumentBytescan hold, so it refuses amplification without refusing size. After the fix every level of the bomb is refused asInvalidContractin ~100 ms at a 10 MiB peak.A-2.
MessageReadingappeared in no#[Covers], so Infection generated no mutants for it at all — the body reading loop, including the byte-budget comparison, was outside the gate. The package's ownAGENTS.mdcalls that the symptom and claims the trait was fixed in the first wave; it never was. Adding it raised the mutant count 2297 → 2373, of which 66 were already killed. The ten that escape are the chunking arithmetic and the media-type helpers, classified inAGENTS.mdwith the reasoning rather than left as noise.Verification:
composer build,composer rector,bin/package-auditgreen; mutation 2206 killed / 158 escaped, MSI 93% against a gate of 92; probes indocs/reviews/probe-openapi-contract-2026-09-06-full/.