Skip to content

test(parser): add regression tests for sorted-sessions cache plan.md guard (#861)#866

Merged
microsasa merged 1 commit intomainfrom
test/sorted-sessions-cache-plan-change-861-fba78bcfd0a68974
Apr 8, 2026
Merged

test(parser): add regression tests for sorted-sessions cache plan.md guard (#861)#866
microsasa merged 1 commit intomainfrom
test/sorted-sessions-cache-plan-change-861-fba78bcfd0a68974

Conversation

@microsasa
Copy link
Copy Markdown
Owner

Closes #861

Adds two regression tests to TestSortedSessionsCacheSkipsRedundantSort covering the previously untested not deferred_sessions guard in get_all_sessions:

  • test_sort_runs_after_plan_change — creates two cached sessions, adds plan.md to one (without touching events.jsonl), and asserts that:

    • session_sort_key is called (cache bypassed due to non-empty deferred_sessions)
    • The returned summary carries the fresh session name extracted from plan.md
  • test_sort_skipped_after_plan_change_then_unchanged — after the plan-change call, calls again with no further file changes and asserts that session_sort_key is not called (sorted cache is now warm and up-to-date)

All existing tests continue to pass. make check passes cleanly (lint, typecheck, security, tests at 99% coverage).

Generated by Issue Implementer · ● 6.2M ·

…guard (#861)

Add two tests to TestSortedSessionsCacheSkipsRedundantSort:

- test_sort_runs_after_plan_change: verifies that adding plan.md to a
  session (while events.jsonl is unchanged) forces a re-sort via the
  `not deferred_sessions` guard, and the returned summary carries the
  fresh session name.

- test_sort_skipped_after_plan_change_then_unchanged: verifies that
  after the plan.md change settles, a subsequent call with no further
  changes hits the warm cache and skips the sort.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 8, 2026 18:19
@microsasa microsasa added the aw Created by agentic workflow label Apr 8, 2026
@microsasa microsasa enabled auto-merge April 8, 2026 18:19
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds regression coverage for the get_all_sessions sorted-sessions cache guard (not deferred_sessions) to ensure plan.md changes correctly trigger a resort and refresh cached session names.

Changes:

  • Adds test_sort_runs_after_plan_change to verify a plan.md add/change forces a fresh sort and updates the returned session name.
  • Adds test_sort_skipped_after_plan_change_then_unchanged to verify the sorted cache is repopulated and subsequent unchanged calls skip sorting again.

@microsasa microsasa added the aw-quality-gate-approved Quality gate approved the PR label Apr 8, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Quality Gate: APPROVE — Low-impact, test-only change with good quality.

What was evaluated:

  • Single file changed: tests/copilot_usage/test_parser.py (+136 lines, 0 deletions)
  • Two new regression tests in TestSortedSessionsCacheSkipsRedundantSort covering the not deferred_sessions guard in get_all_sessions
  • All 8 CI checks pass (lint, typecheck, security, tests, CodeQL, etc.)

Code quality assessment:

  • Tests are meaningful — they verify cache invalidation when plan.md changes and cache hits on subsequent unchanged calls
  • Follows existing testing patterns (spy-counting session_sort_key calls instead of wall-clock timing, consistent with the class's other tests)
  • Proper type annotations, clear docstrings, uses existing test utilities (_write_events, patch.object)
  • Compliant with CODING_GUIDELINES.md (strict typing, pytest conventions, no banned patterns)

Impact: LOW — Test-only addition, no production code changes. Auto-approving for merge.

@microsasa microsasa merged commit 4f05db0 into main Apr 8, 2026
8 checks passed
@microsasa microsasa deleted the test/sorted-sessions-cache-plan-change-861-fba78bcfd0a68974 branch April 8, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aw Created by agentic workflow aw-quality-gate-approved Quality gate approved the PR

Projects

None yet

2 participants