From 0adda6e8af6912fdde2219a88c4003e04197f50c Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 18 Oct 2026 12:24:07 +0200 Subject: [PATCH] docs: add complete Archify architecture diagram set Thirteen source-backed interactive diagrams in docs/architecture with an index page (thothii-diagrams.html): runtime and deployment architecture, module tree, F1-F8 workflow, session and catalog-sync lifecycles, new-question, gate round-trip, resume and OIDC sequences, session runtime classes, metadata dataflow and Metadata Catalog ERD. Replaces the old thothii-core sequence diagram. Co-Authored-By: Claude Opus 5.5 --- docs/architecture/thothii-auth-oidc.html | 14809 ++++++++++++++ .../thothii-auth-oidc.sequence.json | 247 + docs/architecture/thothii-catalog-sync.html | 14776 ++++++++++++++ .../thothii-catalog-sync.lifecycle.json | 45 + docs/architecture/thothii-core.sequence.json | 230 - .../thothii-deployment.architecture.json | 529 + docs/architecture/thothii-deployment.html | 14953 ++++++++++++++ docs/architecture/thothii-diagrams.html | 88 + docs/architecture/thothii-gate-roundtrip.html | 14847 ++++++++++++++ .../thothii-gate-roundtrip.sequence.json | 332 + .../thothii-metadata-catalog.erd.json | 1183 ++ .../thothii-metadata-catalog.html | 16118 ++++++++++++++++ .../thothii-metadata-flow.dataflow.json | 388 + docs/architecture/thothii-metadata-flow.html | 14854 ++++++++++++++ docs/architecture/thothii-modules.html | 14987 ++++++++++++++ docs/architecture/thothii-modules.tree.json | 384 + docs/architecture/thothii-new-question.html | 14877 ++++++++++++++ .../thothii-new-question.sequence.json | 381 + docs/architecture/thothii-phases.html | 14825 ++++++++++++++ .../architecture/thothii-phases.workflow.json | 104 + ...core-sequence.html => thothii-resume.html} | 7634 ++++---- .../architecture/thothii-resume.sequence.json | 256 + .../thothii-session-lifecycle.html | 14753 ++++++++++++++ .../thothii-session-lifecycle.lifecycle.json | 229 + .../thothii-session-runtime.class.json | 359 + .../architecture/thothii-session-runtime.html | 14788 ++++++++++++++ 26 files changed, 172897 insertions(+), 4079 deletions(-) create mode 100644 docs/architecture/thothii-auth-oidc.html create mode 100644 docs/architecture/thothii-auth-oidc.sequence.json create mode 100644 docs/architecture/thothii-catalog-sync.html create mode 100644 docs/architecture/thothii-catalog-sync.lifecycle.json delete mode 100644 docs/architecture/thothii-core.sequence.json create mode 100644 docs/architecture/thothii-deployment.architecture.json create mode 100644 docs/architecture/thothii-deployment.html create mode 100644 docs/architecture/thothii-diagrams.html create mode 100644 docs/architecture/thothii-gate-roundtrip.html create mode 100644 docs/architecture/thothii-gate-roundtrip.sequence.json create mode 100644 docs/architecture/thothii-metadata-catalog.erd.json create mode 100644 docs/architecture/thothii-metadata-catalog.html create mode 100644 docs/architecture/thothii-metadata-flow.dataflow.json create mode 100644 docs/architecture/thothii-metadata-flow.html create mode 100644 docs/architecture/thothii-modules.html create mode 100644 docs/architecture/thothii-modules.tree.json create mode 100644 docs/architecture/thothii-new-question.html create mode 100644 docs/architecture/thothii-new-question.sequence.json create mode 100644 docs/architecture/thothii-phases.html create mode 100644 docs/architecture/thothii-phases.workflow.json rename docs/architecture/{thothii-core-sequence.html => thothii-resume.html} (63%) create mode 100644 docs/architecture/thothii-resume.sequence.json create mode 100644 docs/architecture/thothii-session-lifecycle.html create mode 100644 docs/architecture/thothii-session-lifecycle.lifecycle.json create mode 100644 docs/architecture/thothii-session-runtime.class.json create mode 100644 docs/architecture/thothii-session-runtime.html diff --git a/docs/architecture/thothii-auth-oidc.html b/docs/architecture/thothii-auth-oidc.html new file mode 100644 index 00000000..6ae611ab --- /dev/null +++ b/docs/architecture/thothii-auth-oidc.html @@ -0,0 +1,14809 @@ + + + + + + + + ThothII — login OIDC e richieste autenticate Diagram + + + + + + + + +
+ +
+
+
+

ThothII — login OIDC e richieste autenticate

+
+
+ + + + +
+ + ThothII — login OIDC e richieste autenticate + A sequence diagram generated by Archify. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GET /auth/config + + + + + + + + mode: oidc + + + + + + + + GET /auth/oidc/login + + + + + + + + createOidcState + + nonce e code verifier PKCE + + + + + + + 302 verso il provider + + + + + + + + authorize + PKCE + + login sul provider + + + + + + + 302 callback con code + + + + + + + + GET /auth/oidc/callback + + + + + + + + consumeOidcState + + verifica transazione, revisione e issuer + + + + + + + scambio code + + firma, audience, scadenza, nonce + + + + + + + identità + gruppi + + + + + + + + crea sessione + + ruoli dai gruppi, TTL limitato al token + + + + + + + cookie + redirect / + + + + + + + + API con cookie + + + + + + + + resolve + touch + + sessione revocata se cambia la config + + + + + + + risposta + + + + + + + Avvio login + + + + Provider + + + + Callback + + + + Richieste + + + + + Browser · frontend React · Sequence participant + + + + Browser + frontend React + + + + Backend · route /auth · Sequence participant + + + + Backend + route /auth + + + + Auth state · file, volume auth-state · Sequence participant + + + + Auth state + file, volume auth-state + + + + Identity provider · OIDC · Sequence participant + + + + Identity provider + OIDC + + + + + Legend + + + main request + + + + return + + + + security + + + + message + + + +

+ + + + + + + + + +
+ + + +
+ + + + diff --git a/docs/architecture/thothii-auth-oidc.sequence.json b/docs/architecture/thothii-auth-oidc.sequence.json new file mode 100644 index 00000000..11bdec0b --- /dev/null +++ b/docs/architecture/thothii-auth-oidc.sequence.json @@ -0,0 +1,247 @@ +{ + "schema_version": 1, + "diagram_type": "sequence", + "meta": { + "title": "ThothII — login OIDC e richieste autenticate", + "locale": "it", + "output": "docs/architecture/thothii-auth-oidc.html", + "quality_profile": "showcase", + "repository": { + "url": "https://git.tylconsulting.it/mptyl/ThothII.git", + "link_mode": "local-only", + "revision": "31e6d3a162e9e5ac71fc2d8da4fe44b16c06aae3" + } + }, + "participants": [ + { + "id": "browser", + "type": "frontend", + "label": "Browser", + "sublabel": "frontend React", + "sources": [ + { + "path": "frontend/src/api/auth.ts", + "line": 71, + "end_line": 105, + "label": "config e beginOidcLogin" + } + ] + }, + { + "id": "backend", + "type": "backend", + "label": "Backend", + "sublabel": "route /auth", + "sources": [ + { + "path": "backend/src/auth/routes.ts", + "line": 247, + "end_line": 286, + "label": "GET /auth/oidc/login" + }, + { + "path": "backend/src/auth/routes.ts", + "line": 288, + "end_line": 349, + "label": "GET /auth/oidc/callback" + }, + { + "path": "backend/src/auth/auth.ts", + "line": 76, + "end_line": 110, + "label": "authenticateSession" + } + ] + }, + { + "id": "store", + "type": "database", + "label": "Auth state", + "sublabel": "file, volume auth-state", + "sources": [ + { + "path": "backend/src/auth/session-store.ts", + "line": 389, + "end_line": 395, + "label": "createFileAuthSessionStore" + }, + { + "path": "compose.yaml", + "line": 30, + "end_line": 30 + } + ] + }, + { + "id": "idp", + "type": "security", + "label": "Identity provider", + "sublabel": "OIDC", + "sources": [ + { + "path": "backend/src/auth/oidc-client.ts", + "line": 24, + "end_line": 27, + "label": "OidcProtocol" + } + ] + } + ], + "segments": [ + { + "from": 160, + "to": 342, + "label": "Avvio login" + }, + { + "from": 352, + "to": 444, + "label": "Provider" + }, + { + "from": 454, + "to": 738, + "label": "Callback" + }, + { + "from": 748, + "to": 870, + "label": "Richieste" + } + ], + "messages": [ + { + "from": "browser", + "to": "backend", + "y": 170, + "label": "GET /auth/config" + }, + { + "from": "backend", + "to": "browser", + "y": 200, + "label": "mode: oidc", + "variant": "return" + }, + { + "from": "browser", + "to": "backend", + "y": 230, + "label": "GET /auth/oidc/login", + "variant": "emphasis" + }, + { + "from": "backend", + "to": "store", + "y": 260, + "label": "createOidcState", + "note": "nonce e code verifier PKCE" + }, + { + "from": "backend", + "to": "browser", + "y": 326, + "label": "302 verso il provider", + "variant": "return" + }, + { + "from": "browser", + "to": "idp", + "y": 362, + "label": "authorize + PKCE", + "variant": "security", + "note": "login sul provider" + }, + { + "from": "idp", + "to": "browser", + "y": 428, + "label": "302 callback con code", + "variant": "return" + }, + { + "from": "browser", + "to": "backend", + "y": 464, + "label": "GET /auth/oidc/callback", + "variant": "emphasis" + }, + { + "from": "backend", + "to": "store", + "y": 494, + "label": "consumeOidcState", + "note": "verifica transazione, revisione e issuer" + }, + { + "from": "backend", + "to": "idp", + "y": 560, + "label": "scambio code", + "variant": "security", + "note": "firma, audience, scadenza, nonce" + }, + { + "from": "idp", + "to": "backend", + "y": 626, + "label": "identità + gruppi", + "variant": "return" + }, + { + "from": "backend", + "to": "store", + "y": 656, + "label": "crea sessione", + "note": "ruoli dai gruppi, TTL limitato al token" + }, + { + "from": "backend", + "to": "browser", + "y": 722, + "label": "cookie + redirect /", + "variant": "return" + }, + { + "from": "browser", + "to": "backend", + "y": 758, + "label": "API con cookie", + "variant": "emphasis" + }, + { + "from": "backend", + "to": "store", + "y": 788, + "label": "resolve + touch", + "note": "sessione revocata se cambia la config" + }, + { + "from": "backend", + "to": "browser", + "y": 854, + "label": "risposta", + "variant": "return" + } + ], + "cards": [ + { + "dot": "cyan", + "title": "Tre modalità", + "items": [ + "local: utenti con hash Argon2id in users.yaml", + "oidc: questo flusso (Authorization Code + PKCE)", + "upstream: il proxy del portale (Omics) passa l'identità negli header; niente login né cookie ThothII" + ] + }, + { + "dot": "rose", + "title": "Autorizzazione", + "items": [ + "I gruppi OIDC sono mappati esattamente sui ruoli user e admin", + "I permessi si ricalcolano dai ruoli a ogni richiesta", + "Le richieste che modificano dati richiedono origine esatta e token CSRF" + ] + } + ] +} diff --git a/docs/architecture/thothii-catalog-sync.html b/docs/architecture/thothii-catalog-sync.html new file mode 100644 index 00000000..d901a538 --- /dev/null +++ b/docs/architecture/thothii-catalog-sync.html @@ -0,0 +1,14776 @@ + + + + + + + + ThothII — sincronizzazione schema del Metadata Catalog Diagram + + + + + + + + +
+ +
+
+
+

ThothII — sincronizzazione schema del Metadata Catalog

+
+
+ + + + +
+ + ThothII — sincronizzazione schema del Metadata Catalog + A lifecycle diagram generated by Archify. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + queued · un run attivo per database · Lifecycle state + + + + + 01 + queued + un run attivo per database + + + + running · scan DWH + piano delle modifiche · Lifecycle state + + + + 02 + running + scan DWH + piano delle modifiche + + + + applying · modifiche in una transazione · Lifecycle state · non cancellabile + + + + 03 + applying + modifiche in una transazione + non cancellabile + + + + succeeded · catalogo aggiornato · Lifecycle state + + + + + 04 + succeeded + catalogo aggiornato + + + + awaiting_confirmation · cancellazioni da confermare · Lifecycle state · admin + + + + awaiting_confirmation + cancellazioni da confermare + admin + + + + cancelled · annullato dall'utente · Lifecycle state + + + + + cancelled + annullato dall'utente + + + + failed · errore o timeout · Lifecycle state + + + + + failed + errore o timeout + + + + interrupted · riavvio del servizio · Lifecycle state + + + + + interrupted + riavvio del servizio + + + + + + claim + + + + piano pronto + + + + commit + + + + diff distruttivo + + + + confirm + + + + cancel + + + + cancel + + + + errore + + + + restart + + + + + Legend + + + initial state + + + + active + + + + waiting + + + + success + + + + failure / exit + + + + neutral + + + + final state + + + +

+ + + + + + + + + +
+ + + +
+ + + + diff --git a/docs/architecture/thothii-catalog-sync.lifecycle.json b/docs/architecture/thothii-catalog-sync.lifecycle.json new file mode 100644 index 00000000..474150c6 --- /dev/null +++ b/docs/architecture/thothii-catalog-sync.lifecycle.json @@ -0,0 +1,45 @@ +{ + "schema_version": 3, + "diagram_type": "lifecycle", + "meta": { "title": "ThothII — sincronizzazione schema del Metadata Catalog", "locale": "it", "output": "docs/architecture/thothii-catalog-sync.html", "quality_profile": "showcase", "repository": {"url": "https://git.tylconsulting.it/mptyl/ThothII.git", "link_mode": "local-only", "revision": "31e6d3a162e9e5ac71fc2d8da4fe44b16c06aae3"} }, + "mainPath": ["queued", "running", "applying", "succeeded"], + "states": [ + { "id": "queued", "type": "start", "label": "queued", "sublabel": "un run attivo per database", "step": "01", + "sources": [ { "path": "backend/src/catalog/migrations/003_catalog_schema_sync.ts", "line": 102, "end_line": 104, "label": "indice un solo attivo" } ] }, + { "id": "running", "type": "active", "label": "running", "sublabel": "scan DWH + piano delle modifiche", "step": "02", + "sources": [ { "path": "backend/src/catalog/sync-worker.ts", "line": 175, "end_line": 175, "label": "claimSyncRun" }, { "path": "backend/src/catalog/sync-worker.ts", "line": 210, "end_line": 220, "label": "scan + plan" } ] }, + { "id": "applying", "type": "active", "label": "applying", "sublabel": "modifiche in una transazione", "tag": "non cancellabile", "step": "03", + "sources": [ { "path": "backend/src/catalog/sync-worker.ts", "line": 243, "end_line": 250, "label": "applySchemaSync" } ] }, + { "id": "succeeded", "type": "success", "label": "succeeded", "sublabel": "catalogo aggiornato", "step": "04", + "sources": [ { "path": "backend/src/catalog/sync-worker.ts", "line": 300, "end_line": 300 } ] }, + { "id": "awaiting", "type": "waiting", "label": "awaiting_confirmation", "sublabel": "cancellazioni da confermare", "tag": "admin", + "sources": [ { "path": "backend/src/catalog/sync-worker.ts", "line": 222, "end_line": 240, "label": "diff distruttivo" }, { "path": "backend/src/catalog/sync-worker.ts", "line": 96, "end_line": 112, "label": "confirm" } ] }, + { "id": "cancelled", "type": "neutral", "label": "cancelled", "sublabel": "annullato dall'utente", + "sources": [ { "path": "backend/src/catalog/sync-worker.ts", "line": 114, "end_line": 136, "label": "cancel" } ] }, + { "id": "failed", "type": "failure", "label": "failed", "sublabel": "errore o timeout", + "sources": [ { "path": "backend/src/catalog/sync-worker.ts", "line": 260, "end_line": 272 } ] }, + { "id": "interrupted", "type": "failure", "label": "interrupted", "sublabel": "riavvio del servizio", + "sources": [ { "path": "backend/src/catalog/repository.ts", "line": 1896, "end_line": 1896, "label": "interruptActiveSyncRuns" } ] } + ], + "transitions": [ + { "id": "q-r", "from": "queued", "to": "running", "label": "claim" }, + { "id": "r-a", "from": "running", "to": "applying", "label": "piano pronto" }, + { "id": "a-s", "from": "applying", "to": "succeeded", "label": "commit", "variant": "emphasis" }, + { "id": "r-w", "from": "running", "to": "awaiting", "label": "diff distruttivo", "variant": "security" }, + { "id": "w-q", "from": "awaiting", "to": "queued", "label": "confirm" }, + { "id": "w-c", "from": "awaiting", "to": "cancelled", "label": "cancel" }, + { "id": "q-c", "from": "queued", "to": "cancelled", "label": "cancel" }, + { "id": "r-f", "from": "running", "to": "failed", "label": "errore", "variant": "security" }, + { "id": "r-i", "from": "running", "to": "interrupted", "label": "restart", "variant": "dashed" } + ], + "cards": [ + { "dot": "amber", "title": "Conferma", "items": [ + "Se il piano rimuove tabelle, colonne o relazioni il run si ferma e chiede conferma", + "La conferma vale solo per lo stesso snapshot: se il DWH cambia, si richiede di nuovo" + ] }, + { "dot": "cyan", "title": "Altri run", "items": [ + "I run di generazione descrizioni seguono stati analoghi: queued, running, completed, completed_with_errors, cancelled, failed, interrupted", + "Un run terminato può essere rilanciato con retry" + ] } + ] +} diff --git a/docs/architecture/thothii-core.sequence.json b/docs/architecture/thothii-core.sequence.json deleted file mode 100644 index cd02eccd..00000000 --- a/docs/architecture/thothii-core.sequence.json +++ /dev/null @@ -1,230 +0,0 @@ -{ - "schema_version": 1, - "diagram_type": "sequence", - "meta": { - "title": "Sequenza runtime del core ThothII", - "output": "thothii-core-sequence.html", - "quality_profile": "showcase", - "column_fit": "spread", - "viewBox": [1080, 540] - }, - "participants": [ - { - "id": "reviewer", - "type": "external", - "label": "Revisore", - "sublabel": "browser" - }, - { - "id": "frontend", - "type": "frontend", - "label": "Frontend", - "sublabel": "React + SSE" - }, - { - "id": "api", - "type": "backend", - "label": "Core API", - "sublabel": "Fastify + SseHub" - }, - { - "id": "runtime", - "type": "backend", - "label": "Runtime", - "sublabel": "manager + bridge" - }, - { - "id": "pi", - "type": "backend", - "label": "Pi + tht-gate", - "sublabel": "RPC per sessione" - }, - { - "id": "model", - "type": "external", - "label": "Modello AI", - "sublabel": "provider configurato" - }, - { - "id": "tht", - "type": "backend", - "label": "tht CLI", - "sublabel": "workflow persistito" - }, - { - "id": "state", - "type": "database", - "label": "Stato e dati", - "sublabel": "workspace + dati" - } - ], - "segments": [ - { - "from": 150, - "to": 300, - "label": "Avvio o ripresa" - }, - { - "from": 305, - "to": 395, - "label": "Turno Pi e workflow persistito" - }, - { - "from": 400, - "to": 475, - "label": "Evento SSE e gate umano" - } - ], - "messages": [ - { - "id": "askQuestion", - "from": "reviewer", - "to": "frontend", - "y": 160, - "label": "domanda o decisione gate", - "variant": "emphasis" - }, - { - "id": "createSession", - "from": "frontend", - "to": "api", - "y": 185, - "label": "POST /sessions o /response", - "variant": "emphasis" - }, - { - "id": "newManifest", - "from": "api", - "to": "tht", - "y": 210, - "label": "sessionNew o sessionShow/reopen" - }, - { - "id": "persistQuestion", - "from": "tht", - "to": "state", - "y": 235, - "label": "manifest, artifact e ledger" - }, - { - "id": "createRuntime", - "from": "api", - "to": "runtime", - "y": 260, - "label": "createFor + bind; configure + searchPack", - "note": "configure(...) e searchPack(...) terminano in parallelo prima dell’avvio del modello." - }, - { - "id": "startPi", - "from": "runtime", - "to": "pi", - "y": 285, - "label": "/nuova-domanda o /riprendi-sessione", - "variant": "emphasis", - "note": "In ripresa usa /riprendi-sessione dopo aver riletto provider, modello e thinking dal manifest." - }, - { - "id": "modelRequest", - "from": "pi", - "to": "model", - "y": 315, - "label": "turno modello; token e tool call" - }, - { - "id": "phaseCommand", - "from": "pi", - "to": "tht", - "y": 345, - "label": "comandi phase / session / evidence", - "variant": "emphasis" - }, - { - "id": "readWriteTruth", - "from": "tht", - "to": "state", - "y": 375, - "label": "legge/scrive artifact e ledger", - "note": "Il workspace persistito è la verità; DWH è read-only e Qdrant serve il retrieval." - }, - { - "id": "rpcEvents", - "from": "pi", - "to": "runtime", - "y": 405, - "label": "text_delta / ui_request" - }, - { - "id": "sseEvent", - "from": "runtime", - "to": "frontend", - "y": 430, - "label": "SSE via SseHub: text · info · widget", - "variant": "return" - }, - { - "id": "showResult", - "from": "frontend", - "to": "reviewer", - "y": 455, - "label": "testo o widget di revisione", - "variant": "return" - } - ], - "activations": [ - { - "participant": "frontend", - "from": 155, - "to": 460, - "type": "frontend" - }, - { - "participant": "api", - "from": 180, - "to": 290, - "type": "backend" - }, - { - "participant": "runtime", - "from": 255, - "to": 440, - "type": "backend" - }, - { - "participant": "pi", - "from": 280, - "to": 415, - "type": "backend" - }, - { - "participant": "model", - "from": 310, - "to": 335, - "type": "external" - }, - { - "participant": "tht", - "from": 205, - "to": 390, - "type": "backend" - }, - { - "participant": "state", - "from": 230, - "to": 390, - "type": "database" - } - ], - "cards": [ - { - "dot": "cyan", - "title": "Bootstrap", - "items": [ - "La sessione viene persistita prima dell’avvio di Pi; configurazione e retrieval terminano prima del primo prompt.", - "La ripresa rifiuta sessioni finalizzate o archiviate e usa sempre /riprendi-sessione .", - "Il modello propone; il revisore decide tramite reviewer_select, reviewer_decide o reviewer_confirm.", - "La risposta percorre POST /sessions/:id/response → bridge.respond → extension_ui_response; stale/duplicate ricevono 409.", - "La fase avanza solo dopo append della decisione esplicita e fold del ledger persistito." - ] - } - ] -} diff --git a/docs/architecture/thothii-deployment.architecture.json b/docs/architecture/thothii-deployment.architecture.json new file mode 100644 index 00000000..71c68ad1 --- /dev/null +++ b/docs/architecture/thothii-deployment.architecture.json @@ -0,0 +1,529 @@ +{ + "schema_version": 1, + "diagram_type": "architecture", + "meta": { + "title": "ThothII — deployment Docker Compose", + "locale": "it", + "output": "docs/architecture/thothii-deployment.html", + "quality_profile": "showcase", + "repository": { + "url": "https://git.tylconsulting.it/mptyl/ThothII.git", + "link_mode": "local-only", + "revision": "31e6d3a162e9e5ac71fc2d8da4fe44b16c06aae3" + } + }, + "components": [ + { + "id": "operator", + "type": "external", + "label": "Operatore", + "sublabel": "host", + "pos": [ + 40, + 40 + ], + "size": [ + 150, + 64 + ] + }, + { + "id": "thtcli", + "type": "backend", + "label": "tht (host)", + "sublabel": "CLI Go: setup, start, stop", + "pos": [ + 290, + 40 + ], + "size": [ + 170, + 64 + ], + "sources": [ + { + "path": "tools/tht/cmd/tht/main.go", + "line": 223, + "end_line": 237, + "label": "start / stop" + }, + { + "path": "tools/tht/internal/config/installation.go", + "line": 548, + "end_line": 548, + "label": "docker compose" + } + ] + }, + { + "id": "browser", + "type": "external", + "label": "Browser", + "sublabel": "o proxy del portale", + "pos": [ + 40, + 340 + ], + "size": [ + 150, + 64 + ] + }, + { + "id": "frontend", + "type": "frontend", + "label": "frontend", + "sublabel": "nginx :8080", + "tag": "unica porta pubblica", + "pos": [ + 290, + 340 + ], + "size": [ + 160, + 64 + ], + "sources": [ + { + "path": "compose.yaml", + "line": 190, + "end_line": 208 + }, + { + "path": "docker/nginx.conf.template", + "line": 13, + "end_line": 20, + "label": "/api → core" + }, + { + "path": "deploy/compose.server.yaml", + "line": 32, + "end_line": 34, + "label": "porta server" + } + ] + }, + { + "id": "core", + "type": "backend", + "label": "core", + "sublabel": "backend + Pi + tht :8787", + "tag": "MAX_PI_PROCESSES", + "pos": [ + 540, + 340 + ], + "size": [ + 190, + 84 + ], + "sources": [ + { + "path": "compose.yaml", + "line": 4, + "end_line": 72 + }, + { + "path": "docker/core.Dockerfile", + "line": 1, + "end_line": 5 + } + ] + }, + { + "id": "catalogdb", + "type": "database", + "label": "catalog-db", + "sublabel": "PostgreSQL 17", + "tag": "volume catalog-data", + "pos": [ + 820, + 340 + ], + "size": [ + 170, + 64 + ], + "sources": [ + { + "path": "compose.yaml", + "line": 74, + "end_line": 98 + } + ] + }, + { + "id": "migrate", + "type": "backend", + "label": "catalog-migrate", + "sublabel": "one-shot", + "pos": [ + 1080, + 340 + ], + "size": [ + 160, + 64 + ], + "sources": [ + { + "path": "compose.yaml", + "line": 100, + "end_line": 117 + } + ] + }, + { + "id": "qdrant", + "type": "database", + "label": "qdrant", + "sublabel": "vector store :6333", + "tag": "volume qdrant-data", + "pos": [ + 820, + 490 + ], + "size": [ + 170, + 64 + ], + "sources": [ + { + "path": "compose.yaml", + "line": 210, + "end_line": 228 + } + ] + }, + { + "id": "maint", + "type": "backend", + "label": "workspace-maintenance", + "sublabel": "one-shot, preprocessing", + "pos": [ + 1080, + 490 + ], + "size": [ + 190, + 64 + ], + "sources": [ + { + "path": "compose.yaml", + "line": 119, + "end_line": 188 + }, + { + "path": "backend/src/workspace-maintenance.ts", + "line": 22, + "end_line": 22, + "label": "comandi" + } + ] + }, + { + "id": "embedding", + "type": "backend", + "label": "embedding", + "sublabel": "Ollama :11434", + "tag": "volume embedding-models", + "pos": [ + 820, + 640 + ], + "size": [ + 170, + 64 + ], + "sources": [ + { + "path": "compose.yaml", + "line": 230, + "end_line": 249 + } + ] + }, + { + "id": "modelinit", + "type": "backend", + "label": "embedding-model-init", + "sublabel": "one-shot, scarica il modello", + "pos": [ + 1080, + 640 + ], + "size": [ + 190, + 64 + ], + "sources": [ + { + "path": "compose.yaml", + "line": 251, + "end_line": 264 + } + ] + }, + { + "id": "volumes", + "type": "database", + "label": "Volumi core", + "sublabel": "sessions, settings, pi-state, auth-state", + "tag": "+ workspace-registry/secrets", + "pos": [ + 500, + 560 + ], + "size": [ + 270, + 64 + ], + "sources": [ + { + "path": "compose.yaml", + "line": 42, + "end_line": 50 + }, + { + "path": "compose.yaml", + "line": 269, + "end_line": 278 + } + ] + }, + { + "id": "secrets", + "type": "security", + "label": "Secret + config", + "sublabel": "thothii.secrets, installation.yaml", + "pos": [ + 230, + 560 + ], + "size": [ + 230, + 64 + ], + "sources": [ + { + "path": "compose.yaml", + "line": 51, + "end_line": 57 + }, + { + "path": "compose.yaml", + "line": 280, + "end_line": 290 + } + ] + }, + { + "id": "git", + "type": "cloud", + "label": "Git remote workspace", + "sublabel": "THT_WORKSPACE_GIT_REMOTE", + "pos": [ + 290, + 190 + ], + "size": [ + 200, + 64 + ], + "sources": [ + { + "path": "backend/src/workspaces/git-repository.ts", + "line": 185, + "end_line": 195, + "label": "clone / refresh" + } + ] + }, + { + "id": "dwh", + "type": "cloud", + "label": "DWH", + "sublabel": "Postgres o REST, sola lettura", + "pos": [ + 820, + 190 + ], + "size": [ + 190, + 64 + ], + "sources": [ + { + "path": "compose.yaml", + "line": 36, + "end_line": 37 + } + ] + }, + { + "id": "llm", + "type": "cloud", + "label": "Provider LLM", + "sublabel": "THT_LLM_URL", + "pos": [ + 820, + 40 + ], + "size": [ + 170, + 64 + ], + "sources": [ + { + "path": "compose.yaml", + "line": 38, + "end_line": 38 + } + ] + } + ], + "boundaries": [ + { + "kind": "region", + "label": "rete Compose thothii", + "wraps": [ + "frontend", + "core", + "catalogdb", + "migrate", + "qdrant", + "maint", + "embedding", + "modelinit", + "volumes", + "secrets" + ] + } + ], + "connections": [ + { + "id": "op-cli", + "from": "operator", + "to": "thtcli", + "label": "comandi" + }, + { + "id": "cli-core", + "from": "thtcli", + "to": "core", + "label": "compose up", + "variant": "dashed" + }, + { + "id": "br-fe", + "from": "browser", + "to": "frontend", + "label": "HTTPS", + "variant": "emphasis" + }, + { + "id": "fe-core", + "from": "frontend", + "to": "core", + "label": "/api", + "variant": "emphasis" + }, + { + "id": "core-db", + "from": "core", + "to": "catalogdb", + "label": "SQL", + "variant": "emphasis" + }, + { + "id": "mig-db", + "from": "migrate", + "to": "catalogdb", + "label": "migra" + }, + { + "id": "core-qd", + "from": "core", + "to": "qdrant", + "label": "HTTP" + }, + { + "id": "core-emb", + "from": "core", + "to": "embedding", + "label": "embed" + }, + { + "id": "maint-qd", + "from": "maint", + "to": "qdrant", + "label": "reindicizza" + }, + { + "id": "init-emb", + "from": "modelinit", + "to": "embedding", + "label": "pull" + }, + { + "id": "core-vol", + "from": "core", + "to": "volumes", + "label": "monta" + }, + { + "id": "sec-core", + "from": "secrets", + "to": "core", + "label": "/run/secrets", + "variant": "security" + }, + { + "id": "core-git", + "from": "core", + "to": "git", + "label": "clone" + }, + { + "id": "core-dwh", + "from": "core", + "to": "dwh", + "label": "read-only" + }, + { + "id": "core-llm", + "from": "core", + "to": "llm", + "label": "API modelli" + } + ], + "cards": [ + { + "dot": "cyan", + "title": "Avvio", + "items": [ + "tht start sul host esegue docker compose con base + profilo (local o server)", + "catalog-migrate ed embedding-model-init girano una volta prima del core", + "Il core parte solo con catalog-db e qdrant sani e il modello di embedding scaricato" + ] + }, + { + "dot": "amber", + "title": "Profili", + "items": [ + "local: porte solo su 127.0.0.1 (frontend 8080, core 8787, Qdrant 6333)", + "server: espone solo il frontend dietro il proxy autenticato", + "workspace-maintenance gira on demand: preprocessing ed Evidence" + ] + }, + { + "dot": "rose", + "title": "Confini", + "items": [ + "DWH, provider LLM e Git remote sono esterni alla rete Compose", + "I secret arrivano come Docker secrets, mai in variabili o YAML" + ] + } + ] +} \ No newline at end of file diff --git a/docs/architecture/thothii-deployment.html b/docs/architecture/thothii-deployment.html new file mode 100644 index 00000000..d3ddbf62 --- /dev/null +++ b/docs/architecture/thothii-deployment.html @@ -0,0 +1,14953 @@ + + + + + + + + ThothII — deployment Docker Compose Diagram + + + + + + + + +
+ +
+
+
+

ThothII — deployment Docker Compose

+
+
+ + + + +
+ + ThothII — deployment Docker Compose + An architecture diagram generated by Archify. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Operatore · host · Architecture component + + + + Operatore + host + + + + tht (host) · CLI Go: setup, start, stop · Architecture component + + + + tht (host) + CLI Go: setup, start, stop + + + + Browser · o proxy del portale · Architecture component + + + + Browser + o proxy del portale + + + + frontend · nginx :8080 · rete Compose thothii · unica porta pubblica + + + + frontend + nginx :8080 + unica porta pubblica + + + + core · backend + Pi + tht :8787 · rete Compose thothii · MAX_PI_PROCESSES + + + + core + backend + Pi + tht :8787 + MAX_PI_PROCESSES + + + + catalog-db · PostgreSQL 17 · rete Compose thothii · volume catalog-data + + + + catalog-db + PostgreSQL 17 + volume catalog-data + + + + catalog-migrate · one-shot · rete Compose thothii + + + + catalog-migrate + one-shot + + + + qdrant · vector store :6333 · rete Compose thothii · volume qdrant-data + + + + qdrant + vector store :6333 + volume qdrant-data + + + + workspace-maintenance · one-shot, preprocessing · rete Compose thothii + + + + workspace-maintenance + one-shot, preprocessing + + + + embedding · Ollama :11434 · rete Compose thothii · volume embedding-models + + + + embedding + Ollama :11434 + volume embedding-models + + + + embedding-model-init · one-shot, scarica il modello · rete Compose thothii + + + + embedding-model-init + one-shot, scarica il modello + + + + Volumi core · sessions, settings, pi-state, auth-state · rete Compose thothii · + workspace-registry/secrets + + + + Volumi core + sessions, settings, pi-state, auth-state + + workspace-registry/secrets + + + + Secret + config · thothii.secrets, installation.yaml · rete Compose thothii + + + + Secret + config + thothii.secrets, installation.yaml + + + + Git remote workspace · THT_WORKSPACE_GIT_REMOTE · Architecture component + + + + Git remote workspace + THT_WORKSPACE_GIT_REMOTE + + + + DWH · Postgres o REST, sola lettura · Architecture component + + + + DWH + Postgres o REST, sola lettura + + + + Provider LLM · THT_LLM_URL · Architecture component + + + + Provider LLM + THT_LLM_URL + + + + + + comandi + + + + compose up + + + + HTTPS + + + + /api + + + + SQL + + + + migra + + + + HTTP + + + + embed + + + + reindicizza + + + + pull + + + + monta + + + + /run/secrets + + + + clone + + + + read-only + + + + API modelli + + + + + + rete Compose thothii + + + + + Legend + + + Frontend + + + + Backend + + + + Database + + + + Cloud + + + + Security + + + + External + + + +

+ + + + + + + + + +
+ + + +
+ + + + diff --git a/docs/architecture/thothii-diagrams.html b/docs/architecture/thothii-diagrams.html new file mode 100644 index 00000000..e6206681 --- /dev/null +++ b/docs/architecture/thothii-diagrams.html @@ -0,0 +1,88 @@ + + + + + +Diagrammi ThothII + + + +
+

Diagrammi dell'architettura ThothII

+

Diagrammi interattivi generati con Archify a partire dal codice. Ogni elemento + rimanda ai file e alle righe da cui deriva. Il sorgente JSON di ogni diagramma è nella stessa + cartella, con lo stesso nome.

+ +

Panoramica

+ + +

Workflow e sessioni

+ + +

Backend e sicurezza

+ + +

Dati e Metadata Catalog

+ + +
Per rigenerare un diagramma: modificare il suo JSON e rieseguire + archify finalize con --repo-root sulla radice del repository.
+
+ + diff --git a/docs/architecture/thothii-gate-roundtrip.html b/docs/architecture/thothii-gate-roundtrip.html new file mode 100644 index 00000000..b7d393cb --- /dev/null +++ b/docs/architecture/thothii-gate-roundtrip.html @@ -0,0 +1,14847 @@ + + + + + + + + ThothII — andata e ritorno di un gate reviewer Diagram + + + + + + + + +
+ +
+
+
+

ThothII — andata e ritorno di un gate reviewer

+
+
+ + + + +
+ + ThothII — andata e ritorno di un gate reviewer + A sequence diagram generated by Archify. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + tool call + + + + + + + + reviewer_select + + + + + + + + ctx.ui.input + + descrittore widgetcome JSON + + + + + + + extension_ui_request + + con l'id RPC di Pi + + + + + + + SSE ui_request + + il bridge ricordal'id di Pi + + + + + + + widget + + + + + + + + scelta + + + + + + + + POST /response + + 409 se il gate non èquello in attesa + + + + + + + 204 + + + + + + + + extension_ui_response + + + + + + + + risposta + + + + + + + + decision add + + accoda areview_decisions.jsonl + + + + + + + phase advance --auto + + + + + + + + risultato tool + + + + + + + + turno successivo + + + + + + + Proposta + + + + Decisione + + + + Persistenza + + + + + Reviewer · browser · Sequence participant + + + + Reviewer + browser + + + + Frontend · React · Sequence participant + + + + Frontend + React + + + + Backend · SessionBridge · Sequence participant + + + + Backend + SessionBridge + + + + Pi · --mode rpc · Sequence participant + + + + Pi + --mode rpc + + + + tht-gate.js · reviewer_select · Sequence participant + + + + tht-gate.js + reviewer_select + + + + tht CLI · ledger · Sequence participant + + + + tht CLI + ledger + + + + Provider LLM · modello di sessione · Sequence participant + + + + Provider LLM + modello di sessione + + + + + Legend + + + main request + + + + return + + + + async trace + + + + message + + + +

+ + + + + + + + + +
+ + + +
+ + + + diff --git a/docs/architecture/thothii-gate-roundtrip.sequence.json b/docs/architecture/thothii-gate-roundtrip.sequence.json new file mode 100644 index 00000000..c6105533 --- /dev/null +++ b/docs/architecture/thothii-gate-roundtrip.sequence.json @@ -0,0 +1,332 @@ +{ + "schema_version": 1, + "diagram_type": "sequence", + "meta": { + "title": "ThothII — andata e ritorno di un gate reviewer", + "locale": "it", + "output": "docs/architecture/thothii-gate-roundtrip.html", + "quality_profile": "showcase", + "repository": { + "url": "https://git.tylconsulting.it/mptyl/ThothII.git", + "link_mode": "local-only", + "revision": "31e6d3a162e9e5ac71fc2d8da4fe44b16c06aae3" + } + }, + "participants": [ + { + "id": "reviewer", + "type": "external", + "label": "Reviewer", + "sublabel": "browser" + }, + { + "id": "frontend", + "type": "frontend", + "label": "Frontend", + "sublabel": "React", + "sources": [ + { + "path": "frontend/src/store/sessionStore.ts", + "line": 76, + "end_line": 90, + "label": "pendingWidget" + }, + { + "path": "frontend/src/widgets/registry.ts", + "line": 5, + "end_line": 13, + "label": "registry widget" + }, + { + "path": "frontend/src/api/sessions.ts", + "line": 130, + "end_line": 134, + "label": "postResponse" + } + ] + }, + { + "id": "backend", + "type": "backend", + "label": "Backend", + "sublabel": "SessionBridge", + "sources": [ + { + "path": "backend/src/bridge/session-bridge.ts", + "line": 63, + "end_line": 71, + "label": "ui_request" + }, + { + "path": "backend/src/routes/sessions.ts", + "line": 634, + "end_line": 662, + "label": "POST /response" + }, + { + "path": "backend/src/bridge/session-bridge.ts", + "line": 178, + "end_line": 188, + "label": "respond" + } + ] + }, + { + "id": "pi", + "type": "backend", + "label": "Pi", + "sublabel": "--mode rpc" + }, + { + "id": "gate", + "type": "backend", + "label": "tht-gate.js", + "sublabel": "reviewer_select", + "sources": [ + { + "path": "harness/.pi/extensions/tht-gate.js", + "line": 924, + "end_line": 942, + "label": "execute" + }, + { + "path": "harness/.pi/extensions/tht-gate.js", + "line": 597, + "end_line": 603, + "label": "emitAndWait" + }, + { + "path": "harness/.pi/extensions/tht-gate.js", + "line": 465, + "end_line": 468, + "label": "advanceIfReady" + } + ] + }, + { + "id": "tht", + "type": "backend", + "label": "tht CLI", + "sublabel": "ledger", + "sources": [ + { + "path": "harness/tht/decisions.py", + "line": 98, + "end_line": 120, + "label": "append_decision" + }, + { + "path": "harness/tht/phase.py", + "line": 60, + "end_line": 79, + "label": "current_phase" + } + ] + }, + { + "id": "llm", + "type": "cloud", + "label": "Provider LLM", + "sublabel": "modello di sessione" + } + ], + "segments": [ + { + "from": 160, + "to": 420, + "label": "Proposta" + }, + { + "from": 428, + "to": 600, + "label": "Decisione" + }, + { + "from": 608, + "to": 790, + "label": "Persistenza" + } + ], + "messages": [ + { + "id": "call", + "from": "llm", + "to": "pi", + "y": 170, + "label": "tool call", + "variant": "return" + }, + { + "id": "exec", + "from": "pi", + "to": "gate", + "y": 200, + "label": "reviewer_select" + }, + { + "id": "input", + "from": "gate", + "to": "pi", + "y": 230, + "label": "ctx.ui.input", + "note": "descrittore widget come JSON" + }, + { + "id": "uireq", + "from": "pi", + "to": "backend", + "y": 290, + "label": "extension_ui_request", + "variant": "dashed", + "note": "con l'id RPC di Pi" + }, + { + "id": "sse", + "from": "backend", + "to": "frontend", + "y": 350, + "label": "SSE ui_request", + "variant": "dashed", + "note": "il bridge ricorda l'id di Pi" + }, + { + "id": "widget", + "from": "frontend", + "to": "reviewer", + "y": 410, + "label": "widget", + "variant": "return" + }, + { + "id": "pick", + "from": "reviewer", + "to": "frontend", + "y": 440, + "label": "scelta" + }, + { + "id": "post", + "from": "frontend", + "to": "backend", + "y": 470, + "label": "POST /response", + "variant": "emphasis", + "note": "409 se il gate non è quello in attesa" + }, + { + "id": "ok", + "from": "backend", + "to": "frontend", + "y": 530, + "label": "204", + "variant": "return" + }, + { + "id": "uiresp", + "from": "backend", + "to": "pi", + "y": 560, + "label": "extension_ui_response", + "variant": "emphasis" + }, + { + "id": "value", + "from": "pi", + "to": "gate", + "y": 620, + "label": "risposta", + "variant": "return" + }, + { + "id": "add", + "from": "gate", + "to": "tht", + "y": 650, + "label": "decision add", + "variant": "emphasis", + "note": "accoda a review_decisions.jsonl" + }, + { + "id": "advance", + "from": "gate", + "to": "tht", + "y": 720, + "label": "phase advance --auto", + "variant": "dashed" + }, + { + "id": "result", + "from": "gate", + "to": "pi", + "y": 750, + "label": "risultato tool", + "variant": "return" + }, + { + "id": "next", + "from": "pi", + "to": "llm", + "y": 780, + "label": "turno successivo", + "variant": "emphasis" + } + ], + "activations": [ + { + "participant": "pi", + "from": 165, + "to": 786, + "type": "backend" + }, + { + "participant": "gate", + "from": 198, + "to": 756, + "type": "backend" + }, + { + "participant": "backend", + "from": 288, + "to": 566, + "type": "backend" + }, + { + "participant": "frontend", + "from": 348, + "to": 536, + "type": "frontend" + }, + { + "participant": "tht", + "from": 648, + "to": 726, + "type": "backend" + } + ], + "cards": [ + { + "dot": "cyan", + "title": "Correlazione", + "items": [ + "Pi correla la risposta sul proprio id RPC, non sull'id del descrittore", + "Il bridge rimanda l'id di Pi; il valore contiene l'id del descrittore per il controllo del gate" + ] + }, + { + "dot": "emerald", + "title": "Persistenza", + "items": [ + "Un'opzione con payload decision è già la conferma: il gate la scrive con tht decision add", + "Un'opzione senza payload chiede soltanto e non scrive nulla", + "phase advance --auto avanza solo se la fase è completa" + ] + }, + { + "dot": "amber", + "title": "Altri widget", + "items": [ + "reviewer_decide (scelta multipla) e reviewer_confirm (artefatto o fase) seguono lo stesso percorso" + ] + } + ] +} \ No newline at end of file diff --git a/docs/architecture/thothii-metadata-catalog.erd.json b/docs/architecture/thothii-metadata-catalog.erd.json new file mode 100644 index 00000000..c46e777f --- /dev/null +++ b/docs/architecture/thothii-metadata-catalog.erd.json @@ -0,0 +1,1183 @@ +{ + "schema_version": 1, + "diagram_type": "erd", + "meta": { + "title": "ThothII — Metadata Catalog (PostgreSQL)", + "locale": "it", + "output": "docs/architecture/thothii-metadata-catalog.html", + "quality_profile": "standard", + "repository": { + "url": "https://git.tylconsulting.it/mptyl/ThothII.git", + "link_mode": "local-only", + "revision": "31e6d3a162e9e5ac71fc2d8da4fe44b16c06aae3" + } + }, + "layout": { + "mode": "grid" + }, + "entities": [ + { + "id": "workspace_databases", + "label": "workspace_databases", + "tag": "database", + "row": 0, + "col": 0, + "attributes": [ + { + "name": "id", + "type": "uuid", + "key": "pk" + }, + { + "name": "workspace_id", + "type": "text", + "key": "uk" + }, + { + "name": "engine", + "type": "text" + }, + { + "name": "database_name", + "type": "text" + }, + { + "name": "schema_name", + "type": "text" + }, + { + "name": "version", + "type": "integer" + }, + { + "name": "created_at", + "type": "timestamptz" + }, + { + "name": "updated_at", + "type": "timestamptz" + }, + { + "name": "schema_synced_version", + "type": "integer" + }, + { + "name": "schema_synced_at", + "type": "timestamptz" + }, + { + "name": "metadata_content_revision", + "type": "bigint" + }, + { + "name": "preprocessing_status", + "type": "text" + }, + { + "name": "preprocessing_input_fingerprint", + "type": "text" + }, + { + "name": "preprocessed_metadata_revision", + "type": "bigint" + }, + { + "name": "preprocessing_started_at", + "type": "timestamptz" + }, + { + "name": "preprocessing_finished_at", + "type": "timestamptz" + }, + { + "name": "preprocessing_error_code", + "type": "text" + }, + { + "name": "preprocessing_run_id", + "type": "text" + } + ], + "sources": [ + { + "path": "backend/src/catalog/migrations/001_workspace_databases.ts", + "line": 5, + "end_line": 16 + }, + { + "path": "backend/src/catalog/migrations/013_catalog_preprocessing_state.ts", + "line": 5, + "end_line": 13 + }, + { + "path": "backend/src/catalog/migrations/015_preprocessing_run_identity.ts", + "line": 6, + "end_line": 7 + } + ], + "width": 298 + }, + { + "id": "database_bindings", + "label": "database_bindings", + "tag": "database", + "row": 1, + "col": 0, + "attributes": [ + { + "name": "database_id", + "type": "uuid", + "references": "workspace_databases.id", + "key": [ + "pk", + "fk" + ] + }, + { + "name": "transport", + "type": "text" + }, + { + "name": "host", + "type": "text" + }, + { + "name": "port", + "type": "integer" + }, + { + "name": "username", + "type": "text" + }, + { + "name": "base_url", + "type": "text" + }, + { + "name": "rest_path", + "type": "text" + }, + { + "name": "rest_auth", + "type": "text" + }, + { + "name": "tls_servername", + "type": "text" + }, + { + "name": "ssh_host", + "type": "text" + }, + { + "name": "ssh_port", + "type": "integer" + }, + { + "name": "ssh_username", + "type": "text" + }, + { + "name": "ssh_target_host", + "type": "text" + }, + { + "name": "ssh_target_port", + "type": "integer" + }, + { + "name": "connection_status", + "type": "text" + }, + { + "name": "tested_version", + "type": "integer" + }, + { + "name": "last_tested_at", + "type": "timestamptz" + }, + { + "name": "last_error_code", + "type": "text" + }, + { + "name": "last_error_message", + "type": "text" + }, + { + "name": "updated_at", + "type": "timestamptz" + } + ], + "sources": [ + { + "path": "backend/src/catalog/migrations/001_workspace_databases.ts", + "line": 18, + "end_line": 52 + } + ], + "width": 244 + }, + { + "id": "installation_binding_imports", + "label": "installation_binding_imports", + "tag": "database", + "row": 2, + "col": 0, + "attributes": [ + { + "name": "workspace_id", + "type": "text", + "key": "pk" + }, + { + "name": "database_id", + "type": "uuid", + "key": "uk" + }, + { + "name": "created_at", + "type": "timestamptz" + } + ], + "sources": [ + { + "path": "backend/src/catalog/migrations/014_installation_binding_imports.ts", + "line": 6, + "end_line": 11 + } + ] + }, + { + "id": "catalog_tables", + "label": "catalog_tables", + "tag": "schema", + "row": 0, + "col": 1, + "attributes": [ + { + "name": "id", + "type": "uuid", + "key": "pk" + }, + { + "name": "database_id", + "type": "uuid", + "references": "workspace_databases.id", + "key": "fk" + }, + { + "name": "name", + "type": "text" + }, + { + "name": "source_comment", + "type": "text" + }, + { + "name": "description", + "type": "text" + }, + { + "name": "generated_description", + "type": "text" + }, + { + "name": "version", + "type": "integer" + }, + { + "name": "created_at", + "type": "timestamptz" + }, + { + "name": "updated_at", + "type": "timestamptz" + }, + { + "name": "last_synced_database_version", + "type": "integer" + }, + { + "name": "last_synced_at", + "type": "timestamptz" + } + ], + "sources": [ + { + "path": "backend/src/catalog/migrations/002_catalog_tables.ts", + "line": 5, + "end_line": 19 + }, + { + "path": "backend/src/catalog/migrations/003_catalog_schema_sync.ts", + "line": 10, + "end_line": 13 + } + ], + "width": 291 + }, + { + "id": "catalog_columns", + "label": "catalog_columns", + "tag": "schema", + "row": 1, + "col": 1, + "attributes": [ + { + "name": "id", + "type": "uuid", + "key": "pk" + }, + { + "name": "table_id", + "type": "uuid", + "references": "catalog_tables.id", + "key": "fk" + }, + { + "name": "name", + "type": "text" + }, + { + "name": "ordinal_position", + "type": "integer" + }, + { + "name": "data_type", + "type": "text" + }, + { + "name": "is_nullable", + "type": "boolean" + }, + { + "name": "default_expression", + "type": "text" + }, + { + "name": "primary_key_position", + "type": "integer" + }, + { + "name": "source_comment", + "type": "text" + }, + { + "name": "description", + "type": "text" + }, + { + "name": "generated_description", + "type": "text" + }, + { + "name": "last_synced_database_version", + "type": "integer" + }, + { + "name": "last_synced_at", + "type": "timestamptz" + }, + { + "name": "version", + "type": "integer" + }, + { + "name": "created_at", + "type": "timestamptz" + }, + { + "name": "updated_at", + "type": "timestamptz" + }, + { + "name": "sensitive", + "type": "boolean" + }, + { + "name": "sensitivity_reason", + "type": "text" + } + ], + "sources": [ + { + "path": "backend/src/catalog/migrations/003_catalog_schema_sync.ts", + "line": 15, + "end_line": 38 + }, + { + "path": "backend/src/catalog/migrations/006_sensitive_data_flag.ts", + "line": 5, + "end_line": 7 + }, + { + "path": "backend/src/catalog/migrations/012_sensitivity_reason.ts", + "line": 5, + "end_line": 7 + } + ], + "width": 291 + }, + { + "id": "catalog_relationships", + "label": "catalog_relationships", + "tag": "schema", + "row": 2, + "col": 1, + "attributes": [ + { + "name": "id", + "type": "uuid", + "key": "pk" + }, + { + "name": "database_id", + "type": "uuid", + "references": "workspace_databases.id", + "key": "fk" + }, + { + "name": "constraint_name", + "type": "text" + }, + { + "name": "source_table_id", + "type": "uuid", + "references": "catalog_tables.id", + "key": "fk" + }, + { + "name": "target_table_id", + "type": "uuid", + "references": "catalog_tables.id", + "key": "fk" + }, + { + "name": "update_rule", + "type": "text" + }, + { + "name": "delete_rule", + "type": "text" + }, + { + "name": "deferrable", + "type": "boolean" + }, + { + "name": "initially_deferred", + "type": "boolean" + }, + { + "name": "last_synced_database_version", + "type": "integer" + }, + { + "name": "last_synced_at", + "type": "timestamptz" + }, + { + "name": "created_at", + "type": "timestamptz" + }, + { + "name": "updated_at", + "type": "timestamptz" + } + ], + "sources": [ + { + "path": "backend/src/catalog/migrations/003_catalog_schema_sync.ts", + "line": 42, + "end_line": 60 + } + ], + "width": 291 + }, + { + "id": "catalog_relationship_columns", + "label": "catalog_relationship_columns", + "tag": "schema", + "row": 3, + "col": 1, + "attributes": [ + { + "name": "relationship_id", + "type": "uuid", + "references": "catalog_relationships.id", + "key": [ + "pk", + "fk" + ] + }, + { + "name": "position", + "type": "integer", + "key": "pk" + }, + { + "name": "source_column_id", + "type": "uuid", + "references": "catalog_columns.id", + "key": "fk" + }, + { + "name": "target_column_id", + "type": "uuid", + "references": "catalog_columns.id", + "key": "fk" + } + ], + "sources": [ + { + "path": "backend/src/catalog/migrations/003_catalog_schema_sync.ts", + "line": 64, + "end_line": 74 + } + ] + }, + { + "id": "catalog_logical_relationships", + "label": "catalog_logical_relationships", + "tag": "schema", + "row": 4, + "col": 1, + "attributes": [ + { + "name": "id", + "type": "uuid", + "key": "pk" + }, + { + "name": "database_id", + "type": "uuid", + "references": "workspace_databases.id", + "key": "fk" + }, + { + "name": "source_column_id", + "type": "uuid", + "references": "catalog_columns.id", + "key": "fk" + }, + { + "name": "target_column_id", + "type": "uuid", + "references": "catalog_columns.id", + "key": "fk" + }, + { + "name": "generated", + "type": "boolean" + }, + { + "name": "deleted_at", + "type": "timestamptz" + }, + { + "name": "created_at", + "type": "timestamptz" + }, + { + "name": "updated_at", + "type": "timestamptz" + } + ], + "sources": [ + { + "path": "backend/src/catalog/migrations/008_catalog_logical_relationships.ts", + "line": 5, + "end_line": 25 + } + ] + }, + { + "id": "catalog_sync_runs", + "label": "catalog_sync_runs", + "tag": "sync", + "row": 0, + "col": 2, + "attributes": [ + { + "name": "id", + "type": "uuid", + "key": "pk" + }, + { + "name": "database_id", + "type": "uuid", + "references": "workspace_databases.id", + "key": "fk" + }, + { + "name": "scope", + "type": "text" + }, + { + "name": "table_ids", + "type": "jsonb" + }, + { + "name": "state", + "type": "text" + }, + { + "name": "phase", + "type": "text" + }, + { + "name": "requested_database_version", + "type": "integer" + }, + { + "name": "observed_snapshot", + "type": "jsonb" + }, + { + "name": "planned_diff", + "type": "jsonb" + }, + { + "name": "confirmation_token", + "type": "text" + }, + { + "name": "counts", + "type": "jsonb" + }, + { + "name": "error_code", + "type": "text" + }, + { + "name": "error_message", + "type": "text" + }, + { + "name": "cancel_requested", + "type": "boolean" + }, + { + "name": "created_at", + "type": "timestamptz" + }, + { + "name": "started_at", + "type": "timestamptz" + }, + { + "name": "updated_at", + "type": "timestamptz" + }, + { + "name": "finished_at", + "type": "timestamptz" + }, + { + "name": "heartbeat_at", + "type": "timestamptz" + }, + { + "name": "lease_owner", + "type": "text" + }, + { + "name": "lease_expires_at", + "type": "timestamptz" + } + ], + "sources": [ + { + "path": "backend/src/catalog/migrations/003_catalog_schema_sync.ts", + "line": 76, + "end_line": 99 + } + ], + "width": 278 + }, + { + "id": "catalog_sync_events", + "label": "catalog_sync_events", + "tag": "sync", + "row": 1, + "col": 2, + "attributes": [ + { + "name": "id", + "type": "bigint", + "key": "pk" + }, + { + "name": "run_id", + "type": "uuid", + "references": "catalog_sync_runs.id", + "key": "fk" + }, + { + "name": "sequence", + "type": "integer" + }, + { + "name": "level", + "type": "text" + }, + { + "name": "event_type", + "type": "text" + }, + { + "name": "message", + "type": "text" + }, + { + "name": "data", + "type": "jsonb" + }, + { + "name": "created_at", + "type": "timestamptz" + } + ], + "sources": [ + { + "path": "backend/src/catalog/migrations/003_catalog_schema_sync.ts", + "line": 106, + "end_line": 117 + } + ] + }, + { + "id": "description_generation_runs", + "label": "description_generation_runs", + "tag": "run AI", + "row": 0, + "col": 3, + "attributes": [ + { + "name": "id", + "type": "uuid", + "key": "pk" + }, + { + "name": "database_id", + "type": "uuid", + "references": "workspace_databases.id", + "key": "fk" + }, + { + "name": "scope", + "type": "text" + }, + { + "name": "model_id", + "type": "text" + }, + { + "name": "language", + "type": "text" + }, + { + "name": "status", + "type": "text" + }, + { + "name": "total", + "type": "integer" + }, + { + "name": "processed", + "type": "integer" + }, + { + "name": "generated", + "type": "integer" + }, + { + "name": "non_generatable", + "type": "integer" + }, + { + "name": "failed", + "type": "integer" + }, + { + "name": "created_at", + "type": "timestamptz" + }, + { + "name": "started_at", + "type": "timestamptz" + }, + { + "name": "updated_at", + "type": "timestamptz" + }, + { + "name": "finished_at", + "type": "timestamptz" + }, + { + "name": "error_summary", + "type": "text" + }, + { + "name": "input_tokens", + "type": "integer" + }, + { + "name": "cache_read_tokens", + "type": "integer" + }, + { + "name": "output_tokens", + "type": "integer" + } + ], + "sources": [ + { + "path": "backend/src/catalog/migrations/005_description_generation_runs.ts", + "line": 5, + "end_line": 55 + } + ] + }, + { + "id": "description_generation_events", + "label": "description_generation_events", + "tag": "run AI", + "row": 1, + "col": 3, + "attributes": [ + { + "name": "run_id", + "type": "uuid", + "references": "description_generation_runs.id", + "key": [ + "pk", + "fk" + ] + }, + { + "name": "sequence", + "type": "integer", + "key": "pk" + }, + { + "name": "level", + "type": "text" + }, + { + "name": "message", + "type": "text" + }, + { + "name": "created_at", + "type": "timestamptz" + } + ], + "sources": [ + { + "path": "backend/src/catalog/migrations/005_description_generation_runs.ts", + "line": 64, + "end_line": 81 + } + ] + }, + { + "id": "sensitive_data_suggestion_runs", + "label": "sensitive_data_suggestion_runs", + "tag": "run AI", + "row": 2, + "col": 3, + "attributes": [ + { + "name": "id", + "type": "uuid", + "key": "pk" + }, + { + "name": "database_id", + "type": "uuid", + "references": "workspace_databases.id", + "key": "fk" + }, + { + "name": "scope", + "type": "text" + }, + { + "name": "model_id", + "type": "text" + }, + { + "name": "status", + "type": "text" + }, + { + "name": "total", + "type": "integer" + }, + { + "name": "suggested_sensitive", + "type": "integer" + }, + { + "name": "suggested_non_sensitive", + "type": "integer" + }, + { + "name": "created_at", + "type": "timestamptz" + }, + { + "name": "started_at", + "type": "timestamptz" + }, + { + "name": "updated_at", + "type": "timestamptz" + }, + { + "name": "finished_at", + "type": "timestamptz" + }, + { + "name": "error_summary", + "type": "text" + }, + { + "name": "input_tokens", + "type": "integer" + }, + { + "name": "cache_read_tokens", + "type": "integer" + }, + { + "name": "output_tokens", + "type": "integer" + }, + { + "name": "engine", + "type": "text" + }, + { + "name": "policy_version", + "type": "text" + }, + { + "name": "unknown", + "type": "integer" + } + ], + "sources": [ + { + "path": "backend/src/catalog/migrations/007_sensitive_data_suggestion_runs.ts", + "line": 5, + "end_line": 43 + } + ], + "width": 258 + }, + { + "id": "sensitive_data_suggestion_events", + "label": "sensitive_data_suggestion_events", + "tag": "run AI", + "row": 3, + "col": 3, + "attributes": [ + { + "name": "run_id", + "type": "uuid", + "references": "sensitive_data_suggestion_runs.id", + "key": [ + "pk", + "fk" + ] + }, + { + "name": "sequence", + "type": "integer", + "key": "pk" + }, + { + "name": "level", + "type": "text" + }, + { + "name": "message", + "type": "text" + }, + { + "name": "created_at", + "type": "timestamptz" + } + ], + "sources": [ + { + "path": "backend/src/catalog/migrations/007_sensitive_data_suggestion_runs.ts", + "line": 50, + "end_line": 67 + } + ] + } + ], + "relationships": [ + { + "id": "catalog-columns-table-id", + "from": "catalog_tables", + "to": "catalog_columns", + "fromCardinality": "one", + "toCardinality": "many" + }, + { + "id": "catalog-logical-relationships-database-id", + "from": "workspace_databases", + "to": "catalog_logical_relationships", + "fromCardinality": "one", + "toCardinality": "many" + }, + { + "id": "catalog-logical-relationships-source-column-id", + "from": "catalog_columns", + "to": "catalog_logical_relationships", + "fromCardinality": "one", + "toCardinality": "many" + }, + { + "id": "catalog-logical-relationships-target-column-id", + "from": "catalog_columns", + "to": "catalog_logical_relationships", + "fromCardinality": "one", + "toCardinality": "many" + }, + { + "id": "catalog-relationship-columns-relationship-id", + "from": "catalog_relationships", + "to": "catalog_relationship_columns", + "fromCardinality": "one", + "toCardinality": "many" + }, + { + "id": "catalog-relationship-columns-source-column-id", + "from": "catalog_columns", + "to": "catalog_relationship_columns", + "fromCardinality": "one", + "toCardinality": "many" + }, + { + "id": "catalog-relationship-columns-target-column-id", + "from": "catalog_columns", + "to": "catalog_relationship_columns", + "fromCardinality": "one", + "toCardinality": "many" + }, + { + "id": "catalog-relationships-database-id", + "from": "workspace_databases", + "to": "catalog_relationships", + "fromCardinality": "one", + "toCardinality": "many" + }, + { + "id": "catalog-relationships-source-table-id", + "from": "catalog_tables", + "to": "catalog_relationships", + "fromCardinality": "one", + "toCardinality": "many" + }, + { + "id": "catalog-relationships-target-table-id", + "from": "catalog_tables", + "to": "catalog_relationships", + "fromCardinality": "one", + "toCardinality": "many" + }, + { + "id": "catalog-sync-events-run-id", + "from": "catalog_sync_runs", + "to": "catalog_sync_events", + "fromCardinality": "one", + "toCardinality": "many" + }, + { + "id": "catalog-sync-runs-database-id", + "from": "workspace_databases", + "to": "catalog_sync_runs", + "fromCardinality": "one", + "toCardinality": "many" + }, + { + "id": "catalog-tables-database-id", + "from": "workspace_databases", + "to": "catalog_tables", + "fromCardinality": "one", + "toCardinality": "many" + }, + { + "id": "database-bindings-database-id", + "from": "workspace_databases", + "to": "database_bindings", + "fromCardinality": "one", + "toCardinality": "one" + }, + { + "id": "description-generation-events-run-id", + "from": "description_generation_runs", + "to": "description_generation_events", + "fromCardinality": "one", + "toCardinality": "many" + }, + { + "id": "description-generation-runs-database-id", + "from": "workspace_databases", + "to": "description_generation_runs", + "fromCardinality": "one", + "toCardinality": "many" + }, + { + "id": "sensitive-data-suggestion-events-run-id", + "from": "sensitive_data_suggestion_runs", + "to": "sensitive_data_suggestion_events", + "fromCardinality": "one", + "toCardinality": "many" + }, + { + "id": "sensitive-data-suggestion-runs-database-id", + "from": "workspace_databases", + "to": "sensitive_data_suggestion_runs", + "fromCardinality": "one", + "toCardinality": "many" + } + ], + "cards": [ + { + "dot": "cyan", + "title": "Domini", + "items": [ + "database: identità e binding di ogni database di workspace", + "schema: tabelle, colonne e relazioni sincronizzate dal DWH, con descrizioni e sensibilità", + "sync e run AI: esecuzioni con eventi ordinati per sequence" + ] + }, + { + "dot": "amber", + "title": "Vincoli non disegnati", + "items": [ + "Unicità composte: (database_id, name) su catalog_tables, (table_id, name) su catalog_columns, (run_id, sequence) sugli eventi", + "Al massimo un run di sync attivo per database e un solo run di descrizioni attivo", + "installation_binding_imports.database_id non ha FK: un database importato e poi cancellato va riconciliato" + ] + }, + { + "dot": "emerald", + "title": "Origine", + "items": [ + "Schema ricostruito dalle 15 migrazioni in backend/src/catalog/migrations", + "Tutte le FK hanno ON DELETE CASCADE" + ] + } + ] +} \ No newline at end of file diff --git a/docs/architecture/thothii-metadata-catalog.html b/docs/architecture/thothii-metadata-catalog.html new file mode 100644 index 00000000..4a1d88fa --- /dev/null +++ b/docs/architecture/thothii-metadata-catalog.html @@ -0,0 +1,16118 @@ + + + + + + + + ThothII — Metadata Catalog (PostgreSQL) Diagram + + + + + + + + +
+ +
+
+
+

ThothII — Metadata Catalog (PostgreSQL)

+
+
+ + + + +
+ + ThothII — Metadata Catalog (PostgreSQL) + An entity-relationship diagram generated by Archify. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + database + + + + + + schema + + + + + + sync + + + + + + run AI + + + + + + + + + + + + + + + + + + + + + + + + + + + + + workspace_databases · Entity · database + + + + + + workspace_databases + + + + + PK + id + uuid + + + + + UK + workspace_id + text + + + + + + engine + text + + + + + + database_name + text + + + + + + schema_name + text + + + + + + version + integer + + + + + + created_at + timestamptz + + + + + + updated_at + timestamptz + + + + + + schema_synced_version + integer + + + + + + schema_synced_at + timestamptz + + + + + + metadata_content_revision + bigint + + + + + + preprocessing_status + text + + + + + + preprocessing_input_fingerprint + text + + + + + + preprocessed_metadata_revision + bigint + + + + + + preprocessing_started_at + timestamptz + + + + + + preprocessing_finished_at + timestamptz + + + + + + preprocessing_error_code + text + + + + + + preprocessing_run_id + text + + + + + database_bindings · Entity · database + + + + + + database_bindings + + + + + PKFK + database_id + uuid + + + + + + transport + text + + + + + + host + text + + + + + + port + integer + + + + + + username + text + + + + + + base_url + text + + + + + + rest_path + text + + + + + + rest_auth + text + + + + + + tls_servername + text + + + + + + ssh_host + text + + + + + + ssh_port + integer + + + + + + ssh_username + text + + + + + + ssh_target_host + text + + + + + + ssh_target_port + integer + + + + + + connection_status + text + + + + + + tested_version + integer + + + + + + last_tested_at + timestamptz + + + + + + last_error_code + text + + + + + + last_error_message + text + + + + + + updated_at + timestamptz + + + + + installation_binding_imports · Entity · database + + + + + + installation_binding_imports + + + + + PK + workspace_id + text + + + + + UK + database_id + uuid + + + + + + created_at + timestamptz + + + + + catalog_tables · Entity · schema + + + + + + catalog_tables + + + + + PK + id + uuid + + + + + FK + database_id + uuid + + + + + + name + text + + + + + + source_comment + text + + + + + + description + text + + + + + + generated_description + text + + + + + + version + integer + + + + + + created_at + timestamptz + + + + + + updated_at + timestamptz + + + + + + last_synced_database_version + integer + + + + + + last_synced_at + timestamptz + + + + + catalog_columns · Entity · schema + + + + + + catalog_columns + + + + + PK + id + uuid + + + + + FK + table_id + uuid + + + + + + name + text + + + + + + ordinal_position + integer + + + + + + data_type + text + + + + + + is_nullable + boolean + + + + + + default_expression + text + + + + + + primary_key_position + integer + + + + + + source_comment + text + + + + + + description + text + + + + + + generated_description + text + + + + + + last_synced_database_version + integer + + + + + + last_synced_at + timestamptz + + + + + + version + integer + + + + + + created_at + timestamptz + + + + + + updated_at + timestamptz + + + + + + sensitive + boolean + + + + + + sensitivity_reason + text + + + + + catalog_relationships · Entity · schema + + + + + + catalog_relationships + + + + + PK + id + uuid + + + + + FK + database_id + uuid + + + + + + constraint_name + text + + + + + FK + source_table_id + uuid + + + + + FK + target_table_id + uuid + + + + + + update_rule + text + + + + + + delete_rule + text + + + + + + deferrable + boolean + + + + + + initially_deferred + boolean + + + + + + last_synced_database_version + integer + + + + + + last_synced_at + timestamptz + + + + + + created_at + timestamptz + + + + + + updated_at + timestamptz + + + + + catalog_relationship_columns · Entity · schema + + + + + + catalog_relationship_columns + + + + + PKFK + relationship_id + uuid + + + + + PK + position + integer + + + + + FK + source_column_id + uuid + + + + + FK + target_column_id + uuid + + + + + catalog_logical_relationships · Entity · schema + + + + + + catalog_logical_relationships + + + + + PK + id + uuid + + + + + FK + database_id + uuid + + + + + FK + source_column_id + uuid + + + + + FK + target_column_id + uuid + + + + + + generated + boolean + + + + + + deleted_at + timestamptz + + + + + + created_at + timestamptz + + + + + + updated_at + timestamptz + + + + + catalog_sync_runs · Entity · sync + + + + + + catalog_sync_runs + + + + + PK + id + uuid + + + + + FK + database_id + uuid + + + + + + scope + text + + + + + + table_ids + jsonb + + + + + + state + text + + + + + + phase + text + + + + + + requested_database_version + integer + + + + + + observed_snapshot + jsonb + + + + + + planned_diff + jsonb + + + + + + confirmation_token + text + + + + + + counts + jsonb + + + + + + error_code + text + + + + + + error_message + text + + + + + + cancel_requested + boolean + + + + + + created_at + timestamptz + + + + + + started_at + timestamptz + + + + + + updated_at + timestamptz + + + + + + finished_at + timestamptz + + + + + + heartbeat_at + timestamptz + + + + + + lease_owner + text + + + + + + lease_expires_at + timestamptz + + + + + catalog_sync_events · Entity · sync + + + + + + catalog_sync_events + + + + + PK + id + bigint + + + + + FK + run_id + uuid + + + + + + sequence + integer + + + + + + level + text + + + + + + event_type + text + + + + + + message + text + + + + + + data + jsonb + + + + + + created_at + timestamptz + + + + + description_generation_runs · Entity · run AI + + + + + + description_generation_runs + + + + + PK + id + uuid + + + + + FK + database_id + uuid + + + + + + scope + text + + + + + + model_id + text + + + + + + language + text + + + + + + status + text + + + + + + total + integer + + + + + + processed + integer + + + + + + generated + integer + + + + + + non_generatable + integer + + + + + + failed + integer + + + + + + created_at + timestamptz + + + + + + started_at + timestamptz + + + + + + updated_at + timestamptz + + + + + + finished_at + timestamptz + + + + + + error_summary + text + + + + + + input_tokens + integer + + + + + + cache_read_tokens + integer + + + + + + output_tokens + integer + + + + + description_generation_events · Entity · run AI + + + + + + description_generation_events + + + + + PKFK + run_id + uuid + + + + + PK + sequence + integer + + + + + + level + text + + + + + + message + text + + + + + + created_at + timestamptz + + + + + sensitive_data_suggestion_runs · Entity · run AI + + + + + + sensitive_data_suggestion_runs + + + + + PK + id + uuid + + + + + FK + database_id + uuid + + + + + + scope + text + + + + + + model_id + text + + + + + + status + text + + + + + + total + integer + + + + + + suggested_sensitive + integer + + + + + + suggested_non_sensitive + integer + + + + + + created_at + timestamptz + + + + + + started_at + timestamptz + + + + + + updated_at + timestamptz + + + + + + finished_at + timestamptz + + + + + + error_summary + text + + + + + + input_tokens + integer + + + + + + cache_read_tokens + integer + + + + + + output_tokens + integer + + + + + + engine + text + + + + + + policy_version + text + + + + + + unknown + integer + + + + + sensitive_data_suggestion_events · Entity · run AI + + + + + + sensitive_data_suggestion_events + + + + + PKFK + run_id + uuid + + + + + PK + sequence + integer + + + + + + level + text + + + + + + message + text + + + + + + created_at + timestamptz + + + + + + + + + Legend + + PK + Primary key + + + FK + Foreign key + + + UK + Unique key + + + + One + + + + Many + + + +

+ + + + + + + + + +
+ + + +
+ + + + diff --git a/docs/architecture/thothii-metadata-flow.dataflow.json b/docs/architecture/thothii-metadata-flow.dataflow.json new file mode 100644 index 00000000..92170a7c --- /dev/null +++ b/docs/architecture/thothii-metadata-flow.dataflow.json @@ -0,0 +1,388 @@ +{ + "schema_version": 1, + "diagram_type": "dataflow", + "meta": { + "title": "ThothII — dai metadati del DWH al contesto di sessione", + "locale": "it", + "output": "docs/architecture/thothii-metadata-flow.html", + "quality_profile": "showcase", + "repository": { + "url": "https://git.tylconsulting.it/mptyl/ThothII.git", + "link_mode": "local-only", + "revision": "31e6d3a162e9e5ac71fc2d8da4fe44b16c06aae3" + } + }, + "stages": [ + { + "label": "Fonti" + }, + { + "label": "Catalogo" + }, + { + "label": "Preprocessing" + }, + { + "label": "Indici" + }, + { + "label": "Sessione" + } + ], + "nodes": [ + { + "id": "dwh", + "type": "database", + "label": "DWH", + "sublabel": "sola lettura", + "stage": 0, + "row": 0, + "sources": [ + { + "path": "backend/src/catalog/sync-worker.ts", + "line": 210, + "end_line": 220, + "label": "scan schema" + }, + { + "path": "backend/src/catalog/description-source-sampler.ts", + "line": 153, + "end_line": 160, + "label": "campionamento" + } + ] + }, + { + "id": "gitws", + "type": "cloud", + "label": "Workspace Git", + "sublabel": "fonti Evidence", + "stage": 0, + "row": 2, + "sources": [ + { + "path": "backend/src/workspaces/git-repository.ts", + "line": 185, + "end_line": 195 + } + ] + }, + { + "id": "catalog", + "type": "database", + "label": "Metadata Catalog", + "sublabel": "PostgreSQL", + "stage": 1, + "row": 0, + "sources": [ + { + "path": "backend/src/catalog/repository.ts", + "line": 488, + "end_line": 488, + "label": "KyselyCatalogRepository" + } + ] + }, + { + "id": "descgen", + "type": "backend", + "label": "Descrizioni AI", + "sublabel": "helper LiteLLM", + "stage": 1, + "row": 1, + "sources": [ + { + "path": "backend/src/catalog/model-completer.ts", + "line": 67, + "end_line": 74 + }, + { + "path": "backend/src/catalog/migrations/005_description_generation_runs.ts", + "line": 5, + "end_line": 5, + "label": "run" + } + ] + }, + { + "id": "memdb", + "type": "database", + "label": "Card memoria", + "sublabel": "schema thoth_memory", + "stage": 4, + "row": 0, + "sources": [ + { + "path": "harness/tht/memory/repository.py", + "line": 15, + "end_line": 15, + "label": "MemoryRepository" + }, + { + "path": "harness/tht/memory/migrate.py", + "line": 46, + "end_line": 50 + } + ] + }, + { + "id": "snapshot", + "type": "backend", + "label": "Snapshot catalogo", + "sublabel": "JSON immutabile", + "stage": 2, + "row": 0, + "sources": [ + { + "path": "backend/src/workspaces/preprocessing-service.ts", + "line": 289, + "end_line": 301 + } + ] + }, + { + "id": "prep", + "type": "backend", + "label": "preprocess catalog", + "sublabel": "tht + embedding", + "stage": 2, + "row": 1, + "sources": [ + { + "path": "backend/src/workspaces/preprocessing-service.ts", + "line": 321, + "end_line": 329 + }, + { + "path": "harness/tht/cli/preprocess_cmd.py", + "line": 523, + "end_line": 545 + } + ] + }, + { + "id": "evprep", + "type": "backend", + "label": "preprocess Evidence", + "sublabel": "corpus + embedding", + "stage": 2, + "row": 2, + "sources": [ + { + "path": "backend/src/workspaces/preprocessing-service.ts", + "line": 330, + "end_line": 339 + } + ] + }, + { + "id": "lsh", + "type": "database", + "label": "Indice LSH", + "sublabel": "valori delle colonne", + "stage": 3, + "row": 1, + "sources": [ + { + "path": "harness/tht/cli/preprocess_cmd.py", + "line": 167, + "end_line": 193 + } + ] + }, + { + "id": "qref", + "type": "database", + "label": "Qdrant reference", + "sublabel": "schema + Evidence", + "stage": 3, + "row": 2, + "sources": [ + { + "path": "harness/tht/adapters/vector/qdrant.py", + "line": 327, + "end_line": 327, + "label": "upsert" + } + ] + }, + { + "id": "qmem", + "type": "database", + "label": "Qdrant memory", + "sublabel": "dense + BM25", + "stage": 3, + "row": 0, + "sources": [ + { + "path": "harness/tht/memory/repository.py", + "line": 225, + "end_line": 235, + "label": "proiezioni" + } + ] + }, + { + "id": "pack", + "type": "backend", + "label": "search pack", + "sublabel": "retrieval_pack.md", + "stage": 4, + "row": 2, + "sources": [ + { + "path": "harness/tht/cli/search_cmd.py", + "line": 351, + "end_line": 420 + } + ] + }, + { + "id": "session", + "type": "frontend", + "label": "Sessione F1–F8", + "sublabel": "search find in F4", + "stage": 4, + "row": 1, + "sources": [ + { + "path": "harness/tht/cli/search_cmd.py", + "line": 129, + "end_line": 131, + "label": "search find" + }, + { + "path": "harness/tht/cli/search_cmd.py", + "line": 219, + "end_line": 226, + "label": "usa LSH" + } + ] + } + ], + "flows": [ + { + "id": "dwh-catalog", + "from": "dwh", + "to": "catalog", + "label": "sync schema", + "variant": "emphasis" + }, + { + "id": "dwh-desc", + "from": "dwh", + "to": "descgen", + "label": "campioni", + "variant": "security" + }, + { + "id": "desc-catalog", + "from": "descgen", + "to": "catalog", + "label": "descrizioni" + }, + { + "id": "catalog-snap", + "from": "catalog", + "to": "snapshot", + "label": "metadati", + "variant": "emphasis" + }, + { + "id": "snap-prep", + "from": "snapshot", + "to": "prep", + "label": "file snapshot" + }, + { + "id": "prep-lsh", + "from": "prep", + "to": "lsh", + "label": "MinHash" + }, + { + "id": "prep-qref", + "from": "prep", + "to": "qref", + "label": "vettori schema", + "variant": "emphasis" + }, + { + "id": "git-ev", + "from": "gitws", + "to": "evprep", + "label": "fonti Evidence" + }, + { + "id": "ev-qref", + "from": "evprep", + "to": "qref", + "label": "vettori Evidence" + }, + { + "id": "mem-qmem", + "from": "memdb", + "to": "qmem", + "label": "proiezione", + "variant": "dashed" + }, + { + "id": "qref-pack", + "from": "qref", + "to": "pack", + "label": "ricerca ibrida", + "variant": "emphasis" + }, + { + "id": "qmem-pack", + "from": "qmem", + "to": "pack", + "label": "domande risolte" + }, + { + "id": "pack-session", + "from": "pack", + "to": "session", + "label": "contesto F1", + "variant": "emphasis" + }, + { + "id": "lsh-session", + "from": "lsh", + "to": "session", + "label": "valori" + }, + { + "id": "session-mem", + "from": "session", + "to": "memdb", + "label": "promozione F8", + "variant": "dashed" + } + ], + "cards": [ + { + "dot": "cyan", + "title": "Autorità", + "items": [ + "Il Metadata Catalog è l'unica fonte dei metadati di database per tutto il core", + "Il preprocessing lavora su uno snapshot immutabile del catalogo, non sul DWH" + ] + }, + { + "dot": "amber", + "title": "Collezioni separate", + "items": [ + "reference (schema, relazioni, Evidence) può essere svuotata e ricostruita dal preprocessing", + "memory si ricostruisce dalle card PostgreSQL e non viene toccata dal preprocessing" + ] + }, + { + "dot": "rose", + "title": "Prerequisito", + "items": [ + "Senza preprocessing completato il core non ammette nuove sessioni" + ] + } + ] +} \ No newline at end of file diff --git a/docs/architecture/thothii-metadata-flow.html b/docs/architecture/thothii-metadata-flow.html new file mode 100644 index 00000000..b84c32dd --- /dev/null +++ b/docs/architecture/thothii-metadata-flow.html @@ -0,0 +1,14854 @@ + + + + + + + + ThothII — dai metadati del DWH al contesto di sessione Diagram + + + + + + + + +
+ +
+
+
+

ThothII — dai metadati del DWH al contesto di sessione

+
+
+ + + + +
+ + ThothII — dai metadati del DWH al contesto di sessione + A data-flow diagram generated by Archify. + + + + + + + + + + + + + + + + + + + + + + + + + 01 / Fonti + + + 02 / Catalogo + + + 03 / Preprocessing + + + 04 / Indici + + + 05 / Sessione + + + + + + + + + + + + + + + + + + + + + + + + + + + DWH · sola lettura · 01 / Fonti + + + + DWH + sola lettura + + + + Workspace Git · fonti Evidence · 01 / Fonti + + + + Workspace Git + fonti Evidence + + + + Metadata Catalog · PostgreSQL · 02 / Catalogo + + + + Metadata Catalog + PostgreSQL + + + + Descrizioni AI · helper LiteLLM · 02 / Catalogo + + + + Descrizioni AI + helper LiteLLM + + + + Card memoria · schema thoth_memory · 05 / Sessione + + + + Card memoria + schema thoth_memory + + + + Snapshot catalogo · JSON immutabile · 03 / Preprocessing + + + + Snapshot catalogo + JSON immutabile + + + + preprocess catalog · tht + embedding · 03 / Preprocessing + + + + preprocess catalog + tht + embedding + + + + preprocess Evidence · corpus + embedding · 03 / Preprocessing + + + + preprocess Evidence + corpus + embedding + + + + Indice LSH · valori delle colonne · 04 / Indici + + + + Indice LSH + valori delle colonne + + + + Qdrant reference · schema + Evidence · 04 / Indici + + + + Qdrant reference + schema + Evidence + + + + Qdrant memory · dense + BM25 · 04 / Indici + + + + Qdrant memory + dense + BM25 + + + + search pack · retrieval_pack.md · 05 / Sessione + + + + search pack + retrieval_pack.md + + + + Sessione F1–F8 · search find in F4 · 05 / Sessione + + + + Sessione F1–F8 + search find in F4 + + + + + + sync schema + + + + campioni + + + + descrizioni + + + + metadati + + + + file snapshot + + + + MinHash + + + + vettori schema + + + + fonti Evidence + + + + vettori Evidence + + + + proiezione + + + + ricerca ibrida + + + + domande risolte + + + + contesto F1 + + + + valori + + + + promozione F8 + + + + + Legend + + + primary data + + + + policy / PII + + + + async batch + + + + data store + + + + data flow + + + +

+ + + + + + + + + +
+ + + +
+ + + + diff --git a/docs/architecture/thothii-modules.html b/docs/architecture/thothii-modules.html new file mode 100644 index 00000000..11554549 --- /dev/null +++ b/docs/architecture/thothii-modules.html @@ -0,0 +1,14987 @@ + + + + + + + + ThothII — struttura dei moduli Diagram + + + + + + + + +
+ +
+
+
+

ThothII — struttura dei moduli

+
+
+ + + + +
+ + ThothII — struttura dei moduli + A hierarchy diagram generated by Archify. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ThothII · monorepo, tre layer + operatore · Root + + + + + + ThothII + monorepo, trelayer + operatore + + + frontend/ · React 18 + Vite · Branch + + + + + + frontend/ + React 18 + Vite + + + src/api · client HTTP verso /api · Leaf + + + + + + src/api + client HTTP verso /api + + + src/shell · AppShell e pagine admin · Leaf + + + + + + src/shell + AppShell e pagine admin + + + src/store + stream · transcript live da SSE · Leaf + + + + + + src/store + stream + transcript live da SSE + + + src/widgets · widget dei gate reviewer · Leaf + + + + + + src/widgets + widget dei gate reviewer + + + src/i18n · cataloghi EN/IT · Leaf + + + + + + src/i18n + cataloghi EN/IT + + + backend/ · Fastify + TypeScript · Branch + + + + + + backend/ + Fastify + TypeScript + + + src/routes · API REST e SSE · Leaf + + + + + + src/routes + API REST e SSE + + + src/pi + rpc + bridge · processi Pi e bridge RPC · Leaf + + + + + + src/pi + rpc +bridge + processi Pi e bridge RPC + + + src/sse · SseHub con replay · Leaf + + + + + + src/sse + SseHub con replay + + + src/tht · ThtRunner: shell del CLI · Leaf + + + + + + src/tht + ThtRunner: shell del CLI + + + src/auth · local, OIDC, upstream · Leaf + + + + + + src/auth + local, OIDC, upstream + + + src/catalog · Metadata Catalog, sync, descrizioni · Leaf + + + + + + src/catalog + Metadata Catalog,sync, descrizioni + + + src/workspaces · registry Git e preprocessing · Leaf + + + + + + src/workspaces + registry Git epreprocessing + + + harness/ · workflow NL→SQL · Branch + + + + + + harness/ + workflow NL→SQL + + + workflow.yaml · fasi F1–F8 · Leaf + + + + + + workflow.yaml + fasi F1–F8 + + + .pi/ · estensione gate, skill, prompt · Leaf + + + + + + .pi/ + estensione gate,skill, prompt + + + tht/cli · sottocomandi del CLI tht · Leaf + + + + + + tht/cli + sottocomandi del CLI tht + + + tht/session + phase · manifest, ledger, fase · Leaf + + + + + + tht/session + phase + manifest, ledger, fase + + + tht/adapters · DWH e Qdrant · Leaf + + + + + + tht/adapters + DWH e Qdrant + + + tht/search + vectorstore · retrieval ibrido · Leaf + + + + + + tht/search +vectorstore + retrieval ibrido + + + tht/memory · card e domande risolte · Leaf + + + + + + tht/memory + card e domande risolte + + + tht/evidence · corpus Evidence · Leaf + + + + + + tht/evidence + corpus Evidence + + + tht/mschema · snapshot e schema per il modello · Leaf + + + + + + tht/mschema + snapshot e schemaper il modello + + + tools/tht · CLI host in Go · Branch + + + + + + tools/tht + CLI host in Go + + + cmd/tht · comandi operatore · Leaf + + + + + + cmd/tht + comandi operatore + + + internal/ · compose, setup, doctor, auth · Leaf + + + + + + internal/ + compose, setup,doctor, auth + + + docker/ + deploy/ · immagini e profili Compose · Leaf + + + + + + docker/ + deploy/ + immagini e profili Compose + + + docs/ · MkDocs, ADR, contratti · Leaf + + + + + + docs/ + MkDocs, ADR, contratti + + + + + + + + + + + 29 + + + + + + + + + + 5 + + + + + + + + + + 7 + + + + + + + + + + 9 + + + + + + + + + + 2 + + + + + + + Expand all + + +

+ + + + + + + + + +
+ + + +
+ + + + diff --git a/docs/architecture/thothii-modules.tree.json b/docs/architecture/thothii-modules.tree.json new file mode 100644 index 00000000..abbc76b3 --- /dev/null +++ b/docs/architecture/thothii-modules.tree.json @@ -0,0 +1,384 @@ +{ + "schema_version": 1, + "diagram_type": "tree", + "meta": { + "title": "ThothII — struttura dei moduli", + "locale": "it", + "output": "docs/architecture/thothii-modules.html", + "quality_profile": "showcase", + "repository": { + "url": "https://git.tylconsulting.it/mptyl/ThothII.git", + "link_mode": "local-only", + "revision": "31e6d3a162e9e5ac71fc2d8da4fe44b16c06aae3" + } + }, + "layout": { + "direction": "right" + }, + "nodes": [ + { + "id": "root", + "label": "ThothII", + "sublabel": "monorepo, tre layer + operatore", + "sources": [ + { + "path": "AGENTS.md", + "line": 1 + } + ] + }, + { + "id": "frontend", + "label": "frontend/", + "parent": "root", + "sublabel": "React 18 + Vite", + "sources": [ + { + "path": "frontend/src/main.tsx", + "line": 1 + } + ] + }, + { + "id": "fe_api", + "label": "src/api", + "parent": "frontend", + "sublabel": "client HTTP verso /api", + "sources": [ + { + "path": "frontend/src/api/client.ts", + "line": 1 + } + ] + }, + { + "id": "fe_shell", + "label": "src/shell", + "parent": "frontend", + "sublabel": "AppShell e pagine admin", + "sources": [ + { + "path": "frontend/src/shell/AppShell.tsx", + "line": 1 + } + ] + }, + { + "id": "fe_store", + "label": "src/store + stream", + "parent": "frontend", + "sublabel": "transcript live da SSE", + "sources": [ + { + "path": "frontend/src/store/sessionStore.ts", + "line": 1 + } + ] + }, + { + "id": "fe_widgets", + "label": "src/widgets", + "parent": "frontend", + "sublabel": "widget dei gate reviewer", + "sources": [ + { + "path": "frontend/src/widgets/registry.ts", + "line": 1 + } + ] + }, + { + "id": "fe_i18n", + "label": "src/i18n", + "parent": "frontend", + "sublabel": "cataloghi EN/IT" + }, + { + "id": "backend", + "label": "backend/", + "parent": "root", + "sublabel": "Fastify + TypeScript", + "sources": [ + { + "path": "backend/src/server.ts", + "line": 1 + } + ] + }, + { + "id": "be_routes", + "label": "src/routes", + "parent": "backend", + "sublabel": "API REST e SSE", + "sources": [ + { + "path": "backend/src/routes/sessions.ts", + "line": 1 + } + ] + }, + { + "id": "be_bridge", + "label": "src/pi + rpc + bridge", + "parent": "backend", + "sublabel": "processi Pi e bridge RPC", + "sources": [ + { + "path": "backend/src/pi/pi-process-manager.ts", + "line": 1 + } + ] + }, + { + "id": "be_sse", + "label": "src/sse", + "parent": "backend", + "sublabel": "SseHub con replay", + "sources": [ + { + "path": "backend/src/sse/sse-hub.ts", + "line": 1 + } + ] + }, + { + "id": "be_tht", + "label": "src/tht", + "parent": "backend", + "sublabel": "ThtRunner: shell del CLI", + "sources": [ + { + "path": "backend/src/tht/tht-runner.ts", + "line": 1 + } + ] + }, + { + "id": "be_auth", + "label": "src/auth", + "parent": "backend", + "sublabel": "local, OIDC, upstream", + "sources": [ + { + "path": "backend/src/auth/auth.ts", + "line": 1 + } + ] + }, + { + "id": "be_catalog", + "label": "src/catalog", + "parent": "backend", + "sublabel": "Metadata Catalog, sync, descrizioni", + "sources": [ + { + "path": "backend/src/catalog/service.ts", + "line": 1 + } + ] + }, + { + "id": "be_ws", + "label": "src/workspaces", + "parent": "backend", + "sublabel": "registry Git e preprocessing", + "sources": [ + { + "path": "backend/src/workspaces/preprocessing-service.ts", + "line": 1 + } + ] + }, + { + "id": "harness", + "label": "harness/", + "parent": "root", + "sublabel": "workflow NL→SQL", + "sources": [ + { + "path": "harness/README.md", + "line": 1 + } + ] + }, + { + "id": "h_wf", + "label": "workflow.yaml", + "parent": "harness", + "sublabel": "fasi F1–F8", + "sources": [ + { + "path": "harness/workflow.yaml", + "line": 1 + } + ] + }, + { + "id": "h_pi", + "label": ".pi/", + "parent": "harness", + "sublabel": "estensione gate, skill, prompt", + "sources": [ + { + "path": "harness/.pi/extensions/tht-gate.js", + "line": 1 + } + ] + }, + { + "id": "h_cli", + "label": "tht/cli", + "parent": "harness", + "sublabel": "sottocomandi del CLI tht", + "sources": [ + { + "path": "harness/tht/cli/__init__.py", + "line": 1 + } + ] + }, + { + "id": "h_session", + "label": "tht/session + phase", + "parent": "harness", + "sublabel": "manifest, ledger, fase", + "sources": [ + { + "path": "harness/tht/session/store.py", + "line": 1 + } + ] + }, + { + "id": "h_adapters", + "label": "tht/adapters", + "parent": "harness", + "sublabel": "DWH e Qdrant", + "sources": [ + { + "path": "harness/tht/adapters/factory.py", + "line": 1 + } + ] + }, + { + "id": "h_search", + "label": "tht/search + vectorstore", + "parent": "harness", + "sublabel": "retrieval ibrido", + "sources": [ + { + "path": "harness/tht/vectorstore/embeddings.py", + "line": 1 + } + ] + }, + { + "id": "h_memory", + "label": "tht/memory", + "parent": "harness", + "sublabel": "card e domande risolte", + "sources": [ + { + "path": "harness/tht/memory/repository.py", + "line": 1 + } + ] + }, + { + "id": "h_evidence", + "label": "tht/evidence", + "parent": "harness", + "sublabel": "corpus Evidence", + "sources": [ + { + "path": "harness/tht/evidence/preprocessing.py", + "line": 1 + } + ] + }, + { + "id": "h_mschema", + "label": "tht/mschema", + "parent": "harness", + "sublabel": "snapshot e schema per il modello", + "sources": [ + { + "path": "harness/tht/mschema/catalog_snapshot.py", + "line": 1 + } + ] + }, + { + "id": "tools", + "label": "tools/tht", + "parent": "root", + "sublabel": "CLI host in Go", + "sources": [ + { + "path": "tools/tht/README.md", + "line": 1 + } + ] + }, + { + "id": "t_cmd", + "label": "cmd/tht", + "parent": "tools", + "sublabel": "comandi operatore", + "sources": [ + { + "path": "tools/tht/cmd/tht/main.go", + "line": 1 + } + ] + }, + { + "id": "t_internal", + "label": "internal/", + "parent": "tools", + "sublabel": "compose, setup, doctor, auth", + "sources": [ + { + "path": "tools/tht/internal/compose/runner.go", + "line": 1 + } + ] + }, + { + "id": "deploy", + "label": "docker/ + deploy/", + "parent": "root", + "sublabel": "immagini e profili Compose", + "sources": [ + { + "path": "compose.yaml", + "line": 1 + } + ] + }, + { + "id": "docs", + "label": "docs/", + "parent": "root", + "sublabel": "MkDocs, ADR, contratti", + "sources": [ + { + "path": "mkdocs.yml", + "line": 1 + } + ] + } + ], + "cards": [ + { + "dot": "cyan", + "title": "Lettura", + "items": [ + "Le linee indicano contenimento, non chiamate", + "Alcuni nodi raggruppano più cartelle sorelle con lo stesso ruolo", + "Test, script e cartelle generate sono omessi" + ] + } + ] +} diff --git a/docs/architecture/thothii-new-question.html b/docs/architecture/thothii-new-question.html new file mode 100644 index 00000000..b78e0cb7 --- /dev/null +++ b/docs/architecture/thothii-new-question.html @@ -0,0 +1,14877 @@ + + + + + + + + ThothII — avvio di una nuova domanda Diagram + + + + + + + + +
+ +
+
+
+

ThothII — avvio di una nuova domanda

+
+
+ + + + +
+ + ThothII — avvio di una nuova domanda + A sequence diagram generated by Archify. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + domanda + + + + + + + + POST /sessions + + + + + + + + session new + + scrive il manifest efissa la lingua + + + + + + + id sessione + + + + + + + + spawn processo + + un processo Pi persessione + + + + + + + { id } + + + + + + + + GET /events (SSE) + + + l'hub conserva glieventi già emessi perla riconnessione + + + + + + + set_model + thinking + + + + + + + + search pack + + in parallelo almodello + + + + + + + prompt /nuova-domanda + + + + + + + + hook input + + + + + + + + turno modello + + + + + + + + token + tool call + + + + + + + + tool call + + + + + + + + tht phase / session + + scrive artefatti eledger + + + + + + + eventi RPC + + + + + + + + SSE text_delta + + + + + + + + transcript live + + + + + + + Creazione sessione + + + + Bootstrap + + + + Primo turno (F1) + + + + + Reviewer · browser · Sequence participant + + + + Reviewer + browser + + + + Frontend · React · Sequence participant + + + + Frontend + React + + + + Backend · Fastify · Sequence participant + + + + Backend + Fastify + + + + tht CLI · harness · Sequence participant + + + + tht CLI + harness + + + + Pi · --mode rpc · Sequence participant + + + + Pi + --mode rpc + + + + tht-gate.js · estensione Pi · Sequence participant + + + + tht-gate.js + estensione Pi + + + + Provider LLM · modello di sessione · Sequence participant + + + + Provider LLM + modello di sessione + + + + + Legend + + + main request + + + + return + + + + async trace + + + + message + + + +

+ + + + + + + + + +
+ + + +
+ + + + diff --git a/docs/architecture/thothii-new-question.sequence.json b/docs/architecture/thothii-new-question.sequence.json new file mode 100644 index 00000000..d9c0f163 --- /dev/null +++ b/docs/architecture/thothii-new-question.sequence.json @@ -0,0 +1,381 @@ +{ + "schema_version": 1, + "diagram_type": "sequence", + "meta": { + "title": "ThothII — avvio di una nuova domanda", + "locale": "it", + "output": "docs/architecture/thothii-new-question.html", + "quality_profile": "showcase", + "repository": { + "url": "https://git.tylconsulting.it/mptyl/ThothII.git", + "link_mode": "local-only", + "revision": "31e6d3a162e9e5ac71fc2d8da4fe44b16c06aae3" + } + }, + "participants": [ + { + "id": "reviewer", + "type": "external", + "label": "Reviewer", + "sublabel": "browser" + }, + { + "id": "frontend", + "type": "frontend", + "label": "Frontend", + "sublabel": "React", + "sources": [ + { + "path": "frontend/src/api/sessions.ts", + "line": 96, + "end_line": 115, + "label": "createSession" + }, + { + "path": "frontend/src/stream/useSessionStream.ts", + "line": 117, + "end_line": 121, + "label": "EventSource" + } + ] + }, + { + "id": "backend", + "type": "backend", + "label": "Backend", + "sublabel": "Fastify", + "sources": [ + { + "path": "backend/src/routes/sessions.ts", + "line": 481, + "end_line": 487, + "label": "precheck DWH" + }, + { + "path": "backend/src/routes/sessions.ts", + "line": 513, + "end_line": 570, + "label": "POST /sessions" + }, + { + "path": "backend/src/routes/sessions.ts", + "line": 334, + "end_line": 350, + "label": "bootstrap" + } + ] + }, + { + "id": "tht", + "type": "backend", + "label": "tht CLI", + "sublabel": "harness", + "sources": [ + { + "path": "backend/src/tht/tht-runner.ts", + "line": 484, + "end_line": 500, + "label": "session new" + }, + { + "path": "backend/src/tht/tht-runner.ts", + "line": 514, + "end_line": 518, + "label": "search pack" + }, + { + "path": "harness/.pi/extensions/tht-gate.js", + "line": 277, + "end_line": 280, + "label": "execFileSync" + } + ] + }, + { + "id": "pi", + "type": "backend", + "label": "Pi", + "sublabel": "--mode rpc", + "sources": [ + { + "path": "backend/src/pi/pi-process-manager.ts", + "line": 143, + "end_line": 146, + "label": "spawn" + }, + { + "path": "backend/src/pi/pi-process-manager.ts", + "line": 263, + "end_line": 280, + "label": "configure" + }, + { + "path": "backend/src/pi/pi-process-manager.ts", + "line": 283, + "end_line": 290, + "label": "prompt iniziale" + } + ] + }, + { + "id": "gate", + "type": "backend", + "label": "tht-gate.js", + "sublabel": "estensione Pi", + "sources": [ + { + "path": "harness/.pi/extensions/tht-gate.js", + "line": 780, + "end_line": 795, + "label": "hook input" + }, + { + "path": "harness/.pi/prompts/nuova-domanda.md", + "line": 1, + "end_line": 10, + "label": "template prompt" + } + ] + }, + { + "id": "llm", + "type": "cloud", + "label": "Provider LLM", + "sublabel": "modello di sessione" + } + ], + "segments": [ + { + "from": 160, + "to": 470, + "label": "Creazione sessione" + }, + { + "from": 476, + "to": 595, + "label": "Bootstrap" + }, + { + "from": 605, + "to": 875, + "label": "Primo turno (F1)" + } + ], + "messages": [ + { + "id": "ask", + "from": "reviewer", + "to": "frontend", + "y": 170, + "label": "domanda" + }, + { + "id": "post", + "from": "frontend", + "to": "backend", + "y": 200, + "label": "POST /sessions", + "variant": "emphasis" + }, + { + "id": "new", + "from": "backend", + "to": "tht", + "y": 230, + "label": "session new", + "note": "scrive il manifest e fissa la lingua" + }, + { + "id": "new-ok", + "from": "tht", + "to": "backend", + "y": 315, + "label": "id sessione", + "variant": "return" + }, + { + "id": "spawn", + "from": "backend", + "to": "pi", + "y": 345, + "label": "spawn processo", + "note": "un processo Pi per sessione" + }, + { + "id": "id", + "from": "backend", + "to": "frontend", + "y": 395, + "label": "{ id }", + "variant": "return" + }, + { + "id": "sse", + "from": "frontend", + "to": "backend", + "y": 425, + "label": "GET /events (SSE)", + "note": "l'hub conserva gli eventi già emessi per la riconnessione" + }, + { + "id": "model", + "from": "backend", + "to": "pi", + "y": 485, + "label": "set_model + thinking" + }, + { + "id": "pack", + "from": "backend", + "to": "tht", + "y": 515, + "label": "search pack", + "note": "in parallelo al modello" + }, + { + "id": "prompt", + "from": "backend", + "to": "pi", + "y": 585, + "label": "prompt /nuova-domanda", + "variant": "emphasis" + }, + { + "id": "hook", + "from": "pi", + "to": "gate", + "y": 615, + "label": "hook input" + }, + { + "id": "turn", + "from": "pi", + "to": "llm", + "y": 645, + "label": "turno modello", + "variant": "emphasis" + }, + { + "id": "tokens", + "from": "llm", + "to": "pi", + "y": 675, + "label": "token + tool call", + "variant": "return" + }, + { + "id": "tool", + "from": "pi", + "to": "gate", + "y": 705, + "label": "tool call" + }, + { + "id": "cli", + "from": "gate", + "to": "tht", + "y": 735, + "label": "tht phase / session", + "note": "scrive artefatti e ledger" + }, + { + "id": "event", + "from": "pi", + "to": "backend", + "y": 805, + "label": "eventi RPC", + "variant": "dashed" + }, + { + "id": "push", + "from": "backend", + "to": "frontend", + "y": 835, + "label": "SSE text_delta", + "variant": "dashed" + }, + { + "id": "render", + "from": "frontend", + "to": "reviewer", + "y": 865, + "label": "transcript live", + "variant": "return" + } + ], + "activations": [ + { + "participant": "frontend", + "from": 195, + "to": 871, + "type": "frontend" + }, + { + "participant": "backend", + "from": 200, + "to": 841, + "type": "backend" + }, + { + "participant": "tht", + "from": 228, + "to": 321, + "type": "backend" + }, + { + "participant": "tht", + "from": 513, + "to": 545, + "type": "backend" + }, + { + "participant": "tht", + "from": 733, + "to": 775, + "type": "backend" + }, + { + "participant": "pi", + "from": 343, + "to": 811, + "type": "backend" + }, + { + "participant": "gate", + "from": 613, + "to": 779, + "type": "backend" + }, + { + "participant": "llm", + "from": 643, + "to": 681, + "type": "cloud" + } + ], + "cards": [ + { + "dot": "cyan", + "title": "Ordine di avvio", + "items": [ + "La sessione esiste su disco prima che Pi parta: il manifest è la fonte di verità", + "Il primo prompt parte solo dopo configurazione del modello e search pack" + ] + }, + { + "dot": "amber", + "title": "Precheck DWH", + "items": [ + "In installazione locale il backend verifica il DWH prima di creare la sessione e risponde 503 se non è raggiungibile" + ] + }, + { + "dot": "emerald", + "title": "Stream", + "items": [ + "Il bridge traduce gli eventi Pi in text_delta, info e ui_request", + "Il transcript vive solo nel browser; non viene salvato" + ] + } + ] +} \ No newline at end of file diff --git a/docs/architecture/thothii-phases.html b/docs/architecture/thothii-phases.html new file mode 100644 index 00000000..b7f265af --- /dev/null +++ b/docs/architecture/thothii-phases.html @@ -0,0 +1,14825 @@ + + + + + + + + ThothII — workflow NL→SQL in 8 fasi Diagram + + + + + + + + +
+ +
+
+
+

ThothII — workflow NL→SQL in 8 fasi

+
+
+ + + + +
+ + ThothII — workflow NL→SQL in 8 fasi + A workflow diagram generated by Archify. + + + + + + + + + + + + + + + + + + + + + + + + + + 01 / Domanda + + + 02 / Schema e sintesi + + + 03 / SQL + + + 04 / Chiusura + + + + EX / Ritorno indietro + + + + + + + + + + + + + + + + + + + + + + F1 chiarimento · concetti e ambiguità · Domanda · gate fase + + + + F1 chiarimento + concetti e ambiguità + gate fase + + + + F2 memoria · memorie e esempi risolti · Domanda · auto se vuota + + + + F2 memoria + memorie e esempi risolti + auto se vuota + + + + F3 riscrittura · question.md · Domanda · si chiude da sola + + + + F3 riscrittura + question.md + si chiude da sola + + + + F4 schema linking · schema_linking.json · Schema e sintesi · reviewer_decide + + + + F4 schema linking + schema_linking.json + reviewer_decide + + + + F5 sintesi · valida SchemaLinking · Schema e sintesi · gate fase + + + + F5 sintesi + valida SchemaLinking + gate fase + + + + F6 CTE · piano, CTE e test · SQL · ultima CTE chiude + + + + F6 CTE + piano, CTE e test + ultima CTE chiude + + + + F7 SQL finale · sql_final.sql · SQL · kind sql chiude + + + + F7 SQL finale + sql_final.sql + kind sql chiude + + + + F8 datamart · promozione memorie · Chiusura · si chiude da sola + + + + F8 datamart + promozione memorie + si chiude da sola + + + + Sessione finalizzata · tht session finalize · Chiusura + + + + Sessione finalizzata + tht session finalize + + + + Riapertura fase · /torna → phase reopen · Ritorno indietro · phase_reopened + + + + Riapertura fase + /torna → phase reopen + phase_reopened + + + + + + + + + + + + + finalize + + + + fase N < corrente + + + + /torna + + + + + Legend + + + User UI + + + + Agent logic + + + + Policy + + + + Context / trace + + + + External system + + + +

+ + + + + + + + + +
+ + + +
+ + + + diff --git a/docs/architecture/thothii-phases.workflow.json b/docs/architecture/thothii-phases.workflow.json new file mode 100644 index 00000000..2bca9b5e --- /dev/null +++ b/docs/architecture/thothii-phases.workflow.json @@ -0,0 +1,104 @@ +{ + "schema_version": 2, + "diagram_type": "workflow", + "meta": { + "title": "ThothII — workflow NL→SQL in 8 fasi", + "locale": "it", + "output": "docs/architecture/thothii-phases.html", + "quality_profile": "showcase", + "repository": { + "url": "https://git.tylconsulting.it/mptyl/ThothII.git", + "link_mode": "local-only", + "revision": "31e6d3a162e9e5ac71fc2d8da4fe44b16c06aae3" + } + }, + "lanes": [ + { "id": "domanda", "label": "Domanda" }, + { "id": "schema", "label": "Schema e sintesi" }, + { "id": "sql", "label": "SQL" }, + { "id": "chiusura", "label": "Chiusura" }, + { "id": "eccezioni", "label": "Ritorno indietro", "variant": "exception" } + ], + "mainPath": ["f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "finalizzata"], + "nodes": [ + { "id": "f1", "lane": "domanda", "col": 0, "type": "frontend", "label": "F1 chiarimento", "sublabel": "concetti e ambiguità", "tag": "gate fase", + "sources": [ + { "path": "harness/workflow.yaml", "line": 13, "end_line": 18 }, + { "path": "harness/.pi/skills/tht-sessione/SKILL.md", "line": 57, "end_line": 57 } + ] }, + { "id": "f2", "lane": "domanda", "col": 1, "type": "database", "label": "F2 memoria", "sublabel": "memorie e esempi risolti", "tag": "auto se vuota", + "sources": [ + { "path": "harness/workflow.yaml", "line": 19, "end_line": 24 }, + { "path": "harness/.pi/skills/tht-sessione/SKILL.md", "line": 58, "end_line": 58 } + ] }, + { "id": "f3", "lane": "domanda", "col": 2, "type": "frontend", "label": "F3 riscrittura", "sublabel": "question.md", "tag": "si chiude da sola", + "sources": [ + { "path": "harness/workflow.yaml", "line": 25, "end_line": 31 }, + { "path": "harness/.pi/skills/tht-sessione/SKILL.md", "line": 59, "end_line": 59 } + ] }, + { "id": "f4", "lane": "schema", "col": 2, "type": "frontend", "label": "F4 schema linking", "sublabel": "schema_linking.json", "tag": "reviewer_decide", + "sources": [ + { "path": "harness/workflow.yaml", "line": 32, "end_line": 39 }, + { "path": "harness/.pi/skills/tht-sessione/SKILL.md", "line": 60, "end_line": 60 } + ] }, + { "id": "f5", "lane": "schema", "col": 3, "type": "frontend", "label": "F5 sintesi", "sublabel": "valida SchemaLinking", "tag": "gate fase", + "sources": [ + { "path": "harness/workflow.yaml", "line": 40, "end_line": 46 }, + { "path": "harness/.pi/skills/tht-sessione/SKILL.md", "line": 61, "end_line": 61 } + ] }, + { "id": "f6", "lane": "sql", "col": 3, "type": "backend", "label": "F6 CTE", "sublabel": "piano, CTE e test", "tag": "ultima CTE chiude", + "sources": [ + { "path": "harness/workflow.yaml", "line": 47, "end_line": 55 }, + { "path": "harness/.pi/skills/tht-sessione/SKILL.md", "line": 62, "end_line": 62 } + ] }, + { "id": "f7", "lane": "sql", "col": 4, "type": "backend", "label": "F7 SQL finale", "sublabel": "sql_final.sql", "tag": "kind sql chiude", + "sources": [ + { "path": "harness/workflow.yaml", "line": 56, "end_line": 62 }, + { "path": "harness/.pi/skills/tht-sessione/SKILL.md", "line": 63, "end_line": 63 } + ] }, + { "id": "f8", "lane": "chiusura", "col": 4, "type": "database", "label": "F8 datamart", "sublabel": "promozione memorie", "tag": "si chiude da sola", + "sources": [ + { "path": "harness/workflow.yaml", "line": 63, "end_line": 72 }, + { "path": "harness/.pi/skills/tht-sessione/SKILL.md", "line": 64, "end_line": 64 } + ] }, + { "id": "finalizzata", "lane": "chiusura", "col": 5, "type": "external", "label": "Sessione finalizzata", "sublabel": "tht session finalize", + "sources": [ + { "path": "harness/.pi/extensions/tht-gate.js", "line": 1650, "end_line": 1666, "label": "advancePhaseAndFinalize" } + ] }, + { "id": "riapertura", "lane": "eccezioni", "col": 1, "type": "security", "label": "Riapertura fase", "sublabel": "/torna → phase reopen", "tag": "phase_reopened", + "sources": [ + { "path": "harness/.pi/extensions/tht-gate.js", "line": 1775, "end_line": 1814, "label": "comando /torna" }, + { "path": "harness/tht/phase.py", "line": 60, "end_line": 79, "label": "fold con reopen" } + ] } + ], + "edges": [ + { "id": "f1-f2", "from": "f1", "to": "f2", "variant": "emphasis" }, + { "id": "f2-f3", "from": "f2", "to": "f3", "variant": "emphasis" }, + { "id": "f3-f4", "from": "f3", "to": "f4", "variant": "emphasis" }, + { "id": "f4-f5", "from": "f4", "to": "f5", "variant": "emphasis" }, + { "id": "f5-f6", "from": "f5", "to": "f6", "variant": "emphasis" }, + { "id": "f6-f7", "from": "f6", "to": "f7", "variant": "emphasis" }, + { "id": "f7-f8", "from": "f7", "to": "f8", "variant": "emphasis" }, + { "id": "f8-fin", "from": "f8", "to": "finalizzata", "label": "finalize", "variant": "emphasis" }, + { "id": "torna", "from": "f7", "to": "riapertura", "label": "/torna", "variant": "dashed", "role": "error" }, + { "id": "riapre", "from": "riapertura", "to": "f1", "label": "fase N < corrente", "variant": "dashed", "role": "return" } + ], + "cards": [ + { "dot": "cyan", "title": "Chi decide", "items": [ + "Il modello propone, il reviewer decide tramite widget, tht persiste", + "Gate fase (F1, F2 con memorie, F5): il reviewer conferma che la fase è completa", + "F3, F4, ultima CTE di F6, F7 e F8: l'approvazione sostanziale chiude la fase da sola" + ] }, + { "dot": "emerald", "title": "Fase corrente", "items": [ + "Non è salvata: si calcola ripercorrendo il ledger review_decisions.jsonl", + "phase_approved avanza solo la fase corrente; phase_reopened riporta indietro" + ] }, + { "dot": "amber", "title": "Salti automatici", "items": [ + "F2 avanza da sola se non ci sono memorie pertinenti", + "F6 può essere saltata (phase_skipped) o essere vuota" + ] }, + { "dot": "rose", "title": "Ritorno indietro", "items": [ + "/torna è disponibile da qualunque fase verso una fase precedente; qui è mostrato da F7 come esempio" + ] } + ] +} diff --git a/docs/architecture/thothii-core-sequence.html b/docs/architecture/thothii-resume.html similarity index 63% rename from docs/architecture/thothii-core-sequence.html rename to docs/architecture/thothii-resume.html index afc320cc..11e31c7d 100644 --- a/docs/architecture/thothii-core-sequence.html +++ b/docs/architecture/thothii-resume.html @@ -3,8 +3,9 @@ - - Sequenza runtime del core ThothII Diagram + + + ThothII — ripresa di una sessione 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. --> - - - - - + +
- - Sequenza runtime del core ThothII + + ThothII — ripresa di una sessione A sequence diagram generated by Archify. @@ -5030,277 +5185,272 @@ - + - + - + - - - - - - - - + + + + + + - - - - - - - - - - - - - - + - - + + - - domanda o decisione gate + + riprendi sessione - - + + - - POST /sessions o /response + + POST /sessions/:id/resume - - + + - - sessionNew o sessionShow/reopen + + session show + + 409 se finalizzata oarchiviata + + + + + + + manifest - - + + - - manifest, artifact e ledger + + session reopen - - + + - - createFor + bind; configure + searchPack + + spawn - configure(...) e searchPack(...) terminano in parallelo prima dell’avvio del modello. + sostituisce il runtimefermo - - + + - - /nuova-domanda o /riprendi-sessione - - In ripresa usa /riprendi-sessione <id> dopo aver riletto provider, modello e thinking dal manifest. - - - - - - - turno modello; token e tool call + + 200 { id } - - + + - - comandi phase / session / evidence + + set_model + thinking + + niente search pack: ilcontesto è su disco + + + + + + + prompt /riprendi-sessione - - + + - - legge/scrive artifact e ledger - - Il workspace persistito è la verità; DWH è read-only e Qdrant serve il retrieval. - - - - - - - text_delta / ui_request + + turno modello - - + + - - SSE via SseHub: text · info · widget + + tool call - - + + - - testo o widget di revisione + + tht session show + + fase corrente, stato elingua + + + + + + + tht session documents + + artefatti già prodotti + + + + + + + artefatti + ledger + + + + + + + + gate della fase N + + + + + + + + SSE ui_request + + + + + + + + riprende dalla fase N - - Avvio o ripresa + + Richiesta - - Turno Pi e workflow persistito + + Bootstrap - - Evento SSE e gate umano + + Ricostruzione - - Revisore · browser · Sequence participant - - + + Reviewer · browser · Sequence participant + + - Revisore - browser + Reviewer + browser - - Frontend · React + SSE · Sequence participant - - -

-