Files
IdeA/crates/domain/src/ids.rs
Blomios b82ac76f8b feat(model-server): backend modèles locaux — serveur llama.cpp intégré (#35) et profils OpenCode locaux multiples (#36)
Sprint « Modeles locaux », couche backend (domain/application/infra/app-tauri).

#35 — Serveur de modèle local intégré (llama.cpp) :
- domain: model_server.rs (agrégat + statut), ports ModelServerProbe /
  ManagedProcess / ModelServerRuntime / ModelServerRegistry, événements
  model_server_status_changed et agent_launch_failed.
- application: use case EnsureLocalModelServer branché sur LaunchAgent.
- infrastructure: adapters HttpOpenAiCompatibleProbe, LlamaCppRuntime,
  LocalManagedProcess, FsModelServerRegistry.
- app-tauri: DTO plat LocalModelServerConfigDto, commandes
  list/save/delete_model_server avec garde model_server_in_use, wiring.

#36 — Profils OpenCode locaux multiples :
- domain: VO LocalModelServerId, OpenCodeConfig.local_model_server_id.
- application: use case CloneOpenCodeProfileFromSeed.
- app-tauri: commande clone_opencode_profile_from_seed, DTO/wiring.

Tests verts (exécution réelle) : domain+application OK, app-tauri
dto_model_servers 3/3 et dto_profiles 10/10, infra model_server 2/2,
application model_server+profile_usecases 19/19, cargo build workspace Finished.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-11 15:50:08 +02:00

118 lines
3.0 KiB
Rust

//! Strongly-typed identifiers.
//!
//! Each identifier is a `newtype` around [`uuid::Uuid`]. Using distinct types
//! per concept makes it impossible to pass, say, an [`AgentId`] where a
//! [`ProjectId`] is expected (compile-time safety, SOLID/typing discipline).
use serde::{Deserialize, Serialize};
use uuid::Uuid;
macro_rules! typed_id {
($(#[$meta:meta])* $name:ident) => {
$(#[$meta])*
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
#[serde(transparent)]
pub struct $name(pub Uuid);
impl $name {
/// Wraps an existing [`Uuid`].
#[must_use]
pub const fn from_uuid(id: Uuid) -> Self {
Self(id)
}
/// Generates a fresh random (v4) identifier.
///
/// Prefer injecting an [`crate::ports::IdGenerator`] in application
/// code for determinism; this convenience exists for tests and the
/// composition root.
#[must_use]
pub fn new_random() -> Self {
Self(Uuid::new_v4())
}
/// Returns the inner [`Uuid`].
#[must_use]
pub const fn as_uuid(&self) -> Uuid {
self.0
}
}
impl std::fmt::Display for $name {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
impl From<Uuid> for $name {
fn from(id: Uuid) -> Self {
Self(id)
}
}
};
}
typed_id!(
/// Identifies a [`crate::project::Project`].
ProjectId
);
typed_id!(
/// Identifies an [`crate::agent::Agent`].
AgentId
);
typed_id!(
/// Identifies an [`crate::template::AgentTemplate`].
TemplateId
);
typed_id!(
/// Identifies an [`crate::profile::AgentProfile`].
ProfileId
);
typed_id!(
/// Identifies a local model server configuration.
LocalModelServerId
);
typed_id!(
/// Identifies a [`crate::skill::Skill`].
SkillId
);
typed_id!(
/// Identifies a [`crate::issue::Issue`].
IssueId
);
typed_id!(
/// Identifies a [`crate::sprint::Sprint`].
SprintId
);
typed_id!(
/// Identifies a [`crate::terminal::TerminalSession`].
SessionId
);
typed_id!(
/// Identifies a [`crate::layout::WindowId`]-bearing OS window.
WindowId
);
typed_id!(
/// Identifies a [`crate::layout::Tab`].
TabId
);
typed_id!(
/// Identifies one named terminal layout within a project (L10/#4).
LayoutId
);
typed_id!(
/// Identifies a node in a [`crate::layout::LayoutTree`].
NodeId
);
typed_id!(
/// Identifies one armed one-shot wake-up of a [`crate::ports::Scheduler`]
/// (ARCHITECTURE §21.4). Opaque, cancellable handle returned by
/// [`crate::ports::Scheduler::arm`] and consumed by
/// [`crate::ports::Scheduler::cancel`].
ScheduleId
);
typed_id!(
/// Identifies a first-class background task.
TaskId
);