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/b5d08d0, 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.
This commit is contained in:
sam committed 2026-08-23 23:18:00 +10:00
1 parent 8809d44505
commit ed33ab5380
15 files changed
+313 -30

No files matched your search

+4 -1
View File
@@ -59,6 +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.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-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}
@@ -80,7 +83,7 @@
{"_type":"issue","id":"archie-core-h019.5","title":"Calibration: confirm findings adversarially before surfacing them","description":"The risk that kills this feature is a reviewer that cries wolf. A findings list padded with speculation trains the operator to skim past it, and then the feature is worse than nothing because it consumes attention while lowering trust.\n\nBefore a finding is surfaced, it must be independently checked and marked CONFIRMED or PLAUSIBLE, with only CONFIRMED able to block. The reviewer must also be able to return zero findings, and to state which properties it checked and cleared -- a review that reports nothing is a valid and welcome result, and saying so explicitly is what distinguishes 'I checked and it is fine' from 'I did not look'.\n\nPrior art from the 2026-08-20/21 sessions on PR #530: three passes each separated confirmed from plausible, one explicitly listed properties it had verified clean, and the confirmed findings were reproduced by mutation before being trusted. That calibration is the feature, not the finding count.","acceptance_criteria":"Only CONFIRMED findings block PR creation; a zero-finding review is representable and reported as such; the reviewer records which properties it checked and cleared; padding with style nits is explicitly out of contract.","status":"open","priority":2,"issue_type":"feature","owner":"sam@catlow.tech","created_at":"2026-08-21T13:03:15Z","created_by":"Sam Catlow","updated_at":"2026-08-22T09:25:30Z","external_ref":"https://github.com/samcharles93/archie-core/issues/555","dependencies":[{"issue_id":"archie-core-h019.5","depends_on_id":"archie-core-h019","type":"parent-child","created_at":"2026-08-21T13:03:15Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-h019.5","depends_on_id":"archie-core-h019.1","type":"blocks","created_at":"2026-08-21T13:03:25Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-h019.5","depends_on_id":"archie-core-h019.2","type":"blocks","created_at":"2026-08-21T13:03:25Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":2,"dependent_count":0,"comment_count":0}
{"_type":"issue","id":"archie-core-h019.6","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.","acceptance_criteria":"PR body carries a findings section including the zero-finding case; a task parked on a surviving finding shows the findings as its park reason in the dashboard and /api/tasks; nothing requires reading task logs to learn why a PR was withheld.","status":"open","priority":2,"issue_type":"feature","owner":"sam@catlow.tech","created_at":"2026-08-21T13:03:15Z","created_by":"Sam Catlow","updated_at":"2026-08-22T09:25:31Z","external_ref":"https://github.com/samcharles93/archie-core/issues/556","dependencies":[{"issue_id":"archie-core-h019.6","depends_on_id":"archie-core-h019","type":"parent-child","created_at":"2026-08-21T13:03:15Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-h019.6","depends_on_id":"archie-core-h019.2","type":"blocks","created_at":"2026-08-21T13:03:26Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-h019.6","depends_on_id":"archie-core-h019.1","type":"blocks","created_at":"2026-08-21T13:03:25Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":2,"dependent_count":1,"comment_count":0}
{"_type":"issue","id":"archie-core-h019.7","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.","acceptance_criteria":"docs/architecture/ describes the shipped stage; ARCHITECTURE.md's lifecycle includes the review stage and the waiting_human diversion; CLAUDE.md distinguishes the manual contributor pass from archied's automated one; no doc still claims review is only manual.","status":"open","priority":2,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-08-21T13:03:15Z","created_by":"Sam Catlow","updated_at":"2026-08-22T09:25:32Z","external_ref":"https://github.com/samcharles93/archie-core/issues/557","dependencies":[{"issue_id":"archie-core-h019.7","depends_on_id":"archie-core-h019.4","type":"blocks","created_at":"2026-08-21T13:03:26Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-h019.7","depends_on_id":"archie-core-h019.6","type":"blocks","created_at":"2026-08-21T13:03:26Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-h019.7","depends_on_id":"archie-core-h019","type":"parent-child","created_at":"2026-08-21T13:03:15Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":2,"dependent_count":0,"comment_count":0}
{"_type":"issue","id":"archie-core-nln7","title":"Dashboard-initiated updates get no phase-2 report, so they are never verified","description":"internal/webui/api_chat.go:497 starts an install with releaseupdate.InstallMeta{Channel: \"webui\"} and leaves ReportPath empty. CommandInstaller passes that through as ARCHIE_UPDATE_REPORT_PATH, and scripts/archie-update-watchdog's write_report() returns early when it is empty.\n\nConsequences: an operator who approves an update from the dashboard gets only the synchronous phase-1 result (build/install succeeded, restart queued) and never learns whether the daemon actually came back up, whether it was rolled back, or - since c25799e - whether the installed version is the one now running. Telegram gets all of that; the dashboard silently gets none of it.\n\nThe verification added in c25799e (releaseupdate.Report.Verify) is reached only from internal/channels/telegram/update.go, so this path is unverified regardless.\n\nFix needs two parts: give the webui install a ReportPath (updateReportPath in cmd/archied), and give the dashboard somewhere to relay a pending report on boot the way telegram's reportPendingUpdate does - today ReadPendingReport has exactly one caller, and a single report file shared by two relayers would race to clear it.","acceptance_criteria":"A dashboard-approved update produces a phase-2 report; the dashboard surfaces its outcome including version verification; two relayers cannot double-report or lose a report.","status":"in_progress","priority":2,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-20T14:04:33Z","created_by":"Sam Catlow","updated_at":"2026-08-23T12:56:47Z","started_at":"2026-08-23T12:56:47Z","external_ref":"https://github.com/samcharles93/archie-core/issues/531","dependency_count":0,"dependent_count":0,"comment_count":0}
{"_type":"issue","id":"archie-core-nln7","title":"Dashboard-initiated updates get no phase-2 report, so they are never verified","description":"internal/webui/api_chat.go:497 starts an install with releaseupdate.InstallMeta{Channel: \"webui\"} and leaves ReportPath empty. CommandInstaller passes that through as ARCHIE_UPDATE_REPORT_PATH, and scripts/archie-update-watchdog's write_report() returns early when it is empty.\n\nConsequences: an operator who approves an update from the dashboard gets only the synchronous phase-1 result (build/install succeeded, restart queued) and never learns whether the daemon actually came back up, whether it was rolled back, or - since c25799e - whether the installed version is the one now running. Telegram gets all of that; the dashboard silently gets none of it.\n\nThe verification added in c25799e (releaseupdate.Report.Verify) is reached only from internal/channels/telegram/update.go, so this path is unverified regardless.\n\nFix needs two parts: give the webui install a ReportPath (updateReportPath in cmd/archied), and give the dashboard somewhere to relay a pending report on boot the way telegram's reportPendingUpdate does - today ReadPendingReport has exactly one caller, and a single report file shared by two relayers would race to clear it.","acceptance_criteria":"A dashboard-approved update produces a phase-2 report; the dashboard surfaces its outcome including version verification; two relayers cannot double-report or lose a report.","status":"closed","priority":2,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-20T14:04:33Z","created_by":"Sam Catlow","updated_at":"2026-08-23T12:58:07Z","started_at":"2026-08-23T12:56:47Z","closed_at":"2026-08-23T12:58:07Z","close_reason":"Fixed: dashboard installs now get a ReportPath, and Server.Run relays/verifies/clears the phase-2 report on boot via a new KindUpdateReport SSE event. Adversarial review clean.","external_ref":"https://github.com/samcharles93/archie-core/issues/531","dependency_count":0,"dependent_count":0,"comment_count":0}
{"_type":"issue","id":"archie-core-qk8m","title":"MCP npm servers re-fetched from npm on every task container start","description":"## Problem\n\nd4bb914b/#64 fixed the daemon-side case: cmd/archied/main.go's\nconfiguredMCPProvider now points npx-launched MCP servers at a persistent\nNPM_CONFIG_CACHE under the daemon's own work_dir, so a daemon restart\nreuses a warm cache instead of re-resolving/re-downloading from the npm\nregistry.\n\ninternal/app/agentworker/mcp_providers.go builds the identical\nStdioTransportConfig for archie-agent's own per-task MCP servers, but was\ndeliberately left untouched -- it's not a separate code path, the exact\nsame cfg.Tools.MCPServers list (including any npx entries) is threaded\nthrough to every per-task NATS agent worker (bootstrap.go -\u003e NATSRunner.MCPServers\n-\u003e taskrun.Request -\u003e task_execution.go's startMCPProviders). Since each\ntask runs in a fresh ephemeral container, an npx-based MCP server\nconfigured for task use re-resolves/re-downloads on every task, not\njust every daemon restart -- more frequent, and thus a worse amplifier of\na registry outage than the bug already fixed.\n\n## Why this needs its own issue\n\nUnlike the daemon case, a bare NPM_CONFIG_CACHE=\u003cpath\u003e pointed at a host\ndirectory is meaningless inside an ephemeral container unless a\npersistent Docker volume is actually bind-mounted at that path. No such\nvolume currently exists for this purpose -- internal/container/pool.go's\nmounts are caller-provided, and nothing wires an npm-cache volume in.\nThat's real new infrastructure (a shared, persistent volume across\nper-task containers), not a parameter-threading fix like d4bb914b was.\n\n## Acceptance criteria\n\n- Task containers reuse a persistent npm cache across tasks, the same\n way the daemon now does across restarts.\n- The cache volume/mount is wired through internal/container/pool.go's\n Acquire (or equivalent) without weakening per-task filesystem isolation\n for anything other than the npm cache path itself.\n- Startup time for a task's npx-based MCP server no longer scales with\n package size once the cache is warm.\n","status":"open","priority":2,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-08-18T16:04:59Z","created_by":"Sam Catlow","updated_at":"2026-08-23T12:53:17Z","external_ref":"https://github.com/samcharles93/archie-core/issues/532","metadata":null,"dependency_count":0,"dependent_count":0,"comment_count":0}
{"_type":"issue","id":"archie-core-q5w4","title":"secret engine plugin: age","description":"Resolve SecretRef values from an age-encrypted file of key=value lines. Env: AGE_FILE (encrypted file path), AGE_IDENTITY (age private key file). Resolve runs 'age -d -i \u003cidentity\u003e \u003cfile\u003e' and parses the plaintext. Fresh resolve per call (no cache) so updates are picked up without daemon restart. CLI-based, mirroring the bws engine; ship as a Yaegi plugin in examples/secret-engines/.","status":"closed","priority":2,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-08-17T14:22:03Z","created_by":"Sam Catlow","updated_at":"2026-08-17T22:27:53Z","started_at":"2026-08-17T14:22:10Z","closed_at":"2026-08-17T14:33:52Z","close_reason":"Shipped age engine plugin in examples/secret-engines/age.go (commit 24faf53): CLI-based, AGE_FILE/AGE_IDENTITY, key=value lines.","external_ref":"https://github.com/samcharles93/archie-core/issues/526","metadata":null,"dependency_count":0,"dependent_count":0,"comment_count":0}
{"_type":"issue","id":"archie-core-1786749700635-7-83b8c32f","title":"dashboard: turn_completed events carry no task correlation and drown real activity in the Live Activity feed","description":"## Problem, two compounding parts\n\n**1. `turn_completed` events carry no useful, correlatable content.**\n`internal/gateway/turn.go:306-311` publishes:\n```go\nr.Bus.Publish(events.Event{\n Kind: events.KindTurnCompleted,\n Detail: sessionID,\n Data: map[string]any{\"session\": sessionID, \"channel\": r.Channel},\n})\n```\nNo `TaskID` is set, and `Detail` is a raw internal session identifier (e.g. `1312197967`) with no formatting. On the dashboard's \"Live activity\" table this renders as `Task: —`, `Detail: 1312197967` — meaningless to anyone reading it, and impossible to correlate to a task. This event fires on every chat turn, so it dominates the feed: in a sample of the 30 most-recent Live Activity rows, only 3 were real task-lifecycle events (`task_queued`); the other 27 were content-free `turn_completed` rows.\n\n**2. The `/logs` page has no filtering, search, or level control at all** — just Pause/Refresh. Confirmed live: during the redelivery storm in #517, `handle failed` alone produced 996 near-identical lines, and there is no way to filter by task, by level, or search text to find anything else in the stream. During exactly the situation an operator needs the log page most (an active incident), it is unusable.\n\n## Fix\n\n- Give `turn_completed` (and any other cross-cutting event shown in this feed) a human-meaningful `Detail` — e.g. the channel name plus a short session label — and drop it from the feed entirely if it isn't task-correlated, since a feed titled \"Live activity\" that is 90% non-actionable chat-turn noise defeats its own purpose.\n- Add basic filtering to `/logs`: at minimum a level filter and a task/session search, so a single noisy source can be excluded without losing everything else.","status":"closed","priority":2,"issue_type":"bug","created_at":"2026-08-14T23:19:11Z","updated_at":"2026-08-15T00:35:51Z","started_at":"2026-08-15T00:03:05Z","closed_at":"2026-08-15T00:35:51Z","external_ref":"https://github.com/samcharles93/archie-core/issues/521","source_system":"github:https://github.com/samcharles93/archie-core/issues/521:521","metadata":null,"labels":["bug","webui"],"dependency_count":0,"dependent_count":0,"comment_count":0}
+4 -1
View File
@@ -7,11 +7,14 @@
# ── builder ───────────────────────────────────────────────────────────
FROM golang:1.26-trixie AS builder
ARG RUNTIME_VERSION=dev
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o /usr/local/bin/archie-agent ./cmd/archie-agent/
RUN CGO_ENABLED=0 go build \
-ldflags "-X github.com/samcharles93/archie-core/internal/app/agentworker.version=${RUNTIME_VERSION} -X github.com/samcharles93/archie-core/internal/installtype.buildType=container" \
-o /usr/local/bin/archie-agent ./cmd/archie-agent/
# Same Debian release as the runtime, so glibc matches.
FROM node:24-trixie-slim AS node
+1 -1
View File
@@ -106,7 +106,7 @@ tasks:
- "{{.BIN_DIR}}/archie-agent"
cmds:
- go build -ldflags "-X main.gatewayVersion={{.GATEWAY_VERSION}} -X main.runtimeVersion={{.RUNTIME_VERSION}} -X github.com/samcharles93/archie-core/internal/installtype.buildType=binary" -o {{.BIN_DIR}}/archied ./cmd/archied
- go build -o {{.BIN_DIR}}/archie-agent ./cmd/archie-agent
- go build -ldflags "-X github.com/samcharles93/archie-core/internal/app/agentworker.version={{.RUNTIME_VERSION}} -X github.com/samcharles93/archie-core/internal/installtype.buildType=binary" -o {{.BIN_DIR}}/archie-agent ./cmd/archie-agent
test:
desc: Run the Go test suite
+13 -3
View File
@@ -131,11 +131,19 @@ type boot struct {
providerRegistry *toolprovider.Registry
d *daemon.Daemon
// agentStatus records the most recent version/install-type an
// archie-agent worker reported about itself. Allocated up front, before
// any gateway goroutine (Telegram, webui) that might read it via
// RunningVersions starts, so those closures never see a nil pointer or
// race its assignment -- only its own internal mutex guards concurrent
// Observe/Snapshot calls once tasks start completing.
agentStatus *daemon.AgentStatus
cleanups []func()
}
func newBootstrap() *boot {
return &boot{log: slog.New(slog.NewJSONHandler(os.Stderr, nil))}
return &boot{log: slog.New(slog.NewJSONHandler(os.Stderr, nil)), agentStatus: &daemon.AgentStatus{}}
}
func (b *boot) addCleanup(fn func()) {
@@ -307,7 +315,8 @@ func (b *boot) setupObservability() {
}
b.web = &webui.Server{Store: b.st, Log: log, LogFeed: b.logFeed, TaskLogs: b.taskLogs, Cfg: config.NewHolder(cfg), Channels: b.channelManager, Events: bus}
b.web.UpdateReportPath = updateReportPath(cfg.WorkDir, "webui")
b.web.RunningVersions = daemonRunningVersions
agentStatus := b.agentStatus
b.web.RunningVersions = func() map[string]string { return daemonRunningVersions(agentStatus) }
b.web.SetProvenance(configProvenance)
b.web.ReloadChannel = func(ctx context.Context, id string) error {
if id != "telegram" || b.restartTelegram == nil {
@@ -517,7 +526,7 @@ func (b *boot) setupGateways(ctx context.Context, cfgPath, overlayPath string) b
DefaultChatIdentity: b.defaultChatIdentity, SessionStore: b.chatSessionStore, Updates: b.updateService,
Bus: b.bus,
RegisterRestart: func(request func() error) { b.restartTelegram = request }, Log: log,
ChannelManager: b.channelManager,
ChannelManager: b.channelManager, AgentStatus: b.agentStatus,
})
if !ok {
return false
@@ -1016,6 +1025,7 @@ func (b *boot) buildDaemon() {
Curators: b.curatorRegistry,
Identities: b.identityRunners,
TaskLogs: b.taskLogs,
AgentStatus: b.agentStatus,
}
b.web.TaskStopper = b.d
// web and the daemon must share ONE Holder: a reload swaps d.Cfg and
+32 -13
View File
@@ -16,6 +16,7 @@ import (
channelruntime "github.com/samcharles93/archie-core/internal/channels"
"github.com/samcharles93/archie-core/internal/channels/telegram"
"github.com/samcharles93/archie-core/internal/config"
"github.com/samcharles93/archie-core/internal/daemon"
"github.com/samcharles93/archie-core/internal/events"
"github.com/samcharles93/archie-core/internal/gateway"
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
@@ -56,6 +57,10 @@ type telegramSetup struct {
Bus *events.Bus
Log *slog.Logger
ChannelManager *channelruntime.Manager
// AgentStatus is the composition root's shared tracker for the most
// recently observed archie-agent version (see daemon.AgentStatus).
// Nil disables the agent component of RunningVersions.
AgentStatus *daemon.AgentStatus
}
// setupTelegramGateway initialises the Telegram chat gateway when a
@@ -97,7 +102,8 @@ func setupTelegramGateway(ctx context.Context, s telegramSetup) (start func(), o
},
}
tg.UpdateReportPath = updateReportPath(cfg.WorkDir, cfg.BotUser)
tg.RunningVersions = daemonRunningVersions
agentStatus := s.AgentStatus
tg.RunningVersions = func() map[string]string { return daemonRunningVersions(agentStatus) }
tg.Reload = makeTelegramReload(s)
sessionStore := s.SessionStore
@@ -123,19 +129,32 @@ func setupTelegramGateway(ctx context.Context, s telegramSetup) (start func(), o
}
// daemonRunningVersions reports the component versions this process can
// vouch for from its own build, for checking a pending update report against
// (see releaseupdate.Report.Verify).
// vouch for, for checking a pending update report against (see
// releaseupdate.Report.Verify).
//
// Only the daemon is listed, and that is the whole point: gatewayVersion is
// compiled into this binary, so if an installer claims it put a version into
// service and this value disagrees, the installer is wrong. runtimeVersion
// is deliberately NOT reported for the agent -- it records the agent version
// archied's own release pipeline stamped, not the version the agent
// container is actually running, and the two diverge in exactly the
// situation this check exists to detect. An unverifiable component is left
// out so it is reported as unchecked rather than as confirmed.
func daemonRunningVersions() map[string]string {
return map[string]string{releaseupdate.ComponentDaemon: gatewayVersion}
// The daemon component is always vouched for from its own build:
// gatewayVersion is compiled into this binary, so if an installer claims it
// put a version into service and this value disagrees, the installer is
// wrong. runtimeVersion is deliberately NOT used for the agent component --
// it records the agent version archied's own release pipeline stamped, not
// the version an agent container is actually running, and the two diverge in
// exactly the situation this check exists to detect.
//
// The agent component is included only once agentStatus has actually
// observed one running -- self-reported by an archie-agent worker in a
// taskrun.Response (see daemon.AgentStatus), since every archie-agent
// process is task-scoped and ephemeral, not something this process can query
// directly. Before the first task completes, or when agentStatus is nil
// (composition never wired one), the agent component is left out entirely
// so it reports as unchecked rather than as confirmed.
func daemonRunningVersions(agentStatus *daemon.AgentStatus) map[string]string {
versions := map[string]string{releaseupdate.ComponentDaemon: gatewayVersion}
if agentStatus != nil {
if version, _, ok := agentStatus.Snapshot(); ok {
versions[releaseupdate.ComponentAgent] = version
}
}
return versions
}
func configureTelegramUpdates(tg *telegram.Gateway, s telegramSetup) {
+27 -9
View File
@@ -4,6 +4,7 @@ import (
"testing"
"github.com/samcharles93/archie-core/internal/config"
"github.com/samcharles93/archie-core/internal/daemon"
"github.com/samcharles93/archie-core/internal/installtype"
"github.com/samcharles93/archie-core/internal/releaseupdate"
)
@@ -28,15 +29,17 @@ func TestMakeUpdateServiceWiresInstallType(t *testing.T) {
}
}
// TestDaemonRunningVersionsVouchesOnlyForItself: the point of checking a
// pending update report against running versions is that the value checked
// against is ground truth. This process's own compiled-in version is; the
// agent's is not, because runtimeVersion records what archied's release
// pipeline stamped, not what the agent container is actually running.
// Including a guess here would recreate the false success the check exists
// to catch, so its absence is the assertion.
func TestDaemonRunningVersionsVouchesOnlyForItself(t *testing.T) {
running := daemonRunningVersions()
// TestDaemonRunningVersionsVouchesOnlyForItselfWithoutAgentStatus: the point
// of checking a pending update report against running versions is that the
// value checked against is ground truth. This process's own compiled-in
// version is; a guess at the agent's is not, because runtimeVersion records
// what archied's release pipeline stamped, not what an agent container is
// actually running. Before any task has reported an observed agent version
// (agentStatus nil, or nothing observed yet), including one would recreate
// the false success the check exists to catch, so its absence is the
// assertion.
func TestDaemonRunningVersionsVouchesOnlyForItselfWithoutAgentStatus(t *testing.T) {
running := daemonRunningVersions(nil)
if got := running[releaseupdate.ComponentDaemon]; got != gatewayVersion {
t.Errorf("running[%q] = %q, want gatewayVersion = %q", releaseupdate.ComponentDaemon, got, gatewayVersion)
@@ -46,3 +49,18 @@ func TestDaemonRunningVersionsVouchesOnlyForItself(t *testing.T) {
releaseupdate.ComponentAgent, running)
}
}
// TestDaemonRunningVersionsIncludesObservedAgent: once a task response has
// actually self-reported an agent version (daemon.AgentStatus.Observe), that
// -- not archied's release pipeline's expectation -- is ground truth for
// what is running, so it belongs in the verification set.
func TestDaemonRunningVersionsIncludesObservedAgent(t *testing.T) {
var status daemon.AgentStatus
status.Observe("1.9.11", "container")
running := daemonRunningVersions(&status)
if got := running[releaseupdate.ComponentAgent]; got != "1.9.11" {
t.Errorf("running[%q] = %q, want the observed version %q", releaseupdate.ComponentAgent, got, "1.9.11")
}
}
+5 -2
View File
@@ -14,6 +14,7 @@ import (
"github.com/samcharles93/archie-core/internal/domain/workflow/skillbuild"
"github.com/samcharles93/archie-core/internal/domain/workflow/wfeval"
"github.com/samcharles93/archie-core/internal/events"
"github.com/samcharles93/archie-core/internal/installtype"
"github.com/samcharles93/archie-core/internal/storage"
"github.com/samcharles93/archie-core/internal/store"
"github.com/samcharles93/archie-core/internal/taskrun"
@@ -200,7 +201,9 @@ func runTask(ctx context.Context, req taskrun.Request, dependencies taskDependen
workflow.Run(ctx, wf, tc)
return &taskrun.Response{
Task: tc.Task,
Status: tc.Outcome.Status,
Task: tc.Task,
Status: tc.Outcome.Status,
AgentVersion: Version(),
AgentInstallType: installtype.Type(),
}, nil
}
@@ -21,6 +21,7 @@ import (
"github.com/samcharles93/archie-core/internal/forge"
"github.com/samcharles93/archie-core/internal/forgerpc"
agentnats "github.com/samcharles93/archie-core/internal/infrastructure/agenttransport/nats"
"github.com/samcharles93/archie-core/internal/installtype"
"github.com/samcharles93/archie-core/internal/store"
"github.com/samcharles93/archie-core/internal/storerpc"
"github.com/samcharles93/archie-core/internal/taskrun"
@@ -413,6 +414,15 @@ func TestExecuteTaskRequestUsesInfrastructureRPCDependencies(t *testing.T) {
if response.Status != store.StatusPROpen || len(forge.prs) != 1 {
t.Fatalf("response status/PRs = (%q, %d), want (%q, 1)", response.Status, len(forge.prs), store.StatusPROpen)
}
// archie-core-1786751948782-3-837a8fd0 point 4: every response reports
// what this worker actually is, since it's the only channel the daemon
// has to learn what's really running (see daemon.AgentStatus).
if response.AgentVersion != Version() {
t.Errorf("response.AgentVersion = %q, want Version() = %q", response.AgentVersion, Version())
}
if response.AgentInstallType != installtype.Type() {
t.Errorf("response.AgentInstallType = %q, want installtype.Type() = %q", response.AgentInstallType, installtype.Type())
}
stored, err := st.TaskByIssue(ctx, "acme", "rpc-widget", 2)
if err != nil || stored == nil || stored.Status != store.StatusPROpen || stored.PRNumber != 5 {
t.Fatalf("stored task = (%+v, %v), want RPC-persisted PR-open task #5", stored, err)
+19
View File
@@ -0,0 +1,19 @@
package agentworker
// version is stamped per release artifact via
// "-ldflags -X github.com/samcharles93/archie-core/internal/app/agentworker.version=<value>",
// the same mechanism internal/installtype uses for buildType -- see that
// package's doc comment for why this is baked in at build time rather than
// detected. Reported back to the daemon in every taskrun.Response
// (see task_execution.go) so it can observe the build actually running,
// not the one its own release pipeline expected.
var version = "dev"
// Version reports the archie-agent build this worker process was built
// from, or "dev" for an unstamped build (a local `go build`, for instance).
func Version() string {
if version == "" {
return "dev"
}
return version
}
+28
View File
@@ -0,0 +1,28 @@
package agentworker
import "testing"
// TestVersionReportsDevWhenUnstamped guards the unstamped-build fallback:
// an empty ldflags value (e.g. a local `go build`, or a release pipeline
// that forgot -X for this package) must read as "dev", the same
// placeholder cmd/archied's own version vars use, not as an empty string
// that would silently sail through daemon.AgentStatus as a real version.
func TestVersionReportsDevWhenUnstamped(t *testing.T) {
orig := version
t.Cleanup(func() { version = orig })
version = ""
if got := Version(); got != "dev" {
t.Errorf("Version() = %q, want %q", got, "dev")
}
}
func TestVersionReportsStampedValue(t *testing.T) {
orig := version
t.Cleanup(func() { version = orig })
version = "1.9.11"
if got := Version(); got != "1.9.11" {
t.Errorf("Version() = %q, want %q", got, "1.9.11")
}
}
+41
View File
@@ -0,0 +1,41 @@
package daemon
import "sync"
// AgentStatus tracks the most recent version and install type an
// archie-agent worker reported about itself. It is observed passively, off
// ordinary taskrun.Response traffic in runViaAgent -- there is no dedicated
// poll, since every archie-agent process is task-scoped and ephemeral (see
// docs/architecture and internal/app/agentworker), not a long-lived process
// the daemon could query on demand the way it can Telegram's gateway.
//
// Before the first task completes, nothing is known: Snapshot's ok return
// reports that honestly rather than a caller guessing a value.
type AgentStatus struct {
mu sync.RWMutex
version string
installType string
observed bool
}
// Observe records the version/install-type an archie-agent worker reported
// in a task response. Called for every completed task, so the value always
// reflects whichever agent build most recently ran -- the same one that is
// actually in service, not the version archied's own release pipeline
// stamped for it (those two can diverge, which is exactly what this exists
// to catch).
func (s *AgentStatus) Observe(version, installType string) {
s.mu.Lock()
defer s.mu.Unlock()
s.version = version
s.installType = installType
s.observed = true
}
// Snapshot returns the most recently observed version/install-type, and
// whether any task has reported one yet.
func (s *AgentStatus) Snapshot() (version, installType string, ok bool) {
s.mu.RLock()
defer s.mu.RUnlock()
return s.version, s.installType, s.observed
}
+31
View File
@@ -0,0 +1,31 @@
package daemon
import "testing"
func TestAgentStatusSnapshotBeforeObserveIsUnverified(t *testing.T) {
var s AgentStatus
if version, installType, ok := s.Snapshot(); ok || version != "" || installType != "" {
t.Fatalf("Snapshot() = (%q, %q, %v), want zero values and ok=false before any Observe", version, installType, ok)
}
}
func TestAgentStatusObserveThenSnapshot(t *testing.T) {
var s AgentStatus
s.Observe("1.9.11", "container")
version, installType, ok := s.Snapshot()
if !ok || version != "1.9.11" || installType != "container" {
t.Fatalf("Snapshot() = (%q, %q, %v), want (\"1.9.11\", \"container\", true)", version, installType, ok)
}
}
func TestAgentStatusObserveOverwritesPrevious(t *testing.T) {
var s AgentStatus
s.Observe("1.9.10", "container")
s.Observe("1.9.11", "container")
version, _, _ := s.Snapshot()
if version != "1.9.11" {
t.Fatalf("Snapshot() version = %q, want the most recent observation %q", version, "1.9.11")
}
}
+16
View File
@@ -97,6 +97,14 @@ type Daemon struct {
// the host with the daemon's own authority.
SandboxRequired bool
// AgentStatus records the version/install-type the most recently
// completed archie-agent task response reported about itself, for
// releaseupdate.Report.Verify to check an update claim against. Nil
// disables observation -- runViaAgent skips the Observe call rather
// than reporting the agent as unverifiable via a zero value, which
// would read as a checked "unknown" rather than "never wired".
AgentStatus *AgentStatus
// ContainerPool manages Docker container lifecycle. Nil when [containers]
// is not configured. When non-nil, every task gets a fresh container.
ContainerPool *container.Pool
@@ -1085,6 +1093,14 @@ func (d *Daemon) runViaAgent(ctx context.Context, task *store.Task, repo config.
return
}
// Reached only past every failure return above, so this is always a
// fully decoded, error-free response -- a version is never recorded off
// a request that never reached an agent, or a response describing a
// parked/errored task.
if d.AgentStatus != nil && resp.AgentVersion != "" {
d.AgentStatus.Observe(resp.AgentVersion, resp.AgentInstallType)
}
d.Log.Info("taskrun complete", "task", task.ID, "status", resp.Status)
}
+73
View File
@@ -645,6 +645,79 @@ func TestRunViaAgentSendsExpectedRequest(t *testing.T) {
}
}
// TestRunViaAgentObservesReportedAgentVersion is the regression proof for
// daemon.AgentStatus actually being fed: every archie-agent process is
// task-scoped and ephemeral, so a completed taskrun.Response is the only
// channel the daemon has to learn what build is really running (see
// cmd/archied's daemonRunningVersions, which reads this back out via
// Snapshot for releaseupdate.Report.Verify).
func TestRunViaAgentObservesReportedAgentVersion(t *testing.T) {
d, s, busClient := daemonWithNATS(t)
var status AgentStatus
d.AgentStatus = &status
ctx := context.Background()
if _, err := s.EnqueueIssue(ctx, "acme", "widget", 4, "t", "b", "", ""); err != nil {
t.Fatal(err)
}
task, err := s.ClaimNext(ctx)
if err != nil || task == nil {
t.Fatalf("claim: (%v, %v)", task, err)
}
sub, err := mustCoreConn(t, busClient).Subscribe(agentnats.SubjectForTask(task.ID), func(msg *natsio.Msg) {
data, _ := json.Marshal(taskrun.Response{
Status: store.StatusPROpen, AgentVersion: "1.9.11", AgentInstallType: "container",
})
_ = msg.Respond(data)
})
if err != nil {
t.Fatalf("subscribe: %v", err)
}
t.Cleanup(func() { _ = sub.Unsubscribe() })
d.runViaAgent(ctx, task, config.Repo{Owner: "acme", Name: "widget"})
version, installType, ok := status.Snapshot()
if !ok || version != "1.9.11" || installType != "container" {
t.Fatalf("Snapshot() = (%q, %q, %v), want (\"1.9.11\", \"container\", true)", version, installType, ok)
}
}
// TestRunViaAgentIgnoresEmptyAgentVersion: a worker older than this field,
// or one whose build was never stamped, reports an empty AgentVersion.
// Recording that as observed would read as a confirmed "unknown" version
// rather than as nothing having been reported yet.
func TestRunViaAgentIgnoresEmptyAgentVersion(t *testing.T) {
d, s, busClient := daemonWithNATS(t)
var status AgentStatus
d.AgentStatus = &status
ctx := context.Background()
if _, err := s.EnqueueIssue(ctx, "acme", "widget", 5, "t", "b", "", ""); err != nil {
t.Fatal(err)
}
task, err := s.ClaimNext(ctx)
if err != nil || task == nil {
t.Fatalf("claim: (%v, %v)", task, err)
}
sub, err := mustCoreConn(t, busClient).Subscribe(agentnats.SubjectForTask(task.ID), func(msg *natsio.Msg) {
data, _ := json.Marshal(taskrun.Response{Status: store.StatusPROpen})
_ = msg.Respond(data)
})
if err != nil {
t.Fatalf("subscribe: %v", err)
}
t.Cleanup(func() { _ = sub.Unsubscribe() })
d.runViaAgent(ctx, task, config.Repo{Owner: "acme", Name: "widget"})
if _, _, ok := status.Snapshot(); ok {
t.Fatal("Snapshot() reports observed after an empty AgentVersion response")
}
}
// testForge implements forge.Forge for daemon tests.
type testForge struct {
comments []commentCall
+9
View File
@@ -58,4 +58,13 @@ type Response struct {
Task *store.Task `json:"task"`
Status string `json:"status"`
Error string `json:"error,omitempty"`
// AgentVersion and AgentInstallType report the build of archie-agent
// that actually ran this task -- self-reported by the worker, not the
// version archied's release pipeline expected to be running. Every
// archie-agent process is task-scoped and ephemeral, so this response
// is the only channel the daemon has to observe what is really in
// service; see daemon.AgentStatus. Empty AgentVersion means an
// unstamped build ("dev") or a worker older than this field.
AgentVersion string `json:"agent_version,omitempty"`
AgentInstallType string `json:"agent_install_type,omitempty"`
}