agent-coherence 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. agent_coherence-0.1.0/PKG-INFO +60 -0
  2. agent_coherence-0.1.0/README.md +38 -0
  3. agent_coherence-0.1.0/pyproject.toml +46 -0
  4. agent_coherence-0.1.0/setup.cfg +4 -0
  5. agent_coherence-0.1.0/src/agent_coherence.egg-info/PKG-INFO +60 -0
  6. agent_coherence-0.1.0/src/agent_coherence.egg-info/SOURCES.txt +80 -0
  7. agent_coherence-0.1.0/src/agent_coherence.egg-info/dependency_links.txt +1 -0
  8. agent_coherence-0.1.0/src/agent_coherence.egg-info/entry_points.txt +4 -0
  9. agent_coherence-0.1.0/src/agent_coherence.egg-info/requires.txt +4 -0
  10. agent_coherence-0.1.0/src/agent_coherence.egg-info/top_level.txt +1 -0
  11. agent_coherence-0.1.0/src/ccs/__init__.py +6 -0
  12. agent_coherence-0.1.0/src/ccs/adapters/__init__.py +16 -0
  13. agent_coherence-0.1.0/src/ccs/adapters/autogen.py +60 -0
  14. agent_coherence-0.1.0/src/ccs/adapters/base.py +136 -0
  15. agent_coherence-0.1.0/src/ccs/adapters/crewai.py +58 -0
  16. agent_coherence-0.1.0/src/ccs/adapters/langgraph.py +65 -0
  17. agent_coherence-0.1.0/src/ccs/agent/__init__.py +9 -0
  18. agent_coherence-0.1.0/src/ccs/agent/cache.py +63 -0
  19. agent_coherence-0.1.0/src/ccs/agent/runtime.py +151 -0
  20. agent_coherence-0.1.0/src/ccs/artifacts/__init__.py +24 -0
  21. agent_coherence-0.1.0/src/ccs/artifacts/diff_engine.py +82 -0
  22. agent_coherence-0.1.0/src/ccs/bus/__init__.py +8 -0
  23. agent_coherence-0.1.0/src/ccs/bus/event_bus.py +74 -0
  24. agent_coherence-0.1.0/src/ccs/cli/__init__.py +4 -0
  25. agent_coherence-0.1.0/src/ccs/cli/compare.py +57 -0
  26. agent_coherence-0.1.0/src/ccs/cli/simulate.py +70 -0
  27. agent_coherence-0.1.0/src/ccs/coordinator/__init__.py +5 -0
  28. agent_coherence-0.1.0/src/ccs/coordinator/registry.py +116 -0
  29. agent_coherence-0.1.0/src/ccs/coordinator/service.py +261 -0
  30. agent_coherence-0.1.0/src/ccs/core/__init__.py +20 -0
  31. agent_coherence-0.1.0/src/ccs/core/clock.py +31 -0
  32. agent_coherence-0.1.0/src/ccs/core/exceptions.py +32 -0
  33. agent_coherence-0.1.0/src/ccs/core/granularity.py +56 -0
  34. agent_coherence-0.1.0/src/ccs/core/invariants.py +40 -0
  35. agent_coherence-0.1.0/src/ccs/core/states.py +85 -0
  36. agent_coherence-0.1.0/src/ccs/core/types.py +68 -0
  37. agent_coherence-0.1.0/src/ccs/hardening/__init__.py +8 -0
  38. agent_coherence-0.1.0/src/ccs/hardening/architecture.py +236 -0
  39. agent_coherence-0.1.0/src/ccs/output/__init__.py +13 -0
  40. agent_coherence-0.1.0/src/ccs/output/report.py +107 -0
  41. agent_coherence-0.1.0/src/ccs/simulation/__init__.py +19 -0
  42. agent_coherence-0.1.0/src/ccs/simulation/aggregation.py +104 -0
  43. agent_coherence-0.1.0/src/ccs/simulation/bounds.py +22 -0
  44. agent_coherence-0.1.0/src/ccs/simulation/consistency.py +65 -0
  45. agent_coherence-0.1.0/src/ccs/simulation/engine.py +461 -0
  46. agent_coherence-0.1.0/src/ccs/simulation/metrics.py +105 -0
  47. agent_coherence-0.1.0/src/ccs/simulation/scenarios.py +328 -0
  48. agent_coherence-0.1.0/src/ccs/strategies/__init__.py +23 -0
  49. agent_coherence-0.1.0/src/ccs/strategies/access_count.py +47 -0
  50. agent_coherence-0.1.0/src/ccs/strategies/base.py +77 -0
  51. agent_coherence-0.1.0/src/ccs/strategies/broadcast.py +49 -0
  52. agent_coherence-0.1.0/src/ccs/strategies/eager.py +46 -0
  53. agent_coherence-0.1.0/src/ccs/strategies/lazy.py +37 -0
  54. agent_coherence-0.1.0/src/ccs/strategies/lease.py +57 -0
  55. agent_coherence-0.1.0/src/ccs/strategies/selector.py +48 -0
  56. agent_coherence-0.1.0/src/ccs/transport/__init__.py +5 -0
  57. agent_coherence-0.1.0/src/ccs/transport/network_sim.py +96 -0
  58. agent_coherence-0.1.0/tests/test_adapters.py +83 -0
  59. agent_coherence-0.1.0/tests/test_agent_cache.py +60 -0
  60. agent_coherence-0.1.0/tests/test_agent_runtime.py +98 -0
  61. agent_coherence-0.1.0/tests/test_aggregation.py +72 -0
  62. agent_coherence-0.1.0/tests/test_architecture.py +40 -0
  63. agent_coherence-0.1.0/tests/test_benchmark_fixtures.py +41 -0
  64. agent_coherence-0.1.0/tests/test_bounds.py +48 -0
  65. agent_coherence-0.1.0/tests/test_cli.py +104 -0
  66. agent_coherence-0.1.0/tests/test_clock.py +29 -0
  67. agent_coherence-0.1.0/tests/test_consistency.py +52 -0
  68. agent_coherence-0.1.0/tests/test_coordinator.py +181 -0
  69. agent_coherence-0.1.0/tests/test_demo_script.py +34 -0
  70. agent_coherence-0.1.0/tests/test_diff_engine.py +55 -0
  71. agent_coherence-0.1.0/tests/test_engine.py +137 -0
  72. agent_coherence-0.1.0/tests/test_event_bus.py +70 -0
  73. agent_coherence-0.1.0/tests/test_granularity.py +28 -0
  74. agent_coherence-0.1.0/tests/test_invariants.py +35 -0
  75. agent_coherence-0.1.0/tests/test_network_sim.py +45 -0
  76. agent_coherence-0.1.0/tests/test_property_invariants.py +76 -0
  77. agent_coherence-0.1.0/tests/test_report.py +98 -0
  78. agent_coherence-0.1.0/tests/test_scenarios.py +115 -0
  79. agent_coherence-0.1.0/tests/test_states.py +80 -0
  80. agent_coherence-0.1.0/tests/test_strategies.py +136 -0
  81. agent_coherence-0.1.0/tests/test_transient_timeout.py +50 -0
  82. agent_coherence-0.1.0/tests/test_types.py +59 -0
@@ -0,0 +1,60 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-coherence
3
+ Version: 0.1.0
4
+ Summary: MESI-style artifact coherence for multi-agent AI systems
5
+ Author: Arbiter contributors
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/hipvlady/agent-coherence
8
+ Project-URL: Repository, https://github.com/hipvlady/agent-coherence
9
+ Project-URL: Issues, https://github.com/hipvlady/agent-coherence/issues
10
+ Keywords: multi-agent,llm,cache-coherence,mesi,token-efficiency,agents
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ Requires-Dist: pyyaml>=6.0
20
+ Provides-Extra: dev
21
+ Requires-Dist: pytest>=7.0; extra == "dev"
22
+
23
+ # agent-coherence — The Coherence Protocol for AI Agents
24
+
25
+ [![CI](https://github.com/hipvlady/agent-coherence/actions/workflows/ci.yml/badge.svg)](https://github.com/hipvlady/agent-coherence/actions/workflows/ci.yml)
26
+
27
+ `agent-coherence` implements MESI-style cache coherence for shared artifacts in multi-agent LLM systems, reducing synchronization token overhead and preventing stale-context coordination failures.
28
+
29
+ ## Install
30
+
31
+ ```bash
32
+ pip install agent-coherence
33
+ ```
34
+
35
+ ## Quick start
36
+
37
+ ```python
38
+ from ccs.simulation.engine import run_strategy_comparison
39
+ from ccs.simulation.scenarios import load_scenario
40
+
41
+ scenario = load_scenario("benchmarks/scenarios/planning_canonical.yaml")
42
+ report = run_strategy_comparison(scenario, strategies=["eager", "lazy"], runs=5, seed_start=20260305)
43
+ print(report.to_dict()["aggregated"])
44
+ ```
45
+
46
+ ## Reproduce benchmark artifacts
47
+
48
+ ```bash
49
+ bash reproduce.sh
50
+ ```
51
+
52
+ See [REPRODUCE.md](REPRODUCE.md) for full output mapping and baseline verification details.
53
+
54
+ ## Paper
55
+
56
+ Token Coherence: MESI-Style Cache Coherence for Shared Artifacts in Multi-Agent LLM Systems
57
+
58
+ ## License
59
+
60
+ Apache-2.0 (`LICENSE`)
@@ -0,0 +1,38 @@
1
+ # agent-coherence — The Coherence Protocol for AI Agents
2
+
3
+ [![CI](https://github.com/hipvlady/agent-coherence/actions/workflows/ci.yml/badge.svg)](https://github.com/hipvlady/agent-coherence/actions/workflows/ci.yml)
4
+
5
+ `agent-coherence` implements MESI-style cache coherence for shared artifacts in multi-agent LLM systems, reducing synchronization token overhead and preventing stale-context coordination failures.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pip install agent-coherence
11
+ ```
12
+
13
+ ## Quick start
14
+
15
+ ```python
16
+ from ccs.simulation.engine import run_strategy_comparison
17
+ from ccs.simulation.scenarios import load_scenario
18
+
19
+ scenario = load_scenario("benchmarks/scenarios/planning_canonical.yaml")
20
+ report = run_strategy_comparison(scenario, strategies=["eager", "lazy"], runs=5, seed_start=20260305)
21
+ print(report.to_dict()["aggregated"])
22
+ ```
23
+
24
+ ## Reproduce benchmark artifacts
25
+
26
+ ```bash
27
+ bash reproduce.sh
28
+ ```
29
+
30
+ See [REPRODUCE.md](REPRODUCE.md) for full output mapping and baseline verification details.
31
+
32
+ ## Paper
33
+
34
+ Token Coherence: MESI-Style Cache Coherence for Shared Artifacts in Multi-Agent LLM Systems
35
+
36
+ ## License
37
+
38
+ Apache-2.0 (`LICENSE`)
@@ -0,0 +1,46 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "agent-coherence"
7
+ version = "0.1.0"
8
+ description = "MESI-style artifact coherence for multi-agent AI systems"
9
+ readme = "README.md"
10
+ license = { text = "Apache-2.0" }
11
+ authors = [{ name = "Arbiter contributors" }]
12
+ keywords = ["multi-agent", "llm", "cache-coherence", "mesi", "token-efficiency", "agents"]
13
+ classifiers = [
14
+ "Development Status :: 3 - Alpha",
15
+ "Intended Audience :: Developers",
16
+ "Intended Audience :: Science/Research",
17
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.11",
20
+ ]
21
+ requires-python = ">=3.11"
22
+ dependencies = ["pyyaml>=6.0"]
23
+
24
+ [project.scripts]
25
+ ccs-simulate = "ccs.cli.simulate:main"
26
+ ccs-compare = "ccs.cli.compare:main"
27
+ ccs-check-architecture = "ccs.hardening.architecture:main"
28
+
29
+ [project.optional-dependencies]
30
+ dev = ["pytest>=7.0"]
31
+
32
+ [tool.pytest.ini_options]
33
+ testpaths = ["tests"]
34
+ pythonpath = ["src"]
35
+
36
+ [tool.setuptools]
37
+ package-dir = { "" = "src" }
38
+ license-files = []
39
+
40
+ [tool.setuptools.packages.find]
41
+ where = ["src"]
42
+
43
+ [project.urls]
44
+ Homepage = "https://github.com/hipvlady/agent-coherence"
45
+ Repository = "https://github.com/hipvlady/agent-coherence"
46
+ Issues = "https://github.com/hipvlady/agent-coherence/issues"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,60 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-coherence
3
+ Version: 0.1.0
4
+ Summary: MESI-style artifact coherence for multi-agent AI systems
5
+ Author: Arbiter contributors
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/hipvlady/agent-coherence
8
+ Project-URL: Repository, https://github.com/hipvlady/agent-coherence
9
+ Project-URL: Issues, https://github.com/hipvlady/agent-coherence/issues
10
+ Keywords: multi-agent,llm,cache-coherence,mesi,token-efficiency,agents
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ Requires-Dist: pyyaml>=6.0
20
+ Provides-Extra: dev
21
+ Requires-Dist: pytest>=7.0; extra == "dev"
22
+
23
+ # agent-coherence — The Coherence Protocol for AI Agents
24
+
25
+ [![CI](https://github.com/hipvlady/agent-coherence/actions/workflows/ci.yml/badge.svg)](https://github.com/hipvlady/agent-coherence/actions/workflows/ci.yml)
26
+
27
+ `agent-coherence` implements MESI-style cache coherence for shared artifacts in multi-agent LLM systems, reducing synchronization token overhead and preventing stale-context coordination failures.
28
+
29
+ ## Install
30
+
31
+ ```bash
32
+ pip install agent-coherence
33
+ ```
34
+
35
+ ## Quick start
36
+
37
+ ```python
38
+ from ccs.simulation.engine import run_strategy_comparison
39
+ from ccs.simulation.scenarios import load_scenario
40
+
41
+ scenario = load_scenario("benchmarks/scenarios/planning_canonical.yaml")
42
+ report = run_strategy_comparison(scenario, strategies=["eager", "lazy"], runs=5, seed_start=20260305)
43
+ print(report.to_dict()["aggregated"])
44
+ ```
45
+
46
+ ## Reproduce benchmark artifacts
47
+
48
+ ```bash
49
+ bash reproduce.sh
50
+ ```
51
+
52
+ See [REPRODUCE.md](REPRODUCE.md) for full output mapping and baseline verification details.
53
+
54
+ ## Paper
55
+
56
+ Token Coherence: MESI-Style Cache Coherence for Shared Artifacts in Multi-Agent LLM Systems
57
+
58
+ ## License
59
+
60
+ Apache-2.0 (`LICENSE`)
@@ -0,0 +1,80 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/agent_coherence.egg-info/PKG-INFO
4
+ src/agent_coherence.egg-info/SOURCES.txt
5
+ src/agent_coherence.egg-info/dependency_links.txt
6
+ src/agent_coherence.egg-info/entry_points.txt
7
+ src/agent_coherence.egg-info/requires.txt
8
+ src/agent_coherence.egg-info/top_level.txt
9
+ src/ccs/__init__.py
10
+ src/ccs/adapters/__init__.py
11
+ src/ccs/adapters/autogen.py
12
+ src/ccs/adapters/base.py
13
+ src/ccs/adapters/crewai.py
14
+ src/ccs/adapters/langgraph.py
15
+ src/ccs/agent/__init__.py
16
+ src/ccs/agent/cache.py
17
+ src/ccs/agent/runtime.py
18
+ src/ccs/artifacts/__init__.py
19
+ src/ccs/artifacts/diff_engine.py
20
+ src/ccs/bus/__init__.py
21
+ src/ccs/bus/event_bus.py
22
+ src/ccs/cli/__init__.py
23
+ src/ccs/cli/compare.py
24
+ src/ccs/cli/simulate.py
25
+ src/ccs/coordinator/__init__.py
26
+ src/ccs/coordinator/registry.py
27
+ src/ccs/coordinator/service.py
28
+ src/ccs/core/__init__.py
29
+ src/ccs/core/clock.py
30
+ src/ccs/core/exceptions.py
31
+ src/ccs/core/granularity.py
32
+ src/ccs/core/invariants.py
33
+ src/ccs/core/states.py
34
+ src/ccs/core/types.py
35
+ src/ccs/hardening/__init__.py
36
+ src/ccs/hardening/architecture.py
37
+ src/ccs/output/__init__.py
38
+ src/ccs/output/report.py
39
+ src/ccs/simulation/__init__.py
40
+ src/ccs/simulation/aggregation.py
41
+ src/ccs/simulation/bounds.py
42
+ src/ccs/simulation/consistency.py
43
+ src/ccs/simulation/engine.py
44
+ src/ccs/simulation/metrics.py
45
+ src/ccs/simulation/scenarios.py
46
+ src/ccs/strategies/__init__.py
47
+ src/ccs/strategies/access_count.py
48
+ src/ccs/strategies/base.py
49
+ src/ccs/strategies/broadcast.py
50
+ src/ccs/strategies/eager.py
51
+ src/ccs/strategies/lazy.py
52
+ src/ccs/strategies/lease.py
53
+ src/ccs/strategies/selector.py
54
+ src/ccs/transport/__init__.py
55
+ src/ccs/transport/network_sim.py
56
+ tests/test_adapters.py
57
+ tests/test_agent_cache.py
58
+ tests/test_agent_runtime.py
59
+ tests/test_aggregation.py
60
+ tests/test_architecture.py
61
+ tests/test_benchmark_fixtures.py
62
+ tests/test_bounds.py
63
+ tests/test_cli.py
64
+ tests/test_clock.py
65
+ tests/test_consistency.py
66
+ tests/test_coordinator.py
67
+ tests/test_demo_script.py
68
+ tests/test_diff_engine.py
69
+ tests/test_engine.py
70
+ tests/test_event_bus.py
71
+ tests/test_granularity.py
72
+ tests/test_invariants.py
73
+ tests/test_network_sim.py
74
+ tests/test_property_invariants.py
75
+ tests/test_report.py
76
+ tests/test_scenarios.py
77
+ tests/test_states.py
78
+ tests/test_strategies.py
79
+ tests/test_transient_timeout.py
80
+ tests/test_types.py
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ ccs-check-architecture = ccs.hardening.architecture:main
3
+ ccs-compare = ccs.cli.compare:main
4
+ ccs-simulate = ccs.cli.simulate:main
@@ -0,0 +1,4 @@
1
+ pyyaml>=6.0
2
+
3
+ [dev]
4
+ pytest>=7.0
@@ -0,0 +1,6 @@
1
+ # Copyright (c) 2026 Arbiter contributors.
2
+ # The Coherence Protocol for AI Agents
3
+
4
+ """agent-coherence core package."""
5
+
6
+ __version__ = "0.1.0"
@@ -0,0 +1,16 @@
1
+ # Copyright (c) 2026 Arbiter contributors.
2
+ # The Coherence Protocol for AI Agents
3
+
4
+ """Framework-facing integration adapters for CCS runtime."""
5
+
6
+ from .autogen import AutoGenAdapter
7
+ from .base import CoherenceAdapterCore
8
+ from .crewai import CrewAIAdapter
9
+ from .langgraph import LangGraphAdapter
10
+
11
+ __all__ = [
12
+ "CoherenceAdapterCore",
13
+ "LangGraphAdapter",
14
+ "CrewAIAdapter",
15
+ "AutoGenAdapter",
16
+ ]
@@ -0,0 +1,60 @@
1
+ # Copyright (c) 2026 Arbiter contributors.
2
+ # The Coherence Protocol for AI Agents
3
+
4
+ """AutoGen-oriented coherence adapter utilities."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from typing import Mapping
9
+ from uuid import UUID
10
+
11
+ from ccs.core.types import Artifact
12
+
13
+ from .base import CoherenceAdapterCore
14
+
15
+
16
+ class AutoGenAdapter:
17
+ """Adapter exposing per-turn hooks for AutoGen-like conversations."""
18
+
19
+ def __init__(self, *, strategy_name: str = "lazy", core: CoherenceAdapterCore | None = None) -> None:
20
+ self.core = core if core is not None else CoherenceAdapterCore(strategy_name=strategy_name)
21
+
22
+ def register_agent(self, name: str) -> UUID:
23
+ """Register one conversational agent identity."""
24
+ return self.core.register_agent(name)
25
+
26
+ def register_artifact(self, *, name: str, content: str, size_tokens: int | None = None) -> Artifact:
27
+ """Register shared artifact for conversation context."""
28
+ return self.core.register_artifact(name=name, content=content, size_tokens=size_tokens)
29
+
30
+ def pre_turn_context(
31
+ self,
32
+ *,
33
+ agent_name: str,
34
+ artifact_ids: list[UUID],
35
+ now_tick: int,
36
+ ) -> dict[UUID, str]:
37
+ """Fetch current context before an agent turn."""
38
+ return {
39
+ artifact_id: self.core.read(agent_name=agent_name, artifact_id=artifact_id, now_tick=now_tick).content
40
+ for artifact_id in artifact_ids
41
+ }
42
+
43
+ def post_turn_commit(
44
+ self,
45
+ *,
46
+ agent_name: str,
47
+ updates: Mapping[UUID, str],
48
+ now_tick: int,
49
+ ) -> dict[UUID, int]:
50
+ """Commit turn updates and return updated versions."""
51
+ versions: dict[UUID, int] = {}
52
+ for artifact_id, content in updates.items():
53
+ artifact = self.core.write(
54
+ agent_name=agent_name,
55
+ artifact_id=artifact_id,
56
+ content=content,
57
+ now_tick=now_tick,
58
+ )
59
+ versions[artifact_id] = artifact.version
60
+ return versions
@@ -0,0 +1,136 @@
1
+ # Copyright (c) 2026 Arbiter contributors.
2
+ # The Coherence Protocol for AI Agents
3
+
4
+ """Common adapter runtime that wires coordinator, agents, and event bus."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from dataclasses import dataclass
9
+ from uuid import NAMESPACE_URL, UUID, uuid5
10
+
11
+ from ccs.agent.runtime import AgentRuntime
12
+ from ccs.bus.event_bus import ArtifactUpdateEvent, InMemoryEventBus
13
+ from ccs.coordinator.registry import ArtifactRegistry
14
+ from ccs.coordinator.service import CoordinatorService
15
+ from ccs.core.types import Artifact, FetchResponse
16
+ from ccs.strategies.base import SyncStrategy
17
+ from ccs.strategies.selector import build_strategy
18
+
19
+
20
+ @dataclass(frozen=True)
21
+ class AgentBinding:
22
+ """Resolved identity/runtime tuple for an adapter-managed agent."""
23
+
24
+ name: str
25
+ agent_id: UUID
26
+ runtime: AgentRuntime
27
+
28
+
29
+ class CoherenceAdapterCore:
30
+ """Reusable cluster abstraction for framework adapters."""
31
+
32
+ def __init__(
33
+ self,
34
+ *,
35
+ strategy_name: str = "lazy",
36
+ lease_ttl_ticks: int = 300,
37
+ access_count_max_accesses: int = 100,
38
+ event_bus: InMemoryEventBus | None = None,
39
+ ) -> None:
40
+ self.registry = ArtifactRegistry()
41
+ self.coordinator = CoordinatorService(self.registry)
42
+ self.strategy: SyncStrategy = build_strategy(
43
+ strategy_name,
44
+ lease_ttl_ticks=lease_ttl_ticks,
45
+ access_count_max_accesses=access_count_max_accesses,
46
+ )
47
+ self.event_bus = event_bus if event_bus is not None else InMemoryEventBus()
48
+ self._agents_by_name: dict[str, AgentBinding] = {}
49
+
50
+ def register_agent(self, name: str) -> UUID:
51
+ """Register one agent runtime and subscribe it to bus events."""
52
+ existing = self._agents_by_name.get(name)
53
+ if existing is not None:
54
+ return existing.agent_id
55
+
56
+ agent_id = uuid5(NAMESPACE_URL, f"ccs-agent:{name}")
57
+ runtime = AgentRuntime(agent_id=agent_id, coordinator=self.coordinator, strategy=self.strategy)
58
+ self.event_bus.subscribe(
59
+ agent_id=agent_id,
60
+ on_invalidation=runtime.handle_invalidation,
61
+ on_update=lambda event, runtime=runtime: runtime.handle_update(
62
+ artifact_id=event.artifact_id,
63
+ version=event.version,
64
+ content=event.content,
65
+ now_tick=event.issued_at_tick,
66
+ writer_agent_id=event.issuer_agent_id,
67
+ ),
68
+ )
69
+ self._agents_by_name[name] = AgentBinding(name=name, agent_id=agent_id, runtime=runtime)
70
+ return agent_id
71
+
72
+ def register_artifact(
73
+ self,
74
+ *,
75
+ name: str,
76
+ content: str,
77
+ size_tokens: int | None = None,
78
+ ) -> Artifact:
79
+ """Register a shared artifact in the coordinator directory."""
80
+ return self.coordinator.register_artifact(name=name, content=content, size_tokens=size_tokens)
81
+
82
+ def read(self, *, agent_name: str, artifact_id: UUID, now_tick: int) -> FetchResponse:
83
+ """Read artifact through one registered runtime."""
84
+ return self._binding(agent_name).runtime.read(artifact_id, now_tick=now_tick)
85
+
86
+ def write(
87
+ self,
88
+ *,
89
+ agent_name: str,
90
+ artifact_id: UUID,
91
+ content: str,
92
+ now_tick: int,
93
+ ) -> Artifact:
94
+ """Write artifact through one runtime and dispatch peer events."""
95
+ writer = self._binding(agent_name)
96
+ updated, invalidation_signals = writer.runtime.write(
97
+ artifact_id=artifact_id,
98
+ content=content,
99
+ now_tick=now_tick,
100
+ )
101
+ peers = [binding.agent_id for binding in self._agents_by_name.values() if binding.agent_id != writer.agent_id]
102
+
103
+ for signal in invalidation_signals:
104
+ self.event_bus.publish_invalidation(signal, recipients=peers)
105
+
106
+ if self.strategy.broadcasts_content_on_commit():
107
+ self.event_bus.publish_update(
108
+ ArtifactUpdateEvent(
109
+ artifact_id=artifact_id,
110
+ version=updated.version,
111
+ content=content,
112
+ issued_at_tick=now_tick,
113
+ issuer_agent_id=writer.agent_id,
114
+ ),
115
+ recipients=peers,
116
+ )
117
+
118
+ return updated
119
+
120
+ def content(self, *, agent_name: str, artifact_id: UUID) -> str | None:
121
+ """Return local content cached by one agent runtime."""
122
+ return self._binding(agent_name).runtime.content(artifact_id)
123
+
124
+ def runtime(self, agent_name: str) -> AgentRuntime:
125
+ """Return concrete runtime for adapter extensions/testing."""
126
+ return self._binding(agent_name).runtime
127
+
128
+ def agent_names(self) -> list[str]:
129
+ """Return registered adapter agent names."""
130
+ return sorted(self._agents_by_name.keys())
131
+
132
+ def _binding(self, agent_name: str) -> AgentBinding:
133
+ binding = self._agents_by_name.get(agent_name)
134
+ if binding is None:
135
+ raise KeyError(f"unknown_agent '{agent_name}'")
136
+ return binding
@@ -0,0 +1,58 @@
1
+ # Copyright (c) 2026 Arbiter contributors.
2
+ # The Coherence Protocol for AI Agents
3
+
4
+ """CrewAI-oriented coherence adapter utilities."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from uuid import UUID
9
+
10
+ from ccs.core.types import Artifact
11
+
12
+ from .base import CoherenceAdapterCore
13
+
14
+
15
+ class CrewAIAdapter:
16
+ """Adapter exposing task lifecycle helpers for CrewAI-style flows."""
17
+
18
+ def __init__(self, *, strategy_name: str = "lazy", core: CoherenceAdapterCore | None = None) -> None:
19
+ self.core = core if core is not None else CoherenceAdapterCore(strategy_name=strategy_name)
20
+
21
+ def register_agent(self, name: str) -> UUID:
22
+ """Register one crew member identity."""
23
+ return self.core.register_agent(name)
24
+
25
+ def register_artifact(self, *, name: str, content: str, size_tokens: int | None = None) -> Artifact:
26
+ """Register shared artifact accessible to the crew."""
27
+ return self.core.register_artifact(name=name, content=content, size_tokens=size_tokens)
28
+
29
+ def prepare_task_context(
30
+ self,
31
+ *,
32
+ agent_name: str,
33
+ artifact_ids: list[UUID],
34
+ now_tick: int,
35
+ ) -> dict[UUID, str]:
36
+ """Materialize artifact content for one task execution."""
37
+ content_by_artifact: dict[UUID, str] = {}
38
+ for artifact_id in artifact_ids:
39
+ response = self.core.read(agent_name=agent_name, artifact_id=artifact_id, now_tick=now_tick)
40
+ content_by_artifact[artifact_id] = response.content
41
+ return content_by_artifact
42
+
43
+ def commit_task_artifact(
44
+ self,
45
+ *,
46
+ agent_name: str,
47
+ artifact_id: UUID,
48
+ content: str,
49
+ now_tick: int,
50
+ ) -> int:
51
+ """Commit task output for one artifact and return resulting version."""
52
+ artifact = self.core.write(
53
+ agent_name=agent_name,
54
+ artifact_id=artifact_id,
55
+ content=content,
56
+ now_tick=now_tick,
57
+ )
58
+ return artifact.version
@@ -0,0 +1,65 @@
1
+ # Copyright (c) 2026 Arbiter contributors.
2
+ # The Coherence Protocol for AI Agents
3
+
4
+ """LangGraph-oriented coherence adapter utilities."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from typing import Mapping
9
+ from uuid import UUID
10
+
11
+ from ccs.core.types import Artifact
12
+
13
+ from .base import CoherenceAdapterCore
14
+
15
+
16
+ class LangGraphAdapter:
17
+ """Adapter exposing pre/post node hooks backed by CCS runtime."""
18
+
19
+ def __init__(self, *, strategy_name: str = "lazy", core: CoherenceAdapterCore | None = None) -> None:
20
+ self.core = core if core is not None else CoherenceAdapterCore(strategy_name=strategy_name)
21
+
22
+ def register_agent(self, name: str) -> UUID:
23
+ """Register node runtime identity."""
24
+ return self.core.register_agent(name)
25
+
26
+ def register_artifact(self, *, name: str, content: str, size_tokens: int | None = None) -> Artifact:
27
+ """Register shared artifact used by LangGraph nodes."""
28
+ return self.core.register_artifact(name=name, content=content, size_tokens=size_tokens)
29
+
30
+ def before_node(
31
+ self,
32
+ *,
33
+ agent_name: str,
34
+ artifact_ids: list[UUID],
35
+ now_tick: int,
36
+ ) -> dict[UUID, dict[str, object]]:
37
+ """Read artifacts before node execution and return context payload."""
38
+ context: dict[UUID, dict[str, object]] = {}
39
+ for artifact_id in artifact_ids:
40
+ response = self.core.read(agent_name=agent_name, artifact_id=artifact_id, now_tick=now_tick)
41
+ context[artifact_id] = {
42
+ "version": response.version,
43
+ "content": response.content,
44
+ "state": response.state_grant.value,
45
+ }
46
+ return context
47
+
48
+ def commit_outputs(
49
+ self,
50
+ *,
51
+ agent_name: str,
52
+ writes: Mapping[UUID, str],
53
+ now_tick: int,
54
+ ) -> dict[UUID, int]:
55
+ """Commit node outputs and return artifact versions."""
56
+ versions: dict[UUID, int] = {}
57
+ for artifact_id, content in writes.items():
58
+ artifact = self.core.write(
59
+ agent_name=agent_name,
60
+ artifact_id=artifact_id,
61
+ content=content,
62
+ now_tick=now_tick,
63
+ )
64
+ versions[artifact_id] = artifact.version
65
+ return versions
@@ -0,0 +1,9 @@
1
+ # Copyright (c) 2026 Arbiter contributors.
2
+ # The Coherence Protocol for AI Agents
3
+
4
+ """Agent-side cache and runtime components."""
5
+
6
+ from .cache import ArtifactCache
7
+ from .runtime import AgentRuntime
8
+
9
+ __all__ = ["ArtifactCache", "AgentRuntime"]