~ knotless Search/
↑↓ move↵ open⇧↵ all results

socialweb.computer/socialweb-computer-kcp

socialweb.computer: a compute market on atproto (kcp)

1 collaborator
0
0

tests: 0011 expects the revoke refusal of the transport the token names

Merged johnandersen777.bsky.social asked to merge into main from socialweb.computer/socialweb-computer-kcp:phase-2
docs/plans/0040-findings.md+25−0
@@ -1464,3 +1464,28 @@ Each: what was seen (with the log), the cause, the fix, its proof.
0012:run), 1 FAIL (0002:run: the finding above), 16 to run. It reads the hosts over ssh: the ops routes over iroh
are exercised only by CI's promote. Left open by the 0002 fix: `none_since` stops a collection after 50 pages
(5000 records) without an error (alice's largest: 1151): to plan 0041.
- 0011:token on prod (by-hand gate-1 on hat-8, alice, prod 7a0406d9, 2026-11-18 18:19Z, run
`0011-composition-1795025943759`): `the post after the revoke failed, but not as a refusal: Error: Unauthorized: atirc
token revoked`; on staging (CI, main d6a2b391) it passes. Seen: the same pinned atirc client both places (the host's
`testkit::atirc::atirc_bin`, the newest staged `~/.cache/socialweb-computer/runtime/*/atirc-x86_64`: 54109728 bytes,
`assets.atirc` 0.1.0-58f46d0's rawBytes; hat-8's `/usr/local/bin/atirc` of Oct 29 is never used) and no wording
change in atirc (`git log -S'atirc token revoked'`: only 676c6fe, the revoke's first commit). Cause: atirc `pub` and
`revoke` go to the endpoint the TOKEN names (`cli/src/main.rs:784` `token_info` then `Endpoint::parse`; ATIRC_ENDPOINT
is not read there), and the server mints its iroh ticket there when it has one (`cli/src/server/xrpc.rs:57`
`mint_endpoint`). Prod's irc.fedfork.com runs the split form (`atirc serve` with an ops port plus `atirc-iroh.service`,
`atirc iroh-proxy`, CONTRIBUTING.md:240), which writes the ticket the server reads (`cli/src/server/mod.rs:167`):
its `/health` carries `iroh_ticket`, so prod tokens name iroh and the refusal is `cli/src/server/iroh.rs:324`'s
`{"error":"Unauthorized","message":"atirc token revoked"}` (`auth.rs:880`) printed by `transport.rs:161` as
`{error}: {message}`. Staging's `tests/compositions/staging/atirc.sh` runs one `atirc serve` (in-process iroh, which
never sets the ticket: `mod.rs:181`), so its tokens name the https URL and the refusal is atproto-client's 401
`Not authorized: {code} {message}` (atproto-crates 0c01920 `errors.rs:341`). The earlier finding's "the only kind a
target names" was wrong: the token picks the transport, not the target. CI's promote (release VM, the build's staged
58f46d0 client, the same irc.fedfork.com) would fail the same way. Fix: the host expects the refusal's text for the
transport the observer's token names (`tests/host/src/more.rs` `atirc_revoked`: the token's `endpoint` claim, an iroh
ticket by atirc's own `looks_like_ticket` rule, gives `Unauthorized: atirc token revoked`, anything else `Not
authorized: Unauthorized atirc token revoked`); still one exact text per run, distinct from every other failure
(`Unauthorized: token expired`, `invalid service token`, ...). atirc emits no machine-readable signal (exit 1 for
every failure). Proof (`~/.tmp/rc-0011/proof`): the 58f46d0 client against prod, ATIRC_ENDPOINT the same, a malformed
token naming prod's iroh ticket: `Error: Unauthorized: invalid service token: ...`; naming `https://irc.fedfork.com`:
`Error: error-atproto-client-xrpc-2 Not authorized: Unauthorized invalid service token: ...`. Open: staging does not
run prod's iroh-proxy topology, so the staging gate never exercises atirc over iroh (parity gap).
tests/host/src/more.rs+38−6
@@ -45,10 +45,40 @@ fn origin(url: &str) -> Result<String, String> {
}
const STAGING_PKI_MOUNT: &str = "staging-pki";
/// atirc's error for a token the server refuses because it was revoked: its 401 `Unauthorized`, message `atirc token
/// revoked`, as the CLI prints it over an http(s) endpoint (atproto-client's `Not authorized: {error} {message}`; the
/// `{error}: {message}` form is its iroh transport's, which a target's atirc URL never takes)
const ATIRC_REVOKED: &str = "Not authorized: Unauthorized atirc token revoked";
/// atirc's refusal of a revoked token (error `Unauthorized`, message `atirc token revoked`) as the CLI prints it on the
/// transport the token names: `pub` and `revoke` go to the token's `endpoint` claim, not to ATIRC_ENDPOINT, and the server
/// mints its iroh ticket there when it runs iroh (prod's `atirc-iroh.service`), its http(s) URL otherwise (staging's
/// `atirc serve`). http(s): atproto-client's `Not authorized: {error} {message}`; iroh: atirc's `{error}: {message}`.
const ATIRC_REVOKED_HTTP: &str = "Not authorized: Unauthorized atirc token revoked";
const ATIRC_REVOKED_IROH: &str = "Unauthorized: atirc token revoked";
fn atirc_revoked(token: &str) -> Result<&'static str, String> {
let payload = token.split('.').nth(1).ok_or("the atirc token is not a JWT")?;
let (mut bytes, mut acc, mut bits) = (Vec::new(), 0u32, 0u32);
for c in payload.bytes() {
let v = match c {
b'A'..=b'Z' => c - b'A',
b'a'..=b'z' => c - b'a' + 26,
b'0'..=b'9' => c - b'0' + 52,
b'-' => 62,
b'_' => 63,
_ => return Err("the atirc token's payload is not base64url".into()),
};
acc = (acc << 6) | u32::from(v);
bits += 6;
if bits >= 8 {
bits -= 8;
bytes.push((acc >> bits) as u8);
acc &= (1 << bits) - 1;
}
}
let claims: Value = serde_json::from_slice(&bytes).map_err(|e| format!("the atirc token's payload: {e}"))?;
let endpoint = claims["endpoint"].as_str().ok_or("the atirc token names no endpoint")?;
let iroh = endpoint
.strip_prefix("endpoint")
.is_some_and(|t| !t.is_empty() && t.chars().all(|c| c.is_ascii_lowercase() || ('2'..='7').contains(&c)));
Ok(if iroh { ATIRC_REVOKED_IROH } else { ATIRC_REVOKED_HTTP })
}
/// Chrome takes no CA file: it accepts a certificate by its public key (`--ignore-certificate-errors-spki-list`). The
/// leaf the network's front presents for each name, its chain and name verified against the network CA by openssl first,
@@ -361,7 +391,8 @@ impl Swc {
}
/// `atirc <args>` as the observer: {ok, refused, error}. refused: the server answered that the token is revoked
/// (atirc's `Not authorized: Unauthorized atirc token revoked`), the one failure that is the refusal; error: its last stderr line.
/// (`atirc_revoked`: atirc's text for the transport the token names), the one failure that is the refusal; error: its last
/// stderr line.
async fn observer_run(&self, nick: &str, args: &[&str]) -> Result<Value, String> {
let token = self
.extra
@@ -372,6 +403,7 @@ impl Swc {
.cloned()
.ok_or_else(|| format!("no observer {nick}"))?;
let endpoint = self.target.atirc.clone().ok_or("the target has no atirc")?;
let revoked = atirc_revoked(&token)?;
let out = tokio::process::Command::new(self.atirc()?)
.args(args)
.env("ATIRC_TOKEN", token)
@@ -385,7 +417,7 @@ impl Swc {
.map_err(|e| e.to_string())?;
let stderr = String::from_utf8_lossy(&out.stderr);
let error: String = stderr.lines().last().unwrap_or_default().chars().take(300).collect();
Ok(json!({ "ok": out.status.success(), "refused": !out.status.success() && stderr.contains(ATIRC_REVOKED), "error": error }))
Ok(json!({ "ok": out.status.success(), "refused": !out.status.success() && stderr.contains(revoked), "error": error }))
}
async fn observer_sub(&self, input: &Value) -> Result<Sub, String> {