From d0f1a43064546f6639be3e152556eb3f7a9f36b3 Mon Sep 17 00:00:00 2001 From: codex-bot-andresmgsl <304681515+codex-bot-andresmgsl@users.noreply.github.com> Date: Thu, 23 Jul 2026 10:30:34 +0000 Subject: [PATCH] test: pin injected staleness boundary --- .../issueflow-reconcile/issueflow-reconcile.sh | 8 ++++++-- test/issueflow-reconcile.test.sh | 15 ++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/actions/issueflow-reconcile/issueflow-reconcile.sh b/actions/issueflow-reconcile/issueflow-reconcile.sh index 1afe400..327fec6 100644 --- a/actions/issueflow-reconcile/issueflow-reconcile.sh +++ b/actions/issueflow-reconcile/issueflow-reconcile.sh @@ -95,6 +95,10 @@ claim_decision() { # $1 assignee count, $2 linked open PR, $3 age seconds 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 sed -nE 's/.*Blocked by[[:space:]]+//Ip' \ | sed -E 's/[.;][[:space:]].*$//' \ @@ -175,8 +179,8 @@ reconcile_issue() { if has_issue_label claimed; then assignees="$(jq '.assignees | length' <<<"$ISSUE_JSON")" grep -qxF "$n" <<<"${OPEN_PR_ISSUES:-}" && open_pr=true - age=$((NOW - $(last_issue_activity "$n" "$(jq -r '.created_at' <<<"$ISSUE_JSON")"))) - decision="$(claim_decision "$assignees" "$open_pr" "$age")" + age="$(last_issue_activity "$n" "$(jq -r '.created_at' <<<"$ISSUE_JSON")")" + decision="$(claim_decision_at "$assignees" "$open_pr" "$age")" case "$decision" in FLAG_UNASSIGNED) ensure_comment "$n" claimed-unassigned \ diff --git a/test/issueflow-reconcile.test.sh b/test/issueflow-reconcile.test.sh index 30290f1..442bd0e 100644 --- a/test/issueflow-reconcile.test.sh +++ b/test/issueflow-reconcile.test.sh @@ -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. 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 "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 -check "injected clock is retained" 0 "1700000000" \ - bash -c 'ISSUEFLOW_NOW=1700000000 source "$1"; printf "%s\n" "$NOW"' _ \ +check "injected clock: below stale boundary stays claimed" 0 "KEEP" \ + bash -c 'ISSUEFLOW_NOW=100000 ISSUEFLOW_STALE_HOURS=1 source "$1"; claim_decision_at 1 false 96401' _ \ "$ROOT/actions/issueflow-reconcile/issueflow-reconcile.sh" # shellcheck disable=SC2016 # expansions belong to the isolated bash -c process -check "injected stale hours set the boundary" 0 "10800" \ - bash -c 'ISSUEFLOW_STALE_HOURS=3 source "$1"; printf "%s\n" "$STALE_AFTER"' _ \ +check "injected clock: exact stale boundary stays claimed" 0 "KEEP" \ + 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" # Invariant 3: blocked declarations parse and release only when all close.