Skip to content

makefile .PHONY entry points read as tech debt: the Contextual Baseline Fix has no external-invocation tier #2904

Closed

Description

@squid-protocol

Follow-up to #2872 (engine PR #2902), which gave makefile a _visibility_export_list rule for
the .PHONY: prerequisite list. That rule is correct and this issue does not ask for it to be
changed. It asks about the layer above it: what the resulting orphan count is then classified
as
.

Symptom

Regenerating the golden crucible for #2872 moved two corpus makefiles, in both dependency legs:

file LOC unreferenced_by_name risk_tech_debt
c/cpython/Makefile.pre.in 3480 21 → 57 23.95% → 70.73%
assembly/bootos/Makefile 18 0 → 3 0.0% → 99.33%

bootos/Makefile is 18 lines and declares four callable units; three of them are all, clean
and runqemu, each on its own .PHONY: line. It is a correct, complete, idiomatic makefile with
no dead code in it, and it now reads at 99.33% technical debt.

The census is right

The orphan flag is factually correct in both files, and #2872's rule is why. all, clean and
runqemu are never named anywhere in bootos/Makefile except on their own .PHONY: line and at
their own definition. Nothing in the file references them. Corollary 2 says a visibility
declaration is not a use, so they are unreferenced-by-name, and that is the true answer to the
question the census asks.

This is not a request to weaken #2774 / #2823 / #2872. The census should keep reading 3.

The actual gap

unreferenced_by_name is converted into risk_tech_debt unless something rescues it, and the
one thing that rescues it is galaxyscope.py's Contextual Baseline Fix:

popularity = self.popularity_scores.get(rel_path, 0)
if popularity > 0 and "equations" in meta:
    ...
    meta["equations"]["api"] = ... + (orphans - already_public)   # 1. orphans -> API surface
    meta["equations"]["unreferenced_by_name"] = 0                 # 2. wipe the tech debt

Its own comment states the principle exactly right — "If the file is imported by the ecosystem,
its 'orphans' are actually its API"
— and #2731's note goes further: "a library's public
functions are exactly the ones with no in-repo caller."
The engine already believes that an
uncalled-but-reachable unit is public surface, not dead weight.

The gate is popularity > 0, and popularity_scores is built from the import/dependency
graph
. Measured on both files at the merge commit:

file Popularity Rank Baseline Fix fires?
c/cpython/Makefile.pre.in 0 no
assembly/bootos/Makefile 0 no

Nothing imports a makefile. A makefile's caller is a human typing make all, or CI, or a
Dockerfile — always outside the corpus. So for this whole class of file the rescue is structurally
unreachable, and every declared entry point falls through to tech debt.

The engine currently models two tiers of reachability and is missing a third:

tier how it is reached today
1 an in-repo caller names it census clears the flag ✅
2 an in-repo file imports it Contextual Baseline Fix reclassifies to api ✅
3 an external invoker runs it (declared entry point) falls through to tech debt ❌

This is not the #2806 positional case. JCL declares invocation_model: positional because its
steps cannot be named at all, so the census is unanswerable. A makefile target very much can be
named — a prerequisite list names targets constantly — so the census is answerable, is computed,
and is correct. Makefile is a genuine third shape: the census is right, and the classification
of its result is what does not fit.

Why the engine already has the data

.PHONY: is not an incidental mention. It is a curated declaration whose entire purpose is
"these targets are the externally-invoked interface of this file" — cpython/Makefile.pre.in
carries 109 of them. That is the tier-3 signal, already parsed, already in the registry as
_visibility_export_list, and currently consumed for exactly one purpose: suppressing the use
count.

Ask

Give the Contextual Baseline Fix a tier-3 trigger: a unit that is declared an external entry
point
should take the same path an imported file's orphans take — credited to api surface,
cleared from unreferenced_by_name — while the census itself keeps reading the orphan honestly.

Two deliberate constraints on scope:

  1. Opt-in per language, not universal. A blanket "anything exported is exempt from debt" would
    blind the engine to genuinely dead exported code — a library with 200 exported, uncalled,
    unreachable functions must still read as debt, which is the population orphan census: an export -f name line counts as a use, so a declared-public uncalled function can never be reported dead #2774 was built to
    find. The exemption is only sound where the export construct is narrow and curated
    (.PHONY:), not where it decorates every symbol in the file (a JS/TS export). Suggest a
    top-level registry property in the shape of orphaned_logic reports 100% dead code for five languages whose invocation model never names the callee — the family #2727 closed without covering #2806's invocation_model — a closed, asserted
    set — so each language opts in visibly and a typo cannot silently mean "exempt".
  2. Classification only, never the census. unreferenced_by_name keeps counting; only the
    debt/surface split moves. recorder: raw pre-adjustment hit_vector is unrecoverable once the Contextual Baseline Fix rewrites api/orphaned_logic #2536's raw_pre_adjustment snapshot already preserves the pre-
    adjustment values, so the raw census stays recoverable for the Feature: multi-language control corpus to validate structural extraction equivalence across languages #1096 control corpus exactly as
    it is for imported files today.

Net effect is more signal, not less: a makefile with 109 phony targets has a large public
surface, and risk_api_exposure is the dimension that should carry it. Today that information is
being spent on a false debt reading instead.

Secondary observation (separate call, not part of the ask)

bootos/Makefile reaching 99.33% off three orphans in an 18-line file suggests
risk_tech_debt is very sensitive at small unit counts (3 of 4 units). Even with tier 3 in place
this normalization question stands on its own for small files, and may deserve its own issue if
maintainers agree it is real.

Provenance

Measured at merge commit db383ce5 on fix/2872-m4-makefile-visibility-export (PR #2902),
corpus language-crucible v1.2.0, both the full-precision and zero-dependency legs, which
produce an identical 9-difference footprint. The two golden masters on that branch already record
the numbers in the first table.

🤖 Generated with Claude Code

Activity

  1. added
    scope:frontier
    on Oct 16, 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

    scope:frontier

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions