Bound semantic worker storage and add verified evidence closeout
This commit is contained in:
@@ -272,8 +272,11 @@ def review_index(root):
|
||||
|
||||
|
||||
class Store:
|
||||
def __init__(self, root, *, quota=20 * 1024**3, reserve=12 * 1024**3):
|
||||
def __init__(
|
||||
self, root, *, quota=20 * 1024**3, reserve=12 * 1024**3, research_quota=8 * 1024**3
|
||||
):
|
||||
self.root, self.quota, self.reserve = Path(root), quota, reserve
|
||||
self.research_quota = research_quota
|
||||
self.root.mkdir(parents=True, exist_ok=True)
|
||||
for folder in ("inbox", "datasets", "work", "sources", "logs"):
|
||||
(self.root / folder).mkdir(exist_ok=True)
|
||||
@@ -286,7 +289,26 @@ class Store:
|
||||
self.db.commit()
|
||||
|
||||
def capacity(self, additional):
|
||||
used = sum(p.stat().st_size for p in self.root.rglob("*") if p.is_file())
|
||||
# Historical research has its own finite allowance. It must not consume
|
||||
# the dataset admission budget, nor disappear from all accounting.
|
||||
research_roots = {
|
||||
"experiments",
|
||||
"agent-reviews",
|
||||
"audits",
|
||||
"archives",
|
||||
"reviews",
|
||||
"verification",
|
||||
}
|
||||
used = research = 0
|
||||
for p in self.root.rglob("*"):
|
||||
if not p.is_file():
|
||||
continue
|
||||
if p.relative_to(self.root).parts[0] in research_roots:
|
||||
research += p.stat().st_size
|
||||
else:
|
||||
used += p.stat().st_size
|
||||
if research > self.research_quota:
|
||||
raise RuntimeError("Worker research storage quota reached; close completed experiments")
|
||||
if (
|
||||
used + additional > self.quota
|
||||
or shutil.disk_usage(self.root).free < self.reserve + additional
|
||||
|
||||
Reference in New Issue
Block a user