Skip to content

Fix easy confirmed bugs from bugreport_2026-08-21_merged.md - #8

Merged
daedalus merged 2 commits into
masterfrom
copilot/fix-confirmed-bugs
Aug 24, 2026
Merged

Fix easy confirmed bugs from bugreport_2026-08-21_merged.md#8
daedalus merged 2 commits into
masterfrom
copilot/fix-confirmed-bugs

Conversation

CopilotAI commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes easy confirmed bugs from bugreport_2026-08-21_merged.md, with a regression test hardened per code review to derive its expected value independently rather than duplicating the implementation's formula.

Changes

  • 0045b90 — Fix easy confirmed bugs from bugreport_2026-08-21_merged.md
  • f5d599a — Address code review: derive expected value independently in radamsa test (uses _log2_ceil(9) instead of hardcoding the expected result)

Summary by Sourcery

Fix confirmed seed-generation and random-number reproducibility bugs, with regression coverage for the corrected behavior.

Bug Fixes:

  • Prevent generic seed generation from failing when the configured maximum length is below four bytes.
  • Preserve injected-RNG reproducibility for radamsa numeric mutation sign selection and grammar expansion.

Documentation:

  • Mark the corresponding confirmed bug-report findings as partially or fully fixed and document their remaining scope.

Tests:

  • Add regression coverage for short maximum seed lengths and injected-RNG use in radamsa mutation and grammar generation.

CopilotAIand others added 2 commits August 24, 2026 22:00
Co-authored-by: daedalus <115175+daedalus@users.noreply.github.com>
Co-authored-by: daedalus <115175+daedalus@users.noreply.github.com>
@sourcery-ai

sourcery-aiBot commented Aug 24, 2026

Copy link
Copy Markdown

Reviewer's Guide

Fixes three confirmed reproducibility and seed-generation bugs: short maximum lengths no longer produce invalid random ranges, radamsa numeric sign selection honors injected RNGs, and grammar generation uses its injected RNG for deterministic output; documentation and independent regression coverage were added.

Sequence diagram for deterministic injected-RNG mutation

sequenceDiagram
participant Caller
participant Radamsa as radamsa_mutate_num
participant RNG as InjectedRNG
Caller->>Radamsa: radamsa_mutate_num(val, rng)
Radamsa->>RNG: randint(1, 128)
Radamsa->>RNG: random()
RNG-->>Radamsa: deterministic sign decision
Radamsa-->>Caller: mutated integer
Loading

Sequence diagram for deterministic grammar generation

sequenceDiagram
participant Caller
participant Grammar
participant RNG as InjectedRNG
Caller->>Grammar: mutate(..., rng)
Grammar->>Grammar: _expand_rule(name, depth)
Grammar->>RNG: choice(alts)
Grammar->>Grammar: _expand_tokens(tokens, depth)
Grammar->>RNG: randint(lo, hi)
RNG-->>Grammar: deterministic choices
Grammar-->>Caller: generated bytes
Loading

Flow diagram for safe short-length generic seed generation

flowchart TD
A["Generic seed generation"] --> B["Read f.max_len"]
B --> C["Compute lower bound min(4, f.max_len)"]
C --> D["Compute upper bound min(64, f.max_len)"]
D --> E["rng.randint(lower bound, upper bound)"]
E --> F["Create random buffer of selected length"]
Loading

File-Level Changes

ChangeDetailsFiles
Clamped generic seed lengths to remain valid when the configured maximum is below the normal minimum.
  • Use the smaller of 4 and the configured maximum as the lower bound.
  • Added regression coverage for short maximum lengths and empty-corpus generic seed generation.
src/fuzzer_tool/services/seed_picker.py
tests/test_regression_bugreport_easy_fixes.py
Made radamsa numeric mutations and grammar expansion consistently use injected RNG instances.
  • Route the radamsa scaling sign decision through the injected RNG.
  • Store and use the grammar instance's RNG for alternative selection and repetition counts.
  • Added deterministic regression tests for both RNG plumbing paths.
src/fuzzer_tool/core/mutations/generic.py
src/fuzzer_tool/core/grammar.py
tests/test_regression_bugreport_easy_fixes.py
Documented the confirmed bug fixes and linked them to their regression tests.
  • Marked the seed-picker and RNG findings as partially fixed with implementation locations and remaining scope.
  • Recorded the new regression test coverage in the bug report.
docs/bugreport_2026-08-21_merged.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@daedalus
daedalus marked this pull request as ready for review August 24, 2026 22:06
CopilotAI lite review requested due to automatic review settings August 24, 2026 22:06
@daedalus
daedalus merged commit 7a5599e into masterAug 24, 2026
1 check passed
@daedalus
daedalus deleted the copilot/fix-confirmed-bugs branch August 24, 2026 22:06

@sourcery-aisourcery-aiBot 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.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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

🟡 Changes recommended

The two new RNG regression tests can still pass nondeterministically on regression and should be hardened to fail deterministically (e.g., by patching module-global random.* to raise).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Fixes a few confirmed “easy” bugreport findings affecting seed generation for small --max-len values and RNG determinism (in radamsa numeric mutation and grammar expansion), and adds regressions + notes in the merged bugreport doc.

Changes:

  • Clamp generic seed length bounds to avoid randint() invalid ranges when max_len < 4.
  • Ensure injected RNG is used for radamsa_mutate_num op==9 sign selection and for Grammar rule/token expansion.
  • Add/extend regression tests and mark the corresponding bugreport items as fixed.
File summaries
FileDescription
tests/test_regression_bugreport_easy_fixes.pyAdds regression coverage for the fixed RNG leaks and short max_len seed generation.
src/fuzzer_tool/services/seed_picker.pyFixes invalid randint() bounds in generic seed generation when max_len is small.
src/fuzzer_tool/core/mutations/generic.pyUses injected RNG for radamsa op==9 sign selection to preserve -s determinism.
src/fuzzer_tool/core/grammar.pyUses self._rng (set by mutate()) instead of module-global random during expansion.
docs/bugreport_2026-08-21_merged.mdMarks specific findings as fixed and links to regression tests.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +142 to +149
# op=9 (random scaling): randint(0,9)->9, randint(1,128)->9,
# random()->0.9 selects the "val - n" branch. If the sign draw
# silently fell back to the global `random` module instead of this
# fake, it would not consume the sentinel and the call would raise
# StopIteration on the second next().
n = _log2_ceil(9)
rng = _FakeRng(randints=[9, 9], randoms=[0.9])
assert radamsa_mutate_num(100, rng=rng) == 100 - n
Comment on lines +197 to +200
g._rng = _FakeRng()
out = g.generate("root")
assert out == b"a"
assert g._rng.choice_calls == 1
@daedalus

Copy link
Copy Markdown
Owner

@copilot Fix the code for all comments in this review thread.

When a review comment includes a suggested change, apply the suggestion exactly.

Do not make changes beyond what is described in the linked review thread.

daedalus added a commit that referenced this pull request Aug 25, 2026
Codifies the pattern reviewers flagged in PRs #7/#8 (f00927a, f5d599a):
tests that loop hoping a randomized code path eventually hits a
condition test luck, not behavior. Full rationale/example lives in
docs/refs/bug-classes.md §Testing.
daedalus added a commit that referenced this pull request Aug 25, 2026
Plan derived from PR #1/#7/#8 review-feedback analysis (see AGENTS.md
Hard Rule 39). Inventories retry-until-random-hit test candidates
across the suite (tiered by confidence) and confirms the
supports_priors capability-flag fix already rolled out to all
scheduler classes.
daedalus added a commit that referenced this pull request Aug 29, 2026
Four documents all answered "what should we port next", each with its own
ranking scheme: the six-external-sources survey (`R1`-`R6`), the TigerBeetle
"Tale Of Four Fuzzers" port (`P0-1`..`P2-8`), the 2026-08-25 internet survey
(29 tiered candidates) and the 2026-08-28 GitHub + FFmpeg survey (`I.*`, `II.*`).
They cross-referenced each other, deferred to each other, and repeated each
other. Merged into `docs/port-backlog.md`.
The merge is the point, not the line count. Split across four files it was not
visible that:
- **Four separate proposals solve the same structure-aware-generation gap** —
Grimoire generalization, Gramatron FSA walks, the tree-sitter category and
FormatFuzzer templates. They are now section A, ranked by plumbing already in
place, which puts Grimoire first (it reuses the colorization executor loop
almost verbatim) rather than in the middle of a tier table. That is not the
order any single source gave.
- **Six items overlap on "which bytes should we mutate"** — FairFuzz masks,
WindRanger probing, IDFuzz gradients, DataFlowTrace taint, NestFuzz repair and
identifier canonicalization. Section B. FairFuzz carries the warning it always
had, now next to its competitors: it may simply overlap the rarity bonus we
already ship, so measure before committing.
- **Two solver items and five substrate items** were spread across three files
with three different effort scales. Sections G and H.
Also merged rather than dropped:
- **The four "not worth porting" lists into one "Rejected" section.** These are
the highest-value part of any survey and the easiest to lose — "absent from
the doc" and "considered and declined" are different states, and only one of
them should be re-proposable. Nine rejections with their reasoning, plus the
watch-list.
- **The source-quality accounting.** fitzgen's is the only source with proper
statistics and its conclusions can be trusted; PowerFuzz reports single numbers
per cell with no variance and a 10x throughput tax invisible in every plot, so
take nothing on its numbers. Anyone reading a candidate's claimed win needs
that next to the candidate, not in a different file.
- **The open questions that gate the work**, including the two the 2026-08-28
survey surfaced and nobody has acted on: colorization should probably be
opt-out, and Entropic and our Chao2 rewrite come from the same STADS framework
and have never been reasoned about together.
The FFmpeg harness work (`II.*`) is section J and keeps its 7-commit sequence
intact — it is the one block here that is fully specified and ready to start.
Its status table was re-grepped: every mechanism it lists is still absent.
Ten source and test citations re-pointed. The distinction matters and drove
where each went: citations for items that **shipped** (`P1-5` exhaustive
enumeration, `P2-6` negative space, `#8` subtree crossover) now point at the
learnings note that records what building them actually found, or are made
self-contained — pointing them at a backlog of *open* work would be wrong.
Citations for items still **open** (`P1-4` minimal interface, `P0-1` seed
discipline) point at the backlog.
Sign up for freeto 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.

3 participants

@daedalus