docs: describe the PostgreSQL-only stores, state_dir and the import-only db_path
Architecture, deployment, installer, skill and PRD text now name the Postgres State Store, the offline recovery commands on database_url, state_dir for host state, and db_path as the legacy-file locator for archie-state-store import. Finalised PRDs, CHANGELOG, docs/news and docs/archive are unchanged records.
This commit is contained in:
1 parent
b6010a7913
commit
5c8a8b2393
39 files changed
+248
-219
No files matched your search
@@ -6,6 +6,11 @@
|
||||
|
||||
## Problem
|
||||
|
||||
> Storage superseded: every store now lives in PostgreSQL behind
|
||||
> `internal/domain/storecontract`, implemented in `internal/infrastructure/postgres`
|
||||
> (`docs/prds/state-store-contract.md`). SQLite names below describe the
|
||||
> original design.
|
||||
|
||||
`binding.Binding.Secret` (the per-source HMAC shared secret) is persisted as
|
||||
plaintext in the `bindings.secret TEXT` column. Anyone with read access to the
|
||||
SQLite file -- the same access level as `captured_events.body` and `tasks.body`
|
||||
@@ -94,8 +99,8 @@ old material must be retained.
|
||||
- `internal/app/archied/bootstrap.go` `openStores`: resolve both refs through
|
||||
the already-built `secrets` registry, pass the material to `store.Open` via a
|
||||
new option `store.WithBindingCipher(cipher)`.
|
||||
- `internal/store`: add a `BindingCipher` interface (concrete AES-GCM impl in
|
||||
`binding_cipher.go`), a `bindingCipher` field on `Store`, and the `Open`
|
||||
- `internal/infrastructure/bindingcipher`: the `BindingCipher` interface and
|
||||
concrete AES-GCM impl, consumed by the event-capture store; a `bindingCipher` field on `Store`, and the `Open`
|
||||
option. **Nil cipher = plaintext**, so existing call sites and tests change
|
||||
nothing and legacy deployments keep current behaviour until they set a key.
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ served by one registered engine whose `Manifest()` is the stored definition and
|
||||
whose `Pass` composes `instructions` with the built tool set.
|
||||
|
||||
This is the curator domain's missing half, not a standalone tool: it lands in
|
||||
`internal/domain/curator` (entity + engine), `internal/store` (persistence),
|
||||
`internal/domain/curator` (entity + engine), `internal/infrastructure/postgres` (persistence),
|
||||
`internal/webui` (CRUD), and `internal/app/archied` (seed + apply wiring).
|
||||
|
||||
## Definition sources and the merge rule
|
||||
@@ -147,7 +147,7 @@ without a restart.
|
||||
|
||||
## Sequencing: persistence and the State Store
|
||||
|
||||
The State Store is a standalone process that solely owns `archie.db`; the daemon
|
||||
The State Store is a standalone process that solely owns the task database; the daemon
|
||||
and Gateway never open it (`TestOpenStoresNeverOwnsTaskDB` guards this), and
|
||||
`proto/state/v1/state.proto` is one gRPC service fronting every ratified store
|
||||
contract. AGENTS.md forbids adding a Go interface method without a matching RPC.
|
||||
@@ -162,7 +162,7 @@ That fixes the order:
|
||||
Phases 1 and 2 are genuinely independent of the wire boundary, so they are not
|
||||
blocked on it. Phase 3 is where the boundary is unavoidable: a definition the
|
||||
WebUI can edit must be reachable from the WebUI, and the WebUI reaches the store
|
||||
through the State Store, not by opening `archie.db`. Splitting the RPCs into a
|
||||
through the State Store, not by opening the database. Splitting the RPCs into a
|
||||
later change would leave a table nothing can read -- rejected. Deferring the
|
||||
whole phase is the same rejection, later.
|
||||
|
||||
|
||||
@@ -353,10 +353,15 @@ single-action playbooks the two granularities are equivalent in effect;
|
||||
the difference starts with multi-action runs -- where whole-run keying
|
||||
would already be wrong.
|
||||
|
||||
> Storage superseded: every store now lives in PostgreSQL behind
|
||||
> `internal/domain/storecontract`, implemented in `internal/infrastructure/postgres`
|
||||
> (`docs/prds/state-store-contract.md`). SQLite names below describe the
|
||||
> original design.
|
||||
|
||||
**Storage/lookup: a new durable ledger table `playbook_dispatches` in
|
||||
`internal/store`, copying `binding_dispatches`'s conventions exactly**
|
||||
the event-capture store, copying `binding_dispatches`'s conventions exactly**
|
||||
(durable table, `INSERT OR IGNORE`, sentinel error, rows freed with
|
||||
their parent, survives daemon restarts -- `internal/store/bindings.go`):
|
||||
their parent, survives daemon restarts -- `RecordDispatch`):
|
||||
|
||||
```sql
|
||||
CREATE TABLE playbook_dispatches (
|
||||
@@ -376,9 +381,9 @@ write rather than a constraint error, and the caller matches it with
|
||||
(`internal/daemon/daemon.go` -- "another cycle already won this
|
||||
race," not an error to surface). The record is consumed by the playbook
|
||||
coordinator at dispatch time through a domain-side interface implemented
|
||||
by `internal/store` -- the same shape as `BindingDispatcher`
|
||||
(`internal/store/interface.go`) -- and the table lands in the
|
||||
store's schema application (`internal/store/store.go`). No change
|
||||
by the event-capture store -- the same shape as `BindingDispatcher`
|
||||
(`internal/domain/storecontract`) -- and the table lands in the
|
||||
store's schema migrations. No change
|
||||
to `internal/eventbus`; no per-message dedup state on the client.
|
||||
|
||||
**Lifetime: no time-based expiry, and no automatic reclamation.** Rows are
|
||||
|
||||
@@ -41,7 +41,7 @@ Three further defects fall out of the same split:
|
||||
nothing, and a webhook populates it with nothing either — a route path names
|
||||
a source, not a person, so `webhook.go` leaves `SenderID` empty and carries
|
||||
the route in `Inbound.BudgetKey` for rate limiting. `sender_id` is persisted
|
||||
(`session_store_sqlite.go`), so whatever a channel puts there reaches the
|
||||
(`session_store_postgres.go`), so whatever a channel puts there reaches the
|
||||
consumers that read it.
|
||||
|
||||
`agent-system.md` says the write-scope selection and cross-scope sharing
|
||||
@@ -230,7 +230,7 @@ and would leak user A's extracted facts to user B through the same agent;
|
||||
user-wide would pool facts across agents; and a session id cannot survive the
|
||||
session ending, which is the whole requirement.
|
||||
|
||||
This needs data the tree does not persist: the SQLite `messages` table
|
||||
This needs data the tree does not persist: the `messages` table
|
||||
gains `sender_id`, and `curator.SessionSummary` / `ConversationMessage` gain the
|
||||
agent and participant. The participant is derived from the session's own
|
||||
user-role messages: exactly one distinct non-empty sender writes; zero (a
|
||||
|
||||
@@ -16,7 +16,7 @@ The Messaging Service (`cmd/archie-messaging`, composed via `internal/app/archie
|
||||
It is a peer service to the UI Service and the daemon:
|
||||
- It serves external chat participants across configured communication platforms.
|
||||
- It consumes Gateway's `messaging.ChatContract` exclusively for chat turn execution, streaming, session queries, cancellation, persona selection, and task control actions.
|
||||
- It holds no direct database connections (`*store.Store` or SQLite), owns no LLM execution or model provider credentials, and has no dependency on the daemon runtime or the UI HTTP server.
|
||||
- It holds no direct database connections, owns no LLM execution or model provider credentials, and has no dependency on the daemon runtime or the UI HTTP server.
|
||||
|
||||
## Boundary and Ownership
|
||||
|
||||
@@ -24,7 +24,7 @@ It is a peer service to the UI Service and the daemon:
|
||||
|---|---|---|---|
|
||||
| **Channel transports** | Telegram bot long-polling, Email IMAP/SMTP loops, Inbound Webhook HTTP listener | Gateway `ChatContract` | Direct LLM providers, model runtimes, tokenizer libraries |
|
||||
| **Turn dispatch** | Inbound message packaging, typing indicators, live streaming updates | `ChatContract.Route`, `ChatContract.Stream` | `gateway.Router`, `runtime.Runtime`, agent prompt builders |
|
||||
| **Sessions & History** | Platform-to-session key mapping, conversation thread ID translation | `ChatContract.GetSession`, `RecentMessages`, `RecentTurns` | `*store.Store`, `SessionStore` SQLite handles, direct database files |
|
||||
| **Sessions & History** | Platform-to-session key mapping, conversation thread ID translation | `ChatContract.GetSession`, `RecentMessages`, `RecentTurns` | store implementations, `SessionStore` database handles |
|
||||
| **Control & Actions** | Platform command parsing (`/status`, `/tasks`, `/cancel`, `/stop`, `/persona`) | `ChatContract.Snapshot`, `ApplyTaskAction`, `Cancel`, `SetPersona` | `daemon.Daemon`, workflow execution engine, worktree operations |
|
||||
| **Task Approvals** | Channel interactive keyboards, approval callbacks | `ChatContract.ApplyTaskAction` | Direct task status mutations, forge comment posters |
|
||||
| **Configuration** | Platform bot tokens, allowed sender/user IDs, webhook listen ports | `[chat.*]` channel configs, Gateway target/token | `config.Holder`, forge tokens, repo configs, agent container specs |
|
||||
@@ -66,7 +66,7 @@ It does not read or decode `[forge]`, `[repos]`, `[models]`, `[providers]`, `[ru
|
||||
## Deletion Gate and Verification
|
||||
|
||||
The extraction is guarded by `cmd/archie-messaging/architecture_test.go`, verifying that `go list -deps ./cmd/archie-messaging` links zero banned runtime packages:
|
||||
- `modernc.org/sqlite` and `internal/store` (State Store)
|
||||
- `modernc.org/sqlite`, `github.com/jackc/pgx`, `internal/infrastructure/postgres` and `internal/infrastructure/legacyread` (State Store)
|
||||
- `internal/daemon`, `internal/app/archied`, `internal/container`, `internal/worktree` (Daemon runtime)
|
||||
- `internal/domain/workflow`, `internal/agentexec`, `internal/taskrun` (Workflow engine)
|
||||
- `internal/forge`, `internal/forgerpc` (Forge client)
|
||||
|
||||
@@ -12,6 +12,11 @@ reference by ID.
|
||||
|
||||
## Decision: a new `internal/domain/mapping` package, SQLite storage
|
||||
|
||||
> Storage superseded: every store now lives in PostgreSQL behind
|
||||
> `internal/domain/storecontract`, implemented in `internal/infrastructure/postgres`
|
||||
> (`docs/prds/state-store-contract.md`). SQLite names below describe the
|
||||
> original design.
|
||||
|
||||
`internal/domain/mapping` owns the mapping vocabulary and the pure
|
||||
resolve/preview rule; `internal/store` persists it (mirrors
|
||||
`captures.go`'s shape exactly -- inline schema const, narrow store
|
||||
@@ -107,7 +112,7 @@ is `t2db.4`'s job, not duplicated here.
|
||||
|
||||
## Storage
|
||||
|
||||
`internal/store/mappings.go`, `field_mappings` table: `id, name,
|
||||
The `mappings` table: `id, name,
|
||||
source_hint, fields_json, created_at, updated_at`. `fields_json` is the
|
||||
`[]Field` slice JSON-encoded into one column -- fields have no independent
|
||||
query need (nothing filters "mappings with a field named X"), so a
|
||||
|
||||
@@ -89,7 +89,7 @@ closed or archived is dropped through the same counter: the reaction is only
|
||||
ever work against a PR archie itself opened *and still owns*.
|
||||
|
||||
That lookup does not exist. `pr_number` is written by
|
||||
`internal/store/store.go` and never read in a `WHERE` clause, so this needs a
|
||||
`internal/infrastructure/postgres/store.go` and never read in a `WHERE` clause, so this needs a
|
||||
`TaskStore` method keyed on `(owner, repo, pr_number)`, a matching
|
||||
`StateStoreService` RPC (a Go interface method on a store facade without one
|
||||
is forbidden, `CLAUDE.md`), and an index on those three columns. It is the
|
||||
@@ -97,7 +97,7 @@ authorization boundary, so it is sequenced as its own step below rather than
|
||||
carried along with the envelope.
|
||||
|
||||
**Identity is derived from the resolved task, never carried in the reaction.**
|
||||
The task row already stores `identity` (`internal/store/store.go`), and it is
|
||||
The task row already stores `identity` (`internal/infrastructure/postgres/store.go`), and it is
|
||||
the resolved task's identity that selects the forge client, worktree manager,
|
||||
repo config and `bot_user` for the remediation run and the `ReplyToReview`
|
||||
reply, through the existing `forgeFor`/`treesFor`/`repoFor` helpers. That is
|
||||
|
||||
@@ -42,7 +42,7 @@ boundaries.
|
||||
| Scheduler Service | cron/ticker contract | `internal/domain/scheduling` |
|
||||
| Execution Environment | execution-dispatch contract | `internal/domain/workflow`, task dispatch paths |
|
||||
| Runner | isolated worktree/container execution | `internal/container`, `internal/agentexec`, `internal/worktree` |
|
||||
| State Store | state-access contract | `internal/store` |
|
||||
| State Store | state-access contract | `internal/infrastructure/postgres` |
|
||||
|
||||
### Discovery
|
||||
|
||||
@@ -191,8 +191,8 @@ historical record rather than an outstanding gate.
|
||||
State Store service's contract (less isolation, less migration risk).
|
||||
Not yet decided.
|
||||
|
||||
**RESOLVED.** One State Store service owns the existing
|
||||
single SQLite file behind narrow typed contracts (`TaskStore`,
|
||||
**RESOLVED.** One State Store service owns the task data
|
||||
(now PostgreSQL, see `docs/prds/state-store-contract.md`) behind narrow typed contracts (`TaskStore`,
|
||||
`CaptureStore`, `MappingStore`, `BindingStore`, `WorkflowStore`) over
|
||||
gRPC. *(Ratified 2026-09-06: the workflow contract is now the
|
||||
domain-owned `workflow.Store`, which supersedes
|
||||
@@ -201,7 +201,7 @@ historical record rather than an outstanding gate.
|
||||
No physical database-per-service: the solo-maintainer / team-
|
||||
topology rule of thumb plus the low value of per-service autonomy for
|
||||
one person rule it out, and one store means no distributed-transactions
|
||||
problem. The Gateway keeps its own already-separate session SQLite.
|
||||
problem.
|
||||
Concrete migration path (generalise `storerpc`, swap consumers one
|
||||
contract at a time, stand up the store service, split the file only on
|
||||
evidence):
|
||||
@@ -212,7 +212,7 @@ historical record rather than an outstanding gate.
|
||||
`docs/prds/state-store-contract.md` (rev. 2c): one `StateStore` gRPC service,
|
||||
42 RPCs; **ownership split** — consumer-owned `workflow.Store` +
|
||||
`workflow.Task`/`Status`/`Source` in the workflow domain (dependency rules
|
||||
#2/#7), producer-owned daemon/webui store surfaces in `internal/store`;
|
||||
#2/#7), producer-owned daemon/webui store surfaces in `internal/domain/storecontract`;
|
||||
the `Task`/`Status`/`Source` + interface relocation is a Phase 2
|
||||
prerequisite pulled from migration-decisions §4 (`store.Task →
|
||||
WorkflowExecution`); `RecordDispatch` drops `*sql.Tx`; `Close` off-wire;
|
||||
|
||||
@@ -16,6 +16,15 @@ split `archie.db`. It records method ownership, DTO/wire representation, error s
|
||||
limits, mode/config shape, local-adapter compatibility, and cutover/deletion rules so that
|
||||
`.4.2` and `.4.3` have exactly one authoritative surface to build against.
|
||||
|
||||
> **Storage superseded.** The store behind this contract is PostgreSQL:
|
||||
> `internal/infrastructure/postgres` implements the producer-owned interfaces in
|
||||
> `internal/domain/storecontract` and `workflow.Store`, over the database
|
||||
> `database_url` names. `internal/store`, the SQLite file and the local adapter
|
||||
> are gone; where this document says `archie.db`, `*store.Store` or
|
||||
> `internal/store`, read the State Store's PostgreSQL database and
|
||||
> `internal/infrastructure/postgres`. The contract, ownership split, error
|
||||
> semantics and cutover rules stand.
|
||||
|
||||
> **Current state — read before `.4.2` starts.** The §12 step 2 relocation (`archie-core-8cda.
|
||||
> 4.8`) has landed: `Task`/`Status*`/`Source*` and the 3-method `workflow.Store` now live in
|
||||
> `internal/domain/workflow`, the six production workflow files import no `internal/store`
|
||||
@@ -584,9 +593,9 @@ an explicit operator decision.
|
||||
`target` cannot boot, so the section ships uncommented.
|
||||
- Composition root: `internal/app/archied/bootstrap.go` (the daemon) and
|
||||
`internal/app/archieui/config.go` (the UI process) both read `cfg.Services.Get("state")` and
|
||||
dial the remote State Store. `openProductionTaskStore` is **not** called from the daemon: it
|
||||
lives in the standalone `archie-state-store` process (`internal/app/archied/state_store.go`),
|
||||
which is the only path that opens `archie.db`.
|
||||
dial the remote State Store. The task store is built only in the standalone
|
||||
`archie-state-store` process (`internal/app/archied/state_store.go`), which is the only path
|
||||
that opens the task tables.
|
||||
|
||||
> **Mode fork, decided.** The gateway uses a single `target` address (no enum). The State Store
|
||||
> boundary uses the same seam for symmetry, and **both now require a non-empty `target`**: the
|
||||
@@ -656,7 +665,7 @@ an explicit operator decision.
|
||||
contracts for a contract-code (no dual-live *window*; each contract is either local or remote
|
||||
at a time).
|
||||
7. **Final flip / deletion of the in-process serving path:** when the daemon no longer owns the
|
||||
store (i.e. `TaskStore` has moved), delete the in-process `openProductionTaskStore` /
|
||||
store (i.e. `TaskStore` has moved), delete the in-process task-store /
|
||||
`wireWebStoreSurfaces` path in the daemon in a **same-commit** deletion — no dual-store
|
||||
ownership. The single SQLite file remains owned by `archie-state-store`.
|
||||
8. **Never** split `archie.db` or add a second store. The gateway keeps its own already-separate
|
||||
|
||||
@@ -43,8 +43,8 @@ that has since moved on.
|
||||
|
||||
## Attempt attribution: a column, not a guess
|
||||
|
||||
`events.Event.Attempt`, persisted by `internal/store` as the `events.attempt`
|
||||
column (`internal/store/events.go`, `eventsSchema`), is a real column,
|
||||
`events.Event.Attempt`, persisted as the `events.attempt` column
|
||||
(`internal/infrastructure/postgres/migrations/0001_state_store.sql`), is a real column,
|
||||
`NOT NULL DEFAULT 0`. It was chosen over segmenting the stream on `task_queued` /
|
||||
`task_retried` because a fold would have to guess which side of a boundary an
|
||||
event belongs to when the daemon restarts mid-attempt, when `RecoverStale`
|
||||
@@ -60,6 +60,11 @@ attempt 1.
|
||||
|
||||
## Migration against an existing `archie.db`
|
||||
|
||||
> Storage superseded: every store now lives in PostgreSQL behind
|
||||
> `internal/domain/storecontract`, implemented in `internal/infrastructure/postgres`
|
||||
> (`docs/prds/state-store-contract.md`). SQLite names below describe the
|
||||
> original design.
|
||||
|
||||
The store's migrator (`migrateTasks` in `internal/store/store.go`) already reads
|
||||
`PRAGMA table_info` through `tableColumns` and applies a presence-gated
|
||||
`ALTER TABLE ... ADD COLUMN` list. This change adds an `events` arm: a
|
||||
@@ -249,8 +254,7 @@ than useless.
|
||||
|
||||
## Files this change touches
|
||||
|
||||
- `internal/store/`: the `events.attempt` column, its migrator arm, and the
|
||||
schema-presence test.
|
||||
- the State Store schema: the `events.attempt` column.
|
||||
- `internal/events/`: `Event.Attempt`, `KindChangesCaptured`,
|
||||
`KindConfigCaptured`, `ConfigCapturedSchema`.
|
||||
- `internal/domain/workflow/task/changes.go`: the change value types.
|
||||
|
||||
@@ -157,7 +157,7 @@ The implementation must complete these gates in order:
|
||||
behavior. Add a composition test proving the selected adapter is the one
|
||||
used by production wiring.
|
||||
3. Remove direct `internal/gateway` session/router/runtime access from web UI
|
||||
handlers. Remove direct `internal/store` implementation access, SQL access,
|
||||
handlers. Remove direct store implementation access, SQL access,
|
||||
daemon pointers, and broad runtime callback bundles from the UI constructor.
|
||||
4. Replace the shared `config.Holder` with the UI-owned configuration DTO and
|
||||
narrow configuration application contract. Prove reload/update atomicity
|
||||
@@ -177,7 +177,7 @@ The deletion gate is objective: `go list -deps` from the UI process shows no
|
||||
daemon, SQL/store implementation, workflow, forge, channel, model, or secret
|
||||
runtime package; production composition contains one UI HTTP listener; and
|
||||
architecture tests reject `config.Holder`, concrete `*store.Store`, concrete
|
||||
Gateway runtime types, and direct SQLite imports in the UI service.
|
||||
Gateway runtime types, and direct database drivers in the UI service.
|
||||
|
||||
Rollback is a deployment composition change that points the operator at the
|
||||
last validated UI binary and restores the previous endpoint configuration. It
|
||||
@@ -199,9 +199,9 @@ Current code proves the following migration inputs:
|
||||
Gateway-owned request/value types; handlers must finish the DTO projection.
|
||||
- `internal/webui/server.go:Handler` owns the route set, SPA fallback, health
|
||||
split, capture bypass, and token wrapper.
|
||||
- `internal/app/archied/state_store.go:RunStateStore` owns the task SQLite
|
||||
file and serves the State Store gRPC contract; the UI must use that contract
|
||||
rather than opening the file.
|
||||
- `internal/app/archied/state_store.go:RunStateStore` owns the task
|
||||
database and serves the State Store gRPC contract; the UI must use that contract
|
||||
rather than opening the database.
|
||||
- `internal/app/archied/gateway.go:RunGateway` serves Gateway gRPC and owns
|
||||
Gateway session persistence; the UI must use `ChatContract` rather than
|
||||
Gateway internals.
|
||||
@@ -230,17 +230,17 @@ form again: `internal/webui` receives no holder in any process.
|
||||
### Deletion gate: SATISFIED (archie-core-8cda.5.6, rev. 2)
|
||||
|
||||
The objective gate now holds. `go list -deps ./cmd/archie-ui` links **zero**
|
||||
banned packages: no `modernc.org/sqlite`, no `internal/store`, `internal/gateway`,
|
||||
banned packages: no `modernc.org/sqlite`, no `github.com/jackc/pgx`, no `internal/infrastructure/postgres`, `internal/gateway`,
|
||||
`internal/channels`, `internal/memory`, `internal/secret`, `internal/agentexec`,
|
||||
`internal/tools`, `internal/skill`, `internal/yaegiutil`, `internal/domain/curator`,
|
||||
or the workflow engine (`internal/domain/workflow`). How the runtime handles were
|
||||
severed, each at the producer:
|
||||
|
||||
- **Store contracts** moved to `internal/domain/storecontract` (producer-owned
|
||||
read contracts, state-store-contract rev. 2d); `internal/store` keeps aliases.
|
||||
read contracts, state-store-contract rev. 2d).
|
||||
- **Chat contracts** moved to `internal/domain/messaging`; `internal/gateway`
|
||||
keeps aliases. The UI process holds `ChatContract`, `SessionStore`, turn and
|
||||
stream types without linking the gateway runtime or its SQLite session store.
|
||||
stream types without linking the gateway runtime or its session store.
|
||||
- **Webui-owned views** replaced concrete runtime handles on `webui.Server`:
|
||||
channel lifecycle via `internal/channels/status`, memory via a `MemoryStatus`
|
||||
interface, curators via a `CuratorStatus` interface, and the skill catalogue
|
||||
|
||||
Reference in new issue
Block a user