320b9dc340f7fdef2a2a4191c6170ea4e2ea6990
29
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
a8c2068b7d |
feat(workflow): resume a parked run from a chosen step
Each finished stage records the run's step results; a retry may name a resume point, and the next attempt skips the steps before it with their results loaded. A run with a repository resumes only on its pushed branch. The canvas offers Resume/Re-run from here on parked runs. |
||
|
|
97db5b0c9b | feat(daemon): a workflow that names an identity runs as it; the dispatcher needs run on the workflow | ||
|
|
1bd738cfe8 | refactor(postgres,mcp,archieui,task,prreview,playbook): cut comments down to what the code does | ||
|
|
3c338a9722 |
refactor: strip doc and issue narration from code comments
Remove PRD/doc paths, bead IDs, phase notes and deleted-test references from comments; drop test-only hooks left by the test deletion. Includes in-progress archied bootstrap, gateway and query changes. |
||
|
|
a45300d626 | refactor: testing from the beginning. a journey in 150k lines of tests to none | ||
|
|
00e5b431e4 |
feat(webui): let the operator choose the retry worktree mode
A retry now carries the operator's worktree choice (refresh onto the base branch or continue the work already pushed on the task branch) from the dashboard through the task action to the daemon dispatch, and persists it on the task row so it survives a reload. The daemon resolves the mode from the task, never from the workflow; BeginRemediation records continue explicitly so a remediation still resumes its pull request branch. |
||
|
|
e5a7fadcd6 |
fix(workflow): derive a declared output's captures need for profile selection
A declared output is written through a capture tool, but the dispatch-time
harness check read only the workflow's needs.captures. A workflow that
declared outputs without also writing needs: {captures: true} could name a
Kit profile whose adapter serves no capture tools; a required output then
parked with "output %q is required" instead of the profile being refused.
WorkflowInterface.Needs now reports captures for a non-empty Outputs beside
the declared needs, and the profile check and Kit launcher read it. The
needs: block keeps its meaning for a workflow that captures without
declaring outputs.
- internal/domain/workflow/task: Needs() derives captures; DeclaredNeeds
carries only the declared block.
- internal/daemon: pinTaskProfile and runKitTask read Needs().
- tests: parse-time derivation, and pinTaskProfile refusing an
outputs-declaring workflow against a Kit adapter with no capture MCP.
|
||
|
|
50452639bd |
feat(prreview): the gate records the review it holds and posts the operator's answer
The gate now writes its offer to the task's review_gate document before it waits -- the scored findings, the head SHA, the pull request's identity and the resuming workflow -- because the engine cannot resume a run partway, so a resumed pipeline recomputes its findings and only the recorded document is the review the operator saw (docs/prds/pr-review-operator-response.md, "The review the operator answers"). The document lives with the task column it encodes (internal/domain/ workflow/task), the way EncodeInputs does, and carries each finding as opaque JSON beside the key an operator's selection names. That is what lets the dashboard render and answer a gate without linking the workflow engine -- cmd/archie-ui/architecture_test.go measures the linked binary, and an operator-domain service importing the finding's own type linked prreview into archie-ui. prreview owns the key derivation and the finding's encoding, and the MaxRereviewRounds constant lives in the task vocabulary beside the action names it answers with. Intake restores the document into the run: a re-review's instructions ride one labelled block in runLens's and runReviewer's missions only, and an approve's recorded review is posted by phase 9 filtered by the operator's selection, with the recomputed findings kept out of the output. The gate does not wait again on an answered approve. taskstate gains the rereview action the vocabulary needs -- offered for waiting_human beside approve and reject, routed to queued -- whose surfaces follow in the response channel. |
||
|
|
4b4459f0cf |
feat(staterpc): carry the review gate and re-review rounds, with one guarded response write
The operator-approval gate needs its conversation with the operator persisted before it waits and its answer threaded back (docs/prds/pr-review-operator-response.md, Decision 2). review_gate is a text column beside review_payload, encoded by the package that owns the type; rereview_rounds is a bigint counted only by the new guarded write. RespondReviewGate is the one write beside RetryTask/BeginRemediation: a transition-table guard, one from-status check, an optional round increment, and a requeue in one transaction. The re-review cap is enforced in the row under the guard's lock, and a refusal leaves the task waiting and the row untouched, surfaced as ErrRereviewCapReached (added to the wire error table and the conformance battery). The column joins the column-listing ListTaskSummaries projection and UpdateTask, so the dashboard reads the offer and the store round-trips the count. |
||
|
|
678bf82961 |
feat(workflow): declared workflow outputs for wait:true callers
A workflow declares named, typed outputs beside its inputs (task.WorkflowInterface.Outputs). A run writes each one once through a capture tool named after the output, or from a deterministic Go stage via TaskContext.WriteOutput; the finish write persists them on tasks.outputs before the outcome transition. A wait:true caller receives its successful callee's outputs through WorkflowCallStatus and publishes one as its own through a call step's outputs assignment. Build authority: docs/prds/workflow-call-outputs.md. - save time: WorkflowInterface.Validate checks output names and types; checkCallOutputs checks a call's assignment against both declarations and refuses outputs over a wait:false call. - run time: undeclared, mistyped and required-but-missing values park the run; published callee values are re-checked against the caller's type. - storage/wire: tasks.outputs (goose 0024), reset by each claim so the set is attempt-scoped; an encoded set past the structured-payload bound is refused, not clipped. Task.outputs_json and WorkflowCallStatusResponse.outputs_json carry it; task.Caller keeps its two methods. - examples: firewall-contain calls firewall-investigate and publishes its summary as its own output. |
||
|
|
dc1b61d394 |
feat(eda): per-org workflow enable/disable gating bindings
A workflow-enablement control-plane resource lists, per org, the workflows that org has disabled. A binding targeting a disabled workflow is skipped at dispatch like an unarmed one, is refused on save, and is flagged on the binding list; the workflows page toggles it. Bindings now carry the org_id column they already had in storage, over the State Store wire too. Org-owned workflow definitions are deferred to a follow-up bead: they need the caller's org, which the access chain resolves. |
||
|
|
ce7b46369d |
feat(workflow): watched-repos triggers pr-review via the generic binding system
Watched-repos needs no bespoke webhook-parsing code: the existing generic capture+binding system (internal/infrastructure/captureintake, internal/domain/binding.Binding) already turns any inbound webhook into a task on any workflow, via a dashboard-editable matcher, CEL filter and payload-to-input mapping. pr-review just needed to become a binding-targetable workflow. - Workflow gains an Interface field (task.WorkflowInterface) so a Go-literal builtin can declare inputs the same way a YAML-defined one does; ShippedDefinitions emits an inputs: block only when non-empty, so every other builtin's generated YAML is byte-identical to before. - PRReview() declares pr_number as a required number input. - Task gains EffectivePRNumber(): PRNumber when a producer set it directly (archie's own PRs), else the pr_number input a binding assigned generically through Task.Inputs. Handles json.Number (the store's round-trip encoding), float64 and int. - The daemon resolves it once in acquireTaskContainer, before the task brief is written and before the pr-review prefetch runs, so everything downstream agrees. stagePRIntake falls back to the same resolution for any dispatch path that bypasses container acquisition, and fails loudly if neither PRNumber nor the input is set. An operator wires up watched-repos entirely through the dashboard: a Binding matching the webhook's source, a CEL filter for pull_request events, workflow: pr-review, and an Inputs mapping pr_number from the payload. No code change needed for a new repo or a new source. Operator/chat trigger remains open, left as a precise continuation: EnqueueChatTask is part of the State Store's protobuf-generated gRPC contract (proto/state/v1/state.proto), not just a Go interface -- extending it for a generic inputs parameter needs a proto field addition + regen, a new SQL query (StampTaskBinding cannot be reused, since it unconditionally stamps binding_id/version, which a plain chat task must never carry), and updates across staterpc's client/server and ~20 call sites. Real plumbing, not a quick tool rewrite -- scoped correctly as its own pass rather than rushed here. |
||
|
|
b3e9159dce |
Merge crew/pi-dashboard-sweep: agent-call children, call steps, and the waited-on callee sweep
# Conflicts: # internal/domain/workflow/workflow.go # internal/infrastructure/postgres/queries/steps.sql |
||
|
|
0b8014516a |
feat(workflow): agent-call children, call steps, and the waited-on callee sweep
Plan item 4 of docs/prds/execution-tree-state-machine.md (archie-core-1216), plus the callee half of CancelExecution that plan item 5 deferred until the tree could decide it. Every agent call a stage makes records itself: AgentStage's bridge, the baseline-fix auto-fix run, the adversarial reviewer and a workflow.call each start a child StepExecution of kind agent or call under the stage's own step -- TaskContext.StepID, which the engine sets before the stage body starts and clears when it returns -- and finish it with the call's own outcome and the tokens it accounted. A child's recording write failure parks the execution the same way a stage's does: an agent call that ran unrecorded is the invisibility the step table exists to end. A stage invoked outside the engine's recorded run -- the stage unit tests -- records no child and runs unchanged. The call step is what makes the callee half of the PRD's Cancellation section decidable, and this lands it: a call step closes when its callee ends, so an open call step is a callee the caller waits on (wait:true) and a closed one is a wait:false callee that runs on. CancelExecution reads the open call steps before its sweep closes them and cancels each named callee through its own CancelExecution in the caller's write's aftermath -- the callee's own steps, its own events, its own move to the same destination, and the callee's own wait:true callees beyond it, the depth the enqueue enforces bounding the recursion. A callee that cannot be cancelled is reported and the caller's own record stands. StartStep refuses a call step whose callee is not this run's own (the callee's call_parent_task_id must name the recording execution): a compromised container could otherwise record a step naming a foreign execution and cancel it. StartStepRequest gains called_execution_id (field 6; non-breaking, the column and its named consumer already exist) and StepStart carries it. PRD decisions recorded here: - The reviewer records as one agent child named "review": the Reviewer contract runs one subagent per review, the PRD model's review:1/review:2 are illustrative of depth-1 children. A completed report closes it succeeded, a not-run review failed with the skip reason; the contract carries no usage, so tokens are 0. - A failed-callee call step closes as failed with the callee's detail when the wait ends otherwise; the single open case is the caller itself being cancelled, whose CancelExecution already swept this step -- a late write must not pretend the wait is still the caller's business. - A call step's callee is cancelled to the same destination the caller's action named (parked stays parked, closed_wont_do ends the whole chain), and a callee that cannot be cancelled is reported while the caller's own record stands either way. - The agent child's detail is the result summary on success and the error's text on failure, with the call's own TokensUsed -- the PRD's only usage field, untracked per call for the reviewer contract. |
||
|
|
7876bb4c0a |
feat(state-store): ListSteps, dashboard run detail reads it; drop tasks.stage
docs/prds/execution-tree-state-machine.md: step_executions (0017) is now the
durable per-step record; the dashboard's run detail (GET /api/tasks/{id}/
attempts) still folded stage_start/stage_finish events into a rail by hand,
and tasks.stage duplicated what StartStep/FinishStep already record properly.
Added the missing read:
- ListSteps(execution_id, attempt) -- attempt 0 lists every attempt of the
execution, oldest first, so the rail renders every attempt from one call.
New storecontract.StepReader (separate from StepRecorder: this is a
dashboard/API/dispatch action per the PRD's wire contract, never
task-scoped-grant callable), postgresdb.ListStepExecutions, staterpc
client/server/values.go plumbing, wired through state_store.go's Deps and
archieui/compose.go's Server.Steps the same optional-capability pattern
every other dashboard read uses.
- internal/webui/api_tasks_attempts.go: stageViewsFromSteps replaces
foldStages/finishStage/stageOutcome. Attempt bounds, event_count and which
attempt numbers exist stay sourced from events (an attempt can carry
events -- agent calls -- with no step), only the stage list itself moves.
The wire JSON contract is unchanged, so no frontend change was needed;
`task ui` confirms ui/dist still matches a fresh build.
- A running step past the task's own current attempt reads interrupted, not
running: RecoverStale (archie-core, still open per #1214) is what corrects
a crashed run's stale "running" row, and until it does this is the honest
read rather than trusting a row that may be stale.
Dropped tasks.stage and every reader, no fallback:
- Migration 0018 drops the column; tasks.sql's INSERT/UPDATE/RETURNING lists
and the sqlc-generated code no longer carry it.
- workflow.Task.Stage is gone; workflow.Run's in-flight "which stage is this"
bookkeeping moves to TaskContext.Stage (execution-time only, never
persisted -- park/finish's event tagging is its only reader).
- pb.Task.stage (wire field 10) is `[deprecated = true]`, not deleted (never
reuse a field number); staterpc's taskProto/taskValue no longer map it.
- taskactions.Task.Stage and the retry event's "previous_stage" data field
are gone: the operator-action package had no reader for the column beyond
echoing it.
- The chat /tasks command's per-task "workflow/stage" display drops to
workflow-only (ChatTaskSummary.Stage removed, workflowStage() deleted):
it was a genuine reader with no replacement in scope for this change.
Read the archie-web-ui skill and the state-store/daemon docs/development
pages first, per instruction. Stayed out of cancel/stop code throughout
(Pi's concurrent CancelExecution work); the only shared files touched
(workflow.go, daemon-adjacent SQL) got the smallest possible diff.
|
||
|
|
f884777c5b |
feat(statestore): step_executions, StartStep/FinishStep under the run credential
Plan item 3 of docs/prds/execution-tree-state-machine.md (archie-core-1220), on top of the transition tables and ErrIllegalTransition enforcement (1214/1215, archie-core-qdbo.5): - Migration 0017 adds step_executions -- id, org_id, workspace_id, execution_id, attempt, parent_id, depth, kind, name, called_execution_id, status, detail, tokens_used, started_at, finished_at, indexed on (execution_id, attempt, id). Ownership fields are stamped from the execution's row; depth is derived from the parent, never supplied by a caller. Existing rows gain no backfilled steps. - task.Store (the workflow engine's mid-run facade) gains StartStep/FinishStep (5 methods, within the 8 cap), with storecontract.StepRecorder fronting them on the server; deadlineStore wraps both with its per-call timeout. - The store enforces each write as one transaction: the guarded row write under the shared step transition table plus the transition's own stage_start/stage_finish event row. Staleness is decided before legality, the way guardTransition decides it, and the store returns the persisted event for the caller's post-commit publish -- the EmitDurable convention (the daemon's event sink skips already-persisted rows by assigned ID), which is why workflow.Run stops emitting stage events beside the store and no longer discards step-write errors: a failed start or finish parks the execution, and the stage does not run unrecorded. An interrupted stage records interrupted rather than failed; a recording failure on that shutdown path is logged and left to RecoverStale, which owns the interrupted-execution sweep in plan item 6. - The run credential of docs/prds/orgs-and-access.md authorises StartStep and FinishStep on its own execution only: both requests carry the execution ID the grant check verifies (FinishStep carries it because the interceptor never reads the database), and FinishStep verifies handler-side that the step really is that execution's. authorizesTaskScopedCall's sanctioned widenings are now held as a lookup table so the next one stops growing a switch. - The PRD's wire contract is StartStep(execution, attempt, parent, kind, name) -> step id; the responses also carry the persisted event (needed for the post-commit publish) and FinishStep's request carries execution_id (needed for the grant check) -- both noted here as deliberate additions to the PRD's shorthand. called_execution_id exists in the table but not yet on the wire: its named consumer is the workflow-call recording of plan item 4 (#1216). Conformance drives both adapters; grant tests pin the own-execution scoping; the wire sentinel set gains ErrInvalidStep (InvalidArgument, "step execution invalid") for a step kind no consumer names. |
||
|
|
abb9f8a04e |
feat(harness): declare and enforce a workflow's harness needs at dispatch
docs/prds/external-agent-harness.md ("Contract"): workflow definition
validation must reject a stage whose needs the selected harness cannot
meet -- capture tools without an adapter, or a gate retry without a
resume verb. The step vocabulary had no static way to declare either.
Added task.WorkflowInterface.Needs{Captures, GateRetries}, parsed and
validated (GateRetries >= 0) the same way Inputs/Repository already are.
Only a Kit profile is checked against it: an image profile's built-in
agent loop always supports both, so Needs constrains only the harness path.
Two enforcement points, chosen for where each fact is actually known
without a network fetch at save time:
- Captures vs adapter is knowable from config alone (profile.Adapter, the
agentexec.harnessAdapters table), so daemon.pinTaskProfile checks it
right where it already resolves the profile (validateProfileMeetsNeeds),
parking the task the same way an unconfigured profile already does.
- GateRetries vs the Kit's actual agent-sessions resume verb is only known
once the Kit composition is fetched, which kitrun.Launcher.Launch
already does -- so kit.ValidateNeeds runs there (new kitrun.Request.
GateRetries field, threaded from the workflow's parsed Needs in
daemon.runKitTask) rather than inventing an image-fetching workflow-save
validator.
Deliberately NOT built: "a Kit profile named by no workflow is a
validation error" (external-agent-harness.md "Selection"). Read literally
("a Kit profile [that is] named by no workflow"), this is a
cross-resource check -- an agent-profiles entry unreferenced by anything
in workflow-definitions -- and no control-plane Definition validator can
see another resource today (Definition.Validate is a pure []byte->error
function by design, matching every existing resource kind). Building
that crossing is a real, separate piece of infrastructure with its own
ordering questions (does defining a Kit profile before its workflow now
fail?), not a two-line addition, so it is left for a follow-on rather
than bolted on here.
Also fixes a test bug caught by rerunning with a short -timeout per
instruction: TestRunKitTaskThreadsGateRetriesToTheLauncher's fake NATS
subscriber never responded, so runKitTask's call into runViaAgent blocked
forever waiting for a reply bounded by a zero (unconfigured) wall-clock
budget. Fixed by responding, matching the sibling test's pattern.
|
||
|
|
df58c518dc | feat(workflow): workflow.call step with save-time input and cycle checks (archie-core-t2db.41) | ||
|
|
e0e9a17bd8 | feat(org): idempotency key org/identity/owner/repo/number in one place, task uniqueness to match (archie-core-e5fn) | ||
|
|
7b7aa62c28 |
fix(eda): clear completed tasks; document the tool allowlist's reach and unchecked profile names
ClearTerminalTasks now deletes completed tasks, with a test that holds its SQL list to taskstate.Terminal. The AllowTools comment says agentloop's built-in file tools are outside the allowlist and why. The PRD model diagram lists only what a profile holds (image, tools), and the profile field and AgentProfile say a workflow's profile name is resolved at dispatch, not when the workflow is saved. |
||
|
|
c431834e2b |
feat(eda): workflow inputs, optional repository and agent profiles
Workflow definitions declare inputs, repository (none, optional or required; default required) and profile. A binding assigns each input from a mapped parameter or a constant and may take its repository from a parameter, which must name a configured repo; both are checked when the binding is saved and again at dispatch. Inputs travel as structured task data (tasks.inputs, the task brief, and a JSON block in the agent's mission), never as body text. A task with no repository runs in a per-task scratch workspace with no clone and no publication grant. The agent.run step runs one mission without a repository and finishes the task in the new completed status. Agent profiles live under [containers.profiles.<name>]: an image and an allowlist over the tools archie adds (MCP, scripts, plugins). [containers].image is the default profile; an unconfigured profile parks the task. The workflow is now pinned before the container starts so the profile can choose its image. Also stop two archied tests writing embedded NATS state into the package directory, refuse an empty state_dir for embedded NATS, and drop the NATS store files an earlier lane commit tracked. |
||
|
|
0495af7c3d | docs(store): drop residual SQLite references; fix lane lint findings | ||
|
|
0d82f3fa66 |
feat(workflow): typed park classification and split remediation budgets
The F2+F3 schema wave from the auto-fix/resume investigation, sequenced together as one migration. Every failure funneled to one parked status with free-text ParkReason, and Task.RetryCount doubled as the operator-retry budget and the review-remediation round budget -- so N operator retries ate the remediation budget, a repo-level round cap could re-park a task an operator had just legally retried, and no surface could answer what a park needed from an operator. Park class (F2): a producer-recorded vocabulary in taskstate -- needs_human (the default, so an unclassified park always reads as operator-actionable), transient (environmental; a requeue can succeed), terminal (retrying is pointless). Recorded at the park site, never inferred from reason text; NormalizeParkClass makes unknown values persist as needs_human. Transition-to-parked defaults the class, so every existing unclassified park site reads correctly with no call-site churn; the classified ParkTask write follows for parks that know better. Requeue, RetryTask and BeginRemediation clear the class back to the default with the reason. Split budgets (F3): Task.RemediationRounds is the remediation's own budget; RetryCount stays the operator's. The round-cap stage counts and caps rounds; operator retry keeps counting RetryCount and can drive a task to dead without touching rounds. remediation_rounds is a presence-gated migrator column written through Update. Known state: proto fields, the ParkTask RPC, the staterpc mapping and the daemon-side park-site classification follow in the wire half of this wave (the proto parity test is intentionally red until then). |
||
|
|
d296484a2f |
docs(agents): a bead never carries production instance detail
Beads sync to a Dolt remote, so anything written into one is published. Two beads filed earlier today named an operator host, its internal address and its filesystem paths -- the tracker was treated as a private store, which it is not. The rule is stated where the tracker is described, next to the existing one about .beads/ never reaching a commit, because it is the same class: the tracker is not a private store. Host-specific facts belong in the operator's memos instance, which a bead may point at. |
||
|
|
89c074d213 |
feat(edastore)!: move event capture and bindings onto PocketBase collections
The event-capture tables (captures, mappings, bindings, binding_dispatches,
playbook_dispatches) now live in PocketBase-owned collections and their ids
are opaque record ids rather than autoincrement integers. The task lifecycle
stays on SQLite: tasks/transitions/events carry FIFO claim ordering, id-cursor
pagination and the task-grant map, none of which gain anything from being
hand-editable. binding_dispatches.task_id is the single seam and stays an
integer addressing that store.
BREAKING: CapturedEvent.Id, Mapping.Id, Binding.Id and Binding.MappingId are
strings on the wire, as are the ids in the capture/mapping/binding requests.
RecordDispatchRequest.task_id is deliberately unchanged.
What the collections buy, beyond storage: a payload nobody has modelled yet is
inspectable, a mapping is editable at runtime, and a binding's relation to its
mapping is enforced. The old schema declared no FOREIGN KEY on that link, so a
dangling mapping_id was previously possible and is now refused.
Behaviour preserved deliberately, each recovered from the SQLite version
rather than reimplemented from memory:
- draft -> pending_approval -> armed, with approval only from
pending_approval and an edit always returning a binding for re-approval
- one binding per source, guarded on insert, update and approve
- an empty secret on update keeps the stored one, so an edit form that does
not echo it back cannot silently disarm a binding
- ErrMappingNotFound / ErrBindingNotFound on a missing delete target
- sentinels are re-exported from storecontract, never redefined: staterpc
matches on exact canonical message to rehydrate them, so a second
definition would break errors.Is across the wire invisibly
Two implementation notes worth keeping:
- at-most-once dispatch is now a unique index rather than INSERT OR IGNORE.
Only the unique-violation maps to ErrAlreadyDispatched; any other save
error is returned, because treating them all as "already recorded" would
turn the ledger into a silent at-least-once dispatcher.
- captures store received_at themselves at nanosecond precision in a
fixed-width layout. PocketBase autodates are millisecond and record ids
are random, so same-millisecond captures would otherwise order
arbitrarily; the old store got insertion order free from autoincrement.
- ListUndispatchedCaptures is raw SQL: the anti-join is a subquery and
PocketBase's filter DSL is not SQL. A read fires no hooks either way.
Adds tool_calls, which had no persistence at all: tool calls only ever reached
the on-disk task log, readable as text but never queryable or watchable.
Nothing writes it yet.
The binding secret cipher moves with the bindings it protects.
|
||
|
|
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. |
||
|
|
c29cdf6f79 |
feat(workflow): post line-anchored review comments with suggested fixes (#891)
* 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. |
||
|
|
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. |
||
|
|
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. |