Repository navigation
Conversation
A same-chat reset replaces a session's managed worktree under the same key. An open editor retains only its content hash, so a save after the reset succeeded into the replacement workspace whenever the replacement held identical bytes, silently overwriting its file and violating the write-target contract. The session Files CAS token is now bound to the resolved session workspace root on both the read and the save, so a stale editor gets session_file_conflict and keeps its draft; a fresh read of the replacement authorizes a new edit. Node workspace inspection and stored repository artifacts keep the unbound content hash. Fixes openclaw#178310
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. What this changesThis PR binds session Files save tokens to the workspace root so stale editors cannot overwrite a replacement workspace with identical file contents. Example: Read README.md containing "base\n", reset the same chat, create a replacement worktree with identical README.md bytes, then save the original draft.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep open: this PR addresses a real workspace-target bug, but its token change breaks existing Files tests; the competing fixes do not yet establish a safely landable replacement. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe Gateway resolves session Files RPCs to a workspace, produces preview tokens, and passes conditional saves through the shared filesystem writer, which checks content and live authority before mutation. flowchart TD
A[Files editor] --> B[Session Files RPC]
B --> C[Current session workspace]
C --> D[Preview and workspace token]
D --> A
B --> E[Shared conditional writer]
E --> F[Workspace file]
Technical reviewBest possible solution: Keep the workspace precondition in the existing conditional-write owner and update its consumer tests without weakening content-conflict or live-authority checks. Do we have a high-confidence way to reproduce the issue? Current-main source and the maintainer's recorded lifecycle reproduction establish the identical-content overwrite path; this read-only review executed no target code. Is this the best way to solve the issue? Workspace-bound tokens repair the missing read-time target precondition using the existing writer and preserve unbound node/artifact behavior, but the existing Files test consumers must follow the changed token contract. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f1fd15fed562. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +35, Tests +79. Total +114 across 4 files. Added test files: 0. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 20, 2026, 7:16 AM ET / 11:16 UTC. |
|
Both review asks are addressed on the updated head (
Would a maintainer reopen this PR for re-review, or should I open a fresh one from the same branch? |
|
Superseded by #178336, which landed a protocol-level binding of Files edits to the original read roots with draft preservation and listing refresh — a more complete design than this hash-salt approach. Keeping this closed; no reopen needed. The test updates here remain useful evidence that the workspace-bound token contract is observable at the RPC boundary. |
Closes #178310
What Problem This Solves
Fixes: a session Files save can overwrite a replacement managed workspace after the same chat is reset, when the replacement holds the same relative path and identical bytes as the file the editor originally opened.
User Impact
User impact: an editor opened before the reset gets
session_file_conflicton save (its draft is preserved and a reload is offered) instead of silently overwriting the replacement workspace's file; a fresh read of the replacement authorizes a new edit as before.Why This Change Was Made
The Files CAS token was a plain content hash, so identical bytes in two different workspaces produced the same token; the write-target contract requires a user-bound write to retain its original target. The session Files read and save now derive the CAS token from the resolved session workspace root, so a token minted in the replaced worktree cannot authorize a save into its replacement. Only the Gateway session Files RPC opts in: the node workspace-inspection protocol and stored repository artifacts keep the unbound content hash, and a workspace-root path being recycled for a new worktree within one editor's lifetime is an accepted edge (named in the binding helper).
Evidence
src/gateway/server.sessions.create.workspace-policy.test.tsthrough the registered Gateway handlers and the real session/worktree lifecycle: read → same-chat reset → replacement worktree (new id, identicalbase\nbytes) → stale-hash save now fails withsession_file_conflictand leaves the replacement file untouched; a fresh read's save succeeds (red before: the stale save returned success and overwrote the replacement).