tribunal-kit 4.0.1 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/GEMINI.md +4 -2
- package/.agent/agents/api-architect.md +66 -0
- package/.agent/agents/db-latency-auditor.md +216 -0
- package/.agent/agents/precedence-reviewer.md +41 -4
- package/.agent/agents/resilience-reviewer.md +88 -0
- package/.agent/agents/schema-reviewer.md +67 -0
- package/.agent/agents/throughput-optimizer.md +299 -0
- package/.agent/agents/vitals-reviewer.md +223 -0
- package/.agent/history/case-law/cases/case-0001.json +33 -0
- package/.agent/history/case-law/index.json +35 -0
- package/.agent/rules/GEMINI.md +20 -3
- package/.agent/scripts/case_law_manager.py +237 -7
- package/.agent/skills/agent-organizer/SKILL.md +42 -0
- package/.agent/skills/agentic-patterns/SKILL.md +42 -0
- package/.agent/skills/ai-prompt-injection-defense/SKILL.md +42 -0
- package/.agent/skills/api-patterns/SKILL.md +42 -0
- package/.agent/skills/api-security-auditor/SKILL.md +42 -0
- package/.agent/skills/app-builder/SKILL.md +42 -0
- package/.agent/skills/app-builder/templates/SKILL.md +70 -0
- package/.agent/skills/appflow-wireframe/SKILL.md +42 -0
- package/.agent/skills/architecture/SKILL.md +42 -0
- package/.agent/skills/authentication-best-practices/SKILL.md +42 -0
- package/.agent/skills/bash-linux/SKILL.md +42 -0
- package/.agent/skills/behavioral-modes/SKILL.md +42 -0
- package/.agent/skills/brainstorming/SKILL.md +42 -0
- package/.agent/skills/building-native-ui/SKILL.md +42 -0
- package/.agent/skills/clean-code/SKILL.md +42 -0
- package/.agent/skills/code-review-checklist/SKILL.md +42 -0
- package/.agent/skills/config-validator/SKILL.md +42 -0
- package/.agent/skills/csharp-developer/SKILL.md +42 -0
- package/.agent/skills/data-validation-schemas/SKILL.md +320 -0
- package/.agent/skills/database-design/SKILL.md +42 -0
- package/.agent/skills/deployment-procedures/SKILL.md +42 -0
- package/.agent/skills/devops-engineer/SKILL.md +42 -0
- package/.agent/skills/devops-incident-responder/SKILL.md +42 -0
- package/.agent/skills/documentation-templates/SKILL.md +42 -0
- package/.agent/skills/edge-computing/SKILL.md +42 -0
- package/.agent/skills/error-resilience/SKILL.md +420 -0
- package/.agent/skills/extract-design-system/SKILL.md +42 -0
- package/.agent/skills/framer-motion-expert/SKILL.md +42 -0
- package/.agent/skills/frontend-design/SKILL.md +42 -0
- package/.agent/skills/game-design-expert/SKILL.md +42 -0
- package/.agent/skills/game-engineering-expert/SKILL.md +42 -0
- package/.agent/skills/geo-fundamentals/SKILL.md +42 -0
- package/.agent/skills/github-operations/SKILL.md +42 -0
- package/.agent/skills/gsap-core/SKILL.md +302 -0
- package/.agent/skills/gsap-frameworks/SKILL.md +201 -0
- package/.agent/skills/gsap-performance/SKILL.md +127 -0
- package/.agent/skills/gsap-plugins/SKILL.md +474 -0
- package/.agent/skills/gsap-react/SKILL.md +183 -0
- package/.agent/skills/gsap-scrolltrigger/SKILL.md +344 -0
- package/.agent/skills/gsap-timeline/SKILL.md +155 -0
- package/.agent/skills/gsap-utils/SKILL.md +332 -0
- package/.agent/skills/i18n-localization/SKILL.md +42 -0
- package/.agent/skills/intelligent-routing/SKILL.md +72 -1
- package/.agent/skills/lint-and-validate/SKILL.md +42 -0
- package/.agent/skills/llm-engineering/SKILL.md +42 -0
- package/.agent/skills/local-first/SKILL.md +42 -0
- package/.agent/skills/mcp-builder/SKILL.md +42 -0
- package/.agent/skills/mobile-design/SKILL.md +42 -0
- package/.agent/skills/monorepo-management/SKILL.md +326 -0
- package/.agent/skills/motion-engineering/SKILL.md +42 -0
- package/.agent/skills/nextjs-react-expert/SKILL.md +42 -0
- package/.agent/skills/nodejs-best-practices/SKILL.md +42 -0
- package/.agent/skills/observability/SKILL.md +42 -0
- package/.agent/skills/parallel-agents/SKILL.md +42 -0
- package/.agent/skills/performance-profiling/SKILL.md +42 -0
- package/.agent/skills/plan-writing/SKILL.md +42 -0
- package/.agent/skills/platform-engineer/SKILL.md +42 -0
- package/.agent/skills/playwright-best-practices/SKILL.md +42 -0
- package/.agent/skills/powershell-windows/SKILL.md +42 -0
- package/.agent/skills/project-idioms/SKILL.md +42 -0
- package/.agent/skills/python-patterns/SKILL.md +42 -0
- package/.agent/skills/python-pro/SKILL.md +42 -0
- package/.agent/skills/react-specialist/SKILL.md +42 -0
- package/.agent/skills/readme-builder/SKILL.md +42 -0
- package/.agent/skills/realtime-patterns/SKILL.md +42 -0
- package/.agent/skills/red-team-tactics/SKILL.md +42 -0
- package/.agent/skills/rust-pro/SKILL.md +42 -0
- package/.agent/skills/seo-fundamentals/SKILL.md +42 -0
- package/.agent/skills/server-management/SKILL.md +42 -0
- package/.agent/skills/shadcn-ui-expert/SKILL.md +42 -0
- package/.agent/skills/skill-creator/SKILL.md +42 -0
- package/.agent/skills/sql-pro/SKILL.md +42 -0
- package/.agent/skills/supabase-postgres-best-practices/SKILL.md +42 -0
- package/.agent/skills/swiftui-expert/SKILL.md +42 -0
- package/.agent/skills/systematic-debugging/SKILL.md +42 -0
- package/.agent/skills/tailwind-patterns/SKILL.md +42 -0
- package/.agent/skills/tdd-workflow/SKILL.md +42 -0
- package/.agent/skills/test-result-analyzer/SKILL.md +42 -0
- package/.agent/skills/testing-patterns/SKILL.md +42 -0
- package/.agent/skills/trend-researcher/SKILL.md +42 -0
- package/.agent/skills/typescript-advanced/SKILL.md +327 -0
- package/.agent/skills/ui-ux-pro-max/SKILL.md +42 -0
- package/.agent/skills/ui-ux-researcher/SKILL.md +42 -0
- package/.agent/skills/vue-expert/SKILL.md +42 -0
- package/.agent/skills/vulnerability-scanner/SKILL.md +42 -0
- package/.agent/skills/web-accessibility-auditor/SKILL.md +42 -0
- package/.agent/skills/web-design-guidelines/SKILL.md +42 -0
- package/.agent/skills/webapp-testing/SKILL.md +42 -0
- package/.agent/skills/whimsy-injector/SKILL.md +42 -0
- package/.agent/skills/workflow-optimizer/SKILL.md +42 -0
- package/.agent/workflows/tribunal-backend.md +13 -2
- package/.agent/workflows/tribunal-full.md +15 -8
- package/.agent/workflows/tribunal-speed.md +183 -0
- package/bin/tribunal-kit.js +10 -2
- package/package.json +2 -2
- package/.agent/skills/gsap-expert/SKILL.md +0 -194
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: error-resilience
|
|
3
|
+
description: Error resilience and fault tolerance mastery. Retry strategies (exponential backoff with jitter), circuit breakers, bulkheads, graceful degradation, React error boundaries, dead letter queues, timeout patterns, fallback chains, and idempotent error recovery. Use when building fault-tolerant systems, handling flaky external services, or preventing cascading failures.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep
|
|
5
|
+
version: 1.0.0
|
|
6
|
+
last-updated: 2026-04-17
|
|
7
|
+
applies-to-model: gemini-2.5-pro, claude-3-7-sonnet
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Hallucination Traps (Read First)
|
|
11
|
+
- ❌ Retrying non-idempotent operations (POST payments) without idempotency keys -> ✅ Always require idempotency keys for non-safe HTTP methods before retrying
|
|
12
|
+
- ❌ Using fixed delay retries instead of exponential backoff -> ✅ Exponential backoff with jitter prevents thundering herd
|
|
13
|
+
- ❌ Catching all errors and swallowing them -> ✅ Only catch recoverable (operational) errors; let programmer errors crash
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Error Resilience — Fault-Tolerant Systems
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Error Classification (Always Do This First)
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
// ✅ CRITICAL: Classify errors before handling them
|
|
25
|
+
// Operational errors = expected failures you CAN recover from
|
|
26
|
+
// Programmer errors = bugs you CANNOT recover from
|
|
27
|
+
|
|
28
|
+
class OperationalError extends Error {
|
|
29
|
+
constructor(message: string, public readonly isRetryable: boolean = false) {
|
|
30
|
+
super(message);
|
|
31
|
+
this.name = "OperationalError";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// ❌ BAD: Treating all errors the same
|
|
36
|
+
catch (e) { console.log(e); }
|
|
37
|
+
|
|
38
|
+
// ✅ GOOD: Classifying and routing
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (error instanceof OperationalError && error.isRetryable) {
|
|
41
|
+
return retry(operation);
|
|
42
|
+
}
|
|
43
|
+
if (error instanceof OperationalError) {
|
|
44
|
+
return fallback(error);
|
|
45
|
+
}
|
|
46
|
+
// Programmer error — crash fast, fix the bug
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
53
|
+
│ Operational (recoverable) │
|
|
54
|
+
├─────────────────────────────────────────────────────────────┤
|
|
55
|
+
│ Network timeout → Retry with backoff │
|
|
56
|
+
│ Rate limited (429) → Retry after Retry-After header │
|
|
57
|
+
│ Service unavailable (503) → Circuit breaker + fallback │
|
|
58
|
+
│ Database connection lost → Reconnect with pool │
|
|
59
|
+
│ Input validation failed → Return 400 to client │
|
|
60
|
+
│ File not found → Return 404 or create default │
|
|
61
|
+
├─────────────────────────────────────────────────────────────┤
|
|
62
|
+
│ Programmer (crash immediately) │
|
|
63
|
+
├─────────────────────────────────────────────────────────────┤
|
|
64
|
+
│ TypeError / ReferenceError → Bug — fix the code │
|
|
65
|
+
│ Assertion failure → Invariant violated — fix logic │
|
|
66
|
+
│ Undefined is not a function → Missing import or typo │
|
|
67
|
+
│ Stack overflow → Infinite recursion — fix logic │
|
|
68
|
+
└─────────────────────────────────────────────────────────────┘
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Retry with Exponential Backoff + Jitter
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
interface RetryOptions {
|
|
77
|
+
maxRetries: number;
|
|
78
|
+
baseDelayMs: number;
|
|
79
|
+
maxDelayMs: number;
|
|
80
|
+
retryableErrors?: (error: unknown) => boolean;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const DEFAULT_RETRY: RetryOptions = {
|
|
84
|
+
maxRetries: 3,
|
|
85
|
+
baseDelayMs: 500,
|
|
86
|
+
maxDelayMs: 15_000,
|
|
87
|
+
retryableErrors: (err) =>
|
|
88
|
+
err instanceof Error && (
|
|
89
|
+
err.message.includes("ECONNRESET") ||
|
|
90
|
+
err.message.includes("ETIMEDOUT") ||
|
|
91
|
+
err.message.includes("503") ||
|
|
92
|
+
err.message.includes("429")
|
|
93
|
+
),
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
async function withRetry<T>(
|
|
97
|
+
fn: () => Promise<T>,
|
|
98
|
+
options: Partial<RetryOptions> = {},
|
|
99
|
+
): Promise<T> {
|
|
100
|
+
const opts = { ...DEFAULT_RETRY, ...options };
|
|
101
|
+
|
|
102
|
+
for (let attempt = 0; attempt <= opts.maxRetries; attempt++) {
|
|
103
|
+
try {
|
|
104
|
+
return await fn();
|
|
105
|
+
} catch (error) {
|
|
106
|
+
const isLast = attempt === opts.maxRetries;
|
|
107
|
+
const isRetryable = opts.retryableErrors?.(error) ?? true;
|
|
108
|
+
|
|
109
|
+
if (isLast || !isRetryable) throw error;
|
|
110
|
+
|
|
111
|
+
// Exponential backoff with full jitter
|
|
112
|
+
const exponential = opts.baseDelayMs * 2 ** attempt;
|
|
113
|
+
const capped = Math.min(exponential, opts.maxDelayMs);
|
|
114
|
+
const jitter = Math.random() * capped;
|
|
115
|
+
|
|
116
|
+
console.warn(
|
|
117
|
+
`[RETRY] Attempt ${attempt + 1}/${opts.maxRetries} failed. ` +
|
|
118
|
+
`Retrying in ${Math.round(jitter)}ms...`
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
await sleep(jitter);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
throw new Error("Unreachable");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function sleep(ms: number): Promise<void> {
|
|
128
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// ❌ NEVER retry non-idempotent operations without idempotency keys
|
|
132
|
+
// ❌ withRetry(() => createPayment(order)); // could charge twice!
|
|
133
|
+
// ✅ withRetry(() => createPayment(order, { idempotencyKey: order.id }));
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Circuit Breaker
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
enum CircuitState {
|
|
142
|
+
CLOSED = "CLOSED", // Normal — requests pass through
|
|
143
|
+
OPEN = "OPEN", // Tripped — requests fail immediately
|
|
144
|
+
HALF_OPEN = "HALF_OPEN", // Testing — one request allowed
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
class CircuitBreaker {
|
|
148
|
+
private state = CircuitState.CLOSED;
|
|
149
|
+
private failureCount = 0;
|
|
150
|
+
private lastFailureTime = 0;
|
|
151
|
+
private successCount = 0;
|
|
152
|
+
|
|
153
|
+
constructor(
|
|
154
|
+
private readonly threshold: number = 5,
|
|
155
|
+
private readonly resetTimeoutMs: number = 30_000,
|
|
156
|
+
private readonly halfOpenMax: number = 3,
|
|
157
|
+
) {}
|
|
158
|
+
|
|
159
|
+
async execute<T>(fn: () => Promise<T>, fallback?: () => T): Promise<T> {
|
|
160
|
+
if (this.state === CircuitState.OPEN) {
|
|
161
|
+
if (Date.now() - this.lastFailureTime > this.resetTimeoutMs) {
|
|
162
|
+
this.state = CircuitState.HALF_OPEN;
|
|
163
|
+
this.successCount = 0;
|
|
164
|
+
} else {
|
|
165
|
+
if (fallback) return fallback();
|
|
166
|
+
throw new Error(`Circuit OPEN — service unavailable`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
try {
|
|
171
|
+
const result = await fn();
|
|
172
|
+
this.onSuccess();
|
|
173
|
+
return result;
|
|
174
|
+
} catch (error) {
|
|
175
|
+
this.onFailure();
|
|
176
|
+
if (fallback) return fallback();
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
private onSuccess(): void {
|
|
182
|
+
if (this.state === CircuitState.HALF_OPEN) {
|
|
183
|
+
this.successCount++;
|
|
184
|
+
if (this.successCount >= this.halfOpenMax) {
|
|
185
|
+
this.state = CircuitState.CLOSED; // Recovery confirmed
|
|
186
|
+
this.failureCount = 0;
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
this.failureCount = 0;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
private onFailure(): void {
|
|
194
|
+
this.failureCount++;
|
|
195
|
+
this.lastFailureTime = Date.now();
|
|
196
|
+
if (this.failureCount >= this.threshold) {
|
|
197
|
+
this.state = CircuitState.OPEN;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Usage
|
|
203
|
+
const paymentCircuit = new CircuitBreaker(5, 30_000);
|
|
204
|
+
|
|
205
|
+
const result = await paymentCircuit.execute(
|
|
206
|
+
() => paymentGateway.charge(amount),
|
|
207
|
+
() => ({ status: "deferred", message: "Payment queued for retry" }),
|
|
208
|
+
);
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## React Error Boundaries
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
// ✅ Error boundary with recovery
|
|
217
|
+
import { Component, type ReactNode } from "react";
|
|
218
|
+
|
|
219
|
+
interface Props {
|
|
220
|
+
children: ReactNode;
|
|
221
|
+
fallback?: ReactNode;
|
|
222
|
+
onError?: (error: Error, errorInfo: React.ErrorInfo) => void;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
interface State {
|
|
226
|
+
hasError: boolean;
|
|
227
|
+
error: Error | null;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
class ErrorBoundary extends Component<Props, State> {
|
|
231
|
+
state: State = { hasError: false, error: null };
|
|
232
|
+
|
|
233
|
+
static getDerivedStateFromError(error: Error): State {
|
|
234
|
+
return { hasError: true, error };
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
|
|
238
|
+
this.props.onError?.(error, errorInfo);
|
|
239
|
+
// Send to error tracking (Sentry, etc.)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
render() {
|
|
243
|
+
if (this.state.hasError) {
|
|
244
|
+
return this.props.fallback ?? (
|
|
245
|
+
<div role="alert">
|
|
246
|
+
<h2>Something went wrong</h2>
|
|
247
|
+
<button onClick={() => this.setState({ hasError: false, error: null })}>
|
|
248
|
+
Try Again
|
|
249
|
+
</button>
|
|
250
|
+
</div>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
return this.props.children;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// ❌ TRAP: Error boundaries do NOT catch:
|
|
258
|
+
// - Event handlers (use try/catch inside handlers)
|
|
259
|
+
// - Async code (use Promise.catch or error state)
|
|
260
|
+
// - Server-side rendering errors
|
|
261
|
+
// - Errors in the error boundary itself
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Timeout Patterns
|
|
267
|
+
|
|
268
|
+
```typescript
|
|
269
|
+
// ✅ AbortController-based timeout (modern, cancellable)
|
|
270
|
+
async function withTimeout<T>(
|
|
271
|
+
fn: (signal: AbortSignal) => Promise<T>,
|
|
272
|
+
timeoutMs: number,
|
|
273
|
+
): Promise<T> {
|
|
274
|
+
const controller = new AbortController();
|
|
275
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
276
|
+
|
|
277
|
+
try {
|
|
278
|
+
return await fn(controller.signal);
|
|
279
|
+
} catch (error) {
|
|
280
|
+
if (controller.signal.aborted) {
|
|
281
|
+
throw new OperationalError(`Operation timed out after ${timeoutMs}ms`, true);
|
|
282
|
+
}
|
|
283
|
+
throw error;
|
|
284
|
+
} finally {
|
|
285
|
+
clearTimeout(timer);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// Usage
|
|
290
|
+
const data = await withTimeout(
|
|
291
|
+
(signal) => fetch("https://api.example.com/data", { signal }),
|
|
292
|
+
5000,
|
|
293
|
+
);
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Graceful Degradation (Fallback Chains)
|
|
299
|
+
|
|
300
|
+
```typescript
|
|
301
|
+
// ✅ Layered fallback: primary → cache → stale → default
|
|
302
|
+
async function getUserProfile(userId: string): Promise<UserProfile> {
|
|
303
|
+
// Layer 1: Primary source
|
|
304
|
+
try {
|
|
305
|
+
return await api.getUser(userId);
|
|
306
|
+
} catch { /* fall through */ }
|
|
307
|
+
|
|
308
|
+
// Layer 2: Cache
|
|
309
|
+
try {
|
|
310
|
+
const cached = await cache.get(`user:${userId}`);
|
|
311
|
+
if (cached) return { ...cached, _stale: true };
|
|
312
|
+
} catch { /* fall through */ }
|
|
313
|
+
|
|
314
|
+
// Layer 3: Default
|
|
315
|
+
return {
|
|
316
|
+
id: userId,
|
|
317
|
+
name: "Unknown User",
|
|
318
|
+
avatar: "/default-avatar.png",
|
|
319
|
+
_stale: true,
|
|
320
|
+
_default: true,
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// ❌ BAD: Crash the whole page because one API is down
|
|
325
|
+
// ✅ GOOD: Show stale/partial data with a warning banner
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## Dead Letter Queue Pattern
|
|
331
|
+
|
|
332
|
+
```typescript
|
|
333
|
+
// When a message/job fails after all retries, don't lose it
|
|
334
|
+
interface DeadLetter<T> {
|
|
335
|
+
payload: T;
|
|
336
|
+
error: string;
|
|
337
|
+
failedAt: string;
|
|
338
|
+
attempts: number;
|
|
339
|
+
originalQueue: string;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
async function processWithDLQ<T>(
|
|
343
|
+
payload: T,
|
|
344
|
+
processor: (item: T) => Promise<void>,
|
|
345
|
+
dlqStore: { push: (item: DeadLetter<T>) => Promise<void> },
|
|
346
|
+
): Promise<void> {
|
|
347
|
+
try {
|
|
348
|
+
await withRetry(() => processor(payload), { maxRetries: 3 });
|
|
349
|
+
} catch (error) {
|
|
350
|
+
// Exhausted retries — park in dead letter queue
|
|
351
|
+
await dlqStore.push({
|
|
352
|
+
payload,
|
|
353
|
+
error: error instanceof Error ? error.message : String(error),
|
|
354
|
+
failedAt: new Date().toISOString(),
|
|
355
|
+
attempts: 4,
|
|
356
|
+
originalQueue: "main",
|
|
357
|
+
});
|
|
358
|
+
// Don't throw — the message is preserved for manual review
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
## Anti-Patterns (Never Do These)
|
|
366
|
+
|
|
367
|
+
```
|
|
368
|
+
❌ Swallowing errors silently: catch (e) { /* empty */ }
|
|
369
|
+
❌ Retrying infinitely without a max — causes resource exhaustion
|
|
370
|
+
❌ Retrying POST/DELETE without idempotency keys
|
|
371
|
+
❌ Using fixed-delay retries — causes thundering herd
|
|
372
|
+
❌ Catching Error base class when you mean a specific subclass
|
|
373
|
+
❌ Logging error.message but not error.stack
|
|
374
|
+
❌ Returning null to indicate failure (use Result type or throw)
|
|
375
|
+
❌ Wrapping synchronous code in try/catch when it can't fail
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
## 🤖 LLM-Specific Traps
|
|
384
|
+
|
|
385
|
+
AI coding assistants often fall into specific bad habits when dealing with this domain. These are strictly forbidden:
|
|
386
|
+
|
|
387
|
+
1. **Over-engineering:** Proposing complex abstractions or distributed systems when a simpler approach suffices.
|
|
388
|
+
2. **Hallucinated Libraries/Methods:** Using non-existent methods or packages. Always `// VERIFY` or check `package.json` / `requirements.txt`.
|
|
389
|
+
3. **Skipping Edge Cases:** Writing the "happy path" and ignoring error handling, timeouts, or data validation.
|
|
390
|
+
4. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
|
|
391
|
+
5. **Silent Degradation:** Catching and suppressing errors without logging or re-raising.
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
395
|
+
## 🏛️ Tribunal Integration (Anti-Hallucination)
|
|
396
|
+
|
|
397
|
+
**Slash command: `/review` or `/tribunal-full`**
|
|
398
|
+
**Active reviewers: `logic-reviewer` · `security-auditor`**
|
|
399
|
+
|
|
400
|
+
### ❌ Forbidden AI Tropes
|
|
401
|
+
|
|
402
|
+
1. **Blind Assumptions:** Never make an assumption without documenting it clearly with `// VERIFY: [reason]`.
|
|
403
|
+
2. **Silent Degradation:** Catching and suppressing errors without logging or handling.
|
|
404
|
+
3. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
|
|
405
|
+
|
|
406
|
+
### ✅ Pre-Flight Self-Audit
|
|
407
|
+
|
|
408
|
+
Review these questions before confirming output:
|
|
409
|
+
```
|
|
410
|
+
✅ Did I rely ONLY on real, verified tools and methods?
|
|
411
|
+
✅ Is this solution appropriately scoped to the user's constraints?
|
|
412
|
+
✅ Did I handle potential failure modes and edge cases?
|
|
413
|
+
✅ Have I avoided generic boilerplate that doesn't add value?
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
### 🛑 Verification-Before-Completion (VBC) Protocol
|
|
417
|
+
|
|
418
|
+
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
419
|
+
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
420
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
@@ -106,3 +106,45 @@ A Design System must mandate accessibility at the token level, preventing develo
|
|
|
106
106
|
2. Focus rings must be decoupled and standardized globally (`ring-2 ring-primary ring-offset-2`).
|
|
107
107
|
|
|
108
108
|
---
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## 🤖 LLM-Specific Traps
|
|
114
|
+
|
|
115
|
+
AI coding assistants often fall into specific bad habits when dealing with this domain. These are strictly forbidden:
|
|
116
|
+
|
|
117
|
+
1. **Over-engineering:** Proposing complex abstractions or distributed systems when a simpler approach suffices.
|
|
118
|
+
2. **Hallucinated Libraries/Methods:** Using non-existent methods or packages. Always `// VERIFY` or check `package.json` / `requirements.txt`.
|
|
119
|
+
3. **Skipping Edge Cases:** Writing the "happy path" and ignoring error handling, timeouts, or data validation.
|
|
120
|
+
4. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
|
|
121
|
+
5. **Silent Degradation:** Catching and suppressing errors without logging or re-raising.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## 🏛️ Tribunal Integration (Anti-Hallucination)
|
|
126
|
+
|
|
127
|
+
**Slash command: `/review` or `/tribunal-full`**
|
|
128
|
+
**Active reviewers: `logic-reviewer` · `security-auditor`**
|
|
129
|
+
|
|
130
|
+
### ❌ Forbidden AI Tropes
|
|
131
|
+
|
|
132
|
+
1. **Blind Assumptions:** Never make an assumption without documenting it clearly with `// VERIFY: [reason]`.
|
|
133
|
+
2. **Silent Degradation:** Catching and suppressing errors without logging or handling.
|
|
134
|
+
3. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
|
|
135
|
+
|
|
136
|
+
### ✅ Pre-Flight Self-Audit
|
|
137
|
+
|
|
138
|
+
Review these questions before confirming output:
|
|
139
|
+
```
|
|
140
|
+
✅ Did I rely ONLY on real, verified tools and methods?
|
|
141
|
+
✅ Is this solution appropriately scoped to the user's constraints?
|
|
142
|
+
✅ Did I handle potential failure modes and edge cases?
|
|
143
|
+
✅ Have I avoided generic boilerplate that doesn't add value?
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### 🛑 Verification-Before-Completion (VBC) Protocol
|
|
147
|
+
|
|
148
|
+
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
149
|
+
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
150
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
@@ -193,3 +193,45 @@ const reduce = useReducedMotion();
|
|
|
193
193
|
- ✅ `useMotionValue` for animation-driven values — never `useState`
|
|
194
194
|
- ❌ Nest `AnimatePresence` only when necessary — each adds reconciler overhead
|
|
195
195
|
- `"use client"` required in Next.js — `motion.div` cannot run in Server Components
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## 🤖 LLM-Specific Traps
|
|
201
|
+
|
|
202
|
+
AI coding assistants often fall into specific bad habits when dealing with this domain. These are strictly forbidden:
|
|
203
|
+
|
|
204
|
+
1. **Over-engineering:** Proposing complex abstractions or distributed systems when a simpler approach suffices.
|
|
205
|
+
2. **Hallucinated Libraries/Methods:** Using non-existent methods or packages. Always `// VERIFY` or check `package.json` / `requirements.txt`.
|
|
206
|
+
3. **Skipping Edge Cases:** Writing the "happy path" and ignoring error handling, timeouts, or data validation.
|
|
207
|
+
4. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
|
|
208
|
+
5. **Silent Degradation:** Catching and suppressing errors without logging or re-raising.
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## 🏛️ Tribunal Integration (Anti-Hallucination)
|
|
213
|
+
|
|
214
|
+
**Slash command: `/review` or `/tribunal-full`**
|
|
215
|
+
**Active reviewers: `logic-reviewer` · `security-auditor`**
|
|
216
|
+
|
|
217
|
+
### ❌ Forbidden AI Tropes
|
|
218
|
+
|
|
219
|
+
1. **Blind Assumptions:** Never make an assumption without documenting it clearly with `// VERIFY: [reason]`.
|
|
220
|
+
2. **Silent Degradation:** Catching and suppressing errors without logging or handling.
|
|
221
|
+
3. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
|
|
222
|
+
|
|
223
|
+
### ✅ Pre-Flight Self-Audit
|
|
224
|
+
|
|
225
|
+
Review these questions before confirming output:
|
|
226
|
+
```
|
|
227
|
+
✅ Did I rely ONLY on real, verified tools and methods?
|
|
228
|
+
✅ Is this solution appropriately scoped to the user's constraints?
|
|
229
|
+
✅ Did I handle potential failure modes and edge cases?
|
|
230
|
+
✅ Have I avoided generic boilerplate that doesn't add value?
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### 🛑 Verification-Before-Completion (VBC) Protocol
|
|
234
|
+
|
|
235
|
+
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
236
|
+
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
237
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
@@ -149,3 +149,45 @@ Design is fundamentally broken if it excludes users.
|
|
|
149
149
|
- ✅ Custom dropdowns/selects must support Arrow Keys and Escape.
|
|
150
150
|
- ✅ Color alone cannot convey state (Error text must have an icon too `❌ Password invalid`).
|
|
151
151
|
- ✅ Hide decorative SVG/icons from screen readers `aria-hidden="true"`.
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 🤖 LLM-Specific Traps
|
|
157
|
+
|
|
158
|
+
AI coding assistants often fall into specific bad habits when dealing with this domain. These are strictly forbidden:
|
|
159
|
+
|
|
160
|
+
1. **Over-engineering:** Proposing complex abstractions or distributed systems when a simpler approach suffices.
|
|
161
|
+
2. **Hallucinated Libraries/Methods:** Using non-existent methods or packages. Always `// VERIFY` or check `package.json` / `requirements.txt`.
|
|
162
|
+
3. **Skipping Edge Cases:** Writing the "happy path" and ignoring error handling, timeouts, or data validation.
|
|
163
|
+
4. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
|
|
164
|
+
5. **Silent Degradation:** Catching and suppressing errors without logging or re-raising.
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## 🏛️ Tribunal Integration (Anti-Hallucination)
|
|
169
|
+
|
|
170
|
+
**Slash command: `/review` or `/tribunal-full`**
|
|
171
|
+
**Active reviewers: `logic-reviewer` · `security-auditor`**
|
|
172
|
+
|
|
173
|
+
### ❌ Forbidden AI Tropes
|
|
174
|
+
|
|
175
|
+
1. **Blind Assumptions:** Never make an assumption without documenting it clearly with `// VERIFY: [reason]`.
|
|
176
|
+
2. **Silent Degradation:** Catching and suppressing errors without logging or handling.
|
|
177
|
+
3. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
|
|
178
|
+
|
|
179
|
+
### ✅ Pre-Flight Self-Audit
|
|
180
|
+
|
|
181
|
+
Review these questions before confirming output:
|
|
182
|
+
```
|
|
183
|
+
✅ Did I rely ONLY on real, verified tools and methods?
|
|
184
|
+
✅ Is this solution appropriately scoped to the user's constraints?
|
|
185
|
+
✅ Did I handle potential failure modes and edge cases?
|
|
186
|
+
✅ Have I avoided generic boilerplate that doesn't add value?
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### 🛑 Verification-Before-Completion (VBC) Protocol
|
|
190
|
+
|
|
191
|
+
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
192
|
+
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
193
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
@@ -77,3 +77,45 @@ Design is hypotheses. Playtests are the reality.
|
|
|
77
77
|
Never rely on developers "feeling" the game. You must systematically log death coordinates (heatmaps). If 80% of players die at Level 2 Trap B, your design intent (teaching the mechanic) has failed.
|
|
78
78
|
|
|
79
79
|
---
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## 🤖 LLM-Specific Traps
|
|
85
|
+
|
|
86
|
+
AI coding assistants often fall into specific bad habits when dealing with this domain. These are strictly forbidden:
|
|
87
|
+
|
|
88
|
+
1. **Over-engineering:** Proposing complex abstractions or distributed systems when a simpler approach suffices.
|
|
89
|
+
2. **Hallucinated Libraries/Methods:** Using non-existent methods or packages. Always `// VERIFY` or check `package.json` / `requirements.txt`.
|
|
90
|
+
3. **Skipping Edge Cases:** Writing the "happy path" and ignoring error handling, timeouts, or data validation.
|
|
91
|
+
4. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
|
|
92
|
+
5. **Silent Degradation:** Catching and suppressing errors without logging or re-raising.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 🏛️ Tribunal Integration (Anti-Hallucination)
|
|
97
|
+
|
|
98
|
+
**Slash command: `/review` or `/tribunal-full`**
|
|
99
|
+
**Active reviewers: `logic-reviewer` · `security-auditor`**
|
|
100
|
+
|
|
101
|
+
### ❌ Forbidden AI Tropes
|
|
102
|
+
|
|
103
|
+
1. **Blind Assumptions:** Never make an assumption without documenting it clearly with `// VERIFY: [reason]`.
|
|
104
|
+
2. **Silent Degradation:** Catching and suppressing errors without logging or handling.
|
|
105
|
+
3. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
|
|
106
|
+
|
|
107
|
+
### ✅ Pre-Flight Self-Audit
|
|
108
|
+
|
|
109
|
+
Review these questions before confirming output:
|
|
110
|
+
```
|
|
111
|
+
✅ Did I rely ONLY on real, verified tools and methods?
|
|
112
|
+
✅ Is this solution appropriately scoped to the user's constraints?
|
|
113
|
+
✅ Did I handle potential failure modes and edge cases?
|
|
114
|
+
✅ Have I avoided generic boilerplate that doesn't add value?
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 🛑 Verification-Before-Completion (VBC) Protocol
|
|
118
|
+
|
|
119
|
+
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
120
|
+
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
121
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
@@ -94,3 +94,45 @@ Never trust the client. A multiplayer architecture dictates latency fundamentall
|
|
|
94
94
|
- If the server eventually disagrees, the Client aggressively rewinds and snaps the state to match the Server reality (Rubber-banding).
|
|
95
95
|
|
|
96
96
|
---
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 🤖 LLM-Specific Traps
|
|
102
|
+
|
|
103
|
+
AI coding assistants often fall into specific bad habits when dealing with this domain. These are strictly forbidden:
|
|
104
|
+
|
|
105
|
+
1. **Over-engineering:** Proposing complex abstractions or distributed systems when a simpler approach suffices.
|
|
106
|
+
2. **Hallucinated Libraries/Methods:** Using non-existent methods or packages. Always `// VERIFY` or check `package.json` / `requirements.txt`.
|
|
107
|
+
3. **Skipping Edge Cases:** Writing the "happy path" and ignoring error handling, timeouts, or data validation.
|
|
108
|
+
4. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
|
|
109
|
+
5. **Silent Degradation:** Catching and suppressing errors without logging or re-raising.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## 🏛️ Tribunal Integration (Anti-Hallucination)
|
|
114
|
+
|
|
115
|
+
**Slash command: `/review` or `/tribunal-full`**
|
|
116
|
+
**Active reviewers: `logic-reviewer` · `security-auditor`**
|
|
117
|
+
|
|
118
|
+
### ❌ Forbidden AI Tropes
|
|
119
|
+
|
|
120
|
+
1. **Blind Assumptions:** Never make an assumption without documenting it clearly with `// VERIFY: [reason]`.
|
|
121
|
+
2. **Silent Degradation:** Catching and suppressing errors without logging or handling.
|
|
122
|
+
3. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
|
|
123
|
+
|
|
124
|
+
### ✅ Pre-Flight Self-Audit
|
|
125
|
+
|
|
126
|
+
Review these questions before confirming output:
|
|
127
|
+
```
|
|
128
|
+
✅ Did I rely ONLY on real, verified tools and methods?
|
|
129
|
+
✅ Is this solution appropriately scoped to the user's constraints?
|
|
130
|
+
✅ Did I handle potential failure modes and edge cases?
|
|
131
|
+
✅ Have I avoided generic boilerplate that doesn't add value?
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 🛑 Verification-Before-Completion (VBC) Protocol
|
|
135
|
+
|
|
136
|
+
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
137
|
+
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
138
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|