Repository navigation
fix(api): manage analyzer connection lifetime explicitly - #171
Merged
Merged
Conversation
7 tasks done
This was referenced Oct 3, 2026
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.
📝 Description
Implement the highest-priority connection-lifecycle portion of the v0.4.0 tracking issue.
SnapshotAnalyzer.close()and context-manager support. Normal and exceptional exits clean up; exceptions propagate. Business/discovery methods and context re-entry fail withRuntimeError("SnapshotAnalyzer is closed.")after close.context_cacheand explicitinvalidate_context_cache()cleanup, including after analyzer close. Cache invalidation/closure alone still permits an open analyzer to repopulate its cache.finallycleanup for query, overview and peak-memory report.🔗 Related Issue
Refs #165. Partially addresses #165; this PR must not close the umbrella issue.
🧪 Testing
Local environment: macOS, Python 3.13.11 via
/Users/test1/liuyekang/miniconda3/bin/python; isolated temporary HOME, worktreesrcfirst in PYTHONPATH with existing site packages retained. Confirmed package import resolves to this worktree; no editable reinstall.python -m pytest tests/test_fixture_provenance.py -qbefore deserializing suitespython -m pytest -qpython -m pytest tests/test_analyzer_lifecycle.py tests/test_snapshot_analyzer_cache.py tests/test_query_cache_perf.py tests/test_api.py -q -W error::ResourceWarning -W error::pytest.PytestUnraisableExceptionWarningpython -m ruff check .python -m black --check .python -m basedpyright --pythonpath /Users/test1/liuyekang/miniconda3/bin/python --outputjsongit diff --checkRegression coverage includes real handles becoming unusable after close, multi-database cleanup, query/overview reuse, idempotency, no connection reopening after close, body/template/SQL/schema/overview failures, external shared caches on normal and exceptional exit, public cache compatibility, service reuse, CLI success/error cleanup, and Python 3.13 garbage-collection ResourceWarning checks.
✅ Checklist
Snapshot Runtime Provenance
Not applicable: no files under
src/pt_snap_cli/snapshot/**changed.Snapshot provenance decision: no-update
Snapshot provenance no-update reason: Changes are limited to analyzer/context/service lifetime, CLI cleanup, tests and API documentation; the snapshot runtime is unchanged.
📸 Screenshots (if applicable)
Not applicable.
📋 Additional Notes
origin/mainatc85a357; isolated worktree.worktrees/issue-165-resolve.