fix(tui): keep denied approvals scoped to exact calls#1624
Conversation
There was a problem hiding this comment.
Code Review
This pull request enhances the tool approval system by transitioning from lossy command prefixes to SHA-256 hashes of the full tool arguments, ensuring more precise cache keys. It introduces a canonical JSON serialization mechanism to maintain stable hashes across different object key orderings. The TUI logic was also refactored to use helper functions for session approval checks. Feedback was provided to improve the canonical JSON serialization by removing trailing commas in arrays and objects for a more standard representation.
|
I’m leaving this open rather than closing it as a duplicate. Main already has the smaller #1623 approval fingerprint fix, but this PR appears to go further by hashing exact arguments for shell/file denials. That may be worth harvesting after a focused review/rebase, especially if we can keep it separated from unrelated terminal changes. |
3422e70 to
5651112
Compare
|
Rebased this branch onto the latest I also added Validation run locally:
I also tried the broader |
|
Thanks for the exact-call approval-key work here. I harvested the narrow denial-cache fix into #1698 for v0.8.38, with changelog credit to Nightt / @nightt5879 and lalala / @lalala-233 for the #1617 report. That landed as the scoped fix for #1617, so I am closing this broader PR as superseded rather than merging it as-is. |
Thanks, that makes sense. Glad the scoped fix landed in #1698, and I appreciate the changelog credit. Closing this as superseded works for me. |
Summary
Fixes #1617.
ui.rsso the repository clippy command passes with warnings denied.Root cause
PR #1388 stopped inserting
tool_nameintoapproval_session_denied, but most tools still built fallback approval keys astool:<tool_name>. For tools likeedit_file,write_file, andtask_shell_start, denying one request therefore cached a key reused by later distinct requests. The UI path also still accepted legacy tool-name deny hits.Testing
cargo test --all-featuressession_manager::tests::latest_session_for_workspace_ignores_newer_other_directoryandsession_manager::tests::latest_session_for_workspace_ignores_invalid_parent_git_markeralso fail individually here. This checkout hasC:\.git\HEAD, so the temp workspaces are detected as sharing the same parent git root.commands::change::tests::change_in_non_english_without_api_key_uses_explicit_fallbackalso fails individually in this environment.tools::pandoc::tests::pandoc_convert_roundtrips_markdown_to_html_inlineandtools::pandoc::tests::pandoc_convert_writes_output_path_and_reports_summaryfailed during the full run withpandoc: getXdgDirectory:sHGetFolderPath: illegal operation, but both passed when rerun individually.cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo buildcargo test -p deepseek-tui approval_cachecargo test -p deepseek-tui session_denied_cache_matches_only_approval_keycargo test -p deepseek-tui session_approved_cache_keeps_tool_name_session_grantsChecklist