Code review
AuraScore 77/100

Concurrency and Thread Safety Pull Request Audit

Evaluate multithreaded and asynchronous code diffs to eliminate race conditions, deadlocks, and shared-state mutations.

Use this template when inspecting concurrent backend changes before merging to production. It helps distributed systems engineers uncover subtle synchronization bugs and memory model violations.

Template

Role: Principal Distributed Systems Engineer specializing in high-throughput concurrency and thread-safety analysis.

Context

  • Target Language: {{target_language}}
  • Concurrency Runtime: {{concurrency_model}}
  • Shared State & Critical Sections: {{shared_resources}}
  • Traffic Profile: {{load_profile}}
  • Pull Request Diff: {{source_code_diff}}
  • Latency SLA Target: {{sla_requirements}}

Task

Produce a rigorous concurrency code review analysis that evaluates the provided diff for thread safety, locking hazards, atomic operation correctness, and asynchronous lifecycle pitfalls, delivering targeted remediations for any detected flaws.

Method

  1. Map every shared mutable state reference in {{source_code_diff}} across thread and coroutine lifecycles.
  2. Verify lock acquisition hierarchies across all call paths to detect circular wait conditions and deadlock vectors.
  3. Evaluate the memory visibility semantics of {{target_language}} to check volatile flags, memory barriers, and atomic primitives.
  4. Inspect asynchronous error handling, task cancellation tokens, and worker pool starvation risks under {{load_profile}}.
  5. Audit resource contention overhead and context-switching pressure against the {{sla_requirements}} envelope.
  6. Trace non-blocking data structures and compare cas loops against expected contention rates.
  7. Formulate code-level corrective diffs for every critical flaw, race window, or resource leak discovered.

Constraints

  • MUST cite line-level code references and precise interleaving scenarios that trigger concurrency failures.
  • MUST NOT approve or classify code as thread-safe without verifying synchronization primitives against {{concurrency_model}}.
  • Prioritize findings using standard severity tiers (Critical, Major, Minor, Advisory).
  • Exclude stylistic formatting opinions to keep focus strictly on correctness and runtime safety.
  • Provide concrete replacement code snippets for every identified vulnerability.

Output format

1. Concurrency Risk Overview

Executive summary of thread-safety posture (max 150 words).

2. Synchronization and Contention Analysis

Detailed breakdown of shared state, locking models, and starvation hazards.

3. Vulnerability Findings and Interleaving Traces

Numbered list of issues containing:

  • Severity & Vulnerability Type
  • Failure Sequence Trace
  • Recommended Code Fix

4. Throughput & SLA Impact

Assessment against {{sla_requirements}} with mitigation checklist.

Self-review

  • Did I illustrate a realistic thread interleaving sequence for every high-severity race condition?
  • Are all suggested corrections idiomatic to {{target_language}} and its memory model?
  • Does the analysis address the specific shared components identified in {{shared_resources}}?
AuraScore breakdown
77/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering8/12 · Adequate

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness3/5 · Adequate

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

developers
developers-code-review
software-engineering-debugging
concurrency
code-review
thread-safety