Commit Graph
664 Commits
Author SHA1 Message Date
sam aaa9e85dd4 fix(agentexec): recover omitted finish calls 2026-08-24 14:56:56 +10:00
sam c2b4df6b21 Merge pull request #615 from samcharles93/worktree-shimmering-churning-lobster
fix(worktree): clean untracked files when .git is a gitdir file
2026-08-24 14:54:32 +10:00
sam 4165178dcb Merge pull request #614 from samcharles93/feat/275-ticker-engine
Feat/275 ticker engine
2026-08-24 14:37:21 +10:00
sam ef75feb9b4 chore(gateway): apply go fix rewrites in stream.go
Pre-existing code `task fmt` rewrites on every run: a manual clamp to
`max`, and a `strings.Split` range to `strings.SplitSeq`. Both are
semantically identical; committing them keeps the gate from reporting a
dirty tree on unrelated work.
2026-08-24 13:28:51 +10:00
sam da07c39ca8 feat(scheduling): ticker engine with configurable interval and pools
Adds internal/domain/scheduling, the timing half of the cron/scheduling
epic (archie-core-1786637496320-249-be6d9a20): a tick loop that asks a
JobSource what is due at a configurable cadence and dispatches each due
job to the pool it declares.

The package owns *when* a scheduled job runs and nothing else. The job
store, blueprints and delivery routing are separate issues in that epic,
so the engine declares the two contracts it needs from them (JobSource,
Runner) and names no implementation. That is what lets the timing
behaviour be tested against a fake clock with no store, no NATS and no
model.

Behaviour worth stating explicitly, because each is load-bearing:

- The source is authoritative about what is due. The engine applies no
  schedule arithmetic of its own, so cron expressions, fixed intervals
  and catch-up windows stay the store's decision.
- A job never overlaps itself. While a run is queued or in flight, later
  ticks reporting the same ID are skipped rather than stacked, so a job
  slower than the interval runs back-to-back instead of fanning out.
- The pools do not interfere: a blocked sequential job cannot delay a
  parallel one, and a saturated parallel cap cannot delay the sequential
  worker. They share only the tick.
- An empty Pool means sequential, not parallel. Wrongly serialising a
  job costs latency; wrongly parallelising one costs correctness.
- Every failure is contained and reported: source error, job error, job
  panic and job timeout each emit an event and leave the loop running.
- Stop drains gracefully. Run contexts descend from Background rather
  than the loop context, so halting the loop stops new work without
  yanking the context out from under a run already in progress; the
  caller's deadline is what eventually cancels those.
- An engine is single-use. Restarting after Stop is refused because Stop
  leaves the dropped backlog and the claims of runs it did not wait for
  behind, and a restart would re-run stale queued jobs while permanently
  suppressing the claimed ones.

internal/events gains job_run/job_error: a scheduled run has no task and
no chat turn behind it, so without those kinds a job that fired, stalled
or failed is invisible everywhere.
2026-08-24 13:28:45 +10:00
sam 41446c5c96 fix(worktree): clean untracked files when .git is a gitdir file
cleanUntracked returned filepath.SkipDir for the ".git" entry
unconditionally. On a non-directory, SkipDir skips the remaining
entries of the *parent* directory -- at the worktree root that is the
rest of the walk. A repository whose .git is a gitdir pointer file
(a linked worktree, or a clone adopted by migrateLegacy) therefore had
cleaning silently no-op, and CommitAll staged and published the
previous attempt's abandoned untracked files onto the task branch.

Suppress descent only for the directory shape; the pointer file is
skipped as an ordinary tracked-path miss would be, and left intact.

Refs archie-core-1ysw.3
2026-08-24 13:11:40 +10:00
sam 3421be48a4 fix(telegram): corrected tool outputs to keep context of tool calls (#609) 2026-08-24 07:46:42 +10:00
sam b223b3031c chore(release): archied v1.14.0 2026-08-23 16:47:28 +00:00
sam 53e6c1ad55 Merge pull request #608 from samcharles93/fix/604-telegram-tool-output-pipeline
fix(telegram): compact tool output and drop turn caps
2026-08-24 02:45:43 +10:00
sam cc53e5258d fix(telegram): compact tool output and drop turn caps
Render completed ToolCallEvents as Telegram-safe streaming blocks
with compact name/status and a short cleaned preview. Summarize
file contents and listings instead of dumping source or quoted
JSON. Collapse repeated legacy turn-budget failures.

Remove max_tokens turn gating and the 200000 turn_budget_chars
default so absent or commented config cannot restore an aggregate
cap. Keep per-result max_result_chars and spill.

Confine find/grep discovery to the active workspace/worktree.

Refs #604
2026-08-23 16:40:16 +00:00
sam c7a06c6a1f Merge pull request #607 from samcharles93/fix/component-aware-updates
fix(update): install only approved components
2026-08-24 02:31:22 +10:00
sam 6a8fa1a090 fix(update): pin builds to approved release tags
Build selected components from a temporary worktree at the exact approved tag commit instead of the moving branch tip. Validate release version inputs and require combined component tags to resolve to the same source commit.\n\nRefs #606
2026-08-23 16:28:30 +00:00
sam 2ff09193cd fix(update): install only approved components
Carry the revalidated update snapshot through the installer contract so the shell adapter receives an explicit per-component plan. Build, back up, install, and roll back only selected components, and pass the runtime release version into agent image builds.\n\nCovers gateway-only, runtime-only, combined, and no-op updates.\n\nRefs #606\nBead: archie-core-462t
2026-08-23 16:18:30 +00:00
sam 785f10e496 chore(release): archied v1.13.0 2026-08-23 15:49:43 +00:00
sam 7b147a8a10 chore: apply gofumpt formatting 2026-08-23 15:49:40 +00:00
sam 6bfffc1ee6 Merge pull request #605 from samcharles93/fix/telegram-tool-progress-project-context
fix: make Telegram tool progress readable and bounded
2026-08-24 01:46:01 +10:00
sam 8d0d6f2498 chore(beads): record tool progress UX task 2026-08-23 15:35:20 +00:00
sam fe7246be33 fix(telegram): render tool progress as bounded code blocks 2026-08-23 15:34:38 +00:00
sam 167e8f3891 fix(scripts): replace archie-update-check with carina's real production version
The version committed in the previous commit was authored blind,
without knowing a real archie-update-check already existed and has
been running on carina (production) since Aug 9 -- just never
committed to the repo. That live version is better designed than what
I wrote: it introspects the actually-running binary via `archied
-version` rather than trusting git/filesystem state that could have
silently diverged from what's really installed, and uses `git
ls-remote` for the available version instead of a local fetch, so the
script has no side effects and no dependency on the checkout being a
buildable Go workspace.

Adopt it as the canonical version, with one real fix: it used
Component IDs "archied"/"archie-agent", which don't match
releaseupdate.ComponentDaemon="daemon"/ComponentAgent="agent" --  the
same convention archie-update-watchdog's report and this session's
Service.Enrich already use. Under the old IDs, neither ever actually
applied to carina's real update checks; the mismatch was silent since
an unrecognised component ID just leaves InstallType/Reference/
Verify() unset rather than erroring.
2026-08-24 00:45:38 +10:00
sam d2ed34621c fix(scripts): also refresh archie-update-check on every /update
Install only refreshed itself and the watchdog from the freshly
pulled checkout, so a bootstrapped archie-update-check would never
pick up a later fix to itself the way the other two adapters do.
2026-08-24 00:32:54 +10:00
sam eaa436b09b docs+scripts: add archie-update-check, document missing config sections
The check-side of the reference update adapter never existed:
scripts/ had archie-update-install and archie-update-watchdog but no
archie-update-check, so any deployment that configured
chat.telegram.update_check_command pointing at the documented
"/usr/local/bin/archie-update-check" path had nothing there to run --
/update would report "not configured" regardless of what was actually
set. Add it: read-only, reports the daemon/agent components via git
describe against the local checkout and origin/main (no fetch-and-pull
the way install does), using the same "daemon"/"agent" component IDs
archie-update-watchdog's report and releaseupdate.ComponentDaemon/
ComponentAgent already use, so Service.Enrich and Report.Verify (this
session's earlier work) recognise it automatically.

Also fix archie-update-install's archie-agent build: it stamped
archied's ldflags but built archie-agent with none at all, so even a
native (non-container) archie-agent install reported an unstamped
"dev" build with installtype.Unknown.

config.example.toml gained every section that existed in the Go schema
but wasn't documented anywhere, not even commented: skills_dir,
plugin_dir, [chat.email], [chat].webhook_addr, [log], [memory] (noted
as currently unwired -- RegisterExternal is declared but never called
from cmd/archied, so the section has no effect yet), [[identities]]
(pointer to docs/architecture/identity.md rather than duplicating it),
and [[repos]].max_retries. tools.tool_policy.parallel_execution was
deliberately left undocumented: it's declared on ToolPolicy but never
read anywhere, genuinely dead rather than just underdocumented.
2026-08-24 00:32:37 +10:00
sam 1eb2d36f83 docs: add RELEASING.md, stop asking whether to skip an untouched component
Every release session asked the same question and got the same
answer: archie-agent has no unreleased changes touching its own
package closure, so skip it. Codify the rule instead of asking each
time -- only version a component with actual unreleased commits in
its closure, don't bundle an unrelated backlog into an unrelated
release just because it's "due", and don't ask when the answer is
mechanically decided by tools/release.sh's own dependency check.

CLAUDE.md's Release process section pointed to duplicated instructions;
replaced with a pointer to RELEASING.md so there's one source of truth.
2026-08-23 23:40:45 +10:00
sam 0ec252c4bf chore(release): archied v1.12.0 2026-08-23 23:39:22 +10:00
sam 0356eac0e4 chore(beads): sync interaction log 2026-08-23 23:38:55 +10:00
sam 08fa79e5af feat(webui): surface per-component update status on /api/version and Configuration
The prior two changes gave every component an InstallType/Reference
and a way to observe what's actually running (installtype.Type(),
daemon.AgentStatus, [nats] config), but nothing consumed any of it --
an operator still had no single place to see whether a component's
actual running state agrees with what the update-check command
claims.

Add GET /api/version: per component, install type, observed running
version, the check command's installed/available claims, and a
computed status -- ok / update_available / drift / unknown. drift
takes priority over update_available (a claim the running system
contradicts is worse than a newer release merely existing), and a
component with no installed claim at all reports unknown rather than
guessing "ok" or "update_available" from a comparison that was never
actually made.

Surface it as an "Update status" card above the Configuration page's
existing config view, sourced independently so its own failure (or a
501 on deployments with no update-check command configured, which
renders nothing rather than an error) never blocks the config view
that's already there.

Closes archie-core-1786751948782-3-837a8fd0.3 and, with it,
archie-core-1786751948782-3-837a8fd0 (all 5 design points landed).
2026-08-23 23:36:44 +10:00
sam 25af279d7a feat(releaseupdate): enrich components with install type and reference
Component.Installed/Available come from an operator-owned external
check command, which reports what version exists but has no way to
know how THIS process/deployment actually installed it -- native
binary, container, or embedded process. Two sources for that already
exist and were previously unused for this: internal/installtype
(this process's own build-time stamp) and daemon.AgentStatus (an
archie-agent version observed at runtime, landed in the prior commit).

Add Component.InstallType/Reference and a Service.Enrich hook that
fills them in per component ID after the check command runs, without
overwriting whatever a check command already reported for an ID it
doesn't recognise. Wire the actual sources in cmd/archied via
componentInstallTypeEnricher: the daemon's own installtype.Type(),
the agent's most recently observed install type, and -- for NATS, a
third-party dependency this repo doesn't build -- "embedded" or
"external" (with its URL) read straight from [nats] configuration,
which is already the deployment profile's own record of how NATS is
run. This is wired into the single Service construction shared by
Telegram and the dashboard, so both surfaces get it for free.

Part 2/3 of archie-core-1786751948782-3-837a8fd0 point 4. Closes
archie-core-1786751948782-3-837a8fd0.2.
2026-08-23 23:28:52 +10:00
sam 44b0181485 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/2873cbb, 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.
2026-08-23 23:18:00 +10:00
sam 01dd72ab04 fix(webui): give dashboard-initiated updates a phase-2 report
handleChatUpdateInstall called Install with InstallMeta{Channel:
"webui"} and no ReportPath, so the update watchdog's write_report()
silently returned without ever persisting a phase-2 outcome
(restart/health-check/version verification). Telegram had this via
reportPendingUpdate/SendPendingReport; the dashboard had nothing --
an operator who approved an update from the webui only ever saw the
synchronous phase-1 install result, never whether the daemon came
back up on the version it claimed.

Give webui its own report path (updateReportPath(cfg.WorkDir,
"webui"), hashed the same way as Telegram's per-identity path so the
two can never collide) and a boot-time reportPendingUpdate, mirroring
Telegram's but emitting a structured events.KindUpdateReport onto the
existing SSE/activity stream instead of a chat message -- the
dashboard has no session-scoped recipient to route text to the way a
chat ID gives Telegram one. Report.Verify's Confirmed/Drift/Unverified
partition (c25799e) is reused as-is; only the surface differs.

Closes archie-core-nln7 / GH#531.
2026-08-23 22:58:05 +10:00
sam 1f93eab94b chore(release): archied v1.11.1 2026-08-23 22:31:28 +10:00
sam 88a47e00b2 chore(beads): sync interaction log 2026-08-23 22:31:15 +10:00
sam 4f3e3f8754 fix(webui): theme the Workflows 'Start work' form controls
renderStartWork built raw input/select/textarea elements with no CSS
class, so they fell back to browser-default white boxes against the
rest of the dark theme. Style them like the app's other themed form
controls (Configuration's .kv-input).

Closes archie-core-w35v.
2026-08-23 22:23:12 +10:00
sam 5a29dedbcd Merge pull request #563 from samcharles93/fix/update-runtime-personality-wiring
fix: keep Telegram updates alive and wire personalities
2026-08-23 15:54:44 +10:00
sam 43d349af38 fix(update): wire Telegram personas and survive callback cancellation 2026-08-23 04:29:18 +10:00
sam e5f6bbd020 chore(release): archied v1.11.0 2026-08-23 04:15:11 +10:00
sam 634d7e0b61 chore(beads): close release blockers 2026-08-23 04:14:36 +10:00
sam 67d77edb01 fix(gateway): back off ClaimTurn race retries
The concurrent regression retried SQLITE_BUSY immediately, allowing the losing goroutine to exhaust all attempts before the winning transaction was scheduled to commit on GitHub Actions. Yield for one millisecond between bounded busy retries; non-busy errors still fail immediately and exhausted contention still fails the test.
2026-08-23 04:08:49 +10:00
sam 06d1922f38 fix(gateway): isolate ClaimTurn race trials
The regression used to start all 100 two-store races at once, so it measured global SQLite writer saturation as well as the same-turn insert race. GitHub Actions exhausted the immediate busy retries before competing transactions could finish. Each trial now still releases both independent stores together, but joins them before starting the next turn ID, preserving the intended race without unrelated cross-trial lock contention.
2026-08-23 04:01:21 +10:00
sam 7bbc31be15 fix(gateway): restore media result after adapter removal
BasePlatformAdapter used to own SendResult even though no live channel implemented that adapter contract. The adapter is now gone, but launch-scoped MediaSender values still need the delivery result to classify Telegram failures. Keep SendResult with the media capability contract and make the tests describe senders instead of reviving the dead lifecycle abstraction.
2026-08-23 03:27:44 +10:00
sam 3f0de9f696 Merge pull request #562 from samcharles93/fix-agentworker-json-import
fix(agentworker): move JSONL decode into storage, unblocking CI
2026-08-23 03:00:32 +10:00
sam 27ea40fec5 fix(agentworker): move JSONL decode into storage, unblocking CI
TestApplicationOwnsNoTransportWireMechanics was failing on main since
d82b232: persistent_runner.go imported encoding/json to decode its
own project-memory JSONL log, which the architecture test treats as
a transport-wire-mechanics violation. That ban exists to keep NATS
message encoding out of the app layer -- this was local disk I/O, not
wire traffic, but the test can't tell the difference from an import
alone, and it shouldn't have to: the fix is to not decode JSON in
agentworker at all.

storage.ReadJSONLines is AppendJSONLine's read-side counterpart,
added to the package that already owns this format (see
organisation.md, "a package owns its own format end to end").
persistent_runner.go now calls it instead of scanning and decoding
itself, and no longer imports encoding/json or bufio.

This was blocking every deploy.yml run on main, independent of and
found while shipping the video-generation PR (#561).
2026-08-23 02:57:41 +10:00
sam 485b55b95b Merge pull request #561 from samcharles93/worktree-federated-wiggling-milner
feat: video generation via MiniMax, with a channel media-delivery pipeline
2026-08-23 02:54:19 +10:00
sam 61aec59c3e chore: beads interactions and issues 2026-08-23 02:51:45 +10:00
sam e04045907c feat(archied): wire generate_video end to end, gate it behind config
drainChatStream now detects a tools.MultimodalResult in a tool
result's Output and reports each URL via turn.Media(...), alongside
the existing turn.ToolCall(...) narration -- the missing link between
a tool producing media and a channel delivering it.

MinimaxConfig registers the tool only once an API key actually
resolves (registerMinimaxTool), matching web_fetch's "never advertise
a broken capability" pattern. Off by default, unlike web_fetch: this
spends real API credits per call.
2026-08-23 02:48:25 +10:00
sam 6834452870 feat(tools): add generate_video tool via MiniMax video generation
internal/tools/minimax wraps MiniMax's v2/video_generation (submit)
and v2/query/video_generation/{id} (poll) endpoints. Generation is
asynchronous on MiniMax's side but archie's tool subsystem has no
async-tool flow control (ToolEntry.IsAsync carries no flow control
today), so GenerateAndWait blocks the calling goroutine -- a tool
call, not the model's own generating goroutine -- submitting and
polling until the job reaches a terminal status or MaxWait elapses.

The poll loop tracks elapsed time purely from its injected Sleep
calls rather than a real time.Now() deadline, so a test that fakes
Sleep as an instant counter also makes the loop terminate instantly
instead of spinning in real wall-clock time.

Text-to-video only for now; image-to-video (image_url content items)
is a schema-and-routing change this can grow into. The tool returns a
tools.MultimodalResult carrying the video as a URLs entry -- the
shared envelope the gateway wiring downstream turns into a delivered
attachment.
2026-08-23 02:48:20 +10:00
sam da8ffc0908 feat(tools): add MultimodalResult.URLs for remote-hosted media
MultimodalResult only modeled local bytes written under SubdirHint
(Files). A tool whose media lives at a remote, already-hosted URL --
a generation API's result, for example -- had nowhere to put it.
MediaRef{Type, URL} and the new URLs field give it one, reusing the
existing envelope rather than forking a second convention for the
same concept.
2026-08-23 02:48:12 +10:00
sam f6d7d0dce2 feat(webui): render a media event as a link fallback
The dashboard has no inline media rendering path yet
(archie-core-1786748942243-6-f109697e). chatStreamSink.Media degrades
a MediaEvent to a link appended to the delta stream -- the same
fallback Telegram's liveReply uses when its own SendMedia call fails
-- rather than the event reaching nowhere.
2026-08-23 02:48:06 +10:00
sam d7308b9207 feat(telegram): deliver media attachments, capability-gated
telegramMediaSender routes a MediaAttachment to the matching Bot API
method (sendVideo/sendPhoto/sendAudio/sendDocument) rather than
sendMessage, which cannot carry a file. It is constructed per-launch
from the same *bot.Bot the update handler already has, matching
telegramApprover's lifetime rule: a /restart abandons an in-flight
send against the outgoing bot instance rather than silently
redirecting it through the new one.

liveReply.Media wires TurnStream into this: it checks
gateway.CapabilitiesOf before attempting delivery -- not just on
failure -- so a sender that already knows it cannot deliver a given
media kind never costs a doomed network round trip. Either path
(capability-limited or a failed send) falls back to rendering the
attachment's URL as a visible link, so a generated asset is never
silently dropped.

newMediaSender is an injectable field so tests can prove the
capability check actually short-circuits, since the real Telegram
sender always reports Media: true and can't exercise that path
itself.
2026-08-23 02:48:01 +10:00
sam 242ae53fdf feat(gateway): add MediaSender/CapabilityReporter and TurnStream.Media
Channels had no shared contract for delivering non-text tool output --
MessageEvent/MediaAttachment/MsgVideo existed but nothing produced or
consumed them. MediaSender and CapabilityReporter give a channel an
optional, capability-queryable way to deliver an attachment; TurnStream
gains Media(event) alongside Delta/ToolCall so a tool's media reaches
the channel in the same ordered pass as its text.

CapabilitiesOf takes any deliberately: it must not depend on the
soon-to-be-removed BasePlatformAdapter (archie-core-azbo), since the
live channels implement channels.Channel, not that interface.
2026-08-23 02:47:53 +10:00
sam 00c5e06152 refactor: remove dead BasePlatformAdapter code 2026-08-22 23:23:51 +10:00
sam 657fdaf3f0 chore: beads interactions and issues 2026-08-22 22:06:55 +10:00