From a3df6a970e4ee635514b98eb18b82f3719019392 Mon Sep 17 00:00:00 2001 From: Sambit Biswas Date: Sat, 26 Sep 2026 14:29:09 -0400 Subject: [PATCH] docs(agents): add PR, CI, and branch hygiene rules Codify lessons from the 0.50.0 merge campaign: merge main instead of force-pushing, green CI on the exact head, no cancelling main CI, a one-rerun limit for flaky specs, the known conflict hotspots (test chain, protocol revision, vendored advisor sources), and stacked-PR base branches that GitHub closes when deleted. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GAkZRgQzUoKWGpgupF3a4D --- .memory/ci-merge-hygiene-20260926.md | 11 +++++++++++ AGENTS.md | 14 ++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 .memory/ci-merge-hygiene-20260926.md diff --git a/.memory/ci-merge-hygiene-20260926.md b/.memory/ci-merge-hygiene-20260926.md new file mode 100644 index 0000000000..1616bc8033 --- /dev/null +++ b/.memory/ci-merge-hygiene-20260926.md @@ -0,0 +1,11 @@ +# CI and merge hygiene (2026-09-26) + +Lessons from the 0.50.0 merge-and-release campaign (about 30 PRs merged one after another): + +- Merging PRs one at a time forced a "merge main, rerun CI" loop for every PR. The recurring conflict hotspots were the root `package.json` `test` chain, the Aiden Remote protocol revision (#121 was renumbered to revision 15 after #251), and the vendored advisor sources in `packages/cli/src/vendor/advisor/`. +- Flaky e2e specs (Simulator tab focus, assistant-scheduled-profile click) failed runs under `--fail-on-flaky-tests` and needed manual reruns. +- Deleting merged branches by hand closed stacked PRs #220 and #223, because GitHub closes a PR when its base branch is deleted. Both were restored and reopened. +- The repo setting `delete_branch_on_merge` was turned on 2026-09-26; before that, about 130 merged branches had accumulated. +- A pending macOS SecurityAgent prompt stalled local simulator XCTest, so #255's iOS tests ran only as a CI compile. + +Agent rules derived from this live in AGENTS.md under "Pull requests, CI, and branches". Owner-side follow-ups that were suggested but not yet done: a merge queue with a protected `main`, quarantining the flaky specs, path-filtered CI jobs, workflow concurrency cancellation for PR runs, automated version bumps (release-please or changesets), and running iOS simulator tests on hosted macOS runners. diff --git a/AGENTS.md b/AGENTS.md index ba4e6a0868..c5a920c93e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -43,6 +43,20 @@ The headless Aiden Agent lives in `packages/cli` as a self-contained npm package For complex workflows, record concise implementation friction in `.papercuts/troubleshooting.md` as it occurs. +## Pull requests, CI, and branches + +- Update a shared PR branch by merging `origin/main` into it. Do not rebase or force-push a branch that already has a PR, reviews, or CI history. +- Before requesting bot reviews or waiting on hosted CI, run the narrow suites for the touched surfaces locally. Hosted CI and review bots should not be the first place a failure shows up. +- Treat a PR as mergeable only when CI is green on its exact head commit. After merging `main` in, wait for the new run; do not merge on an earlier head's result. +- Do not cancel CI runs on `main`. Main CI is the baseline every release is cut from. +- Flaky tests: a failure that passes on rerun is still a bug. Rerun failed jobs at most once, then record the spec, the symptom, and the run link in `.papercuts/troubleshooting.md`. Do not paper over it by raising timeouts, adding retries, or weakening `--fail-on-flaky-tests`. +- Known merge-conflict hotspots need a recheck after every `main` merge: + - the root `package.json` `test` chain. Append new scripts and resolve conflicts by union, keeping every script from both sides. + - the Aiden Remote protocol revision. Claim the next revision after the one on `main` when the PR merges, not when it was written, and update the iOS, Android, and fixture contracts together. + - the vendored advisor sources under `packages/cli/src/vendor/advisor/`. When one of their `main/services/` originals changes, re-vendor the copy (keep its header comment) in the same PR; `packages/cli/tests/extensions.test.mjs` fails on drift. +- Stacked PRs: GitHub closes any open PR whose base branch is deleted. Before deleting a branch by hand, check that no open PR uses it as `baseRefName` as well as `headRefName`. Merged branches are deleted automatically on merge, and GitHub retargets their stacked PRs. +- Never delete a branch or worktree that holds uncommitted or unpushed work. Check `git status` and that the tip is on a remote first. + ## Tests When adding a feature or changing behavior, layout, configuration, or contracts, always check whether existing tests need updating and add or extend tests when coverage is missing. Run the relevant suites before finishing (`npm run test`, or the narrower scripts in `package.json` when the change is scoped). If a new test file is added, register it in the appropriate `package.json` test script so CI picks it up.