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

socialweb.computer/socialweb-computer-kcp

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

1 collaborator
0
0

0020, release host calls, discovery drop reasons

Merged johnandersen777.bsky.social asked to merge into main from socialweb.computer/socialweb-computer-kcp:plan-0040-c0020
docs/acceptance/0020-bidder-follows-release.mdnew+22−0
@@ -0,0 +1,22 @@
# 0020 - an installed bidder follows the release channel
Plan 0040 step 4. An installed bidder watches `software.release.channel/socialweb-computer:<rc|stable>` in its
`release-repo` (default socialweb.computer) and installs the version the channel names.
```sh
cd tests
B='[{"version":"<A version>","url":"<A url>","sha256":"<A sha256>","size":<A bytes>},
{"version":"<B version>","url":"<B url>","sha256":"<B sha256>","size":<B bytes>}]'
SWC_TARGET=<staging target.json> cargo run -q -p swc-test-host -- compositions/0020 --entry run --input "{\"builds\": $B}"
```
A and B: two published linux/amd64 builds with the follower (main/<sha>/binaries/ from 6f7f2391 on).
Pass: the bidder installed on the staging root host (`--release-repo` the run's account) names A in its heartbeat after the
account's `rc` channel points at A, then B after it points at B; the records are deleted and the bidder uninstalled. SKIP on
prod or without two builds.
## Readings
| When | Target | Result |
|---|---|---|
docs/plans/0044-ci-by-hand.md+1−0
@@ -380,6 +380,7 @@ everything and exits (finding 5). If its cleanup reports errors (`cleanupErrors`
| 73 | Prod gate 3 (2fb0f74d), 0013 FROZEN "no answer 5 min after the first prompt": the guest's atirc-agent restarted 45 times on "the mesh identity (ATP_USERNAME, /etc/atirc/iroh_key.hex) is not in the secrets bundle yet" (its atirc.env 0 bytes). The requester wrote ATP_USERNAME at 03:14:12.158, 0.3 s after the guest.secretsUpdated it had just sent (secrets-updated-dt3dah...), and sent none after it: the event's name is `secretsUpdated` of (contract, ref URI, ref CID), and the agent path and atirc.go passed the file path with no CID, so every later change of that file was the same name and dropped as known. The guest refetched once, too early. Fix: the ref names the content (`bundleRef`: path and sha256 of the value), so each distinct bundle version sends one event. Also: a hand identity change needs every requester under `$CI_IDENTITY_DIR/requesters` recorded with the old one moved aside (0012's `qs`, 0013's `mp`, not only `stg`) | fixed (branch fix-secrets-updated-version) |
| 74 | Prod gate 3: 0007:restart, the four 0014 and 0015:pressure read PASS in 0-1 s, but each was `readings.skipped` (staging only); the test host now prints its tick lines on stdout before the JSON result, so gate.sh's `jq` of that file failed and fell through to PASS (and a FAIL's note to "exit 1: readings: ..."). Fix: gate.sh reads the document from its first `{` line | fixed |
| 75 | The v0.0.0-rc168 tag build (53cad0e3): `stage` "killed after 900s": two small PUTs to Spaces answered UnknownError (retried), the 545 MB arm64 binary uploaded in 26 s, the amd64 one's PUT never returned: `publish-spaces.ts` gives a request no time limit. Rerun (attempt 2). Fix: every S3 request gets a limit that grows with the file (60 s + 1 s per 5 MB), so a hung PUT is aborted and `attempt` retries it (owner, 2026-11-16: not a control) | fixed |
| 76 | CI test on 62841d92, 0005 FAIL "R2 not Held in 10 min": R2's discovery kept one of 3 candidates (b1, already hosting 0005's outer VM, so every round `requester_bidder_declined` capacity 4608M of 7965M) and dropped b2 with no reason in the log (`dropped 2`). The same suite passed on 2fb0f74d and cd67bb7a. Change: `requester_bidder_discovery` names each drop (`drops: ["<did>: <reason>"]`: no fresh heartbeat, or the offering's reason) so a recurrence says why | open: rerun with the drop reasons |
## Runs
internal/market/requester/market.go+9−1
@@ -438,7 +438,7 @@ func (m *HTTPMarket) discover(ctx context.Context, now time.Time, only []string)
}
discoveryMs := time.Since(discoveryStart).Milliseconds()
m.log().Info("requester_bidder_discovery", "source", source, "sources", counts, "candidates", len(found.Candidates), "bidders", bidderDIDs,
"dropped", len(found.Dropped), "discoveryMs", discoveryMs)
"dropped", len(found.Dropped), "drops", dropSummary(found.Dropped), "discoveryMs", discoveryMs)
if !m.StartedAt.IsZero() && !m.firstDiscovery.Swap(true) {
m.log().Info("requester_start_timing", "step", "firstBidderDiscovery", "sinceStartMs", time.Since(m.StartedAt).Milliseconds(),
"discoveryMs", discoveryMs, "bidders", len(found.Bidders))
@@ -907,3 +907,11 @@ func payloadRef(value map[string]any) market.RecordRef {
}
var ErrParticipationSuspended = errors.New("requester: participation is suspended; no new RFP or accept is published")
func dropSummary(drops []BidderDrop) []string {
out := make([]string, 0, len(drops))
for _, d := range drops {
out = append(out, d.DID+": "+string(d.Reason))
}
return out
}
tests/compositions/0020/compose.tsnew+3−0
@@ -0,0 +1,3 @@
// deno run -A --no-lock compose.ts > composition.json (docs/acceptance/0020-bidder-follows-release.md)
import { build } from "../build.ts";
await build("acceptance 0020", "Acceptance 0020: an installed bidder follows the software.release channel (docs/acceptance/0020-bidder-follows-release.md).", "acc-0020");
tests/compositions/0020/composition.jsonnew+12−0
@@ -0,0 +1,12 @@
{
"$type": "com.fedfork.exec.composition",
"name": "acceptance 0020",
"description": "Acceptance 0020: an installed bidder follows the software.release channel (docs/acceptance/0020-bidder-follows-release.md).",
"instances": [
{
"name": "test",
"module": "acc-0020"
}
]
}
tests/host/src/more.rs+50−0
@@ -1363,6 +1363,56 @@ printf '{{"unit":"%s","current":%s,"high":"%s","max":"%s","swapMax":"%s","events
}
(Err(e), _) | (_, Err(e)) => Err(e),
},
"release.put" | "release.delete" => {
let did = match self.acct() {
Ok(a) => a.did.clone(),
Err(e) => return Some(Err(e)),
};
async {
let base = self.target.pds.trim_end_matches('/').to_string();
let s: Value = self
.http
.post(format!("{base}/xrpc/com.atproto.server.createSession"))
.json(&json!({ "identifier": did, "password": self.password()? }))
.send()
.await
.map_err(|e| e.to_string())?
.json()
.await
.map_err(|e| e.to_string())?;
let jwt = s["accessJwt"].as_str().ok_or_else(|| format!("createSession {did}: {}", s["error"]))?.to_string();
let call = |nsid: &'static str, body: Value| {
let (http, base, jwt) = (self.http.clone(), base.clone(), jwt.clone());
async move {
let r = http.post(format!("{base}/xrpc/{nsid}")).bearer_auth(jwt).json(&body).send().await.map_err(|e| e.to_string())?;
let status = r.status();
let v: Value = r.json().await.unwrap_or_default();
if !status.is_success() {
return Err(format!("{nsid}: {status} {} {}", v["error"], v["message"]));
}
Ok::<Value, String>(v)
}
};
let mut out = Vec::new();
if what == "release.put" {
for r in input["records"].as_array().cloned().unwrap_or_default() {
let v = call("com.atproto.repo.putRecord", json!({ "repo": did, "collection": r["collection"], "rkey": r["rkey"], "record": r["record"], "validate": false })).await?;
out.push(json!({ "uri": v["uri"], "cid": v["cid"] }));
}
} else {
for uri in input["uris"].as_array().cloned().unwrap_or_default() {
let u = uri.as_str().unwrap_or_default();
let parts: Vec<&str> = u.trim_start_matches("at://").splitn(3, '/').collect();
if parts.len() == 3 {
call("com.atproto.repo.deleteRecord", json!({ "repo": did, "collection": parts[1], "rkey": parts[2] })).await?;
out.push(json!({ "uri": u }));
}
}
}
Ok(json!({ "records": out }))
}
.await
}
"root.exec" => {
let Some(host) = (self.target.name != "prod")
.then(|| self.target.root_hosts.first().cloned())
tests/modules/acc-0020/src/lib.rsnew+149−0
@@ -0,0 +1,149 @@
// docs/acceptance/0020-bidder-follows-release.md (plan 0040 step 4): an installed bidder follows the software.release channel.
// On a staging root host: install a bidder (its own network handle, --release-repo the account's DID), write the account's
// project, manifest, version and channel `socialweb-computer:rc` for build A, wait until the bidder's heartbeat names A, move the
// channel to build B, wait for B, then delete the records and uninstall. Builds A and B are input (`builds: [{version, url,
// sha256, size}, ...]`, published builds that have the follower); without them, or on prod, SKIP.
use abi::{Event, Handle, Run, entries};
use serde_json::{Value, json};
use steps::{MIN, S, host, out};
const PROJECT: &str = "socialweb-computer";
const HB: &str = "com.publicdomainrelay.temp.market.heartbeat";
const ST: &str = "/var/lib/socialweb-computer/swc-bidder";
fn cid_of(sha256: &str) -> Option<String> {
let mut bytes = vec![0x01u8, 0x55, 0x12, 0x20];
for i in (0..sha256.len()).step_by(2) {
bytes.push(u8::from_str_radix(sha256.get(i..i + 2)?, 16).ok()?);
}
if bytes.len() != 36 {
return None;
}
const A: &[u8] = b"abcdefghijklmnopqrstuvwxyz234567";
let (mut s, mut buf, mut bits) = (String::from("b"), 0u32, 0u32);
for b in bytes {
buf = (buf << 8) | b as u32;
bits += 8;
while bits >= 5 {
bits -= 5;
s.push(A[((buf >> bits) & 31) as usize] as char);
}
}
if bits > 0 {
s.push(A[((buf << (5 - bits)) & 31) as usize] as char);
}
Some(s)
}
fn manifest(project: &str, b: &Value, now: &str) -> Option<Value> {
Some(json!({ "$type": "software.release.manifest", "project": project, "createdAt": now, "artifacts": [{
"$type": "software.release.defs#httpArtifact", "name": "socialweb-computer-linux-amd64", "url": b["url"],
"cid": cid_of(b["sha256"].as_str()?)?, "size": b["size"], "target": { "os": "linux", "arch": ["amd64"] } }] }))
}
fn run_0020(run: Run<Value>) -> Result<Handle, String> {
let args = &run.args;
let now = args["now"].as_str().unwrap_or_default().to_string();
let mut s = S::new(run.state, &now);
if let Some(h) = steps::market_event(&mut s, &run.event) {
return Ok(h);
}
if args["target"] == "prod" {
return Ok(s.skip("staging only: it installs a bidder as root on a staging host"));
}
let builds: Vec<Value> = args["builds"].as_array().cloned().unwrap_or_default();
if builds.len() < 2 {
return Ok(s.skip("0020 needs two published builds with the follower (input builds)"));
}
let did = args["did"].as_str().ok_or("did")?.to_string();
let first = args["bidders"][0]["name"].as_str().unwrap_or_default();
let Some(rest) = first.strip_prefix("b1-") else {
return Ok(s.skip("0020 names its bidder after the target's b1- bidder"));
};
let handle = format!("b3-{rest}");
let project = format!("at://{did}/software.release.project/{PROJECT}");
let root = |id: &str, cmd: String| host(id, "root.exec", json!({ "cmd": cmd, "stdinPassword": false }));
let bin = "/root/swc-st-socialweb-computer";
let mut h = Handle::new();
match run.event {
Event::Start => h = h.call(host("put", "root.putBinary", json!({}))).timer("deadline", 40 * MIN),
Event::Timer { id } if id == "deadline" => return Ok(s.fail(format!("not done in 40 min (phase {})", s.phase()))),
Event::Timer { id } if id == "poll" => h = h.call(steps::get_record("hb", &format!("at://{handle}/{HB}/self"))),
Event::Result { id, result, .. } => {
let o = match out(&s, &id, result.output()) {
Ok(o) => o,
Err(_) if id == "hb" => Value::Null,
Err(f) => return Ok(f),
};
if o.get("exit").is_some_and(|e| e != 0) {
return Ok(s.fail(format!("{id}: exit {} {}", o["exit"], o["stderr"])));
}
match id.as_str() {
"put" => h = h.call(root("install", format!("{bin} install bidder --handle {handle} --market-network-file /home/stg/stg/net.json -- --release-repo {did}"))),
"install" => {
s.set("up");
s.mark("wait");
h = h.timer("poll", 10_000);
}
"hb" => {
let running = o["value"]["version"]["version"].as_str().unwrap_or_default().to_string();
let want = match s.phase().as_str() {
"up" => "",
"a" => builds[0]["version"].as_str().unwrap_or_default(),
_ => builds[1]["version"].as_str().unwrap_or_default(),
};
if running.is_empty() || (!want.is_empty() && running != want) {
if s.since("wait") > 600.0 {
return Ok(s.fail(format!("phase {}: the heartbeat names {running:?}, want {want:?}", s.phase())));
}
h = h.timer("poll", 10_000);
} else if s.is("up") {
s.reading("installed_version", json!(running));
let m = manifest(&project, &builds[0], &now).ok_or("builds[0] sha256")?;
h = h.call(host("ab", "release.put", json!({ "records": [
{ "collection": "software.release.project", "rkey": PROJECT, "record": { "$type": "software.release.project", "name": PROJECT, "createdAt": now } },
{ "collection": "software.release.manifest", "rkey": "m-a", "record": m } ] })));
} else if s.is("a") {
s.reading("followed_a_s", json!(s.since("wait")));
let m = manifest(&project, &builds[1], &now).ok_or("builds[1] sha256")?;
h = h.call(host("mb", "release.put", json!({ "records": [{ "collection": "software.release.manifest", "rkey": "m-b", "record": m }] })));
} else {
s.reading("followed_b_s", json!(s.since("wait")));
s.set("cleanup");
let uris: Vec<String> = ["software.release.channel/socialweb-computer:rc", "software.release.version/socialweb-computer:a",
"software.release.version/socialweb-computer:b", "software.release.manifest/m-a", "software.release.manifest/m-b",
"software.release.project/socialweb-computer"].iter().map(|r| format!("at://{did}/{r}")).collect();
h = h.call(host("gone", "release.delete", json!({ "uris": uris })));
}
}
"ab" | "mb" => {
let recs = o["records"].as_array().cloned().unwrap_or_default();
let m = recs.last().cloned().unwrap_or_default();
let (b, key) = if id == "ab" { (&builds[0], "a") } else { (&builds[1], "b") };
s.st["manifest"] = m.clone();
s.st["vkey"] = json!(key);
h = h.call(host("v", "release.put", json!({ "records": [{ "collection": "software.release.version", "rkey": format!("{PROJECT}:{key}"),
"record": { "$type": "software.release.version", "project": project, "version": b["version"], "manifest": { "uri": m["uri"], "cid": m["cid"] }, "createdAt": now } }] })));
}
"v" => {
let v = o["records"][0].clone();
h = h.call(host("ch", "release.put", json!({ "records": [{ "collection": "software.release.channel", "rkey": format!("{PROJECT}:rc"),
"record": { "$type": "software.release.channel", "project": project, "name": "rc", "version": { "uri": v["uri"], "cid": v["cid"] }, "updatedAt": now } }] })));
}
"ch" => {
let next = if s.st["vkey"] == "a" { "a" } else { "b" };
s.set(next);
s.mark("wait");
h = h.timer("poll", 10_000);
}
"gone" => h = h.call(root("uninstall", format!("{ST}/bin/current/socialweb-computer uninstall bidder --account swc-bidder --purge"))),
"uninstall" => return Ok(s.pass()),
_ => {}
}
}
_ => {}
}
Ok(s.keep(h))
}
entries! { run => run_0020 }
tests/modules/acc-0020/Cargo.tomlnew+14−0
@@ -0,0 +1,14 @@
[package]
name = "acc-0020"
version = "0.1.0"
edition.workspace = true
license.workspace = true
publish.workspace = true
[lib]
crate-type = ["cdylib"]
[dependencies]
abi.workspace = true
serde_json.workspace = true
steps.workspace = true
tests/modules/acc-0020/module.jsonnew+19−0
@@ -0,0 +1,19 @@
{
"name": "acc-0020",
"description": "Acceptance 0020: an installed bidder follows the software.release channel (plan 0040 step 4).",
"actions": [
{
"entry": "run",
"label": "Run 0020",
"description": "Install a bidder on a staging root host with --release-repo the account, point the account's rc channel at build A, then B: the bidder's heartbeat names each; then delete the records and uninstall."
}
],
"calls": [
"computer.socialweb.test.root.putBinary",
"computer.socialweb.test.root.exec",
"computer.socialweb.test.release.put",
"computer.socialweb.test.release.delete",
"com.atproto.repo.getRecord"
],
"hooks": []
}
tests/modules/Cargo.lock+9−0
@@ -174,6 +174,15 @@ dependencies = [
"steps",
]
[[package]]
name = "acc-0020"
version = "0.1.0"
dependencies = [
"abi",
"serde_json",
"steps",
]
[[package]]
name = "anyhow"
version = "1.0.104"
tests/modules/Cargo.toml+1−1