Repository navigation
feat(exchange): Recoverable Items estimator — $count mode - #221
Merged
NityamPareek merged 3 commits intoNov 17, 2026
Merged
Conversation
Add EORecoverableItemsEstimator, which counts IPM.Note emails in the Deletions, Purges, DiscoveryHolds and Versions Recoverable Items folders of primary mailboxes via the v1.0 admin mailbox API ($count per folder, mailbox addressed by UPN). Backend only; not wired to the UI yet. - Per-mailbox concurrency: mailboxes are de-duplicated, processed 10 at a time in sequential rounds of one $batch, with at most 2 requests per mailbox per $batch, so Exchange's limit of 4 concurrent requests per mailbox is never exceeded. - Every folder error counts 0 and is reported as a partial failure; a mailbox whose four folders all fail is reported as a full failure. - Folder hierarchy mode (Recursive setting) raises NotImplementedError until it is added in a follow-up PR. - New constants, ScanConfig.scan_recoverable_items, factory accessor and unit tests.
…ther mailbox scans Drop RECOVERABLE_ITEMS_MAILBOXES_PER_TASK. The caller decides how many mailboxes a call handles (the scan pipeline will use min(concurrency // 10, 20), as for primary and shared mailboxes). Within a call, each round of two folders is sent as sequential $batch calls of at most graph_batch_size requests, keeping each mailbox's requests for the round in the same $batch.
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.
Part 2 of 7 of the Exchange Recoverable Items (litigation hold) work. Targets the
exchange-litigation-holdintegration branch.Summary
Adds
EORecoverableItemsEstimator, the backend engine that counts IPM.Note emails in the four Recoverable Items folders of primary (user / shared) mailboxes. Backend only: nothing in the UI calls it yet (that comes in PR 4).recoverableitemsdeletionsrecoverableitemspurgesrecoverableitemsdiscoveryholdsrecoverableitemsversionsRequest per folder (v1.0, mailbox addressed by UPN):
Requires the
MailboxItem.Read.Allapplication permission. The permission check is added when the scan is wired up in PR 4.API
get_folder_counts(upns, failures)→{upn: {Deletions, Purges, DiscoveryHolds, Versions}}, used later for the 4 CSV columns.calculate_resource_count({"user_ids": upns}, failures)→{upn: total}.get_folder_totals()→ aggregate per-folder counts, used later for the logs.Per-mailbox concurrency (Exchange limit: 4 concurrent requests per mailbox)
min(concurrency // 10, 20), the same chunking as primary and shared mailbox scans.$batchcalls of at mostgraph_batch_size(10) requests, i.e. up to 5 mailboxes × 2 folders. A mailbox's 2 requests for a round are always in the same$batch, enforced by an explicit check.$batchin flight at a time, and has no internal thread pool. The pipeline will run calls in parallel over disjoint mailboxes.$batchis still running server-side while it is retried, the peak is 2 + 2 = 4.The estimator calls
UrlInvoker.execute_batch_requestdirectly (asfetch_user_batch_dataalready does) instead ofinvoke, becauseinvokedrops 4xx responses. This keeps real status codes and messages in failure reports.Failure handling (no fallbacks)
@odata.count@odata.countINVALID_DATA)NOT_FOUND)NOT_FOUND)Partial failures carry the folder label as
folderId(shown as "Failed Resource" by the existing failure logging).Other changes
util/constants.py: folder allow-list, report column names, max requests per mailbox per batch (2).ScanConfig.scan_recoverable_items(defaultFalse).EstimatorFactory.get_recoverable_items_estimator()(main token manager).NotImplementedErroruntil PR 3.Testing
tests/eo_recoverable_items/eo_recoverable_items_tests.py(13 offline tests): every failure outcome, request shape and encoding, batch composition limits (≤graph_batch_sizeper$batch, ≤ 2 per mailbox, each folder requested once), de-duplication, 200 mailboxes chunked as the pipeline will at concurrency 10 / 30 / 100 never exceeding 2 in-flight requests per mailbox, stop handling, invalid input.