package graph

const SchemaVersionV1 = "v1"

// NodeKind identifies the type of graph node.
type NodeKind string

const (
	NodeKindFile       NodeKind = "file"
	NodeKindPackage    NodeKind = "package"
	NodeKindSymbol     NodeKind = "symbol"
	NodeKindCodeChunk  NodeKind = "code_chunk"
	NodeKindRepository NodeKind = "repository"
	NodeKindSnapshot   NodeKind = "snapshot"
	NodeKindDocFile    NodeKind = "doc_file"
	NodeKindDocSection NodeKind = "doc_section"
	NodeKindDocChunk   NodeKind = "doc_chunk"
)

// EdgeKind identifies the type of graph edge.
type EdgeKind string

const (
	EdgeKindContains EdgeKind = "contains"
	EdgeKindImports  EdgeKind = "imports"
	EdgeKindCalls    EdgeKind = "calls"
	EdgeKindDefines  EdgeKind = "defines"
	EdgeKindHasChunk EdgeKind = "has_chunk"
	EdgeKindHasSection EdgeKind = "has_section"
	EdgeKindDocuments EdgeKind = "documents"
)

// Node represents a node in the code graph IR.
type Node struct {
	ID       string            `json:"id"`
	Kind     NodeKind          `json:"kind"`
	Name     string            `json:"name"`
	Language string            `json:"language,omitempty"`
	Path     string            `json:"path,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

// Edge represents a relationship between graph nodes.
type Edge struct {
	ID       string            `json:"id"`
	Kind     EdgeKind          `json:"kind"`
	SourceID string            `json:"source_id"`
	TargetID string            `json:"target_id"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

// Artifact is the portable graph artifact emitted by the parser service.
type Artifact struct {
	SchemaVersion string `json:"schema_version"`
	RepoID        string `json:"repo_id"`
	CommitSHA     string `json:"commit_sha"`
	SnapshotID    string `json:"snapshot_id"`
	Nodes         []Node `json:"nodes"`
	Edges         []Edge `json:"edges"`
}
