[Bug] PR-mined decisions store the decision sentence again as their rationale

Open Beginner friendly
#5,702 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@suyashgitt is already working on this.

Since Nov 16, 2026.

  • #5706 by @suyashgitt — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start in apply_substring_gate at packages/core/src/repowise/core/analysis/decisions/gate.py:80-90, after the _GATED_FIELDS loop, and compare d.rationale with d.decision using normalize_text from provenance.py; clear the rationale only on equality and leave the substring rule untouched. Read requirement() at lifecycle.py:481 to confirm a cleared rationale then trips NO_RATIONALE_BLOCKER. Reproduce with a fixture PR body plus a model reply where rationale equals decision through DecisionExtractor.extract_all(enabled_sources={"pr"}), then add both cases (echo cleared, distinct rationale kept) to tests/unit/analysis/test_decision_gate.py.

Written by the indexing model from the issue text.

Description

bug good first issue

Summary

When a PR body never says why, the PR miner's model often copies the decision sentence into rationale. The substring gate checks each field against the source separately, so the echo is verified "exact" and stored.

packages/core/src/repowise/core/analysis/decisions/gate.py:80-90

for fname in _GATED_FIELDS:
    val = (getattr(d, fname, "") or "").strip()
    ...
    verdict = verify_quote(val, norm_src)

Mechanism

  • mine_pr_bodies accepts the model's rationale as-is (extractor.py:601-608, model_answers.py:134).
  • The gate grounds decision and rationale against the same sentence, and nothing compares them with each other.
  • requirement() takes the reason from rationale (lifecycle.py:481), so the echo clears NO_RATIONALE_BLOCKER. The comment at line 478 says the why must never come from decision.

Repro

Fixture PR body with one sentence, model reply with rationale == decision, run through DecisionExtractor.extract_all(enabled_sources={"pr"}):

source      : pr | verification: exact
decision    : ChatMarkdown takes a density prop shared across panels and replaces per-panel prose styles.
rationale   : ChatMarkdown takes a density prop shared across panels and replaces per-panel prose styles.
blockers as stored         : []
blockers if rationale empty: ['no rationale or explicit constraint reason']

Impact

get_why and the review queue show a restated "what" as the "why", and these records skip the rationale check on acceptance.

Done looks like

  • In apply_substring_gate, after the field loop, clear rationale when normalize_text(rationale) == normalize_text(decision) (normalize_text is in provenance.py).
  • Keep the substring rule exactly as it is. Do not loosen it.
  • Records without context then show NO_RATIONALE_BLOCKER, and confirm already asks for --reason.
  • Out of scope: rows already stored, because mined PRs are not re-mined.
  • Good first issue: one function, one comparison, an existing normaliser.

Tests

tests/unit/analysis/test_decision_gate.py (or the existing gate test file): an echoed rationale is cleared and the candidate survives; a distinct grounded rationale is kept.

Dominant language
Python
Stars
7.1k
Forks
756
Avg merge
21h 5m
Merged PRs (30d)
797

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from repowise-dev/repowise

All issues in repowise-dev/repowise

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.