fix(anolisa): fail forget dry-run on adapters - #2762
Open
zyw02 wants to merge 1 commit into
Open
Conversation
forget --dry-run skipped the adapter-claim guard that execute enforces, so a preview could succeed and the real drop fail. Run the same fast-fail on dry-run, matching pending-journal and uninstall. Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: zyw02 <zyw02@users.noreply.github.com>
kongche-jbw
reviewed
Aug 22, 2026
kongche-jbw
left a comment
Collaborator
There was a problem hiding this comment.
Review baseline: 271bd99a43b7049d7eb32199658e7345ca7caadc...e3de2cb99b88508e6e58edcf5f0c88aa9e9c567f
[P1] 让 subprocess 用例脱离 root 身份依赖
src/anolisa/crates/anolisa-cli/tests/forget_dry_run_adapter.rs:194 的 real 调用固定使用
--install-mode system。在非 root 环境中,它会在全局参数校验阶段先返回
PERMISSION_DENIED/exit 5,随后在第 157 行失败,无法得到预期的 adapter
INVALID_ARGUMENT/exit 2。我在 uid 1002 下运行该 integration target 可稳定复现,
因此测试结果取决于 runner 身份。
Possible direction: subprocess 只验证无需 root 的 dry-run envelope,并由现有
in-process execute 用例覆盖 real guard;或让 fixture 在 root/non-root 下均使用合法、
等价的执行模式,并补充非 root 回归。
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.
Why
anolisa forget --dry-runskipped the adapter-claim guard that a real forget enforces. A preview could print a successful "would forget" payload whileanolisa forgetthen exits 2 and asks foradapter disable. The pending-journal check in the same function already previews execute refusals, anduninstall --dry-runalready refuses enabled adapters. Dry-run must not tell the operator to proceed when the real drop cannot.What changed
handlealways callsensure_no_adapter_claimsbefore the dry-run success payload. Execute still re-checks under the lock inpersist_forget.INVALID_ARGUMENT, exit 2,adapter disable+ framework name). A receipt on a different component still previews successfully and leaves both records.forget.rsplus subprocesstests/forget_dry_run_adapter.rs(--install-mode system --prefix) so host state cannot change the envelope.Related issue
fixes #2761
User / Agent impact
anolisa forget --dry-run <component>now refuses when that component still has enabled adapters, matching the real command anduninstall --dry-run. Unrelated receipts and the no-claim dry-run preview are unchanged. JSON error envelopes keep the existing schema and exit 2.Risk and compatibility
Dry-run success for a claimed component becomes a refusal. Callers that treated the previous false-green preview as authorization will now see the same error execute already returned. Execute behavior, pending-journal dry-run, and no-claim dry-run are unchanged.
Validation
Environment: Linux. Head
e3de2cb99b88508e6e58edcf5f0c88aa9e9c567fon base271bd99a43b7049d7eb32199658e7345ca7caadc. Focused tests cover execute refusal, dry-run refusal, unrelated-claim dry-run success, and the JSON envelope pair. Fullcargo test --lockedas root still hits pre-existing--install-mode userintegration failures unrelated to this change.Documentation and rollback
No documentation change: dry-run is already a preview of the mutation, and the adapter guard comment already described this check as the dry-run preview. Revert this PR to restore the previous false-green
forget --dry-runwhen adapters are enabled.