diff --git a/AGENTS.md b/AGENTS.md index a935bcdd..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 @@ -32,25 +32,46 @@ 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 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.) + + 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`, 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 - 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 -- \ + ./rebase-and-hold.sh N # rebase and push if behind, then exec sleep 2400 ``` - `--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). -- **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.workflow_run`, which + also brings each check run, the `VisualCI` check's included. + + 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