feat: 任务附件——server/worker/console 链路打通(+ popen goal 新语义补漏)

server:POST /uploads(multipart,413 预检、路径/数量/大小校验、
24h 过期包、used 防一包多用)+ 建任务绑定(同事务写附件行 +
包置 used,cloud 执行器 400)+ 列表/详情带 attachments +
取消删暂存 + 分支带走附件清单;db.py PG 建表 + init_db 补表。
worker:_task_seed_dir(无附件/目录已删静默 None)+ dispatch/
goal 三路(同步本地、popen、Docker 只读挂载 /tmp/codex-seed)
+ cloud 执行器兜底失败 + 终局删暂存。
console:文件/文件夹/图片三路输入,先上传拿 upload_id 再建任务,
列表 [附件×n]、详情列附件路径。
附带:popen 的 goal 命令此前强制要求 verify_command,goal 新语义
任务到本地 worker(走 popen)会直接报错,改成与同步 goal_task
一致(无验收不传 --verify,轮次 0 原样传)。
测试:新增 test_task_attachments.py 15 个。
This commit is contained in:
host committed 2026-10-27 04:30:43 +08:00
1 parent 9537e6f0d2
commit 7c444a688b
8 files changed
+869 -32

No files matched your search

+9 -2
View File
@@ -138,13 +138,18 @@ def validate_bundle(paths, sizes):
def save_bundle(root, paths, datas):
"""把一包附件写进暂存目录,返回 (bundle_id, [(rel_path, size)])。
调用方须先过 validate_bundle;目录是全新 uuid 子目录,里面
不会有符号链接,写盘按相对路径逐级建目录。"""
调用方须先过 validate_bundle;这里再逐路径校验一次(纵深
防御:直接调本函数的调用方漏了校验也不至于把 ../ 写出包外)。
目录是全新 uuid 子目录,里面不会有符号链接,写盘按相对路径
逐级建目录。"""
bundle_id = uuid.uuid4().hex
bundle_dir = os.path.join(root, bundle_id)
os.makedirs(bundle_dir, exist_ok=False)
out = []
for path, data in zip(paths, datas):
err = validate_rel_path(path)
if err:
raise ValueError(err)
dest = os.path.join(bundle_dir, path)
os.makedirs(os.path.dirname(dest), exist_ok=True)
with open(dest, "wb") as f:
@@ -170,4 +175,6 @@ def parse_paths_field(fields, files):
if not isinstance(paths, list) or not all(
isinstance(p, str) for p in paths):
raise ValueError("paths 必须是字符串数组")
if len(paths) != len(files):
raise ValueError("附件路径与文件数量不一致")
return paths