feat: cross-model consensus consolidation (one ranked comment, not N walls) (#17)
Build & push image / build-and-push (push) Successful in 9s
Build & push image / build-and-push (push) Successful in 9s
Co-authored-by: Steve Dudenhoeffer <steve@stevedudenhoeffer.com> Co-committed-by: Steve Dudenhoeffer <steve@stevedudenhoeffer.com>
This commit was merged in pull request #17.
This commit is contained in:
+32
-5
@@ -50,6 +50,13 @@ MAX_DIFF_CHARS="${MAX_DIFF_CHARS:-60000}"
|
||||
MARKER="<!-- gadfly-review:${PROVIDER}:${MODEL} -->"
|
||||
say() { echo "[gadfly-review:${PROVIDER}:${MODEL}] $*" >&2; }
|
||||
|
||||
# When the swarm is consolidating (GADFLY_CONSOLIDATE=1, set by entrypoint.sh for
|
||||
# a multi-model run), this model does NOT post its own comment — it writes its
|
||||
# findings to GADFLY_FINDINGS_OUT and a single cross-model consensus comment is
|
||||
# posted after the whole swarm finishes. Live progress still shows on the status
|
||||
# board. Default 0 (post a per-model comment, the standalone behavior).
|
||||
CONSOLIDATE="${GADFLY_CONSOLIDATE:-0}"
|
||||
|
||||
# Display the model's ACTUAL backend: the provider segment of the spec
|
||||
# ("m1pro/qwen3.6:35b-mlx" -> "m1pro"); a bare id uses GADFLY_PROVIDER (default
|
||||
# ollama-cloud). This is what the comment header shows, not the run.sh lane.
|
||||
@@ -126,7 +133,9 @@ USR="$(printf 'PR #%s: %s\n\nDescription:\n%s\n\nUnified diff to review:\n```dif
|
||||
# --- announce start (placeholder comment) -----------------------------------
|
||||
START_TS="$(date +%s)"
|
||||
say "starting review with ${MODEL}"
|
||||
upsert_comment "$(printf '%s\n### 🪰 Gadfly review — `%s` (%s)\n\n⏳ Reviewing… this comment will update with findings and run time.' \
|
||||
# Skip the per-model placeholder when consolidating (the consensus comment is
|
||||
# posted later; live progress is on the status board).
|
||||
[ "$CONSOLIDATE" = "1" ] || upsert_comment "$(printf '%s\n### 🪰 Gadfly review — `%s` (%s)\n\n⏳ Reviewing… this comment will update with findings and run time.' \
|
||||
"$MARKER" "$MODEL" "$MODEL_PROVIDER")"
|
||||
|
||||
# --- call the model ---------------------------------------------------------
|
||||
@@ -170,6 +179,7 @@ case "$PROVIDER" in
|
||||
GADFLY_BODY="$BODY" \
|
||||
GADFLY_MAX_DIFF_CHARS="$MAX_DIFF_CHARS" \
|
||||
GADFLY_STATUS_FILE="${GADFLY_STATUS_FILE:-}" \
|
||||
GADFLY_FINDINGS_OUT="${GADFLY_FINDINGS_OUT:-}" \
|
||||
"$BIN" 2>"$ERR_FILE"
|
||||
)"
|
||||
rc=$?
|
||||
@@ -204,7 +214,24 @@ esac
|
||||
# --- assemble + post final comment (with run time) --------------------------
|
||||
ELAPSED="$(( $(date +%s) - START_TS ))"
|
||||
DUR="$(fmt_duration "$ELAPSED")"
|
||||
COMMENT="$(printf '%s\n### 🪰 Gadfly review — `%s` (%s)\n\n%s\n\n<sub>Automated adversarial review by Gadfly. Advisory only — does not block merge. · ⏱️ reviewed in %s</sub>' \
|
||||
"$MARKER" "$MODEL" "$MODEL_PROVIDER" "$REVIEW" "$DUR")"
|
||||
upsert_comment "$COMMENT"
|
||||
say "done in ${DUR}"
|
||||
|
||||
# Consolidating: the binary writes its findings file on success. If it failed or
|
||||
# was skipped (no file, or an empty one), write a stub so this model still shows
|
||||
# up in the consensus (as failed) and an all-models-fail run still posts a
|
||||
# comment — never silently drop a model or the whole review.
|
||||
if [ "$CONSOLIDATE" = "1" ] && [ -n "${GADFLY_FINDINGS_OUT:-}" ] && [ ! -s "${GADFLY_FINDINGS_OUT}" ]; then
|
||||
jq -n --arg model "$MODEL" --arg provider "$MODEL_PROVIDER" --arg md "$REVIEW" \
|
||||
'{model:$model, provider:$provider, verdict:"reviewer failed", errored:true, markdown:$md, findings:[]}' \
|
||||
> "${GADFLY_FINDINGS_OUT}" 2>/dev/null || true
|
||||
fi
|
||||
# When consolidating, the binary has written this model's findings to
|
||||
# GADFLY_FINDINGS_OUT; the consensus comment is posted by entrypoint.sh after the
|
||||
# whole swarm finishes, so this model posts no comment of its own.
|
||||
if [ "$CONSOLIDATE" = "1" ]; then
|
||||
say "done in ${DUR} (consolidated; no per-model comment)"
|
||||
else
|
||||
COMMENT="$(printf '%s\n### 🪰 Gadfly review — `%s` (%s)\n\n%s\n\n<sub>Automated adversarial review by Gadfly. Advisory only — does not block merge. · ⏱️ reviewed in %s</sub>' \
|
||||
"$MARKER" "$MODEL" "$MODEL_PROVIDER" "$REVIEW" "$DUR")"
|
||||
upsert_comment "$COMMENT"
|
||||
say "done in ${DUR}"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user