feat(releaseupdate): enrich components with install type and reference
Component.Installed/Available come from an operator-owned external check command, which reports what version exists but has no way to know how THIS process/deployment actually installed it -- native binary, container, or embedded process. Two sources for that already exist and were previously unused for this: internal/installtype (this process's own build-time stamp) and daemon.AgentStatus (an archie-agent version observed at runtime, landed in the prior commit). Add Component.InstallType/Reference and a Service.Enrich hook that fills them in per component ID after the check command runs, without overwriting whatever a check command already reported for an ID it doesn't recognise. Wire the actual sources in cmd/archied via componentInstallTypeEnricher: the daemon's own installtype.Type(), the agent's most recently observed install type, and -- for NATS, a third-party dependency this repo doesn't build -- "embedded" or "external" (with its URL) read straight from [nats] configuration, which is already the deployment profile's own record of how NATS is run. This is wired into the single Service construction shared by Telegram and the dashboard, so both surfaces get it for free. Part 2/3 of archie-core-1786751948782-3-837a8fd0 point 4. Closes archie-core-1786751948782-3-837a8fd0.2.
This commit is contained in:
1 parent
ed33ab5380
commit
de23e0b1c0
6 files changed
+217
-2
No files matched your search
+2
-2
@@ -59,9 +59,9 @@
|
||||
{"_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.","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-14T15:07:36Z","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-1786751948782-3-837a8fd0.2","title":"Add InstallType/Reference fields to releaseupdate.Component, populate from daemon/agent/deployment profile","description":"Part 2/3 of point 4 in archie-core-1786751948782-3-837a8fd0's design. releaseupdate.Component (internal/releaseupdate/service.go:35-41) has ID/Label/Installed/Available/Changelog but no InstallType or Reference fields. Add both, and populate: archied reads its own compiled-in installtype.Type(); archie-agent reports its own over the NATS status round-trip (depends on the sibling issue that adds that round-trip); third-party dependencies Archie doesn't build (e.g. NATS) can't self-report, so their InstallType/Reference should come from the deployment profile (deployments/*.toml) rather than detection -- add the relevant fields there. Reference is something like 'container' + 'ghcr.io/samcharles93/archie-agent:1.9.0@sha256:...', not just a bare install-type string.","status":"open","priority":2,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-08-23T13:06:16Z","created_by":"Sam Catlow","updated_at":"2026-08-23T13:06:16Z","labels":["enhancement","webui"],"dependencies":[{"issue_id":"archie-core-1786751948782-3-837a8fd0.2","depends_on_id":"archie-core-1786751948782-3-837a8fd0.1","type":"blocks","created_at":"2026-08-23T23:06:19Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-1786751948782-3-837a8fd0.2","depends_on_id":"archie-core-1786751948782-3-837a8fd0","type":"parent-child","created_at":"2026-08-23T23:06:15Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":1,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-1786751948782-3-837a8fd0.2","title":"Add InstallType/Reference fields to releaseupdate.Component, populate from daemon/agent/deployment profile","description":"Part 2/3 of point 4 in archie-core-1786751948782-3-837a8fd0's design. releaseupdate.Component (internal/releaseupdate/service.go:35-41) has ID/Label/Installed/Available/Changelog but no InstallType or Reference fields. Add both, and populate: archied reads its own compiled-in installtype.Type(); archie-agent reports its own over the NATS status round-trip (depends on the sibling issue that adds that round-trip); third-party dependencies Archie doesn't build (e.g. NATS) can't self-report, so their InstallType/Reference should come from the deployment profile (deployments/*.toml) rather than detection -- add the relevant fields there. Reference is something like 'container' + 'ghcr.io/samcharles93/archie-agent:1.9.0@sha256:...', not just a bare install-type string.","status":"in_progress","priority":2,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-23T13:06:16Z","created_by":"Sam Catlow","updated_at":"2026-08-23T13:22:37Z","started_at":"2026-08-23T13:22:37Z","labels":["enhancement","webui"],"dependencies":[{"issue_id":"archie-core-1786751948782-3-837a8fd0.2","depends_on_id":"archie-core-1786751948782-3-837a8fd0.1","type":"blocks","created_at":"2026-08-23T23:06:19Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-1786751948782-3-837a8fd0.2","depends_on_id":"archie-core-1786751948782-3-837a8fd0","type":"parent-child","created_at":"2026-08-23T23:06:15Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":1,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-1786751948782-3-837a8fd0.3","title":"Surface per-component update status on Configuration page and /version","description":"Part 3/3, point 5 of archie-core-1786751948782-3-837a8fd0's design. Depends on the InstallType/Reference issue landing first -- there's nothing to surface otherwise. Add a /version endpoint and a per-component block on the Configuration page (internal/webui/api_config.go, ui/src/settings/), structured as {install_type, running_version, reference, latest_available, status} per component, where status is an enum (ok / update_available / drift / unknown) rather than a bare color. The actual comparison basis (e.g. running digest vs latest digest) should be visible on hover/expand, modeled on docker version's Client/Server nested-block convention per the original design doc.","status":"open","priority":2,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-08-23T13:06:16Z","created_by":"Sam Catlow","updated_at":"2026-08-23T13:06:16Z","labels":["enhancement","webui"],"dependencies":[{"issue_id":"archie-core-1786751948782-3-837a8fd0.3","depends_on_id":"archie-core-1786751948782-3-837a8fd0","type":"parent-child","created_at":"2026-08-23T23:06:16Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-1786751948782-3-837a8fd0.3","depends_on_id":"archie-core-1786751948782-3-837a8fd0.2","type":"blocks","created_at":"2026-08-23T23:06:20Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-1786751948782-3-837a8fd0.1","title":"Stamp archie-agent's install type and add NATS status round-trip","description":"Part 1/3 of point 4 in archie-core-1786751948782-3-837a8fd0's design. archied's own build is stamped with internal/installtype via -ldflags (Taskfile.yml:65, Dockerfile.archied:48-49), but archie-agent's build has no equivalent stamp -- Dockerfile:14 and Taskfile.yml:170 (agent build target) pass no -X installtype flag. Without it, an agent worker has nothing to self-report even once the daemon asks. Also add the NATS-side status/version request the daemon can send a running agentworker to get its install type + running version back (agentworker already has a NATS channel for logs; extend it for a status response rather than inventing a new transport). This is the prerequisite for archie-core-1786751948782-3-837a8fd0 point 4's 'archie-agent reports its own the same way' clause.","status":"in_progress","priority":2,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-23T13:06:14Z","created_by":"Sam Catlow","updated_at":"2026-08-23T13:06:41Z","started_at":"2026-08-23T13:06:41Z","labels":["enhancement","webui"],"dependencies":[{"issue_id":"archie-core-1786751948782-3-837a8fd0.1","depends_on_id":"archie-core-1786751948782-3-837a8fd0","type":"parent-child","created_at":"2026-08-23T23:06:14Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":1,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-1786751948782-3-837a8fd0.1","title":"Stamp archie-agent's install type and add NATS status round-trip","description":"Part 1/3 of point 4 in archie-core-1786751948782-3-837a8fd0's design. archied's own build is stamped with internal/installtype via -ldflags (Taskfile.yml:65, Dockerfile.archied:48-49), but archie-agent's build has no equivalent stamp -- Dockerfile:14 and Taskfile.yml:170 (agent build target) pass no -X installtype flag. Without it, an agent worker has nothing to self-report even once the daemon asks. Also add the NATS-side status/version request the daemon can send a running agentworker to get its install type + running version back (agentworker already has a NATS channel for logs; extend it for a status response rather than inventing a new transport). This is the prerequisite for archie-core-1786751948782-3-837a8fd0 point 4's 'archie-agent reports its own the same way' clause.","status":"closed","priority":2,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-23T13:06:14Z","created_by":"Sam Catlow","updated_at":"2026-08-23T13:18:03Z","started_at":"2026-08-23T13:06:41Z","closed_at":"2026-08-23T13:18:03Z","close_reason":"Fixed: archie-agent's build is now stamped (installtype + agentworker.Version), and it reports both back to the daemon in every taskrun.Response. daemon.AgentStatus records the latest observation; daemonRunningVersions includes the agent component once one lands. Adversarial review clean (one nice-to-have comment added).","labels":["enhancement","webui"],"dependencies":[{"issue_id":"archie-core-1786751948782-3-837a8fd0.1","depends_on_id":"archie-core-1786751948782-3-837a8fd0","type":"parent-child","created_at":"2026-08-23T23:06:14Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":1,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-w35v","title":"Workflows page 'Start work' form inputs unstyled (white boxes in dark theme)","description":"The Start work card on the Workflows dashboard page (ui/src/workflows/workflows.js renderStartWork) creates raw \u003cinput\u003e/\u003cselect\u003e/\u003ctextarea\u003e elements with no CSS class, so they fall back to browser default styling -- white background, black text -- against the rest of the dark-themed app. Every other form control in the app (e.g. Configuration's .kv-input in ui/src/settings/config-row.js) uses a themed class. Fix: style these form controls to match the app theme, either by reusing an existing input class or adding scoped rules in ui/src/workflows/workflows.css.","status":"closed","priority":2,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-08-23T12:22:59Z","created_by":"Sam Catlow","updated_at":"2026-08-23T12:53:38Z","closed_at":"2026-08-23T12:23:14Z","close_reason":"Fixed: themed .wf-form input/select/textarea in workflows.css to match the dark theme.","external_ref":"https://github.com/samcharles93/archie-core/issues/593","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-1787489597262-23-f61d8b1b","title":"Docs: promote the shipped review stage into docs/architecture and reconcile CLAUDE.md","description":"Under the scope-discipline rule merged as PR #533, a design is promoted into docs/architecture/ only once it is built and true. This is that promotion, and it is deliberately a separate bead so it is not lost when the feature lands and attention moves on.\n\nDo three things once the stage ships:\n\n1. Promote the docs/prds/ decision into docs/architecture/, describing the review stage as it actually works -- not as designed. Cut anything a reader could learn from the code.\n2. Update ARCHITECTURE.md's task lifecycle: queued -\u003e running(workflow:stage) -\u003e pr_open -\u003e merged|rejected gains a review stage that can divert to waiting_human before pr_open. The current text does not mention it.\n3. Reconcile CLAUDE.md's Development Protocol. It currently tells a human or agent contributor to run the adversarial pass by hand. Once archied does this for the PRs it opens, that section needs to say which path applies to whom, or it will read as describing a manual step that is now automatic.\n\nCLAUDE.md's own rule: a comment or doc that contradicts its code is worse than none, because the next reader trusts it.","status":"open","priority":2,"issue_type":"task","created_at":"2026-08-23T12:22:29Z","updated_at":"2026-08-23T12:22:29Z","external_ref":"https://github.com/samcharles93/archie-core/issues/586","source_system":"github:https://github.com/samcharles93/archie-core/issues/586:586","metadata":null,"dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-1787489597173-22-c7110160","title":"Surface findings on the PR body and the dashboard","description":"The output has to land where the operator already looks, or the review is invisible work.\n\nOn the PR archie opens: a findings section stating what was checked, what was found, what was fixed, and what survived. A PR with zero findings should say the review ran and found nothing -- silence is indistinguishable from the review not running, which is the same unverified-claim problem the update-verification work (PR #530) was about.\n\nOn the dashboard and /api/tasks: a parked-for-findings task must show why, the same way a park reason is already surfaced today. An operator seeing waiting_human needs the findings without digging through logs.","status":"open","priority":2,"issue_type":"feature","created_at":"2026-08-23T12:22:28Z","updated_at":"2026-08-23T12:22:28Z","external_ref":"https://github.com/samcharles93/archie-core/issues/585","source_system":"github:https://github.com/samcharles93/archie-core/issues/585:585","metadata":null,"dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
|
||||
@@ -157,6 +157,40 @@ func daemonRunningVersions(agentStatus *daemon.AgentStatus) map[string]string {
|
||||
return versions
|
||||
}
|
||||
|
||||
// componentInstallTypeEnricher builds Service.Enrich: it knows how to
|
||||
// describe the three component kinds this daemon can say anything true
|
||||
// about. Anything else (a check command reporting a component ID this
|
||||
// process has no source for) is left alone -- an empty return leaves
|
||||
// whatever the check command itself set.
|
||||
func componentInstallTypeEnricher(agentStatus *daemon.AgentStatus, nats config.NATSConfig) func(string) (string, string) {
|
||||
return func(componentID string) (installType, reference string) {
|
||||
switch componentID {
|
||||
case releaseupdate.ComponentDaemon:
|
||||
return installtype.Type(), ""
|
||||
case releaseupdate.ComponentAgent:
|
||||
if agentStatus == nil {
|
||||
return "", ""
|
||||
}
|
||||
_, observedInstallType, ok := agentStatus.Snapshot()
|
||||
if !ok {
|
||||
return "", ""
|
||||
}
|
||||
return observedInstallType, ""
|
||||
case releaseupdate.ComponentNATS:
|
||||
switch nats.Mode {
|
||||
case config.NATSModeEmbedded:
|
||||
return config.NATSModeEmbedded, ""
|
||||
case config.NATSModeExternal:
|
||||
return config.NATSModeExternal, nats.URL
|
||||
default:
|
||||
return "", ""
|
||||
}
|
||||
default:
|
||||
return "", ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func configureTelegramUpdates(tg *telegram.Gateway, s telegramSetup) {
|
||||
if updates := makeUpdateService(s); updates != nil {
|
||||
tg.Updates = updates
|
||||
@@ -172,6 +206,7 @@ func makeUpdateService(s telegramSetup) *releaseupdate.Service {
|
||||
Catalog: releaseupdate.CommandCatalog{Command: cfg.Chat.Telegram.UpdateCheckCommand},
|
||||
StatePath: filepath.Join(cfg.WorkDir, "telegram-update-deferrals.json"),
|
||||
InstallType: installtype.Type(),
|
||||
Enrich: componentInstallTypeEnricher(s.AgentStatus, cfg.NATS),
|
||||
}
|
||||
if len(cfg.Chat.Telegram.UpdateInstallCommand) != 0 {
|
||||
updates.Installer = releaseupdate.CommandInstaller{Command: cfg.Chat.Telegram.UpdateInstallCommand}
|
||||
|
||||
@@ -27,6 +27,80 @@ func TestMakeUpdateServiceWiresInstallType(t *testing.T) {
|
||||
if service.InstallType != installtype.Type() {
|
||||
t.Errorf("Service.InstallType = %q, want installtype.Type() = %q", service.InstallType, installtype.Type())
|
||||
}
|
||||
if service.Enrich == nil {
|
||||
t.Fatal("Service.Enrich is nil; component InstallType/Reference will never be populated")
|
||||
}
|
||||
}
|
||||
|
||||
func TestComponentInstallTypeEnricherDaemon(t *testing.T) {
|
||||
enrich := componentInstallTypeEnricher(nil, config.NATSConfig{})
|
||||
|
||||
gotType, gotRef := enrich(releaseupdate.ComponentDaemon)
|
||||
if gotType != installtype.Type() || gotRef != "" {
|
||||
t.Errorf("daemon = (%q, %q), want (%q, \"\")", gotType, gotRef, installtype.Type())
|
||||
}
|
||||
}
|
||||
|
||||
func TestComponentInstallTypeEnricherAgentBeforeAnyObservation(t *testing.T) {
|
||||
var status daemon.AgentStatus
|
||||
enrich := componentInstallTypeEnricher(&status, config.NATSConfig{})
|
||||
|
||||
gotType, gotRef := enrich(releaseupdate.ComponentAgent)
|
||||
if gotType != "" || gotRef != "" {
|
||||
t.Errorf("agent before any Observe = (%q, %q), want (\"\", \"\")", gotType, gotRef)
|
||||
}
|
||||
}
|
||||
|
||||
func TestComponentInstallTypeEnricherAgentAfterObservation(t *testing.T) {
|
||||
var status daemon.AgentStatus
|
||||
status.Observe("1.9.11", "container")
|
||||
enrich := componentInstallTypeEnricher(&status, config.NATSConfig{})
|
||||
|
||||
gotType, _ := enrich(releaseupdate.ComponentAgent)
|
||||
if gotType != "container" {
|
||||
t.Errorf("agent InstallType = %q, want the observed install type %q", gotType, "container")
|
||||
}
|
||||
}
|
||||
|
||||
func TestComponentInstallTypeEnricherAgentNilStatus(t *testing.T) {
|
||||
enrich := componentInstallTypeEnricher(nil, config.NATSConfig{})
|
||||
|
||||
gotType, gotRef := enrich(releaseupdate.ComponentAgent)
|
||||
if gotType != "" || gotRef != "" {
|
||||
t.Errorf("agent with nil AgentStatus = (%q, %q), want (\"\", \"\")", gotType, gotRef)
|
||||
}
|
||||
}
|
||||
|
||||
func TestComponentInstallTypeEnricherNATS(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
nats config.NATSConfig
|
||||
wantType string
|
||||
wantRef string
|
||||
}{
|
||||
{name: "embedded", nats: config.NATSConfig{Mode: "embedded"}, wantType: "embedded", wantRef: ""},
|
||||
{name: "external", nats: config.NATSConfig{Mode: "external", URL: "nats://nats.internal:4222"}, wantType: "external", wantRef: "nats://nats.internal:4222"},
|
||||
{name: "off", nats: config.NATSConfig{Mode: "off"}, wantType: "", wantRef: ""},
|
||||
{name: "unset", nats: config.NATSConfig{}, wantType: "", wantRef: ""},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
enrich := componentInstallTypeEnricher(nil, test.nats)
|
||||
gotType, gotRef := enrich(releaseupdate.ComponentNATS)
|
||||
if gotType != test.wantType || gotRef != test.wantRef {
|
||||
t.Errorf("nats(%+v) = (%q, %q), want (%q, %q)", test.nats, gotType, gotRef, test.wantType, test.wantRef)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestComponentInstallTypeEnricherUnknownComponent(t *testing.T) {
|
||||
enrich := componentInstallTypeEnricher(nil, config.NATSConfig{})
|
||||
|
||||
gotType, gotRef := enrich("something-else")
|
||||
if gotType != "" || gotRef != "" {
|
||||
t.Errorf("unknown component = (%q, %q), want (\"\", \"\")", gotType, gotRef)
|
||||
}
|
||||
}
|
||||
|
||||
// TestDaemonRunningVersionsVouchesOnlyForItselfWithoutAgentStatus: the point
|
||||
|
||||
@@ -38,6 +38,17 @@ type Component struct {
|
||||
Installed string
|
||||
Available string
|
||||
Changelog string
|
||||
// InstallType and Reference describe how this component is actually
|
||||
// deployed -- "binary"/"container"/"embedded"/"external", and a
|
||||
// deployment-specific pointer such as an image digest or a NATS URL.
|
||||
// The external check command that populates Installed/Available cannot
|
||||
// know either of these: it reports what version exists, not how this
|
||||
// particular instance was installed. See Service.Enrich, which fills
|
||||
// them in from sources that actually know (this process's own build
|
||||
// stamp, an observed archie-agent version, deployment configuration for
|
||||
// a third-party dependency this repo doesn't build).
|
||||
InstallType string
|
||||
Reference string
|
||||
}
|
||||
|
||||
type Snapshot struct {
|
||||
@@ -91,6 +102,18 @@ type Service struct {
|
||||
// process-wide state.
|
||||
InstallType string
|
||||
|
||||
// Enrich supplies InstallType/Reference for a known component ID (see
|
||||
// ComponentDaemon, ComponentAgent, ComponentNATS), using sources the
|
||||
// external check command has no way to know -- this process's own
|
||||
// compiled-in installtype.Type(), an archie-agent version actually
|
||||
// observed at runtime (daemon.AgentStatus), or deployment configuration
|
||||
// for a third-party dependency archie doesn't build. Optional: nil (or
|
||||
// a component ID Enrich doesn't recognise, or an empty installType
|
||||
// return) leaves whatever the check command itself reported untouched,
|
||||
// so a check command that DOES report its own value is never silently
|
||||
// overwritten.
|
||||
Enrich func(componentID string) (installType, reference string)
|
||||
|
||||
mu sync.Mutex
|
||||
installing bool
|
||||
}
|
||||
@@ -103,6 +126,15 @@ func (s *Service) Check(ctx context.Context, recipient int64) (Snapshot, error)
|
||||
if err != nil {
|
||||
return Snapshot{}, fmt.Errorf("check for updates: %w", err)
|
||||
}
|
||||
if s.Enrich != nil {
|
||||
for index := range snapshot.Components {
|
||||
component := &snapshot.Components[index]
|
||||
if installType, reference := s.Enrich(component.ID); installType != "" {
|
||||
component.InstallType = installType
|
||||
component.Reference = reference
|
||||
}
|
||||
}
|
||||
}
|
||||
if s.StatePath == "" {
|
||||
return snapshot, nil
|
||||
}
|
||||
|
||||
@@ -50,6 +50,74 @@ func TestServiceDefersOnlyTheVersionsShownToThatRecipient(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestServiceCheckEnrichesInstallTypeAndReference is the regression proof
|
||||
// for archie-core-1786751948782-3-837a8fd0 point 4: the external check
|
||||
// command reports what version exists, not how this instance was actually
|
||||
// deployed, so Service.Check must fill in InstallType/Reference from Enrich
|
||||
// rather than leaving every component's deployment shape unknown forever.
|
||||
func TestServiceCheckEnrichesInstallTypeAndReference(t *testing.T) {
|
||||
catalog := &catalogStub{snapshot: Snapshot{Components: []Component{
|
||||
{ID: ComponentDaemon, Label: "Gateway", Installed: "1.0.0"},
|
||||
{ID: ComponentNATS, Label: "NATS", Installed: "n/a"},
|
||||
}}}
|
||||
service := Service{Catalog: catalog, Enrich: func(id string) (string, string) {
|
||||
switch id {
|
||||
case ComponentDaemon:
|
||||
return "binary", ""
|
||||
case ComponentNATS:
|
||||
return "external", "nats://nats.internal:4222"
|
||||
default:
|
||||
return "", ""
|
||||
}
|
||||
}}
|
||||
|
||||
snapshot, err := service.Check(context.Background(), 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := snapshot.Components[0]; got.InstallType != "binary" || got.Reference != "" {
|
||||
t.Errorf("daemon component = %+v, want InstallType=binary, Reference=\"\"", got)
|
||||
}
|
||||
if got := snapshot.Components[1]; got.InstallType != "external" || got.Reference != "nats://nats.internal:4222" {
|
||||
t.Errorf("nats component = %+v, want InstallType=external, Reference=nats://nats.internal:4222", got)
|
||||
}
|
||||
}
|
||||
|
||||
// TestServiceCheckEnrichLeavesUnrecognisedComponentsUntouched: a component
|
||||
// ID Enrich has no source for (an operator's check command reporting
|
||||
// something this process cannot describe) must not have its InstallType
|
||||
// silently set to empty over whatever, if anything, the check command
|
||||
// itself already reported.
|
||||
func TestServiceCheckEnrichLeavesUnrecognisedComponentsUntouched(t *testing.T) {
|
||||
catalog := &catalogStub{snapshot: Snapshot{Components: []Component{
|
||||
{ID: "third-party-tool", Label: "Tool", Installed: "1.0.0", InstallType: "reported-by-check-command"},
|
||||
}}}
|
||||
service := Service{Catalog: catalog, Enrich: func(string) (string, string) { return "", "" }}
|
||||
|
||||
snapshot, err := service.Check(context.Background(), 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := snapshot.Components[0].InstallType; got != "reported-by-check-command" {
|
||||
t.Errorf("InstallType = %q, want the check command's own value untouched", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceCheckWithNilEnrichLeavesComponentsUnchanged(t *testing.T) {
|
||||
catalog := &catalogStub{snapshot: Snapshot{Components: []Component{
|
||||
{ID: ComponentDaemon, Installed: "1.0.0"},
|
||||
}}}
|
||||
service := Service{Catalog: catalog}
|
||||
|
||||
snapshot, err := service.Check(context.Background(), 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := snapshot.Components[0].InstallType; got != "" {
|
||||
t.Errorf("InstallType = %q, want empty with no Enrich configured", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceInstallForwardsProgressAndFailure(t *testing.T) {
|
||||
installer := &installerStub{}
|
||||
service := Service{Installer: installer, InstallType: "binary"}
|
||||
|
||||
@@ -15,6 +15,12 @@ import (
|
||||
const (
|
||||
ComponentDaemon = "daemon"
|
||||
ComponentAgent = "agent"
|
||||
// ComponentNATS identifies the NATS server in a Snapshot's Components,
|
||||
// by the same convention -- a third-party dependency archie doesn't
|
||||
// build and Report never claims to have installed, but Service.Enrich
|
||||
// can still describe from deployment configuration (embedded vs
|
||||
// external, and the URL an external server was configured with).
|
||||
ComponentNATS = "nats"
|
||||
)
|
||||
|
||||
// Version placeholders that carry no release information. Both mean "nobody
|
||||
|
||||
Reference in new issue
Block a user