Skip to content

fix(factory): defer startup exit recovery until adoption - #156

Merged
kjgbot merged 1 commit into
mainfrom
fix/defer-startup-exit-reconciliation
Jul 21, 2026
Merged

fix(factory): defer startup exit recovery until adoption#156
kjgbot merged 1 commit into
mainfrom
fix/defer-startup-exit-reconciliation

Conversation

@kjgbot

@kjgbot kjgbot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • collect synchronous fleet reconciliation exits during durable startup adoption
  • queue each collected exit only after every lifecycle has been restored into the batch
  • classify startup-reconciled remote exits so they recover an existing PR or restart instead of waiting forever for branch replication

Production evidence

Public SDK probes correctly reported the five slot-owning sessions absent from the online roster. Factory logged the reconciliation sweep but the async handlers disappeared before entering durable recovery, leaving the slots occupied.

Verification

  • npm run build
  • npm test (1,075 tests)
  • npm run featuremap:check
  • npm run verify:e2e (9/9 checks for f5dd326aa8a41f3e765558fa48e20b8aa4147c8f)

@kjgbot
kjgbot marked this pull request as ready for review July 21, 2026 00:55
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kjgbot, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 53 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a010dcd2-6a4e-414c-8041-f9499947b060

📥 Commits

Reviewing files that changed from the base of the PR and between f5dd326 and 182ced7.

📒 Files selected for processing (2)
  • src/orchestrator/factory.test.ts
  • src/orchestrator/factory.ts
📝 Walkthrough

Walkthrough

Changes

Startup roster reconciliation

Layer / File(s) Summary
Deferred exit capture and roster reconciliation
src/orchestrator/factory.ts
Startup exits are deferred into a signal set, durable agents missing from the online roster are identified, and reconciled-missing exits are queued without duplicating signalled exits.
Reconciliation exit behavior tests
src/orchestrator/factory.test.ts
Parameterized tests cover reconciled exit emission being enabled or disabled and validate terminal entries and synthesized-exit counters.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Broker
  participant FactoryLoop
  participant DurableRoster
  Broker->>FactoryLoop: signal agent exit during startup
  FactoryLoop->>FactoryLoop: defer exit in startupRosterExitSignals
  DurableRoster->>FactoryLoop: reconcile tracked agents
  FactoryLoop->>FactoryLoop: compute missing durable agents
  FactoryLoop->>FactoryLoop: queue reconciled-missing exits
Loading

Possibly related PRs

Suggested reviewers: khaliqgant, miyaontherelay

Poem

I’m a rabbit guarding the roster tonight,
I tucked exit signals out of sight.
Missing agents hop into line,
Duplicate trails are left behind.
Tests bloom in a parameterized row—
Reconciled exits now clearly show.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly matches the main change: deferring startup exit recovery until adoption completes.
Description check ✅ Passed The description is directly about the same startup exit recovery and durable adoption changes in the PR.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/defer-startup-exit-reconciliation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request defers fleet reconciliation exits until durable adoption is complete to prevent fast handlers from suppressing the authoritative roster fallback. It refactors the startup roster reconciliation logic in FactoryLoop to track and queue exits for all signalled agents, and updates the test suite to cover this deferred exit behavior. The review feedback recommends simplifying the agent filtering logic to avoid an intermediate array allocation and iterating over the signalled Set directly rather than using .keys() for cleaner, more idiomatic TypeScript.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/orchestrator/factory.ts Outdated
Comment thread src/orchestrator/factory.ts Outdated
@kjgbot
kjgbot force-pushed the fix/defer-startup-exit-reconciliation branch from f5dd326 to 182ced7 Compare July 21, 2026 01:02
@kjgbot
kjgbot merged commit 01be89c into main Jul 21, 2026
2 of 3 checks passed
@kjgbot
kjgbot deleted the fix/defer-startup-exit-reconciliation branch July 21, 2026 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant