Repository Split
Status: migration guidance.
This document defines the AlphaSwarm monorepo boundaries while the platform is being split into future repositories. The current goal is isolation by responsibility without breaking imports, deployment manifests, or operator workflows.
Principles
- Use a strangler migration: create stable contracts first, then move implementations behind compatibility shims.
- Keep shared abstractions in
alphaswarm_core; do not import from higher-level packages there. - Keep
alphaswarm_controllerstandalone. It may depend onalphaswarm_core, but it must not importalphaswarm.*. - Keep
rpi_kubernetesas cluster bootstrap and platform services only. AlphaSwarm workload controllers and operator features live in this repository. - Prefer generated or typed API contracts between projects over direct imports across future repository boundaries.
Domain Map
| Domain | Current path | Owns | Does not own |
|---|---|---|---|
| Control plane | alphaswarm_controller/ | /manage/*, workload lifecycle, provider adapters, session/control API | Quant runtimes, Celery business tasks, strategy logic |
| Platform core | alphaswarm_core/ | Shared value types, ABCs, auth/resource filters, topology, stable wire models | FastAPI routes, ORM models, concrete cloud SDK workflows |
| Client | alphaswarm_client/ | Operator UI, client docs, generated API contracts, local client behavior | Backend business logic, direct database writes |
| Snippets | alphaswarm_snippets/ | Curated code knowledge, annotations, prompts, provenance indexes | Runtime imports or production package dependencies |
| Bots | alphaswarm_bots/, alphaswarm_bots/templates/ | Bot runtime, templates, examples, sample specs | Direct bypass of BotRuntime or immutable versioning |
| RL | alphaswarm_rl/ | RL subsystem: hash-locked RLExperimentSpec + RLRuntime + RLComponent metaclass + advantage estimators + policy backbones + weight-centric portfolio pipeline + Iceberg trajectory store + matching Celery task / API route / YAML spec library / tests | LLM gateway (router_complete stays in monolith); central registry (alphaswarm.core.registry.register stays in monolith) |
| Models | alphaswarm_models/ | Custom model pulling, building, training, fine-tuning, evaluating, testing — qlib-style ML framework + Predictor Hub + AlphaBacktestExperiment + walk-forward + finetune trainers + every model implementation + custom model serving (vLLM + Ollama) + matching Celery tasks / API routes / YAML spec library / tests | LLM gateway (router_complete stays in monolith); central registry (alphaswarm.core.registry.register stays in monolith) |
| Monolith runtime | alphaswarm/ | Agents, analysis, backtests, data plane, persistence, tasks, API gateway, LLM gateway (router_complete, memory, cache, prompts, tokens), the central registry, the four spec runtimes' shared orchestration. | RL subsystem (extracted to alphaswarm_rl/); ML / model serving (extracted to alphaswarm_models/); new workload control-plane providers |
| Deployment | alphaswarm_platform/deployments/, alphaswarm_platform/terraform/, build/ | Compose, Kubernetes, Terraform, image build contracts | Cluster bootstrap owned by rpi_kubernetes |
Allowed Dependencies
Hard dependency rules:
alphaswarm_coremust not importalphaswarm,alphaswarm_controller, FastAPI, SQLAlchemy, Celery, or heavy optional SDKs.alphaswarm_controllermust not importalphaswarm.*; usealphaswarm_corecontracts or HTTP APIs.alphaswarm_clientmust call backend APIs through generated clients or local API wrappers. It must not duplicate authorization, tenancy, or kill-switch semantics.alphaswarm_snippetsis read-only knowledge for runtime code. Production modules must not import from it.alphaswarm_botsstores templates and guidance until runtime interfaces are extracted fromalphaswarm_bots.alphaswarm_rlandalphaswarm_modelsmay depend onalphaswarm.*for the shared runtime primitives that have not yet been extracted (iceberg_catalog.append_arrow,router_complete,LedgerWriter,RequestContext, ORM models,_progress.emit,MetadataCache,RiskLimits,TargetWeightsRebalancer,alphaswarm.core.registry.register). The reverse direction (alphaswarm.rl.*→alphaswarm_rl.*,alphaswarm.ml.*→alphaswarm_models.*,alphaswarm.llm.{vllm_runner,ollama_client}→alphaswarm_models.serving.*) goes through deprecation-warning compatibility shims underalphaswarm/rl/,alphaswarm/ml/, andalphaswarm/llm/{vllm_runner,ollama_client}.py. New code imports fromalphaswarm_rl.*/alphaswarm_models.*/alphaswarm_models.serving.*directly.
Migration Order
- Stabilize
alphaswarm_corepackage contracts and tests. - Finish
alphaswarm_controlleras the only home for workload lifecycle providers and/manage/*behavior. - Move curated references into
alphaswarm_snippetswith provenance and indexes. - Extract
alphaswarm_clientcontracts around the existing Vite frontend and API gateway behavior before moving source paths. - Split
alphaswarm_botslast, after bot persistence, task dispatch, backtest, paper trading, and agent runtime interfaces are explicit. - Extract
alphaswarm_rl(May 2026) — RL subsystem moved out ofalphaswarm/rl/, with matching Celery task / API route / YAML spec library / tests. Legacyalphaswarm.rl.*imports preserved throughalphaswarm/rl/__init__.pydeprecation shim. - Extract
alphaswarm_models(May 2026) — custom-model boundary moved out ofalphaswarm/ml/plus the model-pulling / serving slice ofalphaswarm/llm/(vllm_runner.py,ollama_client.py). The central LLM gateway (router_complete, memory, cache, prompts, tokens) stays in the monolith atalphaswarm/llm/. Legacyalphaswarm.ml.*andalphaswarm.llm.{vllm_runner,ollama_client}imports preserved through compatibility shims. - Clean root-level build/deploy files only after the projects can be tested independently.
Future Repo Split Gate
A domain is ready to become its own repository when it has:
README.md,AGENTS.md, and a validation command list.- Independent packaging or build metadata.
- No forbidden imports across future repo boundaries.
- Versioned API or model contracts for consumers.
- CI checks that run without relying on the full monolith checkout, except for documented integration tests.