44 Commits
Author SHA1 Message Date
sam 74928925c8 Merge commit '35e2a216a' 2026-11-21 15:20:36 +11:00
sam 35e2a216ab fix(runs): refuse a message.send step whose channel can't send to a chat (#2085) 2026-11-21 15:18:16 +11:00
sam b6907d8366 fix(runs): cancel the runs a cancelled run called (#2086) 2026-11-21 15:17:13 +11:00
sam 4b5c60330d docs(runs): plain the call wait comment (#2044) 2026-11-21 15:00:21 +11:00
sam 69b5b2aba6 Merge branch 'worktree-agent-aa1d52313cfc167e1' 2026-11-21 15:00:11 +11:00
sam 5d8c9303e0 feat(runs): workflow.call, workflow.handoff, workflow.approve and message.send (#2044) 2026-11-21 14:59:49 +11:00
sam 1989948ab3 fix(runs): encode agent prompts and action input with sorted keys (#2083) 2026-11-21 14:53:36 +11:00
sam 7b6154e7e8 docs(runs): plain the comments on run endings (#2042) 2026-11-21 13:55:46 +11:00
sam fb5f3ad472 refactor(runs): run the document's steps in their own function (#2042) 2026-11-21 13:54:34 +11:00
sam a88f5630fe feat(runs): the first step that sets an outcome ends the run (#2042)
Add workflow.finish (completed, parked, waiting_approval, declined). A failed
step parks the run unless it continues on failure, and a parked run retries
from a top-level step, replaying the earlier steps' recorded results. Adds the
retry-run operation and a Retry button on the run page.
2026-11-21 13:52:52 +11:00
sam 90637aa457 fix(runs): settle held actions a skipped or failed approval would leave
The end-of-run decision read the document's last approval step alone, so a conditional approval that was skipped, or one that continued past a failure, let a run finish without ever putting its held actions to people. Those approvals no longer count as settling. Resume still replays the agent and the request exactly once.

Triggers and dry runs now refuse a document that names an identity or profile, dry runs check required inputs, and step ids cannot contain dots that references read as separators.

The shipped investigate document gains a test that holds an action, suspends, resumes through the journal and reports one approved action.

Refs #2039
2026-11-21 01:20:21 +11:00
samandCopilot cbfcd43018 feat(chat): add the chat module to the archie binary (#2018)
Conversations are the chat module's own tables. A turn is stored before it
is acknowledged, runs after the turns before it in its session, and records
everything it streams, so a reader replays it from a cursor. The agent uses
the configured agent model, the same connector tools as a run and the
dashboard's own reads; every action is judged, and one judgement holds is
put to people through approvals and run once when approved. A restart fails
the turns it interrupted visibly and never restarts a started action.

Conversation memory is a set of notes in the memory module. The chat
prompts are copied from internal/prompts (chat-system.tmpl, soul.md,
session-title.md) into internal/platform/prompts while the gateway still
reads them; the tool parameter redaction is copied from
internal/domain/messaging/tool_parameters.go.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-19 19:40:44 +11:00
samandCopilot 64dfad6d53 feat(runs): add typed results and model aliases (#2043)
Also fix repository-free message.send validation (#2046) and add a single-binary development smoke path (#1977).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-18 23:47:35 +11:00
sam ce70d4f3ee feat(runs): workflow documents take today's step shape, references and when (#2039)
A step is id/type/settings with when and on_failure; the five kinds become
the types agent.run (inline mission), connector.action, approval.wait,
run.notify and workflow.sleep. Documents declare inputs, repository,
instructions, identity and profile; references are {{ task|inputs|steps }}
checked at save. Any number of approval steps, each asking only about what
was held since; actions still held at the end are put to people before the
run finishes. Triggers are refused for a workflow they can't start, and the
workflows API lists, reads and saves documents beside a step-type catalog.

Copied from internal/domain/workflow: definition.go, step_refs.go,
step_flow.go's checks, control_steps.go's when parser, vocabulary.go and
task/interface.go. stableid moves to internal/platform.
2026-11-17 18:43:45 +11:00
sam 1026d5e3b6 feat(httpapi): the API is described by an OpenAPI document generated with Huma (#2028)
Every /api operation is registered with Huma behind one admin-token
middleware, served at /api/openapi.json with a docs page at /api/docs,
and committed as api/openapi.yaml, which task check keeps current.
2026-11-16 20:05:05 +11:00
sam 9fe446a426 feat(governance): the agent model names a credential and answers a test call (#2026) 2026-11-16 13:45:15 +11:00
sam 46372b51d5 feat(runs,ui): the trail shows each model request and response, connector calls and delivery attempts
The run trail exposes the model request the journal recorded and its finish reason. Each model and tool step opens a Request and a Response, and each decision lists the connector calls behind it. The composer lists each delivery attempt with its outcome and response.
2026-11-16 12:06:05 +11:00
sam e45fee9bc9 fix(runs): a held action is described to the agent as waiting for approval, not a person's 2026-11-16 11:48:05 +11:00
sam 4657ff2646 fix(runs): a workflow summary names approval, not a person, as what holds an action (#2008) 2026-11-16 10:09:59 +11:00
sam 1e21aa975d refactor(runs): a workflow is a stored document of agent, action, wait-for-approval, notify and sleep steps, and investigate ships as one; dry mode judges without executing (#2008) 2026-11-16 10:05:51 +11:00
sam 42f0688f84 feat(pg): tables for stored workflow documents, dry runs and drafts (#2008) 2026-11-16 10:05:04 +11:00
sam 88afd1ebc9 feat(guard,runs): a guard is shown the agent's diagnosis and the evidence it read before proposing an action (#2006) 2026-11-16 09:55:14 +11:00
sam a4a4e97f07 feat(judgement): a target's owner is looked up from the connectors at decision time, and an unknown owner is a finding that sends the request to the default owner (#1991) 2026-11-16 09:49:33 +11:00
sam 28733c8522 feat(approvals,runs): an unanswered approval escalates step by step and then expires, a discarded approval never counts, and a change-request seam routes and withdraws (#1985) 2026-11-16 09:42:23 +11:00
sam 82cfc1de5b feat(judgement): hard rules and change-request rules as versioned Cedar policy sets (#1989) 2026-11-16 09:38:07 +11:00
sam 46edda9961 refactor(runs): one conclude step ends an investigation, keeping Investigate under the complexity limit 2026-11-16 05:21:48 +11:00
sam 3dcc8da0de fix(runs): find an unattended action's effect under the agent loop's key, which names the agent 2026-11-16 05:19:14 +11:00
sam a2972ac5d6 feat(governance,approvals): people with verified identities, default owner, escalation path and attempts per run; an answer from an unverified identity is refused (#2007) 2026-11-16 05:18:39 +11:00
sam 85e6f8eb40 feat(runs): an action started before a crash is reported unknown on resume and never run again, and the owner is told (archie #2015) 2026-11-16 05:18:05 +11:00
sam 400699cfbb feat(runs): a run is pinned to the workflow version it started with and fails clearly when it changed (archie #2014) 2026-11-16 05:04:30 +11:00
sam a0385a56c7 feat(memory,runs,governance): remember each target's incidents, cite them in a run, and propose a root-cause fix after K with one cause (archie #1993) 2026-11-16 05:04:15 +11:00
sam 25007e8316 feat(runs): an agent that describes an action without calling it gets one more turn to call it (archie #1999) 2026-11-16 04:39:49 +11:00
sam 1f5163092b feat(runs,approvals,ui): a run's trail joins each action's verdicts, approval and effect, and the run view shows them in order (archie #1996) 2026-11-16 04:33:27 +11:00
sam 3a700cddfa fix(connectors,runs): an approved action runs as judged however its input was re-encoded, and one that can't be confirmed is reported as unknown (archie #1985, #1990) 2026-11-16 04:08:15 +11:00
sam 0238f247e5 feat(approvals): a held action is asked of a person, and the run waits for the answer (archie #1985, #1999)
An action judgement holds at propose and wait is no longer a dead end. The
new approvals module owns the request: it binds to the decision and the
action's digest, so an answer covers the action the person was shown and
nothing else, and it settles once. The answer wakes the run, which judges the
action again and runs it only as the approval allows: a refusal still refuses,
an altered input runs nothing, and a judgement that came back worse runs
nothing on that approval.

The composer carries the request as a message with the request id and its
deadline, and its answer is a message too, so the trail shows what was asked
and what was answered. A request nobody answers inside its deadline is settled
as expired and nothing runs.

How long a request waits is an organisation setting, edited in the dashboard
and stored in milliseconds, because a Postgres interval scans as text. A run
pins the deadline it started with, like its model.

An agent that proposes the same action twice is asked about it once, and the
notification says when the investigation proposed nothing at all.
2026-11-16 02:21:06 +11:00
sam 0dbf241106 feat(judgement): the weakest-link decision, and executing only what was judged (#1986, #1989, #1990, #1988)
A new judgement module assesses one concrete action: hard rules refuse before
any guard runs; every guard sets a ceiling and the action runs at the lowest;
a guard that fails, panics or gives no ceiling holds it at propose and wait;
an advisory verdict is recorded and sets no ceiling. Reversibility and
Precedent (the fresh-install class default) are the first guards. Every
decision is recorded with its verdicts and class, and the run's trail lists
them. Agent tools now offer connector actions too: each call is assessed and
executed only as decided and only with the judged input, and a held action
comes back to the agent as a failed call naming its level and findings.
Tools gain Resolve, so an MCP server's declared effect reaches judgement.
2026-11-16 01:05:29 +11:00
sam 4877362223 fix(runs): a step hands back its value as recorded, so a resumed agent doesn't diverge from its journal (#1977)
Killing the binary mid-investigation and restarting it failed the run: the
first model request after the resume didn't match the recorded one. The tool
schemas pinned in a step reached the live attempt as written but the resume
as stored, and both the v2 encoder (compacting raw JSON) and jsonb (reordering
keys) rewrite them. Step now returns the decoded recorded value on the live
path too, and runs.steps.output is json, which keeps the text as written.
2026-11-16 00:36:19 +11:00
sam 6d97f62929 fix(runs,pg): grant the runtime role on sequences, and read a missing result as null (archie #2005)
Two faults stopped an investigation from finishing on staging.

The runtime role was granted DML on every table but nothing on sequences, so
the first table keyed by a serial (deliveries.messages) failed its insert with
"permission denied for sequence messages_seq_seq", failing the run at its
notification step.

A run that failed has no result, and a step with no output is recorded as NULL;
the rows were read straight into jsontext.Value, which can't hold NULL, so the
trail API answered 500 for exactly the runs and steps that needed reading. The
reads coalesce to JSON null instead.

Verified on staging after deploying: the same run's trail reads back.
2026-11-16 00:09:46 +11:00
sam cf249d7643 feat(connectors): MCP servers as a fourth accepted package, with their declared tools offered to agents (archie #2005)
An investigation needs Prometheus's own metrics, and Prometheus publishes an
MCP server, so the connectors module now runs MCP servers as published instead
of wrapping them: a stdio binary in its own user and network namespace with an
egress allow-list, or an HTTP endpoint dialled through declared egress.

Acceptance names the transport, the tools it permits, and the credential slots
that resolve into the server's environment (stdio) or Authorization header
(HTTP). Each permitted tool is declared as a lookup, or as an action with its
effect; a tool the server lists but the acceptance doesn't name is never
offered, and a declared tool the server doesn't list fails the start rather
than going silently missing. Declared tools reach agents beside connector
lookups through the same declaration and the same call path, with the server's
own input schema, under a name no connector can take: an accepted name runs one
package.

A server that fails to start, exits or stops answering is reported by readiness
and reconnected with backoff. Tool calls carry a deadline, results are capped,
and an error result fails its call with the server's own text rather than the
run.

The investigate prompt now asks for a time-until-full figure from
`predict_linear` through the metrics server instead of an estimate from raw
points.

The old core MCP path stays for now: the legacy gateway and task containers
still read config.Tools.MCPServers, so it goes with them.
2026-11-15 23:43:39 +11:00
sam 66220e1752 feat(runs,deliveries): the decision trail, the composer channel, and the dashboard that shows them (#1996, #1984)
GET /api/runs/{id} assembles a run's trail from rows already kept: the event
and trigger that started it, each workflow step, and each model and tool call
from the agent's journal. Investigations end by notifying their findings on
the composer, whose messages are read from a cursor with a live stream that
only says when to read. The binary serves its own SPA entry, archie.html,
calling only the new API. The investigate prompt now treats the event as a
claim to check against what it measures.
2026-11-15 23:36:42 +11:00
sam 02df83ccb7 feat(runs): the in-process agent loop, checkpointed as run steps, and the investigate workflow (#1977, #1889)
The agent model is an organisation setting in the new governance module.
Every model and tool call is a journal step, so a killed run resumes without
repeating either. Agents are offered connector lookups and read-only actions
only, until judgement exists.
2026-11-15 21:49:53 +11:00
sam 68d81fbbd0 refactor: the single binary uses encoding/json/v2 and jsontext (#1977) 2026-11-15 18:11:37 +11:00
sam 8b64ab0afe refactor(runs): Step, Sleep and Wait are generic methods on the run context (#1977) 2026-11-15 17:17:09 +11:00
sam e8366683a9 feat(runs): durable run engine with step checkpoints and lease-fenced writes (#1977) 2026-11-15 17:14:05 +11:00