Skip to content

safety_bypasses/io over-claim: four rules count tokens another rule owns (livecode global, lua _G+collectgarbage, fortran COMMON, dockerfile apt-get clean) — the #2659 shape #2675

Closed

Description

@squid-protocol

Batch B.4 of #2669. Four post-Batch-A residual cells on io / safety_bypasses turn out to be one shape, and all four are regex-level — B.3 material. Corpus-side residuals from the same triage go to keyword-rosetta separately.

The shape

A rule claims a token that another rule already owns, or matches a token in a form too broad to mean what the rule means. Same family as #2659 (doc claiming what ownership owns) and #2544 (a guard that does not guard).

Every one of the four lands exactly on the planted value, and in every case the token removed is still counted by its owning rule, which stays at its own planted value.

language signal now fixed planted token claimed owned by
livecode safety_bypasses 4 2 2 global\s+ globals
lua safety_bypasses 4 2 2 _G, _ENV / collectgarbage globals / cleanup
fortran safety_bypasses 3 2 2 COMMON globals
dockerfile io 5 3 3 bare apt-get/apk/yum/dnf — (over-broad form)

1. livecode safety_bypasses claims global

r"\b(disable\s+messages|unlock\s+(?:screen|messages)|global\s+)\b|\bdo\s+(?![a-zA-Z_]\w*\b)"

disable messages, unlock screen and dynamic do are genuine bypasses. global is a scope declaration, and globals owns it exclusively (\b(global\s+|the\s+global|…)\b). The corpus's probe_globals plants two global declarations in a.lc, and each scores safety_bypasses as well — the entire +2.

Fix: drop the global\s+ alternative.

r"\b(disable\s+messages|unlock\s+(?:screen|messages))\b|\bdo\s+(?![a-zA-Z_]\w*\b)"

2. lua safety_bypasses claims _G/_ENV and collectgarbage

r"\b(rawget|rawset|rawlen|debug\.[a-zA-Z0-9_]+|collectgarbage|_G|_ENV|getfenv|setfenv)\b"

rawget/rawset/rawlen/debug.*/getfenv/setfenv are real bypasses (they defeat metatables or the environment). The other two are not:

  • _G / _ENV — a bare reference to the global table. globals owns it (\b(_G|_ENV|_VERSION|arg)\b). probe_globals in a.lua contributes +1.
  • collectgarbage — GC control, not a safety bypass. cleanup owns it (\b(ffi\.C\.free|collectgarbage|io\.close|:[ \t]*close)\b). probe_cleanup in c.lua contributes +1.

Fix: r"\b(rawget|rawset|rawlen|debug\.[a-zA-Z0-9_]+|getfenv|setfenv)\b"

3. fortran safety_bypasses claims COMMON

r"\b(COMMON|EQUIVALENCE|IMPLICIT\s+(?:REAL|INTEGER|CHARACTER|COMPLEX|LOGICAL|DOUBLE))\b"

EQUIVALENCE and implicit typing are genuine type-safety bypasses. COMMON is a global storage block and globals owns it (\b(COMMON|SAVE|EXTERNAL)\b). probe_globals in a.f90 contributes the +1.

Fix: r"\b(EQUIVALENCE|IMPLICIT\s+(?:REAL|INTEGER|CHARACTER|COMPLEX|LOGICAL|DOUBLE))\b"

4. dockerfile io counts package-manager cleanup as io

r"^[ \t]*(?:COPY|ADD)[ \t]+|\b(?:wget|curl|apt-get|apk|yum|dnf|git[ \t]+clone|…)\b"

The bare package-manager names are there to catch a network fetch (apt-get install). They also match RUN apt-get clean and RUN yum clean all, which touch no network and no external file — they delete a local cache. cleanup owns those exact phrases (apt-get[ \t]+clean, yum[ \t]+clean[ \t]+all, apk[ \t]+(?:cache[ \t]+)?clean). The corpus's probe_cleanup in c.dockerfile is exactly RUN apt-get clean + RUN yum clean all, the whole +2.

Fix — require a subcommand and exclude the clean forms:

r"^[ \t]*(?:COPY|ADD)[ \t]+"
r"|\b(?:wget|curl|git[ \t]+clone|tar[ \t]+-[cx]f|unzip|pip[ \t]+install|npm[ \t]+install)\b"
r"|\b(?:apt-get|apk|yum|dnf)[ \t]+(?!clean\b|cache[ \t]+clean\b)[a-z-]+"

Behaviour on constructed cases, all as intended:

line now fixed want
RUN apt-get update && apt-get install -y git 2 2 2
RUN apk add --no-cache curl 2 2 2
RUN yum install -y vim / RUN dnf install -y vim 1 1 1
RUN apt-get clean 1 0 0
RUN yum clean all 1 0 0
RUN apk cache clean 1 0 0

Real-world check on the 71 language-crucible Dockerfiles: io 94 → 93 — it removes exactly one genuine apt-get clean and nothing else. ReDoS probe (200k chars after RUN apt-get ): 0.0032s.

Verification

Run through the real prism.split_streams, both streams, over keyword-rosetta data/<lang>/ at corpus 357345f:

language.signal               now  fixed  planted
livecode.safety_bypasses        4      2        2  ok
lua.safety_bypasses             4      2        2  ok
fortran.safety_bypasses         3      2        2  ok
dockerfile.io                   5      3        3  ok

livecode.globals    unchanged at 2      lua.globals   unchanged at 2
lua.cleanup         unchanged at 2      fortran.globals unchanged at 2
dockerfile.cleanup  unchanged at 2

Four red/amber cells → green, no owning rule disturbed.

Scope

Registry-regex layer only — same layer as #2672, #2660(go) and #2673, so it can share B.3's PR. Strict tests in tests/extraction/languages/test_<lang>_strict.py: for each, a positive (the owning rule still counts the token), a negative (this rule no longer does), and for dockerfile the six install/clean rows above.

Corpus rebless: livecode/lua/fortran safety_bypasses and dockerfile io all move to their planted value; no other signal in those four languages moves.

Activity

  1. added
    bug
    metrics
    core-engine
    on Sep 2, 2026
  2. squid-protocol commented on Sep 2, 2026

    @squid-protocol
    OwnerAuthor

    Two corrections from implementation. fortran is dropped from this issue — I was wrong about it — and the dockerfile real-world figure was measured over the wrong file set.

    fortran: withdrawn. COMMON firing both rules is deliberate, documented and tested

    I filed fortran's COMMON as a #2659-shape over-claim on the reasoning that globals owns it exclusively. It does not. tests/extraction/languages/test_fortran_strict.py:418 has held the opposite position since #1059:

    def test_fortran_globals_vs_safety_bypasses_common_intentional_double_classification():
        """
        Ambiguity sweep finding: `COMMON` blocks legitimately fire both
        `globals` (persistent shared state across scopes) and
        `safety_bypasses` (legacy unchecked memory sharing) -- both true at
        once, an intentional double-classification, not a false collision.
        """

    It is one of a documented family in that file — concurrency/sync_locks on coarray keywords, reflection_metaprogramming/serialization_parsing on NAMELIST — all from the same ambiguity sweep. And the rationale is sound on the language: a COMMON block lets distinct program units alias the same storage with no type checking, which is a genuine unchecked-memory-sharing mechanism. That is categorically different from livecode's global (a scope declaration) or lua's bare _G (a table reference), which is why those two stand.

    The fortran change has been reverted, and its two test edits with it — the implementation had renamed that test to ..._single_classification and inverted its assertion, which would have silently overturned a deliberate design decision to satisfy a claim in this issue.

    fortran safety_bypasses 3 vs planted 2 is therefore intended morphology, not a defect: probe_globals in a.f90 plants a COMMON block, which correctly double-classifies. It belongs in the ledger alongside haskell's unsafePerformIO (same shape: the probe's required idiom is legitimately also a bypass), and I have added it to keyword-rosetta#33's ledger list.

    This issue is now three languages: livecode, lua, dockerfile. All three still land exactly on their planted value.

    dockerfile: the "94 → 93" real-world figure was wrong

    I measured over every file under language-crucible/data/dockerfile/. That directory is a moby snapshot: 55 .go files, 7 .tar, 3 json, 2 md, and only 4 actual .Dockerfile files. The regex was matching curl/wget/apt-get inside Go source that the dockerfile rule never sees in the real pipeline.

    sample files io before → after
    all files (what I measured) 72 94 → 93
    actual Dockerfiles (correct) 4 87 → 87

    So the real-world delta is zero, not −1: this corpus contains no apt-get clean/yum clean all/apk cache clean at all. The fix is a no-op there, closing a false-positive class the real corpus happens not to exercise — the same situation as kotlin and swift in #2677, and worth stating plainly rather than leaving a number that looks like evidence and isn't.

    The fix itself is unaffected: the rosetta corpus gate confirms io 5 → 3 landing on the planted 3 with no other signal moving, and all seven constructed install/clean rows behave as specified.

    Same error class as the one corrected on #2676 (measuring groovy over *.groovy while .gradle is 40% of the sample), in the opposite direction. Both are now covered by keyword-rosetta#34's hard rule 9.

  3. squid-protocol commented on Sep 3, 2026

    @squid-protocol
    OwnerAuthor

    Closing: verified fixed on main. livecode's safety_bypasses no longer claims global tCount, which the globals rule owns. Landed in #2681 (Batch B.3 wave 2 of #2669), together with the lua/dockerfile members of the same over-claim family. fortran was withdrawn from the set as documented intentional double-classification.

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

    bugcore-enginemetrics

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions