Commit Graph
1477 Commits
Author SHA1 Message Date
sam ff740689cd feat(archied): add shutdown watchdog that force-exits a hung graceful shutdown (#716)
Once graceful shutdown begins (SIGINT/SIGTERM cancels the daemon's
signal context), start an out-of-loop watchdog timer for the drain
window plus a 60s grace period. If the shutdown chain has not completed
by the time that leash expires, force-exit the process (os.Exit) as a
backstop against a hung shutdown.

The watchdog runs in its own goroutine outside the daemon's event loop
and graceful-shutdown machinery, so it fires even when that machinery is
itself the thing that is stuck. It is disarmed via the FIRST registered
cleanup so it runs LAST in the LIFO shutdown chain: it stands down only
after every subsystem has shut down cleanly, and a hung subsystem never
reaches the disarm, letting the watchdog force-exit.

A shutdown that completes within the leash does not trigger the
watchdog; a shutdown that hangs past the leash results in a forced
process exit. The leash uses a test-only short timeout in tests.

Reference bead archie-core-1786637496842-267-8b2984f9.
2026-09-05 13:24:40 +10:00
sam 164ca8d450 docs(prds): resolve execution-time gap 2 -- idempotency keying for playbook actions (#715)
Decision for channel/forge/module action keying in eda-playbook-engine.md:
one durable dedup record per (action, event) pair via a playbook_dispatches
ledger in internal/store, reusing binding_dispatches' INSERT OR IGNORE +
sentinel conventions, with record-before-invoke ordering (at-most-once, the
reverse of the binding loop's ordering, justified by the external-side-effect
harm profile). Key = (playbook_id, playbook_version, event_id, action_id):
event_id is the TaskEnvelope.IdempotencyKey() value already carried on
DispatchInput.TaskID; the key is a fixed structural composition, deliberately
not a CEL expression (event stays dyn; determinism under redelivery is the
binding constraint). Redelivery of a recorded action skips it and continues
the run at debug level, never surfaced as an error. Rows live as long as the
playbook exists, no time-based expiry.

Extends event-sources-and-reactions.md's contract without contradicting it:
PublishUnique's dedup is publish-path only (Nats-Msg-Id + 2-minute
DedupWindow), so consumer redelivery of side-effecting reactions was never
covered; the ledger adds exactly that consumer-side piece, reusing the
TaskEnvelope identity and the typed-family shape. The gap-2 prerequisites
(Playbook ID/Version, DispatchInput.TaskID) already landed in a4a8ae7.
Documentation only: no code changes. Keying implementation is separate
follow-up work.

Refs: archie-core-t2db.17
2026-09-05 10:11:59 +10:00
sam 187fc91d44 docs(prds): resolve execution-time gap 1 mid-playbook action failure semantics (#714)
Resolves archie-core-t2db.18. States stop-on-first-failure as the
committed default when a playbook action fails mid-run, grounded in
workflow.Run's three-way stage-failure distinction
(internal/domain/workflow/workflow.go:294, 317-336) and the t2db.9-12
load-collision drop-and-report rule (eda-playbook-engine.md:155-159),
with explicit reasoning why the default does not violate
event-sources-and-reactions.md's producer-only rule. Gap 2 (execution-time
idempotency) remains open. Documentation only; no code changes.
2026-09-05 10:03:23 +10:00
sam d877b28f95 docs(prds): resolve service-decomposition open questions #2 and #3 (#713)
Land Q2 (contract definition mechanism: buf v2 + grpc-go, committed
proto/ tree, buf breaking gate) and Q3 (in-process-by-default
migration mechanism per organisation.md's Process boundaries rule) as
committed file edits, matching the style of already-resolved #1/#4/#5.
Transcribes decisions from a prior scout pass whose edits were
discarded when its worktree was torn down; codebase facts (go.mod,
organisation.md, servicediscovery.go, storerpc.go,
sessionstore_conformance_test.go, api_chat.go) re-verified in this
worktree before writing.
2026-09-05 09:10:05 +10:00
sam 3e442c569d fix(servicediscovery): check lister/watcher Stop() errors
golangci-lint (errcheck) flagged both deferred Stop() calls in the NATS
KV registry as unchecked. Explicit discard, no behavior change.
2026-09-05 03:13:52 +10:00
sam 4582248fef chore: beads interactions and issues 2026-09-05 03:13:06 +10:00
sam fda9a48d64 Merge crew/servicereg-impl: scaffold ServiceRegistry contract
Adds internal/servicediscovery (broker-neutral ServiceRegistry contract,
zero internal imports) and internal/infrastructure/servicediscovery/nats
(NATS JetStream KV implementation: installed-marker bucket + heartbeat
bucket to express NotInstalled distinctly from Down/Unhealthy, per
docs/prds/service-decomposition.md). Additive and unwired -- no daemon
bootstrap path touched. Verified independently: go build ./... clean,
go vet clean, gofmt clean, full package tests pass with -race.
2026-09-05 03:12:30 +10:00
sam 0bc65b680d feat(servicediscovery): scaffold ServiceRegistry contract and NATS KV implementation
Add a broker-neutral service registry contract (Endpoint, EventKind,
Event, ServiceRegistry, ErrNotInstalled) and a NATS JetStream KV
implementation, plus the registration side a service uses to announce itself.

The contract's governing semantic -- NotInstalled is not Down -- is modeled
by two buckets: a durable installed marker (never expires) distinct from
expiring heartbeat keys. Instances heartbeat their key on an interval; a
stopped process leaves via TTL expiry. Register writes the marker once then
heartbeats; Resolve returns ErrNotInstalled only when the marker is absent,
and an empty roster for installed-but-down. Watch dedupes heartbeat refreshes
so it emits membership changes, not liveness pings.

Unwired: no daemon/bootstrap path consumes it yet. Deliberately uses a dot
key separator instead of the research sketch's slash so per-service watch
wildcards match.
2026-09-05 03:11:43 +10:00
sam a4a8ae7e92 feat(eda): thread Playbook ID/Version and DispatchInput task identity (gap-2 prereqs)
Playbook now carries ID (path-relative to the configured root) and Version
(sha256 content hash recomputed on load), both populated in loadOne, mirroring
Binding.Version's provenance pin without a DB row. DispatchInput gains TaskID
carrying TaskEnvelope.IdempotencyKey(), the identity available at the
discovery point (pollNATS / webhook receiver compute kind+labels from a
TaskEnvelope before any store.Task row exists), NOT a store.Task.ID int64.

These are the two implementation prerequisites named by the t2db.17
idempotency resolution; the playbook_dispatches ledger is built on top.

Note: task check fails on 5 lint findings PRE-EXISTING at HEAD in unrelated
files (bootstrap.go cyclop/nestif, install_script_test.go noctx,
telegram_setup_test.go usetesting), reproduced in a clean worktree and not
caused by this change; the eda/playbook package is gofumpt/vet/lint clean.
2026-09-05 03:10:58 +10:00
sam a73f7cb6a9 docs: resolve service-decomposition open questions #1, #4, #5 2026-09-05 03:04:46 +10:00
sam d92ff825d9 docs: capture AWX/Ansible inspiration research and service-decomposition PRD
Records the AWX pluggable-architecture and Ansible task-model inspiration
thread verbatim, the verified current-vs-ideal coupling analysis (webui's
in-process HTTP task-action detour, direct gateway internals access,
shared config.Holder), the external service-discovery research
(K8s-native primary + NATS fallback behind one ServiceRegistry seam), and
a Proposed-status PRD recording the target service shape and open
questions before any implementation work is filed.
2026-09-05 02:57:04 +10:00
sam 5942fd913e chore(beads): file archie-core-wdn0 (GitHub reconciliation follow-up) 2026-09-03 22:31:01 +10:00
sam 452283aab8 chore(beads): recover 5 carina-only beads during cross-machine sync
Reconciled the helix/carina beads divergence via the Dolt remote. Carina held
28 beads absent from helix, but 23 were the same GitHub issues re-pulled under
freshly-minted IDs -- importing by ID would have duplicated them. Imported the
5 genuinely unique beads (462t, fwvf, n5fz, tzzn, w1d5) with comments intact,
and closed fwvf/n5fz/w1d5 to match GitHub #703/#709/#710, whose fixes had
already merged.
2026-09-03 20:18:47 +10:00
sam c2484df01b Merge pull request #712 from samcharles93/fix/issue-710
fix(ci): skip runtime image on gateway-only releases
2026-09-03 17:09:31 +10:00
sam da68ad4754 Merge pull request #711 from samcharles93/fix/709-bindings-migration
fix(store): migrate binding owner and repo columns
2026-09-03 17:07:29 +10:00
sam 267de136eb fix(ci): skip runtime image on gateway-only releases 2026-09-03 06:43:44 +00:00
sam 7a9122b50e fix(store): migrate binding owner and repo columns 2026-09-03 06:43:03 +00:00
sam faace1940a chore(release): archied v1.22.0 2026-09-03 06:31:21 +00:00
sam bcb78797ab Merge pull request #706 from samcharles93/alert-autofix-6
Potential fix for code scanning alert no. 6: Slice memory allocation with excessive size value
2026-09-03 16:16:04 +10:00
sam 6aa53684ad test(webui): cover log limit validation 2026-09-03 05:36:17 +00:00
sam e077b13640 fix(archied): preserve ephemeral gateway ports (#707) 2026-09-03 15:24:36 +10:00
sam 61ae078fa0 fix(deps): upgrade x/crypto to v0.56.0 (#708) 2026-09-03 15:23:04 +10:00
samandCopilot Autofix powered by AI 50b41e32e0 Potential fix for code scanning alert no. 6: Slice memory allocation with excessive size value
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-09-03 15:13:35 +10:00
sam febc9f075a fix(update): make daemon rollback schema-safe (#704) 2026-09-03 14:53:03 +10:00
sam 7cdd7adb4e feat(telegram): support secret refs for bot tokens (#705) 2026-09-03 14:52:31 +10:00
sam 666cfd4749 chore(release): archied v1.21.0 archie v1.21.0 2026-09-03 09:58:56 +10:00
sam 238aba8d81 chore(beads): wp9s phase-1 notes, file archie-core-mxls (/agents dead wiring) 2026-09-03 07:18:03 +10:00
sam 9b9539fe81 docs(gateway): propose /status Phase 2 health checks
Phase 1 (archie-core-wp9s) shipped /tasks and the /status queue-depth
aggregate. This documents the remaining ask -- broker connectivity,
provider reachability, channel state, container pool, last poll --
split into cheap wiring (nats.Conn.Status(), container.Pool's
already-tracked active count, a new last-poll timestamp) versus two
real product decisions (live-probe vs last-known-outcome for provider
reachability; the ChannelManager-backed shape for channel state).

Proposed resolution, awaiting Sam's sign-off before Phase 2 lands.
2026-09-03 07:17:59 +10:00
sam b698322505 fix(gateway): split /status (health) and /tasks (work) apart
/status conflated two unrelated concerns: a thin per-status task
count that duplicated information belonging to a task view, and
runtime config already visible via /model. Worse, a bare status
count actively misled -- "Running: 1" read the same whether that
task was making progress or stuck in a failure loop, because a count
carries no age or identity.

/status now reports one aggregate queue-depth line (in-flight work:
running/waiting/parked, health signal only) instead of an itemized
breakdown -- queued and terminal states are excluded as neither
actionable nor a health concern.

/tasks is new: the live, per-task view with enough identity and
state to act on it (id, title, status, workflow/stage, age since
last transition, attempt once a retry has happened, and a parked
task's reason). Age comes from Task.UpdatedAt, already persisted and
now threaded through ChatTaskSummary and chatTaskListerAdapter --
no new instrumentation needed. Tasks sort actionable-first (running,
waiting, parked, ...) ahead of terminal states, stable within a
status group so the lister's own recency order survives.

Wired via the existing configureTaskCommands call sites (web,
telegram, email, webhook) using the same chatTaskListerAdapter
already built for the task_list LLM tool -- no parallel data path.

Note: internal/gateway's separate /agents command (AgentReader) is
NOT touched here and remains dead in production (Router.Agents is
never wired by any composition-root call site) -- tracked as its own
finding, not folded into this fix.
2026-09-03 07:15:59 +10:00
sam 6c1caf2f5c fix(eda): make playbook key collision reporting deterministic
loadPlaybookFile ranged over the raw YAML map directly, so which key
"won" when a file declared two colliding bindings depended on Go's
randomized map iteration order -- contradicting the function's own
doc comment promise of a reproducible, deterministic collision error.
Surfaced as a flaky failure in TestLintReportsLoadErrorAsFinding
(internal/app/archieplaybooks), which has two independent collisions
in its fixture and asserted on whichever one used to win by chance.

Sort the file's keys before checking them, matching the existing
sorted-filenames convention for cross-file order. Updated the test's
assertion to the now-deterministic outcome ("bug", alphabetically
first) with a comment explaining why.
2026-09-03 07:15:36 +10:00
sam 11c8121d81 chore(beads): close [[repos]] multi-forge bug as superseded by [[identities]] 2026-09-03 06:58:48 +10:00
sam ddb183642a chore(beads): close archie-core-1786637500926-421-7c63bcd3 2026-09-03 06:57:31 +10:00
sam a6cfbdb3ca fix(webui): stretch HEALTH row cards to equal height
Gate pulse and Finish setting up sat in the same CSS grid row, but a
block-level .card doesn't fill its grid-stretched wrapper's height on
its own -- it shrinks to its own content. With Gate pulse's empty
state being much shorter than the setup checklist, its card ended up
noticeably shorter than its sibling, leaving dead space below it that
read as the content floating uncentered relative to the row.

Flexing the wrapper and growing .card to fill it (scoped to
.dash-top, not the shared .card rule used elsewhere) makes both
HEALTH cards match height while each card's own content keeps
flowing from the top. Verified via a static repro using the real
project CSS: card heights and bottom edges now match (290.5px/y=343
for both, versus 227px/279.5 vs 274.5px/327 before).

Closes archie-core-1786637500926-421-7c63bcd3.
2026-09-03 06:57:22 +10:00
sam 75e050b674 chore(beads): close stale golangci-lint epic and Phase 5 (gate verified green) 2026-09-03 06:50:13 +10:00
sam e090e2c0ec chore(beads): close archie-core-7d5u.6 2026-09-03 06:48:32 +10:00
sam b5ca1b889b docs: reconcile plugins-and-extensions.md and ARCHITECTURE.md with shipped webhook intake
ARCHITECTURE.md described forge intake as polling-only and listed Gitea
as still "planned" despite internal/forge/gitea.go fully implementing
it -- both stale since 7d5u.4/.2/.3 shipped forge webhook intake.
Corrected the opening description, package map, Provenance-by-origin
paragraph, [forge] config bullet, and Implemented/Planned lists; added
a "Webhook intake" subsection documenting internal/forge/webhook as a
separate HTTP receiver reusing the poller's TaskEnvelope/PublishTask
path.

CLAUDE.md gains the internal/forge/webhook/ trap: HMAC verification
must precede payload parsing, and the webhook-built TaskEnvelope must
keep its poll-compatible owner/repo/number idempotency key or
poll/webhook double-dispatch returns.

plugins-and-extensions.md gains a section cross-referencing 7d5u.1's
decision (in-process typed families, no amendment needed) and naming
the Module action position as the shipped instance -- Channel/Forge
positions are correctly left as open investigation (t2db.19), not
claimed as shipped.

Closes archie-core-7d5u.6.
2026-09-03 06:48:02 +10:00
sam d5edd5c1bd chore(beads): close archie-core-t2db.16 2026-09-03 06:42:40 +10:00
sam 5aaa6fd432 refactor(eda): extract helpers to satisfy cyclop/gocognit gates
loadWorkflows (bootstrap.go) split into loadWorkflowRouting,
loadModules, loadEDAPlaybooks -- cyclop 17>15.

LoadPlaybookDirs (routing.go) split into sortedPlaybookFilenames,
loadPlaybookFile, bindPlaybookKey -- gocognit 52>30.

Pure extraction: identical log messages, error strings, and
control flow. golangci-lint run ./... now reports 0 issues.

Closes archie-core-t2db.16.
2026-09-03 06:42:27 +10:00
sam 3eac0c98a8 chore(beads): full vetting record for jsonrpc2 dependency (t2db.20) 2026-09-03 06:33:00 +10:00
sam 353b4fd7e7 chore(beads): narrow LSP dependency candidates for t2db.20 2026-09-03 06:31:20 +10:00
sam 9815a0f831 chore(beads): note proposed gap resolutions on t2db.17/.18 2026-09-03 06:29:54 +10:00
sam 275b0c142f docs(prds): propose resolutions for both execution-time gaps
Drafted for archie-core-t2db.17 (idempotency) and .18 (mid-run
failure), following the same evidence-then-sign-off process the CEL
resolution used -- explicitly marked PROPOSED, not decided, pending
Sam's approval. Every claim checked against the real shipped code
during drafting, not assumed, catching two wrong assumptions before
they landed:

- Gap 1 (mid-run failure): proposes reusing workflow.Run's existing
  three-way distinction (real error -> stop+report; shutdown
  interruption -> not a failure; no-outcome -> definition-bug parked)
  rather than inventing new semantics. States the producer-only
  boundary and the J3 (condition-error) vs action-failure distinction
  explicitly, and states plainly that rollback is not attempted.

- Gap 2 (idempotency): proposes reusing internal/store/bindings.go's
  binding_dispatches at-most-once ledger shape (INSERT OR IGNORE +
  sentinel error) rather than a new mechanism. Caught two real gaps
  while drafting, both stated honestly rather than glossed over: (1)
  t2db.15's shipped Playbook struct has no ID/Version to key a ledger
  on -- Binding gets its identity from being a DB row, a playbook is
  just a loaded file; (2) DispatchInput is a task-label trigger (same
  vocabulary as workflow.Route()), NOT a webhook-capture trigger --
  captured_events.id, the first instinct, does not apply to what
  shipped, and DispatchInput doesn't yet carry any task identity to
  key on either. Both are named as concrete prerequisites for whoever
  implements this, not silently assumed solved.

Not marked as settled -- the status lines say "awaiting Sam's sign-off"
explicitly, matching the process this doc already used for the CEL
decision.
2026-09-03 06:29:41 +10:00
sam f6a341ddb7 chore(beads): close archie-core-mlro 2026-09-03 06:25:31 +10:00
sam a64d72ddbe refactor(ui): extract Pill to ui/src/base/, closing archie-core-mlro
Pill was independently duplicated byte-for-byte across 11 files
(tasks, logs, mapping-editor, capture-row, settings, update-status,
skills, dashboard, memory, channels, curators) plus the bindings page
built earlier this session -- a violation of organisation.md's
"extract on the second distinct consumer" rule, predating this
session entirely. Found while building the bindings UI.

Mechanical extraction only, no behavior change: ui/src/base/pill.jsx
is now the single definition; every call site imports from there.
skills.jsx's copy used `class=` instead of `className=` (functionally
identical in Preact) -- normalized to the shared version's className.
captures.jsx's import of Pill (previously re-exported through
capture-row.jsx) now points at the shared module directly.

Verified via task test:ui (120/120 unchanged) and, since this touches
the exact rendering path that had a real app-wide regression earlier
tonight (commit 8f9f2d6), re-verified in a real browser across all 12
pages: zero "[object Object]" occurrences, and every page's .pill
elements render with real content (settings: 9, bindings: 2, etc.),
not just "the build succeeded."
2026-09-03 06:25:21 +10:00
sam 06b1fe4cb3 chore(beads): close archie-core-t2db.6 2026-09-03 06:20:16 +10:00
sam 417a3dcc3a docs(guides): operator walkthrough for building a first playbook binding
Completes the last open item in archie-core-t2db.6, now unblocked by
t2db.8's UI landing. Every claim verified against the real handler
code, not assumed: the capture endpoint (POST /webhooks/capture/
{source}, mounted on the bypass mux per api_capture.go's own comment
-- capture must accept unauthenticated senders), the HMAC scheme
(webhookguard.VerifyHMAC: HMAC-SHA256 over the raw body, hex-encoded,
X-Hub-Signature-256 header) confirmed against its actual implementation
and cross-checked the documented openssl command against it directly,
and the default listen port from config.example.toml.

Six steps end to end: send a test event, inspect it in the Event
inspector, map fields by clicking the payload tree, create the binding
(covering the new owner/repo pin), approve it, then fire a signed
request and see the resulting task. Cross-references
docs/architecture/bindings.md and ARCHITECTURE.md's provenance
addendum rather than re-deriving their content.
2026-09-03 06:20:14 +10:00
sam 8ddda37997 chore(beads): record binding UI + Preact render fix work 2026-09-03 06:17:44 +10:00
sam 912db8f590 fix(binding): split ValidateForUpdate so edits can preserve the secret
Real bug found via browser-testing the new bindings UI (t2db.8):
UpdateBinding's own store-layer contract documents that an empty
Secret means "preserve the existing one" (COALESCE against NULLIF),
but handleBindingUpdate validated with the create-time Validate(),
which unconditionally requires a full-length secret -- rejecting the
exact "leave blank to keep it" edit flow the store was built to allow.

Root-cause fix, not a UI workaround: Binding.Validate() (create,
unchanged, still requires a real secret -- there's nothing to fall
back to on insert) now delegates shared field checks to a private
validateCommon(); a new ValidateForUpdate() reuses the same checks but
only enforces the secret-length floor when the caller actually
supplied a new one. handleBindingUpdate now calls ValidateForUpdate.

3 new domain tests + 1 new API-layer test pin: empty secret accepted
on update, a genuinely-short new secret still rejected on update,
empty secret still rejected on create.
2026-09-03 06:17:43 +10:00
sam 8f9f2d601e feat(webui): bindings dashboard UI; fix app-wide Preact render regression
Completes t2db.8's remaining UI half. Mirrors ui/src/mappings/ exactly:
bindings.jsx (list + editor), binding-editor.jsx (pure StatusPill/
BindingRow), bindings.css, wired into main.jsx's route table with a new
icon. API helpers (bindingCreate/Update/Delete/Approve) added to
api.jsx following the existing mapping* pattern.

CRITICAL FIX, found via real browser verification (AGENTS.md's UI rule),
not by inspection: every JSX-based page in this app -- dashboard, tasks,
logs, captures, mappings, skills, workflows, memory, curators, channels,
settings, and now bindings -- silently rendered the literal text
"[object Object]" instead of its content. Root cause: main.jsx's router
passed each page's Preact VNode into dom.jsx's mount()/append(), which
only knows how to append real DOM Nodes or stringify everything else --
so a VNode object became exactly that string. Confirmed this predates
tonight's work entirely: extracted and served the already-committed
ui/dist bundle in isolation and reproduced the identical failure on the
stock dashboard, unrelated to any change here.

Fix: main.jsx's show() now detects a Preact VNode vs. a real DOM Node
(the unused `soon: true`/comingSoon() fallback) and calls Preact's own
render() for the former, leaving the generic mount() helper and its
other four vanilla-DOM call sites untouched. Verified every single page
renders correctly post-fix via a throwaway, fully-isolated webui.Server
harness (temp SQLite, no real config/forge/network calls) driven by
Playwright -- not assumed from the source diff alone.

Also found and fixed a second real bug the same way: editing a binding
without retyping its secret (the intended "leave blank to keep the
current one" UX, matching UpdateBinding's own documented COALESCE
contract) was rejected with 400, because the API handler validated
edits with the create-time Validate(), which unconditionally required
a full-length secret. Root-cause fix: split Binding.Validate() (create,
unchanged) from a new ValidateForUpdate() (skips the length floor only
when the secret is empty -- preserving the existing one -- still
enforces it on a genuinely-supplied new secret). Full state machine
(draft -> edit -> pending_approval -> approve -> armed -> delete)
verified end-to-end in the browser afterward.

Filed archie-core-mlro separately for the Pill component's pre-existing
duplication across 11 files -- not fixed here, out of scope for this
ticket, following this session's established discipline.
2026-09-03 06:17:24 +10:00
sam 44ff855a54 chore(beads): block t2db.6's walkthrough on t2db.8 (UI doesn't exist yet) 2026-09-03 04:41:44 +10:00