Files
OpenOPC/opc/layer3_agent/prompt_harness/deltas.py
T
2026-07-01 17:56:31 +08:00

21 lines
676 B
Python

"""Artifact delta helpers."""
from __future__ import annotations
from typing import Iterable
from .types import RuntimeArtifact
def changed_artifacts(
artifacts: Iterable[RuntimeArtifact],
previous_hashes: dict[str, str] | None = None,
) -> list[tuple[RuntimeArtifact, bool]]:
previous = dict(previous_hashes or {})
changed: list[tuple[RuntimeArtifact, bool]] = []
for artifact in artifacts:
content_hash = str(artifact.metadata.get("content_hash", "") or "")
is_delta = bool(previous.get(artifact.artifact_type)) and previous.get(artifact.artifact_type) != content_hash
changed.append((artifact, is_delta))
return changed