From 108a944e1c8016890c9ebc798f693d32873c0b61 Mon Sep 17 00:00:00 2001 From: dan-claude-bot Date: Mon, 20 Jul 2026 16:44:19 +0000 Subject: [PATCH] chore(labels): converge reconciler and fixtures on the canonical text box, rig and cast carry the same reconciler, and the three had drifted to functionally identical but textually different versions of checks_state after the same fix was reached independently in each repo. Comment prose and one fixture helper name differed, so the files were no longer byte-identical and the convergence check had nothing to compare. Standardised on the cast wording for checks_state and on the canonical test/labels-reconcile.sh, which carries the same 51 fixtures under overlap_() where this repo had named the helper drained_(). No behaviour change: the diff to the reconciler is comments only, and the suite is unchanged at 51 passed, 0 failed. Only this repo's own scope:* rows are preserved as local content. Co-Authored-By: Claude Opus 4.8 --- .github/scripts/labels-reconcile.sh | 22 ++++++++--------- test/labels-reconcile.sh | 37 +++++++++++++---------------- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/.github/scripts/labels-reconcile.sh b/.github/scripts/labels-reconcile.sh index f2e4dbe..773ebd3 100644 --- a/.github/scripts/labels-reconcile.sh +++ b/.github/scripts/labels-reconcile.sh @@ -89,21 +89,21 @@ checks_state() { # rollup JSON on stdin → SUCCESS | FAILURE | PENDING | NONE # replacement was still running, which is #136 again. # # So: date a run by when it BEGAN, discarding both spellings of absent - # (null, and the zero sentinel), and fall back only if it never recorded a - # beginning. Deliberately `first` over the preference-ordered list and not - # `max` of it: max mixes "when it started" with "when it ended", which are - # different quantities, so it is not an ordering on runs at all. A run - # cancelled by the concurrency group does not stop the instant its - # replacement starts — the runner has to receive the signal and wind down — - # so predecessor.completedAt > successor.startedAt is the ordinary case - # (13s on the box#137 tip), and under max the dying predecessor - # out-dated its live replacement for the whole drain window. + # (null, and the zero sentinel) and falling back only if it never recorded + # a beginning. NOT by the newest stamp of any kind: `max` compares the + # completion of a finished run against the start of a live one, which are + # different quantities and not an ordering on runs. A run cancelled by the + # concurrency group does not stop the instant its replacement starts — the + # runner has to wind down — so predecessor.completedAt > successor.startedAt + # is the ordinary case, and `max` dated the dead predecessor newer than the + # live run that replaced it, narrowing both failures above without closing + # them. The list is already in preference order, so `first` IS that rule. # # An entry that carries no usable timestamp at all sorts LAST rather than # first — something we cannot date is most likely the thing just created, # and treating it as newest keeps an undateable in-flight run from being - # discarded in favour of a stale success. Every ambiguity here resolves - # toward "not settled". + # discarded in favour of a stale success. Every ambiguity resolves toward + # "not settled". | [ (.statusCheckRollup // [])[] | { ctx: [.workflowName // "", .name // .context // ""], at: ([.startedAt, .createdAt, .completedAt] diff --git a/test/labels-reconcile.sh b/test/labels-reconcile.sh index eea4561..b68de99 100644 --- a/test/labels-reconcile.sh +++ b/test/labels-reconcile.sh @@ -291,26 +291,23 @@ expect "a finished re-run supersedes an earlier in-flight run" SUCCESS \ "$(rollup "[$(inflight_ build 2026-07-20T15:19:00Z),\ $(run_ build SUCCESS 2026-07-20T15:19:45Z)]" | checks_state)" -# -- the DRAIN WINDOW. A run cancelled by the concurrency group does not stop -# the instant its replacement starts: the runner has to receive the signal -# and wind down, so the predecessor's completion lands AFTER the successor's -# start. On box#137's own tip that window was 13s (superseding run started -# 15:19:38, the run it cancelled finished 15:19:51). `run_()` cannot express -# it either — it carries no startedAt — so every fixture above spaces the -# predecessor's completion safely before the successor's start, and the whole -# window is invisible to them. This is why the run is dated by `first` of the -# preference-ordered stamps and not by `max` of them: max compares "when it -# ended" against "when it began", which is not an ordering on runs, and the -# dying predecessor out-dated its live replacement for the entire window. -drained_() { jq -n --arg n "$1" --arg c "$2" --arg s "$3" --arg e "$4" \ - '{__typename:"CheckRun", workflowName:"ci", name:$n, conclusion:$c, - startedAt:$s, completedAt:$e}'; } - -expect "a predecessor still draining does not out-date its live replacement" PENDING \ - "$(rollup "[$(drained_ build CANCELLED 2026-07-20T15:19:29Z 2026-07-20T15:19:51Z),\ - $(inflight_ build 2026-07-20T15:19:38Z)]" | checks_state)" -expect "...and the same when the draining predecessor is green (the #136 shape)" PENDING \ - "$(rollup "[$(drained_ build SUCCESS 2026-07-20T15:19:29Z 2026-07-20T15:19:51Z),\ +# -- the wind-down window. A predecessor cancelled by the concurrency group +# does not stop the instant its replacement starts, so its completion +# routinely lands AFTER the successor's start — on box's aa5a6ba the +# replacement started 15:19:38 and the run it cancelled finished 15:19:51. +# Dating by "newest stamp of any kind" compares the dead run's completion +# against the live run's start, which is not an ordering on runs, and the +# predecessor wins. Every fixture above spaces completion before start, so +# none of them can see it. run_() cannot express the overlap either — it +# carries no startedAt — hence the explicit payloads. +overlap_() { jq -n --arg n "$1" --arg o "$2" --arg s "$3" --arg c "$4" \ + '{__typename:"CheckRun", workflowName:"ci", name:$n, conclusion:$o, + startedAt:$s, completedAt:$c}'; } +expect "a predecessor finishing after its replacement started is still older (CANCELLED)" PENDING \ + "$(rollup "[$(overlap_ scope CANCELLED 2026-07-20T15:19:00Z 2026-07-20T15:19:51Z),\ + $(inflight_ scope 2026-07-20T15:19:38Z)]" | checks_state)" +expect "...and the same when it finished green — mid-flight is not mergeable" PENDING \ + "$(rollup "[$(overlap_ build SUCCESS 2026-07-20T15:19:00Z 2026-07-20T15:19:51Z),\ $(inflight_ build 2026-07-20T15:19:38Z)]" | checks_state)" # -- the classifier feeds the state machine: a cancelled required check must