Repository navigation
fix(runtime): identify workspaces by UUID marker - #1369
Conversation
likun666661
left a comment
There was a problem hiding this comment.
I found one blocking issue in the workspace marker adoption path.
adoptWorkspaceIdentityOnImport can construct a candidate marker that violates the reader's own invariants: at most 32 legacy aliases and at most 4 KiB of serialized marker data. replaceWorkspaceMarker renames that candidate over the durable marker before readWorkspaceMarker validates it.
I reproduced this with a valid marker containing 32 aliases. Adding one distinct legacyWorkspaceIdentity persisted a marker containing 33 aliases; the adoption call then threw invalid_workspace_marker, and every subsequent resolveWorkspaceIdentity call failed on the now-invalid durable marker. The same problem occurs when individually valid aliases produce a serialized marker larger than 4 KiB.
Please validate or bound the complete serialized candidate before replacing the existing marker. A regression test should also verify that a rejected adoption preserves the previous marker bytes exactly.
The overall direction looks sound: UUID revalidation, one-way legacy alias migration, diagnostic-only path changes, explicit storage-root adoption, and removal of the prompt-injection workaround all align with the intended cross-sandbox resume model. The marker write-boundary issue should be fixed before approval.
|
Thanks for catching this — fixed in The complete marker candidate is now validated before any temporary file is opened or the durable marker is replaced:
I also added regression coverage for both failure modes:
Both tests assert Validation completed: workspace identity tests 5/5, Storage typecheck, Biome lint/format, and 展开中文说明感谢指出这个问题,已在 现在会在打开临时文件或替换 durable marker 之前校验完整的 marker candidate:
同时补充了两种失败场景的回归测试:
两个测试都会验证返回 已完成验证:workspace identity 测试 5/5、Storage typecheck、Biome lint/format 以及 |
|
A portable UUID marker fixes the immediate identity mismatch caused by path, device, and inode changes. I think the issue can be smaller, though, and the runtime boundary needs one correction before this lands. With safe-boundary resume enabled,
Failure to establish resumability should make a new run non-resumable, not prevent it from running. Actual resume and pre-execution identity revalidation should remain fail closed. The marker owner should also keep its file out of user-visible Git status. Adding separate exceptions to the TUI and Desktop Git checks would duplicate the rule. Since this format has not shipped, I would remove migration from the old Storage-root adoption is explicitly listed in this issue, but the PR excludes the real Session Bundle importer and nothing in production calls the new API. I would prefer to add adoption with that importer, where the expected root ID, error handling, and end-to-end behavior are known. This is a scope suggestion rather than an implementation finding. The workspace and storage-root implementations also duplicate the same bounded, no-follow, synced, atomic marker I/O. They have already drifted: workspace temp-file cleanup ownership starts only after the write completes, unlike the existing storage-root path. A small internal storage primitive for marker reads, atomic publication, and cleanup would remove that duplication while leaving each marker's schema and identity rules with its current owner. A real tar/untar round trip should be required for this issue. The current archive test uses recursive 中文意见我倾向先把这个 issue 收回到用户真正需要的行为:workspace 换了路径或沙箱以后,恢复逻辑仍能认出它。 现在普通 turn 在真正开始前就必须写入 marker。这样有点本末倒置。只读目录会直接无法聊天;普通干净仓库则会多出一个未跟踪文件,导致 项目还没有发布的话,我不太建议继续维护旧的 我本地还复现了一个结果:adoption 可以先写入一个 4123-byte 的 marker,然后读端才发现超限。报错时原文件已经被替换,后续每次读取都会继续失败。如果作者决定保留 legacy migration,这里至少必须改成发布前校验,失败时原 marker 不动。 storage-root adoption 的确是 issue 明写的 scope。不过真实的 Session Bundle importer 又被排除在本 PR 之外,目前新增 API 也没有生产调用者。我更倾向等 importer 真正落地时一起实现;到那时 expected root ID、失败处理和端到端测试都有真实上下文。这个属于 scope 建议,可以由 issue 作者决定是否接受。 另外,两类 marker 正在分别维护同一套安全文件操作,包括大小限制、不跟随 symlink、临时文件、fsync、原子发布和失败清理。第二份实现已经出现清理时机不一致。可以收敛一个很小的 storage 内部 primitive,只管 marker 字节的安全读取和原子写入,UUID 与 storage-root 的业务规则仍留在各自模块。 最后,tar/untar 是 issue 明确写出的目标,应该用真实归档往返验证。当前递归 |
展开中文说明
概要
dev、ino和路径的 workspace identityfs:{dev}:{ino}:{path}AgentRun identitypendingCwdReminder提示词注入 workaround,同时保证旧 session 仍可读取实现细节
Workspace identity 现在保存在
.maka-workspace.json中,格式为workspace:v1:<uuid>。Marker 使用原子方式创建,并对文件大小、格式和 identity 冲突进行严格校验。Workspace 路径仍会保留在诊断信息中,但不再决定 continuation 能否恢复。Runtime 在 backend 执行前仍会重新校验 UUID,因此如果 marker 在规划完成后被替换,恢复会安全失败。
导入收养机制会保留复制过来的 workspace UUID。对于尚未包含 marker 的旧 bundle,importer 可以显式登记原来的 filesystem anchor。Storage root 也增加了独立的显式收养入口:保留原有
rootId,同时将解压目录的新dev和ino写回 marker。普通 storage-root resolution 的行为不变,在未经过显式收养前仍会拒绝复制出来的 root。CLI/Desktop 的
/move现在只持久化新的cwd。修改cwd本来就会使当前 backend 失效,因此下一轮会按照更新后的 session header 重建 backend。旧 session 文件中的pendingCwdReminder仍可读取,但 normalize 时会丢弃该字段。兼容性与安全性
workspaceIdentity字段rootIdpendingCwdReminder字段可读取,并在下次规范化写入时移除测试
git diff --check尚未运行完整的 Desktop Playwright E2E。现有 E2E 中也还没有 tar/untar 跨 sandbox resume 场景。
Summary
dev/ino/ path) with a versioned UUID markerfs:{dev}:{ino}:{path}AgentRun identities through marker aliasespendingCwdReminderprompt-injection workaround while preserving legacy session readabilityDetails
Workspace identity is now stored in
.maka-workspace.jsonasworkspace:v1:<uuid>. Marker creation is atomic, bounded, and rejects malformed or conflicting markers.Workspace paths remain available for diagnostics but no longer determine whether a continuation can resume. Runtime still revalidates the UUID immediately before backend execution, so replacing the marker after planning fails closed.
Import adoption preserves copied workspace UUIDs. Pre-marker imports may explicitly register their legacy filesystem anchor. Storage roots receive a separate explicit adoption path that preserves
rootIdwhile rebinding the extracted directory’s host-localdevandino. Normal storage-root resolution continues to reject copied roots until that import boundary is invoked.The CLI/Desktop
/movepath now persists only the newcwd. Updatingcwdalready invalidates the active backend, so the next turn rebuilds it from the updated session header. Existing session files containingpendingCwdReminderremain readable, but normalization drops the legacy field.Compatibility and safety
workspaceIdentityfieldrootIdpendingCwdReminderfields are accepted on read and removed on the next normalized writeTests
git diff --checkFull Desktop Playwright E2E was not run. The existing E2E suite does not currently contain a tar/untar cross-sandbox resume scenario.
Closes #1337