fix(lifecycle): stop install fallback when cancellation races managed install#405
Conversation
… install When a managed install subprocess exits successfully but the CLI context is already cancelled, waitForSpawnedCommand reports failure. installAgent now rolls back the current method and stops instead of trying later install methods, preventing duplicate global installs. OpenSpec change: fix-install-cancel-method-fallback
ce3a126 to
4701dee
Compare
There was a problem hiding this comment.
PR Governance — #405
Verdict: Non-blocking governance pass. No approval. PR already reached merge delivery (79a26d4, merged by @Drswith).
OpenSpec intake
- Correct for observable lifecycle behavior change:
fix-install-cancel-method-fallbackcreated with proposal/design/spec delta/tasks beforesrc/edits. - Change correctly remains active until archive closure; Notes document the archive follow-up owner.
Validation
- Checklist matches the changed surface:
memory:check, lint, format, typecheck, and test forsrc/package-manager/behavior. - CI classified and ran the full matrix +
sandbox-tests; all checks green. No evidence of blind CI patching.
PR body / closure
- Template sections present;
validate-bodypassed in PR Governance workflow. - Release intent
patchis appropriate forfix(lifecycle):. - Closure check correctly marks OpenSpec active-by-design and delegates release to automation.
Non-blocking follow-ups
- Archive closure: Spec delta re-lists existing Windows/batch cancellation scenarios. Archive agent must merge additively into
openspec/specs/agent-update/spec.md(add only the new “Cancelled managed install does not fall through…” scenario). - Traceability: No linked GitHub issue for the regression context.
- Checklist gap:
bun run openspec:validateis in tasks but not the PR Validation checklist.
Remaining owners
- OpenSpec archive closure: archive follow-up PR for
fix-install-cancel-method-fallback - Release closure: release-please patch from merged
fix:commit
No reviewer request — maintainer-authored commit and self-merge.
Sent by Cursor Automation: Quantex CLI PR Governance
| - **THEN** it does not perform later update work for remaining agents in the same command | ||
| - **AND** it does not persist normal installed-agent state for the cancelled update operation | ||
|
|
||
| #### Scenario: Cancelled managed install does not fall through to later install methods |
There was a problem hiding this comment.
Non-blocking (archive): This delta re-lists existing Windows wrapper and batch cancellation scenarios. Archive closure must merge additively into openspec/specs/agent-update/spec.md — add only the new scenario at lines 32–40, do not replace or drop the existing requirement text.
| } | ||
| } | ||
|
|
||
| if (getCliContext().cancelled) { |
There was a problem hiding this comment.
Cancellation guard looks correct: loop-start check avoids work when already cancelled; post-executeMethod(false) rollback only runs when cancelled is set, so genuine method failures still fall through to later methods.


Summary
Fix a high-severity lifecycle bug where a cancelled managed install could fall through to the next install method without rolling back a package that had already been installed on disk.
When
waitForSpawnedCommand()reports failure because the CLI context is cancelled after a child exits0,installAgent()now rolls back the current managed method and stops instead of trying later install methods (for example npm after bun).Linked Artifacts
openspec/changes/fix-install-cancel-method-fallbackValidation
bun run memory:checkbun run lintbun run format:checkbun run typecheckbun run test(if behavior changed)Release Intent
Docs Updated
docs/...openspec/...Scope Check
Closure Check
Notes
Bug impact: Duplicate global installs and orphaned packages when install is cancelled by timeout or signal after the first managed method succeeds on disk.
Trigger scenario:
quantex install <agent> --timeout …or exec/shortcut install with timeout; bun (or other managed PM) completesadd -gwith exit0, then cancellation fires before Quantex records success.Root cause:
waitForSpawnedCommand()returns exit code1on cancellation even when the child exited0.installAgent()treated that as a failed method attempt and continued to the next install method without rollback.Fix: Guard each install-method iteration for cancellation; when
executeMethod()returnsfalseand the context is cancelled, roll back the current method and return failure.Remaining owner: Maintainer merge + release-please patch release; archive follow-up for
fix-install-cancel-method-fallbackafter merge.