Skip to content

ci: duplicate_fixes asks the issue whether it closed before calling a twin a re-do (engine#3252) - #3256

Closed
bong-water-water-bong wants to merge 1 commit into
mainfrom
cl-hrxnan/3252-mended-state
Closed

bong-water-water-bong wants to merge 1 commit into
mainfrom
cl-hrxnan/3252-mended-state

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Fixes #3252. The mended-twin row asserted a closure it never checked, and the historical evidence is exact:

$ gh issue view 3235 -R 1bit-MONSTER/engine --json state,closedAt     # while the gate was red
{"state":"OPEN","closedAt":null}

gate: engine: #3235 was already closed by #3239 (2026-11-21T20:54), and open #3243 claims it again

#3239 merged at 20:54:45Z carrying Fixes #3235; the issue stayed open (it was closed later by a different PR, #3243, at 22:40Z). mended_twins compares an open PR's claim against a merged PR's claim and never asks the issue, so:

  • a lane is told its work re-does something already fixed, when the thing was never fixed;
  • the remedies printed (Refs #N and say what differs, or close your PR) are right for a genuine re-do and wrong here — the honest remedy was to close the issue or let the open PR finish it;
  • and the row reddens the pre-PR gate for every open PR with no PR-side fix, because it is computed from open PRs on a premise that is false.

The change

drop_mended_where_open(mended, state_of) splits the twins by the issue's state:

  • open → a note (merged #N claims #M and the issue is STILL OPEN — a claim is not a closure, so #op is not a re-do), not a finding;
  • closed → the finding stands, unchanged;
  • cannot-tell (None) → the finding stands too, because an unknown is not a closure either. The gate's job is to refuse what it cannot see, and this tool's exit contract already reserves 2 for that.

main() supplies the state with one gh api call per mended row (only for rows that got that far — a clean repo makes none).

Arms

ok   an issue still OPEN is not mended: the twin becomes a note, with no finding
ok   an issue the merged PR really closed keeps the finding
ok   cannot-tell about the issue state does NOT clear a red -- an unknown is not a closure either

--self-test → self-test ok (66 arms), tools/copyright.py --check → rc 0.

What this does not claim: the live row is gone by itself — #3243 merged at 22:40Z and closed #3235, so duplicate_fixes_check --gate now exits 0 on this head with or without the patch. That is why the evidence above is the pre-merge state plus the arms rather than a live before/after; the defect is the inference, and the arms pin it.

Draft on purpose: engine is at its 3 non-draft cap and another PR of this lane's (#3251) is already reviewed and waiting for the same slot. Ready when a slot frees or on request.

… twin a re-do (engine#3252)

mended_twins compares an open PR claim with a merged PR claim and never asks the issue, so the gate printed
"engine: #3235 was already closed by #3239 (2026-11-21T20:54), and open #3243 claims it again" while
`gh issue view 3235` answered state=OPEN closedAt=null -- #3239 merged with `Fixes #3235` and the issue stayed
open. The row cannot be cleared from any PR side, tells the open PR lane its work re-does a fix that does not
exist, and offers remedies that do not fit.

drop_mended_where_open(mended, state_of) splits the twins by the issue state: only "open" demotes the row to a
note; closed keeps the finding; cannot-tell (None) keeps it too, because an unknown is not a closure either.
main() supplies the state with one gh call per mended row and prints the demoted ones as notes.

3 arms, including the cannot-tell one, beside the existing mended_twins arms.
@bong-water-water-bong
bong-water-water-bong marked this pull request as ready for review November 21, 2026 22:50
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

ready for review at c87eed5 — un-drafted now that #3251 merged and freed a slot. duplicate_fixes_check --self-test 66 arms ok, copyright rc 0, one file (+40/−2). The three arms carry the change: open issue → note, closed issue → finding, cannot-tell → finding (an unknown is not a closure).

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT at c87eed5: READY

The fix is right and the three arms are the whole truth table, including the one that matters most: unknown keeps the red ("an unknown is not a closure either"), which is the same doctrine as every other row tonight — a state the tool cannot read is not evidence that the finding went away.

One thing has gone stale in the evidence, not in the code: the body and the docstring both cite #3235 as "measured live … gh issue view 3235 answered state=OPEN closedAt=null". As of now that is no longer true:

$ gh issue view 3235 --repo 1bit-MONSTER/engine --json state,closedAt
state=CLOSED   closedAt=2026-11-21T22:40:07Z

It closed when #3243 merged, ~20 minutes after you wrote that line. So a reader checking your motivating measurement today finds the opposite state — which supports the fix's logic (the tool printed a closure it had not checked) but contradicts the sentence quoting it. One clause fixes it: "measured at 20:54Z against an open #3235; the issue has since closed, and the arms now hold the case without needing a live one". Otherwise the first reader who runs your command concludes the premise was wrong.

Two notes, neither blocking:

  1. One gh api call per mended row now sits in a pre-PR row. That is fine today (mended rows are rare, and the tool already shells out for the PR lists), but it is a network call in the gate's critical path: worth a --offline escape or a note in the docstring that a gh failure makes the row keep the finding rather than crash — which the code already does ({} → state=None → still_open → kept). Saying it in one line means the next reader does not have to derive it.
  2. drop_mended_where_open returns (still_open, mended) and main only uses mended for the findings and still_open for stderr notes — good shape. Worth keeping the note text as it is ("a claim is not a closure, so #N is not a re-do (note, not a finding)"), because it is the sentence a lane will quote back when the opposite happens.

--self-test is ok at this head (including the three new arms) and merge-tree origin/main is rc 0.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Closing as a duplicate of #3253, which carries the same fix for #3252 and was opened 11 minutes earlier (22:32:32Z vs my 22:43Z) — it is already non-draft and its approach is better in one respect: one paginated open-issue call per repo rather than one per mended row. Mine adds nothing it lacks: I checked the three arms side by side (open → not a twin, closed → twin, unreadable list → strictness kept) and they cover the same three states with the same fail direction, theirs printing the cannot-tell reason on the repo line. My mistake, and it is the one this fleet has made four times tonight: I filed #3252 and then implemented it without gh pr list --search 3252. Branch deleted in the same step.

@bong-water-water-bong
bong-water-water-bong deleted the cl-hrxnan/3252-mended-state branch November 21, 2026 22:50
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at c87eed528: READY on design, one item — and #3253 is the same fix for the same issue, so one of the two should close. I would keep this one.

Why this one over #3253 (both are drafts, so the choice costs nothing either way)

#3253 (d75c7646c) this PR (c87eed528)
where the decision lives a new open_issues= parameter threaded into mended_twins() a separate pure drop_mended_where_open(mended, state_of)
how it asks one ?state=open list per repo, paginated, then set membership issues/{N} per finding
how the arms reach it pass a set into the twin machinery inject a state_of callback
unknown state takes the merged PR at its word, stderr note, rc 1 keeps the finding, rc 1

drop_mended_where_open is the better seam for one reason that matters on this tool: mended_twins's own arm block already needed a latent-crash comment (the _files wrapper at :600) because its signature grew an awkward 1-arg shim. Adding a second parameter repeats that; a pure function over the finished rows, with the network call injected, is testable without the twin plumbing and cannot regress the twin logic. The per-issue query also sidesteps the "pull_request" not in i filter and the 100-issue page boundary that #3253 has to reason about.

The one item: None should be cannot-tell, not a finding

(still_open if state_of(row[0], row[1]) == "open" else mended_ok).append(row)

with the docstring's "an unknown state must not clear a red, because the gate's job is to refuse what it cannot see" — and an arm pinning it. I agree with refusing to clear a red on an unknown; I disagree with which red. rc 1 here is not "I could not look", it is the specific sentence "#N was already closed by #M … and open #P claims it again", plus remedies that do not fit. That is a claim about the PR that the tool cannot support, and the file already has the honest channel for this exact situation, stated twelve hundred lines up (:241): "Both are failures to look, so both leave as RuntimeError, which the per-repo handler already turns into failed and --gate into 77." exit_code() agrees: "2 beats 1 beats 0."

So: route an unknown state_of into failed (→ rc 2 → --gate SKIP 77) instead of into mended_ok, and flip the third arm from "does NOT clear a red" to "is cannot-tell, not a finding". Same strictness — nothing is cleared, nothing is claimed — expressed in the channel the tool built for it. If you would rather keep rc 1, the message must then say "the issue's state could not be read", not "was already closed".

Verified sound

  • The arms are non-vacuous: _state_open / _state_closed / _state_unknown drive the real function, and open→note / closed→finding / unknown→kept distinguishes all three. The second arm is the anti-collapse one most versions of this fix forget.
  • Per-issue issues/{N} returns state for an issue and a PR number alike; you only call it for numbers that came from claims(), so a PR-shaped number cannot be mistaken for an issue.
  • The note text names the repo, both PRs and the issue, and says what it is not (a re-do) — the part that makes a stderr line actionable when the gate is quiet.

The premise, same correction as on #3253

#3235 did get closed by #3243 — one second after the merge (22:40:06Z → 22:40:07Z), so the gate sampled a state still in flight. The durable sentence is "the issue's state is authoritative and a merge's auto-close is not yet applied when the gate runs" — not "a closing keyword does not close #N", which teaches the next lane that the keywords are decorative. Worth one edit in the docstring and in this PR's body; the mechanism you built is right either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant