Documentation
¶
Index ¶
- Constants
- func CargoExcludes(root, path string, exclusions []string) bool
- func FirstSymlink(path string) (string, error)
- func IsSyntheticRepository(name string) bool
- func UnclaimedTypeScriptSources(ctx context.Context, repository Repository, discovery TypeScriptDiscovery) ([]string, error)
- func ValidatePaths(ctx context.Context, source config.RepositoriesFile) error
- type CargoCrate
- type CargoDiscovery
- type CargoWorkspace
- type GoDiscovery
- type GoModule
- type GoModuleProvider
- type GoModuleRegistry
- type GoPackage
- type GoReplacement
- type GoWorkspace
- type ProviderConflict
- type ProviderConflictKind
- type ProviderConflictReport
- type Registry
- type Repository
- type TypeScriptDiscovery
- type TypeScriptEngine
- type TypeScriptPackage
- type TypeScriptPackageConflict
- type TypeScriptPackageRegistry
- type TypeScriptProgram
- type TypeScriptProject
- type TypeScriptProjectGraph
- func (graph *TypeScriptProjectGraph) Dependents(configPath string) []string
- func (graph *TypeScriptProjectGraph) Get(configPath string) (TypeScriptProgram, bool)
- func (graph *TypeScriptProjectGraph) Len() int
- func (graph *TypeScriptProjectGraph) Order() []string
- func (graph *TypeScriptProjectGraph) Programs() []TypeScriptProgram
- func (graph *TypeScriptProjectGraph) Unsupported() []TypeScriptProgram
- type TypeScriptProjectVersion
- type TypeScriptVersion
- type TypeScriptVersionResolver
- type TypeScriptVersionSource
- type TypeScriptWorkspaceDeclaration
- type TypeScriptWorkspaceFormat
Constants ¶
const SyntheticRepositoryPrefix = "rust:"
SyntheticRepositoryPrefix is the namespace of the providers Kivgraph derives from the machine instead of from `repositories.yaml`. The standard library of a Rust toolchain is registered as `rust:1.96.1`.
The namespace is reserved at registration, and that is what makes the name authoritative: nothing else in the graph can be called this, so a consumer can tell a derived provider from an indexed repository without a second column to carry the answer.
Variables ¶
This section is empty.
Functions ¶
func CargoExcludes ¶
CargoExcludes reports whether Cargo discovery would skip a file below the repository root.
Discovery never descends into a vendored, generated or excluded directory, so no manifest below one is ever read and no crate it declares exists for this repository. Anything that indexes those files later has to answer the same question over a path it did not walk, and it has to answer it the same way: the boundary of a repository is one decision, not one per caller.
func FirstSymlink ¶
FirstSymlink returns the first component of path that is a symbolic link, walking from the filesystem root inwards, or the empty string when none is.
It is exported because two layers enforce the same policy for the same reason: this package refuses to index through a link, and the MCP surface refuses to serve bytes through one. Duplicating four lines of a security check is how two copies of it end up disagreeing.
func IsSyntheticRepository ¶
IsSyntheticRepository reports whether a repository name belongs to the reserved namespace.
func UnclaimedTypeScriptSources ¶ added in v0.4.0
func UnclaimedTypeScriptSources( ctx context.Context, repository Repository, discovery TypeScriptDiscovery, ) ([]string, error)
UnclaimedTypeScriptSources returns the absolute, sorted, duplicate-free .ts and .tsx files below the repository root that no discovered project owns.
A file no project's "files"/"include" reaches belongs to no program: the compiler never type-checks it, so the graph cannot see it and nothing reports it absent. That is the set this function names, and it is named against the same resolution the project graph uses -- resolveTypeScriptConfig followed by resolveTypeScriptSources -- so a file is unclaimed here exactly when the compiler would leave it out of every program.
Three kinds of file are deliberately not in it:
- A declaration file. It declares nothing a caller needs, and a `.d.ts` that no project claims describes an artifact whose source is elsewhere.
- Anything below an installed-dependency or generated-output directory, or below a path the repository's own exclusions name.
- Anything a project excludes. An "exclude" entry is a declaration about that tree, not a gap in the index, so honouring it here is what keeps the two readings of the same configuration from disagreeing.
func ValidatePaths ¶
func ValidatePaths(ctx context.Context, source config.RepositoriesFile) error
ValidatePaths validates repository boundaries without invoking Git. It is safe to call before NewRegistry when only filesystem validation is required.
Types ¶
type CargoCrate ¶
type CargoCrate struct {
ManifestPath string
RootPath string
// WorkspacePath is the manifest of the workspace that resolves this
// crate. A standalone crate names its own manifest.
WorkspacePath string
Name string
// Version and Edition are already resolved: a member that inherits them
// from [workspace.package] carries the inherited value, because the
// version is part of the identity every cross-repository edge depends
// on.
Version string
Edition string
}
CargoCrate is one package declared by a Cargo.toml.
type CargoDiscovery ¶
type CargoDiscovery struct {
Workspaces []CargoWorkspace
Crates []CargoCrate
LockFiles []string
}
CargoDiscovery contains the Cargo workspaces, crates and lockfiles found in a registered repository.
Every crate belongs to exactly one workspace: Cargo treats a package with no workspace section and no parent workspace as a workspace of one, and so does this discovery. That is what makes Workspaces the list of units an indexing pass can schedule without a second rule.
func DiscoverCargo ¶
func DiscoverCargo(ctx context.Context, repository Repository) (CargoDiscovery, error)
DiscoverCargo finds Cargo manifests, workspaces, crates and lockfiles below a repository root. Results are deterministic and use absolute, canonical paths.
Nothing here runs `cargo`: discovery must be hermetic, cheap and free of writes, and a manifest already says what a crate is called and which workspace resolves it.
type CargoWorkspace ¶
type CargoWorkspace struct {
ManifestPath string
RootPath string
// LockPath is the Cargo.lock beside the manifest, empty when absent.
LockPath string
// Virtual reports a manifest that declares [workspace] and no [package].
Virtual bool
// Members are the manifest paths of the crates this workspace resolves,
// sorted, including the root crate when it has one.
Members []string
}
CargoWorkspace is one root that Cargo resolves as a whole.
type GoDiscovery ¶
type GoDiscovery struct {
Modules []GoModule
Workspaces []GoWorkspace
SumFiles []string
Packages []GoPackage
}
GoDiscovery contains Go modules, workspaces, sums and packages found in a registered repository.
func DiscoverGo ¶
func DiscoverGo(ctx context.Context, repository Repository) (GoDiscovery, error)
DiscoverGo finds go.mod, go.sum, go.work, Go packages and replace directives below a repository root. Results are deterministic and use absolute, canonical paths.
type GoModule ¶
type GoModule struct {
ManifestPath string
SumPath string
RootPath string
ModulePath string
GoVersion string
// Requires are the module paths of the require block, in file order.
Requires []string
Replaces []GoReplacement
}
GoModule describes one go.mod, its requirements and its replace directives.
type GoModuleProvider ¶
type GoModuleProvider struct {
ModulePath string
Repository string
ManifestPath string
SumPath string
RootPath string
GoVersion string
Packages []GoPackage
Replaces []GoReplacement
WorkspaceReplaces []GoReplacement
}
GoModuleProvider is a named Go module provider discovered in one repository. WorkspaceReplaces preserves replacements declared by go.work files that include this module.
type GoModuleRegistry ¶
type GoModuleRegistry struct {
// contains filtered or unexported fields
}
GoModuleRegistry is an immutable module-path index for one repository. Cross-repository ambiguity is handled by LUQUE-0408.
func NewGoModuleRegistry ¶
func NewGoModuleRegistry(ctx context.Context, repository Repository) (*GoModuleRegistry, error)
NewGoModuleRegistry discovers and indexes Go modules for one repository.
func (*GoModuleRegistry) Get ¶
func (registry *GoModuleRegistry) Get(modulePath string) (GoModuleProvider, bool)
Get returns a deep copy of the module registered under modulePath.
func (*GoModuleRegistry) List ¶
func (registry *GoModuleRegistry) List() []GoModuleProvider
List returns deep copies sorted by module path.
type GoPackage ¶
type GoPackage struct {
Directory string
ImportPath string
ModulePath string
Name string
Files []string
}
GoPackage describes one package directory and its source files.
type GoReplacement ¶
type GoReplacement struct {
OldPath string
OldVersion string
NewPath string
NewVersion string
NewLocalPath string
}
GoReplacement preserves a replace directive. NewLocalPath is set only when NewPath is a local filesystem path.
type GoWorkspace ¶
type GoWorkspace struct {
Path string
GoVersion string
Modules []string
Replaces []GoReplacement
}
GoWorkspace describes one go.work and its resolved module manifests.
type ProviderConflict ¶
type ProviderConflict struct {
Kind ProviderConflictKind
Provider string
Repositories []string
Versions []string
ManifestPaths []string
}
ProviderConflict identifies all repositories and manifests participating in one classified conflict.
type ProviderConflictKind ¶
type ProviderConflictKind string
ProviderConflictKind classifies one cross-repository provider conflict.
const ( AmbiguousPackageProvider ProviderConflictKind = "AMBIGUOUS_PACKAGE_PROVIDER" AmbiguousModuleProvider ProviderConflictKind = "AMBIGUOUS_MODULE_PROVIDER" PackageVersionMismatch ProviderConflictKind = "PACKAGE_VERSION_MISMATCH" ModuleReplaceConflict ProviderConflictKind = "MODULE_REPLACE_CONFLICT" )
type ProviderConflictReport ¶
type ProviderConflictReport struct {
Conflicts []ProviderConflict
}
ProviderConflictReport is the deterministic result of cross-repository provider validation.
func DetectProviderConflicts ¶
func DetectProviderConflicts(ctx context.Context, repositories []Repository) (ProviderConflictReport, error)
DetectProviderConflicts builds the per-repository TypeScript and Go registries, then classifies duplicate providers and incompatible metadata. No provider is selected automatically.
func (ProviderConflictReport) HasConflicts ¶
func (report ProviderConflictReport) HasConflicts() bool
HasConflicts reports whether any provider conflict was detected.
func (ProviderConflictReport) List ¶
func (report ProviderConflictReport) List() []ProviderConflict
List returns deep copies of all conflicts sorted by kind and provider.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is an immutable, name-indexed set of registered repositories.
func NewRegistry ¶
NewRegistry resolves configured paths, validates repository boundaries and records filesystem and Git metadata. It preserves the order from repositories.yaml.
func (*Registry) Get ¶
func (registry *Registry) Get(name string) (Repository, bool)
Get returns a deep copy of the repository registered under name.
func (*Registry) List ¶
func (registry *Registry) List() []Repository
List returns a deep copy in the order declared by repositories.yaml.
type Repository ¶
type Repository struct {
Name string
Path string
RealPath string
Commit string
Branch string
Dirty bool
Languages []string
Manifests []string
Roots []string
Exclusions []string
}
Repository is the runtime metadata registered for one source repository.
func NewSyntheticRepository ¶
func NewSyntheticRepository(name, path string, languages []string) (Repository, error)
NewSyntheticRepository builds a repository that is not registered and has no version control: a provider the pass derives from the machine rather than from `repositories.yaml`. The standard library of a Rust toolchain is the only one today.
The path policy is the registry's, unchanged: a synthetic provider that resolved through a symlink component would let a pass read outside the tree it declared, and the reason this exists is to index code, not to relax that.
type TypeScriptDiscovery ¶
type TypeScriptDiscovery struct {
PackageManifests []string
Projects []TypeScriptProject
Workspaces []TypeScriptWorkspaceDeclaration
}
TypeScriptDiscovery contains the manifests and project relationships found in one registered repository.
func DiscoverTypeScript ¶
func DiscoverTypeScript(ctx context.Context, repository Repository) (TypeScriptDiscovery, error)
DiscoverTypeScript finds package manifests, TypeScript project configs, workspace declarations and project references below a repository root. Results are deterministic and use absolute, canonical paths.
type TypeScriptEngine ¶
type TypeScriptEngine struct {
// Version is the pinned compiler, used as the last resort.
Version string
// SupportedMin and SupportedMax bound the window of project versions whose
// facts may be emitted as exact. An empty bound is open.
SupportedMin string
SupportedMax string
}
TypeScriptEngine describes the compiler Kivgraph actually runs and the version window whose facts may be exact. It mirrors the HELLO announcement of the worker; per ADR 0010 the engine never changes with the project, only the confidence of the facts does.
type TypeScriptPackage ¶
type TypeScriptPackage struct {
Name string
Version string
Private bool
Repository string
RootPath string
ManifestPath string
Exports json.RawMessage
TypesPath string
ProjectPath string
SourceRoots []string
DeclarationRoots []string
}
TypeScriptPackage is a named package provider discovered in one repository.
type TypeScriptPackageConflict ¶
TypeScriptPackageConflict is one package name several manifests declare.
Neither manifest can be chosen: a reference to that name has no single provider. The ambiguity is reported the same way an ambiguous Go module provider is -- the candidates leave the registry and the conflict is declared -- because a repository that vendors or fixtures a second copy of a package must not make the rest of the graph unbuildable.
type TypeScriptPackageRegistry ¶
type TypeScriptPackageRegistry struct {
// contains filtered or unexported fields
}
TypeScriptPackageRegistry is an immutable package-name index for one repository. Cross-repository ambiguity is handled by LUQUE-0408.
func NewTypeScriptPackageRegistry ¶
func NewTypeScriptPackageRegistry(ctx context.Context, repository Repository) (*TypeScriptPackageRegistry, error)
NewTypeScriptPackageRegistry discovers and indexes named package.json manifests for one repository.
func (*TypeScriptPackageRegistry) Conflicts ¶
func (registry *TypeScriptPackageRegistry) Conflicts() []TypeScriptPackageConflict
Conflicts returns the package names this registry refused to resolve.
func (*TypeScriptPackageRegistry) Get ¶
func (registry *TypeScriptPackageRegistry) Get(name string) (TypeScriptPackage, bool)
Get returns a deep copy of the package registered under name.
func (*TypeScriptPackageRegistry) List ¶
func (registry *TypeScriptPackageRegistry) List() []TypeScriptPackage
List returns deep copies sorted by package name.
type TypeScriptProgram ¶
type TypeScriptProgram struct {
// ConfigPath is the absolute, canonical tsconfig path. It identifies the
// project everywhere else in Kivgraph.
ConfigPath string
// Directory is the directory containing ConfigPath. Relative options and
// patterns are resolved against it.
Directory string
// Extends is the resolved inheritance chain, nearest parent first. It is
// empty for a config that extends nothing.
Extends []string
// CompilerOptions are the options after applying the chain, with path
// valued options rebased to absolute paths.
CompilerOptions map[string]any
// References are the absolute config paths this project depends on.
References []string
// SourceFiles are the absolute files the project owns, sorted and free of
// duplicates.
SourceFiles []string
// Composite reports whether the project may be referenced by others.
Composite bool
// Version is the compiler resolved for this project, per LUQUE-0605.
Version TypeScriptVersion
}
TypeScriptProgram is one fully resolved tsconfig: its inheritance chain, its effective compiler options, the projects it references, the source files it owns and the compiler version that will analyse it.
type TypeScriptProject ¶
TypeScriptProject describes one tsconfig and its resolved project references. ConfigPath and References are absolute paths.
type TypeScriptProjectGraph ¶
type TypeScriptProjectGraph struct {
// contains filtered or unexported fields
}
TypeScriptProjectGraph is the immutable reference DAG of one repository.
func NewTypeScriptProjectGraph ¶
func NewTypeScriptProjectGraph( ctx context.Context, repository Repository, discovery TypeScriptDiscovery, resolver *TypeScriptVersionResolver, ) (*TypeScriptProjectGraph, error)
NewTypeScriptProjectGraph resolves every discovered project and links them through their references.
A resolver is required: a project whose compiler version is unknown would produce facts whose confidence nobody can audit, per ADR 0010.
func (*TypeScriptProjectGraph) Dependents ¶
func (graph *TypeScriptProjectGraph) Dependents(configPath string) []string
Dependents returns the projects that reference configPath, sorted.
func (*TypeScriptProjectGraph) Get ¶
func (graph *TypeScriptProjectGraph) Get(configPath string) (TypeScriptProgram, bool)
Get returns one project by its config path.
func (*TypeScriptProjectGraph) Len ¶
func (graph *TypeScriptProjectGraph) Len() int
Len returns the number of projects.
func (*TypeScriptProjectGraph) Order ¶
func (graph *TypeScriptProjectGraph) Order() []string
Order returns the config paths in dependency order: a referenced project always precedes the projects that reference it.
func (*TypeScriptProjectGraph) Programs ¶
func (graph *TypeScriptProjectGraph) Programs() []TypeScriptProgram
Programs returns every project in dependency order.
func (*TypeScriptProjectGraph) Unsupported ¶
func (graph *TypeScriptProjectGraph) Unsupported() []TypeScriptProgram
Unsupported returns the projects whose facts cannot be exact, sorted by config path. It is the audit list ADR 0010 requires.
type TypeScriptProjectVersion ¶
type TypeScriptProjectVersion struct {
ConfigPath string
TypeScriptVersion
}
TypeScriptProjectVersion binds one discovered project to its compiler.
type TypeScriptVersion ¶
type TypeScriptVersion struct {
// Version is the resolved compiler version, without a leading v.
Version string
// Source is which of the three resolution steps produced it.
Source TypeScriptVersionSource
// ManifestPath is the package.json of the resolved compiler. It is empty
// for the pinned fallback, which is not installed in the repository.
ManifestPath string
// Declared is the range the nearest package.json asks for, when it does.
// It is evidence for auditing, never the resolved version.
Declared string
// DeclaredBy is the manifest carrying Declared.
DeclaredBy string
// WithinSupportedWindow reports whether facts from this project may be
// exact. Outside the window they must degrade to CANDIDATE.
WithinSupportedWindow bool
// OutsideWindowReason explains a false WithinSupportedWindow. It is empty
// when the project is inside the window.
OutsideWindowReason string
}
TypeScriptVersion is the compiler resolved for one project.
type TypeScriptVersionResolver ¶
type TypeScriptVersionResolver struct {
// contains filtered or unexported fields
}
TypeScriptVersionResolver resolves the compiler of each project inside one repository. It is immutable and safe for concurrent use.
func NewTypeScriptVersionResolver ¶
func NewTypeScriptVersionResolver(repository Repository, engine TypeScriptEngine) (*TypeScriptVersionResolver, error)
NewTypeScriptVersionResolver builds a resolver bounded by the repository root. The walk never leaves that root, so a compiler installed outside the registered repository cannot silently decide the confidence of its facts.
func (*TypeScriptVersionResolver) Engine ¶
func (resolver *TypeScriptVersionResolver) Engine() TypeScriptEngine
Engine returns the compiler this resolver falls back to.
func (*TypeScriptVersionResolver) Resolve ¶
func (resolver *TypeScriptVersionResolver) Resolve(configPath string) (TypeScriptVersion, error)
Resolve returns the compiler for the project whose tsconfig lives at configPath.
func (*TypeScriptVersionResolver) ResolveProjects ¶
func (resolver *TypeScriptVersionResolver) ResolveProjects(discovery TypeScriptDiscovery) ([]TypeScriptProjectVersion, error)
ResolveProjects resolves the compiler of every discovered project, in the order the discovery reported them. One unreadable install fails the whole batch: a repository indexed with a version Kivgraph could not determine would produce facts whose confidence nobody can audit.
type TypeScriptVersionSource ¶
type TypeScriptVersionSource string
TypeScriptVersionSource records where the compiler version came from. The order of resolution is local, then workspace, then the pinned fallback, as required by LUQUE-0605.
const ( // TypeScriptVersionLocal is a compiler installed inside the project's own // package. TypeScriptVersionLocal TypeScriptVersionSource = "local" // TypeScriptVersionWorkspace is a compiler hoisted to an ancestor of the // project but still inside the repository. TypeScriptVersionWorkspace TypeScriptVersionSource = "workspace" // TypeScriptVersionPinned is the compiler Kivgraph ships, used when the // project has none installed. TypeScriptVersionPinned TypeScriptVersionSource = "pinned" )
type TypeScriptWorkspaceDeclaration ¶
type TypeScriptWorkspaceDeclaration struct {
ManifestPath string
Format TypeScriptWorkspaceFormat
Patterns []string
}
TypeScriptWorkspaceDeclaration describes package glob patterns declared by a package.json or pnpm-workspace.yaml file.
type TypeScriptWorkspaceFormat ¶
type TypeScriptWorkspaceFormat string
TypeScriptWorkspaceFormat identifies the file format that declares a workspace.
const ( TypeScriptWorkspacePackageJSON TypeScriptWorkspaceFormat = "package.json" TypeScriptWorkspacePNPM TypeScriptWorkspaceFormat = "pnpm-workspace.yaml" )