Skip to content

Commit 586e589

Browse files
authored
fix(manifest): preserve shipped config digest (#86)
Preserve the exact shipped YAML bytes during artifact regeneration so manifest identity matches the public CLI. Includes a regression test and refreshed manifest digests.
1 parent 44d755f commit 586e589

4 files changed

Lines changed: 26 additions & 8 deletions

File tree

data/processed/richer_sample/run_manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"tool_version": "1.2.0",
33
"demo_id": "window",
44
"input_digest": "sha256:e8771283a83c146a2cffce5fe316c1408200b6d7717cbb6d074334aa891672f3",
5-
"config_digest": "sha256:6bffef106b0fcdb04d54e3aac8fe5b4b800bf228ad03fe988861486691c76f65",
5+
"config_digest": "sha256:e7cb0264262cc997edf8f6b987dc0466098f23150d0c6204fb5fd7c245df1d7d",
66
"artifact_schema_versions": {
77
"run_manifest": "run-manifest/v1",
88
"telemetry_summary": "telemetry-summary/v1"

data/processed/run_manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"tool_version": "1.2.0",
33
"demo_id": "window",
44
"input_digest": "sha256:c08795a6a3c361a3339414c5a8441fb74c58f027c96931dbdc0da28560e132ac",
5-
"config_digest": "sha256:a6107a2a732e8f4bf03572e9e86697ce1daa0eed1871724d0b44ec677f924b37",
5+
"config_digest": "sha256:b02cfeb006b05c52f075c3aa454045cd4c46b25be5576e37e184c3f02bf9328b",
66
"artifact_schema_versions": {
77
"run_manifest": "run-manifest/v1",
88
"telemetry_summary": "telemetry-summary/v1"

scripts/regenerate_artifacts.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
from types import SimpleNamespace
1414
from typing import Any
1515

16-
import yaml
17-
1816

1917
REPO_ROOT = Path(__file__).resolve().parents[1]
2018
SRC_ROOT = REPO_ROOT / "src"
@@ -285,10 +283,7 @@ def _run_window_pipeline_job(
285283
shutil.copytree(REPO_ROOT / "data" / "raw", generated_repo / "data" / "raw")
286284

287285
generated_config_path = generated_config_dir / config_path.name
288-
generated_config_path.write_text(
289-
yaml.safe_dump(config, sort_keys=False),
290-
encoding="utf-8",
291-
)
286+
shutil.copyfile(config_path, generated_config_path)
292287
with _pushd(generated_repo), redirect_stdout(io.StringIO()):
293288
run_command(SimpleNamespace(config=str(generated_config_path)))
294289

tests/test_artifact_regeneration_check.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
from __future__ import annotations
22

33
import importlib.util
4+
import json
45
import sys
56
from pathlib import Path
67

8+
from telemetry_lab.manifest import digest_files
9+
710

811
REPO_ROOT = Path(__file__).resolve().parents[1]
912
SCRIPT_PATH = REPO_ROOT / "scripts" / "regenerate_artifacts.py"
@@ -37,6 +40,26 @@ def test_regenerate_artifacts_check_matches_committed_outputs() -> None:
3740
assert exit_code == 0
3841

3942

43+
def test_window_regeneration_hashes_the_shipped_config_bytes(tmp_path) -> None:
44+
script = _load_regeneration_script()
45+
config_path = REPO_ROOT / "configs" / "default.yaml"
46+
47+
artifacts = script._run_window_pipeline_job(
48+
tmp_path,
49+
config_path=config_path,
50+
committed_root=REPO_ROOT / "data" / "processed",
51+
)
52+
manifest = json.loads(
53+
(artifacts.generated_root / "run_manifest.json").read_text(
54+
encoding="utf-8"
55+
)
56+
)
57+
58+
assert manifest["config_digest"] == digest_files(
59+
{config_path.name: config_path}
60+
)
61+
62+
4063
def test_regenerate_artifacts_reports_mismatched_strict_artifact(tmp_path) -> None:
4164
script = _load_regeneration_script()
4265
committed_root = tmp_path / "committed"

0 commit comments

Comments
 (0)