From 676ad3fe48a2fb282f02753cf24dbc0fe9b949ef Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Wed, 29 Jul 2026 09:57:07 +1000 Subject: [PATCH] fix: embed session store in test lister to satisfy full interface --- .beads/issues.jsonl | 4 ++-- internal/gateway/gateway_test.go | 28 ++++++++++------------------ 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/.beads/issues.jsonl b/.beads/issues.jsonl index 741edb601..a3a746780 100644 --- a/.beads/issues.jsonl +++ b/.beads/issues.jsonl @@ -53,11 +53,11 @@ {"_type":"issue","id":"archie-core-abg.18","title":"[EPIC] Memory: pluggable provider architecture with file-backed persistence","description":"Pluggable memory system to match Hermes parity:\\n\\n1. **MemoryProvider interface**: Abstract interface with methods for initialize(), get_tool_schemas(), prefetch(), sync_turn(), and optional lifecycle hooks (on_session_end, on_session_switch, on_pre_compress, on_memory_write).\\n\\n2. **Built-in file-backed memory**: MEMORY.md and USER.md stored per-session/profile. LLM-callable memory tool with add/replace/remove actions. Frozen snapshot at session start (preserves prefix cache), immediate disk write on updates. Section-sign delimited entries with substring matching.\\n\\n3. **MemoryManager**: Orchestrates built-in + at most one external provider. Background serialized write executor. Prefetch with timeout (8s). Streaming context scrubber that strips injected memory spans from model output.\\n\\nRef: docs/prds/hermes-gap-analysis.md section 4","acceptance_criteria":"An external memory provider (e.g. Honcho, Mem0) can be plugged in via config. The built-in memory tool persists across sessions. Conversation context is recalled on session resume.","status":"closed","priority":0,"issue_type":"epic","owner":"sam@catlow.tech","created_at":"2026-07-25T14:02:22Z","created_by":"Sam Catlow","updated_at":"2026-07-28T17:04:41Z","closed_at":"2026-07-28T17:04:41Z","close_reason":"Superseded by merged work: all 32 children complete (32/32, bd flags it 'eligible for close'). MemoryProvider interface, built-in file-backed memory, MemoryManager, scrubber, drain and threat scanning all landed in internal/memory. Nothing left in scope.","dependencies":[{"issue_id":"archie-core-abg.18","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":0,"comment_count":0} {"_type":"issue","id":"archie-core-abg.16","title":"[EPIC] Gateway: rich message model, adapter lifecycle, session management","description":"Foundational gateway infrastructure to match Hermes parity. Three interdependent pieces:\\n\\n1. **Message model**: Replace the 3-field Message struct with a rich MessageEvent (MessageType enum: text/photo/video/audio/voice/document/sticker/command, media_urls, reply_to context, metadata dict, source). This is the wire type every adapter produces.\\n\\n2. **Adapter lifecycle**: Replace the 3-method Gateway interface with a BasePlatformAdapter interface: connect()/disconnect()/send() as required methods, plus optional overrides for typing indicators, edit/delete, image/voice/video/document send, interactive UX (clarify buttons, approval dialogs). Capability flags (supports_code_blocks, splits_long_messages, supports_async_delivery).\\n\\n3. **Session management**: SessionSource struct (platform, chat_id, chat_type, user_id, thread_id, guild_id, profile), AsyncSessionStore for persistent session storage, SessionContext for system prompt injection.\\n\\nAll three blocks together enable adding new platforms as plugins without touching core gateway code.\\n\\nRef: docs/prds/hermes-gap-analysis.md sections 1-2","acceptance_criteria":"New adapters can be added by implementing a Go interface with connect/disconnect/send + optional media methods. Messages carry full metadata through the pipeline. Sessions persist across gateway restarts.","status":"open","priority":0,"issue_type":"epic","owner":"sam@catlow.tech","created_at":"2026-07-25T14:02:21Z","created_by":"Sam Catlow","updated_at":"2026-07-25T14:02:21Z","dependencies":[{"issue_id":"archie-core-abg.16","depends_on_id":"archie-core-abg","type":"parent-child","created_at":"2026-07-26T00:02:21Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-jfg","title":"Spawned archie-agent containers not on daemon's docker network — can't reach NATS","description":"Root cause of 'agent still failing on the server': archied's container.Pool.Acquire creates archie-agent containers via the Docker SDK with no NetworkMode set, so Docker attaches them to the default bridge network. archied and nats run on the compose-created 'archie-core_default' network instead, so the spawned container's hostname resolution for 'nats' (from NATS_URL=nats://nats:4222) fails and archie-agent can't connect. Confirmed on carina host logs: archied logs show repeating 'taskrun request failed err=\"nats: no responders available for request\"' for every task, containers created and destroyed within ~1.5s (consistent with archie-agent's NATS client failing fast). Fixed by detecting the daemon's own container's network in NewPool (selfNetwork, via ContainerInspect on os.Hostname()) and setting HostConfig.NetworkMode on spawned containers to match.","status":"closed","priority":0,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-07-24T03:10:26Z","created_by":"Sam Catlow","updated_at":"2026-07-25T13:04:34Z","closed_at":"2026-07-25T13:04:34Z","close_reason":"Fix already implemented and verified: selfNetwork() in internal/container/pool.go detects the daemon's own container network via ContainerInspect(os.Hostname()) and Acquire() sets HostConfig.NetworkMode to match, so spawned archie-agent containers join the same compose network as nats. Build and internal/container tests pass.","dependency_count":0,"dependent_count":0,"comment_count":0} -{"_type":"issue","id":"archie-core-24g","title":"Trim the remaining agent skills to factual reference","description":"The .agents/skills/ library is 4283 lines across 12 skills. An audit found most carry useful facts buried in process ceremony. Five worst offenders were already parked at /work/apps/archie-skills-parked. Trim what remains to roughly 2200 lines total. KEEP: concrete commands, package anchors, config wiring tables, NellDB shapes, symptom-to-diagnostic indexes, known regressions, domain glossary, operational hazards, false-confidence warnings. CUT: mandated N-step procedures, handoff templates, evidence packets, acceptance checklists, ownership/deletion/rollback field lists, sibling-skill routing prose, repeated 'reject unless' instructions, dated tool snapshots. Preserve every skill's YAML frontmatter name and description. Do not delete any skill file outright.","acceptance_criteria":"Total line count of .agents/skills/*/*.md is between 1900 and 2500. All 12 skills still exist with valid frontmatter. No factual command, path, or table was lost - only procedure and ceremony. go build ./... still clean.","status":"closed","priority":1,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-28T17:18:09Z","created_by":"Sam Catlow","updated_at":"2026-07-28T17:41:37Z","started_at":"2026-07-28T17:18:44Z","closed_at":"2026-07-28T17:41:37Z","close_reason":"Completed","dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"archie-core-24g","title":"Trim the remaining agent skills to factual reference","description":"The .agents/skills/ library is 4283 lines across 12 skills. An audit found most carry useful facts buried in process ceremony. Five worst offenders were already parked at /work/apps/archie-skills-parked. Trim what remains to roughly 2200 lines total. KEEP: concrete commands, package anchors, config wiring tables, NellDB shapes, symptom-to-diagnostic indexes, known regressions, domain glossary, operational hazards, false-confidence warnings. CUT: mandated N-step procedures, handoff templates, evidence packets, acceptance checklists, ownership/deletion/rollback field lists, sibling-skill routing prose, repeated 'reject unless' instructions, dated tool snapshots. Preserve every skill's YAML frontmatter name and description. Do not delete any skill file outright.","acceptance_criteria":"Total line count of .agents/skills/*/*.md is between 1900 and 2500. All 12 skills still exist with valid frontmatter. No factual command, path, or table was lost - only procedure and ceremony. go build ./... still clean.","status":"open","priority":1,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-28T17:18:09Z","created_by":"Sam Catlow","updated_at":"2026-07-28T23:56:03Z","started_at":"2026-07-28T17:18:44Z","dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-5d7.2","title":"Configuration boundary and ownership review","description":"Run the first focused architecture campaign for the configuration refactor. Trace the current TOML/YAML loaders, defaults, validation, overlays, secret references, identity/repository settings, worker snapshots, container/NATS passthrough, and every production consumer. Produce a field-level current-to-target ownership ledger and decide the smallest behavior-preserving migration slice. Do not edit runtime code until ownership, input DTO boundaries, provenance requirements, schema generation boundary, compatibility semantics, and deletion criteria are recorded.","acceptance_criteria":"A reproducible current-state trace covers entrypoints, loaders, consumers, process boundaries, tests, deployment passthrough, and decoded-but-unwired fields; every in-scope setting has one current owner, target owner, scope, validation/provenance behavior, and migration disposition; base/overlay and secret compatibility semantics are explicit; the first implementation slice has an observable outcome, bounded change cone, parity tests, rollback, and deletion criterion; no unresolved semantic decision is left for the implementer to invent.","notes":"Baseline: clean committed tree at d8f4a94b4679f1d7b15abfc6fbff1a2114fe0a2a (2026-07-29). Parent archie-core-5d7 remains in progress; docsgen child 5d7.1 is complete. Initial read-only inventory confirms production uses config.LoadOverlay in cmd/archied; feature LoadDir is tested but not selected by the daemon; TaskConfig.ForTask/ToConfig is a separate worker projection; Compose mounts base+docker TOML and passes a fixed environment allowlist. No runtime edits made in this review slice.","status":"closed","priority":1,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-28T16:28:50Z","created_by":"Sam Catlow","updated_at":"2026-07-28T16:44:27Z","started_at":"2026-07-28T16:29:17Z","closed_at":"2026-07-28T16:44:27Z","close_reason":"Closing: architecture review campaign artifact. The architecture docs in docs/prds/architecture/ are complete and authoritative; no further planning/ledger work wanted.","labels":["architecture","configuration","migration"],"dependencies":[{"issue_id":"archie-core-5d7.2","depends_on_id":"archie-core-5d7","type":"parent-child","created_at":"2026-07-29T02:28:50Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-6pp","title":"Remove source-project references from Archie","description":"Remove every tau reference outside the explicitly preserved Beads data and docs-2/README.md. Delete copied product-specific documentation and accompanied rationale rather than mechanically renaming it. Retain reusable documentation-generation and VitePress scaffolding only after removing source-specific coupling. Update code, tests, archives, and architecture documents so archie-core contains no unauthorized tau references.","acceptance_criteria":"rg 'tau' -ow excluding .beads/** and docs-2/README.md returns zero; retained tools and documentation scaffolding contain no source-project imports, paths, product claims, or rationale; relevant validation passes.","notes":"Complete. Exact case-insensitive whole-word scan excluding .git/**, .beads/**, and docs-2/README.md returns 0. Source-specific provenance and rationale removed, neutral fixtures preserve behavior, docs workflow/site build from docs-2, retained README excluded from publication, and Archie-owned docsgen generates current agent contracts without process-global cwd mutation. tools tests/vet pass; affected package tests pass; VitePress production build passes. Fresh adversarial review reports zero surviving findings. Full task check passes fmt/go-fix/vet/build and all packages except unrelated pre-existing internal/skillscript TestRunWrapsExternalCommand (Run returned newline).","status":"closed","priority":1,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-28T08:00:32Z","created_by":"Sam Catlow","updated_at":"2026-07-28T08:35:55Z","started_at":"2026-07-28T08:00:37Z","closed_at":"2026-07-28T08:35:55Z","close_reason":"Removed all unauthorized source-project references and accompanying rationale; validation and independent review complete.","dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-5d7","title":"Define target project organisation and restructuring rules","description":"Run a package-by-package architecture grilling session, establish the target DDD and semi-microservice organisation, record strict restructuring requirements and package destinations, and produce docs/prds/01-project-management.md as the durable handoff.","acceptance_criteria":"The PRD records agreed project-wide organisation rules, bounded-context and service/plugin boundaries, dependency constraints, migration principles, and the destination of each reviewed package. Decisions are confirmed one at a time with the user before the document is finalized.","notes":"Corrected generated-documentation.md to the agreed architecture: production code/registries/config/CLI are authoritative; docsgen emits deterministic JSON data and protocol schemas only; typed VitePress data loaders/components/templates own page rendering; generated Markdown is prohibited. First implementation slice tracked and completed as archie-core-5d7.1.","status":"closed","priority":1,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-28T00:00:36Z","created_by":"Sam Catlow","updated_at":"2026-07-28T16:44:28Z","started_at":"2026-07-28T00:00:42Z","closed_at":"2026-07-28T16:44:28Z","close_reason":"Closing: the target organisation is already documented in docs/prds/architecture/. Reopen only when implementing a specific slice, not to plan further.","dependency_count":0,"dependent_count":0,"comment_count":0} -{"_type":"issue","id":"archie-core-qa4.4","title":"Phase 4: structural refactor (~28 issues)","description":"funlen, gocognit, cyclop, nestif, maintidx, interfacebloat. This IS the internal/config restructure already discussed (finalize at cognitive complexity 106, feature_config loadDirInto at 74) plus daemon process/checkWaiting. MUST BE LAST: refactoring moves line numbers and invalidates every other phase in flight. Fold into the config file-per-responsibility split rather than doing the same work twice.","status":"closed","priority":1,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-27T15:23:01Z","created_by":"Sam Catlow","updated_at":"2026-07-28T17:42:54Z","started_at":"2026-07-28T17:28:01Z","closed_at":"2026-07-28T17:42:54Z","close_reason":"Completed: structural refactor — 19 of ~28 issues resolved. Config file-per-responsibility split implemented (finalize.go). Daemon process() extracted helpers. Workflow stages extracted. SessionStore interface split. ~68% structural issues cleared. 9 remaining in large functions (cmd/archied, archie-agent, subprocess) deferred to follow-up.","dependencies":[{"issue_id":"archie-core-qa4.4","depends_on_id":"archie-core-qa4","type":"parent-child","created_at":"2026-07-28T01:23:00Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"archie-core-qa4.4","title":"Phase 4: structural refactor (~28 issues)","description":"funlen, gocognit, cyclop, nestif, maintidx, interfacebloat. This IS the internal/config restructure already discussed (finalize at cognitive complexity 106, feature_config loadDirInto at 74) plus daemon process/checkWaiting. MUST BE LAST: refactoring moves line numbers and invalidates every other phase in flight. Fold into the config file-per-responsibility split rather than doing the same work twice.","status":"open","priority":1,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-27T15:23:01Z","created_by":"Sam Catlow","updated_at":"2026-07-28T23:56:03Z","started_at":"2026-07-28T17:28:01Z","dependencies":[{"issue_id":"archie-core-qa4.4","depends_on_id":"archie-core-qa4","type":"parent-child","created_at":"2026-07-28T01:23:00Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-qa4.3","title":"Phase 3: correctness findings needing judgement (~62 issues)","description":"nilerr (11: 6 in internal/agentexec inprocess.go/worker.go, 2 gateway), bodyclose (1), contextcheck (7), containedctx (2), fatcontext. SINGLE SESSION, sequential, no subagents: each nilerr site needs a read of whether the swallow is deliberate degradation or a real bug, and a context-free worker will silently convert deliberate behaviour into a change. Do nilerr FIRST -- highest bug probability in the whole set. BLOCKED on a policy decision for noctx (41 sites, mostly webui/worktree/store): fixing it means threading context through public APIs, which is an API change, not a lint fix.","status":"open","priority":1,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-27T15:23:00Z","created_by":"Sam Catlow","updated_at":"2026-07-28T23:56:02Z","started_at":"2026-07-28T17:27:59Z","dependencies":[{"issue_id":"archie-core-qa4.3","depends_on_id":"archie-core-qa4","type":"parent-child","created_at":"2026-07-28T01:23:00Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-qa4.1","title":"Phase 1: autofix pass (~35 issues)","description":"golangci-lint run --fix plus the formatters. Covers errorlint, fatcontext, gocritic, sloglint, usestdlibvars, usetesting, gci, gofumpt, goimports. Zero judgement. MUST run first: it touches formatting across every file and would conflict with anything in flight. Single command, single commit, verify with task check.","status":"closed","priority":1,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-27T15:22:59Z","created_by":"Sam Catlow","updated_at":"2026-07-28T17:23:59Z","started_at":"2026-07-28T17:18:45Z","closed_at":"2026-07-28T17:23:59Z","close_reason":"Closed","dependencies":[{"issue_id":"archie-core-qa4.1","depends_on_id":"archie-core-qa4","type":"parent-child","created_at":"2026-07-28T01:22:58Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-qa4.2","title":"Phase 2: mechanical per-package fixes (~40 issues)","description":"forcetypeassert (24, internal/tools 20 + internal/memory 2, nearly all tests), predeclared (9, webui/ratelimit/memory), leftover unconvert. Purely mechanical, package-local, no design judgement. THE ONLY PHASE WORTH PARALLELISING. Partition by package: tools / webui / memory+ratelimit / secret. Use git worktree isolation -- other sessions edit this repo concurrently and stale diagnostics are a known hazard. Each worker verifies scoped: go test ./internal/X/... plus golangci-lint run ./internal/X/...","status":"closed","priority":1,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-27T15:22:59Z","created_by":"Sam Catlow","updated_at":"2026-07-28T17:23:35Z","started_at":"2026-07-28T17:18:49Z","closed_at":"2026-07-28T17:23:35Z","close_reason":"Closed","dependencies":[{"issue_id":"archie-core-qa4.2","depends_on_id":"archie-core-qa4","type":"parent-child","created_at":"2026-07-28T01:22:59Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} diff --git a/internal/gateway/gateway_test.go b/internal/gateway/gateway_test.go index 1adb1950b..cbdf32d57 100644 --- a/internal/gateway/gateway_test.go +++ b/internal/gateway/gateway_test.go @@ -689,27 +689,19 @@ func TestRouteProfileNoIdentity(t *testing.T) { // -- /sessions tests -- -type fakeSessionStore struct { +type fakeSessionLister struct { + *fakeSessionStore sessions []SessionContext err error } -func (f *fakeSessionStore) Save(ctx context.Context, s SessionContext) error { return f.err } -func (f *fakeSessionStore) Get(ctx context.Context, id string) (*SessionContext, error) { - for i := range f.sessions { if f.sessions[i].SessionID == id { return &f.sessions[i], nil } } - return nil, f.err +func (f *fakeSessionLister) List(ctx context.Context) ([]SessionContext, error) { + return f.sessions, f.err } -func (f *fakeSessionStore) GetByChannel(ctx context.Context, p, c string) ([]SessionContext, error) { return f.sessions, f.err } -func (f *fakeSessionStore) Delete(ctx context.Context, id string) error { return f.err } -func (f *fakeSessionStore) Touch(ctx context.Context, id string) error { return f.err } -func (f *fakeSessionStore) List(ctx context.Context) ([]SessionContext, error) { return f.sessions, f.err } -func (f *fakeSessionStore) SaveMessage(ctx context.Context, sid string, msg Message) error { return f.err } -func (f *fakeSessionStore) RecentMessages(ctx context.Context, sid string, n int) ([]Message, error) { return nil, f.err } -func (f *fakeSessionStore) Close() error { return nil } func TestRouteSessionsEmpty(t *testing.T) { r := NewRouter(nil, nil, "test-gw") - r.Sessions = &fakeSessionStore{} + r.Sessions = &fakeSessionLister{fakeSessionStore: newFakeSessionStore()} reply, err := r.Route(context.Background(), Message{Text: "/sessions"}) if err != nil { t.Fatalf("Route: %v", err) @@ -732,7 +724,7 @@ func TestRouteSessionsNotConfigured(t *testing.T) { func TestRouteSessionsError(t *testing.T) { r := NewRouter(nil, nil, "test-gw") - r.Sessions = &fakeSessionStore{err: fmt.Errorf("store unavailable")} + r.Sessions = &fakeSessionLister{fakeSessionStore: newFakeSessionStore(), err: fmt.Errorf("store unavailable")} _, err := r.Route(context.Background(), Message{Text: "/sessions"}) if err == nil { t.Error("expected error from Route when List fails") @@ -743,7 +735,7 @@ func TestRouteSessionsError(t *testing.T) { func TestRouteResumeNoArg(t *testing.T) { r := NewRouter(nil, nil, "test-gw") - r.Sessions = &fakeSessionStore{} + r.Sessions = &fakeSessionLister{fakeSessionStore: newFakeSessionStore()} reply, err := r.Route(context.Background(), Message{Text: "/resume"}) if err != nil { t.Fatalf("Route: %v", err) @@ -766,7 +758,7 @@ func TestRouteResumeNotConfigured(t *testing.T) { func TestRouteResumeNoMatch(t *testing.T) { r := NewRouter(nil, nil, "test-gw") - r.Sessions = &fakeSessionStore{ + r.Sessions = &fakeSessionLister{fakeSessionStore: newFakeSessionStore(), sessions: []SessionContext{ {SessionID: "session-1"}, }, @@ -782,7 +774,7 @@ func TestRouteResumeNoMatch(t *testing.T) { func TestRouteResumeAmbiguous(t *testing.T) { r := NewRouter(nil, nil, "test-gw") - r.Sessions = &fakeSessionStore{ + r.Sessions = &fakeSessionLister{fakeSessionStore: newFakeSessionStore(), sessions: []SessionContext{ {SessionID: "abc-123"}, {SessionID: "abc-456"}, @@ -799,7 +791,7 @@ func TestRouteResumeAmbiguous(t *testing.T) { func TestRouteResumeExactMatch(t *testing.T) { r := NewRouter(nil, nil, "test-gw") - r.Sessions = &fakeSessionStore{ + r.Sessions = &fakeSessionLister{fakeSessionStore: newFakeSessionStore(), sessions: []SessionContext{ {SessionID: "abc-123"}, {SessionID: "abc-456"},