Repository navigation
fix(planner): inject current user into scoped queries - #787
Conversation
Signed-off-by: Danny Ward <[email protected]>
vladimirrott
left a comment
There was a problem hiding this comment.
Reviewed at 60a48bd. The code is ready. One mechanical step, a merge with main, stands between it and landing, and that is the only reason this review asks for changes.
You put the daemon in the test as the judge. user_scoped_query_tools_inject_current_user_for_daemon_specs drives the real planner and then hands every captured param set to sysknife_daemon::executor::build_action_spec, so the test fails on what the daemon refuses rather than on a list it keeps itself. That is the cross-crate check #671 asked for. Resolving current_user() once per turn with get_or_insert_with and leaving username out of the tool schemas were both right too.
I ran three mutants in a container:
pristine daemon test ok, host_secrets_are_redacted_... ok
M1 injection line -> `let _ = username;` user_scoped_query_tools_inject_current_user_for_daemon_specs ... FAILED
M2 "query_toolboxes" dropped from the list user_scoped_..._daemon_specs FAILED, host_secrets_are_redacted_... FAILED
M3 `continue;` removed from the unknown-user arm host_secrets_are_redacted_... FAILED
restored, pristine again both ok
M3 matters most to me: it proves the planner test you adjusted is what stops a query going out with no user, so that adjustment carries weight.
Blocking (mechanical): I merged #744 a few minutes ago, and it touches the same lines of planner.rs, so this branch now conflicts. The conflict is two let lines side by side; keep both:
let mut proposed_plan = None;
let mut current_user: Option<Result<String, String>> = None;I built that resolution myself to check it: the daemon test passes (1 test), cargo test -p sysknife-brain --test planner passes 83 of 83, and M1 still goes red on the merged tree. After merging main, please re-run UPDATE_TEST_BASELINE=1 scripts/test_baseline.sh; main now records 2114, so the file should read 2115. Both conflicts come from my merge order, not from anything you did.
Optional: the test names the five user-scoped tools twice, once in the input table and once in the matches!. A loop over every tool query_tool_to_action maps, sending each through build_action_spec, would also catch a sixth user-scoped query that someone adds later without touching query_tool_needs_current_user. Fine to leave for later.
…jection Signed-off-by: Danny Ward <[email protected]>
d22c39a to
1411c74
Compare
vladimirrott
left a comment
There was a problem hiding this comment.
Approved at 1411c74. Thanks for the merge and for keeping both let lines.
I rebuilt main plus the head from my last review (60a48bd) with git merge-tree. Against that tree your merge differs in two places: tests/evidence/workspace-tests.json, which now reads 2129 (main's 2128 plus your one test), and the planner.rs conflict block, where you kept both sides:
let mut proposed_plan = None;
let mut current_user: Option<Result<String, String>> = None;
That is the resolution I asked for. The merge gate re-ran your daemon-backed test at this head in a container, with the injection line mutated:
maintainer-merge verify 787 1411c74c208abed8232e607d1250892e92c47500 user_scoped_query_tools_inject_current_user_for_daemon_specs 's/params\["username"\] = username.clone().into();/let _ = username;/'
rust suite: evidence of 1 executed unit(s), passing unmutated
receipt recorded for #787 at 1411c74c (observed: clean pass, mutated fail)
The fix is ready. One thing is out of your hands: #785, #788 and #791 also record the test baseline, so whichever of them lands before this one will put the evidence file in conflict again. When that happens I'll say so here, and it's one more UPDATE_TEST_BASELINE=1 scripts/test_baseline.sh after merging main. That churn comes from how I order merges, not from your branch.
|
As I said in the review, it happened: I merged #785 a few minutes later, and main's evidence file now reads 2132. After merging main, |
Merge origin/main into the branch and set tests/evidence/workspace-tests.json to main's count plus the 1 test(s) this branch adds. Signed-off-by: Vladimir Rotariu <[email protected]>
vladimirrott
left a comment
There was a problem hiding this comment.
Re-approving at ecb7572.
After #785 and #796 landed, the branch conflicted with main on tests/evidence/workspace-tests.json. I merged main into it and set the baseline to 2133: 2132 on main plus the one test this PR adds. The diff against main is the same five files as the head I approved, 1411c74, and nothing else.
The gate receipt is recorded at this head: maintainer-merge verify 787 ecb7572d... user_scoped_query_tools_inject_current_user_for_daemon_specs, with params["username"] = username.clone().into(); replaced by let _ = username;, printed receipt recorded for #787 at ecb7572d (observed: clean pass, mutated fail). All 15 checks are green on this head.
Thank you for the patient rebases. Merging now.
Summary
Related Issue
Fixes #671
Validation
Tests added or updated.
Security impact considered; the daemon remains the only privileged executor.
Trust boundary preserved; the planner supplies identity without exposing it in model-facing schemas.
All hosted checks pass on current head 1411c74: CI, CodeQL, container, secret-scan, cflite, and e2e.
Every commit is signed off.
UPDATE_TEST_BASELINE=1 scripts/test_baseline.sh— 2,129 passed, 8 skipped in WSL Ubuntu. DAC override was dropped so the permission test exercised EACCES.cargo fmt --all -- --check— passed.cargo clippy --workspace --all-features --all-targets --locked -- -D warnings— passed in hosted CI.git diff --check— passed.No user-facing documentation changes were needed; the model-facing schemas remain unchanged.
Assisted by Codex (GPT-6).