Skip to content

feat(viz): geom_histogram + geom_freqpoly + geom_density layout rows at ggplot2 4.0.3 parity (PLOT-GG-001) - #7128

Merged
paiml-fleet[bot] merged 15 commits into
mainfrom
feat/dist-rows-6962-6964
Nov 16, 2026
Merged

paiml-fleet[bot] merged 15 commits into
mainfrom
feat/dist-rows-6962-6964

Conversation

@paiml-fleet

@paiml-fleet paiml-fleet Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

What it adds

Three distribution rows of PLOT-GG-001 (ggplot2 4.0.3), folded into one branch:

Oracle cases and max abs error

  • geom_histogram: 13 cases (new at 94a8151: binwidth5_center1, bins10_center0, generated with ggplot2 4.0.3 on kfocus), max abs error 3.6e-15 for the first 11 (earlier head); the 2 new cases pass the 1e-9 rel + 1e-12 abs oracle.
  • geom_freqpoly: 9 cases (the same 2 new ones at 94a8151), max abs error 3.6e-15 (bins10 and default; measured on this head by the new per-case line freqpoly-oracle <case> max_abs_err=...).
  • geom_density: 7 cases (new at 4b483b7: iqr0, constant, zero, generated with ggplot2 4.0.3 on kfocus); max abs error 2.7e-15 for the first 4 (earlier head); the 3 new cases pass the 1e-9 rel + 1e-12 abs oracle, max error not separately measured.
  • bw.nrd0 now falls back like R (sd, then abs(x[1]), then 1) when min(sd, IQR/1.34) is 0; constant samples build. Fewer than two values stays refused (R drops the group and returns one NA row).
  • Tolerance unchanged: 1e-9 relative, counts and labels exact.

Verification (rc read directly, head 94a8151)

  • cargo fmt --all -- --check rc 0
  • cargo clippy -p aprender-viz --lib --tests -- -D warnings rc 0
  • cargo test -p aprender-viz --lib rc 0 (888 passed)
  • cargo test -p aprender-contracts --lib rc 0 (2403 passed, 5 ignored) on the working tree before the final commit
  • pv validate on the three dist contracts rc 0; pv lint contracts --gate ont-consistency rc 0
  • scripts/readme_sync.sh --check rc 0
  • scripts/contracts_gate.sh: 7 of 8 steps pass (lint, consistency, census, regen, readme, provenance, diff); the shapes step rc 1 on the build host with a shape (binary-apr-cli-apr-surface) this PR does not touch, and it fails the same way at 4b483b7 with a pv built from this tree

ont-delta: none (no ontology source edit); contracts/contracts.nt gains derived triples only: the three dist contracts' own triples, plot/geom_histogram gains a contract triple and 13 fixture triples (the histogram contract binds the existing core row), and its notProven shrinks to surface and receipt

Refs #6909
keep-open: #6909 is the group ticket; this PR completes its checklist lines for geom_histogram, geom_freqpoly, geom_density; other rows remain
Refs #6962
keep-open: formerly #6962 (folded into #6909); the work is the geom_histogram line of #6909
Refs #6963
keep-open: formerly #6963 (folded into #6909); the work is the geom_freqpoly line of #6909
Refs #6964
keep-open: formerly #6964 (folded into #6909); the work is the geom_density line of #6909

🤖 Generated with Claude Code

noahgift and others added 10 commits November 15, 2026 20:29
…4.0.3 (PLOT-GG-001, #6962)

layout() now resolves one ungrouped geom_histogram: stat_bin as ggplot2
4.0.3 computes it (bins, binwidth, boundary, center, closed = right,
fuzzed edges, bin_breaks_bins' width quirk, zero-range 0.1 width), x scale
trained on the bin edges, y on 0..max count. Grouped histograms, empty,
non-finite or invalid args return typed errors; the other four
distribution kinds still return NOT_BUILT; renderers still refuse.

Measured: 8 R-generated cases (default, bins 10 and 1, binwidth 2,
boundary, center, bins+boundary, constant) match count, x, xmin, xmax,
density and both panel scales; aprender-viz --lib 842 passed.

Refs #6962 #6909
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
stat_density ported from ggplot2 4.0.3 / R 4.6.2: bw.nrd0, linear binning onto a 2n grid,
the exact circular convolution (equal to R FFT up to rounding), approx onto 512 points.
layout() builds one ungrouped geom_density layer; grouped, constant, one-value input is a typed Err.
Fixtures (4 cases) made by R 4.6.2 / ggplot2 4.0.3 on kfocus under C collation.

Measured: 4 oracle cases, max abs error 2.7e-15 (tail FFT noise), max rel 1.3e-15 where density
>1e-3; tolerance 1e-9 rel + 1e-12 abs. Mutations (0.9 factor, ext 4->3, sd-only bandwidth) turn
the oracle red. geom_density is not a core ontology row, so the contract binds no entity.
contracts.nt, the pv-sat witness and the README count (1728) regenerated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…m_histogram row contract

Keeps stat_bin (histogram) and stat_density (density) side by side: BuiltLayer
carries both `bins` and `density`; layout() dispatches Histogram and Density;
dist_math.rs holds both kernels; both oracle modules are wired. Adds
ggplot2-row16-histogram-v1 bound to core row geom_histogram, a histogram refusal
test, explicit oracle test fns (the contract scanner cannot see macro-made ones),
and regenerates contracts.nt, the pv-sat witness and the README count (1729).
The ggplot2-row bound count in shapes_gate_ggplot2_tests.rs goes 7 -> 8.

Refs #6962 #6964 #6909

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…+ position_stack (PLOT-GG-001, #6962)

stat_bin cuts every group at the edges of all of x and keeps empty bins; the
counts are stacked by the bar rows own position_stack. Three R-generated
oracle cases (two groups, three groups with empty bins, default bins).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Generated files regenerated, not merged by hand: contracts.nt (pv extract), the pv-sat
witness, and the README contract count (readme_sync.sh --write, 1730).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
stat_bin with pad = TRUE (one zero-count bin at each end, as wide as its
neighbour) through GGPlot::layout(), ungrouped. New math stat_bin_padded in
dist_math.rs, one dispatch arm and freqpoly() in dist.rs, oracle module
ggplot2_dist_freqpoly_oracle.rs with 7 R-generated cases, and the
ggplot2-geom-freqpoly-v1 contract (geom_freqpoly is not a core ontology row, so
no entity binding). Regenerated contracts.nt, the pv-sat witness and the README
contract count.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… stacking falsifiers

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Keeps histogram (stat_bin_groups), freqpoly (stat_bin_padded) and density.
Witness is stale until regenerated by pv-sat in the next commit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@paiml-fleet
paiml-fleet Bot marked this pull request as ready for review November 15, 2026 22:55
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

§13.11 rung 1 — quorum shadow verdict

S13-SHADOW pr=7128 head=3f9c750d2b825d2f6c22313bd35af0dcb9aa4f61 verdict=REFUSE class=Q1 arm_rc=1

Shadow mode: this records a verdict and merges nothing. A refusal
to arm is not a block (§13 adds zero rows to §7) — the pull request is
exactly as green as it was.

…tness and README count

- stat_bin_padded builds from bin_breaks/bins_from_counts (stat_bin is test-only after the
  histogram row); pad_bins fills ymin/ymax/group.
- freqpoly oracle prints its max abs error per case.
- freqpoly FALSIFY-GFP-002 named a bins1 fixture that does not exist; it now names bins10.
- witness census id set and README contract count regenerated by pv-sat / readme_sync.sh.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@paiml-fleet

paiml-fleet Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

NON-AUTHOR REVIEW: FAIL @e79d243f4b9747443919d25e14d85e6f79d0f62d

Lane: agy, model claude-opus-5-5-high (gemini-4-hydrogen-high returned 429 quota). Two calls (engine; tests/contracts/body). Both VERDICT: FAIL.

Blockers:

  1. dist_math.rs:300-302 bw_nrd0 refuses any sample with IQR == 0 but sd > 0 (e.g. c(0,0,0,0,1)); R's bw.nrd0 falls back to sd and ggplot2 renders it. Confirmed in diff. Doc comment at :288 also wrong (R falls back to sd first). Add an IQR=0 oracle case.
  2. ggplot2-geom-density-v1.yaml:68-72 FALSIFY-GGD-005 cannot go red: constant/one-value input is also refused by the stat_density range guard, and the named test only checks the message contains "stat_density". Name dist_math::tests::refuses_short_constant_and_non_finite_input (unconfirmed by running).
  3. ggplot2-geom-density-v1.yaml:63-67 FALSIFY-GGD-004 predicts an equivalent mutation (dropping .floor(): pos >= 0 always). Unconfirmed by running.

Should-fix (summary): r_mod is not R's myfmod (boundary-rescale case untested); edges/density not total for huge or lost-precision widths (typed Err needed); O(G*N) groups and unbounded bins x groups allocation; +-Inf refused instead of dropped; all errors are Error::Rendering strings; GGH-007 stacking half not asserted; PR body "ont-delta: none" contradicts contracts.nt +31/-1 and bound count 7->8; contract text says "constant" but IQR=0 is also refused.
No reachable panics found. Oracle path (d) and case counts (f) confirmed OK. Many nits in the receipt.

Receipt: /mnt/nvme-raid0/cop-inbox/handoff/agy/review-aprender-7128-e79d243-agy.md

…ds; sharper density falsifiers (PLOT-GG-001, Refs #6909)

bw_nrd0 now takes min(sd, IQR/1.34) and, when that is 0, falls back to sd,
then abs(x[1]), then 1, as stats::bw.nrd0 does. New R fixtures iqr0,
constant, zero (ggplot2 4.0.3). FALSIFY-GGD-004/005 restated so a mutation
turns them red; FALSIFY-GGD-007/008 added.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@paiml-fleet

paiml-fleet Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

Fix round for the review of e79d243 (new head 4b483b7).

  1. bw_nrd0 refused IQR 0 with sd > 0: FIXED in 4b483b7. Now min(sd, IQR/1.34), then on 0 the R chain sd, abs(x[1]), 1. New ggplot2 4.0.3 fixtures iqr0, constant, zero (generated on kfocus, oracle through layout(), 1e-9 rel + 1e-12 abs unchanged). Constant samples build in R (bw from abs(x[1])), so the engine now builds them too (guard from < to relaxed to from <= to); n < 2 stays refused (R warns and drops the group, returning one NA row). Mutation: refusing at lo == 0 turns iqr0 RED; replacing abs(x[1]) with 1 turns constant RED; reverted.
  2. FALSIFY-GGD-005 could not go red: CONFIRMED, FIXED. The range guard also refused the cases. The test now asserts the bandwidth message "needs at least two values"; mutation (length check removed) turns it RED; reverted.
  3. FALSIFY-GGD-004 equivalent mutation: CONFIRMED, FIXED. Restated around lo = from.abs() - EXT * bw, which turns the negative fixture RED; reverted. Added FALSIFY-GGD-007 (iqr0) and -008 (constant/zero).
    Should-fix: 4 (non-finite padded range) fixed with a guard in stat_density. Not fixed, larger than this round: 2 (myfmod emulation plus a rescale fixture), 3 (total edge code), 5 (group-bucketing and output cap), 6 (Inf parity, documented refusal), 7 (error variants). Nits left.
    Verification (framework16): fmt, clippy, viz lib (884 passed), pv validate x3, ont-consistency lint, readme_sync, contracts_gate all rc 0; contracts lib: strict_test_binding failed once (dangling iqr0 ref), fixed, module re-run rc 0.

@paiml-fleet

paiml-fleet Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

NON-AUTHOR REVIEW: FAIL @4b483b71162f53abc790f03b6c4ef1c86560444e

Lane: agy, claude-opus-5-5-high (gemini-4-hydrogen-high returned 429 quota). Two calls: engine PASS, tests/contracts/body FAIL. Old blockers 1-3 are resolved (nrd0 chain matches R; from <= to opens no div-by-zero/NaN/alloc).

Blockers (confirmed against diff: bins_params is called only from breaks_bins; the binwidth path goes breaks_width):

  1. FALSIFY-GGH-004 (ggplot2-row16-histogram-v1.yaml:64-67) and GFP-004 (ggplot2-geom-freqpoly-v1.yaml:62-65): mutation "ignoring boundary in bins_params" is unreachable from the named test binwidth1_boundary0. Name bins5_boundary2 or restate the mutation at breaks_width.
  2. FALSIFY-GGH-005 / GFP-005: binwidth5_center0 gives the same edges as binwidth=5 alone (center 0 == default boundary width/2 mod width), so dropping or sign-flipping center stays green; the qa_gate binning_cases also covers no center. Regenerate with a center that is not a multiple of the width (e.g. binwidth 5, center 1) plus bins=10, center=0.

Should-fix: GGD-008 names only zero (add constant); GGH-007 test cannot see dropped stacking (name groups2); oracle never compares group; bandwidth_cases description lists cases the check does not name; body says contracts.nt "unchanged" but the diff changes it (new triples, notProven shrinks) - state what changed; also bins x groups allocation uncapped and non-finite range gives Ok with NaN bins (R errors) - not blockers (f32 storage; adversarial only).
The 5 deferred items: none is a blocker.

Receipt: /mnt/nvme-raid0/cop-inbox/handoff/agy/review-aprender-7128-4b483b7-agy.md

…ter fixtures that move the edges (PLOT-GG-001, Refs #6909)

- FALSIFY-GGH-004/GFP-004: the binwidth path never reaches bins_params, so the mutation is
  now in breaks_width (ignoring the given boundary).
- FALSIFY-GGH-005/GFP-005: binwidth5_center0 gives the same edges as the default (center 0
  lands on width/2 mod width), so it could not see center. New R fixtures binwidth5_center1
  (edges -1.5, 3.5, ... vs -2.5, 2.5) and bins10_center0 (bins path), oracle cases through the
  public layout() path; the center falsifier now names binwidth5_center1.
- FALSIFY-GGH-003/GFP-003: the origin floor-to-ceil mutation survived binwidth2 (min x sits on a
  boundary); binwidth2 now backs "binwidth wins over bins", new -014 backs the origin with
  binwidth5_center1. New -012/-013 cover boundary and center on the bins path.
- FALSIFY-GGH-007 names groups2 (stacking); FALSIFY-GGD-008 names constant and zero;
  GGD bandwidth_cases description narrowed to what its check covers.
- contracts.nt: two new histogram fixture triples (pv extract).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@paiml-fleet

paiml-fleet Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

Fix round for the second non-author FAIL (head 94a8151). Mutations were applied on framework16 one at a time, the named test run, then reverted.

  1. FALSIFY-GGH-004 / GFP-004: fixed in 94a8151. The mutation is now in breaks_width (always width / 2, ignoring the given boundary). Red: binwidth1_boundary0 (hist and freqpoly).
  2. FALSIFY-GGH-005 / GFP-005: fixed in 94a8151. New R 4.0.3 fixtures binwidth5_center1 (edges -1.5, 3.5, ... vs -2.5, 2.5, ... for center 0 and default; checked in R) and bins10_center0 (edges -1.81 vs -0.81 for bins10). Oracle cases go through the public layout() path; the engine matched R with no change. Mutation: ignore center in breaks_width (boundary = width / 2). Red: binwidth5_center1 (both rows). The binwidth5_center0 case stays green under it (confirmed), so it no longer backs the falsifier. A sign flip (c + w/2) is an equivalent mutant (same edges) and is not claimed. The binning_cases check now names binwidth5_center1.
  3. Other weak falsifiers found and fixed:
    • GGH-003 / GFP-003: floor-to-ceil of the origin survived binwidth2 (min x on a boundary). 003 now says "ignoring binwidth in bin_breaks" (red: binwidth2); new -014 covers the origin (red: binwidth5_center1).
    • GGD-008: now names constant and zero (dropping abs(x[1]) stays green under zero alone, confirmed).
    • GGH-007: now names groups2 (dropping stack_bins stacking: red groups2; the unit test alone stays green, confirmed).
    • New -012/-013 (hist and freqpoly): boundary and center on the bins path, red bins5_boundary2, bins10_center0.
    • GGD bandwidth_cases description narrowed to what its check covers.
    • Checked red with a mutation: GGH/GFP-001/002/006/008, GGH-009/010/011, GFP-007, GGD-001..005/007/008.
  4. Finding 7 (PR body): corrected; contracts.nt changes are described in the ont-delta line.
  5. Not fixed, deferred as agreed: should-fix 1, 2, 3, 5 of call 1 and finding 5 of call 2 (BuiltBins.group oracle).

CI: at e79d243 pr-light was cancelled (superseded by the 4b483b7 push, run 43774089706 cancelled) and workspace-test, ci / gate, gate failed because they require pr-light success ("pr-light is 'cancelled', not success"). Nothing in this PR's content. At 4b483b7 the run (43779227004) was queued with no runner for 25+ min, so no checks reported at first.

Verification (framework16): fmt rc 0; clippy rc 0; aprender-viz lib 888 passed; aprender-contracts lib 2403 passed rc 0; pv validate x3 rc 0; ont-consistency rc 0; readme_sync rc 0; contracts_gate.sh: the shapes step fails (binary-apr-cli-apr-surface), identically at 4b483b7, so not caused by this PR; the diff step passes with the regenerated contracts.nt.

@paiml-fleet

paiml-fleet Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

NON-AUTHOR REVIEW: PASS @94a8151b2ff7920ebdb44a266e904c098d6175f6

Lane: agy, fallback to claude-opus-5-5-high (gemini-4-hydrogen-high returned 429 quota; the Opus answer is complete). Head re-read before posting.

Blockers: none. Both review-2 blockers are fixed. I traced every falsifier (GGH-001..014, GFP-001..008/012..014, GGD-001..008) from the named test through dispatch to the mutated function and checked by arithmetic that the case's output changes: GGH/GFP-004 (breaks_width boundary, binwidth1_boundary0: origin 1 vs 0.5), -005 and -014 (binwidth5_center1: first edge -1.5 vs -2.5 and 3.5), -012 (bins5_boundary2: -6.125 vs -3.0625), -013 (bins10_center0: -1.8056 vs -0.8056). All rows reach and change.
Oracle tests go through layout() at 1e-9 rel + 1e-12 abs with a length check. Body case counts (13/9/7), ont-delta, Refs #6909 and keep-open match the diff. Delta since review 2 has no non-test src, so no second call.

Should-fix (not blocking):

  1. FALSIFY-GGH-011 does not name the group; g3 group c spans the global range, so only a or b turns groups3_default red.
  2. The on_edge width switch in bins_params (dist_math.rs ~86-89) has no fixture or falsifier (carried over).
    Nits: GGH/GFP-001/002/006 name breaks_bins (code is bins_params); GFP-007 puts the empty refusal in freqpoly() (it is check_args); quantile7 relies on the length check; histogram oracle skips the group column.

CI at review time: no check red on this PR (3 pending, 8 skipping).

Receipt: /mnt/nvme-raid0/cop-inbox/handoff/agy/review-aprender-7128-94a8151-agy.md

@paiml-fleet
paiml-fleet Bot enabled auto-merge (squash) November 16, 2026 02:12
…14 renumbered 009-011) (PLOT-GG-001, Refs #6909)

pr-light fail_fast ids reported 2 new test ID gaps.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@paiml-fleet
paiml-fleet Bot disabled auto-merge November 16, 2026 03:00
@paiml-fleet

paiml-fleet Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

pr-light failed on fail_fast ids: FALSIFY-GGD-006 sat after 008 in the density contract and FALSIFY-GFP jumped 008 to 012 in the freqpoly contract. Reordered/renumbered the ids only (no test or code change; fail_fast ids now 0 gaps, aprender-contracts --lib 2403 passed). Head moved, so a new non-author review is needed at the new head; auto-merge disabled.

@paiml-fleet

paiml-fleet Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

NON-AUTHOR REVIEW: PASS @7ce93f87bf92f08f937feb620ce6a5220ebffabe
Lane: Opus, non-author (the author is Sonnet; both agy lanes returned 429). Verdict = the full PASS at 94a8151 (comment 6905399948) + this review of the delta.

Delta 94a8151...7ce93f8 (1 commit) touches 2 files only: ggplot2-geom-density-v1.yaml (+5/-5) and ggplot2-geom-freqpoly-v1.yaml (+3/-3).

  • Density: the FALSIFY-GGD-006 block moved verbatim from after 008 to between 005 and 007.
  • Freqpoly: only the id lines changed (GFP-012/013/014 -> 009/010/011). Mutation text and named tests (bins5_boundary2, bins10_center0, binwidth5_center1) are unchanged.
  • Ids at head: GGH-001..014, GGD-001..008 and GFP-001..011 are contiguous, in order and unique.
  • No stale references at head. No GFP-012..014 anywhere in the tree. The density description's GGD-003/007/008 refs are unchanged and still correct. contracts.nt and the witness file hold no falsifier ids. The PR body cites only GFP-002, which is correct.
  • None of the earlier should-fix items (GGH-011 group, unreached on_edge branch) is touched by the delta, so none becomes a blocker.

Findings: none blocking. Info: the 94a8151 review table's GFP-012..014 rows are now GFP-009..011.

@paiml-fleet
paiml-fleet Bot enabled auto-merge (squash) November 16, 2026 03:33
Keeps main's geom_area/geom_ribbon/position_dodge rows (BuiltFilled) and the PR's dist rows (bins/density); BuiltLayer carries all three. contracts.nt and the witness regenerated with pv extract + pv-sat; ggplot2-row bound count is 11.

Pmat-Ticket: PMAT-6962

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@noahgift noahgift changed the title feat(viz): geom_histogram + geom_density layout rows at ggplot2 4.0.3 parity (PLOT-GG-001) feat(viz): geom_histogram + geom_freqpoly + geom_density layout rows at ggplot2 4.0.3 parity (PLOT-GG-001) Nov 16, 2026
@paiml-fleet
paiml-fleet Bot merged commit 070527c into main Nov 16, 2026
14 checks passed
@paiml-fleet
paiml-fleet Bot deleted the feat/dist-rows-6962-6964 branch November 16, 2026 10:28
noahgift added a commit that referenced this pull request Nov 16, 2026
fix(readme): regenerate the contract count 1731 -> 1734 (main red since #7128)

#7128 added three contracts without running readme_sync, so FALSIFY-README-002 and readme_sync fail on main. Forward fix: scripts/readme_sync.sh --write. Replaces revert #7161, which the ONT ratchet refuses (contracts_anchored 96 -> 95).

Pmat-Ticket: PMAT-6962

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant