From d6df427e39e2dd8f57d51d04318dedffff96523a Mon Sep 17 00:00:00 2001 From: agent-exec-transport Date: Sun, 18 Oct 2026 11:12:05 +0000 Subject: [PATCH] agent-exec transport 3fe48cd812763be825a67eebc5ea78f6/a9ce16b6d684 --- scripts/task.sh | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/scripts/task.sh b/scripts/task.sh index a64e6d01..2d908fd8 100755 --- a/scripts/task.sh +++ b/scripts/task.sh @@ -31,19 +31,31 @@ cmd_precheck() { need_repo local mode mode=$(work_mode) - fetch_target - local branch head rmain dirty sub_drift sub_uninit + # local 模式刷新失败只标记远端新鲜度不可用,不拿缓存远端引用冒充最新;delivery 保持 REMOTE_UNVERIFIED。 + local remote_fresh=1 fetch_err="" + if [ "$mode" = local ]; then + git check-ref-format "refs/heads/${TARGET_BRANCH}" >/dev/null || die "invalid target branch" + fetch_err=$(fetch_target 2>&1 >/dev/null) || remote_fresh=0 + else + fetch_target + fi + local branch head rmain="" dirty sub_drift sub_uninit branch=$(git rev-parse --abbrev-ref HEAD) head=$(git rev-parse HEAD) - rmain=$(git rev-parse --verify "origin/${TARGET_BRANCH}") + [ "$remote_fresh" -eq 1 ] && rmain=$(git rev-parse --verify "origin/${TARGET_BRANCH}") dirty=$(git status --porcelain | { grep -v '^.. \.zcode/' || true; } | wc -l) sub_drift=$(git submodule status --recursive 2>/dev/null | { grep -cE '^\+|^U' || true; }) sub_uninit=$(git submodule status --recursive 2>/dev/null | { grep -cE '^-' || true; }) - local behind ahead - behind=$(git rev-list --count "HEAD..origin/${TARGET_BRANCH}") - ahead=$(git rev-list --count "origin/${TARGET_BRANCH}..HEAD") + local behind=0 ahead=0 echo "[repo] branch=${branch} head=$(echo "$head" | cut -c1-10)" - echo "[remote] origin/${TARGET_BRANCH}=$(echo "$rmain" | cut -c1-10) ahead=${ahead} behind=${behind}" + if [ "$remote_fresh" -eq 1 ]; then + behind=$(git rev-list --count "HEAD..origin/${TARGET_BRANCH}") + ahead=$(git rev-list --count "origin/${TARGET_BRANCH}..HEAD") + echo "[remote] origin/${TARGET_BRANCH}=$(echo "$rmain" | cut -c1-10) ahead=${ahead} behind=${behind}" + else + echo "[remote] origin/${TARGET_BRANCH}=unavailable — refresh failed; remote freshness unverified (cached ref not used)" + [ -n "$fetch_err" ] && printf '%s\n' "$fetch_err" | sed -e '/^\[verdict\]/d' -e 's/^/[remote] /' + fi echo "[tree] $([ "$dirty" -eq 0 ] && echo clean || echo "dirty(${dirty})") submodules_drift=${sub_drift} uninit=${sub_uninit}" local wt merged wt=$(git worktree list | tail -n +2 | wc -l) @@ -116,7 +128,9 @@ cmd_precheck() { echo "[facts] WARN policy/facts.md 不存在——外部事实登记表缺失(AGENTS.md 证据与验证门禁)" fi echo "[required-reading] core/baseline.md, workflows/delivery.md §1$([ -f policy/delivery.md ] && echo ", policy/delivery.md")$([ "$dirty" -gt 0 ] && echo ", standards/collaboration.md(树脏=他人或未收尾现场,不得写入)")" - if [ "$mode" = local ]; then + if [ "$mode" = local ] && [ "$remote_fresh" -eq 0 ]; then + echo "[target] unavailable(remote freshness unverified; task initial baseline is reported separately)" + elif [ "$mode" = local ]; then echo "[target] ${rmain}(observed; task initial baseline is reported separately)" else echo "[R0] $(echo "$rmain" | cut -c1-10)(完整:$rmain)" @@ -127,6 +141,7 @@ cmd_precheck() { fi if [ "$mode" = local ]; then python3 "${SCRIPT_DIR}/evidence.py" --local-context || return 2 + [ "$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" return 0 fi