graphartifact

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 22 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

Index

Constants

View Source
const (
	DefaultMaxNodes           = 500_000
	DefaultMaxEdges           = 2_000_000
	HardMaxNodes              = 2_000_000
	HardMaxEdges              = 10_000_000
	DefaultMaxPathBytes       = 4_096
	DefaultMaxIdentifierBytes = 16_384
)

Variables

View Source
var ErrInvalidArtifact = errors.New("invalid graph artifact")
View Source
var ErrUnsupportedVersion = errors.New("unsupported graph artifact version")

Functions

func Identity

func Identity(node Node) (string, error)

func IdentityV2

func IdentityV2(p *graphv2.Producer, repository, sourceID, occurrence string) (string, error)

IdentityV2 scopes original identity and occurrence by public repository and producer. A repeated qualified name or source ID never collapses declarations.

func MarshalV2

func MarshalV2(a *graphv2.Artifact, limits Limits) ([]byte, error)

func ParseV2

func ParseV2(data []byte, limits Limits) (*graphv2.Artifact, error)

ParseV2 is deliberately separate from the v1 storage/publication reader. No protobuf objects or extension JSON trees are allocated before wire bounds.

func SemanticHashV2

func SemanticHashV2(a *graphv2.Artifact, limits Limits) ([]byte, error)

func SourceOffset

func SourceOffset(source string, p *graphv2.Position) (int, error)

SourceOffset resolves a zero-based UTF-16 position against exact UTF-8 source. It rejects columns inside a surrogate pair, beyond a line, and line-only data. CR is retained before LF, matching both CodeGraph producer implementations.

func Validate

func Validate(artifact Artifact, limits Limits) error

func ValidateV2

func ValidateV2(a *graphv2.Artifact, limits Limits) error

Types

type Analyzer

type Analyzer struct{ Name, Version string }

type Artifact

type Artifact struct {
	SchemaVersion uint32
	Analyzer      Analyzer
	RepositoryID  int64
	Commit        string
	ContentHash   []byte
	Nodes         []Node
	Edges         []Edge
}

func FromSCIP

func FromSCIP(repository SCIPRepository, occurrences []scipgraph.Occurrence, relationships []scipgraph.Relationship) (Artifact, error)

func Parse

func Parse(data []byte, limits Limits) (Artifact, error)

type Edge

type Edge struct {
	SourceUID, TargetUID, Path, ResolutionReason string
	Kind                                         EdgeKind
	Range                                        Range
	Confidence                                   float32
}

type EdgeKind

type EdgeKind uint8
const (
	EdgeUnspecified EdgeKind = iota
	EdgeContains
	EdgeImports
	EdgeReferences
	EdgeCalls
	EdgeExtends
	EdgeImplements
	EdgeExports
	EdgeTypeOf
	EdgeReturns
	EdgeInstantiates
	EdgeOverrides
	EdgeDecorates
	EdgeNavigates
)

type Limits

type Limits struct {
	MaxNodes, MaxEdges, MaxPathBytes, MaxIdentifierBytes int
	// Additional v2 bounds, applied before protobuf or extension JSON decoding.
	MaxArtifactBytes, MaxFiles, MaxUnresolved, MaxDiagnostics int
	MaxMetadataBytes, MaxExtensionBytes, MaxCollectionItems   int
}

type Manifest

type Manifest struct {
	RepositoryID, UploadID int64
	Commit, Source         string
	SchemaVersion          uint32
	ContentHash            []byte
}

type Node

type Node struct {
	UID, Path, Language, SymbolKind, QualifiedName, Signature, SCIPSymbol string
	Kind                                                                  NodeKind
	Range                                                                 Range
}

type NodeKind

type NodeKind uint8
const (
	NodeUnspecified NodeKind = iota
	NodeRepository
	NodeFile
	NodeSymbol
)

type Range

type Range struct{ StartLine, StartCharacter, EndLine, EndCharacter int32 }

type Relationship

type Relationship struct {
	Kind                     EdgeKind
	Name, Outgoing, Incoming string
}

Relationship is the common wire, API-name and display contract. Every relation is directed source -> target; Incoming labels describe the reverse view.

func ParseRelationship

func ParseRelationship(name string) (Relationship, bool)

ParseRelationship validates an API or producer name without aliases.

func RelationshipFromWire

func RelationshipFromWire(kind graphv2.EdgeKind) (Relationship, bool)

RelationshipFromWire checks the full enum width before narrowing.

func Relationships

func Relationships() []Relationship

Relationships returns a copy so callers cannot mutate the validation registry.

func (Relationship) WireKind

func (r Relationship) WireKind() graphv2.EdgeKind

type SCIPRepository

type SCIPRepository struct {
	ID     int64
	Commit string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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