Skip to content

fix(makefile): credit .PHONY external entry points as api surface, not tech debt (#2904) - #2970

Merged
squid-protocol merged 1 commit into
mainfrom
fix/2904-makefile-tier3-entry-points
Sep 11, 2026
Merged

fix(makefile): credit .PHONY external entry points as api surface, not tech debt (#2904)#2970
squid-protocol merged 1 commit into
mainfrom
fix/2904-makefile-tier3-entry-points

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Closes #2904.

Problem

A makefile's callable units are invoked externally — a human typing make all, CI, a Dockerfile — never by an in-repo caller or an import. Its popularity is therefore structurally 0, so galaxyscope's Contextual Baseline Fix (which credits an imported file's orphans to api surface — tier 2) can never reach it. Every .PHONY: entry point falls through to risk_tech_debt (e.g. an 18-line, fully-correct makefile reading 99.33% debt).

Fix — tier-3 external-entry-point rescue (one classification-layer change, per #2812 rule 4)

Verification

  • New test_export_visibility_contract_2904.py (closed-set + opt-in family, mirroring the orphaned_logic reports 100% dead code for five languages whose invocation model never names the callee — the family #2727 closed without covering #2806 contract) and test_galaxyscope.py::...tier3... (bootos all-declared → census 0, api unchanged; a mixed file keeps its undeclared internal orphan as debt; a non-opted-in language untouched).
  • Golden masters regenerated (both legs); bless_scope footprint = 13 substantive diffs, leaf keys Tech Debt Exposure / Unreferenced By Name / tech_debt / avg_tech_debt only, no file newly parsed or excluded (rule did not cross the density aperture).
  • rosetta 46/46, 0 regressions — its makefile fixture's targets are all referenced, so nothing moves. No paired keyword-rosetta corpus rebless is owed.
  • ruff_audit/mypy_audit/dead_key_audit --ci: no new findings. Full pytest tests/: 8738 passed (only the pre-existing test_security_auditor.py xgboost-env failures, identical on origin/main).

Out of scope (follow-ups noted in #2904)

  • risk_tech_debt over-sensitivity at small unit counts (3-of-4 in an 18-line file).
  • Lifting the popularity == 0 api-exposure dampener for tier-3 via a synthetic popularity signal.

🤖 Generated with Claude Code

…t tech debt (#2904)

A makefile's callable units are invoked EXTERNALLY -- a human typing
`make all`, CI, a Dockerfile -- never by an in-repo caller or an import.
So a makefile's popularity is structurally 0 and galaxyscope's Contextual
Baseline Fix (which credits an imported file's orphans to api surface)
could never reach it: every `.PHONY:` entry point fell through to
`risk_tech_debt`, reading e.g. 99.33% debt on an 18-line makefile whose
three targets are correct, complete and idiomatic.

Add a tier-3 branch to the Contextual Baseline Fix, opt-in per language
via a new closed `export_visibility` registry key (mirroring #2806's
`invocation_model`): a language whose export construct is narrow and
curated enough to name EXTERNAL entry points declares
`export_visibility: external_entry_points`. Only makefile opts in -- its
`.PHONY:` (`_visibility_export_list`) names exactly the external
interface, unlike a JS/TS `export` that decorates every symbol and would
blind the #2774 dead-code census.

For an opted-in file, the tier-3 branch clears its DECLARED entry-point
orphans (`api_declared_orphans` -- the orphans whose name sits on an
api-rule line) from the `unreferenced_by_name` census, and heals their
per-function `usage_status`. Crucially it moves ONLY the declared portion:
a genuinely internal, UNdeclared orphan target (never `.PHONY`, no in-repo
caller) stays real dead weight -- cpython's Makefile.pre.in drops from 57
to 21 orphans, not to 0, keeping its 21 undeclared internal targets as
debt. `api` is NOT re-credited (a declared entry point's declaration line
is already an api hit, so re-crediting would double-count), and the honest
census survives in #2536's `raw_pre_adjustment` snapshot -- only the
debt/surface classification moves, never the raw count.

Golden masters regenerated (both legs): the diff is scoped to makefile
Tech Debt Exposure / Unreferenced By Name cells and their rollups, with no
file crossing the density aperture (none newly parsed or excluded).
rosetta stays 46/46 (its makefile fixture's targets are all referenced, so
nothing moves) -- no paired corpus rebless owed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PXAjGXaZKr2Ge6jjZshPRD
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol marked this pull request as ready for review September 11, 2026 19:52
@squid-protocol
squid-protocol merged commit e587b81 into main Sep 11, 2026
32 checks passed
@squid-protocol
squid-protocol deleted the fix/2904-makefile-tier3-entry-points branch September 11, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant