Self-review caught a real architecture bug in a doc I'd just written:
organisation.md's target structure moves forge/ under
internal/infrastructure/forge/; today's internal/forge is a flat,
unmigrated legacy package. A new internal/domain/eda package depending
on it directly would create a domain-to-infrastructure dependency that
breaks the moment forge migrates -- the same trap the workflow domain
package already solved for itself via its own narrow Forger interface
(CloseIssue/CreatePR/LinkBranch, already exactly the three proposed
operations), already satisfied by the daemon's real forge client today.
Depend on workflow.Forger, not internal/forge.
Partial completion of archie-core-t2db.6 -- covers the binding model
(matcher/mapping/versioning/state machine) and verifies each of the
five threat-model non-negotiables from archie-core-t2db.5 against the
actual shipped code (not just the design intent), plus the AES-GCM
secret-at-rest encryption from t2db.7 and the binding_dispatches
at-most-once ledger.
Every claim checked against real code before writing, not assumed --
caught and corrected one wrong claim in-flight: binding-originated
tasks enqueue via EnqueueChatTask (the same direct-to-store.Task path
chat-spawned tasks use), NOT workintake.TaskEnvelope/NATS the way
forge-polled tasks do. Both converge on the same tasks table and
downstream gate/worktree pipeline, but by genuinely different enqueue
mechanisms -- worth noting for t2db.6's still-open ARCHITECTURE.md
task-lifecycle section, since this is exactly the provenance
distinction that section needs to state.
Explicitly does not cover: the ARCHITECTURE.md lifecycle addendum or
the operator walkthrough, both still open pieces of t2db.6.
Both packages no longer exist -- internal/workflow moved to
internal/domain/workflow at the 2026-08-07 domain migration (7e896c9),
confirmed by TaskContext still living there today. internal/nats is
gone entirely; verified TaskMessage as a type doesn't exist anywhere
in the codebase now, and archie.task.* subjects + TaskEnvelope live in
internal/domain/workintake (recorded as a completed migration in
migration-decisions.md), with transport in
internal/infrastructure/agenttransport/nats.
Fixed the two simple path corrections directly. Left the NATS row's
deeper question open rather than guessing: whether the row's entire
"current meaning" is now superseded by TaskEnvelope (not just its
location) needs a closer look this pass didn't have grounds to assert.
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.
Investigation for t2db.19. Forge is ready to design: internal/forge.Forge
is already a typed, general-purpose interface with real implementations
(GitHub/Gitea) -- native-Go-by-name, no Yaegi/Module detour needed.
close-issue/link-branch are the safe first-slice operations; create-pr
is deferred (harder idempotency shape than a single-call operation).
Corrects the crew investigation's assumption about Channel: verified
directly that channels.Channel has no Send capability at all (only
Name/Start/Stop + config validation). The only generic outbound
mechanism in the codebase is the single-destination Notify webhook.
Real per-channel sending (telegramApprover) is deliberately
conversation-scoped, not a reusable registry lookup -- a documented
precedent to prevent reading a shared bot handle across chats, which
doesn't transfer to a playbook trigger with no chat turn to anchor to.
Flags two materially different things "Channel action" could mean and
recommends Sam decide before any Channel design work starts, rather
than guessing.
The example log module's install comment claimed a default module_dir of
~/.config/archie/modules. ModuleDir defaults to empty (internal/config),
and the canonical example path is ~/.local/share/archie/modules, consistent
with plugin_dir/work_dir/skills_dir in config.example.toml. Recomment to
point at config.example.toml's module_dir and drop the overclaim.
Docs audit finding (.crew/reports/docs-audit.md): no live architecture doc
contradicts today's changes; Module-family documentation in ARCHITECTURE.md
is deferred pending sign-off and parity with the Memory precedent.
Sam's explicit requirement: the definitive gate should catch lint
regressions, not just fmt/vet/build/test. Immediately surfaced real
debt on the first run -- see follow-up beads issues.
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).
CEL (cel.dev/cel-go, pinned v0.32.0) is the single expression mechanism
covering both an action's `when` condition and its `args` values,
evaluated against a read-only context (`event`, `actions.<id>.result`).
Rejects the custom-gate precedent (Yaegi-in-YAML) as inverting the
design's own "YAML is data, Yaegi is logic" premise. Expressions
compile/type-check at playbook load, consistent with the existing
collision-handling reject-at-load rule; generated Module Result schemas
become CEL type declarations so result-path typos reject at load too.
Vetted against expr-lang/expr, gval, govaluate (archived), starlark-go:
CEL wins on structural safety (non-Turing-complete, CostLimit-bounded,
error values not panics, zero security advisories on record) despite
the largest binary cost (+13MB) of the candidates -- accepted because
the alternative is re-implementing CEL's type-checker on a bespoke
grammar for the same guarantee.
Sign-off (Sam, 2026-09-03): all judgment calls (J1-J5) accepted as
proposed, including J2's per-value CEL-literal quoting cost and the
+13MB binary size trade.
Cross-references in module-position.md updated to point at this
resolution instead of citing open question 1 as unresolved.
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).
Resolves eda-playbook-engine.md's deferred schema-generation question
for the Module action position. Generalizes the fixed-signature,
resolved-by-name Yaegi pattern already shipped three times (custom
gate, workflow stage plugins, skill plugins) instead of inventing a
new mechanism: one small hand-written schema package per action kind,
go:generate yaegi extract (the same command wfextract/gateextract
already use) producing its symbol table, a ModuleRegistry keyed by
kind rather than a generic any-typed Module interface -- keeping every
position individually compliant with the plugin engine rule instead
of reopening the generic-hook question event-sources-and-reactions.md
already closed.
Closes open question 3 (trust boundary: operator-installed, in-process,
same tier as PluginDir/SecretEngineDir -- not repository-supplied task
code). Recommends a side-effect-free first Module kind, since any kind
with a real external effect is still blocked on the parent doc's
unresolved execution-time gaps (idempotency, mid-run failure).
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.
Not a bundled-vs-standalone tradeoff: validation logic lives in
internal/domain/workflow with no knowledge of its caller, so archied
and agents already validate in-process, and the standalone cmd/
binary (t2db.12) exists only because CI/editors are out-of-process
consumers by nature. One implementation, two thin consumer shapes.
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.
Records the design for drop-in, data-driven workflows/labels/actions:
YAML playbooks as pure orchestration data over four typed logic
positions (Workflow/Module/Channel/Forge), go:generate-driven schemas,
and load-time collision handling (detect+log+report, no auto-arbitration).
Flags execution-time idempotency and mid-run failure handling as
unresolved gaps to close before Channel/Forge or multi-action playbooks
ship.
Use @testing-library/preact rendered under jsdom (registered via
test/register.js) so the Post-Preact .jsx components and pages are
exercised through the real automatic-runtime render path instead of the
legacy el() DOM-helper API the tests were written against.
- Add jsdom + @testing-library/preact dev deps and a jsdom globals setup
in ui/test/register.js (window/document/navigator/getComputedStyle/...).
- Switch the .jsx loader hook to the automatic JSX runtime to match
@preact/preset-vite, so source files that shadow h (mapping-editor) and
Fragment/children arrays work exactly as in the Vite build.
- Migrate captures, config-row, mappings, settings-update-status,
task-logs, settings-lifecycle, settings-schema, tasks-actions and the
chat-app tests to render the Preact components and query the DOM via
testing-library.
- Fix a real render bug in tasks.jsx: <h.Fragment> is not rendered by the
automatic runtime (rows came out as [object Object]); use the imported
<Fragment> instead, matching the other migrated modules.
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