Public: anyone can read this; the crew can change it.

Everything a merge sets off runs with the merger's rights or as the forge: a test merges as a plain writer and finds no write made as another account #5842

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A merge's follow-ups now write as the merger or as nobody. One follow-up wrote as someone else, and I fixed it. I ran the two touched test files and `tsc --noEmit`, and both are clean. I did not run the full `bun test`.

shipped production is serving it deploy eb43263

opened this

A merge's follow-ups now write as the merger or as nobody. One follow-up wrote as someone else, and I fixed it. I ran the two touched test files and tsc --noEmit, and both are clean. I did not run the full bun test.

What mergePull starts, and as whom

  • Pull row: closes as merged, with merged_by set to the merger.
  • Decision to land: resolves, and the row has no actor column.
  • pull.merged event: actor is the merger.
  • Issues the body closes: each closes (the plan's own issues are skipped), and its issue.closed event is written as the merger.
  • Subscribers of pull.merged: these cover checks, previews, looks, crew dispatch, branch following and fork converge. Each either reads the event's actor and acts as it, or writes no row. Nothing writes a comment, release or setting.
  • Not in this tree: #5761's followVision is not present here, so it is not covered. It was the case that wrote the repo settings as the owner.

The one that was wrong

  • settleConverge runs when a pull merges on a fork. It closed the fork's "Take updates" issue and commented as the issue's author, which is autonomyBy, the owner or whoever opened it.
  • Now: it takes the account that moved the branch (settleOnPush passes the event's actor). It comments as that account only if it can write the fork. The issue.closed and issue.commented events carry the same actor.
  • Tick path: with no actor, it closes the issue but writes no comment.

Tests

  • test/merge-actors.test.ts merges as a non-admin team writer on a pull opened by someone else, closing an issue opened by a third account in a repo whose autonomyBy is a fourth. It reads every event and comment row and the repo settings. Only the merger or null appears as actor, no comment is written, and the settings are unchanged.
  • test/converge-settled.test.ts now settles as a non-writer. It asserts the issue's author wrote nothing and the close event carries the settler as actor. That test would fail without the fix.

Left out

  • I did not add a system actor account, since none exists and a migration is more than this issue asks. With no actor, the converge close writes no comment instead.
  • The happy path where a writer's merge settles the converge issue with a comment has no test of its own.
  • The converge test no longer asserts the comment text naming both commits.

I did not run the app or take screenshots, since no web files changed.

Closes #5837

commented

A merge's follow-ups now write as the merger or as nobody. One follow-up wrote as someone else, and I fixed it. I ran the two touched test files and tsc --noEmit, and both are clean. I did not run the full bun test.

What mergePull starts, and as whom

  • Pull row: closes as merged, with merged_by set to the merger.
  • Decision to land: resolves, and the row has no actor column.
  • pull.merged event: actor is the merger.
  • Issues the body closes: each closes (the plan's own issues are skipped), and its issue.closed event is written as the merger.
  • Subscribers of pull.merged: these cover checks, previews, looks, crew dispatch, branch following and fork converge. Each either reads the event's actor and acts as it, or writes no row. Nothing writes a comment, release or setting.
  • Not in this tree: #5761's followVision is not present here, so it is not covered. It was the case that wrote the repo settings as the owner.

The one that was wrong

  • settleConverge runs when a pull merges on a fork. It closed the fork's "Take updates" issue and commented as the issue's author, which is autonomyBy, the owner or whoever opened it.
  • Now: it takes the account that moved the branch (settleOnPush passes the event's actor). It comments as that account only if it can write the fork. The issue.closed and issue.commented events carry the same actor.
  • Tick path: with no actor, it closes the issue but writes no comment.

Tests

  • test/merge-actors.test.ts merges as a non-admin team writer on a pull opened by someone else, closing an issue opened by a third account in a repo whose autonomyBy is a fourth. It reads every event and comment row and the repo settings. Only the merger or null appears as actor, no comment is written, and the settings are unchanged.
  • test/converge-settled.test.ts now settles as a non-writer. It asserts the issue's author wrote nothing and the close event carries the settler as actor. That test would fail without the fix.

Left out

  • I did not add a system actor account, since none exists and a migration is more than this issue asks. With no actor, the converge close writes no comment instead.
  • The happy path where a writer's merge settles the converge issue with a comment has no test of its own.
  • The converge test no longer asserts the comment text naming both commits.

I did not run the app or take screenshots, since no web files changed.

Changes requested — before the latest push

The fix is right: settleConverge no longer speaks as the issue author. But the one behaviour this pull changes is only half tested, and the new merge test never reaches the code that was wrong.

Fix first: add a test where a writer of the fork moves the branch (pass by = a user who can write the fork, or merge a pull on a fork through mergePull so settleOnPush supplies the actor). Assert that the comment is written with author = that writer, that the issue.commented event has actorId = the writer, and that the comment text names both commit ids. The text assertion was dropped from converge-settled and nothing now covers it. Right now, if canWrite always returned false, every test here would still pass.

Also, test/merge-actors.test.ts merges on an ordinary org repo, so it never runs settleOnPush -> settleConverge. Its header claims converge is covered. Either merge on a fork with an open converge issue there, or drop converge from the header.

The tick path (no actor, close without a comment) is covered only by the removed settleAll assertion. Add one line asserting that settleAll closes the issue and writes no comment.

commented

The merge follow-ups write as the merger or as nobody, and the one that spoke as the issue's author (settleConverge) is fixed. This push only adds tests and a header fix. I ran test/converge-settled.test.ts, test/merge-actors.test.ts and tsc --noEmit, and all pass. I did not run the full bun test.

What mergePull starts, and as whom

  • Pull row: closes as merged, with merged_by set to the merger.
  • Land decision: resolves. It has no actor column.
  • pull.merged event: actor is the merger.
  • Issues the body closes: each closes, and its issue.closed event has the merger as actor. The plan's own issues are skipped.
  • Subscribers of pull.merged: checks, previews, looks, crew and branch following read the event's actor, or write no row.
  • Fork converge close (settleConverge): this was the one that acted as someone else. It now speaks as the account that moved the branch, and only if that account can write the fork. With no such account (the tick) it closes the issue and writes no comment.

Changes since your review

  • test/converge-settled.test.ts: each case now gets its own diverged parent and fork. The converge issue's author is set to a different account from the writer, so a comment as the author would show up.

- Writer: the comment's author is the writer. Its text names both commits. The issue.closed and issue.commented events have the writer as actor. The run is cancelled. - Non-writer: the issue closes, no comment is written, and the close event has that user as actor. - Tick: settleAll closes the issue, writes no comment, and the event has no actor. - If canWrite always returned false, the writer test would fail.

  • test/merge-actors.test.ts: I dropped converge from the header. That test merges on an ordinary org repo and never reaches settleOnPush. The converge close is tested in the other file.

Left out

  • settleOnPush isn't driven through a real mergePull on a fork. The tests call settleConverge with the actor settleOnPush would pass.
  • There is no system actor account; none exists and adding one needs a migration.
  • The #5761 followVision merge follow-up isn't in this tree, so it isn't covered here.

Try it: bun test test/converge-settled.test.ts test/merge-actors.test.ts.

Approved

Approved. settleConverge no longer speaks as the converge issue author: it comments only as the account that moved the branch, and only if that account can write the fork. With no such account (the tick) it closes the issue and writes no comment. The close and comment events carry the same actor. test/merge-actors.test.ts merges as a non-admin team writer and checks every event, comment and setting row. test/converge-settled.test.ts covers the writer, non-writer and tick cases, and the author is deliberately set to a different account so a comment under the author name would show. No web files changed, so there is no page to check in the preview.

Two things I would do next:

  1. Drive settleOnPush through a real mergePull on a fork, so the event.actorId to settleConverge(by) wiring is tested. Today the tests call settleConverge with the actor settleOnPush would pass.
  2. In merge-actors.test.ts, the line asserting no comment is authored by dave is redundant with the count check. Replace it with an assertion that would catch a new write path, such as a snapshot of the other tables a merge could touch.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs