15fe012006
M1:library_map template(migration 0003 seed+runtime ensure,D6 零建表零 ALTER); 核實 triplet 按庫定位=不足(prod triplet template 無 library slot、entries metadata.library 未標記)→ 走 SDD 預案:recompute 冪等補 optional library slot (改 template 不動表),slot 值由 ingest 端(M3)補寫,核實結果記入 design §1。 M2:kbdb base 三端點(design §2 歸屬裁定:聚合 SQL 只准住基本盤): - POST /map/recompute?library=X:degree top-N/predicate 分布/跨庫 bridges/ triplet_count 一段 SQL 聚合;narrative 本輪收 body 傳入(wiki 抽取屬 M3); 寫入順序安全(先建新 active map block 再標舊 superseded,讀端取最新 active 自癒); 過渡 source_prefix fallback 讓無 library 值的舊 triplet 靠 source_uri 前綴歸庫。 - GET /map:全館地圖每庫一行(library+narrative+top 3 entities+triplet_count), MCP instructions/GUI 共用(數百 token 內)。 - GET /map/:library:該庫詳圖(完整 slots+可嵌人話 content,design §5 M6 直用)。 測試:node:sqlite(零新依賴)當真 SQLite 實跑 migrations+聚合 SQL, Hono route 行為同款覆蓋;45/45 過、tsc --noEmit 乾淨。 關聯 #39 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JUmjwkHLVBHM3ydhT1WSW3
32 lines
1.5 KiB
TypeScript
32 lines
1.5 KiB
TypeScript
// KBDB Base — atomic universal table worker (arcrun self-hosted data layer + official core).
|
|
// SDD: .agents/specs/arcrun/kbdb-base/design.md
|
|
//
|
|
// Base = D1 only (free, no credit card): entries / templates / records + LIKE search + recipe-stats.
|
|
// Optional modules (NOT in this base): embed (Vectorize+AI binding, semantic search), triplet (separate repo).
|
|
import { Hono } from 'hono';
|
|
import type { Bindings } from './types';
|
|
import { entryRoutes } from './routes/entries';
|
|
import { templateRoutes } from './routes/templates';
|
|
import { recordRoutes } from './routes/records';
|
|
import { recipeStatRoutes } from './routes/recipe-stats';
|
|
import { embedRoutes } from './routes/embed';
|
|
import { mapRoutes } from './routes/map';
|
|
|
|
const app = new Hono<{ Bindings: Bindings }>();
|
|
|
|
app.get('/', (c) => c.json({ service: 'arcrun-kbdb', tier: 'base', status: 'ok' }));
|
|
app.get('/health', (c) => c.json({ ok: true }));
|
|
|
|
app.route('/entries', entryRoutes);
|
|
app.route('/templates', templateRoutes);
|
|
app.route('/records', recordRoutes);
|
|
app.route('/recipe-stats', recipeStatRoutes);
|
|
// Optional embed module admin (backfill). Route mounts unconditionally; the handler
|
|
// honestly 409s when the embed binding is off (base 對內容語意無知,只認通用 embed 旗標)。
|
|
app.route('/embed', embedRoutes);
|
|
// 藏書地圖(library-map SDD M2 / Arcrun#39):聚合 SQL 只准住基本盤(D6 推論),
|
|
// recompute+讀端都在這裡;ingest workflow 只透過 HTTP 呼叫(A 類接 B 類 API,牆不破)。
|
|
app.route('/map', mapRoutes);
|
|
|
|
export default app;
|