Skip to content

lua: api bare-return overmatch + orphan-conversion double-credit compound to +110% api exposure #2657

Closed

Description

@squid-protocol

Found by the #2560 rosetta classification sweep (lua #2584) — together these drive the worst single deviation in the whole sweep (risk_api_exposure +110%).

Mechanism 1: api-bare-return-overmatch

lua's api rule has a bare return <ident> alternative meant for lua's module-export idiom (return M at file end) — but it fires on ordinary function returns anywhere. Same defect pattern as powershell's api keyword collision (filed separately): the export heuristic's alternative is under-scoped.

Mechanism 2: api-orphan-conversion-no-dedup

The Contextual Baseline Fix (galaxyscope.py; raw values now recorded per #2536) adds orphan→api credit without deduplicating against functions the raw api regex already counted — for lua's shape this compounds up to 3x per function (a function counted by the bare-return overmatch AND converted as an orphan).

Fix shape

  1. Scope the bare-return alternative to module-position returns (end-of-file / top-level, e.g. anchored to column-0 return \w+\s*$ near EOF) or drop it in favor of counting M.name = style exports.
  2. Audit the orphan-conversion for dedup against raw-counted api hits — this half is engine-wide, not lua-specific; check other orphan-heavy languages before changing scoring semantics (the recorder: raw pre-adjustment hit_vector is unrecoverable once the Contextual Baseline Fix rewrites api/orphaned_logic #2536 raw columns make before/after verifiable).

Cause-keys api-bare-return-overmatch, api-orphan-conversion-no-dedup; found via keyword-rosetta classification.

Activity

  1. added
    bug
    core-engine
    on Sep 2, 2026
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-engine

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions