Conversation
…ental parse (#1169) Strengthen test_unchanged_file_not_reparsed: - Assert the incremental offset is > 0 (not a full reparse from 0) - Assert the merged summary reflects appended event data (active_output_tokens == 42 for the resumed session) Add test_incremental_merge_preserves_cached_events: - Regression test proving cached prefix events (shutdown model_metrics) survive the incremental merge - Verifies both shutdown metrics retention and new event data inclusion - Anchors the list(ev_cached.events) + new_events merge behavior Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR strengthens the test suite coverage around copilot_usage.parser.get_all_sessions incremental parsing by adding assertions that the cached-offset fast path is actually used and that merged session summaries reflect appended event data after an incremental refresh.
Changes:
- Tighten
TestSessionCacheMtime.test_unchanged_file_not_reparsedto assert a non-zero incremental offset and validateactive_output_tokensafter merge. - Add a new regression test
test_incremental_merge_preserves_cached_eventsto ensure cached-prefix data (e.g., shutdownmodel_metrics, earlieruser_messages) is preserved when new events are appended.
Comment on lines
+6928
to
+6931
| # Second call — incremental parse merges cached + new events. | ||
| result2 = get_all_sessions(tmp_path) | ||
| assert len(result2) == 1 | ||
| sess_after = result2[0] |
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.
Closes #1169
Changes
Strengthens
TestSessionCacheMtime.test_unchanged_file_not_reparsedand adds a regression companion test to guard the incremental-merge path inget_all_sessions.1. Offset assertion (
test_unchanged_file_not_reparsed)Previously the test used
ANYfor the offset argument, which would pass even if the incremental path'sev_cached.end_offset > 0guard were broken and a full reparse from 0 occurred.2. Merged-summary data verification (
test_unchanged_file_not_reparsed)The appended
assistant.messageevent hasoutputTokens=42. After the incremental merge, the resumed session must reflect these tokens. Previously only session count was checked.3. Regression test (
test_incremental_merge_preserves_cached_events)A dedicated test that:
model_metricsfrom the cached prefix survive the merge (would fail iflist(ev_cached.events) + new_eventswere replaced with justnew_events)outputTokensappear inactive_output_tokensuser_messagescount includes the original user message from cached eventsThis mirrors the approach used in
TestIncrementalCacheLogic.test_incremental_append_uses_cached_prefixintest_vscode_parser.py.Warning
The following domains were blocked by the firewall during workflow execution:
astral.shpypi.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.