diff --git a/harnesses/contexts/agent-repo/v1/init.sh b/harnesses/contexts/agent-repo/v1/init.sh index d5f58c6..a53c967 100644 --- a/harnesses/contexts/agent-repo/v1/init.sh +++ b/harnesses/contexts/agent-repo/v1/init.sh @@ -13,9 +13,10 @@ mkdir -p /workspace/.agent-output # Clone reference branches (AR-12, AR-13) if [ -n "${REFERENCE_BRANCHES:-}" ] && [ "${REFERENCE_BRANCHES:-}" != "[]" ]; then echo "Cloning reference branches..." - echo "$REFERENCE_BRANCHES" | python3 -c " + echo "$REFERENCE_BRANCHES" | python3 -u -c " import json, sys, subprocess, os refs = json.load(sys.stdin) +print(f'reference_branches loop: {len(refs)} entries') for ref in refs: name = ref.get('name', '') repo_url = ref.get('repo_url', '') @@ -24,20 +25,30 @@ for ref in refs: print(f'Cloning {repo_url} ({branch}) -> {dest}') # Full clone (no --depth) so AR-14a-seeded agent branches have visible # ancestry when pushed back to the agent-repo. Gitea rejects shallow - # pushes with "shallow update not allowed". Real incident: 2026-05-08 - # probe 7. The cost is a few extra MB on a tmpfs/PVC; acceptable. + # pushes with shallow-update-not-allowed. Real incident: 2026-05-08 + # probe 7. result = subprocess.run( ['git', 'clone', '--branch', branch, '-c', 'core.symlinks=false', repo_url, dest], capture_output=True, text=True ) + print(f'clone returncode={result.returncode}') + if result.stdout: + print(f'clone stdout (last 1KB): {result.stdout[-1000:]}') + if result.stderr: + print(f'clone stderr (last 1KB): {result.stderr[-1000:]}') if result.returncode != 0: - print(f'ERROR: Failed to clone {repo_url}: {result.stderr}', file=sys.stderr) + print(f'ERROR: Failed to clone {repo_url}', file=sys.stderr) sys.exit(1) # Strip any symlinks (security: prevent /proc/1/environ exfiltration) subprocess.run(['find', dest, '-type', 'l', '-exec', 'rm', '{}', ';']) # Make reference read-only - subprocess.run(['chmod', '-R', 'a-w', dest]) + chmod_r = subprocess.run(['chmod', '-R', 'a-w', dest], capture_output=True, text=True) + if chmod_r.returncode != 0: + print(f'WARNING: chmod returned {chmod_r.returncode}: {chmod_r.stderr[:300]}') + if not os.path.isdir(os.path.join(dest, '.git')): + print(f'ERROR: clone exit 0 but {dest}/.git missing', file=sys.stderr) + sys.exit(1) print(f'Cloned {name} successfully') " fi