Skip to content

PYTHON-6178 Persist coverage-increasing inputs from the nightly BSON fuzz runs - #3215

Open
blink1073 wants to merge 10 commits into
mongodb:mainfrom
blink1073:PYTHON-6178
Open

blink1073 wants to merge 10 commits into
mongodb:mainfrom
blink1073:PYTHON-6178

Conversation

@blink1073

Copy link
Copy Markdown
Member

PYTHON-6178

Changes in this PR

  • The nightly fuzz task now harvests its coverage-increasing inputs into the committed fuzz/corpus/ and opens an automated [Fuzz Corpus] PR against main, so later nights build on prior discoveries instead of restarting from the spec seed corpus.
  • Harvest dedupes by content digest against a baseline manifest recorded at setup, caps growth at 50 units per run and 64 KiB per unit (overridable from Evergreen), and treats a run that finds nothing new as a clean no-op.
  • Crashing inputs are excluded automatically: a crashing target fails the task before the harvest command runs, so reproducers keep the existing fuzz/regression/ triage flow.

Test Plan

  • just test test/test_fuzz_harvest.py: 8 unit tests for the harvest module (digest diffing, caps, summary, no-op), written first.
  • just setup-tests fuzz fuzz writes a 485-digest baseline manifest, and a unit committed in fuzz/corpus/ reaches both the scratch corpus and the baseline.
  • Harvest guards: patch builds skip (patch run), an empty harvest exits 0.
  • Evergreen patch on fuzz-regression-rhel8: task green; seeding, baseline manifest, and target replay verified on a real host (patch run).
  • Evergreen patch of the nightly fuzz task, using a temporary in-patch guard that runs the harvest without PR creation: all three targets ran 60s crash-free, and the harvest kept 50 units while skipping 17 oversize and dropping 58 over the per-run cap (patch run).
  • The GitHub-facing PR creation needs the App secrets, so the first real nightly after merge exercises it.

Checklist

Checklist for Author

  • Did you update the changelog (if necessary)? (The repo has no changelog file.)
  • Is there test coverage?
  • Is any followup work tracked in a JIRA ticket? If so, add link(s). (None filed.)

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Is all relevant documentation (README or docstring) updated?

The nightly fuzz run seeds from a committed fuzz/corpus/ directory and, after a green run, harvests its coverage-increasing inputs into an automated [Fuzz Corpus] PR, so later nights build on prior discoveries instead of restarting from the spec seeds. Harvest dedupes by content digest and caps growth at 50 units per run and 64 KiB per unit, overridable from Evergreen; nothing new means no PR. Crashing inputs fail the task before harvest runs, keeping reproducers on the fuzz/regression/ triage flow.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The nightly harvest’s comment-bot bootstrap lacks assumed-role AWS credentials, preventing it from retrieving GitHub App secrets and creating a PR when changes are harvested.

1 open issue
What changed in this PR

Persists coverage-increasing BSON fuzz inputs through automated corpus PRs, allowing future nightly runs to build on earlier discoveries.

Changes:

  • Seeds nightly fuzzing from the committed corpus and records baseline digests.
  • Adds bounded, digest-based harvesting and automated GitHub PR creation.
  • Adds harvest unit tests and documentation, plus temporary Markdown formatter exclusions.
File Description
test/​test_fuzz_harvest.py Tests digest filtering, caps, summaries, and no-op behavior.
pyproject.toml Temporarily excludes two Markdown files from Ruff.
fuzz/​README.md Documents nightly harvesting, limits, and review guidance.
fuzz/​harvest_corpus.py Selects new corpus units and writes harvest summaries.
fuzz/​corpus/​.gitkeep Adds a directory for committed corpus inputs.
CONTRIBUTING.md Links contributor guidance to the harvest documentation.
.evergreen/​scripts/​setup_tests.py Seeds committed inputs and records baseline digests.
.evergreen/​scripts/​harvest-fuzz-corpus.sh Runs harvesting with patch-build and empty-result guards.
.evergreen/​scripts/​generate_config.py Adds harvesting after nightly fuzz tests.
.evergreen/​scripts/​create-fuzz-corpus-pr.sh Commits harvested inputs and creates or updates a PR.
.evergreen/​generated_configs/​tasks.yml Includes the generated nightly harvest command.

Review effort: Balanced

Comment thread .evergreen/scripts/generate_config.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Harvested fuzz inputs are not replayed across all targets before publication, and spec-resync commits omit the public suffix list, risking untriaged crashes and incomplete or failed updates.

2 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Replay harvested inputs against all targets before publishing

.evergreen/​scripts/​harvest-fuzz-corpus.sh:26

handle_fuzz() runs the targets sequentially against one shared corpus, so inputs discovered by later targets are not checked by targets that already finished. A green run can therefore publish an input that fails another target, bypassing the intended crash-triage flow. Replay the harvested files through all three targets in fixed-input mode and abort on failure before creating the PR.

Review effort: Balanced

Comment thread .evergreen/scripts/create-spec-pr.sh Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The authenticated GitHub App push/PR flow remains untested and shares plumbing with spec resync, so credential bootstrap and create/update behavior need confirmation on Evergreen.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Within-run deduplication misses identical candidates, allowing duplicates to consume the harvest cap, exclude distinct inputs, and inflate the reported count.

1 open issue

Review effort: Balanced

Comment thread fuzz/harvest_corpus.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The GitHub App-authenticated publication flow needs maintainer validation with production secrets to confirm token acquisition and permissions, branch pushing, and PR creation/update end to end.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@blink1073
blink1073 marked this pull request as ready for review November 12, 2026 17:28
@blink1073
blink1073 requested a review from a team as a code owner November 12, 2026 17:28

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.

2 participants