Fondations pures (zéro I/O, zéro dépendance landlock, aucun câblage runtime — SpawnSpec.sandbox posé mais jamais lu ⇒ zéro régression) de la voie « airtight » des permissions, complément de la voie projection LP3. - domain/sandbox.rs : SandboxPlan/PathGrant/PathAccess (RO|RW|EXEC), SandboxContext, SandboxKind/Status/Error, port SandboxEnforcer, et la fonction pure compile_sandbox_plan(EffectivePermissions → plan OS). - domain/permission.rs : render_permission_summary (bloc Markdown injecté plus tard ; mentionne explicitement fichiers OS-enforced vs commandes advisory). - domain/ports.rs : SpawnSpec.sandbox: Option<SandboxPlan> (None ⇒ natif), propagé à tous les sites de construction. Sémantique de compile_sandbox_plan : - Invariant produit : eff == None ⇒ None (rien posé ⇒ CLI 100 % native). - Borne Landlock : seules les capabilities fichier produisent des grants (Read→RO, Write/Delete→RW) ; ExecuteBash reste advisory (non verrouillable par chemin). - Deny-wins PAR CLASSE D'ACCÈS (RO/RW), fail-closed intra-classe : un Deny ne ferme que les grants de sa propre classe (un Deny Write n'ampute pas un Allow Read). Choix retenu pour maximiser l'autonomie des agents : on respecte exactement la politique pré-renseignée sans sur-restreindre, donc moins de blocages qui forceraient l'agent à redemander l'utilisateur. - Globs réduits à leur préfixe statique ; grant abandonné si une barrière de même classe chevauche (égal/ancêtre/descendant) — sous-approximation conservatrice (un sandbox additif ne peut pas carver un deny sous-arbre). Tests : 16 tests purs sur sandbox + 3 sur render_permission_summary, cargo test --workspace 100 % vert, 0 ignored. Reste LP4 : LP4-1 adapter LandlockSandbox + pre_exec PTY (fail-open+warning sauf posture Deny), LP4-2 câblage application, LP4-3 composition root. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
148 lines
5.0 KiB
Rust
148 lines
5.0 KiB
Rust
//! # IdeA — Domain layer
|
|
//!
|
|
//! The **pure** hexagonal core (ARCHITECTURE.md §1.4, §3, §4, §7). It contains:
|
|
//!
|
|
//! - **Entities & value objects** with invariants enforced by validating
|
|
//! constructors (`new`/`try_new` returning `Result`),
|
|
//! - the **pure layout logic** (`split`/`merge`/`resize`/`move` as immutable
|
|
//! `&LayoutTree -> Result<LayoutTree, LayoutError>` functions),
|
|
//! - **ports** (traits) the infrastructure implements,
|
|
//! - **domain events** and **errors**.
|
|
//!
|
|
//! ## Dependency rule
|
|
//!
|
|
//! This crate depends on **no I/O**: no `tokio`, no `std::fs`, no
|
|
//! `std::process`, no `git2`/`portable-pty`/`russh`. The only third-party
|
|
//! dependencies are `uuid`, `serde` (allowed solely to derive (de)serialisation
|
|
//! of *persisted* domain types — a metier format constraint, not I/O),
|
|
//! `thiserror`, and `async-trait`.
|
|
//!
|
|
//! ## Async strategy for ports
|
|
//!
|
|
//! I/O-touching ports (`PtyPort`, `FileSystem`, `ProcessSpawner`, `RemoteHost`,
|
|
//! the stores, `GitPort`) are `#[async_trait]`. They are injected as
|
|
//! `Arc<dyn Port>` trait objects at the composition root, which native
|
|
//! `async fn`-in-trait does not yet support dyn-compatibly without boxing;
|
|
//! `async_trait` boxes the returned future and keeps the ports object-safe.
|
|
//! Non-blocking ports (`Clock`, `IdGenerator`, `EventBus`, `AgentRuntime`)
|
|
//! remain plain synchronous traits. See [`ports`] for details.
|
|
|
|
#![forbid(unsafe_code)]
|
|
#![warn(missing_docs)]
|
|
|
|
pub mod agent;
|
|
pub mod conversation;
|
|
pub mod conversation_log;
|
|
pub mod error;
|
|
pub mod events;
|
|
pub mod fileguard;
|
|
pub mod git;
|
|
pub mod ids;
|
|
pub mod input;
|
|
pub mod layout;
|
|
pub mod mailbox;
|
|
pub mod markdown;
|
|
pub mod memory;
|
|
pub mod orchestrator;
|
|
pub mod permission;
|
|
pub mod ports;
|
|
pub mod profile;
|
|
pub mod project;
|
|
pub mod readiness;
|
|
pub mod sandbox;
|
|
pub mod remote;
|
|
pub mod skill;
|
|
pub mod template;
|
|
pub mod terminal;
|
|
|
|
mod validation;
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Curated re-exports for ergonomic downstream use.
|
|
// ---------------------------------------------------------------------------
|
|
|
|
pub use error::DomainError;
|
|
|
|
pub use ids::{
|
|
AgentId, LayoutId, NodeId, ProfileId, ProjectId, SessionId, SkillId, TabId, TemplateId,
|
|
WindowId,
|
|
};
|
|
|
|
pub use project::{Project, ProjectPath};
|
|
|
|
pub use agent::{Agent, AgentManifest, AgentOrigin, ManifestEntry};
|
|
|
|
pub use skill::{Skill, SkillRef, SkillScope};
|
|
|
|
pub use template::{AgentTemplate, TemplateVersion};
|
|
|
|
pub use profile::{
|
|
AgentProfile, ContextInjection, EmbedderProfile, EmbedderStrategy, LivenessStrategy,
|
|
McpServerWiring, SessionStrategy,
|
|
};
|
|
|
|
pub use mailbox::{AgentMailbox, MailboxError, PendingReply, Ticket, TicketId};
|
|
|
|
pub use conversation::{
|
|
Conversation, ConversationError, ConversationId, ConversationParty, ConversationRegistry,
|
|
ConversationSession, SessionRef, WaitForGraph,
|
|
};
|
|
|
|
pub use input::{AgentBusyState, AgentLiveness, InputMediator, InputSource};
|
|
|
|
pub use readiness::{ReadinessPolicy, ReadinessSignal};
|
|
|
|
pub use conversation_log::{
|
|
ConversationLog, ConversationTurn, Handoff, HandoffStore, HandoffSummarizer,
|
|
ProviderSessionStore, TurnId, TurnRole,
|
|
};
|
|
|
|
pub use fileguard::{
|
|
is_orchestrator, may_write_directly, FileGuard, GuardError, GuardedResource, ReadLease,
|
|
WriteLease,
|
|
};
|
|
|
|
pub use markdown::MarkdownDoc;
|
|
|
|
pub use memory::{Memory, MemoryFrontmatter, MemoryIndexEntry, MemoryLink, MemorySlug, MemoryType};
|
|
|
|
pub use remote::{RemoteKind, RemoteRef, SshAuth};
|
|
|
|
pub use terminal::{PtySize, SessionKind, SessionStatus, TerminalSession};
|
|
|
|
pub use git::GitRepository;
|
|
|
|
pub use layout::{
|
|
Direction, GridCell, GridContainer, LayoutError, LayoutNode, LayoutTree, LeafCell,
|
|
SplitContainer, Tab, WeightedChild, Window, Workspace,
|
|
};
|
|
|
|
pub use events::{DomainEvent, OrchestrationSource};
|
|
|
|
pub use permission::{
|
|
render_permission_summary, resolve as resolve_permissions, AgentPermissionOverride, Capability,
|
|
CommandMatcher, CommandRule, Effect, EffectivePermissions, Glob, PathScope, PermissionError,
|
|
PermissionProjection, PermissionProjector, PermissionRule, PermissionSet, Posture,
|
|
ProjectedFile, ProjectionContext, ProjectPermissions, ProjectorKey, PERMISSIONS_VERSION,
|
|
};
|
|
|
|
pub use sandbox::{
|
|
compile_sandbox_plan, PathAccess, PathGrant, SandboxContext, SandboxEnforcer, SandboxError,
|
|
SandboxKind, SandboxPlan, SandboxStatus,
|
|
};
|
|
|
|
pub use orchestrator::{
|
|
OrchestratorCommand, OrchestratorError, OrchestratorRequest, OrchestratorVisibility,
|
|
};
|
|
|
|
pub use ports::{
|
|
AgentContextStore, AgentRuntime, Clock, ContextInjectionPlan, DirEntry, Embedder,
|
|
EmbedderEnvInspector, EmbedderEnvReport, EmbedderError, EmbedderProfileStore,
|
|
EmbedderPromptDismissal, EmbedderPromptStore, EventBus, EventStream, ExitStatus, FileSystem,
|
|
FsError, GitCommitInfo, GitError, GitFileStatus, GitPort, GraphCommit, IdGenerator,
|
|
MemoryError, MemoryQuery, MemoryRecall, MemoryStore, Output, OutputStream, PermissionStore,
|
|
PreparedContext, ProcessError, ProcessSpawner, ProfileStore, ProjectStore, PtyError, PtyHandle,
|
|
PtyPort, RemoteError, RemoteHost, RemotePath, RuntimeError, SpawnSpec, StoreError,
|
|
TemplateStore,
|
|
};
|