pumuki 6.3.185 → 6.3.186

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/VERSION CHANGED
@@ -1 +1 @@
1
- v6.3.185
1
+ v6.3.186
@@ -11,6 +11,7 @@ import {
11
11
  hasKotlinGlobalScopeUsage,
12
12
  hasKotlinHardcodedBackgroundDispatcherUsage,
13
13
  hasKotlinLiveDataStateExposureUsage,
14
+ hasKotlinLifecycleScopeUsage,
14
15
  hasKotlinWithContextUsage,
15
16
  hasKotlinManualCoroutineScopeInViewModelUsage,
16
17
  hasKotlinRunBlockingUsage,
@@ -221,6 +222,31 @@ class SyncOrdersUseCase {
221
222
  assert.equal(hasKotlinWithContextUsage(source), false);
222
223
  });
223
224
 
225
+ test('hasKotlinLifecycleScopeUsage detecta lifecycleScope con llamadas encadenadas', () => {
226
+ const source = `
227
+ class SyncOrdersUseCase {
228
+ fun execute() {
229
+ lifecycleScope.launch { syncRemote() }
230
+ }
231
+ }
232
+ `;
233
+ assert.equal(hasKotlinLifecycleScopeUsage(source), true);
234
+ });
235
+
236
+ test('hasKotlinLifecycleScopeUsage ignora imports, comentarios, strings y nombres parciales', () => {
237
+ const source = `
238
+ import androidx.lifecycle.lifecycleScope
239
+ // lifecycleScope.launch { syncRemote() }
240
+ val sample = "lifecycleScope.launch { syncRemote() }"
241
+ class SyncOrdersUseCase {
242
+ fun execute() {
243
+ customLifecycleScope.launch { syncRemote() }
244
+ }
245
+ }
246
+ `;
247
+ assert.equal(hasKotlinLifecycleScopeUsage(source), false);
248
+ });
249
+
224
250
  test('hasKotlinSupervisorScopeUsage detecta supervisorScope con parentesis y llaves', () => {
225
251
  const parenthesesSource = `
226
252
  class SyncOrdersUseCase {
@@ -263,6 +263,10 @@ export const hasKotlinWithContextUsage = (source: string): boolean => {
263
263
  return collectKotlinRegexLines(source, /\bwithContext\s*(?:<[^>\n]+>\s*)?\(/).length > 0;
264
264
  };
265
265
 
266
+ export const hasKotlinLifecycleScopeUsage = (source: string): boolean => {
267
+ return collectKotlinRegexLines(source, /\blifecycleScope\s*\./).length > 0;
268
+ };
269
+
266
270
  export const hasKotlinSupervisorScopeUsage = (source: string): boolean => {
267
271
  return collectKotlinRegexLines(source, /\bsupervisorScope\s*(?:<[^>\n]+>\s*)?(?:\(|\{)/).length > 0;
268
272
  };
@@ -650,6 +650,7 @@ const textDetectorRegistry: ReadonlyArray<TextDetectorRegistryEntry> = [
650
650
  { platform: 'android', pathCheck: isAndroidNonPresentationKotlinPath, excludePaths: [isKotlinTestPath], detect: TextAndroid.hasKotlinDispatcherMainBoundaryLeakUsage, ruleId: 'heuristics.android.coroutines.dispatchers-main-boundary-leak.ast', code: 'HEURISTICS_ANDROID_COROUTINES_DISPATCHERS_MAIN_BOUNDARY_LEAK_AST', message: 'AST heuristic detected Dispatchers.Main outside Android presentation code.' },
651
651
  { platform: 'android', pathCheck: isAndroidDomainOrApplicationPath, excludePaths: [isKotlinTestPath], detect: TextAndroid.hasKotlinHardcodedBackgroundDispatcherUsage, ruleId: 'heuristics.android.coroutines.hardcoded-background-dispatcher.ast', code: 'HEURISTICS_ANDROID_COROUTINES_HARDCODED_BACKGROUND_DISPATCHER_AST', message: 'AST heuristic detected hard-coded Dispatchers.IO or Dispatchers.Default in Android domain/application code.' },
652
652
  { platform: 'android', pathCheck: isAndroidDomainOrApplicationPath, excludePaths: [isKotlinTestPath], detect: TextAndroid.hasKotlinWithContextUsage, ruleId: 'heuristics.android.coroutines.with-context.ast', code: 'HEURISTICS_ANDROID_COROUTINES_WITH_CONTEXT_AST', message: 'AST heuristic detected withContext usage in Android domain/application code.' },
653
+ { platform: 'android', pathCheck: isAndroidDomainOrApplicationPath, excludePaths: [isKotlinTestPath], detect: TextAndroid.hasKotlinLifecycleScopeUsage, ruleId: 'heuristics.android.coroutines.lifecycle-scope-boundary-leak.ast', code: 'HEURISTICS_ANDROID_COROUTINES_LIFECYCLE_SCOPE_BOUNDARY_LEAK_AST', message: 'AST heuristic detected lifecycleScope usage in Android domain/application code.' },
653
654
  { platform: 'android', pathCheck: isAndroidDomainOrApplicationPath, excludePaths: [isKotlinTestPath], detect: TextAndroid.hasKotlinSupervisorScopeUsage, ruleId: 'heuristics.android.coroutines.supervisor-scope.ast', code: 'HEURISTICS_ANDROID_COROUTINES_SUPERVISOR_SCOPE_AST', message: 'AST heuristic detected supervisorScope usage in Android domain/application code.' },
654
655
  { platform: 'android', pathCheck: isAndroidDomainOrApplicationPath, excludePaths: [isKotlinTestPath], detect: TextAndroid.hasKotlinCoroutineTryCatchUsage, ruleId: 'heuristics.android.coroutines.try-catch.ast', code: 'HEURISTICS_ANDROID_COROUTINES_TRY_CATCH_AST', message: 'AST heuristic detected try-catch handling in Android coroutine code.' },
655
656
  ];
@@ -3,7 +3,7 @@ import test from 'node:test';
3
3
  import { androidRules } from './android';
4
4
 
5
5
  test('androidRules define reglas heurísticas locked para plataforma android', () => {
6
- assert.equal(androidRules.length, 15);
6
+ assert.equal(androidRules.length, 16);
7
7
 
8
8
  const ids = androidRules.map((rule) => rule.id);
9
9
  assert.deepEqual(ids, [
@@ -15,6 +15,7 @@ test('androidRules define reglas heurísticas locked para plataforma android', (
15
15
  'heuristics.android.coroutines.dispatchers-main-boundary-leak.ast',
16
16
  'heuristics.android.coroutines.hardcoded-background-dispatcher.ast',
17
17
  'heuristics.android.coroutines.with-context.ast',
18
+ 'heuristics.android.coroutines.lifecycle-scope-boundary-leak.ast',
18
19
  'heuristics.android.coroutines.supervisor-scope.ast',
19
20
  'heuristics.android.coroutines.try-catch.ast',
20
21
  'heuristics.android.solid.srp.presentation-mixed-responsibilities.ast',
@@ -67,6 +68,10 @@ test('androidRules define reglas heurísticas locked para plataforma android', (
67
68
  byId.get('heuristics.android.coroutines.with-context.ast')?.then.code,
68
69
  'HEURISTICS_ANDROID_COROUTINES_WITH_CONTEXT_AST'
69
70
  );
71
+ assert.equal(
72
+ byId.get('heuristics.android.coroutines.lifecycle-scope-boundary-leak.ast')?.then.code,
73
+ 'HEURISTICS_ANDROID_COROUTINES_LIFECYCLE_SCOPE_BOUNDARY_LEAK_AST'
74
+ );
70
75
  assert.equal(
71
76
  byId.get('heuristics.android.coroutines.supervisor-scope.ast')?.then.code,
72
77
  'HEURISTICS_ANDROID_COROUTINES_SUPERVISOR_SCOPE_AST'
@@ -155,6 +155,26 @@ export const androidRules: RuleSet = [
155
155
  code: 'HEURISTICS_ANDROID_COROUTINES_WITH_CONTEXT_AST',
156
156
  },
157
157
  },
158
+ {
159
+ id: 'heuristics.android.coroutines.lifecycle-scope-boundary-leak.ast',
160
+ description:
161
+ 'Detects lifecycleScope usage in Android domain/application code where lifecycle ownership belongs to UI lifecycle owners.',
162
+ severity: 'WARN',
163
+ platform: 'android',
164
+ locked: true,
165
+ when: {
166
+ kind: 'Heuristic',
167
+ where: {
168
+ ruleId: 'heuristics.android.coroutines.lifecycle-scope-boundary-leak.ast',
169
+ },
170
+ },
171
+ then: {
172
+ kind: 'Finding',
173
+ message:
174
+ 'AST heuristic detected lifecycleScope usage in Android domain/application code.',
175
+ code: 'HEURISTICS_ANDROID_COROUTINES_LIFECYCLE_SCOPE_BOUNDARY_LEAK_AST',
176
+ },
177
+ },
158
178
  {
159
179
  id: 'heuristics.android.coroutines.supervisor-scope.ast',
160
180
  description:
@@ -127,9 +127,10 @@ app/
127
127
  ✅ `skills.android.guideline.android.viewmodelscope-scope-de-viewmodel-cancelado-automa-ticamente` debe mapear a señales ejecutables de scopes manuales dentro de `ViewModel`, empezando por `CoroutineScope(...)` construido en presentation.
128
128
  ✅ `skills.android.guideline.android.dispatchers-main-ui-io-network-disk-default-cpu` debe mapear a señales ejecutables de dispatchers mal ubicados: `Dispatchers.Main` fuera de `presentation` y `Dispatchers.IO` / `Dispatchers.Default` hardcodeados en `domain` o `application` en lugar de entrar por frontera inyectable.
129
129
  ✅ `skills.android.guideline.android.withcontext-cambiar-dispatcher` debe mapear a señal ejecutable de `withContext` en `domain` o `application`.
130
+ ✅ `skills.android.guideline.android.lifecyclescope-scope-de-activity-fragment` debe mapear a señal ejecutable de `lifecycleScope` fuera de la capa UI, empezando por `domain` o `application`.
130
131
  ✅ `skills.android.guideline.android.supervisorscope-errores-no-cancelan-otros-jobs` debe mapear a señal ejecutable de `supervisorScope` en `domain` o `application`.
131
132
  ✅ `skills.android.guideline.android.try-catch-manejo-de-errores-en-coroutines` debe mapear a señal ejecutable de `try/catch` dentro de código coroutine en `domain` o `application`.
132
- ✅ El baseline inicial de coroutines es parcial: cubre APIs bloqueantes, scopes no estructurados, scopes manuales en `ViewModel`, filtraciones de `Dispatchers.Main`, hardcode de dispatchers de background en dominio/aplicación, `withContext`, `supervisorScope` y `try/catch` en coroutines, pero no declara todavía cobertura completa de `Flow`, dispatchers ni cancelación cooperativa.
133
+ ✅ El baseline inicial de coroutines es parcial: cubre APIs bloqueantes, scopes no estructurados, scopes manuales en `ViewModel`, filtraciones de `Dispatchers.Main`, hardcode de dispatchers de background en dominio/aplicación, `withContext`, fuga de `lifecycleScope`, `supervisorScope` y `try/catch` en coroutines, pero no declara todavía cobertura completa de `Flow`, dispatchers ni cancelación cooperativa.
133
134
  ✅ Si se amplía esta cobertura, cada nueva regla debe aterrizar como detector AST/textual semántico con test dirigido antes de declararse cubierta en el registry.
134
135
 
135
136
  ### Enforcement AST inicial de Flow/StateFlow Android
@@ -235,6 +235,10 @@ const registryByRuleId: Record<string, SkillsDetectorBinding> = {
235
235
  'android.coroutines.with-context',
236
236
  ['heuristics.android.coroutines.with-context.ast']
237
237
  ),
238
+ 'skills.android.guideline.android.lifecyclescope-scope-de-activity-fragment': heuristicDetector(
239
+ 'android.coroutines.lifecycle-scope',
240
+ ['heuristics.android.coroutines.lifecycle-scope-boundary-leak.ast']
241
+ ),
238
242
  'skills.android.guideline.android.supervisorscope-errores-no-cancelan-otros-jobs': heuristicDetector(
239
243
  'android.coroutines.supervisor-scope',
240
244
  ['heuristics.android.coroutines.supervisor-scope.ast']
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pumuki",
3
- "version": "6.3.185",
3
+ "version": "6.3.186",
4
4
  "description": "Enterprise-grade AST Intelligence System with multi-platform support (iOS, Android, Backend, Frontend) and Feature-First + DDD + Clean Architecture enforcement. Includes dynamic violations API for intelligent querying.",
5
5
  "main": "index.js",
6
6
  "bin": {
package/skills.lock.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": "1.0",
3
3
  "compilerVersion": "1.0.0",
4
- "generatedAt": "2026-05-12T20:54:35.698Z",
4
+ "generatedAt": "2026-05-12T21:00:49.435Z",
5
5
  "bundles": [
6
6
  {
7
7
  "name": "android-guidelines",