From 6dae0c99ba88cef768038daab67ea6c705d37f15 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 5 Dec 2026 11:49:21 +0000 Subject: [PATCH 1/7] AGENTS.md: take the merge lock only for a green, approved PR, and hold it through one CI run (sc-9611) --- AGENTS.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index a935bcdd..657bd0de 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -32,6 +32,12 @@ design is in `docs/design.md`; read it before changing the architecture, and upd - **Hold the merge lock from the final rebase to the merge.** A PR must be up to date with `main` before it merges, so a merge by one agent sends every other agent's PR back through CI. Take Fleetlayer's lock, one per repository, around the last rebase, the CI run and the merge, in one script, and only for one PR at a time: + - Take it only when the PR is already green and approved (its VisualCI builds reviewed); never to wait for a review + or a fix. + - Rebase onto `main` if it's behind and push, then hold the lock through that one CI run. + - Merge if it's green. If it's red, release the lock at once and fix it outside the lock. + - Never hold it across a second run. (5 Dec 2026: a lock held for two hours while a PR stayed red stopped every + other merge.) ```sh id=$(fleetlayer lease acquire main-merge --payload '{"repo":"DocSpring/visualci"}' --reason "merge PR #N" \ From 88a46e355b1d13a23eefe344789ecca1741ba6e3 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 5 Dec 2026 13:10:17 +0000 Subject: [PATCH 2/7] AGENTS.md: take main-merge only with fleetlayer lease run around the merge script, never a bare lease acquire (sc-9611) --- AGENTS.md | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 657bd0de..b441a65d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -39,17 +39,22 @@ design is in `docs/design.md`; read it before changing the architecture, and upd - Never hold it across a second run. (5 Dec 2026: a lock held for two hours while a PR stayed red stopped every other merge.) + Take it only with `fleetlayer lease run`, around a script that does the rest, which releases it on every exit + (merged, red, conflict, killed), never with a bare `lease acquire`: a lock that expires unreleased pages Fleetlayer + for 30 minutes (4 and 5 Dec 2026, one a day). There is no shared merge script: each session keeps its own, in this + shape: + ```sh - id=$(fleetlayer lease acquire main-merge --payload '{"repo":"DocSpring/visualci"}' --reason "merge PR #N" \ - --pid $$ --wait --json | jq -r .id | tail -1) - trap 'fleetlayer lease release "$id"' EXIT - # rebase onto origin/main, push, wait for the checks (with a timeout), then until - # `gh pr view N --json mergeStateStatus -q .mergeStateStatus` is CLEAN, then gh pr merge N --squash --delete-branch + fleetlayer lease run main-merge --payload '{"repo":"DocSpring/visualci"}' --reason "merge PR #N" --ttl 40m -- \ + ./my-merge.sh N + # my-merge.sh: rebase onto origin/main and push if behind; wait for that CI run (with a timeout); merge with + # gh pr merge N --squash --delete-branch once `gh pr view N --json mergeStateStatus -q .mergeStateStatus` is CLEAN, + # or exit at once on a red check or a conflict (git rebase --abort) ``` - `--pid $$` ties the lock to the script, so it outlives an idle session and is freed when the script ends. (3 Dec - 2026: two agents' merges kept making each other's green PRs out of date.) Wait for CLEAN, not for the CI jobs: the - VisualCI check posts a few seconds after the `visual` job ends, and a merge in that gap is refused (4 Dec 2026). + (3 Dec 2026: two agents' merges kept making each other's green PRs out of date.) Wait for CLEAN, not for the CI + jobs: the VisualCI check posts a few seconds after the `visual` job ends, and a merge in that gap is refused (4 Dec + 2026). - **Wait on CI without polling GitHub hard.** Every agent's `gh` shares Nathan's one GitHub account and its 5,000 API calls an hour; on 4 Dec 2026 polling used them up and blocked a merge. Fleetlayer receives this repository's CI results, so wait on those, at no API cost: after a push, `fleetlayer subscribe ci --commit` in the checkout (each From 2b7f5bd11b74de5f0b82e8b323a409ba86d7d145 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 5 Dec 2026 13:51:08 +0000 Subject: [PATCH 3/7] AGENTS.md: the merge lock's command only rebases and holds; wait on Fleetlayer's CI messages, never a gh polling loop (sc-9611) --- AGENTS.md | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index b441a65d..df75e457 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -39,29 +39,31 @@ design is in `docs/design.md`; read it before changing the architecture, and upd - Never hold it across a second run. (5 Dec 2026: a lock held for two hours while a PR stayed red stopped every other merge.) - Take it only with `fleetlayer lease run`, around a script that does the rest, which releases it on every exit - (merged, red, conflict, killed), never with a bare `lease acquire`: a lock that expires unreleased pages Fleetlayer - for 30 minutes (4 and 5 Dec 2026, one a day). There is no shared merge script: each session keeps its own, in this - shape: + Take it only with `fleetlayer lease run`, never a bare `lease acquire`: it releases the lock however the command + ends, while a lock that expires unreleased pages Fleetlayer for 30 minutes (4 and 5 Dec 2026, one a day). The + command rebases onto `origin/main` and pushes if the PR is behind (`git rebase --abort` and exit on a conflict), then + only holds the lock (`sleep`, within `--ttl`); it never polls GitHub. Your session does the rest, woken by + Fleetlayer's messages: on a red result, `fleetlayer lease release ` at once; on green, merge with + `gh pr merge N --squash --delete-branch`, then release. There is no shared merge script: each session keeps its own. ```sh fleetlayer lease run main-merge --payload '{"repo":"DocSpring/visualci"}' --reason "merge PR #N" --ttl 40m -- \ - ./my-merge.sh N - # my-merge.sh: rebase onto origin/main and push if behind; wait for that CI run (with a timeout); merge with - # gh pr merge N --squash --delete-branch once `gh pr view N --json mergeStateStatus -q .mergeStateStatus` is CLEAN, - # or exit at once on a red check or a conflict (git rebase --abort) + ./rebase-and-hold.sh N # rebase and push if behind, then exec sleep 2400 ``` - (3 Dec 2026: two agents' merges kept making each other's green PRs out of date.) Wait for CLEAN, not for the CI - jobs: the VisualCI check posts a few seconds after the `visual` job ends, and a merge in that gap is refused (4 Dec - 2026). -- **Wait on CI without polling GitHub hard.** Every agent's `gh` shares Nathan's one GitHub account and its 5,000 API - calls an hour; on 4 Dec 2026 polling used them up and blocked a merge. Fleetlayer receives this repository's CI - results, so wait on those, at no API cost: after a push, `fleetlayer subscribe ci --commit` in the checkout (each - workflow's result arrives as a message; it ends by itself and says so if nothing came in 45 minutes), or to be told - once, `fleetlayer watch ci --subject DocSpring/visualci@ --kind github.workflow_run --for 1h`. If you must - poll, `gh run view --json status,conclusion` every few minutes with a timeout, never `gh run watch` with its - default 3-second interval (it also fetches the jobs each time). `gh pr checks --watch --interval 60` is fine. + (3 Dec 2026: two agents' merges kept making each other's green PRs out of date.) The VisualCI check posts after the + `visual` job ends, and a merge before it does is refused (4 Dec 2026). +- **Wait on CI through Fleetlayer's messages; never poll GitHub.** Every agent's `gh` shares Nathan's one GitHub + account and its 5,000 API calls an hour, and on 4 Dec 2026 polling used them up and blocked every session's `gh`. + No `gh run watch`, `gh pr checks --watch` or loop of `gh` calls, however slow. Fleetlayer delivers this repository's + CI results as messages, at no API cost: + - after a push, `fleetlayer subscribe ci --commit` in the checkout: each workflow's result arrives as a message; + the subscription ends by itself, and says so if nothing came within 45 minutes; + - for a PR you're merging, `fleetlayer subscribe ci --branch --kind + github.check_run,github.check_suite,github.workflow_run`, which also brings the VisualCI check. + + When the `CI` run's message arrives, one `gh pr view N --json mergeStateStatus` is allowed, and one more five + minutes later if the VisualCI check hadn't posted yet. No more than that. - A change people using VisualCI can see (a feature, a fix they'd notice, a CLI release, a setting, a price) gets a changelog entry in the same PR: its own file in `frontend/content/changelog/`, which `node scripts/changelog-entry.mjs ""` (in `frontend`) names with New Zealand's date and time. The build From ccc44a548a104ba73ea6b045190d586520bf3ede Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 5 Dec 2026 14:24:48 +0000 Subject: [PATCH 4/7] AGENTS.md: VisualCI's check suite arrives, its check runs don't; don't merge on the suite alone (sc-9611) --- AGENTS.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index df75e457..4cd29415 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -59,8 +59,9 @@ design is in `docs/design.md`; read it before changing the architecture, and upd CI results as messages, at no API cost: - after a push, `fleetlayer subscribe ci --commit` in the checkout: each workflow's result arrives as a message; the subscription ends by itself, and says so if nothing came within 45 minutes; - - for a PR you're merging, `fleetlayer subscribe ci --branch --kind - github.check_run,github.check_suite,github.workflow_run`, which also brings the VisualCI check. + - for a PR you're merging, `fleetlayer subscribe ci --branch` also brings VisualCI's check suite completing. It + can arrive before the last build's check has posted, and check runs themselves don't arrive (5 Dec 2026), so + don't merge on it alone. When the `CI` run's message arrives, one `gh pr view N --json mergeStateStatus` is allowed, and one more five minutes later if the VisualCI check hadn't posted yet. No more than that. From a5b3d8652cfb3a7028ada0a525d52a51dd1391f8 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 5 Dec 2026 14:35:11 +0000 Subject: [PATCH 5/7] AGENTS.md: wake on the VisualCI check run, which Fleetlayer now delivers (sc-9611) --- AGENTS.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 4cd29415..fba9ed23 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -59,12 +59,12 @@ design is in `docs/design.md`; read it before changing the architecture, and upd CI results as messages, at no API cost: - after a push, `fleetlayer subscribe ci --commit` in the checkout: each workflow's result arrives as a message; the subscription ends by itself, and says so if nothing came within 45 minutes; - - for a PR you're merging, `fleetlayer subscribe ci --branch` also brings VisualCI's check suite completing. It - can arrive before the last build's check has posted, and check runs themselves don't arrive (5 Dec 2026), so - don't merge on it alone. + - for a PR you're merging, `fleetlayer subscribe ci --branch --kind github.check_run,github.workflow_run`, which + also brings each check run, the `VisualCI` check's included. - When the `CI` run's message arrives, one `gh pr view N --json mergeStateStatus` is allowed, and one more five - minutes later if the VisualCI check hadn't posted yet. No more than that. + When the `VisualCI` check run completes (it posts after the `CI` run's jobs), one + `gh pr view N --json mergeStateStatus` and, if it's CLEAN, the merge. Don't merge on VisualCI's check suite + completing: it can arrive before the last build's check has posted. - A change people using VisualCI can see (a feature, a fix they'd notice, a CLI release, a setting, a price) gets a changelog entry in the same PR: its own file in `frontend/content/changelog/`, which `node scripts/changelog-entry.mjs ""` (in `frontend`) names with New Zealand's date and time. The build From 0202c0506e22a2cf9af9c9f85a11ca9ce96352de Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 5 Dec 2026 16:45:45 +0000 Subject: [PATCH 6/7] AGENTS.md: review the PR's VisualCI build before taking the merge lock, and the rebased build as soon as CI ends (sc-9611) --- AGENTS.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index fba9ed23..7865c034 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -32,9 +32,13 @@ design is in `docs/design.md`; read it before changing the architecture, and upd - **Hold the merge lock from the final rebase to the merge.** A PR must be up to date with `main` before it merges, so a merge by one agent sends every other agent's PR back through CI. Take Fleetlayer's lock, one per repository, around the last rebase, the CI run and the merge, in one script, and only for one PR at a time: - - Take it only when the PR is already green and approved (its VisualCI builds reviewed); never to wait for a review - or a fix. + - Take it only when the PR is already green and approved: its latest VisualCI builds reviewed, never to wait for a + review or a fix. - Rebase onto `main` if it's behind and push, then hold the lock through that one CI run. + - When that run's `CI` result arrives, look at the PR's VisualCI builds at once (VisualCI's MCP: `list_builds` with + `waiting_for_review`, or `whoami`) and review the rebased build then: the `VisualCI` check stays pending until it + is reviewed, and waiting on the check lets the lock run out (5 Dec 2026, #278). If the rebase brought changes + your PR didn't make (main's, inherited), release the lock and review them outside it. - Merge if it's green. If it's red, release the lock at once and fix it outside the lock. - Never hold it across a second run. (5 Dec 2026: a lock held for two hours while a PR stayed red stopped every other merge.) From 7304212051760b8c1eb46d07fa7bcfb008f8484c Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 5 Dec 2026 16:57:43 +0000 Subject: [PATCH 7/7] AGENTS.md: never --delete-branch; the repository deletes merged branches and moves stacked PRs onto main (sc-9611) --- AGENTS.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 7865c034..8ff29963 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,7 +11,7 @@ design is in `docs/design.md`; read it before changing the architecture, and upd `get_snapshot`; `contact_sheet` for many screenshots), the way our customers' agents do. 2. Approve changes the PR meant to make (`review`). Fix the code and push again for anything it didn't mean: a page that looks broken is a regression even when CI is green. - 3. Merge with `gh pr merge --squash --delete-branch` once every check is green. If GitHub refuses because VisualCI + 3. Merge with `gh pr merge --squash` once every check is green. If GitHub refuses because VisualCI is pending, that's the review you skipped. Never bypass the ruleset. (1 Dec 2026, unreviewed builds let a CSS break from three merges reach production.) - **Git hooks format your commits: install them once per clone** with `mise install && lefthook install` (the hooks @@ -48,7 +48,10 @@ design is in `docs/design.md`; read it before changing the architecture, and upd command rebases onto `origin/main` and pushes if the PR is behind (`git rebase --abort` and exit on a conflict), then only holds the lock (`sleep`, within `--ttl`); it never polls GitHub. Your session does the rest, woken by Fleetlayer's messages: on a red result, `fleetlayer lease release ` at once; on green, merge with - `gh pr merge N --squash --delete-branch`, then release. There is no shared merge script: each session keeps its own. + `gh pr merge N --squash`, then release. There is no shared merge script: each session keeps its own. + Never `--delete-branch`: the repository deletes a merged branch itself ("Automatically delete head branches"), and + then GitHub moves a PR stacked on it onto `main`; a branch the client deletes closes that PR instead (5 Dec 2026, + #259 closed when #257 merged). ```sh fleetlayer lease run main-merge --payload '{"repo":"DocSpring/visualci"}' --reason "merge PR #N" --ttl 40m -- \