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.
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
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
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
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
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.
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.
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.
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.
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).
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.
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.
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.
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.
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.
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.
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.
TestApplicationOwnsNoTransportWireMechanics was failing on main since
d7801bb: 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).
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.
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.
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.
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.
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.
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.
Retry used to retain ignored and untracked output from an interrupted attempt, which CommitAll could publish later. Refresh now derives the tracked HEAD shape, removes every other worktree entry outside .git, and fails closed when the configured base cannot resolve.
Worktree RPC used to accept repository coordinates from the sandbox. It now accepts only an opaque per-dispatch grant, and the daemon derives the repository path and branch from grant-owned state.
Repository worktree paths also move from an ambiguous flattened key to encoded owner/repo components. Origin-matched legacy clones migrate safely; mismatched legacy paths are preserved.