Persist content strategy runtime state in DB-backed SharedStateBackend#433
Open
Persist content strategy runtime state in DB-backed SharedStateBackend#433
Conversation
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.
Motivation
user_idplus task/resource/cache identifiers.Description
SharedStateBackendservice (backend/services/shared_state_backend.py) implementing task lifecycle, latest-strategy refs, and short-lived streaming cache with TTL and cleanup.StrategyGenerationTaskState,LatestGeneratedStrategyState, andStreamingCacheStateinbackend/models/content_strategy_state_models.py(tenant-scoped keys + unique indexes).ai_generation_endpoints.pynow uses authenticatedcurrent_user, writes/reads task status viaSharedStateBackend, persists latest strategy refs, and returns robust 404s for expired/missing tasks.streaming_cacheinstreaming_endpoints.pywith the shared DB cache (SharedStateBackend) for strategic intelligence and keyword research flows, and registers the new models in DB init (backend/services/database.py) so tables are created.Testing
python -m py_compile backend/services/shared_state_backend.py backend/api/content_planning/api/content_strategy/endpoints/ai_generation_endpoints.py backend/api/content_planning/api/content_strategy/endpoints/streaming_endpoints.py backend/models/content_strategy_state_models.py backend/tests/integration/test_shared_state_backend.pysucceeded.cd backend && PYTHONPATH=/workspace/ALwrity/backend pytest -q tests/integration/test_shared_state_backend.pywhich exercises multi-worker semantics (separate SQLAlchemy sessions), TTL expiry and not-found behavior; all tests passed (4 passed).Codex Task