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

socialweb.computer/socialweb-computer-kcp

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

1 collaborator
0
0

tests: a refused accept is declined, not left (0002, 0006); ops route serves the decline line

Merged johnandersen777.bsky.social asked to merge into main from socialweb.computer/socialweb-computer-kcp:phase-2
docs/plans/0040-findings.md+32−0
@@ -1722,3 +1722,35 @@ Each: what was seen (with the log), the cause, the fix, its proof.
dump's own logs, ticks whole, 4 MiB in all, the rest in skipped.txt), asked by `tests/modules/staging/src/lib.rs`
`fetch_runs` after the suite logs of a failed suite (both layouts; reading `gateRuns`). Proof still to come from CI: a
staging run with 0005:b then 0014 (the reading `r2_vms_gone_s`, and a fail run's `logs/gate-runs/`).
- 0002:run FAIL on prod by hand (2026-11-18 ~19:45Z, alice, main with the none_since fix; run dir
`~/.tmp/swc-system-tests/runs/0002-composition-1795029145880`, log `~/.tmp/prod-hand/rerun/0002-run.log`): `records of
the sessions left: [".../market.accept/d2wukrlfmgtvr"] []`.
SEEN: the accept (alice's repo, createdAt 19:13:53.227Z, the entry's `since` 19:12:25.939Z) accepts bid
`bid-da5da7ff685b278a40a8` of swc-dev-bidder-1 (did:plc:4srtkmossz4zzfzszpjpvoww) on RFP `3n2mban644w22`, made during
the entry's transient command (`ssh.exec` 19:12:58Z to 19:14:57Z), signed by alice's own key. The ssh gateway's core
log (socialweb.computer `.../sg/logs/core.log`, alice's per-DID requester): seven bids recovered for that RFP, then
19:13:55Z `submitAccept_retry` and 19:13:56Z `requester_submit_accept_declined` status 409 `CapacityExceeded` "the RFP
asks for 4608M of memory; this bidder's running and reserved guests hold 63282M of its 64279M". The requester took
hat-8's bid (both session receipts are hat-8's, records 6/6 deleted); the RFP is deleted. So: this entry's own
session, a refused accept, not a leftover of a release.
CAUSE: the requester keeps a refused accept by design (`internal/market/requester/runner.go` `replaceDeclined`;
docs/acceptance/0014: "the requester keeps that accept (a bidder may still act on it; old records are not deleted)"),
and `request.records`/`requester.records` already leave those out (`more::declined_accepts`, finding of 0005:b above);
`assert.noneSince`, a createdAt scan of the repo, had no such exclusion. Staging's 0002:run passes because no accept of
its sessions was refused in those runs (not checked per run); 0006:run (`request.records` then `noneSince`) has the
same exposure.
FIX: one rule, `testkit::requester::declined_accepts(lines)` (msg `requester_submit_accept_declined`, its `accept`),
used by `request.records` and `requester.records` (each now also returns `declined`) and by `gateway.log` (over the
DID's lines, both over ssh and over the ops route: `ops::gateway_lines`, `declined`); `none_since` takes `declined`
and reports those accepts as `declined`, not `left`; acc-0002 passes gateway.log's, acc-0006 request.records'; each
records `declined_accepts` in its readings. Every other record created since is still asserted gone. The ops route
(CI prod) serves only `opsread.RequesterMessages` with `RequesterLineKeys`: `requester_submit_accept_declined` and
`accept` added (`internal/contract/opsread/opsread.go`, docs/SYSTEM.md), within the owner-approved design of those
routes ("each one fixed projection of the fields the tests read"); it needs a gateway deploy to reach prod.
PROOF (prod, read-only, `--instance assert --entry none_since`, `since` 19:12:25.939Z, as bob: no sign-in): without
`declined` `left` is that accept (run `0002-composition-1795030491938`); with it `left: []`, `declined: [that accept]`,
`errors: []`, 10.3 s (`-1795030503030`). 0002:run whole on prod with this tree (rc-0002b, alice, 19:40:55Z to
19:52:09Z): PASS 674 s, `declined_accepts: []` (no accept refused this time; run `0002-composition-1795030854965`, log
`~/.tmp/rc-0002/0002-run.log`; a first try failed at the sign-in, headless Chrome "Page.captureScreenshot: Not attached
to an active page" after Authorize, `~/.tmp/oauth-signin/2026-11-18T193930830Z`). Unproven: a whole run with a refusal
through gateway.log; the ops route's new line before a gateway deploy.
docs/SYSTEM.md+1−1
@@ -201,7 +201,7 @@ only). The gateway's `getRequesterLog` is on its https web origin.
| `getHealth` | none | `{unit, started, errors, startupErrors, restarts, vmProcesses, errorSample[<=3] {time, msg, err<=160}, guestImageReadyAt, guestImageUnready}` of the core since its process started (startup: its first 10 min; restarts: the unit's `NRestarts`) |
| `getLog` | `msg` (one of the names in `opsread.Messages`), `subject` (optional: a ComputeVM name, `vm-<name>` or an at:// URI) | `{log, count, lines[<=50]}`: lines since the process started holding that message's texts and the subject; a line is `time`, `msg` and the fixed keys of `opsread.LineKeys` |
| `getVmMemory` | `name` | `{unit, current, high, max, swapMax, events}` of the VM unit's memory cgroup |
| `getRequesterLog` | `did`, `since` (RFC 3339) | `{lines}`: the ssh gateway core's lines of that DID since then whose msg is one of `opsread.RequesterMessages`, as `time`, `msg`, `subhandle`, `contract`, `receipt`, `deleted`, `of`, `reason` |
| `getRequesterLog` | `did`, `since` (RFC 3339) | `{lines}`: the ssh gateway core's lines of that DID since then whose msg is one of `opsread.RequesterMessages`, as `time`, `msg`, `subhandle`, `contract`, `receipt`, `deleted`, `of`, `reason`, `accept` |
The log is the core's own: its stderr file when it has one (a dev instance, the ssh gateway: `logs/core.log`, every
logger of the process writes there). Else, once the secret is configured, the process's one log handler
internal/contract/opsread/opsread.go+2−1
@@ -64,9 +64,10 @@ var RequesterMessages = []string{
"requester_released",
"requester_release_settled_by_termination",
"requester_contract_records_deleted",
"requester_submit_accept_declined",
}
var RequesterLineKeys = []string{"subhandle", "contract", "receipt", "deleted", "of", "reason"}
var RequesterLineKeys = []string{"subhandle", "contract", "receipt", "deleted", "of", "reason", "accept"}
var (
vmName = regexp.MustCompile(`^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$`)
tests/host/src/more.rs+6−9
@@ -1337,14 +1337,12 @@ printf '{{"unit":"%s","current":%s,"high":"%s","max":"%s","swapMax":"%s","events
return Some(Err("the target names no gateway.log".into()));
};
on_host(Some(&l.host), &format!("grep -F '\"did\":\"{did}\"' '{}' || true", l.path.replace('\'', ""))).await.map(|o| {
let lines: Vec<Value> = o
let all: Vec<Value> = o
.lines()
.filter_map(|l| serde_json::from_str::<Value>(l).ok())
.filter(|v| v["time"].as_str().is_some_and(|t| t >= since))
.filter(|v| msgs.is_empty() || v["msg"].as_str().is_some_and(|m| msgs.iter().any(|x| x == m)))
.map(|v| json!({ "time": v["time"], "msg": v["msg"], "subhandle": v["subhandle"], "contract": v["contract"], "receipt": v["receipt"], "deleted": v["deleted"], "of": v["of"], "reason": v["reason"] }))
.collect();
json!({ "lines": lines })
crate::ops::gateway_lines(&all, &msgs)
})
}
"page.fetch" => match input["url"].as_str() {
@@ -1521,7 +1519,7 @@ printf '{{"unit":"%s","current":%s,"high":"%s","max":"%s","swapMax":"%s","events
logs.push(state.join(format!("{name}.log")));
let declined = declined_accepts(&logs);
Ok(json!({ "uris": uris_in(&logs, &a.did).into_iter().filter(|u| !kept_by_rule(u) && !declined.contains(u)).collect::<Vec<_>>(),
"declinedAccepts": declined.len() }))
"declinedAccepts": declined.len(), "declined": declined }))
}
(Err(e), _) | (_, Err(e)) => Err(e),
},
@@ -2259,10 +2257,9 @@ impl Swc {
}
}
/// The accepts a bidder declined (409 CapacityExceeded), by these logs: they stay in the repo by design (a bidder may
/// still act on one), so they are not leftovers of a release.
pub(super) fn declined_accepts(paths: &[PathBuf]) -> std::collections::HashSet<String> {
log_lines_all(paths, "requester_submit_accept_declined").into_iter().filter_map(|l| l["accept"].as_str().map(String::from)).collect()
/// The accepts a bidder declined, by these log files (`testkit::requester::declined_accepts`).
pub(super) fn declined_accepts(paths: &[PathBuf]) -> Vec<String> {
testkit::requester::declined_accepts(&log_lines_all(paths, testkit::requester::ACCEPT_DECLINED))
}
/// Every JSON log line of `msg` in these files.
tests/host/src/ops.rs+12−5
@@ -174,11 +174,7 @@ impl Ops {
pub async fn gateway_log(&self, did: &str, since: &str, msgs: &[String]) -> Result<Value, String> {
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)))
.map(|v| json!({ "time": v["time"], "msg": v["msg"], "subhandle": v["subhandle"], "contract": v["contract"], "receipt": v["receipt"], "deleted": v["deleted"], "of": v["of"], "reason": v["reason"] }))
.collect();
Ok(json!({ "lines": lines }))
Ok(gateway_lines(o["lines"].as_array().map(Vec::as_slice).unwrap_or_default(), msgs))
}
/// A kube call on a cluster served here; None: the cluster is not one of these.
@@ -216,6 +212,17 @@ impl Ops {
}
}
/// gateway.log's answer from the ssh gateway's lines of a DID (over ssh or getRequesterLog): those whose msg is one of
/// `msgs` (none: all), and `declined`, the accepts a bidder refused among all of them (kept by design, not leftovers).
pub fn gateway_lines(all: &[Value], msgs: &[String]) -> Value {
let lines: Vec<Value> = all
.iter()
.filter(|v| msgs.is_empty() || v["msg"].as_str().is_some_and(|m| msgs.iter().any(|x| x == m)))
.map(|v| json!({ "time": v["time"], "msg": v["msg"], "subhandle": v["subhandle"], "contract": v["contract"], "receipt": v["receipt"], "deleted": v["deleted"], "of": v["of"], "reason": v["reason"], "accept": v["accept"] }))
.collect();
json!({ "lines": lines, "declined": testkit::requester::declined_accepts(all) })
}
/// The getLog message and subject of one bidder.logCount text group: the known message whose texts the group holds, and
/// the one text left (a ComputeVM name, `vm-<name>` or an at:// URI), if any.
fn message_of(text: &[String]) -> Option<(&'static str, Option<String>)> {
tests/host/src/swc.rs+1−1
@@ -1321,7 +1321,7 @@ impl Swc {
identlink::market::release_rkey(r)
));
}
Ok(json!({ "uris": uris }))
Ok(json!({ "uris": uris, "declined": declined }))
}
"repo.listCreated" => self.list_created(&input).await,
"account.envFile" => {
tests/modules/acc-0002/src/lib.rs+2−1
@@ -98,9 +98,10 @@ fn run_0002(run: Run<Value>) -> Result<Handle, String> {
if !done {
return Ok(s.keep(h.timer("log", 15_000)));
}
h = h.call(host("since", "assert.noneSince", json!({ "did": args["did"], "since": s.st["since"] })));
h = h.call(host("since", "assert.noneSince", json!({ "did": args["did"], "since": s.st["since"], "declined": o["declined"] })));
}
"since" => {
s.reading("declined_accepts", o["declined"].clone());
if o["left"].as_array().is_none_or(|l| !l.is_empty()) || o["errors"].as_array().is_some_and(|e| !e.is_empty()) {
return Ok(s.fail(format!("records of the sessions left: {} {}", o["left"], o["errors"])));
}
tests/modules/acc-0006/src/lib.rs+3−1
@@ -161,6 +161,7 @@ fn compat_handler(run: Run<Value>) -> Result<Handle, String> {
}
"records" => {
s.reading("records_checked", o["uris"].as_array().map_or(0, Vec::len));
s.st["declined"] = o["declined"].clone();
h = h.call(host("gone", "assert.recordsGone", json!({ "uris": o["uris"] })));
}
"gone" => {
@@ -169,9 +170,10 @@ fn compat_handler(run: Run<Value>) -> Result<Handle, String> {
}
// the logs name only the run's records: the release process's own (market.event, vm.delete) show in a
// scan of the repo since the run started
h = h.call(host("since", "assert.noneSince", json!({ "did": args["did"], "since": s.st["since"] })));
h = h.call(host("since", "assert.noneSince", json!({ "did": args["did"], "since": s.st["since"], "declined": s.st["declined"] })));
}
"since" => {
s.reading("declined_accepts", o["declined"].clone());
if o["left"].as_array().is_none_or(|l| !l.is_empty()) || o["errors"].as_array().is_some_and(|e| !e.is_empty()) {
return Ok(s.fail(format!("records created during the run left: {} {}", o["left"], o["errors"])));
}
tests/modules/assert/src/lib.rs+16−10
@@ -277,20 +277,25 @@ fn list(id: String, did: &str, col: &str, cursor: Option<&str>) -> Call {
steps::host(&id, "repo.listCreated", json!({ "repo": did, "collection": col, "limit": 100, "cursor": cursor }))
}
/// A page's records created at or after `since` into `left`, those with no createdAt into `undated`.
fn tally(st: &mut Value, page: &Value, since: f64) {
/// A page's records created at or after `since` into `left` (an accept a bidder refused, one of `declined`, into
/// `declined`: the requester keeps it by design), those with no createdAt into `undated`.
fn tally(st: &mut Value, page: &Value, since: f64, declined: &[Value]) {
for r in page["records"].as_array().into_iter().flatten() {
match r["createdAt"].as_str() {
Some(t) if steps::secs(t) >= since => st["left"].as_array_mut().unwrap().push(r["uri"].clone()),
Some(t) if steps::secs(t) >= since => {
let to = if declined.contains(&r["uri"]) { "declined" } else { "left" };
st[to].as_array_mut().unwrap().push(r["uri"].clone())
}
Some(_) => {}
None => st["undated"].as_array_mut().unwrap().push(r["uri"].clone()),
}
}
}
/// none_since {did, since, prefixes?}: no record of a collection under `prefixes` (default the market's and compute's)
/// none_since {did, since, prefixes?, declined?}: no record of a collection under `prefixes` (default the market's and compute's)
/// in the repo of `did` was created at or after `since` (its createdAt): {left, undated, errors} (the hand runs' full
/// listRecords scan; it sees records whose URIs no log of the run names, e.g. a separate release process's).
/// listRecords scan; it sees records whose URIs no log of the run names, e.g. a separate release process's). `declined`:
/// the accepts the requester's log says a bidder refused (the caller's host call gives them), reported, not left.
fn none_since_handler(run: Run<Value>) -> Result<Handle, String> {
let did = run.args["did"].as_str().ok_or("did is required")?.to_string();
let since = steps::secs(run.args["since"].as_str().ok_or("since is required")?);
@@ -298,7 +303,8 @@ fn none_since_handler(run: Run<Value>) -> Result<Handle, String> {
Some(p) => p.iter().filter_map(|x| x.as_str().map(String::from)).collect(),
None => MARKET.iter().map(|p| p.to_string()).collect(),
};
let fresh = json!({ "pending": 0, "left": [], "undated": [], "errors": [] });
let declined: Vec<Value> = run.args["declined"].as_array().cloned().unwrap_or_default();
let fresh = json!({ "pending": 0, "left": [], "declined": [], "undated": [], "errors": [] });
let (c, mut st) = clock(&run, &fresh);
Ok(match run.event {
Event::Start | Event::Timer { .. } => Handle::new()
@@ -308,7 +314,7 @@ fn none_since_handler(run: Run<Value>) -> Result<Handle, String> {
let o = result.output()?.clone();
let cols: Vec<String> = o["collections"].as_array().into_iter().flatten().filter_map(|x| x.as_str()).filter(|x| prefixes.iter().any(|p| x.starts_with(p.as_str()))).map(String::from).collect();
if cols.is_empty() {
return Ok(Handle::new().result(json!({ "left": [], "undated": [], "errors": [], "seconds": took(c, &st) })).done());
return Ok(Handle::new().result(json!({ "left": [], "declined": [], "undated": [], "errors": [], "seconds": took(c, &st) })).done());
}
let mut h = Handle::new();
for (i, col) in cols.iter().enumerate() {
@@ -325,10 +331,10 @@ fn none_since_handler(run: Run<Value>) -> Result<Handle, String> {
if let Some(cursor) = o["cursor"].as_str().filter(|_| o["records"].as_array().is_some_and(|r| r.len() == 100) && page < 50) {
let col = o["records"][0]["uri"].as_str().unwrap_or_default().split('/').nth(3).unwrap_or_default().to_string();
let call = list(format!("l-{i}-{}", page + 1), &did, &col, Some(cursor));
tally(&mut st, o, since);
tally(&mut st, o, since, &declined);
return Ok(Handle::new().call(call).state(st));
}
tally(&mut st, o, since);
tally(&mut st, o, since, &declined);
}
Err(e) => st["errors"].as_array_mut().unwrap().push(json!(e)),
}
@@ -340,7 +346,7 @@ fn none_since_handler(run: Run<Value>) -> Result<Handle, String> {
if !clean && let Some(h) = again(c, &st, fresh) {
return Ok(h);
}
Handle::new().result(json!({ "left": st["left"], "undated": st["undated"], "errors": st["errors"], "seconds": took(c, &st) })).done()
Handle::new().result(json!({ "left": st["left"], "declined": st["declined"], "undated": st["undated"], "errors": st["errors"], "seconds": took(c, &st) })).done()
}
_ => Handle::new().state(st),
})
tests/modules/assert/module.json+1−1
@@ -5,7 +5,7 @@
{ "entry": "records_gone", "label": "Records gone", "description": "Reads each record 3 times: left, errors.", "readOnly": true },
{ "entry": "tombstoned", "label": "Tombstoned", "description": "PLC log/last plc_tombstone and no document: alive.", "readOnly": true },
{ "entry": "agent_chain", "label": "Agent chain", "description": "The renter -> R2 -> agent pair + grant chain and walk.", "readOnly": true },
{ "entry": "none_since", "label": "None since", "description": "No market or compute record of the DID created since a time (every page, {uri, createdAt} each, from the host): left, undated, errors.", "readOnly": true }
{ "entry": "none_since", "label": "None since", "description": "No market or compute record of the DID created since a time (every page, {uri, createdAt} each, from the host): left, declined (accepts a bidder refused, given by the caller: kept by design), undated, errors.", "readOnly": true }
],
"calls": ["com.atproto.repo.getRecord", "com.atproto.repo.describeRepo", "computer.socialweb.test.repo.listCreated", "com.fedfork.exec.identlink.plc", "com.fedfork.exec.identlink.walk"],
"implements": [
tests/testkit/src/requester.rs+17−0
tests/testkit/README.md+1−1