fix(zipf): reject KS misfits and alpha pinned at ALPHA_LO - #28
Merged
Merged
Conversation
On png_read (vendored libpng) the seeds-per-edge spectrum is a decaying head plus a hot core every seed owns. The fit pinned alpha at 1.01 with KS 0.17 (5x the 95% critical value) and still said POWER_LAW: only Vuong vs geometric and alpha at ALPHA_HI were checked, so the gate veto fired on a non-power-law. Add KS > 1.36/sqrt(n) and alpha at either bracket end as rejections. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UbKUguEPpHswuuUbhCXSuT
Reviewer's GuideThe PR hardens Zipf-tail classification by requiring an acceptable absolute KS fit and an interior alpha estimate, preventing non-power-law hot-core spectra and low-alpha boundary fits from triggering the saturation-gate veto while preserving valid power-law detection. Flow diagram for hardened Zipf tail classificationflowchart TD
A["Fit Zipf tail"] --> B["_classify(alpha, xmin, n_tail, total, ks, vuong)"]
B --> C{"Alpha pinned at either bound?"}
C -->|Yes| N["NOT_POWER_LAW"]
C -->|No| D{"KS > 1.36 / sqrt(n_tail)?"}
D -->|Yes| N
D -->|No| E{"Tail fraction < 20%?"}
E -->|Yes| N
E -->|No| F{"Vuong < 1.96?"}
F -->|Yes| N
F -->|No| P["POWER_LAW"]
P --> G["Saturation-gate veto may engage"]
N --> H["Saturation-gate veto blocked"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
daedalus
marked this pull request as ready for review
September 27, 2026 13:51
Contributor
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Misleading s output and unaccounted xmin selection can undermine the new classification guard.
Review effort: Lite
Findings: None
What changed in this PR
Strengthens Zipf-tail classification by rejecting poor KS fits and alpha estimates at search boundaries.
Changes:
- Adds KS misfit and boundary-alpha guards.
- Adds regression and falsification tests.
- Documents Zipf behavior and the libpng configuration limitation.
| File | Summary |
|---|---|
tests/test_zipf.py |
Adds Zipf regression and validity tests. |
src/fuzzer_tool/core/zipf.py |
Adds classification safeguards. |
docs/TODO.md |
Records the libpng build limitation. |
docs/DEEP_DIVE.md |
Documents updated Zipf safeguards. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Summary, report and stats file printed s = 1/(alpha - 1) for rejected fits (s=99.96 on png_read). Show alpha and the verdict instead. Note that min-KS xmin selection biases KS low (guard stays lenient). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UbKUguEPpHswuuUbhCXSuT
Chao2 plateaus at 87-89% (seeded, 158k execs) and 84-87% (empty corpus, 80k); the gate never engages past exec 8, so a png A/B of the veto is null by construction. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UbKUguEPpHswuuUbhCXSuT
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.
Bug
On
png_read_noasan.sobuilt against vendored, instrumented libpng (30k execs, 139 seeds, 1501 edges), the seeds-per-edge spectrum is not a power law. The number of edges falls from 188 owned by 1 seed to about 20 owned by 12 seeds, then 95 edges are owned by 137 of the 139 seeds (the parse path every input takes).fit_zipfreturnedalpha=1.01(the lower search bound),KS=0.169, and still classified itPOWER_LAW. The 95% KS critical value at n = 1501 is 0.035.Cause:
_classifyonly checked two things, the Vuong test against a geometric and α pinned atALPHA_HI. A spectrum that is neither a power law nor geometric still wins the Vuong test. The effect: the saturation-gate veto from #22 fired on a signal that doesn't hold.Fix
_classifynow also returnsNOT_POWER_LAWwhen:KS_95 / sqrt(n_tail), withKS_95 = 1.36(Kolmogorov 95%). Two things make this threshold err toward accepting: the parameters are fitted, andxminis chosen as the lowest-KS candidate.ALPHA_HI.The real png spectrum now reads
not_power_law.A second commit comes from Copilot's review overview. The summary, report and stats file printed
s = 1/(α−1)for rejected fits (s=99.96on png). They now show α and the verdict, and includesonly for accepted power-law fits.Tests
test_regression_zipf_ks_misfit_rejected: png-shaped fixture (decaying head plus hot core); α is inside the range but the fit is bad.test_regression_zipf_alpha_pinned_low_rejected: a capped law with true α = 0.6.test_true_power_law_passes_ks_guard: falsification check. The exact fixtures sit 3–50× under the critical value.TestRegressionZipfExponentOnMisfit: checks that the summary, report and stats file leave outsfor rejected fits, and keep it for accepted ones (falsification).Also
docs/TODO.md: new item.build_targets.sh --vendor-tracecmpcan't configure vendored libpng, because the coverage flags inCFLAGSbreak configure's link test. I worked around it by hand for this measurement.🤖 Generated with Claude Code
https://claude.ai/code/session_01UbKUguEPpHswuuUbhCXSuT
Summary by Sourcery
Strengthen Zipf fit validation and report rejected fits without presenting invalid exponents.
Bug Fixes:
Enhancements:
Documentation:
Tests: