Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ review_expectations: |
high logic-error at src/add.py:2 because add returned a - b. The follow-up
changes that line to return a + b. A good review records
resolved_by_change for f_fixed1 with that return change as evidence, does
not list logic-error as an open finding, and mentions f_fixed1 under
Earlier findings.
not list logic-error as an open finding, and mentions the add.py fix under
Comment thread
waynesun09 marked this conversation as resolved.
Resolved
Earlier findings without printing the finding id.
98 changes: 92 additions & 6 deletions scripts/post-review-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2507,7 +2507,9 @@ run_disposition_case "approve-withheld-for-unanswered-high-prior-finding" \
'{"version":2,"findings":[{"severity":"high","category":"logic-error","file":"old.go","line":3,"id":"f_hi1"}]}' \
'([.findings[] | select(.id == "f_hi1")] | length) == 1 and .dispositions == [{id: "f_hi1", status: "open"}]'
assert_last_result "approve-withheld-for-unanswered-high-prior-finding" \
'.action == "request-changes" and (.body | contains("Approval withheld")) and (.body | contains("f_hi1"))'
'.action == "request-changes" and (.body | contains("Approval withheld")) and (.body | contains("f_hi1") | not)'
assert_last_result "approve-withheld-for-unanswered-high-prior-finding" \
'([.findings[] | select(.id == "f_hi1")] | length) == 1 and ([.findings[] | .description // "" | test("f_[A-Za-z0-9]+")] | any | not)'
assert_disposition_stdout "approve-withheld-for-unanswered-high-prior-finding" \
"::warning::Approval withheld: prior high/critical finding id(s) f_hi1" "present"

Expand All @@ -2532,7 +2534,7 @@ run_disposition_case "approve-withheld-for-explicit-open-high-prior-finding" \
'{"version":2,"findings":[{"severity":"high","category":"logic-error","file":"old.go","line":3,"id":"f_hi1"}]}' \
'.dispositions == [{id: "f_hi1", status: "open"}]'
assert_last_result "approve-withheld-for-explicit-open-high-prior-finding" \
'.action == "request-changes" and (.body | contains("Approval withheld")) and (.body | contains("f_hi1"))'
'.action == "request-changes" and (.body | contains("Approval withheld")) and (.body | contains("f_hi1") | not)'

run_disposition_case "approve-withheld-for-empty-evidence-resolved-high-prior-finding" \
"$(jq -c '.action="approve" | .findings=[] | .dispositions=[{id:"f_hi1",status:"resolved_by_change",rationale:"Fixed.",evidence:""}]' <<< "${BASE_REVIEW}")" \
Expand Down Expand Up @@ -2680,7 +2682,7 @@ run_disposition_case "approve-withheld-for-human-dismissed-high-prior-finding" \
'{"version":2,"findings":[{"severity":"high","category":"logic-error","file":"src/add.go","line":2,"id":"f_hi1"}]}' \
'.dispositions == [{id: "f_hi1", status: "open"}]'
assert_last_result "approve-withheld-for-human-dismissed-high-prior-finding" \
'.action == "request-changes" and (.body | contains("Approval withheld")) and (.body | contains("f_hi1"))'
'.action == "request-changes" and (.body | contains("Approval withheld")) and (.body | contains("f_hi1") | not)'
assert_disposition_stdout "approve-withheld-for-human-dismissed-high-prior-finding" \
"::warning::dismissed_by_human is not accepted for high or critical prior finding id(s) f_hi1; recorded as open" "present"
unset MOCK_REVIEW_THREADS_JSON MOCK_PR_AUTHOR
Expand Down Expand Up @@ -2741,7 +2743,7 @@ run_disposition_case "approve-withheld-for-reclassified-without-finding" \
'{"version":2,"findings":[{"severity":"high","category":"logic-error","file":"old.go","line":3,"id":"f_hi1"}]}' \
'.findings == [{"severity":"high","category":"logic-error","file":"old.go","id":"f_hi1","line":3}] and .dispositions == [{id: "f_hi1", status: "open"}]'
assert_last_result "approve-withheld-for-reclassified-without-finding" \
'.action == "request-changes" and (.body | contains("Approval withheld")) and (.body | contains("f_hi1"))'
'.action == "request-changes" and (.body | contains("Approval withheld")) and (.body | contains("f_hi1") | not)'
assert_disposition_stdout "approve-withheld-for-reclassified-without-finding" \
"::warning::Reclassified prior finding id(s) f_hi1 have no current finding with that id; recorded as open" "present"

Expand All @@ -2768,7 +2770,7 @@ run_disposition_case "approve-withheld-for-open-high-prior-finding-re-emitted-lo
'{"version":2,"findings":[{"severity":"high","category":"logic-error","file":"old.go","line":3,"id":"f_hi1"}]}' \
'.findings == [{"severity":"high","category":"logic-error","file":"old.go","id":"f_hi1","line":3}] and .dispositions == [{id: "f_hi1", status: "open"}]'
assert_last_result "approve-withheld-for-open-high-prior-finding-re-emitted-lower" \
'.action == "request-changes" and (.body | contains("Approval withheld")) and (.body | contains("f_hi1"))'
'.action == "request-changes" and (.body | contains("Approval withheld")) and (.body | contains("f_hi1") | not)'

# Re-emitting an open prior high finding at high still leaves it open.
# open is not a resolution, so approval is withheld.
Expand All @@ -2777,7 +2779,91 @@ run_disposition_case "approve-withheld-for-open-high-prior-finding-re-emitted-hi
'{"version":2,"findings":[{"severity":"high","category":"logic-error","file":"old.go","line":3,"id":"f_hi1"}]}' \
'.findings == [{"severity":"high","category":"logic-error","file":"old.go","id":"f_hi1","line":3}] and .dispositions == [{id: "f_hi1", status: "open"}]'
assert_last_result "approve-withheld-for-open-high-prior-finding-re-emitted-high" \
'.action == "request-changes" and (.body | contains("Approval withheld")) and (.body | contains("f_hi1"))'
'.action == "request-changes" and (.body | contains("Approval withheld")) and (.body | contains("f_hi1") | not)'

# Finding ids never reach the posted text, whatever the model wrote: known
# ids and minted-shaped ids are stripped from the body and from each
# finding's description and remediation, while the ledger marker keeps them.
run_disposition_case "posted-text-drops-finding-ids" \
"$(jq -c '.action="request-changes" | .body="Review\n\n### Earlier findings\n- f_hi1 (old.go:3) resolved_by_change: returns a + b\n- f_0123456789abcdef still open." | .findings=[{severity:"high",category:"logic-error",file:"old.go",line:3,description:"Same root cause as f_hi1; see f_hi1 .",remediation:"Fix f_hi1 by checking nil.",id:"f_hi1"}] | .dispositions=[{id:"f_hi1",status:"open",rationale:"Still present.",evidence:""}]' <<< "${BASE_REVIEW}")" \
'{"version":2,"findings":[{"severity":"high","category":"logic-error","file":"old.go","line":3,"id":"f_hi1"}]}' \
'.findings == [{"severity":"high","category":"logic-error","file":"old.go","id":"f_hi1","line":3}] and .dispositions == [{id: "f_hi1", status: "open"}]'
assert_last_result "posted-text-drops-finding-ids" \
'(.body | test("f_[A-Za-z0-9]+") | not) and (.body | contains("### Earlier findings")) and (.body | contains("(old.go:3) resolved_by_change")) and (.findings[0].id == "f_hi1") and (.findings[0].description == "Same root cause as ; see .") and (.findings[0].remediation == "Fix by checking nil.") and ((.body | split("\n")[0]) | test("^<!-- fullsend:review-findings-v2:[A-Za-z0-9+/=]+ -->$"))'
assert_disposition_stdout "posted-text-drops-finding-ids" \
"::warning::Removed finding id(s) f_0123456789abcdef, f_hi1 from the posted review text" "present"

# Prose that merely looks id-like but is neither a known id nor a minted
# id is left alone, so code identifiers in findings survive.
run_disposition_case "posted-text-keeps-unrelated-f-tokens" \
"$(jq -c '.findings=[{severity:"low",category:"logic-error",file:"a.go",line:1,description:"Rename f_count and f_x; f_ab12 is unrelated."}]' <<< "${BASE_REVIEW}")" \
"" \
'(.findings | length) == 1'
assert_last_result "posted-text-keeps-unrelated-f-tokens" \
'.findings[0].description == "Rename f_count and f_x; f_ab12 is unrelated."'
assert_disposition_stdout "posted-text-keeps-unrelated-f-tokens" \
"::warning::Removed finding id(s)" "absent"

# Cleanup after an id removal must not rewrite unrelated whitespace in
# code or string literals (double spaces, space before punctuation).
run_disposition_case "posted-text-keeps-id-free-whitespace" \
"$(jq -c '.findings=[{severity:"low",category:"logic-error",file:"a.go",line:1,description:"if value == \"a b\": print(\"hello , world\")"}]' <<< "${BASE_REVIEW}")" \
"" \
'(.findings | length) == 1'
assert_last_result "posted-text-keeps-id-free-whitespace" \
'.findings[0].description == "if value == \"a b\": print(\"hello , world\")"'
assert_disposition_stdout "posted-text-keeps-id-free-whitespace" \
"::warning::Removed finding id(s)" "absent"

run_disposition_case "posted-text-scrub-preserves-nearby-literals" \
"$(jq -c '.findings=[{severity:"low",category:"logic-error",file:"a.go",line:1,description:"Same as f_hi1 in value == \"a b\"; print(\"hello , world\")",id:"f_hi1"}]' <<< "${BASE_REVIEW}")" \
'{"version":2,"findings":[{"severity":"low","category":"logic-error","file":"a.go","line":1,"id":"f_hi1"}]}' \
'(.findings | length) == 1 and (.findings[0].id == "f_hi1")'
assert_last_result "posted-text-scrub-preserves-nearby-literals" \
'.findings[0].id == "f_hi1" and .findings[0].description == "Same as in value == \"a b\"; print(\"hello , world\")"'

# Markdown wrappers around a stripped id (backticks, bold) must not remain.
run_disposition_case "posted-text-drops-markdown-wrapped-ids" \
"$(jq -c --arg body "$(printf '%s' 'Review

### Earlier findings
- `f_hi1` (old.go:3) resolved_by_change
- **f_hi1** reclassified')" '.action="request-changes" | .body=$body | .findings=[{severity:"high",category:"logic-error",file:"old.go",line:3,description:"See `f_hi1` and **f_hi1**.",id:"f_hi1"}] | .dispositions=[{id:"f_hi1",status:"open",rationale:"Still present.",evidence:""}]' <<< "${BASE_REVIEW}")" \
'{"version":2,"findings":[{"severity":"high","category":"logic-error","file":"old.go","line":3,"id":"f_hi1"}]}' \
'.findings[0].id == "f_hi1"'
assert_last_result "posted-text-drops-markdown-wrapped-ids" \
'(.body | contains("### Earlier findings")) and (.body | contains("(old.go:3) resolved_by_change")) and (.body | contains("reclassified")) and (.body | contains("``") | not) and (.body | contains("**") | not) and (.body | test("f_hi1") | not) and .findings[0].description == "See and ."'
assert_disposition_stdout "posted-text-drops-markdown-wrapped-ids" \
"::warning::Removed finding id(s) f_hi1 from the posted review text" "present"

# Old Earlier findings shape (- id: disposition), bold+colon, parentheses,
# and an id at the start of a later line. List marker must not glue to ":".
run_disposition_case "posted-text-drops-old-earlier-findings-shape" \
"$(jq -c --arg body "$(printf '%s' 'Review

### Earlier findings
- f_hi1: resolved_by_change, fixed
- **f_hi1**: leftover
resolved (f_hi1) earlier
Line one
f_hi1 resolved')" '.action="request-changes" | .body=$body | .findings=[{severity:"high",category:"logic-error",file:"old.go",line:3,description:"d",id:"f_hi1"}] | .dispositions=[{id:"f_hi1",status:"open",rationale:"Still present.",evidence:""}]' <<< "${BASE_REVIEW}")" \
'{"version":2,"findings":[{"severity":"high","category":"logic-error","file":"old.go","line":3,"id":"f_hi1"}]}' \
'.findings[0].id == "f_hi1"'
assert_last_result "posted-text-drops-old-earlier-findings-shape" \
'(.body | contains("### Earlier findings")) and (.body | contains("- resolved_by_change, fixed")) and (.body | contains("- leftover")) and (.body | contains("resolved earlier")) and (.body | contains("Line one\nresolved")) and (.body | contains("-:") | not) and (.body | contains("()") | not) and (.body | test("f_hi1") | not)'
assert_disposition_stdout "posted-text-drops-old-earlier-findings-shape" \
"::warning::Removed finding id(s) f_hi1 from the posted review text" "present"

# A first-review supplied id is reminted; the original string in body /
# description / remediation must still be scrubbed. Unrelated f_count stays.
run_disposition_case "posted-text-drops-reminted-foreign-id" \
"$(jq -c '.action="request-changes" | .body="See f_invented1 and f_count." | .findings=[{severity:"low",category:"logic-error",file:"a.go",line:1,description:"Same as f_invented1; keep f_count.",remediation:"Fix f_invented1, not f_count.",id:"f_invented1"}]' <<< "${BASE_REVIEW}")" \
"" \
'(.findings | length) == 1 and (.findings[0].id != "f_invented1")'
assert_last_result "posted-text-drops-reminted-foreign-id" \
'(.findings[0].id != "f_invented1") and (.body | test("f_invented1") | not) and (.body | contains("f_count")) and (.findings[0].description | test("f_invented1") | not) and (.findings[0].description | contains("f_count")) and (.findings[0].remediation | test("f_invented1") | not) and (.findings[0].remediation | contains("f_count"))'
assert_disposition_stdout "posted-text-drops-reminted-foreign-id" \
"::warning::Removed finding id(s) f_invented1 from the posted review text" "present"

# Reclassifying a high finding to info must persist the new severity even
# when the info row is below the posted-review threshold.
Expand Down
61 changes: 57 additions & 4 deletions scripts/post-review.sh
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,14 @@ PRIOR_LEDGER="$(jq -c --argjson mints "${MINT_IDS}" '
' <<< "${PRIOR_JSON}")"
MINT_IDS="$(jq -c --argjson prior "${PRIOR_LEDGER}" '.[$prior.used_mints:]' <<< "${MINT_IDS}")"

# Ids the model wrote, captured before remint. A first-review supplied id
# is foreign and replaced below; the original string can still appear in
# body/description/remediation and must be in the scrub set.
SUPPLIED_FINDING_IDS="$(jq -c '
[ .findings[]?.id?, .dispositions[]?.id? ]
| map(select(type == "string" and test("^f_[A-Za-z0-9]+$"))) | unique
' "${RESULT_FILE}" 2>/dev/null || echo '[]')"

# Id assignment for this review. A supplied id is kept only when it is an
# open prior id no earlier row already took and this review is not
# resolving; a closed, resolving, foreign, or duplicate id is replaced (a
Expand Down Expand Up @@ -1809,7 +1817,7 @@ fi
BLOCKING_IDS="$(jq -r '.blocking | join(", ")' <<< "${LEDGER_REPORT}")"
if [[ -n "${BLOCKING_IDS}" && "${ACTION}" = "approve" ]]; then
echo "::warning::Approval withheld: prior high/critical finding id(s) ${BLOCKING_IDS} are still open"
LEDGER_NOTICE=$'\n\n> **Note:** Approval withheld. Earlier high or critical finding(s) '"${BLOCKING_IDS}"$' are still open.'
LEDGER_NOTICE=$'\n\n> **Note:** Approval withheld. Earlier high or critical finding(s) are still open.'
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
Resolved
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
Resolved
LEDGER_RESULT="$(mktemp)"
CLEANUP_FILES+=("${LEDGER_RESULT}")
jq --arg notice "${LEDGER_NOTICE}" \
Expand Down Expand Up @@ -1852,7 +1860,7 @@ PRIOR_OPEN_BLOCKING_FINDINGS="$(jq -c --argjson effective "${LEDGER_EFFECTIVE}"
file: (.file // "N/A"),
description: (
if (.description | type == "string" and length > 0) then .description
else ("Previously reported finding " + .id + " remains open: "
else ("Previously reported finding remains open: "
+ .severity + " " + .category + " in " + (.file // "PR-level")
+ (if (.line | type) == "number" then ":" + (.line | tostring) else "" end) + ".")
end
Expand All @@ -1873,7 +1881,7 @@ if [[ "${PRIOR_OPEN_BLOCKING_COUNT}" -gt 0 ]]; then
fi
fi
PRIOR_BLOCKING_SUMMARY="$(jq -r --argjson links "${FINDING_COMMENT_LINKS}" '
map("- " + .id + ": " + .severity + " " + .category + " at "
map("- " + .severity + " " + .category + " at "
+ (.file // "PR-level")
+ (if (.line | type) == "number" then ":" + (.line | tostring) else "" end)
+ (if ($links[.id] | type) == "string" then
Expand Down Expand Up @@ -2082,9 +2090,54 @@ if [[ -n "${PRIOR_FINDINGS_PROJECTION}" ]]; then
PRIOR_FINDINGS_ENCODED="$(printf '%s' "${PRIOR_FINDINGS_PROJECTION}" | base64 | tr -d '\n')"
PROJECTION_MARKER="<!-- fullsend:review-findings-v2:${PRIOR_FINDINGS_ENCODED} -->"
fi
# Finding ids are ledger keys, not prose. The skill tells the model not to
# print them, and this pass makes that true regardless: every id this run
# knows (prior ledger, current findings, dispositions) and anything shaped
# like a minted id is removed from the visible body and from each finding's
# description and remediation, which fullsend posts as inline comments. The
# projection marker below and the inline stamps fullsend adds are built
# from the JSON ids, not from this text, so they keep them.
KNOWN_FINDING_IDS="$(jq -c --argjson prior "${PRIOR_LEDGER}" --argjson supplied "${SUPPLIED_FINDING_IDS}" '
[ $prior.findings[]?.id?, .findings[]?.id?, .dispositions[]?.id?, $supplied[]? ]
| map(select(type == "string" and test("^f_[A-Za-z0-9]+$"))) | unique
' "${RESULT_FILE}")"
LEAKED_FINDING_IDS="$(jq -r --argjson known "${KNOWN_FINDING_IDS}" '
[ (.body // ""), (.findings[]? | .description // "", .remediation // "") ]
| map(select(type == "string"))
| map([ scan("\\bf_[A-Za-z0-9]+\\b") ] | .[])
| map(select(. as $id | ($known | index($id)) != null or test("^f_[0-9a-f]{16}$")))
| unique | join(", ")
' "${RESULT_FILE}")"
if [[ -n "${LEAKED_FINDING_IDS}" ]]; then
echo "::warning::Removed finding id(s) ${LEAKED_FINDING_IDS} from the posted review text; ids stay in the ledger only"
fi
TMP_RESULT="$(mktemp)"
CLEANUP_FILES+=("${TMP_RESULT}")
jq --arg marker "${PROJECTION_MARKER}" '
jq --arg marker "${PROJECTION_MARKER}" --argjson known_ids "${KNOWN_FINDING_IDS}" '
# Closed list of id frames only. Do not tidy unrelated whitespace.
def scrub_id($id):
gsub("(?m)^(?<pfx>[ \\t]*[-*][ \\t]+)(?:\\*\\*|`)?" + $id + "(?:\\*\\*|`)?[ \\t]*:[ \\t]*"; .pfx)
| gsub("\\[" + $id + "\\]\\([^)]*\\)"; "")
| gsub("`" + $id + "`"; "")
| gsub("\\*\\*" + $id + "\\*\\*"; "")
| gsub("\\(" + $id + "\\)"; "")
| gsub("(?m)^" + $id + "\\b[ \\t]*"; "")
| gsub("\\b" + $id + "\\b"; "");
def scrub_ids:
if type != "string" then . else
reduce $known_ids[] as $id (.; scrub_id($id))
| scrub_id("f_[0-9a-f]{16}")
end;
.body |= scrub_ids
| if (.findings | type) == "array" then
.findings |= map(
.description |= scrub_ids
| if (.description | type) == "string" and (.description | length) == 0
then .description = "Previously reported finding remains open." else . end
| if has("remediation") then .remediation |= scrub_ids else . end
)
else . end
|
# pre-review ends the current section at the first line containing a
# history delimiter, so any copy in the agent body would hide the marker.
def strip_reserved:
Expand Down
Loading
Loading