Skip to content

feat(prepare-pr): tell the loop when a PR's green has expired - #11508

Merged
iamwhatever merged 2 commits into
mainfrom
feat/prepare-pr-green-freshness
Sep 18, 2026
Merged

iamwhatever merged 2 commits into
mainfrom
feat/prepare-pr-green-freshness

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

A pull request's green is a verdict about refs/pull/<N>/merge at the moment the
run was triggered. Nothing re-derives it when main moves, so a head that passed
and then waited for review can merge against a base its tests never saw.

That happened. One PR ran CI once, waited about ten hours for review, and merged
with no re-run. Two PRs merged in between had added tests that hand-write payloads
the merged change now validates, so those tests fail on the merged tree. The red
did not surface on either PR: main's own CI is routinely cancel-evicted by the
next merge, three runs in a row reading cancelled, so it appeared two hours later
on an unrelated PR and was fixed there.

Why it matters

The loop that drives a PR to review-ready had no way to notice. prepare-pr
rebases before a push, never during the review wait, and babysit's BEHIND
trigger is dead on this repository: mergeStateStatus reports BEHIND only under
strict up-to-date protection, which is off here. So a PR can sit green for hours,
merge, and hand the failure to whoever opens the next PR.

The obvious server-side fixes are refused by the constraint that matters: the
median merge gap here is about 1.4 minutes against a 19-minute CI, so a merge queue
or strict mode would serialise the repository behind its own CI.

What changed (motivation -> approach -> change)

The loop can now tell whether the wait invalidated the verdict, and it costs
nothing on a PR whose files did not collide.

prepare-pr/scripts/green_age.py compares the files origin/main gained since the
commit this head was tested on top of against the PR's own files, and reports an
overlap in one of four classes: the same file, the same module directory, a moved
.py importing a module this PR changed, and a moved test_<stem>.py whose stem
names a directory this PR changed. The last one is the incident's shape - the new
tests and the changed module shared no path component and no import. A directory
that only describes layout (test/, .github/) is not a module directory, because
those are flat and hold thousands of unrelated files. A relative import resolves
against the moved file's own package, since skipping one reports a real overlap as
no overlap - the dangerous direction. Exit 0 fresh, 30 stale, 2 could not measure;
stdlib only, one injected runner for every command, and no flag or parameter without
a caller - pr_status.py reads the dict by importing summarize(), so the script
has no --json.

prepare-pr/scripts/pr_status.py prints the same line beside the check rollup and
carries the summary in advisory.green_age. It is information for the merger,
never a gate: nothing is passed to decide(), no exit code moves, and a probe that
cannot answer prints unavailable instead of flipping a verdict. It stays out of
progress_key too, since a base that moves every few minutes would reset a stall
streak forever.

prepare-pr/SKILL.md runs it each Phase 3 cycle and states the loop's own bounds:
a PR goes to the user after three consecutive re-syncs rather than being rebased
forever, the existing no-push-while-runs-are-in-flight rule stays ahead of exit 30,
and exit 2 satisfies the readiness criterion no more than it blocks it - after three
of those the loop reports and hands over. references/rationale.md records why the
check is client-side and what it does not close: a human-merged PR gets only the
printed line. babysit/SKILL.md widens its sync trigger and notes why BEHIND
never fires here. .github/PULL_REQUEST_TEMPLATE.md gains a
## Backwards compatibility section for the writer-side half of the same expiry.
The incident's own merge is that half: the PR that waited made a ledger entry's
data validate against a registry, so a payload main accepted before now raises -
and the writers it broke are the ones the two intervening PRs added, which a sweep
taken when it opened could not have seen. So a tightening diff owes Breaking: plus
a writer sweep re-run on fresh main before the last push.

prepare-pr/SKILL.md sat 25 bytes under its 68000-byte ceiling, and that ceiling
is a ratchet that may only tighten. So the picture-authoring rules move verbatim to
the new prepare-pr/references/body-picture.md with a pointer left in the skill,
which pays for the new instruction and leaves the ceiling untouched.

Backwards compatibility

Compatible: green_age.py is a new file whose exit code no other gate reads;
pr_status.py adds one printed line and one advisory key while its exit codes,
progress_key and every other field stay as they were; the template gains a
section no check requires; the skill's picture rules move to a reference file with
every rule intact and a pointer in their place. Nothing that passes today starts
failing.

Tests

test/test_prepare_pr_green_age.py runs against two real repositories on disk - an
upstream whose base branch moves and a clone carrying the feature branch - so the
verdict comes from git rather than from a stub. One case per overlap class, one
negative (a base that moved somewhere else stays fresh), one for the flat-directory
rule, one environment error, and the flags: --ci-base pins the tested commit, an
unresolvable one is exit 2, --pr takes the files from the host, and a failed fetch
is exit 2 rather than a green. Each class was mutation-checked: disabling its branch
in classify_overlap turns its own test red and leaves the rest green.

test/test_prepare_pr_status.py adds four cases: the line prints beside the rollup
and lands in advisory but not progress_key; a STALE probe is reported and the
exit code stays 0; a probe that raises degrades to unavailable with no FRESH
claim; and the probe is asked about the host's own base branch, so a PR against a
release branch is measured against that branch.

test/test_prepare_pr_body_register.py pins the template's two branches, the
contract rule and its Phase 1.5 pointer, and that the section is absent from the
fork gate's required list with the reason recorded in rationale.md.
test/test_prepare_pr_findings.py adds green_age.py to the installed-bundle
fixtures, since pr_status.py now imports it. Three more cases cover the relative
import (a moved caller writing from .._sqlite_compat import x is an overlap), the
resolution rules themselves (__init__.py's own package, and climbing past the root
resolving to nothing), and the skill's stated bounds on re-syncs and on exit 2.

Manual verification

Ran green_age.py against this branch while main moved under it: STALE with the
overlapping paths named when a base commit touched them, and FRESH after the
flat-directory rule stopped every unrelated moved test file from counting - the
first run reported 17 such false overlaps, which is what that rule now removes. The
gate floor's backend surface is green: 1653 scoped tests, isort, flake8,
black, mypy on the new and changed modules, and the diff-scoped scans. The two
remaining mypy src/kiro_crew/ errors are in transcribe.py and
ops_mission_control/backend/providers/cloudwatch.py, neither in this diff. No
frontend file changed, so no rendered surface moved.

Related Issues

no linked issue: the incident was diagnosed while reading merged history, and this
is the client-side half of the fix.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@chenmingwei23
chenmingwei23 requested review from a team and CrysisDeu September 17, 2026 09:51
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Intent: Let the loop notice when a PR's CI green has stopped describing the base it will merge against, and rebase only when the base moved in files this PR also touches.
Not a goal: Any merge gate, any change to merge velocity, or a server-side check. This stays client-side, inside the skill, and no exit code outside green_age.py depends on it.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 17, 2026
@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

Design-level review of 96daa5af6a2b8426bf1d881a20037d54cf2848ab — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

--pr mode can print FRESH for a stale PR whenever the local checkout is not the PR's head — babysit's generic-monitoring path invokes exactly that shape.

Watch

  • The CLI mixes host-derived identity with checkout-derived history: --pr takes mine from gh pr view --json files, but tested_base is merge-base(HEAD, origin/<base>) of the local checkout (head defaults to "HEAD" in main()). babysit/SKILL.md instructs green_age.py --pr <pr#> as a standalone poll; run from a checkout recently rebased onto tip, moved is empty and the line reads FRESH for a PR that is actually stale — the false-green direction the design elsewhere refuses ("skipping one reports a real overlap as no overlap - the dangerous direction"). The embedded pr_status.py path already passes the PR's head_sha; the bare CLI does not.
    Clears when: --pr resolves headRefOid from the same gh call and uses it as head, exiting 2 when it is not resolvable locally — or the babysit instruction routes through pr_status.py's probe only.
  • The description's Tests paragraph claims "--ci-base pins the tested commit, an unresolvable one is exit 2", but the diff pins the opposite: test_the_tested_base_is_the_merge_base_not_a_caller_supplied_sha asserts --ci-base is rejected as unrecognized, for a stated security reason. A stale claim about a deliberately removed override will mislead the next reader of this contract.
    Clears when: the PR body's flags sentence is rewritten to state the flag was removed and why.

[DESIGN-REVIEWED] 96daa5a

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 96daa5af6a2b8426bf1d881a20037d54cf2848ab and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 96daa5a

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 96daa5af6a2b8426bf1d881a20037d54cf2848ab: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed 96daa5af6a2b8426bf1d881a20037d54cf2848ab — this comment is updated in place on each push.

Review details

The regex analysis is deterministic and I've confirmed it by reading the pattern carefully. Let me finalize.

For import kiro_crew.ledger.store # noqa: F401: the import alternative matches import then (?P<plain>[A-Za-z_][\w.,\t ]*) consumes kiro_crew.ledger.store plus spaces but the char class excludes #; the required $ anchor then cannot match (a # and text follow before EOL), and no backtracking within plain can reach past the #, so the entire line yields no match. The from X import y # c form survives because its names group is .+. This is a genuine, reachable false-FRESH in the new code — the direction the module's own docstring calls "the dangerous direction." It is an advisory, non-gating tool, so it does not block.

No blocking findings; one advisory.

FINDING — src/kiro_crew/builtin_skills/kirocrew-dev/prepare-pr/scripts/green_age.py:462 — a moved base file whose only tie to a changed module is a plain import kiro_crew.x # noqa is silently dropped by _IMPORT_RE, because the plain char class [\w.,\t ] excludes # and the trailing $ then never matches, so imported_modules misses it and the import overlap class never fires → false FRESH (exit 0) on a stale green → Fix: in the plain branch allow a trailing comment before $, e.g. (?P<plain>[A-Za-z_][\w.,\t ]*?)[ \t]*(?:#.*)? (or strip comments before matching); the from … import … # c form already works via its .+ names group.

[OPUS-REVIEWED] 96daa5a

Verdict parsed from the review's SHA-scoped output markers for commit 96daa5af6a2b8426bf1d881a20037d54cf2848ab.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 96daa5af6a2b8426bf1d881a20037d54cf2848ab: <one-sentence reason>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 17, 2026
@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of 6b299f3b420878c6e82e2f70ffd6a41a49e45c89 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

The writer-sweep contract rests on an incident naming writers this tree does not contain, and the loop's new auto-re-sync default rests on unverifiable repo-settings claims.

Not justified as shipped

  • Item 3 — inherited: the fifth readiness criterion's necessity rests on "strict_required_status_checks_policy: false" and "median merge gap is about 1.4 minutes" — asserted, checkable only by a maintainer.
    Clears when: a maintainer confirms this repository's branch-protection settings and merge cadence, or records the decision (non-draft RFC on base, or /ai-review override first-principles 6b299f3b420878c6e82e2f70ffd6a41a49e45c89: <decision>).
  • Item 4 — inherited: auto-rebase-and-push of a green PR changes the first-class ship loop's default on the description's argument alone.
    Subtraction: shrink exit 30 to report-and-hand-over; ship the automatic push once the decision is recorded.
    Clears when: same records as item 3.
  • Item 6 — inherited: rationale.md's sole justification names test/test_ledger_kinds.py and test/test_ledger_retention.py as the broken writers; grepped ledger_kinds|ledger_retention: 0 hits outside this PR's own files, no kiro_crew/ledger/ package, no ledger-kind registry validator anywhere in src/.
    Subtraction: defer the template section to its own PR once the incident is citable.
    Clears when: the incident's PRs/commits are linked, or the named writers are shown in this repository's history.
  • Item 7 — inherited: the Phase 1.5 Breaking:/writer-sweep rule stands or falls with item 6's incident.
    Clears when: item 6 clears.

What this change ships

Inventory (10 items) — 6 justified

Intent: let the PR loop notice when a green CI verdict expired because the base moved in overlapping files — ADDITION.

  1. New green_age.py reports whether the base moved in this PR's files (0/30/2) — justified
  2. pr_status.py prints the green-age line and carries advisory.green_age — justified
  3. Review-ready now requires green freshness (fifth criterion) — inherited: unverified repo-settings and merge-gap claims
  4. The loop now auto-rebases and re-pushes a green PR on exit 30 — inherited: changed loop default, decided in-description
  5. babysit widens its sync trigger to green_age exit 30 (optional helper) — justified
  6. PR template gains ## Backwards compatibility — inherited: incident's named writers absent from this tree
  7. Contract section 4 + Phase 1.5 force Breaking: plus writer sweep — inherited: same uncorroborated incident
  8. Picture rules moved verbatim to references/body-picture.md — justified
  9. monitor_start message now instructs green-age handling — justified
  10. rationale.md records why the check is client-side and ungated — justified

[FIRST-PRINCIPLES-REVIEWED] 6b299f3

@chenmingwei23
chenmingwei23 force-pushed the feat/prepare-pr-green-freshness branch from 395e503 to bf3ee0b Compare September 17, 2026 10:07
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

self-added: no
mechanism: none added

  • span=6d1431151369 -- the skill-size ratchet is loosened -- fixed

Legitimate and blocking: AUTOSDE a-ratchet-may-only-tighten names exactly this
shape, and the ceiling was raised so the diff would fit.
The ceiling in test/test_review_repair_routing_skill.py is back to 68000, and the
skill is 67980 bytes. It was paid for by moving the picture-authoring rules
verbatim to prepare-pr/references/body-picture.md, with a pointer left in the
skill: no rule was dropped, and the file it moved to is the one the skill's own
preamble names for authoring detail.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 17, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author
  • span=c48e8dacf504 -- no cap on consecutive green-age re-syncs -- fixed

Legitimate: on a 19-minute CI against a ~1.4-minute merge gap, a PR overlapping a
churned file could re-sync every cycle and never settle.
Phase 3 step 5 now says both things the Clears-when asks for. After three
consecutive green-age re-syncs on one PR the loop hands it to the user instead of
pushing again, because a file the base rewrites faster than CI finishes needs a
decision rather than a fourth rebase. And exit 30 does not override the existing
no-push-while-runs-are-in-flight rule: the round settles first, then the re-sync.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author
  • span=a854b09f3feb -- derive --ci-base from the run's own merge commit -- rebutted

The suggestion is right about the direction of the error and wrong about it being
a defect to fix here. On a never-rebased head the merge base is EARLIER than the
trigger-time base tip, so moved is a superset and the bias is toward reporting
STALE, never toward reporting a stale green as fresh. A false STALE costs one
rebase and a scoped re-run; the failure this exists to catch costs a merged red.
The exact answer already has a seam: --ci-base <sha> takes the commit from any
caller that knows it, and prepare-pr rebases before every push, so for the loop's
own PRs the default IS the tested base. Reading it from the run instead would add
a gh call per cycle on a merge ref GitHub may have collected, to replace an
inference that is exact in the loop's own case.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author
  • Item 7 -- the diff ships the knowledge-store serialization change -- rebutted

Not in this diff, in either direction. gh pr view 11508 --json files returns
exactly 11 paths: the PR template, babysit/SKILL.md, prepare-pr's SKILL.md,
references/rationale.md, scripts/green_age.py, scripts/pr_status.py, and five test
files under test/. git diff --name-only origin/main...HEAD returns the same 11,
and git show --name-only HEAD | grep -c knowledge is 0. No hunk touches
src/kiro_crew/knowledge/ or any knowledge test.
The lane's own note allows for this ("whether the branch carries it or the diff
was computed against a pre-#11166 base"): it read a diff snapshot against an older
base, so #11166's own hunks appeared as this branch's. The subtraction it asks for
is already true of the branch.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author
  • Item 3 -- changed default of a first-class skill, no recorded decision -- needs-a-decision

Putting the question to a maintainer, because its Clears-when names two things only
a maintainer can supply and I will not self-authorize either.
The question: does adding "the base moved in files this PR touches" to the reasons
the loop may push a waiting PR need its own recorded decision, given the loop
already pushes unasked on a CI red and on a review finding, and given this one is
bounded (three consecutive re-syncs, then it hands the PR to a human) and fires
only on a measured file overlap?
What I would do: treat it as covered, on the ground that the loop's contract is
already "keep this PR mergeable and re-push when the evidence changes" and no new
class of action was introduced. If you disagree, the shape I would ship instead is
report-only -- print the line, never re-sync -- which needs no decision at all.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 17, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/prepare-pr-green-freshness branch from bf3ee0b to 0c9368c Compare September 17, 2026 10:46
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

self-added: no
mechanism: relative-import resolution in imported_modules

  • span=a98e039ece9c -- a relative import is skipped, so a real overlap reads FRESH -- fixed

Legitimate, and in the dangerous direction: a missed overlap is a green that looks
valid. imported_modules now takes the moved file's own path, derives its package
and resolves a relative target against it, so src/kiro_crew/knowledge/retrieval.py
writing from .._sqlite_compat import x binds kiro_crew._sqlite_compat and a PR
changing that module is an import-class overlap.
Resolution follows Python's own rules: one dot is the file's own package, each
further dot climbs one level, __init__.py's package is the directory it defines,
and climbing to or past the root resolves to nothing rather than to a top-level
guess. Three tests cover the overlap, the rules, and the unresolvable case.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

self-added: no

  • span=9c4cdc504627 -- overlap records retain unbounded external paths -- rebutted

Accepting the adjudication's own analysis, which downgraded this to advisory on
grounds I cannot improve on: moved and mine both come from
git diff --name-only, so the list is bounded by the repository's file count, not
unbounded; main() prints once and returns, so a fresh process per poll cycle
releases it and nothing accumulates; and the human line is already capped at
_OVERLAP_PRINT_CAP = 12 with an +N more tail, so only the --json dump scales.
Adding entry caps, path truncation and omitted-count accounting would put permanent
branches and state in a short-lived dev-tool script to bound a rare, self-clearing
output bulge. That is the trade the adjudication weighed and refused, and I agree
with it rather than quietly re-litigating it.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author
  • span=7cce2afc1912 -- exit 2 is neutral in two places and a failure in a third -- fixed

Legitimate: the readiness definition said "exits 0", which reads an unreadable base
as a criterion failure, while rationale.md and babysit both treat exit 2 as neither
verdict. Three files said two different things.
The readiness criterion now states it directly -- exit 2 satisfies it no more than it
blocks it -- and Phase 3 says what N consecutive 2s do: keep polling, and after three
report the reason and hand the PR over, since an environment the loop cannot read is
not one it can fix by polling. That matches babysit's exit-30-only sync gate, and
rationale.md now carries the same statement so the three cannot drift again.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author
  • span=f7ad9e962d5d -- the stale signal only reaches PRs the loop is driving -- fixed

Legitimate, and the honest scope of the change: a human-merged PR gets the
green age: line pr_status.py prints and nothing more.
rationale.md now says so under its own heading rather than leaving "the loop can now
tell" to imply the class is closed: the incident class is narrowed, not closed, a
merger who does not read that line can still merge an expired green, and closing it
outright needs the server-side signal the merge-velocity constraint refuses.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author
  • span=e275429b4db1 -- product-shape change with no recorded decision -- needs-a-decision

This needs a maintainer, and its own Clears-when says so: a non-draft RFC or an
override, neither of which I will self-authorize.
The question: does adding "the base moved in files this PR touches" to the reasons the
loop may re-push a waiting PR need its own recorded decision, given the loop already
pushes unasked on a CI red and on a review finding, that this one fires only on a
measured file overlap, and that it is now bounded -- three consecutive re-syncs, then
the PR goes to a human?
What I would do: treat it as covered, because the loop's existing contract is already
"keep this PR mergeable and re-push when the evidence changes" and no new class of
action was added. If you disagree, the shape I would ship instead is report-only --
print the line, never re-sync -- which changes no default and needs no decision.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author
  • span=14c68ca12a10 -- --ci-base and --json have zero shipped callers -- rebutted

The grep is right and the conclusion does not follow, because on this same head the
Design lane asked for the opposite of deleting one of them.
--ci-base is the seam that answers Design span=a854b09f3feb: the default tested base
is an inference from the rebase discipline, and that suggestion's own case -- a
never-rebased head, where the inference over-reports -- is exactly when a caller or a
human debugging a false STALE must be able to supply the real commit. Deleting it
leaves the inference with no override, which is the finding one lane just filed.
--json is the bundle's uniform contract: every prepare-pr entry point a loop polls
emits one machine-readable object, babysit's documented tripwire reads exactly that,
and the consumer here is the loop rather than a human -- pr_status.py already serves
the same object as advisory.green_age. Deleting it would make green_age the one
script in the bundle a loop can only screen-scrape.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 17, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 17, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

/ai-review override first-principles f5c79b8: Maintainer decision: ship the green-expiry fifth readiness criterion and its bounded exit-30 resync without a separate RFC. test_prepare_pr_green_age.py and test_prepare_pr_status.py cover the behavior. This PR records the accepted product choice; do not remove the feature solely for RFC timing.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@chenmingwei23 marked the first-principles AI finding as false positive, not applicable, or explicitly accepted for f5c79b8a9519d4c074507084335fada6ad118d56.

Maintainer decision: ship the green-expiry fifth readiness criterion and its bounded exit-30 resync without a separate RFC. test_prepare_pr_green_age.py and test_prepare_pr_status.py cover the behavior. This PR records the accepted product choice; do not remove the feature solely for RFC timing.

This decision applies only to this commit. A new push requires a new judgment.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 17, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/prepare-pr-green-freshness branch from f5c79b8 to 6b299f3 Compare September 18, 2026 00:42
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 18, 2026
A pull request's green is a verdict about refs/pull/N/merge at trigger
time. Nothing re-derives it when the base branch moves, so a head that
passed and then waited for review can merge against a base its tests
never saw. Measured: one PR ran CI once, waited about ten hours, and
merged with no re-run while two other PRs added tests the merged change
makes fail; the red surfaced later on an unrelated PR, because this
repo's own main CI is routinely cancel-evicted by the next merge.

green_age.py answers the one question that decides whether the wait
invalidated the verdict: did origin/main move in files this PR also
touches since the commit this head was tested on? Four overlap classes,
most direct first -- same-file, same module directory, a moved .py
importing a changed module (absolute or relative, resolved against the
moved file's own package), and a moved test_<stem>.py naming a changed
directory, which is the incident's own shape and shares no path
component at all. A directory that only describes layout (test/,
.github/) is not a module directory: those are flat and hold thousands
of unrelated files, so counting one made every moved test file collide.
Exit 0 fresh, 30 stale, 2 could not measure.

pr_status.py prints the same line beside the check rollup and carries
the summary in advisory.green_age. It is information for the merger,
never a gate: no exit code depends on it, and a probe that cannot
measure degrades to "unavailable" rather than flipping a verdict. A
merge queue or strict up-to-date protection would serialise a repository
whose median merge gap is about 1.4 minutes behind a 19-minute CI, so
the check stays client-side and costs a rebase only on a PR whose files
actually collide.

The skill states the loop's own bounds, so a rule that can re-push every
cycle has a stated end: a PR goes to the user after three consecutive
re-syncs, the no-push-while-runs-are-in-flight rule stays ahead of exit
30, and exit 2 satisfies the readiness criterion no more than it blocks
it.

The PR template gains a Backwards compatibility section for the same
class of failure on the writer side: a diff that tightens a contract
owes a Breaking line plus a writer sweep re-run on fresh main before the
last push. The section is deliberately absent from the fork description
gate's required list, which would fail every body written before this
change.

prepare-pr's SKILL.md sat 25 bytes under its 68000-byte ceiling, which
is a ratchet that may only tighten. The picture-authoring rules
therefore move verbatim into references/body-picture.md with a pointer
left in their place, which pays for the new instruction and leaves the
ceiling untouched.
@chenmingwei23
chenmingwei23 force-pushed the feat/prepare-pr-green-freshness branch from 6b299f3 to 96daa5a Compare September 18, 2026 03:35
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 18, 2026
@iamwhatever
iamwhatever merged commit b05c62d into main Sep 18, 2026
124 of 125 checks passed
@iamwhatever
iamwhatever deleted the feat/prepare-pr-green-freshness branch September 18, 2026 07:01
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 18, 2026
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
…tdev#11508)

* feat(prepare-pr): tell the loop when a PR's green has expired

A pull request's green is a verdict about refs/pull/N/merge at trigger
time. Nothing re-derives it when the base branch moves, so a head that
passed and then waited for review can merge against a base its tests
never saw. Measured: one PR ran CI once, waited about ten hours, and
merged with no re-run while two other PRs added tests the merged change
makes fail; the red surfaced later on an unrelated PR, because this
repo's own main CI is routinely cancel-evicted by the next merge.

green_age.py answers the one question that decides whether the wait
invalidated the verdict: did origin/main move in files this PR also
touches since the commit this head was tested on? Four overlap classes,
most direct first -- same-file, same module directory, a moved .py
importing a changed module (absolute or relative, resolved against the
moved file's own package), and a moved test_<stem>.py naming a changed
directory, which is the incident's own shape and shares no path
component at all. A directory that only describes layout (test/,
.github/) is not a module directory: those are flat and hold thousands
of unrelated files, so counting one made every moved test file collide.
Exit 0 fresh, 30 stale, 2 could not measure.

pr_status.py prints the same line beside the check rollup and carries
the summary in advisory.green_age. It is information for the merger,
never a gate: no exit code depends on it, and a probe that cannot
measure degrades to "unavailable" rather than flipping a verdict. A
merge queue or strict up-to-date protection would serialise a repository
whose median merge gap is about 1.4 minutes behind a 19-minute CI, so
the check stays client-side and costs a rebase only on a PR whose files
actually collide.

The skill states the loop's own bounds, so a rule that can re-push every
cycle has a stated end: a PR goes to the user after three consecutive
re-syncs, the no-push-while-runs-are-in-flight rule stays ahead of exit
30, and exit 2 satisfies the readiness criterion no more than it blocks
it.

The PR template gains a Backwards compatibility section for the same
class of failure on the writer side: a diff that tightens a contract
owes a Breaking line plus a writer sweep re-run on fresh main before the
last push. The section is deliberately absent from the fork description
gate's required list, which would fail every body written before this
change.

prepare-pr's SKILL.md sat 25 bytes under its 68000-byte ceiling, which
is a ratchet that may only tighten. The picture-authoring rules
therefore move verbatim into references/body-picture.md with a pointer
left in their place, which pays for the new instruction and leaves the
ceiling untouched.

* style: black-format test_prepare_pr_green_age.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants