The repository layer is the low-level data exchange boundary for KEG data.
pkg/keg/repository.go defines Repository, the core interface used by
high-level keg operations.
It covers:
- node lifecycle (next/list/move/delete)
- node data (content/meta/stats)
- indexes (
dex/*) - keg config (
kegfile) - optional capabilities (files/images/snapshots)
Commands and services rely on this contract instead of directly accessing files.
Primary implementations in pkg/keg:
repo_memory.gofor in-memory repositoriesrepo_filesystem.gofor filesystem-backed repositoriesrepo_memory_snapshots.gofor in-memory revision historyrepo_filesystem_snapshots.gofor on-disk snapshot storage
NewKegFromTarget in pkg/keg/keg.go selects an implementation from a
kegurl.Target scheme (memory or file).
pkg/keg/keg.go wraps the repository with a stateful API:
Initfor keg bootstrap (config + zero node + indexes)Create,Read,Move,Deletefor node lifecycle- index and query-oriented operations over dex data
This separation allows command code to stay simple while storage behavior stays centralized and testable.
RepositorySnapshots is implemented for both shipped repositories:
MemoryRepostores fully materialized revisions in memory for tests and fast local flowsFsRepostores per-node history undersnapshots/withindex.json, revision content blobs, and revision metadata/stats files
This powers tap and keg snapshot/history commands plus archive
import/export workflows. Archive import reuses source node IDs and overwrites
matching nodes in the target keg.
- storage can change without rewriting command handlers
- tests can run against memory repos for fast behavior checks
- file-backed behavior can be exercised independently in filesystem tests