diff options
| author | soryu <soryu@soryu.co> | 2026-01-31 23:07:56 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-31 23:07:56 +0000 |
| commit | 7567153e6281b94e39e52be5d060b381ed69597d (patch) | |
| tree | 1d7dd73756345f3671af32cc84b9b4235d34d173 /makima/src/db/models.rs | |
| parent | a6e36a8bfecb9ebe6c7b135b9e01557f7ebc3e58 (diff) | |
| parent | 44bb3fe07ab191abd8260af6975bc175c223878e (diff) | |
| download | soryu-7567153e6281b94e39e52be5d060b381ed69597d.tar.gz soryu-7567153e6281b94e39e52be5d060b381ed69597d.zip | |
Merge pull request #52 from soryu-co/makima/contract-management-improvements
feat: Add contract management system improvements (Phase 1)
Diffstat (limited to 'makima/src/db/models.rs')
| -rw-r--r-- | makima/src/db/models.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/makima/src/db/models.rs b/makima/src/db/models.rs index a6b5b05..636d81a 100644 --- a/makima/src/db/models.rs +++ b/makima/src/db/models.rs @@ -1808,6 +1808,37 @@ pub struct ChangePhaseRequest { /// User feedback for changes (used when not confirming) #[serde(skip_serializing_if = "Option::is_none")] pub feedback: Option<String>, + /// Expected version for optimistic locking. If provided, the phase change + /// will only succeed if the current contract version matches. + #[serde(skip_serializing_if = "Option::is_none")] + pub expected_version: Option<i32>, +} + +/// Result of a phase change operation, supporting explicit conflict detection. +#[derive(Debug, Clone)] +pub enum PhaseChangeResult { + /// Phase change succeeded, returning the updated contract + Success(Contract), + /// Version conflict: the contract was modified concurrently + VersionConflict { + /// The version the client expected + expected: i32, + /// The actual current version in the database + actual: i32, + /// The current phase of the contract + current_phase: String, + }, + /// Validation failed (e.g., invalid phase transition) + ValidationFailed { + /// Human-readable reason for the failure + reason: String, + /// List of missing requirements for the phase transition + missing_requirements: Vec<String>, + }, + /// The caller is not authorized to change this contract's phase + Unauthorized, + /// The contract was not found + NotFound, } /// Response for phase transition when phase_guard is enabled |
