fix(messaging): report the daemon version this process was built from

The Telegram update-report relay verified every pending report against a
nil running-version map, so a successful update always ended with "I still
can't confirm which version is actually running" and read as a failure.

The 2026-09-19 extraction decision left RunningVersions nil because the
Messaging Service could obtain only another binary's stamp. 6a3b3509
(archie-core-k94o) then gave every host binary, archie-messaging included,
a buildinfo.Version self-report stamped with the archied release tag, so
the process now has a truthful source for its own running version: report
daemon = buildinfo.Version and leave the agent Unverified, since every
archie-agent process is task-scoped and observed only through
daemon.AgentStatus. A relaying process that the update did not replace
still reports its old build, which Verify reads as drift.
This commit is contained in:
sam committed 2026-10-02 10:16:22 +10:00
1 parent a7f17e4e55
commit 6985be0abd
5 files changed
+145 -16

No files matched your search

+19 -3
View File
@@ -202,13 +202,13 @@ actually owned, not by where it used to be built:
| Seam | Resolution |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Version` | Sourced from the Gateway via `ChatSnapshot.Version`. The Messaging Service never stamps or infers a build version; `cmd/archie-messaging` deliberately takes no version ldflags, so it cannot report a partial upgrade as a matched one. |
| `Version` | Sourced from the Gateway via `ChatSnapshot.Version`. The Messaging Service never renders its own build into `/version`; `cmd/archie-messaging` does carry a `buildinfo` release stamp (added by `archie-core-k94o`, see the amendment below) for the updater's skew check and update verification, but `/version` still shows the Gateway's block so a partially upgraded deployment cannot report itself as matched. |
| `Updates` (`/update`) | Built in the Messaging Service from `[chat.telegram].update_check_command` / `update_install_command` — its own configuration. `Enrich` is dropped: `componentInstallTypeEnricher` reads `[nats]`, which this service must not decode, so the check command's own reported install type stands unmodified. |
| `UpdateReportPath` | A local state file under `work_dir`, keyed by the same `sha256(bot_user)[:8]` scheme the daemon used, so a pending report is found rather than written afresh. |
| `ReleaseAnnouncements` | **Deliberately left nil**, for the same reason as `RunningVersions`. `releaseannounce.Announcer` announces nothing unless each `Component` carries a parseable version, and the only versions this service can obtain are the Gateway's own build stamps, not archied's. Wiring the announcer without them yields a no-op that reads as configured, so it stays unwired until component self-reporting exists. |
| `ReleaseAnnouncements` | **Still left nil**, but no longer for the `RunningVersions` reason (that seam now self-reports — see the amendment below). `releaseannounce.Announcer` announces nothing unless each `Component` carries a parseable version, and the only version this process can vouch for is its own daemon-release stamp, not the agent's. Wiring the announcer without them yields a no-op that reads as configured, so it stays unwired until component self-reporting exists. |
| `SetShowToolCalls` | Projected from `[chat].show_tool_calls`. |
| `Reload` | Local: re-resolves the token and allowlist from this service's own config file and overlay. Reload was never a daemon fact. |
| `RunningVersions` | **Deliberately left nil.** It exists to turn an installer's claim into a checked one, and only a component's own compiled-in build can vouch for it. The Messaging Service knows neither archied's build nor the observed archie-agent version (`daemon.AgentStatus`), and the Gateway's own `gatewayVersion` is a different binary's stamp — reporting it as the daemon's would manufacture exactly the false success the check exists to catch. Update reports therefore relay as unverified claims until a component self-report contract exists. |
| `RunningVersions` | **Wired from this process's own release stamp** (`archie-core-ot33`; see the amendment below). `archie-messaging` is one of the processes in the archied release set (the installer's `GATEWAY_SERVICES`), built from the same `archied/v*` tag and stamped with `buildinfo.Version` by every build site, so its compiled-in build is evidence that the release the installer claims actually reached this host. It reports `daemon = buildinfo.Version` and reports nothing for `agent` (task-scoped, observed only through `daemon.AgentStatus`), leaving the agent Unverified. The Gateway's rendered block is deliberately not used: that is a different process's stamp. |
| `Dangerous` | Stays nil. No daemon composition ever set it; `/rollback` and `/stop` reported "not configured" before the extraction and still do. |
The Messaging Service consequently reads `work_dir`, `bot_user`, `[chat]` and
@@ -217,6 +217,22 @@ The Messaging Service consequently reads `work_dir`, `bot_user`, `[chat]` and
polls from outside to confirm an update came back up; the rest of the PRD's
prohibition list is untouched.
**Amended 2026-10-02 (`archie-core-ot33`, Telegram `RunningVersions`).** The
2026-09-19 decision left `RunningVersions` nil because it judged this process
could obtain only another binary's stamp. That was true when written and stopped
being true three days later: `ec0f17a7` (`archie-core-k94o`) gave every host
binary, `archie-messaging` included, a `buildinfo.Version` self-report so the
updater could detect per-binary skew. `cmd/archie-messaging` now registers
`buildinfo`'s `-version`, and every build site (`install.sh`,
`scripts/archie-update-install`, `.github/workflows/deploy.yml`, `Taskfile.yml`)
stamps it with the same `archied/v*` release as the rest of `GATEWAY_SERVICES`.
The messaging process therefore vouches for the `daemon` component from
`buildinfo.Version` — its own compiled-in build, never the Gateway's rendered
block — and reports nothing for the agent. A relayed update report can now
confirm the daemon and still names the agent as unchecked, while a binary the
update did not replace reads as drift. `ReleaseAnnouncements` stays nil: it needs
a version for every component, and this process can vouch only for itself.
**Phase 4 messaging severance: what must move, and the decision the PRD does
not cover (2026-09-22, `archie-core-1ng1`).** The PRD's deletion gate cannot
pass today. `cmd/archie-messaging/architecture_test.go` does not exist, and the
+1 -1
View File
@@ -64,7 +64,7 @@
"url": "/dev/architecture/migration-decisions/",
"title": "Architecture Migration Decisions",
"section": "Architecture",
"body": "# Architecture Migration Decisions\n\n**Status:** Active migration inventory \n**Date:** 2026-07-28 \n**Tracking issue:** [#73](https://github.com/samcharles93/archie-core/issues/73)\n\n## Purpose\n\nThis document records what remains to be decided before Archie's current\nimplementation can be migrated into the approved domain-oriented structure.\n\nThe product and core domain model are not being redesigned. Existing Archie\nbehaviour and the existing session implementation are the migration\nbaseline. Remaining decisions MUST be grounded in current packages, consumers,\ntests, persistence, and runtime wiring.\n\n## Confirmed domain packages\n\n```text\ninternal/domain/\n identity/ (approved, not yet materialised as a package)\n agent/ (approved, not yet materialised as a package)\n workflow/\n messaging/ (canonical Message/Conversation types only; gateway migration pending, see section 2)\n workintake/\n plugin/ (approved, not yet materialised as a package)\n curator/\n mapping/\n scheduling/\n```\n\n- `identity` owns persistent actors, lifecycle, ownership, attribution, and\n audit identity.\n- `agent` owns persistent assistants, specialisation, instructions,\n model-independent continuity, capability context, and associations with\n identity and memory.\n- `workflow` is a separate domain. It owns reusable, versioned Workflow\n definitions, WorkflowSteps, WorkflowExecutions, StepExecutions, Attempts,\n outcomes, and typed Workflow plugin contracts.\n- `messaging` owns canonical Messages, Conversations, branches, channel and\n source correlation, replies, acknowledgements, delivery attempts, events, and\n projections.\n- `workintake` owns admission, validation, deterministic routing, and accepted\n work requests for the optional transition into durable workflow-backed\n execution.\n- `plugin` owns generic plugin identity, discovery, compatibility, and lifecycle\n mechanics. It remains metadata-only; capability semantics and typed\n registration belong to the owning domain.\n- `curator` owns the curator engine family: long-running agent loops that\n reason over memory and perform maintenance tasks on a declared shape\n (check-in interval, tool set, attached memory engine). See epic\n archie-core-yp9.\n- `mapping` owns the payload field-mapping vocabulary: binding named fields to\n JSON paths inside a captured webhook payload, and detecting drift. See\n `docs/prds/payload-field-mapping.md`.\n- `scheduling` owns the ticker engine: deciding when a scheduled job runs and\n with what concurrency. It declares `JobSource`/`Runner` contracts and owns\n no storage or delivery. See epic archie-core-1786637496320-249-be6d9a20.\n\n**Reconciliation (2026-08-31):** `curator`, `mapping`, and `scheduling` existed\nin the tree without being added to this list when their epics landed. They are\nconfirmed as legitimate, narrowly-scoped domains under the same rules as the\noriginal six — each owns one capability family, declares typed contracts, and\nhas no cross-domain reach. This list was out of date, not the tree.\n\nConversely, `identity`, `agent`, `messaging`, and `plugin` are approved target\ndomains that do not yet exist as packages. Their behaviour currently lives in\npre-migration packages (see \"Complete package destination map\" below for the\nfull inventory). Do **not** create empty stub packages for them ahead of an\nactual migration PR — an unused stub is dead code and gives no test coverage.\nEach materialises when its corresponding migration decision below is resolved\nand implemented in the same change.\n\nMemory's final package placement remains undecided pending focused review of the\nexisting implementation.\n\nThe following are approved shared or composition packages, not domains:\n\n```text\ninternal/eventbus/\ninternal/policy/\ninternal/infrastructure/\ninternal/app/archied/\ninternal/app/agentworker/\n```\n\n## Remaining migration decisions\n\n### 1. Complete package destination map\n\nEvery current package MUST receive one explicit disposition:\n\n- move into a confirmed domain;\n- move under infrastructure as an implementation of a domain-owned contract;\n- move into application composition;\n- merge with an identified duplicate;\n- remain as an approved shared application contract;\n- move to a plugin, extra, deployment, example, or generated artifact;\n- be deleted after its replacement is proven.\n\nThe largest unreviewed areas include memory, tools and capabilities, workspace\nand worktree behaviour, gates, storage, events, web UI, containers, RPC\npackages, release management, and scheduling.\n\nThe destination matrix MUST name the behaviour owner, target path, dependencies\nto remove, state and contracts to preserve, migration prerequisites, and\ndeletion criteria.\n\n**`internal/webui` / UI Service — RATIFIED Phase 3 disposition (2026-09-07).**\nThe current owner is the in-process HTTP/SSE dashboard: SPA hosting, operator\nauthLine truncated
"body": "# Architecture Migration Decisions\n\n**Status:** Active migration inventory \n**Date:** 2026-07-28 \n**Tracking issue:** [#73](https://github.com/samcharles93/archie-core/issues/73)\n\n## Purpose\n\nThis document records what remains to be decided before Archie's current\nimplementation can be migrated into the approved domain-oriented structure.\n\nThe product and core domain model are not being redesigned. Existing Archie\nbehaviour and the existing session implementation are the migration\nbaseline. Remaining decisions MUST be grounded in current packages, consumers,\ntests, persistence, and runtime wiring.\n\n## Confirmed domain packages\n\n```text\ninternal/domain/\n identity/ (approved, not yet materialised as a package)\n agent/ (approved, not yet materialised as a package)\n workflow/\n messaging/ (canonical Message/Conversation types only; gateway migration pending, see section 2)\n workintake/\n plugin/ (approved, not yet materialised as a package)\n curator/\n mapping/\n scheduling/\n```\n\n- `identity` owns persistent actors, lifecycle, ownership, attribution, and\n audit identity.\n- `agent` owns persistent assistants, specialisation, instructions,\n model-independent continuity, capability context, and associations with\n identity and memory.\n- `workflow` is a separate domain. It owns reusable, versioned Workflow\n definitions, WorkflowSteps, WorkflowExecutions, StepExecutions, Attempts,\n outcomes, and typed Workflow plugin contracts.\n- `messaging` owns canonical Messages, Conversations, branches, channel and\n source correlation, replies, acknowledgements, delivery attempts, events, and\n projections.\n- `workintake` owns admission, validation, deterministic routing, and accepted\n work requests for the optional transition into durable workflow-backed\n execution.\n- `plugin` owns generic plugin identity, discovery, compatibility, and lifecycle\n mechanics. It remains metadata-only; capability semantics and typed\n registration belong to the owning domain.\n- `curator` owns the curator engine family: long-running agent loops that\n reason over memory and perform maintenance tasks on a declared shape\n (check-in interval, tool set, attached memory engine). See epic\n archie-core-yp9.\n- `mapping` owns the payload field-mapping vocabulary: binding named fields to\n JSON paths inside a captured webhook payload, and detecting drift. See\n `docs/prds/payload-field-mapping.md`.\n- `scheduling` owns the ticker engine: deciding when a scheduled job runs and\n with what concurrency. It declares `JobSource`/`Runner` contracts and owns\n no storage or delivery. See epic archie-core-1786637496320-249-be6d9a20.\n\n**Reconciliation (2026-08-31):** `curator`, `mapping`, and `scheduling` existed\nin the tree without being added to this list when their epics landed. They are\nconfirmed as legitimate, narrowly-scoped domains under the same rules as the\noriginal six — each owns one capability family, declares typed contracts, and\nhas no cross-domain reach. This list was out of date, not the tree.\n\nConversely, `identity`, `agent`, `messaging`, and `plugin` are approved target\ndomains that do not yet exist as packages. Their behaviour currently lives in\npre-migration packages (see \"Complete package destination map\" below for the\nfull inventory). Do **not** create empty stub packages for them ahead of an\nactual migration PR — an unused stub is dead code and gives no test coverage.\nEach materialises when its corresponding migration decision below is resolved\nand implemented in the same change.\n\nMemory's final package placement remains undecided pending focused review of the\nexisting implementation.\n\nThe following are approved shared or composition packages, not domains:\n\n```text\ninternal/eventbus/\ninternal/policy/\ninternal/infrastructure/\ninternal/app/archied/\ninternal/app/agentworker/\n```\n\n## Remaining migration decisions\n\n### 1. Complete package destination map\n\nEvery current package MUST receive one explicit disposition:\n\n- move into a confirmed domain;\n- move under infrastructure as an implementation of a domain-owned contract;\n- move into application composition;\n- merge with an identified duplicate;\n- remain as an approved shared application contract;\n- move to a plugin, extra, deployment, example, or generated artifact;\n- be deleted after its replacement is proven.\n\nThe largest unreviewed areas include memory, tools and capabilities, workspace\nand worktree behaviour, gates, storage, events, web UI, containers, RPC\npackages, release management, and scheduling.\n\nThe destination matrix MUST name the behaviour owner, target path, dependencies\nto remove, state and contracts to preserve, migration prerequisites, and\ndeletion criteria.\n\n**`internal/webui` / UI Service — RATIFIED Phase 3 disposition (2026-09-07).**\nThe current owner is the in-process HTTP/SSE dashboard: SPA hosting, operator\nauthLine truncated
},
{
"url": "/dev/architecture/observability/",
@@ -8,6 +8,7 @@ import (
"path/filepath"
"time"
"github.com/samcharles93/archie-core/internal/buildinfo"
"github.com/samcharles93/archie-core/internal/channels/telegram"
"github.com/samcharles93/archie-core/internal/domain/messaging"
"github.com/samcharles93/archie-core/internal/installtype"
@@ -17,13 +18,15 @@ import (
// configureTelegram wires the operator seams telegram.Gateway leaves to its
// composition root. Which process may satisfy each one is settled in
// docs/architecture/migration-decisions.md ("Telegram operator surface after
// extraction"); notably RunningVersions, ReleaseAnnouncements and Dangerous
// stay nil deliberately, because nothing this process can observe would make
// them true.
// extraction"); notably ReleaseAnnouncements and Dangerous stay nil, because
// nothing this process can observe would make them true. RunningVersions is
// supplied here from this process's own build stamp; see
// messagingRunningVersions.
func configureTelegram(ctx context.Context, g *telegram.Gateway, cfg ResolvedConfig, chat messaging.ChatContract, log *slog.Logger) {
g.Version = gatewayVersionReporter(ctx, chat, cfg.Options.DependencyTimeout)
g.SetShowToolCalls(cfg.ShowToolCalls)
g.Reload = telegramReloader(cfg.Options, log)
g.RunningVersions = messagingRunningVersions
if updates := updateService(cfg); updates != nil {
g.Updates = updates
@@ -33,6 +36,28 @@ func configureTelegram(ctx context.Context, g *telegram.Gateway, cfg ResolvedCon
}
}
// messagingRunningVersions reports the component versions this process can
// vouch for, for checking a relayed update report against
// (releaseupdate.Report.Verify).
//
// archie-messaging is one of the processes in the archied release set (the
// installer's GATEWAY_SERVICES), built from the same archied/v* tag and stamped
// with buildinfo.Version by every build site (install.sh, the updater, the
// release workflow and Taskfile). Its own compiled-in build is therefore
// evidence that the release the installer claims actually reached this host: a
// binary the update did not replace still reports the version it was built
// from, which Verify reads as drift rather than false success. Reading the
// version from the Gateway instead would report a different process's stamp,
// which is the failure mode the check exists to catch (see
// docs/architecture/migration-decisions.md).
//
// The agent is deliberately absent: every archie-agent process is task-scoped
// and observed only through daemon.AgentStatus, which this process does not
// hold, so it must report Unverified rather than be guessed.
func messagingRunningVersions() map[string]string {
return map[string]string{releaseupdate.ComponentDaemon: buildinfo.Version}
}
// gatewayVersionReporter renders /version from the Gateway's own build block.
// It is read per call rather than captured at compose so an upgraded Gateway
// is reported without restarting this process, and bounded by the same
@@ -8,9 +8,11 @@ import (
"strings"
"testing"
"github.com/samcharles93/archie-core/internal/buildinfo"
"github.com/samcharles93/archie-core/internal/channels/telegram"
"github.com/samcharles93/archie-core/internal/config"
"github.com/samcharles93/archie-core/internal/domain/messaging"
"github.com/samcharles93/archie-core/internal/releaseupdate"
)
type versionChatContract struct {
@@ -84,17 +86,32 @@ func TestTelegramVersionReportsAnUnreachableGateway(t *testing.T) {
}
}
// TestTelegramRunningVersionsStaysUnwired pins the decision recorded in
// docs/architecture/migration-decisions.md: RunningVersions turns an
// installer's claim into a checked one, and only a component's own compiled-in
// build can vouch for itself. This process knows neither archied's build nor
// the observed archie-agent version, so reporting anything here would
// manufacture the false success the check exists to catch.
func TestTelegramRunningVersionsStaysUnwired(t *testing.T) {
// TestTelegramRunningVersionsReportsTheMessagingBuild pins that the Messaging
// Service vouches for the daemon component from its own compiled-in release
// stamp. Every host binary in the archied release set -- archie-messaging
// included -- is built from the same archied/v* tag and stamped with
// buildinfo.Version by every build site (install.sh, the updater, the release
// workflow and Taskfile), so this process's own build is evidence that the
// release actually reached the host, and an old binary still running reports
// the old version as drift. Reading it from the Gateway instead would be a
// different process's stamp, which is the false success the check exists to
// catch.
//
// It reports nothing for the agent: every archie-agent process is task-scoped
// and observed only through daemon.AgentStatus, which this process does not
// hold. Leaving it out makes it Unverified rather than guessed.
func TestTelegramRunningVersionsReportsTheMessagingBuild(t *testing.T) {
gateway := telegramConfig(t, ResolvedConfig{}, &versionChatContract{})
if gateway.RunningVersions != nil {
t.Fatal("telegram RunningVersions is wired; update reports must stay unverified claims")
if gateway.RunningVersions == nil {
t.Fatal("telegram RunningVersions = nil, want the Messaging Service's own release stamp")
}
running := gateway.RunningVersions()
if got := running[releaseupdate.ComponentDaemon]; got != buildinfo.Version {
t.Fatalf("running[%q] = %q, want buildinfo.Version = %q", releaseupdate.ComponentDaemon, got, buildinfo.Version)
}
if _, ok := running[releaseupdate.ComponentAgent]; ok {
t.Fatalf("running vouches for %q, which this process cannot observe: %#v", releaseupdate.ComponentAgent, running)
}
if gateway.Dangerous != nil {
t.Fatal("telegram Dangerous is wired; no composition has ever supplied a command authority")
+71
View File
@@ -140,6 +140,77 @@ func TestReportPendingUpdateSendsAndClearsReport(t *testing.T) {
}
}
// TestReportPendingUpdateVerifiesAgainstRunningVersions drives the acceptance
// both ways through the real relay: a wired RunningVersions must reach the
// message the operator reads, confirming a claim this process can vouch for and
// contradicting one it cannot. Without the wiring the same report relays as
// "I still can't confirm which version" on every success, which is the bug this
// covers.
func TestReportPendingUpdateVerifiesAgainstRunningVersions(t *testing.T) {
const (
daemon = releaseupdate.ComponentDaemon
previous = "1.0.0"
installed = "1.2.3"
)
tests := []struct {
name string
installed string
wantText []string
denyText []string
}{
{
name: "confirmed when the running version matches the claim",
installed: installed,
wantText: []string{"update complete"},
denyText: []string{"can't confirm", "did not take effect"},
},
{
name: "contradicted when the running version differs from the claim",
installed: "9.9.9",
wantText: []string{"did not take effect", installed},
denyText: []string{"update complete", "can't confirm"},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
path := filepath.Join(t.TempDir(), "update-report.json")
report := releaseupdate.Report{
Channel: "telegram", ChatID: 7, ThreadID: 3,
Previous: map[string]string{daemon: previous},
Installed: map[string]string{daemon: test.installed},
HealthCheck: "passed",
}
if err := releaseupdate.WritePendingReport(path, report); err != nil {
t.Fatal(err)
}
g := New("1:test", []int64{42}, slog.Default())
g.UpdateReportPath = path
g.RunningVersions = func() map[string]string { return map[string]string{daemon: installed} }
b, requests := newTelegramTestBot(t)
g.reportPendingUpdate(context.Background(), b)
if len(*requests) != 1 {
t.Fatalf("requests = %#v, want exactly one", *requests)
}
// sendMessage delivers a rich message first, so the operator text is
// the rich_message body (or the plain text field on a fallback).
text := strings.ToLower((*requests)[0].form["rich_message"] + " " + (*requests)[0].form["text"])
for _, want := range test.wantText {
if !strings.Contains(text, want) {
t.Errorf("message = %q, want it to contain %q", text, want)
}
}
for _, deny := range test.denyText {
if strings.Contains(text, deny) {
t.Errorf("message = %q, want it NOT to contain %q", text, deny)
}
}
})
}
}
// TestReportPendingUpdateClearsUnreadableReport: a corrupt report file
// (partial write, disk issue, a future format the running binary doesn't
// understand) must not jam forever -- without clearing it, every future