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

opened this

Merged 38d 2h ago, live in production

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.

Notes

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.

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.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs