validate

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package validate walks the parent edges of a tapes store and reports DAG integrity problems: cycles (which cause Ancestry() to loop forever) and dangling parent references (parents pointing at nodes that no longer exist).

The check is intentionally structured around ParentRef tuples rather than full merkle.Node values so it stays cheap on large stores — the ent driver implementation projects only the hash and parent_hash columns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dangling

type Dangling struct {
	Hash       string
	ParentHash string
}

Dangling is a node whose parent_hash points to a missing node.

type Report

type Report struct {
	// TotalNodes is the number of nodes considered by the check.
	TotalNodes int
	// Roots is the number of nodes whose parent_hash is NULL.
	Roots int
	// Cycles holds one entry per detected cycle. Each entry lists the
	// hashes that form the cycle, in traversal order, with the repeated
	// hash appended at the end so callers can render it as A → B → A.
	Cycles [][]string
	// Dangling holds nodes whose parent_hash points at a hash not present
	// in the store.
	Dangling []Dangling
}

Report summarizes the outcome of a store integrity check.

func Check

func Check(ctx context.Context, lister storage.ParentRefLister) (Report, error)

Check runs the integrity check against the given lister and returns a Report. The lister must return every (hash, parent_hash) tuple in the store; it is expected to be implemented via storage.ParentRefLister.

func CheckRefs

func CheckRefs(refs []storage.ParentRef) Report

CheckRefs runs the integrity check against an already-materialized slice of parent refs. Split from Check so the pure graph analysis is independently testable without a storage driver.

func (Report) OK

func (r Report) OK() bool

OK reports whether the store passed every check.

Jump to

Keyboard shortcuts

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