Skip to content
pi-c Artifact [b84176eef6]
Login

Artifact [b84176eef6]

Artifact b84176eef6a554cfdfeb75c4d88a66f61bf1142637b36a0cf8d8c531237fc40e:


# A verdict per request

Status: built 2026-11-23 (ticket 35). Tier: core (the record: `pic_verdict`, run and journaled in
`src/loop.c`) and bundled (`src/verify.c`: the workspace's `.pic/verify.json`). Clock: durability.
Record: one `pic_verdict` row per answered request a verify command judged. Default: off; no file,
no command, no verdict.

## Why

`pic usage --by-trial` compared cost and tokens between arms but not whether the work passed, so
a cheaper arm that fails more looked better. A verdict is the arm's success rate, kept in the same
journal as its cost. The user-facing description is in [benchmarks](../manual/benchmarks.md).

## Core records, a component configures

The command is workspace configuration, read by `src/verify.c` from `WORKSPACE/.pic/verify.json`
when the workspace is trusted (the rule `hooks.json` follows) and handed to core as
`pic_store.verify`. Core runs it with the executor's `spawn` (its own process group, the request's
exec deadline, each stream kept to 8 KB) and records the outcome. Core includes no bundled header.

## When it runs

In `stop_gate`, after the Stop hooks have decided and only when the reply stands (no block, or the
loop guard ignored one), before the transaction that makes the reply the answer. A Stop hook's block
means the request goes on, so verifying then would judge work that is not finished; running before
the answer commits keeps the request admitted, so whatever runs it next finishes the verdict step
through the same journal-driven gate. With a verify command, a finished reply is journaled as an
assistant turn, as it is with Stop hooks, so the gate always sees it.

## The record and recovery

`pic_verdict(submission_id PRIMARY KEY, entry_seq, command, state, outcome, exit_code, duration_ms,
error, output, created_ms)`. The row commits as `started` before the command runs and as `done`
with `pass` (exit 0) or `fail` (any other exit, a timeout, a command that could not start) after.
The primary key and the gate's check for any row make it once per request. Recovery
(`settle_session`) turns a started row into `unknown` and never runs the command again; a done row
whose request was not yet answered is simply followed by the answer. Ctrl-C during the command
records `unknown` and the request is cancelled, so it has no verdict in the counts. Fault points:
`after-verdict-started`, `after-verdict-run`, `after-verdict` (bench.sh crashes at each).

`pic usage --by-trial` counts the verdicts of answered requests per arm, and adds its columns only
when any exists, so a journal without verdicts prints exactly what it did before.