dbb6550ab3088baaaa70203fbed2c50d77641908
6
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b6f0aea930 |
refactor(daemon,webui): make Daemon.Cfg and webui.Server.Cfg reload-safe
Daemon.Cfg, webui.Server.Cfg, and telegramSetup.Cfg were all held by value (or as a raw shared pointer in webui's case), so a future reload path could not swap the running configuration -- the consumers held frozen snapshots made at construction. This is the prerequisite for issue #348. Add config.Holder, a small RWMutex-backed snapshot holder: - Get returns a value copy under RLock; the copy shares its reference-type fields with the published snapshot, so a doc comment pins the immutability invariant (a published Config is immutable; reload constructs a fresh one). - Set replaces the snapshot under WLock. - Get is nil-safe; Set is not. Convert every consumer to read through the accessor. The convention 'cfg := h.Get() once per logical operation' is documented on the type so the next reader knows that inline d.Cfg.Get().Foo is a code smell (a Set could land between two consecutive Gets). Special cases: - webui.Server.Cfg: was *config.Config, a raw shared pointer read from handler goroutines. Convert to *config.Holder. The pre-existing 'cfg := s.Cfg' aliasing bug at api_config.go:295 (which was *trying* to copy but only copied the pointer) now becomes 'cfg := s.Cfg.Get()', which is the value copy the read-only view always wanted. - daemon_test.go: one test mutated d.Cfg.DiffCapLines in place, which the Holder forbids. Replace with the documented read-modify-write pattern (prev := d.Cfg.Get(); prev.X = Y; d.Cfg.Set(prev)). - telegramSetup.Cfg: matches the daemon's API for consistency even though setup runs before the daemon is alive. TaskContext.Cfg in internal/domain/workflow/workflow.go is deliberately NOT converted -- a task that starts under one config should finish under it, and a config changing between TDD and gate stages is a bug, not a feature. Snapshotted at dispatch, as before. Verified: go test ./... (61 packages), go vet, -race on internal/daemon and internal/config. |
||
|
|
951ddbc9f4 |
feat(daemon): consume agent system logs into per-task sinks and the dashboard feed
Closes the loop #451-#453 opened. archie-agent (#453) now publishes its own logs to agentexec.SubjectForSystem(taskID) over NATS, and a task log sink (#452) exists to persist them, but nothing on the daemon side subscribed, demuxed, or wrote anything -- the messages had nowhere to land. - agentexec: SubjectSystemWildcard + TaskIDFromSystemSubject, the inverse of SubjectForSystem, for a daemon subscribing to every task's system subject with one wildcard subscription. - logging: TaskRegistry manages one open TaskSink per running task attempt, mirroring every write onto the live dashboard Feed the same way a locally-written log would appear. Nil-receiver-safe, matching every other optional composition-wired Daemon field. - daemon: Daemon.process opens a task's log sink for its own duration (covering both the sandboxed-container and in-process dispatch paths uniformly) and closes it on every return path. - cmd/archied: constructs the registry, subscribes core NATS to SubjectSystemWildcard, and wires TaskLogs into both Daemon and webui.Server. - webui: archiving a task now removes its log directory too, so archived tasks' logs don't accumulate forever. Documented as a known, accepted race: a task can reach terminal status (satisfying ArchiveTask's precondition) before process() itself returns and closes the sink, so a very late system-log write can race an archive's Remove. Not corrupting -- the write lands on a soon-to-be-unlinked inode and is discarded -- and not worth fixing here: it would mean tying Close to the store transition instead of to process()'s return, a larger change than this issue's scope. Adversarial review (fresh subagent) found and fixed two real issues in the first draft: a doc comment accidentally spliced between two functions during an extraction meant to fix a lint regression, and a genuine test gap on openTaskLog (added, using TaskRegistry.Write's own true/false contract as the observable -- no Store/Forge/Trees fakes needed, since openTaskLog only touches TaskLogs and Log). |
||
|
|
0d500a4ca9 |
feat(webui): lifecycle-safe task controls with atomic retry and archive
Add cancel/stop/approve/reject/retry/abandon/archive to the dashboard task action matrix, each guarded by an optimistic status check against the store. Retry accounting (RetryCount, max_retries) is now atomic with the status transition instead of a separate write. Archive removes a terminal task's local record with a fail-safe audit event first. Add always-labelled responsive navigation, mobile Jump-to search, and versioned Setup-complete dismissal. Fixes #53 |
||
|
|
1f2e7a42eb |
refactor: one definition of what approving or declining a task means
The dashboard and chat both let an operator approve or refuse work, and they had drifted. Declining from the dashboard left the task closed_wont_do; cancelling the same task from chat left it rejected. Two operators looking at one queue saw different states for the same decision, and "rejected" -- which reconcilePRs also uses for a pull request closed without merging -- stopped meaning one thing. internal/gateway deliberately does not import internal/store, so it kept a hand-synced copy of the status strings with a comment asking future editors to keep them aligned. That is the same defect one level down, and it is how the drift happened. internal/taskstate is a leaf package with no dependencies holding the lifecycle vocabulary and the rules for operator actions. gateway, store and the dashboard all import it, so gateway stays decoupled from store without a copy, and CheckApprove/CheckRetry/CheckDecline have one implementation. Declined is named for what it is -- a human said no -- and stays distinct from Rejected, which is something archie observed. Chat cancel now records Declined. That is the behaviour change: same decision, same state, whichever surface the operator used. Rules were preserved rather than tidied while unifying. A parked task still cannot be declined, which both surfaces already refused, even though "not terminal" would have allowed it -- widening a rule under cover of a refactor is how you ship a change nobody reviewed. The comment says where to change it if that is ever wanted. TestDashboardAndChatAgreeOnTerminalStates drives both real surfaces against one store, so this cannot drift apart again without a red test. Also removes a second rule for the dash-top-standalone class: renderSetup already reconciles it from the data at the top of every call, and a later branch cleared it again. Harmless, but it reads as two sources of truth for one bit of layout state. |
||
|
|
170fe0250b |
fix: close the duplicate-work loop and the dead paths around it
Applies the four-reviewer pass over the forge/dashboard-actions work. The through-line is that several capabilities were wired but inert, and one of them could cost real work. DUPLICATE WORK. "Closes #N" was dropped from PR bodies in favour of LinkBranch, which is sidebar linkage on Gitea and a no-op stub on GitHub -- neither closes anything, and nothing else did either. So a merged task left its issue open, labelled and assigned; the next poll re-enqueued it, and once the dashboard's Clear removed the task row that became a second implementation and a second PR for work already merged. reconcilePRs now closes the issue on merge, and a rejected task closes its issue too. A PR closed without merging deliberately leaves the issue open: that usually means "try again". MAX RETRIES. Configured, defaulted and reported by /api/config, and enforced nowhere -- markDead was unreachable and EffectiveMaxRetries had no callers, so the dashboard's retry incremented retry_count forever. The retry action now retires a task to dead at the cap. DEAD ON ARRIVAL. Tasks() never selected plan or source, so the "Decision required" panel could not render and chat tasks -- whose issue number is synthetic -- linked to forge issues that do not exist. COSMETIC FAILURE, FATAL RESULT. OpenPR failed the whole stage when LinkBranch errored, so the pull request was never opened and the task parked; a retry re-links the same branch, which Gitea answers with a conflict, so every retry parked again. It is best-effort now. INVISIBLE ACTIONS. Approve/retry/reject wrote store rows and nothing else, so the timeline and activity stream never showed that a human had intervened. They emit events now. Also: store write failures answer 500 rather than 409; the dashboard surfaces the server's actual reason instead of "409 Conflict"; action buttons stop propagation (acting on a task no longer also expands it), disable in flight, keep per-task errors instead of one shared string, and confirm before rejecting. Removed: the maybeRetryParked shim and markDead with their now-vacuous tests, WaitingTasks (no consumers; its tests were rewritten to assert the same routing through TaskByID), write-only Daemon.Runtime, and dir/dirs response bloat from /api/skills. skillSource checked workDir before sharedDir, mislabelling every shared skill when the two are equal. DefaultRoots now dedupes roots differing only by a trailing separator. The air build rule claiming to keep ui/dist current never ran -- it required one file to satisfy include_dir and include_file together, and ui/ is excluded from the walk. Deleted with the comment that promised it. task test:ui joins task check and CI; it ran nowhere before, so the dashboard suite could rot silently. Docs corrected where they described behaviour that no longer exists: parks no longer comment on the issue, state labels no longer drive retries, and forgerpc's doc claimed four proxied methods while listing three of five. |
||
|
|
4d44ef76f5 |
feat(webui): rebuild the dashboard
The old UI was a single 200-line Go file serving one hand-written HTML page of task rows. It showed that archied was running and almost nothing about what it was doing -- skills, workflows, memory, channels, logs and configuration were all invisible unless you read the source or the config file. The dashboard now covers each of those as its own section, built as a Vite app under ui/ at the repo root: it is a separate artefact from the Go daemon, not an internal package of it. dist/ is committed so building archied never needs a Node toolchain, and the !no_ui build tag keeps an embed-free build available. Both sides are split by concern rather than by layer -- one Go file per API area, one folder per UI section with its own CSS -- so a change to logs cannot disturb tasks. Pages report consequences, not just state: an empty memory page says Archie starts every conversation with no recollection of earlier ones, and the setup checklist names what is missing in plain language instead of showing a grid of zeroes. Nothing greets by a hardcoded name; the operator comes from [chat], which is deployment data. Auth is exposure control, not capability control -- the agent already holds this user's authority through its own tools. So a loopback bind needs no token, and only a reachable bind mints one and logs a URL, which means an instance cannot be exposed merely by omitting config. Container startup now degrades instead of aborting, for the reason resolveForge already does: a missing agent image should not deny the operator chat and the dashboard, and under Restart=on-failure it turns a recoverable problem into a crash loop with the real error scrolling past. `task dev` runs the daemon under air and the Vite server together in one terminal. |