refactor(realism): enforce synthetic_files 64KB cap at the repo

The orchestrator worker clipped last_body at write time, but the repo
didn't enforce. A future caller that forgot the clip would write the
full body. Move the clip to record_synthetic_file and
update_synthetic_file via SYNTHETIC_FILE_BODY_LIMIT in
decnet/web/db/models/realism.py. Worker now passes the full body and
trusts the repo. Tests retargeted to assert repo enforcement.
This commit is contained in:
2026-04-27 17:37:36 -04:00
parent b86129e35e
commit 7e9bc6d49a
4 changed files with 33 additions and 39 deletions

View File

@@ -3335,6 +3335,9 @@ class SQLModelRepository(BaseRepository):
# ------------------------------------------------------------ realism
async def record_synthetic_file(self, data: dict[str, Any]) -> str:
from decnet.web.db.models.realism import SYNTHETIC_FILE_BODY_LIMIT
if "last_body" in data and data["last_body"] is not None:
data = {**data, "last_body": data["last_body"][:SYNTHETIC_FILE_BODY_LIMIT]}
async with self._session() as session:
row = SyntheticFile(**data)
session.add(row)
@@ -3345,6 +3348,9 @@ class SQLModelRepository(BaseRepository):
async def update_synthetic_file(
self, row_uuid: str, data: dict[str, Any],
) -> None:
from decnet.web.db.models.realism import SYNTHETIC_FILE_BODY_LIMIT
if "last_body" in data and data["last_body"] is not None:
data = {**data, "last_body": data["last_body"][:SYNTHETIC_FILE_BODY_LIMIT]}
async with self._session() as session:
stmt = (
update(SyntheticFile)