Bound semantic worker storage and add verified evidence closeout

This commit is contained in:
DCCONSTRUCTIONS
2026-11-07 18:53:56 +03:00
parent 43148a8769
commit ab5766df6a
15 changed files with 1201 additions and 40 deletions
+24 -2
View File
@@ -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