fix(FN-5994): prevent verification hangs#1518
Conversation
Normalize package file-filter verification to direct Vitest execution, kill timed-out process groups, and bound loop-recovery compaction so stuck tasks cannot spin indefinitely. Fusion-Task-Id: FN-5994
📝 WalkthroughWalkthroughThis PR normalizes package-scoped test commands to direct Vitest invocations, hardens verification process termination with escalation timers and process-group signaling, caps loop-compaction recovery with a timeout and session validation, and prevents duplicate stuck-task recovery callbacks while pending. ChangesTask execution resilience and verification improvements
Sequence Diagram(s)No sequence diagram generated: the PR contains multiple independent subsystems (command normalization, process management, loop recovery state tracking) with no single linear flow that benefits from a unified sequence diagram. Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 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)
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 |
Greptile SummaryThis PR addresses verification hangs and loop-recovery race conditions in the Fusion engine by rewriting
Confidence Score: 5/5Safe to merge — all three concurrency and timeout fixes are well-scoped with correct reset paths, the new tests cover the timer-race and process-group kill logic, and the workflow ID rename is already matched by the reliability test update. The three main changes — moving recoveryInProgress assignment before the async await, bounding compaction with a 60 s race plus abort() call, and switching to process-group kill with detached: true — are each isolated and straightforward. The command normalizer is purely additive with comprehensive unit tests. No silent state corruption, no missing cleanup path, and no auth or data-integrity boundary is touched. No files require special attention. Important Files Changed
Reviews (2): Last reviewed commit: "fix(FN-5994): address verification revie..." | Re-trigger Greptile |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/engine/src/__tests__/run-verification-command.test.ts (1)
27-28: ReworkworkspaceRootto avoid relying onprocess.cwd()
workspaceRoot = join(process.cwd(), "../..")is correct for the normal pnpm flow becausepnpm --filter@fusion/engine...runs the package scripts with that package as the working directory, so../..resolves to the repo root. The assumption breaks ifvitestis invoked directly from another cwd (e.g., repo root) with a different invocation/config.const workspaceRoot = join(process.cwd(), "../..");Prefer deriving the root from the test file location (e.g.,
fileURLToPath(new URL("../../..", import.meta.url))/path.resolve) to make the test robust to invocation cwd.🤖 Prompt for 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. In `@packages/engine/src/__tests__/run-verification-command.test.ts` around lines 27 - 28, The test's workspaceRoot variable (const workspaceRoot = join(process.cwd(), "../..")) depends on the current working directory; change it to compute the repo root from the test file location instead (use fileURLToPath(new URL(..., import.meta.url)) or path.resolve against import.meta.url) so the value is stable regardless of how Vitest is invoked; update the workspaceRoot assignment in run-verification-command.test.ts (and remove reliance on process.cwd()) and keep using the existing workspaceRoot symbol everywhere it is referenced.
🤖 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.
Nitpick comments:
In `@packages/engine/src/__tests__/run-verification-command.test.ts`:
- Around line 27-28: The test's workspaceRoot variable (const workspaceRoot =
join(process.cwd(), "../..")) depends on the current working directory; change
it to compute the repo root from the test file location instead (use
fileURLToPath(new URL(..., import.meta.url)) or path.resolve against
import.meta.url) so the value is stable regardless of how Vitest is invoked;
update the workspaceRoot assignment in run-verification-command.test.ts (and
remove reliance on process.cwd()) and keep using the existing workspaceRoot
symbol everywhere it is referenced.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 014b0b84-ac44-49dd-b1b8-b1a327d8c2b7
📒 Files selected for processing (8)
packages/core/src/agent-prompts.tspackages/engine/src/__tests__/executor-step-session.test.tspackages/engine/src/__tests__/run-verification-command.test.tspackages/engine/src/__tests__/stuck-task-detector.test.tspackages/engine/src/executor.tspackages/engine/src/run-verification-tool.tspackages/engine/src/stuck-task-detector.tspackages/engine/src/workflow-authoritative-driver.ts
👮 Files not reviewed due to content moderation or server errors (1)
- packages/engine/src/executor.ts
Harden command normalization edge cases and abort loop compaction on timeout before falling through to stuck-task requeue. Fusion-Task-Id: FN-5994
Addressed: the normalization test now derives the workspace root from
Addressed: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/engine/src/__tests__/run-verification-command.test.ts (1)
29-84: 💤 Low valueConsider adding test coverage for package-not-found case.
The normalization logic guards against non-existent packages by checking
findWorkspacePackageDirand returning the command unchanged if null. Adding a test with a non-existent package name (e.g.,@fusion/does-not-exist) would verify this guard works correctly.🧪 Suggested test case
it("leaves command unchanged when package directory cannot be found", () => { const command = "pnpm --filter `@fusion/does-not-exist` test -- --run packages/nonexistent/test.ts"; expect(normalizeVerificationCommand(command, workspaceRoot)).toEqual({ command, warnings: [] }); });🤖 Prompt for 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. In `@packages/engine/src/__tests__/run-verification-command.test.ts` around lines 29 - 84, Add a test to packages/engine/src/__tests__/run-verification-command.test.ts that exercises the guard in normalizeVerificationCommand when findWorkspacePackageDir cannot locate a package: call normalizeVerificationCommand with a command like "pnpm --filter `@fusion/does-not-exist` test -- --run packages/nonexistent/test.ts" (using the existing workspaceRoot) and assert the result equals { command, warnings: [] } to ensure the command is left unchanged and no warnings are emitted.
🤖 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.
Nitpick comments:
In `@packages/engine/src/__tests__/run-verification-command.test.ts`:
- Around line 29-84: Add a test to
packages/engine/src/__tests__/run-verification-command.test.ts that exercises
the guard in normalizeVerificationCommand when findWorkspacePackageDir cannot
locate a package: call normalizeVerificationCommand with a command like "pnpm
--filter `@fusion/does-not-exist` test -- --run packages/nonexistent/test.ts"
(using the existing workspaceRoot) and assert the result equals { command,
warnings: [] } to ensure the command is left unchanged and no warnings are
emitted.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 394e88a3-7eb9-4a09-9352-de6e22da73be
📒 Files selected for processing (4)
packages/engine/src/__tests__/executor-step-session.test.tspackages/engine/src/__tests__/run-verification-command.test.tspackages/engine/src/executor.tspackages/engine/src/run-verification-tool.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- packages/engine/src/executor.ts
- packages/engine/src/tests/executor-step-session.test.ts
- packages/engine/src/run-verification-tool.ts
Summary
test -- --runfile filters infn_run_verificationto direct Vitest execution so package scripts do not expand into broad suites firstVerification
pnpm --filter @fusion/engine exec vitest run --project engine-default src/__tests__/run-verification-command.test.ts src/__tests__/stuck-task-detector.test.ts src/__tests__/executor-step-session.test.ts --silent=passed-only --reporter=dotpnpm --filter @fusion/engine exec vitest run --project engine-reliability src/__tests__/reliability-interactions/workflow-interpreter-cutover.test.ts --silent=passed-only --reporter=dotpnpm --filter @fusion/engine typecheckpnpm --filter @fusion/core typecheckpnpm --filter @fusion/engine test:coretimeout 360s pnpm --filter @fusion/engine testpnpm exec eslint packages/core/src/agent-prompts.ts packages/engine/src/executor.ts packages/engine/src/workflow-authoritative-driver.ts packages/engine/src/run-verification-tool.ts packages/engine/src/stuck-task-detector.tsgit diff --checkSummary by CodeRabbit