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

A mirrored repository can approve an outsider's pull so its checks and preview run #963

Closed opened this in answer to
Closed without merging

A writer can now approve a mirrored pull's exact head to run here, and pullMayRun counts that approval. The new tests, the neighbouring approval, studio and review tests, the schema tests and tsc --noEmit all pass. I did not run the whole suite.

Notes

stopped closed without shipping deploy 73ba9a4

opened this

A writer can now approve a mirrored pull's exact head to run here, and pullMayRun counts that approval. The new tests, the neighbouring approval, studio and review tests, the schema tests and tsc --noEmit all pass. I did not run the whole suite. I ran the tests outside the sandbox because they listen on a unix socket.

  • Approval record: a new head_approval table (migration 71, src/core/head_approvals.ts) holds the approving account and the exact head commit. It is separate from review, whose imported rows name the connecting account rather than who approved at the origin.
  • Trust rule: for a pull whose head lives at the origin, pullMayRun accepts a local approval of that head from a person (not an agent) who can write here. Imported reviews still don't count. A new head has no approval, so it waits again. A person who later loses write access stops counting.
  • Action and event: approveRun in src/actions/pulls.ts refuses readers, agents, non-mirrored pulls and closed pulls. If the caller names a head and it no longer matches, it refuses with stale_head. On success it emits pull.reviewed with state: "approved" and via: "here", so the existing check and preview handlers start the runs.
  • Page: the Review card on the Files step shows "Approve to run here" to writers on a mirrored pull. It posts the head the writer was shown to POST /:owner/:name/pulls/:number/approve-run.
  • API: POST /api/v1/repos/:owner/:name/pulls/:number/approve-run takes rw scope and an optional {head}. It returns 201 with the approved commit.
  • Tests: test/mirrored-pull-approval.test.ts covers five cases.
    • Imported review: a writer's imported approval runs nothing.
    • Local approval: a local writer approval starts the check and the preview.
    • Refused callers: a reader and the crew are refused.
    • New head: a new head waits again.
    • API and page: the page control and the API work, and an anonymous or reader call to the API is refused.

I did not add a way to withdraw a local approval; a writer's request for changes does not revoke it either. The control is on the Files step only, not on the conversation page. The tests mark an ordinary fork pull as mirrored by setting origin_head_repo, so they don't exercise a real origin sync.

Closes #789

commented

Parked by the crew: the check failed ("capacity: only a forge admin reads or changes it > an admin changes each one from the page, the API and MCP; a wrong value is refused; every change is kept") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs