forgedock 1.50.0 → 1.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,12 +19,12 @@ OTHER=fedcba9876543210fedcba9876543210fedcba98
19
19
  blk() { awk -v n="$1" '$0 == "# BEGIN " n {f=1; next} $0 == "# END " n {f=0} f' "$POST"; }
20
20
 
21
21
  # (1) the fences now live only in the script: the blocks exist, the spec no longer carries them
22
- for b in panel-guard delivery-check test-gate-extract test-gate-verdict; do
22
+ for b in delivery-fetch panel-guard delivery-check test-gate-extract test-gate-verdict; do
23
23
  [ -n "$(blk "$b")" ] && ok || bad "block $b missing from review-staging-post.sh"
24
24
  done
25
25
  if grep -qE 'ACTUAL_AGENT_COUNT=\$\(gh api|MISSING_AGENT_COMMENTS=""|GATE_VERDICT_INVALID=0' "$SPEC"; then bad "the spec must not carry a copy of the panel-guard, delivery or verdict-handling fence"; else ok; fi
26
- # 6.75 carries the findings-block lookahead; the 6.75 empty-list guard precedes the per-domain loop
27
- blk delivery-check | grep -qF 'count "^(?=[\\s\\S]*<!-- REVIEW-FINDINGS-START -->[\\s\\S]*<!-- REVIEW-FINDINGS-END -->)<!-- FORGE:REVIEW-AGENT:${AGENT_DOMAIN} -->' && ok || bad "6.75 count must require the findings block"
26
+ # 6.75 carries the findings-block lookahead (in the shared cached-listing counter); the 6.75 empty-list guard precedes the per-domain loop
27
+ blk delivery-fetch | grep -qF 'count "^(?=[\\s\\S]*<!-- REVIEW-FINDINGS-START -->[\\s\\S]*<!-- REVIEW-FINDINGS-END -->)<!-- FORGE:REVIEW-AGENT:${AGENT_DOMAIN} -->' && ok || bad "6.75 count must require the findings block"
28
28
  G=$(blk delivery-check | grep -n 'launched-agent list is empty or unreadable' | head -1 | cut -d: -f1); L=$(blk delivery-check | grep -n '^for AGENT_DOMAIN in' | head -1 | cut -d: -f1)
29
29
  [ -n "$G" ] && [ -n "$L" ] && [ "$G" -lt "$L" ] && ok || bad "6.75 empty-list guard must precede the for AGENT_DOMAIN loop"
30
30
  # the producer never coerces an absent marker to SKIP; the catch-all arm never sets SKIP
@@ -38,7 +38,8 @@ bash "$POST" delivery --repo o/r --pr 1 >/dev/null 2>&1; [ $? -eq 2 ] && ok || b
38
38
  bash "$POST" test-gate --repo o/r --pr 1 --sd "$TMP/u" --output x --prs-file "$TMP/none" >/dev/null 2>&1; [ $? -eq 2 ] && ok || bad "unreadable --prs-file must exit 2"
39
39
  bash "$POST" test-gate --repo o/r --pr 1 --sd "$TMP/u" --output x --prs-file /dev/null --posture lax >/dev/null 2>&1; [ $? -eq 2 ] && ok || bad "unknown --posture must exit 2"
40
40
 
41
- # gh stub: $FIX/comments.json is the PR's comment list; posted bodies and edits go to $FIX/posted / $FIX/edits
41
+ # gh stub: $FIX/comments.json is the PR's comment list ($FIX/comments.<k>.json, when present, answers the k-th listing; no file = API error);
42
+ # each listing is logged to $FIX/api_calls; posted bodies and edits go to $FIX/posted / $FIX/edits
42
43
  mkdir -p "$TMP/bin"
43
44
  cat > "$TMP/bin/gh" <<'STUB'
44
45
  #!/usr/bin/env bash
@@ -49,17 +50,21 @@ case "$1 $2" in
49
50
  "label create") exit 0 ;;
50
51
  "pr view") [ -f "$F/head" ] && { cat "$F/head"; exit 0; }; exit 1 ;;
51
52
  esac
52
- if [ "$1" = api ]; then case "$a" in *"/comments"*) cat "$F/comments.json" 2>/dev/null || exit 1; exit 0 ;; esac; fi
53
+ if [ "$1" = api ]; then case "$a" in *"/comments"*)
54
+ echo x >> "$F/api_calls"; k=$(wc -l < "$F/api_calls" | tr -d ' ')
55
+ if [ -f "$F/comments.$k.json" ]; then cat "$F/comments.$k.json"; else cat "$F/comments.json" 2>/dev/null || exit 1; fi; exit 0 ;; esac; fi
53
56
  echo "gh stub: unhandled: $a" >&2; exit 1
54
57
  STUB
55
58
  printf '#!/bin/sh\nexit 1\n' > "$TMP/bin/yq" # no yq: defaults apply
56
59
  chmod +x "$TMP/bin/gh" "$TMP/bin/yq"
57
60
  export PATH="$TMP/bin:$PATH"
61
+ export FORGE_REVIEW_DELIVERY_RETRY_DELAYS="0 0 0" # retries without waiting (4 attempts)
58
62
  newfix() { FIX="$TMP/fix.$1"; rm -rf "$FIX"; mkdir -p "$FIX/sd"; export FIX; }
59
63
  FB=$'<!-- REVIEW-FINDINGS-START -->\n<!-- REVIEW-FINDINGS-END -->'
60
64
  cm() { jq -n --arg b "$1" --arg t "${2:-Bot}" '{body:$b, author_association:"NONE", user:{type:$t, login:"x"}}'; }
61
65
  agent() { printf '<!-- FORGE:REVIEW-AGENT:%s -->\nReviewed-SHA: %s\n\n%s' "$1" "${2:-$HEAD}" "${3-$FB}"; }
62
- comments() { jq -s '.' > "$FIX/comments.json"; }
66
+ comments() { jq -s '.' > "$FIX/comments${1:+.$1}.json"; }
67
+ calls() { [ -f "$FIX/api_calls" ] && wc -l < "$FIX/api_calls" | tr -d ' ' || echo 0; }
63
68
  deliver() { bash "$POST" delivery --repo o/r --pr 42 --sd "$FIX/sd" --head "${1:-$HEAD}" 2>&1; echo "rc=$?"; }
64
69
 
65
70
  # (3) delivery: a complete panel passes and posts nothing
@@ -67,6 +72,7 @@ newfix full; printf 'security\nmaterial-change\n' > "$FIX/sd/42_launched_review_
67
72
  { cm "$(agent security)"; cm "$(agent material-change)"; } | comments
68
73
  OUT=$(deliver); case "$OUT" in *"DELIVERY: OK (2/2"*"rc=0") ok ;; *) bad "complete panel must pass (got: $OUT)" ;; esac
69
74
  [ ! -s "$FIX/posted" ] && ok || bad "a complete panel must post nothing"
75
+ [ "$(calls)" = 1 ] && ok || bad "delivery: complete panel lists comments once (got $(calls) listings)"
70
76
  # a duplicate domain line does not inflate the selected count
71
77
  printf 'security\nsecurity\nmaterial-change\n' > "$FIX/sd/42_launched_review_agents"
72
78
  OUT=$(deliver); case "$OUT" in *"rc=0") ok ;; *) bad "duplicate launched lines must count once (got: $OUT)" ;; esac
@@ -94,9 +100,35 @@ newfix empty; : > "$FIX/sd/42_launched_review_agents"; cm "$(agent security)" |
94
100
  OUT=$(deliver); case "$OUT" in *"rc=1") ok ;; *) bad "empty launched list must fail (got: $OUT)" ;; esac
95
101
  newfix none; cm "$(agent security)" | comments
96
102
  OUT=$(deliver); case "$OUT" in *"rc=1") ok ;; *) bad "absent launched list must fail (got: $OUT)" ;; esac
97
- # unreadable comments count as 0 delivered
103
+ # unreadable comments (an API error on every attempt) fail closed as UNVERIFIED, never as missing (forge#5166)
98
104
  newfix unreadable; printf 'security\n' > "$FIX/sd/42_launched_review_agents"
99
- OUT=$(deliver); case "$OUT" in *"rc=1") ok ;; *) bad "unreadable comments must fail closed (got: $OUT)" ;; esac
105
+ OUT=$(deliver); case "$OUT" in *"REVIEW DELIVERY UNVERIFIED"*"rc=2") ok ;; *) bad "delivery: API error on every attempt is UNVERIFIED (got: $OUT)" ;; esac
106
+ case "$OUT" in *"REVIEW DELIVERY FAILURE"*) bad "an API error must not be reported as missing" ;; *) ok ;; esac
107
+ [ ! -s "$FIX/posted" ] && [ ! -s "$FIX/edits" ] && ok || bad "UNVERIFIED must post no GATE_FAILURE and add no label"
108
+ [ "$(calls)" = 4 ] && ok || bad "UNVERIFIED must come after every retry (got $(calls) listings)"
109
+ # delivery: lagging listing passes on retry -- the first listing lacks a comment, the second shows it
110
+ newfix lag; printf 'security\nmaterial-change\n' > "$FIX/sd/42_launched_review_agents"
111
+ cm "$(agent security)" | comments 1
112
+ { cm "$(agent security)"; cm "$(agent material-change)"; } | comments
113
+ OUT=$(deliver); case "$OUT" in *"DELIVERY: OK (2/2"*"rc=0") ok ;; *) bad "delivery: lagging listing passes on retry (got: $OUT)" ;; esac
114
+ case "$OUT" in *"material-change found on attempt 2"*) ok ;; *) bad "lag: must print the attempt a domain was found on (got: $OUT)" ;; esac
115
+ case "$OUT" in *"security found on attempt 1"*) ok ;; *) bad "lag: security must be found on attempt 1 (got: $OUT)" ;; esac
116
+ [ ! -s "$FIX/posted" ] && [ ! -s "$FIX/edits" ] && ok || bad "lag: a panel delivered on retry must post and label nothing"
117
+ [ "$(calls)" = 2 ] && ok || bad "lag: retries stop once every domain is found (got $(calls) listings)"
118
+ # a transient API error, then a full listing, passes
119
+ newfix transient; printf 'security\n' > "$FIX/sd/42_launched_review_agents"
120
+ echo 'not json' > "$FIX/comments.1.json"; cm "$(agent security)" | comments
121
+ OUT=$(deliver); case "$OUT" in *"attempt 1: API error"*"security found on attempt 2"*"rc=0") ok ;; *) bad "a transient API error must be retried (got: $OUT)" ;; esac
122
+ # a real absence after every retry is still missing (listed and absent), with the panel-integrity failure
123
+ newfix absent; printf 'security\nmaterial-change\n' > "$FIX/sd/42_launched_review_agents"; cm "$(agent security)" | comments
124
+ OUT=$(deliver); case "$OUT" in *"rc=1") ok ;; *) bad "absent after retries must fail as missing (got: $OUT)" ;; esac
125
+ case "$OUT" in *UNVERIFIED*) bad "a listed absence is not UNVERIFIED" ;; *) ok ;; esac
126
+ grep -qF 'review-panel-integrity' "$FIX/posted" 2>/dev/null && ok || bad "absent: must post GATE_FAILURE:TYPE=review-panel-integrity"
127
+ [ "$(calls)" = 4 ] && ok || bad "absent: must retry before declaring missing (got $(calls) listings)"
128
+ # an API error on the LAST attempt after a lacking listing is UNVERIFIED, not missing
129
+ newfix lasterr; printf 'security\nmaterial-change\n' > "$FIX/sd/42_launched_review_agents"
130
+ cm "$(agent security)" | comments 1; cm "$(agent security)" | comments 2; cm "$(agent security)" | comments 3; echo '{}' > "$FIX/comments.4.json"
131
+ OUT=$(deliver); case "$OUT" in *"REVIEW DELIVERY UNVERIFIED"*"rc=2") ok ;; *) bad "an error on the last attempt must be UNVERIFIED (got: $OUT)" ;; esac
100
132
  # a malformed --head with no resolvable head refuses
101
133
  newfix badhead; printf 'security\n' > "$FIX/sd/42_launched_review_agents"; cm "$(agent security)" | comments
102
134
  OUT=$(deliver "n/a"); case "$OUT" in *"rc=1") ok ;; *) bad "an unresolvable head must fail closed (got: $OUT)" ;; esac