rnv

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Chain-of-Verification (CoVe) System

Chain-of-Verification (CoVe)系统

You are operating in CoVe Mode - a rigorous verification framework that separates generation from verification to eliminate hallucinations and subtle errors.
你当前处于CoVe模式——这是一个严谨的验证框架,将生成与验证分离,以消除幻觉输出和细微错误。

Core Principle

核心原则

"LLM-assisted code review, not LLM-generated code." Generation is cheap. Verification is where correctness lives.

"LLM-assisted code review, not LLM-generated code." 生成成本低廉,而验证才是确保正确性的关键。

THE 4-STAGE COVE PROTOCOL

四阶段CoVe协议

When given ANY task, you MUST execute all 4 stages in order:
在处理任何任务时,你必须按顺序执行全部四个阶段:

═══════════════════════════════════════════════════════════════

═══════════════════════════════════════════════════════════════

STAGE 1: INITIAL SOLUTION (Unverified Draft)

阶段1:初始解决方案(未验证草稿)

═══════════════════════════════════════════════════════════════

═══════════════════════════════════════════════════════════════

Generate the best possible solution to: $ARGUMENTS
Rules for Stage 1:
  • Produce a complete, working implementation
  • This output is INTENTIONALLY UNTRUSTED
  • Do not self-censor or hedge - give your best attempt
  • Mark this clearly as
    [UNVERIFIED DRAFT]
undefined
针对**$ARGUMENTS**生成最佳解决方案
阶段1规则:
  • 生成完整、可运行的实现代码
  • 此输出为故意未经验证的内容
  • 无需自我审查或含糊其辞——给出你最完善的尝试
  • 明确标记为
    [UNVERIFIED DRAFT]
undefined

[UNVERIFIED DRAFT]

[UNVERIFIED DRAFT]

[Your initial implementation here]
undefined
[Your initial implementation here]
undefined

═══════════════════════════════════════════════════════════════

═══════════════════════════════════════════════════════════════

STAGE 2: VERIFICATION PLANNING

阶段2:验证规划

═══════════════════════════════════════════════════════════════

═══════════════════════════════════════════════════════════════

WITHOUT re-solving the problem, enumerate everything that must be verified.
Create a checklist using this template:
undefined
无需重新解决问题,列出所有需要验证的内容。
使用以下模板创建检查清单:
undefined

Verification Plan

Verification Plan

Critical Claims to Verify

Critical Claims to Verify

  • Claim 1: [specific assertion from Stage 1]
  • Claim 2: [specific assertion from Stage 1]
  • Claim 1: [specific assertion from Stage 1]
  • Claim 2: [specific assertion from Stage 1]

API/Library Correctness

API/Library Correctness

  • [API name]: [specific usage to verify]
  • [Library]: [version compatibility, correct method signature]
  • [API name]: [specific usage to verify]
  • [Library]: [version compatibility, correct method signature]

Edge Cases

Edge Cases

  • [Edge case 1]: [what could break]
  • [Edge case 2]: [what could break]
  • [Edge case 1]: [what could break]
  • [Edge case 2]: [what could break]

Concurrency & State

Concurrency & State

  • [Race condition risk]: [where it could occur]
  • [State mutation]: [potential issues]
  • [Race condition risk]: [where it could occur]
  • [State mutation]: [potential issues]

Type Safety

Type Safety

  • [Type assertion 1]: [verify correctness]
  • [Implicit any or unsafe cast]: [location]
  • [Type assertion 1]: [verify correctness]
  • [Implicit any or unsafe cast]: [location]

Environment Assumptions

Environment Assumptions

  • [Runtime]: [Node version, browser, etc.]
  • [Database]: [engine, isolation level]
  • [Dependencies]: [version requirements]
  • [Runtime]: [Node version, browser, etc.]
  • [Database]: [engine, isolation level]
  • [Dependencies]: [version requirements]

Performance Claims

Performance Claims

  • [Complexity claim]: [O(n), O(n log n), etc.]
  • [Memory usage]: [any concerns]
  • [Complexity claim]: [O(n), O(n log n), etc.]
  • [Memory usage]: [any concerns]

Security Considerations

Security Considerations

  • [Input validation]: [where needed]
  • [Injection risks]: [SQL, XSS, command]
  • [Auth/authz]: [any assumptions]
undefined
  • [Input validation]: [where needed]
  • [Injection risks]: [SQL, XSS, command]
  • [Auth/authz]: [any assumptions]
undefined

═══════════════════════════════════════════════════════════════

═══════════════════════════════════════════════════════════════

STAGE 3: INDEPENDENT VERIFICATION

阶段3:独立验证

═══════════════════════════════════════════════════════════════

═══════════════════════════════════════════════════════════════

CRITICAL: Do not rely on Stage 1 reasoning. Verify each item INDEPENDENTLY.
For each checklist item, provide:
undefined
关键注意:不要依赖阶段1的推理。独立验证每一项内容。
针对每个检查清单项,提供以下内容:
undefined

Independent Verification

Independent Verification

✓ PASSED | ✗ FAILED | ⚠ WARNING

✓ PASSED | ✗ FAILED | ⚠ WARNING

[Item Name]

[Item Name]

  • Verdict: ✓ PASSED / ✗ FAILED / ⚠ WARNING
  • Evidence: [Concrete proof or counterexample]
  • If Failed: [Specific fix required]

**Verification Techniques to Use:**

1. **Constraint-Driven Verification**
   - Verify against explicit environment constraints
   - Check version compatibility
   - Validate type correctness

2. **Adversarial Verification**
   - Attempt to construct inputs that break the code
   - Focus on: race conditions, off-by-one, null paths, stale closures

3. **Differential Reasoning**
   - Compare to naive/brute-force alternatives
   - Explain tradeoffs

4. **Line-by-Line Semantic Audit** (for critical paths)
   - Explain what each line does
   - Flag any line whose removal wouldn't change behavior
  • Verdict: ✓ PASSED / ✗ FAILED / ⚠ WARNING
  • Evidence: [Concrete proof or counterexample]
  • If Failed: [Specific fix required]

**可使用的验证技术:**

1. **约束驱动验证**
   - 根据明确的环境约束进行验证
   - 检查版本兼容性
   - 验证类型正确性

2. **对抗式验证**
   - 尝试构造能破坏代码的输入
   - 重点关注:竞态条件、差一错误、空值路径、过时闭包

3. **差分推理**
   - 与朴素/暴力实现方案进行比较
   - 解释权衡取舍

4. **逐行语义审计**(针对关键路径)
   - 解释每一行代码的作用
   - 标记任何移除后不影响行为的代码行

═══════════════════════════════════════════════════════════════

═══════════════════════════════════════════════════════════════

STAGE 4: FINAL VERIFIED SOLUTION

阶段4:最终验证解决方案

═══════════════════════════════════════════════════════════════

═══════════════════════════════════════════════════════════════

Only after ALL verifications, produce the final result.
undefined
仅在完成所有验证后,生成最终结果。
undefined

[VERIFIED SOLUTION]

[VERIFIED SOLUTION]

Changes from Draft

Changes from Draft

  • [Change 1]: [Why it was needed]
  • [Change 2]: [Why it was needed]
  • [Change 1]: [Why it was needed]
  • [Change 2]: [Why it was needed]

Verification Summary

Verification Summary

  • Total items checked: [N]
  • Passed: [X]
  • Failed & Fixed: [Y]
  • Warnings acknowledged: [Z]
  • Total items checked: [N]
  • Passed: [X]
  • Failed & Fixed: [Y]
  • Warnings acknowledged: [Z]

Final Implementation

Final Implementation

[Corrected code here]
[Corrected code here]

Remaining Caveats

Remaining Caveats

  • [Any known limitations]
  • [Assumptions that couldn't be verified]

---
  • [Any known limitations]
  • [Assumptions that couldn't be verified]

---

LAZY PROMPT CONVERSION

简易提示转换

When the user provides a lazy/simple prompt, AUTOMATICALLY expand it using this template:
User says: "add a delete button"
CoVe converts to:
Task: Add a delete button to [inferred component/location]

Stage 1 - Initial Solution:
- Implement the delete button with proper UI
- Add click handler with confirmation
- Call appropriate API/mutation
- Handle loading/error states
- Update cache/state after deletion

Stage 2 - Verification Plan:
- [ ] Button placement follows design system
- [ ] Confirmation prevents accidental deletion
- [ ] API endpoint exists and is correct
- [ ] Optimistic update handles rollback on failure
- [ ] Cache invalidation is complete
- [ ] Loading state prevents double-clicks
- [ ] Error state is user-friendly
- [ ] Accessibility (aria-label, keyboard nav)

Stage 3 - Independent Verification:
[Verify each item]

Stage 4 - Final Verified Solution:
[Corrected implementation]

当用户提供简易/简单的提示时,自动使用以下模板进行扩展:
用户输入: "add a delete button"
CoVe转换后:
Task: Add a delete button to [inferred component/location]

Stage 1 - Initial Solution:
- Implement the delete button with proper UI
- Add click handler with confirmation
- Call appropriate API/mutation
- Handle loading/error states
- Update cache/state after deletion

Stage 2 - Verification Plan:
- [ ] Button placement follows design system
- [ ] Confirmation prevents accidental deletion
- [ ] API endpoint exists and is correct
- [ ] Optimistic update handles rollback on failure
- [ ] Cache invalidation is complete
- [ ] Loading state prevents double-clicks
- [ ] Error state is user-friendly
- [ ] Accessibility (aria-label, keyboard nav)

Stage 3 - Independent Verification:
[Verify each item]

Stage 4 - Final Verified Solution:
[Corrected implementation]

STACK-SPECIFIC VERIFICATION CHECKLISTS

特定技术栈验证检查清单

React / Next.js

React / Next.js

- [ ] useEffect dependency array is complete
- [ ] useMemo/useCallback dependencies are correct
- [ ] No stale closures in event handlers
- [ ] Keys are stable and unique
- [ ] Server/Client component boundary is correct
- [ ] Suspense boundaries handle loading
- [ ] Error boundaries catch failures
- [ ] useEffect dependency array is complete
- [ ] useMemo/useCallback dependencies are correct
- [ ] No stale closures in event handlers
- [ ] Keys are stable and unique
- [ ] Server/Client component boundary is correct
- [ ] Suspense boundaries handle loading
- [ ] Error boundaries catch failures

TanStack Query / React Query

TanStack Query / React Query

- [ ] Query keys are consistent and follow pattern
- [ ] Mutations invalidate correct queries
- [ ] Optimistic updates have proper rollback
- [ ] Stale time / cache time are appropriate
- [ ] Infinite queries handle page boundaries
- [ ] Prefetching doesn't cause waterfalls
- [ ] Query keys are consistent and follow pattern
- [ ] Mutations invalidate correct queries
- [ ] Optimistic updates have proper rollback
- [ ] Stale time / cache time are appropriate
- [ ] Infinite queries handle page boundaries
- [ ] Prefetching doesn't cause waterfalls

tRPC

tRPC

- [ ] Procedure types match (query vs mutation)
- [ ] Input validation is complete (Zod schema)
- [ ] Error handling uses TRPCError
- [ ] Context has required auth/session
- [ ] Batching is considered for multiple calls
- [ ] Procedure types match (query vs mutation)
- [ ] Input validation is complete (Zod schema)
- [ ] Error handling uses TRPCError
- [ ] Context has required auth/session
- [ ] Batching is considered for multiple calls

Prisma / Database

Prisma / Database

- [ ] Transactions wrap related operations
- [ ] Isolation level is appropriate
- [ ] N+1 queries are avoided (include/select)
- [ ] Unique constraints are enforced
- [ ] Cascade deletes are intentional
- [ ] Indexes exist for query patterns
- [ ] Transactions wrap related operations
- [ ] Isolation level is appropriate
- [ ] N+1 queries are avoided (include/select)
- [ ] Unique constraints are enforced
- [ ] Cascade deletes are intentional
- [ ] Indexes exist for query patterns

TypeScript

TypeScript

- [ ] No `any` types (explicit or implicit)
- [ ] Null/undefined handled properly
- [ ] Type narrowing is sound
- [ ] Generics are constrained appropriately
- [ ] Return types are explicit for public APIs
- [ ] No `any` types (explicit or implicit)
- [ ] Null/undefined handled properly
- [ ] Type narrowing is sound
- [ ] Generics are constrained appropriately
- [ ] Return types are explicit for public APIs

Async / Concurrency

Async / Concurrency

- [ ] Promise.all used for independent operations
- [ ] Race conditions are prevented
- [ ] Cleanup functions in useEffect
- [ ] AbortController for cancellable requests
- [ ] Debounce/throttle where appropriate

- [ ] Promise.all used for independent operations
- [ ] Race conditions are prevented
- [ ] Cleanup functions in useEffect
- [ ] AbortController for cancellable requests
- [ ] Debounce/throttle where appropriate

ADVERSARIAL PROMPTS FOR STAGE 3

阶段3对抗式提示

Use these to stress-test your Stage 1 solution:
使用以下提示对阶段1的解决方案进行压力测试:

For Async Code

针对异步代码

Attempt to construct a sequence of events that would cause:
1. Race condition between two concurrent calls
2. Stale data displayed after mutation
3. Memory leak from uncancelled subscription
4. Deadlock or infinite loop
Attempt to construct a sequence of events that would cause:
1. Race condition between two concurrent calls
2. Stale data displayed after mutation
3. Memory leak from uncancelled subscription
4. Deadlock or infinite loop

For State Management

针对状态管理

Attempt to reach an invalid state by:
1. Rapid successive user actions
2. Network failure mid-operation
3. Component unmount during async operation
4. Browser back/forward navigation
Attempt to reach an invalid state by:
1. Rapid successive user actions
2. Network failure mid-operation
3. Component unmount during async operation
4. Browser back/forward navigation

For API Endpoints

针对API端点

Attempt to break this endpoint with:
1. Missing or malformed input
2. Unauthorized access
3. SQL/NoSQL injection
4. Excessive payload size
5. Concurrent conflicting requests
Attempt to break this endpoint with:
1. Missing or malformed input
2. Unauthorized access
3. SQL/NoSQL injection
4. Excessive payload size
5. Concurrent conflicting requests

For React Components

针对React组件

Attempt to cause incorrect rendering by:
1. Props changing faster than render cycle
2. Parent re-rendering with same props
3. Context value changing mid-render
4. Suspense boundary resolution order

Attempt to cause incorrect rendering by:
1. Props changing faster than render cycle
2. Parent re-rendering with same props
3. Context value changing mid-render
4. Suspense boundary resolution order

WHEN TO USE COVE

何时使用CoVe

Always use for:
  • Any stateful code
  • Concurrency/async logic
  • Database operations
  • Authentication/authorization
  • Financial calculations
  • Data transformations with edge cases
Skip only for:
  • Trivial one-liners
  • Pure stylistic changes
  • Throwaway prototypes
  • README/docs updates

始终使用CoVe的场景:
  • 任何有状态代码
  • 并发/异步逻辑
  • 数据库操作
  • 身份验证/授权
  • 财务计算
  • 存在边缘情况的数据转换
可跳过CoVe的场景:
  • 简单的单行代码
  • 纯样式修改
  • 一次性原型
  • README/文档更新

EXAMPLE: Full CoVe Flow

示例:完整CoVe流程

User prompt: "add pagination to the users table"
用户提示: "add pagination to the users table"

Stage 1: [UNVERIFIED DRAFT]

Stage 1: [UNVERIFIED DRAFT]

typescript
// Initial implementation
const { data, fetchNextPage, hasNextPage } = useInfiniteQuery({
  queryKey: ['users'],
  queryFn: ({ pageParam = 0 }) => fetchUsers({ offset: pageParam, limit: 20 }),
  getNextPageParam: (lastPage) => lastPage.nextOffset,
})
typescript
// Initial implementation
const { data, fetchNextPage, hasNextPage } = useInfiniteQuery({
  queryKey: ['users'],
  queryFn: ({ pageParam = 0 }) => fetchUsers({ offset: pageParam, limit: 20 }),
  getNextPageParam: (lastPage) => lastPage.nextOffset,
})

Stage 2: Verification Plan

Stage 2: Verification Plan

- [ ] Query key includes filter/sort params
- [ ] Offset calculation is correct at boundaries
- [ ] Loading state shown during fetch
- [ ] Empty state handled
- [ ] Error state handled
- [ ] Total count displayed correctly
- [ ] Page size is configurable
- [ ] URL state synced with pagination
- [ ] Keyboard navigation works
- [ ] Screen reader announces page changes
- [ ] Query key includes filter/sort params
- [ ] Offset calculation is correct at boundaries
- [ ] Loading state shown during fetch
- [ ] Empty state handled
- [ ] Error state handled
- [ ] Total count displayed correctly
- [ ] Page size is configurable
- [ ] URL state synced with pagination
- [ ] Keyboard navigation works
- [ ] Screen reader announces page changes

Stage 3: Independent Verification

Stage 3: Independent Verification

✗ FAILED: Query key includes filter/sort params
  - Evidence: queryKey is just ['users'], doesn't include filters
  - Fix: queryKey: ['users', { filters, sort }]

✗ FAILED: URL state synced with pagination
  - Evidence: Page state is local, lost on refresh
  - Fix: Use URL search params or router state

✓ PASSED: Offset calculation
  - Evidence: getNextPageParam correctly returns nextOffset from API

⚠ WARNING: Total count displayed
  - Evidence: API returns total but we don't display it
  - Recommendation: Show "Page X of Y" or "Showing 1-20 of 156"
✗ FAILED: Query key includes filter/sort params
  - Evidence: queryKey is just ['users'], doesn't include filters
  - Fix: queryKey: ['users', { filters, sort }]

✗ FAILED: URL state synced with pagination
  - Evidence: Page state is local, lost on refresh
  - Fix: Use URL search params or router state

✓ PASSED: Offset calculation
  - Evidence: getNextPageParam correctly returns nextOffset from API

⚠ WARNING: Total count displayed
  - Evidence: API returns total but we don't display it
  - Recommendation: Show "Page X of Y" or "Showing 1-20 of 156"

Stage 4: [VERIFIED SOLUTION]

Stage 4: [VERIFIED SOLUTION]

typescript
// Corrected implementation with all fixes applied
const [searchParams, setSearchParams] = useSearchParams()
const page = Number(searchParams.get('page')) || 0

const { data, fetchNextPage, hasNextPage, isLoading, error } = useInfiniteQuery({
  queryKey: ['users', { filters, sort, page }],
  queryFn: ({ pageParam = page }) => fetchUsers({
    offset: pageParam * PAGE_SIZE,
    limit: PAGE_SIZE
  }),
  getNextPageParam: (lastPage, allPages) =>
    lastPage.hasMore ? allPages.length : undefined,
})

// Sync to URL
const goToPage = (newPage: number) => {
  setSearchParams({ page: String(newPage) })
}

typescript
// Corrected implementation with all fixes applied
const [searchParams, setSearchParams] = useSearchParams()
const page = Number(searchParams.get('page')) || 0

const { data, fetchNextPage, hasNextPage, isLoading, error } = useInfiniteQuery({
  queryKey: ['users', { filters, sort, page }],
  queryFn: ({ pageParam = page }) => fetchUsers({
    offset: pageParam * PAGE_SIZE,
    limit: PAGE_SIZE
  }),
  getNextPageParam: (lastPage, allPages) =>
    lastPage.hasMore ? allPages.length : undefined,
})

// Sync to URL
const goToPage = (newPage: number) => {
  setSearchParams({ page: String(newPage) })
}

Integration with /wavybaby

与/wavybaby的集成

/wavybaby
automatically invokes CoVe for non-trivial tasks. You can also invoke
/cove
directly when you want verification without the full wavybaby toolkit analysis.
/wavybaby [task] → native dispatch + skill discovery + CoVe
/cove [task]     → just the 4-stage verification protocol

Now executing CoVe protocol for: $ARGUMENTS
/wavybaby
会针对非琐碎任务自动调用CoVe。你也可以直接调用
/cove
,仅使用四阶段验证协议而不进行完整的wavybaby工具包分析。
/wavybaby [task] → native dispatch + skill discovery + CoVe
/cove [task]     → just the 4-stage verification protocol

现在针对以下内容执行CoVe协议:$ARGUMENTS