Skip to content

Merge tests/core_engine/languages/ into tests/extraction/languages/ - #1059

Merged
squid-protocol merged 1 commit into
mainfrom
merge-language-test-dirs
Aug 5, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
merge-language-test-dirs

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Follow-up to #1057. Now that the strict structural-signature per-language files are _strict-suffixed (test_<lang>_strict.py), they no longer collide with tests/extraction/languages/'s own test_<lang>.py files — so there's no reason to keep two separate per-language directories. Colocates them: tests/extraction/languages/ now holds both concerns side by side per language, each with its own independent harness module (_extraction_harness.py, _strict_harness.py).

  • git mv for all 45 language files + _strict_harness.py. The internal sys.path bootstrap in each is self-relative (Path(__file__).resolve().parent), so it needed no code changes.
  • Fixed the one non-self-relative path: tests/core_engine/test_language_standards_strict.py's sys.path insert pointed at ./languages (a sibling that no longer exists after the move) — now points at ../extraction/languages.
  • Fixed stale in-file docstrings/comments that named the old tests/core_engine/languages/ path (each file's own "migrated out of" note, the harness docstring, and the duplicated cross-language-sweep intro comments in files that got redistributed functions from Split test_language_standards_strict.py into per-language files #1057's cross-language sections).
  • Updated every doc pointer: CLAUDE.md, tests/README.md, tests/core_engine/readme.md, tests/extraction/readme.md, how_to_add_a_language.md, how_to_harden_extraction.md, LESSONS_LEARNED.md, two cross-file comments in language_standards.py.
  • Reverted an incidental ruff format side effect that reformatted several unrelated, pre-existing extraction files it happened to touch when run across the whole directory — kept this diff scoped to what it actually intended to touch.

No regex/parsing logic changed — pure file reorganization plus doc updates.

Test plan

  • Collected test count for tests/core_engine/ + tests/extraction/ unchanged: 5210.
  • Full tests/core_engine/ + tests/extraction/ run: 5194 passed, 2 skipped, 11 xfailed, 3 xpassed (unchanged).
  • Full repo-wide pytest tests/ run: 5447 passed, 2 skipped, 1 deselected, 11 xfailed, 3 xpassed — identical to baseline, confirming no repeat of Split test_language_standards_strict.py into per-language files #1057's multiprocessing-spawn regression class.
  • Bare pytest (not python -m pytest) invocation from an unrelated cwd, on both an extraction and a strict file for the same language together, confirming no import interference now that they're colocated.
  • python tests/tools/audit_check.py — clean.
  • CI green (crucible-audit, full-suite, ruff/mypy/dead-key audits, smoke-test matrix, CodeQL, etc.)

🤖 Generated with Claude Code

Both directories held one file per language with no basename collision
(test_<lang>_strict.py vs test_<lang>.py), so there's no reason to keep two
separate per-language directories. Colocates them: every language's
extraction-gauntlet coverage and structural-signature coverage now sit next
to each other in tests/extraction/languages/, sharing the directory but not
the harness module (_extraction_harness.py and _strict_harness.py stay
independent, one per test concern).

Mechanically a `git mv` (the internal sys.path bootstrap in each moved file
is self-relative, so it needed no changes), plus:
- Fixed the one non-self-relative path: the residual
  tests/core_engine/test_language_standards_strict.py's sys.path insert,
  which pointed at ./languages (a sibling that no longer exists) and now
  points at ../extraction/languages.
- Fixed stale in-file docstrings/comments (each moved file's own "migrated
  out of / colocated in" note, the harness's docstring, and the duplicated
  cross-language-sweep intro comments) that named the old path.
- Updated every doc pointer accordingly (CLAUDE.md, tests/README.md,
  tests/core_engine/readme.md, tests/extraction/readme.md,
  how_to_add_a_language.md, how_to_harden_extraction.md,
  LESSONS_LEARNED.md, two cross-file comments in language_standards.py).
- Reverted an incidental `ruff format` side effect that reformatted several
  unrelated, pre-existing extraction files it happened to touch when run
  across the whole directory -- kept the diff scoped to files this change
  actually intended to touch.

Verified: collected test count for tests/core_engine/ + tests/extraction/
unchanged (5210), full repo-wide `pytest tests/` unchanged (5447 passed, 2
skipped, 1 deselected, 11 xfailed, 3 xpassed), audit_check.py clean, and the
bare-pytest (CI-style invocation) + cwd-independence checks both still pass.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit e28519a into main Aug 5, 2026
28 checks passed
@squid-protocol
squid-protocol deleted the merge-language-test-dirs branch August 5, 2026 19:26
squid-protocol added a commit that referenced this pull request Sep 3, 2026
…over-claims, three None rules (#2669) (#2681)

* fix(core-engine): count a doc comment once, not once per marker plus once per tag (#2672)

A `doc` rule listing BOTH a doc-comment marker (`/**`, `///`, `=pod`) AND
the tags that live inside it (`@param`, `@return`, `- parameter`, ...) as
independent alternatives counted one comment once per marker plus once per
tag. This is the #2658 shape (python/embedded_python, commit 30a0701),
never swept across the 18 languages that share it.

Fix shape, per language, in alternation order: the bounded non-greedy block
form first (`/\*\*[\s\S]{0,15000}?\*/`, plus objective-c's `/\*!...\*/`),
the line-marker form next (`///` -> `///[^\n]*`), bare tags last so a tag
outside any doc comment still counts -- java's `@Operation`/`@Schema` are
real annotations, not javadoc. perl pairs its POD opener to `^=cut`. cobol
drops `AUTHOR` from the doc header alternation, since `ownership` owns it
exclusively.

Eight languages move to their planted value on the control corpus, each
with a single `doc 2 -> 1` delta and nothing else: java, groovy, kotlin,
php, scala, solidity, perl, cobol. The other nine (c, cpp, objective-c,
dart, javascript, typescript, swift, csharp, yacc) are corpus-inert -- they
read 1 only because the corpus plants one of {marker, tag} and never both,
so the defect was latent, not absent. One ordinary Doxygen block scored
`doc` 4 in c/cpp/objective-c and 3 in java/javascript/typescript.

Since `doc` is a defense term in `_calc_documentation`, this RAISES
`risk_documentation` on tag-heavy real code. That is the intended
direction: documentation mass is already carried by `doc_loc`, so `doc`
counting comments once is the coherent semantic, and it is the one #2658
established for python.

cobol's change corrects two pre-existing tests that encoded the AUTHOR
double-count as intentional. That is the same call #2650/#2659 already made
for ~14 languages -- see `test_abap_doc_vs_ownership_overlap_is_intentional`
being renamed to `..._author_collision_fix` in 6feb8cb -- and cobol is the
last language in that set, which is what #2661 exists to finish.

Corpus rebless is a separate PR. Closes #2670 and #2661 step 2.

Batch B.3 of #2669. Implemented by Claude Sonnet 5, reviewed here.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(apex): pair the ApexDoc block, hand @author to ownership, restore the import type-guard (#2672, #2671)

#2672 -- apex's share of the doc family: the block form now counts once
instead of once per marker plus once per tag, and `@author` is dropped from
`doc` because `ownership` owns it (the #2659 rule). That removal needs a
companion change: apex's `ownership` required a colon (`@author:`), so
idiomatic ApexDoc `@author Joe` was doc-only and would have been lost
entirely. Only that one alternative is relaxed to colon-optional; the
prose-risky `Author|Copyright|...` alternatives stay colon-required, so
`the Author of this module` still scores nothing.

#2671 -- the `import` rule is compiled `re.IGNORECASE`, which neutralised
the `[A-Z]` guard in its type-reference alternative: it degraded from
"lowercase receiver, capitalised member" to "any word.word", so every
qualified method call counted as an import. Restored with a scoped
`(?-i:[A-Z]\w*)` flag override, which re-enables case sensitivity for just
the member-name class while `Type.forName` and the namespace-exclusion
lookahead stay case-insensitive -- a one-token diff that keeps the single
compiled pattern detector.py expects.

Corpus: `import` 6 -> 3 (its planted value), `doc` stays 1, `ownership`
stays 1. `foo.bar`, `conn.clear` and `Logger.info` no longer count as
imports; `System.debug`/`Database.query` remain excluded by the existing
lookahead, and `Type.forName` still counts.

The two issues are separate rules but the same file and test shape, so they
ship together per #2672's own recommendation. Corpus rebless is a separate
PR.

Batch B.3 of #2669. Implemented by Claude Sonnet 5, reviewed here.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(core-engine): three rules stop counting tokens another rule owns (#2675)

The #2659 family: a rule claiming a token another rule already owns, or
matching a token in a form too broad to mean what the rule means. Each
lands exactly on its planted corpus value, with the owning rule undisturbed
at its own planted value.

- livecode `safety_bypasses` dropped `global\s+`. `disable messages`,
  `unlock screen` and dynamic `do` are genuine bypasses; `global ` is a
  scope declaration that `globals` owns exclusively. 4 -> 2.
- lua `safety_bypasses` dropped `_G`/`_ENV` (a bare reference to the global
  table, owned by `globals`) and `collectgarbage` (GC control, owned by
  `cleanup`). rawget/rawset/rawlen/debug.*/getfenv/setfenv stay -- those
  really do defeat metatables or the environment. 4 -> 2.
- dockerfile `io`: the bare package-manager names exist to catch a network
  fetch (`apt-get install`), but also matched `RUN apt-get clean` and
  `RUN yum clean all`, which touch no network and no external file --
  `cleanup` owns those exact phrases. Now requires a non-clean subcommand.
  5 -> 3, with all six install forms kept.

fortran was in the filed issue and has been WITHDRAWN, not implemented.
`test_fortran_strict.py:418` has documented since #1059 that `COMMON`
firing both `globals` and `safety_bypasses` is "an intentional
double-classification, not a false collision" -- one of a family from the
same ambiguity sweep, and correct on the language, since a COMMON block
lets distinct program units alias the same storage with no type checking.
That is genuinely unchecked memory sharing, unlike livecode's scope
declaration or lua's table reference. Notably the #2650/#2659 sweep touched
that same test file for the author-header class and deliberately left
COMMON alone. fortran `safety_bypasses` 3 vs planted 2 is therefore
intended morphology for the ledger, not a defect.

Corpus rebless is a separate PR.

Batch B.3 of #2669. Implemented by Claude Sonnet 5; the fortran withdrawal
was caught in review here.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* feat(html,yaml): wire three rules that were None (#2645, #2646, #2647)

- html `high_risk_execution` (was None): `srcdoc=` embeds a full inline
  document, including <script> content, as a string. It never tripped the
  HANDSHAKE_REGISTRY (whose trigger needs `^[ \t]*<script\b` at a line
  start, not a token inside a quoted attribute) and `io`'s attribute list
  omitted it, so a file that is entirely `<iframe srcdoc="<script>eval(1)
  </script>">` scored 0. Matches the attribute's presence rather than
  sniffing its contents -- the primitive is the risk, as with bare
  eval/exec elsewhere. Per #2645, `on[a-z]+=` and `href="javascript:"` are
  deliberately NOT routed here; they are already correctly claimed by
  listeners/reflection_metaprogramming/safety_bypasses.
- yaml `ownership` (was None): the `author:` / `contact:`-block idiom of
  action.yml and OpenAPI `info.contact`.
- yaml `cleanup` (was None): shell-embedded teardown verbs inside run:/
  script: blocks. Its root-path exclusion is widened from the issue's
  sketch so that `rm -rf /2` no longer matches BOTH cleanup and
  high_risk_execution -- the latter explicitly claims any `/` not followed
  by a letter, pinned by its own existing regression test. The two rules
  are now exact complements. Also covers the space-separated
  `docker compose down`, which the issue named in prose but not in its
  illustrative regex.

These are corpus-visible even though they plant no keyword: GATING.md makes
a cell n/a BECAUSE its rule is None, so wiring one ends the exemption. The
control corpus contains no `srcdoc`, no `author:` and no teardown verb, so
all three still measure 0 -- the manifests already record 0, so
`verify_language.py` and `rosetta-audit` stay green. What changes is the
bias report: the cells leave n/a (excluded from medians) and become
comparable 0s against medians of 3, 1 and 2. The paired corpus PR plants
the idioms so they never surface red; the screened plant text is in its
description.

#2644 (yacc class_start) was the fourth issue of this shape and has been
PULLED -- see its own thread. yacc is absent from detector.py's
_CLASS_START_NAMED_EXTRACTION_LANGS, so wiring its class_start would not
use the new %union rule at all; it would fall through to the legacy generic
`class|struct|interface|trait|enum` fallback and claim the 57 bare
`struct Foo` declarations in the embedded C action code of real grammars
(17 and 9 phantom classes on the two real .y files). Fixing that means
editing the detector allowlist -- the slicer layer -- which #2669's
stacking rule keeps out of a registry-regex PR.

Batch B.3 of #2669. Implemented by Claude Sonnet 5, reviewed here.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* chore(crucible): re-bless golden masters for the B.3 wave-2 regex batch

Blessed after a scoped-diff review, with user sign-off. All 710
differences attribute to the 17 languages this branch changes, plus
aggregate rows -- zero unexplained:

  cobol 207   php 93   lua 52   perl 42   typescript 31   java 28
  apex 20   scala 20   solidity 19   javascript 13   groovy 13
  swift 6   c 5   cpp 4   kotlin 4   html 3   dart 2
  aggregates 148

cobol dominates because dropping AUTHOR from `doc` (#2672, #2661 step 2)
fires on every real COBOL file carrying an AUTHOR paragraph, and a lower
`doc` raises risk_documentation, which ripples into the exposure rows.
That is the intended direction: `doc` is a defense term in
_calc_documentation and was inflated by tag/marker double-counting.

Unlike wave 1 there are ZERO topological coordinate diffs. Consistent:
wave 1 changed func_start, which changes function counts and therefore
structural mass, re-solving the 3D layout corpus-wide. Wave 2 changes
doc/import/safety_bypasses counts, which feed the risk formulas but not
mass, so nothing moves in space.

Scoping note for the next bless: attributing by DIRECTORY name
under-attributes. A first pass left 15 stragglers that were really
`.CBL` (uppercase), an extensionless `exiftool` perl script, and a
`Jenkinsfile` -- the same directory-vs-language trap as `.gradle` and
objective-c. Attribute by the file's actual language, not its folder.
The diff itself came from regenerating the audit and running
golden_diff.deep_compare directly, since crucible_check.py surfaces
only ~28 of 710 (documented in CLAUDE.md as of #2680).

Batch B.3 of #2669.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(html): a srcdoc-bearing iframe fetches nothing, so io must not claim it (#2645)

Follow-on to this branch's own #2645 change, found while planting the
corpus idiom that `high_risk_execution` now measures.

`srcdoc` is an iframe-only attribute, and `io`'s bare-tag alternative
claimed `<iframe` unconditionally -- so planting the srcdoc that
high_risk_execution needs would have pushed html's io from its planted 3
to 5, trading one out-of-band cell for another and leaving the corpus no
better off.

Excluding srcdoc-bearing iframes is not a workaround, it is the correct
reading: such a frame performs no I/O at all, its document is inline, and
per the HTML spec `srcdoc` overrides `src` when both are present. A real
fetch (`<iframe src=...>`) is untouched, and an explicit `src=` attribute
keeps counting through the attribute alternative either way.

Both corpora are unmoved by the rule change itself (crucible html io
362 -> 362, rosetta 3 -> 3) -- neither contained an iframe. With the
companion corpus plant, html's high_risk_execution reaches its planted 2
while io holds at its planted 3.

This supersedes a test added earlier in this same branch that framed the
overlap as an intentional double-classification by analogy with yaml's
`curl ... | bash`. The analogy does not hold: there the curl genuinely
fetches, so both signals are true at once; here the frame fetches nothing.
The test now pins the corrected behaviour and says why.

Batch B.3 of #2669.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: Joe Esquibel <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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