Skip to content

feat(id): F12.5 http.fetch provider — off by default, admin allowlist (#1062) - #12559

Merged
dezren39 merged 3 commits into
mainfrom
felix/1062-http-fetch-provider
Nov 22, 2026
Merged

dezren39 merged 3 commits into
mainfrom
felix/1062-http-fetch-provider

Conversation

@dezren39

@dezren39 dezren39 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Third provider slice for #1062, in the order fixed by the 2026-11-21 decision on that issue (kv: PR #12489, blob: PR #12529). Design: doc/2026-11-22_design_id1062-http-fetch-provider.md.

Problem

F12.5 names four first providers. http.fetch is the first outward-facing one — its effect leaves the node — and the issue fixes its shape: admin allowlist, size and rate bounds, no redirects off the list, off by default, and a test that proves an unlisted host is refused.

Change

  • Registry (id-caps): http.fetch registers as a version-1 host request, Join scope, DefaultCeiling::Excluded — it joins no default ceiling, so a use before an operator names it in both the server caps and the world ceiling is refused outside_ceiling by the ordinary ledger decision. validate_http_fetch_url owns the URL form (http/https only, host required, no userinfo, ≤ 2,048 bytes) and returns the normalized host.
  • Allowlist (id-worlds): WorldLimits::http_fetch_hosts — runtime configuration in the server_caps mould, never journaled, empty by default. WorldCore::check_http_fetch refuses a malformed URL, an unlisted host (exact match on the normalized host; no wildcards, no implied subdomains), and an exhausted rate window before any connection. Attempts are recorded when made, so refused and failed fetches spend the rate budget too.
  • Execution: GET only, args {"url"}, result {"url", "status", "body", "body_bytes"} with the body base64 (the blob wire spelling). The fetch runs on a dedicated OS thread per fetch (the reqwest blocking API panics inside an async runtime; the actor runtime never blocks). Redirects are followed manually, ≤ 3 hops, every hop re-validated and re-checked against the allowlist before connecting. Body read is capped (32 KiB, refused past it, never truncated); one 10 s budget covers all hops.
  • Journaling: none — deliberately. A fetch is an effect against the live network, not world state; no entry records it, so no journal version bump (trail stays at 14). The only entries a fetch ask produces are the ones every request produces (the input commit and the result-delivery System event; CapsGranted if grant-on-use mints). At-most-once across a reopen is the existing stale-wants refusal, whose comment already names http.fetch. Full rationale in the design doc.
  • Bounds (derivations in the design doc): URL ≤ 2,048 B; response ≤ 32 KiB (largest power of two whose base64 fits the 64 KiB result-event cap with the other fields); ≤ 3 redirects; 10 s total timeout; rate 10 attempts per rolling 60 s per world (world clock; window is ephemeral, restart resets it).
  • New dependencies: reqwest 0.13 for id-worlds (blocking + rustls, default features off so no system proxy is consulted; already in the workspace lock as iroh's dependency) and url 2 for id-caps (likewise already in the lock).

Test evidence (venue: sandbox for every run)

  • Fail-before (scratch worktree at base e82b639, tests only, since removed; isolated target dir): id-caps fails to compile with 7 errors naming validate_http_fetch_url, MAX_HTTP_FETCH_URL_BYTES, normalize_http_fetch_host; id-worlds fails with 16 errors naming check_http_fetch (×9), the http_fetch_hosts field, note_http_fetch_attempt, and the MAX_HTTP_FETCH_* / HTTP_FETCH_RATE_WINDOW_MS constants.
  • Pass-after: cargo test -p id-caps 173 passed, 0 failed; cargo test -p id-worlds --lib world:: 477 passed, 0 failed — the world:: filter keeps the ~40 known live-network failures (id-worlds live-network tests fail with connect timeouts in the Muse sandbox (environmental) #12488) out of scope. All 7 new http.fetch tests pass, including the named ones: off-by-default (outside_ceiling, server sees no request), unlisted host refused (server sees no request), ungranted refusal counted, round trip + on-list redirect + 404-as-result against a hermetic loopback server (no live internet in any test), off-list redirect and hop-cap and over-cap body refusals with exact server hit counts, core bound/rate checks on a manual clock, and the replay test (a fetch interleaved with a kv write adds no state entry; restore rebuilds the same state).
  • One assertion was corrected during the run: result delivery is journaled as a System event for every provider (reads included), so the replay test asserts no state entry rather than no entry; the design doc states this precisely.

Left on #1062 after this slice: notify (rate limited), last in the decision order.


See it in action
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 35 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9dc2a8e0-48bb-4e7c-aca6-8f410489f867
Commits

Reviewing files that changed from the base of the PR and between edd6691 and 561c6cc.

Files ignored due to path filters: 1

  • pkgs/id/Cargo.lock is excluded by !**/*.lock
Files selected for processing: 10

  • doc/2026-11-22_design_id1062-http-fetch-provider.md
  • pkgs/id/crates/id-caps/Cargo.toml
  • pkgs/id/crates/id-caps/src/world_caps.rs
  • pkgs/id/crates/id-worlds/Cargo.toml
  • pkgs/id/crates/id-worlds/src/world/actor/execution.rs
  • pkgs/id/crates/id-worlds/src/world/core.rs
  • pkgs/id/crates/id-worlds/src/world/core/operations.rs
  • pkgs/id/crates/id-worlds/src/world/http_fetch.rs
  • pkgs/id/crates/id-worlds/src/world/mod.rs
  • pkgs/id/crates/id-worlds/src/world/tests.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T13:36:59.860719Z 561c6cc PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39
dezren39 requested a review from a team as a code owner November 22, 2026 13:33
@dezren39
dezren39 merged commit 1d6ca73 into main Nov 22, 2026
2 checks passed
@dezren39
dezren39 deleted the felix/1062-http-fetch-provider branch November 22, 2026 13:34

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 561c6cc4e5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +78 to +79
let handle = std::thread::spawn(move || perform(&url, &allowed_hosts));
match handle.join() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Await fetch completion without blocking a Tokio worker

When http.fetch is enabled and an allowlisted endpoint responds slowly, this synchronous join() blocks the Tokio worker for the entire fetch, potentially ten seconds. WorldHandle launches the actor with tokio::spawn (world/handle.rs:334), and its async request loop calls self.execute(&request) synchronously (world/actor/execution.rs:884), so moving the network operation onto another thread does not free the runtime thread waiting here. Concurrent fetches across enough worlds can occupy every runtime worker and stall unrelated worlds and server I/O, exceeding the design's intentionally accepted stall of only the requesting actor. Await a blocking-task completion or completion channel from the async actor path instead.

Useful? React with 👍 / 👎.

Comment on lines +80 to +83
reqwest = { version = "0.13", default-features = false, features = [
"blocking",
"rustls",
] }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Resolve the Rustls crypto provider when enabling AWS-LC

For HTTPS libsql requests made before a process-wide crypto provider has been installed, this dependency change introduces a runtime panic even when http.fetch remains disabled. The updated lockfile adds aws-lc-rs to Rustls, while pkgs/id/Cargo.toml already enables its ring provider; the existing HttpTransport::wrap_tls in pkgs/id/src/foreign_libsql.rs:774 calls rustls::ClientConfig::builder() without selecting a provider, and repository-wide search found no CryptoProvider::install_default() call. With both providers enabled, Rustls cannot infer the default; its builder documentation documents a panic when provider resolution fails. Preserve the existing single-provider configuration or explicitly select/install a provider before these TLS builders run.

Useful? React with 👍 / 👎.

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.

1 participant