mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-10 02:24:35 +08:00
feat: implement FlowExecutor for executing flow definitions with DAG traversal and node execution
This commit is contained in:
File diff suppressed because it is too large
Load Diff
391
.claude/commands/workflow/tools/code-validation-gate.md
Normal file
391
.claude/commands/workflow/tools/code-validation-gate.md
Normal file
@@ -0,0 +1,391 @@
|
||||
---
|
||||
name: code-validation-gate
|
||||
description: Validate AI-generated code for common errors (imports, variables, types) before test execution
|
||||
argument-hint: "--session WFS-test-session-id [--fix] [--strict]"
|
||||
examples:
|
||||
- /workflow:tools:code-validation-gate --session WFS-test-auth
|
||||
- /workflow:tools:code-validation-gate --session WFS-test-auth --fix
|
||||
- /workflow:tools:code-validation-gate --session WFS-test-auth --strict
|
||||
---
|
||||
|
||||
# Code Validation Gate Command
|
||||
|
||||
## Overview
|
||||
|
||||
Pre-test validation gate that checks AI-generated code for common errors before test execution. This prevents wasted test cycles on code with fundamental issues like import errors, variable conflicts, and type mismatches.
|
||||
|
||||
## Core Philosophy
|
||||
|
||||
- **Fail Fast**: Catch fundamental errors before expensive test execution
|
||||
- **AI-Aware**: Specifically targets common AI code generation mistakes
|
||||
- **Auto-Remediation**: Attempt safe fixes before failing
|
||||
- **Clear Feedback**: Provide actionable fix suggestions for manual intervention
|
||||
|
||||
## Target Error Categories
|
||||
|
||||
### L0.1: Compilation Errors
|
||||
- TypeScript compilation failures
|
||||
- Syntax errors
|
||||
- Module resolution failures
|
||||
|
||||
### L0.2: Import Errors
|
||||
- Unresolved module imports (hallucinated packages)
|
||||
- Circular dependencies
|
||||
- Duplicate imports
|
||||
- Unused imports
|
||||
|
||||
### L0.3: Variable Errors
|
||||
- Variable redeclaration
|
||||
- Scope conflicts (shadowing)
|
||||
- Undefined variable usage
|
||||
- Unused variables
|
||||
|
||||
### L0.4: Type Errors (TypeScript)
|
||||
- Type mismatches
|
||||
- Missing type definitions
|
||||
- Excessive `any` usage
|
||||
- Implicit `any` types
|
||||
|
||||
### L0.5: AI-Specific Patterns
|
||||
- Placeholder code (`// TODO: implement`)
|
||||
- Hallucinated package imports
|
||||
- Mock code in production files
|
||||
- Inconsistent naming patterns
|
||||
|
||||
## Execution Process
|
||||
|
||||
```
|
||||
Input Parsing:
|
||||
├─ Parse flags: --session (required), --fix, --strict
|
||||
└─ Load test-quality-config.json
|
||||
|
||||
Phase 1: Context Loading
|
||||
├─ Load session metadata
|
||||
├─ Identify target files (from IMPL-001 output or context-package)
|
||||
└─ Detect project configuration (tsconfig, eslint, etc.)
|
||||
|
||||
Phase 2: Validation Execution
|
||||
├─ L0.1: Run TypeScript compilation check
|
||||
├─ L0.2: Run import validation
|
||||
├─ L0.3: Run variable validation
|
||||
├─ L0.4: Run type validation
|
||||
└─ L0.5: Run AI-specific checks
|
||||
|
||||
Phase 3: Result Analysis
|
||||
├─ Aggregate all findings by severity
|
||||
├─ Calculate pass/fail status
|
||||
└─ Generate fix suggestions
|
||||
|
||||
Phase 4: Auto-Fix (if --fix enabled)
|
||||
├─ Apply safe auto-fixes (imports, formatting)
|
||||
├─ Re-run validation
|
||||
└─ Report remaining issues
|
||||
|
||||
Phase 5: Gate Decision
|
||||
├─ PASS: Proceed to IMPL-001.5
|
||||
├─ SOFT_FAIL: Auto-fix applied, needs re-validation
|
||||
└─ HARD_FAIL: Block with detailed report
|
||||
```
|
||||
|
||||
## Execution Lifecycle
|
||||
|
||||
### Phase 1: Context Loading
|
||||
|
||||
**Load session and identify validation targets.**
|
||||
|
||||
```javascript
|
||||
// Load session metadata
|
||||
Read(".workflow/active/{session_id}/workflow-session.json")
|
||||
|
||||
// Load context package for target files
|
||||
Read(".workflow/active/{session_id}/.process/context-package.json")
|
||||
// OR
|
||||
Read(".workflow/active/{session_id}/.process/test-context-package.json")
|
||||
|
||||
// Identify files to validate:
|
||||
// 1. Source files from context.implementation_files
|
||||
// 2. Test files from IMPL-001 output (if exists)
|
||||
// 3. All modified files since session start
|
||||
```
|
||||
|
||||
**Target File Discovery**:
|
||||
- Source files: `context.focus_paths` from context-package
|
||||
- Generated tests: `.workflow/active/{session_id}/.task/IMPL-001-output/`
|
||||
- All TypeScript/JavaScript in target directories
|
||||
|
||||
### Phase 2: Validation Execution
|
||||
|
||||
**Execute validation checks in order of dependency.**
|
||||
|
||||
#### L0.1: TypeScript Compilation
|
||||
|
||||
```bash
|
||||
# Primary check - catches most fundamental errors
|
||||
npx tsc --noEmit --skipLibCheck --project tsconfig.json 2>&1
|
||||
|
||||
# Parse output for errors
|
||||
# Critical: Any compilation error blocks further validation
|
||||
```
|
||||
|
||||
**Error Patterns**:
|
||||
```
|
||||
error TS2307: Cannot find module 'xxx'
|
||||
error TS2451: Cannot redeclare block-scoped variable 'xxx'
|
||||
error TS2322: Type 'xxx' is not assignable to type 'yyy'
|
||||
```
|
||||
|
||||
#### L0.2: Import Validation
|
||||
|
||||
```bash
|
||||
# Check for circular dependencies
|
||||
npx madge --circular --extensions ts,tsx,js,jsx {target_dirs}
|
||||
|
||||
# ESLint import rules
|
||||
npx eslint --rule 'import/no-duplicates: error' --rule 'import/no-unresolved: error' {files}
|
||||
```
|
||||
|
||||
**Hallucinated Package Check**:
|
||||
```javascript
|
||||
// Extract all imports from files
|
||||
// Verify each package exists in package.json or node_modules
|
||||
// Flag any unresolvable imports as "hallucinated"
|
||||
```
|
||||
|
||||
#### L0.3: Variable Validation
|
||||
|
||||
```bash
|
||||
# ESLint variable rules
|
||||
npx eslint --rule 'no-shadow: error' --rule 'no-undef: error' --rule 'no-redeclare: error' {files}
|
||||
```
|
||||
|
||||
#### L0.4: Type Validation
|
||||
|
||||
```bash
|
||||
# TypeScript strict checks
|
||||
npx tsc --noEmit --strict {files}
|
||||
|
||||
# Check for any abuse
|
||||
npx eslint --rule '@typescript-eslint/no-explicit-any: warn' {files}
|
||||
```
|
||||
|
||||
#### L0.5: AI-Specific Checks
|
||||
|
||||
```bash
|
||||
# Check for placeholder code
|
||||
grep -rn "// TODO: implement\|// Add your code here\|throw new Error.*Not implemented" {files}
|
||||
|
||||
# Check for mock code in production files
|
||||
grep -rn "jest\.mock\|sinon\.\|vi\.mock" {source_files_only}
|
||||
```
|
||||
|
||||
### Phase 3: Result Analysis
|
||||
|
||||
**Aggregate and categorize findings.**
|
||||
|
||||
```javascript
|
||||
const findings = {
|
||||
critical: [], // Blocks all progress
|
||||
error: [], // Blocks with threshold
|
||||
warning: [] // Advisory only
|
||||
};
|
||||
|
||||
// Apply thresholds from config
|
||||
const config = loadConfig("test-quality-config.json");
|
||||
const thresholds = config.code_validation.severity_thresholds;
|
||||
|
||||
// Gate decision
|
||||
if (findings.critical.length > thresholds.critical) {
|
||||
decision = "HARD_FAIL";
|
||||
} else if (findings.error.length > thresholds.error) {
|
||||
decision = "SOFT_FAIL"; // Try auto-fix
|
||||
} else {
|
||||
decision = "PASS";
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 4: Auto-Fix (Optional)
|
||||
|
||||
**Apply safe automatic fixes when --fix flag provided.**
|
||||
|
||||
```bash
|
||||
# Safe fixes only
|
||||
npx eslint --fix --rule 'import/no-duplicates: error' --rule 'unused-imports/no-unused-imports: error' {files}
|
||||
|
||||
# Re-run validation after fixes
|
||||
# Report what was fixed vs what remains
|
||||
```
|
||||
|
||||
**Safe Fix Categories**:
|
||||
- Remove unused imports
|
||||
- Remove duplicate imports
|
||||
- Fix import ordering
|
||||
- Remove unused variables (with caution)
|
||||
- Formatting fixes
|
||||
|
||||
**Unsafe (Manual Only)**:
|
||||
- Missing imports (need to determine correct package)
|
||||
- Type errors (need to understand intent)
|
||||
- Variable shadowing (need to understand scope intent)
|
||||
|
||||
### Phase 5: Gate Decision
|
||||
|
||||
**Determine next action based on results.**
|
||||
|
||||
| Decision | Condition | Action |
|
||||
|----------|-----------|--------|
|
||||
| **PASS** | critical=0, error<=3, warning<=10 | Proceed to IMPL-001.5 |
|
||||
| **SOFT_FAIL** | critical=0, error>3 OR fixable issues | Auto-fix and retry (max 2) |
|
||||
| **HARD_FAIL** | critical>0 OR max retries exceeded | Block with report |
|
||||
|
||||
## Output Artifacts
|
||||
|
||||
### Validation Report
|
||||
|
||||
**File**: `.workflow/active/{session_id}/.process/code-validation-report.md`
|
||||
|
||||
```markdown
|
||||
# Code Validation Report
|
||||
|
||||
**Session**: {session_id}
|
||||
**Timestamp**: {timestamp}
|
||||
**Status**: PASS | SOFT_FAIL | HARD_FAIL
|
||||
|
||||
## Summary
|
||||
- Files Validated: {count}
|
||||
- Critical Issues: {count}
|
||||
- Errors: {count}
|
||||
- Warnings: {count}
|
||||
|
||||
## Critical Issues (Must Fix)
|
||||
### Import Errors
|
||||
- `src/auth/service.ts:5` - Cannot find module 'non-existent-package'
|
||||
- **Suggestion**: Check if package exists, may be hallucinated by AI
|
||||
|
||||
### Variable Conflicts
|
||||
- `src/utils/helper.ts:12` - Cannot redeclare block-scoped variable 'config'
|
||||
- **Suggestion**: Rename one of the variables or merge declarations
|
||||
|
||||
## Errors (Should Fix)
|
||||
...
|
||||
|
||||
## Warnings (Consider Fixing)
|
||||
...
|
||||
|
||||
## Auto-Fix Applied
|
||||
- Removed 3 unused imports in `src/auth/service.ts`
|
||||
- Fixed import ordering in `src/utils/index.ts`
|
||||
|
||||
## Remaining Issues Requiring Manual Fix
|
||||
...
|
||||
|
||||
## Next Steps
|
||||
- [ ] Fix critical issues before proceeding
|
||||
- [ ] Review error suggestions
|
||||
- [ ] Re-run validation: `/workflow:tools:code-validation-gate --session {session_id}`
|
||||
```
|
||||
|
||||
### JSON Report (Machine-Readable)
|
||||
|
||||
**File**: `.workflow/active/{session_id}/.process/code-validation-report.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"session_id": "WFS-test-xxx",
|
||||
"timestamp": "2025-01-30T10:00:00Z",
|
||||
"status": "HARD_FAIL",
|
||||
"summary": {
|
||||
"files_validated": 15,
|
||||
"critical": 2,
|
||||
"error": 5,
|
||||
"warning": 8
|
||||
},
|
||||
"findings": {
|
||||
"critical": [
|
||||
{
|
||||
"category": "import",
|
||||
"file": "src/auth/service.ts",
|
||||
"line": 5,
|
||||
"message": "Cannot find module 'non-existent-package'",
|
||||
"suggestion": "Check if package exists in package.json",
|
||||
"auto_fixable": false
|
||||
}
|
||||
],
|
||||
"error": [...],
|
||||
"warning": [...]
|
||||
},
|
||||
"auto_fixes_applied": [...],
|
||||
"gate_decision": "HARD_FAIL",
|
||||
"retry_count": 0,
|
||||
"max_retries": 2
|
||||
}
|
||||
```
|
||||
|
||||
## Command Options
|
||||
|
||||
| Option | Description | Default |
|
||||
|--------|-------------|---------|
|
||||
| `--session` | Test session ID (required) | - |
|
||||
| `--fix` | Enable auto-fix for safe issues | false |
|
||||
| `--strict` | Use strict thresholds (0 errors allowed) | false |
|
||||
| `--files` | Specific files to validate (comma-separated) | All target files |
|
||||
| `--skip-types` | Skip TypeScript type checks | false |
|
||||
|
||||
## Integration
|
||||
|
||||
### Command Chain
|
||||
|
||||
- **Called By**: `/workflow:test-fix-gen` (after IMPL-001)
|
||||
- **Requires**: IMPL-001 output OR context-package.json
|
||||
- **Followed By**: IMPL-001.5 (Test Quality Gate) on PASS
|
||||
|
||||
### Task JSON Integration
|
||||
|
||||
When used in test-fix workflow, generates task:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "IMPL-001.3-validation",
|
||||
"meta": {
|
||||
"type": "code-validation",
|
||||
"agent": "@test-fix-agent"
|
||||
},
|
||||
"context": {
|
||||
"depends_on": ["IMPL-001"],
|
||||
"requirements": "Validate generated code for AI common errors"
|
||||
},
|
||||
"flow_control": {
|
||||
"validation_config": "~/.claude/workflows/test-quality-config.json",
|
||||
"max_retries": 2,
|
||||
"auto_fix_enabled": true
|
||||
},
|
||||
"acceptance_criteria": [
|
||||
"Zero critical issues",
|
||||
"Maximum 3 error issues",
|
||||
"All imports resolvable",
|
||||
"No variable redeclarations"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Error | Resolution |
|
||||
|-------|------------|
|
||||
| tsconfig.json not found | Use default compiler options |
|
||||
| ESLint not installed | Skip ESLint checks, use tsc only |
|
||||
| madge not installed | Skip circular dependency check |
|
||||
| No files to validate | Return PASS (nothing to check) |
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Run Early**: Execute validation immediately after code generation
|
||||
2. **Use --fix First**: Let auto-fix resolve trivial issues
|
||||
3. **Review Suggestions**: AI fix suggestions may need human judgment
|
||||
4. **Don't Skip Critical**: Never proceed with critical errors
|
||||
5. **Track Patterns**: Common failures indicate prompt improvement opportunities
|
||||
|
||||
## Related Commands
|
||||
|
||||
- `/workflow:test-fix-gen` - Parent workflow that invokes this command
|
||||
- `/workflow:tools:test-quality-gate` - Next phase (IMPL-001.5) for test quality
|
||||
- `/workflow:test-cycle-execute` - Execute tests after validation passes
|
||||
@@ -143,7 +143,7 @@ Determine CLI tool usage per-step based on user's task description:
|
||||
(Detailed specifications in your agent definition)
|
||||
|
||||
### Task Structure Requirements
|
||||
- Minimum 2 tasks: IMPL-001 (test generation) + IMPL-002 (test execution & fix)
|
||||
- Minimum 4 tasks: IMPL-001 (test generation) + IMPL-001.3 (code validation) + IMPL-001.5 (test quality) + IMPL-002 (test execution & fix)
|
||||
- Expandable for complex projects: Add IMPL-003+ (per-module, integration, E2E tests)
|
||||
|
||||
Task Configuration:
|
||||
@@ -154,9 +154,29 @@ Task Configuration:
|
||||
- flow_control: Test generation strategy from TEST_ANALYSIS_RESULTS.md
|
||||
- CLI execution: Add `command` field when user requests (determined semantically)
|
||||
|
||||
IMPL-001.3 (Code Validation Gate) ← NEW:
|
||||
- meta.type: "code-validation"
|
||||
- meta.agent: "@test-fix-agent"
|
||||
- context.depends_on: ["IMPL-001"]
|
||||
- context.validation_config: "~/.claude/workflows/test-quality-config.json"
|
||||
- flow_control.validation_phases: ["compilation", "imports", "variables", "types", "ai_specific"]
|
||||
- flow_control.auto_fix_enabled: true
|
||||
- flow_control.max_retries: 2
|
||||
- flow_control.severity_thresholds: { critical: 0, error: 3, warning: 10 }
|
||||
- acceptance_criteria: Zero compilation errors, all imports resolvable, no variable redeclarations
|
||||
|
||||
IMPL-001.5 (Test Quality Gate):
|
||||
- meta.type: "test-quality-review"
|
||||
- meta.agent: "@test-fix-agent"
|
||||
- context.depends_on: ["IMPL-001", "IMPL-001.3"]
|
||||
- context.quality_config: "~/.claude/workflows/test-quality-config.json"
|
||||
- flow_control: Static analysis, coverage analysis, anti-pattern detection
|
||||
- acceptance_criteria: Coverage ≥ 80%, zero critical anti-patterns
|
||||
|
||||
IMPL-002+ (Test Execution & Fix):
|
||||
- meta.type: "test-fix"
|
||||
- meta.agent: "@test-fix-agent"
|
||||
- context.depends_on: ["IMPL-001", "IMPL-001.3", "IMPL-001.5"]
|
||||
- flow_control: Test-fix cycle with iteration limits and diagnosis configuration
|
||||
- CLI execution: Add `command` field when user requests (determined semantically)
|
||||
|
||||
@@ -190,10 +210,17 @@ PRIMARY requirements source - extract and map to task JSONs:
|
||||
- Implementation targets → context.files_to_test (absolute paths)
|
||||
|
||||
## EXPECTED DELIVERABLES
|
||||
1. Test Task JSON Files (.task/IMPL-*.json)
|
||||
1. Test Task JSON Files (.task/IMPL-*.json) - Minimum 4 required:
|
||||
- IMPL-001.json: Test generation task
|
||||
- IMPL-001.3-validation.json: Code validation gate (AI error detection) ← NEW
|
||||
- IMPL-001.5-review.json: Test quality gate
|
||||
- IMPL-002.json: Test execution & fix cycle
|
||||
|
||||
Each task includes:
|
||||
- 6-field schema with quantified requirements from TEST_ANALYSIS_RESULTS.md
|
||||
- Test-specific metadata: type, agent, test_framework, coverage_target
|
||||
- flow_control includes: reusable_test_tools, test_commands (from project config)
|
||||
- Validation config reference for IMPL-001.3: ~/.claude/workflows/test-quality-config.json
|
||||
- CLI execution via `command` field when user requests (determined semantically)
|
||||
- Artifact references from test-context-package.json
|
||||
- Absolute paths in context.files_to_test
|
||||
@@ -211,7 +238,7 @@ PRIMARY requirements source - extract and map to task JSONs:
|
||||
|
||||
## QUALITY STANDARDS
|
||||
Hard Constraints:
|
||||
- Task count: minimum 2, maximum 18
|
||||
- Task count: minimum 4, maximum 18 (IMPL-001, IMPL-001.3, IMPL-001.5, IMPL-002 required)
|
||||
- All requirements quantified from TEST_ANALYSIS_RESULTS.md
|
||||
- Test framework matches existing project framework
|
||||
- flow_control includes reusable_test_tools and test_commands from project
|
||||
@@ -249,7 +276,11 @@ CLI tool usage is determined semantically from user's task description:
|
||||
- Default: Agent execution (no `command` field)
|
||||
|
||||
### Output
|
||||
- Test task JSON files in `.task/` directory (minimum 2)
|
||||
- IMPL_PLAN.md with test strategy and fix cycle specification
|
||||
- Test task JSON files in `.task/` directory (minimum 4):
|
||||
- IMPL-001.json (test generation)
|
||||
- IMPL-001.3-validation.json (code validation gate)
|
||||
- IMPL-001.5-review.json (test quality gate)
|
||||
- IMPL-002.json (test execution & fix)
|
||||
- IMPL_PLAN.md with test strategy, validation gates, and fix cycle specification
|
||||
- TODO_LIST.md with test phase indicators
|
||||
- Session ready for test execution
|
||||
|
||||
251
.claude/workflows/test-quality-config.json
Normal file
251
.claude/workflows/test-quality-config.json
Normal file
@@ -0,0 +1,251 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"version": "1.0.0",
|
||||
"description": "Test quality and code validation configuration for AI-generated code",
|
||||
|
||||
"code_validation": {
|
||||
"description": "Pre-test validation for AI-generated code common errors",
|
||||
"enabled": true,
|
||||
"phases": {
|
||||
"L0_compilation": {
|
||||
"description": "TypeScript/JavaScript compilation check",
|
||||
"enabled": true,
|
||||
"commands": {
|
||||
"typescript": "npx tsc --noEmit --skipLibCheck",
|
||||
"javascript": "node --check"
|
||||
},
|
||||
"critical": true,
|
||||
"failure_blocks_tests": true
|
||||
},
|
||||
"L0_imports": {
|
||||
"description": "Import statement validation",
|
||||
"enabled": true,
|
||||
"checks": [
|
||||
{
|
||||
"id": "unresolved_imports",
|
||||
"description": "Check for unresolved module imports",
|
||||
"pattern": "Cannot find module|Module not found|Unable to resolve",
|
||||
"severity": "critical"
|
||||
},
|
||||
{
|
||||
"id": "circular_imports",
|
||||
"description": "Check for circular dependencies",
|
||||
"tool": "madge",
|
||||
"command": "npx madge --circular --extensions ts,tsx,js,jsx",
|
||||
"severity": "warning"
|
||||
},
|
||||
{
|
||||
"id": "duplicate_imports",
|
||||
"description": "Check for duplicate imports",
|
||||
"eslint_rule": "import/no-duplicates",
|
||||
"severity": "error"
|
||||
},
|
||||
{
|
||||
"id": "unused_imports",
|
||||
"description": "Check for unused imports",
|
||||
"eslint_rule": "unused-imports/no-unused-imports",
|
||||
"severity": "warning"
|
||||
}
|
||||
]
|
||||
},
|
||||
"L0_variables": {
|
||||
"description": "Variable declaration validation",
|
||||
"enabled": true,
|
||||
"checks": [
|
||||
{
|
||||
"id": "redeclaration",
|
||||
"description": "Check for variable redeclaration",
|
||||
"pattern": "Cannot redeclare|Duplicate identifier|has already been declared",
|
||||
"severity": "critical"
|
||||
},
|
||||
{
|
||||
"id": "scope_conflict",
|
||||
"description": "Check for scope conflicts",
|
||||
"eslint_rule": "no-shadow",
|
||||
"severity": "error"
|
||||
},
|
||||
{
|
||||
"id": "undefined_vars",
|
||||
"description": "Check for undefined variables",
|
||||
"eslint_rule": "no-undef",
|
||||
"severity": "critical"
|
||||
},
|
||||
{
|
||||
"id": "unused_vars",
|
||||
"description": "Check for unused variables",
|
||||
"eslint_rule": "@typescript-eslint/no-unused-vars",
|
||||
"severity": "warning"
|
||||
}
|
||||
]
|
||||
},
|
||||
"L0_types": {
|
||||
"description": "TypeScript type validation",
|
||||
"enabled": true,
|
||||
"checks": [
|
||||
{
|
||||
"id": "type_mismatch",
|
||||
"description": "Check for type mismatches",
|
||||
"pattern": "Type .* is not assignable to type",
|
||||
"severity": "critical"
|
||||
},
|
||||
{
|
||||
"id": "missing_types",
|
||||
"description": "Check for missing type definitions",
|
||||
"pattern": "Could not find a declaration file",
|
||||
"severity": "warning"
|
||||
},
|
||||
{
|
||||
"id": "any_abuse",
|
||||
"description": "Check for excessive any type usage",
|
||||
"eslint_rule": "@typescript-eslint/no-explicit-any",
|
||||
"severity": "warning",
|
||||
"max_occurrences": 5
|
||||
},
|
||||
{
|
||||
"id": "implicit_any",
|
||||
"description": "Check for implicit any",
|
||||
"pattern": "implicitly has an 'any' type",
|
||||
"severity": "error"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"severity_thresholds": {
|
||||
"critical": 0,
|
||||
"error": 3,
|
||||
"warning": 10
|
||||
},
|
||||
"max_retries": 2,
|
||||
"auto_fix": {
|
||||
"enabled": true,
|
||||
"safe_fixes_only": true,
|
||||
"fixable_categories": ["imports", "formatting", "unused_vars"]
|
||||
}
|
||||
},
|
||||
|
||||
"test_quality": {
|
||||
"description": "Test file quality validation (IMPL-001.5)",
|
||||
"enabled": true,
|
||||
"coverage": {
|
||||
"minimum_threshold": 80,
|
||||
"branch_threshold": 70,
|
||||
"function_threshold": 80,
|
||||
"line_threshold": 80
|
||||
},
|
||||
"anti_patterns": {
|
||||
"empty_test_body": {
|
||||
"pattern": "it\\(['\"].*['\"],\\s*\\(\\)\\s*=>\\s*\\{\\s*\\}\\)",
|
||||
"severity": "critical",
|
||||
"description": "Test with empty body"
|
||||
},
|
||||
"missing_assertion": {
|
||||
"pattern": "it\\(['\"].*['\"],.*\\{[^}]*\\}\\)(?![\\s\\S]*expect)",
|
||||
"severity": "critical",
|
||||
"description": "Test without expect() assertion"
|
||||
},
|
||||
"skipped_without_reason": {
|
||||
"pattern": "(it|describe)\\.skip\\(['\"][^'\"]*['\"](?!.*\\/\\/ )",
|
||||
"severity": "error",
|
||||
"description": "Skipped test without comment explaining why"
|
||||
},
|
||||
"todo_test": {
|
||||
"pattern": "(it|test)\\.todo\\(",
|
||||
"severity": "warning",
|
||||
"description": "TODO test placeholder"
|
||||
},
|
||||
"only_test": {
|
||||
"pattern": "(it|describe)\\.only\\(",
|
||||
"severity": "critical",
|
||||
"description": "Focused test (will skip other tests)"
|
||||
}
|
||||
},
|
||||
"required_test_types": {
|
||||
"unit": {
|
||||
"min_per_function": 1,
|
||||
"must_include": ["happy_path"]
|
||||
},
|
||||
"negative": {
|
||||
"min_per_public_api": 1,
|
||||
"description": "Error handling tests for public APIs"
|
||||
},
|
||||
"edge_case": {
|
||||
"required_scenarios": ["null", "undefined", "empty_string", "empty_array", "boundary_values"]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"ai_specific_checks": {
|
||||
"description": "Checks specifically for AI-generated code patterns",
|
||||
"enabled": true,
|
||||
"checks": [
|
||||
{
|
||||
"id": "hallucinated_imports",
|
||||
"description": "Check for imports of non-existent packages",
|
||||
"validation": "npm_package_exists",
|
||||
"severity": "critical"
|
||||
},
|
||||
{
|
||||
"id": "inconsistent_naming",
|
||||
"description": "Check for naming inconsistencies within file",
|
||||
"pattern": "function (\\w+).*\\1(?!\\()",
|
||||
"severity": "warning"
|
||||
},
|
||||
{
|
||||
"id": "placeholder_code",
|
||||
"description": "Check for AI placeholder comments",
|
||||
"patterns": [
|
||||
"// TODO: implement",
|
||||
"// Add your code here",
|
||||
"// Implementation pending",
|
||||
"throw new Error\\(['\"]Not implemented['\"]\\)"
|
||||
],
|
||||
"severity": "error"
|
||||
},
|
||||
{
|
||||
"id": "mock_in_production",
|
||||
"description": "Check for mock/stub code in production files",
|
||||
"patterns": [
|
||||
"jest\\.mock\\(",
|
||||
"sinon\\.",
|
||||
"vi\\.mock\\("
|
||||
],
|
||||
"exclude_paths": ["**/*.test.*", "**/*.spec.*", "**/test/**", "**/__tests__/**"],
|
||||
"severity": "critical"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"validation_commands": {
|
||||
"typescript_check": {
|
||||
"command": "npx tsc --noEmit --skipLibCheck",
|
||||
"timeout": 60000,
|
||||
"parse_errors": true
|
||||
},
|
||||
"eslint_check": {
|
||||
"command": "npx eslint --format json",
|
||||
"timeout": 60000,
|
||||
"auto_fix_command": "npx eslint --fix"
|
||||
},
|
||||
"circular_deps_check": {
|
||||
"command": "npx madge --circular --extensions ts,tsx,js,jsx",
|
||||
"timeout": 30000
|
||||
},
|
||||
"package_validation": {
|
||||
"command": "npm ls --json",
|
||||
"timeout": 30000
|
||||
}
|
||||
},
|
||||
|
||||
"gate_decisions": {
|
||||
"pass_criteria": {
|
||||
"critical_issues": 0,
|
||||
"error_issues": "<=3",
|
||||
"warning_issues": "<=10"
|
||||
},
|
||||
"actions": {
|
||||
"pass": "Proceed to IMPL-001.5 (Test Quality Gate)",
|
||||
"soft_fail": "Auto-fix and retry (max 2 attempts)",
|
||||
"hard_fail": "Block and report to user with fix suggestions"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user