Commit Graph
19 Commits
Author SHA1 Message Date
sam 35ebaa6ce4 docs: describe the PostgreSQL-only stores, state_dir and the import-only db_path
Architecture, deployment, installer, skill and PRD text now name the Postgres
State Store, the offline recovery commands on database_url, state_dir for host
state, and db_path as the legacy-file locator for archie-state-store import.
Finalised PRDs, CHANGELOG, docs/news and docs/archive are unchanged records.
2026-09-24 14:51:48 +10:00
sam 36118f4ee4 fix(release): CI owns the release stamp; :latest moves only from a release
Two beads, one root: four sites stamped a version and only two of them were CI.

`Taskfile.yml`'s build and `install.sh` derived GATEWAY_VERSION/RUNTIME_VERSION
from `git describe`, so a from-source build claimed a release it was not
running, and the stamp became a function of the commit graph -- the one input a
content-checksum build cache cannot see. An empty commit moved `git describe`
while `task build` reported "up to date" and shipped the previous stamp
(archie-core-pdq2). Both sites now stamp `dev`: a source build says so, and the
version a release carries is written into the artifact CI publishes. That
removes the non-file input rather than caching it, and traceability for a local
build is the checkout it came from.

`deploy.yml` published `:latest` from any push to main, so a release's own
stamping survived only until the next ordinary commit -- minutes, in an active
repo -- and a host deploying :latest reported dev, leaving the update path
unable to tell current from stale (archie-core-i5nb). `:latest` now moves only
from a commit that IS a release; every other build publishes `:edge` (mutable,
newest main) and `sha-<commit>` (immutable). A host that runs releases follows
`:latest`; a host that tracks main follows `:edge`, which RELEASING.md now says.

Verified: `task build` reports `archied dev`; the new workflow test fails
against the old workflow on all five guards and passes after; deploy.yml
parses; install.sh passes `bash -n`.

Gated with `task check` (exit 0) at 6046aaf4 -- the v1.39.0 base, CI-green --
with these five files applied. It is NOT gated at HEAD: HEAD carries an
unrelated red, `TestTaskProtoCarriesEveryDomainField`, because fe2a8e6d added
ParkClass and RemediationRounds without the proto mapping. This change neither
causes nor fixes that.
2026-09-23 13:09:01 +10:00
sam ec0f17a7ad feat(update): let every host binary report its version, and refuse skew
The updater is component-driven: it compares the daemon and agent versions and
acts only when they differ, so a host whose individual binaries disagree looks
healthy. Carina ran a hand-installed archie-messaging 1.35.0 against a 1.30.0
state store and crash-looped on an RPC the older store does not serve, while
the updater reported "no approved component changes; nothing to install".

The reason a comparison was impossible: three of the six host binaries carried
no version at all. archie-ui, archie-messaging and archie-playbooks did not link
internal/app/archied, so the release ldflags never reached them; the gateway and
state store linked the variable but exposed no flag. Only archied could say what
it was.

- internal/buildinfo carries Version, stamped by all three build sites: the
  zip, install.sh, and the updater itself.
- Every host binary answers -version ("<name> <version>"). archied's existing
  two-line output is unchanged, because something parses it.
- archie-update-install reads each installed binary before it can report
  "nothing to install" and refuses, naming every binary that disagrees with the
  daemon's version; after an install it verifies the same set against the
  release it just installed, so a binary the release did not rebuild is skew
  rather than success.
- TestDistZipShipsEveryHostCommand pins stamping across the three build sites
  and requires each cmd/ to report, so a seventh command cannot arrive unstamped.
2026-09-22 14:52:18 +10:00
sam 3d6accd7e9 feat(install): write a unit for every host service
install.sh built and installed five host binaries but wrote only
archied.service, so a fresh install ran one of five services and the updater
refused its own first update for units the installer never created
(archie-core-enow). The runbook stood in as the mechanism, which is the
hand-written step that let a messaging binary and unit drift apart
(archie-core-1c01).

- install.sh writes archie-state-store.service, archie-gateway.service,
  archie-ui.service and archie-messaging.service alongside archied.service,
  with the contents the runbook used to tell an operator to paste, and starts
  all five with the store first.
- deployments/systemd-user-service.md no longer carries the unit contents; it
  names the units, explains why each exists, and points at
  systemctl --user cat and drop-ins for inspection and overrides.
- The updater's unmanaged-unit refusal now reads as a safety net for a host
  that drifted rather than the normal path.
2026-09-22 14:41:38 +10:00
sam 323870a9f6 fix(release): build and guard every host service the installers manage
install.sh built five of the six host commands, omitting archie-messaging, and
scripts/archie-update-install's guard only checked that every listed service had
a unit -- never that every host unit was listed. A v1.30.0 updater with the old
list therefore neither backed up nor restarted the messaging service, leaving a
hand-installed binary running under an otherwise updated host (archie-core-1c01,
archie-core-1faq).

- install.sh builds archie-messaging, and its summary names it.
- The updater refuses when a host unit this release ships is not in
  GATEWAY_SERVICES, naming it, alongside the existing refusal for a listed
  service with no unit.
- TestDistZipShipsEveryHostCommand -- the name deploy.yml:255 already promised --
  now pins all four lists to cmd/: the zip's build loop, the zip's copy list,
  install.sh's build loop, and the updater's GATEWAY_BINARIES/GATEWAY_SERVICES.

A fresh install still seeds only archied.service; that gap is tracked separately
as archie-core-enow.
2026-09-22 14:38:10 +10:00
sam 0e64573b04 refactor(install): install.sh delegates config generation, and tests stop reading hand-written configs
Two things fall out of one principle: a test that asserts against a
hand-written file is testing an artifact a human or an agent may legitimately
rewrite at any moment, so only generated output is a valid target.

install.sh generated config.toml two ways -- a full heredoc for the self-host
path and an awk splice of the [forge] block into config.example.toml -- with a
forge_block shell helper feeding both. That is the arrangement
docs/architecture/configuration.md decided against: it "must stop generating
config.toml; archied setup owns it", because the installer hand-rolling TOML
already drifted once (choosing Gitea produced a config naming a token the
installer never wrote). Both generators and forge_block are gone; install.sh
collects its answers as before and passes them to archied setup as parameters,
with secrets passed as REFERENCES to the env keys it just wrote rather than as
values, which would put them on a command line. The installer also now asks for
a cloud model, which archied setup requires and the old path never emitted.

deployment_contract_test.go tested the removed generators by parsing install.sh's
shell text, reconstructing the heredoc and asserting on its content. It broke the
instant install.sh stopped generating config -- "install.sh has no heredoc
declaring the daemon config's [nats] table" -- which is the failure mode in
miniature: the test was coupled to an artifact, not to behaviour. Deleted.

What it actually protected is kept, asserted on the GENERATED config instead:
TestRunSetup_GeneratedConfigSatisfiesDaemonRequirements runs archied setup and
loads what it wrote, requiring services.state.target and bot_user. A test against
generated output fails when generation breaks and passes when a human merely
tidies the template.

Found by an adversarial package sweep (temp tracker: config-1,
repo-root-deployment-1, repo-root-deployment-2).
2026-09-15 03:35:45 +10:00
sam fd4614a7d0 fix(install): emit an active State Store target so a fresh install can boot
install.sh produces config.toml two ways, and neither emitted an active
[services.state].target. The self-host branch writes a hand-rolled heredoc with
no [services] section at all, and the non-self-host branch rewrites only the
[forge] block of config.example.toml -- where [services.state] sat commented
out. openStateStoreAdapter requires a target, so a freshly installed archied
aborted at startup with no way to boot from the config the installer had just
written.

Activate [services.state] with a loopback target in both sources, which is the
producer fix: the config the installer emits is the invalid state, so it is
corrected where it is generated rather than defended against at the daemon.
[services.gateway] is activated alongside it for the same reason it is safe to
-- internal/infrastructure/configuration/defaults.go already defaults that
target to 127.0.0.1:8585, so declaring it changes no resolved value and only
makes the emitted config explicit.

Add TestInstallerGeneratedConfigHasServiceTargets, which parses what each
branch actually produces: config.example.toml through the real config loader,
and the install.sh heredoc reconstructed with its shell expansions resolved.
Both assertions are red-first -- with the sources reverted the test fails on
both branches with the boot-fatal message.

Found by an adversarial package sweep (temp tracker: repo-root-deployment-1,
.local/issue-tracker/).
2026-09-15 02:10:31 +10:00
sam 5c6b0f69b3 fix(update): install and cycle every process in the release
A self-update to 1.23.0 failed its health check and rolled back. The
adapter built and installed ./cmd/archied and nothing else, and the
watchdog restarted archied.service and nothing else, so the new daemon
came up against a State Store, Gateway and UI still on the previous
release. Since 1.23.0 archied cannot boot without a reachable State
Store (openStateStoreAdapter), which on a host that had never run one is
an immediate exit, a failed health check, and a rollback that looks like
a bad release rather than an incomplete deployment.

Install every binary the reference deployment runs, versioned off the
archied tag, and back each up so the rollback restores all of them
together. A binary with no .prev was introduced by the failed release, so
rollback removes it instead of leaving one behind that points at
processes the restored release does not run.

Restart in dependency order: the State Store owns archie.db and every
other process dials it, the Gateway serves the contract archied and the
UI dial, so each comes up before its consumers and stops after them.
archied itself is cycled unconditionally and a failed stop still aborts
the rollback, because a presence probe that guesses wrong must never
skip the stop that keeps a live process off the binary and the database
being restored. The siblings are best-effort, which is safe because the
adapter now refuses the update outright, before touching the host, when
a unit for one of them is missing, naming what to create.

install.sh had the same single-binary assumption, so a fresh install
produced a host that could not start either.

Closes archie-core-hbqk.
2026-09-12 09:52:01 +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 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 401913fffa fix(update): isolate service restart handoff 2026-08-17 00:17:41 +10:00
sam 62adab69af fix(update): stamp install type and bound retry backoff 2026-08-16 23:59:48 +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 fcfe5cf264 fix(deploy): wire ExecReload so SIGHUP config reload works under systemd
archied v1.7.0 reloads its configuration on SIGHUP, but neither the unit
written by install.sh nor the one in the systemd runbook declared
ExecReload. 'systemctl --user reload archied' therefore failed, and the
only way to reach the new reload path was to know about
'systemctl --user kill -s HUP'.

The feature shipped with no supported trigger in the documented
deployment shape. Existing installs need the same line added, either by
re-running install.sh or via a drop-in.
2026-08-10 02:31:59 +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 357abc2097 fix(install.sh): three argument/linger handling defects
--force was advertised in --help, accepted, and inert (FORCE_BUILD was
set and never read -- go build already rebuilds unconditionally).
Removed the flag and its help line rather than fake an up-to-date
check that go build's own cache already makes unnecessary.

Unknown flags fell through the case statement with no default branch
and silently kept every default, so a typo like --no-systmd installed
the systemd service the user asked to skip. Unknown options now print
a diagnostic naming the bad flag and exit 1, per the (a) option agreed
2026-07-30: this is a hand-run interactive installer where typos
dominate and silent wrong behaviour is the worst outcome.

Linger detection grepped for "Linger=no" and treated any other output
-- including a failed or empty `loginctl show-user` from a missing
logind session, a container, or unset $USER aborting under `set -u`
-- as "already enabled" without observing anything. Detection now
requires a positive "Linger=yes" and falls through to enable-linger
(idempotent) in every other case, and uses $(id -un) instead of $USER.

Refs archie-core-bfw, archie-core-c6o, archie-core-utt

Verified manually: bash -n syntax check; a real invocation of an
unknown flag (exits 1, no side effects, before any build/network
step); the linger branch logic exercised in isolation against stubbed
loginctl output for Linger=yes, Linger=no, empty output, and a failing
command. No shell test harness (bats or similar) exists in this repo
yet, so this is direct verification rather than a committed test.
2026-08-05 11:57:16 +10:00
sam 75e58ef595 fix(archied): disable the forge on a missing credential, not the daemon
An unresolvable forge token aborted startup with exit 1, denying the
operator chat, the gateway and every other subsystem over a capability
they may not use -- and under the installed unit (Restart=on-failure,
RestartSec=5s) it crash-looped where the error was never read.

Forge setup moves into resolveForge, shared by the primary forge and
each configured identity, and degrades to NoopForge with a warning.
Malformed config still fails fast in validation. The systemd unit gains
StartLimitIntervalSec/StartLimitBurst as a backstop for other failures.
2026-07-30 02:01:28 +10:00
sam 5fa5d98130 fix(install): honour forge choice, stop echoing secrets, guard Linux
- Render [forge] from the answers given: the generated-config path
  hardcoded the GitHub token key and the Gitea host, so a Gitea install
  read a key the installer never wrote and a GitHub install pointed at
  gitea.example.com. Both config paths now share one renderer.
- Read tokens with -rs so they stay out of terminal scrollback, and
  replace rather than append env keys so a re-run does not leave the
  revoked token in the file.
- Exit early on non-Linux instead of failing later in a heredoc.
- Never abort the install because the shipped source tree has local
  changes; build what is on disk.
2026-07-30 01:45:59 +10:00
sam 6be754787d polish: add install.sh, XDG setup, deployments/ examples, and github-token docs\n\n- Add install.sh following XDG Base Directory specification (~/.config/archie, ~/.local/share/archie, ~/.local/bin)\n- Add interactive setup for code forge (GitHub / Gitea / Standalone) and LLM provider selection (Ollama model picker / Cloud keys)\n- Implement NoopForge in internal/forge/noop.go for running Archie in standalone mode without a forge\n- Enable loginctl user linger and systemd user unit setup in install.sh\n- Add docs/github-token.md with step-by-step guidance for Classic PAT generation\n- Add top-level deployments/ directory with scenario templates (single-forge GitHub, multi-forge GitHub+Gitea, local Ollama standalone, systemd runbook) 2026-07-30 01:25:46 +10:00