tao.chen and Claude
573397dbb4
tools: persist spark_submit calls to SubmissionRepo
...
Co-Authored-By: Claude <noreply@anthropic.com >
2026-07-14 13:45:07 +08:00
tao.chen and Claude
876f1c9edb
uploads: dual-write uploads to DB, startup backfill, and audit log
...
Store now indexes every Save into the upload_files table via SetRepo.
DB failures are logged as warnings and do not fail the upload because
.meta.json remains the source of truth and startup backfill recovers.
Add Store.Backfill to walk Root at startup and insert index rows for
any pre-existing .meta.json sidecars, swallowing duplicate-key races.
The upload_file MCP Tool now writes an audit_log entry on success.
Tests cover dual-write args, repo-error non-failure, and backfill
skipping existing rows.
Co-Authored-By: Claude <noreply@anthropic.com >
2026-07-14 11:30:39 +08:00
tao.chen and Claude
f374ebfdb4
uploads,tools,config,main: 将 upload_file 返回路径改为服务器端绝对路径并透传给 spark_submit
...
之前 upload_file 把文件写到 DataDir/uploads/<filename>,返回相对路径
uploads/hello.txt。MCP 服务器与 agent 不在同一台机器,agent 无法构造服务
器本地路径,因此 spark_submit 无法定位脚本。
改为由新的 internal/uploads 包 mint 一个 32 字符十六进制 file_id,文件落盘为
DataDir/uploads/<file_id>,元数据写入 <file_id>.meta.json(原始文件名只存在
sidecar 里)。upload_file 返回 {file_id, path, name, size, sha256},其中 path
是绝对路径。spark_submit 的 description 明确要求 LLM 直接把 upload_file 返回
的 path 放进 args,不要自己构造路径。
为什么只在描述里约束而不在代码里拒绝非 mint 的绝对路径:集群本地已有路径
(如 /opt/spark/examples/pi.py)是合法的 spark-submit 参数,代码不能替
LLM 拒绝。
测试锁定:
- internal/uploads: Save 往返、AbsPath/Validate 非法路径、Sweep 过期/未过期/
孤立 sidecar
- internal/mcp/tools: upload_file 新响应字段、spark_submit 透传 mint 路径与
集群本地路径
刻意未做:S3/HDFS 上传、给 spark_submit 新增 file_id 参数、在代码层面拒绝
集群本地绝对路径。
破坏性变更:upload_file 响应从相对 path 改为绝对 path,并新增 file_id/name/
sha256 字段。该工具尚无外部调用者。
Co-Authored-By: Claude <noreply@anthropic.com >
2026-07-13 19:13:14 +08:00
tao.chen and Claude
d4ad97f595
Phase 5 Batch 3: fetch_url + upload_file Tool (底层原语)
...
- fetch_url: 通用 HTTP 原语
- host allowlist 校验 (cluster.URLAllowlist + RM/SHS host 兜底)
- 复用 httpclient.ApplyAuth + DoWithRedirect
- mcp.WithEnum 约束 method
- 单元测试: 9 子测试 (basic auth 透传 + 跨主机 redirect 保留 auth)
- upload_file: 本地文件存储 (供 spark_submit 引用)
- filename sanitize: [a-zA-Z0-9._-], 拒绝路径逃逸
- filepath.Base 二次校验
- 写到 <DataDir>/uploads/<name>, 权限 0640
- 单元测试: 路径遍历全部拒绝
- deps.go: +DataDir
- main.go: 注入 cfg.DataDir
- 端到端实测: upload_file + spark_submit 引用上传脚本
Co-Authored-By: Claude <noreply@anthropic.com >
2026-07-10 16:52:10 +08:00