Help us shape the future of Go! Take the 2026 Go Developer Survey

projectlock

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package projectlock owns the per-project critical section that serializes every Agent Layer read and mutation of skill sources with ordinary projection.

It was extracted from internal/sync so skill import operations and ordinary sync share one lock rather than each defining their own. The lock combines a per-process token (so goroutines in one binary serialize without relying on advisory-lock reentrancy) with an advisory flock on `.agent-layer/sync.lock` (so separate processes serialize too).

Index

Constants

View Source
const FileName = "sync.lock"

FileName is the shared project lock filename. The installer aliases it.

Variables

View Source
var (

	// ErrPostWriteCleanup identifies a fatal lock cleanup failure after the
	// locked section already completed its writes successfully.
	ErrPostWriteCleanup = errors.New("sync generated writes succeeded but post-write lock cleanup failed")
)

Functions

func Path

func Path(root string) string

Path returns the lock file path for a repository root.

func With

func With(sys System, root string, fn func() error) error

With runs fn while holding the project lock.

Callers must perform all source loading inside fn: loading configuration or skill sources before acquisition would let a concurrent import mutate the sources between the read and the projection built from it.

func WithContext added in v1.0.0

func WithContext(ctx context.Context, sys System, root string, fn func() error) (err error)

WithContext runs fn under the project lock unless ctx is canceled.

Types

type RealSystem added in v1.0.0

type RealSystem struct{}

RealSystem supplies the ordinary OS lock operations.

func (RealSystem) Close added in v1.0.0

func (RealSystem) Close(file *os.File) error

Close releases the lock file descriptor.

func (RealSystem) Flock added in v1.0.0

func (RealSystem) Flock(fd int, how int) error

Flock applies the requested advisory lock operation.

func (RealSystem) Now added in v1.0.0

func (RealSystem) Now() time.Time

Now returns the current wall clock time.

func (RealSystem) Sleep added in v1.0.0

func (RealSystem) Sleep(duration time.Duration)

Sleep waits for the requested duration between lock attempts.

type System

type System interface {
	Close(file *os.File) error
	Flock(fd int, how int) error
	Now() time.Time
	Sleep(d time.Duration)
}

System abstracts the few operations lock acquisition needs so tests can inject clock and syscall faults. internal/sync's System satisfies it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL