Skip to content

Prefix-anchor matching overrides a known code extension (BUILD.mk -> python) #3134

Closed

Description

@squid-protocol

Found by the first run of the detection-accuracy harness (PR #3130, closes #3117) against the pinned language-crucible corpus. One corpus file — cosmetic next to #3132 and the trampoline issue.

Measured

assembly/cosmopolitan/BUILD.mk classifies as python at Tier 1, intensity 0.95, proof Prefix Anchor (BUILD). Expected makefile.

The file is unambiguously a makefile — its first line is a mode line saying so:

#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐

Mechanism

inspect()'s metadata-anchor block tests the filename prefix (language_lens.py:296-299):

elif name.split(".")[0] in self.anchor_map:
    base_anchor = name.split(".")[0]
    target_id = self.anchor_map.get(base_anchor)
    anchor_proof = f"Prefix Anchor ({base_anchor})"

BUILD is a registered exact_matches anchor for python (Bazel BUILD files) — confirmed: anchor_map["BUILD"] == "python". The branch returns immediately at PROSE_CONFIDENCE and never considers that the file's actual extension .mk is a known, uncontested code extension claimed solely by makefile (extension_map[".mk"] == "makefile", and .mk is not in COLLISION_FREQUENCIES).

The same block already has the concept it needs. The "Executable Shield" guard computes is_known_code_ext at :270-274, and the prose-anchor path immediately below gates on it (if not is_known_code_ext: at :277, and elif is_prose: at :300). The prefix-anchor branch sits between the two gated paths and is the only one without the guard.

Suggested direction (record, do not pre-decide)

Skip prefix-anchoring when the file's own extension is a known code extension — i.e. let a real extension outrank a filename prefix.

Preserve this asymmetry: an exact filename match (Makefile, Dockerfile) should still outrank an extension, since those files have no meaningful extension. That path is a separate branch (if name in self.anchor_map at :294) and should be left alone; only the prefix form at :296 should yield. The fix is therefore surgical to one branch.

Related

#3117 (the harness that found this), #3132 (the other Tier-1.5/gravity error class from the same run).

Activity

  1. added
    bug
    core-engine
    priority: low
    on Sep 17, 2026
  2. squid-protocol commented on Sep 17, 2026

    @squid-protocol
    OwnerAuthor

    Fixed in #3127 (merged 2026-09-17T10:27:25Z, commit bede481f+). The PR referenced this issue but without a closing keyword, so it stayed open — closing manually.

    Regression coverage in tests/core_engine/test_detection_resolution_order.py. Measured effect on the #3117 harness: overall accuracy 0.9964 -> 0.9974, refusals 3 -> 1, Tier 5 conflicts 3 -> 1.

  3. squid-protocol commented on Sep 17, 2026

    @squid-protocol
    OwnerAuthor

    Reopening — my earlier close was premature and wrong.

    #3127 merged as a squash containing only its first half (through the csh/pfsh/luatrace triggers). The trampoline and prefix-anchor fixes were in a later commit that did NOT land: grep -c _trampoline_interpreter on main returns 0. My close comment attributed the fix to a merge that does not contain it.

    The fix is real and tested, but currently only on the fix/detection-3116 branch. Re-landing it on current main now; will close against the merge commit that actually carries it.

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-enginepriority: low

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions