agentslock

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package agentslock is the single shared writer for .agentsrc.lock — the resolved-state companion to .agentsrc.json (config-distribution-model §7).

It is schema-agnostic: it owns the whole JSON document and treats top-level sections (config, packages, adapters, …) as opaque values, so the config/ package resolver and the graph-adapter lifecycle share one file without either importing the other's schema (§7.4). A writer stages only its own section and flushes; sibling sections are preserved verbatim. Flush is atomic (temp file + rename, via fsops.WriteFileAtomic). A single Lockfile is safe for concurrent SetSection from parallel resolver goroutines — the in-process mutex guards the document and the on-disk write is the one serialized step (§7.4 "parallel resolution, serialized write").

Index

Constants

View Source
const LockVersion = 1

LockVersion is the current .agentsrc.lock schema version.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lockfile

type Lockfile struct {
	// contains filtered or unexported fields
}

Lockfile is the in-memory view of a .agentsrc.lock document: open it, read or stage sections, then Flush. Safe for concurrent use.

func Open

func Open(path string) (*Lockfile, error)

Open loads the lockfile at path. A missing file yields a fresh document (lock_version only); a present file is parsed, preserving every top-level key — including sections this process does not know about.

func (*Lockfile) Flush

func (lf *Lockfile) Flush() error

Flush writes the whole document to path atomically, preserving every section. It is callable more than once (e.g. persist config before a slow adapter activation, then flush adapters after). The parent directory must exist.

func (*Lockfile) InputsDigest

func (lf *Lockfile) InputsDigest() (string, bool)

InputsDigest returns the top-level inputs_digest and whether it was present. An absent or empty field reports ("", false).

func (*Lockfile) Section

func (lf *Lockfile) Section(name string, v any) (bool, error)

Section decodes the named section into v and reports whether it was present. An absent section returns (false, nil) so callers can treat "no section yet" and "section exists" uniformly.

func (*Lockfile) SetInputsDigest

func (lf *Lockfile) SetInputsDigest(digest string)

SetInputsDigest stages the top-level inputs_digest field (§7A.3): the whole-normalized hash of all local config scopes that drives staleness. An empty digest clears the field. Safe for concurrent use.

func (*Lockfile) SetSection

func (lf *Lockfile) SetSection(name string, v any) error

SetSection marshals v and stages it as the named section, leaving every other section untouched. Safe to call concurrently from multiple goroutines.

Jump to

Keyboard shortcuts

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