Skip to content

test(coverage): fix what the deletion pins claimed - #3501

Merged
thymikee merged 2 commits into
crap/3426-retire-approval-rowsfrom
crap/3426-review-followups
Oct 12, 2026
Merged

thymikee merged 2 commits into
crap/3426-retire-approval-rowsfrom
crap/3426-review-followups

Conversation

@thymikee

@thymikee thymikee commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Summary

Stacked on #3502: this branch's Coverage job can only go green once that PR retires the three dead APPROVED_OVER_CEILING rows it inherits from post-#3483 main. Retarget to main after. Part of #3414.

Two review threads survived #3486 and #3492, both merged while their checks were queued.

run.test.ts named a case for "a function whose own lines did not change" while its fixture deletes a line inside it. Renamed to what it covers: additions below the span, a removal inside. The third case pinned its fixture rather than a rule, so it now keeps score at CRAP 42 while the source loses the function — what a forgotten pnpm test:coverage leaves — and asserts --all omits it: scoring walks the source, so neither scope reports a function that is gone.

CONTRIBUTING claimed removing code retires debt, and that a deletion's raised score reaches --all rather than the PR. Neither holds as written: dropping covered lines can raise a score, and a function the PR adds lines inside is scored at that value and blocks. The paragraph now says deletions are uncharged, and makes the --all claim conditional.

Validation

  • SHA 42b240396: 59 tests pass, including the --all assertion, which fails if a deleted function ever stops taking its score with it; check:affected --base crap/3426-retire-approval-rows --run green under the gate lock.
  • The stale-map behaviour the docs rest on was probed through run() in both scopes first, not reasoned about.
  • +44 lines, tests and prose only. No change to gate behaviour.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread scripts/coverage-crap/run.test.ts
Comment thread CONTRIBUTING.md Outdated
@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 5.17 MB 5.17 MB 0 B
Package (unpacked) 5.17 MB 5.17 MB 0 B
Package (download) 1.55 MB 1.55 MB +6 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 26.2 ms 26.4 ms +0.1 ms
CLI --help 78.3 ms 78.3 ms +0.1 ms

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready for human review at 6bf8ab9. The code change is correct and I found nothing that needs fixing.

Not blocking: the sentence at https://github.com/callstack/agent-device/blob/6bf8ab9/CONTRIBUTING.md#L258 covers deletion-only edits, but an edit that also adds lines inside the surviving function is charged its post-deletion score. "Only lines you add are charged" implies this, so adding "a deletion-only edit" to the sentence is optional, and you can take it or leave it.

On the open threads from other reviewers, two do not apply, so please resolve them. The test at scripts/coverage-crap/run.test.ts:346 pins the case where the head file no longer contains the function, and the surviving-function tests near lines 309 and 328 keep the --all score assertion, so the stale-map case stays covered: #3501 (comment). The wording at CONTRIBUTING.md:258 is about deletion-only edits and follows "Only lines you add are charged", so a mixed edit is charged normally: #3501 (comment).

The Coverage check fails in the eager-closure-budgets test "no APPROVED_OVER_CEILING row is stale". It reads the approvals against the merge-base, and no file in this diff is on that route, so it looks unrelated to this PR. The merge-base e36f117 is behind main, which fits stale approvals. I did not read the failing job log, and I did not run the coverage-crap tests or trace scripts/coverage-crap/run.ts to confirm how fallow indexes added lines. The two Smoke Tests jobs are still queued. No conflicts are known. Please rebase onto main to clear the stale approvals, then wait for the queued Smoke Tests.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Oct 12, 2026
@thymikee

Copy link
Copy Markdown
Member Author

Why this PR's Coverage job is red, and what it needs. Not this diff — it is one test file and one docs paragraph. It fails eager-closure-budgets.test.ts > no APPROVED_OVER_CEILING row is stale on three packages/test-kit rows this branch never touched: #3483 landed those entries, so from the next branch on the merge-base carries them and their approval rows are dead by the invariant's own definition.

main cannot show that, because staleApprovalRows defers when the merge-base is the head (#2329: otherwise every approval would guarantee a red main one commit after landing). Measured on this head: three rows named. Measured on pristine main: the same file passes. So the failure surfaces only on a branch based on post-#3483 main — which is now every new branch, mine included.

#3502 deletes those three rows (-34 lines, no logic). Files are disjoint and the two merge clean. Merge #3502 first, then rebase this onto main and its Coverage goes green with no change here; a re-run on the current head stays red, because the stale rows are read from this branch's own copy of that file.

Two review threads survived #3486 and #3492 because both were merged while the
checks were still queued.

The second deletion case was named for a function whose own lines did not
change, and its own fixture deletes a line inside that function. Renamed to the
scenario it covers: additions below the span, alongside a removal inside it.

The third case pinned its fixture rather than any scoping rule, since a function
absent from the map is unscored in either scope. Measured that first: a stale
map which still records the deleted function yields nothing from `--all`
either, so no scoping keeps it uncharged — the removal takes the score with it.
The test now asserts that in both scopes and says which of the two mechanisms it
is evidence for.

CONTRIBUTING said removing code retires debt. It does not always: dropping lines
that used to be covered lowers the coverage side of the ratio and can raise the
score, and that debt lands in the `--all` backlog rather than the PR. The
sentence now says deletions are uncharged, which is the accurate claim, and
names where the debt it can create goes.

Part of #3414.
Both review points on the previous commit were right.

The third case's `--all` assertion proved nothing about a stale map, because its
fixture recorded no functions at all — there was no deleted-function score for
`--all` to omit. It now keeps the `score` record at CRAP 42 while the source
loses the function, which is the shape a forgotten `pnpm test:coverage` really
leaves behind, and asserts `--all` omits it anyway: scoring walks the source, so
neither scope reports a function that is no longer there. Measured through
run() before being written.

CONTRIBUTING said a deletion's raised score reaches `--all` rather than the PR,
which holds only when no added line lands inside that function — a charged
function is scored as it stands after the deletions, so the rise blocks with it.
Said conditionally now. The rewrap also brought two over-long lines this
paragraph had inherited back under the house width.
@thymikee
thymikee force-pushed the crap/3426-review-followups branch from 6bf8ab9 to 42b2403 Compare October 12, 2026 14:19
@thymikee
thymikee changed the base branch from main to crap/3426-retire-approval-rows October 12, 2026 14:19
@thymikee
thymikee added this pull request to stack #3508 October 12, 2026 14:53
@thymikee
thymikee merged commit f2e74d2 into main Oct 12, 2026
26 of 36 checks passed
@thymikee
thymikee deleted the crap/3426-review-followups branch October 12, 2026 14:53
thymikee added a commit that referenced this pull request Oct 12, 2026
#3483 landed the three test-kit entries these rows approved, so from the next
branch on the merge-base carries them and the no-growth rule governs: nothing
reads a row any more, which is the invariant's own definition of a stale one and
the failure message says to remove them.

The trap is that `main` cannot show it. `staleApprovalRows` defers when the
merge-base is the head, because otherwise every approval would guarantee a red
`main` one commit after it landed (#2329). So the merged PR is green, `main` is
green, and the first branch rebased onto post-#3483 `main` inherits a failing
blocking Coverage job for a row it did not write. Reproduced on this branch's
own head: three rows named, pristine `main` passes.

Only first-introduced entries consult a ceiling, so deleting a dead row cannot
loosen anything: an entry the merge-base carries is policed by the no-growth
rule, and an entry nobody has carried yet is still measured against
`NEW_ENTRY_CEILINGS`. Unblocks #3501 and every other branch based on current
`main`.
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-12 14:54 UTC

thymikee added a commit that referenced this pull request Oct 12, 2026
#3501 rewrote the deleted-function case to keep the `score` record while the source
loses the function, which was the assertion that could actually fail. That left
`noFunctions` declared and branched on with no caller, so the empty-fnMap path it
exists to build is built by nobody and checked by nothing — the same shape as the
test-only seam removed earlier, with the fixture standing in for a tool.

Nothing else reads the knob, and 59 tests still pass, so the record builder is now
the one shape every case uses.
thymikee added a commit that referenced this pull request Oct 12, 2026
The paragraph said a deletion's raised score waits in the `--all` backlog, and
read the way the reviewer did: only added lines are charged, so a deletion is
never. That holds for a deletion-only edit and for a mixed one whose added lines
stay outside the function -- `run.test.ts` pins exactly that mixed case, adding
below `score` while deleting inside it, and the run is green. It does not hold
for added lines inside the function, which is charged the post-deletion score.

Names both halves so the conditional is visible rather than inferred from
"Adding lines is what charges a function", per the reviewer's optional wording
on #3501. Kept the mixed-edit clause because dropping it would overstate the
exemption the same paragraph is there to bound.
thymikee added a commit that referenced this pull request Oct 12, 2026
#3518)

The paragraph said a deletion's raised score waits in the `--all` backlog, and
read the way the reviewer did: only added lines are charged, so a deletion is
never. That holds for a deletion-only edit and for a mixed one whose added lines
stay outside the function -- `run.test.ts` pins exactly that mixed case, adding
below `score` while deleting inside it, and the run is green. It does not hold
for added lines inside the function, which is charged the post-deletion score.

Names both halves so the conditional is visible rather than inferred from
"Adding lines is what charges a function", per the reviewer's optional wording
on #3501. Kept the mixed-edit clause because dropping it would overstate the
exemption the same paragraph is there to bound.
thymikee added a commit that referenced this pull request Oct 12, 2026
#3483 landed the three test-kit entries these rows approved, so from the next
branch on the merge-base carries them and the no-growth rule governs: nothing
reads a row any more, which is the invariant's own definition of a stale one and
the failure message says to remove them.

The trap is that `main` cannot show it. `staleApprovalRows` defers when the
merge-base is the head, because otherwise every approval would guarantee a red
`main` one commit after it landed (#2329). So the merged PR is green, `main` is
green, and the first branch rebased onto post-#3483 `main` inherits a failing
blocking Coverage job for a row it did not write. Reproduced on this branch's
own head: three rows named, pristine `main` passes.

Only first-introduced entries consult a ceiling, so deleting a dead row cannot
loosen anything: an entry the merge-base carries is policed by the no-growth
rule, and an entry nobody has carried yet is still measured against
`NEW_ENTRY_CEILINGS`. Unblocks #3501 and every other branch based on current
`main`.

(cherry picked from commit ecf597b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant