snapshot

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package snapshot exports and imports the codegrapher index as INGR files.

Layout inside the output directory (default: codegraph/):

.ingitdb.yaml                     root inGitDB config
README.md                         generated summary
nodes/nodes.ingr                  node records
edges/edges.ingr                  edge records
files/files.ingr                  file records
project_metadata/project_metadata.ingr  metadata records

The directory is a valid inGitDB database (`ingitdb validate` exits 0). Records are sorted by primary key for byte-determinism. Volatile fields (updated_at, indexed_at, modified_at) are excluded. Two exports of the same code tree are byte-identical.

Uses github.com/ingr-io/ingr-go (official MIT library, pure Go).

Index

Constants

View Source
const DefaultSnapshotDir = "codegraph"

DefaultSnapshotDir is the default output/input directory for snapshots, relative to the project root (the path passed to export/import).

Variables

This section is empty.

Functions

func CompressGzip

func CompressGzip(data []byte) ([]byte, error)

CompressGzip returns the deterministic gzip encoding of data. The gzip header carries no name and a zero mtime, so re-compressing identical input yields identical bytes.

func CompressZstd

func CompressZstd(data []byte) ([]byte, error)

CompressZstd returns the zstd encoding of data at the default level. zstd is deterministic for a fixed input and level.

func Export

func Export(dbPath, outDir, projectRoot string) error

Export writes INGR snapshot files for the index to outDir, structured as a valid inGitDB database. projectRoot is used to detect the git remote for the README; pass "" to fall back to the outDir parent name. outDir is created if it does not exist.

func ExportScoped

func ExportScoped(stores map[scope.Scope]*store.Store, baseOutDir, ref string) (Manifest, []RecordsetSize, error)

ExportScoped writes each scope's graph under baseOutDir/{lang}/{version}/ as compressed-only INGR recordsets (*.ingr.zst + *.ingr.gz, no plain .ingr) and writes baseOutDir/manifest.json describing ref. It returns the manifest and a per-recordset size report.

func Import

func Import(dbPath, inDir string) error

Import reads INGR snapshot files from inDir and initializes the store at dbPath, replacing any existing data. Run sync afterward to reconcile drift.

Types

type Counts

type Counts struct {
	Nodes        int `json:"nodes"`
	Files        int `json:"files"`
	Edges        int `json:"edges"`
	Coverage     int `json:"coverage,omitempty"`
	NodeCoverage int `json:"node_coverage,omitempty"`
}

Counts are the row counts of a scope, used for tree labels and progress.

type Manifest

type Manifest struct {
	Ref    string          `json:"ref"`
	Scopes []ManifestScope `json:"scopes"`
}

Manifest describes the scopes available for one ref of a repo. It is written as codegraph/manifest.json and served by the DB server / read by the viewer.

type ManifestScope

type ManifestScope struct {
	Language  string `json:"language"`
	Version   string `json:"version"`
	Key       string `json:"key"`
	Counts    Counts `json:"counts"`
	IndexedAt string `json:"indexed_at,omitempty"` // RFC3339
}

ManifestScope is one (language, version) partition entry.

type RecordsetSize

type RecordsetSize struct {
	Scope    string
	Name     string
	Original int
	Zstd     int
	Gzip     int
}

RecordsetSize reports the original and compressed byte sizes of one exported recordset, for the dogfood size report.

Jump to

Keyboard shortcuts

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