c4846b183ccdabf4e8a6d5ba29692aa67faf89df
105
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
50d96b4d28 | fix(eda): tie module results to checker and tighten action ids | ||
|
|
d26ba54e77 |
feat(eda): wire action playbooks through loader and module schemas
Pass 2 of archie-core-nx30. Pass 1 typed each prior action's result in
the CEL env; this pass wires that typing through the loader, module
schemas, and daemon, and removes the now-redundant id classifier.
Loader shape (D2): one playbook is exactly one workflow action
(unchanged) OR one or more module actions; the shapes never mix. Mixed,
unsupported, or zero actions fail the load naming the playbook.
playbook.Load now takes a KindSchemas source (a small interface this
package defines, satisfied by *module.ModuleRegistry) so playbook grows
no module import. Callers: bootstrap.loadEDAPlaybooks passes b.modules;
daemon and playbook tests pass module.New().
Per-playbook env (D3): each action's when and args values compile against
an env built from the PRIOR actions' ids typed by their kinds' Result
structs (expr.NewEnv(DeclaredResult{ID,Type})). event stays dyn. An
undeclared id, a forward reference, or a field the kind's Result lacks is
a compile-time undefined-field error.
Args schema (D4): an args key the kind's Args struct does not define
fails the load. An args VALUE whose compiled type mismatches the field
type is left as a named gap (not cheap without leaking cel-go type kinds
into playbook and handling dyn reads); a wrong-typed value still surfaces
at module invoke, not load.
D1: Store.Dispatch routes workflow playbooks only, so an action playbook
cannot hijack the definition pin. bootstrap.loadEDAPlaybooks logs a
visible Warn (not debug) for each loaded action playbook naming it and
stating it does not execute yet.
D5: ModuleRegistry.Invoke is deliberately schema-agnostic (the stored
invoker is type-erased and returns map[string]any). The map-to-Result
marshalling belongs in the coordinator named by the doc, which is the
t2db.31 run path and out of scope here.
Classifier enumeration (E) and verdict, all proven for a typed action
playbook via CEL (expr.NewEnv with a declared log.Result id):
unknown id CEL compile (undefined field) -> delete unknownActionReference
literal map index actions["x"] CEL compile (no _[_] overload) -> covered
computed index actions[key] CEL compile (undeclared 'key') -> covered
dynamic index actions[event.name] CEL compile (no _[_] overload) -> covered
"x" in actions CEL compile (no @in overload) -> covered
size(actions) CEL compile (no size overload) -> covered
actions.all(...) CEL compile (not a range) -> covered
actions == {} CEL compile (no _==_ overload) -> covered
bare actions compiles; KEPT classifier -> retained resolvable check
unknownActionReference is deleted; actionReferences/ActionReferences are
kept solely for the bare-actions spelling CEL does not reject.
|
||
|
|
2b3e2f756f |
fix(daemon): cut worktrees from the mapped base branch
Repo.BaseBranch() is where an empty base means "main", and the daemon
handed the raw field to worktree.Prepare -- the one call site that did,
beside the workflow step that passes the mapped value. A repository stored
with no base therefore reached git with "" and its branch was never cut
from main.
Reachable now because the document editor stopped prefilling base (its
per-path skeletons retired in
|
||
|
|
d4d10faa9f |
feat(eda): wire the playbook coordinator into production workflow selection
A loaded playbook now decides a real task's workflow. The wiring point is the daemon's definition pin (Daemon.resolveWorkflowID, consumed by pinWorkflowFromCollection), not pollNATS/publishTask as the design doc assumed: routing moved out of the agent process when workflow definitions became database rows pinned before dispatch, so the pin is the one place a task's workflow is chosen. Precedence: an explicit Task.Workflow (the waiting_human -> approved requeue) still wins, then a matching playbook, then workflow.ResolveWorkflowID's existing label/kind bindings. A playbook naming an undefined workflow is a reported failure that parks the task rather than a silent fall-through to the binding's choice -- the operator bound that trigger deliberately. Store.Dispatch returns the selected workflow name plus the matching playbook's id and version, instead of a compiled workflow.Workflow: the production caller decides against the active definition collection, and the id/version are the first two components of the resolved gap-2 idempotency key. The playbook package no longer imports internal/domain/workflow. The shipped example's `when` read event.priority, a field no intake supplies, so it could never have fired once wired. Both examples now read the event surface playbookInput really builds, and label-trigger.yaml documents the axis an instance defines for itself: trigger.kind is the closed workintake vocabulary because a kind addresses a NATS subject, while trigger.labels is free-form and binds an operator's own taxonomy to a workflow. Module/Channel/Forge positions stay rejected at load; they need the playbook_dispatches ledger first (archie-core-t2db.24). Closes archie-core-t2db.23 |
||
|
|
3944f544e8 |
feat(controlplane): runtime administration over the State Store's gRPC server
The Web UI and messaging channels now read and write Archie's runtime settings through one versioned, audited control-plane API hosted on the State Store's existing gRPC server: catalog, query, command, watch. Each feature owns its resource, validation and commands; storage only writes versions and audit records. Workflows move with it. Definitions become portable YAML compiled through a closed, typed step registry and stored as a control-plane resource, so the yaegi interpretation paths (internal/gate, wfeval, wfextract, gateeval, gateextract, skillbuild) are deleted rather than carried. The UI process reads definitions as data: the JSON projection lives in internal/domain/workflow/task so a dashboard decodes the stored collection without linking the workflow engine, which cmd/archie-ui's deletion gate forbids. Shipped definitions ride the catalog descriptor rather than a bespoke REST route, keeping the API to its four operations. archie-messaging gains -state-store-target/-state-store-token and reads channel settings from the database, failing closed when the State Store is unreachable: the database is authoritative for those settings. |
||
|
|
29bd321894 |
feat(messaging): Messaging Service operator surface, chat report rendering, and the diff-cap config fix (#899)
* feat(workflow): post line-anchored review comments with suggested fixes Bead archie-core-q9au (docs/prds/inline-review.md). A review's findings reached the operator only as a flat list in the PR body, so the author had to map every finding back to its line by hand and apply mechanical fixes by hand. Now the line-anchored findings are also posted as inline review comments, carrying a one-click suggestion when the reviewer could state the fix. Domain (internal/domain/workflow): - ReviewFinding gains Suggestion; Validate rejects one on anything but a confirmed finding, so the agent's record_finding call is refused with something it can act on. Validate splits into validateAnchor / validateClassification / validateDisposition, which also brings it back under the cyclop limit the gate enforces. - StagePostReviewComments runs after StageOpenPR in the implement workflow. It posts only line-anchored findings (Line > 0); a whole-file finding has no line to attach to and stays in the body list, which remains the complete record. It is best-effort: the PR is open and the body already lists every finding, so a failed comment is logged, never a park -- the same reasoning as OpenPR's existing best-effort LinkBranch call. - The suggestion fence is gated on Verdict == confirmed where the fence is written, because it is a one-click apply: a wrong suggestion breaks the code and the author has to notice. Forge (internal/forge): ReviewCommentWriter + GitHub/Gitea implementations, type-asserted like PullRequestReader so a forge that cannot is skipped rather than faked (NoopForge is pinned as not satisfying it). GitHub loops one CreateComment per comment and joins the failures, so one refused anchor cannot drop the rest; Gitea carries them on a single COMMENT-state review. Two deliberate departures from the PRD's sketch, both recorded in it: - The interface is batch (CreateReviewComments), not one call per comment: Gitea's only inline shape is one submitted review, and the set then crosses NATS once instead of once per finding. - The head SHA is resolved inside each forge implementation rather than by the caller. The stage runs in archie-agent, which holds no forge credentials and has no PullRequestReader; the daemon-side forgerpc handler is the only place that does. Transport (internal/forgerpc): workflow.Forger gains the method, so the agent reaches the daemon over the new create_review_comments subject; the server type-asserts the writer and answers an incapable forge with an error the stage logs. This is the one proxied method whose absence on an image skew does not park a task. The reviewer prompt and record_finding schema ask for a suggestion on a confirmed, mechanically fixable defect only. Regenerating the wfextract symbol table -- the documented way a new exported workflow symbol reaches interpreted stage plugins -- also picked up symbols that were missing from the committed table (the Status* and Source* constants, ReviewCheck, Store, Task, and the _Store wrapper). Nil-guards were re-applied to every wrapper afterwards, as that file's header requires. Evidence: task check exit 0 (incl. 229 UI tests). Three mutations of the new stage logic each fail a test that names the behaviour -- dropping the confirmed-only gate, dropping the Line > 0 filter, and letting a posting failure escape -- so the tests discriminate rather than passing vacuously. * fix(build): drop the Dockerfile pin assertion The guard fetched golangci-lint's go.mod at image build time to fail the build when GOLANGCI_LINT_VERSION and GOFUMPT_VERSION disagreed. It only ever tripped on self-inflicted pin drift, but it added a network fetch and a new failure mode to the release build, which is not where that belongs. The pins stay correct (golangci-lint 2.13.2, whose vendored gofumpt v0.11.0 equals GOFUMPT_VERSION) and the comment above them still states the invariant, so the reasoning survives without the build-time machinery. The pin change itself reaches the agent image through the normal release path: CI rebuilds and pushes archie-agent on an archie/vX.Y.Z release, and a gateway-only release deliberately does not. * feat(workflow): add the remediate workflow for PR review remediation Implements step 5 of docs/prds/pr-review-remediation.md: a remediate workflow that resumes the task's existing worktree onto its PR branch (worktree.Manager.Resume, not Prepare's refresh), runs a builder agent against the review's actionable comments, commits and pushes to the same branch, and replies via the forge's ReplyToReview. Task.RetryCount doubles as the remediation round counter, capped by the repo's max_retries; the round-cap stage parks the task and posts one comment when it's hit. Task gains a ReviewPayload field (JSON-encoded review unit) with full store/proto/staterpc plumbing. workflow.Forger gains Comment and ReplyToReview, proxied to archie-agent via a new forgerpc RPC. Resume and its Dir lookup are added as an unexported optional Trees capability rather than widening the exported interface, which is already at golangci-lint's interfacebloat cap and is projected into wfextract's Yaegi symbol table for repository-authored stage plugins. The daemon-side reaction consumer that dispatches into this workflow (subscribing ARCHIE_REACTIONS, grouping comments by review, enforcing per-task serialization) is tracked separately in archie-core-8li9.4. * feat(messaging): extract standalone messaging service binary and process composition * feat(messaging): adapt channel frontends to consume Gateway ChatContract * feat(messaging): remove in-process channels and Router from daemon bootstrap Telegram, email and webhook now run only in the Messaging Service, which reaches this process through the Gateway's ChatContract. The daemon builds no channel and no gateway.Router, so the wiring that existed only to serve them goes with it: setupGateways, setupEmailGateway, setupWebhookGateway, setupTelegramGateway, buildTelegramRouter, makeTelegramReload and the release-announcement path helper. The seams those paths owned move to where they can still be honoured: - Channel ValidateConfig runs in archiemessaging.compose, which now returns an error, so a configured-but-invalid front-end fails the service rather than being dropped silently. - The inbound rate limiter moves to the Gateway process, which owns the only Router and therefore the only place a per-sender budget applies to every channel's turns. - The daemon's gateway readiness probe becomes a ContractProbe against the Gateway. It cannot observe a channel lifecycle it no longer runs, and a channel-count probe would have reported every daemon degraded. - telegramSetup is now chatSetup (in chat_setup.go), trimmed to the fields a chat turn runner actually reads. Telegram operator features that were wired only in the daemon (/update, release announcements, version reporting, SIGHUP reload) are not yet wired in the Messaging Service: archie-core-8cda.6.6. Channel lifecycle reporting: archie-core-8cda.6.8. The Gateway process builds no worktree manager, so review_pr is unadvertised on every channel: archie-core-8cda.6.7. * feat(messaging): re-wire the Telegram operator surface in the Messaging Service setupTelegramGateway satisfied eight telegram.Gateway seams from the daemon's own process. Each is resolved by where the fact it needs is owned, not by where it used to be built; the decision table is in docs/architecture/migration-decisions.md. Wired here: /update (built from this service's own [chat.telegram] check and install commands), the update-report relay (same sha256(bot_user)[:8] path the daemon wrote, so a pending report is found rather than written afresh), show_tool_calls, and /restart's config reload, which re-resolves the token and allowlist from this service's own file and refuses a reload that resolves to an empty token. /version is sourced from the Gateway: ChatSnapshot gains a Version field carrying the Gateway's rendered build block, read per call and bounded by the dependency timeout. cmd/archie-messaging deliberately takes no version ldflags, so it cannot report a partial upgrade as a matched one. RunningVersions and ReleaseAnnouncements stay nil. Both need a component's real running version, and the only versions this process can obtain are a different binary's stamps -- reporting them would manufacture exactly the false success the update check exists to catch, and the announcer without parseable versions is a no-op that reads as configured. archie-core-8cda.6.9 carries the contract that unblocks them. Dangerous stays nil: no composition has ever supplied a command authority. Enrich is dropped from the update service: componentInstallTypeEnricher read [nats], which this service must not decode, so the check command's own reported install type stands. * fix(workflow): guard inline review comments against head drift Two findings from the review of q9au. A comment's line numbers describe exactly one revision of the branch, but the forge resolved the pull request's head at posting time -- after the review had already read the worktree. A push in that window (a collaborator, a retry) meant the findings were anchored to whatever now occupied those lines, mislabelling instead of failing. The revision the review measured now travels with the comment set: OpenPR records it from the same worktree read it already performs (TaskContext.ReviewedHeadSHA), StagePostReviewComments threads it through Forger to forgerpc, and the forge refuses the whole set once the head it reads has moved off it -- which the best-effort stage logs, the PR body remaining the record. An unmeasured revision posts unverified rather than dropping every finding, so a worktree that cannot report one degrades instead of regressing. Suggestion was documented single-line only, because GitHub applies a suggestion fence up to its first line and a multi-line replacement would silently corrupt the file. Only the verdict was validated, so a multi-line suggestion reached the renderer and posted as that truncated fence. Validate now rejects an embedded newline, which makes record_finding refuse it with feedback the model can act on instead of the reviewer discovering the corruption later. * fix(gateway): render chat reports as lines, not one run-on paragraph /status and /tasks are line-oriented reports, but their newlines were plain "\n" -- CommonMark's soft wrap. The Telegram rich-block renderer space-joins soft-wrapped lines, by design: a Telegram paragraph renders an embedded newline as nothing at all, so a space is the only separator that survives. The reports therefore arrived as one line each: "Runtime Provider: DeepSeek Model: deepseek/deepseek-flash", and every task's title, state and park reason jammed together. The renderer now implements CommonMark's hard line break (two trailing spaces, or a trailing backslash): the line closes its own block and the next one hugs it, so a stanza keeps its lines without the spacer paragraph that separates unrelated blocks. Ordinary prose is untouched -- a model's wrapped paragraph still joins with a space. The producers mark their report lines with it. Two report fixes alongside: - A park reason is capped to its first line at 160 runes. It carries whatever the failing stage reported, which for a lint gate is the whole tool log; unbounded, one parked task pushed every other task out of the reply. The full reason is still on the task. - /status loses its "Runtime" sub-header. A section header over two fields made a four-fact report read like a document. * fix(config): let diff_cap_lines = 0 actually switch the cap off Config.DiffCapLines was a plain int, so the defaults pass could not tell an absent key from an explicit 0 and rewrote both to 400. The dashboard schema said "0 means unlimited" and StageDiffCap treated <= 0 as unlimited, but 0 never reached the step: the documented way to switch the cap off was unreachable through config. Same root cause, worse instance: configForIdentity assigned root.DiffCapLines = identity.DiffCapLines unconditionally, so an identity that simply omitted the key overwrote the shared cap with the zero value and silently disabled the safety rail for that identity. DiffCapLines is now *int on both Config and IdentityConfig -- nil is absent, 0 is no cap -- read through Config.DiffCap(). Defaults fill only nil, and an identity overrides only when it set the key. TaskConfig keeps a resolved int, so the daemon/agent wire format is unchanged and a version-skewed agent cannot misread a null. The park reason changes too. It told the operator to "approve manually", but a parked task's actions are retry, abandon and reject (internal/taskstate): there is no approve path out of diff-cap, so it sent them looking for a button that does not exist. It now names the two things that work. * feat(config): make the daemon's readiness dependency timeout configurable The daemon's gateway probe bounded its call with a hardcoded 5s constant, while every other NewContractProbe call site (archie-ui, archie-messaging) passes the service's configured DependencyTimeout. It was the only magic number among them. [health].dependency_timeout carries it, defaulting to the same 5s the extracted services' -dependency-timeout flag defaults to, so every process bounds a probe into a dependency the same way out of the box. It is not added to the dashboard config schema or the reloadable set: [health] appears in neither today, health.listen included, and a probe assembled at boot would not observe a reload anyway. |
||
|
|
1dc212e50e |
feat(gateway): give /status a real daemon-health surface (#892)
* feat(gateway): give /status a real daemon-health surface Phase 2 of archie-core-wp9s. Phase 1 split the commands apart (health vs work) but left /status with one aggregate queue line and a static runtime block; it could not answer the questions an operator actually asks when something feels wrong. /status now reports, between the queue line and the runtime block: - Broker: the live state of this process's own NATS connection (eventbus/nats.Client.Connected), not a fresh dial -- a probe would report the probe's reachability, not the daemon's. - Containers: the pool's own active counter against the configured cap (Pool.Active/Cap), not a Docker listing, which would include containers this pool does not own. A zero cap means unlimited, so it is not shown as a ratio. - Channels: the channel manager's real lifecycle state, including a failed adapter's reason (the documented decision: read the existing manager rather than re-deriving health per adapter). - Chat model: last-known outcome of every chat-model call this process made, recorded once in sendChatTurn (the single choke point) and read back by /status. The second documented decision: never a live probe, so /status stays instant and reports what happened -- or says plainly that nothing has been attempted yet. - Last poll: when the most recent poll pass began, stamped on both poll paths (Run's single-identity loop and runIdentities' per-identity goroutines). A pass that hangs leaves the stamp stale, which is the signal; stamping completion would leave a wedged poller looking healthy. Truthful or absent: a section this process has no source for is omitted rather than rendered as a zero. The standalone Gateway owns no poll loop, pool or channel manager, so its /status reports broker and chat-model health only; aggregating across processes would need a new daemon RPC and is deliberately not built. Version stays out (/version owns it). /status and /tasks descriptions now describe what each command actually does on both published surfaces (Telegram menu/help and the shared specs), pinned by a test that also fails if the two surfaces drift. Sources are read through functions, not captured values: occupancy and channel state move, and the daemon is built after the gateways, so a source captured at construction would freeze /status on boot state. Left in place deliberately: the Runtime (provider/model) block, which Phase 1 flagged and which duplicates /model and /whoami. Removing it is a product call on a command Sam uses daily, not a mechanical follow-up. * docs(prds): record the two open /status health decisions as settled Both were flagged in PR #892 as needing the maintainer's call; both are now answered, and the PRD is the place a follow-up would look: - The Runtime (provider/model) block stays. It is the one line in /status the ticket's own rule says should not be there, but /status is read daily to see the active model at a glance, so the duplication is deliberate. Recorded as a settled product decision so it is not removed later as an oversight. - Health stays per-process. Pooling the daemon's and the Gateway's chat-model outcomes would need a new daemon<->gateway health RPC for one status line, and a per-process line is true where an aggregate would be a claim about a process the answering one cannot see. /agents' published description is still left to archie-core-mxls, unchanged. |
||
|
|
192369e98b |
Merge pull request #881 from samcharles93/fix/daemon-sweep-budget-diagnostics
fix(daemon): name an exhausted sweep budget as the cause |
||
|
|
3b027a8670 |
fix(daemon): don't call a cancelled startup a spent sweep budget
ctx.Err() is non-nil for a parent cancellation as well as for the sweep budget, so SIGINT/SIGTERM during the boot sweep logged "sweep budget exhausted" with err="context canceled" -- an expected shutdown reported as a failed sweep (Greptile P2 on #881). Attribute on this sweep's own context instead: DeadlineExceeded is the budget, any other non-nil context error means the startup was cancelled, and neither is a repo access failure. A forge's own request timeout, with the sweep context still live, still reports per repo. RED before (cancelled parent, three repos): budget warnings = 1, want 0 level=WARN msg="push check abandoned: sweep budget exhausted" repo=acme/one err="context canceled" |
||
|
|
2385e81066 |
Merge pull request #878 from samcharles93/feat/attempt-attribution
Feat/attempt attribution |
||
|
|
08e16c82be |
fix(daemon): name an exhausted sweep budget as the cause
sweepAccess spends one sweepTimeout budget on a forge's whole boot
sweep. When that budget ran out mid-loop, every remaining repo was
warned as "repo not pushable -- tasks from it will fail" -- asserting
that access had been denied when all that was known was that the
deadline passed, once per repo.
Report the budget once, name it as the cause, and stop: later calls
return the same deadline error, so continuing only multiplies a
misleading warning.
RED before (three repos, budget exhausted by the first):
VerifyPush calls = 3, want 1
"sweep budget exhausted" logged 0 times, want 1
level=WARN msg="repo not pushable -- tasks from it will fail" repo=acme/one err="context deadline exceeded"
level=WARN msg="repo not pushable -- tasks from it will fail" repo=acme/two err="context deadline exceeded"
level=WARN msg="repo not pushable -- tasks from it will fail" repo=acme/three err="context deadline exceeded"
|
||
|
|
86bbc468c9 |
test(daemon): prove a stalled forge cannot block a sibling sweep
sweepAccess sweeps each forge in its own goroutine, but nothing pinned that: the table test asserts coverage, not ordering, so the sweep could be made sequential again without a failure. The test stalls the root forge in AcceptInvitations and asserts the sibling identity is swept while it is still blocked, then that Startup returns once the stall is released. Verified RED against a sequential sweepAccess (times out waiting for the sibling) and GREEN against the goroutine-per-forge implementation. |
||
|
|
b31e98bee5 |
fix(daemon): sweep the root forge alongside every identity
The per-identity sweep skipped the root forge and root repo list whenever [[identities]] was configured, on the reasoning that Run never polls them there. Polling is not the only way a task reaches a repo: dispatchBinding enqueues with an empty identity, resolveBindingRepo falls back to the root repo list, and forgeFor/repoFor resolve an empty identity to the root forge and root repos. Root targets stay reachable in multi-identity mode, so they stay worth verifying at boot. Collapse both sweeps into one sweepAccess path over the root plus every identity. Each forge is swept in its own goroutine under its own deadline: Startup gates the gateways and the run loop and a forge client carries no request deadline, so warning on a failed sweep isolated a failing sibling but not a stalled one. Test is table-driven over single-identity, multi-identity, and an identity with no repos. |
||
|
|
f51ce148b9 |
fix(daemon): sweep every identity's forge and repos at startup
daemon.Startup ran the invitation sweep and push verification only against the root forge and Cfg().Repos. In multi-identity mode Run branches to runIdentities, where each identity polls its own forge and its own repo list -- so per-identity invitations were never accepted and per-identity repos were never push-verified. A task from those repos failed later at dispatch instead of warning at boot. Startup now branches on len(d.Identities) and sweeps each identity through sweepIdentity, which reuses id.Forge and id.Repos -- the same IdentityRunner fields runIdentities and pollForIdentity already iterate, so there is no second identity-to-forge mapping. One identity's forge outage cannot abort a sibling's sweep: failures are logged as warnings, matching Run's stated failure-isolation intent. Red-then-green: TestStartupSweepsEveryIdentityForgeAndRepos failed with "identity one AcceptInvitations = 0, want 1" (and both identities' repos empty) before the change. |
||
|
|
da4547e27c |
feat(config): key services by name through a registry
Services was a struct with one field per service, so each service's name was stated three times: the field, the loader's defaulting branch, and every consumer's field access. Adding one meant editing all three, and nothing stopped them disagreeing. The drift was already there: stateStoreResolvedToken and gatewayResolvedToken were identical apart from the env var each hard-coded. Services becomes map[string]ServiceConnection, and RegisterService declares a service once with the five fields it has. Everything that differs between services is now an argument rather than a branch elsewhere: an empty registered target means the operator must supply one, which is how services.state.target stays required while the gateway's is defaulted, and the registered token env var replaces the two copied resolvers with Services.ResolvedToken. Defaulting iterates the registry, so a new service needs no loader edit. Consumers read Services.Get(name). Keeping a typo'd section reported took explicit work. [services.gatway] used to land in toml.MetaData.Undecoded() because the struct had no such field; a map decodes any section, so it would have loaded silently and left the daemon dialing the default. unregisteredServiceKeys asks the registry which names are real, and the test for it fails with an empty UnknownKeys when that check is removed. The TOML shape is unchanged, so no deployment profile, config.example.toml or install.sh edit is needed. Refs: archie-core-u23g |
||
|
|
862ac46e8b |
feat(tasks): attribute events, changes and config to the attempt that produced them
The events table had no attempt column, so two attempts of the same task were indistinguishable: a retried task's stage events interleaved into one timeline and nothing could say which run produced a given result. - events gains an `attempt` column through the existing presence-gated migrateTasks loop rather than a version bump, so user_version stays 3 and an existing archie.db is migrated in place. A legacy-database test builds the pre-change schema and proves both that existing rows survive unattributed (attempt = 0) and that a new value round-trips. - Event.attempt = 11 and ReadTaskLogRequest.stage = 9 are field additions to existing messages: no new RPC, no new table, and no change to any canonical error message that crosses the state-store wire. - Every task event the workflow engine emits now carries the attempt. Producers that have no attempt yet (task_queued, binding_dispatch_failure) stay unattributed rather than guessing one. - Changed files are captured as a durable changes_captured event at commit and push time, reusing the existing three-dot diff primitive: paths from FilePatches(), counts from Stats(), base_sha recorded as the merge base actually diffed rather than the base tip, a 200-file cap with totals kept complete. Consumption goes through an unexported optional interface so workflow.Trees -- the yaegi capability surface for interpreted stage plugins -- is not widened. A capture is also taken once the pull request exists, so the capture can link it. - The per-attempt configuration is captured as a durable config_captured event carrying the non-secret config.TaskConfig, instead of a new table plus two new state-store RPCs: events are already this system's per-attempt provenance stream, so a table would have given one feature two provenance mechanisms. Redaction is proven against canary secrets. Measured payload: 539 bytes typical, 2333 bytes at 20 models. - Captures carry a schema marker and are refused unless their key set matches the declared payload shape, so drift surfaces as "recorded but could not be read" rather than as a capture of zeroes. - Three read endpoints serve the attempt rail, the changed-file captures and a raw debug view, mapping to UI-owned response types rather than dumping store types. - The task-log read gains a stage filter, bound to the stage logger for that stage's own lines; agent and tool output records no stage. A task-scoped grant may already insert events on its own task, so this provenance is exactly as trustworthy as the rest of that task's event stream. That limit is documented rather than papered over. |
||
|
|
ff27bd03fe |
fix(daemon): record every park reason in the attempt's own log
An operator who asks "why did task 1 attempt 3 park?" and downloads that attempt's log got a zero-byte file, because nothing daemon-side wrote to a task log at all: the container's system-log subscription was the only writer, so an attempt that parked before any container produced output -- a worktree prepare failure, an unavailable worker, a taskrun error -- left the file the sink had created empty and the reason only in the daemon-wide log. Both park paths now write the reason into that attempt's sink. The entry is written after the guarded transition lands, so a park another actor won does not leave a log claiming an outcome the task board contradicts -- the same race the parked event is already withheld for. |
||
|
|
0b3dc6c01f |
refactor(forge): delete the unwired RepliesAfter surface
DELETE: IssueForge.RepliesAfter and its Reply type had no production caller -- the waiting_human status exists and is reachable, but automatic detection of a human reply never landed, so the intended poller was never built. Neither implementation paginated either (both read one page of 50), so the method would have been wrong if wired as-is. The manual path is untouched: waiting_human remains reachable and an operator requeues through the existing task-action flow. Removing the interface method also removes seven test fakes that existed only to satisfy it. No behavioural test accompanies this: a pure deletion has no assertion to make fail, and the compiler enforces completeness across every implementation. |
||
|
|
2b84ec2989 |
fix(daemon): forward configured MCP servers to task agents
WIRE: taskrun.Request.MCPServers is documented as the channel for MCP server definitions the agent should construct, and the archie-agent worker consumes it (task_execution.go startMCPProviders). The daemon's request constructor dropped the field in a refactor, so configured MCP servers never reached a task container. Restore it from d.configFor(task).Tools.MCPServers. |
||
|
|
16d331a16e |
refactor(daemon): remove unreachable SQLite poll/drain path
DELETE: NATS startup is mandatory (config.NATSConfig documents "there is no broker-off execution mode"), so Daemon.Tasks is never nil in production and pollSQLite/drainSQLite are unreachable. Remove them and their d.Tasks==nil call sites, and correct the Tasks field comment. |
||
|
|
eaa58dfe73 |
fix(daemon): guard binding dispatch loop against nil dispatcher/creator
BindingDispatcher and BindingTaskCreator are documented "optional: nil disables the dispatch loop", same as Bindings, but dispatchBindings only checked Bindings before dereferencing the other two. Any composition that wires Bindings without also wiring both handles panicked on the first dispatch cycle. |
||
|
|
1f3f54bedd |
test(archied): pin the wiring these fixes depend on and drop text coupling
Two fresh-context reviews of the preceding five fixes found that the tests were mostly sound but that three things were not: one harness was coupled to shell source text, one assertion was coupled to a tool count, and -- worse -- the two changes carrying the most weight were pinned by nothing at all. Composition order. review_pr worked only because Run builds the worktree manager before the gateways; no test observed it. Reverting the order left every test green while the daemon silently stopped offering review_pr, because the producer guard then returns nil instead of advertising a broken tool. Pin the order by source position, matching the existing TestSetupBackendsRegistersContainerCleanupAfterNATS, since no runtime seam can see it. methodBody now resolves package-level funcs as well as methods. Composition wiring. The daemon fix's whole point is that resolved routing bindings reach the worker, yet nothing verified that buildDaemon puts them on the daemon: with b.kindWorkflows replaced by nil, only the new test fails and both the daemon and worker packages stay green. That is the "tested in isolation, never verified wired" shape this work exists to remove, so pin the hop. The wire contract itself. taskrun.Request's json tags are the interface between two binaries, and a same-type round trip cannot see a tag rename. Assert the emitted keys literally; renaming one now fails with the key list. Brittleness. selfHostConfig no longer string-matches install.sh's heredoc opener or assumes the delimiter is EOF, and no longer hand-substitutes a copy of forge_block's output -- it discovers heredocs by shape and selects the one declaring [nats], a table the assertions never touch. Verified against four behaviour-preserving refactors that previously failed: renaming the delimiter, reordering the redirect, factoring the path into a variable, and <<-. The two [services.gateway] source greps are gone: defaults.go already supplies that target, so there was no behaviour to pin. review_pr is asserted present by name rather than by entry count, so a sibling review tool cannot turn it red. Also carry the published request's decode error instead of discarding it, so a payload-shape break reports as itself rather than as an empty routing binding. Every new test was verified non-vacuous by reintroducing the defect. |
||
|
|
669f98a059 |
fix(daemon): carry kind/label routing bindings to the process that routes
An operator's kind/label -> workflow overrides were decoded, validated and installed into the DAEMON's package-level state via workflow.SetKindWorkflows/SetLabelWorkflows -- but workflow.Route's only production caller is app/agentworker/task_execution.go, in the separate archie-agent process. The bindings never crossed the boundary, so every configured override was silently ignored and routing always fell back to the built-in defaults (bug -> tdd, feature -> feasibility, bootstrap -> bootstrap). Carry the resolved bindings on taskrun.Request, mirroring how MCPServers already crosses this boundary, and apply them in the worker before Route is called. Resolved values are carried rather than file paths, so the worker does not need the routing files to be readable in its sandbox. nil still means "use the built-in defaults", so this is backward compatible for any request built by an older daemon. routeTask is a named seam for that install-then-route step. It mutates package-level routing state, which is sound here because each archie-agent process is task-scoped and ephemeral; if the worker ever served more than one task that assumption would need revisiting. Tests are mutation-verified: removing either the two Set calls in routeTask or the two request fields in runViaAgent reproduces the exact assertion failures the lane observed red-first, so neither test is vacuous. Found by an adversarial package sweep (temp tracker: workflow-engine-1, .local/issue-tracker/). |
||
|
|
a00c578cb7 |
refactor(ui): sever the archie-ui binary from every daemon runtime package
Completes the objective deletion gate for the UI Service (archie-core-8cda.5.6): go list -deps ./cmd/archie-ui now links zero banned packages -- no modernc.org/sqlite, no internal/store, gateway, channels, memory, secret, agentexec, tools, skill, yaegiutil, curator, or the workflow engine. The closure shrinks from 68 to 26 archie-core packages. Each cut is a producer-side move; no consumer-side defensive shims. - Store contracts (TaskStore family, value types, sentinels) moved from internal/store to internal/domain/storecontract -- the approved contract location per state-store-contract rev. 2d, and NOT internal/contracts: that tree is buf generate output and tools/proto.sh check deletes hand-written files there. internal/store keeps aliases; sentinel message strings are byte-identical and remain the wire contract. - Chat contracts (ChatContract, sessions, turns, streaming, commands) moved from internal/gateway to internal/domain/messaging; gateway keeps aliases. ToolCallEvent rendering helpers become gateway functions (methods cannot live on alias types). - Task vocabulary (Task, statuses, mid-run Store, Definition) split into internal/domain/workflow/task; the pipeline engine stays in package workflow with aliases, so daemon-side callers are unchanged. - overlay.DeniedKeys moved to internal/infrastructure/configuration: webui referenced the constant and that dragged the overlay SQLite store in. - webui.Server's concrete runtime handles become webui-owned view interfaces with daemon-side bootstrap adapters: channel lifecycle (internal/channels/status), MemoryStatus, CuratorStatus, and a SkillCatalog seam replacing the direct skill.DefaultRoots/CatalogRoots calls. Each degrades to an empty page when unwired. - config.SecretRef moved into internal/config (config vocabulary); internal/secret keeps an alias and Registry.Resolve absorbs the zero-value short-circuit. Docs: state-store-contract rev. 2d relocation record; ui-service-boundary deletion gate marked satisfied; ARCHITECTURE.md package map rows. |
||
|
|
983ddd7c4b |
refactor(store): move the producer-owned contracts to internal/contracts/store/v1
The deletion gate for the UI Service (archie-core-8cda.5.6) is objective: go list -deps from cmd/archie-ui must show no SQL/store implementation. internal/store's hand-written contract surfaces (TaskStore and its component interfaces, CaptureStore, MappingStore, BindingStore, BindingDispatcher, BindingTaskCreator, ConfigSnapshotStore) move to internal/contracts/store/v1 (package storev1), alongside the value types they carry (CapturedEvent, ConfigSnapshot, WorkflowStat, StageStat, DayTokens) and the sentinel errors -- whose canonical message strings are the wire contract and are byte-identical after the move. internal/store keeps type aliases, so daemon-side callers (archied, the daemon, staterpc's server side, taskactions) are unaffected. The UI-facing packages switch to storev1 directly: webui, archieui, captureintake, gatewayrpc, and staterpc's client/values -- which drops internal/store and modernc.org/sqlite from the archie-ui binary's import closure. overlay.DeniedKeys moves to internal/infrastructure/configuration for the same reason: webui referenced the constant and that dragged the overlay package's SQLite store in. The chat-contract and remaining runtime-handle decoupling continues under the same bead. |
||
|
|
694aaeb7cd | style: apply gofumpt formatting | ||
|
|
f5414a82a1 |
fix(state-store): task-scope container credentials, stream large capture lists, validate Update, wire dev's state-store (archie-core-8cda.4.7)
Closes six review findings against .4.6 (PR #775): - daemon.StateStoreGrantIssuer + staterpc.TaskGrants: containers get a per-task credential authorized only for their own Update/Transition/ InsertEvent, never the daemon's administrative token. Issued before Acquire, revoked on Release; fails closed if no issuer is wired. - StreamCaptures/StreamUndispatchedCaptures: new streaming RPCs so a batch of large capture bodies can't exceed gRPC's 4MiB unary cap. The original unary RPCs are kept, unmodified (deprecated) rather than reshaped, so buf breaking stays green for an in-flight rolling deploy. - Update rejects a nil Task with InvalidArgument instead of panicking in the store layer. - RequireHostGateway only forces on for embedded NATS, so an externally reachable NATS/State Store no longer requires a local Docker bridge. - Client-side token resolution now matches the server's (target_token, then STATE_STORE_TOKEN secret/env). - task dev now runs archie-state-store (dev:state-store) alongside archied/archie-gateway/vite; deployments/dev.toml points them at it. |
||
|
|
05529d48d5 |
refactor(state-store): cut daemon/Gateway over to the remote State Store (archie-core-8cda.4.6) (#774)
* refactor(state-store): delete NATS storerpc; agent store is gRPC-only (archie-core-8cda.4.6) The agent is fully on the gRPC State Store contract, so the legacy NATS storerpc path is dead (docs/prds/state-store-contract.md §12 step 4): - delete internal/storerpc (Server, Client, subjects) and its tests - drop the storerpc registration from registerTaskRPCServers and the now-unused store param - make the agent transport's State Store URL required and Store() return only the gRPC staterpc.Client (no NATS fallback) - rework agentworker/agent transport tests to back the store with a real gRPC State Store server instead of the deleted NATS storerpc server The agent binary now fails fast when STATE_STORE_URL is absent. Agent store calls (workflow.Store) go over gRPC to the archie-state-store service. * refactor(state-store): delete daemon/gateway in-process store ownership (archie-core-8cda.4.6) The daemon and gateway no longer open archie.db in-process: the single SQLite file is owned by the standalone archie-state-store process, and both consumers dial its gRPC State StateStore contract (docs/prds/state-store-contract.md §12 step 7, no dual-store ownership). - openStores no longer opens the production task store or seeds b.st; it only wires secrets/forge and the gateway conversation store - openStateStoreAdapter now requires [services.state].target (the old local default is deleted) and resolves b.stateStore as the remote *staterpc.Client - delete the in-process startStateStoreServer (the multiplexed gRPC server and its per-task bearer-token registry) from the daemon composition - RunGateway now resolves the same remote State Store adapter; its session SQLite stays Gateway-owned and untouched - daemon.ConnectedStateStore carries the configured target plus the resolved bearer token, which containerEnv injects as STATE_STORE_URL / STATE_STORE_TOKEN so archie-agent authenticates to the same remote service - readiness store probe reads b.stateStore PRD-consistent choice (noted): with the in-process server gone, per-task token generation is removed; the daemon/gateway/agent all present the single [services.state].target_token (or STATE_STORE_TOKEN secret) that the standalone store validates. * docs(webui): require [services.state].target in config and deployment templates (archie-core-8cda.4.6) After the in-process store path is deleted, archied and archie-gateway dial the standalone archie-state-store gRPC service via [services.state].target and never open archie.db themselves (docs/prds/state-store-contract.md §12 step 7). - config.example.toml documents [services.state].target as required, with the loopback vs Docker-bridge gateway + target_token rule - deployment templates set [services.state] per topology: bridge gateway + token for container-mode agents, loopback for host-only - deployments/README.md and systemd-user-service.md describe start commands for both topologies and drop the stale "not yet consumed by the daemon" note * style: gofumpt alignment for State Store daemon literal; appease noctx/staticcheck (archie-core-8cda.4.6) * docs(state-store): refresh stale in-process references post-cutover (archie-core-8cda.4.6) |
||
|
|
576e22b554 |
feat(state-store): generalize storerpc as the State Store gRPC contract (archie-core-8cda.4.2) (#770)
* feat(state-store): generalize storerpc as the State Store gRPC contract Implements archie-core-8cda.4.2 against docs/prds/state-store-contract.md rev. 2c: generate protobuf/gRPC client and server adapters for every ratified store contract (proto/state/v1/state.proto, 40 RPCs, one StateStoreService), add internal/infrastructure/staterpc with a bufconn conformance suite exercising both local and remote adapters, serve the service in-process (bridge address + mandatory per-task bearer token when agent containers exist, loopback-only otherwise), and flip archie-agent's workflow.Store to a long-lived gRPC client when the daemon injects STATE_STORE_URL/STATE_STORE_TOKEN (falling back to the legacy NATS storerpc path otherwise -- one agent process is never both). Also drops the *sql.Tx parameter from store.BindingDispatcher.RecordDispatch (a required wire-blocker fix: a transaction cannot cross a gRPC boundary, and production always passed nil). fix(store): drop RecordDispatch's unusable *sql.Tx parameter feat(config): add services.state contract-adapter selector * fix(state-store): apply no-mistakes review decisions - Drop StreamTokenInterceptor (unused; the State Store service has no streaming RPCs and nothing calls it). - Make StateStoreTokens.Validate compare tokens in constant time (crypto/subtle) per the auto-fix hardening.ing finding. - Amend config.example.toml / config.Services.State doc text so it frames [services.state].target as the ratified surface consumed by the upcoming standalone archie-state-store binary (.4.3), not active today. |
||
|
|
5c0efaceaf |
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 |
||
|
|
ebd2b430dd |
fix(binding): add Owner/Repo pin, fixing multi-repo dispatch
Root-cause fix for the correctness gap named in archie-core-t2db.8: resolveBindingRepo refused to dispatch with zero or multiple configured repos, meaning a multi-repo deployment could never use bindings at all. - binding.Binding gains optional Owner/Repo fields; Validate rejects setting only one (a pin is a complete pair or not a pin at all). - Persisted as new owner/repo columns (NOT NULL DEFAULT '', additive -- no migration needed since bindings is a CREATE TABLE IF NOT EXISTS with no existing deployment yet). - resolveBindingRepo now takes the binding: a pinned binding dispatches to its own owner/repo unconditionally; an unpinned binding keeps today's single-configured-repo fallback (0 or 2+ repos still refuses, unchanged -- verified by a dedicated regression test, not just assumed preserved). - Wired through the API request/response shape (create/update accept and return owner/repo); no repo-existence validation against config added -- smallest workable change, not the named bug. Red-green throughout: 8 new tests across domain/store/daemon/webui layers, each proven to fail before the corresponding implementation step. Zero regressions in existing binding/dispatch test suites. Dashboard UI to expose this (the other half of t2db.8) is unstarted -- this closes the backend correctness gap only. |
||
|
|
5dc3c9895c |
feat(webui): playbook bindings -- matcher + mapping + workflow, HMAC-gated
Implements archie-core-t2db.4: the runtime-editable binding entity that turns a captured webhook into an archie task, plus the per-source HMAC verification at handleCapture that makes t2db.5's 'unauthenticated event cannot trigger a binding' invariant structurally enforceable. Captures, mappings and bindings are now separate concerns on the same single *store.Store; the new BindingStore / BindingDispatcher / BindingTaskCreator split keeps each interface under the interfacebloat limit (8 methods). State machine: draft -> pending_approval -> armed; any edit on an armed binding drops it back to pending_approval, enforced in SQL via status='pending_approval' on UPDATE so the rule cannot be bypassed by a direct status field in the request body. Approve is the only sanctioned transition into armed (WHERE status='pending_approval' guard). Overlap: two bindings may not share a source in any status; enforced at InsertBinding and UpdateBinding (transaction-local SELECT). Approve has a separate TOCTOU guard so a race between Insert and Approve cannot // bypass the check. HMAC at handleCapture: reads X-Hub-Signature-256 (then X-Signature-256) // fallback, verifies via webhookguard.VerifyHMAC against the binding's // per-source secret, marks CapturedEvent.Authenticated=true on match. // Captures with no armed binding, missing signature, or wrong signature all persist as authenticated=false -- the dispatch loop's binding.Matcher.Matches gate (requires authenticated) is what stops them from spawning a task. Two armed bindings for one source returns 409 at capture time as a belt-and-braces TOCTOU guard. Dispatch loop: added Daemon.dispatchBindings, called from both Cycle and maintainAndDrain between poll and drain. Walks captured_events where authenticated=1 AND source IN armed bindings AND id NOT IN binding_dispatches, runs the binding's matcher, resolves the mapping, enqueues a chat-style task with binding_id / // binding_version provenance stamped in the same transaction as the // row insert. The binding_dispatches ledger (composite PK on (binding_id, capture_id)) is the at-most-once guarantee across cycles // and daemon restarts. Tasks schema migration: binding_id INTEGER NOT NULL DEFAULT 0 + binding_version INTEGER NOT NULL DEFAULT 0 (taskSchemaVersion bumped 1 -> 2). Existing tasks keep 0 / 0. Out of scope (documented follow-ups): - secret encryption at rest (plaintext today) - full dashboard HTML for the binding editor (CRUD API only this bead) - per-binding rate limits (existing per-remote-address limit applies) - binding.Owner / binding.Repo fields (dispatch falls back to the single configured repo; multi-repo deployments log and skip) |
||
|
|
fd014f6a7f |
fix(daemon): detach terminal state transitions and cleanup from cancelled context
When an operator stopped a running task via chat /stop or the dashboard Stop button, the task's context was cancelled. Container teardown correctly completed (as Pool.Release detached its context), but terminal state recording in Daemon.runViaAgent and worktree cleanup in Daemon.cleanupTerminalTaskWorktree executed using the same cancelled context. Consequently, SQLite transactions in store.Transition failed immediately and errors were discarded, leaving the task row in 'running' indefinitely until a daemon restart. Extract parkRunningTask in internal/daemon/daemon.go to perform guarded state transitions (store.StatusRunning -> store.StatusParked) using a detached context (context.WithoutCancel) with a bounded 10-second timeout. Update cleanupTerminalTaskWorktree to also use a detached 10-second context for looking up the task status. Check transition errors and log warnings for unexpected database failures while suppressing expected ErrStaleTransition returns when workers have already completed. Add comprehensive table-driven regression tests covering task cancellation, worktree cleanup, and logging behavior. |
||
|
|
fa7b70225a |
fix(daemon): clean worktrees on terminal no-change task completion
Tasks completing with BuildNoChanges transitioned directly to StatusMerged without opening a pull request, bypassing the only production worktree cleanup path inside reconcilePRs (which only queries StatusPROpen tasks). As a result, every no-change task leaked a full git clone on disk. Clean up the identity-correct worktree on terminal non-PR completions: - In daemon.process, invoke cleanupTerminalTaskWorktree using the task's identity-resolved worktree manager when the task reaches a terminal status (Merged/Rejected/ClosedWontDo) with PRNumber == 0. - Ensure parked tasks and open-PR tasks retain their worktrees for post-mortem triage and PR reconciliation respectively. - Add lifecycle regression tests in internal/daemon/terminal_cleanup_test.go. |
||
|
|
972fb5b8e1 |
feat(deployment): default to managed NATS workers
Autonomous workflows now always hand a complete task to a scoped archie-agent container. Embedded NATS is the default and external NATS changes only broker placement; legacy agent and containers.enabled inputs decode for migration but cannot select an execution path. The daemon flushes task-event subscriptions before a worker can publish, and runtime updates snapshot and restore the configured worker image. |
||
|
|
5d00ec7b0c |
refactor(agentexec): remove legacy execution paths
Autonomous workflows now have exactly one production boundary: a task-scoped archie-agent receives a full-task core-NATS request and runs the worker-local stage loop. The legacy [agent] section remains decode-only for migration; it no longer selects runtime behavior. |
||
|
|
cc6b093820 |
fix(daemon): require full-task worker handoff
Autonomous tasks no longer execute workflow stages inside archied; missing worker capability parks before worktree preparation. A transition to parked now atomically makes its detail the task park reason, so daemon-side failures remain visible in task APIs and the dashboard. |
||
|
|
1b7bc004b6 | feat(nats): expose embedded broker to managed workers | ||
|
|
ed33ab5380 |
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/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. |
||
|
|
dbb6550ab3 |
fix(worktree): bind publication to dispatch grants
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. |
||
|
|
508a0ad48c |
feat(forge): GitHub webhook receiver for immediate issue dispatch
Add [forge] intake = "poll" (default) | "webhook" | "both", and a forge
webhook receiver (internal/forge/webhook) that verifies a GitHub webhook's
HMAC signature, decodes the "issues" event, and publishes a matched issue
through the same path the poller uses -- so a labelled or assigned issue
starts a task the moment it happens instead of waiting up to poll_interval
(bead archie-core-7d5u.4).
The dispatch predicate (workintake.MatchesDispatch/RequiresLabel) is now a
single shared definition consumed by both the poller and the webhook
receiver, so the two cannot drift -- including the empty-label guard from
|
||
|
|
63d044603c |
fix(daemon): refuse to poll on an empty label-trigger match (#529)
GitHub's issues-list API treats an empty label filter as no filter at all, so dispatch.trigger = "label"/"either" with cfg.Label unset silently returned every open issue in the repo. A live incident (GH#445) queued 124 unrelated issues in one poll cycle after [dispatch.labels] -- a different field mapping task states to their own labels -- was configured while the actual trigger-match label was left blank. pollIssuesWithConfig's "label" branch now refuses to poll and logs an error when cfg.Label is empty; pollEitherWithConfig skips only the label-side poll in that case, still returning assignee matches. validateDispatch rejects the same misconfiguration at config-load time. A per-identity gap remains: identities have no Label field of their own and share the root's, so an identity overriding dispatch.trigger to "label" isn't caught by validation -- only by the runtime guard, which is why the runtime guard matters even with validation in place. Fixes archie-core-1786637501009-424-5b8332dd / GH#445. |
||
|
|
5da1d5d006 |
fix(agentworker,daemon): reconcile worktree ownership before push
Agent containers run as root (no USER in the Dockerfile, no userns-remap), so a commit the agent writes to the bind-mounted worktree lands owned by UID 0 on the host. The daemon then reads those same loose objects to push, running as its own non-root host user, and fails with "openat objects/../..: permission denied". containerEnv() now passes the daemon's own UID/GID as WORKTREE_UID/WORKTREE_GID. hybridTrees.Push -- the single point where a commit's objects are handed back for the actual push -- chowns the worktree to that owner first, via os.Lchown so a legitimately-tracked-but-dangling symlink doesn't abort a push that would otherwise have succeeded. Closes archie-core-1786749700606-6-bf6aa32d. |
||
|
|
16ec8393fe | style: apply gofumpt formatting | ||
|
|
2b5c67087b | fix(update): stamp install type and bound retry backoff | ||
|
|
20bff1a367 |
feat(agentexec,workflow): surface tool calls on the task timeline
archie-core-467 wired tool-call visibility into the interactive chat gateway, but a workflow task's own transcript never showed what its tools actually did -- only stage/agent-finish events existed, so there was no way to confirm an agent's summary matched what it really ran. Adds a ToolCallReporter, invoked once per completed call from toolExecute (the single choke point every tool call passes through before reaching a model), reported via a new ToolSetOptions.OnToolCall hook. Runner.Run grows a report parameter to carry it in: InProcessRunner wires it through, since it executes in the same process as its tools; SubprocessRunner and NATSRunner accept and ignore it, since their tool calls happen in a different process with nothing here to observe them. The workflow engine turns each report into a tool_call event on the task's own Bus (agent.go, implement.go), riding the same NATS event-forwarding archie-core-518 already built to get container events onto the daemon's timeline. Scoped to the central tool registry (read/write/edit/grep/shell/...) built via BuildToolSet; capture tools (structured finish output) and run_go_script build their ToolSet entries directly and are not yet covered. |
||
|
|
45345cdfb6 |
refactor(agent): move worker runtime into application layer
cmd/archie-agent used to own worker construction, NATS lifecycle, task execution, MCP setup, and workflow wiring. It now owns process input only and invokes internal/app/agentworker, while transport-specific NATS, boot-brief, and git-safety mechanics live under infrastructure. |
||
|
|
f544dd0978 |
feat(config): SIGHUP-triggered reload with requires-restart warnings
The daemon can now re-read its configuration on SIGHUP (or on a future in-process trigger) and republish it through the Holder, closing the first half of issue #348: 'config can change at runtime, safely, and can't brick the daemon.' Reload path: - cmd/archied/reload.go: ReloadController re-runs loader.Resolve on the same paths main.go passed at startup (Resolve is pure -- no reload state added to the loader). apply is called only with a Document that passed validation; a failed reload records the error and its timestamp and leaves the running config untouched. That Set-not-called-on-error property is the safety core and is pinned by TestReloadValidationFailureDoesNotApply. - SIGHUP listener in main.go runs reloadLoop(ctx, ch, controller, log); the loop is extracted as a testable seam (syscall.SIGHUP is Unix-only, fine given the Linux target). PollInterval is genuinely reloadable now, not just re-read: the three ticker sites (Run, per-identity goroutine, shared maintenance loop) re-read the interval each tick and Reset the ticker on change. A reloaded poll_interval takes effect on the next cycle. Diff-and-warn so an operator never has to read the source to know whether an edit took effect: changedNonReloadableFields compares the old and new snapshots against an allowlist of re-read fields (PollInterval, Repos, DiffCapLines, Budgets, Dispatch, and the Containers sub-fields VolumeTTL + MaxConcurrency). Anything else that changed logs Warn 'requires a restart'; a fully-applied reload logs Info. The allowlist is deliberate: a field added to Config later defaults to requires-restart, the safe direction. NATS split-brain closed: containerEnv now hands containers the endpoint the daemon's own client connected with at startup (Daemon.ConnectedNATS, captured at construction) instead of the live config, so a reloaded nats.url cannot point new containers at a server the daemon is not publishing on. A nats change is therefore classified requires-restart, and CLAUDE.md's 'hands its own nats.url verbatim' note is updated to the meaning it now has (same today, deliberately different after a reload). Validation guard: poll_interval <= 0 is rejected in validate.go beside the VolumeTTL guard. applyDefaults fills zero with 60s, so this fires on an explicit negative -- which would panic time.NewTicker/Reset at boot and, after the per-iteration reset, on a SIGHUP mid-run. Observability: config.ReloadStatus (last_error, last_error_at, last_reload_at) is recorded by the controller and surfaced in /api/config via Server.LastReload, so a stale running config is visible in the dashboard, not just the logs. Rendering waits for the UI step. Recovery hatch: --no-config-overlay flag plus ARCHIE_SKIP_CONFIG_OVERLAY=1 (configuration.SkipOverlay), logged at startup. No overlay source exists yet; the flag is the documented escape hatch the DB overlay (step 3 of #348) will consult. webui.Server.ConfigProvenance becomes atomic.Pointer so a reload can swap it via SetProvenance independently of Cfg; the accepted skew (new config alongside old provenance) is documented on the field. Verified: task check clean; -race on daemon, webui, cmd/archied, config, infrastructure/configuration. |
||
|
|
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. |