feat: G7 分层 fail-open/fail-closed + G8 Docker 轮询掐断 + G9 worker 忽略 host 预算 + G13/G14 归属(第三批)
- G7:认领门 closed 时查配额异常回 quota_check_unavailable、标 interrupted(可重试/续跑);轮询与轮次边界用 open,异常时回 quota_check_failed——新回合边界拒绝,执行中轮询经 _quota_hit 闭包过滤此串、只记 warning 不杀在跑任务,确认超限才掐断;查询函数本身不吞异常冒充不限额。 - G8:Docker 路径加 _docker_call_with_quota_poll(后台线程跑阻塞式 docker 调用,主循环每 quota_poll_interval_seconds 缺省 30 秒查一次,确认超限按容器名真杀容器,结果改写 quota_exceeded 走统一收尾:interrupted、成本照记、续跑消息保留,配额命中后不走 ALREADY_EXISTS 回落);同步路径保持边界检查。 - G9:worker 路径默认忽略 host max_daily_turns(host.py 顶层 --ignore-host-budget 只清该项,Local/Docker 执行器在子命令前追加,worker CLI 缺省开、--no-ignore-host-budget 关);standalone 直接跑 host.py 时预算照常。 - G13/G14:/pr 不再走 system 豁免,建任务前按请求用户查配额(402/503 均不排队不改状态),队列路 pr_jobs.created_by 记请求用户(老表 ALTER 补列),worker 跑 pr 任务时审计操作人用 created_by(老行回落 system)。注意:G14 原案的 system 豁免(服务端与 worker 写死)与 P1 冲突(P1:system 按普通属主走默认额度,不另设无限额系统预算),本次 rebase 未合入该豁免,system 豁免需另行决策。 - 配额口径与 P0/P1 对齐:无配额行按默认额度(非不限额),只有显式 NULL 行才不限额;无价上限只计 source='actual' 行;缺属主(含父任务回查仍无)拒绝新回合。 - README 配额节同步以上口径与 G15 接受现状(best-effort 超支、UTC 月切分、在跑任务只在轮询/轮次边界响应配额改动)。G4 与 G15 不在本批。
This commit is contained in:
1 parent
5883169c82
commit
e31fcc6cba
11 files changed
+786
-176
No files matched your search
+14
-2
@@ -189,11 +189,14 @@ class LocalExecutor(Executor):
|
||||
"""
|
||||
|
||||
def __init__(self, host_py_path, config_path=None, runner=None,
|
||||
repo=None, model=None):
|
||||
repo=None, model=None, ignore_host_budget=False):
|
||||
self.host_py_path = host_py_path
|
||||
self.config_path = config_path
|
||||
self.runner = runner if runner is not None else _default_runner
|
||||
self.repo = repo
|
||||
# G9:worker 路径默认忽略 host 预算时由 Worker 同步成
|
||||
# True;standalone 的 LocalExecutor 缺省 False,预算照常。
|
||||
self.ignore_host_budget = bool(ignore_host_budget)
|
||||
# 模型:host.py 的 --model 是顶层全局参数(dispatch/run 共用),
|
||||
# 不传时 host.py 用配置文件里的 model;传了就覆盖配置。
|
||||
# worker 的 fallback 靠它把换模型后的第二次尝试真正发到新模型上,
|
||||
@@ -205,6 +208,10 @@ class LocalExecutor(Executor):
|
||||
cmd = [sys.executable, self.host_py_path]
|
||||
if self.config_path is not None:
|
||||
cmd += ["--config", self.config_path]
|
||||
# G9:顶层全局参数,必须放在子命令之前(调用方在
|
||||
# _base_command 之后才追加子命令)。
|
||||
if getattr(self, "ignore_host_budget", False):
|
||||
cmd += ["--ignore-host-budget"]
|
||||
effective = model or self.model
|
||||
if effective:
|
||||
cmd += ["--model", effective]
|
||||
@@ -693,7 +700,7 @@ class DockerExecutor(Executor):
|
||||
user="1000:1000", worktrees_root=None, env=None,
|
||||
env_key="XCM_API_KEY", timeout=None, extra_mounts=None,
|
||||
model=None, security_opts=None, pids_limit=None,
|
||||
runtime=None, extra_env=None):
|
||||
runtime=None, extra_env=None, ignore_host_budget=False):
|
||||
if host_py_path is None:
|
||||
here = os.path.dirname(os.path.abspath(__file__))
|
||||
host_py_path = os.path.join(os.path.dirname(here), "host.py")
|
||||
@@ -703,6 +710,8 @@ class DockerExecutor(Executor):
|
||||
# 取构造时传的 model,都没有则不传 --model(容器内 host.py
|
||||
# 用配置文件里的 model)。fallback 时 worker 换任务的 model。
|
||||
self.model = model
|
||||
# G9:Worker 会把自己的 ignore_host_budget 同步过来。
|
||||
self.ignore_host_budget = bool(ignore_host_budget)
|
||||
self.runner = runner if runner is not None else _docker_default_runner
|
||||
self.image = image
|
||||
self.cpus = str(cpus)
|
||||
@@ -916,6 +925,9 @@ class DockerExecutor(Executor):
|
||||
if self.config_path is not None:
|
||||
cmd += ["--config",
|
||||
"/app/" + os.path.basename(self.config_path)]
|
||||
# G9:与 LocalExecutor 同款,顶层全局参数,放子命令之前。
|
||||
if getattr(self, "ignore_host_budget", False):
|
||||
cmd += ["--ignore-host-budget"]
|
||||
effective = model or self.model
|
||||
if effective:
|
||||
cmd += ["--model", effective]
|
||||
|
||||
Reference in new issue
Block a user