Addresses PR #783 review findings:
- Memoize the operator-triggered PR reviewer on boot so the Web UI and
Telegram share one in-flight set; a concurrent review of the same PR from
two channels now deduplicates instead of running twice.
- Guard Gitea GetPullRequest against a nil head/base (deleted branch returns
null from Gitea), returning an error instead of panicking.
- Create the worktree root in CheckoutPR before MkdirTemp so a first review on
a fresh work_dir does not fail with os.ErrNotExist.
Add a channel-neutral review_pr command that runs the adversarial reviewer
against an existing pull request and returns structured findings. The Web UI
chat and Telegram invoke the same command; the reviewer model is models.reviewer
(falling back to models.builder), configurable independently of planner/builder.
- forge: PullRequest + PullRequestReader.GetPullRequest (github, gitea)
- worktree: Manager.CheckoutPR materialises a PR head for Diff/Snapshot
- agentworker: NewOperatorReviewer + ReviewerModel (single model-resolution rule)
- gateway: review_pr tool, ChatPRReviewer, wired into TurnRunner for every channel
- archied: prReviewer adapter with identity-scoped repo allow-list and
per-PR single-flight, so duplicate/concurrent reviews are deterministic
Closes archie-core-h019.8.
- ui-service-boundary.md: the /api/captures|/mappings|/bindings row is
resolved by the cutover; archie-ui composes the store contracts and
mounts the captureintake receiver.
- event-capture-storage.md HTTP surface: the receiver mounts on the one
process serving the dashboard; work intake stays with the daemon.
- config.example.toml: [web].listen is the archie-ui process's bind
address; [capture] is projected by archie-ui.
- deployments: document running archie-ui alongside the other services
and add its systemd unit; capabilities comments updated for the
single-serving composition.
PRD gate 7 (docs/prds/ui-service-boundary.md): the daemon's in-process
webui.Run listener is deleted in the same change that wires the UI process,
so no fallback or second HTTP authority remains. The daemon's webui.Server
stays only as the configuration snapshot's renderer (archie-core-ymut): it
keeps the config Holder, provenance, reload status and the override list,
and drops the store surfaces, event broadcast, chat/task wiring that only
fed the listener. The bus drain becomes persistence-only -- the store is
the single fan-out point the UI process reads through its event pump.
The dashboard's configuration write path (PATCH /api/config, per-row reset,
per-repo field update) is deleted rather than left as dead policy: the
writes are descoped for the UI process (archie-core-ymut) and no route
reaches them. Editing is config.toml plus reload; the overlay store stays
for reload wiring.
At the cutover (archie-core-8cda.5.4) the UI process is the only listener
serving POST /webhooks/capture/{source}: the receiver is a persistence shim
over the State Store contract, and the daemon's binding-dispatch loop keeps
consuming captures from the same store, so the HTTP front door moves without
moving the owner of work intake. Zero [capture] options fall back to
configuration.DefaultCapture; the arrival announcement persists through
InsertEvent so the event pump delivers it, where the daemon's bus drain
persisted it before.
The dashboard's POST /webhooks/capture/{source} handler becomes
internal/infrastructure/captureintake.Receiver, mounted by the daemon on
the same bypass mux through webui.Server.CaptureIntake; the dashboard
keeps only the GET /api/captures read and the mapping preview's scan
window. The UI process now mounts no intake route at all instead of one
that answers 503 (archie-core-8cda.5.4).
The dashboard's Run read the watchdog's phase-2 report off local disk and
put it on the activity stream. That is a host-local file read in the process
that is moving off the host: the watchdog restarts archied and leaves its
verdict beside archied, so archied is what can read it.
The daemon now polls and relays it, publishing the same event through the
same bus, so it persists with every other event and reaches whichever
dashboard is watching. The event builder moves to releaseupdate, which owns
Report and its verification; the dashboard keeps only what it needs to tell
an installer where to write.
The startup poll stays: the watchdog writes its result only once the process
answers /healthz, so a single read at boot can always miss the report
describing that very boot.
persistAndBroadcastEvents takes the daemon context and detaches it for the
insert, which is what it always did with context.Background() -- the last
events of a run are the ones an operator reads afterwards.
The same dashboard is served by the daemon, which holds every runtime handle,
and by the UI process, which holds two remote contracts. A section with
nothing behind it still answers -- an empty list, a "disabled" marker, a 501 --
and the browser cannot tell that from a deployment where nothing has happened
yet. GET /api/capabilities says which sections this process can back, and the
nav drops the rest rather than offering a page that is permanently empty.
It fails open in both directions: an unreported section stays visible, and a
failed read hides nothing, because an entry that silently vanished is worse
than a page that explains itself.
Mappings and bindings move the other way. Both are ratified State Store
contracts carried by the client the UI process already holds, so leaving them
nil degraded two pages that have an owner; compose wires them.
A table test now enumerates every route whose capability is daemon-local and
pins what it answers without one (requirement 4 of archie-core-8cda.5.4):
task logs, the log feed and its stream, version and the update flow, channels
and reload, curators, memory, skills, workflows and work requests. Adding a
route with no owner now fails that test rather than the operator's browser.
The configuration page had exactly one source: this process's own
config.Holder. The UI process has no holder and is not permitted one, so the
page was empty there and the shared-holder assumption was the thing blocking
the cutover.
GET /api/config now reads a ConfigViewSource. The daemon builds the
projection from the configuration it owns, as before, and publishes that same
document to the State Store on boot and on every republish -- reload, a
dashboard edit, a repository field change -- since those are exactly the
moments it changes. The UI process renders what it reads there and nothing
else; an unknown schema is refused rather than half-rendered, and nothing
published yet is the documented empty response, not an error.
Editable is a property of the process, not of the configuration, so each
source sets it: the daemon holds the update path, the reader does not. The
settings page honours it, rendering values where it would otherwise offer
controls whose PATCH would answer 503 -- the deliberate feature reduction
archie-core-ymut recorded, made visible instead of discovered by clicking.
A failed publish is logged and degrades to a stale page. It must never fail
the reload or the edit that produced the configuration, both of which have
already taken effect.
archie-core-ymut decided the configuration page reads a projection the daemon
publishes rather than reaching into a shared config.Holder. This is the
carrier: a single-row store surface plus PutConfigSnapshot/GetConfigSnapshot,
taking the contract to 42 RPCs.
The document is opaque here. Its shape belongs to the daemon that builds it
and the page that renders it, so the store neither parses nor validates it,
and schema names the projection so a reader can refuse one it does not
understand. It is secret-free where it is built: the projection carries an API
key's environment variable name and whether it resolved, never a value.
Both RPCs are administrative. authorizesTaskScopedCall is deny-by-default, so
a container's task-scoped grant can neither rewrite what an operator reads nor
read a projection of the deployment it runs inside; a test pins both.
Nothing publishes or reads it yet -- the daemon's publisher and the UI's
read path land with the rest of the cutover.
The update watchdog verifies archied's restart, so archied has to be what
answers. It was probing the dashboard's /healthz, which belongs to the
dashboard: switch [web] off and nothing answers, and in the extracted UI
topology that endpoint reports a different process entirely, which would
confirm a release while the daemon it was meant to verify is down.
[health].listen (127.0.0.1:8485, defaulted, always on) serves /healthz,
/health and /health/detailed for the life of the process. Liveness answers
503 until the daemon reaches its run loop: the listener binds before the
subsystems do, so an unconditional 200 would tell the watchdog a half-booted
release came up. Failing to bind is fatal, because a daemon nothing can probe
gets every update rolled back. The State Store's readiness surface now shares
the listener plumbing, keeping its log and error text verbatim.
Closes archie-core-exbz, which asked which of two bad options to take when
the dashboard is off. Neither: the daemon owns its own liveness.
Also deletes TestInstallUpdateDetachesInstallerFromCallbackContext. It has
failed intermittently under load more than once, racing its fake bot server's
multipart parse against the cancellation it induces.
The dashboard composed its own taskactions.Service over whatever handles
happened to be set on webui.Server. In the extracted UI process those are
all nil, and each nil silently removes a guarantee: no Cfg means max_retries
stops being enforced, no Issues means a rejected task's forge issue stays
open and the poller re-enqueues it, no Events means operator actions never
reach the timeline, no TaskStopper means Stop cannot interrupt running work.
The handler now asks whoever owns task execution, through
ApplyOperatorTaskAction, and Issues/TaskStopper leave the dashboard entirely.
That path crosses two hops that both flatten errors, so the sentinels the
handler maps to 404/409/503 travel explicitly: a kind beside the message on
the NATS envelope, a gRPC code on the Gateway contract, each restored on
arrival. Without them a task that simply moved on reports as a broken daemon.
The action tests keep running the real service, now behind a local contract
the way the daemon serves it in production, so retry limits, forge closure,
events, archiving and log removal stay covered where they were.
archie-core-8cda.5.4 requires /api/tasks/{id}/action to go through
ChatContract rather than a task-action service the UI process composes
itself. The contract could not carry the request: ApplyTaskAction's identity
is a scope, and the daemon's action service distinguishes a named identity
from a nil one, which is the authenticated operator acting across
identities. Sending "" would not have expressed it either -- that is a real
identity in a single-identity deployment (chatTaskProfiles).
ApplyOperatorTaskAction is that case, additively: a separate RPC, so buf
sees no cardinality change on a shipped field, and no request that can carry
both an identity and operator authority. ChatTaskActor's identity becomes a
pointer end to end, from the Gateway's local adapter through the NATS hop to
taskactions.Service.Apply, which has always taken one.
The conformance test now covers both scopes through the local adapter and
the gRPC hop; the chat tool test pins that a chat action is never unscoped.
No caller passes nil yet -- the dashboard handler switches over with the
rest of the cutover.
The watchdog polled http://127.0.0.1:8420/healthz. Nothing binds 8420: the
daemon serves /healthz on [web].listen (127.0.0.1:8484 by default), so every
dashboard- or Telegram-initiated update waited out the 60s health timeout and
rolled back a release that had come up fine.
The daemon is the only process that knows which address it binds, so it now
derives the probe URL from its own config and hands it to the installer;
CommandInstaller exports ARCHIE_HEALTH_URL and the install script forwards it
into the watchdog unit, whose remaining default matches the dashboard's.
The suite never dialled the URL: every watchdog test faked curl as an
immediate failure, so only the unhealthy branch existed. One test now runs
the real curl against a real listener, and another pins the script default.
archie-core-ymut. The ratified boundary assumed one narrow admin contract
carrying both the configuration read and the write. It splits.
Read: webui.ConfigView is already a UI-owned, secret-free value projection
(ProviderView carries the API key's env var name and a Configured bool, never
a value; RepoView is metadata only) and is already the exact shape the browser
receives. The daemon publishes it, plus provenance, reload status and the
overridden-key list, as a snapshot the UI reads over two new State Store RPCs.
Nothing is designed, only moved.
Rejected a config admin service on archied. That would make the daemon a gRPC
server for the first time: grpc.NewServer appears only in RunGateway and
RunStateStore, which are the standalone binaries' entry points, not the
daemon's, so it costs a new listener, port, token and interceptor.
Write: PATCH /api/config, POST /api/config/reset and the repo-field route
answer 503 in the UI process, and the SPA hides the controls. This is a
deliberate feature reduction. The update policy is daemon-local
(installUpdateConfigHandler denies non-runtime-tunable keys, applies a dotted
overlay to a clone, validates the materialised config, writes overlay rows and
rebuilds provenance); contracting it verbatim would build a Configuration
Service inside a migration bead. Revisit with archie-core-1786637498420-327,
where it is a feature rather than migration residue.
Implementation is assigned to archie-core-8cda.5.4, the cutover that removes
the daemon's dashboard. Nothing is built here.
Cloud review of 69a71d0. The GATEWAY_TOKEN / STATE_STORE_TOKEN fallback was
written inside project(), which readProjection only calls after its
file-exists check, and only when -config is non-empty. The flags-only
deployment (both targets on the command line, tokens in the environment, no
config.toml) therefore skipped the fallback entirely and dialled with an empty
bearer, which staterpc.Dial refuses on a non-loopback target. That is the
exact deployment the fallback was added for.
TestResolveTokenFallsBackToEnv missed it because it writes a config file
first. Hoisted into Resolve as withEnvTokens, after withDefaults, so it fires
whether or not a file was loaded; project() goes back to being purely the
file's contribution.
Also narrows the parity claim the old comment made. The daemon resolves these
two names through a secret.Registry, which registers bws by default and can
load sops/Vault engines; this process reads the environment only, because
ui-service-boundary.md's deletion gate forbids a secret runtime package in the
UI process. The operational consequence (whoever starts archie-ui must export
those tokens into its environment) is recorded on archie-core-8cda.5.5, which
writes the deployment profile.
Adds pins for the no-config-file fallback, flag-beats-env, and the
Listen = "off" coercion whose own comment asked for one.
archie-core-za9f. The UI process owns no event bus, so after the .5.4 cutover
the activity feed would show history at page load and then go silent: live
delivery is a Server.Broadcast call made only from the daemon's bus
subscription.
Decided against the push-subscription RPC the bead assumed, on three findings:
* store.Open sets SetMaxOpenConns(1), so writes serialise and the event id is
assigned in commit order. The gap-skipping failure that normally rules out
polling an autoincrement cursor cannot happen here, and SSE catch-up already
depends on the same property.
* sseStream.drain treats a broadcast as a wakeup, not a payload: it fills the
persisted gap via catchUp and delivers the event only if catch-up missed it,
deduplicating on the since watermark. A poller substitutes for the bus with
no change to sse.go and no new SSE semantics.
* The events table is the only complete fan-out point. ArchiveTask writes an
audit event inside its transaction and daemon.go inserts binding-dispatch
failures directly, neither touching the bus. A push hub needs a hook at every
write site and misses any added later.
So: no proto change, no new auth surface, no backpressure policy. The pump
primes past existing history (a client's own catch-up serves that), then ticks
EventsSince into Broadcast. One pump serves every browser. A failed fetch
leaves the watermark intact, so a State Store restart costs latency, not
events.
Wired into archieui.Run in the background so priming a large events table
cannot delay the listener, with -event-poll-interval (default 1s).
Decision recorded in migration-decisions.md; ui-service-boundary.md's /events
route-owner row moves to RESOLVED, and /api/logs splits out of it as still
unresolved and host-local.
D1: the UI read [services.*].target_token verbatim, but the config loader does
not expand environment variables. A deployment that presents the gateway and
state tokens by env (as config.example.toml documents for remote consumers)
would leave archie-ui with an empty token, and staterpc.Dial then refuses a
non-loopback start. Mirror the daemon's stateStoreResolvedToken /
gatewayResolvedToken: explicit key, then GATEWAY_TOKEN / STATE_STORE_TOKEN.
D5: internal/config/services.go claimed the State Store service 'is not yet
extracted into its own process' and that target_token 'remains dead
configuration', both false since the daemon made an empty services.state.target
a hard startup error. State current truth.
D3: document that Web.Listen = 'off' is read with opposite meanings by the
dsaemon (disables the dashboard) and the UI process (falls through to the
default listener), pinning it as the one overloaded key an operator preparing
the split would set.
The UI Service serves task, capture, mapping and binding routes against a
*staterpc.Client, not a concrete *store.Store, but every existing webui test
fed a local store directly. Add remote coverage that stands up a real SQLite
store behind staterpc.RegisterServer, dials it, and asserts the handlers serve
over the wire. This surfaced two composition facts: the server Deps must wire
Captures/Mappings/Bindings/BindingDispatcher or those list endpoints fail
closed with err*Unavailable, and the timeline route's PathValue only resolves
through Server.Handler().
Log and health are asserted as deliberate degradation (log feed and health
registry are nil in a remote composition), matching the route inventory that
no State Store log/health contract exists.
Refs: archie-core-8cda.5.3
Replaced gateway.Message as the currency at the channel-facing boundary
with the canonical internal/domain/messaging.Message. Channel adapters
now build the record directly (RoleUser, ConversationID, Sender) and the
Router hands it back unchanged, so nothing converts between two shapes in
process. gateway.Message is deleted; the dashboard route that had no home
in the record lives in a new Inbound envelope (Message + transport-only
Page), which reaches the system prompt and is never persisted.
Role is now set at construction instead of derived at the store boundary,
and the assistant reply is a direct messaging.Message (RoleAssistant,
Sender=botUser). The gRPC proto is unchanged: pb.Message still carries no
role, and both sides keep deriving it from the owning session's bot
identity via gateway.RoleForSender (ToStoredMessage/FromStoredMessage are
deleted).
Adds tests that the old shape could not express: Page reaches the system
prompt but not the persisted record, and a channel-built Inbound round-trips
with the Role the channel set.
Refs: archie-core-9g5e
The Gateway had no transport boundary: RunGateway refused any non-loopback
listen address and serveGateway registered no interceptor, so archie-ui was
colocation-only while the State Store already had a token-authenticated
equivalent.
gatewayrpc gains a gateway-token metadata credential with constant-time
comparison and both unary and stream interceptors on each side. Stream
coverage is required here and not in staterpc: the Gateway's Stream RPC is
server-streaming. Dial fails closed on a non-loopback target with no token,
mirroring staterpc.Dial. gatewayServerOpts applies the same rule server-side:
loopback stays insecure, non-loopback requires a token, malformed errors.
The daemon resolves [services.gateway].target_token then GATEWAY_TOKEN;
archie-ui passes the token its config projection already carried, so a
distributed dashboard is now possible.
Closes: archie-core-juqx
The gate also runs proto:lint, proto:check and lint (Taskfile.yml:187-200);
the summary line omitted all three. A session that reads this line and
assembles go vet + go build + go test + gofumpt as an equivalent stand-in
misses golangci-lint entirely, which is how main last went red.
89d8dc0 landed with golangci-lint red: scanSearchMessages was an exact copy
of scanMessages bar two error strings (dupl), and the pre-role schema
migration test seeded its fixture with db.Exec (noctx). task check has been
failing on main since.
Collapse the two scanners into one -- SearchMessages already selects the same
column order the history reads do, which the deleted function's own comment
said -- and seed the fixture through ExecContext.
No behaviour change: the gateway suite passes unchanged.
Add cmd/archie-ui and internal/app/archieui: a second composition root that
serves the dashboard and the compiled SPA against the two contracts the daemon
already dials, so the UI stops needing the daemon's in-process objects.
The composition root lives outside internal/app/archied deliberately. That
package pulls 88 internal packages (daemon, forge, containers, NATS, secrets,
workflow); reusing its boot the way RunGateway and RunStateStore do would make
the PRD's deletion gate unreachable. archieui links 41, and cmd/archie-ui 42.
Configuration ownership follows docs/prds/ui-service-boundary.md: the process
reads the shared file, but only [services.gateway].{target,target_token},
[services.state].{target,target_token} and [web].{listen,
trust_forwarded_headers}, with flags taking precedence. Options has no field
for anything else in that file to land in, and no config.Holder.
compose() sets only the contract-backed and process-local fields. Every daemon
runtime handle stays nil on purpose and its route degrades through the
existing 501/503/empty paths. Captures, CaptureLimiter and BindingDispatcher
are withheld for the duration of the seam: the daemon's dashboard still serves
POST /webhooks/capture/{source}, and two intakes are not permitted.
Readiness is the UI's own registry over its two dependencies via a new bounded
readiness.ContractProbe. The existing GatewayProbe was unusable here: with no
channel manager to inject it reports "no gateway channels configured", i.e.
permanently degraded.
The State Store's fail-closed non-loopback rule and the two dial paths move to
staterpc.Dial/TargetIsLoopback and gatewayrpc.Dial, so the server side and
every client share one implementation instead of three copies.
The Gateway remains loopback-only with no auth interceptor, so this process is
scoped to being colocated with it; filed as archie-core-juqx.
Refs: archie-core-8cda.5.2
SessionStore message history now stores/loads domain/messaging.Message:
sender attribution, derived role, and conversation address are canonical
record fields. SQLite gains a role column with open-time backfill for
pre-migration databases. gateway.Message remains the channel-facing
transport; conversion lives in one boundary module. ChatContract,
gatewayrpc proto, and dashboard JSON are unchanged; the RPC client
splits into ChatContract (Client) and SessionStore (StoreClient) views.
Sessions stay SessionContext: UUID keys and platform/bot/title/branch
metadata have no lossless home in Conversation; keyed migration tracked
separately once Agent/user/binding ownership settles.
Refs: archie-core-d9dv
New dist-zip job, independent of build-and-push (no change to the
archied/archie-agent Docker image jobs). Triggers on any archied/vX.Y.Z
tag, so a gateway-only release (RUNTIME=skip) still produces it, keyed
to the archied version alone -- these binaries aren't in
tools/release.sh's two-component split and don't need to be for this.
archie-agent is deliberately excluded: it only ever runs inside the
Docker image build-and-push already publishes, never as a host binary.
Zip contains the four linux/amd64 binaries, the new
deployments/INSTRUCTIONS.md (quickstart + deployment-profile/systemd
pointers), and CHANGELOG.md/CHANGELOG.archied.md/CHANGELOG.archie.md.
README.md is included only if present -- it doesn't exist in this repo
yet, so omitted for now rather than fabricated here.
Verified locally: all four binaries build clean under
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 (modernc.org/sqlite is pure Go,
no cgo sqlite driver to worry about), and the assembled zip's contents
match what the workflow step produces.
The in-process-multiplexed-server and daemon.StateStoreTokens bullets
described the pre-.4.6 design; neither boot.startStateStoreServer nor
daemon.StateStoreTokens exist in the codebase anymore. Replaced with
what's actually true: the standalone archie-state-store process,
staterpc.GrantIssuer/TaskGrants task-scoped credentials, and
archie-agent's single (no longer dual-path) gRPC Store.
Surfaced while reconciling beads .4.2-.4.6 against main -- all five
verified against the code and closed as genuinely done.
Works through .4.7's remaining acceptance items:
- TestStateStoreDataSurvivesRestart: a task written by one
archie-state-store process is still there for a fresh process opened
against the same archie.db path.
- TestOpenStoresNeverOwnsTaskDB: the daemon/gateway composition path
never populates b.st -- that field is reserved for the standalone
binary, so archie.db always has exactly one owner.
- Audited internal/webui and friends for direct internal/store use:
only the narrow contract interfaces (TaskStore, CaptureStore, ...)
are imported, never a concrete *store.Store -- already satisfied,
no code change needed.
- Updated docs/prds/state-store-contract.md's token lifecycle and
payload-limits sections to describe what's actually implemented now
(RegisterTaskGrant/RevokeTaskGrant, per-RPC scoping, the streaming
capture RPCs) instead of the pre-.4.3 in-process-listener language.
- Ran the affected packages under -race; clean.
Left open, for Sam to decide rather than assume: archie-state-store has
no Dockerfile/CI build and isn't in RELEASING.md's two-component split
(tools/release.sh only tracks cmd/archied and cmd/archie-agent). Given
it's currently a native-binary/systemd deployment (deployments/*.toml),
this may be intentional -- flagging rather than inventing release
infra for a third binary unasked.
Closes six review findings against .4.6 (PR #775):
- daemon.StateStoreGrantIssuer + staterpc.TaskGrants: containers get a
per-task credential authorized only for their own Update/Transition/
InsertEvent, never the daemon's administrative token. Issued before
Acquire, revoked on Release; fails closed if no issuer is wired.
- StreamCaptures/StreamUndispatchedCaptures: new streaming RPCs so a
batch of large capture bodies can't exceed gRPC's 4MiB unary cap.
The original unary RPCs are kept, unmodified (deprecated) rather than
reshaped, so buf breaking stays green for an in-flight rolling deploy.
- Update rejects a nil Task with InvalidArgument instead of panicking in
the store layer.
- RequireHostGateway only forces on for embedded NATS, so an externally
reachable NATS/State Store no longer requires a local Docker bridge.
- Client-side token resolution now matches the server's (target_token,
then STATE_STORE_TOKEN secret/env).
- task dev now runs archie-state-store (dev:state-store) alongside
archied/archie-gateway/vite; deployments/dev.toml points them at it.
* test(state-store): real-process smoke + deadline/sentinel error contract
Add end-to-end verification for archie-core-8cda.4.7, the .4.7 State Store
verification stage against docs/prds/state-store-contract.md (rev. 2c):
- Real-process smoke coverage: build ./cmd/archie-state-store, run it against
a minimal config on loopback, poll the readiness surface, and drive the
State Store gRPC contract through staterpc.NewClient exactly as a consumer
does. Covers the combined task/event/capture view, error-sentinel fidelity
across the wire, the found=false-not-error convention, single-owner SQLite
(the binary owns the one archie.db file; the consumer never opens a store
file), per-call deadline behaviour, restart/recovery (SIGTERM + reopen on
the same db), and the remote capture/mapping/binding surfaces.
- Fix a real deadline-identity gap in unmapError: a cancelled or
deadline-exceeded context surfaced by gRPC-Go as a *status.Error was
re-wrapped into a sanitised internal-style error, breaking
errors.Is(err, context.Canceled/DeadlineExceeded). The agent's deadlineStore
bounds each Store call with context.WithTimeout and the workflow consumer
(workflow.go) uses errors.Is(err, context.DeadlineExceeded) to mark a stage
interrupted rather than failed, so the re-wrap would wrongly park an
interrupted task. Unmap Canceled/DeadlineExceeded codes back to the standard
context sentinels.
- Pin the error-mapping contract in staterpc: context-identity preservation,
sentinel round-trip fidelity for every store sentinel, and the sanitisation
rule (an Internal error must not leak raw detail or map to a sentinel).
* test(state-store): assert single-owner SQLite composition (daemon/gateway require target)
The single-owner invariant (docs/prds/state-store-contract.md §12 step 7/8) is
that only archie-state-store opens archie.db; the daemon and gateway resolve
their task-store surface from openStateStoreAdapter, which requires
[services.state].target and opens no local store. This test pins that
composition root so a future change cannot silently reintroduce a local
*store.Store in the daemon or gateway path (dual-store ownership).
* test(state-store): skip real-process smoke tests under -short
The smoke tests build and exec the real archie-state-store binary, which is
slow enough that a -short run (e.g. a focused edit loop) should skip them.
task check (go test ./... -count=1) does not use -short, so they still run in
the full gate.
* test(state-store): fix subprocess log race under -race
The smoke test captured the subprocess's stdout/stderr in a strings.Builder
that the os/exec writer goroutine and the test reader goroutine touched
concurrently, racing under -race. Replace it with a mutex-guarded buffer, the
standard pattern for reading a running subprocess's output.
* test(state-store): satisfy lint (noctx, errorlint) on new tests
- exec.Command -> exec.CommandContext, http.Get -> NewRequestWithContext +
Client.Do, so the subprocess and readiness polling honour the test context
(noctx).
- errorlint: compare the raw non-status error via errors.Is rather than != on
a wrapped error.
* docs(deployments): document State Store readiness verification and single-owner invariant
The deployment runbook described how to launch archie-state-store but not how
to verify it is healthy before starting archied. Document the -ready-addr
readiness surface (/healthz, /health/detailed state_db component) and the
single-owner invariant: one task SQLite file owned by archie-state-store, with
archied/archie-gateway never opening archie.db directly (state-store-contract
§12 step 7/8).
* fix(state-store): preserve context deadline/cancel identity in mapError
The symmetric server-side gap to the unmapError fix: if a store query fails
because the caller's context expires mid-call (§6 StoreTimeout), the handler's
mapError folded context.Canceled/DeadlineExceeded into codes.Internal. The
client would receive a sanitised internal error with no deadline identity, so
the agent's workflow consumer (errors.Is(err, context.DeadlineExceeded)) could
not distinguish an interrupted stage from a failed one.
Map a context cancel/deadline error to its matching gRPC code so unmapError
rehydrates it back to the standard context sentinel, completing the §6/§7
round-trip. Pin both directions with TestMapErrorPreservesContextIdentity.
* refactor(state-store): delete NATS storerpc; agent store is gRPC-only (archie-core-8cda.4.6)
The agent is fully on the gRPC State Store contract, so the legacy NATS
storerpc path is dead (docs/prds/state-store-contract.md §12 step 4):
- delete internal/storerpc (Server, Client, subjects) and its tests
- drop the storerpc registration from registerTaskRPCServers and the
now-unused store param
- make the agent transport's State Store URL required and Store() return
only the gRPC staterpc.Client (no NATS fallback)
- rework agentworker/agent transport tests to back the store with a real
gRPC State Store server instead of the deleted NATS storerpc server
The agent binary now fails fast when STATE_STORE_URL is absent. Agent store
calls (workflow.Store) go over gRPC to the archie-state-store service.
* refactor(state-store): delete daemon/gateway in-process store ownership (archie-core-8cda.4.6)
The daemon and gateway no longer open archie.db in-process: the single SQLite
file is owned by the standalone archie-state-store process, and both consumers
dial its gRPC State StateStore contract (docs/prds/state-store-contract.md
§12 step 7, no dual-store ownership).
- openStores no longer opens the production task store or seeds b.st; it only
wires secrets/forge and the gateway conversation store
- openStateStoreAdapter now requires [services.state].target (the old local
default is deleted) and resolves b.stateStore as the remote *staterpc.Client
- delete the in-process startStateStoreServer (the multiplexed gRPC server and
its per-task bearer-token registry) from the daemon composition
- RunGateway now resolves the same remote State Store adapter; its session
SQLite stays Gateway-owned and untouched
- daemon.ConnectedStateStore carries the configured target plus the resolved
bearer token, which containerEnv injects as STATE_STORE_URL / STATE_STORE_TOKEN
so archie-agent authenticates to the same remote service
- readiness store probe reads b.stateStore
PRD-consistent choice (noted): with the in-process server gone, per-task token
generation is removed; the daemon/gateway/agent all present the single
[services.state].target_token (or STATE_STORE_TOKEN secret) that the standalone
store validates.
* docs(webui): require [services.state].target in config and deployment templates (archie-core-8cda.4.6)
After the in-process store path is deleted, archied and archie-gateway dial the
standalone archie-state-store gRPC service via [services.state].target and never
open archie.db themselves (docs/prds/state-store-contract.md §12 step 7).
- config.example.toml documents [services.state].target as required, with the
loopback vs Docker-bridge gateway + target_token rule
- deployment templates set [services.state] per topology: bridge gateway +
token for container-mode agents, loopback for host-only
- deployments/README.md and systemd-user-service.md describe start commands
for both topologies and drop the stale "not yet consumed by the daemon" note
* style: gofumpt alignment for State Store daemon literal; appease noctx/staticcheck (archie-core-8cda.4.6)
* docs(state-store): refresh stale in-process references post-cutover (archie-core-8cda.4.6)
Route the daemon's task-lifecycle / work-intake / workflow consumers (the
TaskStore composite) through b.stateStore instead of reaching into b.st
directly, the same additive composition pattern .4.4 used for the
capture/mapping/binding contracts (docs/prds/state-store-contract.md
§10/§12 step 6). b.stateStore is the in-process *store.Store by default and
a remote *staterpc.Client dialed to the standalone archie-state-store gRPC
service when [services.state].target is set, so this is behaviour-neutral
until an operator flips the seam.
Consumers migrated: daemon.Daemon.Store, webui.Server.Store, the message
gateway routers, the chat task lister/log-reader adapters, the operator
task action service, event persistence (persistAndBroadcastEvents), the
manual requeue path, and the chat task creator/controller.
openStores now seeds b.stateStore = b.st so it is never nil in either the
daemon (Run) or the gateway (RunGateway) composition; the gateway never
calls openStateStoreAdapter, so it stays on the local adapter and never
dials a remote store (preserving the .4.4 fail-closed intent). The
in-process State Store gRPC server keeps fronting b.st (the agent's gRPC
and NATS storerpc handoff paths both stay on the daemon's local store) and
the in-process serving path is untouched (deletion is .4.6).
Adds focused composition-regression tests asserting the daemon, webui and
task-actions consumers resolve their store from b.stateStore, plus the
existing bufconn conformance suite (grpc adapter) already proves contract
fidelity for the TaskStore surface.
* feat(state-store): add daemon composition path for remote store adapter ($services.state)
Add the additive composition path the daemon's own capture consumers use
(archie-core-8cda.4.4, docs/prds/state-store-contract.md §10/§12 step 6).
bootstrap.go opens production store then resolves b.stateStore: the local
*store.Store by default, or a remote *staterpc.Client dialed to the
standalone archie-state-store gRPC service when [services.state].target is
set. Wire the dashboard CaptureStore surface from b.stateStore.
The in-process StateStore gRPC server keeps serving the daemon's SAME local
store (stateStoreDeps from b.st), not the consumer-facing b.d.* adapters:
task lifecycle (b.st) stays in-process until .4.5/.4.6 and there is no
dual-store ownership. Fail-closed on a non-loopback target without a bearer
token mirrors the standalone server's confinement (§9).
* feat(state-store): route daemon mapping consumers through the state store adapter
Migrate the MappingStore consumer to the State Store contract adapter
(archie-core-8cda.4.4 step 6, Mapping swap): the dashboard's mapping editor
(web.Mappings) and the daemon's dispatch loop (d.Mappings) resolve from
b.stateStore instead of reaching into b.st directly. Local by default,
remote *staterpc.Client when [services.state].target is set.
* feat(state-store): route daemon binding consumers through the state store adapter
Migrate the BindingStore/BindingDispatcher/BindingTaskCreator consumers to
the State Store contract adapter (archie-core-8cda.4.4 step 6, Binding
swap): the dashboard's binding editor (web.Bindings / web.BindingDispatcher)
and the daemon's dispatch loop (d.Bindings / d.BindingDispatcher /
d.BindingTaskCreator) resolve from b.stateStore instead of b.st. Local by
default, remote *staterpc.Client when [services.state].target is set.
* refactor(state-store): resolve daemon state store adapter only in daemon composition
openStores is shared with the standalone archie-gateway (RunGateway), which
does not consume the capture/mapping/binding surfaces. Resolve b.stateStore
from the daemon's own Run() composition instead, so a gateway config that
happens to carry [services.state].target can never dial (or fail closed
against) a state store it does not use. openStateStoreAdapter takes no ctx:
grpc.NewClient connects lazily, and the adapter resolution is synchronous.
* feat(state-store): generalize storerpc as the State Store gRPC contract
Implements archie-core-8cda.4.2 against docs/prds/state-store-contract.md
rev. 2c: generate protobuf/gRPC client and server adapters for every
ratified store contract (proto/state/v1/state.proto, 40 RPCs, one
StateStoreService), add internal/infrastructure/staterpc with a bufconn
conformance suite exercising both local and remote adapters, serve the
service in-process (bridge address + mandatory per-task bearer token when
agent containers exist, loopback-only otherwise), and flip archie-agent's
workflow.Store to a long-lived gRPC client when the daemon injects
STATE_STORE_URL/STATE_STORE_TOKEN (falling back to the legacy NATS
storerpc path otherwise -- one agent process is never both).
Also drops the *sql.Tx parameter from store.BindingDispatcher.RecordDispatch
(a required wire-blocker fix: a transaction cannot cross a gRPC boundary,
and production always passed nil).
fix(store): drop RecordDispatch's unusable *sql.Tx parameter
feat(config): add services.state contract-adapter selector
* fix(state-store): apply no-mistakes review decisions
- Drop StreamTokenInterceptor (unused; the State Store service has no
streaming RPCs and nothing calls it).
- Make StateStoreTokens.Validate compare tokens in constant time
(crypto/subtle) per the auto-fix hardening.ing finding.
- Amend config.example.toml / config.Services.State doc text so it frames
[services.state].target as the ratified surface consumed by the upcoming
standalone archie-state-store binary (.4.3), not active today.
* refactor(workflow,store): relocate Task/Status/Source and define workflow.Store
Move store.Task, store.Status*/store.Source*, and the 3-method workflow
store interface out of internal/store into internal/domain/workflow as
workflow.Task/workflow.Status/workflow.Source plus a consumer-owned
workflow.Store, superseding store.WorkflowStore. internal/domain/workflow
now imports zero internal/store symbols; internal/store persists the
domain type instead (infrastructure depends on domain), and its Store
satisfies workflow.Store.
Updates every production and test caller of the relocated symbols across
daemon, webui, gateway, agentworker, agenttransport/nats, storerpc,
taskrun, and worktreerpc, and removes TestRecordDispatchViaExplicitTx per
docs/prds/state-store-contract.md (rev. 2c) sections 4 and 12 step 2.
Two workflow-package integration tests that exercise the real *store.Store
move to an external workflow_test package (store_integration_test.go) to
avoid a workflow(test)->store->workflow(prod) import cycle now that store
depends on workflow.
* no-mistakes(document): docs(state-store): mark §4.8 relocation done in state-store-contract
Update the editorial revision labels so agents reading the handoff don't think
they are on an older revision: the date and the section annotations in
docs/prds/state-store-contract.md (contract-ownership fork, transitional
internal/store, error-detail sanitisation, transport boundary, token lifecycle,
fail-closed) that describe decisions retained through rev. 2c now read
(rev. 2c), and the service-decomposition PRD's ratification pointer reads
(rev. 2c). The revision-history sentence describing what rev. 2 resolved is
kept as narrative.
Address the third-pass review of the State Store ratification doc:
- service-decomposition.md Q3 generic migration wording no longer contradicts
the ratified design: the compile-time assertion example is now
var _ workflow.Store = (*Client)(nil) (store.WorkflowStore is superseded),
and composition selection is described as presence-based
[services.<name>].target (empty=local, set=dial remote) instead of the dropped
mode = "inproc" | "remote" enum. Defaults differ per service (State Store local,
gateway remote-on-localhost). Points to state-store-contract.md section 10.
- State Store listener topology is now a single explicit rule: one in-process
listener, bound to the host-gateway bridge address with mandatory bearer-token
auth when agent containers consume it (the Phase 2 default), or loopback-only
for a daemon-local-only consumer. Removed the contradictory
"default loopback-only" wording (a container cannot reach the host's
127.0.0.1) and the dual-listener ambiguity across sections 6, 9, and 13.
Address the second-pass review of the State Store ratification doc (beads archie-core-8cda.4.1):
- State migration-decisions.md section 4 remains authoritative and open; this PRD
does not replace it. The Task/Status/Source + interface relocation is flagged as
a minimal, pulled-forward Phase 2 prerequisite only.
- Fix stale WorkflowStore reference in service-decomposition.md Q4: the workflow
contract is the domain-owned workflow.Store, which supersedes internal/store's
WorkflowStore.
- Label internal/store as a TRANSITIONAL compatibility location (target
internal/infrastructure/store), matching dependencies-and-contracts.md.
- Call out the current-state outliers explicitly: workflow files/tests still import
internal/store, store.WorkflowStore is still in TaskContext, and the NATS storerpc
path is still wired -- the acceptance criterion is NOT yet met.
- Operationalize the agent gRPC handoff: who binds the in-process State Store
listener (daemon, mirroring serveGateway), Docker-bridge host-gateway address
selection (reuses the embedded-NATS container/network.go resolution), per-task
injection via containerEnv beside NATS_URL, per-incumbence bearer token lifecycle
+ gRPC-interceptor validation -> codes.Unauthenticated, and fail-closed on
non-loopback targets without TLS/token.
- Update beads archie-core-8cda.4.2/.4.5 descriptions to match the ratified scope
(type/interface relocation, RecordDispatch *sql.Tx drop, in-process serving,
agent gRPC handoff).
Address the review of the Phase 2 ratification doc (beads archie-core-8cda.4.1):
1. Domain-dependency contradiction: ownership splits by consumer layer. The
workflow domain owns a consumer-owned workflow.Store interface plus the
Task/Status/Source types (dependency rules #2/#7), so internal/domain/workflow
imports no internal/store — satisfying the Phase 2 acceptance criterion. The
daemon/webui store surfaces stay producer-owned in internal/store. The type +
interface relocation is a Phase 2 prerequisite pulled from migration-decisions
section 4 (store.Task -> WorkflowExecution).
2. Agent gRPC endpoint propagation: explicit boot handoff via STATE_STORE_URL /
STATE_STORE_TOKEN (mirrors the NATS handoff), added to agentworker.Settings and
the Transport.Store facade; per-call timeout + long-lived grpc client.
3. Transport security + error sanitisation: loopback-only + insecure default, agent
authenticates over the container bridge with a per-task bearer token; TLS/mTLS
is an operator choice for non-loopback/k8s. Sanitised public error details in
gRPC; full detail logged server-side only.
Also records RecordDispatch dropping *sql.Tx as a required interface migration
before .4.2. Cross-references updated in the service-decomposition PRD.