Skip to content

fix(lifecycle): recover uninstall ghost state when package is absent#396

Merged
Drswith merged 1 commit into
mainfrom
cursor/critical-quantex-cli-bugs-ea3b
Jun 30, 2026
Merged

fix(lifecycle): recover uninstall ghost state when package is absent#396
Drswith merged 1 commit into
mainfrom
cursor/critical-quantex-cli-bugs-ea3b

Conversation

@cursor

@cursor cursor Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix uninstall ghost state: when a managed package is already removed from disk but Quantex still records install state, retrying quantex uninstall now clears the stale state entry after confirming package absence.

Linked Artifacts

  • Issue: none; Draft bug report was reproduced on current origin/main
  • ADR:
  • OpenSpec: openspec/changes/fix-uninstall-ghost-state
  • 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

  • openspec/...

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 still active by design until merge.
  • Release is delegated to release automation.

Notes

Draft validation: applying the PR regression test only to current origin/main reproduced the bug: uninstallAgent() returned false when managed uninstall failed but getInstalledVersion() confirmed the package was absent.

Bug impact: permanent ghost install state blocks update --all, uninstall, and doctor until manual state.json edits.

Trigger scenario: managed package removal succeeds but removeInstalledAgentState() fails. A retry calls package-manager uninstall again, gets false because the package is already gone, and previously never cleared state.

Root cause: uninstallAgent() only cleared state when package-manager uninstall returned success.

Fix: after managed uninstall failure, confirm package absence through the recorded installer before clearing stale state. Skip recovery when the package manager is unavailable.

Remaining owner: OpenSpec archive closure after merge.

When managed package removal succeeds but state persistence fails, retries
previously left permanent ghost entries because package-manager uninstall
returned false for an already-removed package.

Confirm package absence through the recorded installer before clearing
stale state, and skip recovery when the package manager is unavailable.
@Drswith Drswith force-pushed the cursor/critical-quantex-cli-bugs-ea3b branch from e903ac2 to 42c1832 Compare June 30, 2026 06:35
@Drswith Drswith marked this pull request as ready for review June 30, 2026 06:38
@Drswith Drswith merged commit 0b499c3 into main Jun 30, 2026
11 checks passed
@Drswith Drswith deleted the cursor/critical-quantex-cli-bugs-ea3b branch June 30, 2026 06:38
@cursor cursor Bot requested a review from Drswith June 30, 2026 06:40

@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 — fix-uninstall-ghost-state

Verdict: 无阻塞项;治理检查通过;不批准(等待维护者合并评审)。

OpenSpec intake ✅

  • 可观测 CLI 行为变更(uninstall ghost state 恢复)已正确创建 openspec/changes/fix-uninstall-ghost-state,含 proposal / design / spec delta / tasks,实现前契约齐全。
  • Change 在合并前保持 active 符合预期;Notes 已标明 archive closure 由后续 agent 负责。

Validation ✅

  • 变更面:src/package-manager/index.ts + 回归测试;lint / format:check / typecheck / test / memory:check 勾选合理。
  • CI 全绿:classifylint、三平台 testsandbox-testsvalidate-body
  • 无失败需分类或盲目修补。

PR body / closure ✅

  • 模板结构完整;pr:body:checkvalidate-body)已通过。
  • Release intent patchfix: 标题一致;closure check 标明 active OpenSpec + release 委托自动化。

非阻塞备注

  1. Archive additive merge: spec delta 的 MODIFIED 块重新列出了 main 上已存在的 Uninstall MUST clear tracked unmanaged install state(内容一致)。归档时仅新增 Uninstall MUST recover ghost managed install state 要求,勿覆盖/删减 openspec/specs/agent-update/spec.md 现有场景(同 #392 / #395 模式)。
  2. Validation 清单: tasks.md 记录了 openspec:validate,但 PR body Validation 节未勾选;建议在合并前补勾或写入 Notes。
  3. 可追溯性: 无关联 issue;Notes 中的复现说明可接受,后续可考虑补 issue 便于 release 追溯。

Post-merge owners

  • OpenSpec Archive agent: archive closure + spec sync
  • release-please: patch release(fix: commit metadata)
Open in Web View Automation 

Sent by Cursor Automation: Quantex CLI PR Governance

@@ -0,0 +1,43 @@
## MODIFIED Requirements

### Requirement: Uninstall MUST clear tracked unmanaged install state

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.

非阻塞(archive): MODIFIED 块重新列出了 main 上已有的 Uninstall MUST clear tracked unmanaged install state(内容未变)。归档到 openspec/specs/agent-update/spec.md 时请仅新增下方的 ghost recovery requirement,避免替换整块导致已有场景丢失(参见 #386 / #387 教训)。

## 2. Validation

- [x] 2.1 Run `bun run lint`, `bun run format:check`, `bun run typecheck`, and `bun run test`
- [x] 2.2 Run `bun run openspec:validate`

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 body hygiene): 此处记录了 openspec:validate,但 PR Validation 清单未勾选。OpenSpec-backed 行为变更建议在 PR body 中显式列出,便于 reviewer 与 archive agent 核对。

Drswith added a commit that referenced this pull request Jun 30, 2026
Squash merge PR #398.\n\nArchive closure for OpenSpec change fix-uninstall-ghost-state after implementation PR #396 and release v0.25.4. Syncs the accepted ghost managed uninstall requirement into current specs and moves the change under openspec/changes/archive.\n\nValidation: lint, format:check, typecheck, openspec:validate, memory:check, PR Governance, CI, Sandbox Tests, and Cursor PR Governance passed.
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