Skip to content

Feature/encryption custom compatibility testing#4

Open
adamnova wants to merge 56 commits into
masterfrom
feature/encryption-custom-compatibility-testing
Open

Feature/encryption custom compatibility testing#4
adamnova wants to merge 56 commits into
masterfrom
feature/encryption-custom-compatibility-testing

Conversation

@adamnova
Copy link
Copy Markdown
Owner

@adamnova adamnova commented Oct 6, 2025

Pull Request Template

Description

Please include a summary of the change and which issue is fixed. Include samples if adding new API, and include relevant motivation and context. List any dependencies that are required for this change.

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [] This change requires a documentation update

Closing issues

To automatically close an issue: closes #IssueNumber

- Add Directory.Packages.props for Central Package Management
- Create CompatibilityTests project with net8.0 target
- Add testconfig.json with version matrix (preview05-07)
- Add VersionMatrix.cs helper for loading test configuration
- Update solution file to include new test project

This establishes the foundation for cross-version compatibility testing
of the Encryption.Custom package.
- Add CrossVersionEncryptionTests.cs with 27 test cases
  - Basic encryption/decryption across version pairs (9 tests)
  - Deterministic encryption compatibility (9 tests)
  - Randomized encryption compatibility (9 tests)
- Add CompatibilityTestBase.cs with logging and version detection
- Add SideBySide testing infrastructure:
  - IsolatedLoadContext.cs for AssemblyLoadContext isolation
  - VersionLoader.cs for loading multiple package versions
- Use xUnit Theory pattern for parameterized testing across 3x3 version matrix

All 27 tests pass with 100% success rate, validating bidirectional
compatibility across preview05, preview06, and preview07.
- Add main pipeline: azure-pipelines-encryption-custom-compatibility.yml
  - Stage 0: API compatibility check against baseline
  - Stage 1: Quick check for PRs (baseline version only)
  - Stage 2: Full matrix test (4 versions in parallel)
- Add reusable templates:
  - encryption-custom-compatibility-test-steps.yml (test execution)
  - encryption-custom-compatibility-test.yml (job wrapper)
  - encryption-custom-apicompat-check.yml (API validation)
- Configure triggers: PR, scheduled (daily 2 AM UTC), manual
- Publish test results and artifacts for analysis

Pipeline runs in <2 minutes for quick checks, ~15 minutes for full matrix.
API Compatibility Tools (Agent 4):
- apicompat-check.ps1: Automated API breaking change detection
- test-api-compat-local.ps1: Local quick API validation
- ApiCompatSuppressions.txt: Suppression file for known changes

Helper Scripts (Agent 5):
- discover-published-versions.ps1: Query NuGet for available versions
- update-test-matrix.ps1: Add/remove versions from test matrix
- download-package-version.ps1: Download packages for SxS testing
- build-local-encryption-custom-package.ps1: Build local test packages
- test-compatibility.ps1: Run full compatibility matrix locally

These tools enable developers to:
- Catch API breaking changes before CI (30s check)
- Manage version matrix without manual JSON editing
- Test locally before pushing to CI
- Build and test against local package builds
Documentation Suite (Agent 5):
- README.md: Navigation hub with role-based paths
- QUICKSTART.md: 5-minute getting started guide
- PIPELINE-GUIDE.md: Azure DevOps pipeline operations
- TROUBLESHOOTING.md: Common issues and solutions
- MAINTENANCE.md: Regular upkeep procedures and checklists
- CHEATSHEET.md: Quick command reference
- API-CHANGES.md: API change tracking template

Implementation Guides:
- 00-OVERVIEW.md: Architecture and design overview
- IMPLEMENTATION-SUMMARY.md: Complete roadmap
- 01-06 AGENT guides: Step-by-step implementation

Validation Reports:
- VALIDATION-COMPLETE.md: Full validation report (10/10 score)
- TEST-EXECUTION-REPORT.md: Detailed test results
- SUMMARY.md: Quick validation summary

Total: 27+ documentation files covering all aspects of the
compatibility testing framework from setup to maintenance.
All tests validated with 100% pass rate (27/27 tests passed).
Refactored compatibility tests to focus solely on cross-version encryption/decryption, added CompatibilityTestBase and VersionValidationTests for version uniqueness validation, and updated CrossVersionEncryptionTests to improve test coverage and logging. Enhanced VersionMatrix to support local source builds and dynamic version resolution, updated testconfig.json for flexible version selection, and added build-current-source.ps1 for local package creation. Updated pipeline and props to support local package sources and improved NuGet caching.
@adamnova adamnova marked this pull request as ready for review October 6, 2025 07:05
…ption.Custom compatibility tests

- Add comprehensive GitHub Actions workflow with quick PR checks and full matrix testing
- Add Cache@2 task to pipeline template for cross-agent NuGet package persistence
- Configure daily scheduled runs and manual workflow dispatch
- Parallel matrix testing for versions preview04-preview07
Remove agent-specific guides, planning documents, and summaries.
Keep only essential operational docs:
- README.md (index)
- QUICKSTART.md
- PIPELINE-GUIDE.md
- MAINTENANCE.md
- TROUBLESHOOTING.md
- CHEATSHEET.md
- API-CHANGES.md
- Add workflow_dispatch inputs for baseline_version and version_matrix
- Create prepare-matrix job to dynamically build version array from inputs
- Support comma-separated version lists without code changes
- Update README with configuration examples and GitHub CLI commands
- Maintain backward compatibility with default version matrix
… restore errors

The test project's restore process looks for a local packages source at
artifacts/local-packages. When this directory doesn't exist in CI, NuGet
fails with NU1301 errors. Creating the directory (even if empty) prevents
these errors while still allowing local development workflows.
- Remove baseline-only quick check mode; always run full matrix
- Add build-current-package job that builds current source as NuGet with unique version (1.0.0-pr{n}-{run} or 1.0.0-ci-{run})
- Update prepare-matrix to inject current package version into test matrix
- Add conditional local NuGet source setup when testing current version
- Update documentation to reflect simplified workflow
Directory.Build.props includes artifacts/local-packages in RestoreSources,
so the folder must exist before running dotnet restore/pack operations.
All jobs need the artifacts/local-packages folder to exist because
Directory.Build.props includes it in RestoreSources. When testing the
current package version, we copy the built package into this folder
so it can be resolved during dotnet restore.
The test framework (CrossVersionEncryptionTests) automatically generates
all version pairs from the versions array in testconfig.json. The CI
workflow now:

1. Builds current source as a NuGet package with unique version
2. Updates testconfig.json with versions to test (default: preview07,current)
3. Runs tests which internally test all pairs:
   - preview07 → preview07
   - preview07 → current
   - current → preview07
   - current → current

This is simpler than managing pairs at the CI level and matches how
the test framework is designed to work.
Remove '1.0.0-preview08-next' which doesn't exist as a published package.
The CI workflow will dynamically update this file to add the current
source version before running tests.
Previously, VersionLoader only checked artifacts/local-packages for
versions containing 'current' in the name. Now it always checks the
local packages folder first for ANY version before falling back to
the global NuGet cache.

This enables the CI workflow to build packages with versions like
'1.0.0-preview08-pr4-3' and have them correctly resolved during tests.
Resolved Git conflict markers that were causing YAML syntax error.
Print paths and directory contents to understand why package isn't being found.
…ersions

- Expose AssemblyPath in VersionLoader for file-level inspection
- Add AssemblyBinaryValidation test that verifies:
  * SHA256 file hashes are unique (proves different binaries)
  * Assembly paths are different (proves separate loading)
  * File sizes (additional validation)
  * Assembly version attributes (AssemblyVersion, FileVersion, InformationalVersion)
  * Strong name/public key token consistency
- Detailed output shows full comparison matrix for debugging
- Replace hardcoded individual jobs with matrix strategy
- Matrix spawns parallel jobs for each version in VersionsToTest
- PR/CI builds: test only against BaselineVersion (preview07)
- Scheduled/Manual runs: test against full matrix (preview07, 06, 05, 04)
- Easy to add new versions by updating VersionsToTest variable
- Groundwork for future version additions
- Changed from runtime variables to compile-time parameters
- Matrix now properly expands with parameters.VersionsToTest
- Each version spawns as separate parallel job
- Fixed replace() to handle both dots and dashes in version strings
- Updated documentation comments to reflect parameter-based approach
- Consolidated QuickCheck and FullMatrix stages into single CompatibilityMatrix stage
- PR builds: Matrix spawns 2 jobs (preview07, preview06) for fast feedback
- Non-PR builds: Matrix spawns 4 jobs (preview07, 06, 05, 04) for full coverage
- Matrix dimension names now visible in job list (e.g., '1_0_0_preview07')
- Simplified stage dependencies (ApiCompatibilityCheck -> CompatibilityMatrix -> Report)
adamnova and others added 27 commits October 6, 2025 15:37
- Replaced single job testing all pairs with matrix spawning separate jobs
- Matrix creates 2 jobs per run: current→preview07 and preview07→current
- Job names now clearly show version pairs: 'Test X ⟷ Y'
- Each matrix job tests specific encrypt/decrypt version combination
- Separate artifacts per version pair for easier debugging
- fail-fast: false ensures all combinations run even if one fails
- Groundwork for expanding matrix to more version combinations
- Removed redundant directional testing (A→B and B→A)
- Matrix now spawns 1 job per version pair instead of 2
- Tests are bidirectional by nature (both encrypt/decrypt directions covered)
- Job name: 'Test current_vs_preview07' showing both versions tested
- Reduces pipeline execution time by 50%
- Easier to add more version pairs without exponential job growth
- Build step now supports matrix of source repositories and branches

- Can test against PRs from forks by specifying repo/ref in build_sources

- Default: builds from current repository and branch

- Manual override via workflow_dispatch build_sources input (JSON array)

- Each build source tested against all specified versions (cross product)

- Job naming shows source name and test version clearly

- Enables testing compatibility between different development branches
PRs included:

- Azure#5385: (Auto-built and tested)

- Azure#5399: (Auto-built and tested)

- Azure#5403: (Auto-built and tested)

- Azure#5417: (Auto-built and tested)

- Azure#5428: (Auto-built and tested)

Matrix behavior:

- PR/CI builds: Test only current branch (fast feedback)

- Scheduled/Manual runs: Test current + 5 PRs (6 builds total)

- Each build tested against 1.0.0-preview07

- Creates 6 parallel compatibility test jobs for comprehensive validation
- Added debug output to show event name and inputs

- Fixed empty string check for build_sources input

- Now correctly expands matrix for manual/scheduled runs

- Manual runs without custom input will test all 6 sources (current + 5 PRs)
- Removed conditional logic that limited PR builds to single source

- Now ALWAYS tests all 6 sources (current + 5 PRs) on every run

- Applies to: pull_request, push, schedule, and workflow_dispatch

- Only exception: custom build_sources via workflow_dispatch input

- Provides comprehensive compatibility validation on every trigger
- Changed from 'include' to direct 'build_source' matrix dimension

- Fixed checkout to use matrix.build_source.repository/ref

- Fixed debug output to use matrix.build_source.* properties

- This resolves artifact upload failures and checkout errors
- Changed from multi-line to single-line JSON array

- Removes whitespace and newlines that caused 'Invalid format' error

- Ensures proper parsing by GitHub Actions output processor
- Add continue-on-error to build step to handle API incompatibilities
- Only upload artifacts for successfully built packages
- Skip test execution for sources that failed to build
- Add clear messaging when builds/tests are skipped
- Update test summary to show skipped vs tested sources

This allows testing compatible PRs while gracefully handling ones with breaking API changes (e.g., PR Azure#5403, Azure#5385).
- Remove continue-on-error from build step (build failures now fail the job)
- Add if: always() to compatibility-tests job (runs even if some builds fail)
- Test jobs skip gracefully when corresponding build job failed
- Failed builds will show as red X, successful builds as green checkmark
- Only successfully built packages will be tested
- Parse PR references (refs/pull/NUMBER/head) and create links to PR pages
- Create branch links for non-PR sources
- Show repository and ref information in summary
- Add link to source when build fails for easier troubleshooting
…tibility tests

- Add IMPLEMENTATION-COMPLETE.md with full validation status report
- Add VALIDATION-REPORT.md with requirements verification
- Add CrossVersionSystemTextJsonTests for JSON processor compatibility
- Add FeatureAvailability helper for version-specific feature detection
- Add RequestOptionsHelper for System.Text.Json configuration
- Add SYSTEM_TEXT_JSON_TESTING.md documentation
- Update README.md with JSON processor testing details
- Update CompatibilityTestBase for enhanced test infrastructure
Implements comprehensive cross-version compatibility testing infrastructure
for PR Azure#5403's System.Text.Json streaming API feature.

Key Changes:
- Feature Detection (FeatureAvailability.cs):
  * SupportsSystemTextJsonSwitch(): Detects ConfigureJsonProcessor API
  * HasJsonProcessorEnum(): Validates JsonProcessor enum existence
  * HasStreamJsonProcessorValue(): Checks for JsonProcessor.Stream value

- Helper Methods (RequestOptionsHelper.cs):
  * TryConfigureJsonProcessor(): Version-agnostic JSON processor config
  * Uses reflection for cross-version compatibility

- Test Suite (JsonProcessorCompatibilityTests.cs):
  * 12 test combinations covering all version/mode permutations
  * Standardized skip pattern for unsupported features
  * Tests encrypt/decrypt across different SDK versions and JSON modes
  * CanEncryptAndDecrypt_AcrossJsonProcessorModes
  * CanEncryptAndDecryptDeterministic_AcrossJsonProcessorModes

- Configuration:
  * Updated testconfig.json to include 'current' version testing
  * Fixed version resolution for proper package loading

Test Results: All 12 tests passing
- Old versions (1.0.0-preview07) gracefully skip unsupported features
- Current version successfully runs all JSON processor combinations
- Cross-version compatibility validated

Documentation:
- JSON_PROCESSOR_TESTING.md: Comprehensive testing guide
- JSON_PROCESSOR_IMPLEMENTATION_SUMMARY.md: Technical details
- JSON_PROCESSOR_QUICK_REFERENCE.md: Quick reference guide
- COMPLETE_IMPLEMENTATION.md: Full implementation overview
…ontainer doesn't exist (Direct mode) (Azure#5500)

## Description

When operations fail with 404, it's ambiguous whether the item doesn't
exist or the parent container/database doesn't exist. This PR fixes the
SDK to properly set substatus code 1003 (OwnerResourceNotFound) when
collection resolution fails during item operations, enabling developers
to distinguish between these two fundamentally different error
conditions.

### Changes

-**SDK Fix**: Modified
`ClientCollectionCache.ResolveCollectionWithSessionContainerCleanupAsync`
to set substatus 1003 when collection resolution fails with 404 for
non-container operations
- Item/document operations now correctly get 404/1003 when container
doesn't exist (Direct mode)
- Container metadata operations continue to get 404/0 when container
doesn't exist (the container itself is the missing resource)
- Query and stored procedure operations get 404/1003 when container
doesn't exist

- **Emulator Tests**: Added parameterized tests validating substatus
code behavior in both TCP (Direct) and Gateway connection modes
  - 404/0 → item not found in existing container
  - 404/1003 → container or database doesn't exist (Direct mode)
  - Tests run with `[DataRow]` attributes for both connection modes
- Test names clarified with `_StreamingAPI` and `_TypedAPI` suffixes to
indicate which API type is being tested
- `ValidateSubStatusCodeForItemNotFoundVsContainerNotFound_StreamingAPI`
tests streaming APIs (ReadItemStreamAsync)
- `ValidateCosmosExceptionSubStatusCodeForNotFound_TypedAPI` tests
typed/non-streaming APIs (ReadItemAsync)
- `ValidateContainerMetadataRequestsHaveSubstatus0` validates that
container operations correctly return substatus 0


- **Unit Tests**: Added tests for CosmosException and ResponseMessage
substatus code handling

- **Documentation**: Added examples in `Exceptions.md` showing how to
distinguish these cases

### Direct Mode vs Gateway Mode

__Direct Mode (TCP)__:

- Fully supports substatus code 1003 for container-not-found scenarios
- Can distinguish between item-not-found (404/0) and container-not-found
(404/1003)

__Gateway Mode__:

- Known limitation: Cannot always distinguish these scenarios due to
Gateway architecture
- Returns 404/0 for both item-not-found and container-not-found
- Database-not-found scenarios still return 404/1003 in both modes

### Usage

Check `SubStatusCode` to differentiate 404 scenarios:

```csharp
try {
    var response = await container.ReadItemAsync(id, partitionKey);
} catch (CosmosException ex) when (ex.StatusCode == HttpStatusCode.NotFound) {
    if (ex.SubStatusCode == 1003) {
        // Container/database doesn't exist - may need to create it
        // (Direct mode only for container-not-found)
    } else {
        // Item doesn't exist - normal case
    }
}
```

Same pattern works with `ResponseMessage.Headers.SubStatusCode` for
stream APIs.

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)

## Closing issues

Resolves Azure#227
Fixes Azure#229

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kirankumarkolli <6880899+kirankumarkolli@users.noreply.github.com>
Co-authored-by: Yash Trivedi <yash2710@users.noreply.github.com>
Co-authored-by: yash2710 <8458233+yash2710@users.noreply.github.com>
…e#5504)

## Description

The CI pipeline currently includes a thinclient test that depends on
emulator, but the thinclient test job doesn't setup the emulator. This
PR adds the emulator setup step to get the test working

## Type of change

Please delete options that are not relevant.

- [x] Bug fix (non-breaking change which fixes an issue)

## Closing issues

Co-authored-by: Arooshi Avasthy <113193425+aavasthy@users.noreply.github.com>
# Pull Request Template

## Description

This PR adds the missing function identifiers for REgexExtract(All) and
Hash functions to the sql dom

## Type of change

Please delete options that are not relevant.

- [] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [] This change requires a documentation update

## Closing issues

To automatically close an issue: closes #IssueNumber

Co-authored-by: Minh Le <leminh@microsoft.com>
…zure#5510)

# Pull Request Template

## Description


This pull request adds support for two new fault injection server error
types—`Unauthorized` and `AadTokenRevoked`—to the Cosmos DB fault
injection framework. This enables more comprehensive testing of
authentication-related failure scenarios, including unauthorized access
and revoked Azure Active Directory (AAD) tokens. The changes cover
updates to the error type enumeration, handling logic, validation, and
new tests to ensure these scenarios are properly simulated.

**Support for new server error types:**

* Added `Unauthorized` (401:0) and `AadTokenRevoked` (401:5013) the
`FaultInjectionServerErrorType` enum, enabling these error types to be
used in fault injection rules.
* Updated error handling logic in
`FaultInjectionServerErrorResultInternal.cs` to generate appropriate
responses for `Unauthorized` and `AadTokenRevoked`, including setting
status codes, headers, and response bodies.
[[1]](diffhunk://#diff-1ae8256c6d505a8f3b0a350978a0cc9a08f6234f7328f28f1db14302ee691d72L273-R293)
[[2]](diffhunk://#diff-1ae8256c6d505a8f3b0a350978a0cc9a08f6234f7328f28f1db14302ee691d72L547-R603)

**Validation and rule filtering:**

* Enhanced gateway connection validation in
`FaultInjectionRuleBuilder.cs` to recognize and handle the new error
types, ensuring unsupported error types are not rejected for metadata
requests.

**Testing:**

* Added new test methods in `FaultInjectionGatewayModeTests.cs` to
verify correct rule filtering and application for `Unauthorized` and
`AadTokenRevoked` error scenarios, including validation of hit counts
and error responses.

## Type of change

Please delete options that are not relevant.

- [] New feature (non-breaking change which adds functionality)

## Closing issues

To automatically close an issue: closes #IssueNumber
# Pull Request Template

## Description

This pull request introduces a new semantic reranking feature to the
Azure Cosmos DB .NET SDK, enabling users to rerank documents using an
inference service that leverages Azure Active Directory (AAD)
authentication. The main changes include the addition of the
`InferenceService` class, new API surface for semantic reranking, and
appropriate integration into the SDK's authorization and client context
infrastructure. Notably, this functionality is only available when using
AAD authentication.

**Semantic Reranking Feature Integration:**

* Added the `InferenceService` class, which handles communication with
the Cosmos DB Inference Service for semantic reranking, including HTTP
client configuration, payload construction, and response handling. This
service enforces AAD authentication and manages its own authorization
and disposal.
* Introduced a new public (under `PREVIEW`) or internal API
`SemanticRerankAsync` to the `Container` class, allowing users to rerank
a list of documents based on a context/query string. This is implemented
in `ContainerInlineCore` and routed through the client context.
[[1]](diffhunk://#diff-e3b7704253edcfb63d18e851d9b0a8de3ea60889d704c363c2da1899a3ac39b7R1682-R1702)
[[2]](diffhunk://#diff-d7119df75f749b2d2ebcadc708f02d419663febceeaab4147a898c4be777e33dR700-R708)
* To use this feature, the environment variable
"AZURE_COSMOS_SEMANTIC_RERANKER_INFERENCE_ENDPOINT", must be set with
the inference endpoint from the service.
* Additionally, the environment variable
"AZURE_COSMOS_SEMANTIC_RERANKER_INFERENCE_SERVICE_MAX_CONNECTION_LIMIT",
can be set to change the inference client's max connection limit.

**Authorization and Token Handling Updates:**

* Extended the `AuthorizationTokenProvider` abstraction and its
implementations to support a new method,
`AddInferenceAuthorizationHeaderAsync`, which is only valid for
AAD-based token providers. Non-AAD providers throw a
`NotImplementedException` for this method.
[[1]](diffhunk://#diff-839842554f21dd8c2180a3c4f5a25abffdc392902a0f10f1130397f064d84db5R55-R60)
[[2]](diffhunk://#diff-93d0d6522a71c823da524b5cdceb024a8aae4497b14b383dcac41a98edf7092aR18-R29)
[[3]](diffhunk://#diff-93d0d6522a71c823da524b5cdceb024a8aae4497b14b383dcac41a98edf7092aR78-R92)
[[4]](diffhunk://#diff-1e0a2b64595baccd2b71f2328bd8f6ca9a81fb8175c5d489e5cdadba1b5c3a05R217-R221)
[[5]](diffhunk://#diff-cca89b75cc8e6136d1f595f20169546258617f88cf0b5e0e345554c073e06e78R95-R99)
[[6]](diffhunk://#diff-3ad037c5217ed55cda63aaa1a0e1897c9b1c6603b6e85b9649cdd8cf457ac6fbR128-R132)

**Client Context and Resource Management:**

* Updated `ClientContextCore` and `CosmosClientContext` to manage the
lifecycle of the `InferenceService`, including creation, caching, and
disposal. Added methods for invoking semantic reranking and for
retrieving or creating the inference service instance.
[[1]](diffhunk://#diff-a41317d6b53931e411d3091f58700758c53e80ca27dccedeafd76226852e58d2R38)
[[2]](diffhunk://#diff-a41317d6b53931e411d3091f58700758c53e80ca27dccedeafd76226852e58d2R472-R497)
[[3]](diffhunk://#diff-a41317d6b53931e411d3091f58700758c53e80ca27dccedeafd76226852e58d2R515)
[[4]](diffhunk://#diff-b0bd965dfed52d866ec53af3bbb3b7afb4f420cdda75ac9071515ac471c0f7baR8)
[[5]](diffhunk://#diff-b0bd965dfed52d866ec53af3bbb3b7afb4f420cdda75ac9071515ac471c0f7baR136-R148)
[[6]](diffhunk://#diff-a41317d6b53931e411d3091f58700758c53e80ca27dccedeafd76226852e58d2R8)

**Dependency Updates:**

* Added a dependency on the `Azure.Identity` package in the test project
to support AAD authentication scenarios.
Please delete options that are not relevant.

**Example**

```csharp
//Sample code to demonstrate Semantic Reranking
// Assume 'container' is an instance of Cosmos.Container
// This example queries items from a fitness store with full-text search and then reranks them semantically.

string search_text = "integrated pull-up bar";

string queryString = $@"
    SELECT TOP 15 c.id, c.Name, c.Brand, c.Description
    FROM c
    WHERE FullTextContains(c.Description, ""{search_text}"")
    ORDER BY RANK FullTextScore(c.Description, ""{search_text}"")
    ";

string reranking_context = "most economical with multiple pulley adjustmnets and ideal for home gyms";

List<string> documents = new List<string>();
FeedIterator<dynamic> resultSetIterator = container.GetItemQueryIterator<dynamic>(
    new QueryDefinition(queryString),
    requestOptions: new QueryRequestOptions()
    {
        MaxItemCount = 15,
    });

while (resultSetIterator.HasMoreResults)
{
    FeedResponse<dynamic> response = await resultSetIterator.ReadNextAsync();
    foreach (JsonElement item in response)
    {
        documents.Add(item.ToString());
    }
}

Dictionary<string, dynamic> options = new Dictionary<string, dynamic>
{
    { "return_documents", true },
    { "top_k", 10 },
    { "batch_size", 32 },
    { "sort", true }
};

SemanticRerankResult results = await container.SemanticRerankAsync(
    reranking_context,
    documents,
    options);

// get the best resulting document from the query
results.RerankScores.First().Document;
// or the index of the document in the original list
results.RerankScores.First().Index;
// or the reranking score 
results.RerankScores.First().Score;

// get the latency information from the reranking operation
Dictonary<string, object. latencyInfo = results.Latency;

// get the token usage information from the reranking operation
Dictonary<string, object> tokenUseageInfo = results.TokenUseage;
```

- [] New feature (non-breaking change which adds functionality)

## Closing issues

To automatically close an issue: closes #IssueNumber
- Add EdgeCaseEncryptionTests with comprehensive test payloads:
  - Empty, single byte, null bytes, all byte values (0-255)
  - High entropy binary data, large 64KB payloads
  - AES block size boundary cases (15, 16, 17 bytes)
  - UTF-8 edge cases with emoji and symbols
  - JSON content, long strings, mixed binary/text

- Add negative tests for tamper detection:
  - Tampered ciphertext (bit flip) should throw
  - Truncated ciphertext should throw
  - Random garbage data should throw
  - Wrong key should throw or produce garbage

- Skip same-version pairs for published packages (only test current↔current)
- Remove CrossVersionSystemTextJsonTests.cs (duplicate of JsonProcessorCompatibilityTests.cs)
- Keep JsonProcessorCompatibilityTests.cs which has:
  - More thorough feature checks (SupportsSystemTextJsonSwitch + HasStreamJsonProcessorValue)
  - Better skip reason logging with out parameters
- Update documentation to reference JsonProcessorCompatibilityTests

Comparison showed 95% code duplication between the two files.
JsonProcessorCompatibilityTests was the more complete implementation.
- Added CompatibilityTestCollection with shared VersionLoaderFixture
- Applied [Collection] attribute to all test classes for proper parallelism
- Added [Trait] attributes for better categorization (Type, Feature)
- Added copyright header to CrossVersionEncryptionTests.cs
- Fixed lint warnings (explicit types, parentheses)
- Removed duplicate TestFixtures/CompatibilityTestBase.cs
- Cleaned up unused imports
adamnova added a commit that referenced this pull request Mar 17, 2026
Production code fixes:
- Issue #1: Replace fire-and-forget Task.Run with tracked LastDistributedCacheWriteTask
  to prevent unobserved exceptions on SetDekProperties
- Issue #3: Add DefaultContractResolver to CacheSerializerSettings for defense-in-depth
  against host-level JsonConvert.DefaultSettings overriding property naming
- Issue Azure#7: Explicit DateTimeOffset conversion for AbsoluteExpiration to prevent
  incorrect timezone offset when DateTime.Kind is Unspecified
- Issue Azure#11: Add version field to CachedDekPropertiesDto for forward-compatible
  cache format evolution

Test fixes:
- Issue #4: Replace Task.Delay(200ms) with SemaphoreSlim-based deterministic
  waiting in proactive refresh test
- Issue #5: Replace Task.Delay(500ms) with deterministic await on
  LastDistributedCacheWriteTask in SetDekProperties tests
- Issue Azure#8: Extract duplicated InMemoryDistributedCache to shared test helper file

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
adamnova added a commit that referenced this pull request Mar 17, 2026
- EnsureCapacity: copy data first, then clear only tail region to avoid
  wastefully zeroing bytes that BlockCopy immediately overwrites
- PooledStreamConfiguration: mark 'current' field volatile for correct
  memory visibility across all architectures
- SerializeToStreamAsync: use JsonSerializer.SerializeAsync for true
  async cancellation support throughout the serialization pipeline
- StreamProcessor.Encryptor: document the intentional inline-dispose
  + finally safety-net disposal pattern for future maintainers

Findings triaged with GPT 5.4 cross-model consultation. Skipped:
- #4 (gap zeroing): different concerns, not inconsistent
- #5 (extra copy): necessary for correctness with using/dispose
- Azure#8 (duplicate const): required for TFM compatibility
- Azure#9 (constructor divergence): by design for NET8+ config support

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

5 participants