Documentation
¶
Overview ¶
Package coordinate is the native symbol-lock store for the NativeCoordinator (change 0013). One file per symbol, created with O_CREATE|O_EXCL so the filesystem itself decides the winner of a concurrent claim — the same atomic primitive grit uses on Azure via If-None-Match, but local.
File locks are single-machine by design. grit's Azure and S3 backends exist for teams; this is for one developer's parallel agents, which is why it ships with OpenPlus rather than requiring an install.
Index ¶
- type Held
- type NativeCoordinator
- func (n *NativeCoordinator) Available() bool
- func (n *NativeCoordinator) Claim(ctx context.Context, agent, intent string, syms []string) (orchestrate.Claim, error)
- func (n *NativeCoordinator) Done(ctx context.Context, agent string) error
- func (n *NativeCoordinator) Release(ctx context.Context, agent string) error
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Held ¶
type Held struct {
Granted bool
// On a refusal:
BlockedBy string
BlockedSymbol string
// On a reclaim of an expired lock:
Reclaimed bool
ReclaimedFrom string
}
Held is the outcome of an Acquire attempt.
type NativeCoordinator ¶
type NativeCoordinator struct {
RepoRoot string
// Expiry bounds how long a lock lives. Zero uses defaultLockExpiry.
Expiry time.Duration
// contains filtered or unexported fields
}
NativeCoordinator implements orchestrate.Coordinator natively: symbol locks backed by the file Store, worktrees via git, merges via git. No external binary (change 0013).
The Coordinator port from change 0012 is unchanged; this is a second adapter. Native is the default because it ships with OpenPlus; grit remains available for non-Go languages and multi-machine coordination.
func (*NativeCoordinator) Available ¶
func (n *NativeCoordinator) Available() bool
Available reports whether coordination is possible: the project must be a git repository (worktrees and merges need it). No external binary is required.
func (*NativeCoordinator) Claim ¶
func (n *NativeCoordinator) Claim(ctx context.Context, agent, intent string, syms []string) (orchestrate.Claim, error)
Claim validates every symbol exists in the Go index, acquires locks for all of them atomically, and creates a detached worktree for the agent. A nonexistent symbol is refused — granting a lock on nothing would let two agents both believe they had exclusive access to nothing.
func (*NativeCoordinator) Done ¶
func (n *NativeCoordinator) Done(ctx context.Context, agent string) error
Done commits everything in the agent's worktree, merges it into the base branch, removes the worktree, and releases locks. A merge conflict is reported and the locks still release — a stuck merge must not hold symbols forever.
type Store ¶
type Store struct {
Dir string // .openplus/locks under the project root
Expiry time.Duration // 0 means locks never expire
// contains filtered or unexported fields
}
Store is the file-backed lock table. Safe for concurrent use.
func (*Store) Acquire ¶
Acquire attempts to lock every symbol for agent. The acquire is all-or- nothing: if any symbol is held (by another agent, within its expiry), nothing is locked and the first blocking holder is reported. A claim of zero symbols is an error — locking nothing grants nothing.
func (*Store) ReleaseAgent ¶
ReleaseAgent frees every lock held by agent. Releasing an agent that holds nothing succeeds quietly — the failure path must not error on cleanup.