a digital entity named phi that roams bsky
phi.zzstoatzz.io
1"""One-off: delete malformed cosmik cards and recreate the URL card correctly.
2
3All 10 existing cards were created before the semble lexicon fix:
4- 9 NOTE cards: missing $type, createdAt, parentCard (semble drops standalone NOTEs)
5- 1 URL card: missing $type discriminators, metadata at wrong nesting level
6
7Run: cd bot && uv run python scripts/fix_cosmik_records.py
8"""
9
10from datetime import UTC, datetime
11
12from atproto import Client
13
14from bot.config import settings
15
16NOTE_RKEYS = [
17 "3miimkmqzfe2h",
18 "3miiee7sd722m",
19 "3mig7idbqdm2q",
20 "3mi3jtxvf362o",
21 "3mi3jsqmenp2n",
22 "3mi3jrmptnx22",
23 "3mi3jqr2ejd2e",
24 "3mi3iwqz6yh2y",
25 "3mi3hxb66i72o",
26]
27
28URL_RKEY = "3mhwa4hm47e2n"
29
30URL_CARD_RECORD = {
31 "type": "URL",
32 "content": {
33 "$type": "network.cosmik.card#urlContent",
34 "url": "https://atproto.brussels/atproto-architecture",
35 "metadata": {
36 "$type": "network.cosmik.card#urlMetadata",
37 "title": "ATProto Architecture — visual summary",
38 "description": (
39 "a single-page visual map of the AT Protocol stack: PDS, AppView,"
40 " identity, records, lexicons. useful when you need to orient quickly"
41 " or explain the system to someone new."
42 ),
43 },
44 },
45 "createdAt": datetime(2026, 3, 25, 12, 0, 0, tzinfo=UTC).isoformat(),
46}
47
48
49def main():
50 client = Client(base_url=settings.bluesky_service)
51 client.login(settings.bluesky_handle, settings.bluesky_password)
52 did = client.me.did
53 print(f"authenticated as {did}")
54
55 # delete orphaned NOTE cards
56 for rkey in NOTE_RKEYS:
57 try:
58 client.com.atproto.repo.delete_record(
59 {"repo": did, "collection": "network.cosmik.card", "rkey": rkey}
60 )
61 print(f" deleted NOTE {rkey}")
62 except Exception as e:
63 print(f" failed to delete {rkey}: {e}")
64
65 # delete old malformed URL card
66 try:
67 client.com.atproto.repo.delete_record(
68 {"repo": did, "collection": "network.cosmik.card", "rkey": URL_RKEY}
69 )
70 print(f" deleted URL {URL_RKEY}")
71 except Exception as e:
72 print(f" failed to delete URL card: {e}")
73
74 # recreate URL card with correct format
75 resp = client.com.atproto.repo.create_record(
76 {
77 "repo": did,
78 "collection": "network.cosmik.card",
79 "record": URL_CARD_RECORD,
80 }
81 )
82 print(f" created URL card: {resp.uri} (cid: {resp.cid})")
83 print("done")
84
85
86if __name__ == "__main__":
87 main()