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
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ updates:
groups:
go-deps:
patterns: ["*"]
# desktop/ is a SEPARATE module. Dependabot v2 does not auto-discover nested
# modules, so without this entry it never received an update PR — and no root
# check reaches it either (govulncheck/vet/golangci/CodeQL all run from the
# root, where `go list ./...` returns zero desktop packages). That gap is why
# x/net, x/crypto and x/text there have needed hand-written catch-up bumps.
- package-ecosystem: gomod
directory: "/desktop"
schedule:
interval: weekly
groups:
desktop-go-deps:
patterns: ["*"]
- package-ecosystem: github-actions
directory: "/"
schedule:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/govulncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@ jobs:
run: go install golang.org/x/vuln/cmd/govulncheck@latest
- name: Run govulncheck
run: govulncheck ./...
# desktop/ is a separate module and `./...` from the root does not reach
# it (`go list ./...` returns zero desktop packages there). Scanned
# without Wails build tags, same as ci.yml's compile step — that covers
# the dependency graph, which is what this check is about.
- name: Run govulncheck (desktop module)
working-directory: desktop
run: govulncheck ./...
2 changes: 1 addition & 1 deletion internal/mutate/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
// cross-file move is the open question in SPEC §15, so `nt undo` does not
// revert it (the CLI says so). Returns the number of tasks moved.
func (e *Engine) Archive() (int, error) {
h, err := lock.Acquire(e.S.LockFile(), lock.DefaultTimeout)
h, err := lock.Acquire(e.S.LockFile(), e.lockTimeout())
if err != nil {
return 0, err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/mutate/doctor.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (r DoctorReport) HasProblems() bool { return r.Issues() > 0 || len(r.Warnin
func (e *Engine) Doctor(apply bool) (DoctorReport, error) {
var rep DoctorReport

h, err := lock.Acquire(e.S.LockFile(), lock.DefaultTimeout)
h, err := lock.Acquire(e.S.LockFile(), e.lockTimeout())
if err != nil {
return rep, err
}
Expand Down
18 changes: 17 additions & 1 deletion internal/mutate/mutate.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ import (
// Engine owns the store and serializes all task-file writes.
type Engine struct {
S *store.Store
// LockTimeout bounds how long a mutation waits for the store lock. Zero
// means lock.DefaultTimeout, which is what every production path uses.
// It exists for tests that deliberately pile many concurrent writers onto
// one store: writers there serialize behind each other, so the tail of the
// queue can exceed the default budget on a loaded machine and report the
// store busy — a property of the test's own contention, not of the
// lock-and-re-read contract it means to assert.
LockTimeout time.Duration
}

// lockTimeout is the effective wait for this engine's mutations.
func (e *Engine) lockTimeout() time.Duration {
if e.LockTimeout > 0 {
return e.LockTimeout
}
return lock.DefaultTimeout
}

// Open resolves the store and returns an engine.
Expand Down Expand Up @@ -93,7 +109,7 @@ func (r *Recorder) finalize() []undo.Change {
// resulting transaction, and atomically writes the file. fn mutates the Doc and
// uses rec to record what it touched.
func (e *Engine) Apply(op string, fn func(d *task.Doc, rec *Recorder) error) error {
h, err := lock.Acquire(e.S.LockFile(), lock.DefaultTimeout)
h, err := lock.Acquire(e.S.LockFile(), e.lockTimeout())
if err != nil {
return err
}
Expand Down
7 changes: 7 additions & 0 deletions internal/mutate/mutate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ func TestUndoRefusesWhenChangedUnderneath(t *testing.T) {
// and confirms none are lost — the lock + re-read-before-write contract holds.
func TestConcurrentAddsNoLostUpdate(t *testing.T) {
e := newEngine(t)
// Every Apply serializes a full acquire-read-mutate-write cycle, so the
// last of n writers waits behind n-1 predecessors. Against the 2s default
// that is a wall-clock race with no margin, and it loses on a loaded CI
// runner — the store reports "busy" and the test fails for a reason that
// has nothing to do with what it asserts. Give the queue room; the
// lost-update check below is the actual assertion.
e.LockTimeout = 60 * time.Second
const n = 25
done := make(chan error, n)
for i := 0; i < n; i++ {
Expand Down
2 changes: 1 addition & 1 deletion internal/mutate/undo.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (e *Engine) Redo(ws string, force bool) (undo.Txn, bool, error) {
// the forward image and its inverse, so both operations apply the same way —
// redo just insists the pending entry IS a redo entry, and undo that it isn't.
func (e *Engine) applyReversal(ws string, force, wantRedo bool) (undo.Txn, bool, error) {
h, err := lock.Acquire(e.S.LockFile(), lock.DefaultTimeout)
h, err := lock.Acquire(e.S.LockFile(), e.lockTimeout())
if err != nil {
return undo.Txn{}, false, err
}
Expand Down
Loading