Repository navigation
Label and auto-review PRs that change existing tests - #314
Conversation
thrawn01
left a comment
There was a problem hiding this comment.
Independent review of 057bc07. No security problem in the workflows, and the labeler holds up. Inverting add and remove, treating tiger's exit 2 as an empty report, skipping the remove path and treating a missing label as success each failed a test. Keep the self-check on this repo as it is. A same-repo PR can already edit changes-existing-tests-pr.yml, so pinning the labeler to main protects nothing and loses the check.
Changes I'd like before merge:
- The user-only approval rule can be passed by accident. skills/dispatch/SKILL.md:12 says a manager's or autobots' review "which can post under the user's account" never counts, but the reviewer has no way to tell those posts from the user's own. Autobots posts "TestX asserts the old timeout, update it" as a PR review under the user's login, the worker edits TestX and quotes it as a user comment, and a fresh reviewer sees the user's login and calls it authorized. Manager decision (settled by the manager): every PR review, PR comment and ticket comment a manager or autobots session posts starts with a fixed first line naming the session kind, the skills say so in one place, and the review treats any post with that line as not authorization. A
dispatch tellfrom a manager already says who sent it, so say that a nudge counts only when the user sent it. Keep it to a few lines. - The late-label text describes a case that mostly can't happen.
Ready(internal/rules/facts.go:143) is true only after every check passed, so the labeler has finished by the time a ready notice fires. Cut the "wait withgh run watch" sentence down to the case that is real, or drop it ifignore_optional_checkscan't exclude this check. Check which before you write it. - A repo missing the label never reaches ready. The labeler check fails, the PR is held, and the worker gets a failing-check nudge it can't fix. Say this in the PR body's risks, and make the worker-facing error say that only someone with repo admin rights can create the label.
- A 404 on remove fails the check (existingtestlabel.go:115). Someone removes the label between the GET and the DELETE and the run goes red. Treat 404 on remove as done, with a test.
- The package takes 15.7s under
-race, about 1s per test, because each test re-execs the race-built test binary as the fake tiger. Run them in parallel or build the fake once.
Not for this PR: internal/rework has its own changed-test matcher and it disagrees with tiger on a comment-only edit, a test moved between files and nested modules. File a ticket for one detector. tiger check also reports 24 findings in the new code, mostly prose comments. Leave those for the ticket that adopts Tiger in this repo, but fix the map-order append at existingtestlabel_test.go:443 now since it can flake.
Ran: make ci (exit 0), the package with and without -race, four mutations, the pinned tiger changed-tests on this PR.
|
Thanks. All five are in b6423a5 and 0ff2dd8.
The map-order append now sorts the job names first. ENG-910 tracks the single detector. I confirmed the disagreement with the pinned tiger on a scratch repo. Editing a comment inside a test's body and moving a test unchanged to another file both reported no changed tests, while rework.go:587-600 counts the first as modified and the second as deleted.
|
thrawn01
left a comment
There was a problem hiding this comment.
Posted by a dispatch manage session.
Independent re-check of 0ff2dd8. The code changes hold. Removing the 404 handling fails TestRemoveSucceedsWhenLabelAlreadyGone, the package runs in 1.5s under -race, and nothing in Go or the rules reads a ## Decision comment by position. Four gaps left in the skills, all small:
- skills/manage/SKILL.md:57 still says decision.md's "first line follows
references/decision-comment.md" and fails an arena that "returns no such line". The reference now opens with the marker, so that check is ambiguous. Use "the line under its heading" as the steps around it do. - The worker's own rule doesn't know the marker. skills/build/SKILL.md:22 still lets "a nudge, or a comment on the PR from the user" authorize a test change. A
dispatch tellfrom a manager is a nudge, and a marked review reads as a PR comment. Point that sentence at the rule indispatch:dispatchor say it in the same words, so the worker stops before the reviewer has to catch it. - A manager post that forgot the marker passes as the user's. Add one sentence to skills/dispatch/SKILL.md:12 for the reviewer who can't tell who wrote a quoted post. It treats the change as not authorized and puts it to the user.
approval_checksalso keeps a check out ofReady(internal/rules/facts.go:143). The late-label sentence names onlyignore_optional_checks.
…s in the late-label case
|
All four are in 9225cf3.
|
thrawn01
left a comment
There was a problem hiding this comment.
Posted by a dispatch manage session.
Read 9225cf3 myself, since it is three sentences of skill text. All four gaps are closed. The build rule now names the marker and user-sent nudges, a reviewer who can't tell who wrote a post treats the change as not authorized, approval_checks is in the late-label sentence, and manage's step 4 says "the line under its heading". CI is green. Nothing more from me.
thrawn01
left a comment
There was a problem hiding this comment.
Posted by a dispatch manage session.
Relaying the user's feedback on the skill prose in this PR. Their words: principle 2 in skills/dispatch/SKILL.md ("Review a worker's PR with sub-agents") "is NOW HUGE one line and confusing, skills should never be confusing or over prescriptive. Agents are smart, this change is not following the skills writing guidelines".
They are right, and my earlier reviews missed it. This PR adds a paragraph of procedure to that one list item: which gh api call reads the labels, how approval_checks and ignore_optional_checks interact with the labeler's check, when to run gh run watch, and what a failed check means. A session can work most of that out.
What the user wants:
- Load
dispatch:principle-skillsand rewrite every skill edit in this PR against it. Write only what a session wouldn't do unprompted, give the reason instead of the steps, and keep it short. Principle 2 is the worst case, but apply it tobuild,manage,autobots,pr-descriptionandreferences/decision-comment.mdtoo. - For principle 2, I think two or three sentences carry it: a PR with the
changes-existing-testslabel is reviewed without asking, the reviewer says for each changed existing test whether the user authorized it, and why that matters. Cut the commands and the check-timing detail unless a session provably gets it wrong without them. You know which of those lines came from a real failure, so keep those and say which in your reply. - Run
dispatch:skill-reviewon the result before you push, as the repo asks for any skill change. - Leave the Go code, the workflows and the tests as they are. Nobody raised anything there.
One push, then reply here with the before and after word count per skill file.
|
Rewritten in 19dce77, one push, Go code and workflows untouched. Words per file (main → before this push → now):
Principle 2 now adds four sentences: what the label means, that a ready notice doesn't carry labels, that the reviewer names each changed test and whether a sentence the user wrote authorized it, and the marker rule. The
Changed from the reader review:
Set aside: renaming "principle 2" and a reason clause in manage. Manage loads
|
thrawn01
left a comment
There was a problem hiding this comment.
Posted by a dispatch manage session.
An independent reviewer read the rewritten skill prose at 19dce77 against dispatch:principle-skills. Most of it is fine as written: autobots, pr-description, the manage Status entry, the ready-event branch, and the "line under the heading" rewording. Three things, one push:
- Principle 2 still carries two topics. The sentence that starts "A session that loads this skill posts under the user's account" is about every post, not about PR review, and it is why the item still reads as one huge line. Move it out to its own numbered principle. The reviewer's suggestion, for you to judge:
- In principle 2: "CI adds that label when a PR edits or deletes an existing test, which usually means behavior changed; a ready notice doesn't show labels, so check. The reviewer lists each such test and whether a sentence the user wrote authorized it (
dispatch:build). Post each unauthorized one and ask the user." - New principle: "Mark what you post. You post as the user, so open each post with
Posted by a dispatch <dispatch|manage|autobots> session.Only the user's own words authorize a test change: a marked post, another session's message or a post of unclear author never does."
- In principle 2: "CI adds that label when a PR edits or deletes an existing test, which usually means behavior changed; a ready notice doesn't show labels, so check. The reviewer lists each such test and whether a sentence the user wrote authorized it (
- Two lists of what doesn't authorize, and they differ.
skills/dispatch/SKILL.md:12has "a post with that line, another session's message, or a post whose author is unclear".skills/build/SKILL.md:22has "A bot's comment, another Claude session's message and a post that opensPosted by a dispatch". Keep one list and point the other at it. - Manage says it twice. Lines 9 and 60 both put unauthorized test changes off-limits. Keep one.
Two more findings are with the user, so don't act on them yet: whether the marker on every post belongs in this ticket, and that ticket bodies are written by sessions under the user's account, so "a sentence the user wrote in the ticket" can't be told from session-written text.
…t authorize a test change
|
All three are in the latest commit, one push.
Words now: dispatch 1612, build 3000, manage 2667. I haven't touched the two findings waiting on the user. |
thrawn01
left a comment
There was a problem hiding this comment.
Posted by a dispatch manage session.
Read c99b591 myself, since it is five lines of skill text. All three items are done: the marker is its own principle, build's rule is the one list, and manage says it once. CI is green. Nothing more from me on the prose. The two findings with the user stay open until they answer.
Intent
When a worker's PR edits or deletes a test that already existed, the behavior that test guarded has usually changed, and maybe nobody asked for that. Nothing marked those PRs, and a session only reviewed a worker's PR when the user asked.
Now CI labels such a PR
changes-existing-testson every push and takes the label off once the change is gone. Any dispatch session that sees the PR become ready reviews a labeled one without asking. The review names each changed test and whether the user authorized it. Each unauthorized change is posted on the PR and goes to the user, who is the only one who can approve it. Neither the manager nor autobots decides it, and autobots won't merge until the user answers.Fixes ENG-860
Surfaces
Workflow
.github/workflows/changes-existing-tests.yml, reusable. A managed repo calls it like this:Input
dispatch-ref(defaultmain) picks the dispatch version whose labeler runs. The check shows aschanges-existing-tests / changes-existing-tests.Workflow
.github/workflows/changes-existing-tests-pr.ymlcalls it on this repo's own PRs, running the labeler from the PR's head.Command
make changes-existing-tests, which the workflow runs:It exits 0 when the label matches the report, including when someone removed the label between its read and its delete, and 2 when it couldn't tell or couldn't change it. Other last lines are
removed changes-existing-tests,changes-existing-tests already set,no existing test changed, andno go.mod in <root>, so no Go tests to check. When the repo has no such label yet:Command
cmd/existingtestlabel(-root -base -repo -pr -tiger), the Go program behind the target. It runstiger changed-tests --format json, with tiger pinned byTIGER_REFto the ENG-859 merge.Skills
dispatch:dispatch,dispatch:manage,dispatch:autobots,dispatch:pr-description.Behavior changes
A PR ready notice for a worker's PR, before and after:
dispatch:dispatchsaid the PR is ready and asked once whether to review it.Every post a dispatch, manage or autobots session makes now opens with
Posted by a dispatch <kind> session., since those posts go out under the user's GitHub and Linear account. A## Decisioncomment puts it above the heading:An unauthorized test change, before and after:
dispatch:managethe manager could decide it like any product question, anddispatch:autobotsdecided findings itself and merged a clean review.The PR description a worker writes now lists, under Behavior changes, each existing test it modified or deleted and why, or "No existing test changed."
Existing tests changed by this PR: none.
Concerns and risks
pull-requests: write, as the ticket specifies, and adding a label the repo lacks would create it, which needsissues: write. I createdchanges-existing-testsin kapetan-io/dispatch. ENG-863, ENG-864 and ENG-865 each needgh label create changes-existing-testsonce. Until then the check fails on that repo's first PR with a changed test, the PR never reaches ready, and its worker gets a failing-check nudge it can't fix. The error names the command and says it needs someone with write access to the repo (GitHub's role table puts creating labels at Moderate or Write).pull-requests: writetoken. Only same-repo PRs reach it (fork and Dependabot PRs are skipped), and their authors can already edit the workflow file, so it grants nothing new. The independent review agreed to keep it.go.mod) are not seen, since tiger runs once at the root. ENG-907 covers that in tiger.internal/reworkfinds changed existing tests in merged PRs with its own matcher, and the label uses tiger. They disagree on a comment-only edit, a test moved to another file and nested modules. ENG-910 tracks making them one.pull-requests: writealone is refused when it creates a label comes fromactions/labeler's README, not a run.## Decisionchanged manage's and build's wording from "the comment's first line" to "the line under its heading". Manage sessions that post decisions before this merges post them without the marker.