Skip to content

Add mr_testing_analyst agent - #880

Open
martinky82 wants to merge 33 commits into
packit:mainfrom
martinky82:merge-changes
Open

martinky82 wants to merge 33 commits into
packit:mainfrom
martinky82:merge-changes

Conversation

@martinky82

Copy link
Copy Markdown
Contributor

Ports the mr_testing Claude Code skill into a Ymir agent so Testing Farm results, CVE verification, and untested/failed-test review can run as part of the automated pipeline instead of only interactively. Mirrors preliminary_testing_agent's Workflow/ReasoningAgent structure, which this agent is intended to eventually replace.

  • New privileged tools parse_mr_test_results and format_mr_testing_comment (ymir/tools/privileged/mr_testing.py), ported from the skill's parse_results.py/format_comments.py, since this workflow is tightly coupled to authenticated GitLab/Jira operations.
  • New update_merge_request_comment and remove_merge_request_labels privileged GitLab tools, closing gaps versus the skill: folding Testing Farm results into anewa's existing comment in place, and keeping the mr_testing_started -> mr_testing_completed -> mr_testing_analyzed label lifecycle clean for status tracking and rescheduling.
  • Wired into compose.yaml, Makefile (run-mr-testing-analyzer-agent-standalone), and agents_as_skills/mr-testing-analyzer for Claude Code use.

TODO:

  • Write new tests or update the old ones to cover new functionality.
  • Update doc-strings where appropriate.
  • Update or write new documentation in packit/packit.dev.
  • ‹fill in›

Fixes

Related to

Merge before/after

RELEASE NOTES BEGIN

Packit now supports automatic ordering of ☕ after all checks pass.

RELEASE NOTES END

martinky82 and others added 4 commits October 19, 2026 22:20
Ports the mr_testing Claude Code skill into a Ymir agent so Testing Farm
results, CVE verification, and untested/failed-test review can run as
part of the automated pipeline instead of only interactively. Mirrors
preliminary_testing_agent's Workflow/ReasoningAgent structure, which this
agent is intended to eventually replace.

- New privileged tools parse_mr_test_results and format_mr_testing_comment
  (ymir/tools/privileged/mr_testing.py), ported from the skill's
  parse_results.py/format_comments.py, since this workflow is tightly
  coupled to authenticated GitLab/Jira operations.
- New update_merge_request_comment and remove_merge_request_labels
  privileged GitLab tools, closing gaps versus the skill: folding Testing
  Farm results into anewa's existing comment in place, and keeping the
  mr_testing_started -> mr_testing_completed -> mr_testing_analyzed label
  lifecycle clean for status tracking and rescheduling.
- Wired into compose.yaml, Makefile (run-mr-testing-analyzer-agent-standalone),
  and agents_as_skills/mr-testing-analyzer for Claude Code use.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@TomasKorbar TomasKorbar left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scheduling is missing, i propose to file MR test analysis job when consolidation finishes and no more consolidation job is supposed to be filed. Wait for Gitlab CI results and if configuration parameter in ymir.yaml is present then also wait for separate runner results, those runners should apply label of your choosing. Then start the analysis and on finish of analysis, add label if you checked gitlab ci or the separate runner results.

@TomasKorbar

Copy link
Copy Markdown
Collaborator

Also there is pre-commit CI commit again. Check your local setup of the pre-commit hook.

@martinky82

Copy link
Copy Markdown
Contributor Author

Scheduling is missing, i propose to file MR test analysis job when consolidation finishes and no more consolidation job is supposed to be filed. Wait for Gitlab CI results and if configuration parameter in ymir.yaml is present then also wait for separate runner results, those runners should apply label of your choosing. Then start the analysis and on finish of analysis, add label if you checked gitlab ci or the separate runner results.

IMO, the analyzer should run only when the results are ready and as indication of that I propose using mr_testing_completed (or similar) label. Runners should be responsible for setting the label. I don;t see any reason to spawn the agent for it only to wait for results that may appear in minutes, hours or never.

But, if we opt for 2 stage testing (using the minimal CI results as a gate for full blown testing) then the analyst should be fired off for processing the CI results and if pass/waive (that can be done by agent, fail only if the analysis shows potential failure caused by the code change), the full testing will commence and alayzer would run for second time processing the full results

@TomasKorbar

Copy link
Copy Markdown
Collaborator

We are not spawning anything but we have to record which MR should be verified. We have basically 3 options to do this.

  1. You have to record the event of MR creation that is supposed to be analysed and check it in some time intervals for either gitlab ci or separate runner finish
  2. Set up some kind of gitlab hook that will submit the analysis job into new api endpoint. But that will most likely be blocked now by prods inability to consume outside traffic.
  3. Query packages in gitlab and try to determine for what MRs you should run the analysis. You will probably have to apply label like ymir_check_this on the MR that is supposed to be tested (you need to place this labels creation in appropriate places in workflows).

Option 3 would allow us to not care about persistent data records and recovery on shutdowns, so it would probably be the best, but it depends whether the queries in gitlab won’t have issues. Also you have to implement some kind of fetcher for this.

As for the 2 phase testing. The analysis will allways wait for gitlab CI and separate runner tests and if there is failure caused by code change in either CI or runner, it has to end with such indication (some boolean in final_answer). We will use that later to respin appropriate jobs. The first identified failure should fail the verification so we can spin up fix immediately and not needlesly verify again MR that is already in a wrong state.

@lbarcziova

Copy link
Copy Markdown
Member

/agentic_review

@qodo-for-packit

qodo-for-packit Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

Nice, no open findings for this group


Remediation recommended

Nice, no open findings for this group


Informational

Nice, no open findings for this group

Grey Divider

Resolved findings

1. Later test plans lose their result links ✓ Resolved High

Resolving commit: ab432b0

Resolution reason
Each plan's own Testing Farm artifacts URL is now recorded in a per-architecture plan_urls map,
the CVE verification prompt directs lookups to the matching plan's URL, and a test confirms
later-plan URLs are kept, so later-plan results remain fetchable.
Description
_parse_markdown_table keeps only the first plan's Testing Farm URL for each architecture and
discards URLs from subsequent plan cells. When a CVE test runs in a later plan, the agent cannot
fetch that plan's artifacts from the parsed result and may report missing or unknown verification
despite available results.

2. Model output can resolve any review thread ✓ Resolved High

Resolving commit: ab432b0

Resolution reason
The model no longer supplies a discussion ID. Resolution is gated on state.gating and performed by
Python, which looks up the OSCI results-comment discussion matching the marker,
resolvable/unresolved state, and this pipeline ID, and never resolves a thread without a match.
Blocking threads (Untested Issues / Test Failure Analysis) can no longer be resolved through this
path.
Description
act_on_result passes the model’s resolve_discussion_id directly to
resolve_merge_request_discussion without checking state.gating or verifying that the ID
identifies the unresolved OSCI bot results discussion for the analyzed pipeline. When
contributor-influenced CI traces or raw MR comments steer the model, this path can reach unrelated
human-review blocking threads, including Untested Issues and Test Failure Analysis, even outside
gating mode.

3. Completed results cannot update the note ✓ Resolved High

Resolving commit: ab432b0

Resolution reason
_comment_id now returns only comment.get("note_id") or comment.get("id") and explicitly does not
fall back to discussion_id (docstring explains GitLab discussion IDs cannot be used for note
updates). The gitlab.py get_authorized_comments now emits note_id=first_note.get("id") on
MergeRequestComment, and fetch_gitlab_mr_notes includes "id" per note. A regression test asserts a
discussion_id-only comment yields note_id None. This matches the suggested fix: expose numeric note
ID, carry it through parsing, never treat discussion ID as note ID.
Description
_comment_id substitutes a discussion ID when the fetched comment has no note ID, but
update_merge_request_comment requires an integer GitLab note ID. The primary comment-fetch tool
exposes only discussion_id, so the instructed in-place update fails on the normal path.

View resolved (15)
4. Parsed results cannot be formatted ✓ Resolved High

Resolving commit: ab432b0

Resolution reason
The parser in ymir/tools/privileged/mr_testing.py now returns results_by_arch as an
architecture-keyed dict (arch -> {overall_status, plans, plan_urls, artifacts_url, request_id}) via
_parse_markdown_table, directly usable by format_mr_testing_comment, with per-plan statuses
preserved and overall_status derived when missing. The ParsedMrTestResults schema and unit tests
were updated to match. The prompt was rewritten to read PARSED_RESULTS directly with no hand
reshaping. This removes the list-vs-dict mismatch and the lost plan statuses. Per-test CVE status
derivation is not fully addressed, but the core schema mismatch the finding describes is fixed.
Description
parse_mr_test_results returns lists of rows with flattened plan fields, while
format_mr_testing_comment requires architecture-keyed dictionaries containing nested plans
fields. Passing the parsed output as the prompt instructs fails input validation; converting only
the outer list still leaves blank plan statuses and missing CVE statuses.

5. Mixed failures can appear to pass ✓ Resolved High

Resolving commit: ab432b0

Resolution reason
Added an early return of False in _cve_status_is_pass when the status contains ❌, :x:, ⚠️, or
:warning:, so mixed pass/fail CVE status strings are no longer treated as passing.
Description
_cve_status_is_pass treats any status containing pass as a pass, even when it also contains a
failure indicator. A fixed-build result such as ❌ failed (2 fail, 10 pass) therefore becomes a
passing CVE result and can produce a verified or inconclusive fix verdict.

6. Partial runs can be marked analyzed ✓ Resolved High

Resolving commit: ab432b0

Resolution reason
The mr_testing_analyzer agent (and its prompt.j2 with the flagged stop condition) was deleted and
replaced by mr_testing_analyst_agent. In the new flow, parse_mr_results (Python) only accepts anewa
results when parsed.get("note_id") is not None or results_by_arch is non-empty; otherwise falls back
to NEWA. The new prompt (mr_testing_analyst/prompt.j2 Step 1) instructs the agent to read
PARSED_RESULTS, and analyzed labeling happens in act_on_result only when result.analyzed is true,
with fetch_and_validate_mr labeling only on no-linked-issues. The started-only case is handled by
the agent's prompt rules and labeling is gated on analyzed. This is a different implementation
addressing the started-comment concern, though the explicit completed-results indicator from the fix
prompt was not added to the parser.
Description
parse_anewa_mr_comments returns an NVR even when it finds no completed comment, leaving both
result lists empty. The prompt's stop condition requires all fields to be empty or null, so an MR
with only a started testing comment can proceed through formatting and receive the analyzed label
before results exist.

7. Authorized notes can be overwritten ✗ Dismissed High
Description
update_merge_request_comment writes to the supplied note ID without checking its author, while the
parser identifies anewa comments solely by text in the body. A project member whose comment passes
authorized-comment retrieval can spoof the **ANEWA:** marker, and the agent also receives raw
comment text that can steer its use of this privileged update tool.

8. Modern test rows show unknown results ✓ Resolved Medium

Resolving commit: ab432b0

Resolution reason
Added _derive_overall_status and wired it into _parse_markdown_table so rows lacking a Result column
get overall_status derived from their plan statuses (all-pass -> "✅ pass", otherwise the first
failing plan's status), eliminating the "unknown" Overall rendering for modern tables.
Description
_parse_markdown_table sets overall_status only when an anewa table has a Result column, while
the modern per-plan format has only plan columns. Passing its parsed rows to the results formatter
therefore renders ❓ unknown in the Overall column for every architecture, including rows whose
plan cells show clear pass or failure statuses.

9. New skill is absent after installation ✗ Dismissed Medium
Description
The new skill declares mr-testing-analyst, but the skill installer's hard-coded SKILLS list does
not include that name. Users running the repository's supported installer will not receive the skill
in their Claude Code or Cursor skills directory.

10. Anewa's comment can be overwritten with altered text ✓ Resolved Medium

Resolving commit: ab432b0

Resolution reason
Raw MR comments are parsed in Python (parse_mr_results step) and only the parsed JSON is given to
the model. note_id and note_body are kept in workflow state, and act_on_result folds the model's
plain formatted markdown into anewa's original note_body via fold_comment_body, so the model can no
longer corrupt or drop anewa's results table.
Description
run_analysis appends the full MR comment list to the prompt as JSON and tells the model to pass it
to the parse tools as-is. The fold then relies on the model copying note_body back into
fold_mr_comment_body, and its result is written over anewa's note with
update_merge_request_comment. A long comment history makes this expensive, and any truncation or
paraphrase during that copying becomes the new body of anewa's original comment and can drop its
results table permanently.

11. NEWA results lack a supported comment format ✓ Resolved Medium

Resolving commit: ab432b0

Resolution reason
The commit adds a new formatter action newa_results_markdown in mr_testing.py
(_format_newa_results_markdown, dispatched in FormatMrTestingCommentTool._run) that takes
all_passed, report_portal_url, and jenkins_url and produces a NEWA-specific comment explicitly
marked as unverified. It also adds the newa_results_markdown template to
mr_testing_templates.json, adds the action to the _FORMAT_ACTIONS list and the prompt's action list,
and rewrites the NEWA branch of prompt.j2 to call format_mr_testing_comment with action
newa_results_markdown. Unit tests cover the new action. This matches the suggested fix (add a
formatter action accepting NEWA status and links, marking it unverified, and use it in the NEWA
branch).
Description
The NEWA-only branch tells the agent to produce a new results comment while the prompt also forbids
hand-composed markdown, but format_mr_testing_comment offers no NEWA-specific action or compatible
arguments for that comment. On a completed NEWA-only run, the agent must either violate its
formatting instruction or misuse a template that requires per-architecture or gating-job results it
does not have.

12. Filtered bot results can be skipped ✓ Resolved Medium

Resolving commit: ab432b0

Resolution reason
The diff adds _comments_contain_expected_marker, which checks a successful authorized-comments
result for the expected results-bot marker (<!--RESULTS_COMMENT--> for gating, **ANEWA:** or NEWA
otherwise). If the marker is missing, the agent falls back to fetch_gitlab_mr_notes (not
role-filtered) and uses that result when it contains the marker. This covers the
successful-but-filtered case the finding describes. It does not verify bot author identity as the
fix prompt suggests, so it differs from the recommended approach, but it addresses the core issue.
Description
fetch_test_results falls back to raw MR notes only when authorized-comment retrieval raises, not
when that successful retrieval omits the results bot's note. If the bot is not a Developer-or-higher
member of the target project, its note is filtered out and the agent receives no results even though
the note exists.

13. A failed run reposts every comment on retry ✓ Resolved Medium

Resolving commit: ab432b0

Resolution reason
Jira comment posting is wrapped in try/except so failures are logged rather than aborting, and the
MR is labeled analyzed right after MR-side comments post, before the Jira loop and OSCI discussion
resolution. A Jira outage therefore no longer leaves the MR unlabeled, so a retry will not repost
the MR comments.
Description
act_on_result posts MR comments, blocking threads and Jira comments one after another, and only
adds the mr_testing_analyzed label at the very end. If any run_tool call raises partway through
(a Jira or GitLab error), the comments already posted stay up and the MR keeps
mr_testing_completed. The next scheduled run then posts duplicate CVE verification comments,
blocking discussion threads and Jira comments.

14. Jira outages produce unchecked analysis ✓ Resolved Medium

Resolving commit: ab432b0

Resolution reason
Jira detail fetch failures in gather_jira_context now abort the whole run with analyzed=False and no
MR/Jira posting or labeling, so the agent never analyzes with missing CVE/Test Coverage context. A
test (test_jira_fetch_failure_aborts_without_posting_or_labeling) covers this.
Description
gather_jira_context catches every Jira-details failure and substitutes an issue with no CVE ID or
Test Coverage. If that fetch fails transiently, the agent still analyzes and labels the MR using
incomplete issue context, so it cannot match the missing CVE and may flag its issue as untested.

15. Analyzer dependencies stay undocumented ✗ Dismissed Medium
Description
mr_testing_analyzer_agent.py introduces an agent that depends on GitLab, Jira, and Testing Farm
services through its gateway and local tools, but the change does not document this agent-specific
dependency flow in THREAT_MODEL.md. These dependencies handle MR comments, Jira issue metadata and
comments, test artifacts, and write operations, so the missing documentation leaves the new agent
boundary and handled data out of the threat model.

16. Fallback cannot fetch MR comments ✓ Resolved Medium

Resolving commit: ab432b0

Resolution reason
Replaced the wrong-schema fallback with _fetch_mr_notes_fallback, which derives project/mr_iid from
the MR URL, passes them to fetch_gitlab_mr_notes, and JSON-decodes the string result before
returning the comment list. fetch_test_results now uses this helper in both the exception path and
the missing-marker path.
Description
fetch_test_results calls fetch_gitlab_mr_notes with merge_request_url, although that tool
requires project and mr_iid. If the arguments are corrected alone, its JSON-encoded string
result still falls through the workflow’s dict/list handling and becomes an empty comment list.

17. Reruns can treat summaries as test rows ✓ Resolved Medium

Resolving commit: ab432b0

Resolution reason
Introduces FOLDED_RESULTS_MARKER and truncates the body at that marker before table parsing in
parse_anewa_mr_comments (both fixed/unfixed and single-table paths), so a rerun no longer treats the
previously appended Testing Farm analysis tables as anewa architecture rows; adds a regression test
for an appended coverage table.
Description
_parse_markdown_table keeps accepting pipe-delimited rows after the original anewa table ends. On
a rerun, a folded Testing Farm comment containing the formatter’s untested-issues coverage table
supplies extra headers and Jira issue rows as apparent architectures; with fixed/unfixed headings,
the trailing fold is included in the unfixed section.

18. Unlinked requests remain in limbo ✓ Resolved Medium

Resolving commit: ab432b0

Resolution reason
The no-linked-issues bail-out now calls _mark_mr_analyzed (adds mr_testing_analyzed, removes
mr_testing_completed; dry-run aware) before returning, so the MR no longer stays stuck in the
completed state. Gating mode is excluded deliberately, since gating never labels the MR.
Description
fetch_and_validate_mr ends immediately when it finds no Resolves: issue, before any label action
can run. For an MR without that line, the skill's specified clean bail-out calls for marking it
analyzed, but the existing completed status remains untouched.

Grey Divider

Context sources
✅ Compliance rules (platform): 6 rules
✅ Web pages:
  +5 more
✅ Context preparation
  Commit messages: summarized; full text retained for this review
Review mode: Auto: 🧠 Deep: Dense new logic: parsers, privileged GitLab writes, agent workflow, prompt across many files.

Grey Divider

Tip of the day
💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit ab432b0

Results up to commit c61e4ba ⚖️ Balanced


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Action required

Nice, no open findings for this group


Remediation recommended

Nice, no open findings for this group


Informational

Nice, no open findings for this group

Resolved findings

1. Completed results cannot update the note ✓ Resolved High

Resolving commit: ab432b0

Resolution reason
_comment_id now returns only comment.get("note_id") or comment.get("id") and explicitly does not
fall back to discussion_id (docstring explains GitLab discussion IDs cannot be used for note
updates). The gitlab.py get_authorized_comments now emits note_id=first_note.get("id") on
MergeRequestComment, and fetch_gitlab_mr_notes includes "id" per note. A regression test asserts a
discussion_id-only comment yields note_id None. This matches the suggested fix: expose numeric note
ID, carry it through parsing, never treat discussion ID as note ID.
Description
_comment_id substitutes a discussion ID when the fetched comment has no note ID, but
update_merge_request_comment requires an integer GitLab note ID. The primary comment-fetch tool
exposes only discussion_id, so the instructed in-place update fails on the normal path.

2. Parsed results cannot be formatted ✓ Resolved High

Resolving commit: ab432b0

Resolution reason
The parser in ymir/tools/privileged/mr_testing.py now returns results_by_arch as an
architecture-keyed dict (arch -> {overall_status, plans, plan_urls, artifacts_url, request_id}) via
_parse_markdown_table, directly usable by format_mr_testing_comment, with per-plan statuses
preserved and overall_status derived when missing. The ParsedMrTestResults schema and unit tests
were updated to match. The prompt was rewritten to read PARSED_RESULTS directly with no hand
reshaping. This removes the list-vs-dict mismatch and the lost plan statuses. Per-test CVE status
derivation is not fully addressed, but the core schema mismatch the finding describes is fixed.
Description
parse_mr_test_results returns lists of rows with flattened plan fields, while
format_mr_testing_comment requires architecture-keyed dictionaries containing nested plans
fields. Passing the parsed output as the prompt instructs fails input validation; converting only
the outer list still leaves blank plan statuses and missing CVE statuses.

3. Mixed failures can appear to pass ✓ Resolved High

Resolving commit: ab432b0

Resolution reason
Added an early return of False in _cve_status_is_pass when the status contains ❌, :x:, ⚠️, or
:warning:, so mixed pass/fail CVE status strings are no longer treated as passing.
Description
_cve_status_is_pass treats any status containing pass as a pass, even when it also contains a
failure indicator. A fixed-build result such as ❌ failed (2 fail, 10 pass) therefore becomes a
passing CVE result and can produce a verified or inconclusive fix verdict.

View resolved (7)
4. Partial runs can be marked analyzed ✓ Resolved High

Resolving commit: ab432b0

Resolution reason
The mr_testing_analyzer agent (and its prompt.j2 with the flagged stop condition) was deleted and
replaced by mr_testing_analyst_agent. In the new flow, parse_mr_results (Python) only accepts anewa
results when parsed.get("note_id") is not None or results_by_arch is non-empty; otherwise falls back
to NEWA. The new prompt (mr_testing_analyst/prompt.j2 Step 1) instructs the agent to read
PARSED_RESULTS, and analyzed labeling happens in act_on_result only when result.analyzed is true,
with fetch_and_validate_mr labeling only on no-linked-issues. The started-only case is handled by
the agent's prompt rules and labeling is gated on analyzed. This is a different implementation
addressing the started-comment concern, though the explicit completed-results indicator from the fix
prompt was not added to the parser.
Description
parse_anewa_mr_comments returns an NVR even when it finds no completed comment, leaving both
result lists empty. The prompt's stop condition requires all fields to be empty or null, so an MR
with only a started testing comment can proceed through formatting and receive the analyzed label
before results exist.

5. Authorized notes can be overwritten ✗ Dismissed High
Description
update_merge_request_comment writes to the supplied note ID without checking its author, while the
parser identifies anewa comments solely by text in the body. A project member whose comment passes
authorized-comment retrieval can spoof the **ANEWA:** marker, and the agent also receives raw
comment text that can steer its use of this privileged update tool.

6. Unlinked requests remain in limbo ✓ Resolved Medium

Resolving commit: ab432b0

Resolution reason
The no-linked-issues bail-out now calls _mark_mr_analyzed (adds mr_testing_analyzed, removes
mr_testing_completed; dry-run aware) before returning, so the MR no longer stays stuck in the
completed state. Gating mode is excluded deliberately, since gating never labels the MR.
Description
fetch_and_validate_mr ends immediately when it finds no Resolves: issue, before any label action
can run. For an MR without that line, the skill's specified clean bail-out calls for marking it
analyzed, but the existing completed status remains untouched.

7. Jira outages produce unchecked analysis ✓ Resolved Medium

Resolving commit: ab432b0

Resolution reason
Jira detail fetch failures in gather_jira_context now abort the whole run with analyzed=False and no
MR/Jira posting or labeling, so the agent never analyzes with missing CVE/Test Coverage context. A
test (test_jira_fetch_failure_aborts_without_posting_or_labeling) covers this.
Description
gather_jira_context catches every Jira-details failure and substitutes an issue with no CVE ID or
Test Coverage. If that fetch fails transiently, the agent still analyzes and labels the MR using
incomplete issue context, so it cannot match the missing CVE and may flag its issue as untested.

8. Fallback cannot fetch MR comments ✓ Resolved Medium

Resolving commit: ab432b0

Resolution reason
Replaced the wrong-schema fallback with _fetch_mr_notes_fallback, which derives project/mr_iid from
the MR URL, passes them to fetch_gitlab_mr_notes, and JSON-decodes the string result before
returning the comment list. fetch_test_results now uses this helper in both the exception path and
the missing-marker path.
Description
fetch_test_results calls fetch_gitlab_mr_notes with merge_request_url, although that tool
requires project and mr_iid. If the arguments are corrected alone, its JSON-encoded string
result still falls through the workflow’s dict/list handling and becomes an empty comment list.

9. Reruns can treat summaries as test rows ✓ Resolved Medium

Resolving commit: ab432b0

Resolution reason
Introduces FOLDED_RESULTS_MARKER and truncates the body at that marker before table parsing in
parse_anewa_mr_comments (both fixed/unfixed and single-table paths), so a rerun no longer treats the
previously appended Testing Farm analysis tables as anewa architecture rows; adds a regression test
for an appended coverage table.
Description
_parse_markdown_table keeps accepting pipe-delimited rows after the original anewa table ends. On
a rerun, a folded Testing Farm comment containing the formatter’s untested-issues coverage table
supplies extra headers and Jira issue rows as apparent architectures; with fixed/unfixed headings,
the trailing fold is included in the unfixed section.

10. Analyzer dependencies stay undocumented ✗ Dismissed Medium
Description
mr_testing_analyzer_agent.py introduces an agent that depends on GitLab, Jira, and Testing Farm
services through its gateway and local tools, but the change does not document this agent-specific
dependency flow in THREAT_MODEL.md. These dependencies handle MR comments, Jira issue metadata and
comments, test artifacts, and write operations, so the missing documentation leaves the new agent
boundary and handled data out of the threat model.

Grey Divider

Qodo Logo

Comment thread ymir/tools/privileged/mr_testing.py Resolved
Comment thread ymir/tools/privileged/gitlab.py Resolved
Comment thread ymir/tools/privileged/mr_testing.py Resolved
Comment thread ymir/tools/privileged/mr_testing.py Resolved

@lbarcziova lbarcziova left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank for kicking this off. Do you plan to finish the scheduling as part of this PR, or as a follow-up? As for mechanism, I agree with Tomas' proposals, but namely I would either start with

  • polling on Ymir submitted MRs (tradeoff is that we won't do testing on non-Ymir MRs)
  • generic Gitlab MR fetcher (similarly as we have the Jira one) that polls Gitlab for MRs with that particular label you propose as a first phase

Could you please also have a look into qodo's comments (I checked the high severity one at least and those look relevant)?

@diaasami diaasami mentioned this pull request Nov 2, 2026
4 tasks
@martinky82

Copy link
Copy Markdown
Contributor Author

thank for kicking this off. Do you plan to finish the scheduling as part of this PR, or as a follow-up? As for mechanism, I agree with Tomas' proposals, but namely I would either start with

* polling on Ymir submitted MRs (tradeoff is that we won't do testing on non-Ymir MRs)

* generic Gitlab MR fetcher (similarly as we have the Jira one) that polls Gitlab for MRs with that particular label you propose as a first phase

Could you please also have a look into qodo's comments (I checked the high severity one at least and those look relevant)?

I reckon the scheduling part should be a folow-up. I certainly opt for polling instead of running the agent only for ymir created MRs - the QE process change affects all testing no matter who or what submitted the MR.

Renames mr_testing_analyzer -> mr_testing_analyst throughout (agent
file, prompt dir, tests, compose/Makefile targets, agents_as_skills
dir), and fixes the review findings from PR packit#880 that still apply:

TomasKorbar:
- Drop the redundant "## Tools" prompt section and the hand-written
  final_answer JSON schema block -- BeeAI already injects the tool
  list and formats expected_output=MrTestingAnalystResult for the
  agent, so both were pure duplication.
- Biggest change: move every GitLab/Jira write out of the
  ReasoningAgent's reach. It now only parses results and returns
  structured content (mr_comments/jira_comments/resolve_discussion_id)
  in its final answer; a new deterministic act_on_result step performs
  every actual post/label/resolve. dry_run/poc/no_jira_comments are
  handled entirely in that step and no longer appear in the prompt at
  all.
- Unroll the comment templates to mr_testing_templates.json (asked
  about inline on the PR), loaded the same way the originating Claude
  Code skill loads its templates.json.

qodo-for-packit automated findings:
- note_id vs discussion_id confusion broke update_merge_request_comment
  on the normal path -- add a real note_id field end to end instead of
  falling back to a discussion_id update_merge_request_comment can't
  accept.
- parse_mr_test_results now returns the architecture-keyed dict shape
  format_mr_testing_comment actually requires, instead of a flat list
  of rows that had to be reshaped by hand (and never correctly was).
- Fix the anewa-still-running case being treated as "has results" and
  marked analyzed prematurely.
- _cve_status_is_pass no longer treats "failed (2 fail, 10 pass)" as a
  pass.
- fetch_gitlab_mr_notes fallback now calls the tool with its actual
  project/mr_iid schema and decodes its JSON string result, instead of
  silently producing an empty comment list.
- A rerun's own previously-folded analysis is no longer re-parsed as
  more anewa architecture rows -- a FOLDED_RESULTS_MARKER bounds table
  parsing, and a new fold_mr_comment_body tool builds the idempotent
  merge deterministically instead of leaving it to prompt instructions.
- An MR with no linked issues now gets labeled mr_testing_analyzed too
  (outside gating mode), so a completed-label scheduler doesn't re-queue
  it forever.
- A Jira fetch failure now aborts the run (analyzed: false, nothing
  posted/labeled) instead of silently continuing on an empty CVE/Test
  Coverage context.
- Document the agent's GitLab/Jira/Testing-Farm dependency flow and the
  comment-spoofing risk inherent to matching on body-text markers as
  T15 in THREAT_MODEL.md, with the deterministic-posting split and
  exact-note-targeting listed as mitigations.

Added/updated unit tests throughout; 108 tests pass in the two
privileged-tools suites. The agent-level test file can't execute in
this environment (pre-existing beeai-framework version mismatch,
confirmed present on unmodified main too) but was hand-verified
against the new act_on_result logic.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@martinky82

Copy link
Copy Markdown
Contributor Author

thank for kicking this off. Do you plan to finish the scheduling as part of this PR, or as a follow-up? As for mechanism, I agree with Tomas' proposals, but namely I would either start with

* polling on Ymir submitted MRs (tradeoff is that we won't do testing on non-Ymir MRs)

* generic Gitlab MR fetcher (similarly as we have the Jira one) that polls Gitlab for MRs with that particular label you propose as a first phase

Could you please also have a look into qodo's comments (I checked the high severity one at least and those look relevant)?

I reckon the scheduling part should be a folow-up. I certainly opt for polling instead of running the agent only for ymir created MRs - the QE process change affects all testing no matter who or what submitted the MR.

@martinky82 martinky82 changed the title Add mr_testing_analyzer agent Add mr_testing_analyst agent Nov 3, 2026
@martinky82

Copy link
Copy Markdown
Contributor Author

/agentic_review

martinky82 and others added 2 commits November 4, 2026 00:45
- check-mcp-install-in-container was failing: ymir-tools' wheel only
  packaged **/*.py, so mr_testing_templates.json never shipped in a
  real `pip install`, and mr_testing.py raises at import time when it
  can't find its templates file. Add **/*.json to the wheel include
  list. Verified by building the wheel and confirming the file is
  present and the module imports successfully from an installed copy.
- pre-commit.ci's ruff hook was failing on lines pre-existing before
  this change, in files this change otherwise touches (ruff lints
  whole files, not diffs): a try/except/pass -> contextlib.suppress,
  one over-length line, two list-concatenation-vs-unpacking nits, and
  an unnecessary dict() call. Fixed all five; `pre-commit run` is now
  clean end to end.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@nforro

nforro commented Nov 4, 2026

Copy link
Copy Markdown
Member

/agentic_review

Comment thread ymir/tools/privileged/mr_testing.py Resolved
Comment thread ymir/agents/mr_testing_analyst_agent.py Resolved
Comment thread ymir/tools/privileged/mr_testing.py Resolved
Comment thread ymir/agents/mr_testing_analyst_agent.py Resolved
Comment thread ymir/agents/mr_testing_analyst_agent.py Resolved
Comment thread ymir/agents/mr_testing_analyst_agent.py Resolved
@qodo-for-packit

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 89a616a

@cgwalters

Copy link
Copy Markdown
Contributor

One thing this relates to is that ultimately I think most agentic flows that operate on a git repository should run in the context of that repo - that's how GitHub Agentic Workflows operates, as does Fullsend etc.

Query packages in gitlab and try to determine for what MRs you should run the analysis. You will probably have to apply label like ymir_check_this on the MR that is supposed to be tested (you need to place this labels creation in appropriate places in workflows).

Which would bypass this type of thing - a workflow like this would be a thing that could be triggered by a slash command or be a scheduled job in the repo, and could run without any global state/queuing at all (other than the global state from the forge itself).

…back

Deterministic-side fixes for 8 qodo-for-packit findings: stop trusting a
model-chosen GitLab discussion ID for resolving OSCI's results thread
(Python now locates and validates it itself, gating-mode only), move
anewa/NEWA/OSCI comment parsing out of the model's own tool calls so raw
comment bodies and anewa's fold target never pass through model-generated
tool arguments, fall back to unfiltered MR notes when the authorized-comments
fetch silently drops the results bot's note, retain all per-plan Testing
Farm URLs instead of just the first, derive overall_status for modern
per-plan-only tables, add a real NEWA-only results comment template, keep a
partial Jira/discussion-resolve failure from blocking MR labeling, and
register the renamed skill in the installer.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@TomasKorbar

Copy link
Copy Markdown
Collaborator

One thing this relates to is that ultimately I think most agentic flows that operate on a git repository should run in the context of that repo - that's how GitHub Agentic Workflows operates, as does Fullsend etc.

Query packages in gitlab and try to determine for what MRs you should run the analysis. You will probably have to apply label like ymir_check_this on the MR that is supposed to be tested (you need to place this labels creation in appropriate places in workflows).

Which would bypass this type of thing - a workflow like this would be a thing that could be triggered by a slash command or be a scheduled job in the repo, and could run without any global state/queuing at all (other than the global state from the forge itself).

I need to check how this could be done in Gitlab. We discussed it with Laura but i ultimately thought that if we will add this as a CI job, then we won't be maintaining only the job but also our scraper which reacts to the external runner, but perhaps gitlab would allow us to trigger the job when the separate runner finished label is applied and thus would allow us to avoid scraping.

@TomasKorbar

Copy link
Copy Markdown
Collaborator

I did some research and discussed the stuff with Stephen Gallagher yesterday and i want to provide additional reasoning behind the scheduling and current plan.

For me the ideal state of this (as i see it right now) would be to have the review showing as additional CI job running after the tests. The job would communicate with our infra running the agents (because to me it seems that maintaining the infra directly in our cluster seems easier than debugging stuff in gitlab runners) and finish when the review is complete. If the review found issues with the MR, another pipeline with job fixing the MR would be run. That way we would show what is happening above the MR directly in the MR.

Separate runners would be instructed to execute pipeline instead of adding label to MR, because reacting to labels or comments would need us filtering those, while triggering pipeline is straightforward and requires no processing. I think it presents no difference whether separate test runners are adding label or triggering pipeline, we just have to tell them what to do.

Now why this can not happen right now is because we are not able to receive traffic from outside of VPN (that means gitlab) on the cluster where we are right now. That is why the querying and polling is a way how to do this in this moment and when we will migrate we will rework the scheduling again.

@TomasKorbar TomasKorbar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried running the workflow as it is and got

============================================================
  RESULT: ⚠️  SKIPPED
============================================================
No `Resolves: RHEL-XXXXX` line found in https://gitlab.com/redhat/rhel/rpms/expat/-/merge_requests/108's description.
============================================================

Current MRs filed by Ymir do not contain those lines in description, because ticket checking automation was then picking those values from MR description instead of commits and since it consumes only limited amount of characters, it split the Resolves: RHEL-XXXXX in half on multiple occasions and blocked the MR. The Resolves are in commits only.

Comment thread ymir/agents/mr_testing_analyst_agent.py Resolved
martinky82 added a commit to martinky82/ai-workflows that referenced this pull request Nov 6, 2026
- Find linked Jira issues from `Resolves:` footers in the MR's commit
  messages (new get_merge_request_commit_messages gateway tool), falling
  back to the description; abort without labeling if commits can't be fetched.
- Drop the agents_as_skills/mr-testing-analyst skill and its installer entry.
- Render gating/non-gating instructions and PARSED_RESULTS in the Jinja
  prompt instead of branching in the agent or appending to the prompt.
- Add queue mode (mr_testing_queue) alongside the direct MR_URL mode.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
martinky82 added a commit to martinky82/ai-workflows that referenced this pull request Nov 6, 2026
- Find linked Jira issues from `Resolves:` footers in the MR's commit
  messages (new get_merge_request_commit_messages gateway tool), falling
  back to the description; abort without labeling if commits can't be fetched.
- Drop the agents_as_skills/mr-testing-analyst skill and its installer entry.
- Render gating/non-gating instructions and PARSED_RESULTS in the Jinja
  prompt instead of branching in the agent or appending to the prompt.
- Add queue mode (mr_testing_queue) alongside the direct MR_URL mode.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
martinky82 and others added 12 commits November 10, 2026 15:53
…st failures

Look at earlier Test Failure Analysis threads on the same MR or, if none,
at up to 4 recent mr_testing_analyzed MRs of the component, and include the
findings (waivers, repeated failures) in the analysis via a new optional
History block in the failure comment.

search_gitlab_project_mrs gains optional label/exclude_drafts filters and
an optional search string.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Find linked Jira issues from `Resolves:` footers in the MR's commit
  messages (new get_merge_request_commit_messages gateway tool), falling
  back to the description; abort without labeling if commits can't be fetched.
- Drop the agents_as_skills/mr-testing-analyst skill and its installer entry.
- Render gating/non-gating instructions and PARSED_RESULTS in the Jinja
  prompt instead of branching in the agent or appending to the prompt.
- Add queue mode (mr_testing_queue) alongside the direct MR_URL mode.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
martinky82 and others added 10 commits November 20, 2026 21:23
- Wrap long summary and Redis startup log lines to satisfy E501.
- Remove dead url/encoded_project/headers assignments from
  SearchGitlabProjectMrsTool; the undefined _get_auth_headers call
  caused F821.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
In gating mode the agent fetched CI traces and Testing Farm logs through
tools, so long log text was pasted into its context and results got
omitted. Python now downloads each gating test job's results.xml and the
logs of its failed or errored testcases into a per-run temp directory
(fetch_test_logs step), and the agent reads those local copies with
view/search_text. Downloads are restricted to artifacts.osci.redhat.com
and capped at 50 logs per job. The temp directory is removed after the run.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
The workflow passed the MR URL as the transaction's jira_issue, so the
trace server indexed every span under the MR URL as if it were a Jira
issue. Transactions now start without an issue key, and once the linked
Jira keys are known the spans are tagged with them (comma-joined, which
the trace server splits on). run_mr_testing_analyst takes the
span_processor for this, as merge_request_agent does.

observability.start_transaction no longer names transactions
"... for None" when there is no issue key.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
The UI percent-encodes the issue key, but the route matched the raw
path, so keys containing "/" or ":" (such as MR URLs) never matched
the stored values. Decode the path before the lookup.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
The SDK default of 128 attributes evicts the oldest ones on LLM spans,
which flatten every message and tool schema. Long ReasoningAgent runs
dropped jira.issue and logged "Attributes dict is full" warnings.
Set SpanLimits.max_span_attributes to 1024 on the tracer provider.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
StreamReader.read(n) returns only the first buffered chunk, so the
fetch tool handed the model about 8 KB of a results file and CVE
testcases past that point looked missing. Read chunks up to the cap.

The full JUnit file is megabytes of system-out, so return one line per
testcase with a short failure message instead, and keep raw text only
for non-XML content. The testcase status rule moves to ymir/common/junit.py.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
The fold into anewa's note carried the unenriched table plus a second
per-architecture breakdown. Before folding, read each architecture's
results file, count testcases per plan, and append counts to the plan
cells (e.g. "✅ pass (4 pass)"). The summary is built without its own
table in that case. Also read the downloaded results in full, since
read(n) returned only the first chunk.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
The MrTestingAnalystWorkflow root span records the whole workflow
state at each step, which overflowed the 1024 limit on a real MR and
made the SDK drop the oldest attributes, including jira.issue.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
The workflow trace copies the state at every step, so the raw MR
comments and the anewa note body were recorded in full on the root
span. Exclude them from the state dump while keeping them in memory
for the fetch, parse, and fold steps, and drop the note body from
PARSED_RESULTS since the model does not need it.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@martinky82

Copy link
Copy Markdown
Contributor Author

Agent tested successfully:

https://gitlab.com/redhat/centos-stream/rpms/python3.12/-/merge_requests/124

the first run is done by my skill, the second by the agent

beeai fails the step with EmptyChatModelResponseError and the trace has
no reply to inspect. A LiteLLM callback now logs the finish reason, the
thinking-part types and lengths, and usage for such replies. The text
itself is never logged.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@martinky82

Copy link
Copy Markdown
Contributor Author

Side note: models like Sonnet 5.5 often error out on empty response from the model. It seems, the culprit is the security guardrails those new models have against misuse (though I never had such problem with my skill). Analysis with Opus 4.6 works flawlessly so far, even on a MR where Sonnet 5.5 reliably errored out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants