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

projectlock

package
v0.24.2 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 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

FileName is sourced from internal/install (the package that owns the .agent-layer layout and its known-paths set) so the lock this package creates and the file the installer recognizes can never drift.

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) (err 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.

Types

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