fix(service): move startup side effects out of CiderAgentService.__init__ - #102
Merged
Conversation
CiderAgentService.__init__ called self.reconcile_session_runtime(), which immediately hits SQLite for the active session and calls Cider RPC via playback_snapshot(). This meant constructing the service could fail if Cider was unreachable, and it made pure unit tests harder to write — construction had side effects that could wipe runtime state carefully set up by tests. Move the reconcile call to the explicit startup paths: - Application.worker_lifespan: the server/transport startup path, called before the background session worker starts. - service_context: the CLI one-shot path, where session state needs to be restored before the command runs. Construction is now cheap and deterministic. Tests that relied on reconcile running during construction (the restart tests) now call reconcile_session_runtime() explicitly after constructing the service. Add a regression test verifying construction makes no playback RPC calls and leaves session runtime empty until reconcile is called explicitly.
randileeharper
force-pushed
the
fix/init-side-effects
branch
from
June 28, 2026 17:54
7949ea6 to
0d12cd8
Compare
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.
Summary
Fixes #86.
CiderAgentService.__init__calledself.reconcile_session_runtime(), which immediately hits SQLite for the active session and calls Cider RPC viaplayback_snapshot(). This meant constructing the service could fail if Cider was unreachable, and it made pure unit tests harder to write — construction had side effects that could wipe runtime state carefully set up by tests.Changes
vesper/service.py: removedself.reconcile_session_runtime()from__init__. Construction is now cheap and deterministic.vesper/app.py:Application.worker_lifespan: callsreconcile_session_runtime()beforestart_background_session_worker(). This is the server/transport startup path.service_context: callsreconcile_session_runtime()before yielding the service. This is the CLI one-shot path where session state needs to be restored.tests/test_service.py:reconcile_session_runtime()explicitly.test_construction_has_no_storage_or_rpc_side_effects: pre-seeds an active session, constructs a service, and asserts no playback RPC calls were made and session runtime is empty untilreconcile_session_runtime()is called explicitly.Test commands run
All 256 tests pass; compileall clean.