fastmcp/.github/agentic/flows/agentic_stack.py
nate nowack 429b1f7b87
Compare triage records as JSON and file maintainer reproductions as decisions (#6562)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 22:57:27 +00:00

32 lines
941 B
Python

from __future__ import annotations
import hashlib
import json
import subprocess
from pathlib import Path
def git(repository: Path, *arguments: str) -> str:
return subprocess.check_output(
["git", *arguments], cwd=repository, text=True
).strip()
def same_json(stored: object, value: object) -> bool:
"""Whether `value` equals `stored` once both are serialized as JSON.
Anything read back from the Prefect API (artifact data, run parameters) has
been through JSON, so an int dict key or a tuple in the in-memory value would
never compare equal to its own round-trip.
"""
def canonical(item: object) -> str:
return json.dumps(item, sort_keys=True, separators=(",", ":"), default=str)
return canonical(stored) == canonical(value)
def digest(value: object) -> str:
return hashlib.sha256(
json.dumps(value, sort_keys=True, separators=(",", ":")).encode()
).hexdigest()