Commit Graph
223 Commits
Author SHA1 Message Date
sam 463f4cd92a feat(messaging): serve MessagingService.Deliver and deliver chat schedules through it 2026-10-05 18:01:33 +11:00
sam ee2c9cda97 feat(releaseupdate): install from release artifacts with journaled rollback, topology check and channels 2026-10-05 17:02:29 +11:00
sam 823d60e1dc feat(presence): services card on the status page and archied status 2026-10-04 03:29:05 +11:00
sam 31715f1a50 refactor(archieplaybooks): fold archie-playbooks into archied playbooks lint|serve 2026-10-04 01:20:33 +10:00
sam 08eb877ba8 refactor(archiegateway): own package for the Gateway service
archie-gateway no longer links the daemon, the web UI or archied. Shared
runtime layering, watches, catalog, NATS discovery and the State Store client
live in servicekit; chat task profiles in chattask. The Gateway waits for the
daemon's NATS endpoint instead of starting a second broker, and chat
approvals go through the task-action client instead of a local service with
no daemon behind it. Version stamping uses buildinfo only.
2026-10-04 00:59:02 +10:00
sam 9f4a9e8249 refactor(statestore): own package for the State Store service; access reset moves to archie-state-store 2026-10-04 00:46:11 +10:00
sam 96e5d7b84b refactor: strip doc and issue narration from code comments
Remove PRD/doc paths, bead IDs, phase notes and deleted-test references
from comments; drop test-only hooks left by the test deletion. Includes
in-progress archied bootstrap, gateway and query changes.
2026-10-03 21:47:46 +10:00
sam ff424b70ac refactor: testing from the beginning. a journey in 150k lines of tests to none 2026-10-03 21:16:25 +10:00
sam dd939ed495 test(messaging): widen the config-read gate past explicit config.Config types
The gate that keeps a PRD-forbidden [models]/[providers] read out of the
Messaging Service only blamed identifiers whose parameter or var type spelled
config.Config. A value reached through an inferred declaration
("cfg := doc.Config") or held in a struct field therefore left the read
intact while the rule saw no holder -- the same class of miss that let voice
transcription ship behind a green link gate.

Widen the holder detection to track the config type through inferred short
variable declarations and vars, struct fields and receivers, type-preserving
expressions, and range variables over a slice or map of config, then assert
each previously-inert shape red first.
2026-10-02 11:44:51 +10:00
sam 4706a2a23b fix(messaging): gate the boundary on config reads, not only package links
The deletion gate checked which packages the messaging binary links, so a
process that reads a decoded [models]/[providers] value passed while
building an LLM client in-process. Go imports are atomic, but a config
read leaves no import to measure.

- add the model-provider capability packages (transcription, embedding)
  to the banned-link table and classify links through a testable
  bannedLink rule.
- scan internal/app/archiemessaging's production sources for a read of a
  top-level config section the PRD forbids, so the projection that built
  the transcriber cannot come back.
- unit-test both rules, including a synthetic copy of the old wiring, so
  the live gate cannot rot into a no-op and still pass.

Red first: TestMessagingReadsNoBannedConfigSection failed on cfg.Models
and cfg.Providers before the capability moved, and the link gate failed on
internal/infrastructure/transcription.
2026-10-02 11:12:59 +10:00
sam 13b03dad5c feat(webui): let the operator choose the retry worktree mode
A retry now carries the operator's worktree choice (refresh onto the base
branch or continue the work already pushed on the task branch) from the
dashboard through the task action to the daemon dispatch, and persists it
on the task row so it survives a reload. The daemon resolves the mode from
the task, never from the workflow; BeginRemediation records continue
explicitly so a remediation still resumes its pull request branch.
2026-10-02 10:53:21 +10:00
sam 72fcab3a13 feat(taskactions): one approval path answers the review gate from every surface
Decision 1 of docs/prds/pr-review-operator-response.md: the dashboard's
POST /api/tasks/{id}/action is the authoritative surface, chat's /approve
is a shortcut that posts every offered finding, and both reach the same
Service.Apply so one operator intent cannot be recorded as two decisions.

The action body now carries instructions (required by rereview) and the
finding keys an approve posts. taskactions.Service answers an offer
through the guarded RespondReviewGate write: approve records the
selection on the offer, rereview records the instructions, increments the
round and clears the offer, and a rereview with no instructions, with no
offer, or at the cap is refused as a conflict with nothing written. Chat
reaches the same service: chatTaskControllerAdapter.ApproveChatTask
delegates to b.taskActions() instead of its own requeue, which is what
removed the handler's hardcoded implement handoff -- feasibility's deliver
stage now names implement on the task before it waits, the invariant the
handler needs.

The payload crosses every hop it must: the NATS action request, the
gateway.v1 gRPC contract (regenerated), the LocalChatAdapter, and the
webui handler, which answers 400 for a rereview without instructions and
409 for the cap. A rereview event kind names its actor the way the
approval and rejection trios do.

taskactions.Task gains review_gate and rereview_rounds, and the two
surfaces' tests assert they agree.
2026-10-02 02:27:59 +10:00
sam 62fe55e474 feat(store): key control-plane resources by (org, kind)
resources and resource_history are one document per org and kind, with
per-org advisory locks, request-ID idempotency and audit keys. The
control-plane Query/History/Command/Watch requests carry org_id; a request
naming none acts in the default org until the caller's org is derived
server-side.
2026-09-30 03:34:02 +10:00
sam 8a7c947cd4 test(state-store): parallelize real-process smoke tests 2026-09-30 02:14:29 +10:00
sam bae53bcb70 feat(pr-review): benchmark live pipeline through generic workflow spawn 2026-09-29 00:35:34 +10:00
sam 772d782fc7 feat(pr-review): operator/chat trigger queues a pr-review task
review_pr self-omitted since d73e0748 deleted the synchronous reviewer it
called. It is rebuilt on the task enqueue path everything else uses: the
tool resolves the identity's configured repo, then queues a pr-review task
naming the pull request through the workflow's declared pr_number input,
which is the same generic input mechanism a watched-repos binding uses.

That input has to reach the store with the task, so
EnqueueChatTaskRequest gains inputs_json and the tasks insert writes the
inputs column directly. StampTaskBinding no longer writes it: the insert is
now the column's only writer, and a chat task must not acquire binding
provenance just to carry an input.

ChatPRReviewer, its result shape and the reviewer wiring are deleted with
the path they served.
2026-09-28 18:24:36 +10:00
sam 2cb5ae3418 feat(access): archied access reset --org/--instance on the State Store host (archie-core-qc8p) 2026-09-26 15:23:32 +10:00
sam 1c7dd08f43 feat(prreview): benchmark harness scoring findings on the Martian problems
Scores a reviewer's findings on the 38 runnable Martian Code-Review-Bench
PRs: the deterministic core turns findings into posted comments, an
independent judge model matches them to the goldens, and the run reports
golden micro-recall and golden-only precision. The reviewer is a findings
fixture directory until the pr-review workflow lands.

Run with: task bench:prreview -- -findings DIR
2026-09-26 10:30:12 +10:00
sam 0b64130b6a feat(agentexec): serve capture tools to harnesses over MCP
archie-agent mcp is a stdio MCP server, on the official go-sdk, serving a
stage's capture tools and appending accepted calls to a captures file.
The harness runner writes the tool spec and a standard mcpServers config,
registers it through HarnessSpec.MCPConfig, and reads the captures back
into the stage result. The captures file is writable by the harness user,
so the worker validates every record again with the same acceptCapture
the built-in loop now shares, and forged, undeclared or over-cap records
are dropped. A stage with capture tools on a harness without MCP is
refused before it runs.
2026-09-26 03:28:58 +10:00
sam 763023a2fe feat(egress): relay forwards the proxy, NATS and the State Store
A Kit task's worker shares the sandbox network with its harness, so it
reaches NATS and the State Store through the relay like the harness
reaches the proxy. archie-agent relay takes repeated -forward
listen=target pairs, binds them all before serving so a port conflict
fails at start, and stops every forward when one fails. RelayArgs builds
the command from the fixed relay ports.
2026-09-26 03:10:11 +10:00
sam c98c9dcc22 feat(egress): relay forwarding a sandbox network to the egress proxy
archie-agent relay listens on the sandbox's isolated network and joins
every connection to one fixed target, the proxy. The relay holds no
secrets and can reach nothing else, so the host needs no address on a
sandbox network at all.
2026-09-26 02:33:41 +10:00
sam 2051ca94d2 chore(state-store): remove the one-time SQLite import and db_path
Every install serves from Postgres, so the legacyread/legacyimport packages,
the archie-state-store import command, the boot gate that refused to serve
over unimported SQLite files, and db_path (which only located those files)
go. Migration 0010 drops the import_completion table.
2026-09-25 00:40:48 +10:00
sam 2393cade0f Merge branch 'pg/foundation' into worktree-agent-a96503bc8828fc104
# Conflicts:
#	docs/data/generated/dev-docs.json
#	internal/app/archied/state_store_test.go
#	internal/app/archied/state_store_toolcalls_test.go
#	internal/contracts/state/v1/state.pb.go
#	internal/daemon/dispatch_bindings_test.go
#	internal/infrastructure/bindingcipher/cipher_test.go
#	internal/infrastructure/captureintake/receiver_test.go
#	internal/infrastructure/edastore/contracts_binding.go
#	internal/infrastructure/edastore/testsupport_test.go
#	internal/infrastructure/postgres/edastore.go
#	internal/infrastructure/postgres/edastore_test.go
#	internal/infrastructure/staterpc/error_test.go
#	internal/store/store.go
#	internal/webui/api_binding_test.go
2026-09-24 19:47:00 +10:00
sam f4b8707ba9 docs(store): drop residual SQLite references; fix lane lint findings 2026-09-24 19:39:06 +10:00
sam e3ee044c5e refactor(store)!: remove the SQLite task store, the PocketBase event store and the SQLite session store
The State Store, event capture and Gateway conversations already serve from
PostgreSQL. This deletes internal/store and internal/infrastructure/edastore,
the SQLite gateway session store and openProductionTaskStore, and the -db
recovery path on a legacy task file; backup, restore, validate and rollback
work on the database database_url names.

- The binding-secret cipher moves to internal/infrastructure/bindingcipher and
  ToolCall to internal/infrastructure/postgres.
- NewSessionStoreMemory is now a pure in-memory store that passes the shared
  SessionStore conformance suite.
- Tests run against PostgreSQL through internal/infrastructure/postgres/pgstore;
  legacyimport/legacyfixture writes the legacy files the import and the boot
  gate read.
- The cron dialect is owned in internal/domain/scheduling, so
  github.com/pocketbase/pocketbase and pocketbase/dbx leave go.mod.
  modernc.org/sqlite stays for the one-time import (legacyread).
- The UI and Messaging architecture gates ban the Postgres and legacy readers
  in place of internal/store.
2026-09-24 14:43:50 +10:00
sam 8a2b5b95f9 merge: t2db.40 sources and signing into pg/foundation
Resolves against t2db.36: captures carry both event_type and unsigned (proto field 10), the State Store serves sources and event types from the Postgres EDA store, the capture row shows event type and signature together, and the staterpc sentinels map both ways from one table.
2026-09-24 14:38:40 +10:00
sam 684ec1263a feat(eda): sources own signing, with UUIDv7 paths and approved unsigned option
A source is the capture endpoint: a UUIDv7 path by default or a unique
URL-safe custom path, signed by default with an Archie-generated secret
(encrypted via the bindings cipher), or unsigned after an approval.
Intake verifies X-Hub-Signature-256/X-Signature-256 against the source
secret before redaction; an unauthenticated event on a signed source is
captured but never dispatched, an event on an approved unsigned source
dispatches and is marked unsigned. The binding secret is retired; migration
0006 derives sources from existing binding and capture source strings,
moving each binding's secret onto its source. SourceStore crosses the
State Store gRPC contract. The dashboard gains a sources panel and flags
unsigned in the capture inspector, binding list and task timeline.
2026-09-24 14:26:21 +10:00
sam 60b88ad6d3 Merge branch 'worktree-agent-a2b33953bdffebf56' into worktree-giggly-marinating-lamport
# Conflicts:
#	docs/data/generated/dev-docs.json
#	internal/app/archied/state_store_pool.go
2026-09-24 10:06:00 +10:00
sam cea88060b1 feat(archied): serve the State Store, event store and Gateway conversations from Postgres
The State Store's task and event-capture stores and the conversation store
read by archied and served by archie-gateway now open on database_url.
Every serving process refuses to start when legacy SQLite data exists and no
import completion is recorded, naming archie-state-store import; a fresh
install records completion itself. The Gateway holds its Postgres serve
claim for its lifetime and releases it before the pool closes.
2026-09-24 10:01:54 +10:00
sam 3fc710fbe7 Merge branch 'worktree-agent-a091696d945ed3377' into worktree-giggly-marinating-lamport
# Conflicts:
#	cmd/archie-state-store/recovery.go
2026-09-24 09:56:10 +10:00
sam d80c01b9fb feat(archied): recovery commands on PostgreSQL; fail-closed pre-update snapshot, no automatic schema rollback
Without -db, backup/restore/validate/rollback resolve database_url from the
config and work on the whole PostgreSQL database. Restore claims every service
role; rollback claims the State Store role; validate refuses a schema newer
than the binary. The installer refuses a daemon update it cannot snapshot
first; the watchdog never restores the database and prints the explicit
offline restore instead.
2026-09-24 09:50:10 +10:00
sam 9298c8f2c3 fix(state-store): real-process tests give the State Store a database_url 2026-09-24 09:48:58 +10:00
sam 823a7d0b40 feat(state-store): one-time import of the legacy SQLite stores into Postgres
archie-state-store import copies the State Store task database, the
PocketBase event store and the Gateway conversation store, all named from
db_path, into Postgres in one transaction. The bead asked for an archied
command; offline maintenance of a store belongs to the binary that owns it,
so it sits beside backup/restore/validate/rollback instead.

It refuses rather than guesses: while the state-store or gateway ownership
claim is held, when a domain it imports already holds rows (an allowlist of
that domain's tables, checked after Migrate), on a completed prior import,
on FK orphans, alias case collisions, duplicate bindings, events whose (at,
id) order microsecond storage would change, schema gaps, and any value the
target column cannot hold, naming table, row, value and rule. Historical ids
are kept and every identity sequence is set from AUTOINCREMENT's high-water
mark. After loading it compares key sets, event order, resource blobs and
binding secrets byte for byte and the next id of every sequence, checks the
source files were not written while read, and only then writes an
import_completion row (migration 0005) in the same transaction.

postgres.ImportComplete and legacyimport.HasLegacyData are the two halves
of the boot gate: legacy data without a completed import must not serve.
2026-09-24 09:45:26 +10:00
sam 8350caf6da refactor(state-store): remove the PocketBase admin view
stateadmin served read-only PocketBase views over the SQLite task file on -admin-addr. PocketBase is SQLite-only and the State Store moves to Postgres (archie-core-7r0x), so the view goes; operators use a Postgres tool of their choice.
2026-09-24 01:09:42 +10:00
sam ee16b8a711 feat(playbooks): archie-playbooks serve, a language server publishing lint findings as diagnostics 2026-09-23 22:22:56 +10:00
sam 69e6d276e6 feat(playbooks): lint an EDA playbook directory with -eda-dir 2026-09-23 22:11:01 +10:00
sam 75454d22c1 feat(workflow): routing and playbook findings carry the key's file:line 2026-09-23 21:41:56 +10:00
sam ba52a34d83 feat(edastore)!: move event capture and bindings onto PocketBase collections
The event-capture tables (captures, mappings, bindings, binding_dispatches,
playbook_dispatches) now live in PocketBase-owned collections and their ids
are opaque record ids rather than autoincrement integers. The task lifecycle
stays on SQLite: tasks/transitions/events carry FIFO claim ordering, id-cursor
pagination and the task-grant map, none of which gain anything from being
hand-editable. binding_dispatches.task_id is the single seam and stays an
integer addressing that store.

BREAKING: CapturedEvent.Id, Mapping.Id, Binding.Id and Binding.MappingId are
strings on the wire, as are the ids in the capture/mapping/binding requests.
RecordDispatchRequest.task_id is deliberately unchanged.

What the collections buy, beyond storage: a payload nobody has modelled yet is
inspectable, a mapping is editable at runtime, and a binding's relation to its
mapping is enforced. The old schema declared no FOREIGN KEY on that link, so a
dangling mapping_id was previously possible and is now refused.

Behaviour preserved deliberately, each recovered from the SQLite version
rather than reimplemented from memory:
  - draft -> pending_approval -> armed, with approval only from
    pending_approval and an edit always returning a binding for re-approval
  - one binding per source, guarded on insert, update and approve
  - an empty secret on update keeps the stored one, so an edit form that does
    not echo it back cannot silently disarm a binding
  - ErrMappingNotFound / ErrBindingNotFound on a missing delete target
  - sentinels are re-exported from storecontract, never redefined: staterpc
    matches on exact canonical message to rehydrate them, so a second
    definition would break errors.Is across the wire invisibly

Two implementation notes worth keeping:
  - at-most-once dispatch is now a unique index rather than INSERT OR IGNORE.
    Only the unique-violation maps to ErrAlreadyDispatched; any other save
    error is returned, because treating them all as "already recorded" would
    turn the ledger into a silent at-least-once dispatcher.
  - captures store received_at themselves at nanosecond precision in a
    fixed-width layout. PocketBase autodates are millisecond and record ids
    are random, so same-millisecond captures would otherwise order
    arbitrarily; the old store got insertion order free from autoincrement.
  - ListUndispatchedCaptures is raw SQL: the anti-join is a subquery and
    PocketBase's filter DSL is not SQL. A read fires no hooks either way.

Adds tool_calls, which had no persistence at all: tool calls only ever reached
the on-disk task log, readable as text but never queryable or watchable.
Nothing writes it yet.

The binding secret cipher moves with the bindings it protects.
2026-09-23 02:19:28 +10:00
sam 97f55793c4 feat(stateadmin): read-only operator dashboard over the State Store
Serve an optional PocketBase surface over archie.db from the process that
already owns it, behind archie-state-store -admin-addr. It co-tenants on
<db_path>-tasks.sqlite via PocketBase's DBConnect hook rather than opening a
database of its own, so the single-owner ownership claim covers it and
PRAGMA user_version stays archie's.

Every archie table is exposed as a view collection, which is read-only by
construction. Views alone do not hold that line: PocketBase also ships
POST /api/sql, which executes write statements as well as reads, and
/api/backups, which would put a second snapshot and restore semantics beside
store.Backup's VACUUM INTO. Both routes are refused rather than left behind a
superuser check, because a superuser writing task state is still a second
writer. The gRPC contract remains the only writer.

apis.NewRouter binds the JSON API but not the dashboard (apis.Serve mounts the
embedded UI itself), so /_/ is mounted here and the caller keeps the listener.

The dependency pin and the Taskfile/README changes for this landed with the
preceding commit, which swept up the staged files.
2026-09-23 00:37:15 +10:00
sam 2a4e764718 refactor(indexing): delete the workspace codesearch indexer
The index built google/codesearch over the chat workspace on every daemon
start, for the process lifetime, through a child-process helper and a
SQLite metadata DB -- and grep consulted it only for searches confined to
the workspace root, which the analysed sessions showed was a small
fraction of searches. The compute was continuous; the benefit was not.

Removes internal/indexing, the workspace-codesearch helper subcommand,
the [indexing] config section, and the GrepIndex accelerator seam from
the grep tool, which returns to its direct walk. google/codesearch
leaves go.mod with it.
2026-09-23 00:36:38 +10:00
sam 3f17821cd8 chore: cleanup incorrect phrasing on package comments. 2026-09-22 21:36:53 +10:00
sam 79f521b65b feat(webui): let a person sign in and act as themselves
The last gap in the identity boundary: enabling a provider used to lock browsers
out, because nothing could turn a sign-in into the credential the dashboard already
verifies. Now a browser completes the authorization code flow with PKCE and the
identity reaching the request context is the person who signed in.

The audience is requested AT THE AUTHORIZATION ENDPOINT, not only at the token
endpoint. Infra measured that a provider asked otherwise returns the audience empty,
and this dashboard then refuses a perfectly valid token -- a failure that reads as a
signing fault and is actually a missing query parameter. A test asserts the
parameter is present, so it cannot quietly go missing.

The flow is the libraries': discovery, the code exchange, PKCE generation and the
challenge transformation are go-oidc and x/oauth2, so archie writes no protocol. The
token returned by the exchange is verified through the SAME Verifier a presented
token goes through, and the identity is then resolved through the same rule -- one
Resolve now shared by Authenticate and the callback, so a browser sign-in cannot be
accepted on terms a presented token would be refused on.

Archie still issues no session. The callback stores the PROVIDER's token in an
HttpOnly cookie and every later request re-verifies it, so what archie holds cannot
outlive the provider's own decision. The callback checks the state it issued, and
expires the state and PKCE verifier cookies on use.

The sign-in routes mount on the bypass mux because they are how a caller becomes
authenticated; gating them behind the credential they obtain would make signing in
impossible. The client secret is never a flag: -oidc-client-secret-env names the
environment variable holding it, so it cannot reach a process listing or a log line.
No client id means no sign-in route and token verification is unaffected, which is
what an agent-only deployment wants.

Evidence, produced by driv·ng the flow rather than the seam:
internal/webui/api_tasks_actor_test.go's TestBrowserSignInRecordsTheSignedInPerson
walks sign-in -> callback -> cookie -> action and asserts the recorded actor is the
signed-in person with human_approved. TestCallbackRefusesAMismatchedState asserts a
replayed state is refused before any credential is verified.
internal/infrastructure/oidc/flow_test.go runs the real flow against a test
provider's own authorize and token endpoints, asserting the audience parameter, the
PKCE challenge, a successful exchange, and a refused wrong verifier.

Verified: task check exit 0 on this tree.
2026-09-22 14:59:03 +10:00
sam ec0f17a7ad feat(update): let every host binary report its version, and refuse skew
The updater is component-driven: it compares the daemon and agent versions and
acts only when they differ, so a host whose individual binaries disagree looks
healthy. Carina ran a hand-installed archie-messaging 1.35.0 against a 1.30.0
state store and crash-looped on an RPC the older store does not serve, while
the updater reported "no approved component changes; nothing to install".

The reason a comparison was impossible: three of the six host binaries carried
no version at all. archie-ui, archie-messaging and archie-playbooks did not link
internal/app/archied, so the release ldflags never reached them; the gateway and
state store linked the variable but exposed no flag. Only archied could say what
it was.

- internal/buildinfo carries Version, stamped by all three build sites: the
  zip, install.sh, and the updater itself.
- Every host binary answers -version ("<name> <version>"). archied's existing
  two-line output is unchanged, because something parses it.
- archie-update-install reads each installed binary before it can report
  "nothing to install" and refuses, naming every binary that disagrees with the
  daemon's version; after an install it verifies the same set against the
  release it just installed, so a binary the release did not rebuild is skew
  rather than success.
- TestDistZipShipsEveryHostCommand pins stamping across the three build sites
  and requires each cmd/ to report, so a seventh command cannot arrive unstamped.
2026-09-22 14:52:18 +10:00
sam 8e4e353805 feat(identity): attribute a task action to the identity that acted
The transport could carry an actor and nothing filled it. It does now, so a
dashboard approval is recorded as the person whose credential verified, and an
agent's token is recorded as the agent's action -- for an agent, agent_approved;
for a person, human_approved; and for a caller whose identity archie could not
verify, task_approved, which claims nothing about who did it.

The actor travels the path the action takes: webui reads it from the request
context the middleware resolved, carries it in the gateway request, the daemon
passes it through the in-process adapter, and the NATS request body carries it to
the service that records it. Scope stays separate from actor at every hop, because
scope is which task a caller may touch and the actor is who touched it.

A chat channel's bound identity is an actor too: a bot acting on its own channel's
task is recorded as an agent's action rather than a person's, via ActorFromScope,
whose empty kind is what keeps it out of human_approved. The agent-facing
task_action tool passes that identity and never input["identity"].

The UI process's credential check is now filled by endpoint references rather than
by configuration: -oidc-issuer and -oidc-audience on archie-ui, two URLs the
process already understands the shape of, with the verifier built in Run because
cmd/ parses flags and nothing else. The UI package still never reads config, and a
configured provider that cannot be reached fails boot rather than falling back to
the gate that names nobody.

Evidence for this change, stated as measured: go build ./... and go vet ./... are
clean, and every package this touches passes -- webui, domain/taskactions,
infrastructure/taskactions, infrastructure/gatewayrpc, gateway, app/archieui,
app/archied, domain/messaging, channels/telegram, cmd/archie-ui. task check could
not be run to completion: it fails in cmd/archie-messaging on an untracked
internal/buildinfo package another lane has in flight, which is not this change and
was left untouched. The end-to-end flip is covered in
internal/webui/api_tasks_actor_test.go: a person's credential produces a record
naming that person with human_approved, an agent's produces agent_approved, an
unverified request produces task_approved with no actor, and a request carrying
forged actor fields cannot name one.
2026-09-22 14:52:10 +10:00
sam a7d6cc8c9d refactor(messaging): sever the Messaging Service from the store and workflow runtime
The PRD's deletion gate for the Messaging Service could not pass: go list -deps
./cmd/archie-messaging linked modernc.org/sqlite, internal/store,
internal/domain/workflow and internal/agentexec -- all through one import,
archiemessaging/run.go -> internal/app/controlplane, from which the service used
three symbols. The decision was to sever rather than amend the gate, because a
boundary you whitelist around is no longer a boundary (archie-core-1ng1, recorded
in docs/architecture/migration-decisions.md).

Measured before touching anything: internal/app/controlplane was the ONLY direct
import of the service that dragged those runtimes -- every other one was clean --
so severing this one dependency is sufficient for the gate.

Moved into the new internal/infrastructure/controlplanerpc: the generic resource
client (NewRPCClient, Query), the RuntimeChatConfig projection, the reader
interface (now the exported ResourceReader), the wire sentinels, the status
mapping (now ClientError), and the channel-settings document with its decode --
ChannelSettings, TelegramSettings, WebhookChannelSettings, EmailSettings,
RateLimitSettings, ChannelDuration, DecodeRenamingLegacyKeys.

internal/app/controlplane keeps the store-backed server, the Definition registry,
every kind's seed/validator/Normalize, the schema derivation, and its
resource-specific reads and watches. Its Client embeds the new one, so the read
path has one implementation while the workflow, persona and cronstore reads stay
with the processes that already link those engines. The documents are type-aliased
back into this package so the store-backed side reads them by the names it has
always used: one definition, not a copy on each side of the boundary.

The gate is now enforced by cmd/archie-messaging/architecture_test.go, measuring
the linked binary against the PRD's banned list, with one exception checked in
both directions: internal/domain/workflow/task, the Task status and view
vocabulary whose own dependency set holds none of the banned runtimes. The UI gate
carries the same entry for the same reason, and the fleet skill names it as the
precedent.

Verified: task check exit 0. The gate was red-proofed twice -- banning
internal/channels fails it, and removing the workflow/task exception fails it --
so neither the loop nor the exception is decorative.
2026-09-22 07:26:55 +10:00
sam 7a8bb8e47b docs: drop one host's service names from port guidance
Five files named a specific host's service and the port it holds as the
reason a deployment might move the state store's listen address, including
config.example.toml, which ships to every operator. The guidance keeps its
point -- move the listen/target pair together when a port is already taken
on the host -- without naming a service the reader may not run, or have
heard of.

Also corrects the Taskfile's dev-stack summary, which still described the
state store as binding 127.0.0.1:9090. deployments/dev.toml pairs it with
9091, and has since the pair became configurable, so the comment described
a stack that does not start.
2026-09-22 04:09:16 +10:00
sam 0263bf4e0d fix(configuration): resolve the default config path in one place
Four binaries derived the default with os.UserConfigDir while the daemon
resolved it from its own config home. The two agree on Linux with an
absolute XDG_CONFIG_HOME and diverge everywhere else, so one deployment
booted from a different config file depending on which binary started.

Move the rule into the package that owns configuration resolution
(internal/infrastructure/configuration, which already owns xdgDataHome and
DefaultWorkDir) as DefaultConfigDir/DefaultConfigPath, and have every
-config default take it from there: archie-gateway, archie-messaging,
archie-state-store (serve and recovery) and archie-ui, plus the daemon's
own parseArgs, setup generator and drain-marker path.

Fence the claim at the source, since the resolved value is only observable
by starting a process: no source under cmd/ or internal/app/archied may
call os.UserConfigDir, and every -config registration must default to the
helper.
2026-09-22 01:57:49 +10:00
sam 9a45a35c27 fix(config): judge a database-owned setting at the layer that owns it
Review of the two previous commits found the split was incomplete in both
directions: the checks moved off the file load path were still enforced
anywhere the value could enter the system, and the fold reached only one of the
three overlay paths.

A stale database-owned TOML value could still stop archie-state-store. The
process seeds every control-plane resource from the same file config on a fresh
database, and the seed runs the resource's own validator; three of the five
values the loader now accepts aborted the boot there (verified by booting
RunStateStore before the fix). A seed that does not validate is now SKIPPED and
reported instead of fatal: the resource stays absent, so the file's value is the
one in effect and editing config.toml is still the fix -- the daemon and the
Gateway are where it fails closed, at boot.runtimeConfig.

The resource validators were weaker than configuration.Validate for exactly the
fields the split reclassified, so a value the file path used to refuse at load
became storable in the database, and then un-fixable by editing config.toml.
The trigger enum and the test-glob rule now come from the configuration package
rather than being restated, the container image is required there as it is in the
file, and a table test ties the two layers together value by value.

The directory form of -config-overlay kept the archie-core-e2e2 failure: it
decoded each overlay file straight into the populated config, so a map-valued
entry it only partly addressed still cleared the fields it did not name. Both
the overlay layer's main file and its feature files now fold, which is what
Loader.Dir's documented parity with Loader.Overlay has always claimed.

The overlay file's key report is derived from the apply's own view of the file as
well as the file decode's, because TOML matches keys case-insensitively and the
fold's yaml decode does not: a key only the file decode matched was consumed by
the report and dropped by the apply, a silent no-op that worked in the base file.

Tests: the state-store boot is asserted against the real process, the directory
overlay and the case-mismatched key each have one, and ImportConfig pins that a
refused seed is not stored.
2026-09-21 22:12:32 +10:00
sam be321d81bc fix(statestore): build the recovery control-plane server on the shared step vocabulary
After the rebase onto main, controlplane.NewServer takes the step vocabulary
it resolves definitions against (controlplane.ResourceStore, *workflow.Manager)
and returns (Server, error). Both offline call sites still passed the store
alone, so internal/app/archied stopped compiling -- and with it
cmd/archie-state-store, cmd/archied and cmd/archie-gateway.

validate and rollback now build their server through
openStateStoreControlPlane, the root helper the served path already uses, so
the offline checks resolve the same shared provider set
(internal/infrastructure/workflowsteps) as the process whose verdict they
predict, and the constructor's error is returned as a refusal rather than
dropped. No second vocabulary call site: the fwmp pin on
openStateStoreControlPlane covers these paths unchanged.

The test's seeding helper builds its server from the same shared set
(workflowsteps.NewManager) because it cannot call the unexported root helper;
an empty manager there would seed values the served path never validates
against. That is not merely a claim: with an empty manager the three
validate tests fail with `workflow "bootstrap" step 1: unknown type
"bootstrap.prepare"`, so they already pin that the offline path resolves a
live, shared vocabulary.
2026-09-21 22:07:41 +10:00
sam 08df95684c fix(statestore): read a kind the store does not hold as its seed, and stop validate touching the daemon's log
Four defects from the re-run contract review, all in the recovery path.

A store missing a control-plane kind was refused while a store with no
resources table at all was accepted -- two stances inside validateStore for
states the daemon cannot tell apart. The State Store seeds every kind from
its own config before it serves (RunStateStore -> ImportConfig), so a kind
the file does not hold yet is one archied reads the seed for: an upgrade that
adds a kind, and a validate before the State Store has started again, exited
1 with "read provider-settings: resource not found" for a store the daemon
boots on fine. StoredRuntimeConfig now reads a missing kind as the seed the
State Store would write for it (Definition.seededValue, shared with
ImportConfig so the two cannot drift), and the missing-table branch is the
same stance taken to its extreme.

defaultConfigPath() derived the daemon's config with os.UserConfigDir, which
disagrees with archied's configHome on darwin and rejects a relative
XDG_CONFIG_HOME outright -- leaving validate with an empty path and no
verdict, on a host where archied boots from relative-dir/archie/config.toml.
It is now the daemon's own rule, exported as archied.DefaultConfigPath and
used by the daemon's own -config default too, with a test pinning the
equality.

-h exited 2, the code documented as "the command line was wrong", while the
serve path in the same binary exits 0 and main.go advertises -h for these
subcommands. ErrHelp now returns 0.

validate resolved the boot config through loadConfig -> setupLogging, which
created cfg.Log.File's directory, opened the log, and wrote a line stamped
component="daemon" -- a diagnostic editing the deployment it inspects, and
rotating a log the daemon is writing. boot.stderrLog keeps setupLogging on
the stderr logger for the recovery path: no feed, no task-log registry, no
durable copy.

Tests: TestRecoveryValidateRunsTheGateBootRuns now asserts the unseeded and
the missing-kind stores are accepted (both exited 1 before), while the
bogus-policy case still refuses; TestRecoveryHelpExitsZero,
TestRecoveryValidateLeavesTheDaemonLogAlone and
TestRecoveryDefaultConfigFollowsTheDaemonsConfigHome are new. Each was run
red first, and the seed fallback and stderrLog were mutation-checked.
2026-09-21 22:04:42 +10:00