chore: wire cf-core shared modules (db, config, llm/router, tasks/scheduler, resources) #68

Closed
opened 2026-04-04 18:42:02 -07:00 by pyr0ball · 1 comment
Owner

Summary

Peregrine currently uses cf-core only for tiers. Kiwi is the reference implementation for full cf-core integration. Wire the remaining modules.

Modules to wire

Module What it replaces in Peregrine
circuitforge_core.config.load_env Hand-rolled .env loading in app/core/config.py
circuitforge_core.db.base + .migrations Local db.py / store.py SQLite connection management
circuitforge_core.llm.router.LLMRouter Local llm_router.py (already a thin shim — remove and use core directly)
circuitforge_core.tasks.scheduler Local background task scheduler (if any)
circuitforge_core.resources.CFOrchClient Direct VRAM allocation for LLM tasks (Paid+ tier)

Approach

Follow kiwi as the reference — compare kiwi/app/ imports against peregrine/app/ and migrate matching patterns. Do NOT break existing functionality; migrate module by module with tests at each step.

Notes

  • circuitforge_core is already installed (editable) in the cf env
  • Peregrine's tiers.py is already a shim over cf-core tiers — same pattern applies to db, llm, config
  • Pin circuitforge-core >= 0.7.0 in peregrine's pyproject.toml / environment.yml
  • cf-core#24: MIT/BSL 1.1 split — coordinate dep declarations after that lands
  • Kiwi is the reference: kiwi/app/core/config.py, kiwi/app/db/store.py, kiwi/app/tasks/scheduler.py
## Summary Peregrine currently uses cf-core only for `tiers`. Kiwi is the reference implementation for full cf-core integration. Wire the remaining modules. ## Modules to wire | Module | What it replaces in Peregrine | |--------|-------------------------------| | `circuitforge_core.config.load_env` | Hand-rolled `.env` loading in `app/core/config.py` | | `circuitforge_core.db.base` + `.migrations` | Local `db.py` / `store.py` SQLite connection management | | `circuitforge_core.llm.router.LLMRouter` | Local `llm_router.py` (already a thin shim — remove and use core directly) | | `circuitforge_core.tasks.scheduler` | Local background task scheduler (if any) | | `circuitforge_core.resources.CFOrchClient` | Direct VRAM allocation for LLM tasks (Paid+ tier) | ## Approach Follow kiwi as the reference — compare `kiwi/app/` imports against `peregrine/app/` and migrate matching patterns. Do NOT break existing functionality; migrate module by module with tests at each step. ## Notes - `circuitforge_core` is already installed (editable) in the `cf` env - Peregrine's `tiers.py` is already a shim over cf-core tiers — same pattern applies to db, llm, config - Pin `circuitforge-core >= 0.7.0` in peregrine's `pyproject.toml` / `environment.yml` ## Related - cf-core#24: MIT/BSL 1.1 split — coordinate dep declarations after that lands - Kiwi is the reference: `kiwi/app/core/config.py`, `kiwi/app/db/store.py`, `kiwi/app/tasks/scheduler.py`
Author
Owner

Status update — 2026-04-04

Done (commit 173da49)

  • circuitforge_core.config.load_env wired at both entry points:
    • app/app.py: module-level call (safe in Docker via setdefault; fills gaps on bare-metal/conda)
    • dev_api.py: called in startup event handler (avoids test-env pollution from local .env)
  • requirements.txt: noted >= 0.7.0 requirement; TODO to pin @v0.7.0 tag once cf-core cuts a release
  • db.get_connection shim was already wired (pre-existing)
  • tasks.scheduler shim was already wired (pre-existing)
  • resources.CFOrchClient VRAM allocation already wired via CF_ORCH_URL in task_scheduler
  • .env.example already updated with CF_ORCH_URL / CF_LICENSE_KEY (via #67)

Deferred

  • DB migration runner (circuitforge_core.db.migrations.run_migrations): current _migrate_db() in db.py uses manual ALTER TABLE — tracked in #43 (Rails-style numbered migrations)
  • Version tag pin: will update requirements.txt to @v0.7.0 once cf-core cuts the tag

Pre-existing (no change needed)

  • llm_router.py shim updated in #67
## Status update — 2026-04-04 ### Done (commit 173da49) - `circuitforge_core.config.load_env` wired at both entry points: - `app/app.py`: module-level call (safe in Docker via `setdefault`; fills gaps on bare-metal/conda) - `dev_api.py`: called in `startup` event handler (avoids test-env pollution from local `.env`) - `requirements.txt`: noted `>= 0.7.0` requirement; TODO to pin `@v0.7.0` tag once cf-core cuts a release - `db.get_connection` shim was already wired (pre-existing) - `tasks.scheduler` shim was already wired (pre-existing) - `resources.CFOrchClient` VRAM allocation already wired via `CF_ORCH_URL` in task_scheduler - `.env.example` already updated with `CF_ORCH_URL` / `CF_LICENSE_KEY` (via #67) ### Deferred - **DB migration runner** (`circuitforge_core.db.migrations.run_migrations`): current `_migrate_db()` in `db.py` uses manual `ALTER TABLE` — tracked in #43 (Rails-style numbered migrations) - **Version tag pin**: will update `requirements.txt` to `@v0.7.0` once cf-core cuts the tag ### Pre-existing (no change needed) - `llm_router.py` shim updated in #67
Sign in to join this conversation.
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/peregrine#68
No description provided.