feat: add rule for TTL-based automatic data expiration#185
Conversation
avinashkamat48
left a comment
There was a problem hiding this comment.
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.
|
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. |
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
Checklist
npm run validateand it passednpm run buildto regenerate AGENTS.m{prefix}-{description}.mdtitle,Tests (Required)
waza run evals/cosmosdb-best-practices/eval.yamland all tasks passid,name,descripexpected.outcomesEval task file:
evals/cosmosdb-best-practicesamlFor 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
Related Issues
Closes #166