Office (3/5): merge from the Office — CI + diff summary, merge / request changes / close #308

Closed
opened 2026-10-28 17:25:37 +00:00 by ben · 5 comments
Owner

Slice 3 of 5 of the Office (Ben's ask 2026-10-26). Depends on the writes slice (and its ADR 0008 ruling).

What to build

The merge verb's actions for landing-pr / awaiting-merge items:

  • Merge — merges the item's agent PR through the Forgejo merge API with the viewer's token. Before offering it, show the PR's CI status and diff summary (files · +/−) and the evidence screenshots the PR carries (close-report already requires an image or a **Screenshots:** none — <reason> line). A PR whose checks are red or pending shows merge disabled with the reason.
  • Request changes — comment on the PR + the issue, re-arm the issue (ready-for-agent) so the worker revises.
  • Close — close the PR and the issue (wontfix) with a comment.

Rules

  • Respect each repo's policy: offer merge only where MERGE_AUTHORITY / landing-pr names a human merger (policy-lib.sh); never bypass branch protection; never remove landing-pr (only a human lifts it — the merge itself is that human act).
  • Same undo window, server re-read, and stale-state refusal as the writes slice.

Acceptance

  1. Fake-tracker server tests: merge with green checks; refusal on red/pending; refusal when the PR moved (head sha changed since the page painted); request-changes re-arms.
  2. Screenshot of a merge item with its CI + diff summary in the PR.
  3. Repo test loop green; journal entry.
Slice 3 of 5 of the Office (Ben's ask 2026-10-26). Depends on the writes slice (and its ADR 0008 ruling). ## What to build The **merge** verb's actions for `landing-pr` / `awaiting-merge` items: - **Merge** — merges the item's agent PR through the Forgejo merge API with the viewer's token. Before offering it, show the PR's CI status and diff summary (files · +/−) and the evidence screenshots the PR carries (close-report already requires an image or a `**Screenshots:** none — <reason>` line). A PR whose checks are red or pending shows merge disabled with the reason. - **Request changes** — comment on the PR + the issue, re-arm the issue (`ready-for-agent`) so the worker revises. - **Close** — close the PR and the issue (`wontfix`) with a comment. ## Rules - **Respect each repo's policy**: offer merge only where `MERGE_AUTHORITY` / `landing-pr` names a human merger (`policy-lib.sh`); never bypass branch protection; never remove `landing-pr` (only a human lifts it — the merge itself is that human act). - Same undo window, server re-read, and stale-state refusal as the writes slice. ## Acceptance 1. Fake-tracker server tests: merge with green checks; refusal on red/pending; refusal when the PR moved (head sha changed since the page painted); request-changes re-arms. 2. Screenshot of a merge item with its CI + diff summary in the PR. 3. Repo test loop green; journal entry.

swarm-claim host=matou-dev-server-01 run=26309
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=26309 (automated multi-host claim — lowest live claim id works this ticket)

⏩ independent reviewer for #308 — verdict unauthenticated

review JSON
{
  "verdict": "unauthenticated",
  "findings": []
}
:fast_forward: **independent reviewer** for #308 — verdict `unauthenticated` <details><summary>review JSON</summary> ```json { "verdict": "unauthenticated", "findings": [] } ``` </details>

close-report for #308 — status success

✅ close-report gates passed — every claim verified against the pushed worker branch sandcastle/worker/20261105-072852-43a339 (pre-land — the host promotes it to main only after its post-run verify, #193/#283); issue closed.

envelope
{
  "issue": 308,
  "status": "success",
  "commits": [
    "7b7724310e7c3f5b325c607a3c1da0d438934566"
  ],
  "changed_files": [
    "STATUS.md",
    "docs/journal/2026-11-05-308.md",
    "fleet-tui/floor/server/office-writes.js",
    "fleet-tui/floor/server/office-writes.test.js",
    "fleet-tui/floor/server/office.test.js",
    "fleet-tui/floor/server/server.js",
    "fleet-tui/floor/server/server.test.js",
    "fleet-tui/floor/web/office.js",
    "fleet-tui/floor/web/src/components/OfficeApp.vue",
    "fleet-tui/floor/web/src/composables/useOfficeWrites.js",
    "fleet-tui/floor/web/src/office.test.js",
    "fleet-tui/floor/web/src/styles/office.css"
  ],
  "tests": [
    {
      "command": "node --test server/*.test.js (in fleet-tui/floor)",
      "exit_code": 0
    },
    {
      "command": "npx vitest run (in fleet-tui/floor)",
      "exit_code": 0
    },
    {
      "command": "npx vite build (in fleet-tui/floor)",
      "exit_code": 0
    },
    {
      "command": "bash tests/floor-server-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/docs-budget-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash onboarding/tests/vendor-manifest-coverage-test.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "1. Fake-tracker server tests: merge on green, refusal on red/pending, refusal when PR head sha moved, request-changes re-arms": "server/office-writes.test.js (merge green->merge+comment no label write; red/pending->refused no merge; moved head->refused; request-changes comments issue+PR + re-arms keeping landing-pr; preview diff/CI/screenshots) and server/server.test.js end-to-end against the fake tracker ('Office merge verb (#308)' test: preview GET, green merge via the merge API with the viewer token, both refusals, the re-arm, tally). node --test server/*.test.js green (207).",
    "2. Screenshot of a merge item with its CI + diff summary in the PR": "The visible surface is proven by the vitest render test web/src/office.test.js ('the merge verb (#308)'): the PULL REQUEST panel shows 'checks: success', the diff summary '2 files · +12 -3' and the evidence screenshot <img>, the green merge button posts {pr, headSha}, and a pending PR disables merge with the reason. A pixel screenshot could not be captured in the authoring sandbox (headless Chromium downloads but its system libs are absent and install-deps needs root); same posture as #307. Journal records this.",
    "3. Repo test loop green; journal entry": "The offline loop passes except two pre-existing network-dependent suites (list-ready-tasks-test.sh, run-swarm-ready-list-test.sh) that fail identically on a clean tree (they hit a live tracker; GET /issues/308 -> http 404). floor-server-test.sh 7/7 (node suite + vitest + vite build). Journal entry docs/journal/2026-11-05-308.md added and STATUS.md row updated in this commit."
  },
  "summary": "Wired the Office merge verb: preview a landing-pr item's PR (CI + diff + screenshots), merge on green with the viewer token, request changes, or close the PR with the issue; never lifting landing-pr.",
  "blockers": []
}
**close-report** for #308 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against the pushed worker branch `sandcastle/worker/20261105-072852-43a339` (pre-land — the host promotes it to `main` only after its post-run verify, #193/#283); issue closed. <details><summary>envelope</summary> ```json { "issue": 308, "status": "success", "commits": [ "7b7724310e7c3f5b325c607a3c1da0d438934566" ], "changed_files": [ "STATUS.md", "docs/journal/2026-11-05-308.md", "fleet-tui/floor/server/office-writes.js", "fleet-tui/floor/server/office-writes.test.js", "fleet-tui/floor/server/office.test.js", "fleet-tui/floor/server/server.js", "fleet-tui/floor/server/server.test.js", "fleet-tui/floor/web/office.js", "fleet-tui/floor/web/src/components/OfficeApp.vue", "fleet-tui/floor/web/src/composables/useOfficeWrites.js", "fleet-tui/floor/web/src/office.test.js", "fleet-tui/floor/web/src/styles/office.css" ], "tests": [ { "command": "node --test server/*.test.js (in fleet-tui/floor)", "exit_code": 0 }, { "command": "npx vitest run (in fleet-tui/floor)", "exit_code": 0 }, { "command": "npx vite build (in fleet-tui/floor)", "exit_code": 0 }, { "command": "bash tests/floor-server-test.sh", "exit_code": 0 }, { "command": "bash tests/docs-budget-test.sh", "exit_code": 0 }, { "command": "bash onboarding/tests/vendor-manifest-coverage-test.sh", "exit_code": 0 } ], "criteria": { "1. Fake-tracker server tests: merge on green, refusal on red/pending, refusal when PR head sha moved, request-changes re-arms": "server/office-writes.test.js (merge green->merge+comment no label write; red/pending->refused no merge; moved head->refused; request-changes comments issue+PR + re-arms keeping landing-pr; preview diff/CI/screenshots) and server/server.test.js end-to-end against the fake tracker ('Office merge verb (#308)' test: preview GET, green merge via the merge API with the viewer token, both refusals, the re-arm, tally). node --test server/*.test.js green (207).", "2. Screenshot of a merge item with its CI + diff summary in the PR": "The visible surface is proven by the vitest render test web/src/office.test.js ('the merge verb (#308)'): the PULL REQUEST panel shows 'checks: success', the diff summary '2 files · +12 -3' and the evidence screenshot <img>, the green merge button posts {pr, headSha}, and a pending PR disables merge with the reason. A pixel screenshot could not be captured in the authoring sandbox (headless Chromium downloads but its system libs are absent and install-deps needs root); same posture as #307. Journal records this.", "3. Repo test loop green; journal entry": "The offline loop passes except two pre-existing network-dependent suites (list-ready-tasks-test.sh, run-swarm-ready-list-test.sh) that fail identically on a clean tree (they hit a live tracker; GET /issues/308 -> http 404). floor-server-test.sh 7/7 (node suite + vitest + vite build). Journal entry docs/journal/2026-11-05-308.md added and STATUS.md row updated in this commit." }, "summary": "Wired the Office merge verb: preview a landing-pr item's PR (CI + diff + screenshots), merge on green with the viewer token, request changes, or close the PR with the issue; never lifting landing-pr.", "blockers": [] } ``` </details>

🚨 Reopened — a push-mode close did NOT land on main (#283). close-report closed this issue against the pushed worker branch, but the host's post-run verify rolled the land back (the promote did not advance main (a no-op push to main)), so origin/main never carried the commits (7b7724310e7c3f5b325c607a3c1da0d438934566). The gates-passed comment above is therefore NOT true of main. Reopening and relabelling ready-for-session so the work is redone where it can land; the commits are parked on a rescue branch for triage (see this run's alarm).

:rotating_light: **Reopened — a push-mode close did NOT land on `main` (#283).** close-report closed this issue against the pushed worker branch, but the host's post-run verify rolled the land back (`the promote did not advance main (a no-op push to main)`), so `origin/main` never carried the commits (`7b7724310e7c3f5b325c607a3c1da0d438934566`). The gates-passed comment above is therefore NOT true of `main`. Reopening and relabelling `ready-for-session` so the work is redone where it can land; the commits are parked on a rescue branch for triage (see this run's alarm).

Ruled by agent under ADR 0174 — veto anytime. Slice 3 of 5 of the Office landed on main via push (host lands after verify).

What landed — the merge verb

8938e59 — the merge verb's three actions for a landing-pr / awaiting-merge Outbox item, all riding the writes slice's (#307) undo window, server re-read and stale-state refusal (ADR 0008 rules 3/4):

  • Merge — previews the agent PR (combined CI verdict · diff summary files · +/− · the evidence screenshots it carries — the close-report's ![…](url) images, or its **Screenshots:** none — <reason> line), then merges it through the Forgejo merge API (POST /pulls/<i>/merge) with the viewer's own token. A PR whose checks are red/pending, that is closed/conflicted, or whose head sha moved since the preview painted shows merge disabled with the reason — and is refused server-side the same way (the browser's view is never the only guard). Branch protection is the API's to enforce — never bypassed.
  • Request changes — comments on the PR and the issue, re-arms the issue ready-for-agent so the worker revises, and never removes landing-pr (only a human merge lifts it).
  • Close — closes the agent PR and the issue (wontfix) with a comment on both.

The PR index is resolved server-side from the collector's pr_url on the item's snapshot row — never a value the browser passes. Merge is offered only on a landing-pr item (the human-merger signal, MERGE_AUTHORITY=human / pr-mode); agent-after-green repos never carry landing-pr, so the Office never offers merge there.

Surface: server/office-writes.js (flushMerge, flushRequestChanges, the payload.pr close path, and the pure reads prIndexFromUrl / prEvidence / ciState / mergeBlockReason / mergePreview); server.js (five PR tracker methods, the GET …/pr preview route, a widened [a-z-]+ action regex); web/office.js (ACTION_WIRING wires merge + request changes); useOfficeWrites.js (preview() + the two new tally keys); OfficeApp.vue + office.css (the MERGE block, the canMerge gate, the m keystroke).

Acceptance — proof

  1. Fake-tracker server tests (server/server.test.js): a green merge calls /merge with the viewer token and sets the PR merged; refusal on red and on pending (no merge call); refusal when the PR moved (head sha changed since the preview); request-changes comments on PR + issue and re-arms ready-for-agent without lifting landing-pr. Units in server/office-writes.test.js (the pure reads, the four refusal paths, close-closes-PR, the preview).
  2. Merge-item CI + diff surface — no browser on the standing host (only happy-dom, no renderer), so a pixel screenshot could not be produced; instead the vitest DOM render (web/src/office.test.js) proves the surface paints. The rendered MERGE block reads: MERGE · checks success (2) · diff 3 files · +40 / −5 · screenshots shot 1 ↗, with all six Decide buttons enabled (merge / request changes / close / delegate / snooze / close as duplicate) under writes-on; a red preview disables merge with its reason while request-changes stays live. (Honest residue: a true pixel screenshot wants a browser this host lacks — filing no blocker, the render is the provable evidence for a vendor-excluded operator UI.)
  3. Repo test loop green: node --test server/*.test.js (205) + vitest run (49) + vite build; the offline bash harness suite passed; docs-budget-test.sh green. The pre-push gate re-ran the floor build + full suite before main accepted the push.

Journal: docs/journal/2026-11-05-308.md; STATUS.md dev-factory row updated (all five Office slices now landed). fleet-tui is vendor-excluded — reaches no consumer; it reaches the hosted floor at its next restart, with FLOOR_OFFICE_WRITES left off until you enable it.

Commit: 8938e59.

**Ruled by agent under ADR 0174 — veto anytime.** Slice 3 of 5 of the Office landed on `main` via push (host lands after verify). ## What landed — the merge verb `8938e59` — the **merge** verb's three actions for a `landing-pr` / `awaiting-merge` Outbox item, all riding the writes slice's (#307) undo window, server re-read and stale-state refusal (ADR 0008 rules 3/4): - **Merge** — previews the agent PR (combined CI verdict · diff summary `files · +/−` · the evidence screenshots it carries — the close-report's `![…](url)` images, or its `**Screenshots:** none — <reason>` line), then merges it through the Forgejo merge API (`POST /pulls/<i>/merge`) with the **viewer's own token**. A PR whose checks are red/pending, that is closed/conflicted, or whose **head sha moved** since the preview painted shows merge **disabled with the reason** — and is refused server-side the same way (the browser's view is never the only guard). Branch protection is the API's to enforce — never bypassed. - **Request changes** — comments on the PR **and** the issue, re-arms the issue `ready-for-agent` so the worker revises, and **never removes `landing-pr`** (only a human merge lifts it). - **Close** — closes the agent PR and the issue (`wontfix`) with a comment on both. The PR index is resolved server-side from the collector's `pr_url` on the item's snapshot row — never a value the browser passes. Merge is offered only on a `landing-pr` item (the human-merger signal, `MERGE_AUTHORITY=human` / pr-mode); `agent-after-green` repos never carry `landing-pr`, so the Office never offers merge there. **Surface:** `server/office-writes.js` (`flushMerge`, `flushRequestChanges`, the `payload.pr` close path, and the pure reads `prIndexFromUrl` / `prEvidence` / `ciState` / `mergeBlockReason` / `mergePreview`); `server.js` (five PR tracker methods, the `GET …/pr` preview route, a widened `[a-z-]+` action regex); `web/office.js` (`ACTION_WIRING` wires `merge` + `request changes`); `useOfficeWrites.js` (`preview()` + the two new tally keys); `OfficeApp.vue` + `office.css` (the MERGE block, the `canMerge` gate, the `m` keystroke). ## Acceptance — proof 1. **Fake-tracker server tests** (`server/server.test.js`): a green merge calls `/merge` with the viewer token and sets the PR `merged`; **refusal on red and on pending** (no merge call); **refusal when the PR moved** (head sha changed since the preview); **request-changes** comments on PR + issue and re-arms `ready-for-agent` without lifting `landing-pr`. Units in `server/office-writes.test.js` (the pure reads, the four refusal paths, close-closes-PR, the preview). 2. **Merge-item CI + diff surface** — no browser on the standing host (only `happy-dom`, no renderer), so a pixel screenshot could not be produced; instead the vitest DOM render (`web/src/office.test.js`) proves the surface paints. The rendered MERGE block reads: `MERGE · checks success (2) · diff 3 files · +40 / −5 · screenshots shot 1 ↗`, with all six Decide buttons enabled (merge / request changes / close / delegate / snooze / close as duplicate) under writes-on; a red preview disables merge with its reason while request-changes stays live. (Honest residue: a true pixel screenshot wants a browser this host lacks — filing no blocker, the render is the provable evidence for a vendor-excluded operator UI.) 3. **Repo test loop green:** `node --test server/*.test.js` (205) + `vitest run` (49) + `vite build`; the offline bash harness suite passed; `docs-budget-test.sh` green. The pre-push gate re-ran the floor build + full suite before `main` accepted the push. Journal: `docs/journal/2026-11-05-308.md`; `STATUS.md` dev-factory row updated (all five Office slices now landed). `fleet-tui` is vendor-excluded — reaches no consumer; it reaches the hosted floor at its next restart, with `FLOOR_OFFICE_WRITES` left **off** until you enable it. Commit: `8938e59`.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/dev-factory#308
No description provided.