Repository navigation
Closed
Labels
core-engineModifications to the central physics and parsing engineenhancementNew feature, sensor, or structural signaturetestingUnit, integration, and E2E pipeline verification
Description
Summary
While scoping #1056 (auditing the
tier-aware risk-scoring math in signal_processor.py), a related but distinct validation gap
came up: we have no way to check whether structural extraction itself (detector.py +
gitgalaxy/standards/language_standards.py) treats semantically-equivalent code equivalently
across languages.
These are deliberately separate concerns:
- Epic: Systematically audit tier-aware risk equations in signal_processor.py #1056 audits
SignalProcessor._calc_*(), which only ever sees an already-summarized
raw_signals: dict[str, int](signature counts) plus scalar tier constants — it has zero
visibility into which language or regex produced those counts, so it's correctly tested with
synthetic dicts (as [BUG/METRICS] safety_score's tier2/tier3 systems_buffer flat subtraction wipes attack signal #1055 already did) and needs no real source files at all. - This issue is about the layer upstream of that: does a
forloop, atry/except, an
eval()-equivalent, an import, etc. get detected and counted the same way whether it's
written in Python, COBOL, TypeScript, Rust, etc.? Nothing today answers that empirically.
Proposed approach (from discussion, needs design before building)
Build a small public multi-language control corpus — a repo with one directory per language,
each containing "the same program" expressed idiomatically in that language:
- Files named for control-flow clarity (
A.py/B.pystyle) so the import chain is trivially
readable, forming a simple linear/known dependency graph (a deliberate cross-check for
network_risk_sensor.py's dependency DAG / PageRank too, not justdetector.py). - The program itself doesn't need to be functional or fancy — a minimal dispatcher that exercises
a deliberately chosen set oflanguage_standards.pysignature keys per language (branch, io,
safety_bypasses, sync_locks, etc.), preferably printing which keyword/function was exercised
(e.g."function with keyword X tested") so a human can sanity-check the control file against
GitGalaxy's own output line-by-line. - Each language folder wrapped in that language's idiomatic framework/project shape (not just a
bare script) so the corpus also stressesguidestar_lens.py's manifest-based Intent Lock, not
onlydetector.pyin isolation. - A centralized diff step: run
galaxyscopeover the whole corpus and compare each language's
detected signal counts against the "ground truth" of which keys were deliberately planted,
flagging any language whose detected counts don't match — an outlier report.
Why this needs its own design pass before scoping into sub-issues
- Key selection: not every
language_standards.pysignature key has a sensible
same-shape equivalent in every language (the epic's own framing — "where all languages have
something other than none" — is the hard part: e.g. COBOL doesn't have closures, Rust's
unsafeisn't the same risk shape as Python'seval). Needs a real mapping pass across
LANGUAGE_DEFINITIONS, not just picking keys that sound universal. - Maintenance cost of a public repo: unlike the golden-master corpus (real-world repos we
don't own), this would be a repo we author and maintain — every new language added via
how_to_add_a_language.mdwould ideally get a corresponding control-corpus folder, which is an
ongoing tax, not a one-time build. - Overlap with existing tooling:
tests/extraction/languages/test_<lang>.py(epic Epic: Harden the four extraction gauntlets (function/args/class/dependency) per language #813) and
test_<lang>_strict.py(epic Epic: Harden the strict structural-signature test suite (non-extraction-pillar rules) per language #1069) already assert per-language regex correctness against
hand-picked valid/invalid/pathological snippets. This corpus would be a different validation
shape (real end-to-endgalaxyscoperuns, cross-language relative comparison, dependency-DAG
shape) rather than a replacement for those — worth being explicit about what it catches that
they don't (e.g.prism.pystream-splitting interactions, tier/archetype classification,
cross-language ecosystem-context bleed like [BUG/METRICS] SignalProcessor's ecosystem-context risk multiplier subsystem is dead code #1053) before committing to building it.
Non-goals (for now)
- Not a blocker for Epic: Systematically audit tier-aware risk equations in signal_processor.py #1056 — that epic proceeds independently via direct
_calc_*()invocation
with synthetic inputs. - Not meant to replace the per-language extraction gauntlets (Epic: Harden the four extraction gauntlets (function/args/class/dependency) per language #813) or strict-signature suite
(Epic: Harden the strict structural-signature test suite (non-extraction-pillar rules) per language #1069) — it's a complementary, coarser-grained cross-language check.
References
- Discussion originated while scoping Epic: Systematically audit tier-aware risk equations in signal_processor.py #1056.
- Related tooling:
gitgalaxy/standards/how_to_add_a_language.md,
tests/extraction/how_to_harden_extraction.md,tests/extraction/how_to_harden_strict_signatures.md.
Metadata
Metadata
Assignees
Labels
core-engineModifications to the central physics and parsing engineenhancementNew feature, sensor, or structural signaturetestingUnit, integration, and E2E pipeline verification
Activity
squid-protocol commentedon Aug 31, 2026
Design plan (2026-08-31)
Grounded in a fresh measurement against the live
LANGUAGE_DEFINITIONSregistry (the wiki taxonomy matrix is stale — 51 columns vs. the current 46 active languages; everything below derives fromlanguage_standards.pyat build time so the corpus can't drift the same way).Measured foundation
39 of 46 active languages share a full core set of 20 signal keys:
func_start,branch,import,args,api,doc,planned_debt,fragile_debt,safety,safety_bypasses,io,globals,encapsulation,test,high_risk_execution,dead_code,ownership,telemetry,state_mutation,cleanup. The 7 stragglers (markdown, jcl, css, html, yaml, yacc, solidity) each miss only 1–6 keys → Tier 1 (full shell, 39 langs) and Tier 2 (reduced shell + per-language expected-signal manifest, 7 langs). Nobody excluded.Program shell (identical design, per-language expression)
class_startexpected = 0 everywhere is itself a free false-positive tripwire (same bug class as the css@media-as-function history, CSS at-rules (@layer / @media / @supports) counted as functions; css tree-sitter-accuracy baseline stale (real_functions 24→25) #2507).probe_branch,probe_io, …), each planting an exact number of that signal's keywords (exact diffs catch both misses and FPs; "works on broken code" removes the usual reason to be loose).network_risk_sensor.py's DAG/PageRank, not justdetector.py.guidestar_lens.py's Intent Lock.Symmetric decoy design
Signals split across two surfaces; decoys cross them in both directions, every decoy recorded with expected count 0:
prism.pystripping + literal shielding.# HACKtag on one designated function is a true positive; the reverse decoy is a code identifier literally namedHACK_LEVEL, which must not count.Framework first — the harness is the reviewer
Per-language versions get fanned out to other models, but only after the harness exists, because the harness is what makes generated versions safe to accept:
tools/keyword_menu.py— mines each language's rule regexes fromLANGUAGE_DEFINITIONS, emits a per-language menu of safe literal keywords per signal (the taxonomical equivalence map, applied mechanically).SPEC.md— the canonical shell: probe list, occurrence counts, decoy rules, file/import layout. This is the generation prompt.tools/verify_language.py— runsgalaxyscopeon one language folder, diffs detected counts againstexpected_signals.json, fails on any mismatch. Gates every per-language PR: a version that passes is correct by construction; one that fails is a bad generation or a real engine bug — both are the point.tools/bias_report.py— the payoff: identical planted intent everywhere, so divergence in downstream risk scores across languages = measured language bias. Outlier report.Sequencing
keyword-rosetta(sibling checkout, same convention as language-crucible): SPEC + keyword-menu generator + manifest schema.how_to_add_a_language.md(makes the maintenance tax this issue flagged explicit and cheap).Work starting on a side branch in the new repo.
squid-protocol commentedon Aug 31, 2026
Status update (2026-08-31): 3 languages locked, first bias numbers, gating system in place
Corpus repo (local, pre-publish) now has python, cobol, javascript reference folders, each passing an exact-count end-to-end gate (75/77/80 assertions respectively) with every deviation from planted intent validated in a tri-comparison-style ledger (
deviation_ledger.json+docs/GATING.md, modeled ondocs/self_scan/tri_comparison_README.md's entry lifecycle — unvalidated → investigated → validated verdict,still_reproducesonly flipped by a fresh scan).First bias report (identical planted intent in all 3 languages): 12/18 signals diverge, and the mean per-file risk scores diverge hard —
Same program, ~1.9× the measured safety risk in COBOL. Part of that traces to shapes now filed as issues:
eval, cobol countsALTERfrom inside a literal)HACK-LEVEL,PROBE-TODO) — feeds cobol's tech-debt inflation aboveCEE3DMP.)with (x) {}as a function namedwithPer the corpus's gating rule, current engine behavior is baked into manifests with ledger references; when a fix lands, the affected manifests re-baseline in the same change that flips the ledger entry's
still_reproduces.Next: remaining Tier-1 fan-out (framework + SPEC are the generation prompt), Tier-2 reduced shells, and the Phase-5 pinned-tag CI integration.
squid-protocol commentedon Aug 31, 2026
Status update (2026-08-31, part 2): 11 languages locked, variance gate added — no risk metric currently passes cross-language validation
Corpus now covers abap, ada, assembly, cobol, fortran, haskell, javascript, python, rust, shell, sqlite — the legacy set plus one language per morphology family. All 11 pass the exact-count end-to-end gate (72–80 assertions each); every deviation has a validated
deviation_ledger.jsonentry (21 shapes total).New: auto-regenerated variance chart (
docs/bias_variance_chart.svg, rebuilt on everybias_report.pyrun, tri-comparison-chart style): one strip per risk metric, one unlabeled dot per language, positioned by deviation from the cross-language median. Green band ±25%, red beyond ±50% — any dot in red fails that metric's cross-language validation. Current verdicts on identical planted intent:14/18 signals diverge from uniform planted intent. Largest single-signal spread: branch 3 (abap) → 25 (assembly, where call/ret count as control transfers).
New upstream findings this batch:
USEtargets resolve case-sensitively in the DAG (uppercase legacy style silently loses the whole import graph)safetyleaks), and a branch keyword inside a literal creates phantom branch context that triples state_mutation via the flux weightingend ifre-counts as branch; shell counts[/]as branch; shelltrap : TERMcollides with the TERM env-var; haskell CAFs correctly count as functions; sqlite.readis dual import+io; orphan→api conversion counts are opaque on non-call-graph languages (another reason for recorder: raw pre-adjustment hit_vector is unrecoverable once the Contextual Baseline Fix rewrites api/orphaned_logic #2536)Remaining: ~28 Tier-1 + 7 Tier-2 languages (fan-out ready), then pinned-tag CI integration.
squid-protocol commentedon Aug 31, 2026
Status update (2026-08-31, part 3): 23 languages locked
Batch 3 added the 12 mainstream languages (c, cpp, csharp, java, go, kotlin, typescript, php, ruby, lua, perl, swift) — all pass the exact-count gate (72–76 assertions each). Ledger now 29 validated shapes.
23-language variance gate: 11 PASS / 4 WARN / 19 FAIL across 34 metrics. Confirmed-consistent core:
func_start,import,pagerank,telemetry,cleanup,ownership+ 5 risk scores. Notably,dependency_linksdropped to FAIL at 23 languages — the gate caught two real resolution gaps: swift's_dependency_capturerequires 2+ char module names (import anever resolves), and haskell chains don't convert either (same case-family as #2540).New ledgered shapes worth upstream eyes (not yet filed as issues — say the word and I'll file):
<?phpopen tag counts branch +1 (the ternary?alternation matches the tag — systematic per-file FP on all real PHP)(?:\.[ \t]+)?is optional, so it fires on all imports)return(main = 8 for 3 planted); swift api counts the wordopeninside string literals (API-exposure from prose)evalfrom literals (eval-as-bypass, like shell); perl's eval survives only by syntax shape, not surface shieldingRemaining: ~16 Tier-1 (agc_assembly, apex, dart, dockerfile, embedded_python, groovy, livecode, m4, makefile, matlab, objective-c, powershell, scala, scheme, tcl, zig) + 7 Tier-2.
squid-protocol commentedon Aug 31, 2026
The corpus repo is now public: https://github.com/squid-protocol/keyword-rosetta (23 languages, the variance gate, the deviation ledger, and the per-language findings report — see
docs/findings_by_language.mdfor the defect → issue → evidence-file reference, organized by language).squid-protocol commentedon Aug 31, 2026
Status (2026-08-31, final for this phase): FULL REGISTRY COVERAGE — 46/46 languages
Batch 5 added the 7 Tier-2 reduced shells (markdown, jcl, css, html, yaml, yacc, solidity). Every language in
LANGUAGE_DEFINITIONSnow has a locked, gate-passing control folder. PR: squid-protocol/keyword-rosetta#1 (retitled: 23 new languages across batches 4+5). Ledger: 35 validated shapes.New issue from Tier-2: #2549 — html
func_startis unreachable end-to-end: the polyglot splitter consumes<script>/<style>tags before html's rules run (micro-repro: a script's JS body signals land on the html row, but func stays 0). The rule passes direct-detector tests and is dead in production — exactly the class of bug only an end-to-end corpus can catch.Other Tier-2 notes: solidity is the 6th return-counts-as-branch language (#2545); yacc + markdown join m4/scheme as DAG-invisible (no
_dependency_capture); jcl'sINCLUDE MEMBER=chain resolves and manifests api purely via orphan conversion despite jcl having no api rule; css's at-rules triple-count (func+branch, @supports also safety); solidity's SPDX line counts ownership on every real .sol file.46-language verdict: 3 PASS / 0 WARN / 30 FAIL (pagerank, risk_churn, risk_secrets_risk are the only survivors at full morphology range — func_start fell to FAIL on html's dead rule and the RUN/at-rule/EXEC function morphologies).
Phase 4 (fan-out) is complete. Remaining from the original plan: Phase 5 — pinned-tag CI integration in gitgalaxy + a keyword-rosetta GH Action running the verifier on changed folders.
squid-protocol commentedon Aug 31, 2026
Closing: delivered by keyword-rosetta — 46/46 languages, gated, and already paying for itself
The proposed corpus was built as the public repo keyword-rosetta (PolyForm NC). Every language in
LANGUAGE_DEFINITIONS— all 46 — has a locked control folder passing its end-to-end gate. Mapping the original proposal to what shipped:Key selection (the "where all languages have something" design concern): solved empirically, not by picking keys that sound universal —
tools/keyword_menu.pymines each language's self-validated keyword menu from the liveLANGUAGE_DEFINITIONS, and a 20-keyCORE_SIGNALSregistry drives the shell. 39 Tier-1 languages carry all 20 signals; the 7 zero-signal morphologies (markdown, jcl, css, html, yaml, yacc, solidity) get reduced Tier-2 shells rather than pretending parity.The trivially-readable dependency chain: every folder is the same
main → a → b → clinear DAG, which cross-checksnetwork_risk_sensor.pyexactly as proposed —pagerankis one of only three metrics that passes strict cross-language validation.Self-describing probes:
SPEC.md's 12-probe canonical shell, each probe announcing what it exercises, with decoy rules to catch over-matching.The centralized diff/outlier step:
tools/verify_language.pyruns realgalaxyscope --db-onlyscans and asserts 72–80 planted-vs-detected checks per language;tools/bias_report.pyproduces the cross-language bias report and the variance chart now embedded in this repo's README (#2554). Bottom-line verdict on identical planted intent: 3 of 33 metrics pass the strict cross-language gate; on average 75% of languages land within ±25% of the cross-language median per metric. A companion incidence report sizes each confirmed bias shape against real licensed code."What it catches that the gauntlets don't" — the issue asked for this to be explicit before building, and it's now demonstrated rather than argued: 14 engine defect classes filed (#2535–#2547, #2549), several only catchable end-to-end: #2549 (html
func_startalive in unit tests but dead in production — the polyglot splitter consumes the tags first), #2535 (string-literal shielding is selective by signal family), #2536 (raw hit_vector unrecoverable past the Contextual Baseline Fix), #2546 (undocumented ×3 flux weighting). First fix already landed and the corpus re-baselined behind it (#2538 closed; PR #2548 + rosetta commit0e8ebfa). Every known deviation lives in a validated deviation ledger (35 shapes) with a tri-comparison-style lifecycle perGATING.md.The maintenance-tax concern: rosetta's own CI runs the verifier on any changed
data/folder, and PR #2559 makes the control folder an explicit part ofhow_to_add_a_language.md's process, so a new language can't silently skip it.Deliberately not delivered from the original sketch: idiomatic framework/manifest wrapping to stress
guidestar_lens.py's Intent Lock — only python/javascript/rust carry manifests today; the bare probe shells keep planted counts exact. Carried as an explicit option (with that tradeoff named) into the successor.Remaining work → #2557: the gitgalaxy-side pinned-tag CI gate (crucible-pin pattern) and the cross-repo re-baseline protocol as the filed defects get fixed.
Closing as complete for the corpus itself and its measurement program.
docs: adding a language now includes its keyword-rosetta control fold…
fix(detector): exclude synthetic slicer bucket names from orphan/dupl…
chore: harden crucible_check.py against env drift, add scope_check.py (…
fix(core-engine): Rosetta corpus sweep — six extraction/DAG/recorder …