Skip to content

feat: add rule for TTL-based automatic data expiration#185

Closed
ramnnn2006 wants to merge 2 commits into
AzureCosmosDB:mainfrom
ramnnn2006:feat/model-ttl-expiration
Closed

feat: add rule for TTL-based automatic data expiration#185
ramnnn2006 wants to merge 2 commits into
AzureCosmosDB:mainfrom
ramnnn2006:feat/model-ttl-expiration

Conversation

@ramnnn2006

Copy link
Copy Markdown

Description

Adds a Data Modeling rule about using TTL for automatic data expiration instead of scheduled cleanup jobs. A lot of apps run timer
-triggered functions that query for old items and delete them in a loop, which burns RUs on every run. The rule shows enabling TTL on the container with a -1 default and per-item ttl overrides, covers the common fits (sessions, event logs, temp caches), and the gotchas: expiry rides on _ts so updates reset the clock, deletes are lazy but expired items drop out of queries right away, and per-item ttl does nothing if container TTL is off. Comes with an eval task.

Type of Change

  • 📝 New rule - Adding a new best practice rule
  • ✏️ Rule improvement - Updating an existing rule
  • 🆕 New skill - Adding an entirely new skill
  • 🐛 Bug fix - Fixing an issue with existing content
  • 📚 Documentation - Updating README, CONTRIBUTING, or other docs
  • 🔧 Build/Scripts - Changes to build process or scripts

Checklist

  • I have read the Contributing Guide
  • I ran npm run validate and it passed
  • I ran npm run build to regenerate AGENTS.m
  • My rule file follows the naming convention: {prefix}-{description}.md
  • My rule includes valid frontmatter (title,

Tests (Required)

  • I added/updated an eval task in `evals/cosmo
  • I ran waza run evals/cosmosdb-best-practices/eval.yaml and all tasks pass
  • My task file includes id, name, descripexpected.outcomes

Eval task file: evals/cosmosdb-best-practicesaml

For New Rules

Rule file: `skills/cosmosdb-best-practices/rul

Category: Data Modeling

Impact level: Medium

Why is this rule important?
TTL is built into Cosmos DB and the deletes run in the background on leftover request units, yet people keep writing cleanup jobs that do cross-partition queries plus a delete per s RUs, competes with live traffic, and is extra code to maintain. Agents should reach for container TTL with per-item overrides first and know the _ts reset behavior so sliding vs fixed expirations come out right.

Agent Testing

  • Tested with GitHub Copilot
  • Tested with Claude Code
  • Tested with Cursor
  • Tested with other agent: _____
  • N/A (documentation only)

Related Issues

Closes #166

@avinashkamat48 avinashkamat48 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for adding this rule. One thing I noticed in skills/cosmosdb-best-practices/AGENTS.md: the inlined section now has ### 1.11 Use TTL for Automatic Data Expiration followed immediately by another ## Use TTL for Automatic Data Expiration. That duplicate higher-level heading appears to come from copying the standalone rule body into the generated AGENTS doc, but here it interrupts the numbered Data Modeling hierarchy and creates two headings for the same rule. I think the inlined AGENTS version should drop the standalone ## heading so the TOC/section structure stays consistent with the surrounding rules.

@ramnnn2006

Copy link
Copy Markdown
Author

good point, dropped the standalone ## heading from the rule body so 1.11 doesn't repeat the title. one thing to flag: the other rules in the doc still carry their own ## heading since every rule body is written that way and compile.js just inlines it, so this is the only section without it now. happy to send a separate pass that strips it across all rules if you'd rather have it uniform, didn't want to balloon this PR's diff.

@TheovanKraay

Copy link
Copy Markdown
Contributor

Closing as a duplicate of #184, which was opened first for the same issue (#166) and already has an approval. Thanks for the contribution though. If you'd like to pick up another open issue, there are several available.

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.

[Rule] Use TTL (Time-to-Live) for automatic data expiration

3 participants