fix(update): remove source checkout dependency
Dashboard-initiated updates also retain a configured Telegram restart-report route, while falling back to the web UI report when Telegram is unavailable.
This commit is contained in:
1 parent
24b50192f6
commit
a27fb5f36e
7 files changed
+81
-29
No files matched your search
@@ -1,9 +1,13 @@
|
||||
{"_type":"issue","id":"archie-core-473l","title":"Reconcile task clone ownership after container commits","description":"Agent containers write Git objects as root into bind-mounted task clones, while ownership is currently repaired only before push. A stopped or failed workflow before push leaves unreadable objects and makes the next host-side worktree prepare fail instantly. Reconcile ownership after every CommitAll result as well as before push.","status":"in_progress","priority":0,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-24T17:24:57Z","created_by":"Sam Catlow","updated_at":"2026-08-24T17:25:30Z","started_at":"2026-08-24T17:25:30Z","lease_expires_at":"2026-08-24T17:30:30Z","heartbeat_at":"2026-08-24T17:25:30Z","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-15iq","title":"Make UUIDv7 session references distinguishable","description":"UUIDv7 session IDs created close together share their first eight characters, making displayed chat session references unusable and allowing /topic to select the wrong first prefix match. Surface a sufficiently distinguishing shorthand and resolve topic references unambiguously.","status":"in_progress","priority":0,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-24T17:20:49Z","created_by":"Sam Catlow","updated_at":"2026-08-24T17:20:53Z","started_at":"2026-08-24T17:20:53Z","lease_expires_at":"2026-08-24T17:25:53Z","heartbeat_at":"2026-08-24T17:20:53Z","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-4tye","title":"Install updates without requiring a source checkout","description":"Make the automatic updater fetch approved release source into an invocation-scoped temporary clone, build and install the binary from that source, and never require or mutate an operator or agent checkout.","status":"closed","priority":0,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-24T17:11:05Z","created_by":"Sam Catlow","updated_at":"2026-08-24T17:19:42Z","started_at":"2026-08-24T17:11:11Z","closed_at":"2026-08-24T17:19:42Z","close_reason":"Implemented, regression-tested, full task check passed, and adversarial review finding resolved.","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-1787489595430-1-8f81afa3","title":"Security: an unauthenticated endpoint must not be able to run an agent","description":"P0 within this epic because the feature's own pitch is the threat model: a public intake surface whose output is an agent with tool access and a repo. Get this wrong and a webhook URL is remote code execution with extra steps.\n\nNon-negotiables to design:\n\n- Per-source authentication. A source registers with a secret (HMAC, as internal/channels/webhook already does per route) before its events can trigger anything. Capture-only for unknown senders is acceptable; triggering is not.\n- Human approval before a binding goes live. An operator authoring a binding is a deliberate act; an event arriving is not. Nothing should self-arm.\n- Rate and volume limits per source, so capture cannot be used to exhaust disk or drown the inspector.\n- Payload content is untrusted input flowing into an agent prompt. Treat prompt injection as expected, not exceptional -- the sender controls that text, and the agent has tools. Bound what a playbook-triggered workflow may do.\n- Captured payloads may contain secrets from the sending system. Decide retention, redaction and who can view them; internal/memory/scrubber may already have applicable prior art.\n\nArchie's own principle applies: environmental enforcement over prompt rules. 'The agent should ignore instructions in the payload' is not a control.","status":"closed","priority":0,"issue_type":"feature","created_at":"2026-08-23T12:22:08Z","updated_at":"2026-08-24T06:58:51Z","closed_at":"2026-08-24T06:58:51Z","external_ref":"https://github.com/samcharles93/archie-core/issues/564","source_system":"github:https://github.com/samcharles93/archie-core/issues/564:564","metadata":null,"dependencies":[{"issue_id":"archie-core-1787489595430-1-8f81afa3","depends_on_id":"archie-core-t2db.5","type":"supersedes","created_at":"2026-08-24T06:58:51Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-mzok","title":"Make ClaimTurn insert-race regression deterministic under CI","description":"GitHub deploy run 32587841233 failed after the gateway compile fix because TestClaimTurnConcurrentInsertRaceNeverReturnsAnError launched 200 concurrent SQLite claims and exhausted its immediate retry loop with SQLITE_BUSY. The test's stated target is the two-connection same-turn insert race, not unrelated global write-lock saturation.","acceptance_criteria":"The regression still races two independent stores over the same turn ID; unrelated cross-trial SQLite contention cannot exhaust retries; repeated focused runs, task check, and diff-scoped lint pass; fresh adversarial review has zero surviving findings.","status":"closed","priority":0,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-08-22T17:34:07Z","created_by":"Sam Catlow","updated_at":"2026-08-24T06:59:21Z","started_at":"2026-08-22T17:34:11Z","closed_at":"2026-08-24T06:59:21Z","close_reason":"Already fixed on main: session_store_sqlite_claimturn_race_test.go now runs the 100 trials serially (two stores racing one turn ID per trial) with bounded SQLITE_BUSY retries, instead of 200 concurrent claims. Verified: -count=3 passes.","external_ref":"https://github.com/samcharles93/archie-core/issues/587","metadata":null,"dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-bia3","title":"Fix merged gateway capability contract blocking GitHub deploy","description":"PR #560 removed the dead BasePlatformAdapter while PR #561 independently added adapter_capabilities.go and tests that still depend on it. Both branches passed alone, but merged main no longer compiles, so deploy.yml cannot publish the intended video-generation release.","acceptance_criteria":"internal/gateway compiles without BasePlatformAdapter; live Telegram media delivery and capability reporting remain covered; task check and lint pass; a fresh adversarial review has zero surviving findings.","status":"closed","priority":0,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-08-22T17:15:14Z","created_by":"Sam Catlow","updated_at":"2026-08-24T06:59:22Z","started_at":"2026-08-22T17:15:22Z","closed_at":"2026-08-24T06:59:22Z","close_reason":"Already fixed on main: BasePlatformAdapter has zero references repo-wide, adapter_capabilities.go + tests stand alone. Verified: go build ./... clean, gateway capability tests pass.","external_ref":"https://github.com/samcharles93/archie-core/issues/588","metadata":null,"dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-1ysw.1","title":"Bind worktree RPC operations to the dispatched task","description":"The sandboxed agent can currently choose owner, repo, issue, base, and branch on worktree RPC requests. The daemon then performs host deletion and credentialed forge operations without correlating the request to the dispatched task or enforcing WorkDir containment.","acceptance_criteria":"Reject traversal and unconfigured or task-mismatched coordinates before any filesystem or forge side effect; derive or validate the permitted branch; regression tests fail on the old behavior and pass on the fix.","status":"closed","priority":0,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-08-22T11:01:43Z","created_by":"Sam Catlow","updated_at":"2026-08-24T06:59:58Z","started_at":"2026-08-22T11:02:03Z","closed_at":"2026-08-24T06:59:58Z","close_reason":"Fixed on main: worktreerpc now exposes only Push, authorized by an opaque per-dispatch grant issued from the dispatched *store.Task (worktreerpc.go:71-83). Sandbox input no longer selects host path, repo or branch; ValidCoordinates rejects traversal. Package tests pass.","external_ref":"https://github.com/samcharles93/archie-core/issues/589","metadata":null,"dependencies":[{"issue_id":"archie-core-1ysw.1","depends_on_id":"archie-core-1ysw","type":"parent-child","created_at":"2026-08-22T21:01:42Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-1ysw","title":"Repair internal/worktree correctness and trust-boundary defects","description":"Track the concrete worktree-package defects proven by the 2026-08-22 evidence-gated review. Child bugs cover RPC authority/path containment, repository-key isolation, retry/base/diff correctness, push lifecycle, terminal cleanup, cancellation, and branch naming. This epic groups implementation only; each child has its own observable acceptance criteria.","acceptance_criteria":"All child bugs are closed with red-green regression tests, scoped lint passes, and the repository quality gate is clean.","status":"closed","priority":0,"issue_type":"epic","owner":"sam@catlow.tech","created_at":"2026-08-22T11:01:18Z","created_by":"Sam Catlow","updated_at":"2026-08-24T08:16:00Z","closed_at":"2026-08-24T08:16:00Z","close_reason":"All 9 children complete. The P0/P1 trust-boundary and correctness defects (.1 RPC task binding, .2 colliding directory keys, .3 untracked cleanup, .4 fail-closed base resolution, .5 three-dot merge-base semantics) were already fixed on main and reconciled 2026-08-24. The remaining four (.6 push result, .7 no-change worktree leak, .8 commit cancellation, .9 branch naming contract) were implemented this session, merged as 474c31d and its two merge commits, task check green, with an independent adversarial review reporting zero findings.","external_ref":"https://github.com/samcharles93/archie-core/issues/590","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-t2db.5","title":"Security: an unauthenticated endpoint must not be able to run an agent","description":"P0 within this epic because the feature's own pitch is the threat model: a public intake surface whose output is an agent with tool access and a repo. Get this wrong and a webhook URL is remote code execution with extra steps.\n\nNon-negotiables to design:\n\n- Per-source authentication. A source registers with a secret (HMAC, as internal/channels/webhook already does per route) before its events can trigger anything. Capture-only for unknown senders is acceptable; triggering is not.\n- Human approval before a binding goes live. An operator authoring a binding is a deliberate act; an event arriving is not. Nothing should self-arm.\n- Rate and volume limits per source, so capture cannot be used to exhaust disk or drown the inspector.\n- Payload content is untrusted input flowing into an agent prompt. Treat prompt injection as expected, not exceptional -- the sender controls that text, and the agent has tools. Bound what a playbook-triggered workflow may do.\n- Captured payloads may contain secrets from the sending system. Decide retention, redaction and who can view them; internal/memory/scrubber may already have applicable prior art.\n\nArchie's own principle applies: environmental enforcement over prompt rules. 'The agent should ignore instructions in the payload' is not a control.","acceptance_criteria":"An event from an unauthenticated source can be captured but cannot trigger a workflow; a new binding requires explicit human approval before it arms; per-source rate limits exist; the blast radius of a playbook-triggered workflow is bounded by code rather than by prompt text; retention and visibility of captured payloads is decided and documented.","notes":"2026-08-22: security design decided and documented in docs/prds/webhook-intake-security.md, covering all five non-negotiables from this bead's description:\n1. Per-source auth reuses internal/channels/webhook's existing HMAC-SHA256 scheme; capture accepts unsigned events (visible, marked unauthenticated), only authenticated events can ever match a binding.\n2. Bindings gain a draft -\u003e pending_approval -\u003e armed state machine; any edit to an armed binding drops it back to pending_approval so approval can't be bypassed by editing. Modeled on telegram's existing dangerousAction/pendingApproval flow (dangerous.go/approval.go).\n3. Per-source token-bucket rate limiting (precedent: pairing/store.go's MaxPendingPerPlatform); limit-exceeded is an observable 429, not a silent drop.\n4. Blast radius bounded by the SAME code-level controls every task already gets -- gate, diff_cap_lines, sandboxed container, worktree isolation -- no new relaxation for playbook-triggered work, and payload text is ordinary untrusted prompt input, never a trusted instruction.\n5. 7-day configurable retention on captured payloads; best-effort redaction reusing gateway/stream.go's sensitiveParameterKey heuristic before persisting; visibility gated by the same dashboard auth as every other webui surface.\n\nThis bead's code-level acceptance criteria (capture-can't-trigger, rate limits exist, blast-radius bounded, approval gate) cannot be implemented yet: they constrain t2db.1 (capture), 7d5u.3 (intake family) and t2db.4 (binding), none of which have landed. This document is the contract those beads build against -- do not build any of them without satisfying it. Leaving this bead in_progress rather than closing it; it closes when t2db.1/7d5u.3/t2db.4 land and demonstrably satisfy points 1-5, not before.","status":"in_progress","priority":0,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-21T13:45:46Z","created_by":"Sam Catlow","updated_at":"2026-08-22T09:25:01Z","started_at":"2026-08-21T14:51:26Z","external_ref":"https://github.com/samcharles93/archie-core/issues/536","dependencies":[{"issue_id":"archie-core-t2db.5","depends_on_id":"archie-core-t2db","type":"parent-child","created_at":"2026-08-21T23:45:45Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":1,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-y1hv","title":"Relay dashboard update completion through Telegram","description":"Integrate the existing Carina-side behavior so dashboard-initiated updates can deliver their post-restart watchdog result to an authorized Telegram recipient, while retaining the web UI report path fallback.","status":"closed","priority":1,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-24T17:18:30Z","created_by":"Sam Catlow","updated_at":"2026-08-24T17:19:42Z","started_at":"2026-08-24T17:18:35Z","closed_at":"2026-08-24T17:19:42Z","close_reason":"Implemented, regression-tested, full task check passed, and adversarial review finding resolved.","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-b7f1","title":"Fix Web UI session UUID compatibility and update-status synchronization","description":"The production Web UI crashes when crypto.randomUUID is unavailable, preventing chat session creation. Review and fix UUID generation compatibility plus the recovered Web UI/Telegram update-status synchronization issue, with regression tests and production-path verification.","status":"closed","priority":1,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-24T16:50:12Z","created_by":"Sam Catlow","updated_at":"2026-08-24T17:00:21Z","started_at":"2026-08-24T16:50:18Z","closed_at":"2026-08-24T17:00:21Z","close_reason":"Implemented UUIDv7 identities, replayable archived chat tool activity, and post-start update report delivery; full quality gate passes.","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-vq92","title":"task_logs truncates at 50KB with no pagination, so full logs are unreachable","description":"The task_logs chat tool caps its response at 50 KB and offers no way to fetch the rest. An operator asking the agent to retrieve or archive a task's logs gets a silently clipped window, and the agent has no mechanism to page past it. Observed 2026-08-24: asked to save a full transcript and agent logs, the agent could only produce a partial archive and had to document the truncation as a limitation rather than satisfy the request.\n\nThe failure compounds with archie-core-p1bl (errors logging as `{}`): a truncated log of uninformative errors leaves an operator with nothing at all, precisely when a task is stuck.\n\n## What is needed\n\nTruncation itself is legitimate -- a tool result must be bounded, and unbounded log text would blow the model's context. The defect is that truncation is TERMINAL: there is no continuation, no offset/cursor, no way to narrow the window, and the caller cannot tell how much was lost.\n\nEstablish first where the cap is applied (the task_logs tool in internal/gateway/task_tools.go and whatever log reader it calls in internal/logging -- note internal/logging owns the on-disk format end to end and internal/webui parses nothing, per CLAUDE.md, so the reader is the right place for range support).\n\nDesign points to decide:\n- A cursor or offset so successive calls walk the whole log, rather than always returning the same head or tail.\n- Filters that make bounded retrieval useful rather than merely possible: by level (errors only), by time range, by stage.\n- The response must state explicitly that it was truncated and how much remains, so the agent can report honestly instead of implying completeness.\n- Consider whether bulk retrieval belongs in a tool result at all, or whether the right answer for \"save the full logs\" is to write the file and deliver it via the new send_file path (archie-core-absb), keeping the tool result small.\n\n## Acceptance Criteria\n\nAn operator can obtain a task's complete logs through the agent, by paging or by file delivery; a truncated response says so and reports what remains rather than ending silently; level and time-range filtering exist so a bounded call can still answer a specific question; the cap remains enforced so no single response can exhaust the model's context; tests cover a log larger than the cap and assert that repeated calls retrieve all of it without gaps or duplication.\n","status":"open","priority":1,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-08-24T15:48:15Z","created_by":"Sam Catlow","updated_at":"2026-08-24T15:50:10Z","external_ref":"https://github.com/samcharles93/archie-core/issues/625","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-p1bl","title":"Task logs serialise errors to an empty object, destroying diagnostics","description":"Error values in task logs sometimes render as an empty JSON object, so the one field that says WHY something failed carries no information. Observed in production task logs 2026-08-24, in the same stream:\n\n {\"time\":\"...\",\"level\":\"ERROR\",\"message\":\"handle failed\",\"fields\":{\"err\":{}}}\n {\"time\":\"...\",\"level\":\"ERROR\",\"message\":\"handle failed\",\"fields\":{\"err\":\"stage re…\"}}\n\nSame message, same field, two different encodings -- one useful, one useless. The empty-object form is what an operator hits when diagnosing a stuck task, which is exactly when the log is the only evidence available.\n\n## Likely mechanism (to be confirmed, not assumed)\n\n`{}` is what encoding/json produces for a struct with no exported fields. A custom error type (a struct implementing `error` via a value or pointer receiver, with all fields unexported) marshals to `{}` rather than to its Error() string, because encoding/json does not consult the error interface. Errors that happen to be `*errors.errorString` or `fmt.Errorf` results go through a different path and survive as text.\n\nStart at internal/logging (attrs.go and its tests already reference a \"handle failed\" record, so the attribute handling is there) and establish where an `error` attribute is converted for the JSONL sink. The fix is to render errors through their Error() string -- and, where the error carries structured context worth keeping, to do so ADDITIONALLY rather than instead.\n\n## Why P1\n\nSam's words: \"LOGGING! ... this is another critical requirement.\" Diagnosis of every other defect depends on it. Two separate investigations this week were slowed by log output that recorded that something failed without recording what.\n\nNote this compounds archie-core-1ysw-era debugging and the parked-task investigation: an operator seeing `{\"err\":{}}` has strictly less information than one seeing no log line at all, because the empty object implies the error was captured.\n\n## Steps to Reproduce\n\n1. Arrange for a code path that logs a custom error type (unexported fields) as an `err` attribute.\n2. Read the task's JSONL log via the dashboard, /api logs, or the task_logs tool.\n3. Observe `\"err\":{}` where the message should be.\n4. Compare with a path that logs a fmt.Errorf value and observe `\"err\":\"...\"` in the same file.\n\n## Acceptance Criteria\n\nEvery error logged as an attribute renders its Error() text in the JSONL sink regardless of the concrete error type; a custom error type with only unexported fields is covered by a test asserting the message survives; structured context on an error is preserved in addition to, never instead of, the message; a regression test fails against the current encoder; no log line can report an error as an empty object.\n","status":"open","priority":1,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-08-24T15:47:44Z","created_by":"Sam Catlow","updated_at":"2026-08-24T15:50:11Z","external_ref":"https://github.com/samcharles93/archie-core/issues/626","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
|
||||
@@ -314,6 +314,10 @@ 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")
|
||||
if cfg.Chat.Telegram.TokenEnv != "" && len(cfg.Chat.Telegram.AllowedUserIDs) > 0 {
|
||||
b.web.TelegramUpdateReportPath = updateReportPath(cfg.WorkDir, cfg.BotUser)
|
||||
b.web.TelegramUpdateChatID = cfg.Chat.Telegram.AllowedUserIDs[0]
|
||||
}
|
||||
agentStatus := b.agentStatus
|
||||
b.web.RunningVersions = func() map[string]string { return daemonRunningVersions(agentStatus) }
|
||||
b.web.SetProvenance(configProvenance)
|
||||
|
||||
@@ -17,9 +17,11 @@ func TestUpdateInstallGatewayOnlySkipsRuntimeWork(t *testing.T) {
|
||||
"ARCHIE_UPDATE_AGENT_PREVIOUS": "1.9.9",
|
||||
})
|
||||
|
||||
assertCallContains(t, calls, "git pull --ff-only")
|
||||
assertCallContains(t, calls, "git clone", "--no-checkout", "https://example.invalid/archie-core.git")
|
||||
assertCallContains(t, calls, "fetch --quiet --tags origin")
|
||||
assertCallAbsent(t, calls, "git pull")
|
||||
assertCallContains(t, calls, "git -C", "rev-parse --verify refs/tags/archied/v1.13.0^{commit}")
|
||||
assertCallContains(t, calls, "git -C", "worktree add --detach")
|
||||
assertCallContains(t, calls, "checkout --quiet --detach approved-release-commit")
|
||||
assertCallContains(t, calls, "go build", "main.runtimeVersion=1.9.9", "./cmd/archied")
|
||||
assertCallAbsent(t, calls, "./cmd/archie-agent")
|
||||
assertCallAbsent(t, calls, "docker compose build agent")
|
||||
@@ -144,20 +146,13 @@ func runUpdateInstallScript(t *testing.T, environment map[string]string) (Result
|
||||
writeFakeCommand(t, fakeDir, "git", `
|
||||
printf '%s\n' "git $*" >> "$ARCHIE_TEST_CALLS"
|
||||
case "$*" in
|
||||
*"rev-parse --verify refs/tags/"*) echo approved-release-commit ;;
|
||||
*"worktree add --detach"*)
|
||||
while [ "$#" -gt 0 ]; do
|
||||
if [ "$1" = "--detach" ]; then
|
||||
source_dir="$2"
|
||||
mkdir -p "$source_dir"
|
||||
/usr/bin/cp -R "$ARCHIE_REPO_DIR/scripts" "$source_dir/scripts"
|
||||
: > "$source_dir/docker-compose.yml"
|
||||
break
|
||||
fi
|
||||
shift
|
||||
done
|
||||
*"clone "*)
|
||||
source_dir="${@: -1}"
|
||||
mkdir -p "$source_dir"
|
||||
/usr/bin/cp -R "$ARCHIE_TEST_SOURCE_DIR/scripts" "$source_dir/scripts"
|
||||
: > "$source_dir/docker-compose.yml"
|
||||
;;
|
||||
*"worktree remove --force"*) ;;
|
||||
*"rev-parse --verify refs/tags/"*) echo approved-release-commit ;;
|
||||
esac
|
||||
`)
|
||||
writeFakeCommand(t, fakeDir, "go", `
|
||||
@@ -208,7 +203,8 @@ printf '%s\n' "cp $*" >> "$ARCHIE_TEST_CALLS"
|
||||
cmd.Env = append(
|
||||
os.Environ(),
|
||||
"PATH="+fakeDir+":"+os.Getenv("PATH"),
|
||||
"ARCHIE_REPO_DIR="+root,
|
||||
"ARCHIE_SOURCE_URL=https://example.invalid/archie-core.git",
|
||||
"ARCHIE_TEST_SOURCE_DIR="+root,
|
||||
"ARCHIE_BIN_DIR="+binDir,
|
||||
"ARCHIE_CONFIG_PATH="+configPath,
|
||||
"ARCHIE_TEST_CALLS="+callsPath,
|
||||
|
||||
@@ -582,6 +582,11 @@ func (s *Server) handleChatUpdateInstall(w http.ResponseWriter, r *http.Request)
|
||||
|
||||
progress := make([]string, 0, 4)
|
||||
meta := releaseupdate.InstallMeta{Channel: "webui", ReportPath: s.UpdateReportPath}
|
||||
if s.TelegramUpdateReportPath != "" && s.TelegramUpdateChatID != 0 {
|
||||
meta.Channel = "telegram"
|
||||
meta.ChatID = s.TelegramUpdateChatID
|
||||
meta.ReportPath = s.TelegramUpdateReportPath
|
||||
}
|
||||
result, err := chat.Updates.Install(r.Context(), fresh, meta, func(message string) { progress = append(progress, message) })
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadGateway)
|
||||
|
||||
@@ -154,6 +154,14 @@ type Server struct {
|
||||
// the dashboard failing to start.
|
||||
Mappings store.MappingStore
|
||||
|
||||
// TelegramUpdateReportPath and TelegramUpdateChatID let a dashboard-
|
||||
// initiated update use the same post-restart notification route as a
|
||||
// Telegram-initiated update. The web UI has no durable chat identity, so
|
||||
// composition supplies an authorized Telegram recipient when one exists.
|
||||
// When either value is empty, UpdateReportPath remains in use.
|
||||
TelegramUpdateReportPath string
|
||||
TelegramUpdateChatID int64
|
||||
|
||||
// UpdateReportPath is where the update watchdog leaves the phase-2
|
||||
// outcome of a dashboard-initiated install for this process to relay on
|
||||
// its next boot -- the webui counterpart of
|
||||
|
||||
@@ -159,3 +159,38 @@ func TestHandleChatUpdateInstallSetsReportPath(t *testing.T) {
|
||||
t.Errorf("ReportPath = %q, want %q", updates.installedMeta.ReportPath, reportPath)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleChatUpdateInstallRoutesRestartReportToTelegram(t *testing.T) {
|
||||
reportPath := filepath.Join(t.TempDir(), "telegram-update-report.json")
|
||||
updates := &chatUpdateStub{snapshot: releaseupdate.Snapshot{
|
||||
Components: []releaseupdate.Component{{ID: "gateway", Label: "Gateway", Installed: "1.0", Available: "1.1"}},
|
||||
}}
|
||||
sessions := gateway.NewSessionStoreMemory()
|
||||
t.Cleanup(func() { _ = sessions.Close() })
|
||||
router := gateway.NewRouter(chatStatusStub{}, nil, "web")
|
||||
server := &Server{
|
||||
Chat: &ChatService{Router: router, Sessions: sessions, Updates: updates},
|
||||
UpdateReportPath: filepath.Join(t.TempDir(), "webui-update-report.json"),
|
||||
TelegramUpdateReportPath: reportPath,
|
||||
TelegramUpdateChatID: 42,
|
||||
}
|
||||
|
||||
body, err := json.Marshal(chatUpdateRequest{Snapshot: updates.snapshot})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
res := httptest.NewRecorder()
|
||||
server.Handler().ServeHTTP(res, httptest.NewRequestWithContext(context.Background(), http.MethodPost, "/api/chat/update/install", bytes.NewReader(body)))
|
||||
if res.Code != http.StatusOK || !updates.installed {
|
||||
t.Fatalf("update install = %d, body = %s", res.Code, res.Body.String())
|
||||
}
|
||||
if updates.installedMeta.Channel != "telegram" {
|
||||
t.Errorf("Channel = %q, want telegram", updates.installedMeta.Channel)
|
||||
}
|
||||
if updates.installedMeta.ChatID != 42 {
|
||||
t.Errorf("ChatID = %d, want 42", updates.installedMeta.ChatID)
|
||||
}
|
||||
if updates.installedMeta.ReportPath != reportPath {
|
||||
t.Errorf("ReportPath = %q, want %q", updates.installedMeta.ReportPath, reportPath)
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ json_escape() {
|
||||
printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'
|
||||
}
|
||||
|
||||
REPO="${ARCHIE_REPO_DIR:-$HOME/projects/archie-core}"
|
||||
SOURCE_URL="${ARCHIE_SOURCE_URL:-https://github.com/samcharles93/archie-core.git}"
|
||||
BIN_DIR="${ARCHIE_BIN_DIR:-$HOME/.local/bin}"
|
||||
CONFIG_PATH="${ARCHIE_CONFIG_PATH:-${XDG_CONFIG_HOME:-$HOME/.config}/archie/config.toml}"
|
||||
export PATH="/usr/local/go/bin:$PATH"
|
||||
@@ -84,17 +84,24 @@ for target in "$GW_TARGET" "$RT_TARGET"; do
|
||||
fi
|
||||
done
|
||||
|
||||
cd "$REPO"
|
||||
tmp="$(mktemp -d)"
|
||||
source_dir="$tmp/source"
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
|
||||
echo "==> fetching approved component releases"
|
||||
git pull --ff-only
|
||||
# Updates are independent of the agent/operator checkout. Fetch into an
|
||||
# invocation-scoped clone, resolve the approved tags there, and build the
|
||||
# installed binary from that isolated source tree.
|
||||
git clone --quiet --filter=blob:none --no-checkout "$SOURCE_URL" "$source_dir"
|
||||
git -C "$source_dir" fetch --quiet --tags origin
|
||||
|
||||
# Build from the exact approved release commit, not the moving branch tip. A
|
||||
# temporary worktree keeps the operator's main checkout on its branch.
|
||||
if [[ ",$components," == *,daemon,* ]]; then
|
||||
gw_commit="$(git -C "$REPO" rev-parse --verify "refs/tags/archied/v$GW^{commit}")"
|
||||
gw_commit="$(git -C "$source_dir" rev-parse --verify "refs/tags/archied/v$GW^{commit}")"
|
||||
fi
|
||||
if [[ ",$components," == *,agent,* ]]; then
|
||||
rt_commit="$(git -C "$REPO" rev-parse --verify "refs/tags/archie/v$RT^{commit}")"
|
||||
rt_commit="$(git -C "$source_dir" rev-parse --verify "refs/tags/archie/v$RT^{commit}")"
|
||||
fi
|
||||
case "$components" in
|
||||
daemon) build_commit="$gw_commit" ;;
|
||||
@@ -108,14 +115,7 @@ case "$components" in
|
||||
;;
|
||||
esac
|
||||
|
||||
tmp="$(mktemp -d)"
|
||||
source_dir="$tmp/source"
|
||||
cleanup() {
|
||||
git -C "$REPO" worktree remove --force "$source_dir" >/dev/null 2>&1 || true
|
||||
rm -rf "$tmp"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
git -C "$REPO" worktree add --detach "$source_dir" "$build_commit"
|
||||
git -C "$source_dir" checkout --quiet --detach "$build_commit"
|
||||
cd "$source_dir"
|
||||
|
||||
# Refresh adapters from the approved release source. The running shell
|
||||
|
||||
Reference in new issue
Block a user