diff options
| author | soryu <soryu@soryu.co> | 2026-02-05 00:48:38 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2026-02-05 00:48:38 +0000 |
| commit | 0302b4596e14210884df5d645df9a179d8f0c1c6 (patch) | |
| tree | 46efe027dffa25a30e4eab87fd62de249c3075ad /makima/src/db/models.rs | |
| parent | e16d49b52a393aa9a762edf57f93434a4bd7844e (diff) | |
| download | soryu-0302b4596e14210884df5d645df9a179d8f0c1c6.tar.gz soryu-0302b4596e14210884df5d645df9a179d8f0c1c6.zip | |
Add multi-repository support for chains
Chains can now have multiple repositories attached, with one marked as
primary. Repositories are used by contracts created from chain definitions.
Backend changes:
- Add chain_repositories table migration
- Add ChainRepository model with CRUD operations
- Add API endpoints for listing, adding, deleting repositories
- Add endpoint to set a repository as primary
- Update Chain and ChainEditorData models to use repositories
- Update chain parser to support repositories in YAML format
- Remove deprecated repository_url/local_path from Chain
Frontend changes:
- Add ChainRepository interface and API functions
- Add repository section to ChainEditor showing attached repos
- Add modal for adding new repositories (remote or local)
- Support setting primary repository and removing repositories
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'makima/src/db/models.rs')
| -rw-r--r-- | makima/src/db/models.rs | 64 |
1 files changed, 54 insertions, 10 deletions
diff --git a/makima/src/db/models.rs b/makima/src/db/models.rs index 4e569ec..30e1603 100644 --- a/makima/src/db/models.rs +++ b/makima/src/db/models.rs @@ -2652,16 +2652,40 @@ pub struct Chain { pub loop_current_iteration: Option<i32>, /// Progress check prompt/criteria for evaluating loop completion pub loop_progress_check: Option<String>, - /// Repository URL for contracts in this chain (optional) - pub repository_url: Option<String>, - /// Local path for contracts in this chain (optional) - pub local_path: Option<String>, /// Version for optimistic locking pub version: i32, pub created_at: DateTime<Utc>, pub updated_at: DateTime<Utc>, } +/// Chain repository record from the database +#[derive(Debug, Clone, FromRow, Serialize, Deserialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct ChainRepository { + pub id: Uuid, + pub chain_id: Uuid, + pub name: String, + pub repository_url: Option<String>, + pub local_path: Option<String>, + pub source_type: String, + pub status: String, + pub is_primary: bool, + pub created_at: DateTime<Utc>, + pub updated_at: DateTime<Utc>, +} + +impl ChainRepository { + /// Parse source_type string to RepositorySourceType enum + pub fn source_type_enum(&self) -> Result<RepositorySourceType, String> { + self.source_type.parse() + } + + /// Parse status string to RepositoryStatus enum + pub fn status_enum(&self) -> Result<RepositoryStatus, String> { + self.status.parse() + } +} + impl Chain { /// Parse status string to ChainStatus enum pub fn status_enum(&self) -> Result<ChainStatus, String> { @@ -2724,6 +2748,7 @@ pub struct ChainWithContracts { #[serde(flatten)] pub chain: Chain, pub contracts: Vec<ChainContractDetail>, + pub repositories: Vec<ChainRepository>, } /// Contract detail within a chain (includes contract info + chain link info) @@ -2790,10 +2815,8 @@ pub struct CreateChainRequest { pub name: String, /// Optional description pub description: Option<String>, - /// Repository URL for contracts in this chain - pub repository_url: Option<String>, - /// Local path for contracts in this chain - pub local_path: Option<String>, + /// Repositories for this chain + pub repositories: Option<Vec<AddChainRepositoryRequest>>, /// Enable loop mode for iterative execution #[serde(default)] pub loop_enabled: Option<bool>, @@ -2805,6 +2828,28 @@ pub struct CreateChainRequest { pub contracts: Option<Vec<CreateChainContractRequest>>, } +/// Request to add a repository to a chain +#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct AddChainRepositoryRequest { + /// Display name for the repository + pub name: String, + /// Remote repository URL (for remote repos) + pub repository_url: Option<String>, + /// Local filesystem path (for local repos) + pub local_path: Option<String>, + /// Source type: remote, local, or managed + #[serde(default = "default_source_type")] + pub source_type: String, + /// Whether this is the primary repository + #[serde(default)] + pub is_primary: bool, +} + +fn default_source_type() -> String { + "remote".to_string() +} + /// Request to create a contract within a chain #[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] #[serde(rename_all = "camelCase")] @@ -2934,8 +2979,7 @@ pub struct ChainEditorData { pub id: Option<Uuid>, pub name: String, pub description: Option<String>, - pub repository_url: Option<String>, - pub local_path: Option<String>, + pub repositories: Vec<ChainRepository>, pub loop_enabled: bool, pub loop_max_iterations: Option<i32>, pub loop_progress_check: Option<String>, |
