Skip to content

GetWorkItemsByModuleRevisionAsync search using baseline at revision call instead of HEAD work items#6

Merged
FrogmanL merged 5 commits intodevelopfrom
fix-missing-work-items-by-module-revision
Apr 16, 2026
Merged

GetWorkItemsByModuleRevisionAsync search using baseline at revision call instead of HEAD work items#6
FrogmanL merged 5 commits intodevelopfrom
fix-missing-work-items-by-module-revision

Conversation

@ebakkum
Copy link
Copy Markdown

@ebakkum ebakkum commented Apr 2, 2026

Fix potentially missing work items when getting items by module revision due to work items being moved or deleted after the specific revision. Updated to query at baseline revision for work items instead of using call that queries work items at the HEAD revision.

… revision call instead of HEAD work items
@ebakkum
Copy link
Copy Markdown
Author

ebakkum commented Apr 7, 2026

This currently has an issue with branched documents across different projects due to SearchWorkitemInBaselineAsync having AND project.id:{_config.ProjectId}. It will thus undesirably filter out any work item from the branched from document location.

I am currently working on a solution to address this and ensure accurate results.

…all projects to support branched documents with cross-project work item references
@ebakkum
Copy link
Copy Markdown
Author

ebakkum commented Apr 10, 2026

Summary

Fixes #5 - GetWorkItemsByModuleRevisionAsync was querying work items at HEAD instead of the requested baseline revision, causing items moved or deleted after the target revision to be silently omitted from results.

Before: 156 items returned
After: 159 items returned (matching Polarion UI at that revision)

Root Cause

Step 3 of the algorithm used SearchWorkitemAsync, which queries the current HEAD snapshot. Work items that existed at the target revision but were subsequently moved or deleted were not present at HEAD and therefore dropped from results — even though they are correctly visible in the Polarion UI when viewing that historical document.

Changes

  • SearchWorkitemInBaselineAsync replaces SearchWorkitemAsync in step 3, querying the Polarion baseline snapshot at the specified revision rather than HEAD
  • includeAllProjects parameter added to SearchWorkitemInBaselineAsync and SearchWorkitemAsync (default: false, backward compatible) - GetWorkItemsByModuleRevisionAsync passes true to avoid the automatic project.id filter excluding work items that belong to other projects via branched documents
  • Recycle bin items are not a concern: the preceding step (step 2) explicitly constrains results to only the IDs active in the historical document, so recycled items are naturally excluded

Notes

  • No breaking changes - all existing callers of SearchWorkitemAsync and SearchWorkitemInBaselineAsync retain the current scoped-to-project behavior by default
  • api.md updated

Copy link
Copy Markdown
Collaborator

@schaveyt schaveyt left a comment

Choose a reason for hiding this comment

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

Changes to functionality look good. Changes to the coding style look no bueno.

Add the following to the .csproj

<!--
        Workaround for IDE0005: removed unused directives, we must enable XML
        documentation and ignore the warning it generates (CS1591)
         -->
        <GenerateDocumentationFile>true</GenerateDocumentationFile>
        <NoWarn>IL2026;IL2104;CS1591</NoWarn>
        <AnalysisLevel>10.0</AnalysisLevel>
        <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
        <TreatWarningsAsErrors>true</TreatWarningsAsErrors>

ebakkum and others added 3 commits April 14, 2026 17:36
- Add .editorconfig with CRLF line endings, 4-space C# indent, and
  csharp_prefer_braces=always:warning to require curly braces on all
  control flow statements
- Enable EnforceCodeStyleInBuild and TreatWarningsAsErrors in
  Polarion.csproj so style violations fail the build
- Suppress IL2026/IL2104 trim warnings that were previously unsilenced
- Pin AnalysisLevel to 10.0 for deterministic analyzer behavior
- Add missing final newlines to 12 files (mostly Connection/, Entities/,
  and several Client/ partials)
- Remove trailing whitespace from blank lines across 24 files
- Fix lambda brace placement (match => { → match =>\n{)
- Add missing space in argument list (PolarionClient_ExportModuleToMarkdownGroupedByHeadingAsync.cs)
- Normalize target-typed new expressions (new (...) → new(...))
Enforce csharp_prefer_braces = always via dotnet_diagnostic.IDE0011.severity
in .editorconfig so violations now fail the build. Fixed all 17 violations
across 4 files: PolarionClient_GetWorkItemsByModuleRevisionAsync.cs,
PolarionClient_SearchWorkitemAsync.cs, PolarionClient_SearchWorkitemInBaselineAsync.cs,
and OutlineNumberComparer.cs.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@ebakkum ebakkum force-pushed the fix-missing-work-items-by-module-revision branch from 36d6567 to d7b8862 Compare April 14, 2026 22:59
@ebakkum
Copy link
Copy Markdown
Author

ebakkum commented Apr 15, 2026

Formatting

Added requested coding style changes to project with a .editorconfig and enforce code style in build. Ran dotnet format .\src\PolarionApiClient.sln to clean up code and whitespaces.

Benchmark Results: GetWorkItemsByModuleRevisionAsync Fix

Ran a benchmark comparing develop vs this branch using the GetWorkItemsInModule MCP tool from PolarionMcpServers, which calls GetWorkItemsByModuleRevisionAsync under the hood. Tested across 4 document scenarios (2 documents x 2 projects), all querying historical revisions.

Execution Time

Scenario develop This Branch Speedup
Doc A / Project 1 282.3s 65.8s 4.3x faster
Doc A / Project 2 225.7s 63.4s 3.6x faster
Doc B / Project 1 63.7s 10.3s 6.2x faster
Doc B / Project 2 114.5s 29.3s 3.9x faster
Total 686.2s 168.8s 4.1x faster

Work Item Completeness

Scenario develop This Branch Delta
Doc A / Project 1 ERROR (0) 2,720 Fixed - was throwing exception
Doc A / Project 2 563 2,684 +377%
Doc B / Project 1 158 160 +1% (stable)
Doc B / Project 2 296 1,396 +372%

Key Findings

  1. Critical bug fixed: On develop, one scenario fails entirely with a URI resolution error when a document references work items from another project. This branch resolves it completely.

  2. Missing work items recovered: develop was only searching within the current project scope, returning a fraction of work items for branched documents with cross-project references. The cross-project baseline search recovers 4-5x more items in affected scenarios.

  3. Significant performance improvement: Every scenario is 3.6x to 6.2x faster. The new baseline-at-revision search strategy is both more correct and more efficient.

  4. No regressions: Documents without cross-project references show near-identical counts (158 vs 160), confirming backward compatibility.

@ebakkum ebakkum requested review from a team and schaveyt April 16, 2026 13:38
Copy link
Copy Markdown

@FrogmanL FrogmanL left a comment

Choose a reason for hiding this comment

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

Reviewed with Eric. Reviewed test results and methodology. No issues found. Approve.

@FrogmanL FrogmanL dismissed schaveyt’s stale review April 16, 2026 17:28

Talked to @schaveyt. No additional review is required.

@FrogmanL FrogmanL merged commit 2a4be1d into develop Apr 16, 2026
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.

3 participants