Skip to content

Optimistic concurrency

content_hash is FNV-1a, 8 hex digits, of the full file bytes. Range, head, tail, and base64 reads still return that full-file hash. Pass it as expected_hash on the next edit_file, multi_edit, or single-file apply_patch.

If the file changed, the edit is rejected. The envelope code is OCC_MISMATCH. retryable is true. recovery is read_and_rebase. The body includes expected_hash, current_hash, and a conflict report (changed_ranges). A bounded diff is included only when include_diff:true or detail:"full".

write_file records the post-write hash from the reopened host file. Chain write_file to edit_file(expected_hash: <hash from write>). That does not look like an external change.

Applies when the edit omits expected_hash. The session stores the hash of each read and of its own writes. It flags external changes, not the session’s own edits.

ValueEffect
offNo automatic check.
warnDefault. Edit proceeds. A non-blocking notice is appended.
blockEdit is rejected. Code HASH_REQUIRED. retryable is true. Read the file and resend with expected_hash.

dry_run does not write and does not update the undo chain.

git(action:"review") and paged git diff use a separate token, status_hash. A mismatch is STALE_GIT (retryable true, recovery read_and_rebase) and returns no diff body.