Skip to content

prism/detector: string-literal shielding is selective by signal family (if/try/open count inside a literal, eval does not) #2535

Closed

Description

@squid-protocol

Summary

Found by the #1096 control corpus (first reference language, python): string-literal
shielding for signal counting is selective by signal family
. Keywords inside the same
string literal count toward branch/safety/io but NOT toward high_risk_execution.

Repro (verified 2026-08-31, full_precision venv, galaxyscope --db-only)

Two-file git repo; identical except the literal's content:

# s1.py
M = "if eval fails, try open"


def alpha(x):
    return x
# s2.py
M = "plain words only here"


def alpha(x):
    return x

Observed diff (s1 minus s2, nonzero signals only):

signal s1.py s2.py
branch 2 (if, try) 0
safety 1 (try) 0
io 1 (open) 0
high_risk_execution 0 (eval did not count) 0
sec_tainted_injection 1 0

So eval inside a literal is suppressed from the structural count (it appears to route to
the taint sensor instead), while if/try/open in the same literal all count.

Question

Is this intentional (dangerous-token literals deliberately reclassified as taint, ordinary
keywords deliberately counted as "code-shaped mass in strings")? Either answer is fine for
the #1096 corpus — but it should be documented, because right now the comment surface is
fully stripped (verified: the same keywords in comments contribute 0) while the string
surface is inconsistently half-counted, which is invisible to anyone reasoning about
cross-language equivalence.

If unintentional, the fix direction needs a decision first: shield literals for ALL
code-stream signals (comment-parity), or count them for all and let sec_* be additive.

References

Activity

  1. squid-protocol commented on Aug 31, 2026

    @squid-protocol
    OwnerAuthor

    Cross-language addendum from the #1096 corpus (cobol + javascript reference folders now scanned):

    • javascript reproduces python exactly: in "if eval fails, try open", if/try count (branch +2, safety +1) while eval does not count high_risk_execution.
    • cobol does NOT shield: in DISPLAY 'IF ALTER FAILS TRY OPEN AGAIN'., ALL of IF (branch), ALTER (high_risk_execution +1), and OPEN (io) count from inside the literal.

    So the selective shielding isn't a global high-risk-family rule — it varies by lexical family (the c-family/python-family masking path vs. cobol's positional stripper). Whatever the intended semantics, they're currently inconsistent across languages, which is precisely the language-bias shape #1096 exists to catch.

  2. added this to the v2.4.9 milestone on Aug 31, 2026
  3. squid-protocol commented on Aug 31, 2026

    @squid-protocol
    OwnerAuthor

    Legacy-batch addendum (fortran, ada, abap, assembly reference folders now scanned) — the shielding matrix is now three distinct profiles plus one amplification:

    profile languages behavior in the same decoy literal
    selective python, javascript branch/safety/io keywords count; high-risk family shielded
    unshielded cobol, fortran, ada, assembly everything counts (ALTER, GOTO, jmp, syscall, ada if) — ARM's single-letter b mnemonic even matches the filename inside %include "b.asm"
    inverted-selective abap branch/high_risk/io shielded, but TRY in a literal does count safety (micro-repro isolated: comment-only file 0, string-only file 1)

    Amplification: a branch keyword inside a literal creates phantom branch context that triggers the state-flux ×3 weighting on unrelated real code — micro-repro: an ada file with two real := and the literal "while" records state_mutation 6; with "plain words" it records 2. The flux weighting itself looks deliberate (1 := inside a real if → 3, confirmed); the literal-triggered version is a pure FP multiplier.

  4. squid-protocol commented on Sep 1, 2026

    @squid-protocol
    OwnerAuthor

    Investigated 2026-09-01 — closing as not-a-bug (root cause identified)

    Traced this to ground with direct scans (not just re-reading regexes). Summary: there is no
    string-literal shielding mechanism in the engine at all
    — strings are never stripped or
    masked from the code stream for any structural signal, in any language checked (only comments
    are). What looked like "selective shielding by signal family" is the ordinary Silencer
    Region dampener
    (spatial_correlation.py's apply_dampener_correlations, Block 2:
    high_risk_execution ← safety, 500-char radius, same-scope) — the same mechanism documented
    in #2546's proximity-correlation table — firing because the corpus's single shared decoy
    sentence ("if eval fails, try open") happens to contain both a real danger keyword and a real
    safety keyword for some languages, purely by accident of which language's own rule
    vocabulary the English words land on.

    Evidence (isolated micro-repros, galaxyscope --db-only, direct DB queries)

    Language Decoy contains In danger rule? In safety rule? Observed state_danger Why
    python eval + try yes yes (try is a safety keyword) 0 Silencer Region dampens (real mechanism, working as designed)
    python, try→use swap eval only yes no 1 No safety hit nearby → no dampening → eval counts fully
    rust eval no — rust's danger rule is panic!/todo!/unimplemented!/process::exit/abort, no eval concept n/a 0 Morphology mismatch — unrelated to shielding entirely
    cobol TRY + ALTER yes (ALTER) no — cobol's safety rule is END-IF/END-PERFORM/.../VALIDATE/CHECK, not TRY 1 (counts fully) No safety hit → no dampening ("looks unshielded")
    abap TRUNCATE + TRY yes yes (TRY is an abap safety keyword) 0 Same Silencer Region mechanism as python — not "inverted", just the same rule firing

    Deleting try from the python/js/rust decoy and re-scanning flips high_risk_execution from
    0 to 1 immediately, with nothing else changed — conclusively isolates the cause.

    What this means

    The "four shielding profiles" the corpus ledger described are a corpus-authoring artifact: one
    English sentence translated per language without checking whether it accidentally collides
    with that language's own safety/danger rule vocabulary, not an engine design inconsistency.
    The engine's actual behavior is already uniform and correct: strings count like ordinary code
    text for every signal, always; the Silencer Region dampener does its job (a danger call
    guarded by a nearby real error-handler is legitimately lower risk) regardless of whether the
    danger/safety tokens happen to sit inside a string literal or in real code — which is the
    right behavior, not a bug. The same explanation applies to #2546's "phantom branch trigger
    from string literals" — that's the ×3 flux dampener correctly finding a branch keyword that's
    genuinely present as text, because (as this issue also establishes) nothing shields it.

    No engine change is warranted. Follow-up is scoped to the corpus: redesigning the decoy
    sentences to stop conflating "is a literal correctly uncounted" with "does an incidental
    nearby safety keyword dampen an unrelated danger keyword" — tracked in a new keyword-rosetta
    issue, and the string-literal-selective-shielding ledger entry + the capstones that cite it
    (jcl.md, cobol.md, python.md §10/§11) are being corrected to match this finding.

    Closing. Re-open if a genuine case surfaces that this explanation doesn't cover.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    core-engineModifications to the central physics and parsing engine

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions