Skip to content

Fail a test whose run asks the scripted model for a wrong number of rounds - #86

Merged
rogers-andrew merged 4 commits into
cppalliance:masterfrom
rogers-andrew:scripted-chat-rounds
Nov 30, 2026
Merged

rogers-andrew merged 4 commits into
cppalliance:masterfrom
rogers-andrew:scripted-chat-rounds

Conversation

@rogers-andrew

@rogers-andrew rogers-andrew commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #46.

ScriptedChat is the scripted model that the tests of runvil-runtime use. A test hands it a list of replies, and it answers each round of the run, one request the run sends to the model, with the next reply. Until now it answered every round past the end of its list with the last reply again, and it accepted a run that left replies unused. A test therefore passed when its run asked the model for more or fewer rounds than the test scripted, unless the test counted the rounds itself.

A wrong round count now fails the test

  • A round past the end of the script panics with "the run asked for model round {n}, and the chat script holds {len} replies".
  • The crate's test drivers end a run through Driving::end: Scenario::run, Driving::finish (a Scenario stepped by the test), and Rig::finish (a run stepped under a seeded shuffle) all call it. It now panics when the run left replies unused, with "the run ended with {left} scripted replies left". The driver of the facade suite, the tests of the runvil-engine crate, already makes both checks with code of its own, in the same words.
  • Both panics happen on the test's own thread, because these drivers answer every effect there, so a panic fails the test even when the test expects its run to fail.
  • ScriptedChat::new(vec![]) is now accepted and means no round may reach the model. It used to panic on an empty list.
  • The new ScriptedChat::repeating(reply) answers every round with one reply. Only the models_loop bench uses it.
  • decisions/testing-and-debugging.md said the script repeats its last reply. It now states the two checks.

A run that a test builds with Scenario::into_run and drives itself never reaches Driving::end, so it gets the round check alone. Production code is unchanged.

45 tests now script the rounds their runs ask for

With the stricter model and the tests unchanged, 43 of the crate's 1,325 tests failed. After a rebase onto master at e3c1e641c, two tests added there since failed the same way. Each of the 45 now scripts the rounds its runs ask for and keeps every assertion it made:

  • 31 take an empty script. A run in each fails or is refused before its first round, or has its one round held (left unanswered by the test so that a cancel can arrive) or canceled before the script answers it. Most of them scripted a single text("unreachable").
  • 10 drop a last reply that their run never asks for, usually text("unreachable").
  • the_ceiling_caps_a_larger_declared_cap runs under a ceiling of 10 rounds and now scripts 10 replies, where it scripted 50. tool_loop_uses_the_default_cap_when_unspecified runs under the default cap of 24 rounds and now scripts 24, where it scripted 25.
  • join_any_joins_the_task_it_returns_and_only_that_task and an_arms_concurrency_limit_gates_its_fanout_and_the_whole_run each ran a scenario under three seeds from one shared script, so the later runs got the repeated last reply. Each run now builds its own script, and each seeded run must use all of it: two replies in the first test, ten in the second. The second keeps its assertion of 30 rounds in total, now summed over the scripts of its three seeded runs. Their helpers also build a scenario for three serial runs that answer with canned replies and leave their scripts unused.

A test of each check fails when that check is turned off

  • a_round_after_a_nonempty_script_is_spent_panics, in scripted_chat.rs, asks a one-reply script for two rounds and expects the round panic.
  • a_run_that_ends_with_a_scripted_reply_unused_panics, in scenario.rs, runs a prompt that asks the model once, with a script of two replies, and expects the unused-reply panic.
  • With the repeat of the last reply restored, only the first test fails. With the unused-reply assertion deleted, only the second fails. With both checks turned off, those two fail and the other 1,348 tests of runvil-runtime pass. Before these tests, and before the rebase, all 1,325 passed with both checks turned off, as Vinnie Falco's review of this pull request found.
  • ScriptedChat::new is now pub(crate). The bench calls repeating in its place, so only code inside the crate calls new, and test_support.rs keeps pub only for the items the bench names.

How the change was checked

  • Each of four script edits, applied alone and then reverted, fails only its own test, with the expected message:
    • dropping the last reply of a_batch_names_the_tool_behind_each_wire_name_an_adhoc_one_included, the issue's example, fails it at round 2;
    • adding a reply to the same script fails it with one reply left;
    • putting text("unreachable") back into an_empty_list_raises_before_any_round fails it with one reply left;
    • scripting 9 replies in the_ceiling_caps_a_larger_declared_cap fails it at round 10.
  • The workspace runs 4,118 tests on this branch, the 4,116 of master and the two new tests below, and all pass. These also pass locally: clippy with warnings denied, cargo fmt --check, cargo doc for the workspace and for runvil-engine with its default features, cargo xtask api --check (both facades match their public-API listings), cargo test -p build-xtask, and node --test tools/docs-claims.mjs. cargo dylint is not installed on my machine, so CI runs it.

The plan, which names 43 of the tests and records the review, the rebase, and the two others, is plan/2026-11-30-2-scripted-model-exact-rounds.plan.md. It took the number 2026-11-30-2 because master already has a 2026-11-30-1 plan.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Scripted model tests now fail when they request more replies than configured or finish with unused replies, helping catch mismatches between expected and actual model rounds.
    • Empty scripts support scenarios where no model request should occur; repeating replies support benchmarks that need a response for every round.
  • Documentation
    • Clarified how scripted model replies are consumed and checked.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@rogers-andrew
rogers-andrew marked this pull request as ready for review November 30, 2026 17:24
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Finite scripted chats now fail when a run requests too many replies or ends with replies unused. A repeating constructor supports intentional reuse. Runtime tests were updated to match expected round counts, and the benchmark now uses the repeating constructor.

Changes: Scripted chat round validation

Layer / File(s) Summary
Script behavior and end-of-run checks
crates/runvil-internal/runtime/src/test_support/scripted_chat.rs, crates/runvil-internal/runtime/src/test_support/scenario.rs, crates/runvil-internal/runtime/src/test_support.rs, decisions/testing-and-debugging.md, plan/2026-11-30-1-scripted-model-exact-rounds.plan.md
Finite scripts allow zero replies and panic when a request exceeds the script. repeating reuses one reply, and Driving::end checks for unused replies. The testing notes and plan describe these rules and related changes.
Empty scripts for no-round cases
crates/runvil-internal/runtime/src/execute/tests/batch_turn.rs, crates/runvil-internal/runtime/src/execute/tests/chat_arm.rs, crates/runvil-internal/runtime/src/execute/tests/compaction*.rs, crates/runvil-internal/runtime/src/execute/tests/models_compact.rs, crates/runvil-internal/runtime/src/execute/tests/models_loop-arguments.rs, crates/runvil-internal/runtime/src/execute/tests/models_loop_compactors.rs, crates/runvil-internal/runtime/src/execute/tests/models_loop_contract.rs, crates/runvil-internal/runtime/src/execute/tests/scheduler/failures.rs, crates/runvil-internal/runtime/src/execute/tests/scheduler/walk/driving.rs, crates/runvil-internal/runtime/src/execute/tests/section_messages.rs, crates/runvil-internal/runtime/src/execute/tests/live_infer.rs
Tests that expect no model round now use empty scripts instead of unreachable or late replies.
Scripts matched to expected rounds
crates/runvil-internal/runtime/src/execute/tests/adhoc_tools.rs, crates/runvil-internal/runtime/src/execute/tests/models_loop-author-shapes.rs, crates/runvil-internal/runtime/src/execute/tests/models_loop_compactors.rs, crates/runvil-internal/runtime/src/execute/tests/models_loop_contract-rounds.rs, crates/runvil-internal/runtime/src/execute/tests/precheck_anchor.rs, crates/runvil-internal/runtime/src/execute/tests/tool_loop.rs
Tests now provide only the replies required for their expected rounds. The max-token helper accepts explicit reply lists, and tool-loop limit tests leave the next round unscripted.
Repeating and per-run scripts
crates/runvil-internal/runtime/benches/models_loop.rs, crates/runvil-internal/runtime/src/execute/tests/happens_before-concurrency.rs, crates/runvil-internal/runtime/src/execute/tests/happens_before.rs
The benchmark uses a repeating reply. Interleaving tests create a fresh scripted gateway for each run and retain their call-count assertions.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other · Severity of issue fixed: Low

Suggested reviewers: vinniefalco

Merge Risk: Minimal · up to 3d3e5

This change makes scripted model tests fail when a run asks for the wrong number of rounds. It affects only test support, tests, the benchmark and documentation, so production behavior is unchanged. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: a test run that requests a wrong number of scripted model rounds now fails. The changeset makes ScriptedChat panic when a run requests a round beyond the script, and …
Linked Issues check Passed Issue #46 requires four things. (1) A round past the script must fail. ScriptedChat::complete_now in crates/runvil-internal/runtime/src/test_support/scripted_chat.rs now records the round, then pa…
Out of Scope Changes check Passed Every changed file is test support, a test, a bench, documentation, or the plan for this change. These are scripted_chat.rs, scenario.rs, test_support.rs, the runtime execute/tests/* files, `b…
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title states the main change: a test run that requests a wrong number of scripted model rounds now fails. The changeset makes ScriptedChat panic when a run requests a round beyond the script, and Driving::end panics when replies remain unused. The title is specific and matches the objectives, though it does not mention the new repeating constructor or the test updates.

Full details: Linked Issues check

Explanation

Issue #46 requires four things. (1) A round past the script must fail. ScriptedChat::complete_now in crates/runvil-internal/runtime/src/test_support/scripted_chat.rs now records the round, then panics with "the run asked for model round {n}, and the chat script holds {len} replies" when replies.get(slot) is None. The old index.min(len - 1) repeat is gone. (2) A run that ends with replies unused must fail. The file documents that the scenario fails such a run, and unused_replies() supplies the count. The PR summary says Driving::end in scenario.rs performs the check. I could not read that hunk within the inspection budget, so this part rests on the PR description and summary. (3) A named repeat must exist. ScriptedChat::repeating(reply) is added, and models_loop.rs uses it. (4) Scripts ending in an unreachable reply must drop it. The summaries show this for adhoc_tools.rs, models_loop_contract-rounds.rs, tool_loop.rs, and other files. The PR description names a_batch_names_the_tool_behind_each_wire_name_an_adhoc_one_included, but the summary of chat_arm.rs does not list that test. The mechanism itself is present at the reviewed head. The issue's examples concern test support and tests, and the PR states production code is unchanged.

Full details: Out of Scope Changes check

Explanation

Every changed file is test support, a test, a bench, documentation, or the plan for this change. These are scripted_chat.rs, scenario.rs, test_support.rs, the runtime execute/tests/* files, benches/models_loop.rs, decisions/testing-and-debugging.md, and plan/2026-11-30-1-scripted-model-exact-rounds.plan.md. Each test edit changes only the script or the expected round count. The summaries say each keeps its assertions. The happens_before*.rs edits give each seeded run its own script, which the issue's shared-script problem requires. The plan and documentation support the change. No production code path is changed, as the PR states.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c1fd8afe-65fc-4cfe-8447-184eebbb4361
Commits

Reviewing files that changed from the base of the PR and between 7951546 and 3d3e599.

Files selected for processing: 25

  • crates/runvil-internal/runtime/benches/models_loop.rs
  • crates/runvil-internal/runtime/src/execute/tests/adhoc_tools.rs
  • crates/runvil-internal/runtime/src/execute/tests/batch_turn.rs
  • crates/runvil-internal/runtime/src/execute/tests/chat_arm.rs
  • crates/runvil-internal/runtime/src/execute/tests/compaction-rules.rs
  • crates/runvil-internal/runtime/src/execute/tests/compaction.rs
  • crates/runvil-internal/runtime/src/execute/tests/happens_before-concurrency.rs
  • crates/runvil-internal/runtime/src/execute/tests/happens_before.rs
  • crates/runvil-internal/runtime/src/execute/tests/live_infer.rs
  • crates/runvil-internal/runtime/src/execute/tests/models_compact.rs
  • crates/runvil-internal/runtime/src/execute/tests/models_loop-arguments.rs
  • crates/runvil-internal/runtime/src/execute/tests/models_loop-author-shapes.rs
  • crates/runvil-internal/runtime/src/execute/tests/models_loop_compactors.rs
  • crates/runvil-internal/runtime/src/execute/tests/models_loop_contract-rounds.rs
  • crates/runvil-internal/runtime/src/execute/tests/models_loop_contract.rs
  • crates/runvil-internal/runtime/src/execute/tests/precheck_anchor.rs
  • crates/runvil-internal/runtime/src/execute/tests/scheduler/failures.rs
  • crates/runvil-internal/runtime/src/execute/tests/scheduler/walk/driving.rs
  • crates/runvil-internal/runtime/src/execute/tests/section_messages.rs
  • crates/runvil-internal/runtime/src/execute/tests/tool_loop.rs
  • crates/runvil-internal/runtime/src/test_support.rs
  • crates/runvil-internal/runtime/src/test_support/scenario.rs
  • crates/runvil-internal/runtime/src/test_support/scripted_chat.rs
  • decisions/testing-and-debugging.md
  • plan/2026-11-30-1-scripted-model-exact-rounds.plan.md

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@vinniefalco

Copy link
Copy Markdown
Member

The implementation looks good. Before merging, could you add two regression tests: one that requests a reply after a nonempty script is exhausted, and one that finishes with a reply unused? Each should assert the corresponding panic.

I temporarily restored the old repeat-last behavior for nonempty scripts and disabled the unused-reply assertion. All 1,325 runtime tests still passed. The manual checks in the plan show that both safeguards work today. Committing those cases would make CI catch either safeguard being removed later.

rogers-andrew and others added 4 commits November 30, 2026 14:57
`ScriptedChat`, the scripted model of `runvil-runtime`'s tests, answers a round past its script with its last reply again and accepts a run that leaves replies unused, so a test passes when its run asks the model one time more or one time fewer than the test scripted. The plan makes both cases fail the test and updates the 43 tests that fail once they do. It fixes issue cppalliance#46.

Plan: /plan/2026-11-30-2-scripted-model-exact-rounds.plan.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ounds

`ScriptedChat` answered a round past its script with its last reply again and accepted a run that left replies unused, so a test passed when its run asked the model one time more or one time fewer than it scripted. A round past a script now panics with the round and the length of the script, and `Driving::end` panics when a run leaves replies unused, in the words the facade suite's driver already uses. An empty script is accepted and means no round may reach the model. `ScriptedChat::repeating` answers every round with one reply, and only the bench uses it. The change touches the test support, the bench, one design page, and tests.

The 45 tests that failed under the stricter model now script the rounds their runs ask for, and every assertion they made stays:

- 31 take an empty script, because a run in each fails, is refused, or has its one round held or canceled before the script answers it.
- 10 drop a last reply that their run never asks for, usually `text("unreachable")`.
- 2 tool-loop tests script the 10 and 24 replies their caps allow, where they scripted 50 and 25.
- `join_any_joins_the_task_it_returns_and_only_that_task` and `an_arms_concurrency_limit_gates_its_fanout_and_the_whole_run` build a script for each run, where each shared one script across its seeded runs. The second still asserts 30 rounds in total.

The plan lists 43 of them, measured before a rebase onto `master` brought two more: `a_coalesced_author_assistant_message_invalidates_the_anchor` drops its unused last reply, and `timed_wait_inside_a_task_under_concurrency_one_wakes_and_cancels_slow_child`, whose one round is held, takes an empty script.

Plan: /plan/2026-11-30-2-scripted-model-exact-rounds.plan.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each of the four script edits fails only its own test, with the message the plan expects: two at a round past the script and two at replies left unused. The workspace runs 4,101 tests on the branch, as on `master`, and they pass. Clippy, the format check, both doc builds, the facade surface check, the structural checks, and the wording checks pass on this machine; `cargo dylint` runs in CI. Vibelight reports the same kinds of lead in the same functions as at `master`, with four leads on `"unreachable"` gone.

Plan: /plan/2026-11-30-2-scripted-model-exact-rounds.plan.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`ScriptedChat` panics when a run asks for a round past the end of its script, and `Driving::end` panics when a run leaves replies of its script unused. Each check now has a test that expects its panic. `a_round_after_a_nonempty_script_is_spent_panics` asks a one-reply script for two rounds, and `a_run_that_ends_with_a_scripted_reply_unused_panics` ends a one-round run whose script holds two replies. With either check turned off, its test fails and the other 1,349 of the crate's 1,350 tests pass. Vinnie Falco's review of pull request cppalliance#86 found that before these tests, and before the rebase onto `master`, all 1,325 tests of `runvil-runtime` passed with both checks off.

`ScriptedChat::new` is now `pub(crate)`. The benchmark calls `repeating` in its place since the earlier commit that added `repeating`, and `test_support.rs` keeps `pub` only for the items the benchmark names.

The plan of this change now decides to add the two tests, and it records the review, the rebase, and the results.

Plan: /plan/2026-11-30-2-scripted-model-exact-rounds.plan.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rogers-andrew

Copy link
Copy Markdown
Contributor Author

Added both in e372b39. With your experiment rerun, turning off either check now fails only its own test.

I also rebased onto master. Two tests added there since scripted a reply their run never asks for, so they got the same fix, and the plan is now 2026-11-30-2 because 2026-11-30-1 was taken.

@rogers-andrew
rogers-andrew merged commit e372b39 into cppalliance:master Nov 30, 2026
13 checks passed
@rogers-andrew
rogers-andrew deleted the scripted-chat-rounds branch November 30, 2026 23:18
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.

An Engine test can pass when its run asks ScriptedChat for more or fewer model rounds than the script holds

3 participants