Audit Reentrancy
Testing & Qualityaudit-reentrancyAudit Reentrancy is an Agent Skill for testing & quality published in the ben-manes/caffeine repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Analyze user callbacks for re-entrancy defects (deadlock, corruption)
QUICK START
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/ben-manes/caffeine/blob/HEAD/.claude/skills/audit-reentrancy/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/audit-reentrancy, 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.
Analyze the cache for defects caused by user callbacks re-entering the cache.
User-provided callbacks:
- CacheLoader.load(key) / loadAll(keys)
- CacheLoader.reload(key, oldValue)
- Weigher.weigh(key, value)
- Expiry.expireAfterCreate / expireAfterUpdate / expireAfterRead
- RemovalListener.onRemoval(key, value, cause)
- EvictionListener (synchronous variant)
- Mapping functions passed to compute, computeIfAbsent, merge
- jcache: synchronous CacheEntryListener (historically caused double refresh), CacheWriter, EntryProcessor.process, ExpiryPolicy
For each callback:
- List every lock held at the point the callback is invoked. Include: evictionLock, CHM bin lock, synchronized(node), any other.
- Determine what happens if the callback calls EACH of these cache methods: get, put, remove, compute, computeIfAbsent, size, clear, cleanUp, asMap().entrySet().
- For each (callback, cache method) pair where locks are held:
- Can it deadlock? (Same lock re-acquired? Lock ordering violated?)
- Can it corrupt state? (Re-entering a method mid-mutation?)
- Can it observe partially-constructed state?
- If the cache defends against re-entrancy (e.g., by deferring work), explain the mechanism and verify it is complete.
For each defect: state the callback, re-entrant method, locks involved, call stack, and observable incorrect behavior.