Phase 4.6: Background tasks → TaskRegistry#578
Merged
Conversation
…Registry - Extract session cleanup + vacuum to modules/core/maintenance.py - Extract wiki embeddings + collection indexes to modules/knowledge/tasks.py - Extract kanban GitHub sync to modules/kanban/tasks.py - Extract WooCommerce daily sync to modules/ecommerce/tasks.py - Replace 6 asyncio.create_task() calls with TaskRegistry.register() + start_all() - Add task_registry.cancel_all() to shutdown_event for graceful cleanup - orchestrator.py: 1121 → 1030 lines Closes #551 Co-Authored-By: Claude Opus 4.6 <[email protected]>
19 tasks
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
asyncio.create_task()toTaskRegistry(Phase 0 infrastructure)orchestrator.pyinto domain modulestask_registry.cancel_all()Changes
4 new files (task functions extracted from orchestrator):
modules/core/maintenance.pycleanup_expired_sessions(1h),periodic_vacuum(7d, initial_delay=24h)modules/knowledge/tasks.pybuild_wiki_embeddings,load_collection_indexesmodules/kanban/tasks.pysync_kanban_issues(15min, initial_delay=60s)modules/ecommerce/tasks.pywoocommerce_daily_sync(daily 23:00 UTC)orchestrator.py (1121 → 1030 lines, −91):
asyncio.create_task()callsTaskRegistryinstance +register()+start_all()in startupcancel_all()inshutdown_event()asyncio,datetime,timedeltaimportsDesign decisions
functools.partial(fn, wiki_rag)to pass the service instance, sinceTaskRegistry.register()expects a zero-arg callablemodules/core/maintenance.py(nottasks.py) to avoid name collision withTaskRegistryinfrastructure inmodules/core/tasks.pyTest plan
ruff check— cleanpytest tests/unit/— 65 tests pass (including 8 TaskRegistry tests)Closes #551
🤖 Generated with Claude Code