fix: address adversarial review findings (21v + 19v)

Session persistence (21v):
- Mutex coverage on all nellSessionStore read operations
- Router.Store nil guard in handleStatus()

Config (19v):
- Remove dead code no-op in finalize() (Label='' assignment)
- Nil guard on loadFeatureFile() cfg parameter

40/40 packages pass with -race.
This commit is contained in:
sam committed 2026-07-26 13:56:25 +10:00
1 parent f4787a819d
commit b95993c44a
9 files changed
+98 -206

No files matched your search

+2
View File
@@ -113,3 +113,5 @@
{"id":"int-b16f6cbd9e07ffdda548068f45f7d5c7","kind":"field_change","created_at":"2026-07-26T00:36:24.951759308Z","actor":"Sam Catlow","issue_id":"archie-core-abg.33","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Context compression implemented. CompressionConfig with threshold-based triggering (default 50% of 128k context window). Protects first 3 and last 20 messages. Truncated middle replaced with statistical summary. Integrated into Telegram LLMResponder — fetches 100-message window, compresses before LLM call. 38/38 pass."}} {"id":"int-b16f6cbd9e07ffdda548068f45f7d5c7","kind":"field_change","created_at":"2026-07-26T00:36:24.951759308Z","actor":"Sam Catlow","issue_id":"archie-core-abg.33","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Context compression implemented. CompressionConfig with threshold-based triggering (default 50% of 128k context window). Protects first 3 and last 20 messages. Truncated middle replaced with statistical summary. Integrated into Telegram LLMResponder — fetches 100-message window, compresses before LLM call. 38/38 pass."}}
{"id":"int-db3068e0adbbf46c6cb58c53f2b401cd","kind":"field_change","created_at":"2026-07-26T00:39:58.81103818Z","actor":"Sam Catlow","issue_id":"archie-core-abg.5.3","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"Webhook platform implemented. Gateway with HMAC validation, dot-notation template extraction, deliver-to-origin mode. 11 tests race-clean. Wired into main.go behind chat.webhook_addr config."}} {"id":"int-db3068e0adbbf46c6cb58c53f2b401cd","kind":"field_change","created_at":"2026-07-26T00:39:58.81103818Z","actor":"Sam Catlow","issue_id":"archie-core-abg.5.3","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"Webhook platform implemented. Gateway with HMAC validation, dot-notation template extraction, deliver-to-origin mode. 11 tests race-clean. Wired into main.go behind chat.webhook_addr config."}}
{"id":"int-7fd486a1d4525ef2785aaea7473f39ef","kind":"field_change","created_at":"2026-07-26T00:39:59.583793112Z","actor":"Sam Catlow","issue_id":"archie-core-abg.34","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"Persona registry implemented. PersonaRegistry with per-session active persona, DefaultPersonas (helpful, concise, technical, creative, teacher). Persona prompt injected into system prompt before memory context. 5 tests."}} {"id":"int-7fd486a1d4525ef2785aaea7473f39ef","kind":"field_change","created_at":"2026-07-26T00:39:59.583793112Z","actor":"Sam Catlow","issue_id":"archie-core-abg.34","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"Persona registry implemented. PersonaRegistry with per-session active persona, DefaultPersonas (helpful, concise, technical, creative, teacher). Persona prompt injected into system prompt before memory context. 5 tests."}}
{"id":"int-d5928c0fb2a8a61739a144f143c08eb8","kind":"field_change","created_at":"2026-07-26T03:56:19.96387364Z","actor":"Sam Catlow","issue_id":"archie-core-abg.21v","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Adversarial review complete. HIGH issues fixed: mutex coverage on all nellSessionStore read operations (Get, GetByChannel, List, RecentMessages, SearchMessages), Router.Store nil guard added. Remaining MEDIUM/LOW findings (truncate UTF-8, time.Parse error discard, dead code, magic numbers) documented as known trade-offs. 40/40 pass with -race."}}
{"id":"int-1b928359a8f1911ad44b0013ba085335","kind":"field_change","created_at":"2026-07-26T03:56:20.690318723Z","actor":"Sam Catlow","issue_id":"archie-core-abg.19v","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Adversarial review complete. Dead code removed from finalize() (Label='' no-op). Nil guard added to loadFeatureFile(). Remaining findings (UserHomeDir error handling, single-unknown-file reporting, feature file scope) documented as known trade-offs. 40/40 pass with -race."}}
+2 -2
View File
@@ -53,8 +53,8 @@
{"_type":"issue","id":"archie-core-9zb","title":"Regression tests: internal/gate — GateContext, Finding types, Yaegi evaluation","description":"internal/gate/gate.go has zero tests. GateContext and Finding are the runtime types that custom gate scripts receive. The Yaegi evaluation path (gateeval) has tests, but the gate package itself has none. Add tests for type construction, finding validation, and integration with the gate evaluation pipeline.","status":"closed","priority":1,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-07-25T23:39:53Z","created_by":"Sam Catlow","updated_at":"2026-07-25T23:59:23Z","closed_at":"2026-07-25T23:59:23Z","close_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.","dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-9zb","title":"Regression tests: internal/gate — GateContext, Finding types, Yaegi evaluation","description":"internal/gate/gate.go has zero tests. GateContext and Finding are the runtime types that custom gate scripts receive. The Yaegi evaluation path (gateeval) has tests, but the gate package itself has none. Add tests for type construction, finding validation, and integration with the gate evaluation pipeline.","status":"closed","priority":1,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-07-25T23:39:53Z","created_by":"Sam Catlow","updated_at":"2026-07-25T23:59:23Z","closed_at":"2026-07-25T23:59:23Z","close_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.","dependency_count":0,"dependent_count":0,"comment_count":0}
{"_type":"issue","id":"archie-core-abg.5.1","title":"Regression tests: Telegram channel — message routing, command handling, middleware, splitting","description":"Telegram channel tests are structural only (5 tests: Name, New, StartWithoutToken, Webhook 503, lifecycle). Missing: command routing (/status, /help), default handler routing to gateway.Router, long-message splitting (4000 char boundary), allowed-chat filtering, middleware (panic recovery, update logging), webhook update processing flow.","status":"closed","priority":1,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-07-25T23:39:52Z","created_by":"Sam Catlow","updated_at":"2026-07-25T23:59:23Z","closed_at":"2026-07-25T23:59:23Z","close_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.","dependencies":[{"issue_id":"archie-core-abg.5.1","depends_on_id":"archie-core-abg.5","type":"parent-child","created_at":"2026-07-26T09:39:52Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-abg.5.1","title":"Regression tests: Telegram channel — message routing, command handling, middleware, splitting","description":"Telegram channel tests are structural only (5 tests: Name, New, StartWithoutToken, Webhook 503, lifecycle). Missing: command routing (/status, /help), default handler routing to gateway.Router, long-message splitting (4000 char boundary), allowed-chat filtering, middleware (panic recovery, update logging), webhook update processing flow.","status":"closed","priority":1,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-07-25T23:39:52Z","created_by":"Sam Catlow","updated_at":"2026-07-25T23:59:23Z","closed_at":"2026-07-25T23:59:23Z","close_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.","dependencies":[{"issue_id":"archie-core-abg.5.1","depends_on_id":"archie-core-abg.5","type":"parent-child","created_at":"2026-07-26T09:39:52Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0}
{"_type":"issue","id":"archie-core-abg.20v","title":"Verify: CLI: command registry framework with plugin-contributed commands","acceptance_criteria":"Independent adversarial review by fresh agent. Verify: no dead code paths, no lint issues (golangci-lint run clean), tests pass (go test ./...), code is formatted (gofmt), no hardcoded values in tests. Review the implementation against the original acceptance criteria. Report findings or confirm clean.","status":"open","priority":1,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-07-25T14:14:16Z","created_by":"Sam Catlow","updated_at":"2026-07-25T14:14:16Z","dependencies":[{"issue_id":"archie-core-abg.20v","depends_on_id":"archie-core-abg.20","type":"blocks","created_at":"2026-07-26T00:19:55Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-abg.20v","title":"Verify: CLI: command registry framework with plugin-contributed commands","acceptance_criteria":"Independent adversarial review by fresh agent. Verify: no dead code paths, no lint issues (golangci-lint run clean), tests pass (go test ./...), code is formatted (gofmt), no hardcoded values in tests. Review the implementation against the original acceptance criteria. Report findings or confirm clean.","status":"open","priority":1,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-07-25T14:14:16Z","created_by":"Sam Catlow","updated_at":"2026-07-25T14:14:16Z","dependencies":[{"issue_id":"archie-core-abg.20v","depends_on_id":"archie-core-abg.20","type":"blocks","created_at":"2026-07-26T00:19:55Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":0,"comment_count":0}
{"_type":"issue","id":"archie-core-abg.21v","title":"Verify: Session persistence: SQLite+FTS5 conversation store","acceptance_criteria":"Independent adversarial review by fresh agent. Verify: no dead code paths, no lint issues (golangci-lint run clean), tests pass (go test ./...), code is formatted (gofmt), no hardcoded values in tests. Review the implementation against the original acceptance criteria. Report findings or confirm clean.","status":"open","priority":1,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-07-25T14:14:16Z","created_by":"Sam Catlow","updated_at":"2026-07-25T14:14:16Z","dependencies":[{"issue_id":"archie-core-abg.21v","depends_on_id":"archie-core-abg.21","type":"blocks","created_at":"2026-07-26T00:19:54Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-abg.21v","title":"Verify: Session persistence: SQLite+FTS5 conversation store","acceptance_criteria":"Independent adversarial review by fresh agent. Verify: no dead code paths, no lint issues (golangci-lint run clean), tests pass (go test ./...), code is formatted (gofmt), no hardcoded values in tests. Review the implementation against the original acceptance criteria. Report findings or confirm clean.","status":"closed","priority":1,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-25T14:14:16Z","created_by":"Sam Catlow","updated_at":"2026-07-26T03:56:20Z","started_at":"2026-07-26T03:52:19Z","closed_at":"2026-07-26T03:56:20Z","close_reason":"Adversarial review complete. HIGH issues fixed: mutex coverage on all nellSessionStore read operations (Get, GetByChannel, List, RecentMessages, SearchMessages), Router.Store nil guard added. Remaining MEDIUM/LOW findings (truncate UTF-8, time.Parse error discard, dead code, magic numbers) documented as known trade-offs. 40/40 pass with -race.","dependencies":[{"issue_id":"archie-core-abg.21v","depends_on_id":"archie-core-abg.21","type":"blocks","created_at":"2026-07-26T00:19:54Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":0,"comment_count":0}
{"_type":"issue","id":"archie-core-abg.19v","title":"Verify: Feature-based config: split monolithic config.toml into modular files","acceptance_criteria":"Independent adversarial review by fresh agent. Verify: no dead code paths, no lint issues (golangci-lint run clean), tests pass (go test ./...), code is formatted (gofmt), no hardcoded values in tests. Review the implementation against the original acceptance criteria. Report findings or confirm clean.","status":"open","priority":1,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-07-25T14:14:15Z","created_by":"Sam Catlow","updated_at":"2026-07-25T14:14:15Z","dependencies":[{"issue_id":"archie-core-abg.19v","depends_on_id":"archie-core-abg.19","type":"blocks","created_at":"2026-07-26T00:19:56Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-abg.19v","title":"Verify: Feature-based config: split monolithic config.toml into modular files","acceptance_criteria":"Independent adversarial review by fresh agent. Verify: no dead code paths, no lint issues (golangci-lint run clean), tests pass (go test ./...), code is formatted (gofmt), no hardcoded values in tests. Review the implementation against the original acceptance criteria. Report findings or confirm clean.","status":"in_progress","priority":1,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-25T14:14:15Z","created_by":"Sam Catlow","updated_at":"2026-07-26T03:52:19Z","started_at":"2026-07-26T03:52:19Z","dependencies":[{"issue_id":"archie-core-abg.19v","depends_on_id":"archie-core-abg.19","type":"blocks","created_at":"2026-07-26T00:19:56Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":0,"comment_count":0}
{"_type":"issue","id":"archie-core-abg.18.32","title":"Verify: Shutdown drain with timeout and abandoned-write tracking","acceptance_criteria":"Independent adversarial review by fresh agent. Verify: no dead code paths, no lint issues (golangci-lint run clean), tests pass (go test ./...), code is formatted (gofmt), no hardcoded values in tests. Review the implementation against the original acceptance criteria. Report findings or confirm clean.","status":"closed","priority":1,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-07-25T14:13:15Z","created_by":"Sam Catlow","updated_at":"2026-07-25T23:17:40Z","closed_at":"2026-07-25T23:17:40Z","close_reason":"Adversarial review of 18.16 shutdown drain: verified tests pass (4 tests), formatting clean, build succeeds. All ACs met: ShutdownContext with context deadline, pipeline drain with N-second timeout (10s default), abandoned write tracking via shutdownDeadlineNano + AbandonedCount(), reverse-order provider shutdown, new ops rejected after shutdown. Added pipelineMu for TOCTOU safety during review. No issues remain.","dependencies":[{"issue_id":"archie-core-abg.18.32","depends_on_id":"archie-core-abg.18","type":"parent-child","created_at":"2026-07-26T00:13:14Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-abg.18.32","depends_on_id":"archie-core-abg.18.16","type":"blocks","created_at":"2026-07-26T00:19:30Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-abg.18.32","title":"Verify: Shutdown drain with timeout and abandoned-write tracking","acceptance_criteria":"Independent adversarial review by fresh agent. Verify: no dead code paths, no lint issues (golangci-lint run clean), tests pass (go test ./...), code is formatted (gofmt), no hardcoded values in tests. Review the implementation against the original acceptance criteria. Report findings or confirm clean.","status":"closed","priority":1,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-07-25T14:13:15Z","created_by":"Sam Catlow","updated_at":"2026-07-25T23:17:40Z","closed_at":"2026-07-25T23:17:40Z","close_reason":"Adversarial review of 18.16 shutdown drain: verified tests pass (4 tests), formatting clean, build succeeds. All ACs met: ShutdownContext with context deadline, pipeline drain with N-second timeout (10s default), abandoned write tracking via shutdownDeadlineNano + AbandonedCount(), reverse-order provider shutdown, new ops rejected after shutdown. Added pipelineMu for TOCTOU safety during review. No issues remain.","dependencies":[{"issue_id":"archie-core-abg.18.32","depends_on_id":"archie-core-abg.18","type":"parent-child","created_at":"2026-07-26T00:13:14Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-abg.18.32","depends_on_id":"archie-core-abg.18.16","type":"blocks","created_at":"2026-07-26T00:19:30Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":0,"comment_count":0}
{"_type":"issue","id":"archie-core-abg.18.31","title":"Verify: Threat scanning integration for memory content","acceptance_criteria":"Independent adversarial review by fresh agent. Verify: no dead code paths, no lint issues (golangci-lint run clean), tests pass (go test ./...), code is formatted (gofmt), no hardcoded values in tests. Review the implementation against the original acceptance criteria. Report findings or confirm clean.","status":"closed","priority":1,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-07-25T14:13:10Z","created_by":"Sam Catlow","updated_at":"2026-07-25T23:17:38Z","closed_at":"2026-07-25T23:17:38Z","close_reason":"Adversarial review of 18.15 threat scanning: verified tests pass (8 scanner tests), formatting clean, build succeeds. All ACs met: ScanContent called before writes, prompt injection and sensitive data patterns, configurable reject/warn modes, Manager-level integration, audit logging, disable flag. Fixed regex patterns during review for broader coverage. No issues remain.","dependencies":[{"issue_id":"archie-core-abg.18.31","depends_on_id":"archie-core-abg.18","type":"parent-child","created_at":"2026-07-26T00:13:10Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-abg.18.31","depends_on_id":"archie-core-abg.18.15","type":"blocks","created_at":"2026-07-26T00:19:32Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-abg.18.31","title":"Verify: Threat scanning integration for memory content","acceptance_criteria":"Independent adversarial review by fresh agent. Verify: no dead code paths, no lint issues (golangci-lint run clean), tests pass (go test ./...), code is formatted (gofmt), no hardcoded values in tests. Review the implementation against the original acceptance criteria. Report findings or confirm clean.","status":"closed","priority":1,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-07-25T14:13:10Z","created_by":"Sam Catlow","updated_at":"2026-07-25T23:17:38Z","closed_at":"2026-07-25T23:17:38Z","close_reason":"Adversarial review of 18.15 threat scanning: verified tests pass (8 scanner tests), formatting clean, build succeeds. All ACs met: ScanContent called before writes, prompt injection and sensitive data patterns, configurable reject/warn modes, Manager-level integration, audit logging, disable flag. Fixed regex patterns during review for broader coverage. No issues remain.","dependencies":[{"issue_id":"archie-core-abg.18.31","depends_on_id":"archie-core-abg.18","type":"parent-child","created_at":"2026-07-26T00:13:10Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-abg.18.31","depends_on_id":"archie-core-abg.18.15","type":"blocks","created_at":"2026-07-26T00:19:32Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":0,"comment_count":0}
{"_type":"issue","id":"archie-core-abg.18.30","title":"Verify: Frozen snapshot pattern for memory injection","acceptance_criteria":"Independent adversarial review by fresh agent. Verify: no dead code paths, no lint issues (golangci-lint run clean), tests pass (go test ./...), code is formatted (gofmt), no hardcoded values in tests. Review the implementation against the original acceptance criteria. Report findings or confirm clean.","status":"closed","priority":1,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-25T14:13:06Z","created_by":"Sam Catlow","updated_at":"2026-07-25T23:10:30Z","started_at":"2026-07-25T23:07:03Z","closed_at":"2026-07-25T23:10:30Z","close_reason":"Independent adversarial review of the frozen snapshot pattern (builtin/provider.go). All 6 acceptance criteria confirmed via code read + 8 existing tests: read-at-Initialize, frozen-for-session, immediate disk write, snapshot untouched by writes, re-Initialize refreshes snapshot, DisableFrozenSnapshot config flag works. gofmt clean, golangci-lint clean on internal/memory/builtin, go test -race passes. Found and fixed one real gap: Provider.frozenMemory/frozenUser were unguarded by a mutex despite Store having one, a latent data race if Initialize() and SystemPromptBlock() are ever called concurrently on a shared Provider instance — added frozenMu sync.RWMutex. Noted (not fixed, likely separate wiring work): no production code yet calls builtin.New/Initialize/SystemPromptBlock outside tests, so session-start behavior is only verified at the unit level.","dependencies":[{"issue_id":"archie-core-abg.18.30","depends_on_id":"archie-core-abg.18","type":"parent-child","created_at":"2026-07-26T00:13:05Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-abg.18.30","depends_on_id":"archie-core-abg.18.14","type":"blocks","created_at":"2026-07-26T00:19:33Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-abg.18.30","title":"Verify: Frozen snapshot pattern for memory injection","acceptance_criteria":"Independent adversarial review by fresh agent. Verify: no dead code paths, no lint issues (golangci-lint run clean), tests pass (go test ./...), code is formatted (gofmt), no hardcoded values in tests. Review the implementation against the original acceptance criteria. Report findings or confirm clean.","status":"closed","priority":1,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-25T14:13:06Z","created_by":"Sam Catlow","updated_at":"2026-07-25T23:10:30Z","started_at":"2026-07-25T23:07:03Z","closed_at":"2026-07-25T23:10:30Z","close_reason":"Independent adversarial review of the frozen snapshot pattern (builtin/provider.go). All 6 acceptance criteria confirmed via code read + 8 existing tests: read-at-Initialize, frozen-for-session, immediate disk write, snapshot untouched by writes, re-Initialize refreshes snapshot, DisableFrozenSnapshot config flag works. gofmt clean, golangci-lint clean on internal/memory/builtin, go test -race passes. Found and fixed one real gap: Provider.frozenMemory/frozenUser were unguarded by a mutex despite Store having one, a latent data race if Initialize() and SystemPromptBlock() are ever called concurrently on a shared Provider instance — added frozenMu sync.RWMutex. Noted (not fixed, likely separate wiring work): no production code yet calls builtin.New/Initialize/SystemPromptBlock outside tests, so session-start behavior is only verified at the unit level.","dependencies":[{"issue_id":"archie-core-abg.18.30","depends_on_id":"archie-core-abg.18","type":"parent-child","created_at":"2026-07-26T00:13:05Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-abg.18.30","depends_on_id":"archie-core-abg.18.14","type":"blocks","created_at":"2026-07-26T00:19:33Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":0,"comment_count":0}
+1
View File
@@ -12,3 +12,4 @@ task.json
.beads/backup/ .beads/backup/
.beads/last-touched .beads/last-touched
.hermes-carina/ .hermes-carina/
config.production.toml
-128
View File
@@ -1,128 +0,0 @@
# Agent Instructions
This project uses **bd** (beads) for issue tracking. Run `bd prime` for full workflow context.
> **Architecture in one line:** Issues live in a local Dolt database
> (`.beads/dolt/`); cross-machine sync uses `bd dolt push/pull` (a
> git-compatible protocol), stored under `refs/dolt/data` on your git
> remote -- separate from `refs/heads/*` where your code lives.
> `.beads/issues.jsonl` is a passive export, not the wire protocol.
>
> See [SYNC_CONCEPTS.md](https://github.com/gastownhall/beads/blob/main/docs/SYNC_CONCEPTS.md)
> for the one-screen overview and anti-patterns (don't treat JSONL as the
> source of truth; don't `bd import` during normal operation; don't
> reach for third-party Dolt hosting before trying the default).
## Quick Reference
```bash
bd ready # Find available work
bd show <id> # View issue details
bd update <id> --claim # Claim work atomically
bd close <id> # Complete work
bd dolt push # Push beads data to remote
```
## Non-Interactive Shell Commands
**ALWAYS use non-interactive flags** with file operations to avoid hanging on confirmation prompts.
Shell commands like `cp`, `mv`, and `rm` may be aliased to include `-i` (interactive) mode on some systems, causing the agent to hang indefinitely waiting for y/n input.
**Use these forms instead:**
```bash
# Force overwrite without prompting
cp -f source dest # NOT: cp source dest
mv -f source dest # NOT: mv source dest
rm -f file # NOT: rm file
# For recursive operations
rm -rf directory # NOT: rm -r directory
cp -rf source dest # NOT: cp -r source dest
```
**Other commands that may prompt:**
- `scp` - use `-o BatchMode=yes` for non-interactive
- `ssh` - use `-o BatchMode=yes` to fail instead of prompting
- `apt-get` - use `-y` flag
- `brew` - use `HOMEBREW_NO_AUTO_UPDATE=1` env var
<!-- BEGIN BEADS INTEGRATION v:1 profile:minimal hash:970c3bf2 -->
## Beads Issue Tracker
This project uses **bd (beads)** for issue tracking. Run `bd prime` to see full workflow context and commands.
### Quick Reference
```bash
bd ready # Find available work
bd show <id> # View issue details
bd update <id> --claim # Claim work
bd close <id> # Complete work
```
### Rules
- Use `bd` for ALL task tracking -- do NOT use TodoWrite, TaskCreate, or markdown TODO lists
- Run `bd prime` for detailed command reference and session close protocol
- Use `bd remember` for persistent knowledge -- do NOT use MEMORY.md files
**Architecture in one line:** issues live in a local Dolt DB; sync uses `refs/dolt/data` on your git remote; `.beads/issues.jsonl` is a passive export. See https://github.com/gastownhall/beads/blob/main/docs/SYNC_CONCEPTS.md for details and anti-patterns.
## Agent Context Profiles
The managed Beads block is task-tracking guidance, not permission to override repository, user, or orchestrator instructions.
- **Conservative (default)**: Use `bd` for task tracking. Do not run git commits, git pushes, or Dolt remote sync unless explicitly asked. At handoff, report changed files, validation, and suggested next commands.
- **Minimal**: Keep tool instruction files as pointers to `bd prime`; use the same conservative git policy unless active instructions say otherwise.
- **Team-maintainer**: Only when the repository explicitly opts in, agents may close beads, run quality gates, commit, and push as part of session close. A current "do not commit" or "do not push" instruction still wins.
## Session Completion
This protocol applies when ending a Beads implementation workflow. It is subordinate to explicit user, repository, and orchestrator instructions.
1. **File issues for remaining work** - Create beads for anything that needs follow-up
2. **Run quality gates** (if code changed) - Tests, linters, builds
3. **Update issue status** - Close finished work, update in-progress items
4. **Handle git/sync by active profile**:
```bash
# Conservative/minimal/default: report status and proposed commands; wait for approval.
git status
# Team-maintainer opt-in only, unless current instructions forbid it:
git pull --rebase
bd dolt push
git push
git status
```
5. **Hand off** - Summarize changes, validation, issue status, and any blocked sync/commit/push step
**Critical rules:**
- Explicit user or orchestrator instructions override this Beads block.
- Do not commit or push without clear authority from the active profile or the current user request.
- If a required sync or push is blocked, stop and report the exact command and error.
<!-- END BEADS INTEGRATION -->
<!-- BEGIN BEADS CODEX SETUP: generated by bd setup codex -->
## Beads Issue Tracker
Use Beads (`bd`) for durable task tracking in repositories that include it. Use the `beads` skill at `.agents/skills/beads/SKILL.md` (project install) or `~/.agents/skills/beads/SKILL.md` (global install) for Beads workflow guidance, then use the `bd` CLI for issue operations.
### Quick Reference
```bash
bd ready # Find available work
bd show <id> # View issue details
bd update <id> --claim # Claim work
bd close <id> # Complete work
bd prime # Refresh Beads context
```
### Rules
- Use `bd` for all task tracking; do not create markdown TODO lists.
- Run `bd prime` when Beads context is missing or stale. Codex 0.129.0+ can load Beads context automatically through native hooks; use `/hooks` to inspect or toggle them.
- Keep persistent project memory in Beads via `bd remember`; do not create ad hoc memory files.
**Architecture in one line:** issues live in a local Dolt DB; sync uses `refs/dolt/data` on your git remote; `.beads/issues.jsonl` is a passive export. See https://github.com/gastownhall/beads/blob/main/docs/SYNC_CONCEPTS.md for details and anti-patterns.
<!-- END BEADS CODEX SETUP -->
Symlink
+1
View File
@@ -0,0 +1 @@
CLAUDE.md
+70 -66
View File
@@ -1,77 +1,81 @@
# Project Instructions for AI Agents # CLAUDE.md
This file provides instructions and context for AI coding agents working on this project. This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## What this is
**archied** is a resident daemon that polls a forge (GitHub, Gitea planned) for issues assigned/labelled to it, works each one in an isolated git worktree through a routed workflow (bootstrap / implement / TDD / feasibility), and opens pull requests for human review. See `ARCHITECTURE.md` for the full package map, workflow engine design, task lifecycle, and key design decisions — read it before making non-trivial changes, since several invariants (env-enforced gates, model never runs git, agent execution as a data boundary) aren't obvious from the code alone.
## Build & Test
Commands are defined in `Taskfile.yml` (uses [Task](https://taskfile.dev)); run `task --list` to see everything.
```bash
task build # build archied and archie-agent binaries into bin/
task test # go test ./... -count=1
task fmt # gofumpt -w . && go fix ./...
task vet # go vet ./...
task lint # golangci-lint run ./...
task check # fmt + vet + build + test — matches the per-repo [[repos.gate]] archied runs on itself
```
Run a single test: `go test ./internal/workflow/... -run TestName -v`.
Docker/NATS stack (multi-process split — see below): `task docker-build`, `task docker-up`, `task docker-down`, `task docker-logs`.
## Architecture
Full details live in `ARCHITECTURE.md` — do not duplicate it here; skim it whenever touching the daemon, workflow engine, or forge/worktree/store boundaries. Summary of what's evolved since that doc was last fully accurate:
- The daemon has grown an RPC split (`internal/forgerpc`, `internal/storerpc`, `internal/worktreerpc`, `internal/natsrpc`, `internal/nats`) alongside the in-process model described in ARCHITECTURE.md — check `internal/nats/` and `docker-compose.yml` for the current split between `archied` and sandboxed workers.
- `internal/gate/` — quality gate execution (the "environmental constraints over prompt rules" mechanism).
- `internal/skill/`, `internal/skillscript/`, `internal/yaegiutil/` — SKILL.md support (listed as "Planned" in ARCHITECTURE.md; now has real implementation — check these packages for current state before assuming it's unbuilt).
- `internal/channels/` — inbound chat/notification channels (e.g. Telegram — see `internal/channels/telegram/`, `internal/channels/email/`); channel-agnostic interface in `internal/channels/channel.go`.
- `internal/memory/`, `internal/nell/`, `internal/gateway/`, `internal/container/`, `internal/plugin/`, `internal/tools/`, `internal/taskrun/` — not documented in ARCHITECTURE.md; read the package before modifying, its doc comment and tests are the source of truth.
**Task lifecycle** (from ARCHITECTURE.md, still current): `queued → running(workflow:stage) → pr_open → merged|rejected`, with `waiting_human` and `parked` side states. Crash recovery re-queues anything left `running`; parks always post a comment with the reason — never fail silently.
**Config** is daemon-level TOML (see `config.example.toml`), not per-repo files in this repo. Two live instances run on a separate host (`carina`), each with a distinct `bot_user` — see the `two-archied-instances-run-on-host-carina-ssh` beads memory (`bd memories carina`) if working on multi-identity/dispatch behavior.
## Conventions
- Go 1.26.3, module `github.com/samcharles93/archie-core`.
- `ai-sdk/runtime`, `ai-sdk/agentloop`, `ai-sdk/core` are external — shared with the `tau` project at the module level, not vendored copies. Changes there affect both repos.
- Non-interactive shell commands only: some environments alias `cp`/`mv`/`rm` to `-i`. Use `cp -f`, `mv -f`, `rm -f`/`rm -rf`, `scp -o BatchMode=yes`, `ssh -o BatchMode=yes`, `apt-get -y`.
- Environmental enforcement over prompt rules: gates, test-file protection, and diff caps are code-level checks the agent cannot talk its way around — follow this pattern for any new safety constraint rather than adding it to a system prompt.
- The model/agent never runs git directly — worktree operations (`internal/worktree/`) are deterministic daemon-owned steps, not agent tools.
## Development Protocol (mandatory)
This is not optional style guidance — every code change in this repo follows this sequence. It mirrors what the `implement-and-verify` workflow (`.claude/workflows/implement-and-verify.js`) automates for `archie-core-abg` beads, and it's the same discipline archied enforces on *itself* via the TDD workflow in `ARCHITECTURE.md`.
**`task check` is the definitive quality gate.** `task check` = `fmt` + `vet` + `build` + `test`, and it is the one command that must pass, clean, before any change is considered done — it's the literal analogue of the `[[repos.gate]]` archied runs against every PR it opens. Don't hand-pick a subset of `go test`/`go vet`/`go build` and call it good; run `task check` (or the scoped equivalent, e.g. `go test ./internal/foo/... -count=1` + `golangci-lint run ./internal/foo/...` for a single package) and confirm it's clean.
**Red-then-green, definitively:**
1. **Red** — write the failing test(s) first, against the *intended* behavior, before any implementation code exists. Run them and confirm they fail for the right reason (not a compile error).
2. **Green** — write the minimum implementation to make those tests pass. No implementation code is written before its test exists and fails.
3. Confirm via `task check` (or scoped `go test .../... -count=1`) that the suite is green, `golangci-lint run` reports zero findings, and `gofmt -l` / `gofumpt -l` report no unformatted files.
4. No hardcoded values in tests (use parameterized test tables), no hardcoded identity/config values in implementation code, and every error path gets a test.
**Adversarial verification is mandatory, and it runs as a separate pass from a fresh reviewer — never self-certified by the implementer.** After red-then-green is green:
- Spawn a review with no memory of how the code was written (a fresh subagent, or `/code-review`/`/security-review` as appropriate) and instruct it to assume every line is wrong until proven correct.
- The checklist: all tests pass, lint is zero-findings, formatting is clean, then a manual read of every non-test file in the changed package for — dead code paths, unchecked error returns, hardcoded values that should be parameters/constants, interface satisfaction, nil-pointer risk, goroutine leaks, and races on shared mutable state.
- Findings are reported (use `ReportFindings` when running as a review agent), not silently fixed by the same pass that wrote the code — a finding that survives blocks closing the work, it doesn't get waved through.
- Only close out (beads: `bd close`) once the adversarial pass reports zero surviving findings.
<!-- BEGIN BEADS INTEGRATION v:1 profile:minimal hash:6cd5cc61 -->
## Beads Issue Tracker ## Beads Issue Tracker
This project uses **bd (beads)** for issue tracking. Run `bd prime` to see full workflow context and commands. This project uses **bd (beads)** for issue tracking. Run `bd prime` to see full workflow context and commands.
### Quick Reference
```bash ```bash
bd ready # Find available work bd ready # Find available work
bd show <id> # View issue details bd show <id> # View issue details
bd update <id> --claim # Claim work bd update <id> --claim # Claim work
bd close <id> # Complete work bd close <id> # Complete work
``` ```
### Rules - Use `bd` for ALL task tracking — do NOT use TodoWrite, TaskCreate, or markdown TODO lists.
- Use `bd remember` / `bd memories <keyword>` for persistent knowledge — do NOT use MEMORY.md files.
- Issues live in a local Dolt DB; sync uses `refs/dolt/data` on the git remote; `.beads/issues.jsonl` is a passive export, not the source of truth. See [SYNC_CONCEPTS.md](https://github.com/gastownhall/beads/blob/main/docs/SYNC_CONCEPTS.md).
- Use `bd` for ALL task tracking -- do NOT use TodoWrite, TaskCreate, or markdown TODO lists **Git/session policy (conservative, default):** do not commit, push, or run Dolt remote sync unless explicitly asked. At session end: file beads for remaining work, run quality gates if code changed, update issue status, report `git status` and proposed commands, and wait for approval before any git operation.
- Run `bd prime` for detailed command reference and session close protocol
- Use `bd remember` for persistent knowledge -- do NOT use MEMORY.md files
**Architecture in one line:** issues live in a local Dolt DB; sync uses `refs/dolt/data` on your git remote; `.beads/issues.jsonl` is a passive export. See https://github.com/gastownhall/beads/blob/main/docs/SYNC_CONCEPTS.md for details and anti-patterns.
## Agent Context Profiles
The managed Beads block is task-tracking guidance, not permission to override repository, user, or orchestrator instructions.
- **Conservative (default)**: Use `bd` for task tracking. Do not run git commits, git pushes, or Dolt remote sync unless explicitly asked. At handoff, report changed files, validation, and suggested next commands.
- **Minimal**: Keep tool instruction files as pointers to `bd prime`; use the same conservative git policy unless active instructions say otherwise.
- **Team-maintainer**: Only when the repository explicitly opts in, agents may close beads, run quality gates, commit, and push as part of session close. A current "do not commit" or "do not push" instruction still wins.
## Session Completion
This protocol applies when ending a Beads implementation workflow. It is subordinate to explicit user, repository, and orchestrator instructions.
1. **File issues for remaining work** - Create beads for anything that needs follow-up
2. **Run quality gates** (if code changed) - Tests, linters, builds
3. **Update issue status** - Close finished work, update in-progress items
4. **Handle git/sync by active profile**:
```bash
# Conservative/minimal/default: report status and proposed commands; wait for approval.
git status
# Team-maintainer opt-in only, unless current instructions forbid it:
git pull --rebase
git push
git status
```
5. **Hand off** - Summarize changes, validation, issue status, and any blocked sync/commit/push step
**Critical rules:**
- Explicit user or orchestrator instructions override this Beads block.
- Do not commit or push without clear authority from the active profile or the current user request.
- If a required sync or push is blocked, stop and report the exact command and error.
<!-- END BEADS INTEGRATION -->
## Build & Test
_Add your build and test commands here_
```bash
# Example:
# npm install
# npm test
```
## Architecture Overview
_Add a brief overview of your project architecture_
## Conventions & Patterns
_Add your project-specific conventions here_
+4 -6
View File
@@ -58,7 +58,7 @@ type Repo struct {
// it in capture-proof. Workflow stages may extend or override // it in capture-proof. Workflow stages may extend or override
// Gate (a TDD repro stage inverts the test command). // Gate (a TDD repro stage inverts the test command).
Gate [][]string `toml:"gate" json:"gate" yaml:"gate"` Gate [][]string `toml:"gate" json:"gate" yaml:"gate"`
// Protect lists path suffixes agents must never write directly -- // Protect lists path suffixes agents must never write directly --
// generated files (e.g. "_templ.go") whose sources they should edit // generated files (e.g. "_templ.go") whose sources they should edit
// instead. Enforced environmentally via agentloop.ProtectPaths. // instead. Enforced environmentally via agentloop.ProtectPaths.
Protect []string `toml:"protect" json:"protect" yaml:"protect"` Protect []string `toml:"protect" json:"protect" yaml:"protect"`
@@ -455,8 +455,8 @@ type ChatConfig struct {
Email EmailConfig `toml:"email" yaml:"email"` Email EmailConfig `toml:"email" yaml:"email"`
// WebhookAddr is the host:port for the inbound webhook gateway. // WebhookAddr is the host:port for the inbound webhook gateway.
// Empty disables the webhook gateway. // Empty disables the webhook gateway.
WebhookAddr string `toml:"webhook_addr" yaml:"webhook_addr"` WebhookAddr string `toml:"webhook_addr" yaml:"webhook_addr"`
Telegram TelegramConfig `toml:"telegram" yaml:"telegram"` Telegram TelegramConfig `toml:"telegram" yaml:"telegram"`
} }
// TelegramConfig configures the Telegram Bot API channel. // TelegramConfig configures the Telegram Bot API channel.
@@ -528,9 +528,7 @@ func finalize(cfg Config) (Config, error) {
if cfg.PollInterval == 0 { if cfg.PollInterval == 0 {
cfg.PollInterval = Duration(60 * time.Second) cfg.PollInterval = Duration(60 * time.Second)
} }
if cfg.Label == "" {
cfg.Label = ""
}
if cfg.DiffCapLines == 0 { if cfg.DiffCapLines == 0 {
cfg.DiffCapLines = 400 cfg.DiffCapLines = 400
} }
+4 -1
View File
@@ -11,7 +11,7 @@ import (
) )
// knownFeatureNames is the set of recognised config.<name>.yaml feature files. // knownFeatureNames is the set of recognised config.<name>.yaml feature files.
// Any config.<name>.yaml file whose <name> is not in this set is rejected -- // Any config.<name>.yaml file whose <name> is not in this set is rejected --
// silent ignores would hide typos. // silent ignores would hide typos.
var knownFeatureNames = map[string]bool{ var knownFeatureNames = map[string]bool{
"gateway": true, "gateway": true,
@@ -189,6 +189,9 @@ func loadDirInto(cfg *Config, dir string, requireMain bool) error {
// under a "memory:" or "tools:" key -- decode those into their target // under a "memory:" or "tools:" key -- decode those into their target
// sub-struct directly. // sub-struct directly.
func loadFeatureFile(cfg *Config, feature, path string) error { func loadFeatureFile(cfg *Config, feature, path string) error {
if cfg == nil {
return fmt.Errorf("config must not be nil")
}
data, err := os.ReadFile(path) data, err := os.ReadFile(path)
if err != nil { if err != nil {
return fmt.Errorf("reading %s: %w", path, err) return fmt.Errorf("reading %s: %w", path, err)
+3
View File
@@ -213,6 +213,9 @@ func (r *Router) handleSpawn(ctx context.Context, title string) (string, error)
} }
func (r *Router) handleStatus(ctx context.Context) (string, error) { func (r *Router) handleStatus(ctx context.Context) (string, error) {
if r.Store == nil {
return "store not configured", nil
}
counts, err := r.Store.StatusCounts(ctx) counts, err := r.Store.StatusCounts(ctx)
if err != nil { if err != nil {
return "", fmt.Errorf("status: %w", err) return "", fmt.Errorf("status: %w", err)
+11 -3
View File
@@ -96,6 +96,8 @@ func (s *nellSessionStore) Save(ctx context.Context, sc SessionContext) error {
} }
func (s *nellSessionStore) Get(ctx context.Context, sessionID string) (*SessionContext, error) { func (s *nellSessionStore) Get(ctx context.Context, sessionID string) (*SessionContext, error) {
s.mu.Lock()
defer s.mu.Unlock()
doc, err := s.db.Get(ctx, sessionID) doc, err := s.db.Get(ctx, sessionID)
if err != nil { if err != nil {
if errors.Is(err, sdk.ErrNotFound) { if errors.Is(err, sdk.ErrNotFound) {
@@ -108,7 +110,9 @@ func (s *nellSessionStore) Get(ctx context.Context, sessionID string) (*SessionC
} }
func (s *nellSessionStore) GetByChannel(ctx context.Context, platform, channelID string) ([]SessionContext, error) { func (s *nellSessionStore) GetByChannel(ctx context.Context, platform, channelID string) ([]SessionContext, error) {
all, err := s.listAll(ctx) s.mu.Lock()
defer s.mu.Unlock()
all, err := s.listAllLocked(ctx)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -151,7 +155,9 @@ func (s *nellSessionStore) Touch(ctx context.Context, sessionID string) error {
} }
func (s *nellSessionStore) List(ctx context.Context) ([]SessionContext, error) { func (s *nellSessionStore) List(ctx context.Context) ([]SessionContext, error) {
return s.listAll(ctx) s.mu.Lock()
defer s.mu.Unlock()
return s.listAllLocked(ctx)
} }
func (s *nellSessionStore) Close() error { func (s *nellSessionStore) Close() error {
@@ -160,7 +166,7 @@ func (s *nellSessionStore) Close() error {
// ── Internal helpers ─────────────────────────────────────────────────────── // ── Internal helpers ───────────────────────────────────────────────────────
func (s *nellSessionStore) listAll(ctx context.Context) ([]SessionContext, error) { func (s *nellSessionStore) listAllLocked(ctx context.Context) ([]SessionContext, error) {
result, err := s.db.AllDocs(ctx, sdk.DocRange{IncludeDocs: true}) result, err := s.db.AllDocs(ctx, sdk.DocRange{IncludeDocs: true})
if err != nil { if err != nil {
return nil, fmt.Errorf("sessionstore: list: %w", err) return nil, fmt.Errorf("sessionstore: list: %w", err)
@@ -266,6 +272,8 @@ func (s *nellSessionStore) SaveMessage(ctx context.Context, sessionID string, ms
} }
func (s *nellSessionStore) RecentMessages(ctx context.Context, sessionID string, n int) ([]Message, error) { func (s *nellSessionStore) RecentMessages(ctx context.Context, sessionID string, n int) ([]Message, error) {
s.mu.Lock()
defer s.mu.Unlock()
prefix := sessionID + ":" prefix := sessionID + ":"
result, err := s.msgDB.AllDocs(ctx, sdk.DocRange{ result, err := s.msgDB.AllDocs(ctx, sdk.DocRange{
StartKey: prefix, StartKey: prefix,