Repository navigation
tests/tools: family_oracle scores each keyword family against an ast oracle (Part of #8863) - #8864
Conversation
…oracle (Part of #8863) For every function in a finished scan, a real parser says what the function does; the tool joins that to the family column on the same function and reports recall, precision, rank correlation, a status and the tokens the family missed. Python (`ast`) first; any other language is refused rather than scored against nothing. Report only, with a --gate hook for a future ratchet. On GitGalaxy's own 72,044 Python functions it reproduces the pilot gaps (#8857-#8861) and adds two: subprocess.check_output is not in state_danger (540 functions) and `global` statements are not in arch_globals (480). Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvejJbzNR67xR3D2VxV
…vaScript, TypeScript, Java and C (Part of #8863) A second module, family_oracle_ts.py, holds one Spec per language: which node types are functions, branches, closures and throws, how to read a function's name and parameters, and which callee names mean print, sleep, regex, clock, file/network I/O or process exit. family_oracle.py now takes any language through one small oracle interface (Python's ast stays as it was). Oracle checks: the `args` column matches the parser's parameter count at 1.00 recall and 1.00 precision in Rust and C and 0.97 / 1.00 in Java. A decorated function is also keyed by its first attribute or doc-comment line, since a scan may start it there. Functions inside macro bodies are not parsed as functions by tree-sitter and are counted as unmatched. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvejJbzNR67xR3D2VxV
… baseline for the grid (Part of #8863) The oracles now read each family as signal_contracts.py states it: closures are anonymous callables only (a lambda, not a nested def); bitwise_ops include `&` and `|` and the compound assignments; time_date_logic includes durations and formatting; serialization_parsing covers json/yaml/csv/xml/pickle/marshal/protobuf calls, not only the unsafe ones; debug prints leave out writers and log calls (telemetry); a doc comment means structured documentation (/** */, ///, godoc); cleanup includes close/remove/unlink/del; lazy includes Generator/Iterator annotations; assert is not an abort. Each family carries its contract key (`rule`). New: --update-baseline merges a result into tests/family_validity_baseline.json (cells[language][contract family]); a pinned corpus is not displaced by an unpinned one, and a cell with fewer than 10 oracle functions does not displace one with real numbers. Python gains `args`. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvejJbzNR67xR3D2VxV
…nnotations (Part of #8863) `str | None` in an annotation is a type union, not a bitwise operator on values; walking the whole function counted ~17,800 of them as `|`. The oracle now skips annotation subtrees (arguments, return, annotated assignments) when reading bitwise operators. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvejJbzNR67xR3D2VxV
…ct (Part of #8863) The branch contract (docs/branch_rule_contract.md, corollary 1) says a handler is not a decision: catch / except / rescue / finally / try / throw belong to safety. The oracle counted catch_clause (Java, JavaScript, TypeScript) and ast.ExceptHandler and assert (Python) as branches; it no longer does. Loops, if/else arms, case/default arms, the ternary and boolean operators still count, as the engine's own rules do. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvejJbzNR67xR3D2VxV
… shell (Part of #8863) Two spec modules, one per group of languages, each with its own node maps on top of family_oracle_ts.Spec (operator and call nodes differ per grammar: Kotlin and Scala infix operators, Swift infix/prefix nodes, Ruby `call`/`binary`, PHP `*_call_expression`, Lua `function_call`, shell `command`), a receiver-aware callee match (a bare name is a bare call; `*.m` is any receiver; `A.` is a prefix), and per-language doc rules. get_oracle() loads them lazily; `shell` is the bash grammar. 227 single-construct cases (family_oracle_cases.json) pin the readings. Reproduced end to end through the repo's CLI on the same scans the two agents used: matched functions and every family's recall and precision are identical for all eight. The agents gated each oracle on `args` and `branch` agreeing with the parser at >= 0.90: C#, Kotlin, Scala, Ruby, PHP and Lua pass; Swift misses on branch precision (0.66, an engine defect, #8895) and shell on branch precision (0.84: words in strings and heredocs, #2535). Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvejJbzNR67xR3D2VxV
|
No description provided. |
|
PR #8864 @ f126cf1: 1 failed check(s) == full-suite part 1/4 (failure) -- real |
|
No description provided. |
…'s renames (Part of #8863) CI's tree_sitter_language_pack knows the C# grammar as `csharp`; this box's release as `c_sharp`. The 9 C# cases failed in CI's full suite with "Language 'c_sharp' is not in the download manifest". get_parser() now tries each name a grammar has been known by (c_sharp/csharp, objc/objective_c, bash/shell) and the three oracle modules use it; a test simulates the CI naming. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvejJbzNR67xR3D2VxV
|
CI shepherd: the head of this PR (fbce8b3) is not the one a maintainer labelled |
|
No description provided. |
|
No description provided. |
…not the IO type (#8935) * fix(haskell): bitwise_ops matches .&. and .|.; io counts operations, not the IO type (Part of #8904) Found by the keyword-family validity tool (#8864) with a Haskell oracle on pandoc's src/ (5,990 functions). bitwise_ops: the rule ended `\.&&\.|\|\.\|\|\.`, spellings Haskell does not have, so Data.Bits' `.&.` and `.|.` never matched (recall 0.0; the family fired in 11 functions on the words shift/xor used as identifiers). It now reads `\.&\.|\.\|\.`: recall 0.0 -> 1.0 on pandoc. io: `IO` was in the keyword list, so every function whose signature mentions the IO type counted as I/O (60 functions fired where the parser sees 44 real operations). The io contract is "an operation that moves data between the program and a system outside its own runtime ... at its invocation"; a type in a signature is not one. `IO` is removed: precision 0.37 -> 0.80, recall 0.50 -> 0.45 (one function had been matched by its type alone). Not in this change: `decorators` (a `{-# INLINE #-}` pragma sits above the function, outside the span the engine counts; the same mechanism as the Python decorators gap, #8857) and the `throwError`/`fail` question for panics_and_aborts. Eleven bitwise false positives remain: functions that use `shift` or `xor` as an ordinary identifier, inherent to a text rule. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvejJbzNR67xR3D2VxV * test: re-bless golden masters for the Haskell io/bitwise rule fix (Part of #8904) The intended effect of 471e0d9 on the haskell/pandoc entry in both golden fixtures: File & Network I/O falls (App.hs 12 -> 2, Shared.hs 2 -> 0) because the `IO` type in a signature no longer counts as an I/O operation; repository-fingerprint and drift values follow, and one DNA hit disappears. Regenerated with tests/tools/crucible_check.py --update --yes; nothing else changed. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvejJbzNR67xR3D2VxV * Merge main; re-bless golden masters (only haskell/pandoc App.hs + Shared.hs move, from this PR's Haskell family fix) Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Sonnet 5.5 <[email protected]> Co-authored-by: Joe Esquibel <[email protected]>
Part of #8863 (keyword-family validity epic).
What this adds
A test tool,
tests/tools/family_oracle.py, that checks whether each per-function signal counts what its name says. For every function in a finished scan it asks Python's ownastwhat the function does, joins that to the family column on the same function (file and start line), and reports per family: recall, precision, rank correlation, a status (ok,misses,over-counts,both,dead,no-instances) and the tokens most common in the functions the family missed, which are the candidates for missing keywords.Each of the 23 families scored carries one sentence saying what it is scored against (
FAMILIESin the tool;--list-familiesprints them). They are provisional until the definition questions in #8862 are answered. Python usesast; Go, Rust, JavaScript, TypeScript, Java and C use tree-sitter (tests/tools/family_oracle_ts.py; C#, Kotlin, Swift, Scala, Ruby, PHP, Lua and shell infamily_oracle_specs_a.pyandfamily_oracle_specs_b.py, loaded on demand, one smallSpecper language: node types for functions, branches, closures and throws, plus the callee names the oracle reads as print, sleep, regex, clock, I/O and exit). Any other language is refused with a clear message rather than scored against nothing. Report only: nothing runs in CI, and--gateis the hook for a ratchet once floors are agreed.What it shows on GitGalaxy's own code (72,044 Python functions, 91 s)
subprocess.check_outputmissed in 540 functions (new)globalstatements in 480 functions (new)lazy_evaluation(yield only),state_bailout_hits.The strict operator-position reading answers the share left open in #8861: only 230 of the 6,700 functions where
bitwise_opsfires have a real<< >> ^ ~.Other languages (one real repository each; recall / precision against tree-sitter)
complexityargsbitwise_opsargsmatching the parser's parameter count is the check that the oracles read functions correctly.bitwise_opsis the systemic result: closing generics (Map<String, List<String>>) count as a right shift, and text inside strings counts (#8866); Java does not countcatch(#8867); the per-language differences that need a definition are in #8868.Tests
tests/tools/test_family_oracle.py(52 cases, 0.1 s; the tree-sitter cases skip when the language pack is not installed): one construct per case (so a regression names itself), a miniature scan database with known recall, precision and statuses (including a decorated function found by its first decorator's line and a function the parser cannot find), the gate's pass and fail paths, and the unsupported-language refusal.Checks run
test_source_reads,test_generated_branch,test_sweep_plan,test_ci_critical_path_split,test_change_classifier) and the new tests: 257 passed, 1 skipped. Time ratchet: 258 tests, none over the limit.tests/tools/audit_check.py: all clear.pr_gates --fast: 8 of 9 gates pass (lint, audits, secrets, xray, gen-docs, derived, workflows, affected).gauntletfails on 8 Kotlin Unicode-identifier cells (kotlin|devanagari|*,kotlin|nfd|*,kotlin|tamil|*:function_data missing; 942 of 950 cells pass). This branch isorigin/main(fa90edd) plus two new files undertests/tools/, so the engine is byte-identical to main and the failure is not from this change. Whether main is red or this box's venv differs from CI's is not established (noci-red-mainissue is open); CI on this PR will say.--ratchets(no golden, ledger or generated file touched).Not in this PR
Fixes to any family (#8857-#8861, #8865-#8867; each needs the CPU-second timing the epic asks for), tree-sitter oracles for C++, C#, Kotlin, PHP, Ruby, Swift, Lua and shell, the keyword-rosetta cross-language consistency report and the missing-keyword mining report: the remaining epic checklist items. Functions inside macro bodies (a large share of tokio) are not parsed as functions by tree-sitter and are reported as unmatched.
🤖 Generated with Claude Code
Update 2026-11-21 (later)
family_oracle_cases.json;tests/tools/test_family_oracle_langs.py). Reproduced through this PR's CLI on the scans two agents used: all eight give identical matched counts and identical recall and precision for every family. Each was gated onargsandbranchagreeing with the parser at 0.90 or better: C#, Kotlin, Scala, Ruby, PHP and Lua pass; Swift misses on branch precision (0.66, a real engine defect: Swift: branch counts optional types and chaining (T?, x?.y), for as an argument label, and default/case outside a switch (precision 0.66) #8895) and shell (0.84: words inside strings and heredocs count, prism/detector: string-literal shielding is selective by signal family (if/try/open count inside a literal, eval does not) #2535).catch/excepthandlers orassertas branches. The branch contract (docs/branch_rule_contract.md, corollary 1) says a handler is not a decision. (WITHDRAWN: Java complexity does not count catch (not a bug: branch contract corollary 1) #8867 withdrawn.)--update-baseline, the contract-aligned readings, and.gitignorewhitelisting of the cases fixture are part of this PR. Checks: ruff, mypy, 513 tests across the tree-wide guards, time ratchet and audits all clean.