This repository has no description
0

Configure Feed

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

refactor: deriveIsland as procedure, separate getIslands query

- deriveIsland is now POST (procedure) — takes optional seed in body
- getIslands is a lightweight GET query — returns summaries from
records_strata without deriving islands on every request
- Added org.latha.strata.getIslands lexicon

👾 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, 2:28 AM UTC) commit c79eb063 parent 0b74a001
+117 -12
+11 -8
lexicons/org/latha/strata/deriveIsland.json
··· 3 3 "id": "org.latha.strata.deriveIsland", 4 4 "defs": { 5 5 "main": { 6 - "type": "query", 7 - "description": "Derive connected components (islands) from the connection graph. Without a seed, returns all islands. With a seed vertex, returns the single island containing it.", 8 - "parameters": { 9 - "type": "params", 10 - "properties": { 11 - "seed": { 12 - "type": "string", 13 - "description": "Optional seed vertex. If provided, returns only the island containing this vertex. If omitted, returns all islands." 6 + "type": "procedure", 7 + "description": "Derive connected components (islands) from the connection graph. Sends all connections to the container for BFS traversal. Without a seed, returns all islands. With a seed vertex, returns the single island containing it.", 8 + "input": { 9 + "encoding": "application/json", 10 + "schema": { 11 + "type": "object", 12 + "properties": { 13 + "seed": { 14 + "type": "string", 15 + "description": "Optional seed vertex. If provided, returns only the island containing this vertex. If omitted, returns all islands." 16 + } 14 17 } 15 18 } 16 19 },
+74
lexicons/org/latha/strata/getIslands.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "org.latha.strata.getIslands", 4 + "defs": { 5 + "main": { 6 + "type": "query", 7 + "description": "List derived islands with their strata analysis. Returns islands that have been derived and stored, sorted by vertex count descending.", 8 + "parameters": { 9 + "type": "params", 10 + "properties": { 11 + "limit": { 12 + "type": "integer", 13 + "minimum": 1, 14 + "maximum": 100, 15 + "default": 50, 16 + "description": "Maximum number of islands to return." 17 + }, 18 + "cursor": { 19 + "type": "string", 20 + "description": "Pagination cursor from a previous response." 21 + } 22 + } 23 + }, 24 + "output": { 25 + "encoding": "application/json", 26 + "schema": { 27 + "type": "object", 28 + "required": ["islands"], 29 + "properties": { 30 + "cursor": { 31 + "type": "string" 32 + }, 33 + "islands": { 34 + "type": "array", 35 + "items": { 36 + "type": "ref", 37 + "ref": "#islandSummary" 38 + } 39 + } 40 + } 41 + } 42 + } 43 + }, 44 + "islandSummary": { 45 + "type": "object", 46 + "required": ["id", "lexmin", "vertexCount", "edgeCount"], 47 + "properties": { 48 + "id": { 49 + "type": "string", 50 + "description": "Stable ID: truncated SHA-256 of the lexmin vertex." 51 + }, 52 + "lexmin": { 53 + "type": "string", 54 + "description": "Lexicographically smallest vertex — the canonical reference." 55 + }, 56 + "vertexCount": { 57 + "type": "integer" 58 + }, 59 + "edgeCount": { 60 + "type": "integer" 61 + }, 62 + "title": { 63 + "type": "string", 64 + "description": "Strata analysis title, if available." 65 + }, 66 + "recordUri": { 67 + "type": "string", 68 + "format": "at-uri", 69 + "description": "AT URI of the org.latha.strata record, if analyzed." 70 + } 71 + } 72 + } 73 + } 74 + }
+32 -4
src/worker.ts
··· 440 440 // ── Islands API ────────────────────────────────────────────────── 441 441 442 442 app.get("/xrpc/org.latha.strata.getIslands", async (c) => { 443 - const islands = await listStrataIslands(db); 443 + const limit = Math.min(parseInt(c.req.query("limit") || "50"), 100); 444 + await ensureContrailReady(db); 445 + 446 + const rows = await db 447 + .prepare("SELECT uri, record FROM records_strata ORDER BY time_us DESC LIMIT ?") 448 + .bind(limit) 449 + .all<{ uri: string; record: string }>(); 450 + 451 + const islands: any[] = []; 452 + for (const row of rows.results || []) { 453 + try { 454 + const rec = JSON.parse(row.record); 455 + const lexmin = rec.source?.uri; 456 + if (!lexmin) continue; 457 + 458 + // Compute stable ID from lexmin 459 + const lexminHash = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(lexmin)); 460 + const id = Array.from(new Uint8Array(lexminHash)).map(b => b.toString(16).padStart(2, "0")).join("").slice(0, 16); 461 + 462 + islands.push({ 463 + id, 464 + lexmin, 465 + title: rec.analysis?.title || null, 466 + recordUri: row.uri, 467 + }); 468 + } catch {} 469 + } 470 + 444 471 return c.json({ islands }); 445 472 }); 446 473 ··· 548 575 return resp.json(); 549 576 } 550 577 551 - // Derive islands — delegates to container 578 + // Derive islands — POST, delegates to container 552 579 // With seed: single island. Without: all islands. 553 - app.get("/xrpc/org.latha.strata.deriveIsland", async (c) => { 554 - const seed = c.req.query("seed"); 580 + app.post("/xrpc/org.latha.strata.deriveIsland", async (c) => { 581 + const body = await c.req.json().catch(() => ({})) as { seed?: string }; 582 + const seed = body.seed; 555 583 556 584 // Load all connections from D1 for the container to traverse 557 585 await ensureContrailReady(db);