Merged
Conversation
Contributor
📝 WalkthroughWalkthroughAdds a PdfAnnotationRemediator that prunes untagged or structurally orphaned annotations from tagged PDFs, integrates it into PdfRemediationProcessor with logging, and includes an integration test suite validating removal while preserving correctly-tagged annotations. Changes
Sequence DiagramsequenceDiagram
participant Processor as PdfRemediationProcessor
participant Remediator as PdfAnnotationRemediator
participant PDF as PDF Document
participant Tree as ParentTree/NumberTree
Processor->>Remediator: RemoveUntaggedAnnotations(pdf, cancellationToken)
Remediator->>PDF: Inspect Catalog / StructTreeRoot
Remediator->>Tree: TryGetParentTree()
Tree-->>Remediator: Return ParentTree (NumberTree root)
loop For each Page
Remediator->>PDF: Get / enumerate Annotations
loop For each Annotation
Remediator->>PDF: Dereference annotation, read StructParent
alt StructParent missing
Remediator-->>Remediator: Mark annotation for removal
else StructParent present
Remediator->>Tree: NumberTreeContainsKey(structParent) (recursive)
alt Key not found
Remediator-->>Remediator: Mark annotation for removal
end
end
end
Remediator->>PDF: Remove marked annotations from Page
end
Remediator-->>Processor: Return totalRemoved
Processor->>Processor: Log removal count (if > 0)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
Contributor
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@server.core/Remediate/PdfAnnotationRemediator.cs`:
- Around line 19-50: The code currently skips validation when parentTree (from
TryGetParentTree) is null, leaving annotations with a StructParent
(dict.GetAsNumber(StructParentKey)) orphaned; update the loop in
PdfAnnotationRemediator.cs where annotations are iterated (the block that
computes structParent and checks parentTree) so that if parentTree is null and
structParent is present you treat that annotation as invalid and add it to
toRemove (same handling as when NumberTreeContainsKey returns false); reference
TryGetParentTree, parentTree, StructParentKey, NumberTreeContainsKey, toRemove
and annotation to locate and change the logic.
This was referenced Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by CodeRabbit
New Features
Tests