Commit Graph
7 Commits
Author SHA1 Message Date
sam 0d4d045050 fix(memory): fall back to the default directory instead of exiting
d615de5 made an unusable memory directory fatal. That was the wrong
call and contradicts the forge and container paths: memory is one
capability among many, and refusing to start over a path denies the
operator chat, the dashboard and everything else -- then crash-loops
under Restart=on-failure with the real error scrolling past unread.

builtin.New now reports an unusable directory through IsAvailable and
Err rather than failing, so the caller decides. The daemon warns and
falls back to the location an unset work_dir would have produced, which
is where someone who copied a config from another host will look. If
that is unusable too it says what the operator loses -- no recollection
between conversations, and failing writes -- and carries on.

The provider stays readable while degraded, so a bad path reads as an
empty memory rather than breaking mid-conversation, and the dashboard's
memory page already renders IsAvailable so this is visible there.

Also fixes a defect the fallback test caught: an empty work_dir made
filepath.Join produce the relative path "memory", which MkdirAll
creates wherever the daemon was started from -- succeeding, and putting
memory somewhere nobody would look.

Refs archie-core-rml
2026-08-04 02:13:05 +10:00
sam d615de5c99 fix(memory): fail startup on an unusable memory directory
Both stores treat a missing file as an empty document, so a memory
directory that does not exist looked exactly like a memory with nothing
in it yet. archied logged "memory manager started" and ran with no
memory at all; the failure would have surfaced at the agent's first
write, as a tool error mid-conversation, long after startup said it was
fine.

Found live: a config copied from carina kept work_dir=/var/lib/archie
/work, a container path with no counterpart on the host.

New now establishes the directory and reports a path it cannot use, so
the existing error path exits at startup where an operator can see it.

Refs archie-core-rml
2026-08-04 02:00:12 +10:00
sam 712388dc6c fix: Phase 4 structural refactor — reduce lint findings from 28 to 5
cyclop (5→0): extract subcommand/case bodies in codesearch,
subprocess, Telegram, indexing
funlen (5→3): extract memory action handlers, tool provider startup
gocognit (7→2): extract config finalize/loadDirInto helpers, release
announcer, capture tool validation, Telegram gateway (200→108),
archie-agent main loop (35→0)
nestif (8→0): extract identity validation, container validation,
conf.d scanning, email multipart parsing, Telegram model/update
parsing, build-no-changes closure
interfacebloat (3→0): split Forge/IssueForge/PRForge/RepoForge,
SessionStore/SessionLifecycle/MessageHistory,
TaskStore/TaskLifecycle/TaskQueries/TaskEvents

Remaining: daemon process, workflow Feasibility/TDD/AgentStage,
archied main.go run (108→30 remaining). These require deeper
refactoring best done per-function in follow-up beads.

Updated contract tests and archied wiring tests to check both
main.go and the new telegram_setup.go.
2026-07-29 10:15:22 +10:00
sam 4ee8579ddc refactor: phase 2 of lint remediation — mechanical fixes (qa4)
130 -> 96. forcetypeassert, predeclared and usetesting are now at zero.

Fanned out across four isolated worktrees partitioned by package so no
two workers could touch the same file: internal/tools (20 assertions),
internal/webui, internal/memory + internal/ratelimit, internal/secret.
Four stragglers outside those scopes fixed inline (internal/pairing,
internal/forge, internal/channels/telegram, internal/tools/mcp).

Unchecked type assertions became comma-ok with a t.Fatalf naming the
actual type. One site in a goroutine uses t.Errorf + return instead,
since t.Fatalf from a non-test goroutine is undefined behaviour.

predeclared renames chose names from meaning rather than adding a
suffix: max -> maxQueryLen, maxMatchLen, maxRequests, alphabetLen, and
nextBackoff's max -> ceiling. `real` -> `base` in the webui tests.

os.Setenv became t.Setenv, which restores on cleanup, so the paired
deferred Unsetenv calls went with it.

Note for future fan-outs: the agent worktrees branched from origin/main
(a7388a0), not from this branch, so every diff arrived based on a tree
without the phase 1 autofix. They were applied with `git apply --3way`
and the phase 1 changes to internal/memory/manager.go were verified to
survive — in particular the repaired `ctx, cancel =` assignment. A plain
`git apply` would have silently reverted it.
2026-07-28 01:37:20 +10:00
sam f6d51416f0 chore: replace 607 em-dashes with double hyphens project-wide
Includes MCP crash-after-init test fix (crash moved from handle() to serve()
entry point so transport sees immediate subprocess death).
2026-07-26 09:53:33 +10:00
sam 52cc8f8a14 feat: memory P1 — sync pipeline, prefetch, notify, frozen snapshot, threat scanning, shutdown drain (18.7-18.9, 18.14-18.16)
sync.go — background serialized writer (single goroutine) for async
memory writes. Prefetch with 8s timeout per provider.

scanner.go — threat pattern scanning for memory content.

manager.go — notify_memory_tool_write bridging built-in writes to
external providers. Shutdown drain with 5s timeout.

All 6 impl + 6 verify beads closed. Memory epic complete.
2026-07-26 09:22:12 +10:00
sam 942deb9336 feat: built-in file-backed memory tool (18.12, 18.13)
internal/memory/builtin/provider.go — MemoryProvider backed by
MEMORY.md + USER.md files. LLM-callable memory tool with
add/replace/remove actions using section-sign delimited entries
and substring matching.

internal/memory/builtin/store.go — file read/write with atomic
replace and chmod 0600.
2026-07-26 08:58:27 +10:00