V2FIX-12: ensure factory one-shot commands self-exit#267
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughAdds a FleetClient.dispose lifecycle method, implements idempotent disposal in InternalFleetClient (unsubscribes, rejects pending waits, optional driver disconnect), integrates disposal into runFleetCli and FactoryLoop.stop, and expands fakes/tests to cover disposal and partial-connect failure paths. ChangesFleet client lifecycle disposal
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed due to a network error. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/factory-sdk/src/cli/fleet.ts`:
- Around line 132-134: The finally block awaiting fleet?.dispose() can throw and
override runFleetCli()’s numeric exit-code behavior; wrap the dispose call in
its own try/catch so disposal errors are caught, logged (or written to stderr)
but not rethrown, ensuring runFleetCli() still returns the deterministic numeric
code from the main flow. Specifically, in the finally where you call await
fleet?.dispose(), change it to a guarded pattern: if (fleet) try { await
fleet.dispose() } catch (err) { /* log error via process.stderr or
processLogger.error but do not throw */ } so any dispose() failure won’t reject
runFleetCli().
In `@packages/factory-sdk/src/fleet/internal-fleet-client.ts`:
- Around line 238-240: The dispose() flow currently returns early but
`#ensureEventSubscription`() can still reattach listeners later; modify dispose()
(method dispose) to set this.#disposed = true immediately at the start and
ensure it removes/cleans up listeners, and update `#ensureEventSubscription`() to
check this.#disposed and no-op if true so methods like waitForInjected,
onAgentExit, and onDeliveryFailed cannot recreate subscriptions after disposal;
apply the same guard to any other subscription-creation helpers referenced in
the same block (the code around the existing subscription setup in
ensureEventSubscription and the event-handler registration paths).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4fd20b9d-f915-4c86-a30b-2ccde2ec6b09
📒 Files selected for processing (8)
packages/factory-sdk/src/cli/fleet.test.tspackages/factory-sdk/src/cli/fleet.tspackages/factory-sdk/src/fleet/internal-fleet-client.test.tspackages/factory-sdk/src/fleet/internal-fleet-client.tspackages/factory-sdk/src/fleet/relay-fleet-client.tspackages/factory-sdk/src/orchestrator/factory.tspackages/factory-sdk/src/ports/fleet.tspackages/factory-sdk/src/testing/fakes.ts
|
Implemented two fixes from CodeRabbit and verified them locally. Changes:
Addressed comments
Advisory NotesNone. VerificationPassed locally:
The first parallel Playwright/build attempt hit local resource pressure, but the same commands passed when rerun sequentially. |
cfb87ed to
95fb9f4
Compare
|
Implemented one additional fix in the PR scope:
Added a regression using Addressed comments
Advisory NotesNone. Local VerificationRan successfully:
|
Summary
factory reap-orphansbypass mount/factory construction so the scheduled reaper uses only local registry/heartbeat state plus the local broker fleetV0 coverage
disconnect(), clears pending wait timers, and is idempotentcloudMountFromConfig/ build a mount and still disposes the fleetVerification
npx vitest run packages/factory-sdk/src/fleet/internal-fleet-client.test.ts packages/factory-sdk/src/cli/fleet.test.tsnpx vitest run packages/factory-sdknpm run typecheck:node -- --pretty falsenpm run typecheck:web -- --pretty falsegit diff --checkV1 scope
fv2 should prove the operator artifact with real-fleet
factory reap-orphansin a tight loop: exit 0 every invocation, zero hung node processes, broker/roster untouched. This PR makes that V1 cloud-independent by keeping reap-orphans off the cloud mount path.