Commit Graph
751 Commits
Author SHA1 Message Date
sam 33da682887 refactor(lint): extract more helpers to clear nestif/gocyclo findings
- toolset.go: extract requireApproval out of toolExecute (nestif)
- gateway.go: extract handleDeny/handleVersion/handleUpdateCheck/
  handleRestartAdapter out of dispatchLocal (gocyclo 26 -> under 20)
- cronstore/store.go: extract applyPatch/applyScheduleChange out of
  Update (nestif, gocognit)

Behavior-preserving.
2026-08-31 21:28:46 +10:00
sam 0d119e58d8 chore: cleanup excessive system prompt 2026-08-31 21:27:26 +10:00
sam 805c508d41 fix(app): repoint capability-host wiring contract test at internal/app/archied
Second architecture test (after contract_test.go) that still grepped
cmd/archied for wiring strings following the cmd/archied ->
internal/app/archied extraction. task check now passes clean.
2026-08-31 21:27:07 +10:00
sam 01a6c4a70e refactor(lint): reduce cyclomatic/cognitive complexity in tools, workflow, webui
Extracts focused helpers out of applyEdits, grepFallback/grepDirFallback,
serveReadContent, handleChatStream, TDD, runFindGoFallback,
makeGrepExecutor and makeShellExecutor to bring them under the
project's cyclop/gocognit/funlen thresholds. Behavior-preserving.

Partial pass on archie-core-agui: richblocks.go (gocognit),
gateway.go dispatchLocal (gocyclo), and a couple of remaining
gocognit/nestif findings are left for a follow-up.
2026-08-31 21:26:22 +10:00
sam 932a8b0680 docs(architecture): reconcile domain package map, add domain/messaging types
- migration-decisions.md: confirm curator/mapping/scheduling as
  legitimate domains that were never added to the confirmed list;
  document identity/agent/messaging/plugin as approved-but-unmaterialised
  targets rather than creating dead stub packages.
- Resolve the open Session/Messaging decision (section 2): keep
  internal/gateway as-is rather than risk a big-bang rewrite of live
  session/compression/approval/branch logic; materialise
  internal/domain/messaging with the already-settled canonical
  Message/Conversation/ToolCall/ToolResult types. Actual gateway
  migration onto these types is tracked as sequenced follow-up bd
  issues (label messaging-migration).
- ARCHITECTURE.md: add internal/gateway, internal/tools, internal/memory,
  internal/secret, internal/plugin, internal/skill to the Package Map.
2026-08-31 21:26:06 +10:00
sam 1ad0fa563c fix(config): standardize Provenance to pointer receivers (recvcheck)
Paths and String were value receivers alongside the mutating record()
pointer method. All Provenance uses are through addressable struct
fields, so this is behavior-preserving.
2026-08-31 21:26:01 +10:00
sam 4e2d90e34b refactor(agentexec): use ai-sdk NewTypedTool for pluginToolSet and scriptToolSet
Replaces hand-written JSON Schema + manual unmarshal with
core.NewTypedTool[In], now available at the pinned ai-sdk v0.1.30. This
removes the class of bug where a hand-rolled schema drifts from the
struct a manual decode unmarshals into.
2026-08-31 21:25:58 +10:00
sam d96f403d93 chore(ci): pin Go version from go.mod and add a govulncheck step
CI's go-version was a floating "1.26" independent of go.mod, so it
could silently drift from the toolchain the project actually builds
with. Switched to go-version-file: go.mod as the single source of
truth, and added `task vuln` (govulncheck) plus a CI scan step -- kept
out of `task check` since it needs network access to the vuln DB.
2026-08-31 21:25:54 +10:00
sam e76f7d5ff0 chore(build): bump Docker builder images from golang:1.26 to golang:1.27-trixie
go.mod is already on 1.27.0 (supersedes the 1.26.6 stdlib CVE fix set);
the Dockerfiles were still pinned to the older 1.26-trixie floating tag.
2026-08-31 21:25:50 +10:00
sam adb958d93c fix(app): repoint archied wiring contract test at internal/app/archied
Follow-up to the cmd/archied -> internal/app/archied wiring extraction:
the architecture test that greps main.go for required wiring strings
still pointed at the old cmd/archied path.
2026-08-31 21:25:45 +10:00
sam 3129422a79 fix(plugin): add missing CLAUDE.md reference to plugin engine rule
Test TestPluginEngineRuleIsCanonicalAndSharedByAgentInstructions was
missing entirely, letting CLAUDE.md drift out of sync with
ARCHITECTURE.md#plugin-engine-rule-strict. Added the test and the
missing reference.
2026-08-31 21:25:20 +10:00
sam ba672965c6 test(coverage): add tests for workintake, secret, forge, natsrpc
Closes coverage gaps flagged in load-bearing packages:
- internal/domain/workintake: 14.3% -> 94.6%
- internal/secret/enginehost: 0% -> 100%
- internal/secret/secretextract: 10% -> 100%
- internal/forge: 36.1% -> 77.0%
- internal/natsrpc: 28.3% -> 91.3%
2026-08-31 21:24:25 +10:00
sam 7a8a13cd88 fix(gateway): fix broken system prompt template and scrub real telegram ID from tests
Funcs() was passed a *strings.Replacer value instead of its Replace
method, panicking gateway's init(). Fixing that surfaced a second bug:
the template still referenced .Operator, removed from promptData by
5465335, which made every render fail and silently fall back to a
generic hardcoded prompt.

Also replaces a real Telegram chat ID hardcoded across several test
fixtures with a placeholder value.
2026-08-29 00:31:47 +10:00
sam 5465335140 refactor: remove unused Operator param. 2026-08-29 00:20:40 +10:00
sam 32c722fe4a refactor: go modernisation fixes 2026-08-29 00:20:05 +10:00
sam 30a8260f7a chore: bump ai-sdk version. 2026-08-29 00:17:16 +10:00
sam 9ce2b6065b refactor: remove unnecessary AI shit 2026-08-29 00:16:43 +10:00
sam fd1276cd4b fix: go.mod bumped to 1.27.0 and stupid tests removed 2026-08-28 23:44:41 +10:00
sam 7e819d85ef chore: fix CLAUDE.md to flow and remove contradictions. 2026-08-28 23:06:17 +10:00
sam ec5e83a995 chore: beads interactions and issues 2026-08-28 22:28:49 +10:00
sam c132aa980d feat(cronstore): durable job store with cross-process locking
Slice 1 of the cron/scheduling epic (archie-core-1786637496320-249-be6d9a20).
Implements the file-backed job store the scheduling ticker engine polls
through scheduling.JobSource. The engine applies no schedule arithmetic
of its own, so the store owns cron expressions, fixed intervals, and
catch-up windows — Slice 1 ships Interval fully, with Once accepted at
Create/fired at Due, and Cron reserved as a wire shape for Slice 2.

Files: per-profile JSON at <path>/jobs.json with a version-stamped
schema. CRUD by job id with merge-semantic Update (nil Patch fields are
preserved). Truncated/partial-write files return ErrCorruptFile; forward
schema versions return ErrUnsupportedSchema. DisallowUnknownFields means
additive shape changes must bump schemaVersion.

Concurrency: three locks stack in fixed order. (1) A package-level
mutex keyed by lock-file path serialises Stores within one process —
Linux flock is per file description, so two Store instances in the
same process have independent fds and would otherwise proceed in
parallel. (2) Cross-process flock serialises Stores across processes
(CLI vs daemon). (3) s.mu guards the in-memory mirror. Every
operation re-hydrates from disk before applying its change so a writer
that just acquired the locks sees every change the previous writer
committed. Atomic write via temp-file + rename + fsync for durability.

Validation: Create and Update validate Pool, Schedule, and required
fields up front so a hand-edited file cannot persist a job the engine
cannot reason about. MarkRun on a kind without next-run arithmetic
returns ErrScheduleUnsupported. Get/List return deep copies so caller
mutation cannot corrupt the in-memory mirror. Files are written 0o600
because payloads can carry operator-identifying data; SetEscapeHTML(false)
keeps operator-readable files human-friendly.
2026-08-28 22:28:49 +10:00
sam 5ce821b561 chore: update issue tracker, remove ai-sdk ADR 2026-08-28 22:28:49 +10:00
sam e88ab5ee85 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
2026-08-28 22:28:48 +10:00
sam ced7bb8038 feat(curator): track and expose recent activity per curator
Add a small bounded activity tracker (activityTracker, in
internal/domain/curator/activity.go) fed directly from the runtime's
existing emitRun point: last-run time, last-run action count, and up to
20 recent actions per curator, newest first. No persistence layer -- it
resets on restart, same as the rest of the runtime's in-memory state.
Registry.RecordActivity/Activity expose it.

Closes archie-core-1786637489932-6-1f803e02.
2026-08-28 22:28:48 +10:00
sam 76d13b76ce fix(telegram): drop retry_after bandaid, bump go-telegram/bot to v1.24.0
go-telegram/bot v1.24.0 fixes getUpdates to honour Telegram's retry_after
on a 429 instead of its own 100ms-doubling-to-5s backoff (release notes:
https://github.com/go-telegram/bot/releases/tag/v1.24.0). pipelineErrorHandler
was our workaround for that upstream gap -- it now just logs.
2026-08-28 22:28:43 +10:00
sam 3b8ac3e8d1 docs: record ai-sdk to goai migration decision 2026-08-28 22:28:26 +10:00
sam 61e7fd3068 feat(webui): dashboard-aware chat — Archie sees the page, points you there
The web chat is now a persistent slide-over drawer available on any page
(not just the /chat route), and the agent is told which dashboard page the
operator is on so it can point them to the relevant page with a clickable chip.

Backend (gateway):
- Message gains a per-message Page field; the system prompt renders it in
  the <env> block (Current page), so Archie knows where the operator is.
- New dashboard_tools.go: a DashboardPages registry plus two web-only tools
  — page_index (lists every page and what it shows) and dashboard_navigate
  (validates a path, returns {path,label}; rejects unknown/empty paths).
- The web chat sink emits a dedicated navigate stream event when the model
  calls dashboard_navigate, independent of ShowToolCalls.

Frontend (webui):
- chat sends currentPage() (location.hash) with each stream request; a
  dashboard_navigate result renders as a clickable link chip (href=#/path).
- The chat is mounted once in a slide-over drawer with a topbar launcher,
  scrim and Esc-to-close; /chat opens the drawer instead of a second page.
- ui/dist rebuilt (committed) with the bundled changes.
- .gitignore: ignore .impeccable/ (impeccable tool critique snapshots).

New capability (per scope discipline): designed in
docs/prds/dashboard-aware-chat-navigation.md.

Tests: dashboard_tools_test (registry, resolve/reject, web-only gating),
prompt page-line cases, webui Message.Page + navigate-frame capture, and
chat-tools chip tests. task check is green.
2026-08-28 22:28:10 +10:00
sam 89dcfae8c6 chore(release): archied v1.19.4
deploy / gate (push) Failing after 3m34s
deploy / build-and-push (push) Skipped
2026-08-28 01:42:27 +00:00
sam 7d8d511dca refactor(telegram): render replies as structured rich blocks
Telegram's rich-message Markdown has no ATX heading support and its MarkdownV2
dialect needs escaping, so hand-building a Markdown string and sending it as
myMarkdown showed literal heading/code markers and mangled unescaped characters.
The previous fix layered blank-line insertion on top of a dialect that could
not render headings at all.

Replace the whole markdown-string pipeline with structured InputRichMessage
blocks: markdownToBlocks emits SectionHeading, Preformatted, List, BlockQuotation
and Paragraph (inline emphasis/code/links reduced to plain text so no marker can
leak), blocksToPlainText feeds the fallback send, and splitBlocks chunks at block
boundaries. sendBlocks, open, edit and the live renderer now send myBlocks.

Delete the dead string surgery (normalizeTelegramText, telegramMarkdown,
telegramPlainText, splitLongMessage, the fence-split cluster and their regexes)
and the tests that pinned it, removing about 1100 lines. splitBlocks and the
parser are unit-tested.
2026-08-28 01:42:09 +00:00
sam e2c24e11e1 chore(release): archied v1.19.3
deploy / gate (push) Failing after 2m43s
deploy / build-and-push (push) Skipped
2026-08-28 00:55:33 +00:00
sam cf06cd6a08 feat(dashboard): render task actions, statuses and filters from the server catalog
Three surfaces stopped keeping hand-synced copies of the lifecycle vocabulary,
so a status or action added on the backend shows up without a frontend change:

- task actions render label/variant/confirm from taskstate.ActionCatalog via
  actionFor(); unknown actions no longer vanish behind a hardcoded switch and
  a new action needs no frontend case
- status labels and pill severities come from taskstate.Statuses via
  statusLabel()/statusKind(); the local copy and the dom.js switch are gone
- the status filter vocabulary and the "needs you" grouping derive from
  statusIds()/attentionStatusIds(); a new status appears in the filter and in
  the settings page's Work lifecycle card, driven by /api/task-meta

Regenerated ui/dist so the embedded binary ships the new dashboard.
2026-08-28 00:55:17 +00:00
sam 23e0895ea2 feat(tasks): serve the lifecycle presentation catalog from /api/task-meta
Archie owns the status and action vocabulary in internal/taskstate, but the
dashboard had to keep a hand-synced copy of the display labels, pill severities
and action confirm prompts -- so a new status or action silently rendered
wrong until someone edited the frontend.

- add taskstate.Statuses() and taskstate.ActionCatalog() so the rules and their
  presentation live in one place
- expose GET /api/task-meta returning {statuses, actions}
- add a client base/task-meta.js that fetches the catalog and exposes
  statusLabel/statusKind/statusIds/attentionStatusIds/actionFor, with a
  freeze-dried default snapshot so the dashboard renders instantly and keeps
  working when archied is unreachable
- tests for the catalog, the endpoint and the client accessors
2026-08-28 00:41:12 +00:00
sam 9cc6d7a4c7 chore(release): archied v1.19.2
deploy / gate (push) Failing after 2m33s
deploy / build-and-push (push) Skipped
2026-08-28 00:19:45 +00:00
sam 47a7af74e8 feat(tasks): allow rejecting a task from any non-terminal state
An operator could only reject work that was waiting on a human decision, so a
task sitting in review (PR open) or running had no way to be refused even
when it was clearly dangerous.

- expose reject in taskstate.Actions for every non-terminal state (queued,
  running, waiting_human, parked, pr_open) so both the dashboard and the chat
  tool surface it; terminal states still only expose archive
- make rejectTask transition from the task's actual status to closed_wont_do
  and interrupt running execution first, so nothing keeps working against a
  task being closed out
- keep the distinct stop (recoverable → parked) semantics; reject is the
  terminal escape hatch
- update the lifecycle contract tests to the new intent
2026-08-28 00:19:27 +00:00
sam fb36e5933e chore(release): archied v1.19.1
deploy / gate (push) Failing after 2m26s
deploy / build-and-push (push) Skipped
2026-08-27 23:33:46 +00:00
sam ab8583e1f9 fix(telegram): keep Markdown headings/lists as blocks and strip Markdown on plain fallback
- insert blank lines around ATX headings and list blocks so Telegram does not
  collapse them into the surrounding paragraph
- leave the SDK's compact triple-backtick tool fences unstyled (do not re-space)
- strip Markdown syntax when the rich send/edit falls back to plain, so the
  user never sees raw '#', '**', backticks or link brackets
- log telegramRenderVersion + mode on every outgoing message
2026-08-27 23:33:24 +00:00
sam 365297a4cb chore(release): archied v1.19.0 archie v1.18.0
deploy / gate (push) Failing after 3m38s
deploy / build-and-push (push) Skipped
2026-08-27 21:40:38 +00:00
sam 08eebcdf5a build(deps): upgrade github.com/samcharles93/ai-sdk to v0.1.29 2026-08-27 21:40:01 +00:00
sam b369f24360 chore(beads): close vq92 (task_logs pagination) 2026-08-26 02:02:42 +10:00
sam 5e240721e2 feat(logging): cursor pagination and filtering for task_logs
task_logs could only read the newest N entries with no way to walk the
rest, so a task's log beyond the page cap was unreachable and the agent
had no honest way to say what was missing. Add logging.Page -- a
byte-offset cursor over the tail-most 8 MiB scan window -- plus
Query.Since/Until time bounds, and wire the gateway's task_logs tool to
expose level/since/until/after_id with cursor and more_available in the
result.

The reader now reads the scan window into a single in-memory buffer and
walks it by exact slice offsets. Offsets into a contiguous buffer are
trivially correct, which an incremental reader over the file is not:
bufio.Reader buffers ahead, so its underlying file position runs one
buffer past its logical position and cannot be used as a cursor. The
same rewrite removes f.Read in favour of f.ReadAt (full-or-error), since
a silent short read would drop the newest entries and still report
success.

The scan window is a documented hard ceiling: for a log over 8 MiB the
oldest bytes are unreachable by any cursor -- that is what Truncated
reports, and send_file remains the path for a complete archive. The
tool description teaches the model the difference between more_available
(more this call did not return) and truncated (older entries the scan
cap hides).

Closes archie-core-vq92 (#625).
2026-08-26 02:02:36 +10:00
sam 36501daf8a chore(beads): close shipped production fixes 2026-08-26 01:05:56 +10:00
sam 068544c180 chore(beads): record GitHub issue links 2026-08-25 05:57:01 +10:00
sam 8bd7b12a3d chore(release): archied v1.18.0 archie v1.17.0
deploy / gate (push) Failing after 2m30s
deploy / build-and-push (push) Skipped
2026-08-25 05:50:01 +10:00
sam a1f447dcda chore(beads): record task observability work 2026-08-25 05:49:28 +10:00
sam a825db283c fix: harden task and chat execution
Task runs now preserve real model context limits, provider usage, baseline-repair spend, commit identity, durable agent-finish telemetry, and useful timeline details without imposing a token cap. Dashboard forge links are canonical per owning GitHub or Gitea identity. Chat turn claims acquire SQLite writer intent before reading, eliminating the concurrent SQLITE_BUSY snapshot race.
2026-08-25 05:48:17 +10:00
sam 9e6f507c06 chore(release): archied v1.17.1 archie v1.16.1
deploy / gate (push) Failing after 2m37s
deploy / build-and-push (push) Skipped
2026-08-25 03:29:11 +10:00
sam 694a977ffe fix(agentworker): reconcile task clone ownership after commits 2026-08-25 03:28:40 +10:00
sam 77b1eaa2df fix(gateway): make UUIDv7 session references unambiguous 2026-08-25 03:28:38 +10:00
sam 3ce8c7dd49 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.
2026-08-25 03:28:37 +10:00
sam a41283ca96 chore(release): archied v1.17.0
deploy / gate (push) Failing after 3m36s
deploy / build-and-push (push) Skipped
2026-08-25 03:06:24 +10:00