diff --git a/docs/architecture/thothii-runtime.architecture.json b/docs/architecture/thothii-runtime.architecture.json index 00dc400d..c2a0b6e6 100644 --- a/docs/architecture/thothii-runtime.architecture.json +++ b/docs/architecture/thothii-runtime.architecture.json @@ -2,265 +2,550 @@ "schema_version": 1, "diagram_type": "architecture", "meta": { - "title": "ThothII Runtime Architecture", - "locale": "en", - "output": "thothii-runtime.html", + "title": "ThothII — architettura runtime NL→SQL", + "locale": "it", + "output": "docs/architecture/thothii-runtime.html", "quality_profile": "showcase", - "viewBox": [1360, 800] + "repository": { + "url": "https://git.tylconsulting.it/mptyl/ThothII.git", + "link_mode": "local-only", + "revision": "c77957af93ec77897e0c1f360091b156f3e2424b" + } }, "components": [ { "id": "reviewer", "type": "external", - "label": "User / Reviewer", - "sublabel": "Browser", - "pos": [20, 300], - "size": [145, 72] + "label": "Reviewer", + "sublabel": "browser", + "pos": [ + 40, + 200 + ], + "size": [ + 120, + 64 + ] }, { "id": "frontend", "type": "frontend", "label": "Frontend", - "sublabel": "React 18 + Vite", - "tag": "in-memory transcript", - "pos": [205, 295], - "size": [165, 82] + "sublabel": "React 18 + nginx", + "tag": "widget gate", + "pos": [ + 260, + 200 + ], + "size": [ + 150, + 64 + ], + "sources": [ + { + "path": "docker/nginx.conf.template", + "line": 13, + "end_line": 20, + "label": "proxy /api → core" + }, + { + "path": "frontend/src/stream/useSessionStream.ts", + "line": 121, + "end_line": 121, + "label": "EventSource SSE" + }, + { + "path": "frontend/src/widgets/registry.ts", + "line": 5, + "end_line": 13, + "label": "registry widget" + } + ] }, { "id": "backend", "type": "backend", "label": "Backend", - "sublabel": "Fastify + TypeScript", - "tag": "session bridge", - "pos": [410, 295], - "size": [175, 82] + "sublabel": "Fastify :8787", + "tag": "SessionBridge + SseHub", + "pos": [ + 510, + 200 + ], + "size": [ + 170, + 64 + ], + "sources": [ + { + "path": "backend/src/routes/sessions.ts", + "line": 634, + "end_line": 663, + "label": "POST risposta gate" + }, + { + "path": "backend/src/bridge/session-bridge.ts", + "line": 63, + "end_line": 71, + "label": "RPC → ui_request" + }, + { + "path": "backend/src/sse/sse-hub.ts", + "line": 107, + "end_line": 113, + "label": "publish SSE" + } + ] }, { "id": "pi", "type": "backend", "label": "Pi", - "sublabel": "RPC process per session", - "tag": "inside core", - "pos": [625, 295], - "size": [170, 82] + "sublabel": "--mode rpc, 1 per sessione", + "pos": [ + 790, + 200 + ], + "size": [ + 170, + 64 + ], + "sources": [ + { + "path": "backend/src/pi/pi-process-manager.ts", + "line": 143, + "end_line": 146, + "label": "spawn pi --mode rpc" + }, + { + "path": "backend/src/pi/pi-process-manager.ts", + "line": 283, + "end_line": 290, + "label": "nuova-domanda / riprendi" + } + ] }, { - "id": "harness", + "id": "gate", "type": "backend", - "label": "tht / Harness", - "sublabel": "8-phase NL→SQL workflow", - "tag": "workflow owner", - "pos": [835, 295], - "size": [190, 82] + "label": "tht-gate.js", + "sublabel": "estensione Pi, fasi F1–F8", + "tag": "reviewer tools", + "pos": [ + 1060, + 200 + ], + "size": [ + 170, + 64 + ], + "sources": [ + { + "path": "harness/.pi/extensions/tht-gate.js", + "line": 597, + "end_line": 603, + "label": "ctx.ui.input" + }, + { + "path": "harness/.pi/extensions/tht-gate.js", + "line": 889, + "end_line": 895, + "label": "reviewer_select" + }, + { + "path": "harness/.pi/skills/tht-sessione/SKILL.md", + "line": 40, + "end_line": 66, + "label": "regole di fase" + } + ] }, { - "id": "workspace", - "type": "database", - "label": "Workspace Repository", - "sublabel": "sessions + phase artifacts", - "tag": "source of truth", - "pos": [1065, 295], - "size": [205, 82] + "id": "tht", + "type": "backend", + "label": "tht CLI", + "sublabel": "harness Python", + "tag": "fase = fold ledger", + "pos": [ + 1335, + 200 + ], + "size": [ + 160, + 64 + ], + "sources": [ + { + "path": "harness/.pi/extensions/tht-gate.js", + "line": 277, + "end_line": 280, + "label": "execFileSync tht" + }, + { + "path": "harness/tht/phase.py", + "line": 60, + "end_line": 79, + "label": "current_phase" + }, + { + "path": "harness/workflow.yaml", + "line": 12, + "end_line": 72, + "label": "workflow F1–F8" + } + ] }, { - "id": "auth", + "id": "llm", + "type": "cloud", + "label": "Provider LLM", + "sublabel": "catalogo modelli installazione", + "pos": [ + 790, + 400 + ], + "size": [ + 170, + 64 + ], + "sources": [ + { + "path": "backend/src/pi/managed-config.ts", + "line": 120, + "end_line": 128, + "label": "models.json di Pi" + }, + { + "path": "backend/src/catalog/model-completer.ts", + "line": 67, + "end_line": 74, + "label": "helper LiteLLM" + }, + { + "path": "harness/tht/internal/litellm_completion.py", + "line": 186, + "end_line": 195 + } + ] + }, + { + "id": "idp", "type": "security", - "label": "Authentication", - "sublabel": "local registry or OIDC", - "pos": [410, 70], - "size": [170, 76] + "label": "Identity provider", + "sublabel": "OIDC / upstream", + "pos": [ + 260, + 30 + ], + "size": [ + 150, + 64 + ], + "sources": [ + { + "path": "backend/src/auth/oidc-client.ts", + "line": 24, + "end_line": 27, + "label": "OidcProtocol" + } + ] }, { - "id": "modelProvider", - "type": "external", - "label": "AI Model Provider", - "sublabel": "installation-selected APIs", - "pos": [615, 70], - "size": [190, 76] + "id": "embedding", + "type": "backend", + "label": "Embedding", + "sublabel": "Ollama :11434", + "pos": [ + 1335, + 30 + ], + "size": [ + 160, + 64 + ], + "sources": [ + { + "path": "compose.yaml", + "line": 230, + "end_line": 249 + }, + { + "path": "harness/tht/vectorstore/embeddings.py", + "line": 65, + "end_line": 75, + "label": "embed()" + } + ] + }, + { + "id": "qdrant", + "type": "database", + "label": "Qdrant", + "sublabel": "vector store :6333", + "pos": [ + 1580, + 200 + ], + "size": [ + 150, + 64 + ], + "sources": [ + { + "path": "compose.yaml", + "line": 210, + "end_line": 228 + }, + { + "path": "harness/tht/adapters/vector/qdrant.py", + "line": 141, + "end_line": 141, + "label": "search" + }, + { + "path": "harness/tht/adapters/vector/qdrant.py", + "line": 327, + "end_line": 327, + "label": "upsert" + } + ] + }, + { + "id": "sessions", + "type": "database", + "label": "Sessioni", + "sublabel": "manifest + artefatti + ledger", + "tag": "fonte di verità", + "pos": [ + 1335, + 400 + ], + "size": [ + 160, + 64 + ], + "sources": [ + { + "path": "harness/tht/session/repository.py", + "line": 74, + "end_line": 92, + "label": "filesystem o Postgres" + }, + { + "path": "harness/tht/session/filesystem_repository.py", + "line": 134, + "end_line": 142, + "label": "append decisioni" + }, + { + "path": "harness/tht/decisions.py", + "line": 10, + "end_line": 10, + "label": "review_decisions.jsonl" + } + ] + }, + { + "id": "dwh", + "type": "database", + "label": "DWH", + "sublabel": "Postgres o REST", + "tag": "sola lettura", + "pos": [ + 1580, + 400 + ], + "size": [ + 170, + 64 + ], + "sources": [ + { + "path": "harness/tht/adapters/dwh/postgres.py", + "line": 29, + "end_line": 33, + "label": "verifica read-only" + }, + { + "path": "harness/tht/adapters/dwh/thoth_rest.py", + "line": 22, + "end_line": 29, + "label": "REST read_only" + }, + { + "path": "backend/src/catalog/description-source-sampler.ts", + "line": 153, + "end_line": 160, + "label": "campionamento" + } + ] }, { "id": "catalog", "type": "database", "label": "Metadata Catalog", - "sublabel": "PostgreSQL + Kysely", - "tag": "backend-owned", - "pos": [410, 545], - "size": [180, 82] - }, - { - "id": "embedding", - "type": "backend", - "label": "Embedding Service", - "sublabel": "Ollama", - "pos": [800, 545], - "size": [170, 76] - }, - { - "id": "qdrant", - "type": "database", - "label": "Vector Store", - "sublabel": "Qdrant", - "pos": [1010, 545], - "size": [160, 76] - }, - { - "id": "dwh", - "type": "external", - "label": "Data Warehouse", - "sublabel": "external, read-only", - "pos": [1070, 70], - "size": [180, 82] + "sublabel": "PostgreSQL 17", + "pos": [ + 510, + 400 + ], + "size": [ + 170, + 64 + ], + "sources": [ + { + "path": "compose.yaml", + "line": 74, + "end_line": 98 + }, + { + "path": "backend/src/catalog/repository.ts", + "line": 2054, + "end_line": 2068, + "label": "pool + repository" + } + ] } ], "boundaries": [ { "kind": "region", - "label": "Local Docker Compose runtime", - "wraps": ["frontend", "backend", "pi", "harness", "catalog", "embedding", "qdrant"], - "pad": 26 - }, - { - "kind": "security-group", - "label": "core container", - "wraps": ["pi", "harness"], - "pad": 18 - }, - { - "kind": "security-group", - "label": "operator-controlled persisted state", - "wraps": ["workspace"], - "pad": 18 + "label": "container core", + "wraps": [ + "backend", + "pi", + "gate", + "tht" + ] } ], "connections": [ { - "id": "reviewerInput", + "id": "rev-fe", "from": "reviewer", "to": "frontend", - "label": "question / gate decision", - "variant": "emphasis", - "labelAt": [185, 391] - }, - { - "id": "restRequests", - "from": "frontend", - "to": "backend", - "label": "REST", + "label": "HTTPS", "variant": "emphasis" }, { - "id": "sseEvents", - "from": "backend", - "to": "frontend", - "label": "SSE: text · info · widget", - "variant": "dashed", - "labelAt": [390, 415] + "id": "fe-be", + "from": "frontend", + "to": "backend", + "label": "/api + SSE", + "variant": "emphasis" }, { - "id": "piRpc", + "id": "be-pi", "from": "backend", "to": "pi", - "label": "JSON-RPC stdio", - "variant": "emphasis", - "labelAt": [605, 391] + "label": "RPC stdio", + "variant": "emphasis" }, { - "id": "gateCommands", + "id": "pi-gate", "from": "pi", - "to": "harness", - "label": "phase / gate commands", - "variant": "emphasis", - "labelAt": [815, 391] + "to": "gate", + "label": "tool call", + "variant": "emphasis" }, { - "id": "persistArtifacts", - "from": "harness", - "to": "workspace", - "label": "artifacts + decision ledger", - "variant": "emphasis", - "labelAt": [1045, 391] + "id": "gate-tht", + "from": "gate", + "to": "tht", + "label": "execFileSync", + "variant": "emphasis" }, { - "id": "authenticate", - "from": "auth", - "to": "backend", - "label": "local session / OIDC callback", - "variant": "security", - "fromSide": "bottom", - "toSide": "top" + "id": "tht-sessions", + "from": "tht", + "to": "sessions", + "label": "scrive" }, { - "id": "sessionModel", + "id": "tht-dwh", + "from": "tht", + "to": "dwh", + "label": "SQL read-only" + }, + { + "id": "tht-qdrant", + "from": "tht", + "to": "qdrant", + "label": "ricerca" + }, + { + "id": "tht-embedding", + "from": "tht", + "to": "embedding", + "label": "embed" + }, + { + "id": "pi-llm", "from": "pi", - "to": "modelProvider", - "label": "session model API", - "fromSide": "top", - "toSide": "bottom", - "labelAt": [755, 185] + "to": "llm", + "label": "prompt" }, { - "id": "catalogState", + "id": "be-llm", "from": "backend", - "to": "catalog", - "label": "catalog CRUD + runs", - "fromSide": "bottom", - "toSide": "top" - }, - { - "id": "metadataModel", - "from": "backend", - "to": "modelProvider", - "label": "short-lived LiteLLM calls", + "to": "llm", + "label": "descrizioni", "variant": "dashed" }, { - "id": "readOnlySql", - "from": "harness", - "to": "dwh", - "label": "introspection + read-only SQL" + "id": "be-idp", + "from": "backend", + "to": "idp", + "label": "OIDC", + "variant": "security" }, { - "id": "embedRequests", - "from": "harness", - "to": "embedding", - "label": "embedding requests", - "fromSide": "bottom", - "toSide": "top", - "labelAt": [830, 490] + "id": "be-catalog", + "from": "backend", + "to": "catalog", + "label": "SQL" }, { - "id": "vectorAccess", - "from": "harness", - "to": "qdrant", - "label": "index + vector retrieval", - "fromSide": "bottom", - "toSide": "top", - "labelAt": [1165, 475] + "id": "be-tht", + "from": "backend", + "to": "tht", + "label": "ThtRunner" } ], "cards": [ { "dot": "cyan", - "title": "Primary session path", + "title": "Flusso di una sessione", "items": [ - "The browser sends questions and reviewer decisions over REST; the backend returns text, information, and widget descriptors over SSE.", - "One Pi RPC process drives each active session and delegates deterministic phase operations to tht / Harness." + "Il backend avvia un processo Pi per sessione e invia /nuova-domanda o /riprendi-sessione", + "tht-gate.js guida le fasi F1–F8 e chiama il CLI tht per ogni passo deterministico", + "I gate reviewer arrivano al browser come ui_request via SSE; la risposta torna con POST /sessions/:id/response" ] }, { "dot": "emerald", - "title": "State ownership", + "title": "Persistenza", "items": [ - "Harness owns the eight-phase workflow and persists session_manifest.yaml, phase artifacts, and review_decisions.jsonl.", - "Backend owns the separate installation-local metadata catalog; the live frontend transcript is not persisted." + "Lo stato è nei documenti di fase e nel ledger review_decisions.jsonl, non nella chat", + "La fase corrente si calcola ripiegando il ledger (phase.py), non viene salvata", + "Repository sessioni su filesystem oppure PostgreSQL, secondo la configurazione" + ] + }, + { + "dot": "amber", + "title": "Catalogo metadati", + "items": [ + "Il backend gestisce il Metadata Catalog PostgreSQL", + "Le descrizioni AI campionano il DWH in sola lettura e usano un helper Python LiteLLM, senza Pi" ] }, { "dot": "rose", - "title": "Trust boundaries", + "title": "Sicurezza", "items": [ - "Catalog DB, Qdrant, and Ollama stay inside Compose; workspace state is operator controlled and mounted into core.", - "The DWH and AI provider remain external endpoints; DWH access is constrained to introspection, tests, bounded samples, and read-only SQL." + "Login OIDC o identità upstream dal portale (Omics embedded)", + "Qdrant ed Embedding sono servizi interni della rete Compose; DWH e LLM sono endpoint esterni" ] } ] diff --git a/docs/architecture/thothii-runtime.html b/docs/architecture/thothii-runtime.html index 25850491..f3b07c72 100644 --- a/docs/architecture/thothii-runtime.html +++ b/docs/architecture/thothii-runtime.html @@ -3,8 +3,9 @@ - - ThothII Runtime Architecture Diagram + + + ThothII — architettura runtime NL→SQL Diagram - - - - + @@ -4853,6 +5046,7 @@ Motion appears only for trace-enabled artifacts and has no shortcut; Keyboard: T toggles theme, S cycles style, F toggles the stage, E opens export. --> - - - - - + +
- - ThothII Runtime Architecture + + ThothII — architettura runtime NL→SQL An architecture diagram generated by Archify. @@ -5025,289 +5180,345 @@ + - - - - - + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - User / Reviewer · Browser · Architecture component - - -

-