agentleFS
gurinderugurinderu/craft/skills/distributed-races/SKILL.md

distributed-races

Skill1 starsChanged 41 days agoMITView on GitHub

Correctness of controllers, reconcile and retry loops in any language — questions about state other actors read and write concurrently: self-triggering status writes, what wakes the loop by its promised deadline, another controller acting on a stale cache, permissions for new API verbs, protection released on spec change, not end of use, objects created before the change, idempotent create/patch, cleanup on delete, error-path retry bounds, holds no watch clears, writes without a resourceVersion or UID fence, unchecked external claims. Use when reviewing or writing a Kubernetes operator/controller, reconcile or requeue path, finalizer, watch, admission webhook, or any converge-to-desired-state loop. Triggers: reconcile, controller, operator, requeue, finalizer, watch, informer, resourceVersion, observedGeneration, eventual consistency, race between controllers. Not for in-process races, locks or async (rust-concurrency), file watchers or MVC controllers.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    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
  1. Distinctive:

    Read that source; the diff alone cannot answer them.

    line 58

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Distributed races — controller and reconcile-loop correctness

A reconcile loop is correct only if it converges from every state another actor can leave behind: a crashed earlier pass, a second controller with an older view, a watch that never fires, an object written by last month's version of the code. The bug is almost never on the changed line; it is in an interleaving the author did not play out. This skill is a list of questions, each with the answer a reviewer must produce and where that answer lives. A question you cannot answer from evidence is a finding to raise as open, not a pass.

How to work it

1. MAP     — name the primary object, every secondary/child it writes, every object it READS that
             another controller owns, and the requeue/error outcomes the pass can return.
2. ASK     — run each class below against that map. Skip a class only by saying why it cannot apply.
             Apply each class to EVERY instance in the diff, not to the first convenient one.
3. SOURCE  — answer from the carrier named in "where", not from comments or the PR text.
4. REPORT  — a finding names the interleaving or the request order that produces the bad state,
             and says what it does NOT establish (live behaviour, actual data loss).

The classes

Each class: question → the answer needed → where to get it. Full wording, examples and the fix shape for every class are in catalogue.md.

#ClassThe question
R1Self-triggering writeFor EVERY write to the primary in a pass (the driver/error path's status/conditions on holds and errors included): does it change a field every pass (lastTransitionTime), and does the primary's own watch (no predicate/generation filter) re-enqueue it sooner than the requeue the code relies on? Is it skipped when nothing changed?
R2Wake sourceFor every outcome the requeue/error policy can return (await-change included), what event or timer guarantees a pass by the deadline the code promises?
R3Foreign stale cacheNot our own stale read (R12). For EACH object another controller owns that a release/delete/label removal depends on: name that controller and its observed-generation gate (status.observedGeneration, an applied/desired generation pair, e.g. status.observedGeneration vs metadata.generation). Can it still act (recreate a child from the OLD template) after we decided from its "absent/finished" state? Wait until it catches up.
R4PermissionsIs every API verb and resource the diff newly calls granted in the shipped Role/ClusterRole/chart/IAM policy?
R5Protection lifetimeIs a finalizer/label/lock/hold released on a change of intent (spec) when the consumer outlives the spec and the release must wait for end of use?
R6Migration windowObjects created before this change lack a field/label/status the new logic relies on — what does the new code do with them?
R7Divergent desired stateDo the create path and the update/patch path express the same desired object?
R8Partial-failure strandIs progress (observedGeneration/Ready/status) recorded around a step that can fail so a transient error strands state or re-mutates the primary every pass?
R9CleanupDoes every resource created during reconcile have a delete path (owner reference that works across the scope boundary, finalizer, or explicit delete)?
R10Stale or churning statusIs a status/condition cleared when its subject disappears, and written only when desired != current?
R11Feature gateDoes a disabled path still call the API, or can its error abort the unrelated primary reconcile?
R12Read-then-write raceIs create/patch chosen off a stale read with no tolerance for 409/AlreadyExists or 404?
R13Swallowed error, no timerIs a secondary error swallowed and the pass returns await-change while no watch event will fire in that failure mode?
R14Strict decode on a shared streamCan one undecodable object on a shared/cluster-wide watch stall the stream for every object?
R15Webhook failure policyDoes the admission handler's error→decision mapping match the shipped failurePolicy?
R16Retry bound lost on an error pathDoes every error arm (a failed status write, a Context error) end in a bounded timed retry, or does it return await-change and wait for a change only another actor can make?
R17Hold only an unwatched object clearsIs every hold or wait released by a change on an object this controller watches (with a mapper back to the primary), or by a timer?
R18Cached write, no version fenceIs a status write built from a reflector/informer snapshot sent without a resourceVersion precondition, overwriting a concurrent writer?
R19No identity fenceBetween selecting an object by name and mutating or deleting it, is the write fenced on its uid, so a recreated object with the same name is not hit?
R20Unverified external claimIs every claim about an external system (API server, KubeVirt, kube-ovn, a cloud API) checked against that system's pinned source or versioned docs?

R1–R6 are the classes reviews miss most: they need a source outside the diff (the watch setup, the requeue table, the other controller's code, the RBAC manifest, data already in the cluster). Read that source; the diff alone cannot answer them. R16-R20 were found missing by an external reviewer on Kubernetes controllers: they too need a source outside the diff (the watch mapper, the patch parameters, the external system's pinned source).

A finding on a deletion or recovery path (finalizer removal, teardown, a delete handler, crash or partial-failure recovery) is at least Medium (catalogue, "Severity floor").

Where answers live

AnswerCarrier
What triggers a passthe controller's watch/owns/predicate setup, generation-change filters
What a pass may returnthe error → requeue policy table, every early return
What another controller doesthat controller's source (same repo or vendored), its status fields
What the controller may callRole/ClusterRole templates in the chart, operator bundle, IAM policy
What exists alreadyCRD schema history, the migration/backfill code, a release note
How an external system behavesits source or versioned docs at the version the lockfile, chart or image pins
What happened on a real clusteran integration/e2e trace, controller logs — the only carrier for "it works"

Relation to other skills

R7–R12 are also catalogued for Rust diffs as REC-001…REC-006 in rust-review's rules.md (the rule IDs a Rust review files findings under). Durability windows between two writes of one pass are the failure-windows lens of the review workflow.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.