Skip to content

merge(evaluation): serve a run's stored trace, raw and manifest - #82

Merged
LittleCoinCoin merged 109 commits into
mainfrom
feat/run-context
Nov 25, 2026
Merged

LittleCoinCoin merged 109 commits into
mainfrom
feat/run-context

Conversation

@LittleCoinCoin

Copy link
Copy Markdown
Member

Why

Candler's purpose includes grading "traces and artifacts, fresh or already on disk, through pluggable evaluators". Until now an evaluator could only be handed artifacts. The wire had context.trace and context.raw[], and needs.trace was a declared field, but nothing filled them, and a kind that declared needs.trace = true was silently served no trace. A shell call's exit status was also missing from the trace, so a kind that grades agent behaviour could not tell a failed command from a successful one.

This change lets a kind be handed any part a sealed run stored (its trace, its raw streams, its manifest) the same way it is handed artifacts, and records each shell call's exit status in the trace on both harnesses.

Changes

Trace

  • ToolResult gains an optional exit, the same ExitStatus every supervised process carries ({kind: code, code}). It is written only for a shell call whose harness stated a code, and is absent otherwise (denied, interrupted, timed out, or not a shell call). null is refused.
  • Claude Code reader (claude-code-stream-json@0.4.0): an Exit code N prefix on an error result gives N, and a plain success gives 0. Claude Code reports some nonzero exits as success: grep with no match, diff on files that differ, a false test. Such a result carries a returnCodeInterpretation key and no code, and it gets no exit, so the trace never says 0 for a command that exited 1.
  • OpenCode reader (opencode-export@0.2.0): metadata.exit on a completed shell call gives the code.
  • Fixtures for both harnesses were recorded by the real binaries on Candler's own rig, and tests/fixtures/README.md says how to record them again.

Serving the run

  • Needs gains raw and manifest, both booleans that default to false, so an existing plug-in's describe stays valid. trace is now honoured.
  • A served part is a read-only private copy in the request workspace, digest-checked against the store: trace.jsonl, raw/<stream>.jsonl.gz, manifest.json. RunContext.trace and RunContext.manifest are {path, abs, sha256}.
  • A part the run does not store is refused with evaluation.run_part_missing, never served empty.
  • One copy routine now serves artifacts, inputs and the new parts alike.
  • The store holds the stored file names in one place, and Store::raw_streams is the one reader of raw/. An entry there that is not a stream Candler writes refuses the context.
  • context_digest adds a key for a part only when it is served, so the digest of every existing context, golden imports included, is unchanged.

Python helper (candler-evaluator, unreleased 0.2.0)

  • RunContext.manifest, and ServedFile for the trace, manifest and raw streams.
  • read_trace yields typed records generated from normalised-trace.schema.json, and refuses a file out of order as the Rust reader does (helper.trace_out_of_order).

End-to-end

  • A new container guard, graded_run_sees_trace, runs one scripted agent on Claude Code and on OpenCode through candler run and candler evaluate. The plug-in passes only if the trace it was served holds the scripted commands with their exit codes and the MCP call's {server, tool}. The guard is in container-e2e.yml's expected list.

Breaking changes

  • On the wire, RunContext.trace is a {path, abs, sha256} object instead of a bare path (the field was never filled before).
  • A kind that declares needs.trace (or raw, manifest) for a run that lacks the part is now refused with evaluation.run_part_missing. Before, the trace need was silently ignored.
  • Both reader versions changed, so a run imported again gets a trace with different bytes.
  • A stray entry in a run's raw/ now refuses the context with candler.internal.

Hard parts

  • What a kind is served. The engine builds one context per request, and a request holds every applicable entry of one evaluator at one stage. A kind is therefore served the union of the needs of the kinds sent with it, and a missing part refuses the whole request. evaluator-protocol.md states this. Whether outcome reuse and refusal should instead follow each kind's own needs is left open.
  • Claude Code's exit codes. The tool states no number for a success-reported nonzero exit. The reader records what the harness stated and infers nothing, so in those cases the field is absent.

Not covered

  • Timeouts get no exit. Neither harness gives a code on its own timeout.
  • The signal variant of ExitStatus is unused in traces, because no harness reports a signal.
  • The helper does not check the trace rules that relate records (seq gaps, undeclared session, a raw_ref to an unlisted stream), and its docs say so.
  • Hidden and *.partial entries in raw/ are skipped by the store's visible-name rule rather than refused.
  • Python's ExitStatus.code is an unbounded int, while Rust's is i32.

Observations

  • candler run rebuilds candler-gateway:latest, and the superseded image disappears.
  • The parity guard's docker ps -aq equality can flake on a machine where other containers start or stop during the test.

Checks

On the tip: cargo fmt --check, clippy with -D warnings and cargo doc pass, and cargo nextest run --workspace runs 738 tests, all passing (33 skipped). The four guard_cli_e2e guards pass locally under --run-ignored only. The helper's pytest, ruff and the gen_models.py drift check pass.

🤖 Generated with Claude Code

LittleCoinCoin and others added 30 commits November 25, 2026 17:05
A kind can be handed a sealed run's artifacts but not its trace, raw
streams or manifest, and needs.trace is silently ignored. The plan
serves each part on declaration, adds a typed exit status to shell
tool results, and names the guards, the probe and their bites.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Eight nodes in four levels: the schema and a probe of real shell
shapes, then both readers, the serving of the stored run and the
helper, then a graded run on both harnesses, then an adversarial
review of the whole diff. Each leaf states its guards, bites,
estimate and cap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both leaves edit the trace enum, its generated schema and its contract
page. The schema leaf now checks first whether trace_context has
merged: the second to land rebases and regenerates, and the two land
in one release for one minor bump. Its doc gate also says that
needs.trace hands a kind the run's instruction texts once the trace
holds context_start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The maintainer approved the spend cap with the go for level 1. The
probe leaf commits under trace-model, since harness is not a scope
cog.toml allows. M6.5's trace_context has not merged into origin/main,
so the schema leaf goes ahead and whichever lands second rebases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The probe recorded that Claude Code moves a timed-out command to the
background with is_error false, so the Claude Code reader must not give
it code 0; a fourth bite guards that. OpenCode kills a timed-out command
and writes its signal by name with no exit, so the OpenCode reader gives
no exit when metadata.exit is missing, whatever the status. The plan
keeps exit absent on a timeout; mapping the signal name waits for a
consumer and joins the follow-ups.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Real Claude Code 2.1.311 and real OpenCode 2.2.7, each on the parity rig, ran
one scripted turn of three shell calls: exit 3, a stderr-only exit 2, and a
sleep that outlives a 1000 ms timeout. Their raw streams are kept as reader
fixtures with provenance. The scratch test and the fake-model script that
produced them ride in this commit and are removed by the next one.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Removes the scratch test and the fake-model script from the rig, and records
what the recorded streams show: OpenCode writes the code in metadata.exit,
Claude Code prefixes the content with Exit code N, and neither gives a code
on its own timeout.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Real Claude Code and OpenCode 2.2.7, run on the parity rig, each made a
shell call that exits 3, one that writes only to stderr and exits 2, and
one their own timeout ends. Their streams land as reader fixtures with
provenance, and the report answers what each writes: Claude Code keeps
the `Exit code N` prefix with stderr only and moves a timed-out command
to the background without a code; OpenCode writes a nonzero exit in
`state.metadata.exit` and a timed-out call as a SIGTERM with no exit.
The probe's own test code is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Verified against its fixtures; merged as e58f091. Its container-e2e
run waits for the integration branch to reach a pull request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A reader of a record Candler writes ignores an unknown field, so the
trace reader cannot refuse `exit` on a call line; the gate now states
what holds. `Needs` keeps the reading `KindSpec` and `DescribeResult`
have, schema strict and Rust reader lenient, instead of becoming the one
strict struct in the describe result. The serving leaf now carries the
engine's needs union, and the helper leaf the `bool | None` models that
could write a null the Rust reader refuses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The schema leaf's doc gate asked for a sentence about an event the trace
cannot carry until M6.5's trace_context lands, so the published schema
would describe a field the wire does not have. Whichever of the two
lands second writes it, in the commit that brings both together.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
History is not rewritten, so whichever of M6d and M6.5 lands second
merges origin/main in rather than rebasing, then regenerates the schemas
and contract pages. M6.5's side is its leaf meet_run_context.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Guards, written before the code and red on the base:
- a tool_result with an exit object reads and is written back; a bare
  {code}, a string and null are refused
- a describe result whose needs set raw and manifest is valid; a
  non-boolean raw and an unknown needs key are invalid, for the Rust
  reader and the helper's models alike
- context digest vectors for contexts that serve a trace, raw streams
  and a manifest, generated by the independent Python generator; the
  existing rows are unchanged

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A trace line's tool_result gains an optional exit, the process exit
object. Needs gains raw and manifest, booleans that read as false when
absent, and refuses a key it does not know. RunContext gains an optional
manifest, and its trace and manifest are {path, abs, sha256} objects.
ContextRaw gains sha256. context_digest adds a key for each served part,
only when it is served, so the digest of a context that serves none of
them is unchanged.

BREAKING CHANGE: RunContext.trace is an object, no longer a path string,
and ContextRaw has a required sha256, so a context written before is
invalid now. Candler never wrote a context with a trace or a raw stream.
Migration: write trace as {"path": "trace.jsonl", "abs": <absolute path>,
"sha256": <digest>} and add "sha256" to each raw stream. In Rust,
EventKind::tool_result takes the exit as a third argument, ContextRaw::new
takes the digest, and RunContextBuilder::trace takes a ContextArtifact.
A describe result whose needs carry a key other than the listed ones is
refused.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The event constructor takes the shell call's exit; the reader gives none yet.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The event constructor takes the shell call's exit; the reader gives none yet.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The generated models follow the schemas: needs gain raw and manifest,
a context gains a manifest, and its trace and manifest carry their
digests. The helper's context builder takes the trace's absolute path
from the object. The vector check of the isolation test skips the
vectors whose fault is in a kind's needs, which an envelope check does
not read.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Needs gain raw and manifest; the context holds an optional manifest,
its trace and manifest are objects with a digest, and each raw stream
carries its digest. The Notes are unchanged and stay within the budget.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A reader that takes exit as free JSON now fails on the refused row
it accepts, not on the key order of a kept row.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Needs ignores an unknown key in serde, as KindSpec and DescribeResult
do; the schema still refuses it. The needs_unknown_key vector goes,
with its README row.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The trace need no longer mentions an event the schema cannot hold, and
ContextArtifact says that the trace and the manifest have its shape.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A trace line's `tool_result` now carries an optional `exit`, the
`ExitStatus` object every supervised process already has, and both
trace readers pass none until they read it. A plug-in's needs gain
`raw` and `manifest`, false when absent. `RunContext.trace` and
`.manifest` are `{path, abs, sha256}` objects in `ContextArtifact`'s
shape, `ContextRaw` carries its sha256, and `context_digest` adds a key
for each of those parts only when it is served, so every existing
digest is unchanged. The schemas, the helper's models and the design
document follow.

The trace reader ignores an unknown field, as every reader of a record
Candler writes does, and `Needs` is read as its siblings in the describe
result are: the schema refuses an unknown key, the Rust reader ignores
it. The `feat(schemas)!` commit's body still says needs refuse an
unknown key; the `fix(schemas)` commit after it is what holds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LittleCoinCoin and others added 20 commits November 25, 2026 20:38
The report now says the glob doc was corrected, what the guard leaves
uncovered, and that bite (a) was applied again after the refactor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A plug-in kind that needs the trace and an artifact grades a real run
of Claude Code and of OpenCode, behind the production gateway and the
scripted fake model, and passes only when it sees each shell call's
command with its exit status and the MCP call's server and tool. The
guard runs in container-e2e and joins its expected list.

The fake model's start, the shared experiment and the sealing of a
run are shared with the parity guard; the seam helpers have one copy;
the e2e cleanup removes every job's containers and networks. The
Needs.artifacts doc says a glob starts with outputs/, as the registry
requires.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The report is numbered 03: 02 is the seam review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The findings of a reviewer who built none of the campaign, judged
against the README purpose paragraph, AGENTS.md and waste. Rulings
and fixes follow on this branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The script took exactly two commands; a recording of more shapes in one
run needs a list of any length.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude Code writes is_error false and a returnCodeInterpretation, with no
code, for grep with no match, diff of two files that differ and a false
test. The reader gave them code 0. They now carry no exit; the reader is
0.4.0, its version one macro invocation instead of two literals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude Code reports grep with no match, diff of different files and a
false test as non-error results, with a returnCodeInterpretation and
no code. The reader wrote exit 0 for them; it now writes no exit, as
the field promises when the harness states none. Reader 0.4.0. The
OpenCode export already states exit 1 for the same commands; both are
recorded as fixtures from the real harnesses, with the recipe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The store layout now owns the file names of the trace, the manifest and
the raw files, and Store::raw_streams is the one reader of raw/: an entry
that is not <stream>.jsonl.gz refuses with the store's Parse error rather
than serving fewer streams. The context, the frame writer and the runner
take their spellings from the layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The store holds the names of the trace, manifest and raw streams, and
reads raw/ once, refusing an entry that is not a stream it writes.
The helper refuses a trace out of order as the Rust reader does.
materialise builds a served entry in one place; each reader version
is spelled once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Claude Code reader is claude-code-stream-json@0.4.0, so the trace
the import writes for run-6 and run-12 changed bytes and hash. The
[[served]] rows record each new hash, taken from the store, and
gen_live_context.py recomputes their projection and digest; --check
agrees. Raw streams and the manifest are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LittleCoinCoin LittleCoinCoin changed the title merge(evaluation): serve a sealed run's trace, raw streams and manifest merge(evaluation): serve a run's stored trace, raw and manifest Nov 25, 2026
LittleCoinCoin and others added 2 commits November 25, 2026 22:09
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
graded_run_sees_trace builds the evaluator helper with `uv sync`, and
the container-e2e runner had no uv, so spawning it failed with
NotFound. Install it as ci.yml does, at the same pinned action.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LittleCoinCoin and others added 3 commits November 26, 2026 01:31
Take main (instructions and hooks as cell values, M6.5) into the run
context branch. Both trace changes meet in one generated schema: the
normalised trace keeps `context_start` and `tool_result.exit`, and the
schemas and contract pages come from BLESS, not a hand merge. No
version is bumped here.

Conflicts:
- parity rig: both sides lifted the fake model's start and the job run
  out of the parity guard. Main's `run_job` and `Fake { container }`
  are kept; `start_fake` takes the fake model's extra settings, `seal`
  is built on `run_job`, and `base_experiment` stays shared. The
  cleanup's job list (`Made::jobs`) replaces `Made::job`, so the
  agent-config guard reads the last job from it.
- Claude Code reader: main replaced the local harness name by
  `spec::CLAUDE_CODE`; the reader version stays 0.4.0.
- fixture provenance, the fake model's model list, the e2e module list
  and the architecture's trace kinds: both sides kept.

`needs.trace` now says that declaring it hands the kind the run's
system text and first message verbatim (`context_start`), which may be
the treatment under test, in the `Needs` doc and the helper README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Take main's release commit (core v0.17.0, schemas@0.14.0) into the run
context branch. The one conflict is the contract index's versions
table: main's core and schema versions are kept beside this branch's
candler-evaluator@0.2.0, and BLESS_CONTRACT regenerates the table
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The merge of main kept main's `start_fake`, which leaves `Made::real`
to its caller, as the parity and agent-config guards do. The graded
trace guard relied on the old `start_fake` setting it, so its cleanup
ran an empty path and panicked with NotFound after both runs had
passed. The guard now sets the cleanup's docker path itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LittleCoinCoin
LittleCoinCoin merged commit 59d1bbc into main Nov 25, 2026
7 checks passed
@LittleCoinCoin
LittleCoinCoin deleted the feat/run-context branch November 25, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant