feat(cloud): enforce host governance budgets
Tests / Test passed: 662

This commit is contained in:
2026-07-13 22:56:31 +08:00
parent 2cd314b183
commit b4803f90e6
28 changed files with 1311 additions and 14 deletions
@@ -33,6 +33,7 @@ class AgentStatusTracker:
self._lock = threading.Lock()
self._current_assignment: _CurrentAssignment | None = None
self._last_heartbeat: _LastHeartbeat | None = None
self._host_policy: dict[str, Any] | None = None
def mark_assignment_started(self, assignment: AssignmentModel) -> None:
with self._lock:
@@ -56,6 +57,19 @@ class AgentStatusTracker:
at=self._now(),
)
def mark_host_policy(self, policy: Any | None) -> None:
with self._lock:
self._host_policy = (
{
"revision": policy.revision,
"self_submission_enabled": policy.self_submission_enabled,
"max_active_tasks": policy.max_active_tasks,
"daily_token_budget": policy.daily_token_budget,
}
if policy is not None
else None
)
def snapshot(self) -> dict[str, Any]:
with self._lock:
current_assignment = self._current_assignment
@@ -81,4 +95,5 @@ class AgentStatusTracker:
if last_heartbeat is not None
else None
),
"host_policy": self._host_policy.copy() if self._host_policy else None,
}