feat(generator): эталонный мир в git и import по умолчанию

- Зачем:
  - менти собирал мир генерацией (минуты и десятки минут CPU); теперь
    готовый трёхдневный мир загружается импортом за ~2 минуты, и числа
    у всех менти совпадают число-в-число (issue #3).
- Что:
  - артефакт data/startup_history/reference-world.json.xz в git:
    3 модельных дня daily-wave, ~850 МБ JSON → 32 МБ xz;
  - чтение и запись артефакта понимают .xz потоково (lzma); пустое поле
    artifact_path в пульте и make startup-history-import читают эталон;
  - длительность профиля daily-wave стала 3d — в тон эталонному миру;
  - предпроверка чистого стенда ставит зависимости генератора через uv;
    экспорт и импорт разведены отдельными переменными Makefile;
  - доки и runbook обновлены; новые контрактные тесты: xz round-trip
    и дефолтные пути артефакта.
- Проверка:
  - make test (210 + 31) и make lint зелёные; импорт на чистом стенде
    за 2м03с, manifest совпал (280437 событий), Superset-проверка
    зелёная; независимое ревью — APPROVED.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-22 18:49:02 +03:00
co-authored by Claude Fable 5
parent b87dde79b7
commit 10ee1a1cb6
21 changed files with 165 additions and 35 deletions
@@ -335,12 +335,13 @@ def target_dag_trigger_error(dag_id: str, dag_model) -> str | None:
def default_artifact_path(operation: str) -> str:
"""Возвращает путь артефакта по умолчанию в общем томе data."""
filename = (
"startup-history-import.json"
if operation == "import"
else "startup-history.json"
)
return str(Path(AIRFLOW_DATA_DIR) / filename)
if operation == "import":
return str(
Path(AIRFLOW_DATA_DIR)
/ "startup_history"
/ "reference-world.json.xz"
)
return str(Path(AIRFLOW_DATA_DIR) / "startup-history.json")
@contextmanager
@@ -47,7 +47,7 @@ PROFILES = {
},
),
"daily-wave": LaunchProfile(
duration="2d",
duration="3d",
env={
"GEN_SEED": "4242",
"GEN_MODEL_T0": "2026-01-01T00:00:00+00:00",
@@ -5,6 +5,7 @@ from __future__ import annotations
import argparse
import hashlib
import json
import lzma
import logging
from copy import deepcopy
from datetime import datetime, timezone
@@ -353,6 +354,15 @@ def write_startup_history_artifact(path: str | Path, artifact: dict) -> None:
"""Пишет артефакт в JSON-файл."""
target = Path(path)
target.parent.mkdir(parents=True, exist_ok=True)
if target.suffix == ".xz":
with lzma.open(
target,
"wt",
encoding="utf-8",
preset=9 | lzma.PRESET_EXTREME,
) as output:
json.dump(artifact, output, ensure_ascii=True, indent=2)
return
target.write_text(
json.dumps(artifact, ensure_ascii=True, indent=2),
encoding="utf-8",
@@ -361,7 +371,11 @@ def write_startup_history_artifact(path: str | Path, artifact: dict) -> None:
def load_startup_history_artifact(path: str | Path) -> dict:
"""Читает артефакт из JSON-файла."""
return json.loads(Path(path).read_text(encoding="utf-8"))
source = Path(path)
if source.suffix == ".xz":
with lzma.open(source, "rt", encoding="utf-8") as input_file:
return json.load(input_file)
return json.loads(source.read_text(encoding="utf-8"))
def validate_startup_history_artifact(