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.
Three of its decisions have no implementation: J1 action ids, J2 args as CEL,
and generated Result schemas declared to CEL for field-level result typing.
That is why it stays Approved rather than Finalised, so the header names the
beads that close the gap.
PutResource replayed a prior write by request_id alone: the dedup
lookup and the schema's own UNIQUE constraint were both global, while
the resource API -- and every production caller -- is per kind. A
request ID reused across kinds therefore either replayed the first
kind's resource with the second kind's name attached to the call, or,
once the lookup was fixed, failed the insert on
UNIQUE(resource_history.request_id). The step-vocabulary agreement test
hit exactly this shape before its fixture was fixed to per-step IDs,
which is what elevated the hazard from latent to demonstrated
(archie-core-fcvd).
The dedup key is now (kind, request ID) in both places: resourceByRequest
filters on the kind, and schema v4 rebuilds resource_history with a
UNIQUE(kind, request_id) index instead of the column constraint.
Existing data satisfies the new shape -- a global constraint is strictly
stricter than the per-kind one -- so the rebuild copies every row and
drops nothing. Detection is the auto-index the old column constraint
created, so the step is a no-op on a database that already has the v4
shape and on one created fresh.
The playbook engine PRD had grown to 972 lines against CLAUDE.md's one-page
bar, because four documents were living in it.
The expression decision was the worst of it: an H2 nested inside a numbered
list item, 270 lines with twelve H3s and its own Status and Date fields. That
broke the outline and gave the document a second, non-canonical status. It is
now docs/prds/playbook-expression-syntax.md, named flat and linked by a Parent
field the way module-position.md already relates to this epic. The parent
keeps the decision and a pointer.
Repetition, against the state-each-fact-once rule: reject-at-load was stated
ten times, the plugin engine rule nine, producer-only seven. The producer-only
argument ran 32 lines and closed by restating itself; it is eight lines and
stated once. One heading read "confirmed non-issue (stated once)" above the
third statement of the point.
Open question 3 was closed by module-position.md and still listed here as
open. The section holding four decisions and one note is no longer called
"Open questions", and the note is a standing constraint, which is what it is.
Also removed: two list summaries written before their lists, ten dated
attributions, two progress claims, three orphan line citations, and the
undefined { Call: ... } notation.
Five findings in other PRDs came from tightening the guard, not from this
split.
The playbook engine PRD passed the guard while carrying a whole second PRD
inside a list item. Three separate blind spots, each with a test:
A second **Status:** field was invisible twice over. lintStatus returned on
the first status it found, and its pattern was anchored at ^, so an indented
one inside a list item was never read. It now checks every status line and
reports a second one as what it is: a nested document that belongs in its
own file.
dated-status matched verb-then-date only, so "(2026-08-22, decided)" and
"surveyed 2026-09-03" read as clean. It matches either order now, plus the
words that turn a date into provenance for a finding rather than a fact.
Rules were line-scoped, so a citation broken across a line wrap was two
innocent lines: "...Dedup section, lines" then "155-159, the rule". Each rule
now also tests the line joined to its successor, reporting the line the match
starts on.
Three defects the first sweep left behind, each caught by a rule the guard
did not yet have.
Statuses. RULES.md gives three; the tree had 25 values, and the free-text ones
were carrying progress. "Implemented (wiring landed)" and "Ratified (rev. 2e).
Rev. 2e adds the OpenTaskByPR lookup. Rev. 2d revised section 10..." were both
changelogs living in the one field the other rules exempt. Every PRD now
declares Draft, Approved or Finalised and nothing else; five that declared
nothing now declare one. A revision number moves to **Revision:**, a pointer
to the authoritative document to **Authority:**, and what a past revision
changed to git. CLAUDE.md's citation of state-store-contract rev. 2e still
resolves.
Stale cross-references. "Supersedes the 2026-09-03 open question", "this
bullet previously said", "an earlier draft of this document claimed" all point
at text the reader cannot see, because it was replaced. A supersede marker
survives only when it names a file, a section or a symbol that can be found.
Temporal hedges. 100 uses of today, currently and right now across 31 files.
Each dates its sentence to the day it was written: "[notify] today is one
webhook URL, read in one place" stops being true the moment this design lands,
while still reading as the premise it rests on.
The header-field exemption was also too wide. "**Date:** 2026-09-03, Channel
resolved 2026-09-22" smuggled a dated status into the one line the rules did
not read; the exemption is now a Date holding only a date and a Status holding
only one of the three.
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.
golangci-lint ran ./... from the repository root, which stops at the root
module, so the tools module was never linted and had drifted unseen. task
check already closes this hole for tests with test:tools; lint now has the
same shape in lint:tools, which runs in the tools directory rather than
passing a path prefix that only rewrites output paths.
Fixes the six issues that had accumulated behind it:
stripJSComments was 21 cyclomatic complexity against a cap of 15, with the
comment-skipping and literal-copying loops inlined into one scanner. It is
four named functions now, and the De Morgan warning went with the rewrite. It
had no test despite deciding whether a commented-out call reads as a live
consumer, so it has one: literals that look like comments, comment markers
inside strings, escapes, and unterminated literals and block comments.
docsgen's missing-artifact error ended in punctuation, and three test type
assertions were unchecked, which panic rather than fail when the generated
artifact does not have the shape the case assumes.
183 findings across 28 of 46 PRDs, of which 150 were file:line citations. Two
were already hard-broken: one named a file that no longer exists, one pointed
past the end of its file. The rest resolved to a line that still exists,
which is the worse failure -- a citation that silently drifted onto unrelated
code still reads as authoritative.
Citations now name the file and the symbol. Dated status markers become the
decision they carried ("Status 2026-09-05: resolved" -> "Resolved"), since
whether a question is answered is design information and when it was answered
is not. Progress inventories become scope statements: mcp-tool-completion now
fences what is out of scope rather than reporting what shipped.
status-health-surface drops phase-completion from its headings and keeps the
rule that earned them, that a reported field must have a truthful source.
eda-playbook-engine.md was the worst file and my own t2db.23 status block was
part of why; it is rewritten as the resolution it records.
A PRD states a decision, a requirement, a constraint or evidence. Those
survive the code moving underneath them. A line number, a progress report or
a dated status claim does not: it is true on the day it is written and
silently wrong a month later, while still reading as authoritative.
prdlint rejects five shapes: file:line citations (including a document citing
its own line numbers), dated status claims, progress reports on the work
being designed, phase-completion narration, and records of how a finding was
produced. Each finding names the file, line, rule and fix.
The rules target decay, not subject matter. A PRD may describe a phased plan,
name a dependency that exists, and carry its own Status and Date header
fields; what it may not do is assert the state of the tree on the day it was
written. Fenced blocks are skipped, since a listing may specify a line
reference as its literal content.
Wired into task check next to docs:check. A sweep alone would not stop the
class recurring.
migrateLegacySchedules replaced the whole legacy cron/jobs.json list into
the schedules resource, whose validator refuses every job whose kind is
not 'workflow' -- and chat is the legacy default (an empty kind on
schema-v1 jobs means chat). One chat job therefore failed the replace,
the migration returned the error and RunStateStore aborted before the
server ever listened. The failure was permanent: the seed had already
landed at version 1, so every restart re-ran the migration and refused
again, until an operator renamed cron/jobs.json by hand -- a remedy no
recovery doc mentions (archie-core-q6vw).
The migration now moves only the jobs the schedules resource can hold
and reports the rest instead of refusing them: chat and unrecognised
kinds were already dead deliveries in the old engine (the delivery
router maps KindWorkflow alone). An unreadable or corrupt sidecar is
logged and left in place for the next start, the way ImportConfig skips
a seed the resource validator refuses -- a value this process cannot
use must not stop the one process every other process dials. A
successful replace is marked by renaming the file to jobs.json.migrated
(the skipped jobs stay readable in it); until the rename lands, the
replaying request ID keeps the replace idempotent across restarts.
Headings carried scheduling status the Blocked-on line already states, and
two paragraphs narrated how the document was written rather than what was
decided. Both violate the PRD rule that every sentence adds a decision,
requirement, constraint, evidence or verification step.
Notification is a contract in internal/domain/messaging, not a channel type.
A channel implementation satisfies it by importing its own parent, which it
already does, so channels.Channel gains no notification method and no import
and the dependency stays channels -> messaging. A notification has no
lifecycle, no inbound direction and no config schema, so modelling it as a
channel would force Start/Stop/ConfigSchema onto something with no meaning
for them.
Destinations are configured, never named by a playbook: [notify] grows from
one webhook URL into named destinations, each binding a name to a channel
already registered in the Messaging composition plus that channel's address.
An action names a destination. Playbook triggers are reachable from a public
intake surface, so an action that could address an arbitrary chat would be a
new exfiltration surface.
Host access needs no new process surface. archie-messaging dials out only and
deliberately has no NATS connection, so nothing can push to it today.
Delivery travels the Gateway connection every process already holds, as a new
server-streaming RPC on ChatService; the per-turn Stream RPC is not reused.
The 2026-09-03 section presenting two options is superseded. Its claim that no
send capability exists anywhere was too strong: telegram.SendPendingReport
already sends unsolicited to a stored chat id, with no interface for it.
Closes archie-core-t2db.19
Project skill for running a bounded agent fleet on this repository. It stays
thin on purpose: the method -- doctrine, pipeline shape, the interview, the
pi-subagents ceilings and traps, scripts/, templates/ -- is the user-scope
high-throughput-programming skill, which is normative for method. This skill
carries only archie's facts and is normative for those.
What it carries: the seven invariants every lane call must repeat (fail-closed
control plane, the webui/workflow deletion gate, single ownership of
<db_path>-tasks.sqlite, no .beads/ commits, generated assets as LAW, scratch in
/tmp because CommitAll stages untracked files, and the cmd -> app -> {domain,
infrastructure} direction); the canonical gate-evidence.sh invocation and why it
must run the module build and the linter, not just a scoped test; the scoped
test-command shape for a lane plus the fact that task check is the serial full
gate the merge train owns; the agent-discovery trap (a lane worktree is a
sibling, so .pi/agents must be symlinked into it or children die with "Unknown
agent: cp-writer"); bd conventions; and that .pi/control-plane-run/ is
disposable run evidence, not documentation.
Also moves the September 2026 control-plane run out of the user-scope skill's
references/worked-example/ and into references/worked-example/ here, so exactly
one copy exists and it is committed. The user-scope skill's References table and
normative-copy paragraph now point at this repository, and note that a run in
another repository uses templates/ plus its own filled-in briefs. The moved
README gains the worktree agent-symlink fix and loses its stale "everything here
is gitignored" claim; its paths to scripts/ and templates/ now name the
user-scope skill explicitly. The scripts warning is unchanged: they are the
snapshot's and must not be copied.
A loaded playbook now decides a real task's workflow. The wiring point is the
daemon's definition pin (Daemon.resolveWorkflowID, consumed by
pinWorkflowFromCollection), not pollNATS/publishTask as the design doc
assumed: routing moved out of the agent process when workflow definitions
became database rows pinned before dispatch, so the pin is the one place a
task's workflow is chosen.
Precedence: an explicit Task.Workflow (the waiting_human -> approved requeue)
still wins, then a matching playbook, then workflow.ResolveWorkflowID's
existing label/kind bindings. A playbook naming an undefined workflow is a
reported failure that parks the task rather than a silent fall-through to the
binding's choice -- the operator bound that trigger deliberately.
Store.Dispatch returns the selected workflow name plus the matching playbook's
id and version, instead of a compiled workflow.Workflow: the production caller
decides against the active definition collection, and the id/version are the
first two components of the resolved gap-2 idempotency key. The playbook
package no longer imports internal/domain/workflow.
The shipped example's `when` read event.priority, a field no intake supplies,
so it could never have fired once wired. Both examples now read the event
surface playbookInput really builds, and label-trigger.yaml documents the axis
an instance defines for itself: trigger.kind is the closed workintake
vocabulary because a kind addresses a NATS subject, while trigger.labels is
free-form and binds an operator's own taxonomy to a workflow.
Module/Channel/Forge positions stay rejected at load; they need the
playbook_dispatches ledger first (archie-core-t2db.24).
Closes archie-core-t2db.23
Two agents independently produced archie-core-eju6. Keeps the wider test (queried
plugin_dir as well as the watched budgets, the SIGHUP reload, a task-scoped grant
denied on the apply-status RPCs, real gRPC over bufconn behind TaskGrants) and
carries over the fix for the staleness leg both versions got wrong: the aged
fixture derived from the constant the reader honours, so it now uses the
documented 90s window instead.
Takes the wider of the two independently-written archie-core-eju6 tests: it also
covers the queried half of boot.runtimeConfig (plugin_dir, not just the watched
budgets), the SIGHUP reload re-applying the database layer, a task-scoped grant
denied on PutApplyStatus/ListApplyStatus, and a real gRPC transport over bufconn
behind TaskGrants.
Its staleness leg had the same defect the narrower test did: the aged fixture was
derived from applystatus.StaleAfter, the constant the reader honours, so the
fixture moved with any mutation and the assertion held for a window measured in
hours. The aged row now uses a documented-window literal (90s, the operator-facing
contract) so the reader is constrained from both sides.
Resolves archie-core-eju6. One end-to-end test drives a settings change through
the dashboard's control-plane API, observes it land in the audit trail as an
ordinary edit attributed to identity.SystemID, restarts the consuming process
against the same store, and asserts it came back on the stored value rather than
the file value, with the apply-status row reporting the applied version and an
aged row reading as 'not reporting' rather than current.
The clause-5 staleness reading aged its fixture by applystatus.StaleAfter, so
the fixture moved with the very constant the reader is supposed to honour and
the reading agreed with the reader by construction: mutating StaleAfter to
1000h left the test passing, which is a staleness assertion that never went
stale.
Age the row by the documented 90-second window (three 30-second re-stamps,
docs/prds/control-plane-apply-status.md) held as a fixture literal instead, so
a window that stopped expiring fails the reading, and say in the fresh half's
assertion that it is the other end of that age pair.
archie-core-eju6.
archie-core-eju6: docs/prds/runtime-control-plane.md ("First implementation")
lists an end-to-end restart test as a deliverable and there was none.
One test drives the whole path against a real State Store: the dashboard's own
HTTP adapter writes a task-limit change (attributed by the adapter to the System
identity), the audit trail records it as an ordinary edit above the migration
seed, the process that consumes it stops and starts again against the same
store and the same file document, and the restarted process is running the
stored limits rather than the file's. The apply-status row for that process
reports the version it applied, and the settings page reads an aged record as
not reporting instead of current.
task.WorkflowDefinitionVersion/Digest/YAML had no pb.Task field and no
taskProto/taskValue mapping, so over gRPC the pin was never persisted and
any pin already in the row was zeroed by the same Update. The production
daemon's Store is the gRPC client, so the digest guard in pinWorkflowDefinition
was dead there: WorkflowDefinitionYAML was never non-empty for a task read
back over the wire, and each retry re-resolved from the active control-plane
resource instead of the version it started with
(docs/prds/runtime-control-plane.md:95).
The SQL store already wrote and read all three columns; only the contract
dropped them. Adds proto fields 28-30 and the mapping both ways.
Field parity was untied, which is why this was invisible: the task still
crossed, just with those fields silently zeroed. TestTaskProtoCarriesEveryDomainField
fills every domain field and requires the round trip to return it, so the
next forgotten field fails by name. The conformance battery now carries the
pin through Update and back out of TaskByID, failing in grpc mode only.
Resolves archie-core-xrux and archie-core-i3qm. The -config-overlay file path
(and the overlay-directory path) now fold a partial map-valued entry instead of
replacing it wholesale, so an overlay that sets one sibling key no longer clears
services.state.target_token. The file load path stops judging settings the
control plane owns, so a stale TOML value in a database-owned field can no
longer stop archie-state-store starting; boot.runtimeConfig remains the one
layering call and still validates the merged document. 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.
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.
Loader.finalize ran the whole validation over the file document, so a stale
TOML value in a setting the control plane owns failed startup -- including
archie-state-store, which resolves its file config and opens the store without
ever layering a database resource over it. docs/prds/runtime-control-plane.md,
"Bootstrap, migration, and recovery": after migration, settings in TOML are
ignored and cannot block State Store startup.
The checks over the settings a control plane resource is seeded from and
replaces wholesale now run only on the effective document: providers
(provider-settings), poll_interval and dispatch (scheduling-policy), containers
(container-runtime-policies) and the repository lists (repository-policies).
They moved from validate to validateDatabaseOwned; validateBootstrap keeps the
checks over settings no resource carries (forge intake, identities, nats,
memory, image, capture). File sources pass validateBootstrap and
Loader.ApplyOverlay, which layers overrides onto an effective document, passes
Validate.
Nothing stops being judged: the daemon and the Gateway both run the full
Validate in boot.runtimeConfig, the one place database resources are layered
in, before any capability starts -- so a stored value that will not validate
still stops the process rather than being published. Cases that asserted the
load path rejects a database-owned value now assert both layers, and
TestRuntimeConfigFailsClosedOnAnInvalidDatabaseValue pins the second.
Loader.overlayFile decoded the overlay file straight into the config the
base file produced, and a decode replaces a map-valued entry wholesale:
[services.state] target = ... in an overlay cleared the target_token the
base file set. That is archie-core-e2e2 on the user-visible -config-overlay
path -- deployments/dev.toml is the documented argument and sets
[services.state] target/listen, while target_token lives in the installed
config.toml. An enabled image.hosted entry lost its class and api_key_env
the same way, silently turning the provider off.
apply.go's foldOverrides is the fix that path was missing, so the file
overlay now goes through the same fold as the map overlay: the overlay file
parses to its raw mapping (decodeFileMapping), the fields of each partially
addressed map entry are folded forward out of the base config, and the
completed mapping is decoded over it. Loader.ApplyOverlay, ApplyOverlayValues
and apply.go stay: the hazard they were written for is this one.
An overlay file still reports its own unknown keys, from a separate decode
into a scratch value.
Resolves archie-core-6zw0. Subcommands of cmd/archie-state-store (not a new
binary, per organisation.md#process-boundaries) operating on the task database
file directly with the State Store stopped: backup, restore, validate, rollback.
A revision carries its value, so restoring replays it through the ordinary
replace and no rollback RPC is added. The pre-flight backup in
scripts/archie-update-install now calls the subcommand; the watchdog's refusal
semantics are unchanged.
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.
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.
Two P1 findings from review, both about a claim outrunning the code.
validate answered a different question from boot's. Boot refuses on
configuration.Validate over the file config with every stored resource
layered onto it (internal/app/archied/control_plane.go:27), which is a
stricter check than the write path's per-resource Decode: validateScheduling
never inspects dispatch.trigger and explicitly permits "0s", while boot
rejects an unknown trigger and a non-positive poll interval. A store holding
such a value printed "is a valid store ... N stored resources validate" and
exited 0 while archied exited 1 on it -- a false green pushing an operator
toward the blunt restore instead of the surgical rollback.
validate now runs both layers and reports both, in boot's order:
store.ValidateFile, then the write path's ValidateStored, then the config
gate. The layering itself is now one implementation: controlplane's
runtimeConfigFrom takes a resourceReader, which the gRPC client and a new
Server.StoredRuntimeConfig (reading its own store) both provide, so the
offline check cannot drift from the daemon's. validate takes -config /
-config-overlay (default: the path the serve subcommand uses), because the
question is about the stored values layered onto that document.
backup had no guard against -out naming the database. It renames its
snapshot over the target, so `backup -db F -out F` replaced a database a
serving State Store may still have open and orphaned the WAL of the file it
just unlinked -- the state Restore refuses up front and maintenance.go's own
comment calls unrecoverable. backup now refuses with the same message
Restore uses, which is what makes its exemption from the ownership lock
sound.
Claims corrected where they ran ahead of the code: ValidateStored now says it
is the write path's check and not boot's, the Restore comment no longer
promises "never a mixture" for the sidecars it removes first, the usage text
advertises validate's -config, and the architecture table drops "must be
stopped" for validate (nothing enforces it; read-only opens skip the lock by
design) and states which two layers validate reports.
Tests: TestRecoveryValidateRunsTheGateBootRuns fails on the pre-fix code
("validate accepted a stored policy the daemon refuses to boot with") and
covers a store the State Store never seeded; TestRecoveryBackupRefuses-
TheDatabaseAsItsOwnSnapshot fails on the pre-fix code ("backup over the
database itself succeeded"). The validate-accept test now seeds the store
through ImportConfig and asserts the reported count is non-zero, and the
stored-resource case uses a value both gates refuse instead of one only the
write path does.
archie-state-store gains the offline recovery commands
docs/prds/runtime-control-plane.md ("Bootstrap, migration, and recovery")
asks for. They work on the task database file directly -- <db_path>-tasks.sqlite,
not db_path -- and need neither archied nor the Web UI, which matters because
the failure they exist for is the one that stops archied starting:
backup -db F -out F consistent snapshot (VACUUM INTO), verified as a
usable store before it is published; safe against
a serving store
restore -db F -from F replace the database with a snapshot, dropping the
replaced file's -wal/-shm
validate -db F readable, not corrupt, schema no newer than this
binary, every stored resource decoding under the
definition that owns it
rollback -db F -kind K replay an earlier revision of a stored resource
[-revision N] through the ordinary replace, recorded as a new
revision
No rollback RPC is added and none is needed: a revision carries its own value,
so restoring one is the same replace the dashboard and the channels already
use, by hand, with the store stopped.
"The State Store is stopped" is checked rather than assumed. The serving
process now takes an exclusive flock on <db>.lock for its whole life
(store.AcquireOwnership), and restore/rollback refuse with
`task database is owned by another process` while it holds it. backup is the
deliberate exception: the update installer runs inside the process it is
replacing and cannot stop the State Store.
scripts/archie-update-install takes its pre-flight snapshot through
`go run ./cmd/archie-state-store backup` from the release being installed
instead of its own sqlite3 shell, so the installer and an operator run one
implementation. The watchdog's refusal semantics are unchanged: an update that
cannot back up still must not start.
Docs: safe-change-and-recovery.md's "Recovery: not yet built" now describes
what exists.
Follow-up to the gate.diff-rules step (archie-core-8szi). The step's contract
said it diffed the worktree; Trees.Diff reports the merge base against HEAD, so
only committed work was visible and a definition placing the step before the
committing step ran every rule against an empty diff and returned nil --
'load and check nothing', indistinguishable in the run's events from a pass.
The step's contract said it diffs "the worktree". It does not: Trees.Diff
reports the merge base against HEAD, so only committed work is visible.
A stored definition that placed gate.diff-rules before the step that
commits therefore ran every rule against an empty diff, found nothing and
returned nil, letting the run proceed -- the "load and check nothing"
failure the same file's settings validation exists to prevent, and
indistinguishable in the run's events from a change that passed.
The rules now read the committed change, and a run that read no committed
change while the worktree still holds uncommitted work fails on the spot,
naming the step it must follow. The count of added lines read is logged on
every run, so "checked nothing" is visible rather than silent.
Telling those two apart needs a fact Trees does not carry, so it arrives as
the same shape of optional capability changeStatsReader is: an unexported
interface in the domain, implemented where git is actually read
(worktree.Manager.HasUncommittedChanges, which excludes ignored files the
way CommitAll's own status check does) and forwarded by hybridTrees, the
Trees every production run uses. A Trees implementation that cannot answer
is refused rather than assumed clean: for a gate, silence about the change
is a failure, not a pass.
The four remaining review findings are recorded, not fixed, in
archie-core-ze7y (the escalated .archie/stages/*.go decision, P1, which now
blocks archie-core-8szi), archie-core-4kbg (discoverability),
archie-core-s1jz (hunk-header and threshold hardening) and archie-core-vof9
(retry keeps the pinned definition, so a rule cannot be unblocked by
editing it).
Part of archie-core-8szi. Restores the deleted .archie/gate.go Check() behaviour
as a registered, declarative workflow step type: RE2 rules matched against the
committed diff, per-rule level (error parks with findings in Detail, warn logs),
file:line preserved, registered through the workflowsteps provider set. The
.archie/stages equivalent (an argv-running step) is deliberately not landed and
is held for the maintainer's trust-boundary decision.
steps.go's StageYaegiGate tells the operator to migrate the deleted
.archie/gate.go hook to a registered YAML workflow step, and
BuiltinStepRegistry() exposed only the six shipped workflows' own stages,
so there was nothing to migrate to. What that hook did, from 3944f544
which deleted it: it read the worktree's repository-authored Go,
exporting Check(GateContext{Diff, ChangedFiles, Dir, BaseRef, Repo})
[]Finding, where each Finding carried a level ("error" blocked the run,
"warn" was advisory) and an optional file and line, and it inspected the
committed diff.
gate.diff-rules is that behaviour as a typed step: operator-written rules
in a stored definition -- per-rule level, RE2 pattern, optional path and
exclude_path scope, message -- matched against the ADDED lines of the
diff against the base branch, reported with their new-file line numbers.
An error-level finding parks the run with the findings in the park
reason; a warn-level finding is logged and nothing else. Unlike the hook
it replaces, no code is read out of the repository being worked on, and
the rules are versioned and audited with the definition they live in.
The settings are validated at the factory, which runs where a definition
is validated and again where it is compiled: a missing level, pattern or
message, an unknown level or settings key, and an expression that is not
a RE2 all refuse the definition rather than load and check nothing.
It arrives through the extension point archie-core-fwmp landed: a
repo-hooks provider in internal/infrastructure/workflowsteps, so both
roots that resolve a step type (the State Store's validating side and the
daemon's workflow-definitions client) register it at once.
Deliberately not landed: a step type for .archie/stages/*.go, whose
faithful equivalent is running a configured command. That would make the
stored workflow-definitions resource a command-execution surface on the
agent host, which is a maintainer's trust decision, not this lane's; it
is escalated, so steps.go's repo-stages error stays as it is.
Resolves archie-core-nwa0. The live apply path builds and probes a replacement
before promoting it and retains the previous component when the probe fails,
reporting the outcome through the apply-status surface instead of a hard-coded
nil.
Review of d7f3d0da found the build-and-probe step shape-only: the check it
added re-ran workflow.ExecutionSettings.Validate, which the store runs before
writing the document and controlplane.Client runs again on the way out, so no
producer could trip it. That review was right; this corrects it.
- The probe is now this process's own runnability check on the candidate it
would switch to: configuration.Validate over the configuration snapshot the
new limits would be published as, the same gate runtimeConfig applies before
publishing a layered config and the readiness probe applies to the published
one. The duplicated schema check is gone.
- The refusal the daemon really meets arrives as a watch error, because the
client decodes every document before the apply path sees it. That branch
logged and returned without writing an apply-status record, so the settings
page showed a live resource as healthy while nothing was being applied. It
now reports the refusal, against the version the reporter last applied.
Whether the stream is re-established afterwards stays archie-core-yrmr.
- `Closes archie-core-nwa0` in d7f3d0da is withdrawn: the item stays open. For
a limits-only kind no producer can make the owned check fail today, so the
refusal path is exercised by test, not by traffic; the live kind whose
candidate check has content is personas (archie-core-nw7t). Both callers are
covered by tests now, through the client seam, instead of by calling the
apply function directly.
- The comments no longer claim behaviour the code lacks: the boot abort is the
fail-closed direction of a rule whose branch boot cannot reach, and the
carried-forward version is the reporter's property, not this call's.
Out of scope and recorded instead: the live apply still publishes with
cfgHolder.Set rather than publishConfig, leaving the dashboard's config
snapshot stale after a live change (archie-core-75cc). workflow-definitions
gets no check because nothing swaps a running definition: the daemon reads the
collection per task pin (daemon.go:1479, pinWorkflowFromCollection) and the
only other reader is the dashboard's stream, so there is no live replacement to
probe.
docs/prds/runtime-control-plane.md ("API") requires a live change to start
and check the new component before switching to it, keeping the old one
running when the check fails. The live workflow-execution-settings apply
stored whatever arrived on the watch, republished the configuration snapshot
new tasks are built from, and reported success unconditionally.
Stage the update as a candidate first: validate the limits and build the
snapshot they produce without touching anything running, then switch both in
only if the check passes. A refused update leaves the running limits and the
snapshot in place and reports the failure through the apply-status surface,
which keeps the version that is still live and carries the error. Boot
propagates the same rejection, so a process is never started on limits it
cannot run.
personas is the other live-watched kind and gets no check or report here;
filed as archie-core-nw7t rather than half-wired.
Closes archie-core-nwa0.
Resolves archie-core-fwmp. The workflow step vocabulary is owned by an
injected workflow.Manager (internal/domain/workflow), assembled from a single
compiled-in provider set (internal/infrastructure/workflowsteps) and registered
at each composition root, following ARCHITECTURE.md#plugin-engine-rule-strict
invariant 2 and the memory family's house pattern. Replaces the five hardcoded
BuiltinStepRegistry() call sites.
Run's added openDaemonWorkflowDefinitions guard pushed it to gocyclo 21
(.golangci.yml's budget is 20). openDaemonStateSurfaces owns the pair --
adapter, then the definitions client on its transport -- so Run keeps one
branch for the whole sequence and no suppression is added.
step_vocabulary_test.go's pin moves with the sequence: it still asserts
adapter before client, client before buildDaemon, and now also that Run
opens neither half directly, so the ordering has exactly one call site.
Behaviour is unchanged; the gateway root still calls openStateStoreAdapter
alone and resolves no step vocabulary.
Review pass on the step-vocabulary shape. The gateway root shared
openStateStoreAdapter with the daemon, so it registered a step vocabulary and
built a workflow-definitions client it never read: the same dead vocabulary the
previous commit removed from internal/app/archiemessaging, reintroduced through
the shared adapter, and able to fail the gateway's boot the day a provider set
can fail to load. The vocabulary and the client now belong to the daemon root
alone (openDaemonWorkflowDefinitions, called by Run before buildDaemon captures
it), which is what Client's "a process that never reads or writes a workflow
definition needs no provider set and cannot be failed by one" already claimed.
The root guard was weaker than its own comment: it asserted that a root calls
stepVocabulary(), not that the manager returned is the one handed to
NewServer/NewWorkflowDefinitionsClient, so a root could call it and inject an
empty manager and keep every test green. The pin now asserts the data flow (both
halves mutation-checked), plus Run's ordering -- after openStateStoreAdapter,
before buildDaemon.
Three root guards asserted exact equality with workflow.BuiltinStepRegistry(),
which contradicted the extension path they guard: adding a provider to
workflowsteps.Providers() -- the documented way a step type arrives -- failed
all three, and the expectation could not be satisfied by editing it. They now
assert what their doc says (every shipped stage present) plus provenance (every
name resolved is declared by the shared provider set), and the workflowsteps
guard derives its expectation from Providers() so both sides move together.
New guard on the defect class the bead exists for: TestNoProductionSiteReaches-
ForTheBuiltinStepRegistry scans the module and fails if any non-test file outside
the domain declaration and the shipped provider names BuiltinStepRegistry, which
the agreement test cannot see for a sixth resolution site added later.
Claim-vs-code corrections: openStateStoreAdapter "reads and replaces" -> the
daemon only reads, and ReplaceWorkflowDefinitions has no production caller yet;
workflowsteps' package/Providers docs no longer claim every Archie binary
registers the set (archie-gateway, archie-messaging, archie-playbooks and
archie-ui do not); the shipped-provider test no longer says production does not
call BuiltinStepRegistry, which is false -- production calls it only there.
Third review pass on the step-vocabulary shape, one fix per finding.
P1, roots unpinned. The agreement test built its own manager and injected it, so
it pinned the resolution sites and not the roots that decide the provider set; a
root regressed to workflow.NewManager() (no shipped stages) left go test green.
archied now resolves through one unit, stepVocabulary (step_vocabulary.go), and
agentworker's productionWorkerDependencies is exercised directly:
internal/app/agentworker/step_vocabulary_test.go and
internal/app/archied/step_vocabulary_test.go assert each root's manager resolves
the shared provider set's shipped stages and accepts a provider registered
through it. RunStateStore and openStateStoreAdapter own a SQLite file and a gRPC
dial, so their calls are pinned by source position, the way
composition_order_test.go pins the memory-engine ordering.
P2-B, dead vocabulary. archie-messaging registered a step vocabulary it never
resolved (its only control-plane call is RuntimeChatConfig) and could fail
startup on it before the State Store target guard. The workflow-definitions
surface is now its own type, controlplane.WorkflowDefinitionsClient, so the
vocabulary is a constructor dependency of the one surface that resolves step
types and of nothing else. The messaging root no longer imports workflowsteps.
P2-C, nil manager. A nil *workflow.Manager dereferenced on every resolution path.
stepRegistry and CompilePinnedWorkflow now refuse with an error naming the wiring
mistake; TestNilStepVocabularyFailsClosedAtEveryResolutionSite pins the refusal.
Claim-vs-code corrections: agreement is stated as within one build (vocabulary.go,
stepRegistry, openStateStoreControlPlane, openStateStoreAdapter); the Yaegi claim
now says no bridge to StepFactory has been built and cites
internal/secret/secretextract; the provider set names its three roots;
Manager.Register's ordering is documented as a constraint with its consequence,
and the shape rule no longer claims to reserve shipped stage names; the
shipped-stage test compares against the builtin factory's own stage.
Self-review of the fwmp shape: the provider enumerates BuiltinStepRegistry and
forwards each factory, so no shipped behaviour changed -- but the one guard the
refactor moved off the production path lost its coverage. "A shipped stage
accepts no settings" was asserted only in
internal/domain/workflow/definition_test.go through BuiltinStepRegistry, which
production no longer calls; TestShippedVocabularyCoversEveryShippedStage
compares names only, so a provider that rebuilt the factories instead of
forwarding them would keep every name, lose the guard, and stay green.
The new test drives every shipped definition through the registered vocabulary
and asserts each step compiles to the shipped stage (not a rebuild named after
the step type) and that settings are still refused.
archie-core-fwmp. Every call site hardcoded workflow.BuiltinStepRegistry(), so
the step vocabulary a workflow definition may name was closed to the six shipped
workflows and archie-agent could compile only what the control plane happened to
validate against the same literal.
internal/domain/workflow.Manager is the family owner (ARCHITECTURE.md#plugin-
engine-rule-strict invariant 2): a constructed, injected value with no
package-level registry and no init()-time registration. Register validates at
the producer and atomically -- nil or unnamed provider, malformed provider or
step-type identifier, a step type with no factory, a duplicate claim, a provider
declaring one type twice, and a contribution shadowing a shipped stage are each
refused, and a refused contribution applies nothing. Registry() hands back a
copy, so the closed set is a property of the manager rather than a convention.
internal/infrastructure/workflowsteps is the one package both composition roots
import: it holds the compiled-in provider set and builds the manager. archied
registers it in RunStateStore (the validating side) and in openStateStoreAdapter
(the daemon's client), archie-agent in productionWorkerDependencies (the
executing side), and archie-messaging at its own root, each before the first
resolution.
The five hardcoded sites now resolve the injected manager instead: the State
Store's workflow-definitions validate closure and encodeWorkflowDefinitions, the
control-plane client's read and write paths, and CompilePinnedWorkflow's shipped
-definition and pinned compiles (one resolution per package).
step_vocabulary_agreement_test.go registers a provider through the production
Manager and drives all three sides with it; breaking any one of the six
resolution points back to the builtin registry fails that side's assertion.
The settings page now reads apply status beside each resource: every known
process with the version it applied, its error if it rejected the edit, and
whether it is still reporting at all. It re-reads after each save, so the page
reflects what the processes did with an edit rather than what was stored.
The server derives liveness only, because it knows whether a record went stale
but not which version the page is showing. The client compares against the
resource it is rendering, which is what turns a live record on an older
version into a pending restart.
A process that stopped re-stamping and one that never reported are separate
rows with separate wording, and neither is an error: the setting may be fine
and the process simply absent, which an operator acts on differently. A failed
apply-status read leaves the previous rows rather than taking the settings
page down with it.
state-store-contract.md gains the pair in its inventory and its count moves
from 45 to 47, with the note that this read is a list rather than the
config-snapshot pair's found=false singleton.
Closes archie-core-pskb.
Every process that layers database-owned settings now publishes the version it
applied, and re-stamps it every 30 seconds so the report time doubles as a
liveness signal. A record older than 90 seconds belongs to a process that has
stopped, which is the only way this surface can tell a live process from one
that applied a version and then died.
RuntimeConfig returned the merged config and discarded the versions it read,
so no caller could report what it had applied. It now returns them, and
archied and archie-gateway report each kind through boot.runtimeConfig at boot
and on SIGHUP. A validation failure reports every kind with the error, because
the layering is all-or-nothing, and leaves the recorded version alone so a
rejected edit does not erase the fact that an older one is live. The daemon
also reports workflow execution settings as the watch applies them, and
archie-messaging reports channel settings at startup.
Reporting is best-effort by construction: the configuration a report describes
has already been applied, so a failed write is logged and never returned. That
keeps it off the reload's error path, where it would have raised a banner
saying a reload failed when its config took effect.
applystatus.New refuses a process name Processes() does not list. The reader
renders known names, so an invented one would be invisible rather than wrong,
which is the same thing the page means by a process that never started.
Relates to archie-core-pskb.