Skip to content

Duplicated test helpers that no single-file fix can dedupe #783

Open

Description

@TheFJK

Three helpers exist as byte-identical copies across test files. The /premerge simplify pass on #768 could not fix any of them, because its one-file-per-agent contract means no single-file edit can honestly dedupe a cross-file copy — two agents returned NO_CHANGE rather than half-do it, which is the right call and the reason these need their own change.

This is the "one contract, N uncompared copies" class (#370/#371). Distinct from #780, which lists patterns where one copy was widened and its twins left narrow; these are cases where the copies still agree and the risk is future drift.

1. The shell function-body extractor — 2 copies

g56_body (tests/goal.test.sh:4820) and rcx15_body (tests/review-pr-consolidate.test.sh:897) are identical down to their comment text and their inf && /^}/ { exit } terminator. tests/goal.test.sh already sources tests/_lib_assert_structural.sh, which has no body extractor.

The terminator is the risk, and it is demonstrated. It bounds the body at the first column-0 }, so a function containing a heredoc with a column-0 } truncates early. Measured: a _uberdev_goal_rebase_collision_chain fixture with such a heredoc extracts 4 of its 8 body lines, and the offender detector then returns zero hits over a body carrying two live unpinned sorts and one unpinned comm — G56.live would print PASS over nothing.

Harden one copy and the other keeps truncating. The >= 10 line-count floors already present in both files do red that case, so they backstop the move.

Fix: define it once in tests/_lib_assert_structural.sh, call from both. Three files.

2. The workflow run-block extractor — 3 copies

The awk program that carves a job's run: block out of .github/workflows/test.yml, including the hardcoded ten-space de-indent, exists in tests/ci-shard.test.sh and tests/ci-wiring.test.sh:651. #781 collapsed the two copies inside ci-shard.test.sh into one run_block_of; the ci-wiring.test.sh copy is untouched and out of that PR's scope. A fourth partial copy of the job-block half lives in tests/ci-job-fixtures.sh, whose own header names this defect class as the reason it exists as one shared file.

Drift has already started: a sibling extractor at tests/ci-shard.test.sh:554 carries a trailing-CR strip for the Windows checkout and the others do not. #781 deliberately did not propagate that strip, because widening what the extractor accepts is a behaviour change rather than a dedupe.

3. The tools: frontmatter predicate — 4 copies

#780 covers the two narrow ones. Adding the state after #781: tests/testers-agent-contract.test.sh and tests/model-routing.test.sh now agree, but only by construction — two byte-equivalent predicates in two files with nothing comparing them, which is the same shape #749 was made of. tests/cluster.test.sh:154,160 and tests/orchestrator-plan-flatten.test.sh:97,181 remain narrow.

Fix: one importable definition all four call, rather than four that happen to match.


Suggested shape for all three: hoist one definition per helper and give it a CONTRACT: marker, so the next divergence is visible rather than silent. The line-count floors already in place are what make the moves safe to verify.

Related: PR #768, PR #781, #780

Activity

  1. added
    premerge-findingAuto-filed by /uberdev:premerge from deferred findings (RFC 0002)
    on Aug 24, 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

    premerge-findingAuto-filed by /uberdev:premerge from deferred findings (RFC 0002)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions