ctxtop 4.0.0 → 4.1.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.
Files changed (89) hide show
  1. package/.antigravity-plugin/plugin.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHECKSUMS.sha256 +59 -42
  4. package/README.md +351 -330
  5. package/bin/ah-statusline.mjs +30 -0
  6. package/bin/ctxtop.mjs +330 -5
  7. package/config/default_flightcheck.json +19 -0
  8. package/config/modelCatalog.json +165 -0
  9. package/hooks/handlers/compact-lifecycle.mjs +323 -8
  10. package/hooks/handlers/config-change.mjs +402 -0
  11. package/hooks/handlers/hookIo.mjs +56 -0
  12. package/hooks/handlers/post-model-switch.mjs +111 -0
  13. package/hooks/handlers/post-tool-use.mjs +117 -16
  14. package/hooks/handlers/pre-model-switch.mjs +823 -24
  15. package/hooks/handlers/pre-tool-use.mjs +271 -4
  16. package/hooks/handlers/stop-gate.mjs +297 -11
  17. package/hooks/handlers/user-prompt-submit.mjs +224 -0
  18. package/hooks/hooks.json +50 -0
  19. package/hooks/post_tool_use.mjs +8 -0
  20. package/hooks/register.js +48 -9
  21. package/hooks/session_start.mjs +11 -1
  22. package/hooks/stop.mjs +11 -1
  23. package/package.json +11 -4
  24. package/packages/antigravity/package.json +1 -1
  25. package/packages/claude-code/package.json +1 -1
  26. package/packages/core/package.json +1 -1
  27. package/packages/engine-node/package.json +1 -1
  28. package/packages/mcp/package.json +1 -1
  29. package/packages/mcp/src/server.mjs +1 -1
  30. package/packages/pro/package.json +1 -1
  31. package/plugin.json +1 -1
  32. package/sidecars/horizon-daemon/server.mjs +38 -2
  33. package/skills/handoff/SKILL.md +8 -0
  34. package/src/adapters/antigravity/index.mjs +31 -1
  35. package/src/adapters/claude-code/index.mjs +40 -1
  36. package/src/cli/horizon_hud.mjs +254 -52
  37. package/src/config/modelCatalog.json +84 -0
  38. package/src/core/bucket_b_runtime.mjs +1200 -0
  39. package/src/core/constants.mjs +191 -4
  40. package/src/core/detectors_det01_to_16.mjs +54 -5
  41. package/src/core/doc_indexer.mjs +338 -0
  42. package/src/core/layer5_hygiene.mjs +118 -0
  43. package/src/core/parser.mjs +2 -1
  44. package/src/core/paths.mjs +3 -2
  45. package/src/core/rsl_clash_auditor.mjs +423 -0
  46. package/src/core/rsl_distiller.mjs +372 -0
  47. package/src/core/rsl_ledger.mjs +969 -0
  48. package/src/core/rsl_triage.mjs +909 -0
  49. package/src/core/session_auditor.mjs +658 -0
  50. package/src/core/shield_manager.mjs +1417 -0
  51. package/src/core/task_quota_router.mjs +1 -1
  52. package/src/core-isomorphic/coach/cacheGravityRouter.mjs +874 -47
  53. package/src/core-isomorphic/coach/resumeToolsetAuditor.mjs +321 -0
  54. package/src/core-isomorphic/coach/smartCompactAdvisor.mjs +305 -0
  55. package/src/core-isomorphic/coach/ttlWatchdog.mjs +13 -6
  56. package/src/core-isomorphic/config/anthropicModelCatalog.json +404 -1
  57. package/src/core-isomorphic/config/catalogLoader.mjs +546 -46
  58. package/src/core-isomorphic/config/horizonConfig.mjs +47 -1
  59. package/src/core-isomorphic/diagnostics/prompt_hygiene_governor.mjs +266 -0
  60. package/src/core-isomorphic/economics/cacheGravity.mjs +18 -0
  61. package/src/core-isomorphic/economics/cliffBreaker.mjs +98 -12
  62. package/src/core-isomorphic/economics/driftLatency.mjs +114 -0
  63. package/src/core-isomorphic/guards/bucketBAlphaBeta.mjs +860 -0
  64. package/src/core-isomorphic/guards/bucketBGamma.mjs +442 -0
  65. package/src/core-isomorphic/guards/bucketBHeuristics.mjs +37 -0
  66. package/src/core-isomorphic/guards/circuitBreakers.mjs +191 -191
  67. package/src/core-isomorphic/guards/det01_03_shell_secret.mjs +154 -5
  68. package/src/core-isomorphic/guards/det04_12_thrash_rot.mjs +103 -11
  69. package/src/core-isomorphic/guards/det13_20_mcp_scope.mjs +311 -1
  70. package/src/core-isomorphic/guards/docIndexCore.mjs +446 -0
  71. package/src/core-isomorphic/guards/losslessPostSanitizer.mjs +16 -0
  72. package/src/core-isomorphic/guards/slopsquatGate.mjs +551 -0
  73. package/src/core-isomorphic/index.js +1 -0
  74. package/src/core-isomorphic/telemetry/telemetryBridge.mjs +36 -12
  75. package/src/core-isomorphic/ui/horizonPanelHtml.mjs +293 -237
  76. package/src/core-isomorphic/ui/modViews.mjs +35 -9
  77. package/src/diagnostics/claudeHookCapabilities.mjs +396 -0
  78. package/src/diagnostics/doctorEngine.mjs +95 -3
  79. package/src/engine-node/db/probe.mjs +234 -2
  80. package/src/engine-node/index.mjs +3 -0
  81. package/src/engine-node/sensors/blindspots.mjs +13 -6
  82. package/src/hooks/antigravity_rsl_hook.mjs +250 -0
  83. package/src/hooks/claude_rsl_hook.mjs +288 -0
  84. package/src/hooks/post_invocation.mjs +196 -4
  85. package/src/hooks/pre_invocation.mjs +732 -22
  86. package/src/hooks/session_start.mjs +39 -1
  87. package/src/utils/modelSwitchTelemetry.mjs +308 -0
  88. package/src/utils/sessionCalibration.mjs +657 -0
  89. package/src/webview/horizon_panel.html +1325 -317
@@ -411,6 +411,45 @@ function splitEnvKeyValToken(token = '') {
411
411
  return { key: m[1], value: m[2] };
412
412
  }
413
413
 
414
+ /**
415
+ * Checks whether the user's prompt explicitly requested modifying, deleting, or skipping tests.
416
+ * @param {string} [promptText='']
417
+ * @returns {boolean}
418
+ */
419
+ export function hasExplicitTestModifyIntent(promptText = '') {
420
+ const s = String(promptText || '');
421
+ if (!s) return false;
422
+ return (
423
+ /\b(?:edit|update|modify|delete|remove|drop|skip|disable|rewrite|adjust|refactor)\s+(?:(?:the|all|any|some|these|those|existing|failing|obsolete|legacy|old|broken|flaky|unit|integration|e2e)\s+)*(?:tests?|specs?|assertions?)\b/i.test(
424
+ s
425
+ ) ||
426
+ (/\.(?:test|spec)\.[a-z0-9]+\b/i.test(s) &&
427
+ /\b(?:delete|remove|drop|skip|disable|update|rewrite)\b/i.test(s))
428
+ );
429
+ }
430
+
431
+ /**
432
+ * Checks whether a shell argument token points to a repository test file (excluding temp/cache paths).
433
+ * @param {string} [token='']
434
+ * @returns {boolean}
435
+ */
436
+ function isProtectedTestFileToken(token = '') {
437
+ const norm = String(token || '').trim().replace(/^['"]|['"]$/g, '').replace(/\\/g, '/');
438
+ if (!norm) return false;
439
+ if (
440
+ /^(?:\/tmp\/|\/var\/folders\/)/i.test(norm) ||
441
+ /(?:^|\/)(?:tmp|temp|\.claude\/cache|\.agents\/tmp)\//i.test(norm) ||
442
+ /appdata\/local\/temp\//i.test(norm)
443
+ ) {
444
+ return false;
445
+ }
446
+ return (
447
+ /\.(?:test|spec)\.(?:[cm]?[jt]sx?|py|go|rs)$/i.test(norm) ||
448
+ /(?:^|\/)(?:test|tests|__tests__)\/.*\.(?:[cm]?[jt]sx?|py|go|rs)$/i.test(norm) ||
449
+ /_test\.(?:py|go)$/i.test(norm)
450
+ );
451
+ }
452
+
414
453
  /**
415
454
  * DET-01: Destructive Shell & Git Hook-Bypass Blocker (`Bash|PowerShell`).
416
455
  * Strictly skips option arguments (such as `-m "-next..."`, `-m "Fix HUSKY=0"`, `-F`, `-c`, `--author`),
@@ -585,11 +624,19 @@ export function evaluateDet01GitAndShellSafety(params = {}, _depth = 0) {
585
624
  }
586
625
 
587
626
  // 2f. Nested shell wrappers (`bash -c "..."`, `sh -c "..."`, `cmd /c "..."`, `pwsh -Command "..."`)
627
+ const userExplicitTestIntent =
628
+ Boolean(params.userExplicitTestIntent) ||
629
+ hasExplicitTestModifyIntent(params.lastUserInput || params.prompt || '');
588
630
  if (['bash', 'bash.exe', 'sh', 'sh.exe', 'zsh', 'dash'].includes(bin)) {
589
631
  const cPos = rawTokens.findIndex((t, ti) => ti > idx && (t === '-c' || /^-[a-zA-Z]*c$/.test(t)));
590
632
  if (cPos !== -1 && rawTokens[cPos + 1]) {
591
633
  const nested = evaluateDet01GitAndShellSafety(
592
- { toolName: 'Bash', command: rawTokens[cPos + 1] },
634
+ {
635
+ toolName: 'Bash',
636
+ command: rawTokens[cPos + 1],
637
+ userExplicitTestIntent,
638
+ lastUserInput: params.lastUserInput || params.prompt || ''
639
+ },
593
640
  _depth + 1
594
641
  );
595
642
  if (nested.triggered) return nested;
@@ -601,7 +648,12 @@ export function evaluateDet01GitAndShellSafety(params = {}, _depth = 0) {
601
648
  if (cPos !== -1 && cPos + 1 < rawTokens.length) {
602
649
  const nestedCmd = rawTokens.slice(cPos + 1).join(' ');
603
650
  const nested = evaluateDet01GitAndShellSafety(
604
- { toolName: 'cmd', command: nestedCmd },
651
+ {
652
+ toolName: 'cmd',
653
+ command: nestedCmd,
654
+ userExplicitTestIntent,
655
+ lastUserInput: params.lastUserInput || params.prompt || ''
656
+ },
605
657
  _depth + 1
606
658
  );
607
659
  if (nested.triggered) return nested;
@@ -613,7 +665,12 @@ export function evaluateDet01GitAndShellSafety(params = {}, _depth = 0) {
613
665
  if (cPos !== -1 && cPos + 1 < rawTokens.length) {
614
666
  const nestedCmd = rawTokens.slice(cPos + 1).join(' ');
615
667
  const nested = evaluateDet01GitAndShellSafety(
616
- { toolName: 'PowerShell', command: nestedCmd },
668
+ {
669
+ toolName: 'PowerShell',
670
+ command: nestedCmd,
671
+ userExplicitTestIntent,
672
+ lastUserInput: params.lastUserInput || params.prompt || ''
673
+ },
617
674
  _depth + 1
618
675
  );
619
676
  if (nested.triggered) return nested;
@@ -621,8 +678,8 @@ export function evaluateDet01GitAndShellSafety(params = {}, _depth = 0) {
621
678
  continue;
622
679
  }
623
680
 
624
- // 2g. Destructive filesystem wipe commands on tokenized segment (`rm -rf /`, `Remove-Item -Recurse -Force C:\`)
625
- if (bin === 'rm' || bin === 'rm.exe') {
681
+ // 2g. Destructive filesystem wipe commands & Test File Deletion Lock (#3)
682
+ if (bin === 'rm' || bin === 'rm.exe' || bin === 'unlink' || bin === 'unlink.exe') {
626
683
  const rmArgs = rawTokens.slice(idx + 1);
627
684
  const hasRecursive = rmArgs.some(
628
685
  (a) => a === '--recursive' || (/^-[a-zA-Z]+$/.test(a) && /[rR]/.test(a))
@@ -642,6 +699,20 @@ export function evaluateDet01GitAndShellSafety(params = {}, _depth = 0) {
642
699
  reason: `[DET-01 Destructive Shell Blocked] Recursive root/home deletion is forbidden.`
643
700
  };
644
701
  }
702
+ if (!userExplicitTestIntent) {
703
+ const deletedTestTarget = rmArgs.find(
704
+ (a) => !a.startsWith('-') && isProtectedTestFileToken(a)
705
+ );
706
+ if (deletedTestTarget) {
707
+ return {
708
+ detectorId: 'DET-01',
709
+ triggered: true,
710
+ decision: 'deny',
711
+ subType: 'TEST_FILE_DELETION',
712
+ reason: `[DET-01 Test Integrity Lock (#3)] Deleting test file "${deletedTestTarget}" via shell without explicit user instruction is forbidden.`
713
+ };
714
+ }
715
+ }
645
716
  continue;
646
717
  }
647
718
 
@@ -661,6 +732,20 @@ export function evaluateDet01GitAndShellSafety(params = {}, _depth = 0) {
661
732
  reason: `[DET-01 Destructive Shell Blocked] Recursive root/home deletion is forbidden.`
662
733
  };
663
734
  }
735
+ if (!userExplicitTestIntent) {
736
+ const deletedTestTarget = psArgs.find(
737
+ (a) => !a.startsWith('-') && !a.startsWith('/') && isProtectedTestFileToken(a)
738
+ );
739
+ if (deletedTestTarget) {
740
+ return {
741
+ detectorId: 'DET-01',
742
+ triggered: true,
743
+ decision: 'deny',
744
+ subType: 'TEST_FILE_DELETION',
745
+ reason: `[DET-01 Test Integrity Lock (#3)] Deleting test file "${deletedTestTarget}" via shell without explicit user instruction is forbidden.`
746
+ };
747
+ }
748
+ }
664
749
  continue;
665
750
  }
666
751
 
@@ -936,6 +1021,70 @@ export function evaluateDet01GitAndShellSafety(params = {}, _depth = 0) {
936
1021
  }
937
1022
  }
938
1023
  }
1024
+
1025
+ // Item A9 (#18): Un-stashed Working-Tree Discard Guard (`git checkout -- <path>`, `git checkout .`, `git checkout -f`, `git restore <path>`)
1026
+ if (subcommand === 'checkout') {
1027
+ const isBranchCreation = subArgs.some((a) => a === '-b' || a === '-B' || a === '--orphan');
1028
+ if (!isBranchCreation) {
1029
+ const hasForceCheckout = subArgs.some((a) => a === '-f' || a === '--force');
1030
+ const hasDoubleDashDiscard = subArgs.includes('--');
1031
+ const hasDotDiscard = subArgs.includes('.');
1032
+ if (hasForceCheckout || hasDoubleDashDiscard || hasDotDiscard) {
1033
+ return {
1034
+ detectorId: 'DET-01',
1035
+ triggered: true,
1036
+ decision: 'deny',
1037
+ subType: 'GIT_UNSTASHED_DISCARD',
1038
+ reason: `[DET-01 Worktree Destructive Guard (#18)] Un-stashed working-tree discard ("git checkout") destroys uncommitted edits. Run "git stash push -u" first.`
1039
+ };
1040
+ }
1041
+ }
1042
+ }
1043
+
1044
+ if (subcommand === 'restore') {
1045
+ const hasStagedOnly =
1046
+ subArgs.some((a) => a === '--staged' || a === '-S') &&
1047
+ !subArgs.some((a) => a === '--worktree' || a === '-W');
1048
+ if (!hasStagedOnly && subArgs.some((a) => a !== '--help' && a !== '-h')) {
1049
+ return {
1050
+ detectorId: 'DET-01',
1051
+ triggered: true,
1052
+ decision: 'deny',
1053
+ subType: 'GIT_UNSTASHED_DISCARD',
1054
+ reason: `[DET-01 Worktree Destructive Guard (#18)] Un-stashed "git restore" overwrites working-tree edits. Run "git stash push -u" first (or pass --staged to unstage).`
1055
+ };
1056
+ }
1057
+ }
1058
+
1059
+ // Item A2 (#3): EvilGenie `.git` Object / Reflog Answer-Mining Guard (`git fsck`, `git cat-file`, `git reflog`, `git log --all -p`)
1060
+ const promptForGit = String(params.lastUserInput || params.prompt || '');
1061
+ const userRequestedGitForensics = /\b(?:reflog|fsck|cat-file|recover\s+lost|dangling)\b/i.test(
1062
+ promptForGit
1063
+ );
1064
+ if (!userRequestedGitForensics) {
1065
+ if (subcommand === 'fsck' || subcommand === 'cat-file' || subcommand === 'reflog') {
1066
+ return {
1067
+ detectorId: 'DET-01',
1068
+ triggered: true,
1069
+ decision: 'deny',
1070
+ subType: 'GIT_HISTORY_MINING',
1071
+ reason: `[DET-01 Test Integrity Lock (#3)] Raw git object/reflog inspection ("git ${subcommand}") is blocked to prevent benchmark/test history mining.`
1072
+ };
1073
+ }
1074
+ if (
1075
+ subcommand === 'log' &&
1076
+ subArgs.includes('--all') &&
1077
+ subArgs.some((a) => a === '-p' || a === '--patch')
1078
+ ) {
1079
+ return {
1080
+ detectorId: 'DET-01',
1081
+ triggered: true,
1082
+ decision: 'deny',
1083
+ subType: 'GIT_HISTORY_MINING',
1084
+ reason: `[DET-01 Test Integrity Lock (#3)] Full-history patch mining ("git log --all -p") is blocked.`
1085
+ };
1086
+ }
1087
+ }
939
1088
  }
940
1089
 
941
1090
  return { detectorId: 'DET-01', triggered: false, decision: 'allow', reason: null };
@@ -198,8 +198,42 @@ export function evaluateDet05DiffThrashing(params = {}) {
198
198
  }
199
199
  }
200
200
 
201
- // 3. Scan ONLY deleted and added diff lines for test-assertion stripping / error masking
202
- const assertionRegex = /\b(?:assert\.[a-zA-Z]+|expect\s*\(|should\.)/;
201
+ const rawIntentPrompt = String(params.lastUserInput || params.prompt || '');
202
+ const userExplicitTestIntent =
203
+ Boolean(params.userExplicitTestIntent) ||
204
+ /\b(?:edit|update|modify|delete|remove|drop|skip|disable|rewrite|adjust|refactor)\s+(?:(?:the|all|any|some|these|those|existing|failing|obsolete|legacy|old|broken|flaky|unit|integration|e2e)\s+)*(?:tests?|specs?|assertions?)\b/i.test(
205
+ rawIntentPrompt
206
+ ) ||
207
+ (/\.(?:test|spec)\.[a-z0-9]+\b/i.test(rawIntentPrompt) &&
208
+ /\b(?:delete|remove|drop|skip|disable|update|rewrite)\b/i.test(rawIntentPrompt));
209
+ const normFilePath = String(params.filePath || '').replace(/\\/g, '/');
210
+ const isTestTarget =
211
+ /\.(?:test|spec)\.[a-z0-9]+$/i.test(normFilePath) ||
212
+ /(?:^|\/)(?:test|tests|__tests__)\/.*\.(?:[cm]?[jt]sx?|py|go|rs)$/i.test(normFilePath) ||
213
+ /_test\.(?:py|go)$/i.test(normFilePath);
214
+
215
+ // 2a. Test file truncation lock (#3): block emptying/truncating short test files (>=3 lines -> <=20%)
216
+ if (
217
+ isTestTarget &&
218
+ !userExplicitTestIntent &&
219
+ effectiveOldLines >= 3 &&
220
+ effectiveNewLines <= Math.floor(effectiveOldLines * 0.2)
221
+ ) {
222
+ return {
223
+ detectorId: 'DET-05',
224
+ triggered: true,
225
+ decision: 'deny',
226
+ subType: 'TEST_ASSERTION_STRIPPING',
227
+ nextHash,
228
+ oldLineCount: effectiveOldLines,
229
+ newLineCount: effectiveNewLines,
230
+ reason: `[DET-05 Test Integrity Lock (#3)] Truncating test file "${params.filePath || 'test'}" from ${effectiveOldLines} lines to ${effectiveNewLines} lines without explicit user instruction is forbidden.`
231
+ };
232
+ }
233
+
234
+ // 3. Scan ONLY deleted and added diff lines for test-assertion stripping / skip injection / weakening / error masking
235
+ const assertionRegex =
236
+ /\b(?:assert(?:\.[a-zA-Z0-9_]+)?\s*\x28|expect\s*\x28|should\.|assert_eq!\s*\x28|assert_ne!\s*\x28)|^\s*assert\s+(?!false\b)\S+/;
203
237
  const trivialTautologyRegex =
204
238
  /\b(?:assert\.ok\s*\(\s*true\s*\)|assert\.(?:strictEqual|equal)\s*\(\s*true\s*,\s*true\s*\)|expect\s*\(\s*true\s*\)\s*\.toBe\s*\(\s*true\s*\))/;
205
239
  const deletedAssertions = deletedLines.filter(
@@ -209,30 +243,88 @@ export function evaluateDet05DiffThrashing(params = {}) {
209
243
  (l) => assertionRegex.test(l) && !trivialTautologyRegex.test(l)
210
244
  );
211
245
 
212
- const errorMaskingRegex =
213
- /(?:catch\s*(?:\([^)]*\))?\s*\{\s*\}|@ts-ignore|@ts-nocheck|eslint-disable)/;
214
- const addedErrorMasking = addedLines.filter((l) => errorMaskingRegex.test(l));
215
-
216
- if (deletedAssertions.length >= 2 && addedAssertions.length === 0) {
246
+ // Item A2 (#3): Block >= 1 net deleted assertion without replacement unless user explicitly asked
247
+ if (!userExplicitTestIntent && deletedAssertions.length > addedAssertions.length) {
248
+ const netDeleted = deletedAssertions.length - addedAssertions.length;
217
249
  return {
218
250
  detectorId: 'DET-05',
219
251
  triggered: true,
220
252
  decision: 'deny',
221
253
  subType: 'TEST_ASSERTION_STRIPPING',
222
254
  nextHash,
223
- deletedAssertionsCount: deletedAssertions.length,
224
- reason: `[DET-05 Test Stripping Breaker] Diff deletes ${deletedAssertions.length} test assertions without replacement.`
255
+ deletedAssertionsCount: netDeleted,
256
+ reason: `[DET-05 Test Integrity Lock (#3)] Diff deletes ${netDeleted} net test assertion(s) without replacement.`
225
257
  };
226
258
  }
227
259
 
228
- if (addedErrorMasking.length > 0 && deletedLines.length > addedLines.length && deletedAssertions.length > 0) {
260
+ // Item A2 (#3): Block net increase in skipped/disabled tests (.skip, xit, @pytest.mark.skip, #[ignore])
261
+ const skipMarkerRegex =
262
+ /(?:\.(?:skip|todo)\s*\x28|\b(?:xit|xdescribe|xtest)\s*\x28|@pytest\.mark\.skip(?:if)?\b|#\[\s*ignore\b)/;
263
+ const deletedSkips = deletedLines.filter((l) => skipMarkerRegex.test(l));
264
+ const addedSkips = addedLines.filter((l) => skipMarkerRegex.test(l));
265
+ if (!userExplicitTestIntent && addedSkips.length > deletedSkips.length) {
266
+ const netSkips = addedSkips.length - deletedSkips.length;
267
+ return {
268
+ detectorId: 'DET-05',
269
+ triggered: true,
270
+ decision: 'deny',
271
+ subType: 'TEST_SKIP_INJECTION',
272
+ nextHash,
273
+ addedSkipsCount: netSkips,
274
+ reason: `[DET-05 Test Integrity Lock (#3)] Diff injects ${netSkips} skipped/disabled test marker(s) (.skip / xit / @pytest.mark.skip) without explicit user instruction.`
275
+ };
276
+ }
277
+
278
+ // Item A2 (#3): Block assertion weakening (strict equality -> truthy/defined)
279
+ const strongAssertRegex = /\b(?:toEqual|toStrictEqual|deepStrictEqual|strictEqual|deepEqual)\s*\x28/;
280
+ const weakAssertRegex = /\b(?:toBeTruthy|toBeDefined|toBeUndefined|assert\.ok)\s*\x28/;
281
+ if (
282
+ !userExplicitTestIntent &&
283
+ deletedLines.some((l) => strongAssertRegex.test(l)) &&
284
+ addedLines.some((l) => weakAssertRegex.test(l)) &&
285
+ !addedLines.some((l) => strongAssertRegex.test(l))
286
+ ) {
287
+ return {
288
+ detectorId: 'DET-05',
289
+ triggered: true,
290
+ decision: 'deny',
291
+ subType: 'TEST_ASSERTION_WEAKENING',
292
+ nextHash,
293
+ reason: `[DET-05 Test Integrity Lock (#3)] Diff weakens strict equality assertion(s) (toEqual/deepStrictEqual) into loose truthiness check(s) (toBeTruthy/toBeDefined).`
294
+ };
295
+ }
296
+
297
+ // Item A7 (#12): Standalone Silent Error-Masking Linter (independent of deletedAssertions!)
298
+ const justificationCommentRe = /(?:\/\/|\/\*|#)\s*(?:ignore|expected|noop|fallback|non-fatal|intentionally|best-effort)\b/i;
299
+ const inlineSuppressionRe = /(?:@ts-ignore|@ts-nocheck|eslint-disable(?!\s+[^\r\n]*--\s*\S{4,}))/;
300
+ const singleLineEmptyCatchRe = /\bcatch\s*(?:\x28[^\x29]*\x29)?\s*\{\s*\}/;
301
+ const addedInlineMasking = addedLines.filter(
302
+ (l) =>
303
+ (singleLineEmptyCatchRe.test(l) || inlineSuppressionRe.test(l)) &&
304
+ !justificationCommentRe.test(l)
305
+ );
306
+
307
+ const multiLineEmptyCatchRe = /\bcatch\s*(?:\x28[^\x29]*\x29)?\s*\{\s*\}/g;
308
+ const oldEmptyCatchCount = (oldText.match(multiLineEmptyCatchRe) || []).length;
309
+ const newEmptyCatchCount = (newText.match(multiLineEmptyCatchRe) || []).length;
310
+
311
+ const pyPassBlockRe = /\bexcept(?:\s+[A-Za-z0-9_.,\s()]+)?\s*:(?:[ \t]*(?:#[^\r\n]*)?\r?\n[ \t]*|[ \t]*)pass\b/g;
312
+ const countUnjustifiedPyPass = (txt) => {
313
+ const matches = txt.match(pyPassBlockRe) || [];
314
+ return matches.filter((m) => !justificationCommentRe.test(m)).length;
315
+ };
316
+ const addedMultiLineMasking =
317
+ newEmptyCatchCount > oldEmptyCatchCount ||
318
+ countUnjustifiedPyPass(newText) > countUnjustifiedPyPass(oldText);
319
+
320
+ if (addedInlineMasking.length > 0 || addedMultiLineMasking) {
229
321
  return {
230
322
  detectorId: 'DET-05',
231
323
  triggered: true,
232
324
  decision: 'deny',
233
325
  subType: 'ERROR_MASKING_DIFF',
234
326
  nextHash,
235
- reason: `[DET-05 Error Masking Breaker] Newly added diff lines introduce empty catch / lint suppression while deleting verification checks.`
327
+ reason: `[DET-05 Error Masking Breaker (#12)] Newly added diff introduces silent error masking (empty catch / except: pass / @ts-ignore / eslint-disable) without logging, rethrow, or justification comment.`
236
328
  };
237
329
  }
238
330