/branch copies the parent's history into the child. Because the store
honours an incoming MessageID -- which is what lets a read-modify-write
preserve identities -- the copies kept the parent's canonical IDs, so
two sessions claimed one identity and branch-point correlation was
ambiguous. Two branches from one parent made it three. It also broke
dedup in the child: an inherited message carried an ID derived from the
parent's session, so redelivering it appended (confirmed on both
backends: 3 messages became 4).
newMessageID's doc already claimed the opposite behaviour, and the
Message.MessageID doc said it was "ignored on write" -- which is exactly
the misreading that produced this. Both now describe what the code does,
including the obligation on a caller copying messages between sessions.
Also removes a doc comment describing msgID and its disambiguating
counter, deleted in 0814f7b, which had come to sit above
messageIDNamespace describing the opposite of the current design; and
corrects the Telegram comment still claiming a redelivered update
"updates the stored turn", the behaviour the immutability fix removed.
Refs archie-core-la1
Making the store idempotent stopped redelivery duplicating the inbound
record, but nothing consulted that result: respond() saved the message,
ignored the fact that nothing had changed, and called the model anyway.
The cost was a second billed turn, any tool side effects run a second
time, and a second assistant reply appended -- replies carry no upstream
reference, so they always get a fresh identity and always append. The
stated problem, "a re-delivered update appends a duplicate turn", was
only half fixed.
PriorReply answers "have I already replied to this?" from the history
the caller has already loaded, and the chat path replays that answer
instead of regenerating it. A message with nothing after it was never
answered -- the turn may have died partway -- so that still runs, since
the user is owed a reply.
CanonicalMessageID exposes the store's own derivation rather than
letting the caller reimplement it, since a lookup that silently never
matches is indistinguishable from a message never seen.
Refs archie-core-i6q
applyCompress reads the history, computes a summary, then replaces it.
ReplaceMessages removed everything outside the replacement set, so a
chat turn saved in that window was deleted without ever having been
read, let alone summarised. Confirmed on both backends. It is
unrecoverable loss, and it sits outside the write-then-delete guarantee
because the window is in the caller, not the store.
ReplaceMessages now takes the messages the caller is superseding instead
of inferring them from the complement of the replacement. A caller
computes a replacement from a history it read; anything that arrives
afterwards is not part of that, and is now left alone. IDs in both lists
are still kept, so read-modify-write callers are unaffected.
The test fake's ReplaceMessages was a slice assignment, which could not
observe ordering or identity at all -- it now mirrors the real stores.
Refs archie-core-6e0
resolve saved a newly created session to the store and only then asked
the cache who had won a concurrent race. The loser had already persisted
a session that nothing pointed at: unreachable, but still listed by
/topic and /sessions as "(untitled)", and -- now that resolution goes by
recency -- resurrectable on a later restart. Confirmed by forcing the
interleaving: the store held 2 sessions where it should hold 1.
The claim now happens under the same double-check, ahead of the store
write, so only the winner writes. A failed Save releases the claim, or
the cache would point every later message in that chat at a session that
was never stored.
Refs archie-core-x35
handleTopic "off" copied the thread's active session onto the flat key
via setActive(getActive(...)). With nothing cached for that thread it
copied the empty string, and resolve treats map presence as
authoritative -- so it returned "" from then on, permanently, since
cacheActive also returned the empty existing value. Every later message
in that chat persisted under session "", history was shared with any
other poisoned chat, and the turn-lane key became "" so /stop in one
chat cancelled a turn in another.
Reachable as a first message on the webhook and email channels, which
call Route directly without resolving a session first.
setActive now rejects an empty session ID, so no caller can poison the
map whatever it computes, and resolve and cacheActive treat an empty
cached value as a miss so an existing entry repairs itself.
The get-then-set was also two critical sections, silently clobbering a
concurrent /resume or /branch with the value read before the switch.
flattenTopic does it in one.
Refs archie-core-jex
resolve's comment claimed to find "the most recent session matching this
thread and bot" and took whichever the store returned first. On the
NellDB store that is document order -- by session ID -- so it was
effectively arbitrary. The tracker cache is in-memory, so every restart
re-resolves from the store, and the operator could be dropped back into
a session they had left with /new, answering against pre-/new history.
Probed over 10 restarts, 4 landed in the older session. LastActiveAt was
populated on every record and never read.
resolve now picks by LastActiveAt, which also makes it independent of
the two backends disagreeing: SQLite's GetByChannel orders created_at
DESC and NellDB's did not, and the conformance suite did not pin it.
listAllLocked reversed document order and passed that off as recency,
so List -- documented newest-first, and what /sessions and the dashboard
render -- returned reverse-lexicographic order. It now sorts on
LastActiveAt, falling back to CreatedAt for records never touched.
Refs archie-core-7s3
Two defects, both confirmed on the NellDB and SQLite backends.
IDENTITY. applyCompress rebuilt the protected head and tail as bare
Message{From, Text}, so every message that survived a compression was
deleted and re-inserted with a fresh canonical MessageID, no SourceID
and a timestamp of now. A rebuilt message is a different message: after
one compression, redelivery deduplication was broken for the rest of the
session's life, so a Telegram backlog replay after a restart appended
every surviving message a second time -- 24 became 25 on a redelivery
that was a correct no-op beforehand. That made the dedup guarantee
survive only until the first /compress, and violated
messaging-and-work-intake.md:88-90 and 112-114.
CompressHistory now reports which input messages it protected and the
write-back carries those originals through untouched, so only the
summary is a new record. The summary is attributed to the bot rather
than falling through to "user": CompressHistory emits it with role
"system", which has no representation in the store, so the model was
replaying "[Earlier conversation has been summarised...]" as if the
human had typed it.
DISPATCH. Three ways to rewrite a history the operator did not ask to
rewrite, or to fail to rewrite one they did:
- Bare /compress took the preview branch, and the preview closes with
"Run /compress to apply" -- the documented way to compress could never
compress, and the failure-safe path was unreachable.
- /compress focus <topic> discarded the topic and ran a full default
compression. Nothing implements focused summarisation; it now says so
instead of doing something else irreversibly.
- /compress here (no count) and any typo fell through to a full
compression. Both now print usage.
compressPreview also read a fixed 200-message window while reporting the
real count, so the two numbers in one sentence described different
conversations and it advised against compressions that were needed.
Refs archie-core-cz8, archie-core-8k8, archie-core-le6
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
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
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.
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.
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.
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.
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.
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.
- 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
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.
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
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
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'.
'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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.