Skip to content

576 of 4021 function bodies are copies, and nothing asks whether the function already exists #4290

Description

@gHashTag

Measured

A walk over every .t27 in specs/, comparing function bodies after comments and whitespace are normalised away (2026-09-20, master):

function bodies with real content 4021
bodies that are byte-identical copies 576 (14.4%)
groups 165

The largest: magadd written 30 times, magsub 30, sadd 29, magmul 21, smul 19, tmul 13.

They were not refactored into one place — they were written again. An agent implementing specs/ternary/gft_train2.t27 has no way to ask whether sadd already exists, so it writes one. Every later fix to that function has to be made 29 times, and the corpus grows faster than the thing it describes.

Not every copy is a defect

specs/numeric/gf4.t27 through gf64.t27 are parallel formats and their validate_format reads the same by design. A gate that demanded zero would be argued with and then switched off. So this is a ledger, like tools/assertionless_spec_tests_baseline.txt: what exists today is recorded, and the gate fails when a NEW group appears or a known one GROWS. It moves down only.

What a bee needs before it writes

Two questions, answered with a file and a line:

$ python3 tools/dupe_scan.py --name magadd
magadd already exists in 30 place(s):
  specs/ternary/gft_axpy.t27:11
  ...

$ python3 tools/dupe_scan.py --like specs/ternary/gft_sadd.t27
specs/ternary/gft_sadd.t27:11 magadd is already written in 29 place(s):
  specs/ternary/gft_axpy.t27:11 magadd

Done when

    1. python3 tools/dupe_scan.py --self-test prints a line beginning ok — the checker is exercised against a comment-only difference (which IS a duplicate) and a one-liner (which is not)
    1. python3 tools/dupe_scan.py --bless && python3 tools/dupe_scan.py exits 0 — blessing and checking agree
    1. adding a copy of an existing body makes python3 tools/dupe_scan.py exit 1 and name the group that grew
    1. ls .github/workflows/dupe-ratchet.yml prints the path — it runs on pull requests and on pushes to master
    1. python3 scripts/ci/check_pr_branch_filters.py exits 0 — the new workflow is classified

Boundary

tools/dupe_scan.py

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions