Commit Graph
20 Commits
Author SHA1 Message Date
sam e6a2e5b3b4 feat(state-store): stand up archie-state-store binary and own archie.db (archie-core-8cda.4.3) (#771) 2026-09-07 03:41:32 +10:00
sam d5e8669991 fix(archied): initialize conversation persistence on daemon startup 2026-09-07 00:49:54 +10:00
sam bec9caa24e feat(gateway): delete in-process ChatContract path, make remote the only mode
archie-gateway is now the sole owner of ChatContract; the daemon always
dials it over gRPC for webui chat, no in-process fallback left. Telegram
and email keep their own in-process routers unchanged (their streaming
responder is a callback that can't cross the wire-safe contract).

- composeChatContract only accepts mode="remote"; config defaults
  Services.Gateway to remote + 127.0.0.1:8585 when unset
- deleted taskActionsActor (dead code once the local branch is gone)
- task dev now launches archie-gateway alongside archied + Vite

Verified end-to-end: archie-gateway + archied booted against a shared
NATS/store, webui's /api/chat/sessions round-tripped through the gRPC hop.
2026-09-06 02:07:02 +10:00
sam 79375f33e9 feat(gateway): extract ChatContract service 2026-09-05 23:06:16 +10:00
sam 3d7666002c feat(contracts): add gateway service seams and protobuf toolchain 2026-09-05 22:57:45 +10:00
sam 2dd095c8a7 fix(build): clear pre-existing task check gate blockers (#719)
Baseline `task check` failed on a clean main checkout, blocking unrelated
in-flight work. Fixes only those pre-existing failures:

- bootstrap.go: extract wireWebStoreSurfaces from setupObservability
  (cyclop 16 > 15) and startEmbeddedNATS from connectNATS (nestif).
- telegram_setup_test.go: os.Setenv -> t.Setenv (usetesting).
- install_script_test.go: exec.Command -> exec.CommandContext with
  t.Context() (noctx).
- Taskfile: add a ui:deps install step shared by `ui` and `test:ui`.
  ui/node_modules is gitignored and nothing in the gate installed it, so
  `task test:ui` died on a missing jsdom rather than a real test failure.
- shutdown_watchdog_test.go: `go fix` output adopted verbatim.

Refs bead archie-core-14cs.
2026-09-05 13:37:34 +10:00
sam 96516335df chore(taskfile): make task check include golangci-lint
Sam's explicit requirement: the definitive gate should catch lint
regressions, not just fmt/vet/build/test. Immediately surfaced real
debt on the first run -- see follow-up beads issues.
2026-09-03 04:09:37 +10:00
sam 8c19555b4a feat(playbooks): standalone lint tool for playbook binding dirs
Fourth slice of docs/prds/eda-playbook-engine.md (t2db.12): the design
doc's pre-merge collision layer, as a gopls-shaped standalone binary
(cmd/archie-playbooks) rather than a Taskfile wrapper -- one binary, one
schema source, mode-based entrypoints.

- cmd/archie-playbooks: subcommand dispatch table from day one (lint now;
  an lsp/serve mode later slots in without restructuring), flag parsing
  only per organisation.md's cmd/ rule.
- internal/app/archieplaybooks: the lint mode's composition -- collects
  directories, calls workflow.LoadPlaybookDirs (the daemon's own loader),
  reports findings. No second validation path: the linter agrees with
  runtime startup validation by construction.
- Reuses LoadKindWorkflowsYAML/LoadLabelWorkflowsYAML/LoadPlaybookDirs
  directly; collision/malformed/invalid bindings exit non-zero.
- Known limitation recorded: findings are file-granular, not
  line-granular (yaml.Unmarshal into map discards line numbers; a
  file:line diagnostic needs a yaml.Node upgrade, out of scope here).
- Taskfile lint:playbooks target; PRD records the shipped shape and the
  file-granular caveat.
2026-09-03 03:07:27 +10:00
sam 1425050506 fix(build): stamp gatewayVersion/runtimeVersion in the right package
-X main.gatewayVersion/main.runtimeVersion targeted package main, but
those vars live in internal/app/archied (cmd/archied is a thin
wrapper). An -X target that doesn't exist is silently ignored by the
linker, so every archied binary this shipped -- task build, install.sh,
Dockerfile.archied, and the carina self-update script -- reported
"dev" instead of its real version. Point every one of those ldflags at
the actual package.

Also, while chasing the carina incident this surfaced:

- restart.go: /restart didn't check for an in-flight /update install.
  The install runs as archied's own child process, so a restart killed
  it mid-build (observed: "signal: terminated") instead of letting it
  finish or fail cleanly. Refuse the restart while updateInProgress.
- update.go / update_report.go: the "no version could be confirmed
  running" branch still opened with "Update complete", contradicting
  its own next clause. Reworded so an unverified outcome isn't
  reported as completion.
2026-09-02 00:00:32 +10:00
sam f66824ae08 chore(ci): pin Go version from go.mod and add a govulncheck step
CI's go-version was a floating "1.26" independent of go.mod, so it
could silently drift from the toolchain the project actually builds
with. Switched to go-version-file: go.mod as the single source of
truth, and added `task vuln` (govulncheck) plus a CI scan step -- kept
out of `task check` since it needs network access to the vuln DB.
2026-08-31 21:25:54 +10:00
sam 1f05dbb33c feat(deployment): default to managed NATS workers
Autonomous workflows now always hand a complete task to a scoped archie-agent container. Embedded NATS is the default and external NATS changes only broker placement; legacy agent and containers.enabled inputs decode for migration but cannot select an execution path. The daemon flushes task-event subscriptions before a worker can publish, and runtime updates snapshot and restore the configured worker image.
2026-08-24 14:56:57 +10:00
sam 44b0181485 feat(agent): stamp archie-agent's build and report it back to the daemon
archied's own build has carried a compiled-in gatewayVersion and an
internal/installtype stamp since archie-core-522/2873cbb, but
archie-agent's build had neither -- its Taskfile.yml and Dockerfile
build steps passed no -ldflags at all, so even a daemon that wanted to
verify what agent build is actually in service had nothing to check
against. daemonRunningVersions said as much explicitly: the agent was
left out of every verification on purpose, because nothing self-reported
a real value.

Every archie-agent process is task-scoped and ephemeral (spawned per
task, dies after), not a long-lived process the daemon can poll on
demand the way it polls Telegram's gateway. So there's no "ask the
agent its version" request -- the only channel back is whatever a
worker includes in the taskrun.Response it already sends on every
completed task.

Stamp archie-agent's build the same way archied's is (installtype,
plus a new agentworker.Version()), have executeTaskRequest report both
in its Response, and have the daemon record the latest observation in
a new mutex-guarded AgentStatus, fed from runViaAgent on every
successful response only -- never off a request that never reached an
agent, or one describing a failed/parked task. daemonRunningVersions
now includes the agent component once (and only once) something has
actually been observed, so Report.Verify gets a real value to check
future update claims against instead of omitting the component
entirely.

Part 1/3 of archie-core-1786751948782-3-837a8fd0 point 4. Closes
archie-core-1786751948782-3-837a8fd0.1.
2026-08-23 23:18:00 +10:00
sam 54be74ae89 feat(releaseupdate): stamp install type at build time, fail closed on unknown
/update could report success at the correct target version while the
archie-agent container running it never actually changed: the update
mechanism trusted the configured installer's exit code and reported
whatever version number the release claimed, with nothing verifying
the two agreed.

The first piece of the fix: a new internal/installtype package
reports how a binary was built for distribution (Type(), defaulting
to "unknown"), stamped once per release artifact via
"-ldflags -X .../installtype.buildType=<value>" rather than guessed
at runtime by probing the environment -- restic and Tailscale both
treat "which install shape is this" as a build-time decision for the
same reason: a probed signal is guessable, a compiled-in one is not.

releaseupdate.Service.Install now refuses to run the configured
Installer at all when InstallType is unset or installtype.Unknown, so
an unstamped or misconfigured build can no longer silently attempt an
update it has no way to know is even the right kind for how this
instance was deployed. Wired through every real archied build path so
the gate doesn't just exist in principle: Taskfile.yml's build task
(binary), Dockerfile.archied (container), and install.sh (binary) all
now stamp it; cmd/archied/telegram_setup.go wires
Service.InstallType from installtype.Type().

Configuration-page display of install type/version and post-update
verification against the actually-running reference (not just the
installer's reported version) remain open -- this lands the
correctness gate, not the full observability surface.

Refs #522
2026-08-15 10:34:46 +10:00
sam 94adedc2d7 fix(build): stamp versions in task build, not only in the Docker image
Version stamping lived solely in Dockerfile.archied's -ldflags, so any
build from source reported gatewayVersion/runtimeVersion as "dev". That
covers every host deployment: carina builds the binaries with go build
and runs them under systemd, never touching the image, so /version there
answered "Archie Gateway: dev Runtime: dev" for a tagged release.

Derive the same -X values from the release tags. git describe without
--abbrev=0 gives 1.7.0-2-gbb54786 when HEAD has moved past the tag,
which is the honest answer for a mid-cycle build rather than claiming
the release itself.

archie-agent has no version variable, so only archied is stamped.
2026-08-10 02:42:24 +10:00
sam 61b4b7b0cf refactor(store): replace legacy persistence with SQLite
Task and event persistence now uses a dedicated SQLite sidecar derived from the configured state prefix, matching the independently persisted conversation store. The configured path now means a state-path prefix rather than a database file so fresh SQLite state never attempts to interpret the previous storage format.

Remove the retired implementation and dependency completely, strengthen SQLite migrations and concurrency behavior, restore backend-neutral coverage, and align configuration, operational guidance, UI labels, and deployment documentation with the new storage and host-daemon topology.
2026-08-09 22:27:25 +10:00
sam 170fe0250b fix: close the duplicate-work loop and the dead paths around it
Applies the four-reviewer pass over the forge/dashboard-actions work.
The through-line is that several capabilities were wired but inert, and
one of them could cost real work.

DUPLICATE WORK. "Closes #N" was dropped from PR bodies in favour of
LinkBranch, which is sidebar linkage on Gitea and a no-op stub on
GitHub -- neither closes anything, and nothing else did either. So a
merged task left its issue open, labelled and assigned; the next poll
re-enqueued it, and once the dashboard's Clear removed the task row that
became a second implementation and a second PR for work already merged.
reconcilePRs now closes the issue on merge, and a rejected task closes
its issue too. A PR closed without merging deliberately leaves the issue
open: that usually means "try again".

MAX RETRIES. Configured, defaulted and reported by /api/config, and
enforced nowhere -- markDead was unreachable and EffectiveMaxRetries had
no callers, so the dashboard's retry incremented retry_count forever.
The retry action now retires a task to dead at the cap.

DEAD ON ARRIVAL. Tasks() never selected plan or source, so the
"Decision required" panel could not render and chat tasks -- whose issue
number is synthetic -- linked to forge issues that do not exist.

COSMETIC FAILURE, FATAL RESULT. OpenPR failed the whole stage when
LinkBranch errored, so the pull request was never opened and the task
parked; a retry re-links the same branch, which Gitea answers with a
conflict, so every retry parked again. It is best-effort now.

INVISIBLE ACTIONS. Approve/retry/reject wrote store rows and nothing
else, so the timeline and activity stream never showed that a human had
intervened. They emit events now.

Also: store write failures answer 500 rather than 409; the dashboard
surfaces the server's actual reason instead of "409 Conflict"; action
buttons stop propagation (acting on a task no longer also expands it),
disable in flight, keep per-task errors instead of one shared string,
and confirm before rejecting.

Removed: the maybeRetryParked shim and markDead with their now-vacuous
tests, WaitingTasks (no consumers; its tests were rewritten to assert
the same routing through TaskByID), write-only Daemon.Runtime, and
dir/dirs response bloat from /api/skills. skillSource checked workDir
before sharedDir, mislabelling every shared skill when the two are equal.
DefaultRoots now dedupes roots differing only by a trailing separator.

The air build rule claiming to keep ui/dist current never ran -- it
required one file to satisfy include_dir and include_file together, and
ui/ is excluded from the walk. Deleted with the comment that promised it.
task test:ui joins task check and CI; it ran nowhere before, so the
dashboard suite could rot silently.

Docs corrected where they described behaviour that no longer exists:
parks no longer comment on the issue, state labels no longer drive
retries, and forgerpc's doc claimed four proxied methods while listing
three of five.
2026-08-05 03:54:25 +10:00
sam 4d44ef76f5 feat(webui): rebuild the dashboard
The old UI was a single 200-line Go file serving one hand-written HTML
page of task rows. It showed that archied was running and almost nothing
about what it was doing -- skills, workflows, memory, channels, logs and
configuration were all invisible unless you read the source or the
config file.

The dashboard now covers each of those as its own section, built as a
Vite app under ui/ at the repo root: it is a separate artefact from the
Go daemon, not an internal package of it. dist/ is committed so building
archied never needs a Node toolchain, and the !no_ui build tag keeps an
embed-free build available.

Both sides are split by concern rather than by layer -- one Go file per
API area, one folder per UI section with its own CSS -- so a change to
logs cannot disturb tasks.

Pages report consequences, not just state: an empty memory page says
Archie starts every conversation with no recollection of earlier ones,
and the setup checklist names what is missing in plain language instead
of showing a grid of zeroes. Nothing greets by a hardcoded name; the
operator comes from [chat], which is deployment data.

Auth is exposure control, not capability control -- the agent already
holds this user's authority through its own tools. So a loopback bind
needs no token, and only a reachable bind mints one and logs a URL,
which means an instance cannot be exposed merely by omitting config.

Container startup now degrades instead of aborting, for the reason
resolveForge already does: a missing agent image should not deny the
operator chat and the dashboard, and under Restart=on-failure it turns a
recoverable problem into a crash loop with the real error scrolling past.

`task dev` runs the daemon under air and the Vite server together in one
terminal.
2026-08-04 01:45:36 +10:00
sam c91f373879 chore: add task release for changelog generation and tagging
The changelogs said 1.1.0 while 116 commits sat untagged on main, and
the deploy workflow stamps images 'dev' when no tag points at HEAD.

Two steps, so generated notes can be edited before a tag freezes them:
release:prepare writes them, release commits and tags. Which commits
land in which changelog is decided by each binary's package closure
(go list -deps), so a change to a package archied does not import
cannot show up in archied's changelog.
2026-07-31 01:33:08 +10:00
sam 146acf5466 feat: secret engine registry foundation (archie-core-xec)
internal/secret package:
- Engine interface (Name, Version, Resolve) for pluggable secret backends
- SecretRef type replacing TokenEnv/APIKeyEnv string fields
- ResolveOrEnv for backward-compatible env-var fallback
- Built-in env engine registered by default
- Registry with Register/Get/Resolve/LoadDir (yaegi-based)
- DefaultRegistry() singleton for one-off resolution
- 12 tests, race-clean

Scoped to foundation only. Provider/NATS/Telegram migration deferred
to xec.4 (separate bead — those call sites forward env var names to
subprocesses/runtimes and need eager-resolve-then-inject, not a simple
field rename).

40/40 packages pass with -race.
2026-07-26 14:20:19 +10:00
sam 6ebbd3b2cf fix: add missing LinkBranch stubs to test doubles
Fix go vet/test failures by adding LinkBranch methods to stubForge, prCapturingForge, testForge, and fakeForge. Update test data from 'sam/archie' to 'acme/widget' and state label defaults from 'archie:*' to 'agent:*'. Add Taskfile.yml for project build automation. Implement container self-network detection so spawned agents join the daemon's Docker network.
2026-07-24 13:32:50 +10:00