This repository has no description
0

Configure Feed

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

feat: add org.latha.strata.getIsland query method

- GET /xrpc/org.latha.strata.getIsland?id=<id>
- Accepts stable ID (sha256 of lexmin) or AT URI
- Returns full island with vertices, edges, metadata, and strata analysis
- Falls back to deriving island from seed if no strata record exists

๐Ÿ‘พ 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:29 AM UTC) commit 755598c2 parent c79eb063
+194
+75
lexicons/org/latha/strata/getIsland.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "org.latha.strata.getIsland", 4 + "defs": { 5 + "main": { 6 + "type": "query", 7 + "description": "Get a single island by its stable ID. Returns the full island with vertices, edges, vertex metadata, and strata analysis if available.", 8 + "parameters": { 9 + "type": "params", 10 + "required": ["id"], 11 + "properties": { 12 + "id": { 13 + "type": "string", 14 + "description": "Island ID (truncated SHA-256 of lexmin vertex) or AT URI of an org.latha.strata record." 15 + } 16 + } 17 + }, 18 + "output": { 19 + "encoding": "application/json", 20 + "schema": { 21 + "type": "object", 22 + "required": ["island"], 23 + "properties": { 24 + "island": { 25 + "type": "ref", 26 + "ref": "#islandDetail" 27 + }, 28 + "recordUri": { 29 + "type": "string", 30 + "format": "at-uri", 31 + "description": "AT URI of the org.latha.strata record, if analyzed." 32 + } 33 + } 34 + } 35 + } 36 + }, 37 + "islandDetail": { 38 + "type": "object", 39 + "required": ["id", "lexmin", "vertices", "edges"], 40 + "properties": { 41 + "id": { 42 + "type": "string" 43 + }, 44 + "lexmin": { 45 + "type": "string" 46 + }, 47 + "vertices": { 48 + "type": "array", 49 + "items": { 50 + "type": "string" 51 + } 52 + }, 53 + "edges": { 54 + "type": "array", 55 + "items": { 56 + "type": "ref", 57 + "ref": "org.latha.strata.deriveIsland#edge" 58 + } 59 + }, 60 + "vertexMeta": { 61 + "type": "json", 62 + "description": "Map of vertex URI to {title, description, type}." 63 + }, 64 + "summary": { 65 + "type": "string", 66 + "description": "Strata analysis title." 67 + }, 68 + "strata": { 69 + "type": "json", 70 + "description": "Full strata analysis data (themes, connections, tensions, synthesis)." 71 + } 72 + } 73 + } 74 + } 75 + }
+119
src/worker.ts
··· 471 471 return c.json({ islands }); 472 472 }); 473 473 474 + // โ”€โ”€ Get single island by ID or AT URI โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ 475 + 476 + app.get("/xrpc/org.latha.strata.getIsland", async (c) => { 477 + const id = c.req.query("id"); 478 + if (!id) { 479 + return c.json({ error: "MissingRequiredParameter", message: "id is required" }, 400); 480 + } 481 + 482 + await ensureContrailReady(db); 483 + 484 + // If it's an AT URI, look up the strata record and derive from its lexmin 485 + if (id.startsWith("at://")) { 486 + const row = await db 487 + .prepare("SELECT uri, record FROM records_strata WHERE uri = ?") 488 + .bind(id) 489 + .first<{ uri: string; record: string }>(); 490 + 491 + if (!row) { 492 + return c.json({ error: "RecordNotFound" }, 404); 493 + } 494 + 495 + const rec = JSON.parse(row.record); 496 + const lexmin = rec.source?.uri; 497 + if (!lexmin) { 498 + return c.json({ error: "InvalidRecord" }, 400); 499 + } 500 + 501 + const island = await deriveIsland(db, lexmin); 502 + if (!island) { 503 + return c.json({ error: "IslandNotFound" }, 404); 504 + } 505 + 506 + const meta = await resolveVertexMeta(db, island.vertices); 507 + const analysis = rec.analysis || {}; 508 + 509 + return c.json({ 510 + island: { 511 + ...island, 512 + lexmin: island.vertices.slice().sort()[0], 513 + vertexMeta: Object.fromEntries(meta), 514 + summary: analysis.title || null, 515 + strata: { 516 + prose: analysis.synthesis || "", 517 + title: analysis.title || "", 518 + themes: analysis.themes || [], 519 + relationships: (analysis.connections || []).map((conn: any) => conn.description || ""), 520 + tensions: analysis.tensions || [], 521 + open_questions: analysis.openQuestions || [], 522 + synthesis: analysis.synthesis || "", 523 + }, 524 + }, 525 + recordUri: row.uri, 526 + }); 527 + } 528 + 529 + // Stable ID โ€” derive from lexmin by reverse-lookup 530 + // Find the strata record whose lexmin hashes to this ID 531 + const strataRows = await db 532 + .prepare("SELECT uri, record FROM records_strata") 533 + .all<{ uri: string; record: string }>(); 534 + 535 + for (const row of strataRows.results || []) { 536 + try { 537 + const rec = JSON.parse(row.record); 538 + const lexmin = rec.source?.uri; 539 + if (!lexmin) continue; 540 + 541 + const lexminHash = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(lexmin)); 542 + const candidateId = Array.from(new Uint8Array(lexminHash)).map(b => b.toString(16).padStart(2, "0")).join("").slice(0, 16); 543 + 544 + if (candidateId === id) { 545 + const island = await deriveIsland(db, lexmin); 546 + if (!island) continue; 547 + 548 + const meta = await resolveVertexMeta(db, island.vertices); 549 + const analysis = rec.analysis || {}; 550 + 551 + return c.json({ 552 + island: { 553 + ...island, 554 + lexmin: island.vertices.slice().sort()[0], 555 + vertexMeta: Object.fromEntries(meta), 556 + summary: analysis.title || null, 557 + strata: { 558 + prose: analysis.synthesis || "", 559 + title: analysis.title || "", 560 + themes: analysis.themes || [], 561 + relationships: (analysis.connections || []).map((conn: any) => conn.description || ""), 562 + tensions: analysis.tensions || [], 563 + open_questions: analysis.openQuestions || [], 564 + synthesis: analysis.synthesis || "", 565 + }, 566 + }, 567 + recordUri: row.uri, 568 + }); 569 + } 570 + } catch {} 571 + } 572 + 573 + // No strata record โ€” try deriving island by treating the ID as a lexmin seed 574 + // (for islands that haven't been analyzed yet) 575 + const island = await deriveIsland(db, id); 576 + if (!island) { 577 + return c.json({ error: "IslandNotFound" }, 404); 578 + } 579 + 580 + const meta = await resolveVertexMeta(db, island.vertices); 581 + return c.json({ 582 + island: { 583 + ...island, 584 + lexmin: island.vertices.slice().sort()[0], 585 + vertexMeta: Object.fromEntries(meta), 586 + summary: null, 587 + strata: null, 588 + }, 589 + recordUri: null, 590 + }); 591 + }); 592 + 474 593 // โ”€โ”€ List strata records (AT URI-based) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ 475 594 476 595 app.get("/xrpc/org.latha.strata.listRecords", async (c) => {