a7d6f71d5a2c9da170a46bfc4471f9979189de87
14
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
a7d6f71d5a
|
feat(identity): verify provider tokens and attribute task actions to their actor
Two halves of one boundary: a credential resolves to an identity, and an action records which identity acted and whose authority it used. resource server. internal/infrastructure/oidc verifies a provider-issued bearer token against the provider's published keys, using an OSS OIDC library: archie compares no signature, validates no claim and rotates no key itself, holds no client secret and issues no session, so a compromised archie cannot mint an identity. Audience is required rather than optional -- a token minted for another service must not authenticate here -- and discovery happens at construction, so an unreachable provider is a startup failure rather than a request-time surprise. identity.Authenticate is the single place a credential becomes an identity, and it refuses in four distinguishable ways: no credential presented, a credential that did not verify (wrong key, expired, wrong issuer, wrong audience, malformed), a verified subject with no identity bound to it, and an identity that may not act. The order is deliberate: verification happens before any field of the token is used, so nothing an unverified token carries can select an identity. A suspended identity is refused even though its credential verified, because suspension is archie's decision and must not depend on the provider withdrawing a token. The binding is the second bridge beside the legacy-name alias: identity_subjects keys (issuer, subject) so the same subject string from another issuer is a different caller, and rebinding moves a subject so two identities can never claim one provider subject. The contract Authenticate needs is SubjectResolver, narrower than Repository, so a consumer that only authenticates does not take the whole identity CRUD surface -- and staterpc.Client, which asserts Repository, does not need a new RPC to satisfy it. attribution. taskactions now records two identities per action: the acting identity and the authorising principal, both on the event row as new columns added through the existing migration table. The rule that the bug turned on is enforced by the event kind describing the actor: a person's approval is human_approved, an agent's is agent_approved, and an action with no verified actor is task_approved, a task-level event that credits nobody. An agent acting under a person's standing approval records itself as the actor and that person as the principal, so "approved by came from me" is answerable from the record rather than asserted. Scope and actor are separated: scope decides which task a caller may touch and is never promoted into an actor, because the dashboard's credential is a shared token and possession of it is not evidence that a person was at the keyboard. That last point is a deliberate fidelity trade, and the reason the transport is not wired: the dashboard action path passes no actor yet, so dashboard approvals are now recorded as task_approved rather than claimed as a human's. Recording nothing false is the requirement; naming the human verifiably needs the dashboard to authenticate a token and resolve it, which needs two new state-store RPCs (ResolveIdentitySubject, BindIdentitySubject) -- the next piece, not a rewrite: the verifier is a one-method interface, so introspection would be a second implementation of it. Verified: task check exit 0; focused runs recorded in the handoff. Opaque authelia_at_ tokens were inspected rather than assumed and cannot be verified against public keys; infra is configuring access_token_signed_response_alg RS256 on the archie client, with audience https://archie.catlow.cloud and issuer https://auth.catlow.cloud. |
||
|
|
a484693f11
|
refactor(logging): pass the caller's context to TaskRegistry.Write
Write built its own context.Background() for the handler call, which meant any new caller with a context to offer could not hand it over. Taking the caller's context is what the next commit's park-reason writer needs, and it is what contextcheck requires of a daemon-side writer. No behaviour change: the context is used for the handler's own attribute extraction and never consulted for cancellation -- a park is recorded at exactly the moment a run's context has been cancelled, so a cancelled context must not suppress the entry. |
||
|
|
21d8250cde |
feat(webui): read a task's log through the State Store and let it be downloaded
The dashboard's attempt-log panel answered every read with "task logging is
optional and was not enabled for this run". That message was false: logging is
wired unconditionally in the daemon, and the log files exist. The dashboard
process simply had no reader -- composition left TaskLogs absent because no
contract carried it -- so the handler saw a nil registry and reported the
disabled shape, which the page rendered as a claim about configuration.
internal/logging now answers whether an attempt has a log at all: Tail sets
Result.Found, so "this attempt has no log" is a value rather than an empty
list indistinguishable from a read that never happened. Its registry gains
TaskLog (a decoded page) and TaskLogContent (the file verbatim, streamed,
because a log is unbounded input), and an absent reader reports
ErrTaskLogsUnavailable rather than an empty page -- a process that cannot read
logs must not implicate the attempt.
Those two answers travel the State Store contract as storecontract.TaskLogStore
(ReadTaskLog, StreamTaskLogContent) and are rehydrated on the client by
(Unavailable, canonical message), so archie-ui composes the reader from its own
store client instead of opening another process's files. The daemon's registry
is wired as the server-side reader in the State Store process only.
On top of that read, GET /api/tasks/{id}/logs/download serves the attempt's log
as a Content-Disposition attachment named task-<id>-attempt-<n>.log, and the
panel offers it. The JSON route keeps its shape and gains found, so the page
states the attempt has no log instead of blaming a setting.
Task log files stay owned by their directory's owner: archiving still removes a
task's log directory, and that removal is the daemon's, not the dashboard's.
|
||
|
|
e84aded3fb
|
refactor(state): delete the dead IncrementRetryCount RPC (breaking change, accepted)
IncrementRetryCount had zero production callers -- only tests and the staterpc plumbing referenced it. taskactions.Service.applyRetry already uses the atomic RetryTask exclusively, which increments retry_count and requeues in one transaction. Unlike ListCaptures/ListUndispatchedCaptures (kept as declared-unconsumed compatibility surfaces because a rolling deploy could have an old client/server pairing mid-flight), this repo has one production consumer (see AGENTS.md's solo-project note), so the breaking removal is accepted outright rather than deprecated-and-kept. Deleted the Go method, the storecontract interface entry, the staterpc server/client methods, and the RPC/messages from state.proto, regenerating the .pb.go/_grpc.pb.go pair. Test fixtures that used IncrementRetryCount as a setup helper now drive retry_count through the real path instead: queries_test.go bumps it via direct SQL (same package, no contract to route through), and api_tasks_actions_test.go now loops RetryTask+Transition, which exercises production code instead of a deleted one. |
||
|
|
19062a702d |
refactor(webui): take configuration off the dashboard server
webui.Server declared Cfg *config.Holder with eight read sites, none of
which ran in the UI process: composition leaves it nil there. The field
survived because the daemon kept a webui.Server it never served, using it
to render the published ConfigView snapshot and to hold the readiness
probes (archie-core-ml30).
Split at the producer. LocalConfigView becomes webui.BuildConfigView, a
pure function over a ConfigViewInput the configuration owner assembles;
the DTO and its schema stay where the UI renders them. The daemon builds
that input from its own state (boot.configViewInput) and publishes the
result. Readiness reads the daemon's Holder, channel manager and chat
contract, and the registry it produces is a daemon field, not a field on
a server with no listener. Boot now owns one Holder instead of seeding a
second and replacing it in buildDaemon; operator retry caps read it too,
so they follow a reload rather than a boot-time snapshot.
Server loses Cfg, ConfigProvenance, LastReload, ConfigOverrides and
SetProvenance. The nil-guarded branches they fed went with them, each
checked first against what the UI process actually serves:
- chat.show_tool_calls and the /api/setup checklist were degraded, not
dead. ConfigView gains a chat section carrying show_tool_calls, the
operator name and whether a channel is configured, and both surfaces
read the projection. The end-to-end suite asserts the checklist renders
from the published snapshot.
- /api/logs takes its path as a process-local option. The history is on
the daemon's disk, so a dashboard elsewhere cannot read it by learning
the path; that route still needs a contract.
- handleChannels drops its config-derived fallback, superseded by the
status manager, which already carries the descriptions and detail.
- trustForwardedHeaders keeps only the process's own setting, which the
UI process already sets.
- resolveForge keeps the published-projection path it already had.
ConfigView.Editable moves to handleConfig, decided by whether this
process holds UpdateConfig. It describes the writer, not the document, so
the write contract (archie-core-j28m) makes the page editable by wiring
one field. The write handlers and their seams stay for it.
overlay.Store gains Keys: Snapshot nests dotted keys for decoding, so the
overridden-key list was publishing section names ("budgets") where the
dashboard marks and resets rows by stored key ("budgets.max_steps").
Multi-identity forge links move to archie-core-pv6t: forgeConfigForTask
resolved a task's forge from config.Config, had no reachable caller once
the holder was gone, and belongs in the projection rather than the
rendering package.
|
||
|
|
d0b5be1491 |
feat(webui): route dashboard task actions through the Gateway contract
The dashboard composed its own taskactions.Service over whatever handles happened to be set on webui.Server. In the extracted UI process those are all nil, and each nil silently removes a guarantee: no Cfg means max_retries stops being enforced, no Issues means a rejected task's forge issue stays open and the poller re-enqueues it, no Events means operator actions never reach the timeline, no TaskStopper means Stop cannot interrupt running work. The handler now asks whoever owns task execution, through ApplyOperatorTaskAction, and Issues/TaskStopper leave the dashboard entirely. That path crosses two hops that both flatten errors, so the sentinels the handler maps to 404/409/503 travel explicitly: a kind beside the message on the NATS envelope, a gRPC code on the Gateway contract, each restored on arrival. Without them a task that simply moved on reports as a broken daemon. The action tests keep running the real service, now behind a local contract the way the daemon serves it in production, so retry limits, forge closure, events, archiving and log removal stay covered where they were. |
||
|
|
5e94cef784 |
refactor(workflow): relocate Task/Status/Source and define workflow.Store (#754)
* refactor(workflow,store): relocate Task/Status/Source and define workflow.Store Move store.Task, store.Status*/store.Source*, and the 3-method workflow store interface out of internal/store into internal/domain/workflow as workflow.Task/workflow.Status/workflow.Source plus a consumer-owned workflow.Store, superseding store.WorkflowStore. internal/domain/workflow now imports zero internal/store symbols; internal/store persists the domain type instead (infrastructure depends on domain), and its Store satisfies workflow.Store. Updates every production and test caller of the relocated symbols across daemon, webui, gateway, agentworker, agenttransport/nats, storerpc, taskrun, and worktreerpc, and removes TestRecordDispatchViaExplicitTx per docs/prds/state-store-contract.md (rev. 2c) sections 4 and 12 step 2. Two workflow-package integration tests that exercise the real *store.Store move to an external workflow_test package (store_integration_test.go) to avoid a workflow(test)->store->workflow(prod) import cycle now that store depends on workflow. * no-mistakes(document): docs(state-store): mark §4.8 relocation done in state-store-contract |
||
|
|
96c82cd4e0 |
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 |
||
|
|
4b340d2b56 |
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. |
||
|
|
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. |
||
|
|
61b4b7b0cf |
refactor(store): replace legacy persistence with SQLite
Task and event persistence now uses a dedicated SQLite sidecar derived from the configured state prefix, matching the independently persisted conversation store. The configured path now means a state-path prefix rather than a database file so fresh SQLite state never attempts to interpret the previous storage format. Remove the retired implementation and dependency completely, strengthen SQLite migrations and concurrency behavior, restore backend-neutral coverage, and align configuration, operational guidance, UI labels, and deployment documentation with the new storage and host-daemon topology. |
||
|
|
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 |
||
|
|
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. |