Skip to content

feat(web): nginjen backend for web_search and web_fetch, and doctor web lines (#625 part 2) - #674

Merged
ajianaz merged 3 commits into
developfrom
feat/web-nginjen-backend
Nov 13, 2026
Merged

ajianaz merged 3 commits into
developfrom
feat/web-nginjen-backend

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What

Part 2 of #625. With NGINJEN_BASE_URL and NGINJEN_API_KEY both set, web_search and web_fetch use a full nginjen service: POST /search and POST /scrape with a bearer key. Results the backend produced through its Jina Reader fallback are discarded. tole doctor now names the lane each web tool uses. This closes #625's scope together with parts 1a (#671) and 1b (#672).

Depends on: #671 and #672, both merged. Based on develop, with the latest develop merged in.

Why

#625's decision 2: two variables switch both tools to the full nginjen backend, the generic TOLE_WEB_* settings keep working, and otherwise the built-in tools apply. Your ruling on Jina: never ask for it, and discard any result marked engine_used: "jina" with a note.

Changes

  • tole_core::web:
    • nginjen_backend(env): (base, key) only when both variables are non-blank. A base URL that is not http(s) is an error naming the variable, never the key.
    • WebSearchTool::nginjen(base, key): the existing default contract (POST {query, limit}, answering results with title, url and snippet) at {base}/search with Authorization: Bearer <key>. The query is redacted as before, and no redirect is followed.
    • NginjenFetchTool:
      • vets the target before anything leaves: http(s), no credentials, no known secret, a public host (the opt-out is passed in, not read in the tool);
      • POSTs {url, format} to {base}/scrape with the bearer key. The formats are markdown (default), compact, text (sent as content), html (sent as rawHtml) and links;
      • discards a result marked engine_used: "jina" with an error saying why;
      • bounds the envelope and caps the text (20,000 characters) and links (200);
      • redacts errors with the process secrets.
  • tole_cli::tool_roster:
    • WebLane / web_lanes(env): one place picks each tool's lane. The order is a TOLE_WEB_* backend, then nginjen, then the built-in tools; without web-builtin, the direct fetcher and no search. build registers from it.
    • web_doctor_lines(env): web_search: … and web_fetch: … (built-in, nginjen backend, generic backend, direct text fetch, or off). Names only, never a URL or the key.
  • tole doctor prints those two lines.
  • Docs: CHANGELOG, the README web row, and a threat-model paragraph covering the key's handling, the target disclosure and the Jina discard.

Dependencies: none added; tole-cli and tole-core crate counts are unchanged from #672.

Memory: none resident; one HTTP agent per call.

Testing

  • TDD: crates/tole-core/tests/web_nginjen.rs (6 tests) went red against stubs (6 of 6 failed), then green.

  • Those 6 tests run against a local stand-in for the backend on 127.0.0.1, with no DNS or external network. They cover:

    • variable selection;
    • search posting the redacted query with the bearer key;
    • fetch posting {url, format}, with the format mapping;
    • links returned as a list;
    • a Jina result discarded;
    • target vetting (secret, credentials, private, nothing sent), and the key absent from errors.
  • crates/tole-cli/tests/web_lanes.rs (3 tests) covers:

    • the lane order, with and without web-builtin;
    • the doctor lines (names only);
    • an in-process tool_roster::build with the nginjen variables registering the nginjen web_fetch and a web_search, with no key in any spec.

    These were written after the code; the mutation breaks below show they pin it.

  • Gates on this head:

    • cargo fmt --all
    • cargo clippy --workspace --all-targets --all-features -- -D warnings
    • cargo test --workspace
    • cargo test -p tole-core --no-default-features
    • the no-mcp commands (tole-cli without web-builtin)
    • cargo test -p tole-cli --no-default-features --test web_lanes
  • In the workspace run, tui_e2e::tui_streams_approves_cancels_and_leaves_an_ordinary_session timed out once. It is the known flake, unrelated to this change, and passed 15 of 15 when re-run alone.

  • cora review --no-llm --base origin/develop: no issues.

  • Mutation breaks, each restored afterwards; the tests caught all 12:

    • one variable is enough;
    • any base scheme accepted;
    • search sent without the key;
    • the text format not mapped;
    • Jina results kept;
    • a secret target sent;
    • credentials sent;
    • a private target sent;
    • the generic backend does not win;
    • nginjen ignored;
    • the doctor line shows the lane's value;
    • the nginjen fetch not registered.

@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 9d9246c into develop Nov 13, 2026
19 checks passed
@ajianaz
ajianaz deleted the feat/web-nginjen-backend branch November 20, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(web): nginjen-lite — built-in search and scrape (core version of nginjen)

2 participants