policy submits_per_hour: an agent can be capped at N submissions or resubmissions per hour (the User asked the DeepSeeks to slow down and check their work)

This commit is contained in:
KeelrLeek committed 2026-10-07 11:04:54 -05:00
1 parent a3fc48802c
commit c77ed1a4db
3 files changed
+25

No files matched your search

+3
View File
@@ -762,6 +762,7 @@ class Harbor(WorkMixin, ExtrasMixin, FlowMixin, LaunchMixin):
raise HarborError("no reviewer: name one, or set reviewers in the project file")
canonical = parse_scope(scope)[0] if scope else None
commit = self.resolve_commit(author, commit)
self.check_submit_policy(author)
def do(c):
now = self.now()
@@ -825,6 +826,8 @@ class Harbor(WorkMixin, ExtrasMixin, FlowMixin, LaunchMixin):
self.check_landing_policy(item_id)
if is_author and commit:
commit = self.resolve_commit(agent, commit)
if is_author and to_state == "submitted":
self.check_submit_policy(agent)
def do(c):
now = self.now()
+14
View File
@@ -265,6 +265,20 @@ class FlowMixin:
raise HarborError(f"policy: item #{item_id} needs approval from {', '.join(missing)} before it lands "
"(since its last submission)")
def check_submit_policy(self, author):
"""policy submits_per_hour: an agent capped at N submissions (new or resubmitted) per hour must slow down
and check its work before sending more."""
cap = (self.policy("submits_per_hour") or {}).get(author)
if not cap:
return
since = iso(utc(self.clock() - 3600))
count = self.conn.execute("SELECT COUNT(*) FROM item_events WHERE agent=? AND to_state='submitted' AND at>=?",
(author, since)).fetchone()[0]
if count >= int(cap):
raise HarborError(f"policy: at most {cap} submissions per hour for {author}. Slow down: re-read the "
"disassembly against your C line by line, run quick_readable and re_behaviour, list "
"your changed annotation rows, and submit only work you have checked twice")
def check_message_policy(self, sender, to_all):
cap = self.policy("all_per_hour")
if not cap or not to_all or sender in self.coordinators:
+8
View File
@@ -196,6 +196,14 @@ def _policy(raw, names):
policy["all_per_hour"] = int(policy["all_per_hour"])
except (TypeError, ValueError):
raise ProjectError("policy all_per_hour must be a whole number")
if "submits_per_hour" in policy: # {agent: n}: submissions and resubmissions per hour
caps = policy["submits_per_hour"]
if not isinstance(caps, dict) or not all(k in names for k in caps):
raise ProjectError("policy submits_per_hour must map agents on the roster to whole numbers")
try:
policy["submits_per_hour"] = {k: int(v) for k, v in caps.items()}
except (TypeError, ValueError):
raise ProjectError("policy submits_per_hour must map agents on the roster to whole numbers")
return policy