Skip to content

fix(agent): AI CI-refutation — an AI-judgment failure never closes (or visibly blocks) a green-CI PR - #1331

Merged
JSONbored merged 2 commits into
mainfrom
fix/ai-defect-no-close-on-green-ci
Jun 25, 2026
Merged

fix(agent): AI CI-refutation — an AI-judgment failure never closes (or visibly blocks) a green-CI PR#1331
JSONbored merged 2 commits into
mainfrom
fix/ai-defect-no-close-on-green-ci

Conversation

@JSONbored

@JSONbored JSONbored commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Summary

A live dry-run audit of 44 metagraphed PRs found the AI reviewer false-closing ~60% of clean, green, mergeable contributor PRs: the two free Workers-AI models share the same hallucination (e.g. inferring a JSON field is "required" from sibling data, or claiming "schema validation fails" / "the artifacts-test count is wrong" on a PR whose CI is green), and the consensus/split blocker auto-CLOSES the PR. Grounding already feeds the finished CI status to the reviewer, but the model can ignore it — and nothing enforced the deterministic ground truth.

This makes the engine enforce it, in both surfaces so they always agree:

  1. Disposition (planAgentMaintenanceActions): when the gate FAILED solely on an AI-judgment blocker (ai_consensus_defect / ai_review_split) and the real CI is green, the effective verdict is success → a clean + green PR MERGES. Never manual (only guardrails hold), never overrides a deterministic blocker (a mixed failure still closes) or a red/unverified CI.
  2. Public comment (reconcileGateEvaluationForGreenCi): the same condition renders the comment headline + Gate panel row as success/advisory instead of a contradictory red "blocked/closed". The specific AI concern still surfaces as a raised concern under the green verdict — visible, not silenced.

Both gate on one shared predicate aiCiRefutationActive(env, repo) (grounding AND convergence-allowlisted), so the action and the message can never disagree, and it's byte-identical for non-convergence repos.

Closes #1331

Scope

  • src/ only — pure helpers + flag-gated, branch-free call sites
  • No secrets/wallets/hotkeys/trust-scores/reward terms; codes are public-safe finding identifiers
  • No site/CNAME/lovable; no CHANGELOG

Validation

  • npm run test:ci — exit 0; 4283 tests pass
  • npm audit --audit-level=moderate — 0 vulnerabilities
  • Every changed src line AND branch covered (verified via lcov BRDA; eliminated one unreachable ?? [] defensive branch)
  • New tests: agent-actions (consensus/split→merge, enabled-false→close, red-CI/mixed/deterministic/inconclusive→close, guardrail-still-held); rules (isAiJudgmentOnlyFailure + reconcile across enabled/ciState/code combos); grounding-wire (aiCiRefutationActive all 4 grounding×convergence arms)

Safety

  • Can only ever turn a would-CLOSE into a would-MERGE for a green + deterministically-clean PR; cannot enable a close or weaken a deterministic blocker
  • Guardrail manual-hold precedence preserved (test); red/unverified CI never overridden (test)

…(#ai-ci-refutation)

A live dry-run audit of 44 metagraphed PRs found the AI reviewer false-closing ~60%
of clean, green, mergeable contributor PRs: the dual free Workers-AI models share the
same hallucination (e.g. inferring a JSON field is "required" from sibling data, or
claiming "schema validation fails" / "the test count is wrong" on a PR whose CI is
green), and the consensus/split blocker auto-CLOSES the PR. Grounding already feeds
the finished CI status to the reviewer, but the model can ignore it — nothing enforced
the deterministic ground truth.

This makes the disposition enforce it: when the gate FAILED solely because of an
AI-judgment blocker (ai_consensus_defect / ai_review_split) and the real CI is GREEN,
the AI claim is refuted by the validator → the effective verdict is success → a
clean + green PR MERGES. It is NOT routed to manual review (only the guardrail path
holds), and it NEVER overrides a deterministic blocker (every blocker must be an
AI-judgment code) or a red/unverified CI. The AI concern still surfaces in the review
comment as an advisory; it simply no longer auto-closes a green PR.

- agent-actions.ts: AI_JUDGMENT_BLOCKER_CODES + an effective `conclusion` that downgrades
  an AI-only failure to success when ciState==passed; threads through gatePassing,
  willClose, and the label-reason display (now reports verdict=success; CI green).
- processors.ts: thread the gate blocker CODES into the planner, gated under the same
  grounding + convergence condition as the converged AI review that produces the defects
  (flag-off / non-convergence repo ⇒ codes omitted ⇒ byte-identical verdict).
@dosubot dosubot Bot added the size:M label Jun 25, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.24%. Comparing base (06a3a42) to head (1af8c0f).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1331   +/-   ##
=======================================
  Coverage   95.23%   95.24%           
=======================================
  Files         185      185           
  Lines       20259    20270   +11     
  Branches     7286     7291    +5     
=======================================
+ Hits        19294    19306   +12     
  Misses        378      378           
+ Partials      587      586    -1     
Files with missing lines Coverage Δ
src/queue/processors.ts 87.52% <100.00%> (+0.02%) ⬆️
src/review/grounding-wire.ts 94.80% <100.00%> (+0.06%) ⬆️
src/rules/advisory.ts 97.27% <100.00%> (+0.05%) ⬆️
src/settings/agent-actions.ts 91.08% <100.00%> (+1.39%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…are the gate

Completes the AI CI-refutation: the disposition (planAgentMaintenanceActions) merges a
green-CI PR whose only gate failure was an AI-judgment blocker, but the review COMMENT was
still rendered from the raw gate.conclusion=failure — so a merged PR would show a red
"blocked/closed" headline + Gate panel row. reconcileGateEvaluationForGreenCi makes the
comment render SUCCESS/advisory in that case, matching the action; the specific AI concern
still surfaces from the advisory findings as a raised concern under the green verdict.

To keep the two surfaces in lock-step and fully unit-testable (no uncovered branch in the
processor):
- advisory.ts: canonical AI_JUDGMENT_BLOCKER_CODES + isAiJudgmentOnlyFailure +
  reconcileGateEvaluationForGreenCi(gate, ciState, enabled). agent-actions now imports the
  shared code set instead of a local copy.
- grounding-wire.ts: aiCiRefutationActive(env, repo) — the single grounding+convergence gate
  both the disposition and the comment use, so they can never disagree. Called as a plain
  function at each processor site (no inline && / ternary → no integration-only branch).
- agent-actions.ts: the refutation is now gated by an explicit aiCiRefutationEnabled flag
  (unit-tested), and the blocker codes are resolved once so the nullish fallback is covered.
- processors.ts: the comment block resolves live CI first, then reconciles the gate ONCE and
  uses it for both the panel rows and the comment body.
@dosubot dosubot Bot added the size:L label Jun 25, 2026
@JSONbored JSONbored changed the title fix(agent): an AI-judgment gate failure must not close a green-CI PR fix(agent): AI CI-refutation — an AI-judgment failure never closes (or visibly blocks) a green-CI PR Jun 25, 2026
@JSONbored JSONbored self-assigned this Jun 25, 2026
@JSONbored
JSONbored merged commit 5a8851e into main Jun 25, 2026
18 checks passed
@JSONbored
JSONbored deleted the fix/ai-defect-no-close-on-green-ci branch June 25, 2026 07:03
@JSONbored JSONbored added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant