Sharpen the sync evidence warning to non-card changes only

Why: evidence rows are written before their containing card commit, so a naive
HEAD-diff would flag every task's evidence as stale and train people to ignore
the warning.

Evidence: bash -n clean; the live task-sync for this task exercises the new
path (warning fires only when a non-.task diff follows an evidence row's HEAD).

Impact: scripts/task.sh cmd_sync now excludes .task from the staleness diff;
AGENTS.md wording aligned (three-output evidence via make evidence).

Refs: task card evidence table; guidelines verification.md tool-written rule.
This commit is contained in:
2026-10-05 10:51:39 +00:00
parent 6518f6ed0a
commit 0123cec450
3 changed files with 30 additions and 6 deletions
+6 -4
View File
@@ -189,14 +189,16 @@ cmd_sync() {
printf '| 同步前验收 | %s | %s | %s |\n' "$base" "$head" "$(date -u +%FT%TZ)" >> "$card"
git add "$card"
git commit -q -m "Record the sync checkpoint" || true
# [evidence] 同步改变了被测对象:卡片证据表中旧 HEAD 的行自动失效,关键检查须重跑。
local eh stale_ev="" short_head
# [evidence] 同步改变了被测对象:卡片证据表中旧 HEAD 的行,其后若有非 .task 变更则失效须重跑。
local eh stale_ev="" short_head changed
short_head=$(echo "$head" | cut -c1-10)
while IFS='|' read -r _ _ _ eh _ _ _; do
eh=$(echo "$eh" | tr -d ' `')
[ -n "$eh" ] && [ "$eh" != "$short_head" ] && stale_ev="$stale_ev $eh"
{ [ -n "$eh" ] && [ "$eh" != "$short_head" ]; } || continue
changed=$(git diff --name-only "${eh}" HEAD -- . ':(exclude).task' 2>/dev/null | head -1)
[ -n "$changed" ] && stale_ev="$stale_ev ${eh}"
done < <(grep -E '^\| [0-9]{4}-[0-9]{2}-[0-9]{2}T[^|]*\|' "$card" 2>/dev/null || true)
[ -n "$stale_ev" ] && echo "[evidence] WARN 证据表含旧被测 HEAD:$(echo $stale_ev | tr ' ' '\n' | sort -u | tr '\n' ' ')(≠ 当前 $short_head)——同步后关键检查须重跑并以 make evidence 重新写入"
[ -n "$stale_ev" ] && echo "[evidence] WARN 证据表被测 HEAD 落后且其后有非卡片变更:$(echo $stale_ev | tr ' ' '\n' | sort -u | tr '\n' ' ')(当前 $short_head)——关键检查须重跑并以 make evidence 重新写入"
else
echo "[warn] 找不到分支 ${branch} 的任务卡,同步记录未写入" >&2
fi