Documentation
¶
Overview ¶
Package config defines the on-disk configuration and the repository registry, their defaults, and the rules that decide where each one lives.
Index ¶
- Constants
- func DefaultConfigPath() (string, error)
- func DefaultRepositoriesPath() (string, error)
- func RegisterRepositories(path string, additions []Repository) error
- func SaveRepositories(path string, repositories RepositoriesFile) error
- func SupportedLanguage(language string) bool
- func SupportedLanguages() []string
- type Config
- type DartConfig
- type Duration
- type GoConfig
- type IndexingConfig
- type InitOptions
- type InitResult
- type Loaded
- type LoggingConfig
- type MCPConfig
- type PythonConfig
- type RepositoriesFile
- type Repository
- type RustConfig
- type StorageConfig
- type TelemetryConfig
- type TypeScriptConfig
- type WatcherConfig
- type WebConfig
- type WorkspaceConfig
Constants ¶
const (
// CurrentSchemaVersion is the configuration schema understood by Kivgraph.
CurrentSchemaVersion = 1
)
Variables ¶
This section is empty.
Functions ¶
func DefaultConfigPath ¶
DefaultConfigPath returns the expanded default config path.
func DefaultRepositoriesPath ¶
DefaultRepositoriesPath returns the expanded default repository registry path.
func RegisterRepositories ¶
func RegisterRepositories(path string, additions []Repository) error
RegisterRepositories appends repositories to the validated registry. Paths are resolved relative to the registry file and duplicate names or paths are rejected before the file is replaced.
func SaveRepositories ¶
func SaveRepositories(path string, repositories RepositoriesFile) error
SaveRepositories validates and atomically replaces a repository registry. Callers use this when a candidate registry has already been validated in memory and must become durable without exposing a partially written YAML document.
func SupportedLanguage ¶
SupportedLanguage reports whether the indexer can analyse a repository that declares this language. The comparison ignores case and surrounding space, which is what every consumer of the field already does.
func SupportedLanguages ¶
func SupportedLanguages() []string
SupportedLanguages is the vocabulary an indexed repository may declare, in the order an error lists them.
It lives here, next to the registry that stores the value, because the registry is where a language is written: a name the indexer cannot analyse used to be accepted by `init` and only rejected by the rebuild, hours later and in another process.
Types ¶
type Config ¶
type Config struct {
Version int `yaml:"version"`
Workspace WorkspaceConfig `yaml:"workspace"`
Storage StorageConfig `yaml:"storage"`
Web WebConfig `yaml:"web"`
MCP MCPConfig `yaml:"mcp"`
Indexing IndexingConfig `yaml:"indexing"`
Watcher WatcherConfig `yaml:"watcher"`
TypeScript TypeScriptConfig `yaml:"typescript"`
Go GoConfig `yaml:"go"`
Rust RustConfig `yaml:"rust"`
Python PythonConfig `yaml:"python"`
Dart DartConfig `yaml:"dart"`
Telemetry TelemetryConfig `yaml:"telemetry"`
Logging LoggingConfig `yaml:"logging"`
}
Config is the complete Kivgraph configuration document.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the explicit defaults from the configuration contract. Paths use the documented home-directory notation until Load expands them.
func LoadConfig ¶
LoadConfig reads and validates only the main configuration document.
type DartConfig ¶ added in v0.3.3
type DartConfig struct {
AnalyzerCommand string `yaml:"analyzer_command"`
MaximumWorkers int `yaml:"maximum_workers"`
SDKPath string `yaml:"sdk_path"`
IncludeTests bool `yaml:"include_tests"`
IncludeGenerated bool `yaml:"include_generated"`
IncludeExternal bool `yaml:"include_external_packages"`
IncludeSDK bool `yaml:"include_sdk"`
PackageConfig string `yaml:"package_config"`
WaitForAnalysis bool `yaml:"wait_for_analysis"`
MaximumAnalysisTime Duration `yaml:"maximum_analysis_time"`
}
DartConfig controls the Dart analysis-server based indexer.
type Duration ¶
Duration is a YAML duration such as 10m or 30s.
func (Duration) MarshalYAML ¶
MarshalYAML emits durations in the same form accepted by UnmarshalYAML.
type GoConfig ¶
type GoConfig struct {
SyntheticWorkFile string `yaml:"synthetic_work_file"`
IncludeTests bool `yaml:"include_tests"`
// GOOS and GOARCH select the build platform. Empty values use the
// platform of the configured Go toolchain.
GOOS string `yaml:"goos"`
GOARCH string `yaml:"goarch"`
CGOEnabled *bool `yaml:"cgo_enabled"`
// BuildTags are the build constraints every Go load satisfies. A
// package guarded by a tag that is absent here contributes no symbol to
// the graph and is reported as unresolved.
BuildTags []string `yaml:"build_tags"`
// AllowNetwork lets the go command reach a module proxy while loading.
// Indexing is hermetic by default: a module the local cache does not
// hold is reported, not fetched. A multi-repository workspace resolves
// one shared build list, so its selection can need a version no member
// downloaded on its own.
AllowNetwork bool `yaml:"allow_network"`
// MaximumLoads bounds concurrent Go loads. Each load holds a complete
// type universe, so this trades memory for speed. Zero uses the
// processor count, capped.
MaximumLoads int `yaml:"maximum_loads"`
}
GoConfig controls Go-specific synthetic workspace behavior.
type IndexingConfig ¶
type IndexingConfig struct {
GeneratedFiles string `yaml:"generated_files"`
UnresolvedReferences string `yaml:"unresolved_references"`
SyntaxAcceleration bool `yaml:"syntax_acceleration"`
FullRebuildOnSchemaChange bool `yaml:"full_rebuild_on_schema_change"`
// FactCache decides whether an analysis unit may be served from the
// facts a previous pass stored for it. `off` analyses everything,
// `on` serves an entry whose recorded inputs all still match, and
// `verify` analyses everything and fails the pass when a servable
// entry disagrees with what the analysis produced.
FactCache string `yaml:"fact_cache"`
// FactCachePath holds one entry per analysis unit, outside every
// indexed repository.
FactCachePath string `yaml:"fact_cache_path"`
}
IndexingConfig controls which facts and references are retained.
type InitOptions ¶
InitOptions controls creation of the local configuration files.
type InitResult ¶
type InitResult struct {
ConfigPath string
RepositoriesPath string
ConfigCreated bool
RepositoriesCreated bool
}
InitResult reports what Initialize created.
func Initialize ¶
func Initialize(options InitOptions) (InitResult, error)
Initialize creates the default configuration and repository registry without replacing existing files unless Force is set. It also creates every local state directory named by the configuration.
type Loaded ¶
type Loaded struct {
Config Config
Repositories RepositoriesFile
ConfigPath string
RepositoriesPath string
// RetiredKeys are the dotted names of keys the file carries that this
// build no longer implements. They are reported rather than rejected, so
// something has to be able to say they were there. See ADR 0062.
RetiredKeys []string
}
Loaded combines the validated configuration and its repository registry.
type LoggingConfig ¶
type LoggingConfig struct {
Format string `yaml:"format"`
Level string `yaml:"level"`
// EventLogPath is the append-only record of indexing passes, tool calls
// and server lifecycle that `kivgraph logs` and `kivgraph tool-stats`
// read. It lives in the state directory rather than beside the
// configuration because it is derived data: losing it costs history, not
// a working installation.
EventLogPath string `yaml:"event_log_path"`
}
LoggingConfig controls the process log output.
type MCPConfig ¶
type MCPConfig struct {
Transport string `yaml:"transport"`
DefaultLimit int `yaml:"default_limit"`
MaximumLimit int `yaml:"maximum_limit"`
MaximumDepth int `yaml:"maximum_depth"`
MaximumVisitedNodes int `yaml:"maximum_visited_nodes"`
}
MCPConfig controls transport and query limits.
type PythonConfig ¶ added in v0.3.3
type PythonConfig struct {
IndexerCommand string `yaml:"indexer_command"`
// AnalyzerCommand is an optional type-aware producer. It must emit the
// versioned semantic payload understood by Kivgraph. The bundled AST
// worker remains the fallback when AnalyzerMode is `fallback`.
AnalyzerCommand string `yaml:"analyzer_command"`
AnalyzerMode string `yaml:"analyzer_mode"`
MaximumWorkers int `yaml:"maximum_workers"`
PythonPath string `yaml:"python_path"`
IncludeTests bool `yaml:"include_tests"`
IncludeGenerated bool `yaml:"include_generated"`
IncludeExternal bool `yaml:"include_external_packages"`
}
PythonConfig controls the external Python semantic indexer.
The command is deliberately configurable: Python projects may use different interpreters, environments and Pyright-derived indexers. The indexer must emit Kivgraph's versioned Python facts payload.
type RepositoriesFile ¶
type RepositoriesFile struct {
Version int `yaml:"version"`
Repositories []Repository `yaml:"repositories"`
}
RepositoriesFile is the repository registry document referenced by Config.
func LoadRepositories ¶
func LoadRepositories(path string) (RepositoriesFile, error)
LoadRepositories reads and validates a repository registry document. An empty path selects ~/.config/kivgraph/repositories.yaml.
type Repository ¶
type Repository struct {
Name string `yaml:"name"`
Path string `yaml:"path"`
Languages []string `yaml:"languages"`
Manifests []string `yaml:"manifests,omitempty"`
Roots []string `yaml:"roots,omitempty"`
Exclusions []string `yaml:"exclusions,omitempty"`
}
Repository identifies one source repository to index.
type RustConfig ¶
type RustConfig struct {
AnalyzerCommand string `yaml:"analyzer_command"`
// MaximumWorkspaces bounds concurrent rust-analyzer invocations. Each
// one holds a whole Cargo workspace and its sysroot in memory, so this
// trades memory for speed. Zero uses the processor count, capped.
MaximumWorkspaces int `yaml:"maximum_workspaces"`
// Features, AllFeatures and NoDefaultFeatures decide which code exists
// at all: a symbol behind an inactive feature is absent from the graph
// and reported as unresolved.
Features []string `yaml:"features"`
AllFeatures bool `yaml:"all_features"`
NoDefaultFeatures bool `yaml:"no_default_features"`
// Cfgs are the additional `--cfg` values the analysis assumes.
Cfgs []string `yaml:"cfgs"`
// BuildScripts and ProcMacros keep generated code and derive expansions
// in the graph. Disabling them is faster and declares what it lost.
BuildScripts bool `yaml:"build_scripts"`
ProcMacros bool `yaml:"proc_macros"`
// IncludeTests sets `cfg(test)` for the crates of the workspace, which
// is the analyzer's own default. Turning it off removes every test item
// from the graph, and the grammar then reports each one as a
// declaration the index does not carry.
IncludeTests bool `yaml:"include_tests"`
// AllowNetwork lets cargo reach a registry while the analyzer loads a
// workspace. Indexing is hermetic by default: a crate the local cache
// does not hold is reported, not fetched.
AllowNetwork bool `yaml:"allow_network"`
// TargetDirectory holds the build artifacts of the analysis. It lives
// outside every indexed repository: rust-analyzer runs build scripts,
// and a pass never writes inside the code it indexes.
TargetDirectory string `yaml:"target_directory"`
// Sysroot is `discover`, `none`, or a path. Without a sysroot the
// standard library is absent and the proc-macro server cannot start.
//
// It says where the standard library is, never whether it enters the
// graph: loading it is what lets the analyzer resolve `Vec` at all, and
// that is needed even when nothing about `core` is published.
Sysroot string `yaml:"sysroot"`
// IndexSysroot publishes the standard library as a synthetic provider
// repository named after the toolchain release. It is off by default
// because it multiplies the symbols of a graph by an order of magnitude:
// one toolchain is around 350.000 monikers and half a minute of indexing.
//
// With it off, a `#[derive]`, an overloaded operator, a `?` and every call
// into the standard library leave no edge, and the pass says so. With it
// on, they resolve to the crate that declares them.
IndexSysroot bool `yaml:"index_sysroot"`
}
RustConfig controls the external rust-analyzer batch indexer.
Rust is analysed by a process Kivgraph does not ship, so the command, the build configuration it is given and the directory its build artifacts land in all belong to the configuration rather than to the code.
type StorageConfig ¶
type StorageConfig struct {
DatabasePath string `yaml:"database_path"`
BackupsPath string `yaml:"backups_path"`
}
StorageConfig controls persistent graph locations.
It used to carry snapshots_path and retain_snapshots. Neither did anything: nothing was ever written to the first, and nothing read the second. They are accepted and reported rather than rejected, because a configuration that was valid yesterday must not stop a server today. See ADR 0062.
type TelemetryConfig ¶
TelemetryConfig controls metrics and tracing.
type TypeScriptConfig ¶
type TypeScriptConfig struct {
WorkerCommand string `yaml:"worker_command"`
MaximumWorkers int `yaml:"maximum_workers"`
ProjectIdleTimeout Duration `yaml:"project_idle_timeout"`
// IncludeUnclaimedSources indexes the repository's TypeScript files that
// no tsconfig claims. A file no project's "files"/"include" reaches
// belongs to no program, so it is invisible by construction: nothing
// type-checks it and nothing reports it absent. Enabling this loads
// those files into TypeScript's inferred project, whose compiler
// options are Kivgraph's choice and not the ones the project declaring
// them would have applied -- there is no project declaring them. It is
// off by default: what it adds is real, and what it adds it under an
// authority weaker than a configured project's.
IncludeUnclaimedSources bool `yaml:"include_unclaimed_sources"`
}
TypeScriptConfig controls the persistent TypeScript worker.
type WatcherConfig ¶
type WatcherConfig struct {
Enabled bool `yaml:"enabled"`
DebounceMilliseconds int `yaml:"debounce_ms"`
MaximumBatchMilliseconds int `yaml:"maximum_batch_ms"`
ReconciliationInterval Duration `yaml:"reconciliation_interval"`
}
WatcherConfig controls incremental file watching.
type WebConfig ¶
type WebConfig struct {
Address string `yaml:"address"`
}
WebConfig controls the explicit local HTTP viewer command.
type WorkspaceConfig ¶
type WorkspaceConfig struct {
RepositoriesFile string `yaml:"repositories_file"`
}
WorkspaceConfig points to the repository registry.