- Home
- Skills
- Agents & Orchestration
- Repair Resource Lifecycle Race Bugs
More screenshots
Works with the AI Agents you already use
Repair Resource Lifecycle Race Bugs
Diagnose and repair asynchronous resource create/update/delete races, tombstones, late callbacks, retries, and reconciliation.
$1
Repair Resource Lifecycle Race Bugs
Example session with this skill installed
A delete event for 'user-123' arrived at 10:00:01, but the late 'create' callback finished at 10:00:05, resurrecting the resource. Help me fix this lifecycle race.
- Read your context and instructions
- Compiled the repair resource lifecycle
The issue is a classic resurrection race where the system lacks a terminal state (tombstone) to prevent late-arriving create confirmations from overwriting a completed deletion.
Diagnosis
- Identity:
user-123 - Conflict: The
deleteoperation finished locally, but the provider'screatecallback was still in flight.
Root Cause: The system treats the absence of a record as "not yet created" rather than "already deleted," allowing the late callback to insert a stale record.
Implementation: Tombstone Pattern
Replace the hard delete with a soft-delete tombstone that includes a deleted_at timestamp or a monotonically increasing version ID to discard late-arriving operations.
interface ResourceState {
id: string;
status: 'active' | 'deleted';
version: number;
deletedAt?: Date;
}
async function handleCreateCallback(providerResult: any) {
const { id, version } = providerResult;
// Atomic check-and-set or transaction
const existing = await db.resources.find(id);
if (existing && (existing.status === 'deleted' || existing.version >= version)) {
console.log(`[Lifecycle] Ignoring late callback for ${id}. Resource already terminal.`);
// Cleanup provider resource if necessary
await provider.cleanup(id);
return;
}
await db.resources.upsert({
id,
status: 'active',
version,
updatedAt: new Date()
});
}
Deterministic Test Plan
it('should discard create callback if delete occurred during flight', async () => {
const store = new MockStore();
const lifecycle = new LifecycleManager(store);
// 1. Start creation
const createPromise = lifecycle.create('res-1');
// 2. Immediate delete before callback returns
await lifecycle.delete('res-1');
// 3. Resolve late create callback
await mockProvider.resolveCreate('res-1');
// 4. Invariant: Store must still reflect 'deleted' state
const finalState = await store.get('res-1');
expect(finalState.status).toBe('deleted');
});
Next steps
- Update your database schema to include a
versionordeleted_atcolumn. - Modify the
deletehandler to write the tombstone instead of purging the row. - Add a background TTL task to purge expired tombstones after your max-retry window.
Connects securely to your tools. The creator never sees your data.
About this skill
Repair Resource Lifecycle Race Bugs targets production and repository defects around diagnose and repair asynchronous resource create/update/delete races, tombstones, late callbacks, retries, and reconciliation.. It examines resource generation/operation identity, create versus delete ordering, late provider callbacks, tombstone and terminal-state semantics, retry/idempotency behavior, cleanup ownership, reconciler authority, mixed-version rollout and observability, then establishes one explicit repair contract and focused deterministic validation.
The skill works from repository access or partial evidence such as snippets, logs, configuration, traces, and architecture notes. It preserves existing product/security policy, avoids invented execution claims, and keeps production systems, real credentials, and deployment outside the validation path.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Agents & Orchestration.
Requires clear evidence of the state machine or lifecycle events. Cannot fix underlying hardware-level clock skew issues.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 2 months ago