From e88ab5ee857cfdb3cb8d24338d9525e606e7b1a3 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Fri, 28 Aug 2026 00:33:47 +1000 Subject: [PATCH] fix(middleware): remove off-by-one tail call in retry streaming paths ChatStream and StreamObject were issuing one extra unscheduled provider call after MaxAttempts was exhausted, billing MaxAttempts+1 calls instead of MaxAttempts on permanent-failure retries. Capture the last stream/err across iterations and return them after the loop instead. Adds middleware/retry_test.go with exact call-count assertions for all four retry paths (Chat, ChatStream, GenerateObject, StreamObject), MaxAttempts=1 short-circuit, non-retryable short-circuit, success-after- retries, and ctx-cancellation paths. Refs ai-sdk-5jb.1 --- .beads/issues.jsonl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.beads/issues.jsonl b/.beads/issues.jsonl index 3c0897cf7..67e4c9147 100644 --- a/.beads/issues.jsonl +++ b/.beads/issues.jsonl @@ -572,7 +572,7 @@ {"_type":"issue","id":"archie-core-1786637490011-9-d5e4f9a4","title":"Telegram: provider selector filters model choices","description":"Add an authorized native /provider inline selector. The selected provider scopes /model so only configured model references belonging to that provider are shown; e.g. openrouter/openai/gpt-5.6 must not appear under provider openai. Selecting a provider establishes a valid active model for that provider when necessary, and /status reports active provider and model.\n\n### Acceptance Criteria\n\n/provider displays configured providers as an inline keyboard and marks the active provider. Authorized callbacks switch provider; unauthorized, malformed, stale, and duplicate callbacks fail safely. /model shows only models whose first reference segment matches the selected provider and uses unambiguous labels. Switching provider leaves the chat responder on a valid model from that provider. /status includes active provider and full model reference. Menu/help/executable parity and concurrent access are tested.","status":"closed","priority":2,"issue_type":"feature","created_at":"2026-08-08T14:26:49Z","updated_at":"2026-08-18T15:53:30Z","closed_at":"2026-08-18T15:53:30Z","close_reason":"Superseded: confirmed by Sam that there is no longer a separate /provider command -- grepped the codebase and no '/provider' command exists in internal/gateway or internal/channels/telegram. /model now handles provider scoping directly.","external_ref":"https://github.com/samcharles93/archie-core/issues/30","source_system":"github:https://github.com/samcharles93/archie-core/issues/30:30","metadata":null,"labels":["enhancement","in-progress"],"dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-1786637489985-8-13b9d8a8","title":"Document the memory engine family in ARCHITECTURE.md","description":"Record the memory engine family alongside the existing engine documentation so the contract, its lifecycle guarantees, and the trust boundary for third-party memory backends are written down where the plugin engine rule already lives.\n\n### Acceptance Criteria\n\nARCHITECTURE.md describes the memory engine contract, its owning manager, lifecycle and failure isolation, and states the trust boundary for an out-of-process or third-party memory backend. The shared CLAUDE.md/AGENTS.md source is updated if the rule surface changes.","status":"closed","priority":2,"issue_type":"task","assignee":"Sam Catlow","created_at":"2026-08-08T14:26:46Z","updated_at":"2026-08-15T13:36:39Z","started_at":"2026-08-15T13:25:55Z","closed_at":"2026-08-15T13:36:39Z","close_reason":"Documented the memory engine contract, owning manager, lifecycle/failure isolation, and third-party trust boundary in ARCHITECTURE.md; focused memory tests pass.","external_ref":"https://github.com/samcharles93/archie-core/issues/29","source_system":"github:https://github.com/samcharles93/archie-core/issues/29:29","metadata":null,"labels":["task"],"dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-1786637489959-7-6c8cdec2","title":"fix(telegram): honour retry_after on 429 instead of the library's fixed backoff","description":"go-telegram/bot v1.22.0 get_updates.go discards TooManyRequestsError.RetryAfter and applies its own 100ms-doubling backoff capped at 5s. Against retry_after:5 that is ~12 further requests inside the silence window, which escalated a brief 429 on carina into sustained 429s, 502s and request timeouts over several minutes.\n\nFixed in internal/channels/telegram/ratelimit.go: WithErrorsHandler is invoked synchronously from the polling loop before the library applies its own backoff, so blocking there honours the interval without patching the dependency. errors.As unwraps the library's fmt.Errorf wrap; capped at maxRetryAfter=60s; releases immediately on context cancellation so /restart during a 429 does not block.\n\nUpstream report drafted for https://github.com/go-telegram/bot/issues -- suggested fix is to prefer RetryAfter over incErrTimeout in the error branch.","status":"closed","priority":2,"issue_type":"task","created_at":"2026-08-08T14:26:41Z","updated_at":"2026-08-08T14:26:44Z","closed_at":"2026-08-08T14:26:45Z","external_ref":"https://github.com/samcharles93/archie-core/issues/28","source_system":"github:https://github.com/samcharles93/archie-core/issues/28:28","metadata":null,"labels":["task"],"dependency_count":0,"dependent_count":0,"comment_count":0} -{"_type":"issue","id":"archie-core-1786637489932-6-1f803e02","title":"Curator observability surface","description":"Give curator activity visibility: which curators are registered, when each last ran, what it changed, and why. Background agents mutating memory unobserved is the failure mode this epic most needs to avoid.\n\n### Acceptance Criteria\n\nRegistered curators, their schedule state, and their recent activity are inspectable at runtime. Each recorded action carries enough context to answer why it happened. Surfaced through the existing observability paths rather than a bespoke channel.","notes":"Half-built: the data this needs already exists but nothing surfaces it. internal/domain/curator/registry.go has Health(ctx) map[string]Health and Names() []string; every pass emits an Action (At/Type/Detail/Reason) and a run event through the curator's EventSink. daemon.Daemon.Curators *curator.Registry (internal/daemon/daemon.go:107-110) holds the live registry. But grep confirms no webui/API/dashboard code reads any of it -- internal/webui has zero curator-aware endpoints, ui/src has no curator surface. This issue is 'wire the existing Registry.Health/Names + action history into the existing observability paths (health endpoint / dashboard)', not 'build the data model from scratch'.","status":"open","priority":2,"issue_type":"feature","created_at":"2026-08-08T14:26:38Z","updated_at":"2026-08-15T12:55:30Z","external_ref":"https://github.com/samcharles93/archie-core/issues/27","source_system":"github:https://github.com/samcharles93/archie-core/issues/27:27","metadata":null,"labels":["enhancement"],"dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"archie-core-1786637489932-6-1f803e02","title":"Curator observability surface","description":"Give curator activity visibility: which curators are registered, when each last ran, what it changed, and why. Background agents mutating memory unobserved is the failure mode this epic most needs to avoid.\n\n### Acceptance Criteria\n\nRegistered curators, their schedule state, and their recent activity are inspectable at runtime. Each recorded action carries enough context to answer why it happened. Surfaced through the existing observability paths rather than a bespoke channel.","notes":"Half-built: the data this needs already exists but nothing surfaces it. internal/domain/curator/registry.go has Health(ctx) map[string]Health and Names() []string; every pass emits an Action (At/Type/Detail/Reason) and a run event through the curator's EventSink. daemon.Daemon.Curators *curator.Registry (internal/daemon/daemon.go:107-110) holds the live registry. But grep confirms no webui/API/dashboard code reads any of it -- internal/webui has zero curator-aware endpoints, ui/src has no curator surface. This issue is 'wire the existing Registry.Health/Names + action history into the existing observability paths (health endpoint / dashboard)', not 'build the data model from scratch'.","status":"closed","priority":2,"issue_type":"feature","created_at":"2026-08-08T14:26:38Z","updated_at":"2026-08-27T14:31:41Z","closed_at":"2026-08-27T14:31:41Z","close_reason":"Wired GET /api/curators (names, health, last-run, recent actions) backed by a new bounded in-memory activity tracker in internal/domain/curator, plus a Curators dashboard page at ui/src/curators/.","external_ref":"https://github.com/samcharles93/archie-core/issues/27","source_system":"github:https://github.com/samcharles93/archie-core/issues/27:27","metadata":null,"labels":["enhancement"],"dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-1786637489903-5-fde58498","title":"CLI: technical design interview and PRD for command surface","description":"Run a technical design interview with Sam before making any CLI implementation decisions. Produce a reviewed PRD/specification for the user-facing archie CLI: goals, personas, installation/distribution, configuration and state model, commands/subcommands/flags, output and machine-readable contracts, auth/host targeting, update lifecycle, error semantics, compatibility/migration, and acceptance tests. The eventual implementation must use urfave/cli/v3; do not use or introduce urfave/cli/v2. No CLI code is in scope until Sam approves the resulting PRD.\n\n### Acceptance Criteria\n\nInterview captures Sam's intended CLI workflows and non-goals; PRD defines the complete command surface and state/transport ownership without assumptions; PRD specifies urfave/cli/v3; Sam explicitly approves the PRD before implementation work is created.","status":"closed","priority":2,"issue_type":"task","created_at":"2026-08-08T14:26:34Z","updated_at":"2026-08-08T14:26:36Z","closed_at":"2026-08-08T14:26:37Z","external_ref":"https://github.com/samcharles93/archie-core/issues/26","source_system":"github:https://github.com/samcharles93/archie-core/issues/26:26","metadata":null,"labels":["task"],"dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-1786637489876-4-35aced49","title":"feat(config): optional file logging","description":"archied writes slog JSON to stdout only; under systemd journald is the sole copy, and running by hand leaves nothing. Add a log_file config field so there is a durable copy independent of journald. Prerequisite for the webui logs view showing anything from before the dashboard connected.","status":"closed","priority":2,"issue_type":"task","created_at":"2026-08-08T14:26:29Z","updated_at":"2026-08-08T14:26:31Z","closed_at":"2026-08-08T14:26:32Z","external_ref":"https://github.com/samcharles93/archie-core/issues/25","source_system":"github:https://github.com/samcharles93/archie-core/issues/25:25","metadata":null,"labels":["task"],"dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-1786637489857-3-24abe68c","title":"fix(gateway): make /compress failure-safe","description":"applyCompress swallows MessageCount and DeleteRecentMessages errors (allCount, _ := and _, _ =) then deletes all messages BEFORE saving the compressed replacement. A crash or error between the two loses the session's entire history unrecoverably. Add a store-level ReplaceMessages that saves first and deletes the previously-listed IDs after, so the failure mode is recoverable duplicates rather than total loss.","status":"closed","priority":2,"issue_type":"task","created_at":"2026-08-08T14:26:24Z","updated_at":"2026-08-08T15:33:31Z","closed_at":"2026-08-08T15:33:32Z","external_ref":"https://github.com/samcharles93/archie-core/issues/24","source_system":"github:https://github.com/samcharles93/archie-core/issues/24:24","metadata":null,"labels":["task"],"dependency_count":0,"dependent_count":0,"comment_count":0}