Repository navigation
fix(brain): scope query tools by distro - #658
Conversation
vladimirrott
left a comment
There was a problem hiding this comment.
Danny, I ran the E2E stories you couldn't run from macOS, and the Ubuntu prompt holds up. Rendering {AVAILABLE_QUERY_TOOLS} from query_tools_for_distro was the right call: the list the model reads and the tools it gets offered now come from one place, and your planner test pins that per distro.
What I ran
I ran the same 122 dry-run stories (the curated 26 plus every # Distro: ubuntu story from 55 to 153) on an Ubuntu 24.04 host, first against main at edfb6f24, then against your branch merged onto that commit (04edff03 + edfb6f24). Provider was Groq openai/gpt-oss-120b, since my OpenAI key was revoked. Each side used its own freshly built binary.
| passed | failed | |
|---|---|---|
main |
115/122 | 11, 12, 15, 16, 21, 38, 41 |
| #658 | 114/122 | 11, 12, 15, 16, 21, 38, 41, 47 |
The seven shared failures also fail on main, so they belong to this model. The Ubuntu install stories (57, 85, 95) pass on both.
Story 47 is the one difference. I reran it five more times per side: main passed 6/6 and your branch 1/6. On your branch the model answers "show me all my installed flatpak apps" with UbuntuListFlatpaks instead of ListInstalledFlatpaks. Both build the same flatpak list --user --app argv at Low risk (crates/sysknife-daemon/src/actions/flatpak.rs:110 and :216), and story 130 already accepts either name on Ubuntu for that reason. Story 47 has no distro scope and only accepts the Fedora name. The host sees no difference, and I'll scope story 47 myself.
Mutation results
I broke seven things in the prompt and query-tool code and re-ran your tests. Six went red: offering every tool regardless of distro, leaving the preamble unfiltered, giving Debian the Fedora Example B, dropping query_current_user, a wrong entry in query_tool_action_name, and giving the generic prompt the Debian Example B.
One survived. If I delete the " (params: " block in push_preamble, no test fails, so the model could lose the parameter names and nothing would notice. One assertion closes it:
assert!(ubuntu.contains("`query_logs` (params: `unit`)"));Before you mark it ready
CLAUDE.mdstill says "on Ubuntu → checkdpkgstatus before proposingAptInstall". Your Debian Example B now tells the model no apt-backed query tool exists and to go straight toAptInstall, so please update that line in this PR.- Optional:
query_tool_to_actioncould take its action name fromquery_tool_action_name, so one table holds the mapping and the parity test has nothing left to guard. I'd merge without it.
Add the assertion and the CLAUDE.md line, mark it ready, and I'll review it the same day. Thank you for taking #657 on so fast, and for doing it without the E2E stories on your machine.
|
Addressed the requested follow-ups in a7e39e1:
|
vladimirrott
left a comment
There was a problem hiding this comment.
Danny, both follow-ups landed the way I asked, and the CLAUDE.md line now reads like the Debian Example B it describes: no package query on Ubuntu, propose AptInstall, let APT say whether it is already there. Approving at a7e39e1.
The new assertion closes the survivor from my last review. I ran it through the merge gate in a container, with a mutation that skips the (params: …) block in push_preamble. The last two lines come from the receipt the gate wrote:
running 'system_prompt_contains_example_c_and_distro_aware_package_example_b' unmutated
rust suite: evidence of 1 executed unit(s), passing unmutated
applying the mutation and re-running
receipt recorded for #658 at a7e39e12 (observed: clean pass, mutated fail)
mutation: s/if !properties.is_empty() {/if false {/
observed_failure: test prompt::tests::system_prompt_contains_example_c_and_distro_aware_package_example_b ... FAILED
The Windows compile failure you hit is the Unix-only import in journal.rs; nothing for you to fix there, and CI is green at this head. The branch is behind main by e99a536, the story 47 scoping I promised in the last review, and git merge-tree reports no conflict.
Thank you for turning both items around the same evening.
Minor release. #627 keys request_hash with an HMAC under the audit key (chain_version 4; previews stored by an older release fail closed after upgrading) and #639 changes the history request a newer CLI sends, so a caller relying on the old behaviour notices: the middle digit moves. Also: the planner sees only its host's distribution (#626, #656, #658, #684), checkpoint and the MCP audit tools share the audit-store resolver (#636), every workflow job has a time limit (#662), a weekly cargo audit (#640), release hardening (#635, #637, #660), and every published figure is rendered from its source (#685). Claude-Session: https://claude.ai/code/session_01UpyrhbDTW1gBwzGAC44GYU Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
The planner previously exposed query tools without applying the distro policy used by
propose_plan, while the shared prompt listed those tools and directed Ubuntu users to Fedora's layered-package query.available_onrule as the action catalogue.query_current_useravailable on every host because the planner resolves it locally.AptInstalland let APT report when a package is already installed.Related Issue
Closes #657
Validation
04edff0; the manual E2E container smoke is skipped for pull request events.cargo fmt --all -- --check— passed.git diff --check— passed.scripts/check_no_secrets.shon the changed files — passed.CARGO_TARGET_DIR=/private/tmp/sysknife-657-distro-query-tools/target CARGO_PROFILE_TEST_DEBUG=0 CARGO_INCREMENTAL=0 rustup run 1.96.0 cargo test --locked -p sysknife-brain --lib— attempted, but dependency compilation stopped when the filesystem ran out of space while compilingregex-automataandaws-lc-sys. The generated target directory was removed afterward.tests/e2e/run-stories.sh.Notes for Reviewers
The planner regression test compares every
query_*name in the rendered Ubuntu and Fedora prompts with the planner's actual tool definitions. It also asserts thatquery_packagesis absent on Ubuntu and present on Fedora, and thatquery_current_userremains available on both.AI assistance
Codex (GPT-6) assisted with issue analysis, implementation, regression-test updates, and review.