manifests

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package manifests holds Sidecar's vendored copy of Herdr's agent-detection manifests, the lock that pins them, and the extracted alias and authority tables that go with them.

Everything under upstream/ is a byte-for-byte copy of a Herdr file and is never edited by hand: TestVendoredManifestsMatchLock hashes each one against upstream.lock.json so an edit fails CI. Sidecar's own rule changes belong in sidecar/<agent>.toml overlays.

The package embeds the files and does no work at init. Parsing happens lazily behind a sync.Once in the accessors, per the startup-latency rule.

It must not import internal/agentactivity; the dependency runs the other way.

Index

Constants

View Source
const (
	AuthorityHooks           = "hooks"
	AuthoritySessionIdentity = "session_identity"
	AuthorityNone            = "none"
)

The three values AuthorityAgent.LifecycleAuthority takes.

View Source
const (
	SourceBundled   = "bundled"
	SourcePublished = "published"
)

SourceBundled and SourcePublished are the two values LockAgent.Source takes.

View Source
const (
	// FetchResultChecking is written before the network work starts, and is
	// what a second process sees while a first one is still fetching.
	FetchResultChecking = "checking"
	// FetchResultChecked means the catalog was read and every agent has its own
	// result below.
	FetchResultChecked = "checked"
	// FetchResultUpdated means a newer manifest was cached for this agent.
	FetchResultUpdated = "updated"
	// FetchResultCurrent means the published manifest matched what is cached.
	FetchResultCurrent = "current"
	// FetchResultFailed means the fetch or the validation failed.
	FetchResultFailed = "failed"
	// FetchResultIgnored means the file was served and read but must not be
	// used: it needs a newer engine, or it names another agent.
	FetchResultIgnored = "ignored"
)

The values a fetch records for the run as a whole and for one agent. They are Herdr's strings (manifest_update.rs) plus "ignored", which Herdr has no need for because it refuses a file rather than keeping a note about it.

View Source
const CatalogSchemaVersion = 1

CatalogSchemaVersion is the only index schema this client understands, as Herdr's parse_catalog does.

View Source
const FetchInterval = 24 * time.Hour

FetchInterval is the shortest gap between two checks. The plan's rule is "never more than once per day"; this is that day.

View Source
const FetchRetryInterval = time.Hour

FetchRetryInterval is the shortest gap after a check that *failed*.

"Claim the day" and "never retry a failure inside the day" are separable, and running them together was wrong in the ordinary case: a laptop opened on a train with no connectivity claimed the day at 08:40, failed, and then never tried again once the connection came back, so a user whose Sidecar is only ever open away from a network would never fetch at all. An hour is short enough that a transient outage -- a train, a VPN reconnect, a catalog deploying -- is retried inside the session it happened in, and long enough that the worst case is 24 requests a day for a static file rather than one. The crash-loop protection is untouched: a process killed mid-check leaves "checking" behind, not "failed", and that still burns the day.

View Source
const FetchStatusSchemaVersion = 1

FetchStatusSchemaVersion is the version of the status.json document.

View Source
const GeneratedNotice = "generated by internal/tools/herdrsync"

GeneratedNotice is the Origin recorded for upstream/NOTICE, which Sidecar writes rather than copies.

View Source
const LockSchemaVersion = 1

LockSchemaVersion is the shape version of upstream.lock.json. Bump it when a field changes meaning, so a stale lock fails loudly.

View Source
const MaxFetchBytes = 256 * 1024

MaxFetchBytes caps every file the catalog serves, index included. It is Herdr's MAX_FETCH_BYTES (manifest_update.rs:19).

View Source
const OverrideDirName = "agent-detection"

OverrideDirName is the directory under ~/.config/sidecar that holds local overrides. It is Herdr's spelling, because the two directories hold the same files and a user tuning a rule will have both open.

View Source
const RemoteDirName = "agent-detection"

RemoteDirName is the directory under the state directory that holds the runtime fetch cache and its status file. It is Herdr's spelling, the same one OverrideDirName uses on the config axis, because the two directories hold the same kind of file.

Variables

This section is empty.

Functions

func Agents

func Agents() ([]string, error)

Agents lists every vendored upstream manifest id, in file order.

func AliasesJSON

func AliasesJSON() []byte

AliasesJSON returns the raw aliases.upstream.json bytes.

func AuthorityJSON

func AuthorityJSON() []byte

AuthorityJSON returns the raw authority.upstream.json bytes.

func ClearCache

func ClearCache() ([]string, error)

ClearCache deletes every cached manifest and the status file, and returns the paths it removed, in order.

It is the "way out" the setting on its own does not give anyone. Turning fetching off stops the cache being used, but the bytes stay on disk, and a user who changed catalogs, or who wants the next check to start from nothing, otherwise has to find a state directory and delete files by hand. That is not a step a first-class agent user can take from a script, so it is a verb.

Removing nothing is success: the caller asked for an empty cache and there is one. The compiled manifests for every agent are invalidated afterwards by the caller, not here, because Invalidate is per agent and this is a whole-tree operation.

func FetchStatusPath

func FetchStatusPath() string

FetchStatusPath returns the status file's path.

func HTTPClientsBuilt

func HTTPClientsBuilt() int64

HTTPClientsBuilt reports how many HTTP clients this package has constructed in this process.

func HasOverlay

func HasOverlay(agent string) bool

HasOverlay reports whether an overlay is vendored for an agent.

func Invalidate

func Invalidate(agents ...string)

Invalidate drops the memoised load for the named agents, so the next Load re-reads the cache and the override from disk.

It is Herdr's reload_manifests_for_agents (manifest_update.rs:175), and it exists for the same reason: a fetch that cached a newer manifest would otherwise do nothing at all until the process restarted, and a user who turned the setting on would see no change and no explanation. Only the agents whose cache actually moved are invalidated, so a check that found everything current costs no recompilation.

It is safe to call with agents that were never loaded, and it is safe to call while another goroutine is inside Load for the same agent: each Load holds the entry it started with and writes its answer into that entry, so an invalidation mid-load leaves a result nobody can reach rather than overwriting the next load's fresher one. See the entry type in load.go.

func LockJSON

func LockJSON() []byte

LockJSON returns the raw upstream.lock.json bytes.

func OverrideDir

func OverrideDir() string

OverrideDir returns the directory local overrides are read from, or "" when Sidecar cannot resolve its config directory at all.

It derives from config.ConfigPath rather than from os.UserHomeDir, which is what makes `-config <temp path>` and a test's SetTestConfigPath move the override directory with everything else on the config axis. Note that XDG_CONFIG_HOME deliberately moves nothing here, exactly as it moves nothing for config.json itself.

func OverridePath

func OverridePath(agent string) string

OverridePath returns the file a local override for an agent would be read from. The base name is the vendored manifest's file name, so `github-copilot.toml` overrides `upstream/github-copilot.toml` and `sidecar/github-copilot.toml`. Herdr names its override files after its agent *label* instead, which differs for exactly two agents (`copilot` and `agy`); following the vendored file name keeps one rule -- an override is named after the file it replaces -- rather than two spellings that agree nineteen times out of twenty-one.

func RemoteCachePath

func RemoteCachePath(agent string) string

RemoteCachePath returns the file a fetched manifest for an agent is cached at. The base name is the vendored manifest's file name, exactly as OverridePath's is, so `github-copilot.toml` is one spelling everywhere.

func RemoteDir

func RemoteDir() string

RemoteDir returns the directory the runtime fetch cache lives in, or "" when Sidecar cannot resolve its state directory at all.

It derives from config.StateDir, which is what makes XDG_STATE_HOME and a test's SetTestStateDir move the cache with everything else on the state axis. Note that this is the state axis, not the config axis OverrideDir uses: an override is a file the user wrote and belongs with their configuration, and a cache is data Sidecar can throw away and re-fetch.

func SidecarOverlays

func SidecarOverlays() (fs.FS, error)

SidecarOverlays returns the overlay files as a filesystem rooted at the sidecar directory, so a caller opens "claude.toml" rather than "sidecar/claude.toml".

func Upstream

func Upstream() (fs.FS, error)

Upstream returns the vendored Herdr files as a filesystem rooted at the upstream directory, so a caller opens "claude.toml" rather than "upstream/claude.toml". The embed itself costs nothing at init; only this sub-filesystem is built, and only on first use.

func UpstreamBytes

func UpstreamBytes(name string) ([]byte, error)

UpstreamBytes reads one vendored file by its path relative to upstream/.

Types

type AgentFetchStatus

type AgentFetchStatus struct {
	// CachedVersion is the version now in the cache, which is not necessarily
	// the version that was served: a served file that was older, invalid, or
	// too new for this engine leaves the previous cached copy in place.
	CachedVersion string `json:"cachedVersion,omitempty"`
	// ServedVersion is the version the catalog served, when it could be read.
	ServedVersion   string `json:"servedVersion,omitempty"`
	LastResult      string `json:"lastResult"`
	LastError       string `json:"lastError,omitempty"`
	LastCheckedUnix int64  `json:"lastCheckedUnix,omitempty"`
}

AgentFetchStatus is one agent's result from the last check.

type Aliases

type Aliases struct {
	SchemaVersion int    `json:"schema_version"`
	GeneratedFrom string `json:"generated_from"`
	HerdrRef      string `json:"herdr_ref"`
	// Agents maps a Herdr agent id to every process name lookup_agent accepts
	// for it, the canonical id included.
	Agents map[string][]string `json:"agents"`
	// GenericRuntimes is Herdr's is_generic_runtime_or_shell list, without the
	// python family, which is a rule rather than a list.
	GenericRuntimes []string `json:"generic_runtimes"`
	// PythonRuntimeRule describes how python is matched, in prose, because it
	// is a predicate and not an enumerable set.
	PythonRuntimeRule string `json:"python_runtime_rule"`
	// VersionedBinaryPrefixes maps an agent id to a process-name prefix that
	// must be followed by a digit, Herdr's is_muse_versioned_binary shape.
	VersionedBinaryPrefixes map[string]string `json:"versioned_binary_prefixes"`
	// NormalizedSuffixes are stripped from a process name before lookup.
	NormalizedSuffixes []string `json:"normalized_suffixes"`
}

Aliases is the process-identity table extracted from Herdr's src/detect/mod.rs. Adding a brand-new agent still needs a binary change in both projects; this table is what makes the gap visible.

func LoadAliases

func LoadAliases() (*Aliases, error)

LoadAliases returns the parsed alias table.

type Authority

type Authority struct {
	SchemaVersion int                       `json:"schema_version"`
	GeneratedFrom []string                  `json:"generated_from"`
	HerdrRef      string                    `json:"herdr_ref"`
	Agents        map[string]AuthorityAgent `json:"agents"`
}

Authority is Herdr's per-agent lifecycle authority table. It is a *target*, not a claim: Sidecar's own tiers in internal/agentlifecycle are earned by traces and are never copied from here.

func LoadAuthority

func LoadAuthority() (*Authority, error)

LoadAuthority returns the parsed authority table.

type AuthorityAgent

type AuthorityAgent struct {
	DisplayName string `json:"display_name"`
	// LifecycleAuthority is "hooks", "session_identity", or "none".
	LifecycleAuthority string `json:"lifecycle_authority"`
	StateAuthority     string `json:"state_authority"`
	IntegrationRole    string `json:"integration_role"`
	// IntegrationVersion is the HERDR_INTEGRATION_VERSION carried by the
	// agent's integration assets, or 0 where Herdr ships no integration.
	IntegrationVersion int `json:"integration_version,omitempty"`
	// IntegrationAssetDir is the directory under src/integration/assets that
	// holds those assets.
	IntegrationAssetDir string `json:"integration_asset_dir,omitempty"`
}

AuthorityAgent is one row of Herdr's published agent table.

type FetchOptions

type FetchOptions struct {
	// CatalogURL is the index to read. Required: the caller resolves it from
	// the setting, so this package never decides on its own that fetching is
	// allowed.
	CatalogURL string
	// Client overrides the HTTP client, for tests. When nil a client is built,
	// which is the event HTTPClientsBuilt counts.
	Client *http.Client
	// Now is the clock. Zero means time.Now().
	Now time.Time
	// Force skips the once-a-day gate. The app never sets it: this is what
	// `sidecar agent manifests --refresh` asks for, and what a test uses. An
	// explicit "check now" is the recovery path for a user who changed the
	// catalog, or whose day was claimed by a check that has since been fixed.
	Force bool
}

FetchOptions tunes one check. The zero value fetches Herdr's own catalog with a fresh client at the current time, which is what the app passes.

type FetchResult

type FetchResult struct {
	// Skipped reports that no network work happened, with Reason saying why.
	Skipped bool
	Reason  string
	// Updated names the agents whose cache moved, keyed the way Load keys
	// agents: the vendored file's base name.
	Updated []string
	// Status is the status file as it now stands on disk.
	Status FetchStatus
}

FetchResult is what one check did.

func Fetch

func Fetch(ctx context.Context, opts FetchOptions) (FetchResult, error)

Fetch reads the catalog index and every manifest it lists, caching the ones that are newer than what is cached already.

It never returns a user-visible failure: a caller that ignores the error gets the same behaviour a caller that reads it does, because everything a check learns is written to the status file for `sidecar agent manifests` and `sidecar agent explain` to report. The error return is for tests and for the log line.

func FetchFromConfig

func FetchFromConfig(ctx context.Context, detection config.DetectionConfig, opts FetchOptions) (FetchResult, error)

FetchFromConfig runs a check when the setting enables one.

This is the only entry point the app uses, and it is deliberately the place the setting is read: a caller cannot fetch by accident, and the "off" path returns before anything is built, opened, or dialled.

type FetchStatus

type FetchStatus struct {
	SchemaVersion int `json:"schemaVersion"`
	// CatalogURL is the index the last check used, so a user who changed the
	// setting can see which catalog the cache came from.
	CatalogURL string `json:"catalogUrl,omitempty"`
	// LastCheckUnix is when the last check *started*, not when it finished. It
	// is written before the network work, which is what makes it a claim: see
	// Fetch.
	LastCheckUnix int64  `json:"lastCheckUnix,omitempty"`
	LastResult    string `json:"lastResult,omitempty"`
	LastError     string `json:"lastError,omitempty"`
	// SkippedRows names catalog rows the last check could not use and passed
	// over: an id this binary has no vendored manifest for, or a path it will
	// not resolve. They are recorded rather than dropped because a row skipped
	// silently is a manifest that quietly stops updating.
	SkippedRows []string `json:"skippedRows,omitempty"`
	// Agents is keyed by the vendored file's base name, the same key Load and
	// OverridePath use, never by Herdr's agent label.
	Agents map[string]AgentFetchStatus `json:"agents,omitempty"`

	// ReadError says why the status file on disk could not be used, when a file
	// was there and could not be read or parsed. It describes *this read*, not
	// the document, so it is never serialised: a caller writing the status back
	// would otherwise persist a note about a file that no longer exists.
	//
	// It exists because this file is where the whole feature's observability
	// lives. A status file that is unreadable used to read as "never checked",
	// which is the one answer that makes a broken fetch look like a fetch that
	// was never configured.
	ReadError string `json:"-"`
}

FetchStatus is what the last runtime catalog fetch left behind. It is the diagnostic half of this feature: a fetch never fails visibly, so this file is the only place a user with fetch on can find out that it has not worked for a week. `sidecar agent manifests` prints it.

func LoadFetchStatus

func LoadFetchStatus() FetchStatus

LoadFetchStatus reads the status file. A missing or unreadable file reads as an empty status, because the status is a diagnostic and losing it must never be an error in its own right -- a fetch whose claim cannot be read runs, and rewrites the file.

A file that was there and could not be used sets ReadError, so a reader can tell "nothing has ever checked" apart from "the record of what checked is unreadable". Those are opposite pieces of news and this file is the only place either of them is written down.

type Lock

type Lock struct {
	SchemaVersion int          `json:"schema_version"`
	GeneratedAt   string       `json:"generated_at"`
	EngineVersion int          `json:"engine_version"`
	Herdr         LockUpstream `json:"herdr"`
	Catalog       LockCatalog  `json:"catalog"`
	Agents        []LockAgent  `json:"agents"`
	// Files pins the vendored files that are not agent manifests: the upstream
	// LICENSE and the generated NOTICE. They carry the attribution the vendored
	// tree depends on, so they are digest-pinned exactly like a manifest.
	Files []LockFile `json:"files"`
	// Notes carries anything about this sync a reviewer needs and the fields
	// above cannot express, such as an unreachable network.
	Notes []string `json:"notes,omitempty"`
}

Lock records exactly which upstream bytes are vendored and where they came from, so a reader can reproduce the sync and a test can prove the tree has not been edited by hand.

func LoadLock

func LoadLock() (*Lock, error)

Lock returns the parsed lock. It is decoded once and shared; callers must not mutate the result.

func (*Lock) Agent

func (l *Lock) Agent(id string) (LockAgent, bool)

Agent returns the lock entry for an agent id.

func (*Lock) File

func (l *Lock) File(path string) (LockFile, bool)

File returns the lock entry for a vendored non-manifest file path, such as "upstream/LICENSE".

type LockAgent

type LockAgent struct {
	ID     string `json:"id"`
	Path   string `json:"path"`
	SHA256 string `json:"sha256"`
	Bytes  int    `json:"bytes"`

	Version          string `json:"version"`
	MinEngineVersion int    `json:"min_engine_version"`
	UpdatedAt        string `json:"updated_at,omitempty"`
	RuleCount        int    `json:"rule_count"`

	// Source is "bundled" or "published": which of the two copies a Herdr
	// client would load, and therefore which one is vendored here.
	Source       string `json:"source"`
	SourceReason string `json:"source_reason"`

	BundledVersion   string `json:"bundled_version,omitempty"`
	PublishedVersion string `json:"published_version,omitempty"`

	Aliases []string `json:"aliases"`

	// RegexIncompatibilities names every pattern in this file that Rust's
	// regex crate accepts and Go's RE2 cannot compile. Vendoring does not fail
	// on one; an overlay carries the rewrite.
	RegexIncompatibilities []LockRegexIncompatibility `json:"regex_incompatibilities,omitempty"`
}

LockAgent pins one vendored manifest.

type LockCatalog

type LockCatalog struct {
	URL string `json:"url"`
	// ETag is the catalog's HTTP ETag, or "unknown" when the catalog could not
	// be reached.
	ETag string `json:"etag"`
	// Fetched is false for an offline sync, where the published copies came
	// from the source checkout's distribution directory instead.
	Fetched       bool   `json:"fetched"`
	Source        string `json:"source"`
	SchemaVersion int    `json:"schema_version"`
	Path          string `json:"path"`
	SHA256        string `json:"sha256"`
}

LockCatalog records the published catalog this sync consulted.

type LockFile

type LockFile struct {
	Path   string `json:"path"`
	SHA256 string `json:"sha256"`
	Bytes  int    `json:"bytes"`
	// Origin is the upstream path the bytes came from, or a description of what
	// generated them where Sidecar writes the file itself.
	Origin string `json:"origin"`
}

LockFile pins one vendored non-manifest file.

type LockRegexIncompatibility

type LockRegexIncompatibility struct {
	RuleID  string `json:"rule_id"`
	Field   string `json:"field"`
	Pattern string `json:"pattern"`
	Error   string `json:"error"`
}

LockRegexIncompatibility is one pattern RE2 cannot compile.

type LockUpstream

type LockUpstream struct {
	Repository string `json:"repository"`
	// Ref is what was asked for: a tag, a branch, or a commit.
	Ref string `json:"ref"`
	// Commit is the resolved commit when it could be determined.
	Commit string `json:"commit,omitempty"`
	// SourceDir records that a local checkout supplied the bytes.
	SourceDir string `json:"source_dir,omitempty"`
	// PinnedReleaseTag is the Herdr release the differential harness runs
	// against. It can differ from Ref while a sync tracks main.
	PinnedReleaseTag string `json:"pinned_release_tag"`
}

LockUpstream pins the Herdr source the manifests were read from.

type RemoteCacheSummary

type RemoteCacheSummary struct {
	Path       string
	Version    string
	Diagnostic string
}

RemoteCacheSummary is what one cached file says about itself, for the `sidecar agent manifests` table. It reports a refused cache too, because "you have a cached file and it is not the one running" is the question the table exists to answer.

func CachedRemote

func CachedRemote(agent string) RemoteCacheSummary

CachedRemote reports the fetch cache's state for an agent without loading or compiling anything else. It returns a zero summary when nothing is cached.

It reads the file whatever detection.remoteManifests says, which is what makes "you have a cached file and the setting is off, so it is not the one running" something `sidecar agent manifests` can print. Only the loader is gated.

type Source

type Source struct {
	// Agent is the Herdr agent id the manifest was loaded for.
	Agent string
	// Kind names which source won. The zero value reads as KindBundled, so a
	// caller that only cares about the vendored path can leave it unset.
	Kind SourceKind
	// Version is the loaded manifest's version: the vendored one for a bundled
	// source, the cached one for a remote source, the override's own for a
	// local override.
	Version string
	// VendoredVersion is always the version of the manifest vendored into this
	// binary, whichever source won. It is what makes "am I ahead of the
	// vendored tree?" answerable from one record.
	VendoredVersion string
	// CachedRemoteVersion is the version in the runtime fetch cache, or "" when
	// nothing is cached or the cache was refused. Herdr reports the same field
	// under the same name (manifest.rs:43).
	CachedRemoteVersion string
	// OverlayApplied records that sidecar/<agent>.toml was merged in. It is
	// true for a bundled or a remote source that took the overlay, and never
	// for a local override, which replaces the overlay along with the file it
	// is named after.
	OverlayApplied bool
	// Path is the file a local override or a cached remote manifest was read
	// from. Empty for a bundled source.
	Path string
	// Diagnostic is a human-readable note about something that went wrong but
	// did not stop the load: an overlay that failed to parse, merge, or
	// validate, or a local override that was found and refused, in which case
	// the next source down is used, because a broken user-owned file must never
	// take a working vendored file with it. It also carries the one problem an
	// override can have while still being used: a rule Go's regexp cannot
	// compile, which is dead in a file that has no overlay under it to rewrite
	// it. Empty when nothing went wrong.
	Diagnostic string
}

Source describes which files produced a compiled manifest, in the style of Herdr's `manifest_source` explain field, so a `sidecar agent explain` record and a `herdr agent explain` record read the same way side by side.

func Load

func Load(agent string) (*manifest.Compiled, Source, error)

Load returns the compiled manifest for a Herdr agent id: a valid local override if the user has one, otherwise the vendored manifest with its Sidecar overlay merged in.

The work happens on first use per agent behind a sync.Once, never at package init: a Sidecar start that never opens a pane running Claude should not pay to parse claude.toml, and the startup-latency rule forbids doing it in Init() anyway. The one filesystem read on this path -- the local override -- is inside that same sync.Once for the same reason. The compiled result is immutable and shared; callers must not mutate it.

func (Source) Label

func (s Source) Label() string

Label renders the Herdr-style source string, e.g. "bundled claude 2026.08.29.1 + sidecar overlay", or, for an override, the path it was read from, which is what Herdr's own label is.

type SourceKind

type SourceKind string

SourceKind names which of the manifest sources produced a compiled manifest. It is Herdr's ManifestSource::kind (manifest.rs:64 at e2b85c7) with Sidecar's overlay folded in as a flag on the upstream kinds rather than a kind of its own, because an overlay amends an upstream file rather than replacing it.

The fourth source the Phase 3 comment reserved is KindRemote, added in Phase 5: a manifest fetched from the published catalog, which slots in between the bundled file and the local override. An override still wins over it, exactly as it does in Herdr.

const (
	// KindBundled is the vendored Herdr manifest, alone or with its overlay.
	KindBundled SourceKind = "bundled"
	// KindRemote is a manifest fetched from the published catalog and cached
	// under the state directory, alone or with its overlay. It appears only
	// when detection.remoteManifests is on and the cached copy is at least as
	// new as the vendored one.
	KindRemote SourceKind = "remote"
	// KindLocalOverride is ~/.config/sidecar/agent-detection/<agent>.toml.
	KindLocalOverride SourceKind = "local override"
)

The kinds a Source takes.

These are not the lock file's SourceBundled/SourcePublished (lock.go), which record which of Herdr's two *distribution* copies the sync tool vendored. This is which file the running engine loaded.

Jump to

Keyboard shortcuts

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