Skip to content

tests/tools: family_validity_chart draws the keyword-family accuracy grid (Part of #8863) - #8876

Merged
squid-shepherd[bot] merged 6 commits into
mainfrom
tool/family-validity-chart
Nov 21, 2026
Merged

squid-shepherd[bot] merged 6 commits into
mainfrom
tool/family-validity-chart

Conversation

@squid-protocol

@squid-protocol squid-protocol commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Part of #8863 (keyword-family validity epic, milestone Eagle Eye).

What this adds

The third validation graph, beside function finding (tri_comparison_chart.svg) and the call graph (graph_coverage_chart.svg): which keyword families are measured, in which language, and how well.

grid

One column per code language the engine parses (73), one row per family that has a written contract in signal_contracts.py (71, grouped by the contract's phase). A cell is:

  • black: N/A, the language defines no rule for that family (2,290 cells);
  • gray: a rule exists, not yet scored by a parser oracle (2,800 cells); a green dot on it means the parserless decoy test passed there (721 cells, red if a comment leaked: none did);
  • dotted gray: scored, but the oracle never sees the construct in the corpus;
  • rainbow: the weaker of recall and precision against a parser's reading of the same functions (red 0%, orange 50%, green 80%, cyan 90%, blue 100%). Taking the weaker side keeps a family that finds everything but also fires on strings (recall 1.00, precision 0.03) from looking good.
    Faded = fewer than 10 oracle functions behind the cell. Hatched = from a corpus that is not a pinned crucible release (exploratory, not reproducible). Hover a cell for recall, precision, function counts and corpus.

python tests/tools/family_validity_chart.py prints a markdown summary; --write writes the SVG; --check fails on a stale SVG; --history PATH appends per-language rows. It is a pure function of tests/family_validity_baseline.json and the engine's own registry (no scan), like graph_coverage_chart.py.

Where the data comes from

tests/family_validity_baseline.json is written by the family-validity tool (#8864): family_oracle.py SCAN_DB --src ROOT --lang L --corpus NAME [--pinned] --update-baseline. A pinned result is never overwritten by an exploratory one, and a cell with fewer than 10 oracle functions never displaces one with real numbers behind it. This PR does not depend on #8864 to merge (the chart only reads the JSON), but the baseline can only be refreshed once #8864 is in.

Seeded with 91 parser-scored cells and the decoy section (2026-11-21): language-crucible v1.7.0 (pinned) for Python, Go, Rust, TypeScript, JavaScript, Java and C, plus exploratory GitGalaxy-engine, prometheus, tokio, express, vue, retrofit and redis scans where the pinned corpus has too few functions. In its current form 858 of 2,894 defined cells are tested (30%): 181 against a parser (15 languages) and 677 by the decoy test only (keyword-rosetta menus and decoy lines: the family keyword planted as bare code, as a comment and as a string literal in each language's syntax; comments stripped in 756 of 756 controlled cells, a keyword in a string counts in 93%, which is #2535's documented behaviour).

README

A short block after the call-graph chart: what a cell is, the date and count, one limit (one corpus per language; the oracle is our reading of each contract, not ground truth).

Checks run

  • ruff 0.17.4 (check and format) and mypy 2.4.1: clean.
  • 15 new tests (synthetic grids, so they do not depend on the registry, plus checks that the committed baseline names real families and languages and that the committed SVG is current).
  • Tree-wide guards, README hand-count test, doc-refs audit, graph_coverage_chart tests: 228 passed, 1 skipped. Time ratchet: 229 tests, none over the limit. audit_check.py: all clear.
  • Not run: the full suite (CI), pr_gates (this box's gauntlet gate fails on 8 Kotlin Unicode cells that also fail on unchanged main code; see tests/tools: family_oracle scores each keyword family against an ast oracle (Part of #8863) #8864).

Not in this PR

Registering the chart in merge_main.py's regenerate table and the history workflow (follow-up), more oracles (C++, C#, Kotlin, PHP, Ruby, Swift, Lua, shell), and a non-tree-sitter oracle for COBOL, JCL, assembler (26 of the 79 language definitions have no tree-sitter grammar). Hand-written files: 3 (tool, test, README); the baseline and SVG are generated.

🤖 Generated with Claude Code

…grid (Part of #8863)

One column per language, one row per family with a written contract (71 families, 73 code languages, grouped by the contract's phase). A cell is
N/A (the language defines no rule), gray (a rule, not yet tested), dotted (scored, the oracle never sees the construct) or a rainbow colour for
the weaker of recall and precision against a parser's reading of the same functions. Faded = fewer than 10 functions; hatched = an unpinned
corpus. A pure function of tests/family_validity_baseline.json and the engine registry, in the house style of graph_coverage_chart.py: --write,
--check (stale SVG), --history. Seeded with the 91 cells scored so far (Python, Go, Rust, JavaScript, TypeScript, Java, C).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018srRvejJbzNR67xR3D2VxV
squid-protocol and others added 2 commits November 21, 2026 08:45
… parserless decoy test) (Part of #8863)

The baseline gains a `decoys` section (language -> family -> comment pass/leak, string counts, keyword) from the keyword-rosetta decoy matrix: the family's
menu keyword planted as bare code (positive control), as a comment and as a string literal in each language's own syntax. The grid draws a green dot on
every cell with a passed comment decoy (red if it leaked) and a tooltip; a decoy-only cell stays gray under the dot. 812 of 2,893 defined cells are now
tested (91 against a parser, 721 by decoy only). README numbers and the legend updated.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018srRvejJbzNR67xR3D2VxV
…8863)

The reviewer's findings: green dots read as "validated" though they marked only the half of the decoy test that cannot fail; the stretched rainbow made 80%
look green; red/green is not colour-blind safe; the title promised parser agreement while 89% of tested cells were decoy-only; ~2,000 identical gray cells
buried the ~90 cells with evidence.

README figure (family_validity_chart.svg) is now a summary: a coverage bar (91 parser / 721 decoy only / 2,081 untested), a table of every parser-measured
cell with the score printed in it (lower of recall and precision, R/P marks the weaker side, red outline under 50%, one blue hue in five fixed bins, rows
worst first), and the decoy result as two bars (comment ignored 756/756, string counted 665/715). The full 73 x 71 grid becomes a separate maintainer
matrix (family_validity_matrix.svg) with hover tooltips, no dots, the same palette. --write and --check cover both.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018srRvejJbzNR67xR3D2VxV
squid-protocol and others added 2 commits November 21, 2026 09:04
…ract, README figure 900 px wide (Part of #8863)

Baseline: C#, Kotlin, Scala, Swift, Ruby, PHP, Lua and shell added (181 parser-measured cells in 15 languages; 677 decoy-only; 2,036 untested), from
oracle specs written by two agents and gated on args and branch (6 of 8 pass; Swift misses on branch precision, a real engine defect; shell on strings).
All branch cells re-scored after the branch contract's corollary 1 (a handler is not a decision): catch, except and assert no longer count in the oracle.

Figure: language names rotated and the decoy panel moved below the table, so the README figure stays about 900 px wide and readable with 15 columns.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018srRvejJbzNR67xR3D2VxV
@squid-protocol
squid-protocol marked this pull request as ready for review November 21, 2026 14:22
@squid-protocol squid-protocol added the shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md label Nov 21, 2026
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

@squid-shepherd
squid-shepherd Bot enabled auto-merge (squash) November 21, 2026 15:20
@squid-shepherd
squid-shepherd Bot merged commit a125232 into main Nov 21, 2026
59 checks passed
@squid-shepherd
squid-shepherd Bot deleted the tool/family-validity-chart branch November 21, 2026 15:36
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant