From 08c05eb8941d76a409a44b4095db90bd88589ce9 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Tue, 14 Apr 2026 13:30:18 -0300 Subject: [PATCH] chore: update submodules --- PROD.md | 5 +++- botui | 2 +- prompts/v6.2.md | 44 ----------------------------- snapshot_chat_ready.yml | 31 +++++++++++++++++++++ snapshot_initial.yml | 30 ++++++++++++++++++++ snapshot_response.yml | 61 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 127 insertions(+), 46 deletions(-) delete mode 100644 prompts/v6.2.md create mode 100644 snapshot_chat_ready.yml create mode 100644 snapshot_initial.yml create mode 100644 snapshot_response.yml diff --git a/PROD.md b/PROD.md index 75a35a9..abc1151 100644 --- a/PROD.md +++ b/PROD.md @@ -100,6 +100,9 @@ HashiCorp Vault is the single source of truth for all secrets. Botserver reads ` **Vault troubleshooting — cannot connect:** Check that the vault container's systemd unit is running, verify the token in `.env` is not expired with `vault token lookup`, confirm the CA cert path in `.env` matches the actual file location, and test network connectivity from system to vault container. To generate a new token: `vault token create -policy="botserver" -ttl="8760h" -format=json` then update `.env` and restart botserver. +# Get database credentials from Vault v2 API +$ ssh user@ip"sudo incus exec system -- curl -s --cacert /opt/gbo/conf/system/certificates/ca/ca.crt -H 'X-Vault-Token: hvs...' https://ip:8200/v1/secret/data/gbo/tables 2>/dev/null" + **Vault troubleshooting — secrets missing:** Run `vault kv get secret/gbo/tables` (and other paths) to check if secrets exist. If a path returns NOT FOUND, add secrets with `vault kv put secret/gbo/tables host= port=5432 database=botserver username=gbuser password=` and similar for other paths. **Vault sealed after restart:** Run `vault operator unseal `, repeat with key2 and key3 (3 of 5 keys from init.json), then verify with `vault status`. @@ -206,4 +209,4 @@ The `.ast` file has all transforms applied: `USE KB "cartas"` becomes `USE_KB("c **Tools (TOOL_EXEC) load `.ast` only** — there is no `.bas` fallback. If an `.ast` file is missing, the tool fails with "Failed to read tool .ast file". DriveMonitor must have compiled it first. -**Suggestion deduplication** uses Redis `SADD` (set) instead of `RPUSH` (list). This prevents duplicate suggestion buttons when `start.bas` runs multiple times per session. The key format is `suggestions:{bot_id}:{session_id}` and `get_suggestions` uses `SMEMBERS` to read it. \ No newline at end of file +**Suggestion deduplication** uses Redis `SADD` (set) instead of `RPUSH` (list). This prevents duplicate suggestion buttons when `start.bas` runs multiple times per session. The key format is `suggestions:{bot_id}:{session_id}` and `get_suggestions` uses `SMEMBERS` to read it. diff --git a/botui b/botui index 91e9701..90dc21e 160000 --- a/botui +++ b/botui @@ -1 +1 @@ -Subproject commit 91e9701c3ec47e8b5ecebddcc89ac108dd708197 +Subproject commit 90dc21ef3a4f0c8acaf990b83de8a2d323bc5719 diff --git a/prompts/v6.2.md b/prompts/v6.2.md deleted file mode 100644 index 3879fae..0000000 --- a/prompts/v6.2.md +++ /dev/null @@ -1,44 +0,0 @@ -# v6.2 — Make KB "cartas" work end-to-end - -## What we want - -User clicks "Cartas" → `cartas.bas` runs → `USE KB "cartas"` → searches Qdrant → bot answers with KB content. No restarts. - -## 3 Bugs we found - -### Bug 1: KB files re-indexed every 10s (wasteful) ✅ FIXED - -Every cycle, `check_gbkb_changes` replaces file_states with `indexed: false`, so DriveMonitor re-downloads and re-indexes all PDFs every 10 seconds. - -**Fix:** Preserve `indexed: true` when etag hasn't changed. -**File:** `botserver/src/drive/drive_monitor/mod.rs:1376` - -### Bug 2: USE KB looks for wrong collection name ✅ FIXED - -When `kb_collections` has no entry for "cartas", `USE KB` creates a collection name using a random UUID (`salesianos__cartas`). But Qdrant has `salesianos_6deedba8_cartas`. They never match → search returns nothing. - -**Fix:** Use `bot_id_short` (first 8 chars of bot UUID) consistently. Also changed `ON CONFLICT DO NOTHING` to `DO UPDATE` so stale entries get corrected. -**File:** `botserver/src/basic/keywords/use_kb.rs:221-244` - -### Bug 3: KB indexing never writes to kb_collections table ✅ FIXED - -`index_kb_folder` creates a Qdrant collection and indexes documents, but never writes a row to `kb_collections`. So when `USE KB "cartas"` runs, it queries `kb_collections` → empty → hits Bug 2's fallback path. - -**Fix:** After indexing, upsert into `kb_collections` with correct collection name. -**File:** `botserver/src/core/kb/mod.rs:167-220` - -Also changed `process_gbkb_folder` return type from `Result<()>` to `Result` so `handle_gbkb_change` can use `collection_name` and `documents_processed`. - -## Checklist - -- [x] Bug 1 code fix (file_states indexed flag) -- [x] Bug 2 code fix (USE KB collection name) -- [x] Bug 3 code fix (kb_collections upsert after indexing) -- [x] `cargo check -p botserver` passes -- [ ] Push botserver → origin + ALM -- [ ] Push main repo → origin + ALM -- [ ] Deploy to production (ask user first) -- [ ] Restart botserver (one-time for new binary) -- [ ] Test: click "Cartas" → verify KB search works -- [ ] Test: click "Procedimentos" → verify KB search works -- [ ] Verify PROMPT.md injection \ No newline at end of file diff --git a/snapshot_chat_ready.yml b/snapshot_chat_ready.yml new file mode 100644 index 0000000..7fbb349 --- /dev/null +++ b/snapshot_chat_ready.yml @@ -0,0 +1,31 @@ +- generic [ref=e5]: + - generic [ref=e6]: + - generic [ref=e7]: Chat + - generic [ref=e8]: + - button [ref=e9] [cursor=pointer]: + - img [ref=e10] + - button [ref=e11] [cursor=pointer]: + - img [ref=e12] + - button [ref=e14] [cursor=pointer]: + - img [ref=e15] + - generic [ref=e18]: + - generic [ref=e19]: + - main [ref=e20]: + - paragraph [ref=e23]: Olá! Bem-vinda(o) ao assistente virtual do Salesianos. + - generic [ref=e25]: oi + - contentinfo [ref=e29]: + - generic [ref=e30]: + - button "Cartas" [ref=e31] [cursor=pointer] + - button "Procedimentos" [ref=e32] [cursor=pointer] + - button "Tabelas" [ref=e33] [cursor=pointer] + - generic [ref=e34]: + - generic [ref=e35]: + - button "Agent" [ref=e36] [cursor=pointer] + - button "Chat" [ref=e37] [cursor=pointer] + - textbox "Message... (type @ to mention)" [active] [ref=e38] + - button "↑" [ref=e39] [cursor=pointer] + - button "Scroll to bottom": + - img + - generic: + - generic: + - button "View" \ No newline at end of file diff --git a/snapshot_initial.yml b/snapshot_initial.yml new file mode 100644 index 0000000..18b1aca --- /dev/null +++ b/snapshot_initial.yml @@ -0,0 +1,30 @@ +- generic [ref=e106]: + - generic [ref=e107]: + - generic [ref=e108]: Chat + - generic [ref=e109]: + - button [ref=e110] [cursor=pointer]: + - img [ref=e111] + - button [ref=e112] [cursor=pointer]: + - img [ref=e113] + - button [ref=e115] [cursor=pointer]: + - img [ref=e116] + - generic [ref=e119]: + - generic [ref=e120]: + - main [ref=e194]: + - paragraph [ref=e197]: Olá! Bem-vinda(o) ao assistente virtual do Salesianos. + - contentinfo [ref=e166]: + - generic [ref=e198]: + - button "Cartas" [ref=e199] [cursor=pointer] + - button "Procedimentos" [ref=e200] [cursor=pointer] + - button "Tabelas" [ref=e201] [cursor=pointer] + - generic [ref=e169]: + - generic [ref=e170]: + - button "Agent" [ref=e171] [cursor=pointer] + - button "Chat" [ref=e172] [cursor=pointer] + - textbox "Message... (type @ to mention)" [active] [ref=e173] + - button "↑" [ref=e174] [cursor=pointer] + - button "Scroll to bottom": + - img + - generic: + - generic: + - button "View" \ No newline at end of file diff --git a/snapshot_response.yml b/snapshot_response.yml new file mode 100644 index 0000000..a6b7ada --- /dev/null +++ b/snapshot_response.yml @@ -0,0 +1,61 @@ +- generic [ref=e106]: + - generic [ref=e107]: + - generic [ref=e108]: Chat + - generic [ref=e109]: + - button [ref=e110] [cursor=pointer]: + - img [ref=e111] + - button [ref=e112] [cursor=pointer]: + - img [ref=e113] + - button [ref=e115] [cursor=pointer]: + - img [ref=e116] + - generic [ref=e119]: + - generic [ref=e120]: + - main [ref=e194]: + - paragraph [ref=e197]: Olá! Bem-vinda(o) ao assistente virtual do Salesianos. + - generic [ref=e203]: oi + - generic [ref=e326]: + - generic [ref=e327]: + - heading "Olá! Seja bem-vindo(a)!" [level=1] [ref=e330] + - heading "Sou o assistente virtual da Escola Salesiana" [level=2] [ref=e331] + - paragraph [ref=e332]: + - text: É uma grande alegria recebê-lo aqui! Meu nome é o Assistente Virtual Salesiano, criado para ser ponte entre você e toda a riqueza da nossa instituição, fundamentada nos ideais de Dom Bosco e na + - strong [ref=e333]: Pedagogia Preventiva + - text: . + - paragraph [ref=e334]: Baseado nas cartas inspiradoras de Dom Bosco e no modo salesiano de educar, estou aqui para ajudá-lo com informações, orientações e todo o suporte que precisar sobre nossa escola. + - generic [ref=e335]: + - paragraph [ref=e336]: + - strong [ref=e337]: Como posso ser útil hoje? + - paragraph [ref=e338]: + - text: Posso orientá-lo sobre + - strong [ref=e339]: matrículas + - text: "," + - strong [ref=e340]: protocolos escolares + - text: "," + - strong [ref=e341]: eventos + - text: "," + - strong [ref=e342]: calendário acadêmico + - text: "," + - strong [ref=e343]: projetos pedagógicos + - text: e muito mais. Sinta-se à vontade para perguntar sobre qualquer aspecto da nossa comunidade educativa! + - generic [ref=e344]: + - generic [ref=e345]: + - img [ref=e346] + - heading "Calendário" [level=3] [ref=e348] + - paragraph [ref=e349]: Datas importantes, feriados, eventos e prazos do ano letivo. + - img [ref=e351] + - contentinfo [ref=e166]: + - generic [ref=e198]: + - button "Cartas" [ref=e199] [cursor=pointer] + - button "Procedimentos" [ref=e200] [cursor=pointer] + - button "Tabelas" [ref=e201] [cursor=pointer] + - generic [ref=e169]: + - generic [ref=e170]: + - button "Agent" [ref=e171] [cursor=pointer] + - button "Chat" [ref=e172] [cursor=pointer] + - textbox "Message... (type @ to mention)" [active] [ref=e173] + - button "↑" [ref=e174] [cursor=pointer] + - button "Scroll to bottom": + - img + - generic: + - generic: + - button "View" \ No newline at end of file