Skip to content

Contextual Baseline Fix: case-fold the resolver for case-insensitive-import languages (#2871) - #2915

Merged
squid-protocol merged 1 commit into
mainfrom
fix/2871-cbf-case-fold
Sep 9, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/2871-cbf-case-fold

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Closes #2871. Phase 1 of #2908 (child of #2812).

What

Two dependency resolvers disagreed. network_risk_sensor's graph (pagerank, the recorded popularity column) learned in #2540 that haskell's necessarily-capitalised import B binds b.hs. The orchestrator's own _resolve_dependency_graph — the resolver the Contextual Baseline Fix is gated on — did not: its suffix fast path is exact-case (key b, token B) and its stem fallback's len(stem) >= 3 guard rejects b. So every visible column said the chain resolved while the orphan wipe never ran.

This adds the orchestrator's twin of the sensor's Stage 1c: a per-language lowercase view of the suffix keys, built only for CASE_INSENSITIVE_IMPORT_LANGS (fortran, cobol, haskell — the registry flag #2540 introduced) and holding only that language's own files, consulted only after both exact-case fast paths miss. Case-sensitive languages gain nothing, folding never invents a cross-language edge, and the language-agnostic stem fallback is untouched.

Measured

haskell corpus folder, full precision, before → after:

file CBF popularity state_unreferenced risk_tech_debt
a.hs 0 → 1 3 → 0 97.07 → 0.00
b.hs 0 → 1 3 → 0 97.07 → 0.00
c.hs 0 → 1 3 → 0 100.00 → 81.76
main.hs 0 → 0 1 → 1 37.75 → 37.75

java, rust and swift (same stratum, same layout) read exactly 0 / 0 / 81.76. This clears the risk_tech_debt open-defect cell and takes haskell's risk_documentation input onto the right footing for Phase 2.

  • rosetta_audit.py, 46 languages against keyword-rosetta at origin/main: no gated cell moves (haskell PASS, 80 assertions; the one reported regression is c's a.c, c api rule counts top-level variable declarations as public surface (a.c reads api 5 for 3 functions; +25.0% sits at the band edge) #2907's re-bless in keyword-rosetta#110). The manifest gate cannot see unreferenced_by_name after the wipe, which is why this was ledgered rather than asserted.
  • crucible_check.py: both golden masters PASS unchanged — no crucible file carries a short capitalised import that this path decides.
  • test_galaxyscope.py 60 passed, incl. the new regression (haskell import B → b.hs; go B does not fold; haskell import Q does not fold onto q.py). audit_check.py all clear.

Corpus

Label rosetta:rebless-owed for the ledger only: haskell-module-name-invisible-to-popularity-tally retires (risk_tech_debt haskell +178% → on the median), and the haskell manifest note's "control for #2827" remark gets the correction the issue names (its api_orphan_credit 0 was a suppression that never had a chance to run). No manifest number changes.

Not done here

The issue's deeper fix — the Contextual Baseline Fix reading the sensor's graph instead of a second resolver — is a refactor of the orchestrator's Phase 1.5 and stays open as a design question. This PR makes the two resolvers agree on the case the corpus proved, with the same scoping rules, so they cannot disagree on it again.

🤖 Generated with Claude Code

…import languages (#2871)

galaxyscope's _resolve_dependency_graph -- the resolver the Contextual
Baseline Fix is gated on -- kept an exact-case suffix fast path and a stem
fallback whose `len(stem) >= 3` guard rejects `b`. Haskell module names must
be capitalised, so `import B` missed the fast path (key `b`) and was refused
by the fallback, while network_risk_sensor's #2540 case-folded graph (the one
pagerank and the recorded `popularity` column read) resolved the same edge
fine. Every column a reviewer could see said the chain resolved; the one
consumer that wipes an imported file's orphans never ran. keyword-rosetta
haskell a/b/c: unreferenced_by_name 3 where every other language reads 0,
risk_tech_debt 97 against an irc0 median of 30.

This adds the orchestrator's twin of the sensor's Stage 1c: a per-language
lowercase view of the suffix keys, built only for CASE_INSENSITIVE_IMPORT_LANGS
(fortran, cobol, haskell -- the same registry flag #2540 introduced) and
holding only that language's own files, consulted only after both exact-case
fast paths miss. Case-sensitive languages gain nothing; folding never invents
a cross-language edge; the language-agnostic stem fallback is untouched.

Measured: haskell a/b/c popularity 0 -> 1 at the CBF, state_unreferenced
3 -> 0, risk_tech_debt 97.07/97.07/100 -> 0/0/81.76 (java, rust, swift read
exactly that). rosetta_audit 46/46: no gated cell moves (haskell PASS 80; c's
a.c is #2907's pending re-bless). crucible_check: both golden masters PASS
unchanged. Corpus owes the retirement of ledger entry
haskell-module-name-invisible-to-popularity-tally (rosetta:rebless-owed).

Phase 1 of #2908.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@squid-protocol squid-protocol added bug Unintended behavior or logic failure in the engine metrics Heuristics, risk exposures, and topological math updates core-engine Modifications to the central physics and parsing engine rosetta:rebless-owed Intentionally moves keyword-rosetta counts; audit warns, corpus re-blesses after merge labels Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit e4ec82f into main Sep 9, 2026
81 checks passed
@squid-protocol
squid-protocol deleted the fix/2871-cbf-case-fold branch September 9, 2026 13:13
squid-protocol added a commit that referenced this pull request Sep 9, 2026
…S timing asserts (#2901) (#2919)

* ci: dedupe concurrent runs, parallelise pytest, cap job runtime

Measured over the last 400 workflow runs (~27h window, 2026-09-08/09):
2201 min of wall clock, of which Full Suite Gate alone was 983 min (45%).
The cost was not test execution -- it was running the same tests repeatedly
and then queueing for runners.

Three findings drove this:

1. `full-suite-gate.yml` triggers on `pull_request: types: [labeled]` with
   no label filter, so EVERY label added starts a separate run. PRs here
   routinely carry four labels (bug, metrics, core-engine,
   rosetta:rebless-owed), and #2915 fired four identical 12-job matrix runs
   against one SHA (56624e7) within 10 seconds. rosetta-audit, which also
   listens for `labeled`/`unlabeled`, fired five times on the same commit.
   No workflow in the repo declared `concurrency`, so nothing superseded
   anything. ~577 min of the sampled 2201 was redundant.

2. Queue time dwarfed run time. In run 34346837647 the matrix jobs RAN for
   10-18 min but QUEUED for 23-65 min, macOS worst (51-65 min) as the
   scarcest pool -- 16 macOS jobs were queued where 4 were needed.

3. `pytest tests/ -v` ran the whole suite single-threaded and streamed 7946
   lines / 1.1 MB to the Actions log per job.

Changes:

- `concurrency` on 18 workflows, keyed by workflow + PR number (or ref).
  `cancel-in-progress` is deliberately scoped to `pull_request` via an
  expression: the push/schedule/tag runs are the ones that COMMIT (docs
  deploy, tri-comparison / tree-sitter history charts, releases), and
  cancelling one mid-write risks a half-written commit. Those now serialise
  on the group instead. `publish.yml` and `release-crucible-archive.yml` are
  left untouched entirely -- the release path should not be interfered with.

- pytest jobs get `pytest-xdist` and run `-n auto -q -ra --durations=25`.
  Verified locally against this same tree: 8685 tests, serial 323.6s ->
  parallel 104.8s (3.1x on 6 cores), identical pass/skip/xfail counts. CI
  runners are 4-core, so expect ~2.5x. `-ra` keeps the xfail/skip summary
  and `--durations=25` keeps a slow-test report, which is the only part of
  `-v` that was load-bearing on a green run.

- `timeout-minutes` on every job across 18 workflows. The default is 6h; a
  Full Suite Gate run was observed sitting at 78 min mid-flight during this
  investigation with nothing to stop it.

- `full-suite-gate.yml` sizes its matrix per checkpoint. A `v*` tag still
  gets the untrimmed 12-way grid. A PR label gets 8 jobs: all four Python
  versions on ubuntu (the thing this gate exists to catch is a
  version-specific break the every-push ubuntu/3.12 full-suite cannot see),
  with windows and macOS covering the version floor and ceiling only. That
  halves the macOS jobs that dominate the queue.

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

* fix(tests): replace wall-clock ReDoS ratios with absolute bounds (#2901)

#2901 reports two asserts going red on shared macOS runners for PRs whose
diffs touched neither: `test_embedded_python_spec_exposure_redos_immunity`
(macOS runs 34288012477, 34212533327 -- expected ratio > 2.5, got 2.31) and
`test_var_decl_pattern_scales_linearly_not_quadratically`. Both compare
wall-clock samples on a contended runner.

Scope is wider than the two files the issue names, deliberately: the same
shape appears at 22 timing sites, and the companion CI change in this branch
runs the suite under `pytest -n auto`, which raises CPU contention and would
have made every one of them flakier. `_strict_harness._best_of_timing`'s own
docstring already records this class of failure recurring (#713, #800), and
groovy's spec_exposure test carries a comment about it going red on
macos-3.10 during #770.

Triaged into three groups:

- 6 sites already assert an ABSOLUTE bound on the shipped pattern
  (test_prism, abap, matlab, scheme, yaml, security_lens). Left alone --
  these are the shape the issue recommends.

- 13 sites timed the PRE-FIX pattern to prove it was quadratic before
  checking the shipped one. Removed. They measured a regex this repo no
  longer ships, so no threshold makes them both meaningful and stable, and
  every one is redundant with an `assert_redos_immune` already in the same
  test. The measured pre-fix numbers are preserved as comments, and
  `test_language_standards_strict.py` keeps each language's pre-fix pattern
  in its parametrize table as documentation (the param is renamed
  `_old_pattern_text` to mark it non-executable).

- 3 sites (groovy x2, yacc) asserted a ratio ceiling on the SHIPPED pattern
  immediately after an `assert_redos_immune` call on a 100k payload. The
  ratio was strictly weaker than the absolute bound above it; removed.

- 2 sites converted from ratio to absolute bound, since they had no
  `assert_redos_immune` of their own:
  * `var_decl`: verified the replacement still catches what it is for --
    restoring the adjacent-unbounded-quantifier shape (`[^=\n]{0,80}` ->
    `[^=\n]*`) makes the new 160k assertion FAIL, while the shipped pattern
    passes it in ~1.1s including process spawn.
  * ada `func_start`: measured while replacing it, this site has NO reachable
    quadratic regression -- the aspect segment is lazy, so even fully
    unbounded (`[^;{}]{0,300}?` -> `[^;{}]*?`) it stays linear (0.0002s /
    0.0004s / 0.0007s / 0.0014s at n=2000/4000/8000/16000). The old ratio's
    additive 0.05 floor was deciding the result. Kept as a plain ceiling on
    a long aspect run and the docstring says so rather than overclaiming.

Suite is green both ways on this tree: 8685 passed / 4 skipped / 9 xfailed /
3 xpassed, identical serial and under `-n auto`. No new ruff findings (the
one I001 in test_language_standards_strict.py predates this branch).

Closes #2901

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

bug Unintended behavior or logic failure in the engine core-engine Modifications to the central physics and parsing engine metrics Heuristics, risk exposures, and topological math updates rosetta:rebless-owed Intentionally moves keyword-rosetta counts; audit warns, corpus re-blesses after merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Contextual Baseline Fix reads a weaker dependency resolver than every column it is audited by (haskell)

1 participant