Commit Graph
2877 Commits
Author SHA1 Message Date
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 6532537e24 chore(beads): sync issue export 2026-08-04 01:45:39 +10:00
sam 4d44ef76f5 feat(webui): rebuild the dashboard
The old UI was a single 200-line Go file serving one hand-written HTML
page of task rows. It showed that archied was running and almost nothing
about what it was doing -- skills, workflows, memory, channels, logs and
configuration were all invisible unless you read the source or the
config file.

The dashboard now covers each of those as its own section, built as a
Vite app under ui/ at the repo root: it is a separate artefact from the
Go daemon, not an internal package of it. dist/ is committed so building
archied never needs a Node toolchain, and the !no_ui build tag keeps an
embed-free build available.

Both sides are split by concern rather than by layer -- one Go file per
API area, one folder per UI section with its own CSS -- so a change to
logs cannot disturb tasks.

Pages report consequences, not just state: an empty memory page says
Archie starts every conversation with no recollection of earlier ones,
and the setup checklist names what is missing in plain language instead
of showing a grid of zeroes. Nothing greets by a hardcoded name; the
operator comes from [chat], which is deployment data.

Auth is exposure control, not capability control -- the agent already
holds this user's authority through its own tools. So a loopback bind
needs no token, and only a reachable bind mints one and logs a URL,
which means an instance cannot be exposed merely by omitting config.

Container startup now degrades instead of aborting, for the reason
resolveForge already does: a missing agent image should not deny the
operator chat and the dashboard, and under Restart=on-failure it turns a
recoverable problem into a crash loop with the real error scrolling past.

`task dev` runs the daemon under air and the Vite server together in one
terminal.
2026-08-04 01:45:36 +10:00
sam 449c925f29 feat(logging): optional rotating log file
Under systemd, journald held the only copy of archied's output, and
running it by hand left no record at all -- so "where are the logs?" had
no good answer, and the dashboard had no history to show from before it
connected. [log] adds a file destination alongside stderr, with
size-based rotation and retention done in-package rather than pulling in
a dependency for a few hundred lines.

A file that cannot be opened is reported and the daemon continues on
stderr: losing the durable copy is not worth refusing to start over.

reader.go owns the on-disk format so nothing else has to parse it, and
bounds every read -- tailing keeps the newest entries within a fixed
scan window, so pointing it at a large file cannot exhaust memory.
2026-08-04 01:44:56 +10:00
sam cbe02c1e6b fix(telegram): pause the update loop when rate limited
go-telegram/bot retries a 429 immediately and only then grows its own
backoff, so a rate-limited daemon kept hammering getUpdates and stayed
limited. The pipeline error handler now reads Telegram's own RetryAfter
and waits it out, capped at a minute so a hostile value cannot park the
loop indefinitely, and cancellable so shutdown is not held up.
2026-08-04 01:44:31 +10:00
sam 0814f7b9b4 fix(gateway): give messages durable identity and a SQLite store
Three defects shared one root cause -- messages had no identity of their
own, so the store could not tell a redelivery from a new message:

- SaveMessages destroyed history. Writing a batch replaced records that
  a concurrent write had already stored, and earlier messages vanished.
- A redelivered channel message overwrote the stored one, contradicting
  the append-only sequence in docs/architecture/messaging-and-work-intake
  .md:112-114.
- /compress stranded whatever exceeded one page: deleting 1200 reported
  1000 deleted and left 200 behind.

Messages now carry an application-generated MessageID, derived from
(session, source id) so a redelivery lands on the same record, and
stored records are immutable -- a repeat write is a no-op rather than an
overwrite. SourceID keeps the channel-native id for correlation without
being load-bearing. _ts is written as Unix milliseconds and clamped
monotonic per session: Telegram dates are whole seconds, so replies
arriving inside the same second would otherwise order arbitrarily.
Deletes page with a cursor instead of assuming one page holds everything.

Adds a SQLite session store behind the same interface, per
docs/architecture/messaging-and-work-intake.md:107. A shared conformance
suite runs all 19 groups against both implementations, so the two cannot
drift while the NellDB path is still the one wired up.
2026-08-04 01:44:26 +10:00
sam 7d7d03191f fix(store): surface task timestamps and tag the summary structs
Task carried no created/updated times, so the dashboard had nothing to
sort or age a queue by. Both columns already existed in the schema and
are now scanned through; SQLite returns them as strings in several
shapes, so sqliteTime does the parsing in one place rather than at each
of the five call sites.

WorkflowStat, StageStat and DayTokens had no JSON tags at all, so
/api/summary answered {"Day":...,"Tokens":...} while the dashboard read
d.tokens -- every sparkline would have plotted zero.
2026-08-04 01:44:10 +10:00
sam efa7e65755 perf(tools): drop the embedded ripgrep binaries
The rg package carried three platform binaries (14MB) inside the Go
binary and extracted the matching one to a temp file on every single
run, so a long-lived daemon left a trail of copies behind and paid the
write on each grep. Nothing depended on ripgrep's own output format.

grep now uses the Go implementation unconditionally.
2026-08-04 01:44:03 +10:00
sam bb77f88f73 fix: message history ordering and paged search
- Add Message.At timestamp as the ordering key, stamped at save when zero
- Store each session's messages in its own collection with time-ordered IDs
- Fix bulk saves overwriting history and sequence reuse after deletes
- Walk past NellDB's internal scan limit for history and deletes
- Add paged SearchMessages (MessageQuery/MessagePage) with truncation reporting
- Drop a session's message collection when the session is deleted
2026-08-03 19:08:40 +10:00
sam cfec693716 chore: update NellDB to v0.3.0
- Add .pi-subagents/ to gitignore
2026-08-03 19:08:10 +10:00
sam c7f060584b chore(beads): close archie-core-ci3, add b4i task 2026-08-03 19:07:49 +10:00
sam ef8856872c chore(release): archied v1.4.1 2026-07-31 08:48:49 +10:00
sam 76f6299f22 fix(catalog): match SDK provider fallback 2026-07-31 08:48:38 +10:00
sam e71fc92364 chore(release): archied v1.4.0 2026-07-31 08:46:23 +10:00
sam 3ae59c99c0 fix(secrets): wire provider credentials through engines 2026-07-31 08:45:58 +10:00
sam 059eee412c chore(release): archied v1.3.1 2026-07-31 03:47:42 +10:00
sam b571b207af chore: sync issue export 2026-07-31 03:47:33 +10:00
sam cc1d929db7 fix(telegram): omit empty model picker markup 2026-07-31 03:47:08 +10:00
sam 272f61e166 chore(release): archied v1.3.0 2026-07-31 03:43:41 +10:00
sam 2307c8c81a feat: unify provider and model selection 2026-07-31 03:40:03 +10:00
sam 8ea6367ee0 chore: remove stray Tau CLI manual from archie-core docs
docs/ is the archie-core VitePress site (Archie-branded, see index.md).
This README.md was a Tau reference manual that was never linked from the
site index and doesn't belong in this repo.

The tau references in internal/tools/builtin/ are legitimate attribution
headers — those files were deliberately lifted from tau with source
commit hashes.
2026-07-31 02:21:49 +10:00
sam 782ba5b525 fix(memory): replace hermes-specific names with generic equivalents
SaveConfig's hermesHome parameter and HERMES_HOME references in comments
were copied from another project. The interface and its callers are
entirely internal to archie-core (no external call sites exist outside
tests), so renaming them is safe.

hermesHome -> dataHome
HERMES_HOME -> data directory
/tmp/hermes -> /tmp/archie-test
2026-07-31 02:19:50 +10:00
sam 6c32550345 chore: replace personal owner names in tests and config with generic values
Test fixtures used 'sam', 'samcharles93', and 'sam/<repo>' as owner
names. These are personal and machine-specific — the repo should use
generic placeholders like 'acme' (matching the existing convention in
worktree_test.go).

config.example.toml: samcharles93 -> your-github-username
Test owner: sam -> acme
Repo refs: sam/archie-core -> acme/archie-core, etc.
Example skills: sam -> acme
2026-07-31 02:15:41 +10:00
sam 82b420520a chore: trim CLAUDE.md to what an agent actually needs
Three per-package traps (telegram polling, task.json path, MCP hard-fail).
Five deployment facts (host daemon, gateway NATS, pull_policy, agent
profile, config location). Release process. Dropped the history notes,
binary-extraction recipe, .dockerignore and GOTMPDIR bullets.
2026-07-31 02:11:03 +10:00
sam 4484028111 chore: trim the sensors bullet from CLAUDE.md
It's gone from the tree; no agent would try to recreate it, and
documenting it as a memory is a waste of tokens.
2026-07-31 02:10:05 +10:00
sam 8c6cf128f5 chore: document deployment, release process, and add CI gate
CLAUDE.md now describes the host+container deployment model, release
workflow, and per-package traps agents need to know about (no sensors
package, WriteTaskJSON path, long-polling drop, MCP provider hard-fail,
.dockerignore, GOTMPDIR).

CI (deploy.yml) gains a gate job that runs before the image builds:
the quality gate (fmt, vet, build, test), then a check that every
release tag at HEAD has a matching [version] section in its changelog.
A tag without a changelog entry fails the build. No tags at HEAD prints
a warning — images get stamped 'dev'.
2026-07-31 02:08:57 +10:00
sam db8352744b fix(deploy): correct pull_policy in the docker-nats-stack template
'always' against a private registry answers 401 because the daemon
calls ImagePull with no credentials. The live config already uses
'missing'. This just brings the template in line.
2026-07-31 02:04:48 +10:00
sam 367b89e5ee chore(deploy): run archied on the host, keep NATS and agents in Docker
The chat agent's file tools operate on host paths, so the daemon has to
see the host filesystem. It keeps spawning agent containers through the
Docker socket and talking to NATS, so compose still carries the bus and
the network; archied and watchtower leave it.

Pins the network subnet: the daemon hands agent containers its own
nats.url verbatim, so that URL has to work from the host and from inside
a container. The gateway address does; a Docker-assigned subnet would
move it silently when the network is recreated.
2026-07-31 02:00:11 +10:00
sam fd1abdd6c8 fix(deploy): stop the agent stanza starting, and pull agent images
The agent service created a container that exited 0 immediately while
compose reported it as "Started", which reads like a crash loop. A build
profile keeps it out of `up -d`; naming it still works for build and pull.

containers.pull_policy was "if-not-present", which is not a recognised
value -- the pool pulls only when it is "always" or "missing", so the
typo disabled pulling outright and the deployed agent image drifted a day
behind the daemon. Watchtower cannot cover for it: agent containers are
spawned per task, and it only restarts long-running ones.
2026-07-31 01:51:19 +10:00
sam 34232c75d9 chore(release): archied v1.2.0 archie v1.2.0 2026-07-31 01:35:33 +10:00
sam c91f373879 chore: add task release for changelog generation and tagging
The changelogs said 1.1.0 while 116 commits sat untagged on main, and
the deploy workflow stamps images 'dev' when no tag points at HEAD.

Two steps, so generated notes can be edited before a tag freezes them:
release:prepare writes them, release commits and tags. Which commits
land in which changelog is decided by each binary's package closure
(go list -deps), so a change to a package archied does not import
cannot show up in archied's changelog.
2026-07-31 01:33:08 +10:00
sam 75e30cb18a fix(telegram): drop pending updates before long polling
After the daemon was down ~9 hours it booted and answered every message
sent while it was gone -- 8 stale messages, 8 LLM turns, one burst.

Telegram holds undelivered updates for 24h and replays them on the first
getUpdates. launch()'s webhook branch already passes DropPendingUpdates;
the long-polling fallback had no equivalent, and polling is what this
deployment uses. deleteWebhook carries the flag even when no webhook is
registered -- the same call python-telegram-bot makes when it starts
polling -- and it doubles as a guard against a stale webhook, which
would otherwise fail getUpdates with 409.

Bounded by a 10s deadline so an unreachable Telegram cannot hold up
gateway startup.
2026-07-31 01:33:02 +10:00
sam f4bf755727 chore: untrack build artefacts and local agent tooling
None of these belong in the repo, and .gitignore already said so for
three of them -- adding a pattern does not untrack what is already
committed.

- .codex/: bd init's Codex hook wiring, local tooling
- .references/skills-implementation.md: one stray from an ignored dir
- task.json: a runtime artefact, not config. The daemon writes one per
  task into the container's worktree mount; this was a leftover brief
  for issue #57 that an agent committed from its own checkout.
- archie-agent: a 50MB host-built binary. /archied was ignored but
  /archie-agent was not.
2026-07-31 01:13:30 +10:00
sam 3ee3bcf202 chore(deploy): commit the compose stack, drop the required overlay
docker-compose.yml was never committed -- it only existed on the
deployment host. It bind-mounted ./config.docker.toml and passed
-config-overlay unconditionally, which made an untracked repo-root
file load-bearing: Docker creates a directory when a bind source is
missing, and the loader rejects a directory, so a fresh clone took the
daemon down at boot.

The stack now passes a single -config pointing at a path outside the
repo. Nothing in the working tree is required at runtime. The
docker-specific values move to deployments/docker-nats-stack.toml as a
reference config, alongside the other deployment guides.

Also drops the ./:/workspace mount, which existed only for
desktop-commander's work_dir.
2026-07-31 01:13:23 +10:00
sam bc5d8dcdc9 test: drop tests that grep source text instead of behaviour
These asserted on file contents rather than what the code does:
Dockerfile strings, deploy.yml YAML, CHANGELOG headings, and greps of
main.go for identifiers. Two also referenced config.docker.toml and
docker-compose.yml, which were never committed, so they could not pass
at all.

The worst compared strings.Index byte offsets in main.go to assert
startup ordering -- it would pass on code that never runs and fail on
a correct refactor that moved a line.
2026-07-31 01:13:16 +10:00
sam 4c0a06df6d fix(container): write the task boot brief under .git
WriteTaskJSON wrote task.json to the worktree root -- the same worktree
the agent commits from. CommitAll stages with go-git's All option, and
go-git's Add does not honour .gitignore or .git/info/exclude, so the
brief was swept into the agent's commit and pushed onto every task
branch. That is how a task.json for issue #57 ended up committed in
the repo root.

This is the identical failure the prepared sentinel hit; worktree.go
already documents the fix. Nothing under .git can ever be tracked, so
put the brief there rather than papering over it with an exclude.
2026-07-31 01:13:08 +10:00
sam 10775e5edf fix(docker): slim both images and repair unreachable Go tooling
archie-agent 3.92GB -> 1.43GB, archied 475MB -> 251MB.

- rm -rf /go/pkg/mod/cache cleared the wrong thing: it left the
  extracted module sources and the whole GOCACHE in the image, so that
  layer was 2.23GB to deliver 168MB of binaries.
- /go/bin was never on PATH, so golangci-lint, gofumpt, buf and dlv
  shipped as unreachable dead weight.
- Replace go install with pinned upstream release binaries. delve is
  dropped: it publishes no prebuilt binary and was the only thing
  forcing a compile step. go install it at runtime if needed.
- beads from its Go release rather than npm, and drop dolt entirely --
  bd runs Dolt embedded.
- uv manages Python; no apt Python, no deadsnakes, one version.
- debian:trixie-slim base, Node copied from node:24-trixie-slim.
- archied drops Node: the builtin tools cover what desktop-commander
  did, and archied registers MCP providers itself and hard-fails the
  process when one cannot start.

Add .dockerignore: the build context was shipping .git, docs/, bin/
and two host-built binaries into every COPY.
2026-07-31 01:13:02 +10:00
sam 19d8bec69b fix: remove orphaned sensors package and its dangling route
The revert in ed61ce3 removed handleSensors but left the route
registration pointing at it, so cmd/archied did not compile. The
sensors package itself was left behind fully orphaned -- nothing in
the repo referenced it. There is no sensor monitoring in this app.
2026-07-31 01:12:52 +10:00
sam 5310de21f6 chore: add issue for MCP servers re-fetch on every daemon start 2026-07-30 22:42:41 +10:00
sam e7e029440d beads: file MCP provider failure isolation and npm refetch issues 2026-07-30 22:42:16 +10:00
sam be4e9f596c fix(docker): install unzip and Node 24 so MCP servers can start
archied crash-looped on startup: mcp.desktop-commander failed with
"transport closed while waiting for response", which failed the whole
tool-provider family and exited the daemon.

The proximate cause was a missing unzip. desktop-commander depends on
puppeteer, whose postinstall extracts a downloaded browser and aborts
with "no zip archiver is available" without it, so npx exited before
writing a byte. Node also moves to 24 from nodesource, matching the
worker image: Ubuntu 24.04 ships Node 18 and several of the server's
transitive dependencies require >=20 or >=22.

Verified in the built image: npx now completes an MCP initialize
handshake and exits 0.
2026-07-30 22:42:16 +10:00
sam b2c30352f8 chore: cleanup 2026-07-30 16:22:36 +10:00
sam ed61ce32d1 Revert "feat: add /api/sensors endpoint and watchdog cron"
This reverts commit 03ef6fdcbae33f5a0c2f7681b63782aa76fdc71e.
2026-07-30 16:13:51 +10:00
sam 49305e06d9 feat: add /api/sensors endpoint and watchdog cron 2026-07-30 16:13:51 +10:00
sam f4074b6335 feat: add /api/sensors endpoint and watchdog cron 2026-07-30 16:13:51 +10:00
sam cbb7929ea6 fix: use msg.Reply instead of header for NATS reply-to 2026-07-30 16:13:51 +10:00
sam 8a8caa1ca7 fix: silence a staticcheck directive false alarm and file remaining lint debt
configtemplate's package comment explained the module-root placement by
naming the embed directive in prose, which staticcheck reads as a
malformed directive (SA9009). Reworded, with a note saying why.

Found by running golangci-lint repo-wide while auditing 6108fc5, which
also showed that archie-core-qa4 reports 4/4 phases complete and offers
to close while 56 findings remain. Filed as archie-core-qa4.5 so the
epic's completion count reflects the gate rather than the phase list;
qa4.5 depends on archie-core-ts9, because the nilerr findings in grep.go
are the same swallowed-error bug and fixing them mechanically would
change tool behaviour.
2026-07-30 02:27:25 +10:00
sam 14be7c5567 feat: embed config.example.toml and add comment-preserving TOML writer
Groundwork for archied setup owning config generation (archie-core-ewk),
so install.sh stops emitting a second copy of the config that drifts from
the example operators actually read.

configtemplate lives at the module root because go:embed cannot reach
outside its own directory and config.example.toml is kept at the root
where it is easy to hand-edit. tomlwrite applies setup answers to that
template in place, preserving the comments that make the generated file
readable - BurntSushi/toml round-trips values but not comments, so
re-encoding a decoded document would strip them.
2026-07-30 02:24:20 +10:00
sam 3b2e7949ed fix: restore /model parsing and close the 6108fc5 autofix audit
The nestif extraction in 712388d pulled --provider handling out of
parseModelRest into a helper that took modelParts by pointer and
appended every surviving field to it. The caller's own loop appended
the same fields again, so every model name was doubled: /model gpt-5.6
asked the router for "gpt-5.6 gpt-5.6" and SetActiveModel rejected it
as unknown. The index loop becoming a range loop also stopped the
space-separated "--provider openai" value being consumed with its flag,
so it landed in the name too. Direct model switching over Telegram was
broken for everything but --refresh and provider-only switches.

splitProviderFlag is now the sole accumulator and returns the surviving
fields, so the shared-slice shape that allowed the double append cannot
recur (archie-core-0d6).

Found while auditing the remaining hunks of 6108fc5 (archie-core-ifi):
the naked return in the same function could not be regression-tested
until the function produced correct values. That audit is complete and
the other seven hunks are behaviour-neutral. Notably shell.go's
errorlint rewrite is not a repeat of the grep failure - it had no
companion exit-code condition to drop, and the ctx.Err() timeout check
already runs first - and find.go's errors.Is rewrite is safe because
errors.Is(err, nil) is false for any non-nil err.

Tests cover the return order of parseModelRest (two strings and three
bools, so a transposed pair compiles silently), the field count of the
model name, and shell's exit-code branch, which had no coverage at all.
The find fallback's habit of reporting a cancelled walk as "no matches
found" is filed as archie-core-ts9.
2026-07-30 02:24:10 +10:00
sam 3c9c35c7c9 beads: file outstanding install/lint issues, SOUL epic, and session learnings 2026-07-30 02:11:05 +10:00