PrefixFreeValidator

org.sigilaris.core.assembly.PrefixFreeValidator

Utility for validating prefix-free properties of encoded table prefixes.

Prefix-free requirement (from ADR-0009):

  • All table prefixes must be distinct (no two tables share the same prefix)
  • No prefix may be a prefix of another (strict prefix-free property)

This validator operates at the byte level after encoding with length-prefix format: length(segment_bytes) ++ segment_bytes ++ 0x00

Attributes

Source
PrefixFreeValidator.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

final case class IdenticalPrefixes(prefix: ByteVector, count: Int) extends ValidationResult

Indicates two or more table prefixes encode to identical byte vectors.

Indicates two or more table prefixes encode to identical byte vectors.

Value parameters

count

the number of occurrences

prefix

the duplicated byte vector

Attributes

Source
PrefixFreeValidator.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class PrefixCollision(prefix1: ByteVector, prefix2: ByteVector) extends ValidationResult

Indicates one encoded prefix is a strict prefix of another.

Indicates one encoded prefix is a strict prefix of another.

Value parameters

prefix1

the shorter prefix that is a prefix of prefix2

prefix2

the longer prefix that starts with prefix1

Attributes

Source
PrefixFreeValidator.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case object Valid extends ValidationResult

Indicates all prefixes are distinct and no prefix is a strict prefix of another.

Indicates all prefixes are distinct and no prefix is a strict prefix of another.

Attributes

Source
PrefixFreeValidator.scala
Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
Valid.type
sealed trait ValidationResult

Result of prefix-free validation, indicating whether a set of prefixes satisfies the prefix-free property.

Result of prefix-free validation, indicating whether a set of prefixes satisfies the prefix-free property.

Attributes

Source
PrefixFreeValidator.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Value members

Concrete methods

inline def collectSchemaPrefixes[Path <: Tuple, Schema <: Tuple](acc: List[ByteVector]): List[ByteVector]

Collects encoded table prefixes from a schema tuple at compile time using inline expansion.

Collects encoded table prefixes from a schema tuple at compile time using inline expansion.

Type parameters

Path

the mount path tuple

Schema

the schema tuple of org.sigilaris.core.application.state.Entry types

Value parameters

acc

accumulator for collected prefixes (defaults to empty)

Attributes

Returns

list of encoded byte-vector prefixes, one per entry in the schema

Source
PrefixFreeValidator.scala
def exampleValidation(): Unit

Example demonstrating how to validate a composed schema at runtime.

Example demonstrating how to validate a composed schema at runtime.

Attributes

Source
PrefixFreeValidator.scala
def formatResult(result: ValidationResult): String

Formats a ValidationResult into a human-readable string for logging or test output.

Formats a ValidationResult into a human-readable string for logging or test output.

Value parameters

result

the validation result to format

Attributes

Returns

a multi-line string describing the outcome

Source
PrefixFreeValidator.scala
def isStrictPrefix(a: ByteVector, b: ByteVector): Boolean

Checks whether byte vector a is a strict prefix of b (i.e. a is shorter and b starts with a).

Checks whether byte vector a is a strict prefix of b (i.e. a is shorter and b starts with a).

Value parameters

a

the candidate prefix

b

the byte vector to check against

Attributes

Returns

true if a is a strict prefix of b

Source
PrefixFreeValidator.scala
def validate(prefixes: List[ByteVector]): ValidationResult

Validates that all prefixes in the given list are prefix-free.

Validates that all prefixes in the given list are prefix-free.

Value parameters

prefixes

the list of encoded table prefixes to validate

Attributes

Returns

Valid if all prefixes are distinct and prefix-free, PrefixCollision if one prefix is a strict prefix of another, or IdenticalPrefixes if duplicates exist

Source
PrefixFreeValidator.scala
inline def validateSchema[Path <: Tuple, Schema <: Tuple]: ValidationResult

Validates that the given schema produces prefix-free table prefixes when mounted at the given path.

Validates that the given schema produces prefix-free table prefixes when mounted at the given path.

This is a runtime check that can be used in tests or during module assembly.

Type parameters

Path

the mount path tuple

Schema

the schema tuple of org.sigilaris.core.application.state.Entry types

Attributes

Returns

Valid if all entry prefixes are prefix-free, or an error result otherwise

Source
PrefixFreeValidator.scala
def validateWithNames(prefixes: List[(String, ByteVector)]): ValidationResult

Validates prefixes with human-readable names for better error reporting.

Validates prefixes with human-readable names for better error reporting.

Value parameters

prefixes

list of (name, encoded prefix) pairs; the names are used only for diagnostics

Attributes

Returns

the ValidationResult for the underlying byte vectors

Source
PrefixFreeValidator.scala
def wouldCollide(newPrefix: ByteVector, existing: List[ByteVector]): Boolean

Checks whether a new prefix would collide (be identical to or a strict prefix of) any existing prefix.

Checks whether a new prefix would collide (be identical to or a strict prefix of) any existing prefix.

Value parameters

existing

the list of already-registered prefixes

newPrefix

the candidate prefix to test

Attributes

Returns

true if newPrefix conflicts with any element in existing

Source
PrefixFreeValidator.scala