test: pin injected staleness boundary

This commit is contained in:
codex-bot-andresmgsl 2026-07-23 10:30:34 +00:00
parent 1030634b09
commit d0f1a43064
2 changed files with 14 additions and 9 deletions

View file

@ -95,6 +95,10 @@ claim_decision() { # $1 assignee count, $2 linked open PR, $3 age seconds
fi fi
} }
claim_decision_at() { # $1 assignee count, $2 linked open PR, $3 last activity epoch
claim_decision "$1" "$2" "$((NOW - $3))"
}
blocked_references() { # body on stdin -> issue numbers, one per line blocked_references() { # body on stdin -> issue numbers, one per line
sed -nE 's/.*Blocked by[[:space:]]+//Ip' \ sed -nE 's/.*Blocked by[[:space:]]+//Ip' \
| sed -E 's/[.;][[:space:]].*$//' \ | sed -E 's/[.;][[:space:]].*$//' \
@ -175,8 +179,8 @@ reconcile_issue() {
if has_issue_label claimed; then if has_issue_label claimed; then
assignees="$(jq '.assignees | length' <<<"$ISSUE_JSON")" assignees="$(jq '.assignees | length' <<<"$ISSUE_JSON")"
grep -qxF "$n" <<<"${OPEN_PR_ISSUES:-}" && open_pr=true grep -qxF "$n" <<<"${OPEN_PR_ISSUES:-}" && open_pr=true
age=$((NOW - $(last_issue_activity "$n" "$(jq -r '.created_at' <<<"$ISSUE_JSON")"))) age="$(last_issue_activity "$n" "$(jq -r '.created_at' <<<"$ISSUE_JSON")")"
decision="$(claim_decision "$assignees" "$open_pr" "$age")" decision="$(claim_decision_at "$assignees" "$open_pr" "$age")"
case "$decision" in case "$decision" in
FLAG_UNASSIGNED) FLAG_UNASSIGNED)
ensure_comment "$n" claimed-unassigned \ ensure_comment "$n" claimed-unassigned \

View file

@ -31,18 +31,19 @@ check "needs-triage plus queue is a conflict" 0 "FLAG_CONFLICT" queue_decision <
# Invariant 2: claims have an owner and either a PR or recent activity. # Invariant 2: claims have an owner and either a PR or recent activity.
check "claim with open PR stays claimed" 0 "KEEP" claim_decision 1 true 999999 check "claim with open PR stays claimed" 0 "KEEP" claim_decision 1 true 999999
check "claim below stale boundary stays claimed" 0 "KEEP" claim_decision 1 false $((STALE_AFTER - 1))
check "claim exactly at stale boundary stays claimed" 0 "KEEP" claim_decision 1 false "$STALE_AFTER"
check "claim past stale boundary is reclaimed" 0 "RECLAIM" claim_decision 1 false $((STALE_AFTER + 1))
check "unassigned claim is flagged" 0 "FLAG_UNASSIGNED" claim_decision 0 false 60 check "unassigned claim is flagged" 0 "FLAG_UNASSIGNED" claim_decision 0 false 60
check "quiet unassigned claim is also reclaimed" 0 "RECLAIM" claim_decision 0 false $((STALE_AFTER + 1)) check "quiet unassigned claim is also reclaimed" 0 "RECLAIM" claim_decision 0 false $((STALE_AFTER + 1))
# shellcheck disable=SC2016 # expansions belong to the isolated bash -c process # shellcheck disable=SC2016 # expansions belong to the isolated bash -c process
check "injected clock is retained" 0 "1700000000" \ check "injected clock: below stale boundary stays claimed" 0 "KEEP" \
bash -c 'ISSUEFLOW_NOW=1700000000 source "$1"; printf "%s\n" "$NOW"' _ \ bash -c 'ISSUEFLOW_NOW=100000 ISSUEFLOW_STALE_HOURS=1 source "$1"; claim_decision_at 1 false 96401' _ \
"$ROOT/actions/issueflow-reconcile/issueflow-reconcile.sh" "$ROOT/actions/issueflow-reconcile/issueflow-reconcile.sh"
# shellcheck disable=SC2016 # expansions belong to the isolated bash -c process # shellcheck disable=SC2016 # expansions belong to the isolated bash -c process
check "injected stale hours set the boundary" 0 "10800" \ check "injected clock: exact stale boundary stays claimed" 0 "KEEP" \
bash -c 'ISSUEFLOW_STALE_HOURS=3 source "$1"; printf "%s\n" "$STALE_AFTER"' _ \ bash -c 'ISSUEFLOW_NOW=100000 ISSUEFLOW_STALE_HOURS=1 source "$1"; claim_decision_at 1 false 96400' _ \
"$ROOT/actions/issueflow-reconcile/issueflow-reconcile.sh"
# shellcheck disable=SC2016 # expansions belong to the isolated bash -c process
check "injected clock: past stale boundary is reclaimed" 0 "RECLAIM" \
bash -c 'ISSUEFLOW_NOW=100000 ISSUEFLOW_STALE_HOURS=1 source "$1"; claim_decision_at 1 false 96399' _ \
"$ROOT/actions/issueflow-reconcile/issueflow-reconcile.sh" "$ROOT/actions/issueflow-reconcile/issueflow-reconcile.sh"
# Invariant 3: blocked declarations parse and release only when all close. # Invariant 3: blocked declarations parse and release only when all close.