This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

feat: embed full edge data in strata connections, eliminate D1 lookups

Lexicon: connections field now holds objects {uri, source, target,
connectionType, note} instead of bare AT URIs. The graph renders
straight from the record — no chunked D1 queries needed.

Backfilled both existing records via PDS putRecord.

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta Code <noreply@letta.com>

author
nandi
co-author
Letta Code
date (May 14, 2026, 3:29 AM UTC) commit 587b78f3 parent 2538fdfb
+39 -36
+27 -3
lexicons/org/latha/strata/strata.json
··· 20 20 "type": "array", 21 21 "maxLength": 500, 22 22 "items": { 23 - "type": "string", 24 - "format": "at-uri" 23 + "type": "object", 24 + "required": ["uri", "source", "target"], 25 + "properties": { 26 + "uri": { 27 + "type": "string", 28 + "format": "at-uri", 29 + "description": "AT URI of the connection record" 30 + }, 31 + "source": { 32 + "type": "string", 33 + "description": "Source vertex URI" 34 + }, 35 + "target": { 36 + "type": "string", 37 + "description": "Target vertex URI" 38 + }, 39 + "connectionType": { 40 + "type": "string", 41 + "description": "Type of connection (relates, supports, contradicts, etc.)" 42 + }, 43 + "note": { 44 + "type": "string", 45 + "maxGraphemes": 500, 46 + "description": "Optional note about the connection" 47 + } 48 + } 25 49 }, 26 - "description": "AT URIs of the network.cosmik.connection records that form this island. The island's edges — the stigmergic trail itself." 50 + "description": "The island's edges — connection records with their graph structure embedded. No lookups needed to render." 27 51 }, 28 52 "analysis": { 29 53 "type": "ref",
+12 -33
src/worker.ts
··· 436 436 const lexminHash = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(lexmin)); 437 437 const id = Array.from(new Uint8Array(lexminHash)).map(b => b.toString(16).padStart(2, "0")).join("").slice(0, 16); 438 438 439 - // Reconstruct island from stored connections (chunked for D1) 440 - const connectionUris: string[] = rec.connections || []; 441 - let vertices: string[] = []; 442 - let edges: any[] = []; 443 - let vertexMeta: Record<string, any> = {}; 439 + // Build graph directly from embedded connections — no D1 lookups needed 440 + const connections: any[] = rec.connections || []; 441 + const vertexSet = new Set<string>(); 442 + const edges: any[] = []; 444 443 445 - if (connectionUris.length > 0) { 446 - const CHUNK_SIZE = 50; 447 - const vertexSet = new Set<string>(); 448 - 449 - for (let i = 0; i < connectionUris.length; i += CHUNK_SIZE) { 450 - const chunk = connectionUris.slice(i, i + CHUNK_SIZE); 451 - const placeholders = chunk.map(() => "?").join(","); 452 - const connRows = await db 453 - .prepare(`SELECT r.record, r.did, r.rkey, i.handle FROM records_connection r LEFT JOIN identities i ON r.did = i.did WHERE r.uri IN (${placeholders})`) 454 - .bind(...chunk) 455 - .all<{ record: string; did: string; rkey: string; handle: string | null }>(); 456 - 457 - for (const cr of connRows.results || []) { 458 - try { 459 - const val = JSON.parse(cr.record); 460 - vertexSet.add(val.source); 461 - vertexSet.add(val.target); 462 - edges.push({ 463 - uri: `at://${cr.did}/network.cosmik.connection/${cr.rkey}`, 464 - did: cr.did, rkey: cr.rkey, 465 - source: val.source, target: val.target, 466 - connectionType: val.connectionType || "relates", 467 - note: val.note || "", handle: cr.handle, 468 - }); 469 - } catch {} 470 - } 444 + for (const conn of connections) { 445 + if (typeof conn === "object" && conn.source && conn.target) { 446 + vertexSet.add(conn.source); 447 + vertexSet.add(conn.target); 448 + edges.push(conn); 471 449 } 472 - vertices = [...vertexSet].sort(); 473 - vertexMeta = Object.fromEntries(await resolveVertexMeta(db, vertices)); 474 450 } 451 + 452 + const vertices = [...vertexSet].sort(); 453 + const vertexMeta = Object.fromEntries(await resolveVertexMeta(db, vertices)); 475 454 476 455 const analysis = rec.analysis || {}; 477 456 islands.push({