review-invariants
Skill11k starsChanged yesterdayMITView on GitHub
Correctness and invariants lens for Orleans — invariants and assertions, error handling, failure semantics, idempotence, grain concurrency and reentrancy, activation scheduling, async and cancellation, security boundaries, and observability. Use during code review, and when designing or implementing runtime or provider code.
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Look for an invariant or redesign that eliminates each fallback.
- Distinctive: line 16
When an invariant almost holds, or it is unclear whether it should hold, ask the maintainer (in reviews, raise it as a question) before …
- Distinctive: line 17
Check failure semantics, idempotence, concurrency ownership, activation scheduling, cancellation flow, and trust boundaries.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Invariants lens
Apply with root AGENTS.md, including its assertion policy. This lens examines
what must always be true, who guarantees it, and what happens when something fails.
Procedure
- For each affected boundary, identify the guarantees material to the change, including implicit ones the code already relies on: what the component provides to consumers and what it demands of callers and lower layers.
- Classify each changed error path: expected operational failure, invalid external input, cancellation, or programming-invariant violation.
- Look for an invariant or redesign that eliminates each fallback; replace fallbacks for states that cannot occur with assertions; give each condition that can occur a designed path in the spec.
- When an invariant almost holds, or it is unclear whether it should hold, ask the maintainer (in reviews, raise it as a question) before code depends on it.
- Check failure semantics, idempotence, concurrency ownership, activation scheduling, cancellation flow, and trust boundaries.
Checklist
- Invariants in both directions. Each affected boundary states what it guarantees and requires, using types where practical, XML docs for non-obvious caller-visible guarantees, and assertions for programming invariants.
- Explicit guarantees. Guarantees that code relies on are made explicit unless they are obviously maintained: in the type where the type system can express them, otherwise in a doc comment at the owning boundary and an assertion where they are relied on.
- Invariants, not fallbacks. Code relies on established invariants and asserts programming violations at their owning boundary. Prefer an invariant or simpler design that removes a condition; an operational alternative required by the contract has a reachable trigger, a defined outcome, and an oracle that exercises it. Yuan et al. found incorrect handling of non-fatal errors in 92% of the 48 catastrophic failures in their study (source).
- Fix contracts at their owner. A guarantee stated in a layer's contract is established for its dependents; a layer found violating it has a defect, fixed in that layer with a contract test that would have caught it (for example, an
IJournalStorageprovider whose append is not atomic is fixed in that provider). Dependents keep relying on the stated contract while the fix lands; compensating checks, retries, fallbacks, or test workarounds added to a dependent are defects. A guarantee the contract lacks is added through a contract change at the owning boundary. - Designed hints. Caches and directory, routing, and placement entries are specified as possibly stale, define how staleness is detected (validity check, version, or rejection by the authority), and recover through the authoritative path.
- Illegal states unrepresentable. External input is converted to validated types at the owning boundary and trusted inside, and revalidated when it crosses another trust boundary (parse, don't validate).
- Two kinds of error. Expected failures (I/O, timeouts, silo failure, storage conflicts, invalid external input, cancellation) are handled explicitly; product programming errors are caught by side-effect-free
Debug.AssertperAGENTS.md. Handlers that are empty or only log, catch overly general exceptions, or are left asTODOare defects; these three patterns caused 35% of the catastrophic failures Yuan et al. studied. - Precise assertions. Each assertion states one precondition, postcondition, or invariant, so a failure identifies the broken term, and covers both what must hold and what must not (for example, an entry is present and not yet disposed).
- Paired assertions. An invariant on data crossing a boundary is asserted on both sides: before it is written or sent, and after it is read or received (pair assertions).
- Safety, then liveness. Safety holds for every execution admitted by the fault model; progress follows stated quorum, scheduling, and communication assumptions, with deadlines or stall detection where the contract requires them.
- Failure semantics. Each interface that can time out, be cancelled, partially complete, see duplicates, or return stale data defines that behavior; a timed-out grain call may still have executed.
- Idempotence. Retried operations define duplicate behavior end to end, using natural idempotence, stable operation IDs, ETags or versions, or deduplication.
- Single-owner concurrency. Single-owner state (grain turns), sharding, and commutative (order-independent) updates are preferred to locks; leases and epochs, rather than distributed locks, govern ownership that moves between silos.
- Fencing. The protected resource checks ownership generation as part of applying a mutation, so work from a superseded owner cannot commit after the cutover (Chubby).
- Virtual synchrony. Each operation takes effect within the configuration that accepted it or not at all: the reconfiguration decision fixes the old configuration's closing state (for example, grain directory partition handoff on a membership change), so in-flight work from a sealed configuration never becomes visible later (Birman, Malkhi, and van Renesse).
- Recovery eligibility. A recovering participant resumes each role after restoring the durable evidence or completing the rebuild protocol that establishes that role's safety guarantees (Paxos Made Live).
- Interleaving. In reentrant or interleaved paths (
[Reentrant],[AlwaysInterleave], call-chain reentrancy), assumptions about mutable activation state are re-checked after eachawaitat which another turn can run. - Activation scheduling. Grain state is accessed only on the activation's scheduler: grain code awaits on the captured context (
ConfigureAwait(false)is flagged byORLEANS0014),Task.Runwork returns results without touching grain state, and external callbacks enter the activation throughRunRequestAsync. - Determinism. Time (
TimeProvider), randomness, and external I/O that tests must control are injected so executions reproduce. - Async and cancellation. Operations that accept a
CancellationTokenpass it to every cancellable callee; async code awaits instead of blocking (.Result,.Wait(),GetAwaiter().GetResult()). - Ownership and lifetime. Long-lived resources (timers, subscriptions, connections,
IDisposables) have one owner and are released at that owner's boundary: request, activation, component, provider, or silo. - Security. The trusted computing base stays small, components hold least privilege, and data is validated according to its trust level before it influences privileged or persistent state.
- Observability. Operationally significant failures are diagnosable from logs, metrics, or traces emitted at the owning boundary with stable context (grain ID, silo, operation); repeated product log messages use
[LoggerMessage].
Findings
Report the location, the violated or missing invariant, and a concrete fix. List invariant questions separately.
Trending
More talk lately.about the whole repository
Who's talking about dotnet/orleans
- Stack Overflow“Any good implementation of Actors for C#?”Stack Overflow · Jan 2, 2014 · 56 votes
- A Hacker News story“Orleans – Distributed Actor Model”Hacker News · Jan 26, 2015 · 36 points
- Stack Overflow“Any good implementation of Actors for C#?”Stack Overflow · Apr 11, 2014 · 25 votes
- Stack Overflow“Orleans slow with minimalistic use case”Stack Overflow · Nov 4, 2022 · 14 votes
- Stack Overflow“In Orleans when to use IGrainFactory vs IClusterClient”Stack Overflow · Feb 26, 2020 · 10 votes
The biggest 5 of 90 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 90
Talked about on GitHub, Stack Overflow, Hacker News and the web (90 times).
On GitHub · 50
- May 6, 2016Add public methods to supress visibility checks for compilation — dotnet/roslyn8 reactions · 15 comments
- Feb 13, 2024Orleans Broadcast Channels - Relationship between publisher and consumer is unclear — dotnet/docs7 reactions · 3 comments
- Oct 7, 2020Can more non-cryptographic hash algorithms be added into .NET BCL? — dotnet/runtime5 reactions · 21 comments
- May 19, 2019Microsoft.Azure.Storage.Common dependency — Azure/azure-cosmos-table-dotnet4 reactions · 6 comments
- Nov 29, 2024fix: target current LTS framework for `Microsoft.AspNetCore.Connections.Abstractions` — dotnet/aspnetcore3 reactions · 1 comment
45 more on GitHub
- Jul 3, 2024[Orleans] Update grain timer docs to account for new IGrainTimer APIs — dotnet/docs3 reactions · 2 comments
- Nov 7, 2022Perf-trap with `IBinaryInteger<T>.WriteLittleEndian` — dotnet/runtime3 reactions · 6 comments
- Nov 5, 2025Corrected Membership Session Handling — OrleansContrib/Orleans.Providers.MongoDB2 reactions · 2 comments
- May 23, 2025Proposal: Upstream MongoDB providers into dotnet/orleans — OrleansContrib/Orleans.Providers.MongoDB2 reactions · 8 comments
- Dec 19, 2023bugfix: using collection name as key for caching collections — OrleansContrib/Orleans.Providers.MongoDB2 reactions · 2 comments
- Jan 5, 2022.NET 7 Improvements — Dotnet-Boxed/Templates2 reactions
- Mar 8, 2020F# compiler warnings in .NET Core 3.1 — dotnet-websharper/core2 reactions · 5 comments
- Nov 7, 2019Clustering: support extended membership protocol — OrleansContrib/Orleans.Providers.MongoDB2 reactions · 4 comments
- Oct 29, 2026chore(deps): update orleans redis providers to 10.4.1 — thomhurst/Respire1 reaction · 3 comments
- Jul 8, 2026[API Proposal]: Amend `WritableMemoryStream` and `ReadOnlyMemoryStream` to derive from `Stream`, not `MemoryStream` — dotnet/runtime1 reaction · 6 comments
- Feb 9, 2026Bump Microsoft.Orleans.Persistence.AzureStorage from 10.0.0 to 10.0.1 — Gibbs-Morris/mississippi1 reaction · 1 comment
- Feb 9, 2026Bump Microsoft.Orleans.Clustering.AzureStorage from 10.0.0 to 10.0.1 — Gibbs-Morris/mississippi1 reaction · 1 comment
- Feb 9, 2026Bump Microsoft.Orleans.Client from 10.0.0 to 10.0.1 — Gibbs-Morris/mississippi1 reaction · 1 comment
- May 29, 2025[New article]: [Orleans] Add doc/details for Grain Migration — dotnet/docs1 reaction · 2 comments
- Jan 24, 2024Upgrade to Orleans 8 — VincentH-Net/Orleans.Multitenant1 reaction · 12 comments
- Aug 15, 2023Update the KubernetesClient NuGet package. — OrleansContrib/Orleans.Clustering.Kubernetes1 reaction
- Nov 30, 2022Fixed OrleansAdventure.sln broken link to github — dotnet/docs1 reaction
- Aug 17, 2022Fixed issue when EventFlowLogger throws on duplicate log message arguments — Azure/diagnostics-eventflow1 reaction
- Mar 28, 2017Evaluate sqlite as a replacement for BDB — zcash/zcash1 reaction · 7 comments
- Oct 15, 2026Bump Microsoft.Orleans.EventSourcing from 10.1.0 to 10.4.0 — devlooped/CloudActors0 reactions
- Oct 15, 2026Bump Microsoft.Orleans.CodeGenerator from 10.1.0 to 10.4.0 — devlooped/CloudActors0 reactions
- Oct 15, 2026Bump Microsoft.Orleans.Clustering.AzureStorage from 10.1.0 to 10.4.0 — devlooped/CloudActors0 reactions
- Oct 7, 2026Bump the dotnet group with 7 updates — IvanMarkitan/dotnet-docs0 reactions
- Sep 18, 2026Bump Microsoft.Orleans.Reminders and Microsoft.Orleans.Reminders.AzureStorage — en-gen/Wayfinder0 reactions · 1 comment
- Sep 18, 2026Bump Microsoft.Orleans.Reminders and Microsoft.Orleans.Sdk — en-gen/Wayfinder0 reactions
- Sep 16, 2026Bump the dotnet group with 6 updates — zbalkan/docs0 reactions
- Sep 16, 2026Bump the dotnet group with 5 updates — zbalkan/docs0 reactions
- Sep 16, 2026Bump the dotnet group with 7 updates — zbalkan/docs0 reactions
- Sep 16, 2026Bump the dotnet group with 7 updates — IvanMarkitan/dotnet-docs0 reactions
- Sep 16, 2026Bump the dotnet group with 6 updates — IvanMarkitan/dotnet-docs0 reactions
- Sep 16, 2026Bump the dotnet group with 4 updates — IvanMarkitan/dotnet-docs0 reactions
- Sep 9, 2026Bump the dotnet group with 10 updates — zbalkan/docs0 reactions
- Sep 9, 2026Bump the dotnet group with 7 updates — IvanMarkitan/dotnet-docs0 reactions
- Sep 9, 2026Bump Microsoft.Orleans.Sdk and Microsoft.Orleans.Server — IvanMarkitan/dotnet-docs0 reactions
- Jul 31, 2026Bump Microsoft.Orleans.Persistence.AzureStorage from 10.2.1 to 10.2.2 — en-gen/Wayfinder0 reactions
- Jul 31, 2026Bump Microsoft.Orleans.EventSourcing from 10.2.1 to 10.2.2 — en-gen/Wayfinder0 reactions
- Jul 31, 2026Bump Microsoft.Orleans.Clustering.AzureStorage from 10.2.1 to 10.2.2 — en-gen/Wayfinder0 reactions
- Jul 30, 2026Bump the orleans group with 4 updates — rick-dev-creator/Observa0 reactions
- Apr 29, 2026Bump Microsoft.Extensions.Hosting and 3 others — IEvangelist/docs0 reactions
- Apr 29, 2026Bump the dotnet group with 6 updates — IEvangelist/docs0 reactions
- Apr 22, 2026Bump Microsoft.Extensions.Hosting and 4 others — IEvangelist/docs0 reactions
- Apr 22, 2026Bump the dotnet group with 3 updates — IEvangelist/docs0 reactions
- Apr 22, 2026Bump Microsoft.Extensions.Hosting and 7 others — TimShererWithAquent/dotnet-docs0 reactions
- Apr 22, 2026Bump the dotnet group with 8 updates — TimShererWithAquent/dotnet-docs0 reactions
- Apr 20, 2026Bump Microsoft.Orleans.Core and Microsoft.Orleans.Core.Abstractions — mivertowski/Orleans.GpuBridge.Core0 reactions
On Stack Overflow · 30
- Jan 2, 2014Any good implementation of Actors for C#?56 votes
- Apr 11, 2014Any good implementation of Actors for C#?25 votes
- Nov 4, 2022Orleans slow with minimalistic use case14 votes
- Feb 26, 2020In Orleans when to use IGrainFactory vs IClusterClient10 votes
- Dec 12, 2015Orleans cluster communication7 votes
25 more on Stack Overflow
- Apr 6, 2016Using SQL Server as Orleans storage6 votes · 1 answer
- Jul 8, 2015MSR Orleans, How does PlacementStrategy work?5 votes
- Apr 6, 2016Using SQL Server as Orleans storage4 votes
- Jan 14, 2022How to configure TestClusterBuilder such that the test cluster has access to SMSProvider?3 votes
- Jul 22, 2021Is it possible to run Microsoft Orleans in classic ASP.NET MVC 43 votes
- May 20, 2019What is the Relaese date for Microsoft Orleans which can support service fabric?3 votes
- May 9, 2016How to make simple state presistance work in MS Orleans?3 votes
- Dec 16, 2015Getting exceptions when running basic orleans application3 votes
- May 22, 2017How can I start the server with the code configuration rather than the XML file configuration?2 votes
- Aug 8, 2021Orleans When Use RedisGrainStorage for "PubSubStore" throw GrainReferenceNotBoundException1 vote
- Mar 31, 2021Orleans Multi Region Deployments1 vote · 1 answer
- Dec 13, 2019How to properly inherit from tuples so that serializer generation from orleans is correct?1 vote
- Jan 19, 2019Asynchronous message passing in .NET1 vote
- Jan 11, 2019Understanding Elixir1 vote
- Jul 31, 2018microsoft orleans how to IServiceCollection replace to Castle Windsor1 vote
- Jun 2, 2016what could be reason for client silo not getting initialized in azure?1 vote
- Oct 5, 2015Saving state that resides in POCO/DTO using Actor Model1 vote
- Jul 26, 2024Orleans IPersistentState POCO Namespace Versioning problems0 votes
- Dec 22, 2019MSOrleans 2.0 Ado.net Persistent0 votes
- Mar 6, 2019Orleans - Custom TCP Socket Connection0 votes
- Nov 15, 2017Orleans - how to implement storage sharding by Tenant with AdoNetStorageProvider0 votes
- Oct 28, 2016"key was not present in the dictionary" when using generic orleans grains0 votes
- Jun 2, 2016Serializers for Orleans streams payload classes0 votes
- Mar 15, 2016Orleans Extension not installed0 votes
- Dec 12, 2015Orleans Error while Initializing Orleans Client0 votes
On Hacker News · 9
- Jan 26, 2015Orleans – Distributed Actor Model36 points · 19 comments
- Jun 23, 2016Orleans – Distributed Virtual Actor Model from Microsoft Research10 points · 1 comment
- Jan 23, 2015Microsoft Orleans – Distributed actor system open sourced – GitHub5 points
- Feb 22, 2017Orleans – Distributed Virtual Actor Model v1.44 points
- Jul 12, 2024Microsoft Orleans v8.2.02 points
4 more on Hacker News
- Nov 7, 2023Orleans v7.2.3 Released2 points
- Dec 5, 2019Orleans: Cross-platform framework for building distributed apps in .NET2 points · 1 comment
- Jul 7, 2017Microsoft Orleans v1.5.0 (Distributed Virtual Actor Framework for Dotnet)2 points
- Feb 18, 2015Microsoft Research New Orleans Framework2 points
On the web · 1
- Sep 17, 2018Distributed tracing and Orleans · Issue #4992 — google.com
In this repository10 other files it gives its agents.
- AGENTS.mdAGENTS.md
- docs/AGENTS.mdAGENTS.md
- samples/AGENTS.mdAGENTS.md
- test/AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- code-reviewSkill
- review-architectureSkill
- review-code-craftSkill
- review-performanceSkill
- review-testingSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

