Part of archie-core-1786637499480 (ship the file-writing store as the
default memory engine).
Records the missing design decision first (migration-decisions.md#5,
"authoritative memory record and revision model" was explicitly open):
internal/memory/builtin.Store addresses blocks by content substring with
no stable per-block ID, which the new Record{ID}/Forget(id) contract
needs. Decided and implemented: an ID assigned once at Write via a
leading `<!--mem:<uuid>-->` marker line, stripped back out of
Record.Content on read, located by that marker (not content) for
Forget -- so an unrelated edit can never orphan a Forget. Identity maps
to a directory named hex(sha256(identity)), not the identity string, so
an arbitrary identity can never traverse outside the configured root.
Kind maps to a builtin section name via the store's own
ValidateSectionName, so an invalid Kind fails the same way an invalid
section already does.
internal/infrastructure/memory.BuiltinEngine wraps one builtin.Store per
identity and implements domain/memory.MemoryEngine end to end
(Write/Query/List/Forget, Lifecycle, Manifest). Lives under
internal/infrastructure per organisation.md ("infrastructure implements
domain contracts"), not internal/domain/memory, which stays
contract-only.
internal/memory/builtin is untouched -- confirmed via git status and its
own test suite passing unmodified, per this issue's acceptance
criterion. This engine is not yet wired into daemon bootstrap or the
config surface (archie-core-1786637490043); it proves the contract
holds for the builtin store the same way curator's reference
implementations prove the curator contract, and registers/runs cleanly
through domain/memory.Registry (TestBuiltinEngineRegistersAndRuns
ThroughTheRegistry).
Part of archie-core-1786637490069-11-e245c170 (memory engine contract
and owning registry), under epic archie-core-1786637499161 (pluggable
memory engine).
Stands up internal/domain/memory as a conforming engine family per the
strict plugin engine rule, mirroring internal/domain/curator's split
exactly as that issue's notes specify:
- contract.go: MemoryEngine (Lifecycle + Store + identity + Bind), with
Store carrying the real domain operations the epic requires --
Write/Query/List/Forget -- not just Name/Version. Store is split out
from MemoryEngine so the interface stays under golangci-lint's
interfacebloat threshold the same way curator's embedded Lifecycle
does: an embedded interface counts as one slot, not its expanded
method count.
- registrar.go: narrow typed host access (EventSink, Clock). No
capability-gated fields yet -- unlike curator's Tools/Skills, no
memory-specific host service exists to gate on today, so Registry.Bind
passes the host straight through rather than filtering.
- registry.go: Register/Get/Names/Start/Health/Stop with the same
duplicate/nil/panic/failure-isolation guarantees as curator's registry,
ctx-bounded Stop, reverse-order shutdown.
This is the contract only -- no engine implements it yet, and
internal/memory's existing ad-hoc MemoryProvider/Manager (pre-migration)
is untouched, per the issue's explicit "do not extend in place" note.
Closes archie-core-atv2.
Media delivery is fire-and-forget with a 30s budget, far longer than
the turn's text usually finishes -- so a large upload failing (or
timing out) after doFinalize has already retired the renderer goroutine
is the normal case, not an edge one. appendFallbackLine was still
writing into toolLines and calling requestRender, a non-blocking send
into a channel nothing reads any more once stopRendering has returned:
the line was silently dropped and the finalized message stood
unchanged, with nothing telling the user or the agent the file never
arrived.
stopRendering is the single point every finalize/abandon path funnels
through to retire the renderer, so it's the right place to mark the
reply finalized. appendFallbackLine now checks that flag and, once
set, sends the fallback as its own follow-up message instead of
appending to a buffer nothing will render again.
Two bugs behind the "System statusEverything is operating normally."
render:
1. Consecutive plain lines with no blank line between them were joined
into one paragraph's text with an embedded "\n". Telegram's
rich-block paragraph does not render an interior "\n" as a break --
it renders nothing, so the words ran together with zero separator.
Join with a space instead: the correct rendering of a CommonMark
soft line break anyway, and it survives regardless of how the
client treats a literal "\n".
2. Telegram's renderer adds no vertical gap between adjacent blocks on
its own -- only a heading carries its own margin -- so a label line
immediately followed by a list (or any two non-heading blocks back
to back) rendered touching, with the list's first item glued to the
preceding text and no visible line break at all. appendBlock now
inserts an empty spacer paragraph before any block that doesn't
follow a heading, making the gap explicit instead of depending on
client-side spacing that isn't there.
Reproduced directly against markdownToBlocks with the reported input
and confirmed the fix before writing this up.
"Treat this as UNCONFIRMED, not complete" is developer-speak in a
message an operator with no codebase context has to act on. Reword to
plain instruction: say what's known, then what to do about it.
git push --follow-tags pushes main plus both archied/v* and archie/v*
tags in one operation, all pointing at the same commit. on.push
matches branches and tags, so every release push fired three identical
deploy runs -- observed just now: archied/v1.19.7, archie/v1.19.7, and
main all running in parallel from the same commit. The ref-keyed
concurrency group added earlier couldn't see these as the same work
since github.ref differs per trigger. Key on github.sha instead so all
three collapse into one.
Both images built via plain docker build/push with no cache, so every
push to main rebuilt archie-agent's full toolchain (apt packages,
golangci-lint, gofumpt, buf, uv+python, npm globals) from scratch --
several minutes, even when none of those inputs changed. Switch to
docker/build-push-action with GHA-backed layer caching per image.
Also add a concurrency group so a burst of pushes (e.g. a fix commit
immediately followed by its release commit) cancels the superseded
deploy rather than running three in parallel for capacity none of them
can use -- only the last one's :latest push matters anyway.
CodeQL's Go analyzer (go/uncontrolled-allocation-size, alert #6) can't
trace min(limit, MaxTailLines) as a bound on the request-derived limit
before make([]Entry, 0, limit). The clamp was already correct and has
been in place since 5e24072 -- confirmed by rescanning at current HEAD,
the alert still fires -- so this is an analyzer gap, not a live bug.
Same clamp, written as an explicit if so static analysis (and readers)
can verify the bound directly.
-X main.gatewayVersion/main.runtimeVersion targeted package main, but
those vars live in internal/app/archied (cmd/archied is a thin
wrapper). An -X target that doesn't exist is silently ignored by the
linker, so every archied binary this shipped -- task build, install.sh,
Dockerfile.archied, and the carina self-update script -- reported
"dev" instead of its real version. Point every one of those ldflags at
the actual package.
Also, while chasing the carina incident this surfaced:
- restart.go: /restart didn't check for an in-flight /update install.
The install runs as archied's own child process, so a restart killed
it mid-build (observed: "signal: terminated") instead of letting it
finish or fail cleanly. Refuse the restart while updateInProgress.
- update.go / update_report.go: the "no version could be confirmed
running" branch still opened with "Update complete", contradicting
its own next clause. Reworded so an unverified outcome isn't
reported as completion.
- mcp client_test: assert both initialize handshake calls happened and
notifications/initialized has an empty ID, not their exact order
- telegram model_test: assert the resolved model has an openrouter/
prefix instead of scanning button text for the string; replace the
single-hardcoded-count pagination test with cases covering 0/1/8/9/100
models so pageBounds and nav-row logic are actually exercised
- webui api_chat_test: assert the actionable file path is present in the
streamed error instead of matching generic wording
Implements archie-core-h019.3 (reviewer isolation) and h019.4 (wiring),
per docs/prds/adversarial-self-review.md.
- internal/domain/workflow: new Reviewer interface and StageReview,
inserted between StageDiffCap and StageOpenPR in the implement
workflow. Fail-closed: a review that didn't run, or a confirmed
error-level finding, parks the task (store.StatusParked) with
findings in Detail; warn/plausible findings never block. Inert
unless Repo.ReviewEnabled.
- internal/worktree: Manager.Snapshot exports HEAD's tracked files into
a fresh directory with no .git, for the reviewer's isolated
workspace. Trees interface gains Snapshot; hybridTrees delegates to
it.
- internal/app/agentworker: subagentReviewer implements Reviewer using
ai-sdk's agent.Subagent (nested, in-process, non-streaming
generation) -- conversation isolation is structural (Subagent.Run
never carries message history), workspace isolation is the snapshot
above. The reviewer's toolset is read-only (read/grep/find) rooted
at the snapshot, never the worker's own toolset, so it cannot reach
the worktreerpc publication grant. Findings are captured via a typed
record_finding tool appending to a slice the stage owns, read even
when Subagent.Run errors (a truncated run's captured findings
survive).
- internal/config: Repo.ReviewEnabled (default false) and
Models["reviewer"] (falls back to Models["builder"], no schema
change).
Judgment calls: Reviewer.Review never returns a Go error -- every
failure folds into ReviewReport per the PRD's fail-closed contract,
which the stage can act on uniformly. A Subagent.Run error with zero
captured findings resolves to ReviewStatusNotRun (park); a
Subagent.Run error with >=1 captured findings resolves to
ReviewStatusCompleted with those findings, since the PRD's own example
("three defects survive a step-limit truncation") requires them to
still be evaluated for blocking rather than discarded.
- tomlwrite.go: split Apply into collectPending + an applier struct
(indexTables/resolveTable/matchActiveKeys/uncommentKeys/
appendMissingKeys/render). gocognit 82 -> under threshold.
- find.go: split findWalkVisitor's closure into findSkipEntry/
findMatchesFilters. gocognit 46 -> under threshold. This clears the
last complexity finding from archie-core-agui's original 31.
- richblocks.go: go fix modernization (strings.SplitSeq).
Behavior-preserving.
markdownToBlocks's nested closures over shared mutable state become
methods on a markdownBlockParser struct; blocksToPlainText's list/quote
cases become listBlockPlainText/quoteBlockPlainText. gocognit 37 -> under
threshold for both. Behavior-preserving.
turn.go: extract checkConfigured, replayPriorReply, claimTurn,
recordInboundMessage, prepareTurn, generateAndComplete out of Run
(gocognit 53 -> under threshold, gocyclo brought under 20 then under
cyclop's 15 too).
gateway.go: split dispatchLocal's second half into dispatchLocalMisc
(cyclop 18 -> under 15, on top of the earlier gocyclo fix).
Behavior-preserving; internal/gateway lint clean.
gocognit 70 -> under threshold. Behavior-preserving: same request
fields, same guardrail/validate/persist/deliver sequence, just named
steps instead of one closure.
- toolset.go: extract requireApproval out of toolExecute (nestif)
- gateway.go: extract handleDeny/handleVersion/handleUpdateCheck/
handleRestartAdapter out of dispatchLocal (gocyclo 26 -> under 20)
- cronstore/store.go: extract applyPatch/applyScheduleChange out of
Update (nestif, gocognit)
Behavior-preserving.
Second architecture test (after contract_test.go) that still grepped
cmd/archied for wiring strings following the cmd/archied ->
internal/app/archied extraction. task check now passes clean.
Extracts focused helpers out of applyEdits, grepFallback/grepDirFallback,
serveReadContent, handleChatStream, TDD, runFindGoFallback,
makeGrepExecutor and makeShellExecutor to bring them under the
project's cyclop/gocognit/funlen thresholds. Behavior-preserving.
Partial pass on archie-core-agui: richblocks.go (gocognit),
gateway.go dispatchLocal (gocyclo), and a couple of remaining
gocognit/nestif findings are left for a follow-up.
- migration-decisions.md: confirm curator/mapping/scheduling as
legitimate domains that were never added to the confirmed list;
document identity/agent/messaging/plugin as approved-but-unmaterialised
targets rather than creating dead stub packages.
- Resolve the open Session/Messaging decision (section 2): keep
internal/gateway as-is rather than risk a big-bang rewrite of live
session/compression/approval/branch logic; materialise
internal/domain/messaging with the already-settled canonical
Message/Conversation/ToolCall/ToolResult types. Actual gateway
migration onto these types is tracked as sequenced follow-up bd
issues (label messaging-migration).
- ARCHITECTURE.md: add internal/gateway, internal/tools, internal/memory,
internal/secret, internal/plugin, internal/skill to the Package Map.
Paths and String were value receivers alongside the mutating record()
pointer method. All Provenance uses are through addressable struct
fields, so this is behavior-preserving.
Replaces hand-written JSON Schema + manual unmarshal with
core.NewTypedTool[In], now available at the pinned ai-sdk v0.1.30. This
removes the class of bug where a hand-rolled schema drifts from the
struct a manual decode unmarshals into.
CI's go-version was a floating "1.26" independent of go.mod, so it
could silently drift from the toolchain the project actually builds
with. Switched to go-version-file: go.mod as the single source of
truth, and added `task vuln` (govulncheck) plus a CI scan step -- kept
out of `task check` since it needs network access to the vuln DB.
Follow-up to the cmd/archied -> internal/app/archied wiring extraction:
the architecture test that greps main.go for required wiring strings
still pointed at the old cmd/archied path.
Test TestPluginEngineRuleIsCanonicalAndSharedByAgentInstructions was
missing entirely, letting CLAUDE.md drift out of sync with
ARCHITECTURE.md#plugin-engine-rule-strict. Added the test and the
missing reference.
Funcs() was passed a *strings.Replacer value instead of its Replace
method, panicking gateway's init(). Fixing that surfaced a second bug:
the template still referenced .Operator, removed from promptData by
5465335, which made every render fail and silently fall back to a
generic hardcoded prompt.
Also replaces a real Telegram chat ID hardcoded across several test
fixtures with a placeholder value.