Skip to content

fix: require user approval for doctor write/delete operations#79

Merged
Keith-CY merged 4 commits intodevelopfrom
fix/doctor-auto-approve-writes
Mar 5, 2026
Merged

fix: require user approval for doctor write/delete operations#79
Keith-CY merged 4 commits intodevelopfrom
fix/doctor-auto-approve-writes

Conversation

@Keith-CY
Copy link
Copy Markdown
Collaborator

@Keith-CY Keith-CY commented Mar 5, 2026

Summary

  • Narrow isDoctorAutoSafeInvoke to only auto-approve read-only diagnostic commands
  • Remove mutative operations (config-upsert, config-delete, file write, sessions-upsert, sessions-delete, fix-openclaw-path, config set, config delete, config unset) from the auto-safe list
  • Write/delete doctor invokes now surface as "pending" and require explicit user approval

Test plan

  • npm run build passes (verified)
  • Without "full auto" enabled, doctor write/delete suggestions show as pending and require manual approval
  • Read-only commands (probe-openclaw, file read, config-read, config get, etc.) still auto-approve as before

🤖 Generated with Claude Code

Keith-CY and others added 4 commits March 4, 2026 23:57
OpenClaw updated its secrets management to use SecretRef objects
({ source, provider, id }) in auth-profiles.json instead of plaintext
strings. This adds compatibility so profile sync from VPS/local can
resolve credentials through the new scheme.

- Add SecretRef parsing and resolution for env/file sources
- Parameterize credential extraction with env resolver for local vs remote
- Update RemoteAuthCache to discover and batch-fetch SecretRef env vars
- Update per-profile fallback to resolve SecretRef env vars via SSH
- Fix pre-existing test import in agent_fallback.rs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Extract check_entry closure to free function collect_secret_ref_env_names_from_entry
- Add eprintln diagnostic for non-absolute SecretRef file paths
- Run cargo fmt --all to fix formatting (CI failure)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
isDoctorAutoSafeInvoke was auto-approving mutative commands (config
writes, file writes, session deletes) without user consent. Narrow the
safe list to read-only diagnostic commands only.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Keith-CY Keith-CY changed the base branch from main to develop March 5, 2026 04:00
Copy link
Copy Markdown
Collaborator

@dev01lay2 dev01lay2 left a comment

Choose a reason for hiding this comment

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

No CI checks reported yet — please wait for CI before merging.

The core change in use-doctor-agent.ts is correct and important: auto-approving write/delete/upsert doctor operations was unsafe, and restricting auto-approve to read-only diagnostics is the right call.

Blocking

get_ssh_transfer_stats was dropped from the Tauri invoke handler in src-tauri/src/lib.rs. The diff shows it removed from the use crate::commands::{...} import block that feeds invoke_handler!, but it is not added anywhere else. Any frontend call to get_ssh_transfer_stats will fail at runtime with a command-not-found error. If this was intentional (renamed or moved), please explain; otherwise restore it.

Non-blocking

NBS: resolve_secret_ref_with_env silently ignores source values other than env and file. A tracing::warn! for unrecognised sources would help users debug misconfigured secret refs instead of getting silent failures.

Copy link
Copy Markdown
Collaborator

@dev01lay2 dev01lay2 left a comment

Choose a reason for hiding this comment

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

APPROVED

The headline change — narrowing isDoctorAutoSafeInvoke to read-only commands only — is correct and important. Auto-approving mutative ops (config-upsert, file write, sessions-delete, config set/delete/unset) was a real foot-gun; users now get a chance to intercept any destructive doctor suggestion. The remaining auto-safe list looks genuinely read-only.

The SecretRef credential resolution landing is also solid. RemoteAuthCache.find_in_auth_stores now correctly routes through env_lookup instead of the local-env variant, and the build reorder (auth stores → scan SecretRef names → single batch env read) is efficient and correct.

NBS x2 (carried over):

  • eprintln! in resolve_secret_ref_file should go through tracing::warn! / log::debug! — bypasses the structured log pipeline
  • ["token", "key", "apiKey", "api_key", "access"] is duplicated between collect_secret_ref_env_names_from_entry and extract_credential_from_auth_entry_with_env — a new credential field added to extraction won't automatically be collected for remote env batch reads; consider a shared constant

No CI checks reported yet — worth waiting for green before merge.

@Keith-CY Keith-CY merged commit e126ee3 into develop Mar 5, 2026
@Keith-CY Keith-CY deleted the fix/doctor-auto-approve-writes branch March 5, 2026 04:04
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.

2 participants