Skip to content
ln-628-concurrency-auditor logo

Concurrency Auditor (L3 Worker)

ln-628-concurrency-auditor

Checks async races, thread safety, TOCTOU, deadlocks, blocking I/O, resource contention. Use when auditing concurrency safety.

SKILL.md

Full skill instructions

Paths: File paths (shared/, references/, ../​ln-*) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root. If shared/ is missing, fetch files via WebFetch from https://raw.githubusercontent.com/​levnikolaevich/​claude-code-skills/​master/​skills/​{path}.

Concurrency Auditor (L3 Worker)

Type: L3 Worker

Specialized worker auditing concurrency, async patterns, and cross-process resource access.

Purpose & Scope

  • Audit concurrency (Category 11: High Priority)
  • 7 checks: async races, thread safety, TOCTOU, deadlocks, blocking I/​O, resource contention, cross-process races
  • Two-layer detection: grep finds candidates, agent reasons about context
  • Calculate compliance score (X/​10)

Inputs

MANDATORY READ: Load shared/​references/​audit_worker_core_contract.md. MANDATORY READ: Load shared/​references/​mcp_tool_preferences.md and shared/​references/​mcp_integration_patterns.md

Receives contextStore with: tech_stack, best_practices, codebase_root, output_dir.

Use hex-graph first when dataflow or call-path analysis materially improves concurrency findings. Use hex-line first for local code reads when available. If MCP is unavailable, unsupported, or not indexed, continue with built-in Read/​Grep/​Glob/​Bash and state the fallback in the report.

Workflow

MANDATORY READ: Load shared/​references/​two_layer_detection.md for detection methodology.

  1. Parse context -- extract tech_stack, language, output_dir from contextStore
  2. Per check (1-7):
    • Layer 1: Grep/​Glob scan to find candidates
    • Layer 2: Read 20-50 lines around each candidate. Apply check-specific critical questions. Classify: confirmed / false positive / needs-context
  3. Collect confirmed findings with severity, location, effort, recommendation
  4. Calculate score per shared/​references/​audit_scoring.md
  5. Write Report -- build in memory, write to {output_dir}/​ln-628--global.md (atomic single Write)
  6. Return Summary to coordinator

Audit Rules

Unified severity escalation: For ALL checks -- if finding affects payment/​auth/​financial code -> escalate to CRITICAL regardless of other factors.

1. Async/​Event-Loop Races (CWE-362)

What: Shared state corrupted across await/​yield boundaries in single-threaded async code.

Layer 1 -- Grep patterns:

LanguagePatternGrep
JS/​TSRead-modify-write across await\w+\s*[+\-*/]?=\s*.*await (e.g., result += await something)
JS/​TSCheck-then-initialize raceif\s*\(!?\w+\) followed by \w+\s*=\s*await in same block
PythonRead-modify-write across await\w+\s*[+\-*/]?=\s*await inside async def
PythonShared module-level state in asyncModule-level \w+\s*= + modified inside async def
AllShared cache without lock`.set(

Layer 2 -- Critical questions:

  • Is the variable shared (module/​global scope) or local?
  • Can two async tasks interleave at this await point?
  • Is there a lock/​mutex/​semaphore guarding the access?

Severity: CRITICAL (payment/​auth) | HIGH (user-facing) | MEDIUM (background)

Safe pattern exclusions: Local variables, const declarations, single-use await (no interleaving possible).

Effort: M

2. Thread/​Goroutine Safety (CWE-366)

What: Shared mutable state accessed from multiple threads/​goroutines without synchronization.

Layer 1 -- Grep patterns:

LanguagePatternGrep
GoMap access without mutexmap\[.*\].*= in struct without sync.Mutex or sync.RWMutex
GoVariable captured by goroutinego func + variable from outer scope modified
PythonGlobal modified in threadsglobal\s+\w+ in function + threading.Thread in same file
JavaHashMap shared between threadsHashMap + Thread|Executor|Runnable in same class without synchronized|ConcurrentHashMap
RustRc in multi-thread contextRc<RefCell + thread::spawn|tokio::spawn in same file
Node.jsWorker Threads shared stateworkerData|SharedArrayBuffer|parentPort + mutable access without Atomics

Layer 2 -- Critical questions:

  • Is this struct/​object actually shared between threads? (single-threaded code -> FP)
  • Is mutex/​lock in embedded struct or imported module? (grep may miss it)
  • Is go func capturing by value (safe) or by reference (unsafe)?

Severity: CRITICAL (payment/​auth) | HIGH (data corruption possible) | MEDIUM (internal)

Safe pattern exclusions: Go map in init() or main() before goroutines start. Rust Arc<Mutex<T>> (already safe). Java Collections.synchronizedMap().

Effort: M

3. TOCTOU -- Time-of-Check Time-of-Use (CWE-367)

What: Resource state checked, then used, but state can change between check and use.

Layer 1 -- Grep patterns:

LanguageCheckUseGrep
Pythonos.path.exists()open()os\.path\.exists\( near open\( on same variable
Pythonos.access()os.open()os\.access\( near os\.open\(|open\(
Node.jsfs.existsSync()fs.readFileSync()existsSync\( near readFileSync\(|readFile\(
Node.jsfs.accessSync()fs.openSync()accessSync\( near openSync\(
Goos.Stat()os.Open()os\.Stat\( near os\.Open\(|os\.Create\(
Java.exists()new FileInputStream\.exists\(\) near new File|FileInputStream|FileOutputStream

Layer 2 -- Critical questions:

  • Is the check used for control flow (vulnerable) or just logging (safe)?
  • Is there a lock/​retry around the check-then-use sequence?
  • Is the file in a temp directory controlled by the application (lower risk)?
  • Could an attacker substitute the file (symlink attack)?

Severity: CRITICAL (security-sensitive: permissions, auth tokens, configs) | HIGH (user-facing file ops) | MEDIUM (internal/​background)

Safe pattern exclusions: Check inside try/​catch with retry. Check for logging/​metrics only. Check + use wrapped in file lock.

Effort: S-M (replace check-then-use with direct use + error handling)

4. Deadlock Potential (CWE-833)

What: Lock acquisition in inconsistent order, or lock held during blocking operation.

Layer 1 -- Grep patterns:

LanguagePatternGrep
PythonNested lockswith\s+\w+_lock: (multiline: two different locks nested)
PythonLock in loopfor.*: with \.acquire\(\) inside loop body
PythonLock + external call\.acquire\(\) followed by await|requests\.|urllib before release
GoMissing defer unlock\.Lock\(\) without defer.*\.Unlock\(\) on next line
GoNested locksTwo \.Lock\(\) calls in same function without intervening \.Unlock\(\)
JavaNested synchronizedsynchronized\s*\( (multiline: nested blocks with different monitors)
JSAsync mutex nestingawait\s+\w+\.acquire\(\) (two different mutexes in same function)

Layer 2 -- Critical questions:

  • Are these the same lock (reentrant = OK) or different locks (deadlock risk)?
  • Is the lock ordering consistent across all call sites?
  • Does the external call inside lock have a timeout?

Severity: CRITICAL (payment/​auth) | HIGH (app freeze risk)

Safe pattern exclusions: Reentrant locks (same lock acquired twice). Locks with explicit timeout (asyncio.wait_for, tryLock).

Effort: L (lock ordering redesign)

5. Blocking I/​O in Async Context (CWE-400)

What: Synchronous blocking calls inside async functions or event loop handlers.

Layer 1 -- Grep patterns:

LanguageBlocking CallGrepReplacement
Pythontime.sleep in async deftime\.sleep inside async defawait asyncio.sleep
Pythonrequests.* in async defrequests\.(get|post|put|delete) inside async defhttpx or aiohttp
Pythonopen() in async defopen\( inside async defaiofiles.open
Node.jsfs.readFileSync in asyncfs\.readFileSync|fs\.writeFileSync|fs\.mkdirSyncfs.promises.*
Node.jsexecSync in asyncexecSync|spawnSync in async handlerexec with promises
Node.jsSync crypto in asynccrypto\.pbkdf2Sync|crypto\.scryptSynccrypto.pbkdf2 (callback)

Layer 2 -- Critical questions:

  • Is this in a hot path (API handler) or cold path (startup script)?
  • Is the blocking duration significant (>100ms)?
  • Is there a legitimate reason (e.g., sync read of small config at startup)?

Severity: HIGH (blocks event loop/​async context) | MEDIUM (minor blocking <100ms)

Safe pattern exclusions: Blocking call in if __name__ == "__main__" (startup). readFileSync in config loading at init time. Sync crypto for small inputs.

Effort: S-M (replace with async alternative)

6. Resource Contention (CWE-362)

What: Multiple concurrent accessors compete for same resource without coordination.

Layer 1 -- Grep patterns:

PatternRiskGrep
Shared memory without syncData corruptionSharedArrayBuffer|SharedMemory|shm_open|mmap without Atomics|Mutex|Lock nearby
IPC without coordinationMessage orderingprocess\.send|parentPort\.postMessage in concurrent loops
Concurrent file appendInterleaved writesMultiple appendFile|fs\.write to same path from parallel tasks

Layer 2 -- Critical questions:

  • Are multiple writers actually concurrent? (Sequential = safe)
  • Is there OS-level atomicity guarantee? (e.g., O_APPEND for small writes)
  • Is ordering important for correctness?

Severity: HIGH (data corruption) | MEDIUM (ordering issues)

Safe pattern exclusions: Single writer pattern. OS-guaranteed atomic operations (small pipe writes, O_APPEND). Message queues with ordering guarantees.

Effort: M

7. Cross-Process & Invisible Side Effects (CWE-362, CWE-421)

What: Multiple processes or process+OS accessing same exclusive resource, including operations with non-obvious side effects on shared OS resources.

Layer 1 -- Grep entry points:

PatternRiskGrep
Clipboard dual accessOSC 52 + native clipboard in same flowosc52|\\x1b\\]52 AND clipboard|SetClipboardData|pbcopy|xclip in same file
Subprocess + shared fileParent and child write same filespawn|exec|Popen + writeFile|open.*"w" on same path
OS exclusive resourceWin32 clipboard, serial port, named pipeOpenClipboard|serial\.Serial|CreateNamedPipe|mkfifo
Terminal escape sequencesstdout triggers terminal OS access\\x1b\\]|\\033\\]|writeOsc|xterm
External clipboard toolsClipboard via spawned processpbcopy|xclip|xsel|clip\.exe

Layer 2 -- This check relies on reasoning more than any other:

  1. Build Resource Inventory:

    ResourceExclusive?Accessor 1Accessor 2Sync present?
  2. Trace Timeline:

    t=0ms  operation_A() -> resource_X accessed
    t=?ms  side_effect   -> resource_X accessed by external process
    t=?ms  operation_B() -> resource_X accessed again -> CONFLICT?
    
  3. Critical Questions:

    • Can another process (terminal, OS, child) access this resource simultaneously?
    • Does this operation have invisible side effects on shared OS resources?
    • What happens if the external process is slower/​faster than expected?
    • What happens if user triggers this action twice rapidly?

Severity: CRITICAL (two accessors to exclusive OS resource without sync) | HIGH (subprocess + shared file without lock) | HIGH (invisible side effect detected via reasoning)

Safe pattern exclusions: Single accessor. Retry/​backoff pattern present. Operations sequenced with explicit delay/​await.

Effort: M-L (may require removing redundant access path)

Scoring Algorithm

MANDATORY READ: Load shared/​references/​audit_worker_core_contract.md and shared/​references/​audit_scoring.md.

Output Format

MANDATORY READ: Load shared/​references/​audit_worker_core_contract.md and shared/​templates/​audit_worker_report_template.md.

Write JSON summary per shared/​references/​audit_summary_contract.md. In managed mode the caller passes both runId and summaryArtifactPath; in standalone mode the worker generates its own run-scoped artifact path per shared contract.

Write report to {output_dir}/​ln-628--global.md with category: "Concurrency" and checks: async_races, thread_safety, toctou, deadlock_potential, blocking_io, resource_contention, cross_process_races.

Return summary per shared/​references/​audit_summary_contract.md.

When summaryArtifactPath is absent, write the standalone runtime summary under .hex-skills/​runtime-artifacts/​runs/​{run_id}/​evaluation-worker/​{worker}--{identifier}.json and optionally echo the same summary in structured output.

Report written: .hex-skills/​runtime-artifacts/​runs/​{run_id}/​audit-report/​ln-628--global.md
Score: X.X/​10 | Issues: N (C:N H:N M:N L:N)

Critical Rules

MANDATORY READ: Load shared/​references/​audit_worker_core_contract.md.

  • Do not auto-fix: Report only -- concurrency fixes require careful human review
  • Two-layer detection: Always apply Layer 2 reasoning after Layer 1 grep. Never report raw grep matches without context analysis
  • Language-aware detection: Use language-specific patterns per check
  • Unified CRITICAL escalation: Any finding in payment/​auth/​financial code = CRITICAL
  • Effort realism: S = <1h, M = 1-4h, L = >4h
  • Exclusions: Skip test files, skip single-threaded CLI tools, skip generated code

Definition of Done

MANDATORY READ: Load shared/​references/​audit_worker_core_contract.md.

  • contextStore parsed (language, concurrency model, output_dir)
  • All 7 checks completed with two-layer detection:
    • async races, thread safety, TOCTOU, deadlock potential, blocking I/​O, resource contention, cross-process races
  • Layer 2 reasoning applied to each candidate (confirmed / FP / needs-context)
  • Findings collected with severity, location, effort, recommendation
  • Score calculated per shared/​references/​audit_scoring.md
  • Report written to {output_dir}/​ln-628--global.md (atomic single Write call)
  • Summary written per contract

Reference Files

  • Two-layer detection methodology: shared/​references/​two_layer_detection.md
  • Audit output schema: shared/​references/​audit_output_schema.md

Version: 4.0.0 Last Updated: 2026-03-04

More skills from boisenoise

database-cloud-optimization-cost-optimize logo
boisenoise/skills-collections

database-cloud-optimization-cost-optimize

You are a cloud cost optimization expert specializing in reducing infrastructure expenses while maintaining performance and reliability. Analyze cloud spending, identify savings opportunities, and implement cost-effective architectures across AWS, Azure, and GCP.

10 0
View
postmark-automation logo
boisenoise/skills-collections

postmark-automation

Automate Postmark email delivery tasks via Rube MCP (Composio): send templated emails, manage templates, monitor delivery stats and bounces. Always search tools first for current schemas.

10 0
View
game-development logo
boisenoise/skills-collections

game-development

Game development orchestrator. Routes to platform-specific skills based on project needs.

10 0
View
test-fixing logo
boisenoise/skills-collections

test-fixing

Systematically identify and fix all failing tests using smart grouping strategies. Use when explicitly asks to fix tests (\"fix these tests\", \"make tests pass\"), reports test failures (\"tests are failing\", \"test suite is broken\"), or completes implementation and wants tests passing.

10 0
View
notebooklm logo
boisenoise/skills-collections

notebooklm

Interact with Google NotebookLM to query documentation with Gemini's source-grounded answers. Each question opens a fresh browser session, retrieves the answer exclusively from your uploaded documents, and closes.

10 0
View
agent-evaluation logo
boisenoise/skills-collections

agent-evaluation

Testing and benchmarking LLM agents including behavioral testing,

10 0
View
clickup-automation logo
boisenoise/skills-collections

clickup-automation

Automate ClickUp project management including tasks, spaces, folders, lists, comments, and team operations via Rube MCP (Composio). Always search tools first for current schemas.

10 0
View
wordpress-penetration-testing logo
boisenoise/skills-collections

wordpress-penetration-testing

Assess WordPress installations for common vulnerabilities and WordPress 7.0 attack surfaces.

10 0
View
ln-761-secret-scanner logo
boisenoise/skills-collections

ln-761-secret-scanner

Scans codebase for hardcoded secrets with severity classification and remediation guidance. Use when auditing a project for leaked credentials.

10 0
View
azure-monitor-ingestion-java logo
boisenoise/skills-collections

azure-monitor-ingestion-java

Azure Monitor Ingestion SDK for Java. Send custom logs to Azure Monitor via Data Collection Rules (DCR) and Data Collection Endpoints (DCE).

10 0
View
ln-513-agent-reviewer logo
boisenoise/skills-collections

ln-513-agent-reviewer

Runs parallel external agent reviews (Codex + Gemini) on code changes. Process-as-arrive, critical verification with debate. Returns filtered suggestions.

10 0
View
drip-jobs-automation logo
boisenoise/skills-collections

drip-jobs-automation

Automate Drip Jobs tasks via Rube MCP (Composio). Always search tools first for current schemas.

10 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View