59 Commits
Author SHA1 Message Date
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 2e48acfc92 fix(pg): hold one advisory lock across migration and grants (#2082) 2026-11-21 14:53:17 +11:00
sam 7b6154e7e8 docs(runs): plain the comments on run endings (#2042) 2026-11-21 13:55:46 +11:00
sam 3513dad609 Merge branch 'worktree-agent-a3fd604fba0fb36cc' 2026-11-21 13:55:00 +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 f47e60db00 refactor(events,deliveries): split source saving and plain the new prose (#2021, #2016) 2026-11-21 13:52:33 +11:00
sam 29a06f7c54 Merge branch 'worktree-agent-a2d0eb6dd8a9d5b66' 2026-11-21 13:47:46 +11:00
sam 01eb4aaf7c fix(events): verify webhook signatures before parsing (#2021)
A source now declares how its deliveries prove themselves: token (the
default, unchanged), hmac (HMAC-SHA256 over the raw body, per-source header
and prefix, secret sealed at rest and write-only) or none. The events module
verifies before the connector parses, answers 401 and logs the refusal.

The digest comparison is ported from internal/webhookguard/hmac.go and the
header-borne signature from internal/infrastructure/captureintake/receiver.go;
the old copies stay until their service goes. The seal package moves to
internal/platform/seal so events can seal the secret.
2026-11-21 13:46:48 +11:00
sam b48616798d fix(deliveries): stop retrying a delivery the channel rejects for good (#2016) 2026-11-21 13:45:31 +11:00
sam 073959b4f9 feat(memory): scope chat notes and preserve deletions on restore (#2069)
Keep personal notes private by default and require review before publishing shared notes. Restore backups and replay forgotten notes in one transaction, and retain the installed release when an unattended rollback could bring back forgotten notes.
2026-11-21 13:20:31 +11:00
sam ee66e4f0f3 refactor(prompts): the last three instructions written in Go are files (#2051)
AGENTS.md sends every instruction to a file in internal/prompts, and the
workspace scoping rule, the PR-review adversary mission and the model probe
were the three that still read as Go string literals. The text is unchanged:
the templates render the same bytes the concatenations built.
2026-11-21 03:48:42 +11:00
sam 98c0c11cbb feat(chat): track session taint and hold mutations in tainted conversations (#2068)
A conversation gets a persisted tainted flag (migration 00040), set the
first time output from a tool whose declaration trust level is not
"trusted" enters the turn, before that output reaches the model. The
flag is only ever set, never cleared, so later turns and resumed
processes inherit it. In a tainted conversation every non-read-only
action is raised to a floor of propose_and_wait, so the existing hold
path renders the approval card with the exact judged action; read-only
lookups still run, and a hard-rule refusal stays a refusal. An
unreadable taint state or a failed taint write fails closed. Trust
levels live on connectors.Declaration; unknown levels are untrusted.
2026-11-21 03:15:04 +11:00
sam 064eeab748 feat(governance): let owners rename the organisation and workspaces
Adds the organisation routes the single binary's dashboard needs (list, get, workspace list and create) plus owner-only renames of the organisation and its workspaces. A rename is guarded by the version the caller read, writes only the display label, and appends an actor-attributed event in governance.org_events in the same transaction. The Organisation page shows those name changes, and a deep link is no longer replaced by the landing page while the router is still resolving it.

Refs #2077
2026-11-20 21:10:34 +11:00
samandCopilot cf6108ad14 feat(chat): conversations belong to their person and act with their access (#2065)
Sessions carry an owner; every chat route serves only the caller's own
conversations (others are 404). Each turn and each approved held action
acts as its owner's principal, checked against the access rules before
judgement, so an operator's chat can't do what the operator can't. Chat is
open to any signed-in person, and the stream sends chat updates only to
the owner.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-20 19:05:20 +11:00
samandCopilot 59b0ac03c9 feat(dashboard): serve the live stream the Vue dashboard connects to
Same frames as internal/webui/sse.go with a keepalive; signed-in only.
Topics are added as each page moves onto the binary.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-20 00:34:46 +11:00
samandCopilot c12f6b7947 feat(governance): sign in to the archie binary from the Vue dashboard (#2017)
The binary serves the account routes the Vue client already calls: status,
setup, password and passkey sign-in, recovery, sign-out, OIDC, account
passkeys, password and recovery codes, personal tokens and capabilities.
The API authenticates a session cookie, a personal token or the bootstrap
admin token, and unsafe requests pass cross-origin protection. The
dashboard serves the Vue app at /.

Copied from internal/webui/{accounts,passkeys,personal_tokens,
api_capabilities,auth}.go, internal/infrastructure/oidc/{flow,oidc}.go and
internal/app/archieui/account_oidc.go, which archie-ui still imports.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-20 00:30:11 +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 0218e4ec89 feat(governance): move identity, org and Cedar access engine into governance (#2017)
Copied from internal/domain/identity, internal/domain/org, internal/domain/access, internal/infrastructure/access and internal/infrastructure/postgres.
2026-11-18 02:09:29 +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 db36d853ce feat(deliveries): every attempt keeps its response, its error and how long it took
A delivery.attempts row is written with the success or failure the store already records. The composer API returns the connector attempts that carry each message, so the dashboard can show each attempt's outcome and response.
2026-11-16 12:06:05 +11:00
sam 4b97ac5841 feat(audit): a connector call keeps the request core sent and the response it received
Resolve, target facts, invoke, lookup, deliver and parse record the protobuf wire messages as JSON on the context recorder the owning module supplies. Credentials are redacted and a body over 1 MiB keeps its prefix, full length and SHA-256. Judgement stores the resolve and target facts in the decision body and appends the executed invoke to it.
2026-11-16 12:06:05 +11:00
sam 564339e1aa feat(events,runs): an event keeps the payload it arrived in, and every model call records the request it sent via ai-sdk v0.8.1 (audit requirement) 2026-11-16 11:54:50 +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 4b1ae4babf feat(governance): each escalation step has its own deadline, and the path skips anyone below the authority an action needs (#1985) 2026-11-16 09:42:23 +11:00
sam 50b75f6987 feat(events): unmatched events are grouped by source, type and key fields, and Archie's own deliveries never group (#1994) 2026-11-16 09:42:23 +11:00
sam ef62dcc97a feat(judgement): impact, provenance, timing and cost guards from data, with business hours, blackouts and action budgets as settings (#1988) 2026-11-16 09:38:34 +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 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 55077620bb feat(judgement,connectors): guard extension contract; every running guard judges with the built-ins and records its name and digest (archie #1986) 2026-11-16 05:17:58 +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 22aee72679 feat(judgement,approvals,governance,ui): a class earns a raise after N approvals and drops on denial or failure; a freeze holds changing actions (#2004) 2026-11-16 05:03:24 +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 b9dd744f8c fix(pg): number the action classes migration after the schedules one, so it applies in order (archie #2003) 2026-11-16 04:37:11 +11:00
sam a91df7ec1f feat(judgement,approvals,ui): action classes are records with a level, history and reset; the precedent guard reads the class level (#2003) 2026-11-16 04:35:12 +11:00
sam 5712c9c4e6 feat(events,approvals): triggers fire on an interval, and an expired approval is escalated on every channel (archie #1992) 2026-11-16 04:33:28 +11:00
sam 1b8eb362d2 fix(prompts): the agent calls a lookup it would recommend instead of ending on it (archie #1999) 2026-11-16 04:24:38 +11:00
sam 7903a0e225 feat(connectors,deliveries,events): channels are connectors that deliver and listen; messages retry from their rows, and answers arrive as events (archie #1984, #1985) 2026-11-16 04:22:52 +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 200c6d0928 fix(prompts): the investigate prompt tells the agent to call the action it recommends (archie #1999)
It also said its tools only read, which stopped being true when actions became tools. Judgement decides whether an action runs, so calling one is the proposal.
2026-11-16 01:39:32 +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 eb9d470ba8 fix(runs): the forecast figure is in hours, so the model doesn't convert it (archie #2005) 2026-11-16 00:16:14 +11:00
sam a3d32e92e5 feat(runs): the investigate prompt names the labels and the figure (archie #2005)
An alert about a filesystem carries instance and mountpoint, and those are the
labels the forecast query needs, so the prompt names both and gives the query
that answers what an operator asks: the seconds until the disk is full, from
predict_linear and deriv over the same window. A negative figure is the
filesystem not filling, which the prompt says to report as that rather than as
a time.
2026-11-16 00:13:13 +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