agent-exec transport 3d1dd4ef1d7a2e761c3af308dc662a98/0cfaf24c9ad2

This commit is contained in:
agent-exec-transport
2026-10-18 13:37:32 +00:00
parent 95d1718858
commit 9c0e765708
2 changed files with 18 additions and 9 deletions
+15 -8
View File
@@ -18,14 +18,15 @@ fetch_target() {
git rev-parse --verify "refs/remotes/origin/${TARGET_BRANCH}^{commit}" >/dev/null \
|| { echo "[verdict] REMOTE_UNVERIFIED — target commit missing" >&2; return 6; }
}
target_rewound() { # 0 仅当 origin 通告的目标提交本地可用且不是缓存 origin/<target> 的后代;不可达或无法比较返回 1
target_history() { # 输出 ok(远端不可查询/目标 ref 缺失/无缓存目标/通告提交为缓存后代)、rewound(回退或分叉)或 uncomparable(通告提交本地缺失或无法比较)
local cached advertised rc=0
cached=$(git rev-parse -q --verify "refs/remotes/origin/${TARGET_BRANCH}^{commit}" 2>/dev/null) || return 1
cached=$(git rev-parse -q --verify "refs/remotes/origin/${TARGET_BRANCH}^{commit}" 2>/dev/null) || { echo ok; return 0; }
advertised=$(git ls-remote origin "refs/heads/${TARGET_BRANCH}" 2>/dev/null \
| awk -v ref="refs/heads/${TARGET_BRANCH}" '$2 == ref && !seen { print $1; seen = 1 }') || return 1
[ -n "$advertised" ] && git cat-file -e "${advertised}^{commit}" 2>/dev/null || return 1
| awk -v ref="refs/heads/${TARGET_BRANCH}" '$2 == ref && !seen { print $1; seen = 1 }') || { echo ok; return 0; }
[ -n "$advertised" ] || { echo ok; return 0; }
git cat-file -e "${advertised}^{commit}" 2>/dev/null || { echo uncomparable; return 0; }
git merge-base --is-ancestor "$cached" "$advertised" 2>/dev/null || rc=$?
[ "$rc" -eq 1 ]
case "$rc" in 0) echo ok ;; 1) echo rewound ;; *) echo uncomparable ;; esac
}
check_worktree() { python3 "${SCRIPT_DIR}/check-worktree.py" "$1"; }
main_worktree_root() { git worktree list --porcelain -z | python3 -c 'import os,sys; print(os.fsdecode(sys.stdin.buffer.read().split(bytes([0]),1)[0][9:]))'; }
@@ -150,9 +151,15 @@ cmd_precheck() {
fi
if [ "$mode" = local ]; then
python3 "${SCRIPT_DIR}/evidence.py" --local-context --active || return 2
if [ "$remote_fresh" -eq 0 ] && target_rewound; then
echo "[verdict] REMOTE_UNVERIFIED — origin/${TARGET_BRANCH} rewound or diverged from the cached target; preserve local work and reconcile the target history"
return 6
if [ "$remote_fresh" -eq 0 ]; then
case "$(target_history)" in
rewound)
echo "[verdict] REMOTE_UNVERIFIED — origin/${TARGET_BRANCH} rewound or diverged from the cached target; preserve local work and reconcile the target history"
return 6 ;;
uncomparable)
echo "[verdict] REMOTE_UNVERIFIED — advertised origin/${TARGET_BRANCH} commit is missing locally and cannot be compared with the cached target; preserve local work and retry the refresh"
return 6 ;;
esac
fi
[ "$remote_fresh" -eq 1 ] || echo "[remote-freshness] unavailable — LOCAL_READY rests on local task context only"
echo "[verdict] LOCAL_READY — existing task may continue authorized local work; final delivery still requires latest-target sync and checks"