Rename content_hash/output_hash to cid throughout

Refactor to use IPFS CID as the primary content identifier:
- Update database schema: content_hash -> cid, output_hash -> output_cid
- Update all services, routers, and tasks to use cid terminology
- Update HTML templates to display CID instead of hash
- Update cache_manager parameter names
- Update README documentation

This completes the transition to CID-only content addressing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gilesb
2026-01-12 08:02:44 +00:00
parent 494a2a8650
commit 92d26b2b72
22 changed files with 981 additions and 988 deletions

View File

@@ -99,7 +99,7 @@ class RunStatus(BaseModel):
output_name: Optional[str] = None
created_at: Optional[str] = None
completed_at: Optional[str] = None
output_hash: Optional[str] = None
output_cid: Optional[str] = None
username: Optional[str] = None
provenance_cid: Optional[str] = None
celery_task_id: Optional[str] = None
@@ -244,13 +244,13 @@ async def get_run(
# Build artifacts list from output and inputs
artifacts = []
output_media_type = None
if run.get("output_hash"):
if run.get("output_cid"):
# Detect media type using magic bytes
output_hash = run["output_hash"]
output_cid = run["output_cid"]
media_type = None
try:
from ..services.run_service import detect_media_type
cache_path = get_cache_manager().get_by_content_hash(output_hash)
cache_path = get_cache_manager().get_by_cid(output_cid)
if cache_path and cache_path.exists():
simple_type = detect_media_type(cache_path)
media_type = type_to_mime(simple_type)
@@ -258,7 +258,7 @@ async def get_run(
except Exception:
pass
artifacts.append({
"hash": output_hash,
"hash": output_cid,
"step_name": "Output",
"media_type": media_type or "application/octet-stream",
})
@@ -271,7 +271,7 @@ async def get_run(
for i, input_hash in enumerate(run["inputs"]):
media_type = None
try:
cache_path = cache_manager.get_by_content_hash(input_hash)
cache_path = cache_manager.get_by_cid(input_hash)
if cache_path and cache_path.exists():
simple_type = detect_media_type(cache_path)
media_type = type_to_mime(simple_type)
@@ -393,9 +393,9 @@ async def list_runs(
for run in runs:
# Add output media info
if run.get("output_hash"):
if run.get("output_cid"):
try:
cache_path = cache_manager.get_by_content_hash(run["output_hash"])
cache_path = cache_manager.get_by_cid(run["output_cid"])
if cache_path and cache_path.exists():
simple_type = detect_media_type(cache_path)
run["output_media_type"] = type_to_mime(simple_type)
@@ -409,7 +409,7 @@ async def list_runs(
for input_hash in inputs[:3]:
preview = {"hash": input_hash, "media_type": None}
try:
cache_path = cache_manager.get_by_content_hash(input_hash)
cache_path = cache_manager.get_by_cid(input_hash)
if cache_path and cache_path.exists():
simple_type = detect_media_type(cache_path)
preview["media_type"] = type_to_mime(simple_type)
@@ -756,8 +756,8 @@ async def publish_run(
raise HTTPException(404, "Run not found")
# Check if run has output
output_hash = run.get("output_hash")
if not output_hash:
output_cid = run.get("output_cid")
if not output_cid:
error = "Run has no output to publish"
if wants_html(request):
return HTMLResponse(f'<span class="text-red-400">{error}</span>')
@@ -766,7 +766,7 @@ async def publish_run(
# Use cache service to publish the output
cache_service = CacheService(database, get_cache_manager())
ipfs_cid, error = await cache_service.publish_to_l2(
content_hash=output_hash,
cid=output_cid,
actor_id=ctx.actor_id,
l2_server=ctx.l2_server,
auth_token=request.cookies.get("auth_token"),
@@ -780,4 +780,4 @@ async def publish_run(
if wants_html(request):
return HTMLResponse(f'<span class="text-green-400">Shared: {ipfs_cid[:16]}...</span>')
return {"ipfs_cid": ipfs_cid, "output_hash": output_hash, "published": True}
return {"ipfs_cid": ipfs_cid, "output_cid": output_cid, "published": True}