From f2dd8d8a515c1a2a220836231ad1a671a5e9b73d Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 13 Apr 2026 08:09:33 +0300 Subject: ask: serialize concurrent CLI with repo lock and stale PID recovery Add advisory lock under .git/hexai-ask.lock around Taskwarrior execution, with metadata (PID and process basename) and Linux /proc comm checks to remove orphan lock files when the recorded holder is gone or not ask. Extract internal/filelock for shared flock helpers; stats uses it too. Made-with: Cursor --- internal/askcli/runlock_stale_linux_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 internal/askcli/runlock_stale_linux_test.go (limited to 'internal/askcli/runlock_stale_linux_test.go') diff --git a/internal/askcli/runlock_stale_linux_test.go b/internal/askcli/runlock_stale_linux_test.go new file mode 100644 index 0000000..7c581fb --- /dev/null +++ b/internal/askcli/runlock_stale_linux_test.go @@ -0,0 +1,19 @@ +//go:build linux + +package askcli + +import ( + "os/exec" + "testing" +) + +func TestLockHolderIsStale_NonAskLiveProcess(t *testing.T) { + cmd := exec.Command("sleep", "60") + if err := cmd.Start(); err != nil { + t.Skip("sleep not available:", err) + } + defer func() { _ = cmd.Process.Kill() }() + if !lockHolderIsStale(cmd.Process.Pid, "ask") { + t.Fatal("expected sleep process to be stale when expecting ask") + } +} -- cgit v1.2.3