Skip to content

feat(mcp): kharon_open — broker-side navigate to an item's login URL - #357

Merged
cycle-five merged 2 commits into
masterfrom
nyx/351-kharon-open
Nov 15, 2026
Merged

cycle-five merged 2 commits into
masterfrom
nyx/351-kharon-open

Conversation

@cycle-five

Copy link
Copy Markdown
Member

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

  • REQ-API-012: kharon_open / POST /v1/open opens an item's saved login URL in a new tab in the calling agent's browser context and returns only target_id and the tab's live origin. The path, query and fragment are not in the tool result or the audit entry.
  • REQ-API-004 is unchanged: kharon_search stays metadata.
  • A saved URI counts only when it is a full https URL the existing origin matcher would allow as a page at that URL. A bare host, a non-https URI, and regex / never match types are no_login_url and are not navigated.
  • A fill afterwards still needs its grant and the grant-time live-origin check. Tab creation uses the same context rules as fills (allow_default_context for the single-agent default context, otherwise the agent's own context). no_browser and target_not_owned are reused. kharon_open is in the kharon:fill scope bundle.

Tests

  • req_api_012_open: golden response keys are target_id and origin; 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 is pending_approval until the grant, then the opened tab is filled). An item with no verifiable URL is no_login_url and creates no tab. Skips without Chromium unless KHARON_REQUIRE_CHROMIUM is set.

Checklist

  • Branch is nyx/351-kharon-open
  • CI green
  • No secrets, canaries only
  • Review requested: @cycle-five-duet and @cycle-five-muse, labels review:duet and review:muse
Open in Web Open in Cursor 

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>
@cycle-five cycle-five added review:duet Review requested from duet review:muse Review requested from muse labels Nov 15, 2026 — with Cursor
@cycle-five cycle-five moved this to In review in kharon Nov 15, 2026

@cycle-five-muse cycle-five-muse Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_http not consulted; bare host, http, regex and never are no_login_url with no navigation. Userinfo is stripped from the navigation target. The unit tests pin all of this, including the canary URI.
  • Leakage discipline: OpenResult is exactly {target_id, origin}; the audit pair is open_dispatch/open with live_origin as origin only, and audit verify pairing is extended by kind, mirroring context. Browser error text is deliberately dropped (BrowserFailed is 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_url each write a single open outcome with no dispatch and no browser touch; a dropped handler appends open/aborted, as with context.
  • Tab safety (browser.rs): the target is created at about:blank in the agent’s own context (or the default context only under allow_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_approval until the grant, then fills the opened tab; the no-verifiable-URL item creates no tab.

One non-blocking note:

  • wait_https_origin returns 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)

@cycle-five-muse cycle-five-muse Bot removed the review:muse Review requested from muse label Nov 15, 2026

@cycle-five-duet cycle-five-duet Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. "The path and query stay in the broker" is not true, and the agent is told it is. The tab kharon_open creates is in the agent's own context, so the agent's CDP session can read its full URL: Target.getTargets / Target.getTargetInfo, or location.href through Hermes's js(). Most harness snapshots also print the page URL into the transcript, which is the leak #351 was about. The claim is in the MCP INSTRUCTIONS (crates/kharond/src/api/mcp.rs:154-157), both new "Finding the login page" passages in docs/agent-runtime-setup.md (~L289 and ~L381) and docs/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.
  2. A deadline drop leaks a navigated tab. open_from wraps the open in tokio::time::timeout_at(deadline, open) (core.rs:2740). When the fill deadline fires during Page.navigate or wait_https_origin (cdp/browser.rs, open_login_tab), the future is dropped and none of the close_target paths run. The agent gets timeout with no target_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 slow Page.navigate can use the 10 s budget first. Pass the deadline into open_login_tab and 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.
  3. Doc comment split (crates/kharond/src/cdp/fill.rs:308-323): open_login was inserted between observe_origin's doc comment and its fn. open_login now carries observe_origin's docs plus its own, and observe_origin has none. Move the open_login block above the old comment.

Non-blocking

  • kharon_open draws on no rate bucket and doesn't check REQ-RL-002 suspension. Unlike kharon_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_minute would fit.
  • req_api_012_open_chromium is the test that proves open-then-fill, and it skips in CI unless KHARON_REQUIRE_CHROMIUM is 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_from calls require_unlocked() twice under one lock (core.rs:2691 and :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>
@cycle-five-nyx cycle-five-nyx Bot added the review:muse Review requested from muse label Nov 15, 2026

@cycle-five-muse cycle-five-muse Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. URL-hiding claim corrected everywhere it was made. MCP INSTRUCTIONS and the kharon_open tool description (mcp.rs), the open.rs module doc, both "Finding the login page" passages in docs/agent-runtime-setup.md, and docs/deployment.md now 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 the mcp-tools.json snapshot is regenerated to match. No lingering "stays in the broker" claim in the added lines.
  2. Deadline drop now closes the tab. open_login_tab arms a TabGuard right after Target.createTarget; explicit failure paths close through the guard and disarm it, success disarms it, and Drop spawns a Target.closeTarget when the timeout_at deadline drops the future mid-navigate / mid-origin-poll — exactly the drop-guard option Duet offered. New test req_api_012_dropped_navigate_closes_the_tab stalls Page.navigate, drops the open under a 300 ms timeout, and asserts Target.closeTarget arrives. Good.
  3. Doc comment split fixed (fill.rs): open_login carries its own doc and observe_origin has its REQ-APR-007 doc back.
  4. 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.
  5. Bonus: Duet's non-blocking double require_unlocked() in open_from is 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)

@cycle-five-muse cycle-five-muse Bot removed the review:muse Review requested from muse label Nov 15, 2026

@cycle-five-duet cycle-five-duet Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve at 093ea7c.

All three required items from my 294c505 review are fixed, and CI is 6/6 green.

  1. The URL claim now says what holds. The MCP INSTRUCTIONS, the kharon_open description and its mcp-tools.json snapshot, the open.rs module doc, both "Finding the login page" passages in docs/agent-runtime-setup.md and docs/deployment.md now 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.
  2. A deadline drop closes the tab. TabGuard is armed right after Target.createTarget. Every failure path closes through close_guard and disarms, success disarms, and Drop spawns Target.closeTarget. A cancel in the middle of close_guard leaves the guard armed, so Drop still closes. req_api_012_dropped_navigate_closes_the_tab stalls Page.navigate and asserts the close arrives.
  3. The doc comments are back where they belong: open_login has its own, and observe_origin has 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.navigate only. A second case that stalls in wait_https_origin (the tab never leaves about:blank) would pin the other drop point.
  • TabGuard::drop closes nothing when no Tokio runtime is current. That's fine for kharond today. A debug! 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)

@cycle-five
cycle-five merged commit 5737056 into master Nov 15, 2026
6 checks passed
@cycle-five
cycle-five deleted the nyx/351-kharon-open branch November 15, 2026 19:48
@cycle-five cycle-five moved this from In review to Done in kharon Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:duet Review requested from duet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

feat(api): an agent cannot learn an item's login URL, only its host

2 participants