/status conflated two unrelated concerns: a thin per-status task
count that duplicated information belonging to a task view, and
runtime config already visible via /model. Worse, a bare status
count actively misled -- "Running: 1" read the same whether that
task was making progress or stuck in a failure loop, because a count
carries no age or identity.
/status now reports one aggregate queue-depth line (in-flight work:
running/waiting/parked, health signal only) instead of an itemized
breakdown -- queued and terminal states are excluded as neither
actionable nor a health concern.
/tasks is new: the live, per-task view with enough identity and
state to act on it (id, title, status, workflow/stage, age since
last transition, attempt once a retry has happened, and a parked
task's reason). Age comes from Task.UpdatedAt, already persisted and
now threaded through ChatTaskSummary and chatTaskListerAdapter --
no new instrumentation needed. Tasks sort actionable-first (running,
waiting, parked, ...) ahead of terminal states, stable within a
status group so the lister's own recency order survives.
Wired via the existing configureTaskCommands call sites (web,
telegram, email, webhook) using the same chatTaskListerAdapter
already built for the task_list LLM tool -- no parallel data path.
Note: internal/gateway's separate /agents command (AgentReader) is
NOT touched here and remains dead in production (Router.Agents is
never wired by any composition-root call site) -- tracked as its own
finding, not folded into this fix.
loadPlaybookFile ranged over the raw YAML map directly, so which key
"won" when a file declared two colliding bindings depended on Go's
randomized map iteration order -- contradicting the function's own
doc comment promise of a reproducible, deterministic collision error.
Surfaced as a flaky failure in TestLintReportsLoadErrorAsFinding
(internal/app/archieplaybooks), which has two independent collisions
in its fixture and asserted on whichever one used to win by chance.
Sort the file's keys before checking them, matching the existing
sorted-filenames convention for cross-file order. Updated the test's
assertion to the now-deterministic outcome ("bug", alphabetically
first) with a comment explaining why.
Real bug found via browser-testing the new bindings UI (t2db.8):
UpdateBinding's own store-layer contract documents that an empty
Secret means "preserve the existing one" (COALESCE against NULLIF),
but handleBindingUpdate validated with the create-time Validate(),
which unconditionally requires a full-length secret -- rejecting the
exact "leave blank to keep it" edit flow the store was built to allow.
Root-cause fix, not a UI workaround: Binding.Validate() (create,
unchanged, still requires a real secret -- there's nothing to fall
back to on insert) now delegates shared field checks to a private
validateCommon(); a new ValidateForUpdate() reuses the same checks but
only enforces the secret-length floor when the caller actually
supplied a new one. handleBindingUpdate now calls ValidateForUpdate.
3 new domain tests + 1 new API-layer test pin: empty secret accepted
on update, a genuinely-short new secret still rejected on update,
empty secret still rejected on create.
Root-cause fix for the correctness gap named in archie-core-t2db.8:
resolveBindingRepo refused to dispatch with zero or multiple configured
repos, meaning a multi-repo deployment could never use bindings at all.
- binding.Binding gains optional Owner/Repo fields; Validate rejects
setting only one (a pin is a complete pair or not a pin at all).
- Persisted as new owner/repo columns (NOT NULL DEFAULT '', additive --
no migration needed since bindings is a CREATE TABLE IF NOT EXISTS
with no existing deployment yet).
- resolveBindingRepo now takes the binding: a pinned binding dispatches
to its own owner/repo unconditionally; an unpinned binding keeps
today's single-configured-repo fallback (0 or 2+ repos still refuses,
unchanged -- verified by a dedicated regression test, not just
assumed preserved).
- Wired through the API request/response shape (create/update accept
and return owner/repo); no repo-existence validation against config
added -- smallest workable change, not the named bug.
Red-green throughout: 8 new tests across domain/store/daemon/webui
layers, each proven to fail before the corresponding implementation
step. Zero regressions in existing binding/dispatch test suites.
Dashboard UI to expose this (the other half of t2db.8) is unstarted --
this closes the backend correctness gap only.
golangci-lint's nilerr finding was syntactically correct but not a bug:
a per-skill parse failure is deliberately converted into a reportable
curator.Action instead of propagated as an execution error, because
Pass()'s loop aborts the whole batch on a non-nil error -- which would
stop reviewing every other skill over one bad file. Confirmed against
skillcurator_test.go's existing "must not abort review of the others"
coverage before touching anything. Scoped //nolint with the reasoning
inline, not a blind suppression.
Seventh slice of docs/prds/eda-playbook-engine.md (t2db.15), consuming
t2db.14's expr package: the rich trigger+actions playbook document and
the coordinator that dispatches it.
- internal/domain/eda/playbook: Load(dir) reads *.yaml/*.yml playbook
documents (trigger + exactly one workflow-kind action + optional CEL
when), validating the HARD BOUNDARY at load: a playbook with 2+ actions
or a non-workflow action position is a reported load failure --
multi-action and Module/Channel/Forge actions stay blocked on the
unresolved execution-time gaps. Any malformed YAML, invalid trigger,
missing workflow name, or when compile failure fails the WHOLE load
(reject-at-load, same shape as routing collisions); a missing dir is an
empty store. Trigger reuses the existing workintake kind/label
vocabulary (no second label-matching mechanism). Dispatch matches
trigger, evaluates when (CEL, event context with actions: {} -- no
prior actions in single-action playbooks), and returns the named
workflow from the registry via the same lookup Route() uses -- no
duplicated dispatch logic. when eval error follows the resolved doc's
J3: false, skip, caller logs.
- Store.Dispatch(reg, DispatchInput) is the coordinator entrypoint; input
carries Labels/Kind/Event. Production task intake wiring
(daemon.go/pollNATS/publishTask) is explicitly NOT in this ticket -- a
follow-up; proven end to end via direct tests plus the shipped example
(examples/eda-playbooks/bug-tdd.yaml) loaded and dispatched through the
real path.
- Config: EDAPlaybookDir (eda_playbook_dir), documented as DISTINCT from
PlaybookDirs (flat binding files) -- a reader cannot confuse the two.
- Bootstrap: playbook.Load wired in loadWorkflows, log-and-abort on
failure matching every prior slice; nonexistent dir is an empty store.
- workflow.Route(), workflowForLabels, and the t2db.9-.12 binding loaders
are UNTOUCHED (verified: their full test suites pass, zero regressions).
Also carries small lint cleanups on t2db.13/.14 code flagged by the gate
run: expr Eval no longer type-asserts to ref.Val (Eval returns ref.Val
directly in v0.32.0; cel-go's own Eval wraps evaluation in recover --
verified in source); module decodeLogArgs extracted to clear the nestif
finding. golangci-lint: 0 issues.
Tests (10): single-action round trip, when-false skip, 2-action load
failure, non-workflow position load failure, when compile failure drops
playbook, empty trigger load failure, trigger mismatch skip, no-when
match, one-invalid-file fails whole load, missing dir empty store, plus
the shipped example load+dispatch. task check clean (113/113 UI, exit 0).
Sixth slice of docs/prds/eda-playbook-engine.md (t2db.14): the
internal/domain/eda/expr package implementing the resolved open question 1
(CEL decision), standalone -- no coordinator/dispatch yet, mirroring how
t2db.13 built ModuleRegistry before any consumer.
- NewEnv: CEL env declaring the two context roots (event + actions, both
map(string, dyn)) with DefaultCostLimit (100,000, tunable per J5).
- Compile: parses/type-checks an expression string; syntax error, unknown
root (anything other than event/actions), or type error is a returned
error -- the reject-at-load entry point the playbook loader and lint
tool will share.
- Eval: evaluates a compiled program against a dispatch-time Context;
missing-field/wrong-type/cost-limit errors are returned, never panics.
No recover() wrapper: CEL is panic-free by design, verified by the
hostile-data tests (5000-deep map, no panic). CEL's ref.Val wrappers
(types.Bool etc.) are unwrapped to native Go values.
Dependency: cel.dev/cel-go v0.32.0 (direct), the only new dependency,
already vetted in the resolved doc's vetting record -- no re-vet.
Tests (table-driven, verified against real CEL semantics, not guessed):
valid boolean against event fields; syntax error at compile; unknown root
rejected at compile naming the root; missing event field errors not
panics (== on a missing key evaluates false -- verified CEL semantics);
has() presence macro; actions context reads; deep-nested hostile data
error-free or false without panic; cost-limit enforcement proven by
aborting a macro expression under a tiny limit (CEL's cost model accrues
on map/filter iteration, not field reads -- verified by probing).
task check clean (113/113 UI, exit 0).
Fifth slice of docs/prds/eda-playbook-engine.md (t2db.13), implementing
docs/prds/module-position.md's recommended first slice: prove schema ->
go:generate -> Yaegi load -> ModuleRegistry end to end with a
side-effect-free action kind, before any kind with a real external effect
(notify, image-gen, forge writes) -- those stay blocked on the parent
doc's unresolved execution-time gaps (idempotency, mid-run failure).
- internal/domain/eda/module/log: hand-written schema source (Args/Result/
SchemaVersion per module-position.md) + logextract generated symbol
table via go:generate yaegi extract (same tooling as wfextract/
gateextract; scoped to ./internal/domain/eda/module/...).
- internal/domain/eda/module: ModuleRegistry with Register(kind, dir) /
Invoke(ctx, kind, rawArgs). No generic Module interface with an any
payload: each kind is its own tiny package with its own generated
contract; the registry's internal storage is the only place erasure
appears (exactly as inside wfextract). Invoke decodes rawArgs strictly
into the kind's Args before calling the interpreted function -- an
unknown key or wrong type is a reported failure, not a silent
zero-value fill (the 'schema defines the accepted message' rule).
Generalizes gateeval's fixed-signature Yaegi pattern via
yaegiutil.New/Resolve/Safe -- no new interpreter-construction or
panic-recovery mechanism.
- Config: ModuleDir mirroring PluginDir's shape and doc comment
(operator-trusted directory of Yaegi module implementations, one .go
per kind; empty means none loaded). Wired at daemon startup in
bootstrap.go alongside PlaybookDirs loading -- log-and-abort on load
failure (a broken module is a startup failure, not degrade-and-skip).
- examples/modules/log.go: operator-facing example (//go:build ignore,
mirroring examples/secret-engines/) proving the shipped contract.
Tests: registry (register/invoke, unknown kind, missing file, strict
arg-decode shape failures, malformed file, panic recovery), logextract
smoke test, and an example-load test that runs the shipped
examples/modules/log.go through the real registry (not a test fixture).
task check clean (113/113 UI, exit 0).
Playbook YAML action dispatch is deliberately out of this slice: a
minimal 'run this one module action, no chaining' dispatch still requires
naming how args values reach the action (parent doc open question 1 --
data-flow/interpolation syntax) and what the result feeds, both
unresolved by design. Dispatch is a follow-up ticket that consumes this
registry as-is; recorded in module-position.md.
Two pre-existing issues discovered while scoping the Module-position slice
(archie-core-e7bo), unrelated to the playbook engine work:
1. wfextract's //go:generate directive still targeted
internal/workflow, a path gone since the domain migration -- the
committed generated file was hand-patched for imports only, never
regenerated. 'go generate ./...' failed repo-wide, silently.
2. Regeneration surfaced real drift on three surfaces:
- wfextract: the committed table predated the migration and was
missing everything added since -- routing YAML loaders (t2db.9/.10/
.11), the review types, and the Forger/Reviewer/Trees interfaces
that TaskContext exposes to every interpreted stage plugin. A stage
plugin referencing tc.Trees or the review types could not resolve
them.
- pluginextract: internal/plugin/host.go (f73b2d1) added the
Host/Module/Manifest/Permission/Health/CapabilityKind/LifecycleState
/ModuleStatus types and NewHost/AdaptLegacy/HostAPIVersion, none of
which were ever extracted. A daemon plugin written against the
capability-host API (bootstrap.go:707 LoadDir) silently had no way
to reference them.
- secretextract: symbol exports were current; only the hand-applied
nil-guards and comments differ from raw generator output.
Fix: update the wfextract directive to internal/domain/workflow and
regenerate all four extract surfaces via 'go generate ./...'. Re-apply
the documented hand-written nil-guards on interface wrappers (Yaegi
wrappers omit them natively), restating the IMPORTANT note in wfextract's
package doc (it now has interface wrappers for the first time). Delete
the stale hand-patched wfextract generated file in favour of the
correctly-named regeneration.
Regression coverage (the previously-missing types are now reachable from
interpreted code, proven by tests that fail against the old tables):
- wfextract/reachability_test.go: interprets a stage plugin referencing
Trees/Reviewer/LoadPlaybookDirs and calls it; plus a Go-side nil-guard
test on the three wrappers.
- pluginextract/reachability_test.go: interprets a daemon plugin building
a Host from a Go-side Module and calls it end to end; plus nil-guard
tests on the _Module/_Plugin wrappers.
- secretextract keeps its existing wrapper nil-guard tests.
Verified red-then-green: after a fresh 'go generate ./...' wipes the
guards, the guard tests fail with nil-pointer panics; after re-applying,
they pass. task check clean (113/113 UI, exit 0).
Fourth slice of docs/prds/eda-playbook-engine.md (t2db.12): the design
doc's pre-merge collision layer, as a gopls-shaped standalone binary
(cmd/archie-playbooks) rather than a Taskfile wrapper -- one binary, one
schema source, mode-based entrypoints.
- cmd/archie-playbooks: subcommand dispatch table from day one (lint now;
an lsp/serve mode later slots in without restructuring), flag parsing
only per organisation.md's cmd/ rule.
- internal/app/archieplaybooks: the lint mode's composition -- collects
directories, calls workflow.LoadPlaybookDirs (the daemon's own loader),
reports findings. No second validation path: the linter agrees with
runtime startup validation by construction.
- Reuses LoadKindWorkflowsYAML/LoadLabelWorkflowsYAML/LoadPlaybookDirs
directly; collision/malformed/invalid bindings exit non-zero.
- Known limitation recorded: findings are file-granular, not
line-granular (yaml.Unmarshal into map discards line numbers; a
file:line diagnostic needs a yaml.Node upgrade, out of scope here).
- Taskfile lint:playbooks target; PRD records the shipped shape and the
file-granular caveat.
Third slice of docs/prds/eda-playbook-engine.md (t2db.11), completing open
question 2: instead of a single playbook dir, the config gains a LIST of
directories (playbook_dirs) of *.yaml/*.yml binding files, loaded at
startup as an additional input to workflow_routing_file and
workflow_labels_file, which remain supported unchanged.
- LoadPlaybookDirs(dirs []string) reads every yaml file across the
configured directories and merges kind + arbitrary-label bindings.
- This is what finally exercises the design doc's drop-and-report
collision rule: a single file cannot collide with itself, so the
cross-source path (two files in one dir, two dirs, or a dir plus a
single-file field) had never run in production. A binding key declared
by more than one source is a reported load failure, not a silent
pick-one by source order or version.
- Router-level collision handling: MergeKindWorkflows/MergeLabelWorkflows
fail on a key bound by both the single-file fields and the playbook
dirs, applied at boot.
- Config: PlaybookDirs []string, empty by default (no behavior change for
existing configs). Repo-scoping (typing dirs to Config.Repos owner/name)
is explicitly deferred to a separate later decision per ticket;
org/tenant keying is out of scope.
- PRD: records the list shape per Sam's correction (single dir would
contradict multiple independently-maintained playbook sources).
Second slice of docs/prds/eda-playbook-engine.md, complementing the
kind->workflow layer (WorkflowRoutingFile): the label vocabulary itself
becomes playbook data. A label outside the closed bug/feature/bootstrap
kind set (e.g. security) now dispatches to a registered workflow from an
optional WorkflowLabelsFile, instead of falling through to triage.
- LabelWorkflows + LoadLabelWorkflowsYAML/SetLabelWorkflows in
internal/domain/workflow/routing.go, mirroring the kind layer's
once-at-startup lifecycle. The closed Kind/NATS-subject set is
untouched; the map only extends binding authority for labels the kind
layer does not own.
- Collision rule per design doc: a label owned by the kind set, an empty
label, an empty workflow name, or a duplicate binding is a reported
load failure (dropped, logged, error returned to the caller) -- the
schema defines what is accepted; nothing is silently arbitrated by
schema/version.
- Route() precedence: explicit t.Workflow -> arbitrary-label binding ->
kind binding -> triage -> implement -> default.
- Config: WorkflowLabelsFile (workflow_labels_file), wired at boot
alongside WorkflowRoutingFile; documented in config.example.toml.
- PRD: records this slice's decisions (single-file shape, collision rule,
precedence) so later slices stay anchored.
First slice of docs/prds/eda-playbook-engine.md: which registered
workflow an intake Kind (bug/feature/bootstrap) prefers is now data,
loaded from an optional WorkflowRoutingFile, instead of a Go literal.
labelKinds and the NATS-subject-per-kind set are unchanged -- expanding
the label vocabulary itself is a separate, larger decision (subject
allocation) deferred per the design doc's open questions.
An unrecognised kind in the file is a reported load failure (schema
defines what's accepted, per the design doc's collision-handling rule),
not a silently-dropped binding. No file configured falls back to
today's hardcoded defaults unchanged.
append(nonce, sealed...) appends to a slice initialized with a non-zero
length, which makezero flags. Build the nonce||ciphertext||tag payload with
an explicit buffer sized upfront instead.
Found by golangci-lint.
RedactPayload only redacted values under a fixed set of sensitive key
names, so a sender that names a secret field something else leaked it into
captured_events.body. Harden the heuristic:
- broaden the key-name markers (compound names like access_token,
client_secret, signing_key, x_api_key, webhook_secret, refresh_token)
and keep gateway.sensitiveParameterKey identical to preserve the
documented agreement between the two redaction paths.
- add value-shape detection: a compact JWT or a PEM private-key block is
redacted under any key, catching the 'sender named the field something
the heuristic misses' gap.
- keep it conservative so schema-by-example field mapping still works:
only unambiguous shapes (eyJ-prefixed JWTs, PEM key blocks) are
redacted by value, never ordinary content.
Best-effort per docs/prds/webhook-intake-security.md point 5.
Refs archie-core-t2db (captured_events.body redaction)
binding.Binding.Secret was persisted as plaintext in the bindings.secret
column, so anyone with the SQLite file saw sender-side HMAC secrets. Seal
it with AES-256-GCM transparently inside the store: encrypt-on-write,
decrypt-on-read.
- cipher: AES-256-GCM, 12-byte random nonce, SHA-256-normalised 32-byte
key resolved through the secret registry ([bindings].encryption_key).
- envelope 'arcie-binding:v1:<fingerprint>:<b64(nonce||ct||tag)>' so a
future cipher/KDF change is a version bump and old rows stay readable.
- rotation via previous_encryption_keys; key identity is the material's
SHA-256 fingerprint embedded in each row.
- legacy plaintext rows written before a key was configured stay readable;
encryption is not retroactive.
- nil cipher (no key configured) preserves the pre-t2db.7 plaintext path.
Deferred: captured_events.body redaction upgrade (separate concern, see
docs/prds/binding-secret-encryption.md).
Refs archie-core-t2db.7
Implements archie-core-t2db.4: the runtime-editable binding entity that
turns a captured webhook into an archie task, plus the per-source HMAC
verification at handleCapture that makes t2db.5's 'unauthenticated event
cannot trigger a binding' invariant structurally enforceable.
Captures, mappings and bindings are now separate concerns on the same
single *store.Store; the new BindingStore / BindingDispatcher /
BindingTaskCreator split keeps each interface under the interfacebloat
limit (8 methods).
State machine: draft -> pending_approval -> armed; any edit on an armed
binding drops it back to pending_approval, enforced in SQL via
status='pending_approval' on UPDATE so the rule cannot be bypassed by a
direct status field in the request body. Approve is the only sanctioned
transition into armed (WHERE status='pending_approval' guard).
Overlap: two bindings may not share a source in any status; enforced at
InsertBinding and UpdateBinding (transaction-local SELECT). Approve has
a separate TOCTOU guard so a race between Insert and Approve cannot
// bypass the check.
HMAC at handleCapture: reads X-Hub-Signature-256 (then X-Signature-256)
// fallback, verifies via webhookguard.VerifyHMAC against the binding's
// per-source secret, marks CapturedEvent.Authenticated=true on match.
// Captures with no armed binding, missing signature, or wrong signature
all persist as authenticated=false -- the dispatch loop's
binding.Matcher.Matches gate (requires authenticated) is what stops
them from spawning a task. Two armed bindings for one source returns
409 at capture time as a belt-and-braces TOCTOU guard.
Dispatch loop: added Daemon.dispatchBindings, called from both Cycle
and maintainAndDrain between poll and drain. Walks
captured_events where authenticated=1 AND source IN armed bindings
AND id NOT IN binding_dispatches, runs the binding's matcher, resolves
the mapping, enqueues a chat-style task with binding_id /
// binding_version provenance stamped in the same transaction as the
// row insert. The binding_dispatches ledger (composite PK on
(binding_id, capture_id)) is the at-most-once guarantee across cycles
// and daemon restarts.
Tasks schema migration: binding_id INTEGER NOT NULL DEFAULT 0 +
binding_version INTEGER NOT NULL DEFAULT 0 (taskSchemaVersion bumped
1 -> 2). Existing tasks keep 0 / 0.
Out of scope (documented follow-ups):
- secret encryption at rest (plaintext today)
- full dashboard HTML for the binding editor (CRUD API only this bead)
- per-binding rate limits (existing per-remote-address limit applies)
- binding.Owner / binding.Repo fields (dispatch falls back to the
single configured repo; multi-repo deployments log and skip)
Adds PATCH /api/config/repos/{owner}/{name}, a dedicated seam distinct
from the generic dotted-key PATCH /api/config path: a repository is
one element of []config.Repo, not a flat key. Traced the mechanism
before adding any new plumbing -- overlay.Nest/ApplyOverlayValues
already handle "repos" as a single whole-slice key with no dot, so
the fix is a webui handler plus a bootstrap seam that reads the
daemon's live, untrimmed Repos (never webui.RepoView, which omits
Preflight/TestGlob), mutates the one matched field via the pure
applyRepoFieldUpdate helper, and republishes through the existing
UpdateConfig(ctx, {"repos": repos}) path unchanged.
config-row.js's row() gains an opts.save override so an edit can be
redirected to a different persistence call. The repositories table
renders an autosaving checkbox for the two booleans and a
save-on-blur/Enter input for max_retries, via api.configRepoUpdate.
Closes archie-core-b6ew.6, and with it archie-core-b6ew.
TestConfigFieldDescriptorsRestartRequiredIsDeliberate pins the exact
RestartRequired value per field against the reload.go evidence
already documented in configFieldDescriptors' own comment, so a field
reclassified without re-checking reload.go fails loudly instead of
silently defaulting to "takes effect immediately."
ui/test/settings-schema.test.js renders settingsPage against a schema
fixture containing a field settings.js was never written to know
about, proving the renderer needs no field-specific branch to show it
correctly, and asserts by reading settings.js's own source that none
of the generically-rendered fields' keys appear literally in it --
the direct regression test for archie-core-b6ew.3.
The rest of this issue's scope (metadata completeness, structured/
locked non-editability, schema secret-leak guard) was already covered
incrementally while implementing archie-core-b6ew.1 through .4.
Closes archie-core-b6ew.5
RepoView.ReviewEnabled was previously absent from GET /api/config
entirely, not just unrendered; add it alongside AllowConcurrent and
MaxRetries. The repositories table gains Concurrent/Max retries/
Self-review columns as read-only pills -- this is the concrete
discoverability fix for "why isn't a second agent running": that
config was already reachable from the API, just never shown.
config.example.toml documents review_enabled, which had no example
entry before this.
Full inline editing of per-repo fields is out of scope here: the
dashboard's PATCH /api/config path has no array-index support for
updating one element of the Repos slice, which is separate,
real scope -- filed as archie-core-b6ew.6.
Closes archie-core-b6ew.4
settings.js drops identityCard/budgetsCard/storageCard/webCard/
pullPolicyLabel in favour of one schemaCards() that walks cfg.schema
and builds a card per section, a row per non-structured field --
label, type, description, editability and enum options all come from
the backend descriptor instead of a hardcoded row(...) call per key.
config-row.js gains: enum fields edit as a <select> from opts.options;
opts.editable === false renders read-only distinct from a locked row
(no reason to show, just no edit affordance); opts.hint carries a
field's description as the label's tooltip, so "0 means unlimited."
travels with the field instead of being baked into a display-value
string per key.
ConfigSection also gains Description, filled in per section to match
each card's existing sub-text, since the card's own explanation is
schema metadata too.
Structured sections (repositories, models & providers) are untouched
-- still the existing bespoke renderers, reserved for archie-core-b6ew.4.
Closes archie-core-b6ew.3
ConfigView.Schema carries the archie-core-b6ew.1 descriptor catalog
with each request's own values, locked reasons, and overridden
markers attached (buildConfigSchema), additive alongside the existing
flat fields so nothing that reads ConfigView today breaks.
Tests confirm schema values match their flat-field source of truth,
locked reasons propagate to the schema entry, structured fields stay
non-editable, and secrets never reach the schema block.
Closes archie-core-b6ew.2
Introduces ConfigField/ConfigSection and configFieldDescriptors(),
attaching key/label/type/editable/restart-required to every field
GET /api/config already exposes -- the data-independent half of the
schema contract from docs/prds/config-schema.md. RestartRequired is
sourced from reload.go's reloadableFields/reloadableSubFields
allowlist rather than guessed.
Not wired into the API response yet (archie-core-b6ew.2); this issue
is the catalog and its contract tests only.
Closes archie-core-b6ew.1
session-memory's extracted actions never set Action.At, so the wire
carried time.Time's zero value ("0001-01-01") and the Curators
dashboard rendered it as "105694 wks ago". Stamp the action with the
curator's clock at the producer, and backfill any zero Action.At in
activityTracker.record from the pass's own timestamp so an engine
with no clock (skillcurator) can't hit the same bug.
Closes archie-core-z6wy
Persona/SOUL text was interpolated raw at the top of archie.md.tpl,
so a hostile SOUL could inject its own <core_rules> or
<instruction_precedence> tags ahead of the real ones. Render it
through the existing xml-escaping helper into a labeled
trust="data" <soul> block, and tell instruction_precedence
explicitly that the block is reference data, not an authority.
Closes archie-core-1786637490097-12-bf415ffb
Route() had no content-aware fallback: any task with no explicit
workflow and no label match ran the full "implement" pipeline
regardless of content. Confirmed in production (task 6): a
chat-spawned task whose entire content was "this is just a test,
close it when you receive it" burned 669,421 tokens finding that out
the expensive way -- baseline, plan, and build all ran before the
plan stage's own conclusion (nothing needed to change) arrived too
late to save anything.
Adds a "triage" workflow: one cheap, read-only classification turn
(mirrors feasibility.go's decide-tool pattern) that either closes a
task needing no code change immediately, or sets Task.Workflow and
requeues under whichever workflow fits. Route()'s fallback now
prefers a registered "triage" over "implement", unchanged when
triage isn't registered. Labeled tasks are untouched -- a label is
already a free, reliable signal, so triage never fires there.
See docs/prds/dynamic-workflow-triage.md for the full design.
Confirmed in production (task 6, 2026-09-02): dashboard/PR summaries
showed raw prompt-token sums with no cache accounting -- 360,018 of a
reported 400,021 "prompt tokens" were cache hits billed at a steep
discount, not full price. Real fresh spend was ~40,003 tokens, roughly
10x less than the headline number implied. Nothing was double-counted;
the totals were internally consistent, just presented misleadingly.
Adds TaskContext.RunUsage (in-memory, presentation-only) and
formatTokenUsage, rendering "N tokens (F fresh + C cached)" in PR
bodies and the dashboard timeline instead of a raw sum, falling back
to the plain total when no breakdown is available.
Also trims StageBaselineGate's retry-mission prompt to failing-only
go test output via extractFailingGateOutput -- the full passing-
package listing was a direct, mechanical contributor to the growing
per-iteration prompt sizes on every gate-repair retry, not just a
display problem. Degrades to unchanged output for non-Go gates or
unrecognized shapes.
Confirmed in production (carina, 2026-09-02, task 6): StageBaselineGate
spent 405,004 tokens genuinely fixing two broken pre-existing tests and
committed the fix locally, then the plan/build stages correctly found
nothing further to do for a content-free task. StageCommitPush decided
"no changes required" purely from the build stage's own empty diff,
with zero awareness that StageBaselineGate had already committed a
real, gate-verified change two stages earlier -- so it never pushed,
never opened a PR, and the whole worktree (including the real fix) was
discarded. 669,421 tokens burned to fix a real bug that then evaporated,
and it recurs: any task that hits the same red baseline pays the
identical tax again since the fix never lands.
Adds TaskContext.BaselineFixed, set when StageBaselineGate's own
CommitAll reports a real commit. The build stage's no-changes
determination now respects it, and StageCommitPush pushes whenever
either a fresh commit was made or a baseline fix already landed,
instead of erroring on an empty tree.
channels.Manager.MarkRunning was never called for telegram, email, or
webhook -- every start path only called MarkStarting then MarkFailed
on error, so the dashboard showed a working channel stuck on
"Starting" forever (confirmed live: Telegram polling and delivering
messages while /api/channels still reported "starting").
Adds gateway.Lifecycle{Starting, Running func()}, threaded through
Gateway.Start(ctx, router, lifecycle). Email and webhook report
Running once their listener actually binds -- webhook moves off
http.Server.ListenAndServe's internal bind to an explicit
net.ListenConfig.Listen so binding is observable before Serve.
Telegram reports Running after StartWebhook launches in webhook mode,
or after the first successful getUpdates response in long-poll mode,
observed via a pollReadinessClient http.Client wrapper since the
go-telegram/bot library keeps polling errors inside its own worker
goroutine. Restart re-reports Starting/Running each cycle.
Adds internal/domain/image (Provider/Registry per the plugin engine
family shape, but no Lifecycle -- a provider is call-scoped, not
long-running) and config.ImageConfig with the same explicit
enabled=true cost gate MinimaxConfig already uses, since a hosted
provider spends real API credits and a local one can saturate the
host GPU. Design doc at docs/prds/image-capability-contract.md per
CLAUDE.md's rule for undesigned capabilities.
No provider implementation lands here -- that's the epic's next
child bead. Also re-links all 7 epic children that were unlinked
from archie-core-1786748942120-1-6636e629 (same orphaning pattern
found in the curator/memory epics earlier this session).
FeedHandler.WithAttrs/WithGroup only tracked bound attrs for the live
feed copy; Handle forwarded the bare record to the wrapped handler, so
component (and any other With-bound attr) never reached stderr/file
JSON sinks or survived restart for historical log filtering. Now
WithAttrs/WithGroup also derive the wrapped handler via its own
With*, matching agentexec.SystemLogHandler's existing pattern.
Closes archie-core-1786637499114 (persistent session-memory curator),
the last open item in the curator engine epic.
docs/prds/session-memory-curator.md records the decisions this needed
before coding, most notably: Observation.Identity is the session ID,
not a user or cross-session identity. migration-decisions.md#5's
memory-scope mapping (global/agent-wide/user-wide/agent-user
relationship) is still explicitly open, and this issue has no business
deciding it unilaterally -- session-as-identity is the narrowest
unambiguous scope available today and is forward-compatible with a
later, properly-decided identity resolution.
curator gains ConversationSource (RecentSessions/Messages), gated in
Registry.validateDeclared/filter exactly like Skills/MemoryEngines, plus
Manifest.Conversations. internal/infrastructure/sessioncurator/adapter.go
adapts gateway.SessionStore's full CRUD/branch/search surface down to
those two read-only methods -- curator must not import gateway.Message,
so role derivation (message.From == botUser -> assistant) is copied from
gateway.compressTurnHistory's existing logic, not shared.
sessioncurator.go: Check is a cheap RecentSessions bool. Pass takes each
session's last 40 messages, asks the model for a JSON array of durable
facts (capped at 5/session), and writes each through
Registrar.MemoryEngines.Get(name) -- resolved by name at call time, the
same trust model every other curator capability already uses. A
response that fails to parse degrades to "nothing extracted" for that
session (not a Pass error); a real model-call failure propagates as one
(these were originally conflated into the same swallowed-error path --
caught by TestPassPropagatesALLMFailure, fixed by splitting the model
call from the parse step). PassInput.Since zero resolves to a 24h
lookback, not the beginning of time, so a cold-start first pass can't
read a session's entire history.
Manifest.OnInput = true wakes it via the existing WakeOnPrimaryInput
wiring (events.KindTurnCompleted), which already excludes every
curator-derived event kind from the forwarded set -- the trigger-
accounting invariant (archie-core-1786637489768) needed no new code to
hold here.
Wired into bootstrap.go:setupCurators via a new curatorLLMRunner adapter
(main.go) over the shared ai-sdk runtime, and sessioncurator.NewAdapter
over b.chatSessionStore/b.cfg.BotUser. Model resolves from
b.chatModels.ActiveModel() -- not b.defaultChatIdentity, which names a
task-routing identity, not a model reference (the same source
telegram_setup.go's sendChatTurn already uses for a real chat turn).
task check is green (full Go suite + dashboard tests).
Part of archie-core-1786637499206 (skill curator reference
implementation), under the curator engine epic.
docs/prds/skill-curator.md records the design decision this needed
before coding (no settled design existed for what "review, prune, and
improve skill definitions" means as concrete Pass() behavior): v1 is
mechanical validation and safe whitespace normalization only. No
LLM-authored rewrites of skill content, no automatic deletion -- an
autonomous process editing or deleting a user's skill has no undo path
today, and the epic's actual purpose for this issue is proving the
curator contract holds for a second, structurally different consumer
(files-as-skills vs. observations-as-memory), not solving "what makes a
skill good."
internal/infrastructure/skillcurator/store.go: a curator.SkillStore
implementation over one root's .agents/skills/*/SKILL.md files. Not
internal/skill.Discover directly -- Discover parses every skill up front
and fails the WHOLE call if any one of them doesn't parse (correct for
"load the catalog to boot the daemon", wrong for "review each skill and
report what's wrong with it individually"). This store lists/reads raw
bytes per skill; the curator itself parses each one so one bad skill's
parse failure becomes one Action, not an aborted pass.
internal/infrastructure/skillcurator/skillcurator.go: the CuratorEngine.
Check is a cheap directory-listing bool. Pass classifies each skill into
exactly one of: skill.invalid (frontmatter parse failure, left
untouched), skill.incomplete (missing required name/description,
untouched), skill.normalized (trailing whitespace / missing final
newline, written back), or nothing (already clean). Manifest declares
only Skills -- no Tools, no MemoryEngine -- since nothing here needs
either.
Wired into internal/app/archied/bootstrap.go:setupCurators, rooted the
same way loadWorkflows already resolves skillsBase (cfg.SkillsDir falling
back to cfg.WorkDir) -- one local root, not the full multi-root catalog a
chat turn reads. Skills is now a shared registrar-level service
(alongside Events/MemoryEngines), narrowed out of a curator's view by
registry.filter when undeclared, same as every other capability.
task check is green (full Go suite + dashboard tests); go test ./...
is green.
Closes archie-core-1786637499161-356-e424e40d.1.
setupMemory's own doc comment claimed external providers are added via
RegisterExternal when cfg.Memory.Provider is set -- no such call
existed. Investigated wiring it for real: there is no external
MemoryProvider implementation anywhere in the repo to construct and
register (only internal/memory/builtin.Provider exists), so there is
nothing to route memory.provider's value to yet. Wiring the call would
be dead plumbing to nothing, not a fix.
The actual defect is that setting memory.provider has always silently
done nothing -- an operator who set it reasonably believed they
configured something. validateMemory now rejects it outright with a
clear reason, turning a silent no-op into a loud one at config load,
same failure-loudly posture as every other unimplemented-value check in
this file. Drop the rejection once a real external provider (or the new
domain/memory engine family's Honcho proof, archie-core-1786637492031)
gives the field an effect again.
Updated setupMemory's doc comment and config.example.toml to match --
the provider_config example is removed too, since it has nothing left
to configure.
Closes archie-core-1786637499636 (bind curators to memory engines).
curator.Registrar gets MemoryEngines, a MemoryEngineSource
(Get(name) (domainmemory.MemoryEngine, bool)) mirroring
domain/memory.Registry.Get's exact signature so the real registry
satisfies it with no adapter. Registration enforces presence the same
way Tools/Skills already do: a curator declaring Manifest.MemoryEngine
with no MemoryEngineSource on the host is rejected at Register, and
filter() clears MemoryEngines from a curator's view when it declared no
engine. A curator with a declared name that turns out not to exist in
the registry is not this layer's problem -- Get(name) at call time
returns false, same as ToolBuilder.Build with an undeclared tool.
Resolution is by name at call time, not a value pre-fetched at Bind: a
curator calls MemoryEngines.Get(its own Manifest().MemoryEngine) itself,
the identical trust model ToolBuilder.Build(ctx, declared) already
uses -- the curator is trusted to pass its own declared identifier, not
handed something pre-scoped to it. Swapping the configured engine (a
different name resolving through the same registry) changes where a
curator's memories land with no change to the curator itself, since
nothing about the curator's own code names a concrete engine.
setupCurators wires b.memEngines (*domainmemory.Registry, set by
setupMemoryAll which Run() calls first) straight in -- it already
satisfies MemoryEngineSource.
A curator declaring no memory engine remains valid (existing behavior,
now also covered by the "nothing declared" and "no source" table
cases) and is only ever affected by a memory operation it never has the
means to attempt, since MemoryEngines is nil in its view.
Completes archie-core-1786637499480 (ship the file-writing store as
the default memory engine): cfg.Memory.Engine now actually selects and
starts an engine, closing the gap the previous commit's message called
out as remaining.
setupMemoryEngine builds a domain/memory.Registry, registers
infraMemory.BuiltinEngine for "builtin" (and the empty/unconfigured
case, matching applyMemoryDefaults' resolution) rooted at
workDir/memory-engine -- separate from the legacy provider's
workDir/memory, so the two can never collide on the same files while
both exist -- starts the registry, and stops it on daemon shutdown.
cfg.Memory.Engine is already validated against the same set at config
load (configuration.validateMemory), so the switch's default case only
guards the two lists drifting apart, not live operator input.
setupMemory and setupMemoryEngine are both called through a new
setupMemoryAll from Run(), which was already at its cyclomatic
complexity budget -- a genuine grouping (both are memory-subsystem
startup), not two unrelated steps merged just to hit a number.
setupMemoryEngine deliberately does not thread Run()'s ctx through to
registry.Start, matching setupMemory's own existing choice for the same
reason (Start is a synchronous startup step, not a subscription that
needs the daemon's lifetime the way setupCurators' WakeOnPrimaryInput
does) -- also what avoids a contextcheck trip that threading ctx through
setupMemoryAll produced during development.
Not yet done: internal/memory.Manager (the live system-prompt/tool-call
path) does not read through this registry -- the two memory systems run
in parallel, per archie-core-1786637490069-11-e245c170's explicit "do
not extend the legacy system in place" scoping. That convergence is
future work, not part of this issue.
Part of archie-core-1786637490043 (config surface for memory engine
selection and settings).
config.MemoryConfig gets an Engine field selecting among the
domain/memory engine family, plus toml tags on every field -- Provider,
ProviderConfig, and SessionTTL had none before, yaml/json only, which
didn't match repo convention.
Engine and Provider are kept as two separate fields rather than one:
they select between two different mechanisms (the new engine family vs.
the legacy external-provider path, archie-core-1786637499161-356-e424e40d.1),
and conflating them would mean a value meant for one silently getting
read by the other once both are wired.
applyMemoryDefaults resolves an absent engine to "builtin" so
unconfigured and explicitly-builtin are the same state everywhere after
defaulting. validateMemory rejects an unrecognised engine name in the
same style as forge.type's existing validation -- named constant list,
"%w: field %q (want %s)" shape, wired into the same validate() chain.
config.example.toml documents the new field.
Not yet wired to anything: nothing reads cfg.Memory.Engine at daemon
boot yet to actually select and start an engine through
domain/memory.Registry. That's bootstrap wiring, tracked as the
remaining half of archie-core-1786637499480 (ship the builtin store as
the default engine).
Part of archie-core-1786637499480 (ship the file-writing store as the
default memory engine).
Records the missing design decision first (migration-decisions.md#5,
"authoritative memory record and revision model" was explicitly open):
internal/memory/builtin.Store addresses blocks by content substring with
no stable per-block ID, which the new Record{ID}/Forget(id) contract
needs. Decided and implemented: an ID assigned once at Write via a
leading `<!--mem:<uuid>-->` marker line, stripped back out of
Record.Content on read, located by that marker (not content) for
Forget -- so an unrelated edit can never orphan a Forget. Identity maps
to a directory named hex(sha256(identity)), not the identity string, so
an arbitrary identity can never traverse outside the configured root.
Kind maps to a builtin section name via the store's own
ValidateSectionName, so an invalid Kind fails the same way an invalid
section already does.
internal/infrastructure/memory.BuiltinEngine wraps one builtin.Store per
identity and implements domain/memory.MemoryEngine end to end
(Write/Query/List/Forget, Lifecycle, Manifest). Lives under
internal/infrastructure per organisation.md ("infrastructure implements
domain contracts"), not internal/domain/memory, which stays
contract-only.
internal/memory/builtin is untouched -- confirmed via git status and its
own test suite passing unmodified, per this issue's acceptance
criterion. This engine is not yet wired into daemon bootstrap or the
config surface (archie-core-1786637490043); it proves the contract
holds for the builtin store the same way curator's reference
implementations prove the curator contract, and registers/runs cleanly
through domain/memory.Registry (TestBuiltinEngineRegistersAndRuns
ThroughTheRegistry).
Part of archie-core-1786637490069-11-e245c170 (memory engine contract
and owning registry), under epic archie-core-1786637499161 (pluggable
memory engine).
Stands up internal/domain/memory as a conforming engine family per the
strict plugin engine rule, mirroring internal/domain/curator's split
exactly as that issue's notes specify:
- contract.go: MemoryEngine (Lifecycle + Store + identity + Bind), with
Store carrying the real domain operations the epic requires --
Write/Query/List/Forget -- not just Name/Version. Store is split out
from MemoryEngine so the interface stays under golangci-lint's
interfacebloat threshold the same way curator's embedded Lifecycle
does: an embedded interface counts as one slot, not its expanded
method count.
- registrar.go: narrow typed host access (EventSink, Clock). No
capability-gated fields yet -- unlike curator's Tools/Skills, no
memory-specific host service exists to gate on today, so Registry.Bind
passes the host straight through rather than filtering.
- registry.go: Register/Get/Names/Start/Health/Stop with the same
duplicate/nil/panic/failure-isolation guarantees as curator's registry,
ctx-bounded Stop, reverse-order shutdown.
This is the contract only -- no engine implements it yet, and
internal/memory's existing ad-hoc MemoryProvider/Manager (pre-migration)
is untouched, per the issue's explicit "do not extend in place" note.