chore(storage): bound build retention, caches and test resources

Track build ownership, qualified pins and bounded cache/log lifecycles. Move Vite fixtures to a job-owned server helper and preserve private outputs outside Git.
This commit is contained in:
DCCONSTRUCTIONS
2026-10-29 09:09:58 +03:00
parent 55f64f195b
commit 70ef3f9f1c
119 changed files with 3128 additions and 331 deletions
+25 -3
View File
@@ -3,6 +3,7 @@ from __future__ import annotations
import json
import logging
import os
import stat
from datetime import UTC, datetime
from logging.handlers import RotatingFileHandler
from pathlib import Path
@@ -116,7 +117,7 @@ class ScannerDiagnosticJsonFormatter(logging.Formatter):
for field in _EXTRA_FIELDS:
value = getattr(record, field, None)
if value is not None and isinstance(value, (str, int, bool)):
document[field] = value
document[field] = value[:256] if isinstance(value, str) else value
if record.exc_info is not None:
exception_type, _exception, traceback = record.exc_info
if exception_type is not None:
@@ -137,7 +138,28 @@ class ScannerDiagnosticJsonFormatter(logging.Formatter):
for value in properties
):
document["write_characteristic_properties"] = sorted(set(properties))
return json.dumps(document, ensure_ascii=False, separators=(",", ":"))
payload = json.dumps(document, ensure_ascii=False, separators=(",", ":"))
# An oversized extra field cannot bypass the rotation budget in one record.
for field in reversed(_EXTRA_FIELDS):
if len(payload.encode("utf-8")) <= 16384:
break
document.pop(field, None)
document["fields_omitted"] = True
payload = json.dumps(document, ensure_ascii=False, separators=(",", ":"))
return payload
class PrivateRotatingFileHandler(RotatingFileHandler):
def _open(self):
descriptor = os.open(
self.baseFilename, os.O_WRONLY | os.O_CREAT | os.O_APPEND | os.O_NOFOLLOW, 0o600
)
info = os.fstat(descriptor)
if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1 or info.st_uid != os.getuid():
os.close(descriptor)
raise ValueError("Invalid diagnostic journal")
os.fchmod(descriptor, 0o600)
return os.fdopen(descriptor, "a", encoding=self.encoding, errors=self.errors)
def configure_scanner_diagnostics(logs_root: Path) -> Path:
@@ -151,7 +173,7 @@ def configure_scanner_diagnostics(logs_root: Path) -> Path:
if getattr(handler, _HANDLER_MARKER, None) == str(target):
return target
handler = RotatingFileHandler(
handler = PrivateRotatingFileHandler(
target,
maxBytes=5 * 1024 * 1024,
backupCount=5,