core

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: LGPL-2.1 Imports: 5 Imported by: 0

README

mod/core

mod/core defines the shared value objects used by the rest of the runtime. It has no storage, network, or configuration side effects. Packages depend on it for stable names for hashes, tree entries, artifact descriptors, version metadata, diagnostics inputs, and small formatting helpers.

Place in the Runtime

flowchart LR
  source["source"] --> core["mod/core"]
  archive["archive"] --> core
  overlay["overlay"] --> core
  storage["storage"] --> core
  server["server"] --> core
  core --> hashes["hashes and value objects"]

mod/core sits below the domain packages. It keeps the common vocabulary in one place so source, archive, overlay, storage, and server do not copy wire-neutral structs.

Responsibilities

  • Represent BLAKE3-24 content hashes and provide deterministic formatting.
  • Represent version trees as path, mode, blob hash, and size entries.
  • Describe artifacts, listeners, source metadata, and publish inputs shared across packages.
  • Keep semver and raw-version value checks close to the core model.
  • Provide small time and byte helpers used by generated API responses.

Contracts

  • Hashes are fixed-size values. The zero hash is a sentinel and should not be stored as real content.
  • Tree entries are canonical data, not filesystem paths. Callers must validate archive paths before creating them.
  • Version metadata is the storage-facing shape. Public API packages should project it into response-specific DTOs.
  • Comments on fields document non-obvious invariants such as sequence ordering, verification timestamps, and blocked Go module zip state.

Important Files

  • hash.go: BLAKE3-24 hashing, parsing, and formatting.
  • tree.go, staged.go: canonical tree and staged publish DTOs.
  • version.go: version metadata, deletion state, Go overlay block state, upstream sequence fields.
  • artifact.go: artifact kind, listener binding, digest metadata.
  • time.go, bytes.go: formatting helpers used by API and HTML builders.

Usage Notes

Keep this package dependency-light. It is safe for low-level packages to import mod/core, but adding dependencies from core back to storage, server, config, or source would create cycles and blur the shared model boundary.

Documentation

Index

Constants

View Source
const (
	// HashSize is the truncated BLAKE3 digest length in bytes (24 = 192 bits); it defines HashObj and key size.
	HashSize = 24

	// PebbleKeyFormat marks the storage key schema (tag + 24-byte hash) and is written to metadata.
	PebbleKeyFormat = "tag_hash24"

	// ModeFile is the tree entry mode for a regular file.
	ModeFile = "file"
	// ModeSymlink is the tree entry mode for a symbolic link.
	ModeSymlink = "symlink"

	// DefaultFormat is the default artifact format version.
	DefaultFormat = 1
)
View Source
const (
	ListingModeUndecided = ""
	ListingModeReleases  = "releases"
	ListingModeTags      = "tags"
)

Git listing mode is sticky: the first successful non-empty listing chooses it, and a later conflict freezes key updates instead of switching automatically.

View Source
const TimeFormat = "2006-01-02T15:04:05.000Z07:00"

TimeFormat is the canonical RFC3339 format with milliseconds for UTC timestamps.

Variables

This section is empty.

Functions

func FormatTime

func FormatTime(ts time.Time) string

FormatTime serializes a timestamp in the canonical UTC TimeFormat.

func ParseTime

func ParseTime(text string) (time.Time, error)

ParseTime parses a timestamp in TimeFormat.

func VerifyHash

func VerifyHash(expectedObj HashObj, dataArr []byte) error

VerifyHash checks integrity by comparing the buffer digest with the expected hash.

Types

type ArtifactDigestObj

type ArtifactDigestObj struct {
	BodyHash   HashObj
	BodySha256 []byte
	BodySha1   []byte
	SizeBytes  uint64
	ETag       string
}

ArtifactDigestObj is the built artifact identity used by RegisterArtifact and computed by storage.

type ArtifactKeyObj

type ArtifactKeyObj struct {
	MaterializerID string
	ArtifactKind   string
	ListenerID     string
	Key            string
	Version        string
}

ArtifactKeyObj identifies an artifact for storage addressing by materializer, kind, listener, key, and version.

type ArtifactObj

type ArtifactObj struct {
	MaterializerID string
	ArtifactKind   string
	ListenerID     string
	Key            string
	Version        string
	ETag           string
	BodyHash       HashObj
	BodySha256     []byte
	BodySha1       []byte
	SizeBytes      uint64
	FormatVersion  uint32
	FilePath       string
	DegradedReason string
}

ArtifactObj is a built edge artifact: body, validators, disk path, and stale/degraded flags for server output.

type DetectionObj

type DetectionObj struct {
	IsGo         bool
	IsComposer   bool
	Conflict     bool
	EvidenceJSON string

	// GoZipBlocked means the version tree cannot become a valid Go module zip
	// because of invalid paths, fold collisions, symlinks, or hard module-zip limits.
	GoZipBlocked bool
	// GoZipBlockReason is a short English reason; empty means not blocked.
	GoZipBlockReason string
}

DetectionObj is the source-type detection result for Go modules and Composer packages, including evidence.

type FeedEventObj

type FeedEventObj struct {
	Key          string
	Version      string
	EventTS      time.Time
	TreeHash     HashObj
	BodyHash     HashObj
	ReleaseNotes string
	FirstPublish bool
}

FeedEventObj is a publish history event for Atom feeds: version, time, hashes, current release notes, and whether this is the first publication.

type HashObj

type HashObj [HashSize]byte

HashObj is a fixed-size truncated BLAKE3 digest; it is comparable and usable as a map key.

func HashBytes

func HashBytes(dataArr []byte) HashObj

HashBytes returns the BLAKE3 digest of an arbitrary buffer.

func HashFromBytes

func HashFromBytes(dataArr []byte) (HashObj, error)

HashFromBytes restores HashObj from raw bytes and requires exactly HashSize bytes.

func HashFromHasher

func HashFromHasher(hasherObj *blake3.Hasher) HashObj

HashFromHasher extracts the truncated digest from an already-filled streaming hasher.

func (HashObj) BytesCopy

func (obj HashObj) BytesCopy() []byte

BytesCopy returns an independent copy of digest bytes.

func (HashObj) Hex

func (obj HashObj) Hex() string

Hex returns the digest as hex.

func (HashObj) IsZero

func (obj HashObj) IsZero() bool

IsZero reports whether the digest is empty and uninitialized.

type InputEntryObj

type InputEntryObj struct {
	Path      string
	Mode      string
	Content   []byte
	BlobHash  HashObj
	SizeBytes uint64
}

InputEntryObj is an input publication tree entry with in-memory content for ingestion.

type IntegrityReportObj

type IntegrityReportObj struct {
	Errors []string
}

IntegrityReportObj is a storage integrity-check result: the errors found during the scan.

type KeySourceObj

type KeySourceObj struct {
	Key         string
	URL         string
	Class       string
	WebAddr     string
	YggAddr     string
	OriginURL   string
	ListingMode string
	BoundTS     time.Time
}

KeySourceObj is the durable binding between key and source: source URL/class, learned public brother addresses, and advertised upstream origin. It survives restarts; web/ygg/origin stay empty until first contact. ListingMode pins the git listing strategy (empty, "releases", or "tags"); it changes only via SetKeyListingMode.

type PublishObj

type PublishObj struct {
	Key             string
	Version         string
	SourceHash      HashObj
	SourceSizeBytes uint64
	UpstreamSeq     int64 // precomputed source position; 0 lets publish assign max+1
	Entries         []InputEntryObj
	Detection       DetectionObj
	RewriteBlobs    []HashObj
	Artifacts       []ArtifactObj
	UpstreamDeleted bool
	EventType       string
	EventMessage    string
	ReleaseNotes    string
	HealPending     bool
	UpstreamRef     string    // source commit SHA; empty means unknown
	VerifiedTS      time.Time // deep verification timestamp to publish; zero leaves it unset
}

PublishObj requests version publication with entry bodies in memory, including tree, detection, artifacts, and history event parameters.

type PublishResultObj

type PublishResultObj struct {
	Key        string
	Version    string
	TreeHash   HashObj
	Published  bool
	Skipped    bool
	Historical string
}

PublishResultObj reports whether a version was written or skipped and the final TreeHash.

type StagedBlobObj

type StagedBlobObj struct {
	BlobHash  HashObj
	SizeBytes uint64
	FilePath  string
}

StagedBlobObj is a prepared publication blob whose body is stored in a temporary file on disk.

type StagedEntryObj

type StagedEntryObj struct {
	Path      string
	Mode      string
	BlobHash  HashObj
	SizeBytes uint64
}

StagedEntryObj is a prepared publication tree entry: path, mode, and blob hash reference.

type StagedPublishObj

type StagedPublishObj struct {
	Key             string
	Version         string
	SourceHash      HashObj
	SourceSizeBytes uint64
	UpstreamSeq     int64 // precomputed source position; 0 lets publish assign max+1
	Entries         []StagedEntryObj
	Blobs           []StagedBlobObj
	Detection       DetectionObj
	RewriteBlobs    []HashObj
	Artifacts       []ArtifactObj
	UpstreamDeleted bool
	EventType       string
	EventMessage    string
	ReleaseNotes    string
	HealPending     bool
	UpstreamRef     string    // source commit SHA; empty means unknown
	VerifiedTS      time.Time // deep verification timestamp to publish; zero leaves it unset
}

StagedPublishObj is a publication with bodies staged to disk, describing tree and blobs by file references so archive content does not stay in RAM.

type TreeEntryObj

type TreeEntryObj struct {
	Path      string
	Mode      string
	SizeBytes uint64
	BlobHash  HashObj
}

TreeEntryObj is a persisted version-tree entry: path, mode, and blob hash reference without body.

type VersionObj

type VersionObj struct {
	Key             string
	Version         string
	SourceHash      HashObj
	SourceSizeBytes uint64
	TreeHash        HashObj
	IngestTS        time.Time
	UpstreamSeq     int64 // source listing position: larger is newer; 0 means unset
	UpstreamDeleted bool
	ReplacedBy      string
	ReleaseNotes    string
	HealPending     bool
	UpstreamRef     string    // commit SHA from source refs advertisement; empty means unknown (brother/legacy)
	VerifiedTS      time.Time // last deep verification time; zero means never verified
}

VersionObj is a persisted mirror version: source/tree hashes, ingest timestamp, lifecycle flags, and neighbor links.

Jump to

Keyboard shortcuts

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