OpenParable
Skip to content
← Back to skills

Race Conditions

Testing & Quality
race-conditions

Race Conditions is an Agent Skill for testing & quality published in the kubernetes-sigs/kueue repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Review concurrent Go code for races, preferring fixes at the mutation site over adding snapshot fields.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/kubernetes-sigs/kueue/blob/HEAD/cmd/experimental/skills/reviewer/race-conditions/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/race-conditions, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Skill: Race Condition Review — Fix the Mutation Site, Not the Read Site

Use this when reviewing concurrent Go code that adds a snapshot or mirror field to protect a reader from a concurrent writer.

Pattern to recognize

A secondary field is added so readers get a safe copy of data that a writer might mutate:

type inflightWorkload struct {
    info      *workload.Info
    resources map[corev1.ResourceName]int64  // snapshot of info.TotalRequests
}

Why to push back

It puts complexity at the read site and creates a new invariant: both fields must be set and cleared in sync. Ask first: can we just stop the mutation from happening?

If the writer was mutating shared data through an alias, cloning at the mutation site is usually simpler and leaves no invariant to maintain:

// Before: alias → race
requests = a.wl.TotalRequests

// After: clone → no race, no snapshot field needed
for i, ps := range a.wl.TotalRequests {
    requests[i] = ps
    requests[i].Requests = maps.Clone(ps.Requests)
}

When the snapshot IS correct

  • The clone would be expensive and the read path is hot.
  • The writer must mutate the original by contract.
  • Multiple callers can mutate the data concurrently.

In those cases, wrap the paired fields in a named struct so the invariant is enforced by the type system, not convention.