check-cascading-failures
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "check-cascading-failures" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-aacc887080fb1a6c14bf219d7c052f913e976fffe5cd18cbe082360a4108d8d1. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Detect cascading failure risks in PHP systems. Identifies and reports shared resources, unbounded queues, missing backpressure, thread pool exhaustion, and potential fault propagation paths.
Introduction source: third_party · dykyi-roman · 0.0.1 Reference
SkillPi interpretation
- Tasks
- Detects cascading failure risks in PHP systems. Identifies shared resources, unbounded queues, missing backpressure, thread pool exhaustion, and failure propagation paths.
- Inputs and outputs
- ```markdown
- Testing
- Not tested
Browse files
Frontmatter
name: check-cascading-failures
description: Detects cascading failure risks in PHP systems. Identifies shared resources, unbounded queues, missing backpressure, thread pool exhaustion, and failure propagation paths.Cascading Failure Detection
Analyze PHP code for patterns that can cause cascading failures across services and components.
Detection Patterns
1. Shared Resource Without Isolation
// CRITICAL: Single connection pool shared by all services
final class DatabasePool
{
private static array $connections = [];
public static function getConnection(): PDO
{
// All services compete for same pool
// If one service hogs connections, all others starve
return self::$connections[array_rand(self::$connections)];
}
}
// CORRECT: Isolated pools per service (Bulkhead pattern)
final readonly class IsolatedDatabasePool
{
public function __construct(
private string $serviceName,
private int $maxConnections,
) {}
}
2. Unbounded Queue Growth
// CRITICAL: No size limit on in-memory queue
class EventQueue
{
private array $events = []; // Grows without bound
public function push(Event $event): void
{
$this->events[] = $event; // Memory exhaustion risk
}
}
// CRITICAL: No consumer backpressure
while (true) {
$message = $producer->produce($data);
// No check if consumer is keeping up
// Queue grows → memory fills → OOM → crash
}
// CORRECT: Bounded queue with backpressure
final class BoundedEventQueue
{
private SplQueue $events;
public function __construct(
private readonly int $maxSize = 10000,
) {
$this->events = new SplQueue();
}
public function push(Event $event): void
{
if ($this->events->count() >= $this->maxSize) {
throw new QueueFullException('Backpressure: queue at capacity');
}
$this->events->enqueue($event);
}
}
3. Synchronous Chain Without Circuit Breaker
// CRITICAL: Cascading synchronous calls
class OrderService
{
public function createOrder(OrderData $data): Order
{
$inventory = $this->inventoryService->reserve($data->items()); // If this hangs...
$payment = $this->paymentService->charge($data->total()); // ...this waits...
$shipping = $this->shippingService->schedule($data->address()); // ...everything stops
$notification = $this->notificationService->send($data->email()); // ...cascade!
}
}
// CORRECT: Each call protected with circuit breaker + timeout
class OrderService
{
public function createOrder(OrderData $data): Order
{
$inventory = $this->circuitBreaker->call(
fn () => $this->inventoryService->reserve($data->items()),
fallback: fn () => $this->reserveLater($data->items()),
);
}
}
4. Retry Storm (Thundering Herd)
// CRITICAL: All instances retry at same time
class ApiClient
{
public function call(string $endpoint): Response
{
for ($i = 0; $i < 3; $i++) {
try {
return $this->http->get($endpoint);
} catch (Exception $e) {
sleep(1); // Fixed delay — all instances retry simultaneously!
}
}
throw new ApiException('Failed after 3 retries');
}
}
// CORRECT: Exponential backoff with jitter
$delay = min($baseDelay * (2 ** $attempt) + random_int(0, 1000), $maxDelay);
5. Missing Health Checks
// CRITICAL: Serving traffic while dependencies are down
class ApiController
{
public function handle(Request $request): Response
{
// No check if database/cache/external services are available
// Returns 500 errors, load balancer keeps sending traffic
return $this->service->process($request);
}
}
// CORRECT: Health check endpoint
class HealthController
{
public function check(): Response
{
$checks = [
'database' => $this->checkDatabase(),
'redis' => $this->checkRedis(),
'queue' => $this->checkQueue(),
];
$healthy = !in_array(false, $checks, true);
return new Response(
json_encode($checks),
$healthy ? 200 : 503,
);
}
}
6. Resource Leak Under Failure
// CRITICAL: Connection not released on exception
class MessageProcessor
{
public function process(): void
{
$connection = $this->pool->acquire();
$this->doWork($connection); // If this throws...
$this->pool->release($connection); // ...connection is leaked!
}
}
// CORRECT: Always release in finally
class MessageProcessor
{
public function process(): void
{
$connection = $this->pool->acquire();
try {
$this->doWork($connection);
} finally {
$this->pool->release($connection);
}
}
}
Grep Patterns
# Shared static resources
Grep: "private static.*\$.*=.*\[\]|protected static.*pool|static.*\$connections" --glob "**/*.php"
# Unbounded collections
Grep: "\$this->.*\[\].*=|\[\].*events|array_push" --glob "**/Infrastructure/**/*.php"
# Synchronous chains (multiple service calls in one method)
Grep: "\$this->.*Service->.*\n.*\$this->.*Service->" --glob "**/Application/**/*.php"
# Fixed retry delays (no jitter)
Grep: "sleep\([0-9]+\)|usleep\([0-9]+\)" --glob "**/*.php"
# Missing finally blocks
Grep: "->acquire\(\)|->lock\(" --glob "**/*.php"
Grep: "finally" --glob "**/*.php"
# Missing health checks
Grep: "class.*HealthCheck|function.*health|/health" --glob "**/*.php"
Severity Classification
| Pattern | Severity |
|---|---|
| Shared pool without isolation | 🔴 Critical |
| Unbounded queue in memory | 🔴 Critical |
| Synchronous chain without breaker | 🔴 Critical |
| Retry storm (no jitter) | 🟠 Major |
| Missing health checks | 🟠 Major |
| Resource leak on failure | 🟠 Major |
| No backpressure mechanism | 🟡 Minor |
Output Format
### Cascading Failure Risk: [Description]
**Severity:** 🔴/🟠/🟡
**Location:** `file.php:line`
**Failure Path:** ServiceA → ServiceB → ServiceC
**Issue:**
[Description of the cascading failure risk]
**Blast Radius:**
- Direct: [immediately affected components]
- Indirect: [downstream components that will fail]
**Code:**
```php
// Vulnerable pattern
Fix:
// With isolation/circuit breaker/backpressure
Current listing version
0.0.1
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- PHP系统级联故障检测是生产环境稳定性保障的核心需求
- 直接解决分布式系统架构中的关键痛点
- 具有广泛实用价值
Highlights
- 触发词精准完整,覆盖多种变体
- 边界清晰
- 明确描述了检测PHP系统中的级联故障风险
Highlights
- Phase/步骤清晰,有出口条件
- 含端到端示例
- frontmatter完整
Highlights
- 工具来源明确,参数正确
- 覆盖主要异常
- 提供了具体的grep命令和代码模式
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.