swg_write
Writes a workspace text file under a stale-write guard: acquire the path, write, commit, and keep the grant until released so concurrent agents cannot silently overwrite changes.
Instructions
Write a workspace text file (acquire -> write -> commit). In either mode the write takes a write grant on the path and keeps it after the write. When you finish writing a path, swg_release it: until you do, other opted-in agents that write it wait, for up to 30 minutes. On a refuse-mode server (SWG_ON_HELD=refuse) a success also carries opted_in: true when the write asked first, false when the path is not among the managed files, so the write took the file from any agent that held it. A refusal carries reason, recover and retryable; follow its next_step when it has one. DENIED with reason=stale_view if the file changed since you read it — a peer commit OR an out-of-band edit (another tool/editor): recover with swg_reacquire, then write FROM its bytes, never the content you just sent. The other reasons: other_holder (refuse mode only), another agent holds the path and nothing was written (recover=wait_then_reacquire); commit_preempted, a mid-write preempt (disk may hold un-versioned bytes; reacquire_and_reconcile); commit_unconfirmed, the bytes are on disk but may be unrecorded (recover=write_again); link_out_of_managed (refuse mode only), the path goes through a link to a file outside the managed files; handed_off, this session handed the path off; coordinator_failed, the coordinator failed while answering (recover=reacquire when an earlier attempt of this session still holds the path); coordinator_unavailable, it gave no usable answer or is not attached; caller_principal_absent, caller_principal_foreign or caller_principal_claimed, this session's caller principal was refused (swg_status shows principal_claim); internal_error, a failure with no recovery; invalid_path or io_error, a bad path or a disk failure. SINGLE-HOST only. Out of guarantee and NOT detected in v1: writers on different hosts or across a synced/network mount, divergent-history reconciliation, semantic correctness, server-enforced auto-merge.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"path": "<path>",
"content": "<content>"
},
"name": "swg_write"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| content | Yes |