refactor(error-contracts): migrate browser_tools.rs to ToolError (#3576 slice)#6218
Merged
Conversation
… slice) Another slice of the structured-error-contracts migration. The ten tool_browser_* dispatchers (navigate / click / type / screenshot / read_page / close / scroll / wait / run_js / back) now return Result<String, ToolError> instead of Result<String, String>: missing params map to MissingParameter, an SSRF-blocked URL to InvalidParameter, and CDP transport / command failures to Upstream via upstream_msg. The dispatch boundary drops its per-arm .map_err(ToolError::upstream_msg) so the typed variants flow through tool_result_from_typed; the None (browser-not-wired) arm still yields Unavailable. Mirrors the merged web_search slice. Refs #3576
added 2 commits
June 18, 2026 18:07
The Screenshot and run_js error arms were hand-written single-line but exceed rustfmt's chain-width threshold at this indentation, so cargo fmt --check failed in CI. Apply rustfmt's canonical output.
…ustfmt CI's cargo xtask fmt wants each browser_tools dispatch call and its trailing .await on one line; the prior commit only formatted browser_tools.rs. Apply the same to the 10 dispatch arms.
# Conflicts: # .secrets.baseline
houko
enabled auto-merge (squash)
June 19, 2026 04:51
GQAdonis
pushed a commit
to GQAdonis/librefang
that referenced
this pull request
Jun 19, 2026
Merge upstream/main into the BossFang fork; origin/main was 15 commits behind. Notable upstream changes: - librefang#6225 scope the compaction-summary banner to the compacted session (adds canonical_sessions.compacted_summary_session_id). - librefang#6196 deny WASM fs_write to the audit anchor via a capability deny-list. - librefang#6226 / librefang#6227 add agent label and exit-reason metrics to the agent loop. - librefang#6215 context-window usage indicator + honest quota-error classification. - librefang#6217 per-instance sidecar secrets so each agent owns its own handle. - librefang#6194 global Auto-Dream on/off switch on the Memory tab. - librefang#6211 / librefang#6214 / librefang#6212 token/context cap fixes; librefang#6208 refuse to delete the active prompt version. - librefang#6218 browser_tools.rs ToolError migration; librefang#6203 launchctl let-binding build fix; librefang#6224 docs dep bumps; librefang#6193 drop five orphaned email deps. Conflict resolution: - deny.toml: keep our RUSTSEC-2025-0141 (bincode 2.0.x) ignore entry (take ours). - deny.toml: ignore three pre-existing unmaintained advisories newly tripped by the RustSec DB (all transitive via the UAR provider chain, none introduced by this merge): RUSTSEC-2024-0384 (instant), RUSTSEC-2024-0436 (paste), RUSTSEC-2025-0119 (number_prefix). BossFang preservation (SurrealDB schema parity for upstream SQLite v46 / librefang#6225): - Add crates/librefang-storage/src/migrations/sql/032_canonical_sessions_compacted_summary_session_id.surql declaring the new field on the SCHEMAFULL canonical_sessions table (SCHEMAFULL silently drops undefined fields on write), registered as version 32 in migrations/mod.rs. - migrate/sqlite_to_surreal.rs: copy the new column so a SQLite to SurrealDB migration preserves the owning-session pointer rather than dropping it. - backends/surreal_session.rs: preserve compacted_summary_session_id across canonical appends, since the upsert replaces the whole record. - Cargo.lock: pick up the workspace version bump (beta.19 to beta.20) the merge introduced. Verification: - cargo check --workspace --lib — clean. - cargo check -p librefang-storage -p librefang-memory -p librefang-uar-spec — clean. - cargo test -p librefang-storage migration — ok (migration ordering / SurrealDB-3 flexible-syntax invariants). - cargo test -p librefang-memory --lib session — 50 passed (incl. upstream's store_llm_summary round-trip test). - cargo clippy -p librefang-storage -p librefang-memory — clean. - python3 scripts/enforce-branding.py --check — clean; Tauri desktop audit and URL-drift scan both clean.
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.
Summary
One slice of the #3576 error-contracts migration:
browser_tools.rsfromResult<String, String>toResult<String, ToolError>. Mirrors the mergedweb_searchslice (#6107) — same crate, same dispatch pattern.Changes
crates/librefang-runtime/src/browser_tools.rs— the tentool_browser_*dispatchers now returnToolError:ToolError::MissingParameter("url" | "selector" | "text" | "expression")check_ssrf) →ToolError::InvalidParameter { name: "url", reason }send_command) + command-failure responses →ToolError::upstream_msg(...)crate::tool_runner::ToolError(same pathweb_search.rsuses).crates/librefang-runtime/src/tool_runner/dispatch.rs— the ten browser arms drop their per-arm.map_err(ToolError::upstream_msg), so the typed variants flow throughtool_result_from_typed. TheNone(browser-not-wired) arm still yieldsToolError::Unavailable("Browser tools").browser_toolshas no other callers in the crate, and no unit tests (the dispatchers need a live CDP browser — unchanged from before).This keeps #3576 as the umbrella tracker (hence
Refs #3576, notCloses). Remaining slices per the migration roadmap:terminal_tmux.rs(anyhow), the channels bridge (needs theChannelError-vs-ToolErrordecision first),librefang-cli, and theclippy::disallowed_typesenforcement.Verification