fix(selfHosted): align worker workspace layout - #16
Merged
Conversation
## 简述 统一 self-hosted worker 的工作目录语义并对齐 CMA,同时修正内部隐藏目录命名,并隔离不同 session 的工具结果恢复账本。 ## 修改前 - Run 模式会把配置的 Workdir 当作根目录,并自动追加 session ID。 - HandleItem 模式直接使用配置的 Workdir,两种入口行为不一致。 - 工具结果账本使用 `.ma_self_host_worker/tool_ledger`。 - Workdir 扁平化后,如果账本仍直接放在共享 Workdir 下,旧 session 的 pending tool result 可能被恢复到新 session。 ## 修改后 - Run 和 HandleItem 都直接使用配置的 Workdir,不再自动创建 session ID 子目录。 - Skill 在两种模式下都安装到 `<Workdir>/skills/<skill_name>`,与 CMA 一致。 - EnvironmentWorker 的工具结果账本改为 `<Workdir>/.ma_self_hosted_worker/tool_ledger/<session_id>`,避免跨 session 恢复和误投递。 - 非法路径字符的 session ID 会映射为稳定哈希目录,避免路径逃逸。 - 保留 `FileToolResultStore(workdir)` 的原有调用方式;EnvironmentWorker 传入 session ID 启用隔离。 - 删除不再需要的 session workdir 计算逻辑,并增加目录、安全与跨 session 隔离回归测试。 ## 兼容边界 - 多个并发 worker 需要工具文件隔离时,应由调用方分别配置独立 Workdir。 - 不自动迁移旧 `.ma_self_host_worker` 账本:旧共享账本无法可靠判定记录所属 session,自动搬迁存在误投递风险。 ## 验证 - Python 全量测试:54 passed - `ruff check src/` 通过 - `ruff format --check src/` 通过 - `test/run.sh --sdk` 真实 STG 三语言 smoke:Go、Python 通过;Java 首轮遇到模型限流,单 case 重跑通过 ## 二次 Review 修复 - 共享 Workdir 下,tool-result ledger 按 session 隔离,避免旧 session 的结果被新 session 恢复或误投递。 - worker 结束时只清理本轮成功安装的 skill 目录,保留 `skills/` 根目录及非 SDK 管理内容,避免 skill 跨 session 泄漏;该生命周期与 CMA 的 Cleanup 行为一致。 ## 补充验证 - `.venv/bin/pytest -q`(54 passed)、ruff check/format - STG 真实 SkillHub + 私有 skill 下载通过,且 Python worker 均真实执行 Python/Java 版本命令。 See merge request: !93 Sync-Source-Commit: 890523c9625536ca93332db652054be572e50a10 Hand-Written-Reason: No Ark-APIs provenance marker; treated as a hand-written source commit. Release-Version: 0.4.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hand-written change from the internal SDK repository — not produced by
make vendor.fix(selfHosted): align worker workspace layoutSync-Source-Commit: 890523c9625536ca93332db652054be572e50a10
Hand-Written-Reason: No Ark-APIs provenance marker; treated as a hand-written source commit.
Release-Version: 0.4.0
Created by ark-hand.