Skip to content

docs(t27o): Python debt census -- 2,126 tracked .py files, 12,547 functions, and the share that fits a convertible subset (Closes #11168) - #11176

Merged
gHashTag merged 2 commits into
masterfrom
t27o/python-debt-a9
Oct 19, 2026
Merged

gHashTag merged 2 commits into
masterfrom
t27o/python-debt-a9

Conversation

@gHashTag

@gHashTag gHashTag commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

What this is

The measure-first step of the Python front end (#8995, #9006), analysis only: no Python is deleted and no spec is added. docs/now/2026-10-20-python-debt.md counts the hand-written Python of the five repositories with Python's own ast module, classifies every function against a written subset (rules R1 to R10 in the file), ranks files by the lines a port could delete, and checks 30 functions by hand against the scanner. Same discipline as #11149 and #11159: measure first, name the method and the commits, write a rule only above a stated threshold.

Closes #11168

The ranked table, totals and answer are also posted on #11168: #11168 (comment)

Answer

  • 812 of 331,183 distinct hand-written, non-test Python lines (0.25%) sit in the 105 distinct functions that fit the typed subset today, and 4,090 lines (1.23%) in the 454 that fit once their parameter types are inferred from traces; no file is a whole-file candidate of 150 lines or more, so a Python port deletes functions, not files.
  • Scale: 2,126 tracked .py files, 434,986 gate-counted lines (t27 alone 153,503, equal to git diff --numstat of deleting every tracked .py). 1,943 files and 412,066 lines after generated (23 files), vendored (22) and test-only (138) paths; 12,547 functions, 8,501 distinct function bodies; 331,183 distinct lines.
  • Typed subset: 105 distinct functions, 812 lines (0.25%). Shape subset (parameter types to be inferred from traces): 454 functions, 4,090 lines (1.23%). The median in-subset function has 6 lines, the largest 34 (typed) and 89 (shape).
  • Whole-file candidates: none typed; one shape-only, tools/ternary_model.py (93 lines, already has a spec twin). No file of 150 lines or more has every function in the typed subset. The closest, tools/gft_train_demo.py (201 lines), has 16 of 18 functions that fit the shape subset and none typed.
  • Hand check: 29 of 30 verdicts agreed on the first sample (one rule added), 30 of 30 on a fresh sample drawn after the fix (15 of 15 in, 15 of 15 out).
  • t27c gen-python lowers no function (consts, enums and structs only), so a port keeps its entry point through a hand-written loader or its callers change.

Not run

No t27c, cargo, tri build or converter ran (there is no Python front end yet; "fits" means "passes the written rules"). Callers in the four sibling repositories were searched in .py, shell, YAML, Makefile, Dockerfile and package.json files only. The local checkouts of those four repositories were not used (stale feature branches); the pinned commits of #11149 and #11159 were fetched into scratch.

🤖 Generated with Claude Code

…ctions, and the share that fits a convertible subset (Closes #11168)

Analysis only: no Python is deleted and no spec is added. docs/now/2026-10-20-python-debt.md
counts the hand-written Python of the five repositories with Python's own ast and tokenize
modules, classifies every function against a written subset (rules R1 to R10 in the file),
and ranks files by the lines a port could delete. Measure-first step of #8995 and #9006.

- 434,986 gate-counted lines in 2,126 files; 412,066 lines in 1,943 files after generated,
  vendored and test-only paths; 331,183 lines and 8,501 function bodies counting copies once.
- Typed subset: 105 distinct functions, 812 lines (0.25%). Shape subset (types to be inferred
  from traces): 454 functions, 4,090 lines (1.23%). Median in-subset function: 6 lines.
- No whole-file candidate of 150 lines or more; the only whole-file fit is
  tools/ternary_model.py (93 lines). t27c gen-python lowers no function, so a port keeps
  its entry point through a hand-written loader or its callers change.
- Hand check: 29 of 30 verdicts agreed before one rule was added, 30 of 30 on a fresh sample.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-19 23:01:27 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 47
PRs with All Checks Green 3
READY 2
FAILING 47
PENDING 0
NO CHECKS YET 0

These columns do not partition: 2 + 47 + 0 + 0 = 49, and there are 50 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=e34e1b174c96 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

…d near-whole candidates in the totals table (Closes #11168)

The totals table named how many whole-file and near-whole candidates each repository has
but not their lines; the column now reads "files (lines)" so the table answers the issue's
"whole-file candidates and their lines" directly.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-19 23:13:58 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 47
PRs with All Checks Green 3
READY 2
FAILING 47
PENDING 0
NO CHECKS YET 0

These columns do not partition: 2 + 47 + 0 + 0 = 49, and there are 50 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=e34e1b174c96 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

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.

t27o Python debt census (measure first for #8995): lines, functions and the share that fits a convertible subset, ranked

2 participants