Commit Graph
317 Commits
Author SHA1 Message Date
openqj 8d8774edee Merge pull request #160 from openqj/feat-console-single-chat
console: 对话只留一处实时单列;任务列表与 API Key 加滚动上限、三栏等高
2026-10-30 01:52:45 +08:00
host 41c2b0ab2f console: 任务列表与 API Key 加滚动上限,左中右栏等高
任务列表与 Key 列表此前无高度上限:任务一多就把整栏
(乃至整页)撑到无限高,左中右栏又因 align-items:start
各按内容高度结束,底部参差不齐。
改法(仅宽/中屏,窄屏 <900px 仍是单列页面滚动,不动):
- .issue-list 上限 60vh、内部纵向滚动,搜索/筛选栏在
  列表外、滚动时仍可见;.api-key-list 上限 320px、内部
  滚动;两处均 overscroll-behavior:contain,不让列表
  滚动直接拖动整页。
- 三栏固定为同一高度:calc(100vh - 260px)(减顶栏、
  数据卡片与页面边距),下限 480px,超出的部分各栏
  自己内部滚动;网格 align-items 改为 stretch。
2026-10-30 01:40:57 +08:00
host c192c5dec8 console: 对话只保留一处实时单列(ChatGPT 式)
根因:ConversationSection 同时渲染 TracePanel(prompt +
全部链路条目)和 ContinuePanel(GET /chat-history,
服务端已把 prompt + 继续 + 后续 + 全部链路种类按时间
合并、并去掉了后续消息回声),简单任务的两份名单
显示同一组用户 + 助手卡片,看起来就是对话重复。
改法:删 TracePanel 名单,只留 ContinuePanel 这一列;
TracePanel 唯一不重复的控件(链路类型筛选、下载完整
链路)移到这一列顶部,筛选只过滤链路消息、用户消息
恒保留;实时性不丢:基础是 10 秒轮询的 chat-history,
SSE 新链路条目按 id 去重合并进来,轮询拿到后不再
重复;无 chat-history 的旧服务端回退路径也改成渲染
全部链路种类(不再只渲染 message),并跳过 fu- 回声。
2026-10-30 01:40:20 +08:00
openqj 9ac0199eba Merge pull request #156 from openqj/feat-cross-worker-kill
feat: 跨 worker 真 kill(kill_requests 意图表 + 收殓器)与自动化触发入闸
2026-10-30 01:40:05 +08:00
host 3a06205d8b feat: 跨 worker 真 kill(kill_requests 意图表 + 收殓器)与自动化触发入闸
机制 A 移植自旧 PR #101(分支 feat-residual-b,头 895e004),
不合旧 PR:旧基线 6e3eb7b 已 CONFLICTING,本批重做到现 main
6d4f87e(#151 合并后)上。

- kill_requests 意图表:cloud/db.py POSTGRES_SCHEMA + migrations
  清单补表;server.ensure_kill_requests_table / request_kill
  (同一任务只留一条 pending,写失败返回 False);init_db 的
  SQLite 分支补建表(PG 分支由 POSTGRES_SCHEMA 全量建表覆盖)。
- 取消/sweep 写请求 best-effort:_cancel_task 在 commit 后调
  request_kill(失败不挡取消);sweep_stale_tasks 在同一事务
  内为被扫任务写 system 请求。
- worker 收殓器 _reap_kill_requests:owner 活着(心跳停滞未超
  300 秒,COALESCE(last_heartbeat, updated_at))绝不抢杀;只
  有 owner 已死且任务仍 interrupted 时,按任务派生容器名
  (executor.container_name,codex-<安全字符任务 id>)在本机
  真杀,绝不按前缀扫、绝不杀自由传入的名字;本机无容器时
  请求照常终结;任务行失踪或已不在 interrupted 时请求直接
  终结;单条异常只记日志。run loop 每轮调一次,放在 sweep
  块外(旧 PR 只在 sweep 块内,sweep 关掉时请求会积压)。
- 自动化入闸只补两条旁路:worker._coord_sync_children 建子任
  务前过 _quota_exceeded(超限跳过建任务、记审计,同一 worker
  内同一分工只记一次);automations.run_due_automation
  (claim 抢单 -> 配额门 -> 建任务 -> 记产出,超限记
  skipped_quota 不进失败重试)。triage/webhook/续跑/后续/
  分叉未动。
- 单测:旧 PR 三份单测原样移植(Worker/Server 签名与现 main
  兼容,未改用例语义)。
2026-10-30 01:32:35 +08:00
openqj b306b56517 Merge pull request #155 from openqj/feat-chatgpt-codex-align1
ChatGPT Codex 对齐:技能包 + 租户播种 + web_search Docker 联网修法
2026-10-30 01:29:47 +08:00
openqj 3c80d277b0 Merge pull request #154 from openqj/feat-console-detail-cards
console: 任务详情改卡片式排版
2026-10-30 01:24:54 +08:00
host 6aa4b45f2c align: 记白名单后端到端全绿结论
- 白名单 6 域名已同步主机并 reload,curl 验 3 个 200、
  time.is 仍 403、worldtimeapi 站侧 TLS 失败(timeapi 兜底)。
- 全新项目任务 6a267baf:web_search 6/6、web_fetch 1/4
  成功(weather.com.cn),答案报出上海时间与北京晴
  5°C、风力 3 级以下,带来源与快照时间,未编造高低温。
- 诚实边界:时间来自系统时钟 + UTC+8 换算,非 timeapi
  fetch;天气来自 fetch 成功的一级来源页。
清理已核,用户剩余 0,生产 health fd9fe5f。
2026-10-30 01:16:49 +08:00
host 1dc2f7dc21 egress: 白名单加一级时间/天气域名,供 live-info fetch 核数
2026-10-30 端到端再测:web_search 已通,但 web_fetch
4 次全败于 Tinyproxy 403 Filtered——模型要 fetch 的
一级来源域名都不在白名单里,搜索摘要又无可靠数字,
故按技能规则未报数字。加:worldtimeapi.org、timeapi.io
(时间 API)、open-meteo.com(免费天气 API,无 key)、
weather.com.cn(中国气象局英文站)、meteoblue.com、
accuweather.com(搜索结果里的天气一级来源)。
刻意不加 time.is/time.org.cn/time.ms(次级时间站)与
任何新闻/社交域名,白名单仍 fail-closed。
主机 /etc/tinyproxy/tinyproxy-filter 须同步此文件并
reload tinyproxy 才能生效,仓库文件是下次部署不被
revert 的依据。
2026-10-30 01:16:49 +08:00
host 84c79302d7 align: 记 MCP env 根因与端到端再测结论
- MCP 子进程不继承 Codex env,docker -e 无用,env 须
  写 config;手动加 env 后 web_search 立刻成功,代码
  修法 dc9b29e 已落地并经全新项目验证(config 自动
  写进 MCP env,web_search 5/6 成功)。
- 端到端仍未报出数字:web_fetch 4 次全败于 Tinyproxy
  403 Filtered,一级来源域名不在 egress 白名单里;
  下一层是主机白名单变更,另等用户定,非代码。
清理已核,用户剩余 0,生产 health fd9fe5f。
2026-10-30 01:16:49 +08:00
host 71e31b22a0 websearch: MCP env 写进租户 config,不只靠 docker -e
2026-10-30 实测:Codex bash 里有 SEARXNG_URL + proxy,
MCP 链却只有 duckduckgo、DNS 瞬间失败——Codex 的 MCP
子进程不继承 Codex 进程 env;给租户 config 加
[mcp_servers.websearch.env] 后同一任务立刻返回真实
SearXNG 结果。修法:worker 在 _docker_task_context
算出网关后、容器启动前,用 ensure_websearch_mcp_env
把 proxy + 搜索 env 写进租户 config(网关此时才已知,
播种时写不死;写失败只记日志不阻塞)。
测试:新增 test_websearch_mcp_env 4 项,相关共 33 项全过。
2026-10-30 01:16:49 +08:00
host 08d56b15ce websearch: SearXNG 默认只查 bing,360search
默认 general 类别在 Docker 任务容器里要 20.0 秒才回
(wikipedia/wikidata/brave/duckduckgo/google 引擎全超时,
只有 bing+360search 回),撞 MCP 默认 20 秒超时;随后
DuckDuckGo 经代理也超时,整条链失败。代理本身无问题
(Tinyproxy 白名单早已放行 searx 与 duckduckgo)。
修法:_provider_searxng 默认 engines=bing,360search,
SEARXNG_ENGINES 可覆盖、空值恢复旧行为;worker 搜索
env 透传补 SEARXNG_ENGINES。容器实测:钉住后 0.26 秒
回 3 条(首条北京天气),auto 链 0.15 秒成功;旧 20.0 秒。
测试:新增 test_websearch_searxng 3 项,MCP/worker 共
21 项全过。生产未部署。
2026-10-30 01:16:49 +08:00
host 79cc59e72e align: 记真实任务实测:技能在 Docker 任务里被发现并读取
2026-10-30 临时 worker 实测(生产未部署):
- 隔离:depends_on 假依赖门 + run_one 单任务,生产
  worker 永不认领,临时 worker 只跑指定任务。
- 第一次失败:GitHub clone 卡 684K 6 分钟 + run_one
  无心跳线程,300 秒被 sweep 标 interrupted,播种未跑到。
- 第二次成功(test-repo 项目 + 心跳线程):任务
  7235de8f completed,租户 skills/ 含 3 个 SKILL.md,
  trace 里 agent 真读了容器内 live-info/SKILL.md,
  答案按技能规则明说 web_search 不可用、不编造数字。
- 独立未解:Docker 里 web_search 本身 DNS/联网失败,
  与 2026-10-28 探针同类,另批再修,不在本批宣称内。
清理已核:临时用户/项目/任务/租户目录/临时代码全删,
生产 health 仍 3696dad、worker_ok。
2026-10-30 01:16:49 +08:00
host 378cddfb1e align: 修正技能播种路径:codex-home/skills/ 才是用户技能目录
2026-10-30 主机实测(临时 codex-home,生产未动)纠正:
先播 .agents/skills/ 时 skills/list 只返回 5 个系统技能,
3 个自有技能一个没出现;改播 skills/ 后返回 8 个,
3 个自有技能以 scope=user 出现。系统技能本身就在
skills/.system/ 下。
- skill_seed DEST_SUBDIR 由 .agents/skills 改为 skills,
  模块文档与 worker 注释同步修正。
- 测试期望路径同步改为 skills/。
- 对照表补实测结论与附带发现:Codex 自带系统技能
  imagegen,图片生成在 Codex 本体里不是无技能。

验证:skill_seed + chatgpt skills + websearch worker
共 14 项全过。主机探针文件已全部清理,生产未动。
2026-10-30 01:16:49 +08:00
host cf9d17f035 align: 第二批:把技能包播种进租户 codex-home
仿 websearch MCP 播种,默认关:
- cloud/skill_seed.py:cloud/skills/ 的 SKILL.md 拷进租户
  codex-home/.agents/skills/(个人级技能路径,见模块
  文档的路径依据与诚实边界);幂等,租户改过的文件
  绝不覆盖(上报 differs),缺包不阻塞任务。
- cloud/worker.py:新增 --seed-skills,_tenant_dirs 里
  调用播种;老租户下一次任务自动合并;播种失败只记
  日志、不阻塞任务(技能是可选流程说明)。
- cloud/tests/test_skill_seed_worker.py:播种助手 + worker
  开关,仿 test_websearch_worker.py 的结构。
- docs/chatgpt-codex-alignment.md:补第二批说明与实测
  待办(真实 Docker 任务 skills/list + $live-info 调用,
  通过前不宣称生产任务已能用这些技能)。

验证:skill_seed + chatgpt skills + websearch worker
共 14 项全过。本批不改生产配置、不部署,autoscaler
加 --seed-skills 是部署时另行的主机步骤。
2026-10-30 01:16:49 +08:00
host 8a26d1973c align: ChatGPT Codex 对齐第一批:技能包 + 对照表
对照用户提供的 ChatGPT Codex 工具目录,区分可对齐与
不照搬:核心编程工作流已对齐,ChatGPT 托管专属
(CUA、宠物、Docs/Sites 连接器、图片生成模型)不在
开源宿主编排层范围,不凭空宣称对齐。

第一批只补技能层,不改 worker、不改生产行为:
- cloud/skills/live-info:天气/时区/股票/体育,查一级
  来源、带来源和快照时间,绝不编数字。
- cloud/skills/document-tools:LaTeX/Word/PDF/表格/
  演示文稿,先核查工具、缺了明说、产出后重读验证。
- cloud/skills/image-workflow:已有图片处理 + 生成工具
  已配置时才生成,未配置时明说、绝不顶替。
- docs/chatgpt-codex-alignment.md:逐项对照表与不照搬
  的诚实边界,方向为自动化编程任务平台。
- cloud/tests/test_chatgpt_codex_skills.py:校验技能
  frontmatter、名字与目录一致、正文非空、无密钥占位。

验证:新测试 2 项全过。播种进租户 codex-home、 worker
改动、CUA/连接器/图片模型均不在本批,另行评审。
2026-10-30 01:16:49 +08:00
host b60f4facbd console: 任务详情改卡片式排版
只改排版,不改数据与操作:原来一整块 <br> 分隔的
信息行拆成卡片——概览(状态 + 耗时/token/成本三张
指标卡)、基本信息(键值网格)、prompt(单独一张
卡,长 prompt 不再挤在信息行末尾)、操作与结果、
协调子任务/子代理链路/评审队列/审批队列/发消息/
线程(各一张卡)。指标卡在窄的详情列里用
auto-fit 网格自动折成一列,不挤压;nav-detail
锚点保留在外层容器上。
2026-10-30 01:13:32 +08:00
openqj 6d4f87e286 Merge pull request #151 from openqj/feat-trace-truncation
trace: 标注被截断的链路消息,避免误读为模型未写完
2026-10-30 01:12:33 +08:00
host ce85043a24 trace: 标注被截断的链路消息,避免误读为模型未写完
2026-10-29 实弹:468 字 final_answer 在链路里只剩前 300 字、
断在 fu 后,控制台照原样当助手回复展示,用户误以为模型
没写完。截断本身是设计(防链路文件写爆),缺的是标记。

- host.py _summarize_trace_item:agentMessage 超 300 字时
  条目带 truncated=True,短消息不带,完整回复仍在任务
  result_text 里,不在链路条目里。
- 控制台:TraceEntry 加 truncated 字段,mapTrace 与
  traceLineText 在被截断的消息后标注“链路摘要已截断至
  300 字,完整回复见右侧任务结果”,console.html 为构建产物同步。
- 单测:tests/test_host_trace.py 新增截断标记用例(468 字
  截 300 字且带标记、短消息不带标记)。

验证:host 10 项、cloud test_task_trace 14 项全过;
React tsc+vite 构建通过,产物 322151 字节、含截断标注、
含 #150 的 total_tokens/首字/总耗时,无回退。
2026-10-30 01:01:50 +08:00
openqj fd9fe5f254 Merge pull request #153 from openqj/feat-auth-unknown-role
fix(auth): unknown project role denies instead of KeyError 500
2026-10-30 00:55:54 +08:00
openqj 284e821d0c Merge pull request #152 from openqj/feat-console-task-detail-meta
console: 任务详情显示首字、总耗时、token 与自动成本明细
2026-10-30 00:50:08 +08:00
host c823e32336 fix(auth): unknown project role denies instead of KeyError 500
check_permission now returns False for roles not in _ROLE_LEVEL
(e.g. a directly-written 'member' row, which set_member itself
rejects but legacy/direct DB rows can still carry), so the failure
mode is PermissionError/403, never an unhandled 500. Regression test
test_unknown_role_denied_not_500 fails with KeyError on old code.
2026-10-30 00:49:03 +08:00
host 994c4ea5d1 console: 任务详情自动显示成本明细
打开详情就自动拉 GET /tasks/{id}/cost(不再只靠
“查成本”按钮出 JSON),详情顶部新一行:美元、总
token(实际/估算、缓存、无价单列)、轮数、fallback
次数;美元小于 1 美分时用 4 位小数,避免小任务
显示成 $0.00 误导成免费;加载中/失败有各自的
弱化文案,成本拉失败不影响详情其它内容;原
“查成本”按钮不动,仍可手动拉原始 JSON。
服务端不用改:成本接口与 _get_task 的 token 聚合
都已在 #150 / 详情 meta 那单里就位。
2026-10-30 00:39:13 +08:00
host 0f7162934b console: 任务详情也显示首字、总耗时、token
列表行与详情共用同一口径:新抽 api/taskMeta.ts(首字/
总耗时/token 计算),TaskListSection 改 import 它(逻辑
原样不动),TaskDetailPanel 在状态行下方加一行:首字
方块 + 耗时 + token,title 里写口径。
详情的数据缺口一并补上:单任务接口 _get_task 此前走
_task_to_dict 默认 total_tokens=None,详情 token 只能
显示占位;现与列表一样用 _task_tokens_map 一次聚合
(单任务只多一条查询),详情直接出真数。
types.ts 里过期的“列表不回 token”注释同步更新。
新测试:单任务 GET /tasks/{id} 聚合回 total_tokens。
2026-10-30 00:39:13 +08:00
openqj 3696dad7c8 Merge pull request #146 from openqj/feat-task-files-tenant
fix: task files endpoint resolves tenant docker worktrees
2026-10-30 00:04:37 +08:00
host 4cbdc41e20 fix: task files endpoint resolves tenant docker worktrees
GET /tasks/{id}/files previously returned 409 for all docker tasks
on the grounds that tenant docker shares /app/work per project.
Production inspection shows the worker creates a per-task
host-worktrees/<task-id> subdirectory under the tenant work dir
(62 such dirs under the wwww tenant), so per-task reads are
attributable after all: the endpoint now resolves tenant docker
tasks via tenants/<project>/work/host-worktrees/<task-id> (local
worktree as fallback), never serves the shared /app/work mount
itself, and still 409s cloud/cross-host tasks. Docs and the
harness2_tasks boundary notes are updated to match.
2026-10-29 23:16:01 +08:00
openqj d4a517fc7e Merge pull request #150 from openqj/feat-console-task-meta
console: 任务列表行显示首字、总耗时、token(服务端列表补 total_tokens)
2026-10-29 18:38:36 +08:00
host 9eedee5a3d server: 任务列表一次聚合回 total_tokens
_list_tasks 在取附件的同时用 _task_tokens_map 一次查
cost_records 按 task_id 求和(GROUP BY),一屏只多一条
查询,不按任务逐个调成本接口。无记录计 0、表不存在时
全计 0 且列表不失败;_task_to_dict 新增 total_tokens
参数,默认 None(非列表调用方不把“未算”写成 0)。
前端 TaskListSection 的 token 栏位此前已接好 total_tokens,
补上后列表行直接显示真数,不再显示 token —;前端注释
与占位文案同步更新。
新测试 test_task_list_tokens.py 3 项:HTTP 列表聚合
(actual+estimated 加总、无记录为 0)、缺表不炸、
_task_to_dict 默认 None。
2026-10-29 18:27:53 +08:00
host 65a875ada9 console: 任务列表行显示首字、总耗时、token 栏位
任务列表每一行新增三项(筛选、搜索、选中高亮、状态点不动):
- 首字:行前小方块,prompt 第一个非空白字符(按码点取),
  无 prompt 时用任务 id 首字符兜底;原 prompt 文案不动。
- 总耗时:只用列表已回时间戳算。终态用 finished_at -
  started_at(与服务端 avg_duration_seconds 同口径);running
  显示“进行中 + 已用时长”,随列表刷新更新;无 started_at
  时用 created_at 兜底(含排队,title 注明口径)。格式:
  3分12秒、1小时5分、1天1小时。
- token:栏位已接好,total_tokens 优先,actual +
  estimated 分项加总次之;但列表接口 _task_to_dict 目前
  不回任何 token 字段,单任务真数只在 GET /tasks/{id}/cost
  里,所以当前显示“token —”,不编造、不逐个调 /cost
  拖慢列表。服务端在列表里补 total_tokens 后本行自动出真数。

诚实边界:worker 每次认领重写 started_at,多轮续跑任务
的耗时是末次认领时长,不是历次之和;严格累计需服务端
保留首次 started_at 或累加各轮时长。token 的服务端缺口:
需在 _task_to_dict / 列表查询里按 task_id 聚合 cost_records
的 total_tokens,不需要新端点。
构建:npm run build(tsc + vite singlefile)0 退出,
dist/index.html 原样拷到 cloud/console.html,产物含
issue-first、耗时、token —,未动其它确认框。
2026-10-29 18:24:07 +08:00
openqj e5bf361c6d Merge pull request #149 from openqj/feat-no-full-confirm
console: 新建任务选完全访问不再弹确认框
2026-10-29 18:17:16 +08:00
host 6d9cd24553 console: 新建任务选完全访问不再弹确认框
DispatchSection 提交时删掉 full 的 window.confirm:下拉里
选 full 本身就是显式选择,提交直接送 approval,不再二次
确认。计划模式与 full 互斥的拦截不动,其它确认框(取消/
合并/提 PR 等)不动。
构建产物 cloud/console.html 由 npm run build(tsc + vite
singlefile)重新生成,产物里已无“确认提交吗”,仅剩下拉
选项本身的“完全访问”文案。
2026-10-29 18:06:18 +08:00
openqj baf330f112 Merge pull request #148 from openqj/feat-console-goal-invincible
console: 增加 goal 模式无敌版勾选
2026-10-29 18:05:19 +08:00
host 7d400afa37 console: add goal-mode invincible option
DispatchSection gains a 'goal 模式无敌版' checkbox next to 'goal 模式':
checking it sends goal_mode=1 plus no_time_limit=1 (server already
accepts the field; the console just never exposed it). Plain goal
checkbox behavior is unchanged; invincible wins when both are
checked. Plan/coordinator mutual exclusion now covers invincible
too (it is a goal variant). TaskDetailPanel shows
'goal 模式无敌版(不限时)' when a task carries no_time_limit.
Help text states the honest boundary: worker/docker total timeouts
are lifted, the 600s single-turn host guard stays. Built with
npm run build (tsc+vite pass); console.html synced verbatim from
dist/index.html.
2026-10-29 17:58:50 +08:00
openqj 9961a251d1 Merge pull request #147 from openqj/feat-prestart-goal-logs
worker: 补漏:goal 路径的 docker 分段日志 + 审计任务 id
2026-10-29 17:52:30 +08:00
host 6f0eec71b6 worker: cover goal docker paths with prestart stage logging
PR #145 added docker_run_* lines only to _run_in_container, but
goal/goal-resume/goal-resume-breakpoint call _call_runner directly
(to keep full stdout for goal conclusions), so the production live
test (a goal task) produced zero docker_run_ lines. Extract a
_docker_call_staged helper and route all four task paths through it;
error lines log the class name then re-raise so each caller's
kill+failed handling is unchanged.

Also fix audit attribution: audit_log has no task_id column, and
worker_exec_done/error details carried no task id, so per-task
queries missed them (the rows existed). All three exec details now
start with task_id=. Tests: 2 new goal-path stage cases + a done
detail task-id assertion (8 total in test_prestart_stages).
2026-10-29 17:46:12 +08:00
openqj a17f0c7412 Merge pull request #145 from openqj/feat-prestart-logs
worker: 启动前分段日志(派发卡死可定位)
2026-10-29 17:33:05 +08:00
host 9d90d97046 worker: prestart stage logging for dispatch stalls
Claim-to-dispatch stalls (cf. 2026-10-29 task A: 61s to interrupted
with zero detail) were invisible because docker run blocks with
captured output and watchdog kills were silent. Add three layers:
- worker_exec_start/done/error audit rows in _run_attempt (PG,
  survives --rm), start/done pairing shows whether an attempt died
  inside the executor call;
- docker_run_start/done/error log lines in DockerExecutor (container
  + image only, never the inner command/prompt);
- stdout tail (last 2000 chars) to the worker log on failed or
  interrupted results, and a log line on both watchdog kill paths.
Tests: cloud/tests/test_prestart_stages.py, 6 cases incl. a
no-prompt-in-logs assertion.
2026-10-29 17:07:53 +08:00
openqj 0129b0149a Merge pull request #144 from openqj/feat-neverstart-fresh
worker: 从未启动的任务自动续跑回落全新跑
2026-10-29 16:51:42 +08:00
host e74f20608b worker: auto-resume falls back to fresh goal for never-started tasks
2026-10-29 live test: task A was interrupted 61s after claim but had
never written anything (no host-state entry, no worktree, no trace,
no checkpoint); auto-resume ran goal-resume, which host rightly
refused, and the task failed. Refusal only makes sense for tasks
with progress but a lost breakpoint (those go through the P0
checkpoint rebuild); for a never-started task the only meaningful
outcome is a fresh run, identical to its first attempt (same task
id, same goal, worktree does not exist yet so nothing is
overwritten).

Change (claim path only, via _resolve_breakpoint_resume):
- rebuild from checkpoint first, unchanged;
- if rebuild fails AND _task_never_started holds (state entry,
  checkpoint row, worktree dir, trace file all absent), clear the
  breakpoint flag so the run takes the fresh goal path, with a
  worker_fresh_restart audit event;
- any evidence of prior execution, or any check failure,
  keeps the old refusal path (fail-closed); the auto-resume
  count cap and no-progress stall guard still bound retries.

Tests: cloud/tests/test_neverstart_fresh.py, 10 items (fallback
holds, entry/checkpoint/worktree/trace presence each block it,
corrupt state blocks it, rebuild still wins when a checkpoint
exists); test_goal_resume's breakpoint-routing test now sets up
a task with a checkpoint so it still exercises goal-resume.
Full suites: cloud 1178 (skipped 4), host 104, deploy 39, green.
2026-10-29 16:45:07 +08:00
openqj a4586cbebc Merge pull request #143 from openqj/feat-harness2-followups
harness2: per-role models, sweep batch, task file assets endpoint
2026-10-29 16:39:48 +08:00
host c20192bce8 harness2: per-role models, sweep batch, task file assets endpoint
- Role models: run_improvement_via_tasks gains role_models
  (probe/editor/selector/reflector) plus --model-<role> CLI flags;
  missing/empty falls back to shared --model, both empty means
  server default, so default behavior is unchanged.
- Sweep: run_sweep + examples/harness2_sweep.py manifest CLI with
  shared library_root (library restore), per-run failure isolation
  and sweep-report.json summary; preflight gates task creation.
- Deliverable assets: GET /tasks/{id}/files for local-executor
  tasks (safe path resolution, UTF-8 text <=256KB, listing <=200;
  docker/cloud/cross-host 409 with explicit reason, since tenant
  Docker shares one /app/work per project and per-task attribution
  would misattribute); probe rollout deliverable_files from the
  endpoint plus DELIVERABLE FILE reply blocks (endpoint wins on
  collision, bad blocks dropped), surfaced in
  deliverables/<label>/files/ context and full_result summary.
- Docs: harness2.md comparison table updated for all three items.
2026-10-29 16:32:58 +08:00
openqj 9e444eca38 Merge pull request #142 from openqj/feat-state-lock
host: 修复断点丢失(tmp 碰撞 + 跨容器 flock 失效)
2026-10-29 16:04:12 +08:00
host 9ea0a05fb1 host: fix state-loss from tmp collision and cross-container flock failure
2026-10-29 task 2 lost its host-state entry (version 390 -> single
digits) while running under Docker/gVisor. Root cause, proven live:
- save_state tmp name contained only pid, and every containerized
  host.py runs as pid 1, so concurrent writers shared one tmp file
  and interleaved writes produced corrupt JSON;
- fcntl.flock does not exclude across runsc containers sharing a
  bind-mounted lock file (both entered at 0.0s in a live probe);
- _read_state_file silently treated corrupt JSON as empty state, so
  the next save legitimately rewrote the file with only the
  surviving writer's tasks.

Fix:
- tmp name now hostname + pid + thread + uuid4 (backup tmp same);
- mkdir atomic lock replaces flock (atomic on the host fs, holds
  across bind mounts/gofer), with stale-lock recovery after 120s
  and a loud timeout instead of unlocked writes; reads need no lock
  because publication is tmp + os.replace;
- save path uses a strict disk read: corrupt JSON, non-object top
  level, or wrong-shaped tasks/automations now raise instead of
  overwriting (recovery stays with restore_state + .bak).

Tests: tests/test_host_state_lock.py, 7 items (tmp uniqueness in
process and across processes, 8-process concurrent saves all
survive with version 8, stale lock recovery, fresh lock timeout
raises, corrupt/wrong-shaped disk refuses to overwrite).
Full suites: cloud 1168 (skipped 4), host 104, deploy 39, all green.
2026-10-29 15:57:46 +08:00
openqj 7425f2e778 Merge pull request #141 from openqj/feat-harness2-gaps
harness2: upstream gap fill — trivial fix, session budget, tag validation, preflight
2026-10-29 15:40:09 +08:00
openqj 4d16d63313 Merge pull request #140 from openqj/feat-longtask-p0-three
断点镜像状态标签回落:host-state 条目写 status 不是 goal_status
2026-10-29 15:37:51 +08:00
host 4ed1479d7a harness2: upstream gap fill — trivial selection fix, session budget, run_tag validation, preflight check
- select_final trivial condition now k==1 and single-candidate pool,
  regardless of whether a selector is provided (previously gated on
  selector is None, so wired runs always paid for a useless selector
  task at k=1)
- Budget gains max_sessions gate (probe + stage-attempt sessions;
  fmt2 corrections and selector/reflector sessions exempt), the
  backstop for unpriced models where the USD gate never binds
- validate_run_tag (charset, no leading '-', no s<N> seed prefix)
  enforced at run_improvement_via_tasks and the CLI
- CLI --check preflight (base harness, source dir, prompt, tag,
  control-plane /health probe) without creating tasks
- ModeResult.to_dict now includes rollout summaries so a lost probe
  is visible in full_result instead of only on the server
- CLI plan counts the selector only when k>1
2026-10-29 15:31:58 +08:00
host 8c719c7e62 断点镜像状态标签回落:host-state 条目写 status 不是 goal_status
生产实弹:极小 goal 任务的 timeline 里 checkpoint goal_status 为
None——host.py 的任务条目只有 status(goal-running/goal-met),
没有 goal_status 键,镜像原样读 goal_status 永远是空。修法:
entry.get('goal_status') or entry.get('status')。轮次、thread_id、
state_sha 等关键字段不受影响(熔断只看轮次),纯标签 fidelity
修复;单测加 status-only 条目镜像断言。
2026-10-29 15:31:07 +08:00
openqj 3d60f32bd3 Merge pull request #139 from openqj/feat-longtask-p0-three
长任务 P0 三件:断点进库、错误分类+熔断、Run/Step 时间线
2026-10-29 15:19:43 +08:00
host 585242fc8f 长任务 P0 三件:断点进库、错误分类+熔断、Run/Step 时间线
断点进库:task_checkpoints 表(PG 新库 + 老库幂等补表 + 迁移清单
对齐);worker 在 goal 任务执行期间每 30 秒把磁盘 host-state 断点
镜像进库,终局再补一次;断点续跑认领前,若 host-state 条目丢失
但库里有断点,先按库断点重建最小条目再跑,库里也没有断点时不
造假、走原有拒绝路径。

错误分类+熔断:sandbox 四处解析加永久错误分支(KeyError、配置
缺失等无结论异常退出判 failed 死信,不再判 interrupted;host 已
明言 interrupted 的不受影响,未知错误不分类);worker 自动恢复
加退避(10 秒起指数退避、封顶 300 秒)与无进展熔断(库断点轮次
连续 3 次不变即标 auto_resume_stalled 等人工)。

时间线:task_steps 表 + host 每轮写 host-steps 步骤文件 + worker
导入;GET /tasks/{id}/timeline 一次返回 steps 与 checkpoints;
认领、暂停、自动恢复、终局都记步骤。旧任务返回空数组,不编造。

单测:cloud/tests/test_p0_three.py 14 项(分类、熔断、镜像重建、
步骤导入去重、timeline 接口)。
2026-10-29 15:13:01 +08:00
openqj d56bd3a99e Merge pull request #138 from openqj/feat-harness2
harness2: recursive harness optimization wired to real codex tasks
2026-10-29 14:28:44 +08:00