Skip to content

refactor(eval): an adapter from arms.v1 runs to answers.v1/eval.v1 - #1148

Merged
vlad-perevezentsev merged 23 commits into
intel:mainfrom
vlad-perevezentsev:refactor/arms-to-answers-adapter
Nov 24, 2026
Merged

vlad-perevezentsev merged 23 commits into
intel:mainfrom
vlad-perevezentsev:refactor/arms-to-answers-adapter

Conversation

@vlad-perevezentsev

@vlad-perevezentsev vlad-perevezentsev commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#228 step 4b. dokimi/eval/arms_adapter.py adds to_binary(arms): a pure function from an arms.v1 run to the answers.v1 and eval.v1 payloads that Stack P writes. With it, step 4c can hand answering and judging in evaluate/benchmark to ArmRunner and leave the readers of those files alone. No reader changes, and no numbers change. Refs #228.

  • Arms. The run's baseline_arm becomes without_docs, and it must be a baseline arm: each of its answered cells records arm_kind baseline (a --baseline-arm docs run is refused). Its one other arm becomes with_docs, and that arm must be a docs arm: each of its answered cells' metadata.arm_kind must be docs or mcp_doc (DocTreatment, treatments/factory.py).
    • The cells of a run-wide stop record no arm_kind (arm_stop.py). In a stopped run (a terminated or partial block), an arm that has only such cells, stopped before it answered, is taken as the docs arm: all with_docs gets from it is null, so nothing can be misread as a retrieval miss. A non-docs arm stopped that early cannot be told apart and converts too. In a run that never stopped, a kind-less arm is refused.
    • A run of the baseline arm alone is a knowledge run: with_docs: null, run_intent: knowledge.
    • Three or more arms, no baseline among them, a profile/skill/agent arm as the other one, or a session run (its answers are the last turn's): RecordError. A profile arm retrieves nothing, so read as with_docs every question would be a retrieval miss and the trust gate would fail the run on its hit rate.
  • Answers. A cell keeps its fields. Its context_chunks become retrieved_docs, keeping the non-empty objects of the list, which is what records.Answer reads. doc_source is the first chunk's source, as the answerer writes it.
    • An errored or empty cell becomes null, and the record's error names it (docs: generation_failed: ...), as the answerer records a failed condition.
  • Scores. Score blocks are copied from the run's evaluations list only (records.arm_scores), never from a legacy inline arms[name].evaluation.
    • delta, diagnosis and retrieval_hit are derived from those scores and answers the way the judge derives them.
    • A judge failure on an answered cell becomes the eval record's error.
    • run_metadata gets answer_model/answer_provider, judge_model/judge_provider, evaluator_independence_warning and run_intent. evaluated_at is the arms run's generated_at; the arms file is assembled after judging.
  • Absent, because arms.v1 does not record them:
  • Incomplete runs.
    • A run that a run-wide error stopped keeps its terminated block in the answers file and in the eval's run_metadata, so report eval shows its stop note. This holds for a run stopped on its first question as well.
    • The partial file of an unfinished run (<out stem>.partial.json, fix(arms): a crashed arms run keeps its answers in <out stem>.partial.json #1004) becomes an answers file with a terminated block. The block holds the partial block's counts and no reason, and there is no eval file: nothing in the partial file was judged. records.read still refuses the arms partial file itself.
  • report model-compare is not a reader of these files. extract_scores needs an arms file's baseline_arm, and an eval.v1 file gives it no rows. It keeps reading the arms file, and the test checks that its rows match the adapted eval question for question.

docs/architecture.md gets one sentence on the module, under "Treatment-arm comparison".

Changed output

None. Nothing calls to_binary yet; step 4c will.

Evidence

  • Golden test (tests/test_arms_adapter.py). Both stacks answer and judge the parity fixture (tests/answering_stack_parity.py), Stack A's run goes through to_binary, and the results are saved with save_artifact, which validates them against the schemas. Each reader then reads Stack P's own files and the adapted ones:

    • records.load: shape, conditions, answers, docs, retrieval_hit, knowledge-run check
    • the trust gate
    • report generate --format json
    • report eval: the markdown, past its "Generated" line, and the .qa.json records
    • the dashboard aggregator
    • RAGAS: the rows it is handed, whole context texts included
    • grounding
    • baseline's summary
    • significance_test
    • extract_scores

    On the five questions the stacks answer alike, every reader gives the same result, except two pinned rows:

    • the 200-character snippet ends in ... in the answerer and in … in the arm runner;
    • the run_metadata keys differ: P has question_model, question_provider and question_set_hash, the adapted eval has run_intent.

    The sixth question, q-empty, differs as parity row D2 pins it. P judges no with-docs answer (the placeholder: delta null, empty_retrieval, dashboard unjudged_miss). A judges a plain-prompt answer (60/60, delta 0, docs_helped). Both record retrieval_hit: false.

  • Other tests: a failed cell and a judge failure; a knowledge run; method_version carried and never stamped; the refusals (not arms.v1, a session run from ArmRunner with two turns, three arms, no baseline, a profile arm, an arm with no arm_kind); a legacy inline evaluation; malformed context_chunks; a stopped run, including ArmRunner stopped on its first question and judged; a partial file with no record; a real partial file from arms run crashing on the third of four questions.

  • Mutations, each failing a test and then reverted (16):

    • retrieval_hit dropped; doc_source dropped; retrieved_docs dropped
    • delta reversed
    • the empty-cell check removed; the judged-answer condition on the eval error removed
    • the partial block ignored
    • evaluated_at, the independence flag, the baseline-in-arms check or the knowledge intent dropped
    • the docs-arm check removed, and loosened in two ways
    • arm_scores back to rec.scores; the chunk filter loosened
    • One survives: the context_scored argument to diagnose. It is equivalent here, because the adapter never writes a fallback_none/none doc_source.
  • CI's mutation step (first commit): 39 of 40 killed. The survivor, zip(..., strict=True) → strict=False, is equivalent: the two lists are built from the same records.

  • make ci-local --offline on the first commit:

    • 26 passed, 21 skipped (network, docker, matrix).
    • 1 failed: Fragment for package changes, which this PR answers with skip-changelog.
    • Changed-line coverage of arms_adapter.py: 100%.
  • Review fix commits: make ci-local --offline --jobs static,typecheck plus the whole suite pass (26746 passed, 81 skipped), with the same fragment row failing.

  • scripts/check_growth.py: clean.

  • Not run: a live model or doc source. The adapter does not call either.

Open questions

  • method_version. arms.v1 carries no method_version (parity row artifact.method_version: 3 vs None), so the adapter writes none. answers_method_version then reads the adapted files as legacy v1. Nothing compares versions today. Step 4c has to stamp one, in the arms output or in the pipeline; this PR does not invent it.

Not in this PR

  • Calling the adapter from evaluate/benchmark: step 4c (A-4).
  • The token usage of an errored cell: answers.v1 has nowhere to put it, the same as for the answerer's failed conditions.
  • Session runs: refused (a session block or session_turns), not read turn by turn; each cell holds the last turn's answer.
  • token_usage_summary: derivable from the cells, but no reader reads it.

Checklist

…eline's readers

intel#228 step 4b. eval/arms_adapter.py's to_binary turns an arms run of a
baseline arm and at most one other into the answers.v1 and eval.v1
payloads Stack P writes, so step 4c can hand answering and judging to
ArmRunner without touching the trust gate, the reports, the dashboard,
RAGAS, grounding or baseline.

The baseline arm is without_docs and the other arm with_docs; a cell's
context_chunks become retrieved_docs and its first source doc_source.
delta, diagnosis and retrieval_hit are derived as the judge derives
them. What arms.v1 does not record (retrieval_metadata,
token_usage_summary, question_set_hash, judge_placeholder) stays absent,
and method_version is carried only when the run has one. A run-wide
stop keeps its terminated block; the partial file of an unfinished run
(intel#1004) reads as a terminated block with its counts and no eval.

The golden test runs both stacks on the parity fixture: on the five
questions they answer alike every reader gives the same result on the
adapted files as on the pipeline's own, except the pinned rows (the
snippet ellipsis, the run_metadata keys); q-empty differs as parity D2
pins it.

Refs intel#228

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
A profile, skill or agent arm retrieves nothing, so read as with_docs
every question was a retrieval miss: retrieval_hit False, diagnosis
empty_retrieval, and the trust gate failed the run on its hit rate.
to_binary now refuses a context arm whose cells name no arm_kind or one
other than docs/mcp_doc (DocTreatment's, treatments/factory.py), and the
partial-file test runs a knowledge run instead of a profile arm.

Refs intel#228

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
_eval_record read rec.scores, which also holds a legacy inline
arms[name].evaluation (under aggregate_score). Two such cells crashed
with KeyError 'aggregate'; one gave with_docs a block that is not an
eval.v1 score. records.arm_scores is the run's evaluations list only.

Refs intel#228

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
…eads

A context_chunks of strings crashed _answer with AttributeError, and an
object with KeyError 0, though records._answer had read the same cell
without complaint. retrieved_docs is now what that reader keeps: the
non-empty objects of a list.

Refs intel#228

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
@vlad-perevezentsev
vlad-perevezentsev requested a review from a team as a code owner November 23, 2026 15:43
@vlad-perevezentsev vlad-perevezentsev added the skip-changelog No user-visible change: bypasses the changelog fragment check label Nov 23, 2026
@vlad-perevezentsev vlad-perevezentsev self-assigned this Nov 23, 2026
@exai-bot

exai-bot commented Nov 23, 2026 •

Copy link
Copy Markdown

✅ OpenCodeReview: Review complete: 0 finding(s) across 3 selected item(s).

CI at ce42c5a: 21 passing, 4 skipped.

Review details
  • Commit reviewed: ce42c5a against merge base d378a62
  • Coverage: 3 files in 3 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 377k tokens (245k from cache), 49s
  • Tool calls: 28 (20 file_read, 3 code_search, 2 local_check_results, 2 pr_threads, 1 ci_status)
  • dokimi/docs/architecture.md: 1 file
  • dokimi/dokimi/eval/arms_adapter.py: 1 file
  • dokimi/tests/test_arms_adapter.py: 1 file

Comment thread dokimi/dokimi/eval/arms_adapter.py Resolved
@codecov-commenter

codecov-commenter commented Nov 23, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.09%. Comparing base (d378a62) to head (ce42c5a).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #1148    +/-   ##
========================================
  Coverage   96.08%   96.09%            
========================================
  Files         479      480     +1     
  Lines       63399    63507   +108     
  Branches    10978    10998    +20     
========================================
+ Hits        60919    61028   +109     
+ Misses       1529     1527     -2     
- Partials      951      952     +1     
Files with missing lines Coverage Δ
dokimi/dokimi/eval/arms_adapter.py 100.00% <100.00%> (ø)

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
…m answered

A run-wide stop on the first question writes cells with empty metadata
(arm_stop.stop_question), so the docs arm recorded no arm_kind and
to_binary refused the run instead of keeping its terminated block. A
context arm with no kind and no answer has nothing to misread as a
retrieval miss, so it now converts (with_docs null); an arm that
answered with no kind, or with a kind other than docs/mcp_doc, is still
refused. The check is now a set difference, and both doc kinds are
tested.

Refs intel#228

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
…ocs arm again

feafcb5 let to_binary take a context arm with no arm_kind and no answer
as with_docs, so a run stopped before a skill or agent arm answered (or
the partial file of a run killed before its first question) converted
as a paired docs run. The cells of a run-wide stop recorded no kind
because arm_stop wrote metadata {} for every arm.

stop_question and mark_not_asked now take each arm's arm_kind metadata
(arm_stop.arm_kinds, from the treatments; static_arm_kind moved there
from arm_runner.py, which stays under the 800-line cap), so a stopped
docs cell says it is one. The adapter is strict again: the context arm
must record arm_kind docs or mcp_doc.

Refs intel#228

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
…nd-less stopped arm

b87b725 stamped each arm's arm_kind on the cells of a run-wide stop.
That changes arms.v1 output and the numbers derived from it (a not_asked
cell of a skill_agent arm counted in skill_selection_summary.n_failed),
outside this PR's goal. arm_stop.py and arm_runner.py are back as on
main. to_binary instead refuses a context arm that records no arm_kind
and answered nothing, saying the run stopped before the arm ran; a run
stopped after its docs arm answered still converts with its stop.

Refs intel#228

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
@vlad-perevezentsev

Copy link
Copy Markdown
Contributor Author
🔍 **OpenCodeReview** found **1** issue(s) in this PR.
CI at `9021ffe`: 3 failing, 18 pa…

@exai-bot Agreed on the three failing checks: they are the growth ratchet on dokimi/commands/novelty.py, which is 801 lines on main itself (since #1133/#1134); this PR does not touch it. The local run on the merged head shows the same violation from main's file.

Comment thread dokimi/dokimi/eval/arms_adapter.py Resolved
Comment thread dokimi/tests/test_arms_adapter.py Resolved
Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
…m answered

059c382 refused a run whose context arm has only the cells of a
run-wide stop: they record no arm_kind (arm_stop.stop_question), so a
run stopped on its first question lost its terminated block. Such an arm
holds no answer, so all with_docs gets from it is null, which no reader
can misread as a retrieval miss: it is taken as the docs arm again. An
arm that answered with no kind, or whose cells name another kind, is
still refused. The stop cells themselves stay as on main.

Refs intel#228

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
…topped run

e0d883c converted any context arm with no arm_kind and no answer as
the docs arm, also in a run that never stopped: a kind-less errored
agent arm, or an arm with no cell at all, read as a paired docs run. The
exception is for the stop cells of arm_stop, so it now needs a
terminated or partial block. The docstring says so, wrapped at 120, and
that a non-docs arm stopped before it answered converts too.

Refs intel#228

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Comment thread dokimi/tests/test_arms_adapter.py Resolved

@napetrov napetrov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change class: CONTRACT (head 3503c34)

  • Contract: changed. defaults dokimi/dokimi/eval/arms_adapter.py:50; errors dokimi/dokimi/eval/arms_adapter.py:57
  • Responsibility: candidate. policy dokimi/docs/architecture.md
  • Dependency: none
  • Review depth: check the changed surface: callers, docs, tests pin new behaviour
  • Coverage gaps: none

I checked the adapter against the binary readers, paired and baseline-only runs, judge errors, stopped runs and partial files. A two-turn session can escape the documented refusal. The reader-parity test finding also remains open. Focused tests on 3503c3454: 26 passed.

Comment thread dokimi/dokimi/eval/arms_adapter.py Resolved
Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
A session cell holds its last turn's answer, so a binary record would
pair it with the first question; ArmRunner refuses to judge such records
for that reason. Without a turn reminder a session has only the
requested arms, so the arm count did not refuse it. to_binary now
refuses a run with a session block or a record with session_turns.

Refs intel#228

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
…unts

The golden test reduced RAGAS's retrieved_contexts to a count and the
record docs to their last characters, so an adapter that garbled a
snippet (two words swapped) still passed. It now compares the whole
texts on both sides, past the pinned "..."/"…" cut mark, and a negative
control swaps two words in one adapted snippet and sees exactly the doc
texts and the RAGAS rows differ.

Refs intel#228

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Comment thread dokimi/docs/architecture.md Resolved

@napetrov napetrov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change class: CONTRACT (head 22ea212)

  • Contract: changed. defaults dokimi/dokimi/eval/arms_adapter.py:50; errors dokimi/dokimi/eval/arms_adapter.py:58
  • Responsibility: candidate. policy dokimi/docs/architecture.md
  • Dependency: none
  • Review depth: check the changed surface: callers, docs, tests pin new behaviour
  • Coverage gaps: none

The previous two-turn ArmRunner case now raises RecordError. The reader-parity regression compares the retrieved context strings, including their order. All 29 adapter tests passed locally. One documentation nit remains in the architecture overview, where “one other arm” should say “one docs arm”.

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
The overview said a run of a baseline and "one other arm", but
to_binary refuses a profile, skill or agent arm and a session run. It
now says a single-turn run of a baseline arm and at most one docs arm.

Refs intel#228

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
…line arm

_binary_arms checked only the context arm's kind, so a --baseline-arm
docs run with an mcp arm converted as paired: without_docs held the docs
arm's answers, and the readers took an mcp-vs-docs delta as
docs-vs-no-docs. A baseline arm whose cells record an arm_kind other
than baseline (BaselineTreatment's) is now refused; stop cells, which
record none, pass. The overview no longer promises a refusal of other
arms in a run stopped before that arm answered.

Refs intel#228

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
The bare `--arms docs` arm takes no argument (specs.py), so `docs:`
read as if it were not covered.

Refs intel#228

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Comment thread dokimi/dokimi/eval/arms_adapter.py Resolved
Comment thread dokimi/tests/test_arms_adapter.py Resolved
Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
_binary_arms looked at the set of kinds an arm's cells record, so one
answered cell with no kind passed beside a docs cell, and read as a
with_docs answer (a retrieval miss when it had no chunks). Each answered
cell must now record a docs kind (the context arm) or baseline (the
baseline arm); only unanswered cells, such as a stop's, may record none.

Refs intel#228

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
The main parity test leaves out q-empty (D2), and its own test pinned
only the with-docs side and the scores, so an adapter that changed or
dropped q-empty's without_docs answer passed. The test now pins the
baseline answer as the record reader and the report eval Q&A read it,
the same on both stacks, and a negative control changes the adapted one
and sees only that row differ.

Refs intel#228

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
…kind

Since 51ee1a4 an answered baseline cell with no arm_kind is refused,
but the Arms bullet still let the baseline arm record none. It now says
for both arms that each answered cell records its kind and only an
unanswered (stop) cell may record none.

Refs intel#228

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
_cell_kinds decided which cells must name their kind with
not is_empty_reply(cell.text), and _answers_record which cells become
null with is_empty_reply(cell.text). The kind check holds only while
the two agree, so both now call _answered.

Refs intel#228

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
@vlad-perevezentsev
vlad-perevezentsev merged commit 7cfdbfa into intel:main Nov 24, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog No user-visible change: bypasses the changelog fragment check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants