Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 0 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/tracedecay-agent-hosts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ test-transport = [
[dependencies]
cap-fs-ext = "4.0.2"
cap-std = "4.0.2"
fs2 = "0.4"
same-file = "1.0.6"
getrandom = "0.2"
hex = "0.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use std::sync::atomic::{AtomicU64, Ordering};
use cap_fs_ext::{DirExt, FollowSymlinks, OpenOptionsFollowExt};
use cap_std::ambient_authority;
use cap_std::fs::{Dir, OpenOptions as CapOpenOptions};
use fs2::FileExt;
use sha2::{Digest, Sha256};
use tracedecay_domain::canonical_json_bytes;
use tracedecay_host_integration::host_bundle_recovery_required;
Expand Down Expand Up @@ -1312,7 +1311,8 @@ fn open_host_writer_lock(
.open_with(&name, &options)
.map_err(|_| HostBundleError::UnsafeInstallPath)?
.into_std();
file.try_lock_exclusive()
file.try_lock()
.map_err(std::io::Error::from)
.map_err(|_| host_bundle_recovery_required!())?;
Ok(HostWriterLock { host, file })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use std::path::Path;
use cap_fs_ext::{FollowSymlinks, OpenOptionsFollowExt};
use cap_std::ambient_authority;
use cap_std::fs::{Dir, OpenOptions as CapOpenOptions};
use fs2::FileExt;
use same_file::Handle;
use tracedecay_domain::canonical_text::sha256_hex;

Expand Down Expand Up @@ -46,7 +45,7 @@ impl Drop for HostFileWriteLock {
"host config lock file could not be unlinked while held"
);
}
if let Err(error) = FileExt::unlock(self.handle.as_file()) {
if let Err(error) = self.handle.as_file().unlock() {
tracing::warn!(
lock_name = %self.lock_name,
error = %error,
Expand Down Expand Up @@ -141,10 +140,9 @@ pub(super) fn lock_host_file_write(path: &Path) -> Result<HostFileWriteLock> {
),
});
}
lock.lock_exclusive()
.map_err(|error| TraceDecayError::Config {
message: format!("failed to lock host config {}: {error}", path.display()),
})?;
lock.lock().map_err(|error| TraceDecayError::Config {
message: format!("failed to lock host config {}: {error}", path.display()),
})?;
let locked = Handle::from_file(lock).map_err(|error| TraceDecayError::Config {
message: format!(
"failed to identify host config lock {}: {error}",
Expand Down
1 change: 0 additions & 1 deletion crates/tracedecay-application/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ test-transport = [

[dependencies]
cap-std = "4.0.2"
fs2 = "0.4"
getrandom = "0.2"
gix = { version = "=0.86.0", default-features = false, features = ["revision", "blob-diff", "parallel", "sha1", "sha256", "status"] }
glob = "0.3"
Expand Down
17 changes: 9 additions & 8 deletions crates/tracedecay-application/src/pr_tracking/worktrees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use std::path::{Path, PathBuf};

use fs2::FileExt;
use tracedecay_domain::canonical_text::sha256_hex;
use tracedecay_runtime_core::branch::BranchAddOutcome;

Expand Down Expand Up @@ -80,7 +79,7 @@ impl ManualBranchArtifactsV1 {
/// lease is taken before the branch identity is resolved, so a typed
/// pre-mutation refusal (missing ref, unavailable Git authority) must not
/// leave the worktree root behind as evidence of an activation that never
/// happened — and nothing enumerating branch worktrees has to filter a
/// happened, and nothing enumerating branch worktrees has to filter a
/// non-worktree entry out.
fn lifecycle_lock_path(&self, data_root: &Path) -> PathBuf {
data_root
Expand Down Expand Up @@ -132,12 +131,14 @@ pub fn try_acquire_manual_branch_lifecycle(
lock_path.display()
))
})?;
lock.try_lock_exclusive().map_err(|error| {
ManualBranchActivationError::lifecycle_contended(format!(
"branch '{branch}' lifecycle is already active at '{}': {error}",
lock_path.display()
))
})?;
lock.try_lock()
.map_err(std::io::Error::from)
.map_err(|error| {
ManualBranchActivationError::lifecycle_contended(format!(
"branch '{branch}' lifecycle is already active at '{}': {error}",
lock_path.display()
))
})?;
Ok(ManualBranchLifecycleLeaseV1 {
branch: branch.to_owned(),
_lock: lock,
Expand Down
1 change: 0 additions & 1 deletion crates/tracedecay-automation-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ test-helpers = [
[dependencies]
cap-fs-ext = "4.0.2"
cap-std = "4.0.2"
fs2 = "0.4"
getrandom = "0.2"
hex = "0.4"
hotpath.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,8 @@ fn with_journal_lock<T>(path: &Path, operation: impl FnOnce() -> Result<T>) -> R
let lock = open_lock_nofollow(&lock_path)
.map_err(|error| contract_error(format!("automation terminal lock failed: {error}")))?;
let result = operation();
let unlock = fs2::FileExt::unlock(&lock)
let unlock = lock
.unlock()
.map_err(|error| contract_error(format!("automation terminal unlock failed: {error}")));
match (result, unlock) {
(Err(error), _) => Err(error),
Expand Down Expand Up @@ -1242,7 +1243,7 @@ fn open_lock_nofollow(path: &Path) -> std::io::Result<std::fs::File> {
));
}
let file = file.into_std();
fs2::FileExt::lock_exclusive(&file)?;
file.lock()?;
Ok(file)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1349,12 +1349,12 @@ fn with_index_lock<T>(path: &Path, operation: impl FnOnce() -> Result<T>) -> Res
"automation pending index lock is not a regular file",
));
}
fs2::FileExt::lock_exclusive(&file)?;
file.lock()?;
Ok(file)
})
.map_err(|error| contract_error(format!("automation pending index lock failed: {error}")))?;
let result = operation();
let unlock = fs2::FileExt::unlock(&lock).map_err(|error| {
let unlock = lock.unlock().map_err(|error| {
contract_error(format!("automation pending index unlock failed: {error}"))
});
match (result, unlock) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ fn complete_after_pending_removal_with(
)),
}
})();
let unlock = fs2::FileExt::unlock(&lock).map_err(|error| {
let unlock = lock.unlock().map_err(|error| {
contract_error(format!(
"shipped proposal retirement unlock failed: {error}"
))
Expand Down Expand Up @@ -661,7 +661,7 @@ fn restore_existing_capture(source_path: &Path, captured_path: &Path) -> Result<
})?;
restore_captured_source(&parent, captured_name, source_name, source_path)
})();
let unlock = fs2::FileExt::unlock(&lock).map_err(|error| {
let unlock = lock.unlock().map_err(|error| {
contract_error(format!(
"shipped proposal retirement unlock failed: {error}"
))
Expand Down Expand Up @@ -746,7 +746,7 @@ fn capture_exact_source_with_capture(
}
Ok(Some(tombstone_path))
})();
let unlock = fs2::FileExt::unlock(&lock).map_err(|error| {
let unlock = lock.unlock().map_err(|error| {
contract_error(format!(
"shipped proposal retirement unlock failed: {error}"
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2252,7 +2252,6 @@ async fn dropping_retained_waiter_does_not_abort_blocking_owner() {

#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn retained_projector_panic_finishes_recovery_before_releasing_task_lock() {
use fs2::FileExt;
use std::time::{Duration, Instant};

let temp = tempfile::tempdir().expect("tempdir");
Expand All @@ -2278,7 +2277,7 @@ async fn retained_projector_panic_finishes_recovery_before_releasing_task_lock()
.open(&journal_lock_path)
.expect("projector-panic journal lock");
journal_lock
.lock_exclusive()
.lock()
.expect("block projector-panic recovery terminal");

let (projected_tx, projected_rx) = std::sync::mpsc::channel();
Expand All @@ -2302,7 +2301,9 @@ async fn retained_projector_panic_finishes_recovery_before_releasing_task_lock()

assert!(task_lock_is_denied(dashboard_root, job_id).await);

FileExt::unlock(&journal_lock).expect("release projector-panic recovery terminal");
journal_lock
.unlock()
.expect("release projector-panic recovery terminal");
let deadline = Instant::now() + Duration::from_secs(5);
loop {
let terminal = read_indexed_record_blocking(&journal_path)
Expand Down Expand Up @@ -2467,8 +2468,6 @@ async fn dropping_request_waiting_pair_before_submit_abandons_both_authorities()

#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn partial_pair_submit_abandons_the_closed_sibling_under_shared_guard_ownership() {
use fs2::FileExt;

let temp = tempfile::tempdir().expect("tempdir");
let dashboard_root = temp.path();
let mut fixture = request_waiting_pair_fixture(dashboard_root, "pair-partial-submit").await;
Expand All @@ -2480,7 +2479,7 @@ async fn partial_pair_submit_abandons_the_closed_sibling_under_shared_guard_owne
))
.expect("open second request-waiting journal lock");
second_journal_lock
.lock_exclusive()
.lock()
.expect("block closed sibling abandonment");
let submission = fixture
.submission
Expand Down Expand Up @@ -2512,7 +2511,9 @@ async fn partial_pair_submit_abandons_the_closed_sibling_under_shared_guard_owne
task_lock_is_denied(dashboard_root, &fixture.job_ids[1]).await,
"closed sibling released its lock before durable abandonment"
);
FileExt::unlock(&second_journal_lock).expect("release closed sibling abandonment");
second_journal_lock
.unlock()
.expect("release closed sibling abandonment");
assert_request_waiting_pair_abandoned_cleanly(dashboard_root, &fixture).await;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::fs::OpenOptions;
use std::io::Write;
use std::path::{Path, PathBuf};

use fs2::FileExt;
use serde::{Deserialize, Serialize};

use super::config_error;
Expand Down Expand Up @@ -114,7 +113,7 @@ fn with_locked_state<T>(
.truncate(false)
.open(&lock_path)
.map_err(|error| config_error(format!("failed to open host receipt lock: {error}")))?;
lock.lock_exclusive()
lock.lock()
.map_err(|error| config_error(format!("failed to lock host receipts: {error}")))?;
let mut state = std::fs::read(&state_path)
.ok()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::io::Write;
use std::path::{Path, PathBuf};

use super::config_error;
use fs2::FileExt;
use serde::{Deserialize, Serialize};
use tracedecay_automation::run_labels::SKILL_OVERLAP_REMOVAL_TOMBSTONE;
use tracedecay_domain::errors::Result;
Expand Down Expand Up @@ -107,7 +106,7 @@ struct SkillStoreLock(File);

impl Drop for SkillStoreLock {
fn drop(&mut self) {
let _ = FileExt::unlock(&self.0);
let _ = self.0.unlock();
}
}

Expand All @@ -132,7 +131,7 @@ fn lock_skill_store(profile_root: &Path) -> Result<SkillStoreLock> {
path.display()
))
})?;
file.lock_exclusive().map_err(|e| {
file.lock().map_err(|e| {
config_error(format!(
"failed to lock skill store '{}': {e}",
path.display()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ fn append_jsonl_line_locked(path: &Path, line: &str) -> std::io::Result<()> {
}
Ok(())
})();
let unlock_result = fs2::FileExt::unlock(&lock);
let unlock_result = lock.unlock();
write_result?;
unlock_result?;
Ok(())
Expand Down Expand Up @@ -972,8 +972,8 @@ fn validate_requested_task_key(task_key: &str) -> Result<()> {
/// A read must not mint the dashboard directory: acquiring the lock creates
/// it, and a root that does not exist has no ledger. Absence is therefore
/// answered from `absent` alone. Running `read` there would open whatever a
/// first writer created in the meantime — outside the lock and outside
/// `ensure_no_exact_append_intent` — and expose a row whose publication has
/// first writer created in the meantime, outside the lock and outside
/// `ensure_no_exact_append_intent`, and expose a row whose publication has
/// not settled; the directory's absence at the time of check says nothing
/// about the ledger at the time of use.
///
Expand Down Expand Up @@ -1007,7 +1007,7 @@ fn with_run_ledger_read_lock<T>(
})?;
hotpath::measure_block!("automation.run_ledger.read_lock.body", read())
})();
let unlock = fs2::FileExt::unlock(&lock).map_err(TraceDecayError::from);
let unlock = lock.unlock().map_err(TraceDecayError::from);
result.and_then(|value| unlock.map(|()| value))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,9 @@ pub fn find_run_record_exact_bounded_blocking(
.map_err(tracedecay_domain::errors::TraceDecayError::from)?;
read_exact_run_record_bounded(&path, run_id)
})();
let unlock =
fs2::FileExt::unlock(&lock).map_err(tracedecay_domain::errors::TraceDecayError::from);
let unlock = lock
.unlock()
.map_err(tracedecay_domain::errors::TraceDecayError::from);
result.and_then(|record| unlock.map(|()| record))
}

Expand Down
Loading
Loading