docs: capture AWX/Ansible inspiration research and service-decomposition PRD
Records the AWX pluggable-architecture and Ansible task-model inspiration thread verbatim, the verified current-vs-ideal coupling analysis (webui's in-process HTTP task-action detour, direct gateway internals access, shared config.Holder), the external service-discovery research (K8s-native primary + NATS fallback behind one ServiceRegistry seam), and a Proposed-status PRD recording the target service shape and open questions before any implementation work is filed.
This commit is contained in:
1 parent
5942fd913e
commit
d92ff825d9
4 files changed
+714
No files matched your search
@@ -0,0 +1,147 @@
|
||||
# Service decomposition -- decision
|
||||
|
||||
**Status:** Proposed -- not yet approved for implementation
|
||||
**Date:** 2026-09-05
|
||||
**Beads epic:** not yet filed; file one before any implementation work starts
|
||||
**Prior art:** `docs/inspiration/2026-09-05-awx-service-decomposition-and-ansible-task-model.md`,
|
||||
`docs/inspiration/module-reference-awx-decomposition-vs-archie.md`,
|
||||
`docs/inspiration/service-discovery-research-2026-09-05.md`,
|
||||
`/work/artefacts/archie-core-current-state-archify.html`,
|
||||
`/work/artefacts/archie-core-ideal-state-archify.html`
|
||||
|
||||
## Decision
|
||||
|
||||
archie-core moves from one Go binary (`archied`) hosting every domain
|
||||
in-process to a set of independently deployable services, each exposing
|
||||
exactly one typed contract. Consumers depend on the contract; they never
|
||||
reach into another service's internal types, session state, or config.
|
||||
gRPC is the synchronous transport; NATS remains for asynchronous fan-out
|
||||
(status, telemetry) rather than being replaced.
|
||||
|
||||
This is a **distribution decision**, not a rewrite of Archie's domain
|
||||
model. The six-domain split already approved in
|
||||
`docs/architecture/index.md` and `docs/architecture/organisation.md`
|
||||
(Identity, Agent, Messaging, Workflow, Work Intake, Plugin) is unchanged;
|
||||
this PRD is about how the *processes* running that domain logic get
|
||||
packaged, contracted, and discovered -- not about redrawing domain
|
||||
boundaries.
|
||||
|
||||
### Target services
|
||||
|
||||
| Service | Contract it owns | Existing code it replaces/wraps |
|
||||
|---|---|---|
|
||||
| UI Service | thin client only; talks to Gateway's contract | `internal/webui` (SPA hosting stays; API surface becomes a Gateway client, not a peer with direct access) |
|
||||
| Gateway Service | routing / turn / session contract | `internal/gateway` |
|
||||
| Messaging Service | channel-plugin contract (Telegram, email, Discord, Teams, ...) | `internal/channels` |
|
||||
| Curator Service | curator contract; **optional**, installs as a Gateway plugin | `internal/domain/curator` |
|
||||
| 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` |
|
||||
|
||||
### Discovery
|
||||
|
||||
Per `docs/inspiration/service-discovery-research-2026-09-05.md`:
|
||||
|
||||
- **Primary:** Kubernetes-native discovery (Service + headless-Service/DNS
|
||||
+ EndpointSlice, served by CoreDNS), delivered as a Helm chart + Operator,
|
||||
on k3s for single-host installs and a real cluster for multi-host or a
|
||||
hosted offering.
|
||||
- **Fallback:** NATS-based discovery (micro `$SRV` announce + JetStream KV
|
||||
registry) for no-K8s single-host installs, with a custom gRPC resolver
|
||||
reading `host:port` from the KV bucket.
|
||||
- Both implementations sit behind one internal interface:
|
||||
|
||||
```go
|
||||
type ServiceRegistry interface {
|
||||
Resolve(service string) []Endpoint
|
||||
Watch(service string) <-chan Event // join/leave
|
||||
}
|
||||
```
|
||||
|
||||
- An optional service (Curator today; others later) that is not installed
|
||||
must resolve to a distinct `NotInstalled` outcome, never a `Down`/
|
||||
`Unhealthy` one. Under K8s this falls out of DNS returning no record;
|
||||
under the NATS fallback it requires an explicit "installed" marker in the
|
||||
KV registry, not just absence-implies-down.
|
||||
|
||||
### Distribution model this supports
|
||||
|
||||
Both self-hosted (customer runs the Helm chart or the NATS-fallback
|
||||
binaries themselves) and a managed/hosted offering (we run the same Helm
|
||||
chart) are in scope -- this is the RHEL / Ansible Automation Platform
|
||||
model: one architecture, sold both ways. This PRD does not decide the
|
||||
business model; it decides that the architecture must not foreclose
|
||||
either shape.
|
||||
|
||||
## Why this shape
|
||||
|
||||
`docs/inspiration/module-reference-awx-decomposition-vs-archie.md`
|
||||
established that Archie's existing domain split already does what AWX's
|
||||
service-decomposition post argues for -- boundaries exist. What doesn't
|
||||
exist is deployability: `internal/webui` is not a passive frontend today.
|
||||
Verified couplings that this decomposition must eliminate:
|
||||
|
||||
- Telegram's task-action execution (pause/resume) currently routes through
|
||||
`internal/webui`'s own HTTP handler in-process
|
||||
(`chatTaskActorAdapter.ApplyChatTaskAction`,
|
||||
`internal/app/archied/main.go:224-242`, dispatching into
|
||||
`internal/webui/server.go:231`'s `handleTaskAction`). Under this PRD,
|
||||
Messaging Service calls Gateway Service's contract directly -- no HTTP
|
||||
detour through a UI process.
|
||||
- `internal/webui/api_chat.go` calls `gateway.SessionStore`, `Router`, and
|
||||
`TurnHistory` directly (lines 97, 142, 198, 256, 261) instead of through
|
||||
a narrow interface. Under this PRD, UI Service only ever sees Gateway
|
||||
Service's `ChatContract`.
|
||||
- `bootstrap.go:1239` shares the daemon's live `config.Holder` with webui
|
||||
rather than passing config. Under this PRD, each service owns its own
|
||||
configuration surface; nothing shares a live in-process struct across a
|
||||
service boundary because there is no longer a shared process.
|
||||
|
||||
## Non-goals
|
||||
|
||||
- Redesigning the domain model (Identity/Agent/Messaging/Workflow/Work
|
||||
Intake/Plugin boundaries are settled elsewhere and unchanged).
|
||||
- Replacing NATS. It remains the async transport; this PRD only adds gRPC
|
||||
for synchronous request/response and (optionally) K8s-native discovery.
|
||||
- Deciding the business model (self-hosted vs. managed vs. both). Kept
|
||||
open deliberately; the architecture must serve either.
|
||||
- Config relocation (`config.toml` -> ConfigMaps/Secrets) is real work
|
||||
implied by a K8s-native deployment but is its own decision, not decided
|
||||
here. Flagged in the discovery research as a phased concern.
|
||||
- Any concrete adoption of Pi (or another external agent harness) as an
|
||||
execution runner. Raised in conversation alongside this decomposition,
|
||||
but it is a separate decision (agent execution as a strict data
|
||||
boundary, `ARCHITECTURE.md`) and does not gate or get gated by this PRD.
|
||||
|
||||
## Open questions (blocking before implementation starts)
|
||||
|
||||
1. **Extraction order.** Which service gets pulled out of the monolith
|
||||
first? The webui entanglement findings above suggest Gateway Service's
|
||||
`ChatContract` should exist before UI Service is extracted, since UI is
|
||||
the most entangled consumer today. Not yet sequenced.
|
||||
2. **Contract definition mechanism.** Protobuf/gRPC service definitions
|
||||
need a home (a new `proto/` or `contracts/` tree, versioning scheme,
|
||||
codegen wiring into `Taskfile.yml`). Not yet designed.
|
||||
3. **In-process vs. out-of-process during migration.** Whether services
|
||||
can run multiplexed inside one binary behind the same `ServiceRegistry`
|
||||
interface during a transition period (so extraction is incremental and
|
||||
testable) or whether each service must be a separate binary from day
|
||||
one. Strongly recommend the former for a solo maintainer, but not
|
||||
decided here.
|
||||
4. **State Store's contract shape.** Whether every service gets its own
|
||||
storage (true microservice isolation) or several services share the
|
||||
State Store service's contract (less isolation, less migration risk).
|
||||
Not yet decided.
|
||||
5. **Helm chart / Operator ownership.** Net-new work with no existing
|
||||
analog in this repository (`deployments/` currently holds TOML profiles
|
||||
and a `docker-compose.yml`, not Kubernetes manifests). Scoping not yet
|
||||
started.
|
||||
|
||||
## Completion criteria
|
||||
|
||||
Not applicable yet -- this PRD records the target shape and the discovery
|
||||
decision. It does not authorize implementation. Before work begins: file
|
||||
a beads epic, resolve the open questions above (at minimum #1-#3), and
|
||||
get explicit go-ahead given the scale of this change relative to
|
||||
`AGENTS.md`'s "smallest workable change" default for this solo project.
|
||||
Reference in new issue
Block a user