From 97a5c0d2ca8262044a5e4b82dced40a7d9b381d2 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Thu, 3 Sep 2026 02:35:42 +1000 Subject: [PATCH] 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. --- .beads/issues.jsonl | 39 ++++++------ internal/app/archied/bootstrap.go | 6 ++ internal/config/config.go | 6 ++ internal/domain/workflow/routing.go | 77 ++++++++++++++++++++++-- internal/domain/workflow/routing_test.go | 74 +++++++++++++++++++++++ 5 files changed, 177 insertions(+), 25 deletions(-) diff --git a/.beads/issues.jsonl b/.beads/issues.jsonl index 1bdd4d0a9..b60d18bba 100644 --- a/.beads/issues.jsonl +++ b/.beads/issues.jsonl @@ -13,7 +13,7 @@ {"_type":"issue","id":"archie-core-1ysw.1","title":"Bind worktree RPC operations to the dispatched task","description":"The sandboxed agent can currently choose owner, repo, issue, base, and branch on worktree RPC requests. The daemon then performs host deletion and credentialed forge operations without correlating the request to the dispatched task or enforcing WorkDir containment.","acceptance_criteria":"Reject traversal and unconfigured or task-mismatched coordinates before any filesystem or forge side effect; derive or validate the permitted branch; regression tests fail on the old behavior and pass on the fix.","status":"closed","priority":0,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-08-22T11:01:43Z","created_by":"Sam Catlow","updated_at":"2026-08-24T06:59:58Z","started_at":"2026-08-22T11:02:03Z","closed_at":"2026-08-24T06:59:58Z","close_reason":"Fixed on main: worktreerpc now exposes only Push, authorized by an opaque per-dispatch grant issued from the dispatched *store.Task (worktreerpc.go:71-83). Sandbox input no longer selects host path, repo or branch; ValidCoordinates rejects traversal. Package tests pass.","external_ref":"https://github.com/samcharles93/archie-core/issues/589","metadata":null,"dependencies":[{"issue_id":"archie-core-1ysw.1","depends_on_id":"archie-core-1ysw","type":"parent-child","created_at":"2026-08-22T21:01:42Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-1ysw","title":"Repair internal/worktree correctness and trust-boundary defects","description":"Track the concrete worktree-package defects proven by the 2026-08-22 evidence-gated review. Child bugs cover RPC authority/path containment, repository-key isolation, retry/base/diff correctness, push lifecycle, terminal cleanup, cancellation, and branch naming. This epic groups implementation only; each child has its own observable acceptance criteria.","acceptance_criteria":"All child bugs are closed with red-green regression tests, scoped lint passes, and the repository quality gate is clean.","status":"closed","priority":0,"issue_type":"epic","owner":"sam@catlow.tech","created_at":"2026-08-22T11:01:18Z","created_by":"Sam Catlow","updated_at":"2026-08-24T08:16:00Z","closed_at":"2026-08-24T08:16:00Z","close_reason":"All 9 children complete. The P0/P1 trust-boundary and correctness defects (.1 RPC task binding, .2 colliding directory keys, .3 untracked cleanup, .4 fail-closed base resolution, .5 three-dot merge-base semantics) were already fixed on main and reconciled 2026-08-24. The remaining four (.6 push result, .7 no-change worktree leak, .8 commit cancellation, .9 branch naming contract) were implemented this session, merged as 474c31d and its two merge commits, task check green, with an independent adversarial review reporting zero findings.","external_ref":"https://github.com/samcharles93/archie-core/issues/590","dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-t2db.5","title":"Security: an unauthenticated endpoint must not be able to run an agent","description":"P0 within this epic because the feature's own pitch is the threat model: a public intake surface whose output is an agent with tool access and a repo. Get this wrong and a webhook URL is remote code execution with extra steps.\n\nNon-negotiables to design:\n\n- Per-source authentication. A source registers with a secret (HMAC, as internal/channels/webhook already does per route) before its events can trigger anything. Capture-only for unknown senders is acceptable; triggering is not.\n- Human approval before a binding goes live. An operator authoring a binding is a deliberate act; an event arriving is not. Nothing should self-arm.\n- Rate and volume limits per source, so capture cannot be used to exhaust disk or drown the inspector.\n- Payload content is untrusted input flowing into an agent prompt. Treat prompt injection as expected, not exceptional -- the sender controls that text, and the agent has tools. Bound what a playbook-triggered workflow may do.\n- Captured payloads may contain secrets from the sending system. Decide retention, redaction and who can view them; internal/memory/scrubber may already have applicable prior art.\n\nArchie's own principle applies: environmental enforcement over prompt rules. 'The agent should ignore instructions in the payload' is not a control.","acceptance_criteria":"An event from an unauthenticated source can be captured but cannot trigger a workflow; a new binding requires explicit human approval before it arms; per-source rate limits exist; the blast radius of a playbook-triggered workflow is bounded by code rather than by prompt text; retention and visibility of captured payloads is decided and documented.","notes":"2026-08-22: security design decided and documented in docs/prds/webhook-intake-security.md, covering all five non-negotiables from this bead's description:\n1. Per-source auth reuses internal/channels/webhook's existing HMAC-SHA256 scheme; capture accepts unsigned events (visible, marked unauthenticated), only authenticated events can ever match a binding.\n2. Bindings gain a draft -\u003e pending_approval -\u003e armed state machine; any edit to an armed binding drops it back to pending_approval so approval can't be bypassed by editing. Modeled on telegram's existing dangerousAction/pendingApproval flow (dangerous.go/approval.go).\n3. Per-source token-bucket rate limiting (precedent: pairing/store.go's MaxPendingPerPlatform); limit-exceeded is an observable 429, not a silent drop.\n4. Blast radius bounded by the SAME code-level controls every task already gets -- gate, diff_cap_lines, sandboxed container, worktree isolation -- no new relaxation for playbook-triggered work, and payload text is ordinary untrusted prompt input, never a trusted instruction.\n5. 7-day configurable retention on captured payloads; best-effort redaction reusing gateway/stream.go's sensitiveParameterKey heuristic before persisting; visibility gated by the same dashboard auth as every other webui surface.\n\nThis bead's code-level acceptance criteria (capture-can't-trigger, rate limits exist, blast-radius bounded, approval gate) cannot be implemented yet: they constrain t2db.1 (capture), 7d5u.3 (intake family) and t2db.4 (binding), none of which have landed. This document is the contract those beads build against -- do not build any of them without satisfying it. Leaving this bead in_progress rather than closing it; it closes when t2db.1/7d5u.3/t2db.4 land and demonstrably satisfy points 1-5, not before.","status":"closed","priority":0,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-21T13:45:46Z","created_by":"Sam Catlow","updated_at":"2026-09-02T13:09:39Z","started_at":"2026-08-21T14:51:26Z","closed_at":"2026-09-02T13:09:39Z","close_reason":"Closed","external_ref":"https://github.com/samcharles93/archie-core/issues/536","dependencies":[{"issue_id":"archie-core-t2db.5","depends_on_id":"archie-core-t2db","type":"parent-child","created_at":"2026-08-21T23:45:45Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":1,"comment_count":0} -{"_type":"issue","id":"archie-core-95dj","title":"StageCommitPush discards baseline-fix commits when build makes no changes","description":"Confirmed via carina production logs (task 6, chat-spawned synthetic test task, 2026-09-02). StageBaselineGate (internal/domain/workflow/implement.go:37) found the repo's gate red at the base commit, spent 405,004 tokens/14 iterations genuinely fixing two broken pre-existing tests, and committed the fix locally via tc.Trees.CommitAll (implement.go:104) -- verified passing. plan and build stages then correctly found nothing else to do for the (synthetic, content-free) task. StageCommitPush -\u003e closeNoChangesIssue (steps.go:56) decides 'no changes' purely from tc.BuildNoChanges, which the build AgentStage sets from its own len(res.Changes)==0 (implement.go:176) -- it has zero awareness that StageBaselineGate already committed real changes two stages earlier. Never pushed, never opened a PR; the entire worktree containing a real, gate-verified fix for genuinely broken tests was discarded when the task closed as 'merged: completed -- no changes required'.\n\nCost: 669,421 tokens burned to fix a real bug that then evaporated. This recurs: any task that hits the same red baseline pays the identical tax again since the fix never lands. Evidence a prior incident already happened: an orphaned 'fix: baseline gate repair' commit (e49f3cd) sits on a stale, unmerged branch (fix/441-archied-repos-entries-cant-span-more-than-one-forge) from an earlier occurrence.","design":"Fix direction: either (a) StageBaselineGate sets a flag /flips tc.BuildNoChanges appropriately when it commits, or (b) StageCommitPush's no-changes branch checks the worktree's actual diff against the base branch (tc.Trees, similar to StageDiffCap's ChangedLines) instead of trusting tc.BuildNoChanges alone. Prefer (a): cheaper, and keeps the diff-against-base check (which already exists for StageDiffCap) from being computed twice per task.","acceptance_criteria":"A task whose baseline-fix stage committed real changes, but whose plan/build stages found nothing further to do, still pushes and opens a PR carrying the baseline-fix commit -- it must never be silently discarded. tc.BuildNoChanges (or StageCommitPush's decision) accounts for what StageBaselineGate already committed, not just the build stage's own diff. Regression test reproduces the exact scenario (baseline-fix commits, build stage reports zero changes) and proves a PR opens. task check passes.","status":"closed","priority":1,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-09-02T11:20:48Z","created_by":"Sam Catlow","updated_at":"2026-09-02T11:25:53Z","started_at":"2026-09-02T11:20:51Z","closed_at":"2026-09-02T11:25:53Z","close_reason":"Fixed via a new TaskContext.BaselineFixed flag: StageBaselineGate sets it when its own CommitAll reports a real committed change (implement.go:104-111). The build stage's OnResult only sets BuildNoChanges when its own diff is empty AND BaselineFixed is false (implement.go:177), so a baseline-only fix can no longer be masked as 'no changes'. StageCommitPush itself now calls CommitAll directly and pushes whenever either a new commit was made OR BaselineFixed is true (steps.go), instead of erroring on 'nothing to commit' when the real change already sits on the branch from the baseline-fix commit. Two new regression tests (TestStageCommitPushPushesBaselineFixEvenWithNothingNewToCommit, TestStageBaselineGateSetsBaselineFixedWhenItCommits) plus a guard test that the old empty-tree error still fires without a baseline fix. task check clean.","dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"archie-core-95dj","title":"StageCommitPush discards baseline-fix commits when build makes no changes","description":"Confirmed via carina production logs (task 6, chat-spawned synthetic test task, 2026-09-02). StageBaselineGate (internal/domain/workflow/implement.go:37) found the repo's gate red at the base commit, spent 405,004 tokens/14 iterations genuinely fixing two broken pre-existing tests, and committed the fix locally via tc.Trees.CommitAll (implement.go:104) -- verified passing. plan and build stages then correctly found nothing else to do for the (synthetic, content-free) task. StageCommitPush -\u003e closeNoChangesIssue (steps.go:56) decides 'no changes' purely from tc.BuildNoChanges, which the build AgentStage sets from its own len(res.Changes)==0 (implement.go:176) -- it has zero awareness that StageBaselineGate already committed real changes two stages earlier. Never pushed, never opened a PR; the entire worktree containing a real, gate-verified fix for genuinely broken tests was discarded when the task closed as 'merged: completed -- no changes required'.\n\nCost: 669,421 tokens burned to fix a real bug that then evaporated. This recurs: any task that hits the same red baseline pays the identical tax again since the fix never lands. Evidence a prior incident already happened: an orphaned 'fix: baseline gate repair' commit (e49f3cd) sits on a stale, unmerged branch (fix/441-archied-repos-entries-cant-span-more-than-one-forge) from an earlier occurrence.","design":"Fix direction: either (a) StageBaselineGate sets a flag /flips tc.BuildNoChanges appropriately when it commits, or (b) StageCommitPush's no-changes branch checks the worktree's actual diff against the base branch (tc.Trees, similar to StageDiffCap's ChangedLines) instead of trusting tc.BuildNoChanges alone. Prefer (a): cheaper, and keeps the diff-against-base check (which already exists for StageDiffCap) from being computed twice per task.","acceptance_criteria":"A task whose baseline-fix stage committed real changes, but whose plan/build stages found nothing further to do, still pushes and opens a PR carrying the baseline-fix commit -- it must never be silently discarded. tc.BuildNoChanges (or StageCommitPush's decision) accounts for what StageBaselineGate already committed, not just the build stage's own diff. Regression test reproduces the exact scenario (baseline-fix commits, build stage reports zero changes) and proves a PR opens. task check passes.","status":"closed","priority":1,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-09-02T11:20:48Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:56:02Z","started_at":"2026-09-02T11:20:51Z","closed_at":"2026-09-02T11:25:53Z","close_reason":"Fixed via a new TaskContext.BaselineFixed flag: StageBaselineGate sets it when its own CommitAll reports a real committed change (implement.go:104-111). The build stage's OnResult only sets BuildNoChanges when its own diff is empty AND BaselineFixed is false (implement.go:177), so a baseline-only fix can no longer be masked as 'no changes'. StageCommitPush itself now calls CommitAll directly and pushes whenever either a new commit was made OR BaselineFixed is true (steps.go), instead of erroring on 'nothing to commit' when the real change already sits on the branch from the baseline-fix commit. Two new regression tests (TestStageCommitPushPushesBaselineFixEvenWithNothingNewToCommit, TestStageBaselineGateSetsBaselineFixedWhenItCommits) plus a guard test that the old empty-tree error still fires without a baseline fix. task check clean.","external_ref":"https://github.com/samcharles93/archie-core/issues/682","dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-s81k","title":"Preserve bound slog attributes in persistent log sinks","description":"PR #650 scopes daemon, Web UI, and curator loggers with slog.Logger.With. internal/logging.FeedHandler.WithAttrs retains those bound attributes for the live feed but does not pass them to the wrapped handler, while Handle forwards the bare slog.Record. As a result, component is present in live Web UI entries but absent from stderr and file JSON; after restart, historical component discovery and filtering cannot see those records. Fix bound-attribute propagation without breaking slog group semantics or duplicating attributes.","acceptance_criteria":"Bound attributes appear in both Feed entries and the wrapped JSON sink; component values survive file persistence and are discoverable and filterable through historical /api/logs reads; regression tests exercise logger.With for both live and persistent paths; task check passes.","status":"closed","priority":1,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-09-02T09:37:55Z","created_by":"Sam Catlow","updated_at":"2026-09-02T09:48:54Z","closed_at":"2026-09-02T09:43:01Z","close_reason":"Fixed: FeedHandler.WithAttrs/WithGroup now propagate to the wrapped handler, matching SystemLogHandler's existing pattern. Added regression test covering both feed and persistent sink.","external_ref":"https://github.com/samcharles93/archie-core/issues/655","dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-d66k","title":"P1: Update ARCHITECTURE.md Package Map with missing packages","description":"ARCHITECTURE.md's Package Map omits sizeable load-bearing packages:\n- internal/gateway: 18.7k LOC\n- internal/tools: 20.9k LOC\n- internal/memory: 7k LOC\n- secret/*\n- plugin/*\n- skill/*\n\nA contributor or agent reading the map would miss where most of the code actually lives.\n\nNeed to:\n- Audit ARCHITECTURE.md Package Map section\n- Add all missing packages with their responsibilities\n- Ensure consistency with actual package structure\n- Verify LOC counts are accurate\n\nBlocked by: nothing","status":"closed","priority":1,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-08-28T13:42:10Z","created_by":"Sam Catlow","updated_at":"2026-09-02T09:48:55Z","closed_at":"2026-08-31T10:10:50Z","close_reason":"Added internal/gateway, internal/tools, internal/memory, internal/secret, internal/plugin, internal/skill to ARCHITECTURE.md Package Map with LOC and role descriptions","external_ref":"https://github.com/samcharles93/archie-core/issues/656","dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-p3wt","title":"P1: Fix recvcheck - mixed pointer/value receivers","description":"recvcheck found mixed pointer/value receivers on:\n- Duration\n- TaskEnvelope\n- Provenance\n\nThis is a latent mutation-semantics bug - methods may not behave correctly if they expect to mutate the receiver.\n\nNeed to:\n- Audit all methods on Duration, TaskEnvelope, Provenance\n- Standardize to either all pointer receivers or all value receivers\n- Prefer pointer receivers for types that need mutation\n- Verify no behavior changes after fix\n\nBlocked by: nothing","status":"closed","priority":1,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-08-28T13:42:07Z","created_by":"Sam Catlow","updated_at":"2026-09-02T09:48:55Z","closed_at":"2026-08-31T10:09:59Z","close_reason":"Duration and TaskEnvelope were already consistent by the time this was picked up; fixed the remaining recvcheck violation on Provenance (Paths/String moved to pointer receiver to match the mutating record() method). All Provenance uses are through addressable struct fields, so build/tests are unaffected. recvcheck now reports 0 issues.","external_ref":"https://github.com/samcharles93/archie-core/issues/657","dependency_count":0,"dependent_count":0,"comment_count":0} @@ -91,24 +91,25 @@ {"_type":"issue","id":"archie-core-g7tm","title":"telegram: finalize the reply through a live context, matching the error branch","description":"The success path calls live.finalize(turnCtx, reply) with the raw cancellable turn context (telegram.go:582), while the error branch two lines above deliberately uses context.WithoutCancel(turnCtx). If /stop lands during finalize, the rich edit, the plain-text retry, and the split-send fallback all abort with context.Canceled (go-telegram/bot builds requests with NewRequestWithContext), so the authoritative reply is never delivered and the live message keeps the ▌ cursor forever. The reply is persisted to the ledger, so the loss is delivery-level — but the user sees a frozen half-answer.\n\nFailure: a long tool-using turn is /stop-ped as it completes; turnCtx is cancelled mid-finalize; every send fails on the dead context; the chat shows the last live frame with a blinking cursor and no final answer.\n\nFound by code-review of PR #476 (feat/467, merged 98e8dda).","design":"live.finalize(context.WithoutCancel(turnCtx), reply) — the one-liner the error branch already uses. Consider making finalize take a live context internally rather than trusting each caller to remember.","acceptance_criteria":"A /stop landing mid-finalize still delivers the authoritative reply and drops the cursor; a test covers the cancellable-context finalize path.","status":"closed","priority":1,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-14T14:43:08Z","created_by":"Sam Catlow","updated_at":"2026-08-14T15:07:36Z","started_at":"2026-08-14T14:53:28Z","closed_at":"2026-08-14T15:03:28Z","close_reason":"Fixed in internal/channels/telegram/live.go and telegram.go: finalize/abandon strip context cancellation before sending (mirroring each other), ToolCall escapes Markdown metacharacters via bot.EscapeMarkdown, splitLongMessage splits on rune boundaries. All new/changed tests verified red-then-green; task check clean; adversarial review pass found no blocking issues.","external_ref":"https://github.com/samcharles93/archie-core/issues/484","labels":["code-review","streaming","telegram"],"dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-tb3a","title":"Fix streaming review blockers for inline tool calls","description":"Resolve the four evidence-gated findings in merged inline tool-call streaming: preserve the authoritative Telegram reply when final edits fail; keep Telegram network I/O off the model FullStream consumer and cancellable; correlate tool inputs with results and render a bounded redacted parameter summary; snapshot show_tool_calls per live reply to avoid reload races. Add regression tests for every path and run task check plus lint/race validation.","acceptance_criteria":"Regression tests fail on the merged implementation and pass after the fix. Final edit failure falls back to normal split delivery. Delta and ToolCall callbacks do not wait on Telegram HTTP and stop cancels in-flight rendering. Completed tool events include bounded redacted parameters correlated by tool-call ID. Reload cannot race an in-flight reply's show_tool_calls setting. task check passes, golangci-lint reports no new findings, and focused race tests pass.","notes":"Implemented in worktree /tmp/archie-core-tb3a on branch fix/archie-core-tb3a. Added cancellable async Telegram rendering, final edit failure fallback through normal split delivery, call-ID-correlated bounded conservative parameter summaries, atomic per-reply show_tool_calls snapshots, SSE/UI parameter rendering, rebuilt ui/dist, and regression tests. Validation: GOFLAGS=-buildvcs=false task check passed; golangci-lint --new-from-rev=HEAD ./... reported 0 issues; focused race suite passed; fresh adversarial reviewer reported PASS with zero findings. Plain task check is blocked in linked worktrees by Go VCS stamping exit 128, hence buildvcs override.\n2026-08-24 reconciliation: the close reason's 'worktree left uncommitted' is stale. The work did land on main via ba33527 (Merge pull request #477 from samcharles93/fix/archie-core-tb3a); verified on main: gateway/stream.go sensitiveParameterKey+redactToolParameters, telegram/live.go per-reply showToolCalls snapshot, webui/api_chat.go gating. The /tmp/archie-core-tb3a worktree and its branch are gone, as expected.\n","status":"closed","priority":1,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-13T18:05:35Z","created_by":"Sam Catlow","updated_at":"2026-08-24T07:29:09Z","started_at":"2026-08-13T18:05:39Z","closed_at":"2026-08-13T18:35:26Z","close_reason":"Completed and independently reviewed; worktree left uncommitted per conservative repository policy.","external_ref":"https://github.com/samcharles93/archie-core/issues/485","dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-dzx","title":"Remove duplicate archie-agent safe.directory setup","description":"## Problem\\ncmd/archie-agent/main.go configures git safe.directory inline and then calls markWorktreeSafe, so startup writes the same global git configuration twice.\\n\\n## Scope\\nKeep markWorktreeSafe as the single tested production path and remove the older inline exec.Command block/import. Add regression coverage proving startup wiring has exactly one authoritative safe-directory call.\\n\\n## Acceptance\\n- archie-agent startup invokes markWorktreeSafe exactly once\\n- no second inline safe.directory command remains in main.go\\n- cmd/archie-agent tests and repository quality gate pass","acceptance_criteria":"Single tested safe.directory setup path remains; duplicate inline command is removed; tests and task check pass","notes":"Red proof: TestMainConfiguresWorktreeSafetyOnce failed with 2 setup paths before implementation. Green proof: go test/vet/build ./cmd/archie-agent/... passed; golangci-lint --new-from-rev=HEAD reported 0 issues. Fresh adversarial review found no blockers. Full task check was not run because the working tree contains unrelated in-progress changes and task check rewrites files; scoped package gate used per repository protocol.","status":"closed","priority":1,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-13T16:10:09Z","created_by":"Sam Catlow","updated_at":"2026-08-13T16:13:48Z","started_at":"2026-08-13T16:10:24Z","closed_at":"2026-08-13T16:13:48Z","close_reason":"Removed duplicate inline safe.directory setup; markWorktreeSafe is now the single tested production path","external_ref":"https://github.com/samcharles93/archie-core/issues/470","dependency_count":0,"dependent_count":0,"comment_count":0} -{"_type":"issue","id":"archie-core-v9gv.2","title":"Refactor hyperscript el() usage to Preact JSX","status":"closed","priority":2,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-09-02T13:37:19Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:24:02Z","closed_at":"2026-09-02T14:24:02Z","dependencies":[{"issue_id":"archie-core-v9gv.2","depends_on_id":"archie-core-v9gv","type":"parent-child","created_at":"2026-09-02T13:37:19Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} -{"_type":"issue","id":"archie-core-v9gv.3","title":"Update main entrypoint to mount via Preact render","status":"closed","priority":2,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-09-02T13:37:19Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:24:03Z","closed_at":"2026-09-02T14:24:03Z","dependencies":[{"issue_id":"archie-core-v9gv.3","depends_on_id":"archie-core-v9gv","type":"parent-child","created_at":"2026-09-02T13:37:19Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} -{"_type":"issue","id":"archie-core-v9gv.1","title":"Rename UI view files from .js to .jsx","status":"closed","priority":2,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-09-02T13:37:18Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:24:01Z","closed_at":"2026-09-02T14:24:01Z","dependencies":[{"issue_id":"archie-core-v9gv.1","depends_on_id":"archie-core-v9gv","type":"parent-child","created_at":"2026-09-02T13:37:18Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} -{"_type":"issue","id":"archie-core-v9gv","title":"Migrate Web UI to Preact","status":"closed","priority":2,"issue_type":"epic","owner":"sam@catlow.tech","created_at":"2026-09-02T13:37:08Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:24:11Z","closed_at":"2026-09-02T14:24:11Z","close_reason":"All children completed","dependency_count":0,"dependent_count":0,"comment_count":0} -{"_type":"issue","id":"archie-core-t2db.8","title":"Dashboard UI for playbook bindings","description":"The t2db.4 backend shipped the CRUD API (POST/GET/PATCH/DELETE /api/bindings + POST /api/bindings/{id}/approve) plus the state machine and HMAC wiring. Operators cannot author bindings from the dashboard yet: a list-and-approve page exists in api_binding.go's response shape but the matching ui/src/ feature folder does not. Build the click-through editor mirroring ui/src/mappings/ (three-file split: bindings.js, binding-editor.js, bindings.css per docs/prds/payload-field-mapping.md:145-152): source matcher, mapping picker, workflow picker, secret input, state-machine controls (create -\u003e edit -\u003e approve -\u003e armed). Also add binding.Owner / binding.Repo fields so multi-repo deployments have a UI to pin a binding to one repo (today the dispatch loop falls back to the single configured repo with a warning; multi-repo is broken). See docs/prds/webhook-intake-security.md and docs/prds/payload-field-mapping.md.","status":"open","priority":2,"issue_type":"feature","owner":"sam@catlow.tech","created_at":"2026-09-02T13:24:13Z","created_by":"Sam Catlow","updated_at":"2026-09-02T13:24:13Z","dependencies":[{"issue_id":"archie-core-t2db.8","depends_on_id":"archie-core-t2db","type":"parent-child","created_at":"2026-09-02T13:24:13Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} -{"_type":"issue","id":"archie-core-t2db.7","title":"Encrypt binding secrets at rest","description":"binding.Binding.Secret is currently stored as plaintext in the bindings.secret TEXT column. Anyone with read access to the SQLite file (the same access level as captured_events.body and tasks.body) sees HMAC secrets in plaintext. Add at-rest encryption for the secret column so a leaked database file does not leak sender-side shared secrets. See docs/prds/webhook-intake-security.md point 5. Decide the cipher (likely AES-GCM with a key derived from archied's secret registry or a deployment-level key file), the key-rotation story, and whether captured_events.body redaction is upgraded at the same time. Phase F work for t2db.","status":"closed","priority":2,"issue_type":"feature","owner":"sam@catlow.tech","created_at":"2026-09-02T13:24:12Z","created_by":"Sam Catlow","updated_at":"2026-09-02T13:55:47Z","closed_at":"2026-09-02T13:55:47Z","close_reason":"Closed","dependencies":[{"issue_id":"archie-core-t2db.7","depends_on_id":"archie-core-t2db","type":"parent-child","created_at":"2026-09-02T13:24:12Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} -{"_type":"issue","id":"archie-core-b6ew.6","title":"Inline editing for per-repo config fields (allow_concurrent, max_retries, review_enabled)","description":"archie-core-b6ew.4 shipped visibility for AllowConcurrent, MaxRetries, and ReviewEnabled on the repositories card (read-only), which was the concrete discoverability gap Sam hit. Actual inline editing was scoped out of that issue because it hits a real backend limitation discovered while implementing it: the dashboard's PATCH /api/config path (installUpdateConfigHandler in internal/app/archied/bootstrap.go) applies dotted-key updates via overlay.Nest + configuration.ApplyOverlayValues, and overlay.Nest (internal/infrastructure/configuration/overlay/overlay.go:162) only builds nested maps by splitting on '.' -- it has no array-index handling, so a key like 'repos.0.allow_concurrent' cannot be expressed, and Repos is a []config.Repo slice, not a map, so ApplyOverlayValues's YAML-merge-onto-struct approach cannot target one element either.\n\nThis needs either: (a) a dedicated repo-update seam (e.g. a webui handler keyed by owner/name that reads-modifies-writes the Repos slice directly, bypassing the generic dotted-overlay path), or (b) extending overlay.Nest/ApplyOverlayValues to support array indices generically, which is broader-reaching (touches every list-shaped config field, not just Repos) and needs its own design decision about whether index-based overlay keys are stable across a file edit that reorders [[repos]] entries. Option (a) is almost certainly the smaller, safer change -- decide in a short design note before implementing, per this repo's settled-design-first rule, since option (b) has real footguns (index stability) that deserve a deliberate answer, not a guess.","status":"closed","priority":2,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-09-02T12:22:53Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:34:55Z","started_at":"2026-09-02T12:26:59Z","closed_at":"2026-09-02T12:34:55Z","close_reason":"Traced the mechanism before implementing: overlay.Nest/ApplyOverlayValues has no array-index support, but Repos is addressed as a WHOLE dotted key ('repos', no dot) whose value is the full slice -- so no changes to overlay/configuration packages were needed at all. Added PATCH /api/config/repos/{owner}/{name} (webui.Server.UpdateRepoField seam + handleConfigRepoUpdate), wired in archied/bootstrap.go's installUpdateRepoFieldHandler: reads the daemon's own live, untrimmed Repos (not webui.RepoView, which omits Preflight/TestGlob and would silently drop them on a naive round-trip), mutates the one matched repo's one field via the pure applyRepoFieldUpdate helper, and republishes through the existing UpdateConfig(ctx, {\"repos\": repos}) path unchanged -- zero duplicated validate/persist/publish logic.\n\nFrontend: config-row.js's row() gained an opts.save override so a caller can redirect where an edit persists; the repositories table renders an autosaving checkbox (allow_concurrent, review_enabled) and a save-on-blur/Enter text input (max_retries) via api.configRepoUpdate, reverting/erroring inline on failure rather than reloading the whole page mid-edit.\n\nGo tests cover the pure applyRepoFieldUpdate function directly (matched-repo-only mutation, untouched-field preservation including Preflight, type coercion, unknown repo/field rejection) and the webui handler (seam delegation, editable-field allowlist enforced before the seam is called, 503/400 mapping). JS tests cover the structural render (checkbox/input initial state) -- the save round trip itself isn't exercisable through the test shim (addEventListener is a no-op there), consistent with existing config-row.test.js coverage.","dependencies":[{"issue_id":"archie-core-b6ew.6","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:22:53Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} -{"_type":"issue","id":"archie-core-c0y4","title":"TelegramConfig gains a bws-capable Token (SecretRef), not just TokenEnv","description":"internal/config/config.go's TelegramConfig only has TokenEnv (a plain OS env var name); it never resolves through secret.Registry the way Forge.Token and Provider.APIKey do (secret.SecretRef{engine,key}), per ARCHITECTURE.md:220-224's own note that TelegramConfig.TokenEnv is one of the older env-only fields kept for backwards compatibility. internal/app/archied/telegram_setup.go:75 does a bare os.Getenv(cfg.Chat.Telegram.TokenEnv), bypassing the secret registry entirely.\n\nThis means a bws-stored Telegram token cannot be referenced directly in config.toml the way [providers.openai].api_key or [forge.token] already can -- the operator has to bridge it into a real process env var by hand (bws secret get ... | export ARCHIE_TELEGRAM_TOKEN=...) instead of writing [chat.telegram.token] = { engine = \"bws\", key = \"...\" }.\n\nFix: add a Token secret.SecretRef field to TelegramConfig, mirroring Forge.Token's shape and resolution path. Keep TokenEnv working as a fallback/legacy path (same pattern documented for Provider.APIKeyEnv vs APIKey) rather than a breaking config change -- resolve Token first if set, fall back to TokenEnv. Update config.example.toml and docs/architecture identity/config docs to show the SecretRef form as the preferred one.","status":"open","priority":2,"issue_type":"feature","owner":"sam@catlow.tech","created_at":"2026-09-02T12:21:10Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:21:10Z","dependency_count":0,"dependent_count":0,"comment_count":0} -{"_type":"issue","id":"archie-core-b6ew.4","title":"Structured configuration editors: repositories, maps","description":"Repositories currently render as a static read-only table missing AllowConcurrent, MaxRetries, and ReviewEnabled entirely (ReviewEnabled is absent from RepoView in api_config.go, not just unrendered). Add ReviewEnabled to RepoView, and build a dedicated backend-defined editor for the repositories section (and the models/providers maps) so these stop being silently read-only. This is the concrete fix for the allow_concurrent discoverability gap Sam hit, delivered as a typed editor rather than a one-off card patch, since the schema this epic introduces is what should own its shape.","status":"closed","priority":2,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:46Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:23:52Z","started_at":"2026-09-02T12:21:13Z","closed_at":"2026-09-02T12:23:52Z","close_reason":"Scoped to visibility, not full inline editing -- while implementing, found that the dashboard's PATCH /api/config path (overlay.Nest + configuration.ApplyOverlayValues) has no array-index support, so a per-element update to the Repos slice cannot be expressed as a dotted key today. That's real, separate scope, filed as archie-core-b6ew.6 rather than bolted on.\n\nShipped: RepoView.ReviewEnabled (previously absent from the API entirely, not just unrendered) alongside AllowConcurrent and MaxRetries; the repositories card now shows Concurrent/Max retries/Self-review columns as read-only pills, closing the concrete discoverability gap (Sam couldn't see allow_concurrent without an agent tracing Go source). config.example.toml documents review_enabled, which was undocumented before this. Go test pins ReviewEnabled reaching ConfigView for both a configured and a zero-value repo.","dependencies":[{"issue_id":"archie-core-b6ew.4","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:46Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.4","depends_on_id":"archie-core-b6ew.2","type":"blocks","created_at":"2026-09-02T12:00:51Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":1,"comment_count":0} -{"_type":"issue","id":"archie-core-b6ew.5","title":"Schema contract tests: metadata completeness and secret-safety","description":"Assert every field the schema exposes carries type, label, and section; assert restart_required and editable are set deliberately (not zero-value defaults hiding an unreviewed field); assert secrets still never appear (extend the existing TestHandleConfigNeverLeaksSecrets pattern to the schema response); assert the frontend's generic renderer can render the full schema fixture without any field-specific branch (a JS test walking the schema and asserting no field key appears literally in settings.js).","status":"closed","priority":2,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:46Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:26:27Z","started_at":"2026-09-02T12:24:40Z","closed_at":"2026-09-02T12:26:27Z","close_reason":"Most of this issue's assertions were already covered incrementally by tests added in .1-.4 (key/label/type completeness, structured/locked non-editability, secret-leak guard on the schema block, schema values matching their flat-field source). This issue adds the two pieces still missing: TestConfigFieldDescriptorsRestartRequiredIsDeliberate pins the exact RestartRequired value per key against the reload.go evidence documented in configFieldDescriptors' own comment, so a reclassification without checking reload.go fails loudly. ui/test/settings-schema.test.js renders settingsPage against a schema fixture containing a field settings.js has never heard of (proving the renderer needs no field-specific branch to show it correctly) and asserts, by reading settings.js's own source text, that none of the generically-rendered section's field keys appear literally in it -- the direct regression test for archie-core-b6ew.3's whole point.","dependencies":[{"issue_id":"archie-core-b6ew.5","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:46Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.5","depends_on_id":"archie-core-b6ew.3","type":"blocks","created_at":"2026-09-02T12:00:52Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.5","depends_on_id":"archie-core-b6ew.4","type":"blocks","created_at":"2026-09-02T12:00:52Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":2,"dependent_count":0,"comment_count":0} -{"_type":"issue","id":"archie-core-b6ew.3","title":"Generic frontend renderer for scalar configuration fields","description":"Replace settings.js's hardcoded row(...) calls for scalar/bool/int/enum/duration fields with a renderer that walks the backend's sections/fields schema and builds the section cards, labels, and edit affordances from the descriptor alone -- the frontend must not know that containers.max_concurrency is an int or which card it belongs in. Structured fields (repositories, models, providers maps) are out of scope here and keep their existing bespoke rendering, tagged type=structured so the generic renderer skips them without special-casing each key.","status":"closed","priority":2,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:45Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:12:41Z","started_at":"2026-09-02T12:08:25Z","closed_at":"2026-09-02T12:12:41Z","close_reason":"settings.js renders identity/budgets/storage/web cards generically from cfg.schema sections (schemaCards()), replacing identityCard/budgetsCard/storageCard/webCard/pullPolicyLabel -- label, type, description, editability, and options all come from the backend descriptor. config-row.js gained enum edit support (select from opts.options), an editable:false branch distinct from locked rows, and a hint tooltip carrying the field's description. Structured sections (repositories, models \u0026 providers) are unaffected -- still rendered by their existing bespoke functions, reserved for b6ew.4. Not visually verified in a live browser (needs a full daemon+forge+NATS stack); verified via unit tests mirroring the existing config-row.test.js patterns and Go contract tests.","dependencies":[{"issue_id":"archie-core-b6ew.3","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:45Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.3","depends_on_id":"archie-core-b6ew.2","type":"blocks","created_at":"2026-09-02T12:00:50Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":1,"comment_count":0} -{"_type":"issue","id":"archie-core-b6ew.1","title":"Backend configuration schema contract: field descriptor types and section metadata","description":"Define the descriptor types (Section, Field, Option) in internal/webui alongside ConfigView -- Key, Label, Description, Section, Type (string|int|bool|duration|enum|structured), Editable, LockedReason, Overridden, Options, RestartRequired. Hand-author one descriptor per existing ConfigView field, grouped into the sections the settings page already renders (identity, repositories, models, providers, budgets, storage, containers, web). No reflection over config.Config -- config.Config is scheduled for dissolution (internal/config/config.go package doc) and every field here is already a deliberate allowlist entry, so this is metadata on fields that already passed the secret-safety allowlist, not a new safety boundary.","status":"closed","priority":2,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:44Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:05:40Z","started_at":"2026-09-02T12:02:40Z","closed_at":"2026-09-02T12:05:40Z","close_reason":"Added internal/webui/config_schema.go: ConfigFieldType/ConfigField/ConfigSection descriptor types and configFieldDescriptors(), hand-authoring key/label/type/editable/restart_required for every field ConfigView exposes today, grouped into the sections settings.js already renders. RestartRequired sourced from internal/app/archied/reload.go's reloadableFields/reloadableSubFields allowlist. Contract tests pin key completeness, structured-field non-editability, and locked-storage-field non-editability. Not yet wired into GET /api/config -- that's b6ew.2.","dependencies":[{"issue_id":"archie-core-b6ew.1","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:44Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":1,"comment_count":0} -{"_type":"issue","id":"archie-core-b6ew.2","title":"Expose the config schema via GET /api/config","description":"Extend handleConfig's response with a schema-driven shape (sections of fields, each carrying its descriptor and current value) built from the field descriptors, replacing the flat ConfigView value tree the frontend currently re-interprets by hand. Keep the existing Locked/Overridden/Reload/Provenance top-level fields -- they describe runtime state, not the field catalog, and the schema-driven fields reference into them (locked_reason, overridden) rather than duplicating that logic.","status":"closed","priority":2,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:44Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:07:58Z","started_at":"2026-09-02T12:06:31Z","closed_at":"2026-09-02T12:07:58Z","close_reason":"ConfigView gains a Schema []ConfigSection field, populated in handleConfig via buildConfigSchema(view), which attaches each request's Value/LockedReason/Overridden onto the static configFieldDescriptors() catalog. The flat ConfigView fields (Identity, Repositories, etc.) are untouched -- Schema is additive. Tests confirm schema values match the flat fields they derive from, locked reasons propagate, structured fields stay non-editable, and secrets never reach the schema block.","dependencies":[{"issue_id":"archie-core-b6ew.2","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:44Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.2","depends_on_id":"archie-core-b6ew.1","type":"blocks","created_at":"2026-09-02T12:00:50Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":2,"comment_count":0} -{"_type":"issue","id":"archie-core-b6ew","title":"[EPIC] Backend-owned configuration schema for the webui Configuration page","description":"The Configuration page's field definitions (label, section, type, editability, restart-required, options) are hand-maintained in ui/src/settings/settings.js and config-row.js, disjoint from the backend's own ConfigView allowlist in internal/webui/api_config.go. Adding or changing a runtime-tunable setting today means editing Go and JS in two unrelated places by hand, and nothing catches drift between them. Repo.ReviewEnabled is missing from the API entirely; AllowConcurrent and MaxRetries reach the API but the repositories card never renders them, which is what blocked Sam from discovering the allow_concurrent fix without an agent tracing the Go source directly.\n\nDesign: docs/prds/config-schema.md. The backend keeps its existing hand-picked, secret-free allowlist (ConfigView in api_config.go) -- config.Config is scheduled for dissolution per its own package doc, so this is deliberately NOT a reflection-based schema over config.Config. Instead each already-allowlisted field gains a hand-authored descriptor (label, section, type, editable, restart_required, options) alongside its existing value, and the frontend renders scalar/bool/int/enum/duration fields generically from that descriptor instead of hardcoding rows. Structured fields (repositories, maps) get dedicated typed editors rather than staying silently read-only.","status":"closed","priority":2,"issue_type":"epic","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:27Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:35:11Z","closed_at":"2026-09-02T12:35:11Z","close_reason":"All six child issues shipped: hand-authored field descriptor catalog (.1), schema attached to GET /api/config (.2), generic scalar renderer replacing hardcoded settings.js rows (.3), repository field visibility incl. the previously-API-absent ReviewEnabled (.4), schema contract tests pinning restart-required deliberateness and generic-render proof (.5), and inline editing for the three per-repo fields via a dedicated PATCH /api/config/repos/{owner}/{name} seam (.6). The concrete complaint that started this (allow_concurrent invisible on the dashboard) is fully resolved: visible, editable, and backed by a schema the frontend no longer hardcodes.","dependency_count":0,"dependent_count":0,"comment_count":0} -{"_type":"issue","id":"archie-core-z6wy","title":"Curator action timestamps rendered as '105694 wks ago'","description":"Curator actions built without an explicit At (e.g. sessioncurator before this fix, and skillcurator) serialized time.Time's zero value to the dashboard, which rendered as a nonsense relative time. Fixed by stamping sessioncurator's action with its clock and backfilling any zero Action.At in activityTracker.record from the pass timestamp.","status":"closed","priority":2,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-09-02T11:52:20Z","created_by":"Sam Catlow","updated_at":"2026-09-02T11:52:24Z","closed_at":"2026-09-02T11:52:24Z","close_reason":"Fixed: sessioncurator now stamps Action.At from its clock; activityTracker.record backfills any zero Action.At from the pass timestamp as a defense in depth for engines with no clock (skillcurator).","dependency_count":0,"dependent_count":0,"comment_count":0} -{"_type":"issue","id":"archie-core-enfj","title":"[EPIC] Dynamic workflow routing: route task intent to the cheapest sufficient workflow","description":"workflow.Route() (internal/domain/workflow/workflow.go:237) only checks an explicit t.Workflow, then label match, then falls back unconditionally to 'implement' -- the heaviest workflow. There is no content/intent-based routing at all. task_spawn's own tool schema actively overpromises: 'workflow: ... Omit to let the daemon route it' (internal/gateway/task_tools.go:240), implying real routing exists when it means only 'check labels, then give up and run the heaviest workflow anyway'.\n\nConfirmed via production task 6 (2026-09-02): a chat-spawned task whose entire content was 'this is just a test, close it when you receive it' ran the full implement pipeline (prepare, baseline, plan, build, commit-push) end to end, burning 669,421 tokens and ~7 minutes, when nothing about the request needed a worktree, a plan, or a build at all.\n\nNeeds a design doc before any code lands per CLAUDE.md's scope-discipline rule (no settled design exists).","status":"closed","priority":2,"issue_type":"epic","owner":"sam@catlow.tech","created_at":"2026-09-02T11:29:07Z","created_by":"Sam Catlow","updated_at":"2026-09-02T11:40:00Z","closed_at":"2026-09-02T11:40:00Z","close_reason":"Implemented internal/domain/workflow/triage.go: a cheap classify-only-once AgentStage (still runs StagePrepareWorktree -- AgentStage requires tc.Dir to mount into the container, no cheaper primitive exists) that either closes a task needing no code change (reusing the CloseIssue/StatusMerged pattern feasibility.go's OnResult already established for the same ctx-less constraint) or sets tc.Task.Workflow and requeues under the chosen workflow (implement/tdd/feasibility, defaulting to implement for a missing/unrecognized choice). Route()'s fallback (workflow.go) now prefers reg[\"triage\"] over reg[\"implement\"] when registered, falling back unchanged when it isn't -- fully backward compatible. Registered in skillbuild.builtins(). 9 new tests (triage_test.go, routing_test.go) plus the design doc at docs/prds/dynamic-workflow-triage.md. task check clean.","dependency_count":0,"dependent_count":0,"comment_count":0} -{"_type":"issue","id":"archie-core-rwzo","title":"Token usage totals mislead: raw prompt sum not netted against cache hits","description":"Confirmed on production task 6 (2026-09-02, carina): dashboard/PR summary showed '14 iterations · 405,004 tokens · 400,021 prompt · 4,983 completion · 360,018 cached'. Cross-checked against the per-iteration daemon log: nothing is double-counted or hardcoded -- the totals are the correct sum of 14 real, separately-billed API calls with growing context. But 360,018 of the 400,021 'prompt tokens' shown were cache hits (billed at a steep discount), not full price -- real fresh spend was ~40,003 tokens. Showing only the raw prompt-token sum makes every agent run's cost read roughly 10x worse than what was actually billed, everywhere this aggregate surfaces (PR body, dashboard timeline).\n\nSeparately (real, not just cosmetic cost): StageBaselineGate's retry-mission prompt re-injected the ENTIRE go test ./... output -- hundreds of lines covering every passing package -- into every retry iteration's prompt, not just the failing ones. Direct mechanical contributor to the growing per-iteration prompt sizes.","design":"TaskContext.RunUsage (in-memory, not persisted -- Task.TokensUsed remains authoritative) accumulates agentexec.Usage across every agent run in one workflow execution. formatTokenUsage(total, usage) renders 'N tokens (F fresh + C cached)' with a plain fallback. extractFailingGateOutput(s) strips go test 'ok' package lines, only when it recognizes --- FAIL:/FAIL\\t markers, else returns input unchanged. Known gap: a task resumed after a daemon restart mid-workflow loses RunUsage and falls back to the plain total -- an honest degrade, not a bug; persisting the breakdown would need a store migration for a purely presentational value, not worth it yet.","acceptance_criteria":"PR bodies and the dashboard timeline show a fresh-vs-cached breakdown (or an equivalent net figure) instead of a raw prompt-token sum, falling back gracefully when no usage breakdown is available. Gate-retry mission prompts drop passing-package output, keeping only failure-relevant content, with graceful degradation for non-Go gates or unrecognized output shapes. task check passes.","status":"closed","priority":2,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-09-02T11:28:39Z","created_by":"Sam Catlow","updated_at":"2026-09-02T11:28:49Z","closed_at":"2026-09-02T11:28:49Z","close_reason":"Added TaskContext.RunUsage + accumulateUsage (agent.go, implement.go's baseline-fix branch) and formatTokenUsage (workflow.go), wired into implement.go's and tdd.go's PR-body footers plus ui/src/tasks/timeline-event.js's agent_finish rendering (raw prompt replaced with computed fresh = prompt - cached). Added extractFailingGateOutput (workflow.go) trimming go test 'ok' package lines from StageBaselineGate's retry mission, degrading to unchanged output when no --- FAIL:/FAIL\\t marker survives the filter. 5 new Go tests, 1 updated JS test. task check clean, 100/100 JS tests.","dependency_count":0,"dependent_count":0,"comment_count":0} -{"_type":"issue","id":"archie-core-n2pv","title":"Dashboard Logs page never surfaces per-task attempt-log detail","description":"internal/webui/api_tasks_logs.go's handleTaskLogs (GET /api/tasks/{id}/logs) was fully working -- internal/logging/reader.go's decode() already captures every JSON field generically into Entry.Fields (stage, tokens, iterations, model, stop_reason, everything). But no frontend code called it: ui/src/logs/logs.js (the dashboard's only Logs page) exclusively called api.logs(), the daemon-wide feed, which only carries the daemon's own component-scoped Info/Warn/Error lines -- never the rich per-stage/per-agent-run detail that lives in a task's own per-attempt log file. An operator could never see why a specific task took as long as it did, what each workflow stage did, or its token spend breakdown from the dashboard, even though the daemon already recorded and could already serve all of it. Discovered while investigating production task 6 (2026-09-02, archie-core-95dj).","acceptance_criteria":"A task's persisted attempt log (stage timings, iteration counts, token/prompt/completion/cached breakdowns, model) is visible from the dashboard task view. Reuses the daemon-wide log page's row-rendering logic rather than duplicating it. Handles disabled/empty/error states without crashing. task check (including task test:ui) passes.","status":"closed","priority":2,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-09-02T11:26:44Z","created_by":"Sam Catlow","updated_at":"2026-09-02T11:26:52Z","closed_at":"2026-09-02T11:26:52Z","close_reason":"Added ui/src/base/log-row.js (row rendering extracted out of logs.js, shared -- second consumer per CLAUDE.md), ui/src/tasks/task-logs.js (taskLogPanel handling loading/error/disabled/empty/populated states), api.taskLogs() in ui/src/base/api.js, and a collapsible 'Attempt log' section wired into each task's existing timeline drill-down in ui/src/tasks/tasks.js -- lazily fetched on first expand. New tests: ui/test/log-row.test.js, ui/test/task-logs.test.js. task check clean, 100/100 JS tests.","dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"archie-core-t2db.9","title":"workflow: make kind-to-workflow routing YAML-overridable","description":"First slice of the EDA playbook engine (docs/prds/eda-playbook-engine.md): make workflow/routing.go's kindWorkflows map overridable from an optional YAML file, so which workflow runs for an intake Kind is data instead of a Go literal. labelKinds/NATS subjects are explicitly out of scope for this slice (closed subject-per-kind question deferred).","acceptance_criteria":"Route() accepts an optional KindWorkflows override; a YAML file with the same shape as the built-in map overrides it; absent file/nil override falls back to today's hardcoded defaults unchanged; config gains an optional path field; task check passes.","status":"in_progress","priority":2,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-09-02T16:32:45Z","created_by":"Sam Catlow","updated_at":"2026-09-02T16:32:50Z","started_at":"2026-09-02T16:32:50Z","lease_expires_at":"2026-09-02T16:37:50Z","heartbeat_at":"2026-09-02T16:32:50Z","dependencies":[{"issue_id":"archie-core-t2db.9","depends_on_id":"archie-core-t2db","type":"parent-child","created_at":"2026-09-02T16:32:45Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"archie-core-v9gv.2","title":"Refactor hyperscript el() usage to Preact JSX","status":"closed","priority":2,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-09-02T13:37:19Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:56:07Z","closed_at":"2026-09-02T14:24:02Z","external_ref":"https://github.com/samcharles93/archie-core/issues/683","dependencies":[{"issue_id":"archie-core-v9gv.2","depends_on_id":"archie-core-v9gv","type":"parent-child","created_at":"2026-09-02T13:37:19Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"archie-core-v9gv.3","title":"Update main entrypoint to mount via Preact render","status":"closed","priority":2,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-09-02T13:37:19Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:56:07Z","closed_at":"2026-09-02T14:24:03Z","external_ref":"https://github.com/samcharles93/archie-core/issues/684","dependencies":[{"issue_id":"archie-core-v9gv.3","depends_on_id":"archie-core-v9gv","type":"parent-child","created_at":"2026-09-02T13:37:19Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"archie-core-v9gv.1","title":"Rename UI view files from .js to .jsx","status":"closed","priority":2,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-09-02T13:37:18Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:56:08Z","closed_at":"2026-09-02T14:24:01Z","external_ref":"https://github.com/samcharles93/archie-core/issues/685","dependencies":[{"issue_id":"archie-core-v9gv.1","depends_on_id":"archie-core-v9gv","type":"parent-child","created_at":"2026-09-02T13:37:18Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"archie-core-v9gv","title":"Migrate Web UI to Preact","status":"closed","priority":2,"issue_type":"epic","owner":"sam@catlow.tech","created_at":"2026-09-02T13:37:08Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:56:09Z","closed_at":"2026-09-02T14:24:11Z","close_reason":"All children completed","external_ref":"https://github.com/samcharles93/archie-core/issues/686","dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"archie-core-t2db.8","title":"Dashboard UI for playbook bindings","description":"The t2db.4 backend shipped the CRUD API (POST/GET/PATCH/DELETE /api/bindings + POST /api/bindings/{id}/approve) plus the state machine and HMAC wiring. Operators cannot author bindings from the dashboard yet: a list-and-approve page exists in api_binding.go's response shape but the matching ui/src/ feature folder does not. Build the click-through editor mirroring ui/src/mappings/ (three-file split: bindings.js, binding-editor.js, bindings.css per docs/prds/payload-field-mapping.md:145-152): source matcher, mapping picker, workflow picker, secret input, state-machine controls (create -\u003e edit -\u003e approve -\u003e armed). Also add binding.Owner / binding.Repo fields so multi-repo deployments have a UI to pin a binding to one repo (today the dispatch loop falls back to the single configured repo with a warning; multi-repo is broken). See docs/prds/webhook-intake-security.md and docs/prds/payload-field-mapping.md.","status":"open","priority":2,"issue_type":"feature","owner":"sam@catlow.tech","created_at":"2026-09-02T13:24:13Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:56:09Z","external_ref":"https://github.com/samcharles93/archie-core/issues/687","dependencies":[{"issue_id":"archie-core-t2db.8","depends_on_id":"archie-core-t2db","type":"parent-child","created_at":"2026-09-02T13:24:13Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"archie-core-t2db.7","title":"Encrypt binding secrets at rest","description":"binding.Binding.Secret is currently stored as plaintext in the bindings.secret TEXT column. Anyone with read access to the SQLite file (the same access level as captured_events.body and tasks.body) sees HMAC secrets in plaintext. Add at-rest encryption for the secret column so a leaked database file does not leak sender-side shared secrets. See docs/prds/webhook-intake-security.md point 5. Decide the cipher (likely AES-GCM with a key derived from archied's secret registry or a deployment-level key file), the key-rotation story, and whether captured_events.body redaction is upgraded at the same time. Phase F work for t2db.","status":"closed","priority":2,"issue_type":"feature","owner":"sam@catlow.tech","created_at":"2026-09-02T13:24:12Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:56:10Z","closed_at":"2026-09-02T13:55:47Z","close_reason":"Closed","external_ref":"https://github.com/samcharles93/archie-core/issues/688","dependencies":[{"issue_id":"archie-core-t2db.7","depends_on_id":"archie-core-t2db","type":"parent-child","created_at":"2026-09-02T13:24:12Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"archie-core-b6ew.6","title":"Inline editing for per-repo config fields (allow_concurrent, max_retries, review_enabled)","description":"archie-core-b6ew.4 shipped visibility for AllowConcurrent, MaxRetries, and ReviewEnabled on the repositories card (read-only), which was the concrete discoverability gap Sam hit. Actual inline editing was scoped out of that issue because it hits a real backend limitation discovered while implementing it: the dashboard's PATCH /api/config path (installUpdateConfigHandler in internal/app/archied/bootstrap.go) applies dotted-key updates via overlay.Nest + configuration.ApplyOverlayValues, and overlay.Nest (internal/infrastructure/configuration/overlay/overlay.go:162) only builds nested maps by splitting on '.' -- it has no array-index handling, so a key like 'repos.0.allow_concurrent' cannot be expressed, and Repos is a []config.Repo slice, not a map, so ApplyOverlayValues's YAML-merge-onto-struct approach cannot target one element either.\n\nThis needs either: (a) a dedicated repo-update seam (e.g. a webui handler keyed by owner/name that reads-modifies-writes the Repos slice directly, bypassing the generic dotted-overlay path), or (b) extending overlay.Nest/ApplyOverlayValues to support array indices generically, which is broader-reaching (touches every list-shaped config field, not just Repos) and needs its own design decision about whether index-based overlay keys are stable across a file edit that reorders [[repos]] entries. Option (a) is almost certainly the smaller, safer change -- decide in a short design note before implementing, per this repo's settled-design-first rule, since option (b) has real footguns (index stability) that deserve a deliberate answer, not a guess.","status":"closed","priority":2,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-09-02T12:22:53Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:56:11Z","started_at":"2026-09-02T12:26:59Z","closed_at":"2026-09-02T12:34:55Z","close_reason":"Traced the mechanism before implementing: overlay.Nest/ApplyOverlayValues has no array-index support, but Repos is addressed as a WHOLE dotted key ('repos', no dot) whose value is the full slice -- so no changes to overlay/configuration packages were needed at all. Added PATCH /api/config/repos/{owner}/{name} (webui.Server.UpdateRepoField seam + handleConfigRepoUpdate), wired in archied/bootstrap.go's installUpdateRepoFieldHandler: reads the daemon's own live, untrimmed Repos (not webui.RepoView, which omits Preflight/TestGlob and would silently drop them on a naive round-trip), mutates the one matched repo's one field via the pure applyRepoFieldUpdate helper, and republishes through the existing UpdateConfig(ctx, {\"repos\": repos}) path unchanged -- zero duplicated validate/persist/publish logic.\n\nFrontend: config-row.js's row() gained an opts.save override so a caller can redirect where an edit persists; the repositories table renders an autosaving checkbox (allow_concurrent, review_enabled) and a save-on-blur/Enter text input (max_retries) via api.configRepoUpdate, reverting/erroring inline on failure rather than reloading the whole page mid-edit.\n\nGo tests cover the pure applyRepoFieldUpdate function directly (matched-repo-only mutation, untouched-field preservation including Preflight, type coercion, unknown repo/field rejection) and the webui handler (seam delegation, editable-field allowlist enforced before the seam is called, 503/400 mapping). JS tests cover the structural render (checkbox/input initial state) -- the save round trip itself isn't exercisable through the test shim (addEventListener is a no-op there), consistent with existing config-row.test.js coverage.","external_ref":"https://github.com/samcharles93/archie-core/issues/689","dependencies":[{"issue_id":"archie-core-b6ew.6","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:22:53Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"archie-core-c0y4","title":"TelegramConfig gains a bws-capable Token (SecretRef), not just TokenEnv","description":"internal/config/config.go's TelegramConfig only has TokenEnv (a plain OS env var name); it never resolves through secret.Registry the way Forge.Token and Provider.APIKey do (secret.SecretRef{engine,key}), per ARCHITECTURE.md:220-224's own note that TelegramConfig.TokenEnv is one of the older env-only fields kept for backwards compatibility. internal/app/archied/telegram_setup.go:75 does a bare os.Getenv(cfg.Chat.Telegram.TokenEnv), bypassing the secret registry entirely.\n\nThis means a bws-stored Telegram token cannot be referenced directly in config.toml the way [providers.openai].api_key or [forge.token] already can -- the operator has to bridge it into a real process env var by hand (bws secret get ... | export ARCHIE_TELEGRAM_TOKEN=...) instead of writing [chat.telegram.token] = { engine = \"bws\", key = \"...\" }.\n\nFix: add a Token secret.SecretRef field to TelegramConfig, mirroring Forge.Token's shape and resolution path. Keep TokenEnv working as a fallback/legacy path (same pattern documented for Provider.APIKeyEnv vs APIKey) rather than a breaking config change -- resolve Token first if set, fall back to TokenEnv. Update config.example.toml and docs/architecture identity/config docs to show the SecretRef form as the preferred one.","status":"open","priority":2,"issue_type":"feature","owner":"sam@catlow.tech","created_at":"2026-09-02T12:21:10Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:56:12Z","external_ref":"https://github.com/samcharles93/archie-core/issues/690","dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"archie-core-b6ew.4","title":"Structured configuration editors: repositories, maps","description":"Repositories currently render as a static read-only table missing AllowConcurrent, MaxRetries, and ReviewEnabled entirely (ReviewEnabled is absent from RepoView in api_config.go, not just unrendered). Add ReviewEnabled to RepoView, and build a dedicated backend-defined editor for the repositories section (and the models/providers maps) so these stop being silently read-only. This is the concrete fix for the allow_concurrent discoverability gap Sam hit, delivered as a typed editor rather than a one-off card patch, since the schema this epic introduces is what should own its shape.","status":"closed","priority":2,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:46Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:56:13Z","started_at":"2026-09-02T12:21:13Z","closed_at":"2026-09-02T12:23:52Z","close_reason":"Scoped to visibility, not full inline editing -- while implementing, found that the dashboard's PATCH /api/config path (overlay.Nest + configuration.ApplyOverlayValues) has no array-index support, so a per-element update to the Repos slice cannot be expressed as a dotted key today. That's real, separate scope, filed as archie-core-b6ew.6 rather than bolted on.\n\nShipped: RepoView.ReviewEnabled (previously absent from the API entirely, not just unrendered) alongside AllowConcurrent and MaxRetries; the repositories card now shows Concurrent/Max retries/Self-review columns as read-only pills, closing the concrete discoverability gap (Sam couldn't see allow_concurrent without an agent tracing Go source). config.example.toml documents review_enabled, which was undocumented before this. Go test pins ReviewEnabled reaching ConfigView for both a configured and a zero-value repo.","external_ref":"https://github.com/samcharles93/archie-core/issues/691","dependencies":[{"issue_id":"archie-core-b6ew.4","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:46Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.4","depends_on_id":"archie-core-b6ew.2","type":"blocks","created_at":"2026-09-02T12:00:51Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":1,"comment_count":0} +{"_type":"issue","id":"archie-core-b6ew.5","title":"Schema contract tests: metadata completeness and secret-safety","description":"Assert every field the schema exposes carries type, label, and section; assert restart_required and editable are set deliberately (not zero-value defaults hiding an unreviewed field); assert secrets still never appear (extend the existing TestHandleConfigNeverLeaksSecrets pattern to the schema response); assert the frontend's generic renderer can render the full schema fixture without any field-specific branch (a JS test walking the schema and asserting no field key appears literally in settings.js).","status":"closed","priority":2,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:46Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:56:13Z","started_at":"2026-09-02T12:24:40Z","closed_at":"2026-09-02T12:26:27Z","close_reason":"Most of this issue's assertions were already covered incrementally by tests added in .1-.4 (key/label/type completeness, structured/locked non-editability, secret-leak guard on the schema block, schema values matching their flat-field source). This issue adds the two pieces still missing: TestConfigFieldDescriptorsRestartRequiredIsDeliberate pins the exact RestartRequired value per key against the reload.go evidence documented in configFieldDescriptors' own comment, so a reclassification without checking reload.go fails loudly. ui/test/settings-schema.test.js renders settingsPage against a schema fixture containing a field settings.js has never heard of (proving the renderer needs no field-specific branch to show it correctly) and asserts, by reading settings.js's own source text, that none of the generically-rendered section's field keys appear literally in it -- the direct regression test for archie-core-b6ew.3's whole point.","external_ref":"https://github.com/samcharles93/archie-core/issues/692","dependencies":[{"issue_id":"archie-core-b6ew.5","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:46Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.5","depends_on_id":"archie-core-b6ew.3","type":"blocks","created_at":"2026-09-02T12:00:52Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.5","depends_on_id":"archie-core-b6ew.4","type":"blocks","created_at":"2026-09-02T12:00:52Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":2,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"archie-core-b6ew.3","title":"Generic frontend renderer for scalar configuration fields","description":"Replace settings.js's hardcoded row(...) calls for scalar/bool/int/enum/duration fields with a renderer that walks the backend's sections/fields schema and builds the section cards, labels, and edit affordances from the descriptor alone -- the frontend must not know that containers.max_concurrency is an int or which card it belongs in. Structured fields (repositories, models, providers maps) are out of scope here and keep their existing bespoke rendering, tagged type=structured so the generic renderer skips them without special-casing each key.","status":"closed","priority":2,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:45Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:56:14Z","started_at":"2026-09-02T12:08:25Z","closed_at":"2026-09-02T12:12:41Z","close_reason":"settings.js renders identity/budgets/storage/web cards generically from cfg.schema sections (schemaCards()), replacing identityCard/budgetsCard/storageCard/webCard/pullPolicyLabel -- label, type, description, editability, and options all come from the backend descriptor. config-row.js gained enum edit support (select from opts.options), an editable:false branch distinct from locked rows, and a hint tooltip carrying the field's description. Structured sections (repositories, models \u0026 providers) are unaffected -- still rendered by their existing bespoke functions, reserved for b6ew.4. Not visually verified in a live browser (needs a full daemon+forge+NATS stack); verified via unit tests mirroring the existing config-row.test.js patterns and Go contract tests.","external_ref":"https://github.com/samcharles93/archie-core/issues/693","dependencies":[{"issue_id":"archie-core-b6ew.3","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:45Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.3","depends_on_id":"archie-core-b6ew.2","type":"blocks","created_at":"2026-09-02T12:00:50Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":1,"comment_count":0} +{"_type":"issue","id":"archie-core-b6ew.1","title":"Backend configuration schema contract: field descriptor types and section metadata","description":"Define the descriptor types (Section, Field, Option) in internal/webui alongside ConfigView -- Key, Label, Description, Section, Type (string|int|bool|duration|enum|structured), Editable, LockedReason, Overridden, Options, RestartRequired. Hand-author one descriptor per existing ConfigView field, grouped into the sections the settings page already renders (identity, repositories, models, providers, budgets, storage, containers, web). No reflection over config.Config -- config.Config is scheduled for dissolution (internal/config/config.go package doc) and every field here is already a deliberate allowlist entry, so this is metadata on fields that already passed the secret-safety allowlist, not a new safety boundary.","status":"closed","priority":2,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:44Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:56:15Z","started_at":"2026-09-02T12:02:40Z","closed_at":"2026-09-02T12:05:40Z","close_reason":"Added internal/webui/config_schema.go: ConfigFieldType/ConfigField/ConfigSection descriptor types and configFieldDescriptors(), hand-authoring key/label/type/editable/restart_required for every field ConfigView exposes today, grouped into the sections settings.js already renders. RestartRequired sourced from internal/app/archied/reload.go's reloadableFields/reloadableSubFields allowlist. Contract tests pin key completeness, structured-field non-editability, and locked-storage-field non-editability. Not yet wired into GET /api/config -- that's b6ew.2.","external_ref":"https://github.com/samcharles93/archie-core/issues/694","dependencies":[{"issue_id":"archie-core-b6ew.1","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:44Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":1,"comment_count":0} +{"_type":"issue","id":"archie-core-b6ew.2","title":"Expose the config schema via GET /api/config","description":"Extend handleConfig's response with a schema-driven shape (sections of fields, each carrying its descriptor and current value) built from the field descriptors, replacing the flat ConfigView value tree the frontend currently re-interprets by hand. Keep the existing Locked/Overridden/Reload/Provenance top-level fields -- they describe runtime state, not the field catalog, and the schema-driven fields reference into them (locked_reason, overridden) rather than duplicating that logic.","status":"closed","priority":2,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:44Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:56:16Z","started_at":"2026-09-02T12:06:31Z","closed_at":"2026-09-02T12:07:58Z","close_reason":"ConfigView gains a Schema []ConfigSection field, populated in handleConfig via buildConfigSchema(view), which attaches each request's Value/LockedReason/Overridden onto the static configFieldDescriptors() catalog. The flat ConfigView fields (Identity, Repositories, etc.) are untouched -- Schema is additive. Tests confirm schema values match the flat fields they derive from, locked reasons propagate, structured fields stay non-editable, and secrets never reach the schema block.","external_ref":"https://github.com/samcharles93/archie-core/issues/695","dependencies":[{"issue_id":"archie-core-b6ew.2","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:44Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.2","depends_on_id":"archie-core-b6ew.1","type":"blocks","created_at":"2026-09-02T12:00:50Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":2,"comment_count":0} +{"_type":"issue","id":"archie-core-b6ew","title":"[EPIC] Backend-owned configuration schema for the webui Configuration page","description":"The Configuration page's field definitions (label, section, type, editability, restart-required, options) are hand-maintained in ui/src/settings/settings.js and config-row.js, disjoint from the backend's own ConfigView allowlist in internal/webui/api_config.go. Adding or changing a runtime-tunable setting today means editing Go and JS in two unrelated places by hand, and nothing catches drift between them. Repo.ReviewEnabled is missing from the API entirely; AllowConcurrent and MaxRetries reach the API but the repositories card never renders them, which is what blocked Sam from discovering the allow_concurrent fix without an agent tracing the Go source directly.\n\nDesign: docs/prds/config-schema.md. The backend keeps its existing hand-picked, secret-free allowlist (ConfigView in api_config.go) -- config.Config is scheduled for dissolution per its own package doc, so this is deliberately NOT a reflection-based schema over config.Config. Instead each already-allowlisted field gains a hand-authored descriptor (label, section, type, editable, restart_required, options) alongside its existing value, and the frontend renders scalar/bool/int/enum/duration fields generically from that descriptor instead of hardcoding rows. Structured fields (repositories, maps) get dedicated typed editors rather than staying silently read-only.","status":"closed","priority":2,"issue_type":"epic","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:27Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:56:17Z","closed_at":"2026-09-02T12:35:11Z","close_reason":"All six child issues shipped: hand-authored field descriptor catalog (.1), schema attached to GET /api/config (.2), generic scalar renderer replacing hardcoded settings.js rows (.3), repository field visibility incl. the previously-API-absent ReviewEnabled (.4), schema contract tests pinning restart-required deliberateness and generic-render proof (.5), and inline editing for the three per-repo fields via a dedicated PATCH /api/config/repos/{owner}/{name} seam (.6). The concrete complaint that started this (allow_concurrent invisible on the dashboard) is fully resolved: visible, editable, and backed by a schema the frontend no longer hardcodes.","external_ref":"https://github.com/samcharles93/archie-core/issues/696","dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"archie-core-z6wy","title":"Curator action timestamps rendered as '105694 wks ago'","description":"Curator actions built without an explicit At (e.g. sessioncurator before this fix, and skillcurator) serialized time.Time's zero value to the dashboard, which rendered as a nonsense relative time. Fixed by stamping sessioncurator's action with its clock and backfilling any zero Action.At in activityTracker.record from the pass timestamp.","status":"closed","priority":2,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-09-02T11:52:20Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:56:18Z","closed_at":"2026-09-02T11:52:24Z","close_reason":"Fixed: sessioncurator now stamps Action.At from its clock; activityTracker.record backfills any zero Action.At from the pass timestamp as a defense in depth for engines with no clock (skillcurator).","external_ref":"https://github.com/samcharles93/archie-core/issues/697","dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"archie-core-enfj","title":"[EPIC] Dynamic workflow routing: route task intent to the cheapest sufficient workflow","description":"workflow.Route() (internal/domain/workflow/workflow.go:237) only checks an explicit t.Workflow, then label match, then falls back unconditionally to 'implement' -- the heaviest workflow. There is no content/intent-based routing at all. task_spawn's own tool schema actively overpromises: 'workflow: ... Omit to let the daemon route it' (internal/gateway/task_tools.go:240), implying real routing exists when it means only 'check labels, then give up and run the heaviest workflow anyway'.\n\nConfirmed via production task 6 (2026-09-02): a chat-spawned task whose entire content was 'this is just a test, close it when you receive it' ran the full implement pipeline (prepare, baseline, plan, build, commit-push) end to end, burning 669,421 tokens and ~7 minutes, when nothing about the request needed a worktree, a plan, or a build at all.\n\nNeeds a design doc before any code lands per CLAUDE.md's scope-discipline rule (no settled design exists).","status":"closed","priority":2,"issue_type":"epic","owner":"sam@catlow.tech","created_at":"2026-09-02T11:29:07Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:56:19Z","closed_at":"2026-09-02T11:40:00Z","close_reason":"Implemented internal/domain/workflow/triage.go: a cheap classify-only-once AgentStage (still runs StagePrepareWorktree -- AgentStage requires tc.Dir to mount into the container, no cheaper primitive exists) that either closes a task needing no code change (reusing the CloseIssue/StatusMerged pattern feasibility.go's OnResult already established for the same ctx-less constraint) or sets tc.Task.Workflow and requeues under the chosen workflow (implement/tdd/feasibility, defaulting to implement for a missing/unrecognized choice). Route()'s fallback (workflow.go) now prefers reg[\"triage\"] over reg[\"implement\"] when registered, falling back unchanged when it isn't -- fully backward compatible. Registered in skillbuild.builtins(). 9 new tests (triage_test.go, routing_test.go) plus the design doc at docs/prds/dynamic-workflow-triage.md. task check clean.","external_ref":"https://github.com/samcharles93/archie-core/issues/698","dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"archie-core-rwzo","title":"Token usage totals mislead: raw prompt sum not netted against cache hits","description":"Confirmed on production task 6 (2026-09-02, carina): dashboard/PR summary showed '14 iterations · 405,004 tokens · 400,021 prompt · 4,983 completion · 360,018 cached'. Cross-checked against the per-iteration daemon log: nothing is double-counted or hardcoded -- the totals are the correct sum of 14 real, separately-billed API calls with growing context. But 360,018 of the 400,021 'prompt tokens' shown were cache hits (billed at a steep discount), not full price -- real fresh spend was ~40,003 tokens. Showing only the raw prompt-token sum makes every agent run's cost read roughly 10x worse than what was actually billed, everywhere this aggregate surfaces (PR body, dashboard timeline).\n\nSeparately (real, not just cosmetic cost): StageBaselineGate's retry-mission prompt re-injected the ENTIRE go test ./... output -- hundreds of lines covering every passing package -- into every retry iteration's prompt, not just the failing ones. Direct mechanical contributor to the growing per-iteration prompt sizes.","design":"TaskContext.RunUsage (in-memory, not persisted -- Task.TokensUsed remains authoritative) accumulates agentexec.Usage across every agent run in one workflow execution. formatTokenUsage(total, usage) renders 'N tokens (F fresh + C cached)' with a plain fallback. extractFailingGateOutput(s) strips go test 'ok' package lines, only when it recognizes --- FAIL:/FAIL\\t markers, else returns input unchanged. Known gap: a task resumed after a daemon restart mid-workflow loses RunUsage and falls back to the plain total -- an honest degrade, not a bug; persisting the breakdown would need a store migration for a purely presentational value, not worth it yet.","acceptance_criteria":"PR bodies and the dashboard timeline show a fresh-vs-cached breakdown (or an equivalent net figure) instead of a raw prompt-token sum, falling back gracefully when no usage breakdown is available. Gate-retry mission prompts drop passing-package output, keeping only failure-relevant content, with graceful degradation for non-Go gates or unrecognized output shapes. task check passes.","status":"closed","priority":2,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-09-02T11:28:39Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:56:20Z","closed_at":"2026-09-02T11:28:49Z","close_reason":"Added TaskContext.RunUsage + accumulateUsage (agent.go, implement.go's baseline-fix branch) and formatTokenUsage (workflow.go), wired into implement.go's and tdd.go's PR-body footers plus ui/src/tasks/timeline-event.js's agent_finish rendering (raw prompt replaced with computed fresh = prompt - cached). Added extractFailingGateOutput (workflow.go) trimming go test 'ok' package lines from StageBaselineGate's retry mission, degrading to unchanged output when no --- FAIL:/FAIL\\t marker survives the filter. 5 new Go tests, 1 updated JS test. task check clean, 100/100 JS tests.","external_ref":"https://github.com/samcharles93/archie-core/issues/699","dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"archie-core-n2pv","title":"Dashboard Logs page never surfaces per-task attempt-log detail","description":"internal/webui/api_tasks_logs.go's handleTaskLogs (GET /api/tasks/{id}/logs) was fully working -- internal/logging/reader.go's decode() already captures every JSON field generically into Entry.Fields (stage, tokens, iterations, model, stop_reason, everything). But no frontend code called it: ui/src/logs/logs.js (the dashboard's only Logs page) exclusively called api.logs(), the daemon-wide feed, which only carries the daemon's own component-scoped Info/Warn/Error lines -- never the rich per-stage/per-agent-run detail that lives in a task's own per-attempt log file. An operator could never see why a specific task took as long as it did, what each workflow stage did, or its token spend breakdown from the dashboard, even though the daemon already recorded and could already serve all of it. Discovered while investigating production task 6 (2026-09-02, archie-core-95dj).","acceptance_criteria":"A task's persisted attempt log (stage timings, iteration counts, token/prompt/completion/cached breakdowns, model) is visible from the dashboard task view. Reuses the daemon-wide log page's row-rendering logic rather than duplicating it. Handles disabled/empty/error states without crashing. task check (including task test:ui) passes.","status":"closed","priority":2,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-09-02T11:26:44Z","created_by":"Sam Catlow","updated_at":"2026-09-02T14:56:20Z","closed_at":"2026-09-02T11:26:52Z","close_reason":"Added ui/src/base/log-row.js (row rendering extracted out of logs.js, shared -- second consumer per CLAUDE.md), ui/src/tasks/task-logs.js (taskLogPanel handling loading/error/disabled/empty/populated states), api.taskLogs() in ui/src/base/api.js, and a collapsible 'Attempt log' section wired into each task's existing timeline drill-down in ui/src/tasks/tasks.js -- lazily fetched on first expand. New tests: ui/test/log-row.test.js, ui/test/task-logs.test.js. task check clean, 100/100 JS tests.","external_ref":"https://github.com/samcharles93/archie-core/issues/700","dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-1786637499161-356-e424e40d.1","title":"setupMemory never calls RegisterExternal; cfg.Memory.Provider is silently inert","description":"internal/app/archied/bootstrap.go:setupMemory's own doc comment says\n\"External providers from config are added via RegisterExternal when\ncfg.Memory.Provider is set\" -- no such branch exists in the function body.\nToday, an operator who sets [memory] provider = \"...\" in config.toml gets\nno error and no effect: the builtin file-backed provider is the only one\nthat ever runs. config.example.toml already documents this as a known gap\n(\"[memory] exists to register an EXTERNAL provider alongside it, but as of\nthis writing that wiring ... is not called\").\n\nSeparately, internal/config.MemoryConfig (config.go:287) has no `toml`\nstruct tag on any field (yaml/json only), so even fixing the wiring call\nmay not bind values from config.toml, the format operators actually use --\nverify this before or as part of the fix.\n\nThis sits ahead of the typed engine-family work (archie-core-...-11-e245c170)\nin the sense that it's a bug in the CURRENT ad-hoc MemoryProvider wiring,\nnot a gap in the future engine contract -- decide whether it's worth fixing\nin the legacy path or superseded once the conforming memory engine family\nlands, rather than fixing both.","status":"closed","priority":2,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-09-01T15:50:52Z","created_by":"Sam Catlow","updated_at":"2026-09-01T16:51:00Z","closed_at":"2026-09-01T16:51:00Z","close_reason":"Fixed, but not as originally framed. Investigated wiring RegisterExternal\nfor real: there is no external MemoryProvider implementation anywhere in\nthe repo to construct and pass to it (only internal/memory/builtin.Provider\nexists) -- calling RegisterExternal would be dead plumbing to nothing, not\na fix.\n\nThe actual fix: configuration.validateMemory now rejects memory.provider\nbeing set at all, with a clear reason, instead of accepting it and doing\nnothing. Turns the silent no-op into a loud one. setupMemory's doc comment\nand config.example.toml updated to match; the now-pointless\nprovider_config example section removed.\n\ntoml struct tags (the other half of this bug) were already fixed in\narchie-core-1786637490043's commit.\n\nDrop the rejection once a real external provider (or the domain/memory\nengine family's Honcho proof, archie-core-1786637492031) gives the field\nan effect again.\n\nTestValidateMemoryRejectsProviderSetToAnything covers it. task check is\ngreen.","external_ref":"https://github.com/samcharles93/archie-core/issues/649","labels":["epic"],"dependencies":[{"issue_id":"archie-core-1786637499161-356-e424e40d.1","depends_on_id":"archie-core-1786637499161-356-e424e40d","type":"parent-child","created_at":"2026-09-01T15:50:52Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-r3gh","title":"Harden task origin response assertions","description":"Replace brittle prose substring assertions in internal/webui/api_tasks_origin_test.go with stable structural checks for HTTP error responses while preserving origin and media-type coverage.","acceptance_criteria":"The origin test does not assert human-readable response text; rejected cases verify stable HTTP error response structure; focused tests and task check pass.","status":"in_progress","priority":2,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-31T12:49:20Z","created_by":"Sam Catlow","updated_at":"2026-09-02T09:49:05Z","started_at":"2026-08-31T12:49:27Z","lease_expires_at":"2026-08-31T12:54:27Z","heartbeat_at":"2026-08-31T12:49:27Z","external_ref":"https://github.com/samcharles93/archie-core/issues/664","dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-h3w2","title":"Migrate email/webhook channels onto domain/messaging types","description":"Update remaining gateway-based channels (email, webhook) to use domain/messaging types, completing the migration described in migration-decisions.md section 2.","status":"open","priority":2,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-08-31T10:12:16Z","created_by":"Sam Catlow","updated_at":"2026-09-02T09:49:06Z","external_ref":"https://github.com/samcharles93/archie-core/issues/665","labels":["messaging-migration"],"dependencies":[{"issue_id":"archie-core-h3w2","depends_on_id":"archie-core-d9dv","type":"blocks","created_at":"2026-08-31T10:12:24Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":0,"comment_count":0} diff --git a/internal/app/archied/bootstrap.go b/internal/app/archied/bootstrap.go index 136e3fb99..a4d8d499a 100644 --- a/internal/app/archied/bootstrap.go +++ b/internal/app/archied/bootstrap.go @@ -639,6 +639,12 @@ func (b *boot) setupGateways(ctx context.Context, cfgPath, overlayPath string) b // built-ins fill gaps. func (b *boot) loadWorkflows(ctx context.Context) error { cfg, log := b.cfg, b.log + kindWorkflows, err := workflow.LoadKindWorkflowsYAML(cfg.WorkflowRoutingFile) + if err != nil { + log.Error("workflow routing file load failed", "path", cfg.WorkflowRoutingFile, "err", err) + return err + } + workflow.SetKindWorkflows(kindWorkflows) skillsBase := cfg.SkillsDir if skillsBase == "" { skillsBase = cfg.WorkDir diff --git a/internal/config/config.go b/internal/config/config.go index ac1998d4f..13dfdfbfd 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -433,6 +433,12 @@ type Config struct { // (plugin-defined workflows override built-ins). When empty, // only built-in workflows are available. SkillsDir string `toml:"skills_dir" yaml:"skills_dir"` + // WorkflowRoutingFile is an optional path to a YAML file rebinding + // which registered workflow an intake Kind (bug/feature/bootstrap) + // prefers -- see docs/prds/eda-playbook-engine.md. When empty, the + // built-in bindings (bug->tdd, feature->feasibility, + // bootstrap->bootstrap) are used unchanged. + WorkflowRoutingFile string `toml:"workflow_routing_file" yaml:"workflow_routing_file"` // MaxRetries caps how many times a parked task is retried before // being permanently parked (status "dead"). Defaults to 3. MaxRetries int `toml:"max_retries" yaml:"max_retries"` diff --git a/internal/domain/workflow/routing.go b/internal/domain/workflow/routing.go index d6ed1641d..8732a9c0e 100644 --- a/internal/domain/workflow/routing.go +++ b/internal/domain/workflow/routing.go @@ -1,27 +1,92 @@ package workflow -import "github.com/samcharles93/archie-core/internal/domain/workintake" +import ( + "fmt" + "os" -// kindWorkflows names the registry entry each intake kind prefers. Bootstrap -// exercises the full pipeline deterministically (no LLM spend) -- invites, -// clone, push, PR, labels. + "gopkg.in/yaml.v3" + + "github.com/samcharles93/archie-core/internal/domain/workintake" +) + +// KindWorkflows maps an intake kind to the registered workflow name it +// prefers. The zero value is not itself a valid override -- pass the result +// of LoadKindWorkflowsYAML to SetKindWorkflows, or nil to restore defaults. +type KindWorkflows map[workintake.Kind]string + +// defaultKindWorkflows names the registry entry each intake kind prefers +// when no override has been loaded. Bootstrap exercises the full pipeline +// deterministically (no LLM spend) -- invites, clone, push, PR, labels. // // The label vocabulary itself belongs to workintake, which is what reads // forge issues. This package owns only the choice of workflow for a kind: // keeping both here meant the transport and the registry each had their own // copy of the label table. -var kindWorkflows = map[workintake.Kind]string{ +var defaultKindWorkflows = KindWorkflows{ workintake.KindBug: "tdd", workintake.KindFeature: "feasibility", workintake.KindBootstrap: "bootstrap", } +// activeKindWorkflows is what workflowForLabels actually reads. Set once at +// daemon startup by SetKindWorkflows; nil means "use defaultKindWorkflows". +// This is package state deliberately, matching the once-at-startup, +// never-concurrent-with-Route lifecycle SkillsDir/PluginDir already have -- +// Route() is never called before the daemon finishes loading configuration. +var activeKindWorkflows KindWorkflows + +// SetKindWorkflows overrides the kind-to-workflow-name bindings Route() +// consults, e.g. from a file loaded by LoadKindWorkflowsYAML. Passing nil +// restores the built-in defaults -- the first slice of +// docs/prds/eda-playbook-engine.md: which workflow a Kind prefers is data, +// not a Go literal, without touching labelKinds or the closed NATS-subject +// set that Kind itself still governs. +func SetKindWorkflows(kw KindWorkflows) { + activeKindWorkflows = kw +} + +// LoadKindWorkflowsYAML reads a kind-to-workflow-name binding file. An empty +// path returns (nil, nil) -- "no file configured" means "use defaults", +// matching SkillsDir's own empty-means-built-ins-only convention rather than +// requiring callers to stat first. +// +// A kind the workintake package does not recognise is a definition failure, +// per the design doc's rule: the schema (here, the closed Kind vocabulary) +// defines what's accepted, and anything else is the caller's fault -- +// reported as an error, not silently dropped or guessed at. +func LoadKindWorkflowsYAML(path string) (KindWorkflows, error) { + if path == "" { + return nil, nil + } + data, err := os.ReadFile(path) + if err != nil { + return nil, fmt.Errorf("read kind-workflows file %s: %w", path, err) + } + raw := map[string]string{} + if err := yaml.Unmarshal(data, &raw); err != nil { + return nil, fmt.Errorf("parse kind-workflows file %s: %w", path, err) + } + kw := make(KindWorkflows, len(raw)) + for k, name := range raw { + kind := workintake.Kind(k) + if err := kind.Validate(); err != nil { + return nil, fmt.Errorf("kind-workflows file %s: %w", path, err) + } + kw[kind] = name + } + return kw, nil +} + // workflowForLabels returns the registered workflow name for a task's // labels, trying each recognised kind in label order so a "bug,feature" task // still reaches feasibility when no tdd workflow is registered. func workflowForLabels(reg Registry, labels string) (Workflow, bool) { + kw := activeKindWorkflows + if kw == nil { + kw = defaultKindWorkflows + } for _, kind := range workintake.KindsForLabels(workintake.SplitLabels(labels)) { - name, ok := kindWorkflows[kind] + name, ok := kw[kind] if !ok { continue } diff --git a/internal/domain/workflow/routing_test.go b/internal/domain/workflow/routing_test.go index fb930f515..eb3ae0df3 100644 --- a/internal/domain/workflow/routing_test.go +++ b/internal/domain/workflow/routing_test.go @@ -1,8 +1,11 @@ package workflow import ( + "os" + "path/filepath" "testing" + "github.com/samcharles93/archie-core/internal/domain/workintake" "github.com/samcharles93/archie-core/internal/store" ) @@ -47,3 +50,74 @@ func TestRouteLabelMatchStillWinsOverTriage(t *testing.T) { t.Fatalf("Route() = %q, want %q", wf.Name, "tdd") } } + +// TestLoadKindWorkflowsYAMLOverridesDefaultBinding is the first slice of +// docs/prds/eda-playbook-engine.md: which workflow a Kind prefers becomes +// data, not a Go literal. A YAML file rebinding "bug" to "feasibility" +// must be honoured by Route() once loaded. +func TestLoadKindWorkflowsYAMLOverridesDefaultBinding(t *testing.T) { + dir := t.TempDir() + path := filepath.Join(dir, "workflow-routing.yaml") + writeFile(t, path, "bug: feasibility\n") + + kw, err := LoadKindWorkflowsYAML(path) + if err != nil { + t.Fatalf("LoadKindWorkflowsYAML() error = %v", err) + } + SetKindWorkflows(kw) + t.Cleanup(func() { SetKindWorkflows(nil) }) + + task := &store.Task{Labels: "bug"} + wf := Route(task, Registry{"tdd": TDD(), "feasibility": Feasibility()}) + if wf.Name != "feasibility" { + t.Fatalf("Route() = %q, want %q (YAML override not applied)", wf.Name, "feasibility") + } +} + +// TestSetKindWorkflowsNilRestoresDefaults pins the fallback: no file, or +// an explicit nil override, must reproduce today's hardcoded bindings +// unchanged -- required for backward compatibility per the design doc. +func TestSetKindWorkflowsNilRestoresDefaults(t *testing.T) { + SetKindWorkflows(KindWorkflows{workintake.KindBug: "feasibility"}) + SetKindWorkflows(nil) + + task := &store.Task{Labels: "bug"} + wf := Route(task, Registry{"tdd": TDD(), "feasibility": Feasibility()}) + if wf.Name != "tdd" { + t.Fatalf("Route() = %q, want %q (default binding not restored)", wf.Name, "tdd") + } +} + +// TestLoadKindWorkflowsYAMLRejectsUnknownKind ensures a typo'd or invalid +// kind in the YAML is a reported load failure, not a silently-ignored +// binding -- the "schema defines the accepted message; anything else is +// the caller's fault, dropped and logged" rule from the design doc. +func TestLoadKindWorkflowsYAMLRejectsUnknownKind(t *testing.T) { + dir := t.TempDir() + path := filepath.Join(dir, "workflow-routing.yaml") + writeFile(t, path, "not-a-real-kind: tdd\n") + + if _, err := LoadKindWorkflowsYAML(path); err == nil { + t.Fatal("LoadKindWorkflowsYAML() error = nil, want error for unknown kind") + } +} + +// TestLoadKindWorkflowsYAMLMissingFileReturnsNilNoError treats an unset +// routing file as "use defaults", matching SkillsDir's own "empty means +// built-ins only" convention rather than requiring callers to stat first. +func TestLoadKindWorkflowsYAMLMissingFileReturnsNilNoError(t *testing.T) { + kw, err := LoadKindWorkflowsYAML("") + if err != nil { + t.Fatalf("LoadKindWorkflowsYAML(\"\") error = %v, want nil", err) + } + if kw != nil { + t.Fatalf("LoadKindWorkflowsYAML(\"\") = %#v, want nil", kw) + } +} + +func writeFile(t *testing.T, path, content string) { + t.Helper() + if err := os.WriteFile(path, []byte(content), 0o600); err != nil { + t.Fatalf("write %s: %v", path, err) + } +}