feat: implement DCOS source tree, tests, and build configuration

Complete implementation of the DCOS package including:
- 40+ Python source files across agents, communication, core, learning, memory, protocols, utils
- pyproject.toml build configuration
- 102 unit tests across all subsystems
- Fixed flake.nix (Python 3.12, proper dependencies, pyproject build)
- Fixed .woodpecker.yml (correct paths, removed silent-fail flags)
- Added .gitignore
- Cleared stale pytest cache
This commit is contained in:
Celes Renata
2026-08-02 03:29:55 -07:00
parent 38bb291a02
commit 57619860d5
157 changed files with 2742 additions and 10 deletions
+45
View File
@@ -0,0 +1,45 @@
"""
Resource allocator — manages compute and memory resource distribution among agents.
"""
from __future__ import annotations
from typing import Dict, List, Optional, Tuple
class ResourceAllocator:
"""Allocates system resources (compute, memory, bandwidth) among agents."""
def __init__(self) -> None:
self._total_cpu: float = 100.0
self._total_memory: float = 1024.0
self._allocations: Dict[str, Dict[str, float]] = {}
def allocate(self, agent_id: str, cpu: float, memory: float) -> bool:
if cpu <= 0 or memory <= 0:
return False
remaining_cpu = self._total_cpu - sum(
a.get("cpu", 0) for a in self._allocations.values()
)
remaining_memory = self._total_memory - sum(
a.get("memory", 0) for a in self._allocations.values()
)
if cpu > remaining_cpu or memory > remaining_memory:
return False
self._allocations[agent_id] = {"cpu": cpu, "memory": memory}
return True
def release(self, agent_id: str) -> bool:
return agent_id in self._allocations and bool(
self._allocations.pop(agent_id, None)
)
def get_allocation(self, agent_id: str) -> Dict[str, float]:
return self._allocations.get(agent_id, {"cpu": 0.0, "memory": 0.0})
def utilization(self) -> Dict[str, float]:
total_cpu = sum(a.get("cpu", 0) for a in self._allocations.values())
total_mem = sum(a.get("memory", 0) for a in self._allocations.values())
return {
"cpu": total_cpu / self._total_cpu,
"memory": total_mem / self._total_memory,
}