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.
This commit is contained in:
host committed 2026-10-29 23:16:01 +08:00
1 parent d4a517fc7e
commit 4cbdc41e20
4 files changed
+76 -25

No files matched your search

+10 -10
View File
@@ -8,8 +8,8 @@
GET /tasks/{id}/trace 轨迹(探针的 trajectory 来源)
GET /tasks/{id}/cost 成本(usd_micros / 1e6;无价 token 不计入 USD,
这是现有 cost 模型的边界,不是本层漏算)
GET /tasks/{id}/files 读本地任务 worktree 文件(产物资产端点;
Docker/跨机任务回 409,见下)
GET /tasks/{id}/files 读任务 worktree 文件(产物资产端点;
cloud/跨机任务回 409,见下)
POST /tasks/{id}/cancel 超时取消,不留孤儿任务继续烧钱
认证:X-API-Key 请求头;密钥只由调用方持有,本模块不读、不存、
不打印密钥。
@@ -21,12 +21,12 @@
harness 下跑。prompt = 原任务 prompt + 一段交付脚注(见
_PROBE_DELIVERABLE_FOOTER),因为评审只看最终回复:agent 必须
把交付物完整写在最终回复里,不能只说“文件已写好”。
文件型产物走两层(产物资产):①本地任务经 GET /tasks/{id}/files
读 worktree 新增/改动文件(端点为准);②所有执行器都可用
回复里的 DELIVERABLE FILE 块(agent 自报,端点结果优先)。
边界仍在:租户 Docker 下 /app/work 是整项目共享目录,按任务
归属读文件会错指,端点对 Docker 任务一律 409——这时只有第
②层可用,且内容以 agent 自报为准(可能截断,截断有标记)。
文件型产物走两层(产物资产):①经 GET /tasks/{id}/files 读
worktree 新增/改动文件(端点为准;本地任务走本地 worktree,
租户 Docker 任务走 tenants 下的任务级子目录);②所有执行器
都可用回复里的 DELIVERABLE FILE 块(agent 自报,端点结果
优先)。边界仍在:cloud/跨机任务端点回 409,此时只有第②层
可用,且内容以 agent 自报为准(可能截断,截断有标记)。
- 编辑(CodexEditor.edit):bundle = context/ 前缀的证据树(task.md /
rollouts / deliverables / harness / library / pool / decisions)。
agent 在 worktree 的 context/harness/ 里改文件,最终回复里用
@@ -290,7 +290,7 @@ class TaskClient(Protocol):
def get_task_files(self, task_id: str, path: str = "") -> dict:
"""GET /tasks/{id}/files:不传 path 列 worktree 文件,传 path
读单个文件。服务端对 Docker/跨机任务回 409,调用方须把
读单个文件。服务端对 cloud/跨机任务回 409,调用方须把
409 当成“无文件通道”、不得当成探针失败。"""
...
@@ -638,7 +638,7 @@ class CodexProbeAdapter:
取 seed 里没有的新文件,以及内容被改过的 seed 文件(与
seed 字节比对,不一致才算产物);跳过隐藏文件、最多收
8 个、最多读 16 个;端点不可用(Docker/跨机 409、读错)
8 个、最多读 16 个;端点不可用(cloud/跨机 409、读错)
时返回空 dict——文件产物是 enrichment,绝不能因此炸轮次。
"""
try: