johnandersen777.bsky.social/socialweb-computer-console
console.socialweb.computer: kcp, kubectl and ssh compiled to wasm in a browser tab with a terminal; a kcp fork
0
0
Plan 0036, page/wasm side: requester association and policy eval in kcp.wasm
Read-only research by wasm-assoc. kcp-wasm worktree atirc-agent (HEAD 6af2d7ada);
socialweb at origin/main 702daf27 (local checkout 62fe79b7). socialweb paths are
relative to ~/src/kcp/socialweb-computer-kcp at origin/main.
1. Requester association on the page today: none
scripts/browser/app.js:2067requesterIdentity()sendsmode(from the select),association: "Skip"(:2074), the page-origin OAuth client id and redirect, plus handle orpdsUrl=https://bsky.social.patchRequesterIdentity()(:2083) merge-patches it intomarketrequesters/app.scripts/browser/app.html:360-362: the only enabled mode isoauthBrowser;localRepois disabled ("Local PDS (pending)").app.js:766and:2320migrate a storedlocalRepotooauthBrowser.- In oauthBrowser the requester DID is the signed-in account (aliceoa), which is its own operator, so no association is needed or run.
- The wasm overlay copy of the check (same logic as upstream
internal/app/compose/identity.go):socialweb-wasm/overlays/compose/identity.go:309OperatorWatchedsetsassociateWith/associationWatch/associationServiceonly for localRepo and not Skip.:357ClaimOpen,:390associationRequired(localRepo and not Skip and a watch/operator set),:397AssociationWait,:413OperatorDID(firstapprovedAssociations, elsestatus.associations).socialweb-wasm/overlays/app/marketrequester.go:156PlanAccount(..., AssociationRequireApproval default),:246RequesterSpec.OperatorDID,:489AssociationWait(plan, id, requester_associate)gates Ready; the status texts the page shows are:492-496("waiting for the requester's MarketIdentity to sign in" etc).
associateConfirm:internal/atproto/oauth/scope.go:47RPCAssociateConfirmis only inDIDKeyAssociatorOAuthScope(:104-108), not inRequesterOAuthScope; the constantAssociateConfirmNSID(internal/app/compose/identity.go:32, overlay copy:32) has no caller in Go. The page never calls it and never talks to the did-key associator / qr.fedfork.com. Its XRPC is served by the old atproto-market associator (docs/plans/0023:177-183: verifies service auth, writes badgeBlueKeys in the requester repo).- Existing mechanism (already record based, MarketIdentity side, runs in the
wasm binary too since
marketidentity.Registerand the record-watch controllers are wired,orchestrator.go:251-262):deploy/apps/repo-pds/association-watch.prod.yamlAtprotoRecordWatch oncom.publicdomainrelay.temp.badgeBlueKeysmatchingkeyId = subject did,service = requester_associate; verified byinternal/marketidentity/atproto/association.go:76associationClaimDid(challengeis a DID,keyId == subject,record.Did == challenge, i.e. the record lives in the operator repo), result intostatus.associationsand conditionAssociated.
2. Policy eval in wasm
socialweb-wasm/internal/socialweb/orchestrator.go:315-320(Sandboxat :316): engine factory withSandbox: worker.New(),DisableActions: true(the PolicyEngine CR path resets it to false,internal/policyengine/controller/manager.go:247).internal/sandbox/worker/worker.go:29Fenced()is false, sointernal/policyengine/controller/engine.go:165Ready()is false andinternal/policyengine/workflow/expression.go:289refuses policy code. The bundled tangy actions (internal/policyengine/bundled-actions/tangy/policy-*, JS dist) never run in the page: any requester workflow verdict is Deny (commit e73c38b56 message says so).- The requester links
Workflows = requester-tangled-vouch, requester-only-me, requester-mutuals, open(overlays/app/marketrequester.go:36, PolicyRunLink:146) but the page sets no workflow, sointernal/market/requester/policy.go:30/:38return Allow andinternal/market/requester/runner.go:481skips Evaluate (policyRef == nil).accept.go:346Scope likewise allows. - Inputs when a run does happen:
PolicyInput(self/subject/counterparty DID, RFP and Bid strong refs, perspective, mode); the Go side seedscache["trust/<counterparty>"]fromtrust.BuildSnapshotFor(internal/policyengine/controller/run.go:277-288,trust.go:230) before the sandbox runs. - Where "record X in repo Y references requester Z" is checked in Go today,
without OAuth, and which runs inside kcp.wasm over fetch:
internal/policyengine/trust/trust.go:103ResolveOperatorDidFor: listRecords badgeBlueKeys in the subject repo,keyId == subject,challenge= operator.internal/market/requester/discovery.go:65operatorsOfand:103operatedBy: operator repo record plus the mirrored record in the subject repo (two-repo check). This is what finds the lead's bidders from the phone today, so public listRecords from the browser is proven.
- Conclusion: in wasm the association check has to be Go (trust/discovery/ MarketIdentity), not a policy action, until a fenced sandbox exists in the page.
3. What changes on the page/wasm side for record-based association
- Build: discovery, trust, record watch and marketidentity code come from the
socialweb mirror at REV; only
overlays/compose/identity.goandoverlays/app/marketrequester.goare wasm copies (3-way merged by build-page.sh). A new MarketIdentity/MarketRequester field needs thesocialweb-wasm/manifestssync, else the page logs "field not declared in schema". - Read path: verify by
com.atproto.repo.getRecordof a pinned at-uri (optional cid) in the operator repo. One CORS GET (bsky PDS answersAccess-Control-Allow-Origin: *), cached like trust.go's 5 min TTL. Avoid a streaming AtprotoRecordWatch onapp.bsky.feed.post: iOS low-memory (tab dies near 630 MiB, 1-3 GB/min churn already open from no-op applies) and Firehose mode has no ingress anyway. If a watch is used, the EventSource must carrywantedDids=<operator>andwantedCollections=<collection>(internal/events/jetstream/jetstream.go:144). - Config surface: identify by DID and at-uri (or collection + rkey), never a
handle: the browser has no DNS TXT; DIDs resolve via plc.directory
(
orchestrator.go:254). Match rule for a bsky post: a mention facet withdid == requester DID(or the DID string in text); for a custom record the existingAtprotoRecordMatch{fieldPath, value}shape fits. - Writing the marker from the page: the page scope already has
repo:com.publicdomainrelay.temp.badgeBlueKeys?action=create&action=update&action=delete(scripts/serve-public.ts:53,RequesterOAuthScope), so a signed-in operator tab can write the operator-side record for an agent DID today, no associateConfirm needed. A bsky post as marker needsrepo:app.bsky.feed.post?action=createadded to the requester scope (fresh sign-in, see AGENTS.md) or the operator posts from any bsky client and pastes the at-uri. - Display: nothing shows association now (Skip). Minimal: show
status.associations/ theAssociatedcondition of the MarketIdentity in the identity panel, and for an operator tab an "associate agent DID" action that writes the record and prints its at-uri. - Open question for linux-kcp: is the non-OAuth agent always a CLI requester (VM, plan 0035), with the page only ever the operator side? If yes the page needs no new identity mode; if an agent should drive a page requester without OAuth, the page needs a non-OAuth mode (localRepo is still "pending" in wasm: overlays/atproto pds_store.go / repo_sqlite.go exist but the option is disabled).
V1 result (2026-10-30, page-driven, production)
- Prod page https://shell.socialweb.computer 14e10250a (socialweb rc125 720ca71b), alice, Agent + "socialweb-computer in the VM (R2)" (guestTools + association.fromGuest): Held 17:10:18Z on hat-7; guest installed socialweb-computer from the bidder; agent aliceoa-3mz4bihylhh2s.
- R2 =
run request --association-refinside the VM as the agent user (root refused by devinstance.RefuseRoot; non-root workaround), own localRepo did:plc:4bcvjivkb6r24w7qta3lbgtu on its in-VM PDS behind xrpc.fedproxy.com. - guest.requesterDid 17:15:49Z; page row "R2: ... Pending" 17:15:51Z -> "Verified" 17:15:52Z (one getRecord of R2's associationRequest through xrpc.fedproxy.com).
- R2's own RFP 3mz4btoodgi22: hat-7 bidder-tangled-vouch allowed R2 via alice (bid 17:16:09Z, accept 17:16:16Z), nested VM fc-4bcvjivkb6r2-10005e5b Running 17:16:19Z; R2 joined atirc as r2-xjw6w5wbmgcdh ("r2: online"). PASS.
- Not covered: R2's own agents (grandchildren, atircParentRef unused in the workaround); CLI path blocked by the run request option parsing bug (fixed on r2bin-fix 853e2adf, 8294bacd).
- Release: outer contract Released 17:17:31.9Z from the page; contract-scoped association requester_associate-9c02c8bc668311f157676fe1dce9c79f-xjw6w5wbmgcdh in alice's repo -> getRecord 400 RecordNotFound (deleted); hat-7 orphan check 17:17:44Z clean. R2's own nested contract Released 17:16:31.8Z (releaseOk).
- Revoke: atirc revocations.ndjson revoked_at 2026-10-30T17:17:30Z for r2-xjw6w5wbmgcdh.aliceoa.bsky.social and aliceoa-3mz4bihylhh2s.aliceoa.bsky.social (atirc-dev, server-side). V1 PASS incl cleanup.
V1 grandchild run (2026-10-30, rc125 workaround)
- Prod page 4cba14c3a, alice, Agent + R2: outer Held 17:23:29Z on hat-7; VM agent aliceoa-3mz4ca3etg627 joined.
- R2 started as the agent user with --agent --hold: did:plc:reephqeca6eeq7hohvikcmot Pending 17:26:15Z -> Verified 17:26:16Z; child token r2-regb26j7a4jna.aliceoa.bsky.social minted 17:26:17Z; R2 joined and stayed subscribed 17:26:28Z ("r2: online (agent run)").
- R2's own RFP accepted by hat-7 17:26:42Z (repo did:plc:reephqeca6eeq7hohvikcmot); R2's own VM (separate Firecracker VM on hat-7, nested by ownership, not virtualization) Held 17:26:59Z;
run request agent r2-agent-> agentStart -> grandchild agent joined atirc as vm-3mz4cgbnb6z22.r2-regb26j7a4jna.aliceoa.bsky.social (token minted below R2's via atircParentRef). PASS: alice -> R2 -> R2 VM agent. - Release 17:50:32Z (page): aliceoa-3mz4ca3etg627 revoked 17:50:32Z, r2-regb26j7a4jna 17:50:33Z, left=0. Grandchild sub dropped 17:50:33-34Z while its VM fc-reephqeca6ee-2311a14c was still Running (hat-7 17:50:47Z): subhandle-suffix revoke cascade works.
- GAP: R2's own contract is not released by the outer release; R2's repo dies with alice's VM, so only a bidder-side release or exp (~24h) frees it. rc127 fix: guest teardown releases R2 held contracts first; bidder TTL backstop.
V1 rerun on rc126, one command (2026-10-30)
- CLI requester alice (QR, no handle) signed in 18:04:12Z; hat-7 accept nrmujbwskqbxk 18:04:21Z; VM agent aliceoa-3mz4ejuf5fy2k joined.
- In the VM, as the agent user (no root, no chmod, no units):
socialweb-computer run request --name r2 --guest-requester --agent --hold. - R2 DID did:plc:jsueozcdhc3usuofmc6vih2p 18:06:52Z -> association ref 18:07:00Z (subhandle r2-nrmujbwskqbxk.aliceoa, no atirc sub) -> R2 RFP 3mz4eox6uxb22 (hat-7 bid 18:07:17Z under rc126 tangled-vouch but lost; another rc126 bidder hosts the R2 VM) -> R2 VM Held 18:08:30Z ->
run request agent r2-> grandchild vm-3mz4eox6uxb22 online. PASS, no workaround. - GAP (rc126): R2 token r2-nrmujbwskqbxk and grandchild vm-3mz4eox6uxb22 were not revoked on release. Cause (assoc-b): writeStatus(Released) merges Released first and runs the revokes in a goroutine; the CLI stops kcp ~4s later and kills it (outer revoked only its agent token 18:10:21Z; R2's own release revoked nothing). The page is not hit (its kcp keeps running; the release marker resumes revokes on reload). Mitigated server-side 18:14:57Z (revocations.ndjson, suffix covers the grandchild); fixed in rc127.