Commit Graph
7 Commits
Author SHA1 Message Date
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 a19cd24b83 feat(controlplane): derive resource schemas from the documents they describe
Twelve definitions each advertised a bare {"type":"object"} or {"type":"array"},
so no resource descriptor carried a single field: the Web UI had nothing to
label, describe or format a field with, and the one component that parsed a
schema was dead code. The constants could not be kept honest either -- a schema
written beside a struct drifts the moment a field is added, and nothing compares
the two.

Definition now names its document type and Descriptor derives the schema from it.
json tags give the keys, falling back to the Go field name because that is what
encoding/json stores; the Go type gives type and format; and a field's own
title, format and doc tags override. A duration is a string with format
"duration", which is how every duration field in the catalogue -- poll_interval,
max_uptime, rate_limit.window -- gets a client-side affordance from one rule
instead of twelve hand-written ones.

Deliberately structural: it emits no prose of its own. Field descriptions already
have one home (internal/webui/config_schema.go, keyed by dotted config path), and
a second would be two places to keep the same fact true. It also never emits
"required", because an empty string is legitimate for nearly every field here --
a blank workspace, a disabled rate limit -- so requiring most of them would
invite a client to enforce something the document does not mean.

Guarded by TestEveryResourceDescriptorDerivesProperties, which walks the catalogue
the production constructor builds and fails if any kind describes no fields --
the assertion that would have caught all twelve. It accepts a keyed collection's
additionalProperties as described, because a map document has no fixed keys.

Verified: controlplane, workflow, webui, archieui and staterpc suites, go vet,
go build ./..., golangci-lint run ./... (0 issues), docs:check.
2026-09-22 03:50:53 +10:00
sam 092194cd5d fix(controlplane): give the channel document its own shape
The channel-settings resource embedded internal/config types directly, so the
document the Web UI edits was a JSON projection of TOML-tagged structs:
encoding/json fell back to Go field names, and rate_limit.window was a bare
time.Duration. An operator saw "Window" over a field expecting a nanosecond
count -- 60000000000 for the window = "1m" the file example writes -- and
"ListenAddr" over the email addresses, while every sibling resource in the same
registry is snake_case.

Define the shape here instead: emailSettings and rateLimitSettings with explicit
tags, and channelDuration, which writes the string the file accepts and reads
that, a nanosecond count, and the Go-cased keys an existing store holds.

Reading a legacy document is deliberate, so it stays strict about everything
else. decodeRenamingLegacyKeys renames the four known legacy keys and keeps
DisallowUnknownFields, because swallowing an unknown key decodes as "unset", and
an unset rate limit is off -- the failure this shape exists to end. A
misspelling is refused.

normalizeChannels, through the Definition.Normalize hook schedules already uses,
rewrites a legacy document into the current shape on write, so a stored document
converges the next time it is saved. Reads tolerate it until then, so no
deployment has to re-save before the document can be read.

Verified: the controlplane, messaging and configuration suites, archied (the
loadRuntimeConfig consumer), go vet, go build ./..., golangci-lint run ./..., and
docs:check. The full task check is the merge train's, on this tip.

The same audit found container-runtime-policies embedding config.ContainerConfig
(seven fields, no json tags); tracked separately rather than folded in here.
2026-09-22 03:43:46 +10:00
sam fbd5739235 fix(controlplane): make the scheduling policy carry the label its trigger pairs with
The scheduling-policy resource carried the dispatch trigger but not the
trigger-matching label, so validateScheduling could judge only half of
the pairing the file layer's validateDispatch enforces on the effective
document (a label-requiring trigger with no label matches every open
issue -- the GH#445 guard). The write path therefore stored trigger
label/either with no label whenever the file's own label was unset, and
boot then refused the layered document: a value the store blessed,
archied unstartable, the operator left with the offline rollback as the
only remedy (archie-core-7pyj).

The resource now carries the label: the seed copies the file document's
label, RuntimeConfig layers it with the trigger (a policy stored before
the field existed decodes nil and leaves the file's label in force, the
same absence-means-inherited shape a kind with no stored value has),
and validateScheduling refuses a label-requiring trigger with no label,
the pairing judged on the data the store actually holds. Once the store
carries a label it owns it, so a file that later loses the label can no
longer break a stored policy that depends on one. The parity test
gains both directions, and a legacy policy without the field is pinned
as an absence, not an erasure.
2026-09-22 00:32:30 +10:00
sam 7f7eb573a1 fix(controlplane): a kind with no stored value leaves the file's value in force
The fix-closure review found the previous pass moved the failure instead of
ending it. A seed the resource validator refuses leaves the kind ABSENT, and
RuntimeConfig treated an absent kind as fatal, so archied and the Gateway
refused to start with "control-plane resource not found" -- a database-named
error that editing config.toml cannot clear. Reproduced before the fix: every
kind in the new table failed that way.

Two changes, one on each side of the seam:

- Client.RuntimeConfig (and RuntimeChatConfig) now treat a kind with no stored
  value as "the file document's value stays in effect", which is what the
  skip-and-report comment already claimed. The version map records no version
  for such a kind, so nothing is reported as applied. A value the file layer
  also refuses still fails closed, at configuration.Validate, with a message
  naming the file's own field -- and the file is the fix.

- Which repository lists are valid can no longer differ between the layers.
  configuration.ValidateRepositories is now the single rule set (owner and name
  present, no duplicates, compilable test glob) and the repository-policies
  resource validator delegates to it. The file layer had no duplicate rule
  while the resource layer did, so a duplicate [[repos]] entry passed the loader
  and then vanished into a skipped seed.

Also, from the same review: the scheduling validator's "0s" carve-out is gone,
so a zero poll interval is refused at write time as configuration.Validate
refuses it (there is no defaulting behind a stored value); applyOverlayFile's
doc now says which overlay forms fold (a conf.d extra does not, and nothing
reads cfg.Extra); and plugin-settings' no-op validator is a named function with
the reason it accepts everything.
2026-09-21 22:12:32 +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 924b02a1b0 feat(controlplane): runtime administration over the State Store's gRPC server
The Web UI and messaging channels now read and write Archie's runtime
settings through one versioned, audited control-plane API hosted on the
State Store's existing gRPC server: catalog, query, command, watch. Each
feature owns its resource, validation and commands; storage only writes
versions and audit records.

Workflows move with it. Definitions become portable YAML compiled through
a closed, typed step registry and stored as a control-plane resource, so
the yaegi interpretation paths (internal/gate, wfeval, wfextract,
gateeval, gateextract, skillbuild) are deleted rather than carried.

The UI process reads definitions as data: the JSON projection lives in
internal/domain/workflow/task so a dashboard decodes the stored
collection without linking the workflow engine, which cmd/archie-ui's
deletion gate forbids. Shipped definitions ride the catalog descriptor
rather than a bespoke REST route, keeping the API to its four operations.

archie-messaging gains -state-store-target/-state-store-token and reads
channel settings from the database, failing closed when the State Store
is unreachable: the database is authoritative for those settings.
2026-09-21 08:17:42 +10:00