@boyingliu01/xp-gate 0.9.5 → 0.10.1

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.
@@ -101,4 +101,64 @@ run_coverage() {
101
101
  fi
102
102
 
103
103
  return $PYTEST_EXIT
104
- }
104
+ }
105
+ # ── Gate M: Python mutation testing (mutmut) ──
106
+
107
+ run_mutation() {
108
+ local files_arg="$1"
109
+ local timeout_ms="${2:-120000}"
110
+ local timeout_s=$((timeout_ms / 1000))
111
+
112
+ if ! detect_python_mutation_testable; then
113
+ echo "⚠ mutmut not installed. SKIP — Gate M (Python)."
114
+ return 0
115
+ fi
116
+
117
+ # Parse comma-separated file list into mutmut --paths-to-mulate args
118
+ local file_list=""
119
+ IFS=',' read -ra FILE_ARRAY <<< "$files_arg"
120
+ for f in "${FILE_ARRAY[@]}"; do
121
+ f=$(echo "$f" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
122
+ [ -f "$f" ] && file_list="$file_list $f"
123
+ done
124
+
125
+ if [ -z "$file_list" ]; then
126
+ echo "📚 No valid Python source files for mutation. SKIP — Gate M (Python)."
127
+ return 0
128
+ fi
129
+
130
+ echo "🐍 Running Python mutation testing (mutmut) on: $file_list"
131
+
132
+ # Gate M orchestrator (TypeScript) handles mutmut via MutmutRunner in src/mutation/runners/
133
+ # The shell adapter delegates to the TS runner for consistency with TS Gate M.
134
+ if [ -f "src/mutation/gate-m.ts" ]; then
135
+ timeout "${timeout_s}s" npx tsx src/mutation/gate-m.ts \
136
+ --changed-files "$files_arg" 2>&1
137
+ return $?
138
+ fi
139
+
140
+ # Fallback: direct mutmut CLI if TS gate module not available
141
+ local MUTATION_OUTPUT
142
+ MUTATION_OUTPUT=$(mktemp)
143
+
144
+ timeout "${timeout_s}s" mutmut run --paths-to-mutate $file_list > "$MUTATION_OUTPUT" 2>&1
145
+ local EXIT_CODE=$?
146
+
147
+ cat "$MUTATION_OUTPUT"
148
+ rm -f "$MUTATION_OUTPUT"
149
+
150
+ case $EXIT_CODE in
151
+ 0)
152
+ echo "✅ Gate M (Python): PASS"
153
+ return 0
154
+ ;;
155
+ 124)
156
+ echo "⏱ Gate M (Python): TIMEOUT (${timeout_s}s). Allowing push with warning."
157
+ return 0
158
+ ;;
159
+ *)
160
+ echo "❌ Gate M (Python): mutation score below threshold"
161
+ return 1
162
+ ;;
163
+ esac
164
+ }
@@ -1,9 +1,9 @@
1
1
  # SRC/MOCK-POLICY KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-06-21
4
- **Commit:** 1050a30
3
+ **Generated:** 2026-06-22
4
+ **Commit:** 448ac7e
5
5
  **Branch:** main
6
- **Version:** 0.9.5.0
6
+ **Version:** 0.10.1.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Mock layering policy enforcement — Gate M3 of pre-push hook. Ensures integration tests use real implementations for internal dependencies, mock external dependencies, and annotate pending mocks with removal plans. Combines project scope scanning, mock decision engine, and per-file validation into a single pipeline.
@@ -1,9 +1,9 @@
1
1
  # SRC/MUTATION KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-06-21
4
- **Commit:** 1050a30
3
+ **Generated:** 2026-06-22
4
+ **Commit:** 448ac7e
5
5
  **Branch:** main
6
- **Version:** 0.9.5.0
6
+ **Version:** 0.10.1.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **Gate M** (incremental mutation testing) + **Gate M2** helpers (test-layer detection used by `src/mock-policy/`). Pre-push quality gate. TypeScript-only; uses Stryker.