Skip to content

feat(apr): apr plot verb over the proven ggplot2 rows (re-cut AP3 of #6992) - #7042

Merged
noahgift merged 11 commits into
mainfrom
recut/ap3-plot-verb
Nov 14, 2026
Merged

noahgift merged 11 commits into
mainfrom
recut/ap3-plot-verb

Conversation

@noahgift

@noahgift noahgift commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Closes #7041
Refs #6991
Refs #6909

keep-open: #6909 is the master ticket; rows remain

degraded: same-family

What

Third slice of the #6992 re-cut, on top of #7020, which is now merged to main. It wires the plot library from #7020 into apr plot:

apr plot --data <CSV> --aes x=..,y=.. [--geom point] [--width N] [--height N] [--output term|svg] [--no-color]
  • crates/aprender-viz/src/plot_cli/cli.rs (new): PlotFlags, a clap front end behind the new feature plot-cli (clap + batuta-common/cli-roles, so apr surface reads the InputFile/FreeText roles). It maps the flags onto the library's existing PlotArgs. It refuses by name any geom other than point and any aesthetic other than x/y, along with a missing x or y.
  • apr-cli: a Plot variant (feature visualization, which now enables trueno-viz/plot-cli) and plot_result, which refuses the global --json/--quiet. command_owns_stdout sends the --verbose preamble to stderr for plot only.
  • Registry entry, surface audit row, dogfood coverage 927 -> 928, contracts.nt regenerated, book page, and the ci fragment 729 running the plot-cli unit tests.
  • No new R fixture: the tests read the row 1 fixture already in the base.
  • Deferred to a later slice: --spec, --title, --xlab, --ylab, --out.

Provenance (source head c9f2448)

Size vs main (head 111d9e7): 17 files, +587/-11 = 598 lines. Since 6db5761: merged #7020 and main, reworded the plot comments in the registry YAML and cli_commands.rs (aprender-present plot is a separate front end), and aprender-viz now takes clap from the workspace.

Verbatim from the source: the apr-cli wiring shape, 7 of the source's 10 cli_commands plot tests (the 3 spec tests move with --spec), the registry/audit/coverage/nt rows, SUMMARY, the fragment, parse_aes and refuse.

New in slice (132 lines):

  • cli.rs: 102 lines. PlotFlags, plot_args, run and their tests. This is needed because the base's PlotArgs is not a clap struct.
  • book page: 17 lines. Synopsis and refusals for the flags shipped here.
  • 13 lines across the type paths, the feature lines and the wording with --out removed:
    • commands_enum.rs 2
    • dispatch.rs 4
    • apr-cli-commands-v1.yaml 2
    • aprender-viz/Cargo.toml 2
    • plot_cli/mod.rs 3

Gates (head 6db5761)

gate rc
cargo fmt --all -- --check 0
clippy -p aprender-viz --lib --tests -D warnings (default / --features plot-cli) 0 / 0
clippy -p apr-cli --lib -D warnings 0
cargo test -p aprender-viz --lib --features plot-cli plot_cli:: 0 (19 passed)
nextest -p aprender-viz --lib --tests / --lib --features plot-cli 0 (890) / 0 (773)
nextest -p apr-cli --lib 0 (7654)
cargo test -p apr-cli --test cli_commands 0 (24)
cargo test -p aprender-contracts --lib 0 (2382)
pv validate apr-cli-commands-v1 / apr-dogfood-coverage-v1 0 / 0
scripts/contracts_gate.sh (8 of 8 steps ran) 0
fail_fast.py ids --base origin/main 0 (0 new gaps)
check_complexity_ratchet.sh 0
check_tree_reader_tests.sh / check_include_files.sh 0 / 0
check_dogfood_coverage.sh / surface_audit_bins_gate.sh 0 / 0 (928 rows, 33/33)
cargo deny check advisories 0
changed-line coverage (llvm-cov, viz lib + cli_commands) 162 instrumented, 0 missed

Known on the base, not in this diff: clippy -p apr-cli --tests is red in the existing falsification_crux_*.rs and nf4_classifier.rs tests, and at cli_commands.rs:845 and :1204. This PR adds lines only after line 1382 of that file.

Mutants

  • cargo mutants --in-diff on aprender-viz --features plot-cli: 15 found, 15 caught, 0 missed, 0 timeout, 0 unviable.
  • cargo-mutants does not follow include!(), so it finds no mutants in apr-cli dispatch.rs/dispatch_run.rs. They were hand-mutated instead. Each red below is a test panic, not a build error:
id mutation red test
H1 if on -> if false apr_plot_refuses_json_and_quiet
H2 quiet -> false apr_plot_refuses_json_and_quiet
H3 skip cli::run apr_plot_draws_row1_on_stdout_with_the_oracle_breaks
H4 owns_stdout -> false apr_plot_keeps_verbose_lines_off_stdout
H5 owns_stdout -> true verbose_preamble_stays_on_stdout_for_commands_that_do_not_own_it

Review: same-family Claude review only, so this is marked degraded: same-family. Draft, auto-merge not armed.

🤖 Generated with Claude Code

ont-delta: none (apr plot clap front end; no ontology type, shape or concept changes)

noahgift and others added 7 commits November 13, 2026 14:18
The library core of `apr plot`: a CSV file drawn as ggplot2's row 1
(geom_point) to the terminal or SVG. No CLI wiring yet.

- Scales train on the f64 column range (GGPlot::trained_on), so edge
  labels match R where the f32 engine frame would round them (B3).
- breaks.rs: pow10 is exact for |z| <= 22, as R's powl is;
  libm::pow(10, -5) is one ulp low and moved an edge break inside.
- Inf, -inf, infinity and 1e400 are refused by column and line (B4);
  only "" and NA are missing, null is text (N8); "1 row" (N9).
- New fixture geom_point_edges (R 4.6.2, ggplot2 4.0.3, LC_ALL=C):
  17 sets whose labels the test reads byte for byte.
- FALSIFY-GG1-004/005 in ggplot2-row1-point-v1; GG1-INV-002 states
  what is compared. contracts.nt, witness and README regenerated.

Refs #6909
Closes #7009

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…6992)

Second slice of the #6992 re-cut, stacked on AP1. build.rs derives
src/plot_cli/proven_rows.rs from the ggplot2_row blocks of
contracts/trueno-viz/ggplot2-*.yaml and fails the build when the
committed table differs. The generator lives in plot_cli/proven_gen.rs,
include!d by build.rs and by the plot_cli unit tests.

Carries #6992 review findings:
- N4: an oracle must draw exactly one layer of the block's geom.
- N3: a column with one value is refused by name.
- N7: tests pin MAX_F32_ERROR_OF_RANGE = 1e-4 from both sides.

Kept lines are byte-identical to #6992 @ c9f2448; new-in-slice
lines are listed in the PR body. Contract falsifiers FALSIFY-GG1-006/007.

Refs #6909

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… fixtures (Refs #6909)

The review of c05f286 found the build.rs wiring untested: deleting the
check_oracle call, the contract-dir check or the drift check left every
test green, and only the first expected*.json was ever exercised.

- read_rows, expected_jsons and the drift check (sync) move from build.rs
  into proven_gen.rs; build.rs only calls sync.
- the_contract_walk_admits_only_rows_their_oracles_back drives sync on a
  tempdir: no contracts dir, a non-row yaml, an oracle with only
  expected_*.json, drift then regen, a valid second row (scale_x log10),
  a bad second oracle after a good one, a second row whose oracle draws
  GeomLine, and a row without a falsifier.
- check_oracle cross-checks the oracle spec for stat, position, scale_x,
  scale_y, coord, facet and theme.
- the_committed_table_is_the_contracts_rendered runs sync over every
  contracts/trueno-viz/ggplot2-*.yaml, not row 1 alone.
- N7 is pinned at exactly 1e-4: refused at range 9999, drawn at 10000.
- FALSIFY-GG1-006 names the walk test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… double-quoted spec is refused (Refs #6909)

The rule claimed the spec dimensions and the one-layer check, but its test
ran only the walk test. It now runs plot_cli::generator::, and the
prediction names both tests. named() refuses a spec naming a key twice or
holding a double quote instead of reading the default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts were derived files only: README contract count and the
contracts.nt witness; took main and re-derived.

Refs #6909

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oven-rows

Refs #6909

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…6992)

Wires the plot library of the previous slice into `apr plot`:
`--data <CSV> --aes x=..,y=.. [--geom point] [--width N] [--height N]
[--output term|svg] [--no-color]`. Behind aprender-viz feature
`plot-cli` (clap + batuta-common/cli-roles), enabled by apr-cli's
`visualization` feature.

Re-cut of source head c9f2448 (#6992). Line map:
- verbatim from source: apr-cli wiring (commands_enum variant,
  dispatch plot_result, dispatch_run command_owns_stdout), the cli_commands
  plot tests (7 of 10; the 3 spec tests move with --spec), command registry
  entry, dogfood coverage 927->928, surface audit row, contracts.nt triples,
  book SUMMARY, the ci fragment 729, parse_aes and refuse.
- new in slice: crates/aprender-viz/src/plot_cli/cli.rs (PlotFlags, a clap
  front end onto the previous slice's PlotArgs, since its PlotArgs is not a
  clap struct), the feature lines, the type paths in the apr-cli wiring, and
  a book page limited to the flags this slice ships.
Deferred to a later slice: --spec, --title, --xlab, --ylab, --out.

Refs #6909
Refs #6991

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@noahgift noahgift added this to the 0.74.2 milestone Nov 14, 2026
@paiml-fleet
paiml-fleet Bot marked this pull request as ready for review November 14, 2026 15:18
@noahgift

Copy link
Copy Markdown
Member Author

Non-author review: PASS at 6db5761 (delta on top of #7020)

Reviewer: gemini-4-argon-high (agy lane, read-only, sandboxed; witness e691a1fa7cb8c5f1788c708cc8e13798). Author model: Claude. Blocking findings: 0. Diff reviewed: fceef5d26...6db57610f (17 files, +587/-11). No workflow edits; no gate, threshold or allow-list loosened (dogfood surface rows 927 -> 928, covered unchanged). No unwrap(); the 6 unit and 7 integration tests assert specific outputs and error strings.

Non-blocking follow-up: crates/aprender-viz/src/plot_cli/cli.rs types GEOMS and AESTHETICS by hand for its refusal messages, while book/src/cli/plot.md:14-17 says the drawable set is derived from proven_rows.rs. Execution does go through PROVEN_ROWS; only the message lists can drift.

Not measured by the reviewer: build, tests, clippy (CI measures them). This PASS is bound to this head: the PR is stacked (#7018 -> #7020 -> this). It is armed only after it is retargeted to main; a material change from merging main gets a re-review.

noahgift and others added 3 commits November 14, 2026 16:56
…7018

Pmat-Ticket: #6909
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-plot-verb

Refs #6909
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es the verb; viz clap from workspace (N10, N12)

Refs #6909
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from recut/ap2-proven-rows to main November 14, 2026 16:43
Refs #6909
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

§13.11 rung 1 — quorum shadow verdict

S13-SHADOW pr=7042 head=111d9e76e838e41286a5a0ac64e4247aaa1f4fb7 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.

@noahgift noahgift left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Non-author review: gemini-4-argon-high PASS at 634076f (tree 611aab6df27d, witness 23d423433efa094291c9f5340415a4aa). 0 blocking.

Checked: apr plot parsing and dispatch have no unwrap or panic on user input; unsupported geoms, aesthetics, --json and --quiet are refused; the CLI registry and cli_commands.rs are in step; no content from main was lost in the branch's merges; no gate, threshold, allow-list or workflow change.

Non-blocking, for a follow-up: book/src/cli/plot.md:44-45 still says a one-value column is refused. After #7018 it is drawn over the expanded span (v ± 0.05), and only values f32 moves by more than 1e-4 of that span are refused.

The review read the diff; it did not build or run tests.

@noahgift
noahgift enabled auto-merge (squash) November 14, 2026 17:17
@noahgift
noahgift merged commit faab37e into main Nov 14, 2026
31 of 36 checks passed
@noahgift
noahgift deleted the recut/ap3-plot-verb branch November 14, 2026 18:46
noahgift added a commit that referenced this pull request Nov 14, 2026
docs(changelog): 0.74.0 lists #7042 and #7053, merged before #7051 (#7029)

Pmat-Ticket: PMAT-7029

Co-authored-by: Claude Fable 5.2 <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.

apr plot: wire the verb into apr (re-cut AP3 of #6992)

1 participant