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

socialweb.computer/socialweb-computer-kcp

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

1 collaborator
0
0

findings 79-81, 8d DNS handles, 0020 in CI, install bidder --market-network-file

Merged johnandersen777.bsky.social asked to merge into main from socialweb.computer/socialweb-computer-kcp:c0020-roothost
cmd/socialweb-computer/install.go+2−2
@@ -23,7 +23,7 @@ import (
)
var installOptions = []string{backendOpt, "handle", "account", "state-dir", "vm-slots", "dry-run", "adopt-account", "json", "root", "unit-prefix", "allow-dev-binary",
install.OptKcpFront, install.OptTLSFront, install.OptCertFront, install.OptSpecFile, install.OptBidderSpecFile, install.OptGuestImg, install.OptGuestImgBase, install.OptReadyTimeout, install.OptNetworkTimeout, install.OptNoGuestLANUDP, install.OptGuestHostUDP, install.OptBidderPolicy, install.OptBidderOperator, install.OptComputeKinds, install.OptCPUOvercommit, install.OptVMM}
install.OptKcpFront, install.OptTLSFront, install.OptCertFront, install.OptSpecFile, install.OptBidderSpecFile, install.OptNetworkFile, install.OptGuestImg, install.OptGuestImgBase, install.OptReadyTimeout, install.OptNetworkTimeout, install.OptNoGuestLANUDP, install.OptGuestHostUDP, install.OptBidderPolicy, install.OptBidderOperator, install.OptComputeKinds, install.OptCPUOvercommit, install.OptVMM}
var installRequesterOptions = []string{backendOpt, "name", "account", "state-dir", "dry-run", "adopt-account", "json", "root", "unit-prefix", "allow-dev-binary",
install.OptReadyTimeout, install.OptNetworkTimeout}
@@ -116,7 +116,7 @@ func runInstall(role hostcontract.Role) verbFunc {
continue
}
if v := passed(k); v != "" {
if k == install.OptSpecFile || k == install.OptBidderSpecFile {
if k == install.OptSpecFile || k == install.OptBidderSpecFile || k == install.OptNetworkFile {
if abs, err := filepath.Abs(v); err == nil {
v = abs
}
docs/acceptance/0020-bidder-follows-release.md+4−1
@@ -9,7 +9,9 @@ SWC_TARGET=<staging target.json> cargo run -q -p swc-test-host -- compositions/0
```
A is the installed build's own `main/<commit>` binary; B defaults to `main/bce9465b` (the first follower that reads the network's
PLC). The host fetches each for its sha256, size and version.
PLC). The host fetches each for its sha256, size and version. The bidder is installed on the target's root host
(`rootHosts`; on staging the atproto VM, `root@127.0.0.1`) with `--market-network-file` and a `--bidder-spec-file` naming
`release-repo`; its heartbeat is read at its agent DID (its offering's repo), not its handle.
Pass: a 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
@@ -19,3 +21,4 @@ prod, or when the installed build has no `main/<commit>` binary (a branch).
| When | Target | Result |
|---|---|---|
| 2026-11-17 | staging (hand cycle, ab95532f) | PASS: followed A in 10 s, B (bce9465b) in 30 s |
docs/plans/0040-release-pipeline.md+1−2
@@ -187,8 +187,7 @@ Version and channel:
A bidder is on a release when it runs the binary of the release's artifact (CIDv1 raw sha2-256 of its own executable
equals the artifact's CID), not when version strings match: CI's rcs are main builds (`v0.0.0-rc99.0.<time>-<sha>`), so
a name like `v0.0.1-rc0` is never a binary's own version. The channel is `release-channel` (`install bidder -- --release-channel
rc|stable`), default `rc` for a version with `-rc`, else `stable`.
a name like `v0.0.1-rc0` is never a binary's own version. The channel is the `release-channel` option (an installed bidder's `--bidder-spec-file`: `options: [{name: release-channel, value: rc|stable}]`; the release repo the same way, `release-repo`), default `rc` for a version with `-rc`, else `stable`.
The standard kcp pattern: an `AtprotoRecordWatch` on
`at://did:plc:gmlkrhimoueejcertevr4hl3/software.release.channel/socialweb-computer:<rc|stable>`, fed by the relay and
docs/plans/0044-ci-by-hand.md+6−3
@@ -380,9 +380,12 @@ 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". Cause: staging bidder b2 published no heartbeat until 17:31:48 (0006 reading `guestImageReadyAt`; b1 17:08:52), because a bidder writes no offering/heartbeat until its guest image verifies, and b2's 1.5 GB rootfs download from Spaces ran ~1 MB/s for 24 min (b1, same host, same object, same minute: 66 s; probes now 20-65 MB/s from hat-8 and from both staging VMs). `guestimage.fetchOne` had only the 30 min FetchTimeout, no per-attempt limit, no resume. R2 dropped b2 (`no fresh heartbeat`) and b1 was full. Fix: each attempt gets 60 s + 1 s per 5 MB still to fetch, then resumes with `Range` from the bytes already hashed (hand proof: a stream stalled at 10 of 40 MiB resumes and verifies in 70 s). Also: `requester_bidder_discovery` names each drop and its reason. Lesson: I cleaned up the frozen run before finding this; the cause came from the CI artifacts (0006 readings) | fixed |
| 77 | CI test on b8b8ed18, 0006 and 0008 FAIL: b2's one startup ERROR `the HostProcess supervisor stopped` at 20:08:33.874: `APIBinding hostprocesses in root ... metadata.labels[claimed.internal.apis.kcp.io/...]: Invalid value: ""`. Cause: the computevm component and the HostProcess supervisor apply the same hostprocesses set at once (20:08:33.632/.665/.861); kcpapply skips an unchanged APIBinding only on a strict spec match, and the live spec carries the server default `deletionPolicy: Delete`, so every re-apply was an update; one landed after the create (20:08:33) and before `kcp-apibinding` stamped the claimed label (20:08:34), and admission refused it. Fix: an APIBinding is unchanged when every field the manifest declares matches the live spec (`covered`), so repeated and concurrent applies send no update Still red on bce9465b (the covered fix in): b1 `policy-binding.yaml` in set provider, computevm and hostprocess both applying it at 21:19:03.6, both reading no binding, so the second apply was an update before kcp stamped the label (live spec covered, managers socialweb-computer then kcp-apibinding 1 s later). Root: two components of one core apply the same set at once. Fix 2: kcpapply serializes Apply per (kcp, base, set name) in the process, so the second reads the created binding and sends nothing | fixed (2) |
| 78 | CI test on 7bc127f1 (0006/0008 green: 77 fixed), 0013 FAIL `sbx1 is "Requesting" after the restart`. Cause: a resumed contract re-enters the guest wait and replays its events; network, host keys, secrets and image skip an event already recorded, the sandbox case did not, so the replayed sandbox event wrote `Requesting` ("awaitingGuestOnNetwork") over the Held contract (22:55:06.799) before the wait ended and wrote Held again; 0013's one read after the restart landed in that window. Fix: a sandbox event equal to the recorded one is skipped | fixed |
| 76 | CI test on 62841d92, 0005 FAIL "R2 not Held in 10 min". Cause: staging bidder b2 published no heartbeat until 17:31:48 (0006 reading `guestImageReadyAt`; b1 17:08:52), because a bidder writes no offering/heartbeat until its guest image verifies, and b2's 1.5 GB rootfs download from Spaces ran ~1 MB/s for 24 min (b1, same host, same object, same minute: 66 s; probes now 20-65 MB/s from hat-8 and from both staging VMs). `guestimage.fetchOne` had only the 30 min FetchTimeout, no per-attempt limit, no resume. R2 dropped b2 (`no fresh heartbeat`) and b1 was full. Fix: each attempt gets 60 s + 1 s per 5 MB still to fetch, then resumes with `Range` from the bytes already hashed (hand proof: a stream stalled at 10 of 40 MiB resumes and verifies in 70 s). Also: `requester_bidder_discovery` names each drop and its reason. Lesson: I cleaned up the frozen run before finding this; the cause came from the CI artifacts (0006 readings) | fixed, proven: main 85457330 release+test green (2026-11-17) |
| 77 | CI test on b8b8ed18, 0006 and 0008 FAIL: b2's one startup ERROR `the HostProcess supervisor stopped` at 20:08:33.874: `APIBinding hostprocesses in root ... metadata.labels[claimed.internal.apis.kcp.io/...]: Invalid value: ""`. Cause: the computevm component and the HostProcess supervisor apply the same hostprocesses set at once (20:08:33.632/.665/.861); kcpapply skips an unchanged APIBinding only on a strict spec match, and the live spec carries the server default `deletionPolicy: Delete`, so every re-apply was an update; one landed after the create (20:08:33) and before `kcp-apibinding` stamped the claimed label (20:08:34), and admission refused it. Fix: an APIBinding is unchanged when every field the manifest declares matches the live spec (`covered`), so repeated and concurrent applies send no update Still red on bce9465b (the covered fix in): b1 `policy-binding.yaml` in set provider, computevm and hostprocess both applying it at 21:19:03.6, both reading no binding, so the second apply was an update before kcp stamped the label (live spec covered, managers socialweb-computer then kcp-apibinding 1 s later). Root: two components of one core apply the same set at once. Fix 2: kcpapply serializes Apply per (kcp, base, set name) in the process, so the second reads the created binding and sends nothing | fixed, proven: main 85457330 release+test green (2026-11-17) |
| 78 | CI test on 7bc127f1 (0006/0008 green: 77 fixed), 0013 FAIL `sbx1 is "Requesting" after the restart`. Cause: a resumed contract re-enters the guest wait and replays its events; network, host keys, secrets and image skip an event already recorded, the sandbox case did not, so the replayed sandbox event wrote `Requesting` ("awaitingGuestOnNetwork") over the Held contract (22:55:06.799) before the wait ended and wrote Held again; 0013's one read after the restart landed in that window. Fix: a sandbox event equal to the recorded one is skipped | fixed, proven: main 85457330 release+test green (2026-11-17) |
| 79 | CI test on e36c4353, 0013 stuck in phase agent (no requester_agent_identity) from 00:54 until its 75 min deadline. Cause: R2 in the agent1 guest (a guest of a staging bidder that is a guest of hat-8) ran `run request` with its kcp starved (readyz 80 s, every phase ~30 s, kcp `Handler timeout`s, 8.5 min CPU in 4.5 min on 2 vCPUs) and exited at 00:57:54 `compose: no Ready APIBinding ... within 3m0s`; socialweb-r2.service ran once (no Restart), so R2 never reported its DID, was never verified, the agent's env stayed empty (`ATP_USERNAME` unset in /etc/atirc/atirc.env) and atirc-agent waited 100+ restarts. Fix: socialweb-r2.service `Restart=on-failure` (10 s, no start limit); its state is kept across a stop, so a restart resumes. A deliberate stop (0005 r2fail, guest.r2Release) is not restarted | fixed |
| 80 | CI test on e36c4353, 0014:exhausted FAIL `waits for capacity, not after every bidder refused it ...: 1 refusals, newRfp 1`. Cause: both full bidders bid; the accept to b2 got 409 CapacityExceeded and the requester went to the next bid, whose selection re-reads offerings: b1's read answered `HTTP 503: NoSubscriber` (its PDS's ingress tunnel between subscribers for an instant), which dropped the bidder that had bid 4 s before, so the round had no bids and a new RFP went out. Fix: an offering read that fails other than not-found or invalid is read again (3 attempts, 1 s then 2 s) before the candidate is dropped Deeper: the round's discovery at 02:14:36 hit b1's 503: the relay evicts every ingress subscriber when its service-auth token expires (every 5 min, `subscriber_expired`, here 02:14:34) and the client reconnects only after the eviction, a gap of ~50 ms that was 2.95 s here (`subscriber_connected` 02:14:36.956); the next-bid path reused that round's discovery, so b1 stayed "offerings read failed". Fix 2: the subscription renews in place: before its token expires the client sends `renew` with a fresh subscribe token on the same connection and the relay extends the subscriber (`subscriber_renewed`): no eviction, no reconnect, no gap; an older relay ignores the frame and evicts as before | fixed |
| 81 | Hand run of 0020 on 347004ce: the installed bidder logs `releasefollow_on` but never sees a channel; prod's hats the same (on rc169, `rc` names rc169, no `releasefollow_seen`). Cause: the bidder's core applies its set with only the `association-watch` optional phase (`marketbidder.go` phases), so `release-channel-watch@<profile>` was never applied and no AtprotoRecordWatch `release-channel` exists. Fix: the phase is always included (a profile without it is skipped by infraSet). Plan 0040 step 4 was never live on prod before this Then the watch, made by hand, is `Failed`: `no accepted ComponentLink allows root:EventStream.../watch-release-channel-... to call root:AtprotoRecordWatch.../release-channel with events.deliver{release-channel}`: the watch sources add a deliver link only for `association` (`compose/streams.go`). Fix 2: the same link for `release-channel` | fixed |
## Runs
internal/app/compose/identity.go+2−0
@@ -32,6 +32,8 @@ const (
EnvPdsAccountPassword = "ATPROTO_PASSWORD"
AssociationWatch = "association"
ReleaseChannelWatch = "release-channel"
)
const (
internal/app/compose/streams.go+5−3
@@ -419,9 +419,11 @@ func (c *Composer) applyRootSources(ctx context.Context, r Root, ws string, in S
links = append(links, RelayEventSourceLink(backendRef, AppRef(ComponentKindRelay, s.Relay.RelayRef.Name, ws)))
}
}
links = append(links, SelectorLink(eventLinkName(rootSourceValue, "deliver", ws, AssociationWatch), watchSelector,
commonv1.ObjectRef{Group: v1alpha1.GroupName, Kind: events.RecordWatchKind, Name: AssociationWatch, Workspace: ws},
Cap(events.CapabilityDeliver, AssociationWatch)))
for _, watch := range []string{AssociationWatch, ReleaseChannelWatch} {
links = append(links, SelectorLink(eventLinkName(rootSourceValue, "deliver", ws, watch), watchSelector,
commonv1.ObjectRef{Group: v1alpha1.GroupName, Kind: events.RecordWatchKind, Name: watch, Workspace: ws},
Cap(events.CapabilityDeliver, watch)))
}
selector := marketSourceLabel + "=" + rootSourceValue
for _, gvr := range []schema.GroupVersionResource{eventsv1alpha1.EventSourceGVR, eventsv1alpha1.RelayEventSourceGVR,
eventsv1alpha1.JetstreamEventSourceGVR, eventsv1alpha1.PdsEventSourceGVR} {
internal/app/marketbidder/marketbidder.go+2−2
@@ -356,9 +356,9 @@ func (p *pass) reconcile(ctx context.Context) (ctlruntime.Result, error) {
if err := c.ApplyLinks(ctx, r, "root", links); err != nil {
return ctlruntime.Result{}, err
}
var phases []string
phases := []string{"release-channel-watch"}
if plan.UsesAssociation() {
phases = []string{"association-watch"}
phases = append(phases, "association-watch")
}
values := p.infraValues()
intact, err := c.CheckWorkloads(ctx, r)(c.SetWorkloads(BidderSet, o.Spec.Profile, values, phases...))
internal/atproto/cloudinit/agent.go+2−2
@@ -350,8 +350,8 @@ func AssociationModule(refFile, guestPLC, ingress string) UserDataModule {
{Path: GuestRequesterRunPath, Owner: "root:root", Permissions: "0755", Content: guestRequesterRunScript},
{Path: GuestRequesterReleasePath, Owner: "root:root", Permissions: "0755", Content: guestRequesterReleaseScript},
{Path: "/etc/systemd/system/" + GuestRequesterUnit, Owner: "root:root", Permissions: "0644", Content: unitFile(
append([]string{"Description=the guest requester (plan 0036 A7), started by guest.r2Start"}, after...),
[]string{"Type=exec", "User=" + GuestRequesterUser, "ExecStart=" + GuestRequesterRunPath,
append([]string{"Description=the guest requester (plan 0036 A7), started by guest.r2Start", "StartLimitIntervalSec=0"}, after...),
[]string{"Type=exec", "User=" + GuestRequesterUser, "ExecStart=" + GuestRequesterRunPath, "Restart=on-failure", "RestartSec=10s",
"TimeoutStopSec=" + seconds(GuestRequesterStopTimeout-30*time.Second), "StandardOutput=journal", "StandardError=journal"})},
{Path: "/etc/systemd/system/" + GuestRequesterReleaseUnit, Owner: "root:root", Permissions: "0644", Content: unitFile(
append([]string{"Description=release every contract of the guest requester (plan 0036 A8), started by guest.r2Release"}, after...),
internal/atproto/ingress/client.go+51−0
@@ -3,6 +3,7 @@ package ingress
import (
"cmp"
"context"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
@@ -242,6 +243,7 @@ func (s *Subscriber) openOnce(ctx context.Context) error {
}
s.conn = conn
s.wg.Go(func() { s.readLoop(conn) })
s.wg.Go(func() { s.renewLoop(conn, tokenExpiry(subscribeToken)) })
s.mu.Unlock()
return nil
}
@@ -941,3 +943,52 @@ func (c *Caller) Close() {
}
c.wg.Wait()
}
const RenewBefore = time.Minute
func tokenExpiry(jwt string) time.Time {
parts := strings.Split(jwt, ".")
if len(parts) != 3 {
return time.Time{}
}
raw, err := base64.RawURLEncoding.DecodeString(strings.TrimRight(parts[1], "="))
if err != nil {
return time.Time{}
}
var claims struct {
Exp int64 `json:"exp"`
}
if json.Unmarshal(raw, &claims) != nil || claims.Exp == 0 {
return time.Time{}
}
return time.Unix(claims.Exp, 0)
}
func (s *Subscriber) renewLoop(conn *websocket.Conn, expires time.Time) {
for !expires.IsZero() {
left := time.Until(expires)
t := time.NewTimer(max(left-min(RenewBefore, left/5), time.Second))
select {
case <-s.ctx.Done():
t.Stop()
return
case <-t.C:
}
s.mu.Lock()
current := s.conn == conn && !s.closed
s.mu.Unlock()
if !current {
return
}
token, err := s.cfg.GetServiceAuthToken(s.ctx, SubscribeNSID)
if err != nil {
s.report(SubscriberRegistered, fmt.Errorf("ingress: renewing the subscription: %w", err), 0, "")
expires = time.Now().Add(RenewBefore / 2)
continue
}
if err := s.send(map[string]any{"$type": frameType("renew"), "serviceAuth": token}); err != nil {
return
}
expires = tokenExpiry(token)
}
}
internal/atproto/ingress/protocol.go+1−0
@@ -87,6 +87,7 @@ type frame struct {
Subdomain string `json:"subdomain"`
IngressRef string `json:"ingressRef"`
Hosts []string `json:"hosts"`
ServiceAuth string `json:"serviceAuth,omitempty"`
}
func b64encode(b []byte) string {
internal/atproto/ingress/server.go+47−12
internal/clicfg/options.json+1−1
internal/install/install.go+6−1
internal/market/requester/market.go+25−2
internal/services/requester/networkdirectory.godeleted+0−122
internal/services/requester/service.go+1−1
internal/stack/bidder/release.go+2−1
scripts/ci-test.sh+1−1
tests/compositions/staging/target.sh+1−1
tests/host/src/swc.rs+2−0
tests/modules/acc-0020/src/lib.rs+21−3
tests/modules/staging/src/lib.rs+15−7
.plans.yaml+22−22