Skip to content

Add ttl and conflict commands for container TTL and conflict resolution policy (#111) - #151

Merged
Mike Krüger (mkrueger) merged 7 commits into
mainfrom
dev/mkrueger/ttl-conflict-issue-111
Jul 9, 2026
Merged

Mike Krüger (mkrueger) merged 7 commits into
mainfrom
dev/mkrueger/ttl-conflict-issue-111

Conversation

@mkrueger

@mkrueger Mike Krüger (mkrueger) commented Jul 3, 2026 •

Copy link
Copy Markdown
Collaborator

Implements the ttl and conflict commands requested in #111, so container time-to-live and conflict resolution policy can be viewed and changed without leaving the shell.

What's included

ttl command

  • ttl show - display the current TTL configuration as JSON (status is disabled, no-default, or enabled)
  • ttl set <seconds> - enable TTL with a positive default expiration
  • ttl on - enable TTL with no container default (only items with their own ttl expire)
  • ttl off - disable TTL so items never expire

conflict command

  • conflict show - display the current conflict resolution policy as JSON
  • conflict set --mode <lastWriterWins|custom> - set the mode
  • --path for last-writer-wins (defaults to /_ts), --procedure for custom mode; unsupplied options keep their current value

Both commands target the current container by default and accept --database/--container overrides.

Implementation notes

  • Reads/writes route through CosmosResourceFacade with both ARM and data-plane implementations, consistent with the existing throughput/index commands.
  • Argument validation happens before any network call so bad input fails fast.
  • Added new value types ContainerTtlView, ConflictResolutionView, and ConflictResolutionUpdate.

Docs & localization

  • Localized help/error strings in lang/en.ftl
  • New sections in docs/commands.md
  • Feature bullets in README.md

Tests

  • Added offline unit tests (TtlCommandTests, ConflictCommandTests) covering not-connected, wrong-scope, and argument-validation branches plus the pure helper methods. All 32 pass.

Closes #111

…on policy (#111)

Implements the ttl and conflict commands requested in issue #111.

- ttl: show, set <seconds>, on, off for the container default time-to-live
- conflict: show and set for the conflict resolution policy (lastWriterWins or custom stored procedure)
- Routes reads/writes through CosmosResourceFacade with ARM and data-plane implementations
- Adds localized help/error strings, docs, README bullets, and offline unit tests

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds new CLI surface area to CosmosDBShell for managing container Time-to-Live (TTL) and conflict resolution policy directly from the shell, including both data-plane and ARM-backed implementations, plus docs/localization/tests.

Changes:

  • Introduces ttl and conflict commands (show + update flows) with JSON output and pre-network argument validation.
  • Extends ICosmosResourceOperations / CosmosResourceFacade and ARM + data-plane implementations to read/replace TTL and conflict resolution policy.
  • Updates user docs (README.md, docs/commands.md), localization (lang/en.ftl), and adds offline unit tests for key validation branches.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
README.md Adds feature bullets for the new ttl and conflict commands.
docs/commands.md Documents usage, subcommands, and examples for ttl and conflict.
CosmosDBShell/lang/en.ftl Adds localized help/description/error strings for ttl and conflict.
CosmosDBShell/Azure.Data.Cosmos.Shell.Core/ICosmosResourceOperations.cs Adds core interface methods for TTL and conflict policy read/replace.
CosmosDBShell/Azure.Data.Cosmos.Shell.Core/DataPlaneCosmosResourceOperations.cs Implements TTL + conflict policy read/replace via data-plane SDK calls.
CosmosDBShell/Azure.Data.Cosmos.Shell.Core/ArmCosmosResourceOperations.cs Implements TTL + conflict policy read/replace via ARM container resources.
CosmosDBShell/Azure.Data.Cosmos.Shell.Core/CosmosResourceFacade.cs Wires new TTL/conflict operations through the facade layer.
CosmosDBShell/Azure.Data.Cosmos.Shell.Core/ContainerTtlView.cs Adds a TTL view record for command JSON output.
CosmosDBShell/Azure.Data.Cosmos.Shell.Core/ConflictResolutionView.cs Adds a conflict policy view record for command JSON output.
CosmosDBShell/Azure.Data.Cosmos.Shell.Core/ConflictResolutionUpdate.cs Adds an update record representing a fully-resolved conflict policy write.
CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/TtlCommand.cs New ttl command implementation (show/set/on/off).
CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/ConflictCommand.cs New conflict command implementation (show/set) with mode normalization.
CosmosDBShell.Tests/CommandTests/TtlCommandTests.cs Offline tests for not-connected/wrong-scope/argument-validation + helper mapping.
CosmosDBShell.Tests/CommandTests/ConflictCommandTests.cs Offline tests for not-connected/wrong-scope/argument-validation + mode normalization.
@github-code-quality

github-code-quality Bot commented Jul 3, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: C#

C# / code-coverage/dotnet

The overall coverage in the dev/mkrueger/ttl-con... branch is 61%. The coverage in the main branch is 62%.

Show a code coverage summary of the most impacted files.
File main 2ccd01d dev/mkrueger/ttl-con... e97e951 +/-
D:\a\CosmosDBSh...sourceFacade.cs 24% 17% -7%
D:\a\CosmosDBSh...lInterpreter.cs 52% 51% -1%
D:\a\CosmosDBSh...ceOperations.cs 2% 2% 0%
D:\a\CosmosDBSh...lutionUpdate.cs 0% 0% 0%
D:\a\CosmosDBSh...solutionView.cs 0% 0% 0%
D:\a\CosmosDBSh...ticalTtlView.cs 0% 0% 0%
D:\a\CosmosDBSh...ainerTtlView.cs 0% 0% 0%
D:\a\CosmosDBSh...s\TtlCommand.cs 0% 50% +50%
D:\a\CosmosDBSh...flictCommand.cs 0% 50% +50%

Updated July 09, 2026 10:56 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

Extend the ttl command with an --analytical/-a flag so show/set/on/off operate on the container's analytical store TTL instead of the default item TTL. Adds facade, interface, ARM, and data-plane support plus docs, localization, and tests.
Treat explicitly empty option values the same as omitting the option, matching the ThroughputCommand NormalizeOption pattern. Adds offline tests covering the fallback behavior.
Copilot AI review requested due to automatic review settings July 9, 2026 08:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Treat empty/whitespace --procedure as not provided in both pre-validation and SetAsync, consistent with --path. Adds offline tests.
Copilot AI review requested due to automatic review settings July 9, 2026 09:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

conflict show now emits /_ts for the effective LWW resolution path when the stored policy is missing or empty, matching the command default and documented JSON shape. The empty-procedure LWW test now invokes PreValidateSet via reflection instead of ExecuteAsync so it no longer hits the Cosmos endpoint offline.
Copilot AI review requested due to automatic review settings July 9, 2026 09:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

conflict set now rejects the mutually exclusive --path/--procedure combination in PreValidateSet before any network call. ReplaceAnalyticalTimeToLiveAsync now takes int? end to end, removing the overflow-prone checked cast and aligning the data-plane and ARM implementations.
Copilot AI review requested due to automatic review settings July 9, 2026 10:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Comment thread CosmosDBShell/lang/en.ftl Resolved
The invalid_seconds and toggle_no_args strings are reused by both item and analytical TTL, so the item-specific phrases (no default / default expiration) were reworded to on/off enable/disable and specify a TTL in seconds.
Copilot AI review requested due to automatic review settings July 9, 2026 10:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.

@mkrueger
Mike Krüger (mkrueger) merged commit 324e232 into main Jul 9, 2026
11 checks passed
@mkrueger
Mike Krüger (mkrueger) deleted the dev/mkrueger/ttl-conflict-issue-111 branch July 9, 2026 13:51
Mike Krüger (mkrueger) added a commit that referenced this pull request Jul 20, 2026
## What

Stamps the changelog release heading as `## 1.1.136-preview —
2026-07-20` and fills in the entries for PRs merged since
1.1.115-preview.

Supersedes #185 (same content, version heading bumped from `1.1.135` to
`1.1.136` to account for the extra git-height commit).

## Added entries

- **New features** — `ttl` and `conflict` commands for container
time-to-live and conflict-resolution policy
([#151](#151),
[#111](#111)).
- **Fixes** — MCP protocol-version rejection (e.g. Claude Code) and the
`ObjectDisposedException: The CancellationTokenSource has been disposed`
error on tool calls
([#150](#150)).
- **Build & pipeline** — CodeQL analysis workflow
([#165](#165)), Node 24
GitHub Actions updates
([#152](#152)), and a `union`
merge driver for `CHANGELOG.md`
([#172](#172)).

## Scope

- `CHANGELOG.md` only. No source or behavior changes. `version.json` is
unchanged — the patch is derived from git height by
Nerdbank.GitVersioning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants