Skip to content

fix(lifecycle): stop install fallback when cancellation races managed install#405

Merged
Drswith merged 1 commit into
mainfrom
cursor/critical-quantex-cli-bugs-a679
Jul 3, 2026
Merged

fix(lifecycle): stop install fallback when cancellation races managed install#405
Drswith merged 1 commit into
mainfrom
cursor/critical-quantex-cli-bugs-a679

Conversation

@cursor

@cursor cursor Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

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 exits 0, installAgent() now rolls back the current managed method and stops instead of trying later install methods (for example npm after bun).

Linked Artifacts

  • Issue:
  • ADR:
  • OpenSpec: openspec/changes/fix-install-cancel-method-fallback
  • Discussion:

Validation

  • bun run memory:check
  • bun run lint
  • bun run format:check
  • bun run typecheck
  • bun run test (if behavior changed)
  • Not run, explained below

Release Intent

  • Release: patch - bug fix

Docs Updated

  • Not needed
  • docs/...
  • openspec/...
  • Follow-up issue or OpenSpec change created instead

Scope Check

  • I did not add a new ad hoc root-level Markdown file.
  • I updated the relevant issue, ADR, spec, runbook, or captured the missing doc work as follow-up.
  • I did not silently expand project scope without recording it explicitly.

Closure Check

  • Working tree was clean after commit.
  • Branch was pushed and this PR is the active delivery artifact.
  • OpenSpec change is not needed, still active by design until merge, already archived, or queued for agent-driven archive closure.
  • Release is not applicable, delegated to release automation, or verified.

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) completes add -g with exit 0, then cancellation fires before Quantex records success.

Root cause: waitForSpawnedCommand() returns exit code 1 on cancellation even when the child exited 0. 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() returns false and 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-fallback after merge.

Open in Web View Automation 

… 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
@Drswith Drswith force-pushed the cursor/critical-quantex-cli-bugs-a679 branch from ce3a126 to 4701dee Compare July 3, 2026 02:33
@Drswith Drswith marked this pull request as ready for review July 3, 2026 02:35
@Drswith Drswith merged commit 79a26d4 into main Jul 3, 2026
10 checks passed
@Drswith Drswith deleted the cursor/critical-quantex-cli-bugs-a679 branch July 3, 2026 02:35

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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-fallback created with proposal/design/spec delta/tasks before src/ 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 for src/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-body passed in PR Governance workflow.
  • Release intent patch is appropriate for fix(lifecycle):.
  • Closure check correctly marks OpenSpec active-by-design and delegates release to automation.

Non-blocking follow-ups

  1. 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).
  2. Traceability: No linked GitHub issue for the regression context.
  3. Checklist gap: bun run openspec:validate is 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.

Open in Web View Automation 

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

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