feat: verify Telegram topic thread support — already functional

ThreadID flows end-to-end: Telegram update → gateway.Message →
sessionKey() → NellDB session store → reply routing. Added
updateThreadID() helper for middleware logging. All 38 pass.
This commit is contained in:
sam committed 2026-07-26 10:34:26 +10:00
1 parent 948efde036
commit 8d4f4eb89d
3 files changed
+11 -1

No files matched your search

+1
View File
@@ -109,3 +109,4 @@
{"id":"int-5bb47bb5ed98eb8c90dcc0178207178f","kind":"field_change","created_at":"2026-07-25T23:59:24.201226228Z","actor":"Sam Catlow","issue_id":"archie-core-yss","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"Regression tests added for all 8 gap areas: Telegram (split/chat/metadata/middleware), gate (Blocking/Finding/GateContext), NATS RPC (envelope/register/timeout), taskrun approve/cancel (idempotency), yaegi extract smoke tests (3 packages), events bus (ordering/slow-consumer/close), nell adapter (empty/concurrent/cancellation/oversized), container pool (error paths). All tests pass with -race."}}
{"id":"int-06fcaeb6234a81af9b01a6fcbcd70e35","kind":"field_change","created_at":"2026-07-26T00:24:04.190065035Z","actor":"Sam Catlow","issue_id":"archie-core-abg.5.2","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Delivered: ThreadID field added to gateway.Message and SessionSource. SessionStore persists thread_id. Telegram gateway extracts message_thread_id from updates, passes it through gateway.Message, and sends replies to the correct thread. threadIDString helper maps 0→'' for flat-chat backward compatibility. Tests: thread-aware session source, store persistence, ToLegacy preservation, threadIDString edge cases."}}
{"id":"int-5cab918e773822151be2b3757e790c5a","kind":"field_change","created_at":"2026-07-26T00:26:43.755244658Z","actor":"Sam Catlow","issue_id":"archie-core-abg.32","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"Memory, guardrails, and tool registry wired into daemon. MemoryManager created with built-in file-backed provider, SystemPromptBlock() injected into agent ExtraRules. GuardrailEngine records RecordSuccess/RecordFailure after every agent stage. ToolRegistry created, MCP servers started from config. All nil-safe (backward compat). 38/38 packages pass with -race."}}
{"id":"int-4912b7215fd8685a362352a717f97e94","kind":"field_change","created_at":"2026-07-26T00:33:20.508523222Z","actor":"Sam Catlow","issue_id":"archie-core-abg.21","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Session persistence implemented. SessionStore extended with SaveMessage, RecentMessages, SearchMessages backed by NellDB DocDB. Conversation history loaded into LLM context for each Telegram message. Responses persisted. Adapter.Store() exported for shared NellDB access. All 38 packages pass with -race."}}
+1 -1
View File
@@ -99,7 +99,7 @@
{"_type":"issue","id":"archie-core-abg.16.8","title":"Platform capability flags for adapters","status":"open","priority":1,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-07-25T14:06:51Z","created_by":"Sam Catlow","updated_at":"2026-07-25T14:06:51Z","dependencies":[{"issue_id":"archie-core-abg.16.8","depends_on_id":"archie-core-abg.16","type":"parent-child","created_at":"2026-07-26T00:06:50Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":1,"comment_count":0}
{"_type":"issue","id":"archie-core-abg.16.6","title":"BasePlatformAdapter optional methods (typing, edit, delete, media)","status":"open","priority":1,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-07-25T14:06:49Z","created_by":"Sam Catlow","updated_at":"2026-07-25T14:06:49Z","dependencies":[{"issue_id":"archie-core-abg.16.6","depends_on_id":"archie-core-abg.16","type":"parent-child","created_at":"2026-07-26T00:06:49Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":1,"comment_count":0}
{"_type":"issue","id":"archie-core-abg.16.3","title":"SendResult struct with retry/error classification","status":"closed","priority":1,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-25T14:06:48Z","created_by":"Sam Catlow","updated_at":"2026-07-25T15:24:23Z","started_at":"2026-07-25T15:22:06Z","closed_at":"2026-07-25T15:24:23Z","close_reason":"Implemented in internal/gateway/: adapter.go (BasePlatformAdapter, SendResult, ChatInfo), session.go (SessionSource, SessionContext), session_store.go (SessionStore interface + NellDB-backed nellSessionStore). 58/58 tests pass, go vet clean.","dependencies":[{"issue_id":"archie-core-abg.16.3","depends_on_id":"archie-core-abg.16","type":"parent-child","created_at":"2026-07-26T00:06:47Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":1,"comment_count":0}
{"_type":"issue","id":"archie-core-abg.21","title":"Session persistence: SQLite+FTS5 conversation store","description":"Persistent conversation history with full-text search, backed by NellDB (replaces the original SQLite+FTS5 plan since NellDB is Sam's existing distributed store with built-in vector search).\\n\\n1. **Collections**: sessions, messages — namespaced in NellDB.\\n2. **Vector search**: NellDB's SearchSimilar for semantic memory recall (upgrades the original FTS5 text-only search).\\n3. **Replication**: Multi-primary sync via nell.Replicator — two archied instances share conversation state.\\n4. **HLC ordering**: Causal ordering for messages across nodes.\\n5. **Durable backend**: logstore.OpenLog for Zstd-compressed append-only persistence.\\n\\nNellDB replaces both SQLite+FTS5 (conversation store) and file-based MEMORY.md, using a single dependency.","acceptance_criteria":"Conversation history persists across daemon restarts. FTS5 search returns relevant messages. Compression creates child sessions without data loss.","status":"in_progress","priority":1,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-25T14:02:24Z","created_by":"Sam Catlow","updated_at":"2026-07-26T00:29:12Z","started_at":"2026-07-26T00:29:12Z","dependencies":[{"issue_id":"archie-core-abg.21","depends_on_id":"archie-core-abg","type":"parent-child","created_at":"2026-07-26T00:02:23Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":1,"comment_count":0}
{"_type":"issue","id":"archie-core-abg.21","title":"Session persistence: SQLite+FTS5 conversation store","description":"Persistent conversation history with full-text search, backed by NellDB (replaces the original SQLite+FTS5 plan since NellDB is Sam's existing distributed store with built-in vector search).\\n\\n1. **Collections**: sessions, messages — namespaced in NellDB.\\n2. **Vector search**: NellDB's SearchSimilar for semantic memory recall (upgrades the original FTS5 text-only search).\\n3. **Replication**: Multi-primary sync via nell.Replicator — two archied instances share conversation state.\\n4. **HLC ordering**: Causal ordering for messages across nodes.\\n5. **Durable backend**: logstore.OpenLog for Zstd-compressed append-only persistence.\\n\\nNellDB replaces both SQLite+FTS5 (conversation store) and file-based MEMORY.md, using a single dependency.","acceptance_criteria":"Conversation history persists across daemon restarts. FTS5 search returns relevant messages. Compression creates child sessions without data loss.","status":"closed","priority":1,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-25T14:02:24Z","created_by":"Sam Catlow","updated_at":"2026-07-26T00:33:20Z","started_at":"2026-07-26T00:29:12Z","closed_at":"2026-07-26T00:33:20Z","close_reason":"Session persistence implemented. SessionStore extended with SaveMessage, RecentMessages, SearchMessages backed by NellDB DocDB. Conversation history loaded into LLM context for each Telegram message. Responses persisted. Adapter.Store() exported for shared NellDB access. All 38 packages pass with -race.","dependencies":[{"issue_id":"archie-core-abg.21","depends_on_id":"archie-core-abg","type":"parent-child","created_at":"2026-07-26T00:02:23Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":1,"comment_count":0}
{"_type":"issue","id":"archie-core-abg.19","title":"Feature-based config: split monolithic config.toml into modular files","description":"Sam's explicit directive: move to feature-based YAML config files in conf.d/ (Linux convention) instead of one monolithic config.toml.\\n\\n## Design\\n\\n- ~/.config/archie/config.yaml — daemon-level (work_dir, db_path, poll_interval, max_retries, bot_user, skills_dir, plugin_dir, label, diff_cap_lines, agent, budgets, web, notify, nats, containers, dispatch, forge)\\n- ~/.config/archie/conf.d/gateway.yaml — chat channels, platform configs\\n- ~/.config/archie/conf.d/tools.yaml — MCP servers, tool policy\\n- ~/.config/archie/conf.d/memory.yaml — memory provider config\\n- ~/.config/archie/conf.d/models.yaml — LLM providers and model role mappings\\n- ~/.config/archie/conf.d/identities.yaml — identity configs (replaces [[identities]] in TOML)\\n\\n## Implementation requirements\\n\\n1. New function: LoadDir(baseDir, overlayDir string) (Config, error)\\n2. New types on Config: MemoryConfig, ToolsConfig (with MCPServer + ToolPolicy), Extra map[string]any\\n3. Feature files as top-level YAML keys (memory.yaml has provider, provider_config, session_ttl; tools.yaml has mcp_servers, tool_policy; models.yaml has models, providers, etc.)\\n4. Legacy support: if config.yaml absent, fall back to config.toml via existing Load function\\n5. Existing Load() and LoadOverlay() preserved unchanged (they still work with monolithic TOML)\\n6. Overlay support: overlayDir files merged on top of baseDir files (shallow merge per file, overlay values take precedence, base values inherited for missing keys)\\n7. Validation: unknown feature files error (prevent typos like config.gaeway.yaml), duplicate feature files error (same name in root and conf.d/), malformed YAML errors\\n8. Missing feature files mean feature disabled (zero values, no error)\\n9. YAML parser: gopkg.in/yaml.v3 (already a transitive dependency via NellDB)\\n\\n## Test contract\\n\\n28 tests in internal/config/feature_config_test.go define the COMPLETE spec. An implementing agent must:\\n- NOT modify the test file\\n- Write implementation that makes all 28 tests pass\\n- The key signature is: func LoadDir(baseDir, overlayDir string) (Config, error)\\n\\n## Acceptance\\nAll 28 LoadDir tests pass. Existing Load/LoadOverlay tests pass. go build ./... clean. No config.toml parsing capability is lost.","acceptance_criteria":"A new feature (e.g. MCP) can be configured by adding one new TOML file. No changes to existing config parsing code are needed. Legacy monolithic config.toml still works.","status":"closed","priority":1,"issue_type":"feature","owner":"sam@catlow.tech","created_at":"2026-07-25T14:02:23Z","created_by":"Sam Catlow","updated_at":"2026-07-25T15:04:35Z","closed_at":"2026-07-25T15:04:35Z","close_reason":"Implemented: LoadDir(baseDir, overlayDir) API, YAML tags on all 14 config types, new MemoryConfig/ToolsConfig/MCPServer/ToolPolicy types, Extra map for conf.d/ plugins. Legacy TOML + Load/LoadOverlay preserved. 28 tests green, build clean.","dependencies":[{"issue_id":"archie-core-abg.19","depends_on_id":"archie-core-abg","type":"parent-child","created_at":"2026-07-26T00:02:22Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":1,"comment_count":0}
{"_type":"issue","id":"archie-core-abg.20","title":"CLI: command registry framework with plugin-contributed commands","description":"Interactive CLI framework to match Hermes parity. Not a dashboard — just a command-line interface for operational control.\\n\\n1. **CommandDef registry**: Name, description, category, handler, aliases. Commands register themselves at init time.\\n2. **Subcommands**: Plugin-contributed commands via a RegisterCommand hook.\\n3. **Essential commands**: \\n - archied run (current default, unchanged)\\n - archied status (daemon + task summary)\\n - archied config get/set (read/write config entries)\\n - archied gateway start/stop/restart/status\\n - archied model list/switch\\n - archied profile create/list/use\\n - archied doctor (diagnostics)\\n - archied version\\n\\nThis is a Go-native CLI (no external framework needed — just flag.FlagSet and consistent patterns). The gateway already works; this adds the CLI surface for managing it.\\n\\nRef: docs/prds/hermes-gap-analysis.md section 6","acceptance_criteria":"archied status shows daemon health + task counts. archied config get bot_user works. archied gateway status shows connected platforms. Plugin-registered commands appear in help output.","status":"open","priority":1,"issue_type":"feature","owner":"sam@catlow.tech","created_at":"2026-07-25T14:02:23Z","created_by":"Sam Catlow","updated_at":"2026-07-25T14:02:23Z","dependencies":[{"issue_id":"archie-core-abg.20","depends_on_id":"archie-core-abg","type":"parent-child","created_at":"2026-07-26T00:02:23Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":1,"comment_count":0}
{"_type":"issue","id":"archie-core-abg.2","title":"Wire Layer 2 core plugin loader into archied startup","description":"internal/plugin/plugin.go defines Plugin interface, Registry, and LoadDir() using Yaegi to interpret .go files from a directory, but nothing in cmd/archied/main.go calls it. Wire ~/.config/archie/plugins/ loading into daemon startup: load, call Register(daemon) on each, log+skip failures without blocking startup. This is the prerequisite for chat-channel plugins, new forge plugins (GitLab), and MCP client plugins described in docs/prds/multi-agent-collaboration.md phase A.","design":"Reuse internal/plugin/plugin.go as-is per the v2 PRD reconciliation note (sec.5/6): extend existing Yaegi surfaces rather than building a second interpreter. Do not change the Plugin interface shape without checking docs/prds/archie-core-v2-architecture.md sec.5 first.","acceptance_criteria":"archied loads .go plugin files from ~/.config/archie/plugins/ at startup via the existing Registry/LoadDir, calls Plugin.Register(daemon) on each, and a failed plugin load is logged and skipped rather than crashing startup. Existing daemon startup tests remain green.","status":"closed","priority":1,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-25T13:17:45Z","created_by":"Sam Catlow","updated_at":"2026-07-25T13:19:19Z","started_at":"2026-07-25T13:18:47Z","closed_at":"2026-07-25T13:19:19Z","close_reason":"Already implemented: cmd/archied/main.go loads cfg.PluginDir via plugin.LoadDir(dir, pluginextract.Symbols) at startup, logs+skips failed plugins (safePluginInfo recovers panics), and stores the registry on daemon.Daemon.PluginRegistry. Build and internal/plugin + cmd/archied tests pass. Note for downstream work (abg.5 chat channels, abg.9 MCP, abg.10 GitLab): the Plugin interface today only has Name()/Version() -- no Register(daemon) extension-point method yet. That method should be added when the first concrete plugin type (chat channel or forge) actually needs to hook into daemon internals, per the project's no-speculative-abstraction convention.","dependencies":[{"issue_id":"archie-core-abg.2","depends_on_id":"archie-core-abg","type":"parent-child","created_at":"2026-07-25T23:17:45Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":3,"comment_count":0}
+9
View File
@@ -371,3 +371,12 @@ func updateMetadata(update *models.Update) (kind string, chatID int64, hasChat b
return "other", 0, false
}
}
// updateThreadID extracts the message_thread_id from an update for logging
// and session routing. Returns 0 for flat chats / non-message updates.
func updateThreadID(update *models.Update) int {
if update == nil || update.Message == nil {
return 0
}
return update.Message.MessageThreadID
}