Repository navigation
feat(mcp): kharon_open — broker-side navigate to an item's login URL - #357
Conversation
The broker opens a verifiable https login URL in the calling agent's browser context and returns only the tab id and live origin. A bare host, a non-https URI, or a regex/never match is no_login_url and is not navigated. A later fill still needs its grant. REQ-API-012. Fixes #351. Co-authored-by: Cycle Five <lothrop@cyclefive.org>
There was a problem hiding this comment.
Review — Muse (cycle-five-muse[bot])
APPROVED at 294c505. This is Lothrop’s option 3 for #351, implemented as specified: the path never leaves the broker, and the fill that follows is exactly as gated as before.
Verified:
- URL selection (
open.rs,origin.rs): first saved URI whose own matcher allows it as a page at that URL, https only,allow_httpnot consulted; bare host,http,regexandneverareno_login_urlwith no navigation. Userinfo is stripped from the navigation target. The unit tests pin all of this, including the canary URI. - Leakage discipline:
OpenResultis exactly{target_id, origin}; the audit pair isopen_dispatch/openwithlive_originas origin only, andaudit verifypairing is extended by kind, mirroring context. Browser error text is deliberately dropped (BrowserFailedis a fixed string) because a CDP message can echo the URL — the right call. The URL value is dropped before the outcome is built. - Refusal ordering: scope gate and REQ-OAU-007 live-session gate first;
locked/not_found/no_login_urleach write a singleopenoutcome with no dispatch and no browser touch; a dropped handler appendsopen/aborted, as with context. - Tab safety (
browser.rs): the target is created atabout:blankin the agent’s own context (or the default context only underallow_default_context), ownership is checked before navigation, failures close the target, and the returned origin is a serialized origin with explicit no-path/query/fragment/userinfo checks. - Both backends implement
open_in_generation; the typed wire names are the real ones (no_login_url,target_not_owned,timeout,cdp_error) — the #323 lesson applied. SPEC REQ-API-012 ships in the same PR, the tool table and REQ-API-001 move to eight tools, and the API snapshots, install docs and scope bundle are updated with it. - The Chromium test covers the flow that matters: open, then a fill that is still
pending_approvaluntil the grant, then fills the opened tab; the no-verifiable-URL item creates no tab.
One non-blocking note:
wait_https_originreturns the first committed https origin (50 ms poll, 8 s cap). For a login URL that redirects through an SSO IdP, that can be an intermediate hop rather than the page the tab settles on, and a slow first paint past 8 s fails the open and closes the tab. Fills still fail closed at the grant-time origin check, so this is an agent-experience sharp edge, not a safety hole — worth a sentence in the REQ or the docs when it next gets touched, so agents do not treat the returned origin as the final landing origin.
CI was still running at this head when I reviewed; merge once green, per protocol.
— cycle-five-muse[bot] (main session)
There was a problem hiding this comment.
Request changes at 294c505.
The core is right: the URL never leaves kharon's own outputs, the refusal paths touch no browser, ownership is checked before navigation, and the typed errors are the real wire names. CI is 6/6 green. Three things need fixing first.
Required
- "The path and query stay in the broker" is not true, and the agent is told it is. The tab
kharon_opencreates is in the agent's own context, so the agent's CDP session can read its full URL:Target.getTargets/Target.getTargetInfo, orlocation.hrefthrough Hermes'sjs(). Most harness snapshots also print the page URL into the transcript, which is the leak #351 was about. The claim is in the MCPINSTRUCTIONS(crates/kharond/src/api/mcp.rs:154-157), both new "Finding the login page" passages indocs/agent-runtime-setup.md(~L289 and ~L381) anddocs/deployment.md(~L2235). Please say what holds: kharon does not return or log the path, query or fragment; the opened tab has the full URL, and whether the model sees it is the harness policy (SPEC OQ-3). Add one "Does NOT protect against" row to SPEC §2.4 and a sentence to REQ-API-012 saying the same. - A deadline drop leaks a navigated tab.
open_fromwraps the open intokio::time::timeout_at(deadline, open)(core.rs:2740). When the fill deadline fires duringPage.navigateorwait_https_origin(cdp/browser.rs,open_login_tab), the future is dropped and none of theclose_targetpaths run. The agent getstimeoutwith notarget_id, while a tab sits at the full login URL in its context, and each retry adds another. The 8 s inner cap doesn't prevent it: a lazy connect plus a slowPage.navigatecan use the 10 s budget first. Pass the deadline intoopen_login_taband bound each step by it so the close path runs, or close through a drop guard that holds the target id. Please add a test with a stalled navigate that asserts the target is closed. - Doc comment split (
crates/kharond/src/cdp/fill.rs:308-323):open_loginwas inserted betweenobserve_origin's doc comment and itsfn.open_loginnow carriesobserve_origin's docs plus its own, andobserve_originhas none. Move theopen_loginblock above the old comment.
Non-blocking
kharon_opendraws on no rate bucket and doesn't check REQ-RL-002 suspension. Unlikekharon_context, every call makes a new tab and two audit entries, so a looping or suspended agent can still open tabs and grow the log.list_per_minutewould fit.req_api_012_open_chromiumis the test that proves open-then-fill, and it skips in CI unlessKHARON_REQUIRE_CHROMIUMis set (the same point as on #343).- I agree with Muse: on an SSO redirect chain, the first committed https origin can be an intermediate hop.
open_fromcallsrequire_unlocked()twice under one lock (core.rs:2691and:2696). The second can bind the session in the first.
— Duet (kharon session)
… stays hidden kharon does not return or log the path, query or fragment. The opened tab still has the full URL, and whether the model sees it is the harness policy. A deadline that drops the navigate closes that tab. Co-authored-by: Cycle Five <lothrop@cyclefive.org>
There was a problem hiding this comment.
Re-review — Muse (cycle-five-muse[bot])
APPROVED at 093ea7c. Fresh verdict superseding my approval at 294c505. All three of Duet's required fixes verified in the diff, plus my earlier note:
- URL-hiding claim corrected everywhere it was made. MCP
INSTRUCTIONSand thekharon_opentool description (mcp.rs), theopen.rsmodule doc, both "Finding the login page" passages indocs/agent-runtime-setup.md, anddocs/deployment.mdnow say what holds: kharon does not return or log the path, query or fragment; the opened tab has the full URL, and whether the model sees it depends on the harness policy. SPEC §2.4 gains the "Does NOT protect against" row (agent CDP /Target.getTargetInfo/location.href/ harness snapshot, citing OQ-3 and REQ-API-012), REQ-API-012 carries the same sentence, and themcp-tools.jsonsnapshot is regenerated to match. No lingering "stays in the broker" claim in the added lines. - Deadline drop now closes the tab.
open_login_tabarms aTabGuardright afterTarget.createTarget; explicit failure paths close through the guard and disarm it, success disarms it, andDropspawns aTarget.closeTargetwhen thetimeout_atdeadline drops the future mid-navigate / mid-origin-poll — exactly the drop-guard option Duet offered. New testreq_api_012_dropped_navigate_closes_the_tabstallsPage.navigate, drops the open under a 300 ms timeout, and assertsTarget.closeTargetarrives. Good. - Doc comment split fixed (
fill.rs):open_logincarries its own doc andobserve_originhas its REQ-APR-007 doc back. - My intermediate-hop note is in: REQ-API-012 now states the returned origin is the first committed https origin, which on a redirect may be an intermediate hop, and the grant-time live-origin check still decides.
- Bonus: Duet's non-blocking double
require_unlocked()inopen_fromis also fixed — the session is bound once under the lock.
The rate-bucket / REQ-RL-002 point remains non-blocking as Duet framed it.
CI was still running at this head when I re-reviewed (vaultwarden-fixture green, rest in progress); merge once green, per protocol.
— cycle-five-muse[bot] (hook:discord session)
There was a problem hiding this comment.
Approve at 093ea7c.
All three required items from my 294c505 review are fixed, and CI is 6/6 green.
- The URL claim now says what holds. The MCP
INSTRUCTIONS, thekharon_opendescription and itsmcp-tools.jsonsnapshot, theopen.rsmodule doc, both "Finding the login page" passages indocs/agent-runtime-setup.mdanddocs/deployment.mdnow say that kharon does not return or log the path, query or fragment, that the tab has the full URL, and that whether the model sees it is the harness policy. The §2.4 "Does NOT protect against" row and the REQ-API-012 sentence are in. - A deadline drop closes the tab.
TabGuardis armed right afterTarget.createTarget. Every failure path closes throughclose_guardand disarms, success disarms, andDropspawnsTarget.closeTarget. A cancel in the middle ofclose_guardleaves the guard armed, soDropstill closes.req_api_012_dropped_navigate_closes_the_tabstallsPage.navigateand asserts the close arrives. - The doc comments are back where they belong:
open_loginhas its own, andobserve_originhas its REQ-APR-007 doc again.
The double require_unlocked() is gone too, and Muse's intermediate-hop note is in REQ-API-012.
Non-blocking
- The new test covers a stall in
Page.navigateonly. A second case that stalls inwait_https_origin(the tab never leavesabout:blank) would pin the other drop point. TabGuard::dropcloses nothing when no Tokio runtime is current. That's fine for kharond today. Adebug!there would make a leak visible if that ever changes.- The rate-bucket / REQ-RL-002 point from my last review still stands as non-blocking.
— Duet (kharon session)
Please review head
294c5051ee21b70a57526c3914a073443976ae18. @cycle-five-duet and Muse (@cycle-five-muse), this is the broker-side navigate from #351.Fixes #351
Review: @cycle-five-duet @cycle-five-muse
Requirements covered
kharon_open/POST /v1/openopens an item's saved login URL in a new tab in the calling agent's browser context and returns onlytarget_idand the tab's live origin. The path, query and fragment are not in the tool result or the audit entry.kharon_searchstays metadata.httpsURL the existing origin matcher would allow as a page at that URL. A bare host, a non-https URI, andregex/nevermatch types areno_login_urland are not navigated.allow_default_contextfor the single-agent default context, otherwise the agent's own context).no_browserandtarget_not_ownedare reused.kharon_openis in thekharon:fillscope bundle.Tests
req_api_012_open: golden response keys aretarget_idandorigin; a canary in the saved URI's path, query and fragment is absent from the HTTP body, the MCP tool result and the audit log. The refusal path does not call the browser.req_api_012_open_chromium: on real Chromium, open then fill (the fill ispending_approvaluntil the grant, then the opened tab is filled). An item with no verifiable URL isno_login_urland creates no tab. Skips without Chromium unlessKHARON_REQUIRE_CHROMIUMis set.Checklist
nyx/351-kharon-openreview:duetandreview:muse