A local Agent may modify only an independent copy in the system temporary directory. Upload is allowed only after the Workspace is confirmed as status=active, workspace connect has returned ssh_binding_status=bound and ssh_verified=true, the developer has explicitly authorized this synchronization, and the target path has been confirmed.
Save the original path and SHA-256, and treat the source file as read-only. Never apply an in-place patch or formatter, overwrite it through redirection, or save over it from an editor.
Copy only the files that need changes in this run. Point every editor, patch, generator, and formatter at that temporary directory.
Show the diff between the source and copy, run syntax/format checks appropriate to the target language, and confirm that the copy contains no Secrets, sessions, or caches.
Reuse the existing workspace_id with workspace status. If it is active, run workspace connect with an existing local key. Connection information is usable only when the result reports ssh_binding_status=bound and ssh_verified=true. Without explicit authorization to synchronize, stop at the local-diff stage.
Use the complete SCP command returned by the successful workspace connect result to transfer the copy into /oasn/.oasn-staging/<run-id>/. Do not overwrite the final target directly.
Enter the SSH session returned by the same successful connection result and verify the digest of the remote staged file. Only after it matches may you copy or install the staged file at the confirmed target.
After business validation, remove only the temporary and staging directories created by this run. Finally, recalculate the developer's original file digest; it must be identical to the value from step 1.
source_file="<developer-file>"
file_name="<file-name>"
sha256_file() {
if command -v sha256sum >/dev/null 2>&1; then
sha256sum -- "$1" | awk '{print $1}'
else
shasum -a 256 "$1" | awk '{print $1}'
fi
}
source_hash="$(sha256_file "$source_file")"
work_dir="$(mktemp -d "${TMPDIR:-/tmp}/oasn-sa-dev.XXXXXX")"
copy_file="$work_dir/$file_name"
cp -p -- "$source_file" "$copy_file"
copy_hash="$(sha256_file "$copy_file")"
printf 'source=%s\ncopy=%s\n' "$source_hash" "$copy_hash"
git diff --no-index -- "$source_file" "$copy_file"
git diff --no-index exits with code 1 when it finds the expected differences. That is not a validation failure.
$sourceFile = "<developer-file>"
$workDir = Join-Path ([System.IO.Path]::GetTempPath()) ("oasn-sa-dev-" + [guid]::NewGuid())
New-Item -ItemType Directory -Path $workDir | Out-Null
$copyFile = Join-Path $workDir "<file-name>"
Copy-Item -LiteralPath $sourceFile -Destination $copyFile
$sourceHash = (Get-FileHash -Algorithm SHA256 -LiteralPath $sourceFile).Hash
$copyHash = (Get-FileHash -Algorithm SHA256 -LiteralPath $copyFile).Hash
"source=$sourceHash"
"copy=$copyHash"
Replace <developer-file> and <file-name> with the single target confirmed for this run. Do not use broad globs, and do not copy an entire user directory or repository.
.env, Token, Cookie, private key, browser data, session, log, .git, or cache.workspace_id has returned active from workspace status, and workspace connect has returned ssh_binding_status=bound and ssh_verified=true for an existing local key./oasn in the current Workspace.A successful workspace connect result supplies complete SSH/SCP connection information. Copy that result; do not assemble a command from a URL, another Workspace, or history. In the returned SSH session, create an explicit staging directory for this run:
run_id="sync-$(date -u +%Y%m%dT%H%M%SZ)-$$"
stage_dir="/oasn/.oasn-staging/$run_id"
install -d -m 0700 -- "$stage_dir"
printf '%s\n' "$stage_dir"
The run_id must be unique to this run. The UTC time and current shell PID above generate a new directory; do not repeatedly reuse a literal placeholder. Then exit SSH and copy the complete scp_command from the successful connection result. Replace only its <file> with the local temporary copy and its final remote target with the stage_dir printed above. Preserve every connection parameter, including -P, -i, host, and user. After the upload, re-enter the same SSH session:
stage_dir="/oasn/.oasn-staging/<run-id>"
stage_file="$stage_dir/<file-name>"
test -f "$stage_file"
sha256sum -- "$stage_file"
Compare the first remote column exactly with the copy_hash/$copyHash recorded before upload. Stop if they differ. The following is a complete example of applying one ordinary Program file as /oasn/AGENTS.md. For any other target, first change target_file to the confirmed path under /oasn and choose permissions appropriate to that file. Do not copy this procedure unchanged for a Secret, directory, or executable.
Still in the same verified Workspace SSH session, set the staging directory printed for this run. The commands preserve a temporary copy of the existing target and then install the new content with permissions for an ordinary read-only data file:
stage_dir="/oasn/.oasn-staging/<run-id>"
stage_file="$stage_dir/AGENTS.md"
target_file="/oasn/AGENTS.md"
backup_file="$stage_dir/AGENTS.md.before"
test -f "$stage_file"
test "$target_file" = "/oasn/AGENTS.md"
if test -e "$target_file"; then
cp -p -- "$target_file" "$backup_file"
fi
install -m 0644 -- "$stage_file" "$target_file"
sha256sum -- "$target_file"
sed -n '1,40p' -- "$target_file"
The target file's SHA-256 must still equal the local copy digest, and the first 40 lines must contain the expected content. Then open the WebChat URL for this Workspace and run both normal input and controlled failure cases. If the digest, content, or business behavior is wrong, roll back before cleaning the staging directory:
if test -f "$backup_file"; then
install -m 0644 -- "$backup_file" "$target_file"
else
rm -- "$target_file"
fi
The rollback branch deletes the newly created /oasn/AGENTS.md only if you confirmed that the target did not exist before this run. If the target is a protected location such as /root/.openclaw/openclaw.json, use sudo remotely only within the authorized scope, and first design validation and rollback steps specific to that file. Never use the original local developer file itself as a remote write target.
After both WebChat and the file digest pass, remove only the two known staged files from this run. If the directory contains anything unexpected, rmdir safely fails and preserves the evidence:
stage_dir="/oasn/.oasn-staging/<run-id>"
test "$stage_dir" = "/oasn/.oasn-staging/<run-id>"
rm -f -- "$stage_dir/AGENTS.md" "$stage_dir/AGENTS.md.before"
rmdir -- "$stage_dir"
Finally, return to the local terminal, confirm that the developer's original file digest never changed, and then delete only this run's unique temporary copy:
test "$(sha256_file "$source_file")" = "$source_hash"
case "$work_dir" in
"${TMPDIR:-/tmp}"/oasn-sa-dev.*) rm -rf -- "$work_dir" ;;
*) printf 'Refusing to clean unexpected path: %s\n' "$work_dir" >&2; exit 1 ;;
esac
if ((Get-FileHash -Algorithm SHA256 -LiteralPath $sourceFile).Hash -ne $sourceHash) {
throw "The developer's original file changed; stopping cleanup"
}
$expectedPrefix = Join-Path ([System.IO.Path]::GetTempPath()) "oasn-sa-dev-"
$resolvedWorkDir = (Resolve-Path -LiteralPath $workDir).Path
if (-not $resolvedWorkDir.StartsWith($expectedPrefix, [StringComparison]::OrdinalIgnoreCase)) {
throw "Refusing to clean unexpected path: $resolvedWorkDir"
}
Remove-Item -LiteralPath $resolvedWorkDir -Recurse -Force
workspace connect to bind and verify this Workspace before using its connection information.