AX notes · Incident

Every branch passed its AI review, and the merged code still had 12 defects

A branch review reads only its own diff. After merging parallel branches, run a separate review that reads only the merged code; ours confirmed 12 defects that per-branch review and CI had missed.

By Stephen Working with agents 10 min read Last updated

Many agents, one repository 5/6

Hand each feature to its own AI coding agent on its own branch, and every branch can pass review and tests while the places where they meet still disagree. In the early hours of October 10, 2026, after the 13 branches of AXFamily, a family calendar app we are building, were merged, review agents that read only the merged code confirmed 12 defects. Neither the existing tests nor git conflicts had shown any of them, and 10 turned out to be broken agreements between code written by two different packages.

Contents (11)
  1. From the 01:51 merges to the 05:34 PR merge
  2. The first assumption: green tests meant the integration was done
  3. 32 findings from six lenses; 12 survived refutation
  4. 10 of the 12 sat between two packages
  5. Each branch review read only its own diff
  6. The check we kept: a sorted-query-to-index table
  7. Other routes: a staging project, shared test vectors
  8. What a read-only review missed
  9. How to run integration review as its own step
  10. Next to check: server queries and gaps in the table
  11. FAQ

From the 01:51 merges to the 05:34 PR merge

The first parallel wave ran one workflow that put every package through the same steps: one agent implemented it, three agents reviewed the branch through security, cost and correctness lenses, and a fix agent addressed their findings and got the PR to green CI. How the 13 branches were merged is in Multiple Claude Code sessions: one owner per file.

Time (KST)What happened
01:51All 13 branches merged into the integration branch in just over two minutes
02:09Minimal fixes for 6 package pairs the merge broke
02:53 to 04:23Three wiring commits applying cross-package decisions: contract, then server, then app
04:29Six review agents start reading the merged code; done in 6 to 9 minutes
04:38Each of 12 blockers and majors goes to its own refuting agent; all 12 confirmed within a minute
05:28Fix commit: 115 files, 2,088 lines added
05:3411 CI jobs pass; integration PR merged

The first assumption: green tests meant the integration was done

The plan described the wave as "parallel feature work (separate files only)", and its conflict rules were written per shared file. The integration step was told to resolve conflicts keeping both sides' intent, run every suite, and fix integration breakage minimally.

The integration agent finished by that standard. Its PR reported five suites, 2,115 tests in all (977 of them Flutter tests, 5 Rules tests skipped), all passing. None of the 12 defects found later changed any of those numbers. They surfaced only in the review step that had been placed at the end of the workflow in advance.

32 findings from six lenses; 12 survived refutation

The six lenses were Firestore security rules (Rules) and contract, function security, cost, app security and privacy, app UX, and flow tracing, which followed the core flow in code from sign-in to account deletion. Of 32 findings, 20 were minor and 12 blocker or major. Two of the 12 were the same defect found from two sides, so there were 11 distinct defects.

Bar chart: blocker and major findings were 2 from Rules and contract, 2 from function security, 2 from app security and privacy, 4 from app UX, 2 from flow tracing and 0 from cost, 12 in all.
Five of the six lenses produced a blocker or major finding; the cost lens produced only minor ones.

The refutation prompt told each agent to read the code and try to break the finding, and to reject it unless the defect could be shown. Each refuter returned a verdict in 16 to 25 seconds, citing files and line numbers. On the missing index, the verdict even pointed out that other collections queried the same way already had their composite indexes.

10 of the 12 sat between two packages

Rewriting each confirmed defect as "which two pieces of code believed different things" gives the table below. The classification is ours, made while writing this note; app feature details are kept short.

Lens (severity)The two sidesThe mismatch
Rules and contract, function security (major, same defect twice)Rules vs. a function added during wiringRules let any adult in the household edit a field the function trusted as proof of consent eligibility
Rules and contract (major)Records screen query vs. index fileNo composite index for a sorted query
Function security (major)Revocation check vs. ownership transferRevocation re-evaluated against the revoker's current role, so a role change undid it
App security and privacy (major)Records cleanup vs. sign-out cleanup listCleanup never registered, so a failure was never retried
App security and privacy (major)Inside the share inboxCopied files left behind when the queue overflowed or got corrupted
App UX (blocker)Billing entry widget vs. family screenZero callers of the widget
App UX (major)Household deletion function vs. settings screenThe app never sent the cancel flag and read the cancelled reply as an error
App UX (major)UI spec vs. bottom action buttonButton on tabs the spec excluded, with the wrong label
App UX (major)Banner slot vs. screen state reportsOne failure blocked banners for the whole session (spec says per screen)
Flow tracing (blocker)App capture vs. AI extraction functionFor PDF sources the app sent image/webp; the server accepted only application/pdf
Flow tracing (major)Household picker vs. calendar screens and billingThe picker wrote a new key, the screens read an old key nothing wrote, billing used the first household

Only two stayed inside one package: the share inbox files and the bottom button. In the other 10, each side was correct on its own. In the PDF case, the app sent a first-page thumbnail exactly as its own code comment said, and the server counted pages from PDF bytes exactly as the contract said at the time.

Each branch review read only its own diff

The branch review prompt had each reviewer read git diff origin/develop...origin/<branch>. The index file was already on the development branch and the Rules package was changing it separately, but it never appeared in the diff of the agent reviewing the sorted query. The server check that accepts only PDFs was likewise outside the app capture reviewer's diff.

The billing package's review had already found one of these. Told to grep for production callers of every new API, it found that nothing called the billing entry widget, but rated it minor; a re-review just before integration raised it to major. The call belonged in the family screen file, which the file owner rules kept the billing side from touching, so the item went into the PR's "to align with other packages" section. The integration workflow's wiring list, though, had been fixed in its script before that re-review, and the item came back as a blocker in the integration review.

Tests ran per package against that package's own fakes and the Firestore emulator, which does not enforce composite indexes. The contract's query table listed a collection that the same document's required-index list left out. CI passed, and only production would have answered with FAILED_PRECONDITION. (It was caught before any production deploy.)

Agent-written comments and tests also hid mismatches. A comment in the calendar code said the active-household key was "written by the household switcher", but git grep found no code that wrote it. The bottom button test was named "on every tab", locking in a placement the spec had ruled out.

After merging parallel branches, run a review that reads only the merged code, however many branch reviews came before.

The check we kept: a sorted-query-to-index table

The fix commit added, for each defect, a test that fails on the old code; for the Rules, index and consent fixes the fix was actually reverted to watch the test fail (the technique is in Catch fake AI-written tests by deleting guards). Two fixes became checks for the next mismatch of the same kind.

For indexes, the Rules test suite gained a table of app queries that use orderBy. Each row names the app file, the query and the index it needs, and the test looks for that index in the index file. A final test compares how often orderBy: ' appears in app code, and in which files, with the table, so anyone adding a sorted query has to add a row first.

const count = (rel) => (readFileSync(resolve(appRoot, rel), 'utf8').match(/orderBy:\s*'/g) ?? []).length;
// …
expect(actual).toEqual(expected);
// fail if a file outside the table uses orderBy: '<field>'
const all = execSync(`grep -rlE "^\\s*orderBy: '" lib || true`, { cwd: appRoot, encoding: 'utf8' })
  .split('\n').filter(Boolean).map((f) => f.trim());
expect(all.sort()).toEqual(files.sort());

By October 13, three more app files with sorted queries had been added to the table. For household selection, the app session's current household became the single source of truth; with two or more households and no valid selection, the picker returns null instead of falling back to the first one.

Other routes: a staging project, shared test vectors

A real Firestore project would have exposed the missing index at once. The plan had postponed a staging project until after launch ("low benefit for the risk, one more place that can charge us"), and the device runs that morning used an emulator backend to keep costs at zero.

One method had already worked. The billing tests were written to read a shared vector file (expected answers for whether a subscription counts as active) that the billing server package would add, and skipped while it was missing. Right after the merge they ran and caught the app and server disagreeing on entitlement. Contracts without a vector file, like consent eligibility or household selection, were out of its reach.

What a read-only review missed

Three rounds of device E2E the same day found more runtime defects. One was a Firestore trigger that crashed without a default Admin app, and the fix report itself says the Android side got unit tests only. Why device checks run separately even after a review converges on zero is in AI code review: fix only what survives refutation.

Each finding got one refuter for 16 to 25 seconds, so 12 out of 12 surviving is not evidence that refutation can be dropped. And the app UX lens compared screens against a written UI spec; without one, that lens has nothing to compare against.

How to run integration review as its own step

  1. Collect every branch PR's "to align with other packages" list into the integration task list, and finalize the wiring list only after every branch review is done.
  2. Once everything is merged and green, hand the integration diff to one read-only agent per area. Ask for concrete defects with evidence only, each one challenged by the reviewer before it is reported.
    git diff --stat origin/develop...origin/<integration-branch>
  3. Count production callers for every new widget, function and parameter, excluding the file that defines it. Zero is a finding by itself.
    git grep -n "<NewWidget>(" -- <app source dir> ':!<defining file>'
  4. Send each blocker and major to a different agent to refute, and drop anything that cannot be shown.
  5. For each confirmed defect, add a test that fails on the old code, and revert the fix once to watch it fail.
  6. Turn each defect type into a check: a table check when both sides can be counted, like queries and indexes; a shared vector file read by both sides' tests when it is a decision rule.

Next to check: server queries and gaps in the table

The sorted-query table counts only the orderBy: ' string in app code. Server function queries were still added to the required index list by hand on October 13. Whether server queries can be counted the same way is the next thing to try.

FAQ

If every branch had an AI review, do I still need an integration review?

Yes. Every branch here was reviewed by three agents, and the merged code still had 12 blocker or major defects. A branch review reads only its own diff, so it misses the other side of a contract whenever that side is not in the diff.

Will Firestore emulator tests catch a missing composite index?

No. The emulator does not enforce composite indexes, so tests pass with the index missing. Add a static check that matches the app's sorted queries against the index file, or run the queries against a real project.

How long did the integration review take?

Review took 6 to 9 minutes and refutation under a minute; the fix took about 49 minutes to its commit and about 55 minutes to the PR merge. From the 01:51 merges to the 05:34 PR merge was 3 hours 43 minutes.

Sources: the app repository's git history, the integration and billing PR descriptions, the fix report, and the integration workflow script and run log (rechecked October 31, 2026). Times are KST.

This note is written from values SugarMount measured itself; an AI coding agent was used to draft it.

All AX notes