feat(tasks): add background task scheduler for LLM expiry fallback #6

Open
pyr0ball wants to merge 0 commits from feature/shared-task-scheduler into main
Owner

Summary

  • Adds app/tasks/runner.py wiring Kiwi to circuitforge_core.tasks.scheduler
  • Task type: expiry_llm_fallback (2.0 GB VRAM budget) — calls ExpirationPredictor when barcode/OCR expiry parsing fails
  • insert_task() is idempotent: returns (task_id, is_new) using INSERT OR IGNORE
  • Migration 006: background_tasks table + status index
  • Lifespan in app/main.py starts the scheduler and calls shutdown(timeout=10.0) + reset_scheduler() on teardown
  • ExpirationPredictor at module scope (required for patch() to intercept it in tests)

⚠️ Depends on Circuit-Forge/circuitforge-core#2 (shared task scheduler)

Test plan

  • App starts and scheduler initialises without error
  • expiry_llm_fallback task enqueues and runs via _run_expiry_llm_fallback()
  • Duplicate insert_task() calls return same task_id, is_new=False
  • Scheduler shuts down cleanly on app teardown
## Summary - Adds `app/tasks/runner.py` wiring Kiwi to `circuitforge_core.tasks.scheduler` - Task type: `expiry_llm_fallback` (2.0 GB VRAM budget) — calls `ExpirationPredictor` when barcode/OCR expiry parsing fails - `insert_task()` is idempotent: returns `(task_id, is_new)` using `INSERT OR IGNORE` - Migration 006: `background_tasks` table + status index - Lifespan in `app/main.py` starts the scheduler and calls `shutdown(timeout=10.0)` + `reset_scheduler()` on teardown - `ExpirationPredictor` at module scope (required for `patch()` to intercept it in tests) > ⚠️ **Depends on Circuit-Forge/circuitforge-core#2** (shared task scheduler) ## Test plan - [ ] App starts and scheduler initialises without error - [ ] `expiry_llm_fallback` task enqueues and runs via `_run_expiry_llm_fallback()` - [ ] Duplicate `insert_task()` calls return same `task_id`, `is_new=False` - [ ] Scheduler shuts down cleanly on app teardown
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feature/shared-task-scheduler:feature/shared-task-scheduler
git checkout feature/shared-task-scheduler

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git checkout main
git merge --no-ff feature/shared-task-scheduler
git checkout feature/shared-task-scheduler
git rebase main
git checkout main
git merge --ff-only feature/shared-task-scheduler
git checkout feature/shared-task-scheduler
git rebase main
git checkout main
git merge --no-ff feature/shared-task-scheduler
git checkout main
git merge --squash feature/shared-task-scheduler
git checkout main
git merge --ff-only feature/shared-task-scheduler
git checkout main
git merge feature/shared-task-scheduler
git push origin main
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Circuit-Forge/kiwi#6
No description provided.