feat(plc): PLC findings keyed by what they flag, saved through RunFindings (#491 follow-up) #499

Merged
sharang merged 2 commits from feat/plc-content-fingerprints into main 2026-10-06 11:27:35 +00:00
Owner

Follow-up to #491/#497, requested by the platform session. Stage only.

Problem

PLC findings were still keyed by POU + line and inserted one by one. Every line shift in an export created a duplicate finding, and the old one stayed, because PLC findings aren't auto-closed.

Change

  • plc::analyze_tree gives each hit its content:

    • the POU;
    • the rule's title and description, which name variables and functions but contain no line numbers;
    • an occurrence index among identical hits in the POU, ordered by line.

    A PLCopen XML line refers to the embedded body, not the file, so the file isn't read.

  • The PLC scan saves through RunFindings:

    • content keys;
    • a row stored under the line-based fingerprint is taken over (id, status, triage kept);
    • moved lines are followed;
    • control refs are refreshed on earlier rows, which is what the replaced loop did.
    • Still no auto-close for PLC.
  • content_fingerprints now works without a tree when the scanner supplies the content, because a PLC scan reads several trees.

Tests

  • plc_findings_are_keyed_by_what_they_flag_not_their_line: a comment added at the top keeps every content key (the lines move by 2), and no two hits share one.
  • PLC and finding_store unit tests green. Agent lib: 711 tests.
  • Mongo: content_fingerprints, group_findings, group_decisions, resolve_findings green.
  • fmt and clippy -D warnings.

To check on stage

Check 19: rescan a PLC target unchanged, then with a comment added at the top.

  • No new findings, statuses kept.
  • Logs: … now keyed by their content on the first rescan, then findings whose code moved ….

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

Follow-up to #491/#497, requested by the platform session. Stage only. ## Problem PLC findings were still keyed by POU + **line** and inserted one by one. Every line shift in an export created a duplicate finding, and the old one stayed, because PLC findings aren't auto-closed. ## Change - **`plc::analyze_tree`** gives each hit its content: - the POU; - the rule's title and description, which name variables and functions but contain no line numbers; - an occurrence index among identical hits in the POU, ordered by line. A PLCopen XML line refers to the embedded body, not the file, so the file isn't read. - **The PLC scan saves through `RunFindings`:** - content keys; - a row stored under the line-based fingerprint is **taken over** (id, status, triage kept); - moved lines are followed; - control refs are refreshed on earlier rows, which is what the replaced loop did. - Still no auto-close for PLC. - **`content_fingerprints`** now works without a tree when the scanner supplies the content, because a PLC scan reads several trees. ## Tests - `plc_findings_are_keyed_by_what_they_flag_not_their_line`: a comment added at the top keeps every content key (the lines move by 2), and no two hits share one. - PLC and finding_store unit tests green. Agent lib: 711 tests. - Mongo: `content_fingerprints`, `group_findings`, `group_decisions`, `resolve_findings` green. - fmt and clippy `-D warnings`. ## To check on stage Check 19: rescan a PLC target unchanged, then with a comment added at the top. - No new findings, statuses kept. - Logs: `… now keyed by their content` on the first rescan, then `findings whose code moved …`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang added 2 commits 2026-10-06 11:15:41 +00:00
PLC findings were still keyed by POU and line and inserted one by one, so
every line shift in an export made a duplicate finding (they are not
auto-closed, so the old one stayed).

- plc::analyze_tree gives each hit its content: the POU, the rule's title
  and description (variable and function names, no line numbers) and its
  occurrence among identical hits in the POU. A PLCopen XML line is a line
  of the embedded body, not of the file, so the file is not read.
- The PLC scan saves through RunFindings: content keys, the row stored
  under the line-based fingerprint taken over (id, status, triage kept),
  moved lines followed, control refs refreshed on earlier rows (what the
  removed loop did). Still no auto-close for PLC.
- content_fingerprints works without a tree when the scanner gives the
  content (a PLC scan reads several trees).
- Test: a comment added on top keeps every PLC content key, and no two
  hits share one. Staging test plan: check 19.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
ci: retrigger after runner disk failure
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 11m16s
922635daa2
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang force-pushed feat/plc-content-fingerprints from 83c892bdfa to 922635daa2 2026-10-06 11:15:41 +00:00 Compare
sharang merged commit 9d1f8b6883 into main 2026-10-06 11:27:35 +00:00
Sign in to join this conversation.