2c7eab2b2df19e4bf0672b79a7cced900ef2fd4e
16
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e7afe2da8b |
feat(eda): playbook document + event coordinator, single-action workflow-kind dispatch
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).
|
||
|
|
cba3a9a86d |
feat(eda): Module position first slice -- registry + side-effect-free log kind
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. |
||
|
|
cf6c5f42d5 |
feat(workflow): load kind/label bindings from multiple playbook directories
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). |
||
|
|
17e626dfba |
feat(workflow): route arbitrary forge labels to workflows via playbook YAML
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. |
||
|
|
5268634f27 |
feat(workflow): make kind-to-workflow routing YAML-overridable
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. |
||
|
|
7ee6ee5554 |
feat(store): encrypt playbook binding secrets at rest
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 |
||
|
|
543c10ac9a |
feat(webui): playbook bindings -- matcher + mapping + workflow, HMAC-gated
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) |
||
|
|
a4fbd8d6ef |
feat(webui): inline editing for per-repo allow_concurrent/max_retries/review_enabled
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.
|
||
|
|
c7e3bf190e |
fix(channels): call MarkRunning once a channel is actually up
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.
|
||
|
|
7515ad82aa | curator and other components aren't being logged or shown in the Web UI (archie) | ||
|
|
c4871569ce |
feat(curator): session-memory curator reference implementation
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). |
||
|
|
c85bcff57d |
feat(curator): skill curator reference implementation
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. |
||
|
|
704a5ee642 |
fix(config): reject memory.provider instead of silently ignoring it
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. |
||
|
|
388b093b78 |
feat(curator): bind curators to memory engines
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. |
||
|
|
538b29aa0f |
feat(daemon): wire the domain/memory engine registry at boot
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. |
||
|
|
5fa010c9c2 |
fix(plugin): add missing CLAUDE.md reference to plugin engine rule
Test TestPluginEngineRuleIsCanonicalAndSharedByAgentInstructions was missing entirely, letting CLAUDE.md drift out of sync with ARCHITECTURE.md#plugin-engine-rule-strict. Added the test and the missing reference. |