0
0
prod gate: the ops routes over the bidder's iroh market endpoint
docs/plans/0040-findings.md+28−0
| @@ -1349,3 +1349,31 @@ Each: what was seen (with the log), the cause, the fix, its proof. | ||
work on branch `ops-iroh`: the test host reads the routes over iroh, the requester's own transport. | ||
- The stop job logs `release-rollback: not found` (exit 127): the requester repo's `step-12` module is not published. | ||
- Hand network stg-414197 released 15:57Z (cleanup, no errors); 0020:run's rerun on it PASSED 15:07Z (hand-0020.log). | ||
- Step 11, the prod target has no https market endpoint for any prod bidder (branch `ops-iroh`, off main d6a2b391). | ||
SEEN: promote at main d6a2b3913261 (`~/.tmp/ci-main/promote3.one:25`): `ci-prod-target: did:plc:2l2wdry77c7jtucbslstagkj | ||
of bobvmbuilder.bsky.social: ... no https market endpoint in its offering`, exit 1 before the gate. CAUSE: the lead | ||
assumed every bidder serves its market mux on an https endpoint, as staging bidders do; every prod bidder is behind NAT | ||
and its `market.offering/self` has exactly two endpoints, `iroh` (`endpoint...` ticket) and `webrtc`. The ops routes are | ||
on the prod bidders' market mux all along; the target only had no way to name it. FIX: `scripts/ci-prod-target.sh` | ||
gives a bidder `ops: {url}` when its offering has an https endpoint, else `ops: {iroh: <ticket>}` (an `iroh://` prefix | ||
dropped; the ticket must be `endpoint[a-z2-7]+`), and exits 1 only for neither; URLs stay https-only. | ||
`tests/testkit/src/target.rs` `OpsRead` is `url` or `iroh`; `tests/host/src/ops.rs` sends the same GETs, query and | ||
`Authorization: Bearer` over iroh as HTTP/1.1 through atlibs-iroh's existing raw fetch (`Iroh::http` on | ||
`iroh://<ticket>/<path>`: `dumbpipe connect <ticket>`, the ALPN and framing of the bidder's `dumbpipe listen-tcp` | ||
market listener; `internal/ingress/iroh/client.go` is the Go requester's same path), 120 s per read. Chosen over a new | ||
`internal` CLI command: it exists, is pinned already (atlibs e40f5d6), has its own loopback test in atlibs, sends the | ||
headers on dumbpipe's stdin (never argv) with a cleared environment, and changes no Go code or binary; the CI VM needs | ||
dumbpipe on PATH, as the gate's iroh attach and kube reach already do. The bearer goes only inside the end to end | ||
encrypted iroh connection to the node the ticket names; the ticket is the bidder's own offering record on its PDS | ||
(PDS from the DID's PLC document, DID from `deploy/release/rc-operators.json`). No Go change, no new listener or | ||
route. PROOF (hat-8, read-only): `ci-prod-target.sh --dry-run` with an empty HOME wrote all 4 rc-operator bidders | ||
with `ops.iroh` and nothing on stderr, no secret value in the target. A probe binary compiling `tests/host/src/ops.rs` | ||
as is (`~/.tmp/ops-iroh/probe`) loaded that target (dummy secret file) and read `getHealth` of each of the 4 prod | ||
bidders (rc176, no ops routes): 404 from the mux on all 4, and `/healthz` over the same fetch 200 `{"ok":true}` on all | ||
4: reach and framing. Locally, the real `opsread.RegisterBidder` routes (`~/.tmp/ops-iroh/stand`, built with a go | ||
overlay) behind `dumbpipe listen-tcp`: no secret configured 404; wrong bearer 401 `AuthenticationRequired`; right | ||
bearer 200 for `getHealth` and `getVmMemory?name=cvm-probe` (query carried), all over iroh through `Ops`. To prove: | ||
a CI promote with a build that has the routes on the prod bidders, and the real secret (not used here: the prod | ||
bidders' build has no routes). Seen while at it: the discovered names are `httpsident`, `httpsident-<did tail>`: the | ||
bidders' `alsoKnownAs[0]` is `https://ident.link/agent-of/<did>`, not `at://<handle>`, so the label rule yields | ||
`httpsident` (names are unique; not changed here). | ||
docs/plans/0040-release-pipeline.md+4−0
| @@ -439,6 +439,10 @@ All answered 2026-11-17. | ||
changes land through the queue; no long-lived side branches. `release` gets the test workflows' `paths:` filter | ||
("fix path filter NOW"): a docs-only push builds and tests nothing. The plan doc holds the plan only; the working | ||
notes are `0040-findings.md` ("move all that stuff that's not the core plan into its own file"). | ||
35. (2026-11-18, AskUserQuestion: "Yes, land it") On prod the read-only ops routes are read over the bidder's public | ||
iroh market endpoint (a prod bidder's offering has an iroh and a webrtc endpoint, no https one): the requester's | ||
own transport, the same GETs and shared secret, no host ssh, no new listener. The gateway's route stays https. | ||
| ||
| ||
| ||
| ||
docs/security/proposed-controls.md+2−2
| @@ -55,9 +55,9 @@ Controls an agent thinks are needed. None is implemented until the owner approve | ||
- Input checks that are part of it: `name` a DNS label (a VM's cgroup is found by its exact unit name), `subject` a DNS label or an at:// URI, `did` a DID, `since` RFC 3339, `msg` one of the fixed message names (`internal/contract/opsread`); a log answer holds at most 50 lines of fixed keys, an error text at most 160 characters; a secret file that group or others can read is refused (the routes stay absent, one warning). | ||
- Where: `internal/services/opsread/routes.go` (`LoadSecret`, `RegisterBidder`, `RegisterGateway`), `internal/contract/opsread`, `internal/opsread/hostread`, `internal/controllers/opsread`, `internal/services/bidder/routes.go`, `internal/services/sshserver/service.go`. | ||
- What the holder of the secret reads of other tenants (reviewer's list): `listVms`, `getVm` and `getVmMemory` answer for any VM of the bidder (name, requester DID, receipt URI, phase, image sha256, memory figures); `getLog` returns the first 50 matching lines across tenants; `getRequesterLog` answers for any DID. | ||
- Decided by the owner, not built (2026-11-18): that reach is "Expected": "take no action" (no per-tenant allowlist); "one secret for all": one shared secret for every bidder and the gateway, no per-host or derived secret. The test host sends it to `https://` origins only. | ||
- Decided by the owner, not built (2026-11-18): that reach is "Expected": "take no action" (no per-tenant allowlist); "one secret for all": one shared secret for every bidder and the gateway, no per-host or derived secret. The test host sends it to `https://` origins only, or, for a bidder whose offering has no https endpoint (prod: iroh and webrtc only), inside the iroh connection to the iroh market endpoint its own `market.offering/self` record names (the same listener and mux every requester dials; no new listener, route or exposure); never over `http://`. | ||
- Proposed, not built (the owner has not approved any): a minimum secret length; throttling of the routes; a limit on concurrent reads (each `getHealth`/`getLog` scans the log); secret rotation; a cap on how many VMs `listVms` returns. | ||
- Rejected by the owner: an ssh or iroh route from the CI VM to the bidder hosts. | ||
- Rejected by the owner: an ssh or iroh route from the CI VM to the bidder hosts (their shells, kcp, journals). The bidder's own public iroh market endpoint is not such a route: it serves only the market mux. | ||
| ||
## Existing, not owner-approved | ||
| ||
docs/ci-debug.md+17−0
| @@ -209,6 +209,23 @@ agent config), `==> page ... tools ...`, `==> prod target` with its paths, `==> | ||
composition ok` line per prod runbook (17), `==> rehearsal done`. 2026-11-17 on main de0b91ee the older dry run (no | ||
target, no tools, no test host) passed; this one has not run on a VM yet. | ||
| ||
The prod target's bidders: `scripts/ci-prod-target.sh` gives each bidder `ops: {url}` (its https market endpoint) when | ||
its offering has one, else `ops: {iroh}` (its iroh endpoint ticket: every prod bidder today); it exits 1 for a bidder with | ||
neither (`no https or iroh market endpoint in its offering`). Check on hat-8 with an empty HOME, no secret: | ||
| ||
```sh | ||
H=$(mktemp -d ~/.tmp/fakehome-ops.XXXX); env -u TMPDIR HOME=$H CI_HOME=$H/ci bash scripts/ci-prod-target.sh --dry-run $H/t.json | ||
jq -c '[.bidders[] | {name, ops: (.ops | keys)}]' $H/t.json | ||
``` | ||
| ||
Reach of one bidder's market mux over its iroh endpoint, by hand (needs dumbpipe on PATH; `/healthz` 200 on every | ||
build, an ops route 404 on a build without them or without the secret configured, 401 on a wrong bearer): | ||
| ||
```sh | ||
t=$(jq -r '.bidders[0].ops.iroh' $H/t.json) | ||
printf 'GET /healthz HTTP/1.1\r\nhost: guest\r\nconnection: close\r\n\r\n' | IROH_SECRET=$(openssl rand -hex 32) timeout 60 dumbpipe connect $t | head -1 | ||
``` | ||
| ||
The same without a VM, on hat-8, as the caller (no tools unless `$CI_HOME/page` holds the page; the test host's dry run | ||
only when `tests/target/release/swc-test-host` is there): | ||
| ||
docs/SYSTEM.md+11−1
| @@ -172,7 +172,7 @@ flowchart LR | ||
| `compute.secrets.getSecrets/<contract>` | requester ingress | guest `setup-secrets.service` (workload identity token) | | ||
| `compute.guest.subscribeEvents` | GuestControlPlane | guest agent (WebSocket, cursor, 25 s keepalive) | | ||
| `computer.socialweb.k8s.*` | GatewayAPI | cluster owners (service auth, aud `did:web:k8s.socialweb.computer`) | | ||
| `com.fedfork.exec.ops.listVms`, `getVm`, `getBidder`, `getHealth`, `getLog`, `getVmMemory` | bidder ingress (its market endpoint) | the operator's checks (the prod gate in CI): `Authorization: Bearer <ops read secret>` | | ||
| `com.fedfork.exec.ops.listVms`, `getVm`, `getBidder`, `getHealth`, `getLog`, `getVmMemory` | bidder ingress (its market endpoint: https where its offering has one, else iroh) | the operator's checks (the prod gate in CI): `Authorization: Bearer <ops read secret>` | | ||
| `com.fedfork.exec.ops.getRequesterLog` | SshServer web origin | the same | | ||
| ||
Read-only operations routes (owner, 2026-11-18; lexicons `lexicons/com/fedfork/exec/ops/`, contract `internal/contract/opsread`, | ||
| @@ -183,6 +183,16 @@ host holds an ops read secret: a file of mode 0600, `<instance state dir>/ops-re | ||
compared in constant time (sha256 of both sides), never logged, never in a kcp object; a wrong or missing bearer is 401, a | ||
POST 405. | ||
| ||
A bidder's routes are on its market mux, so they are reached over its market endpoint, the one its | ||
`market.offering/self` record names: its https endpoint where the offering has one (staging), else its iroh endpoint | ||
(prod bidders are behind NAT and offer iroh and webrtc only). Over iroh the test host (`tests/host/src/ops.rs`) sends the | ||
same GET and `Authorization: Bearer` as HTTP/1.1 through atlibs-iroh's raw fetch (`iroh://<endpoint ticket>/<path>`: | ||
`dumbpipe connect <ticket>`, the stream a requester's market calls take to that listener), end to end encrypted to the | ||
iroh node the ticket names. What binds the ticket to the bidder: the offering record in the bidder's own repo on its | ||
PDS, the PDS resolved from the bidder DID's PLC document, the DID from `deploy/release/rc-operators.json` | ||
(`scripts/ci-prod-target.sh`). A URL is never `http://` (the secret goes to https origins or an iroh endpoint ticket | ||
only). The gateway's `getRequesterLog` is on its https web origin. | ||
| ||
| route | params | answer | | ||
|---|---|---| | ||
| `listVms` | none | `{items: [{metadata {name, deletionTimestamp}, spec {vm.cpus, requester.did, contract.receipt.uri}, status {phase, lostReason}}]}`: the bidder's ComputeVMs, every tenant's | | ||
scripts/ci-prod-target.sh+15−10
| @@ -9,8 +9,10 @@ | ||
# password: one line). john (atircOwner) keeps prod.json's path: no composition reads it | ||
# bidders discovered, replacing prod.json's hand-kept list (its kcp kubeconfigs and ssh hosts are for the gate | ||
# by hand on hat-8): every bidder DID of deploy/release/rc-operators.json, named after its handle's first | ||
# label, with `ops.url` its https market endpoint (its market.offering/self record on its own PDS): the | ||
# origin of its read-only ops routes (GET /xrpc/com.fedfork.exec.ops.*, docs/SYSTEM.md). No kcp, no ssh | ||
# label, with `ops` its market endpoint (its market.offering/self record on its own PDS), the one | ||
# that serves its read-only ops routes (GET /xrpc/com.fedfork.exec.ops.*, docs/SYSTEM.md): `ops.url` | ||
# its https endpoint when the offering has one (staging), else `ops.iroh` its iroh endpoint (prod | ||
# bidders are behind NAT: iroh and webrtc only). Neither: exit 1. No kcp, no ssh | ||
# opsSecretFile $CI_HOME/ops-read-secret from PROD_OPS_READ_SECRET: the bearer of those routes | ||
# gateway.ops the ssh gateway's web origin (its getRequesterLog route), in place of gateway.log over ssh: r2 holds | ||
# no droplet key | ||
| @@ -59,7 +61,7 @@ export ${p}_ATPROTO_PASSWORD=${!v:-}" | ||
done | ||
| ||
# the bidders are discovered, never listed by hand: every bidder DID of the rc operators, its PDS from its DID document, its | ||
# https market endpoint from its market.offering record (the origin that serves its read-only ops routes) | ||
# market endpoint from its market.offering record (the mux that serves its read-only ops routes): https, else iroh | ||
[ "$dry" = 1 ] || need PROD_OPS_READ_SECRET | ||
put "$home/ops-read-secret" PROD_OPS_READ_SECRET "${PROD_OPS_READ_SECRET:-}" | ||
plc=$(jq -r '.plc' "$src"); pds=$(jq -r '.pds' "$src") | ||
| @@ -73,16 +75,19 @@ for handle in $(jq -r '.operators[].handle' "$ops"); do | ||
label=$(jq -r '(.alsoKnownAs[0] // "") | sub("^at://"; "") | split(".")[0] | ascii_downcase | gsub("[^a-z0-9-]"; "")' <<<"$doc") | ||
name=${label:-bidder-${did: -8}} | ||
[ "$(jq --arg n "$name" '[.[] | select(.name == $n)] | length' <<<"$bidders")" = 0 ] || name=$name-${did: -8} | ||
url="" | ||
[ -z "$bpds" ] || url=$(get "$bpds/xrpc/com.atproto.repo.getRecord?repo=$did&collection=com.publicdomainrelay.temp.market.offering&rkey=self" | | ||
jq -r '[.value.endpoints[]? | select(.kind == "https") | .address][0] // ""') || url="" | ||
offering='{}' | ||
[ -z "$bpds" ] || offering=$(get "$bpds/xrpc/com.atproto.repo.getRecord?repo=$did&collection=com.publicdomainrelay.temp.market.offering&rkey=self") || offering='{}' | ||
url=$(jq -r '[.value.endpoints[]? | select(.kind == "https") | .address][0] // ""' <<<"$offering") | ||
case $url in https://*) ;; *) [ -z "$url" ] || echo "ci-prod-target: $did: its https endpoint $url is not https" >&2; url="" ;; esac | ||
if [ -z "$operator" ] || [ -z "$url" ]; then | ||
echo "ci-prod-target: $did of $handle: operator ${operator:-unresolved}, PDS ${bpds:-unresolved}, no https market endpoint in its offering" >&2 | ||
iroh=$(jq -r '[.value.endpoints[]? | select(.kind == "iroh") | .address][0] // "" | sub("^iroh://"; "")' <<<"$offering") | ||
[[ $iroh =~ ^endpoint[a-z2-7]+$ ]] || { [ -z "$iroh" ] || echo "ci-prod-target: $did: its iroh endpoint is not an endpoint ticket" >&2; iroh=""; } | ||
if [ -n "$url" ]; then via=$(jq -n --arg u "${url%/}" '{url: $u}'); elif [ -n "$iroh" ]; then via=$(jq -n --arg i "$iroh" '{iroh: $i}'); else via=""; fi | ||
if [ -z "$operator" ] || [ -z "$via" ]; then | ||
echo "ci-prod-target: $did of $handle: operator ${operator:-unresolved}, PDS ${bpds:-unresolved}, no https or iroh market endpoint in its offering" >&2 | ||
[ "$dry" = 1 ] && continue | ||
exit 1 | ||
fi | ||
bidders=$(jq --arg n "$name" --arg d "$did" --arg o "$operator" --arg u "${url%/}" '. + [{name: $n, did: $d, operator: $o, ops: {url: $u}}]' <<<"$bidders") | ||
bidders=$(jq --arg n "$name" --arg d "$did" --arg o "$operator" --argjson v "$via" '. + [{name: $n, did: $d, operator: $o, ops: $v}]' <<<"$bidders") | ||
done | ||
done | ||
web=$(jq -r '.gateway.sshWeb // ("https://ssh." + .gateway.ssh)' "$src") | ||
| @@ -111,4 +116,4 @@ fi | ||
jq --arg c "$home/agent-config.toml" --arg p "$page" --arg o "$tools" '.agentConfig = $c | .pageRepo = $p | .tools = $o' <<<"$t" > "$out.part" | ||
[ ${#own[@]} = 0 ] || chown r2 "$out.part" | ||
mv "$out.part" "$out" | ||
echo "==> prod target $out: $(jq -c '{requester, pageRepo, tools, agentConfig, creds: (.accounts | map_values(.creds)), opsSecretFile, gateway: .gateway.ops, bidders: [.bidders[] | {name, did, ops: .ops.url}]}' "$out")" | ||
echo "==> prod target $out: $(jq -c '{requester, pageRepo, tools, agentConfig, creds: (.accounts | map_values(.creds)), opsSecretFile, gateway: .gateway.ops, bidders: [.bidders[] | {name, did, ops}]}' "$out")" | ||
tests/host/src/ops.rs+73−24
| @@ -2,6 +2,10 @@ | ||
//! of a bidder or the ssh gateway it has no kcp or shell on (prod in CI). A bidder with `ops` in the target is the | ||
//! kube cluster `bidder:<name>` served here: get and list of the kinds the routes answer, in the routes' fixed projection | ||
//! (the fields the modules read), every write refused. One shared secret for every bidder and the gateway (owner): it is the target's `opsSecretFile` (0600), sent as the bearer and never logged. | ||
//! A bidder's routes are on its market mux, reached over its market endpoint: https (`ops.url`) where its offering has | ||
//! one, else iroh (`ops.iroh`, the `endpoint...` ticket of its market.offering record): the same GETs and bearer as | ||
//! HTTP/1.1 over atlibs-iroh's raw fetch (`dumbpipe connect <ticket>`, the stream a requester's market calls take), | ||
//! end-to-end encrypted to the iroh node the ticket names. The gateway's route is its https web origin. | ||
| ||
use std::collections::HashMap; | ||
use std::sync::Arc; | ||
| @@ -11,7 +15,7 @@ use atlibs_host::BoxFut; | ||
use atlibs_host::run::{Call, Request, Sub}; | ||
use atlibs_kube::Kube; | ||
use serde_json::{Value, json}; | ||
use testkit::target::Target; | ||
use testkit::target::{OpsRead, Target}; | ||
| ||
const NS: &str = "com.fedfork.exec.ops."; | ||
| ||
| @@ -33,30 +37,54 @@ const MESSAGES: &[(&str, &[&str])] = &[ | ||
("accept_provision_failed", &["the provision of an accept failed"]), | ||
]; | ||
| ||
/// Where a bidder's ops routes are: an https origin, or an iroh market endpoint ticket. | ||
enum Base { | ||
Https(String), | ||
Iroh(String), | ||
} | ||
| ||
impl Base { | ||
fn of(o: &OpsRead) -> Result<Self, String> { | ||
match (o.url.as_deref(), o.iroh.as_deref()) { | ||
// the bearer goes to https origins only | ||
(Some(u), None) if u.starts_with("https://") => Ok(Self::Https(u.trim_end_matches('/').to_string())), | ||
(Some(u), None) => Err(format!("the ops route {u} is not https: the ops read secret is sent to https origins only")), | ||
(None, Some(t)) => { | ||
let t = t.strip_prefix("iroh://").unwrap_or(t); | ||
match atlibs_iroh::raw_url(&format!("iroh://{t}/")) { | ||
Some(Ok(_)) => Ok(Self::Iroh(t.to_string())), | ||
_ => Err(format!("the ops iroh endpoint {t} is not an iroh endpoint ticket")), | ||
} | ||
} | ||
_ => Err("an ops endpoint is exactly one of url (https) and iroh".into()), | ||
} | ||
} | ||
} | ||
| ||
pub struct Ops { | ||
http: reqwest::Client, | ||
iroh: atlibs_iroh::Iroh, | ||
secret: String, | ||
bidders: HashMap<String, String>, | ||
gateway: Option<String>, | ||
bidders: HashMap<String, Base>, | ||
gateway: Option<Base>, | ||
} | ||
| ||
impl Ops { | ||
/// None: the target names no ops route. | ||
pub fn load(target: &Target) -> Result<Option<Arc<Self>>, String> { | ||
let bidders: HashMap<String, String> = target | ||
.bidders | ||
.iter() | ||
.filter(|b| b.kcp.is_none()) | ||
.filter_map(|b| Some((b.name.clone(), b.ops.as_ref()?.url.trim_end_matches('/').to_string()))) | ||
.collect(); | ||
let gateway = target.gateway.ops.as_ref().map(|o| o.url.trim_end_matches('/').to_string()); | ||
let mut bidders = HashMap::new(); | ||
for b in target.bidders.iter().filter(|b| b.kcp.is_none()) { | ||
if let Some(o) = &b.ops { | ||
bidders.insert(b.name.clone(), Base::of(o).map_err(|e| format!("bidder {}: {e}", b.name))?); | ||
} | ||
} | ||
let gateway = match target.gateway.ops.as_ref().map(Base::of).transpose()? { | ||
Some(Base::Iroh(_)) => return Err("the gateway's ops route is its https web origin, not iroh".into()), | ||
g => g, | ||
}; | ||
if bidders.is_empty() && gateway.is_none() { | ||
return Ok(None); | ||
} | ||
// the bearer goes to https origins only | ||
if let Some(u) = bidders.values().chain(gateway.iter()).find(|u| !u.starts_with("https://")) { | ||
return Err(format!("the ops route {u} is not https: the ops read secret is sent to https origins only")); | ||
} | ||
let file = target.ops_secret_file.as_deref().ok_or("the target names ops routes and no opsSecretFile")?; | ||
let path = testkit::target::expand(file); | ||
let secret = std::fs::read_to_string(&path).map_err(|e| format!("{}: {e}", path.display()))?.trim().to_string(); | ||
| @@ -64,7 +92,9 @@ impl Ops { | ||
return Err(format!("{} is empty", path.display())); | ||
} | ||
let http = reqwest::Client::builder().timeout(Duration::from_secs(120)).build().map_err(|e| e.to_string())?; | ||
Ok(Some(Arc::new(Self { http, secret, bidders, gateway }))) | ||
// raw iroh fetches use no ssh key; the path is the host's iroh transport's | ||
let iroh = atlibs_iroh::Iroh::new(testkit::home_tmp("iroh_ed25519")); | ||
Ok(Some(Arc::new(Self { http, iroh, secret, bidders, gateway }))) | ||
} | ||
| ||
/// The bidder `name` is read through its ops routes. | ||
| @@ -76,19 +106,38 @@ impl Ops { | ||
self.gateway.is_some() | ||
} | ||
| ||
async fn get(&self, base: &str, method: &str, params: &[(&str, &str)]) -> Result<Value, String> { | ||
let url = format!("{base}/xrpc/{NS}{method}"); | ||
let res = self.http.get(&url).query(params).bearer_auth(&self.secret).send().await.map_err(|e| format!("{NS}{method}: {}", e.without_url()))?; | ||
let status = res.status(); | ||
let body: Value = res.json().await.unwrap_or(Value::Null); | ||
if !status.is_success() { | ||
async fn get(&self, base: &Base, method: &str, params: &[(&str, &str)]) -> Result<Value, String> { | ||
let (status, body) = match base { | ||
Base::Https(base) => { | ||
let url = format!("{base}/xrpc/{NS}{method}"); | ||
let res = self.http.get(&url).query(params).bearer_auth(&self.secret).send().await.map_err(|e| format!("{NS}{method}: {}", e.without_url()))?; | ||
let status = res.status().as_u16(); | ||
(status, res.json::<Value>().await.unwrap_or(Value::Null)) | ||
} | ||
Base::Iroh(ticket) => { | ||
let mut query = String::new(); | ||
if !params.is_empty() { | ||
let mut u = reqwest::Url::parse("http://q/").map_err(|e| e.to_string())?; | ||
u.query_pairs_mut().extend_pairs(params); | ||
query = format!("?{}", u.query().unwrap_or_default()); | ||
} | ||
let url = format!("iroh://{ticket}/xrpc/{NS}{method}{query}"); | ||
let headers = vec![("authorization".to_string(), format!("Bearer {}", self.secret))]; | ||
let res = tokio::time::timeout(Duration::from_secs(120), self.iroh.http("GET", &url, headers, vec![])) | ||
.await | ||
.map_err(|_| format!("{NS}{method}: no response over iroh in 120 s"))? | ||
.map_err(|e| format!("{NS}{method}: {e}"))?; | ||
(res.status, serde_json::from_slice(&res.body).unwrap_or(Value::Null)) | ||
} | ||
}; | ||
if !(200..300).contains(&status) { | ||
return Err(format!("{NS}{method}: {status} {} {}", body["error"].as_str().unwrap_or_default(), body["message"].as_str().unwrap_or_default())); | ||
} | ||
Ok(body) | ||
} | ||
| ||
fn bidder(&self, name: &str) -> Result<&str, String> { | ||
self.bidders.get(name).map(String::as_str).ok_or(format!("no ops route for the bidder {name}")) | ||
fn bidder(&self, name: &str) -> Result<&Base, String> { | ||
self.bidders.get(name).ok_or(format!("no ops route for the bidder {name}")) | ||
} | ||
| ||
pub async fn health(&self, name: &str) -> Result<Value, String> { | ||
| @@ -137,7 +186,7 @@ impl Ops { | ||
| ||
/// gateway.log: the ssh gateway's lines of `did` since `since` whose msg is one of `msgs` (none: every known one). | ||
pub async fn gateway_log(&self, did: &str, since: &str, msgs: &[String]) -> Result<Value, String> { | ||
let base = self.gateway.as_deref().ok_or("the target names no gateway ops route")?; | ||
let base = self.gateway.as_ref().ok_or("the target names no gateway ops route")?; | ||
let o = self.get(base, "getRequesterLog", &[("did", did), ("since", since)]).await?; | ||
let lines: Vec<Value> = (o["lines"].as_array().into_iter().flatten()) | ||
.filter(|v| msgs.is_empty() || v["msg"].as_str().is_some_and(|m| msgs.iter().any(|x| x == m))) | ||
tests/testkit/src/target.rs+9−4
| @@ -121,13 +121,18 @@ pub struct Gateway { | ||
pub ops: Option<OpsRead>, | ||
} | ||
| ||
/// The read-only operations routes (GET /xrpc/com.fedfork.exec.ops.*) of a bidder or the ssh gateway: the public | ||
/// origin that serves them. The host reads through them what it otherwise reads with an admin kubeconfig and a shell | ||
/// on the host; nothing is written through them. | ||
/// The read-only operations routes (GET /xrpc/com.fedfork.exec.ops.*) of a bidder or the ssh gateway: the endpoint that | ||
/// serves them, exactly one of `url` (an https origin: the gateway's web origin, a bidder's https market endpoint) and | ||
/// `iroh` (a bidder's iroh market endpoint, the `endpoint...` ticket of its market.offering record: prod bidders behind | ||
/// NAT have no https one). The host reads through them what it otherwise reads with an admin kubeconfig and a shell on | ||
/// the host; nothing is written through them. | ||
#[derive(Debug, Deserialize, Clone)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct OpsRead { | ||
pub url: String, | ||
#[serde(default)] | ||
pub url: Option<String>, | ||
#[serde(default)] | ||
pub iroh: Option<String>, | ||
} | ||
| ||
impl Gateway { | ||
tests/testkit/README.md+1−1
| @@ -160,7 +160,7 @@ SWC_TARGET=$PWD/targets/prod.json cargo run -p swc-test-host -- compositions/000 | ||
| `com.fedfork.exec.kube.{get,list,apply,patch,delete}`, `kube.watch` (subscription) | atlibs-kube (knotless) | any kcp or cluster the host names; writes only to what the run created, or what the host's guard allows; `cleanup()` deletes them and restores patched specs | | ||
| `com.fedfork.exec.ssh.{exec,session}` | atlibs-ssh (knotless) | the system ssh to destinations the host names (`-F /dev/null`, `SetEnv`) | | ||
| `computer.socialweb.test.{requester,request,account,atirc}.*` | `tests/host` (`swc-test-host`) | the requester under test as the account: `run requester` (its kcp becomes cluster `requester:<name>`), `run request` (its log events a subscription), the owner's mesh node; released and stopped after the run | | ||
| `computer.socialweb.test.bidder.health`, `computer.socialweb.test.gateway.log` | `tests/host` | a bidder host's health without sudo (its `run bidder` journal: ERROR lines since start and in the first 10 min, automatic restarts, VM processes), over the bidder's ssh alias or here; the ssh gateway log lines of a DID (target `gateway.log`). A bidder with `ops {url}` and no `kcp` in the target (and `gateway.ops`; the secret in the target's `opsSecretFile`) is read through its read-only routes `com.fedfork.exec.ops.*` instead (`tests/host/src/ops.rs`): these calls, `bidder.logCount` / `bidder.logLines`, `vm.memory` without setHigh, and kube `get` / `list` of ComputeVM, FirecrackerVM, MarketIdentity, Bidder and MarketBidder on `bidder:<name>`; every other kube verb there is refused, and the module sees `write: false` on that bidder | | ||
| `computer.socialweb.test.bidder.health`, `computer.socialweb.test.gateway.log` | `tests/host` | a bidder host's health without sudo (its `run bidder` journal: ERROR lines since start and in the first 10 min, automatic restarts, VM processes), over the bidder's ssh alias or here; the ssh gateway log lines of a DID (target `gateway.log`). A bidder with `ops {url}` (https) or `ops {iroh}` (its iroh market endpoint ticket, fetched over atlibs-iroh's raw `dumbpipe connect`) and no `kcp` in the target (and `gateway.ops`; the secret in the target's `opsSecretFile`) is read through its read-only routes `com.fedfork.exec.ops.*` instead (`tests/host/src/ops.rs`): these calls, `bidder.logCount` / `bidder.logLines`, `vm.memory` without setHigh, and kube `get` / `list` of ComputeVM, FirecrackerVM, MarketIdentity, Bidder and MarketBidder on `bidder:<name>`; every other kube verb there is refused, and the module sees `write: false` on that bidder | | ||
| `com.fedfork.exec.identlink.{walk,plc}` | `tests/host` (to move into atlibs-host) | identlink's verified walk, PLC log/last and documents of the target's PLC | | ||
| `assert` | `tests/modules/assert` | records gone (x3), tombstones, an agent VM's chain, no market or compute record created since a time (`none_since`, every listRecords page); each asks again every 10 s for up to `within` s (180) | | ||
| `acc-0004` | `tests/modules/acc-0004`, `tests/compositions/0004` | the runbook as a state machine | | ||