feat(issues): a tracker issue follows its finding's status #451

Merged
sharang merged 1 commits from feat/issue-status-sync into main 2026-10-05 14:14:14 +00:00
Owner

Follow-up to #444 and #443, as the platform session requested: an issue in the repository follows the status of its finding.

Behaviour

Finding becomes Issue
Behoben (by the scan: "nicht mehr gefunden" / "jetzt Herstellercode"; or by a person) comment explaining why, then closed
Fehlalarm – Regel/Zuordnung, Ignoriert comment, closed
Risiko akzeptiert comment with the person's reason, label risk:accepted (Gitea), closed
Offen / Bewertet / Zu prüfen again (the scan finds it again, or a person reopens it) comment, reopened
  • Comments are German then English, like the labels.
  • Triggers:
    • PATCH /findings/{id}/status;
    • PATCH /findings/bulk-status;
    • the scan's close and reopen from #443 (RunFindings::status_changed).
    • In every case the sync runs in the background, so neither the API response nor the scan waits for it.
  • Robust: the sync reads the finding's current status when it runs, so a change made in between wins. It does nothing when the issue already matches. A tracker that can't be reached is logged, and the next change tries again.

Code

  • pipeline/issue_sync.rs (new): IssueSync { db, config, secrets, net_guard }::spawn(ids).
  • build_tracker is now a free function, so the API can use it; the orchestrator method delegates to it.
  • TrackerDispatch gains update_issue_status and add_comment, which existed in the trait but were never called.
  • GiteaTracker gains add_labels.
  • pruefwerk_labels() gains risk:accepted, created via ensure_labels like the others.

Tests

  • End-to-end (issue_sync::tests::an_issue_follows_its_findings_status, real Mongo plus a fake Gitea), using a target whose tracker is a managed Gitea repository:
    1. scan-closed finding → comment "Bei der Prüfung nicht mehr gefunden…" + state: closed;
    2. same status synced again → no further call;
    3. finding open again → state: open;
    4. accepted risk → labels: [42], then state: closed.
  • Unit tests for the status-to-action mapping and the comment texts (DE/EN, with the reason quoted).
  • Label tests updated (7 labels).
  • Agent lib tests: 533. Integration tests resolve_findings, live_findings and git_source pass against local Mongo.
  • fmt and clippy with the CI flags.
  • Docs: managed-git.md (DE) and managed-git-en.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

Follow-up to #444 and #443, as the platform session requested: **an issue in the repository follows the status of its finding.** ## Behaviour | Finding becomes | Issue | |---|---| | **Behoben** (by the scan: "nicht mehr gefunden" / "jetzt Herstellercode"; or by a person) | comment explaining why, then **closed** | | **Fehlalarm – Regel/Zuordnung**, **Ignoriert** | comment, **closed** | | **Risiko akzeptiert** | comment with the person's reason, label **`risk:accepted`** (Gitea), **closed** | | **Offen / Bewertet / Zu prüfen** again (the scan finds it again, or a person reopens it) | comment, **reopened** | - Comments are German then English, like the labels. - **Triggers:** - `PATCH /findings/{id}/status`; - `PATCH /findings/bulk-status`; - the scan's close and reopen from #443 (`RunFindings::status_changed`). - In every case the sync runs in the background, so neither the API response nor the scan waits for it. - **Robust:** the sync reads the finding's **current** status when it runs, so a change made in between wins. It does nothing when the issue already matches. A tracker that can't be reached is logged, and the next change tries again. ## Code - `pipeline/issue_sync.rs` (new): `IssueSync { db, config, secrets, net_guard }::spawn(ids)`. - `build_tracker` is now a free function, so the API can use it; the orchestrator method delegates to it. - `TrackerDispatch` gains `update_issue_status` and `add_comment`, which existed in the trait but were never called. - `GiteaTracker` gains `add_labels`. - `pruefwerk_labels()` gains `risk:accepted`, created via `ensure_labels` like the others. ## Tests - **End-to-end** (`issue_sync::tests::an_issue_follows_its_findings_status`, real Mongo plus a fake Gitea), using a target whose tracker is a managed Gitea repository: 1. scan-closed finding → comment "Bei der Prüfung nicht mehr gefunden…" + `state: closed`; 2. same status synced again → no further call; 3. finding open again → `state: open`; 4. accepted risk → `labels: [42]`, then `state: closed`. - Unit tests for the status-to-action mapping and the comment texts (DE/EN, with the reason quoted). - Label tests updated (7 labels). - Agent lib tests: 533. Integration tests `resolve_findings`, `live_findings` and `git_source` pass against local Mongo. - fmt and clippy with the CI flags. - Docs: `managed-git.md` (DE) and `managed-git-en.md`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang added 1 commit 2026-10-05 14:02:36 +00:00
feat(issues): a tracker issue follows its finding's status
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 10m44s
8fff28b2db
#444 opens an issue per finding in the managed repository, but nothing
updated it afterwards. Now, when a finding's status changes, by a person
(single or bulk) or by the scan (#443 closes and reopens), its issue
follows, in the background:
- resolved, false positive (rule or mapping) or ignored: a comment with
  the reason, then closed;
- accepted risk: the comment (with the person's reason) and, on Gitea,
  the new `risk:accepted` label, then closed;
- open, triaged or needs review again: reopened with a comment.

The sync reads the finding's current status when it runs, so a change in
between wins, and does nothing when the issue already matches. Comments
are German then English, like the labels. build_tracker is now a free
function the API can use; TrackerDispatch gains update_issue_status and
add_comment; GiteaTracker gains add_labels.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang merged commit 654f387c80 into main 2026-10-05 14:14:14 +00:00
Sign in to join this conversation.