mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[GH-ISSUE #360] [Design Proposal] SQL-backed snapshot catalog and resource lifecycle #90
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#90
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @guozy18 on GitHub (Oct 12, 2026).
Original GitHub issue: https://github.com/kvcache-ai/AgentENV/issues/360
Affected component
Cross-cutting / other: snapshot metadata, shared layer dependencies, snapshot/volume content retention, sandbox resource ownership, and artifact reclamation.
Problem statement
At high snapshot churn, the system needs a consistent answer to four questions: what is required to run a snapshot, which artifacts other snapshots still reference, which consumers are still using them, and when their bytes may be deleted.
Public records, aliases, shared artifact storage, runtime inputs, and local files have different coordination and lifetime boundaries. Moving metadata to SQL should establish a transactional boundary for publication and resource protection. It should not add a database request to every VM operation or retain every completed use and full historical manifest indefinitely.
Use case
Training and evaluation workloads create many independent snapshots with potentially little reuse. A typical flow creates a sandbox, executes work, captures a result, forks or pauses/resumes, and eventually deletes the sandbox and snapshot.
Publication, startup, and reclamation must continue while users are active. Capacity validation must include a workload where successive starts use different snapshots; a high hit rate on a shared template is not an adequate baseline.
Current behavior and workarounds
OSS/POSIX repositories store public records, alias bindings, runtime manifests, and artifact bytes. The resolver materializes runtime inputs, and local guards or leases retain the associated files and work. Local caches reduce byte reads, but do not themselves form a shared ledger of snapshot dependencies and active consumers.
Publication, lookup, local ownership, and physical cleanup therefore have different coordination boundaries. Independent directory scans and local references do not provide a single transaction that commits a public result together with every managed dependency that must remain available.
Desired behavior
Proposed approach
Architecture before and after
Catalog is an in-process Rust library, backed by PostgreSQL for a cluster and SQLite for a single-node deployment. It records fixed content, immutable layer dependencies, chain heads, and shared usage holds. These are required facts, not a predetermined table count. Snapshot S and shared usage period H retain their business and lifecycle semantics.
SQL stores each layer UUID's predecessor once and records only the heads retained by each content entry. Walking predecessors reconstructs dependencies without rereading all OSS manifests on every GC round. For snapshots
[A,B,C]and[A,B,D]that inherit the same A/B artifacts:An unfamiliar independent chain still requires full initial registration. Prefix reuse comes from inheriting the same sealed artifacts or reusing a valid conversion result; it is not guaranteed for independent OCI cold conversions.
Reuse and unify AENV's existing file UUID rather than adding another prefix UUID. A sealed UUID must have fixed content and predecessor. OCI conversion, memory, compaction, and publication transformations must satisfy that contract. The digest identifies the final published bytes; because the UUID is embedded in the file, distinct UUIDs must not be assumed to share a full-file digest. Producers and transformations should return the final digest/size descriptor for upload and P2P reuse, avoiding redundant digest scans. Known-digest reads must not accept an unrelated UUID match.
The complete immutable runtime manifest may remain in OSS, with
manifest_refand the necessary query, admission, dependency, and lifecycle information in SQL. Snapshot and volume share content-retention mechanisms while keeping their business records and admission rules. A mutable volume ID is not an immutable backing identity: a backing switch must preserve old users' fixed inputs. The precise table representation remains to be specified in #361.Layer chains do not replace retention rules for VM state, startup artifacts, or registry publication roots. Asynchronous startup attachments need an explicit description/dependency handoff boundary rather than an in-place mutation of an allegedly immutable main manifest.
An H may be shared by a prepared entry, multiple VMs, captured artifacts, and paused state. It is neither one central row per VM nor a time-expiring runtime lease. Actual bytes remain in object storage, shared filesystems, registries, and local storage.
Retirement does not immediately revoke reuse of an already protected prepared entry. Aliases remain bound to their original identity. Whether a deleted UUID or physical key may ever be reused remains a design decision in #364: either account for terminal-record retention, or establish isolation from delayed DELETE requests before enabling reuse-dependent GC.
Design workstreams
Initial data conversion and later SQL/application upgrades are separate workflows. A background tool can convert old records gradually, while a compatibility repository coordinates per-snapshot handover and retains existing consumers. Subsequent releases use schema expansion, a period of common-format operation, explicit activation of new data formats, and eventual contraction.
Smallest verifiable implementation sequence
Each step has an observable result; this does not make partially connected production consumers safe. Implementation tasks should follow these end-to-end boundaries rather than splitting solely by table.
Acceptance criteria
Compatibility and operational impact
Database connection configuration, a complete codec, and compatibility checks become part of Catalog setup. New cold preparation, publication, and metadata queries require the database. Existing valid local inputs continue to work during a database interruption; pending releases remain durable.
The complete runtime description must preserve existing backend, virtualization, startup, drive, volume, and extension semantics. Asynchronous publication work must use the same identity arbitration and conditional updates as foreground operations. Additional artifact dependencies become visible atomically with their descriptions.
Initial import preserves existing snapshot/hold identities and exact artifact locations where compatible. Layers with missing, conflicting, or context-inconsistent UUIDs require explicit compatibility handling; existing consumers keep their original files, and normalization must not rewrite them in place. Once SQL owns a snapshot, it cannot fall back to an older file record. Later upgrades keep schema availability separate from the data formats that deployed binaries are allowed to produce and required to read.
Alternatives considered
Non-goals
This proposal does not add a separate Catalog service, store VM/memory/disk bytes in SQL, redesign scheduling or volume mount/read-write ownership, replace the byte cache, or expand the CLI. Sharing content retention does not require a universal resource table or a second layer identity. It does not make runtime live migration a prerequisite for schema upgrades.
Contribution
I can provide more design details.
Pre-submission checklist