Skip to content

🧪 [test extract_session_id fallbacks in harvest.py]#28

Merged
masuda-so merged 1 commit into
mainfrom
testing-improvement-harvest-session-id-fallbacks-8390380699473989570
May 10, 2026
Merged

🧪 [test extract_session_id fallbacks in harvest.py]#28
masuda-so merged 1 commit into
mainfrom
testing-improvement-harvest-session-id-fallbacks-8390380699473989570

Conversation

@masuda-so
Copy link
Copy Markdown
Owner

🧪 Testing Improvement: Harvest Session ID Fallbacks

🎯 What:

The testing gap addressed was the lack of unit tests for the extract_session_id function in scripts/harvest.py. This function handles critical session identification logic with multiple fallback layers and string normalization.

📊 Coverage:

The new test suite in scripts/tests/test_harvest.py covers:

  • Priority Logic: Confirms event["session_id"] is preferred over event["sessionId"] and environment variables.
  • Environment Fallbacks: Verifies CLAUDE_SESSION_ID and CLAUDE_CODE_SESSION_ID are used when event keys are missing.
  • Defaulting: Ensures "unknown-session" is returned if no identifiers are found.
  • Normalization: Validates regex-based character replacement and stripping of leading/trailing dashes.
  • Edge Cases: Handles non-string inputs and inputs that become empty after normalization.

Additionally, scripts/tests/test_index_vault.py was updated to align with the existing json_each(?) implementation in scripts/index-vault.py, resolving pre-existing test failures.

Result:

Improved reliability of the knowledge harvesting pipeline by ensuring session tracking logic is robust and correctly handles various execution environments. All 88 unit tests and the integration test suite are now passing.


PR created automatically by Jules for task 8390380699473989570 started by @masuda-so

- Implement `scripts/tests/test_harvest.py` to cover session ID extraction logic.
- Verify priority of event keys (`session_id`, `sessionId`) and environment variables.
- Ensure string normalization correctly sanitizes session IDs.
- Fix stale assertions in `scripts/tests/test_index_vault.py` to match current implementation.

Co-authored-by: masuda-so <258961222+masuda-so@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@masuda-so masuda-so merged commit 197c72f into main May 10, 2026
2 checks passed
@masuda-so masuda-so deleted the testing-improvement-harvest-session-id-fallbacks-8390380699473989570 branch May 10, 2026 14:09
masuda-so added a commit that referenced this pull request May 10, 2026
- Implement `scripts/tests/test_harvest.py` to cover session ID extraction logic.
- Verify priority of event keys (`session_id`, `sessionId`) and environment variables.
- Ensure string normalization correctly sanitizes session IDs.
- Fix stale assertions in `scripts/tests/test_index_vault.py` to match current implementation.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: masuda-so <258961222+masuda-so@users.noreply.github.com>
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.

1 participant