Skip to content

Commit d38c2af

Browse files
sjarmakclaude
andcommitted
fix: replace rsync with cp -a in sgonly verifier wrappers
rsync is not available in most base images (golang, python, ubuntu). The sgonly_verifier_wrapper.sh used rsync to restore /repo_full/ into /workspace before verification. Replaced with cp -a which is universally available. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 92f9ad5 commit d38c2af

File tree

136 files changed

+8976
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+8976
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
# SG-only verifier wrapper: restore full repo + overlay agent changes
3+
#
4+
# Source this at the TOP of test.sh for build-requiring tasks that use
5+
# sg_only_env mode. It detects /tmp/.sg_only_mode and:
6+
# 1. Identifies files the agent wrote (non-empty, non-git, non-test)
7+
# 2. Backs up those files to /tmp/agent_work/
8+
# 3. Restores the full repo from /repo_full/
9+
# 4. Overlays agent's changes on top
10+
#
11+
# For non-sg_only runs, this script is a no-op.
12+
#
13+
# Usage in test.sh:
14+
# #!/bin/bash
15+
# # Source the sg_only wrapper (no-op if not in sg_only mode)
16+
# if [ -f /tests/sgonly_verifier_wrapper.sh ]; then
17+
# source /tests/sgonly_verifier_wrapper.sh
18+
# fi
19+
# # ... rest of test.sh as normal ...
20+
21+
if [ ! -f /tmp/.sg_only_mode ]; then
22+
# Not in sg_only mode — nothing to do
23+
return 0 2>/dev/null || exit 0
24+
fi
25+
26+
echo "[sg_only_verifier] Detected sg_only mode, restoring full repo..."
27+
28+
# Read the working directory
29+
WORKDIR="$(cat /tmp/.sg_only_workdir 2>/dev/null || echo '/app')"
30+
echo "[sg_only_verifier] Working directory: $WORKDIR"
31+
32+
if [ ! -d /repo_full ]; then
33+
echo "[sg_only_verifier] WARNING: /repo_full not found, cannot restore"
34+
return 0 2>/dev/null || exit 0
35+
fi
36+
37+
# 1. Find files the agent wrote (non-empty, non-git, non-test files)
38+
cd "$WORKDIR"
39+
mkdir -p /tmp/agent_work
40+
AGENT_FILES=0
41+
find . -type f -size +0 ! -path './.git/*' ! -path './tests/*' ! -path './.claude/*' \
42+
-print0 | while IFS= read -r -d '' f; do
43+
mkdir -p "/tmp/agent_work/$(dirname "$f")"
44+
cp "$f" "/tmp/agent_work/$f"
45+
AGENT_FILES=$((AGENT_FILES + 1))
46+
done
47+
echo "[sg_only_verifier] Backed up agent-written files"
48+
49+
# 2. Restore full repo from backup
50+
# Remove old workspace content (except .git and agent output)
51+
find "$WORKDIR" -mindepth 1 -maxdepth 1 ! -name .git ! -name .claude -exec rm -rf {} + 2>/dev/null || true
52+
cp -a /repo_full/. "$WORKDIR/"
53+
echo "[sg_only_verifier] Restored full repo from /repo_full/"
54+
55+
# 3. Overlay agent's changes
56+
cd /tmp/agent_work
57+
find . -type f -print0 | while IFS= read -r -d '' f; do
58+
target="${WORKDIR}/${f#./}"
59+
mkdir -p "$(dirname "$target")"
60+
cp "$f" "$target"
61+
done
62+
echo "[sg_only_verifier] Overlaid agent changes"
63+
64+
# Return to working directory
65+
cd "$WORKDIR"
66+
echo "[sg_only_verifier] Restore complete, proceeding with tests"
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
# SG-only verifier wrapper: restore full repo + overlay agent changes
3+
#
4+
# Source this at the TOP of test.sh for build-requiring tasks that use
5+
# sg_only_env mode. It detects /tmp/.sg_only_mode and:
6+
# 1. Identifies files the agent wrote (non-empty, non-git, non-test)
7+
# 2. Backs up those files to /tmp/agent_work/
8+
# 3. Restores the full repo from /repo_full/
9+
# 4. Overlays agent's changes on top
10+
#
11+
# For non-sg_only runs, this script is a no-op.
12+
#
13+
# Usage in test.sh:
14+
# #!/bin/bash
15+
# # Source the sg_only wrapper (no-op if not in sg_only mode)
16+
# if [ -f /tests/sgonly_verifier_wrapper.sh ]; then
17+
# source /tests/sgonly_verifier_wrapper.sh
18+
# fi
19+
# # ... rest of test.sh as normal ...
20+
21+
if [ ! -f /tmp/.sg_only_mode ]; then
22+
# Not in sg_only mode — nothing to do
23+
return 0 2>/dev/null || exit 0
24+
fi
25+
26+
echo "[sg_only_verifier] Detected sg_only mode, restoring full repo..."
27+
28+
# Read the working directory
29+
WORKDIR="$(cat /tmp/.sg_only_workdir 2>/dev/null || echo '/app')"
30+
echo "[sg_only_verifier] Working directory: $WORKDIR"
31+
32+
if [ ! -d /repo_full ]; then
33+
echo "[sg_only_verifier] WARNING: /repo_full not found, cannot restore"
34+
return 0 2>/dev/null || exit 0
35+
fi
36+
37+
# 1. Find files the agent wrote (non-empty, non-git, non-test files)
38+
cd "$WORKDIR"
39+
mkdir -p /tmp/agent_work
40+
AGENT_FILES=0
41+
find . -type f -size +0 ! -path './.git/*' ! -path './tests/*' ! -path './.claude/*' \
42+
-print0 | while IFS= read -r -d '' f; do
43+
mkdir -p "/tmp/agent_work/$(dirname "$f")"
44+
cp "$f" "/tmp/agent_work/$f"
45+
AGENT_FILES=$((AGENT_FILES + 1))
46+
done
47+
echo "[sg_only_verifier] Backed up agent-written files"
48+
49+
# 2. Restore full repo from backup
50+
# Remove old workspace content (except .git and agent output)
51+
find "$WORKDIR" -mindepth 1 -maxdepth 1 ! -name .git ! -name .claude -exec rm -rf {} + 2>/dev/null || true
52+
cp -a /repo_full/. "$WORKDIR/"
53+
echo "[sg_only_verifier] Restored full repo from /repo_full/"
54+
55+
# 3. Overlay agent's changes
56+
cd /tmp/agent_work
57+
find . -type f -print0 | while IFS= read -r -d '' f; do
58+
target="${WORKDIR}/${f#./}"
59+
mkdir -p "$(dirname "$target")"
60+
cp "$f" "$target"
61+
done
62+
echo "[sg_only_verifier] Overlaid agent changes"
63+
64+
# Return to working directory
65+
cd "$WORKDIR"
66+
echo "[sg_only_verifier] Restore complete, proceeding with tests"
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
# SG-only verifier wrapper: restore full repo + overlay agent changes
3+
#
4+
# Source this at the TOP of test.sh for build-requiring tasks that use
5+
# sg_only_env mode. It detects /tmp/.sg_only_mode and:
6+
# 1. Identifies files the agent wrote (non-empty, non-git, non-test)
7+
# 2. Backs up those files to /tmp/agent_work/
8+
# 3. Restores the full repo from /repo_full/
9+
# 4. Overlays agent's changes on top
10+
#
11+
# For non-sg_only runs, this script is a no-op.
12+
#
13+
# Usage in test.sh:
14+
# #!/bin/bash
15+
# # Source the sg_only wrapper (no-op if not in sg_only mode)
16+
# if [ -f /tests/sgonly_verifier_wrapper.sh ]; then
17+
# source /tests/sgonly_verifier_wrapper.sh
18+
# fi
19+
# # ... rest of test.sh as normal ...
20+
21+
if [ ! -f /tmp/.sg_only_mode ]; then
22+
# Not in sg_only mode — nothing to do
23+
return 0 2>/dev/null || exit 0
24+
fi
25+
26+
echo "[sg_only_verifier] Detected sg_only mode, restoring full repo..."
27+
28+
# Read the working directory
29+
WORKDIR="$(cat /tmp/.sg_only_workdir 2>/dev/null || echo '/app')"
30+
echo "[sg_only_verifier] Working directory: $WORKDIR"
31+
32+
if [ ! -d /repo_full ]; then
33+
echo "[sg_only_verifier] WARNING: /repo_full not found, cannot restore"
34+
return 0 2>/dev/null || exit 0
35+
fi
36+
37+
# 1. Find files the agent wrote (non-empty, non-git, non-test files)
38+
cd "$WORKDIR"
39+
mkdir -p /tmp/agent_work
40+
AGENT_FILES=0
41+
find . -type f -size +0 ! -path './.git/*' ! -path './tests/*' ! -path './.claude/*' \
42+
-print0 | while IFS= read -r -d '' f; do
43+
mkdir -p "/tmp/agent_work/$(dirname "$f")"
44+
cp "$f" "/tmp/agent_work/$f"
45+
AGENT_FILES=$((AGENT_FILES + 1))
46+
done
47+
echo "[sg_only_verifier] Backed up agent-written files"
48+
49+
# 2. Restore full repo from backup
50+
# Remove old workspace content (except .git and agent output)
51+
find "$WORKDIR" -mindepth 1 -maxdepth 1 ! -name .git ! -name .claude -exec rm -rf {} + 2>/dev/null || true
52+
cp -a /repo_full/. "$WORKDIR/"
53+
echo "[sg_only_verifier] Restored full repo from /repo_full/"
54+
55+
# 3. Overlay agent's changes
56+
cd /tmp/agent_work
57+
find . -type f -print0 | while IFS= read -r -d '' f; do
58+
target="${WORKDIR}/${f#./}"
59+
mkdir -p "$(dirname "$target")"
60+
cp "$f" "$target"
61+
done
62+
echo "[sg_only_verifier] Overlaid agent changes"
63+
64+
# Return to working directory
65+
cd "$WORKDIR"
66+
echo "[sg_only_verifier] Restore complete, proceeding with tests"
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
# SG-only verifier wrapper: restore full repo + overlay agent changes
3+
#
4+
# Source this at the TOP of test.sh for build-requiring tasks that use
5+
# sg_only_env mode. It detects /tmp/.sg_only_mode and:
6+
# 1. Identifies files the agent wrote (non-empty, non-git, non-test)
7+
# 2. Backs up those files to /tmp/agent_work/
8+
# 3. Restores the full repo from /repo_full/
9+
# 4. Overlays agent's changes on top
10+
#
11+
# For non-sg_only runs, this script is a no-op.
12+
#
13+
# Usage in test.sh:
14+
# #!/bin/bash
15+
# # Source the sg_only wrapper (no-op if not in sg_only mode)
16+
# if [ -f /tests/sgonly_verifier_wrapper.sh ]; then
17+
# source /tests/sgonly_verifier_wrapper.sh
18+
# fi
19+
# # ... rest of test.sh as normal ...
20+
21+
if [ ! -f /tmp/.sg_only_mode ]; then
22+
# Not in sg_only mode — nothing to do
23+
return 0 2>/dev/null || exit 0
24+
fi
25+
26+
echo "[sg_only_verifier] Detected sg_only mode, restoring full repo..."
27+
28+
# Read the working directory
29+
WORKDIR="$(cat /tmp/.sg_only_workdir 2>/dev/null || echo '/app')"
30+
echo "[sg_only_verifier] Working directory: $WORKDIR"
31+
32+
if [ ! -d /repo_full ]; then
33+
echo "[sg_only_verifier] WARNING: /repo_full not found, cannot restore"
34+
return 0 2>/dev/null || exit 0
35+
fi
36+
37+
# 1. Find files the agent wrote (non-empty, non-git, non-test files)
38+
cd "$WORKDIR"
39+
mkdir -p /tmp/agent_work
40+
AGENT_FILES=0
41+
find . -type f -size +0 ! -path './.git/*' ! -path './tests/*' ! -path './.claude/*' \
42+
-print0 | while IFS= read -r -d '' f; do
43+
mkdir -p "/tmp/agent_work/$(dirname "$f")"
44+
cp "$f" "/tmp/agent_work/$f"
45+
AGENT_FILES=$((AGENT_FILES + 1))
46+
done
47+
echo "[sg_only_verifier] Backed up agent-written files"
48+
49+
# 2. Restore full repo from backup
50+
# Remove old workspace content (except .git and agent output)
51+
find "$WORKDIR" -mindepth 1 -maxdepth 1 ! -name .git ! -name .claude -exec rm -rf {} + 2>/dev/null || true
52+
cp -a /repo_full/. "$WORKDIR/"
53+
echo "[sg_only_verifier] Restored full repo from /repo_full/"
54+
55+
# 3. Overlay agent's changes
56+
cd /tmp/agent_work
57+
find . -type f -print0 | while IFS= read -r -d '' f; do
58+
target="${WORKDIR}/${f#./}"
59+
mkdir -p "$(dirname "$target")"
60+
cp "$f" "$target"
61+
done
62+
echo "[sg_only_verifier] Overlaid agent changes"
63+
64+
# Return to working directory
65+
cd "$WORKDIR"
66+
echo "[sg_only_verifier] Restore complete, proceeding with tests"
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
# SG-only verifier wrapper: restore full repo + overlay agent changes
3+
#
4+
# Source this at the TOP of test.sh for build-requiring tasks that use
5+
# sg_only_env mode. It detects /tmp/.sg_only_mode and:
6+
# 1. Identifies files the agent wrote (non-empty, non-git, non-test)
7+
# 2. Backs up those files to /tmp/agent_work/
8+
# 3. Restores the full repo from /repo_full/
9+
# 4. Overlays agent's changes on top
10+
#
11+
# For non-sg_only runs, this script is a no-op.
12+
#
13+
# Usage in test.sh:
14+
# #!/bin/bash
15+
# # Source the sg_only wrapper (no-op if not in sg_only mode)
16+
# if [ -f /tests/sgonly_verifier_wrapper.sh ]; then
17+
# source /tests/sgonly_verifier_wrapper.sh
18+
# fi
19+
# # ... rest of test.sh as normal ...
20+
21+
if [ ! -f /tmp/.sg_only_mode ]; then
22+
# Not in sg_only mode — nothing to do
23+
return 0 2>/dev/null || exit 0
24+
fi
25+
26+
echo "[sg_only_verifier] Detected sg_only mode, restoring full repo..."
27+
28+
# Read the working directory
29+
WORKDIR="$(cat /tmp/.sg_only_workdir 2>/dev/null || echo '/app')"
30+
echo "[sg_only_verifier] Working directory: $WORKDIR"
31+
32+
if [ ! -d /repo_full ]; then
33+
echo "[sg_only_verifier] WARNING: /repo_full not found, cannot restore"
34+
return 0 2>/dev/null || exit 0
35+
fi
36+
37+
# 1. Find files the agent wrote (non-empty, non-git, non-test files)
38+
cd "$WORKDIR"
39+
mkdir -p /tmp/agent_work
40+
AGENT_FILES=0
41+
find . -type f -size +0 ! -path './.git/*' ! -path './tests/*' ! -path './.claude/*' \
42+
-print0 | while IFS= read -r -d '' f; do
43+
mkdir -p "/tmp/agent_work/$(dirname "$f")"
44+
cp "$f" "/tmp/agent_work/$f"
45+
AGENT_FILES=$((AGENT_FILES + 1))
46+
done
47+
echo "[sg_only_verifier] Backed up agent-written files"
48+
49+
# 2. Restore full repo from backup
50+
# Remove old workspace content (except .git and agent output)
51+
find "$WORKDIR" -mindepth 1 -maxdepth 1 ! -name .git ! -name .claude -exec rm -rf {} + 2>/dev/null || true
52+
cp -a /repo_full/. "$WORKDIR/"
53+
echo "[sg_only_verifier] Restored full repo from /repo_full/"
54+
55+
# 3. Overlay agent's changes
56+
cd /tmp/agent_work
57+
find . -type f -print0 | while IFS= read -r -d '' f; do
58+
target="${WORKDIR}/${f#./}"
59+
mkdir -p "$(dirname "$target")"
60+
cp "$f" "$target"
61+
done
62+
echo "[sg_only_verifier] Overlaid agent changes"
63+
64+
# Return to working directory
65+
cd "$WORKDIR"
66+
echo "[sg_only_verifier] Restore complete, proceeding with tests"

0 commit comments

Comments
 (0)