fix(lifecycle): recover uninstall ghost state when package is absent#396
Merged
Conversation
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.
e903ac2 to
42c1832
Compare
Contributor
Author
There was a problem hiding this comment.
PR Governance — fix-uninstall-ghost-state
Verdict: 无阻塞项;治理检查通过;不批准(等待维护者合并评审)。
OpenSpec intake ✅
- 可观测 CLI 行为变更(
uninstallghost 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 全绿:
classify、lint、三平台test、sandbox-tests、validate-body。 - 无失败需分类或盲目修补。
PR body / closure ✅
- 模板结构完整;
pr:body:check(validate-body)已通过。 - Release intent
patch与fix:标题一致;closure check 标明 active OpenSpec + release 委托自动化。
非阻塞备注
- 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 模式)。 - Validation 清单:
tasks.md记录了openspec:validate,但 PR body Validation 节未勾选;建议在合并前补勾或写入 Notes。 - 可追溯性: 无关联 issue;Notes 中的复现说明可接受,后续可考虑补 issue 便于 release 追溯。
Post-merge owners
- OpenSpec Archive agent: archive closure + spec sync
- release-please: patch release(
fix:commit metadata)
Sent by Cursor Automation: Quantex CLI PR Governance
| @@ -0,0 +1,43 @@ | |||
| ## MODIFIED Requirements | |||
|
|
|||
| ### Requirement: Uninstall MUST clear tracked unmanaged install state | |||
Contributor
Author
| ## 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` |
Contributor
Author
There was a problem hiding this comment.
非阻塞(PR body hygiene): 此处记录了 openspec:validate,但 PR Validation 清单未勾选。OpenSpec-backed 行为变更建议在 PR body 中显式列出,便于 reviewer 与 archive agent 核对。
18 tasks
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Fix uninstall ghost state: when a managed package is already removed from disk but Quantex still records install state, retrying
quantex uninstallnow clears the stale state entry after confirming package absence.Linked Artifacts
origin/mainopenspec/changes/fix-uninstall-ghost-stateValidation
bun run memory:checkbun run lintbun run format:checkbun run typecheckbun run test(if behavior changed)Release Intent
Docs Updated
openspec/...Scope Check
Closure Check
Notes
Draft validation: applying the PR regression test only to current
origin/mainreproduced the bug:uninstallAgent()returnedfalsewhen managed uninstall failed butgetInstalledVersion()confirmed the package was absent.Bug impact: permanent ghost install state blocks
update --all,uninstall, and doctor until manualstate.jsonedits.Trigger scenario: managed package removal succeeds but
removeInstalledAgentState()fails. A retry calls package-manager uninstall again, getsfalsebecause 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.