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:
@@ -130,13 +130,13 @@ class TestL2SharedChecker:
|
||||
class TestL1CacheManagerStorage:
|
||||
"""Tests for cache storage operations."""
|
||||
|
||||
def test_put_and_get_by_content_hash(self, manager, temp_dir):
|
||||
def test_put_and_get_by_cid(self, manager, temp_dir):
|
||||
"""Can store and retrieve by content hash."""
|
||||
test_file = create_test_file(temp_dir / "input.txt", "hello world")
|
||||
|
||||
cached = manager.put(test_file, node_type="test")
|
||||
|
||||
retrieved_path = manager.get_by_content_hash(cached.content_hash)
|
||||
retrieved_path = manager.get_by_cid(cached.cid)
|
||||
assert retrieved_path is not None
|
||||
assert retrieved_path.read_text() == "hello world"
|
||||
|
||||
@@ -155,7 +155,7 @@ class TestL1CacheManagerStorage:
|
||||
|
||||
cached = manager.put(test_file, node_type="test")
|
||||
|
||||
assert manager.has_content(cached.content_hash) is True
|
||||
assert manager.has_content(cached.cid) is True
|
||||
assert manager.has_content("nonexistent") is False
|
||||
|
||||
def test_list_all(self, manager, temp_dir):
|
||||
@@ -177,7 +177,7 @@ class TestL1CacheManagerStorage:
|
||||
cached1 = manager.put(f1, node_type="test")
|
||||
cached2 = manager.put(f2, node_type="test")
|
||||
|
||||
assert cached1.content_hash == cached2.content_hash
|
||||
assert cached1.cid == cached2.cid
|
||||
assert len(manager.list_all()) == 1
|
||||
|
||||
|
||||
@@ -193,14 +193,14 @@ class TestL1CacheManagerActivities:
|
||||
output_cached = manager.put(output_file, node_type="effect")
|
||||
|
||||
activity = manager.record_simple_activity(
|
||||
input_hashes=[input_cached.content_hash],
|
||||
output_hash=output_cached.content_hash,
|
||||
input_hashes=[input_cached.cid],
|
||||
output_cid=output_cached.cid,
|
||||
run_id="run-001",
|
||||
)
|
||||
|
||||
assert activity.activity_id == "run-001"
|
||||
assert input_cached.content_hash in activity.input_ids
|
||||
assert activity.output_id == output_cached.content_hash
|
||||
assert input_cached.cid in activity.input_ids
|
||||
assert activity.output_id == output_cached.cid
|
||||
|
||||
def test_list_activities(self, manager, temp_dir):
|
||||
"""Can list all activities."""
|
||||
@@ -209,7 +209,7 @@ class TestL1CacheManagerActivities:
|
||||
out = create_test_file(temp_dir / f"out{i}.txt", f"output{i}")
|
||||
inp_c = manager.put(inp, node_type="source")
|
||||
out_c = manager.put(out, node_type="effect")
|
||||
manager.record_simple_activity([inp_c.content_hash], out_c.content_hash)
|
||||
manager.record_simple_activity([inp_c.cid], out_c.cid)
|
||||
|
||||
activities = manager.list_activities()
|
||||
assert len(activities) == 3
|
||||
@@ -225,10 +225,10 @@ class TestL1CacheManagerActivities:
|
||||
out1_c = manager.put(out1, node_type="effect")
|
||||
out2_c = manager.put(out2, node_type="effect")
|
||||
|
||||
manager.record_simple_activity([input_cached.content_hash], out1_c.content_hash, "run1")
|
||||
manager.record_simple_activity([input_cached.content_hash], out2_c.content_hash, "run2")
|
||||
manager.record_simple_activity([input_cached.cid], out1_c.cid, "run1")
|
||||
manager.record_simple_activity([input_cached.cid], out2_c.cid, "run2")
|
||||
|
||||
found = manager.find_activities_by_inputs([input_cached.content_hash])
|
||||
found = manager.find_activities_by_inputs([input_cached.cid])
|
||||
assert len(found) == 2
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ class TestL1CacheManagerDeletionRules:
|
||||
test_file = create_test_file(temp_dir / "orphan.txt", "orphan")
|
||||
cached = manager.put(test_file, node_type="test")
|
||||
|
||||
can_delete, reason = manager.can_delete(cached.content_hash)
|
||||
can_delete, reason = manager.can_delete(cached.cid)
|
||||
assert can_delete is True
|
||||
|
||||
def test_cannot_delete_activity_input(self, manager, temp_dir):
|
||||
@@ -252,11 +252,11 @@ class TestL1CacheManagerDeletionRules:
|
||||
output_cached = manager.put(output_file, node_type="effect")
|
||||
|
||||
manager.record_simple_activity(
|
||||
[input_cached.content_hash],
|
||||
output_cached.content_hash,
|
||||
[input_cached.cid],
|
||||
output_cached.cid,
|
||||
)
|
||||
|
||||
can_delete, reason = manager.can_delete(input_cached.content_hash)
|
||||
can_delete, reason = manager.can_delete(input_cached.cid)
|
||||
assert can_delete is False
|
||||
assert "input" in reason.lower()
|
||||
|
||||
@@ -269,11 +269,11 @@ class TestL1CacheManagerDeletionRules:
|
||||
output_cached = manager.put(output_file, node_type="effect")
|
||||
|
||||
manager.record_simple_activity(
|
||||
[input_cached.content_hash],
|
||||
output_cached.content_hash,
|
||||
[input_cached.cid],
|
||||
output_cached.cid,
|
||||
)
|
||||
|
||||
can_delete, reason = manager.can_delete(output_cached.content_hash)
|
||||
can_delete, reason = manager.can_delete(output_cached.cid)
|
||||
assert can_delete is False
|
||||
assert "output" in reason.lower()
|
||||
|
||||
@@ -283,9 +283,9 @@ class TestL1CacheManagerDeletionRules:
|
||||
cached = manager.put(test_file, node_type="test")
|
||||
|
||||
# Mark as pinned (published)
|
||||
manager.pin(cached.content_hash, reason="published")
|
||||
manager.pin(cached.cid, reason="published")
|
||||
|
||||
can_delete, reason = manager.can_delete(cached.content_hash)
|
||||
can_delete, reason = manager.can_delete(cached.cid)
|
||||
assert can_delete is False
|
||||
assert "pinned" in reason
|
||||
|
||||
@@ -294,10 +294,10 @@ class TestL1CacheManagerDeletionRules:
|
||||
test_file = create_test_file(temp_dir / "orphan.txt", "orphan")
|
||||
cached = manager.put(test_file, node_type="test")
|
||||
|
||||
success, msg = manager.delete_by_content_hash(cached.content_hash)
|
||||
success, msg = manager.delete_by_cid(cached.cid)
|
||||
|
||||
assert success is True
|
||||
assert manager.has_content(cached.content_hash) is False
|
||||
assert manager.has_content(cached.cid) is False
|
||||
|
||||
def test_delete_protected_item_fails(self, manager, temp_dir):
|
||||
"""Cannot delete protected items."""
|
||||
@@ -308,14 +308,14 @@ class TestL1CacheManagerDeletionRules:
|
||||
output_cached = manager.put(output_file, node_type="effect")
|
||||
|
||||
manager.record_simple_activity(
|
||||
[input_cached.content_hash],
|
||||
output_cached.content_hash,
|
||||
[input_cached.cid],
|
||||
output_cached.cid,
|
||||
)
|
||||
|
||||
success, msg = manager.delete_by_content_hash(input_cached.content_hash)
|
||||
success, msg = manager.delete_by_cid(input_cached.cid)
|
||||
|
||||
assert success is False
|
||||
assert manager.has_content(input_cached.content_hash) is True
|
||||
assert manager.has_content(input_cached.cid) is True
|
||||
|
||||
|
||||
class TestL1CacheManagerActivityDiscard:
|
||||
@@ -330,8 +330,8 @@ class TestL1CacheManagerActivityDiscard:
|
||||
output_cached = manager.put(output_file, node_type="effect")
|
||||
|
||||
activity = manager.record_simple_activity(
|
||||
[input_cached.content_hash],
|
||||
output_cached.content_hash,
|
||||
[input_cached.cid],
|
||||
output_cached.cid,
|
||||
"run-001",
|
||||
)
|
||||
|
||||
@@ -347,13 +347,13 @@ class TestL1CacheManagerActivityDiscard:
|
||||
output_cached = manager.put(output_file, node_type="effect")
|
||||
|
||||
manager.record_simple_activity(
|
||||
[input_cached.content_hash],
|
||||
output_cached.content_hash,
|
||||
[input_cached.cid],
|
||||
output_cached.cid,
|
||||
"run-001",
|
||||
)
|
||||
|
||||
# Mark output as pinned (published)
|
||||
manager.pin(output_cached.content_hash, reason="published")
|
||||
manager.pin(output_cached.cid, reason="published")
|
||||
|
||||
can_discard, reason = manager.can_discard_activity("run-001")
|
||||
assert can_discard is False
|
||||
@@ -368,8 +368,8 @@ class TestL1CacheManagerActivityDiscard:
|
||||
output_cached = manager.put(output_file, node_type="effect")
|
||||
|
||||
manager.record_simple_activity(
|
||||
[input_cached.content_hash],
|
||||
output_cached.content_hash,
|
||||
[input_cached.cid],
|
||||
output_cached.cid,
|
||||
"run-001",
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user