Inline the single-use artifact version path builder

Keep version archival behavior and streaming assertions unchanged while removing its one-call path wrapper. This preserves function-count headroom when the selected acceptance evidence and owner-restart fixes land together.
This commit is contained in:
Ouroboros 2026-09-18 00:38:32 +03:00
parent 09355b9e72
commit 167a1645d6
2 changed files with 5 additions and 9 deletions

View file

@ -1271,20 +1271,16 @@ def registered_task_artifact(drive_root: Any, task_id: str, name: str) -> Option
return dict(row) if isinstance(row, dict) else None
def _artifact_versions_dir(drive_root: pathlib.Path, task_id: str, artifact_name: str) -> pathlib.Path:
safe_name = pathlib.Path(artifact_name).name.replace("/", "_").replace("\\", "_")
if not safe_name or safe_name in {".", ".."}:
safe_name = "artifact"
return pathlib.Path(drive_root) / "task_results" / _ARTIFACT_VERSIONS_DIR / validate_task_id(task_id) / safe_name
def _archive_previous_artifact_version(drive_root: pathlib.Path, task_id: str, dest: pathlib.Path, source: pathlib.Path) -> None:
if not dest.is_file() or not source.is_file():
return
previous = stream_artifact_file(dest)
if previous == stream_artifact_file(source):
return
version_dir = _artifact_versions_dir(drive_root, task_id, dest.name)
safe_name = pathlib.Path(dest.name).name.replace("/", "_").replace("\\", "_")
if not safe_name or safe_name in {".", ".."}:
safe_name = "artifact"
version_dir = pathlib.Path(drive_root) / "task_results" / _ARTIFACT_VERSIONS_DIR / validate_task_id(task_id) / safe_name
version_dir.mkdir(parents=True, exist_ok=True)
suffix = dest.suffix
stem = dest.name[: -len(suffix)] if suffix else dest.name

View file

@ -41,7 +41,7 @@ def test_large_copy_version_and_directory_are_streamed(tmp_path, monkeypatch):
with large.open("ab") as handle:
handle.write(b"new version")
artifacts.copy_file_to_task_artifacts(ctx, large)
versions = list(artifacts._artifact_versions_dir(ctx.drive_root, ctx.task_id, copied["name"]).iterdir())
versions = list((ctx.drive_root / "task_results" / "artifact_versions" / ctx.task_id / copied["name"]).iterdir())
assert len(versions) == 1
assert artifacts.stream_artifact_file(versions[0]) == expected
records = artifacts.copy_directory_to_task_artifacts(ctx, source)