Pairs tool_use and tool_result blocks by ID into tool-call reports, keeps
the latest session_id, takes the run's usage from the result event and
falls back to per-message usage, counted once per message ID, for a run
killed before its result. Tested on streams recorded from Claude Code
2.1.282 and scrubbed of host detail.
The lifecycle block still showed `running -> merged` and never mentioned
`completed`. `running -> merged` is now illegal (taskstate transition table)
and `merged` is reachable only from `pr_open`; a workflow that opens no pull
request ends in the terminal `completed`.
Rewrite the block to the current rules and fold the crash-recovery requeue
into the `running` row it belongs to. Regenerate the committed docs artifact
carried by `task docs:artifact:check`.
The execution transition table refuses most of the pairs shipped fixtures
wrote to build a finished task -- running -> merged, queued -> parked,
queued -> waiting_human, queued -> merged -- so those fixtures fail the
moment the store enforces it.
internal/taskstate/taskstatetest seeds a status by walking the table's
legal edges (shortest route, computed from taskstate.CanTransition), so a
fixture cannot write an illegal pair and fails loudly when no route
exists. The fixtures in internal/daemon, internal/app/archied,
internal/webui and internal/infrastructure/postgres go through it, and
the table's own test names running -> merged as refused.
The cleanup added for no-change runs removed a `completed` task's
worktree whenever it had no PR. agent.run also ends its workflow
`StatusCompleted`, and it works in a real clone whose uncommitted edits
are the deliverable, so the status alone was enough to delete the work:
no commit, no push, no other copy of those edits anywhere.
Cleanup now reads the worktree first and skips a dirty one. A worktree
whose status cannot be read is kept too -- a wrong keep costs disk, a
wrong delete costs the work -- while one that is not on disk has nothing
to keep. The lifecycle fixtures prepare a real clone now, which is the
only shape the daemon ever cleans up, and the cancelled-context test
still cancels only the cleanup call.
The workflows page's per-workflow bar and its 'N of M' text, and the
workflow picker's percent on the new-task form, counted `merged` alone.
A workflow whose runs now end `completed` (a no-change build, a triage
that needed no code) therefore rendered zero delivery beside three
sibling surfaces that already counted both.
The count moves into ui/src/lib/delivered.ts, which GatePulseCard,
ThroughputTiles and TasksSummary now read too instead of keeping their
own copies of the arithmetic. The picker's label says delivered, not
merged: a run that ends completed is not merged.
The transition table moved the no-change outcomes to StatusCompleted, so a
run that opens no pull request now ends in a status the per-workflow stats
did not count at all: it was not merged, not in review, not parked, and the
workflows page would have shown it as a run that went nowhere. The count
travels the whole State Store path, since every dashboard consumer reads it
through the gRPC client rather than the local store.
- WorkflowStats filters `completed` beside merged and pr_open; the SQL is
the count, so a wrong filter reads as zero rather than failing, and
TestWorkflowStatsCountsCompletedRuns holds it against a real store.
- storecontract.WorkflowStat gains Completed (json "completed"), the proto
message gains field 9, and workflowStatProto/workflowStatValue carry it;
TestWorkflowStatProtoCarriesEveryField round-trips every field by name.
- The gateway's chat task report names the status.
- The dashboard counts a completed run as delivered in GatePulseCard's
totals and badge numerator, and the WorkflowStat/WorkflowStats/WorkflowRow
interfaces carry the field.
- TestOutcomeSitesAreTransitionsFromRunning is the guard that keeps the
producer and the table agreeing: it re-reads this package's tc.Outcome
assignment sites from source and requires each status to be one
internal/taskstate allows from running, so a new or moved site has to be
adjudicated against the table instead of discovered on a live run.
archie-agent mcp is a stdio MCP server, on the official go-sdk, serving a
stage's capture tools and appending accepted calls to a captures file.
The harness runner writes the tool spec and a standard mcpServers config,
registers it through HarnessSpec.MCPConfig, and reads the captures back
into the stage result. The captures file is writable by the harness user,
so the worker validates every record again with the same acceptCapture
the built-in loop now shares, and forged, undeclared or over-cap records
are dropped. A stage with capture tools on a harness without MCP is
refused before it runs.
The duplicate merge compared each finding against the ones already kept, so
overlap was transitive only through the survivors: a chain of findings 1-2,
2-3, 3-4 collapsed to one finding or to two depending on the order they were
handed in, and the two readings tied on score. It is a clustering now -- a
canonical sort, then a union of each run of overlapping ranges -- so the
surviving set is a property of the findings and not of the permutation they
arrived in, and a cluster's member is chosen by score and then by the
finding itself rather than by arrival order.
Two things the merge got wrong besides order. The PRD keys duplicates on
(file, overlapping lines, category), not on severity, so Finding carries a
Category and the merge reads it, while the severity now only decides which
duplicate speaks for the cluster. And a cluster is blocking when any member
is, so an advisory duplicate can no longer swallow the merge gate's verdict
and turn REQUEST_CHANGES into COMMENT.
diff.go read only the shape git writes. A plain unified diff -- sections
opened by a --- / +++ header pair with no "diff --git" line -- belonged to no
file and contributed no added lines, a silent narrowing of the diff-rules
gate's input; a file section opens from either now. git's C-quoted paths are
decoded from the diff --git line, the --- / +++ headers and the rename pair,
octal escapes to bytes, because a quoted path is not a path the snapshot has.
FileStatus is derived from every statement the section makes -- new file
mode, deleted file mode, old mode / new mode, rename from / rename to, and
the /dev/null side -- so a binary or empty file, whose patch has no headers
and no hunks, is reported as what it was rather than as a modification, and a
change of object type is the typechange the change capture already persists.
Score recorded a finding's duplicate identity before dropping it under its
severity's confidence floor, so a below-floor finding shadowed a later
above-floor duplicate of the same defect. The floor now runs first, and the
merge keeps the higher-scoring of two duplicates, so the result depends on
which findings were given and not on the order they were given in.
The duplicate rule was byte-identical line ranges. The PRD's rule is
overlapping lines: two same-file, same-severity findings whose ranges share a
line are now one finding.
FileStatus said "removed" for a deleted file, a second vocabulary for the
status the repository persists as "deleted". The value says "deleted" now.
Every phase of docs/prds/pr-review-agent.md that can be computed is computed
here, in a package that imports the standard library only: diff parsing with
renames, deletions, multi-hunk files and no-newline markers; directory
clustering; per-language blast radius; evidence packages; scoring,
deduplication, line mapping to diff coordinates and the review event.
The review event is REQUEST_CHANGES when a finding is blocking and COMMENT
otherwise; there is no approving value, because archie does not own the merge
decision.
internal/domain/workflow/prreview is now the one diff parser in this
repository: the diff-rules step's addedDiffLines delegates to it and the
private hunk-header and path helpers it used to carry are deleted, so a
repository rule and a review comment cannot disagree about which line a change
introduced. diff_rules_test.go is unchanged.
Blast radius resolves Go imports through the module path in go.mod, Python
module names, and JavaScript/TypeScript relative specifiers, all against files
inside the snapshot; an import that resolves to nothing there contributes no
edge. Evidence extraction reads through an fs.FS rooted at the snapshot, so
both are tested against fstest.MapFS fixtures.
NOTICE records the derivation from PR-AF (Apache-2.0).
StartKit calls InstallDone after the install hooks, before files and
startup hooks, so the caller moves the egress session to its runtime
policy exactly where the Kit spec ends the install phase.
StartKit creates the Kit container with archie's worker as its root
entrypoint and credentials, the Kit's volumes keyed by execution, then
runs install hooks as their users, writes the Kit's files as the harness
user, and runs startup hooks. A failing hook removes the container and
reports the hook's output. The Docker test proves on a real container
that the harness user cannot read the worker's environment, and fails if
the worker shares the harness uid.
Assemble turns an admitted Kit composition and the workload image's
config into the harness spec (the image's user, never root; the image
env plus the workspace, egress and credential sentinels; the launch
argv and agent-sessions verbs), lifecycle hooks with their declared users
and restricted environments (the image-derived baseline, egress settings,
and only the runtime variables each hook declares), the Kit's files, and
volume names stable per execution.
A Kit task's worker shares the sandbox network with its harness, so it
reaches NATS and the State Store through the relay like the harness
reaches the proxy. archie-agent relay takes repeated -forward
listen=target pairs, binds them all before serving so a port conflict
fails at start, and stops every forward when one fails. RelayArgs builds
the command from the fixed relay ports.
A Kit task runs worker and harness in one container, separated by user:
the worker keeps its credentials as root, and every harness invocation
runs as the Kit's user with only its declared environment. A nil env
would inherit the worker's, so the runner always passes an explicit one;
root is refused as a harness user, and a root worker refuses to start a
harness with no user. The PRD's container layout now says one container
per run, with the relay forwarding the proxy, NATS and the State Store.
The harness runner made internal/agentexec import go-git, which the tools
module reaches through docsgen, so tools/go.sum needed its entries; tidy
also dropped the stale modernc sqlite requirements. Request gained the
Harness field, so contracts.json is regenerated with the HarnessSpec
schema.
A stage whose request carries a HarnessSpec runs the Kit's CLI as a
subprocess in its own process group, with the mission and archie's rules
as the prompt. After every invocation the runner compares HEAD, every ref
and the git configuration, and the worktree against a pre-run baseline:
any ref or config change, a protected-path edit, or a write in a
read-only stage parks the step whatever the CLI claimed. The runner runs
the gate itself and resumes the same session with the gate's output, up
to the gate's failure cap. The wall clock and cancellation kill the whole
process group, so the CLI's children cannot outlive the step.
A session carries its run and its Kit's credential@1 requests. The proxy
applies apiKey inject rules only in the credential's phase and only to
hosts its rule names, after the network policy has admitted the request,
so a key never reaches a host its Kit did not declare. The real value
comes from a Resolver that returns only secrets the run credential
carries: a required credential that is unbound or unresolvable stops the
request before anything is sent, and an optional one passes only when it
is genuinely unbound. Named keys appear in the sandbox as a sentinel;
inject-only keys have no presence.
A harness is an agent profile whose environment is a Kit composition, so
image profiles and existing workflows are unchanged and only Kit runs take
the egress path; the relay replaces the claim that containers reach the
proxy directly. Credentials, step records, store installs and reviews are
org-scoped under the run credential and the Authorizer, and workflow calls
are linked across executions rather than nested.
Each sandbox gets an internal bridge on which the host holds no address,
so host services listening on every interface are unreachable; the relay
is attached under a fixed alias and is the one way out. ProxyEnv gives a
sandbox container its proxy URL and CA trust. The Docker integration test
proves allowed egress works and that the proxy listener, host services and
the internet are unreachable directly; it fails if the host-address
inhibition is removed.
archie-agent relay listens on the sandbox's isolated network and joins
every connection to one fixed target, the proxy. The relay holds no
secrets and can reach nothing else, so the host needs no address on a
sandbox network at all.
CONNECT tunnels and absolute-form http requests authenticate to a
per-container session, are checked against the session's phase policy,
and are forwarded with verified upstream TLS. A tunnel serves only its
admitted host: mismatched SNI and Host headers are refused. Upstream dials
refuse loopback, and refuse internal addresses unless the policy names the
exact IP, so an allowed name cannot resolve back into the host.
Decodes published descriptors from the manifest annotation, composes one
workload with its mixins through the Kit spec package, and applies the
runtime's support table: unsupported required capabilities refuse the
launch, optional ones are skipped and recorded, and forge or passthrough
credentials are refused. A composition must carry a headless prompt verb.
configuredSecretRegistry resolved provider keys in place, and the State Store's
copy of the config shared the providers map with b.cfg, so ImportConfig seeded
the process-local ARCHIE_PROVIDER_<hash> env name. Provider resolution now
runs only in the daemon and gateway boot (openStores).
A role has one value, so its row is the control instead of an accordion
that reveals the same text. Embedding pairs a provider select, limited to
configured providers whose class the embed package implements (openai,
openai-compatible, gemini, ollama, cohere, mistral), with a model name; the
chat model list never held embedding models.
archied already finds usable providers (key set in the environment, or
configured) through the model catalog; the published config view now
carries that catalog, providers with their model ids. Settings > Models
offers role models only from configured providers, lists the catalog's
unconfigured providers as available, and adding one carries its class, key
variable and endpoint. Roles and providers are two accordions, each ending
in an add row.
The four roles the daemon reads always show and cannot be deleted;
clearing one unsets it, and custom workflow roles can still be added.
Provider class is a select of the SDK's classes, the provider name is a
heading rather than an input, and a key read from the environment shows
as one line with Set reference instead of an 'unset / unset' reference.
It read as an alert that something had changed. Restart needs show where
they apply: in the review drawer for the changes being saved, and in the
Restart pending banner once a saved change is waiting on a restart.