Fix: name the diverging event in the conformance replay comparison - #840
Open
AmaadMartin wants to merge 2 commits into
Open
Fix: name the diverging event in the conformance replay comparison#840AmaadMartin wants to merge 2 commits into
AmaadMartin wants to merge 2 commits into
Conversation
added 2 commits
August 8, 2026 20:21
validateSession compared the two normalized event arrays with one assert.deepStrictEqual, so a failure diffed the whole session and never said which event diverged. Node elides unchanged regions, so the reader could not recover the index by counting either. Compare the arrays one event at a time and check the length first, so a mismatch reports either "Event count mismatch - Actual: n, Recorded: m" or "event <i> mismatch:" with the diff of that event alone. Mirrors compare_events() in adk-python's _replay_validators.py.
The helper had one caller and existed only to mirror a function name in adk-python. The observable failure messages are what parity requires, and inlining leaves them identical.
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
Link to an existing issue (if applicable):
Or, if no issue exists, describe the change:
Problem:
validateSessioncompares the two normalized event arrays with oneassert.deepStrictEqual. The failure diffs the whole session and never names the event that diverged. Node elides unchanged regions, so the reader cannot recover the index by counting. A length difference is also reported as a content difference.Solution:
validateSessionchecks the event count first, then compares the arrays one event at a time. A count difference reportsEvent count mismatch - Actual: <n>, Recorded: <m>and stops before any element comparison. A content difference reportsevent <i> mismatch:followed by Node's+ actual - expecteddiff for that event alone. This ports the granularity and the message vocabulary ofcompare_events()in adk-pythonsrc/google/adk/cli/conformance/_replay_validators.py.Parity note: the message words follow adk-python, the layout does not. The reference embeds newlines in the count message. Two integers read better on one line, and the failure printer indents every line it is given.
Scope note:
dev/src/integration/run_integration_tests.tsstill discards the message it catches. That file belongs to a separate change, so this PR leaves it alone. The harness prints these messages once that change lands.Collision check: I listed all 729 open PRs on the fork and read the diff of every PR that touches
dev/src/integration/test_runner.ts(#494, #643, #746, #749, #231) and the two conformance-reporting PRs (#745, #839). None reports the event index. #746 edits the same function to add a session-state assertion, but it keeps the single whole-arraydeepStrictEqual, so it is an overlap and not a duplicate. I branched frommainrather than stacking on #746: stacking would pull the unrelated state comparison into this review, and both PRs add the sameexportkeyword, so a rebase resolves cleanly.Testing Plan
Please describe the tests that you ran to verify your changes. This is required for all PRs that are not small documentation or typo fixes.
Unit Tests:
New file
dev/test/integration/test_runner_test.ts, 7 cases: identical sessions, per-run fields only, empty sessions, both count directions, the diverging index, and the first of several diverging indexes.Coverage of the new code is 100% of lines and branches, measured with
--coverage.include='dev/src/integration/test_runner.ts': no statement between the new lines 153 and 176 is uncovered, and every branch counter in that range is non-zero.Proof the tests can fail. I reverted
validateSessionto its old body:4 of the 7 cases then failed (both count cases and both index cases), for example:
Restoring the new body returns all 7 to green.
Manual End-to-End (E2E) Tests:
Please provide instructions on how to manually test your changes, including any necessary setup or configuration.
I drove the real replay path with no mocks:
batchLoadYamlAgentConfigandbatchLoadYamlTestDefsover a YAML fixture tree, thenTestRunner.run(), which builds a realRunner,InMemorySessionService,ReplayPluginandDummyLlm. To repeat it:npm run build --workspace core && npm run build --workspace dev.root_agent.yaml, plusspec.yaml,generated-recordings.yamlandgenerated-session.yamlfor one test.TestRunner.run(testInfo, true)inside atry/catchthat printserror.message.generated-session.yaml. The caught error readsEvent count mismatch - Actual: 2, Recorded: 1.text. The caught error names the event index, for exampleevent 0 mismatch:followed by the diff of that event.The fixture tree lives outside the repository, so it is not part of this diff.
Checklist