Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
bbb5d6f
fix(worktrees): delete a worktree outside the store's ownership lock
yyhhyyyyyy Nov 24, 2026
7756df2
fix(worktrees): refuse a non-force removal that a symlink redirects
yyhhyyyyyy Nov 24, 2026
0b714f8
docs(worktrees): state the removal lock scope and its known limits
yyhhyyyyyy Nov 24, 2026
3d10185
test(worktrees): pin the removal registration's refusals
yyhhyyyyyy Nov 24, 2026
93002fd
fix(worktrees): refuse a record deletion while its path is being removed
yyhhyyyyyy Nov 24, 2026
da53f48
fix(worktrees): skip an empty workspace in a stored fork configuration
yyhhyyyyyy Nov 24, 2026
2bdd13b
docs(worktrees): state the removal registration and its refusals
yyhhyyyyyy Nov 24, 2026
09834d7
docs(worktrees): drop the Session deletion from the refused operations
yyhhyyyyyy Nov 24, 2026
b2efafa
test(worktrees): pin a creation out of a path a removal is deleting
yyhhyyyyyy Nov 24, 2026
9de54f4
fix(worktrees): keep a creation out of a path a removal is deleting
yyhhyyyyyy Nov 24, 2026
91fc8a9
docs(worktrees): state the removal registration and the creation check
yyhhyyyyyy Nov 24, 2026
ee9a566
test(worktrees): pin a removal off a path a creation is building
yyhhyyyyyy Nov 24, 2026
b7f58ce
fix(worktrees): keep a removal off a path a creation is building
yyhhyyyyyy Nov 24, 2026
ba1430f
docs(worktrees): state the creation registration and its refusals
yyhhyyyyyy Nov 24, 2026
a1f2e7c
test(worktrees): pin the path a failed creation rolls back
yyhhyyyyyy Nov 24, 2026
833307b
fix(worktrees): hand a failed creation's registration to its rollback
yyhhyyyyyy Nov 24, 2026
f0b6b08
docs(worktrees): state the rollback's hand-over of the creation regis…
yyhhyyyyyy Nov 24, 2026
913e160
style(worktrees): wrap the new creation test calls
yyhhyyyyyy Nov 24, 2026
f8c3162
docs(worktrees): state the hand-over in the module summary
yyhhyyyyyy Nov 24, 2026
482e53f
fix(worktrees): refuse the non-Unix non-force removal of an unregiste…
yyhhyyyyyy Nov 24, 2026
a292d92
docs(worktrees): record the non-Unix refusal of an unregistered removal
yyhhyyyyyy Nov 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions crates/dim-app-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ pub struct UnregisteredRemovalHold {
pub release: tokio::sync::Notify,
}

/// Feature `testing`: a hold on one managed worktree creation at a point a test
/// picked: after it registered the directory it chose and before it builds
/// there, after it found the directory free and before it registers it, or in a
/// failed creation before its rollback removes the worktree. It notifies
/// `reached` once held and returns once `release` is notified.
#[cfg(feature = "testing")]
#[derive(Default)]
pub struct WorktreeCreationHold {
pub reached: tokio::sync::Notify,
pub release: tokio::sync::Notify,
}

/// Feature `testing`: a hold on one subscription's `follow` task. It notifies
/// `waiting` once it is held, `cancelled` once retirement cancels it, and
/// returns once `release` is notified.
Expand Down Expand Up @@ -364,6 +376,46 @@ impl RunningServer {
.get::<worktrees::ManagedWorktrees>()
.map(|managed| managed.hold_next_unregistered_removal())
}
/// Names the task id the next managed worktree creation tries first, so a
/// test can make it meet a path a removal registered. Answers whether the
/// part is present. Feature `testing` only.
#[cfg(feature = "testing")]
pub fn prefer_next_worktree_task_id(&self, task_id: &str) -> bool {
match self.root.get::<worktrees::ManagedWorktrees>() {
Some(managed) => {
managed.prefer_next_task_id(task_id);
true
}
None => false,
}
}
/// Holds the next managed worktree creation after it checked its directory
/// and before it builds there, so a test can remove that path in between.
/// Feature `testing` only.
#[cfg(feature = "testing")]
pub fn hold_next_worktree_creation(&self) -> Option<Arc<WorktreeCreationHold>> {
self.root
.get::<worktrees::ManagedWorktrees>()
.map(|managed| managed.hold_next_creation())
}
/// Holds the next managed worktree creation after it found its directory
/// free and before it registers that path, so a test can let a rollback of
/// that path run in between. Feature `testing` only.
#[cfg(feature = "testing")]
pub fn hold_next_worktree_creation_check(&self) -> Option<Arc<WorktreeCreationHold>> {
self.root
.get::<worktrees::ManagedWorktrees>()
.map(|managed| managed.hold_next_creation_check())
}
/// Holds the next failed managed worktree creation before its rollback
/// removes the worktree it built, so a test can register that path first.
/// Feature `testing` only.
#[cfg(feature = "testing")]
pub fn hold_next_worktree_rollback(&self) -> Option<Arc<WorktreeCreationHold>> {
self.root
.get::<worktrees::ManagedWorktrees>()
.map(|managed| managed.hold_next_rollback())
}
/// Holds the next subscription's `follow` task open until `release`, so a
/// test can keep an attach or detach in flight at a known point. Feature
/// `testing` only.
Expand Down
24 changes: 22 additions & 2 deletions crates/dim-app-server/src/storage/face.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{PreparedWorktree, SessionStore, WorktreeDirectory};
use super::{PreparedWorktree, SessionStore, WorktreeCreation, WorktreeDirectory};
use crate::protocol::SessionOrigin;
use dim_agent_runtime::{AgentError, ReplyLanguage, SessionConfig};
use dim_agent_types::grant::{GrantKind, GrantMode};
Expand Down Expand Up @@ -150,17 +150,37 @@ impl Store {
pub fn remove_worktree(
&self,
directory: WorktreeDirectory,
remove: impl FnOnce(PathBuf) -> BoxFuture<'static, Result<()>>,
remove: impl FnOnce(PathBuf) -> BoxFuture<'static, Result<()>> + Send + 'static,
) -> impl Future<Output = Result<bool>> {
self.0.remove_worktree(directory, remove)
}
/// Removes the worktree a failed creation built, taking the creation's own
/// registration over as the path's deletion registration. The rollback of
/// a managed creation is the only caller, so this stays off the face.
pub(crate) fn remove_created_worktree(
&self,
directory: WorktreeDirectory,
creation: WorktreeCreation,
remove: impl FnOnce(PathBuf) -> BoxFuture<'static, Result<()>> + Send + 'static,
) -> impl Future<Output = Result<bool>> {
self.0.remove_created_worktree(directory, creation, remove)
}
pub fn remove_unregistered_directory(
&self,
path: PathBuf,
remove: impl FnOnce(PathBuf) -> BoxFuture<'static, Result<()>> + Send + 'static,
) -> impl Future<Output = Result<bool>> {
self.0.remove_unregistered_directory(path, remove)
}
/// Registers a worktree directory a creation selected until the returned
/// guard drops; the registration takes the ownership lock a removal
/// registers under.
pub(crate) fn begin_worktree_creation(
&self,
path: &std::path::Path,
) -> impl Future<Output = Result<WorktreeCreation>> {
self.0.begin_worktree_creation(path)
}
}

#[derive(Deserialize)]
Expand Down
1 change: 1 addition & 0 deletions crates/dim-app-server/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub use timeline::testing as timeline_testing;
pub fn rebuild_text_index(connection: &rusqlite::Connection) -> dim_agent_runtime::Result<()> {
text::backfill(connection)
}
pub(crate) use timeline::WorktreeCreation;
pub use timeline::{
PreparedWorktree, SessionStore, SessionStorePlugin, SqliteTimelineStore, TurnWindow,
WorktreeDirectoryRecord, WorktreeUsage,
Expand Down
Loading