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).
Part of #452 (task-observability epic #450). A task's real work
happens in an ephemeral archie-agent container; currently nothing
persists what it logs once the container exits (AutoRemove: true).
Adds TaskSink: a per-task, per-attempt JSONL log destination sharing
the exact on-disk format the daemon-wide logger already writes (see
Entry/Tail/Query/Components in reader.go), so a task's history is
readable with the same reader rather than a second format to keep in
sync. Backed by the existing rotatingFile, so it gets the same
size-based rotation and retention as the daemon-wide log for free.
Deliberately does not fall back to stderr on open failure the way the
daemon-wide New does: that fallback exists because losing the daemon
over a broken log path is worse than losing the durable copy, and
there is no equivalent daemon-level fallback for one task's log.
This lands only the sink primitive and its own tests. Wiring an
agent-side publisher and a daemon-side NATS consumer into it is
tracked separately in #453 and #454.