deepmodebot 0.9.1 → 0.11.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 (705) hide show
  1. package/.agents/plugins/marketplace.json +20 -0
  2. package/.claude-plugin/marketplace.json +2 -2
  3. package/.omp-plugin/marketplace.json +2 -2
  4. package/README.md +38 -5
  5. package/bin/deepmodebot.mjs +257 -4
  6. package/lib/clients.mjs +50 -3
  7. package/lib/tree.mjs +64 -10
  8. package/native/dmb-gate/Cargo.toml +13 -0
  9. package/native/dmb-gate/src/agents.rs +110 -0
  10. package/native/dmb-gate/src/ci.rs +1032 -0
  11. package/native/dmb-gate/src/cleanup.rs +198 -0
  12. package/native/dmb-gate/src/gap.rs +1376 -0
  13. package/native/dmb-gate/src/guard.rs +135 -0
  14. package/native/dmb-gate/src/main.rs +535 -0
  15. package/native/dmb-gate/src/map.rs +173 -0
  16. package/native/dmb-gate/src/perf.rs +347 -0
  17. package/native/dmb-gate/src/reward.rs +2867 -0
  18. package/native/dmb-gate/src/sim.rs +969 -0
  19. package/native/dmb-gate/src/skill_check.rs +171 -0
  20. package/native/dmb-gate/src/slop.rs +2004 -0
  21. package/native/dmb-gate/src/ui.rs +842 -0
  22. package/native/dmb-gate/src/util.rs +260 -0
  23. package/native/dmb-net/go.mod +3 -0
  24. package/native/dmb-net/main.go +624 -0
  25. package/native/dmb-net/main_test.go +122 -0
  26. package/package.json +12 -2
  27. package/plugins/deepmodebot/.antigravity-plugin/plugin.json +1 -1
  28. package/plugins/deepmodebot/.antigravity-plugin/skills/deep/SKILL.md +5 -5
  29. package/plugins/deepmodebot/.antigravity-plugin/skills/pr-thread/SKILL.md +1 -1
  30. package/plugins/deepmodebot/.antigravity-plugin/skills/review-pr/SKILL.md +2 -2
  31. package/plugins/deepmodebot/.antigravity-plugin/skills/suggest/SKILL.md +13 -0
  32. package/plugins/deepmodebot/.antigravity-plugin/skills/tournament/SKILL.md +2 -2
  33. package/plugins/deepmodebot/.claude-plugin/plugin.json +1 -1
  34. package/plugins/deepmodebot/.codex-plugin/plugin.json +46 -0
  35. package/plugins/deepmodebot/agents/comment-sicko.md +29 -0
  36. package/plugins/deepmodebot/agents/researcher.md +29 -0
  37. package/plugins/deepmodebot/agents/reviewer.md +29 -0
  38. package/plugins/deepmodebot/agents/scout.md +28 -0
  39. package/plugins/deepmodebot/agents/security-reviewer.md +27 -0
  40. package/plugins/deepmodebot/commands/deep.md +7 -6
  41. package/plugins/deepmodebot/commands/research.md +8 -0
  42. package/plugins/deepmodebot/commands/suggest.md +10 -0
  43. package/plugins/deepmodebot/commands/tournament.md +2 -2
  44. package/plugins/deepmodebot/hooks/hooks.json +12 -2
  45. package/plugins/deepmodebot/hooks.json +1 -1
  46. package/plugins/deepmodebot/scripts/antigravity-guard.mjs +862 -26
  47. package/plugins/deepmodebot/scripts/omp-mcp-server.mjs +179 -47
  48. package/plugins/deepmodebot/skills/agent-harnesses/SKILL.md +4 -6
  49. package/plugins/deepmodebot/skills/agent-harnesses/assets/sdks/check_antigravity.py +3 -0
  50. package/plugins/deepmodebot/skills/agent-harnesses/references/ai-native-tooling.md +4 -0
  51. package/plugins/deepmodebot/skills/agent-harnesses/references/ai-sdk-selection.md +3 -1
  52. package/plugins/deepmodebot/skills/agent-harnesses/references/antigravity.md +3 -3
  53. package/plugins/deepmodebot/skills/agent-harnesses/references/delegation-efficiency.md +12 -2
  54. package/plugins/deepmodebot/skills/agent-harnesses/references/protocols.md +11 -3
  55. package/plugins/deepmodebot/skills/app-automation-relay/SKILL.md +17 -0
  56. package/plugins/deepmodebot/skills/app-automation-relay/assets/relay_server.ts +364 -0
  57. package/plugins/deepmodebot/skills/app-automation-relay/references/adapter-cookbook.md +15 -0
  58. package/plugins/deepmodebot/skills/app-automation-relay/references/wire-protocol.md +23 -0
  59. package/plugins/deepmodebot/skills/cloud-devsecops/SKILL.md +4 -3
  60. package/plugins/deepmodebot/skills/cloud-devsecops/references/cloudflare-edge.md +43 -0
  61. package/plugins/deepmodebot/skills/cloud-devsecops/references/local-emulators.md +15 -2
  62. package/plugins/deepmodebot/skills/contribute/SKILL.md +3 -35
  63. package/plugins/deepmodebot/skills/create-formal-verification-skill/LICENSE +21 -0
  64. package/plugins/deepmodebot/skills/create-formal-verification-skill/NOTICE.md +16 -0
  65. package/plugins/deepmodebot/skills/create-formal-verification-skill/SKILL.md +71 -0
  66. package/plugins/deepmodebot/skills/create-verification-skill/SKILL.md +2 -2
  67. package/plugins/deepmodebot/skills/deep-learning/LICENSE +21 -0
  68. package/plugins/deepmodebot/skills/deep-learning/SKILL.md +33 -0
  69. package/plugins/deepmodebot/skills/deep-learning/references/neural-architectures.md +43 -0
  70. package/plugins/deepmodebot/skills/deep-learning/references/papers-and-repos.md +128 -0
  71. package/plugins/deepmodebot/skills/deep-learning/references/reinforcement-learning.md +57 -0
  72. package/plugins/deepmodebot/skills/deep-learning/references/training-optimization.md +40 -0
  73. package/plugins/deepmodebot/skills/deep-learning/references/weight-space-programming.md +76 -0
  74. package/plugins/deepmodebot/skills/deep-learning/scripts/hf_passes.py +166 -0
  75. package/plugins/deepmodebot/skills/deep-learning/scripts/wsp.py +493 -0
  76. package/plugins/deepmodebot/skills/deep-stack/SKILL.md +1 -1
  77. package/plugins/deepmodebot/skills/deep-stack/references/design-workflow.md +46 -92
  78. package/plugins/deepmodebot/skills/deep-stack/references/isolate.md +1 -0
  79. package/plugins/deepmodebot/skills/deep-stack/references/prove.md +6 -0
  80. package/plugins/deepmodebot/skills/deep-stack/references/stack.md +11 -1
  81. package/plugins/deepmodebot/skills/deepmodebot/SKILL.md +83 -146
  82. package/plugins/deepmodebot/skills/deepmodebot/assets/agents-md/agents_md.py +67 -24
  83. package/plugins/deepmodebot/skills/deepmodebot/assets/autoroute/autoroute.py +1026 -0
  84. package/plugins/deepmodebot/skills/deepmodebot/assets/cleanup/self_cleanup.py +305 -0
  85. package/plugins/deepmodebot/skills/deepmodebot/assets/contain/claude-guard.sh +4 -0
  86. package/plugins/deepmodebot/skills/deepmodebot/assets/contain/claude_guard.py +736 -6
  87. package/plugins/deepmodebot/skills/deepmodebot/assets/contain/holdout_guard_cases.json +272 -0
  88. package/plugins/deepmodebot/skills/deepmodebot/assets/contain/omp-contain.ts +861 -9
  89. package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/design.py +3 -0
  90. package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/record.py +2 -0
  91. package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/rehearsal_gate.py +536 -0
  92. package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/review.py +2 -0
  93. package/plugins/deepmodebot/skills/deepmodebot/assets/f2p-gate/f2p_gate.py +547 -0
  94. package/plugins/deepmodebot/skills/deepmodebot/assets/formal-verification/verify_proof.py +638 -0
  95. package/plugins/deepmodebot/skills/deepmodebot/assets/gap-audit/gap_audit.py +1047 -0
  96. package/plugins/deepmodebot/skills/deepmodebot/assets/gen-ui/gen_ui.py +1782 -0
  97. package/plugins/deepmodebot/skills/deepmodebot/assets/git-guardrails/git-guard-patterns.txt +7 -0
  98. package/plugins/deepmodebot/skills/deepmodebot/assets/git-guardrails/git-guard.sh +55 -7
  99. package/plugins/deepmodebot/skills/deepmodebot/assets/git-guardrails/git-guard.ts +55 -5
  100. package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/ghapp.py +2 -0
  101. package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/install.py +2 -0
  102. package/plugins/deepmodebot/skills/deepmodebot/assets/local-ci/local_ci.py +796 -0
  103. package/plugins/deepmodebot/skills/deepmodebot/assets/local-ci/slop_gate.py +1049 -0
  104. package/plugins/deepmodebot/skills/deepmodebot/assets/loop/loop.py +748 -46
  105. package/plugins/deepmodebot/skills/deepmodebot/assets/loop/plan.py +2 -1
  106. package/plugins/deepmodebot/skills/deepmodebot/assets/loop/windows_job.py +2 -0
  107. package/plugins/deepmodebot/skills/deepmodebot/assets/memory/project_memory.py +928 -0
  108. package/plugins/deepmodebot/skills/deepmodebot/assets/mutation/mutation_gate.py +798 -0
  109. package/plugins/deepmodebot/skills/deepmodebot/assets/perf-audit/bench_harness.py +48 -21
  110. package/plugins/deepmodebot/skills/deepmodebot/assets/perf-audit/perf_audit.py +339 -5
  111. package/plugins/deepmodebot/skills/deepmodebot/assets/pr-agent/diff_coverage.py +96 -6
  112. package/plugins/deepmodebot/skills/deepmodebot/assets/pr-agent/pr_agent_local.py +2 -0
  113. package/plugins/deepmodebot/skills/deepmodebot/assets/pr-conversation/arena.py +2 -0
  114. package/plugins/deepmodebot/skills/deepmodebot/assets/pr-conversation/show_thread.py +2 -0
  115. package/plugins/deepmodebot/skills/deepmodebot/assets/prompt-tools/prompt_tools.py +1239 -0
  116. package/plugins/deepmodebot/skills/deepmodebot/assets/quota-guard/quota_guard.py +424 -0
  117. package/plugins/deepmodebot/skills/deepmodebot/assets/repo-references.json +477 -1
  118. package/plugins/deepmodebot/skills/deepmodebot/assets/reward-guard/reward_guard.py +3447 -0
  119. package/plugins/deepmodebot/skills/deepmodebot/assets/rules/rule-paths.json +100 -0
  120. package/plugins/deepmodebot/skills/deepmodebot/assets/rules/rule_ledger.py +1671 -0
  121. package/plugins/deepmodebot/skills/deepmodebot/assets/rules/rules_watch.py +436 -0
  122. package/plugins/deepmodebot/skills/deepmodebot/assets/scrape/yt_enrich.py +2 -0
  123. package/plugins/deepmodebot/skills/deepmodebot/assets/scrape/yt_meta.py +2 -0
  124. package/plugins/deepmodebot/skills/deepmodebot/assets/scrape/yt_transcript_relay.js +13 -10
  125. package/plugins/deepmodebot/skills/deepmodebot/assets/security-audit/static_sec_audit.py +275 -0
  126. package/plugins/deepmodebot/skills/deepmodebot/assets/self-grill/self_grill.py +2049 -0
  127. package/plugins/deepmodebot/skills/deepmodebot/assets/setup/model_setup.py +329 -0
  128. package/plugins/deepmodebot/skills/deepmodebot/assets/setup/project_setup.py +348 -0
  129. package/plugins/deepmodebot/skills/deepmodebot/assets/sim/sim.py +856 -0
  130. package/plugins/deepmodebot/skills/deepmodebot/assets/tournament/tournament.py +304 -18
  131. package/plugins/deepmodebot/skills/deepmodebot/assets/worker-gate/worker_gate.py +237 -0
  132. package/plugins/deepmodebot/skills/deepmodebot/assets/workspace-map/workspace_map.py +121 -78
  133. package/plugins/deepmodebot/skills/deepmodebot/references/README.md +14 -0
  134. package/plugins/deepmodebot/skills/deepmodebot/references/catalog.md +17 -11
  135. package/plugins/deepmodebot/skills/deepmodebot/references/contain.md +2 -1
  136. package/plugins/deepmodebot/skills/deepmodebot/references/delegation.md +18 -0
  137. package/plugins/deepmodebot/skills/deepmodebot/references/flows.md +2 -0
  138. package/plugins/deepmodebot/skills/deepmodebot/references/full-scope.md +9 -0
  139. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/authoring-a-skill.md +1 -1
  140. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/babysit.md +2 -0
  141. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/end-to-end.md +12 -9
  142. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/feature.md +7 -3
  143. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/hillclimb.md +3 -0
  144. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/investigation.md +4 -4
  145. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/opening-a-pr.md +1 -1
  146. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/perf-issue.md +13 -10
  147. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/refactoring.md +6 -6
  148. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/reference-rebuild.md +1 -0
  149. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/run-a-goal.md +3 -1
  150. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/self-authoring.md +1 -1
  151. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/setup.md +1 -2
  152. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/visual-parity.md +1 -0
  153. package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/work-a-queue.md +4 -2
  154. package/plugins/deepmodebot/skills/deepmodebot/references/principles/hardcore-mode.md +7 -0
  155. package/plugins/deepmodebot/skills/deepmodebot/references/principles/no-reward-hacking.md +8 -0
  156. package/plugins/deepmodebot/skills/deepmodebot/references/principles/test-behavior-not-implementation.md +2 -1
  157. package/plugins/deepmodebot/skills/deepmodebot/references/principles/type-system-discipline.md +2 -2
  158. package/plugins/deepmodebot/skills/deepmodebot/references/rule-approval.md +71 -0
  159. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/architect.md +10 -24
  160. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/architecture-review.md +5 -4
  161. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/arena.md +3 -3
  162. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/autoroute.md +50 -0
  163. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/blast-radius.md +1 -1
  164. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/catchup-video.md +13 -0
  165. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/correct.md +9 -7
  166. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/course.md +2 -1
  167. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/devex-review.md +13 -0
  168. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/expand-contract.md +13 -0
  169. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/formal-verification.md +33 -0
  170. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/gen-ui.md +60 -0
  171. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/grill.md +2 -1
  172. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/how.md +7 -18
  173. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/inner-loop.md +12 -8
  174. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/model-setup.md +14 -0
  175. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/modernize-pr.md +15 -0
  176. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/mutation-testing.md +35 -0
  177. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/no-comments.md +5 -5
  178. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/panel.md +9 -5
  179. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/pr-conversation.md +1 -1
  180. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/pr-review.md +8 -5
  181. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/pre-commit.md +1 -2
  182. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/prior-art.md +33 -38
  183. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/product-lens.md +12 -0
  184. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/prompt-upgrade.md +30 -0
  185. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/recall.md +1 -1
  186. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/reframe.md +18 -0
  187. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/release-and-canary.md +10 -0
  188. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/research.md +62 -89
  189. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/security-audit.md +5 -1
  190. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/self-grill.md +54 -0
  191. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/sharpen.md +3 -3
  192. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/show-me-your-work.md +7 -0
  193. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/sim.md +41 -0
  194. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/sme-review.md +3 -2
  195. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/suggest.md +24 -0
  196. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/swarm.md +7 -0
  197. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/tdd.md +12 -0
  198. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/teach.md +2 -2
  199. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/tournament.md +30 -18
  200. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/variant-analysis.md +11 -0
  201. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/video-forensics.md +46 -0
  202. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/visual-e2e.md +10 -1
  203. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/webhook-ui.md +11 -0
  204. package/plugins/deepmodebot/skills/deepmodebot/references/techniques/writing-for-agents.md +6 -0
  205. package/plugins/deepmodebot/skills/deepmodebot/scripts/check_skill.py +7 -0
  206. package/plugins/deepmodebot/skills/deepmodebot/scripts/trending.py +141 -18
  207. package/plugins/deepmodebot/skills/deepmodebot/worker.md +28 -0
  208. package/plugins/deepmodebot/skills/domain-rules/SKILL.md +13 -119
  209. package/plugins/deepmodebot/skills/domain-rules/references/backend-system-design.md +19 -1
  210. package/plugins/deepmodebot/skills/domain-rules/references/engineering-practice.md +7 -0
  211. package/plugins/deepmodebot/skills/domain-rules/references/language-ecosystems.md +11 -0
  212. package/plugins/deepmodebot/skills/domain-rules/references/sources.md +108 -0
  213. package/plugins/deepmodebot/skills/frontend-ui/SKILL.md +30 -131
  214. package/plugins/deepmodebot/skills/frontend-ui/assets/themes/canvas.css +42 -0
  215. package/plugins/deepmodebot/skills/frontend-ui/assets/themes/editorial.css +39 -0
  216. package/plugins/deepmodebot/skills/frontend-ui/assets/themes/layouts.css +95 -0
  217. package/plugins/deepmodebot/skills/frontend-ui/assets/themes/swiss.css +40 -0
  218. package/plugins/deepmodebot/skills/frontend-ui/assets/themes/tactile.css +41 -0
  219. package/plugins/deepmodebot/skills/frontend-ui/assets/themes/workbench.css +50 -0
  220. package/plugins/deepmodebot/skills/frontend-ui/references/patterns/mobbin-animations.md +49 -0
  221. package/plugins/deepmodebot/skills/frontend-ui/references/patterns/mobbin-shipped-apps.md +46 -24
  222. package/plugins/deepmodebot/skills/frontend-ui/references/patterns/motion-clips.md +27 -258
  223. package/plugins/deepmodebot/skills/frontend-ui/references/patterns/motion-graphics.md +26 -51
  224. package/plugins/deepmodebot/skills/frontend-ui/references/patterns/pinterest-animations.md +22 -195
  225. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/00-art-direction.md +39 -0
  226. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/01-workflow.md +27 -24
  227. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/02-review-rubric.md +23 -17
  228. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/03-ai-tells.md +22 -45
  229. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/04-components.md +11 -0
  230. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/04a-agent-ui.md +32 -152
  231. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/05-motion.md +36 -91
  232. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/05a-motion-graphics.md +14 -120
  233. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/06-typography-layout.md +11 -10
  234. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/06a-color.md +9 -9
  235. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/06b-media-icons-charts.md +19 -0
  236. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/06c-product-shots-craft.md +42 -0
  237. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/07-copy.md +5 -6
  238. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/08-quality-floor.md +28 -56
  239. package/plugins/deepmodebot/skills/frontend-ui/references/playbook/09-steering-agents.md +9 -7
  240. package/plugins/deepmodebot/skills/frontend-ui/scripts/motion_diff.py +259 -0
  241. package/plugins/deepmodebot/skills/frontend-ui/scripts/ui_audit.py +496 -0
  242. package/plugins/deepmodebot/skills/maintain-formal-verification-skill/LICENSE +21 -0
  243. package/plugins/deepmodebot/skills/maintain-formal-verification-skill/NOTICE.md +16 -0
  244. package/plugins/deepmodebot/skills/maintain-formal-verification-skill/SKILL.md +68 -0
  245. package/plugins/deepmodebot/skills/maintain-verification-skill/SKILL.md +1 -1
  246. package/plugins/deepmodebot/skills/office-documents/SKILL.md +24 -0
  247. package/plugins/deepmodebot/skills/office-documents/references/documents-docx-pdf.md +15 -0
  248. package/plugins/deepmodebot/skills/office-documents/references/presentations-pptx.md +15 -0
  249. package/plugins/deepmodebot/skills/office-documents/references/spreadsheets-xlsx.md +15 -0
  250. package/plugins/deepmodebot/skills/office-documents/scripts/doc_audit.py +230 -0
  251. package/plugins/deepmodebot/skills/project-brief/SKILL.md +2 -19
  252. package/plugins/deepmodebot/skills/project-brief/assets/pr-overlap.py +4 -0
  253. package/plugins/deepmodebot/skills/project-brief/assets/sync-roadmap.py +4 -0
  254. package/plugins/deepmodebot/skills/project-brief/references/claim-contract.md +55 -0
  255. package/plugins/deepmodebot/skills/research/SKILL.md +18 -0
  256. package/plugins/deepmodebot/skills/secrets-and-auth/SKILL.md +1 -1
  257. package/plugins/deepmodebot/skills/seo-and-geo/SKILL.md +29 -0
  258. package/plugins/deepmodebot/skills/seo-and-geo/references/geo-and-agentic-web.md +30 -0
  259. package/plugins/deepmodebot/skills/seo-and-geo/references/technical-and-schema.md +25 -0
  260. package/plugins/deepmodebot/skills/seo-and-geo/scripts/seo_audit.py +282 -0
  261. package/plugins/deepmodebot/skills/software-architecture/SKILL.md +2 -2
  262. package/plugins/deepmodebot/skills/software-architecture/references/backend-infrastructure.md +5 -0
  263. package/plugins/deepmodebot/skills/software-architecture/references/monorepos.md +1 -0
  264. package/plugins/deepmodebot/skills/statechart/LICENSE +21 -0
  265. package/plugins/deepmodebot/skills/statechart/NOTICE.md +21 -0
  266. package/plugins/deepmodebot/skills/statechart/SKILL.md +106 -0
  267. package/plugins/deepmodebot/skills/statechart/references/render.md +93 -0
  268. package/plugins/deepmodebot/skills/statechart/references/tooling.md +78 -0
  269. package/plugins/deepmodebot/skills/statechart/scripts/backends/cfg.ts +33 -0
  270. package/plugins/deepmodebot/skills/statechart/scripts/backends/mermaid.ts +249 -0
  271. package/plugins/deepmodebot/skills/statechart/scripts/backends/plain-text.ts +72 -0
  272. package/plugins/deepmodebot/skills/statechart/scripts/backends/report.ts +177 -0
  273. package/plugins/deepmodebot/skills/statechart/scripts/frontends/config.ts +276 -0
  274. package/plugins/deepmodebot/skills/statechart/scripts/frontends/dot.ts +77 -0
  275. package/plugins/deepmodebot/skills/statechart/scripts/frontends/marks.ts +93 -0
  276. package/plugins/deepmodebot/skills/statechart/scripts/frontends/messages.ts +52 -0
  277. package/plugins/deepmodebot/skills/statechart/scripts/frontends/spec.ts +114 -0
  278. package/plugins/deepmodebot/skills/statechart/scripts/frontends/trace.ts +24 -0
  279. package/plugins/deepmodebot/skills/statechart/scripts/frontends/value.ts +166 -0
  280. package/plugins/deepmodebot/skills/statechart/scripts/frontends/verdict.ts +40 -0
  281. package/plugins/deepmodebot/skills/statechart/scripts/frontends/view.ts +119 -0
  282. package/plugins/deepmodebot/skills/statechart/scripts/ir.ts +547 -0
  283. package/plugins/deepmodebot/skills/statechart/scripts/janitor.ts +13 -0
  284. package/plugins/deepmodebot/skills/statechart/scripts/kill.ts +15 -0
  285. package/plugins/deepmodebot/skills/statechart/scripts/package.json +11 -0
  286. package/plugins/deepmodebot/skills/statechart/scripts/passes/annotate.ts +128 -0
  287. package/plugins/deepmodebot/skills/statechart/scripts/passes/label.ts +269 -0
  288. package/plugins/deepmodebot/skills/statechart/scripts/passes/lift.ts +85 -0
  289. package/plugins/deepmodebot/skills/statechart/scripts/passes/loop-check.ts +68 -0
  290. package/plugins/deepmodebot/skills/statechart/scripts/passes/paths.ts +60 -0
  291. package/plugins/deepmodebot/skills/statechart/scripts/passes/reach.ts +135 -0
  292. package/plugins/deepmodebot/skills/statechart/scripts/passes/region-check.ts +97 -0
  293. package/plugins/deepmodebot/skills/statechart/scripts/passes/regions.ts +295 -0
  294. package/plugins/deepmodebot/skills/statechart/scripts/pipeline.ts +76 -0
  295. package/plugins/deepmodebot/skills/statechart/scripts/run.ts +500 -0
  296. package/plugins/deepmodebot/skills/statechart/scripts/statechart +29 -0
  297. package/plugins/deepmodebot/skills/statechart/scripts/statechart.ts +165 -0
  298. package/plugins/deepmodebot/skills/statechart/scripts/test/ConfigOracle.java +63 -0
  299. package/plugins/deepmodebot/skills/statechart/scripts/test/chart.test.ts +1253 -0
  300. package/plugins/deepmodebot/skills/statechart/scripts/test/charts/Braces.mmd +7 -0
  301. package/plugins/deepmodebot/skills/statechart/scripts/test/charts/Escapes.mmd +11 -0
  302. package/plugins/deepmodebot/skills/statechart/scripts/test/charts/Phases.mmd +29 -0
  303. package/plugins/deepmodebot/skills/statechart/scripts/test/cli.test.ts +1344 -0
  304. package/plugins/deepmodebot/skills/statechart/scripts/test/config-fuzz.test.ts +263 -0
  305. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Counter/ChartRun.out +57 -0
  306. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Counter/Counter.cfg +3 -0
  307. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Counter/Counter.tla +10 -0
  308. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Counter/chart.mmd +9 -0
  309. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Counter/graph.dot +16 -0
  310. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Counter/report.md +7 -0
  311. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Counter/sany.out +2 -0
  312. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Counter/verdict-1.out +49 -0
  313. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/ChartRun.out +60 -0
  314. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/CounterAction.cfg +4 -0
  315. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/CounterAction.tla +22 -0
  316. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/chart.mmd +26 -0
  317. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/graph.dot +19 -0
  318. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/report.md +20 -0
  319. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/sany.out +2 -0
  320. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/verdict-1.exit +1 -0
  321. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/verdict-1.out +56 -0
  322. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/verdict-2.exit +1 -0
  323. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/verdict-2.out +82 -0
  324. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/verdict-3.out +57 -0
  325. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/ChartRun.out +59 -0
  326. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/CounterDeadlock.cfg +3 -0
  327. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/CounterDeadlock.tla +11 -0
  328. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/chart.mmd +22 -0
  329. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/graph.dot +16 -0
  330. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/report.md +17 -0
  331. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/sany.out +2 -0
  332. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/verdict-1.exit +1 -0
  333. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/verdict-1.out +56 -0
  334. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/verdict-2.exit +1 -0
  335. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/verdict-2.out +77 -0
  336. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterFan/ChartRun.out +69 -0
  337. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterFan/CounterFan.cfg +2 -0
  338. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterFan/CounterFan.tla +11 -0
  339. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterFan/chart.mmd +85 -0
  340. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterFan/graph.dot +70 -0
  341. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterFan/report.md +12 -0
  342. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterFan/sany.out +2 -0
  343. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterFan/verdict-1.exit +1 -0
  344. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterFan/verdict-1.out +67 -0
  345. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterFan/verdict-2.out +57 -0
  346. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/ChartRun.exit +1 -0
  347. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/ChartRun.out +85 -0
  348. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/CounterGuard.cfg +6 -0
  349. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/CounterGuard.tla +13 -0
  350. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/chart.mmd +5 -0
  351. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/graph.dot +10 -0
  352. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/report.md +31 -0
  353. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/sany.out +2 -0
  354. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/verdict-1.exit +1 -0
  355. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/verdict-1.out +64 -0
  356. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/verdict-2.exit +1 -0
  357. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/verdict-2.out +77 -0
  358. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPast/ChartRun.out +55 -0
  359. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPast/CounterInitPast.cfg +3 -0
  360. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPast/CounterInitPast.tla +10 -0
  361. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPast/chart.mmd +12 -0
  362. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPast/graph.dot +6 -0
  363. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPast/report.md +12 -0
  364. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPast/sany.out +2 -0
  365. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPast/verdict-1.exit +1 -0
  366. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPast/verdict-1.out +33 -0
  367. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPast/verdict-2.out +54 -0
  368. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPastHolds/ChartRun.out +54 -0
  369. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPastHolds/CounterInitPastHolds.cfg +3 -0
  370. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPastHolds/CounterInitPastHolds.tla +10 -0
  371. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPastHolds/chart.mmd +1 -0
  372. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPastHolds/graph.dot +6 -0
  373. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPastHolds/report.md +7 -0
  374. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPastHolds/sany.out +2 -0
  375. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPastHolds/verdict-1.out +46 -0
  376. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInstance/ChartRun.out +59 -0
  377. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInstance/CounterInstance.cfg +2 -0
  378. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInstance/CounterInstance.tla +10 -0
  379. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInstance/CounterSteps.tla +6 -0
  380. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInstance/chart.mmd +17 -0
  381. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInstance/graph.dot +15 -0
  382. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInstance/report.md +14 -0
  383. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInstance/sany.out +3 -0
  384. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInstance/verdict-1.exit +1 -0
  385. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInstance/verdict-1.out +78 -0
  386. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterJump/ChartRun.out +59 -0
  387. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterJump/CounterJump.cfg +3 -0
  388. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterJump/CounterJump.tla +19 -0
  389. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterJump/chart.mmd +26 -0
  390. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterJump/graph.dot +22 -0
  391. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterJump/report.md +12 -0
  392. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterJump/sany.out +2 -0
  393. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterJump/verdict-1.exit +1 -0
  394. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterJump/verdict-1.out +58 -0
  395. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterJump/verdict-2.out +57 -0
  396. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterLoop/ChartRun.out +57 -0
  397. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterLoop/CounterLoop.cfg +2 -0
  398. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterLoop/CounterLoop.tla +11 -0
  399. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterLoop/chart.mmd +17 -0
  400. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterLoop/graph.dot +15 -0
  401. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterLoop/report.md +14 -0
  402. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterLoop/sany.out +2 -0
  403. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterLoop/verdict-1.exit +1 -0
  404. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterLoop/verdict-1.out +76 -0
  405. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/ChartRun.out +59 -0
  406. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/CounterOrder.cfg +3 -0
  407. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/CounterOrder.tla +11 -0
  408. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/chart.mmd +19 -0
  409. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/graph.dot +10 -0
  410. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/report.md +15 -0
  411. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/sany.out +2 -0
  412. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/verdict-1.exit +1 -0
  413. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/verdict-1.out +56 -0
  414. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/verdict-2.exit +1 -0
  415. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/verdict-2.out +67 -0
  416. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/ChartRun.out +62 -0
  417. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/CounterRules.cfg +6 -0
  418. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/CounterRules.tla +24 -0
  419. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/Moves.tla +5 -0
  420. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/chart.mmd +22 -0
  421. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/graph.dot +10 -0
  422. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/report.md +23 -0
  423. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/sany.out +3 -0
  424. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/verdict-1.exit +1 -0
  425. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/verdict-1.out +58 -0
  426. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/verdict-2.exit +1 -0
  427. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/verdict-2.out +66 -0
  428. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/verdict-3.exit +1 -0
  429. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/verdict-3.out +74 -0
  430. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/verdict-4.out +59 -0
  431. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStart/ChartRun.out +58 -0
  432. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStart/CounterStart.cfg +3 -0
  433. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStart/CounterStart.tla +15 -0
  434. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStart/chart.mmd +18 -0
  435. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStart/graph.dot +13 -0
  436. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStart/report.md +11 -0
  437. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStart/sany.out +2 -0
  438. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStart/verdict-1.exit +1 -0
  439. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStart/verdict-1.out +33 -0
  440. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStart/verdict-2.out +57 -0
  441. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStop/ChartRun.out +57 -0
  442. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStop/CounterStop.cfg +3 -0
  443. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStop/CounterStop.tla +15 -0
  444. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStop/chart.mmd +7 -0
  445. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStop/graph.dot +13 -0
  446. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStop/report.md +6 -0
  447. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStop/sany.out +2 -0
  448. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStop/verdict-1.out +49 -0
  449. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/ChartRun.out +61 -0
  450. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/CounterTie.cfg +4 -0
  451. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/CounterTie.tla +14 -0
  452. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/chart.mmd +30 -0
  453. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/graph.dot +19 -0
  454. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/report.md +27 -0
  455. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/sany.out +2 -0
  456. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/verdict-1.exit +1 -0
  457. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/verdict-1.out +56 -0
  458. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/verdict-2.exit +1 -0
  459. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/verdict-2.out +64 -0
  460. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/verdict-3.exit +1 -0
  461. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/verdict-3.out +87 -0
  462. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/verdict-4.out +57 -0
  463. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTieInGraph/ChartRun.out +60 -0
  464. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTieInGraph/CounterTieInGraph.cfg +3 -0
  465. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTieInGraph/CounterTieInGraph.tla +12 -0
  466. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTieInGraph/chart.mmd +23 -0
  467. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTieInGraph/graph.dot +19 -0
  468. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTieInGraph/report.md +11 -0
  469. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTieInGraph/sany.out +2 -0
  470. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTieInGraph/verdict-1.exit +1 -0
  471. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTieInGraph/verdict-1.out +56 -0
  472. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTieInGraph/verdict-2.out +57 -0
  473. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/ChartRun.out +61 -0
  474. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/CounterView.cfg +4 -0
  475. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/CounterView.tla +14 -0
  476. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/chart.mmd +23 -0
  477. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/graph.dot +19 -0
  478. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/report.md +27 -0
  479. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/sany.out +2 -0
  480. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/verdict-1.exit +1 -0
  481. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/verdict-1.out +56 -0
  482. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/verdict-2.exit +1 -0
  483. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/verdict-2.out +64 -0
  484. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/verdict-3.exit +1 -0
  485. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/verdict-3.out +87 -0
  486. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/verdict-4.out +57 -0
  487. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/view.mjs +1 -0
  488. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/DieHard/ChartRun.out +59 -0
  489. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/DieHard/DieHard.cfg +4 -0
  490. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/DieHard/DieHard.tla +38 -0
  491. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/DieHard/chart.mmd +92 -0
  492. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/DieHard/graph.dot +126 -0
  493. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/DieHard/report.md +17 -0
  494. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/DieHard/sany.out +2 -0
  495. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/DieHard/verdict-1.exit +1 -0
  496. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/DieHard/verdict-1.out +91 -0
  497. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/DieHard/verdict-2.out +57 -0
  498. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/ChartRun.out +61 -0
  499. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/FirstRule.cfg +6 -0
  500. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/FirstRule.tla +11 -0
  501. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/chart.mmd +22 -0
  502. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/graph.dot +16 -0
  503. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/report.md +25 -0
  504. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/sany.out +2 -0
  505. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/verdict-1.exit +1 -0
  506. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/verdict-1.out +56 -0
  507. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/verdict-2.exit +1 -0
  508. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/verdict-2.out +64 -0
  509. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/verdict-3.exit +1 -0
  510. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/verdict-3.out +64 -0
  511. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/verdict-4.exit +1 -0
  512. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/verdict-4.out +77 -0
  513. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/HiddenClock/ChartRun.out +57 -0
  514. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/HiddenClock/HiddenClock.cfg +4 -0
  515. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/HiddenClock/HiddenClock.tla +11 -0
  516. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/HiddenClock/chart.mmd +13 -0
  517. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/HiddenClock/graph.dot +12 -0
  518. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/HiddenClock/report.md +11 -0
  519. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/HiddenClock/sany.out +2 -0
  520. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/HiddenClock/verdict-1.exit +1 -0
  521. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/HiddenClock/verdict-1.out +72 -0
  522. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Login/ChartRun.out +57 -0
  523. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Login/Login.cfg +3 -0
  524. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Login/Login.tla +62 -0
  525. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Login/chart.mmd +28 -0
  526. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Login/graph.dot +40 -0
  527. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Login/report.md +7 -0
  528. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Login/sany.out +1 -0
  529. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Login/verdict-1.out +47 -0
  530. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Login/view.mjs +1 -0
  531. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginGuarded/ChartRun.out +57 -0
  532. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginGuarded/LoginGuarded.cfg +2 -0
  533. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginGuarded/LoginGuarded.tla +64 -0
  534. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginGuarded/chart.mmd +28 -0
  535. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginGuarded/graph.dot +37 -0
  536. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginGuarded/report.md +8 -0
  537. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginGuarded/sany.out +1 -0
  538. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginGuarded/verdict-1.out +47 -0
  539. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginGuarded/view.mjs +1 -0
  540. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/ChartRun.out +60 -0
  541. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/LoginParallel.cfg +3 -0
  542. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/LoginParallel.tla +64 -0
  543. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/chart.mmd +44 -0
  544. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/graph.dot +58 -0
  545. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/report.md +17 -0
  546. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/sany.out +1 -0
  547. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/verdict-1.exit +1 -0
  548. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/verdict-1.out +83 -0
  549. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/verdict-2.out +57 -0
  550. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/view.mjs +1 -0
  551. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/ChartRun.out +60 -0
  552. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/MediaPlayer.cfg +3 -0
  553. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/MediaPlayer.tla +103 -0
  554. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/chart.mmd +43 -0
  555. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/graph.dot +93 -0
  556. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/report.md +14 -0
  557. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/sany.out +1 -0
  558. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/verdict-1.exit +1 -0
  559. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/verdict-1.out +59 -0
  560. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/verdict-2.out +72 -0
  561. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/view.mjs +3 -0
  562. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerFixed/ChartRun.out +57 -0
  563. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerFixed/MediaPlayerFixed.cfg +2 -0
  564. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerFixed/MediaPlayerFixed.tla +100 -0
  565. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerFixed/chart.mmd +31 -0
  566. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerFixed/graph.dot +85 -0
  567. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerFixed/report.md +9 -0
  568. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerFixed/sany.out +1 -0
  569. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerFixed/verdict-1.out +47 -0
  570. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerFixed/view.mjs +3 -0
  571. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/ChartRun.out +59 -0
  572. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/MediaPlayer.tla +103 -0
  573. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/MediaPlayerProps.cfg +3 -0
  574. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/MediaPlayerProps.tla +6 -0
  575. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/chart.mmd +42 -0
  576. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/graph.dot +93 -0
  577. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/report.md +19 -0
  578. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/sany.out +2 -0
  579. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-1.exit +1 -0
  580. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-1.out +61 -0
  581. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-2.out +59 -0
  582. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-3.out +61 -0
  583. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-4.exit +1 -0
  584. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-4.out +66 -0
  585. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-5.exit +1 -0
  586. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-5.out +58 -0
  587. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-6.out +49 -0
  588. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/view.mjs +3 -0
  589. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/PickWorker/ChartRun.out +57 -0
  590. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/PickWorker/PickWorker.cfg +6 -0
  591. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/PickWorker/PickWorker.tla +11 -0
  592. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/PickWorker/chart.mmd +5 -0
  593. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/PickWorker/graph.dot +11 -0
  594. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/PickWorker/report.md +7 -0
  595. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/PickWorker/sany.out +5 -0
  596. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/PickWorker/verdict-1.out +70 -0
  597. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Shadow/ChartRun.out +61 -0
  598. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Shadow/Shadow.cfg +4 -0
  599. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Shadow/Shadow.tla +11 -0
  600. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Shadow/ShadowLib.tla +6 -0
  601. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Shadow/ShadowSub.tla +3 -0
  602. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Shadow/chart.mmd +9 -0
  603. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Shadow/graph.dot +16 -0
  604. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Shadow/report.md +8 -0
  605. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Shadow/sany.out +4 -0
  606. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Shadow/verdict-1.out +65 -0
  607. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/ChartRun.out +59 -0
  608. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/SpacedNames.cfg +2 -0
  609. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/SpacedNames.tla +9 -0
  610. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/chart.mmd +23 -0
  611. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/graph.dot +17 -0
  612. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/report.md +15 -0
  613. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/sany.out +1 -0
  614. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/verdict-1.exit +1 -0
  615. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/verdict-1.out +65 -0
  616. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/verdict-2.exit +1 -0
  617. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/verdict-2.out +75 -0
  618. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/ChartRun.out +69 -0
  619. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/TwoPhase.cfg +3 -0
  620. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/TwoPhase.tla +75 -0
  621. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/chart.mmd +60 -0
  622. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/graph.dot +297 -0
  623. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/report.md +20 -0
  624. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/sany.out +1 -0
  625. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/verdict-1.exit +1 -0
  626. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/verdict-1.out +95 -0
  627. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/verdict-2.out +57 -0
  628. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/view.mjs +1 -0
  629. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhaseFixed/ChartRun.out +57 -0
  630. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhaseFixed/TwoPhaseFixed.cfg +3 -0
  631. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhaseFixed/TwoPhaseFixed.tla +75 -0
  632. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhaseFixed/chart.mmd +37 -0
  633. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhaseFixed/graph.dot +223 -0
  634. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhaseFixed/report.md +11 -0
  635. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhaseFixed/sany.out +1 -0
  636. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhaseFixed/verdict-1.out +47 -0
  637. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhaseFixed/view.mjs +1 -0
  638. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/ChartRun.exit +1 -0
  639. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/ChartRun.out +75 -0
  640. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/TypeGuard.cfg +5 -0
  641. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/TypeGuard.tla +11 -0
  642. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/chart.mmd +18 -0
  643. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/graph.dot +14 -0
  644. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/report.md +29 -0
  645. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/sany.out +2 -0
  646. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/verdict-1.exit +1 -0
  647. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/verdict-1.out +64 -0
  648. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/verdict-2.exit +1 -0
  649. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/verdict-2.out +75 -0
  650. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/ChartRun.out +58 -0
  651. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/UserNoDeadlock.cfg +2 -0
  652. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/UserNoDeadlock.tla +8 -0
  653. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/chart.mmd +22 -0
  654. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/graph.dot +16 -0
  655. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/report.md +15 -0
  656. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/sany.out +2 -0
  657. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/verdict-1.exit +1 -0
  658. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/verdict-1.out +56 -0
  659. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/verdict-2.exit +1 -0
  660. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/verdict-2.out +77 -0
  661. package/plugins/deepmodebot/skills/statechart/scripts/test/corpus.test.ts +441 -0
  662. package/plugins/deepmodebot/skills/statechart/scripts/test/differential.test.ts +565 -0
  663. package/plugins/deepmodebot/skills/statechart/scripts/test/drawn.ts +20 -0
  664. package/plugins/deepmodebot/skills/statechart/scripts/test/grid/Grid.cfg +2 -0
  665. package/plugins/deepmodebot/skills/statechart/scripts/test/grid/Grid.tla +9 -0
  666. package/plugins/deepmodebot/skills/statechart/scripts/test/grid/sany.out +2 -0
  667. package/plugins/deepmodebot/skills/statechart/scripts/test/java.ts +63 -0
  668. package/plugins/deepmodebot/skills/statechart/scripts/test/labels.ts +648 -0
  669. package/plugins/deepmodebot/skills/statechart/scripts/test/messages.test.ts +226 -0
  670. package/plugins/deepmodebot/skills/statechart/scripts/test/pipeline.test.ts +270 -0
  671. package/plugins/deepmodebot/skills/statechart/scripts/test/plain-tlc.test.ts +255 -0
  672. package/plugins/deepmodebot/skills/statechart/scripts/test/render.test.ts +145 -0
  673. package/plugins/deepmodebot/skills/statechart/scripts/test/tlc-out.test.ts +90 -0
  674. package/plugins/deepmodebot/skills/statechart/scripts/test/tlc.ts +158 -0
  675. package/plugins/deepmodebot/skills/statechart/scripts/tsconfig.json +11 -0
  676. package/plugins/deepmodebot/skills/statechart/scripts/worker.ts +35 -0
  677. package/plugins/deepmodebot/agents/reviewer/agent.md +0 -33
  678. package/plugins/deepmodebot/agents/scout/agent.md +0 -34
  679. package/plugins/deepmodebot/agents/security-reviewer/agent.md +0 -30
  680. package/plugins/deepmodebot/skills/agent-harnesses/assets/sdks/bun.lock +0 -391
  681. package/plugins/deepmodebot/skills/deepmodebot/assets/agents-md/test_agents_md.py +0 -146
  682. package/plugins/deepmodebot/skills/deepmodebot/assets/contain/test_antigravity_guard.py +0 -483
  683. package/plugins/deepmodebot/skills/deepmodebot/assets/contain/test_audit_regressions.py +0 -139
  684. package/plugins/deepmodebot/skills/deepmodebot/assets/contain/test_contain.py +0 -301
  685. package/plugins/deepmodebot/skills/deepmodebot/assets/contain/test_omp_mcp.py +0 -602
  686. package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/test_design.py +0 -69
  687. package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/test_evidence.py +0 -160
  688. package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/test_record.py +0 -180
  689. package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/test_review.py +0 -265
  690. package/plugins/deepmodebot/skills/deepmodebot/assets/git-guardrails/test_git_guard.py +0 -192
  691. package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/test_bot.py +0 -2182
  692. package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/test_brand.py +0 -19
  693. package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/test_local_updates.py +0 -691
  694. package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/test_review_context.py +0 -127
  695. package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/test_workspace_cleanup.py +0 -496
  696. package/plugins/deepmodebot/skills/deepmodebot/assets/loop/test_loop.py +0 -1426
  697. package/plugins/deepmodebot/skills/deepmodebot/assets/loop/test_plan.py +0 -320
  698. package/plugins/deepmodebot/skills/deepmodebot/assets/loop/test_windows_job.py +0 -326
  699. package/plugins/deepmodebot/skills/deepmodebot/assets/perf-audit/test_bench_harness.py +0 -55
  700. package/plugins/deepmodebot/skills/deepmodebot/assets/perf-audit/test_perf_audit.py +0 -53
  701. package/plugins/deepmodebot/skills/deepmodebot/assets/pr-agent/test_diff_coverage.py +0 -94
  702. package/plugins/deepmodebot/skills/deepmodebot/assets/pr-conversation/test_arena.py +0 -610
  703. package/plugins/deepmodebot/skills/deepmodebot/assets/scrape/test_yt_enrich.py +0 -250
  704. package/plugins/deepmodebot/skills/deepmodebot/assets/tournament/test_tournament.py +0 -654
  705. package/plugins/deepmodebot/skills/deepmodebot/assets/workspace-map/test_workspace_map.py +0 -879
@@ -0,0 +1,2867 @@
1
+ use crate::util::{json_escape, parallel_map, sha256_hex};
2
+ use std::collections::{BTreeMap, BTreeSet};
3
+ use std::fs;
4
+ use std::path::{Path, PathBuf};
5
+ use std::process::{Command, ExitCode};
6
+
7
+ #[derive(Clone, Debug, PartialEq, Eq)]
8
+ pub struct RewardFinding {
9
+ pub severity: &'static str,
10
+ pub rule: &'static str,
11
+ pub file: String,
12
+ pub line: usize,
13
+ pub message: String,
14
+ pub fix: &'static str,
15
+ }
16
+
17
+ const MIN_FLOOR_EPSILON: f64 = 1e-4;
18
+
19
+ fn metric_min_floor(metric: &str) -> f64 {
20
+ match metric {
21
+ "iou" | "ssim" | "dice" | "f1" | "auc" | "accuracy" | "acc" | "precision" | "recall"
22
+ | "fidelity" | "similarity" | "coverage" | "pass_rate" | "win_rate" | "ndcg" | "mrr"
23
+ | "hit_rate" | "r2" | "spearman" | "pearson" => 0.50,
24
+ "clip" | "clip_score" | "ap" | "map" | "bleu" | "rouge" => 0.15,
25
+ "psnr" => 10.0,
26
+ "protrusion" => 0.02,
27
+ "score" | "confidence" | "symmetry" => 0.05,
28
+ "cov_fail_under" | "fail_under" => 50.0,
29
+ _ => MIN_FLOOR_EPSILON,
30
+ }
31
+ }
32
+ const BARE_LOWER_METRICS: &[&str] = &[
33
+ "iou", "ssim", "psnr", "clip_score", "dice", "f1", "auc", "bleu", "rouge", "accuracy",
34
+ "precision", "recall", "fidelity", "similarity", "coverage", "pass_rate", "win_rate",
35
+ "score", "confidence", "protrusion", "symmetry", "fail_under",
36
+ "throughput", "qps", "rps", "tps", "fps", "ops_per_sec", "tok_per_sec", "speedup",
37
+ "ndcg", "mrr", "hit_rate", "sharpe", "r2", "spearman", "pearson",
38
+ ];
39
+
40
+ const QUAL_LOWER_METRICS: &[&str] = &[
41
+ "iou", "ssim", "psnr", "clip", "clip_score", "dice", "f1", "auc", "ap", "map", "bleu",
42
+ "rouge", "accuracy", "acc", "precision", "recall", "fidelity", "similarity", "coverage",
43
+ "pass_rate", "win_rate", "score", "confidence", "protrusion", "symmetry", "fail_under",
44
+ "cov_fail_under", "throughput", "qps", "rps", "tps", "fps", "ops_per_sec", "tok_per_sec",
45
+ "speedup", "ndcg", "mrr", "hit_rate", "sharpe", "r2", "spearman", "pearson",
46
+ ];
47
+
48
+ const BARE_UPPER_METRICS: &[&str] = &[
49
+ "mse", "mae", "rmse", "lpips", "chamfer", "hausdorff", "drift", "tolerance", "holes",
50
+ "non_manifold", "latency", "latency_ms", "p50", "p95", "p99", "p99_ms", "ttft", "ttft_ms",
51
+ "max_ms", "duration_ms", "memory_mb", "rss_mb", "heap_mb", "allocs", "bundle_kb",
52
+ "perplexity", "ppl", "wer", "cer", "fpr", "fnr", "max_diff_pixel_ratio", "max_diff_pixels",
53
+ ];
54
+
55
+ const QUAL_UPPER_METRICS: &[&str] = &[
56
+ "mse", "mae", "rmse", "lpips", "chamfer", "hausdorff", "drift", "tolerance", "holes",
57
+ "non_manifold", "latency", "latency_ms", "p50", "p95", "p99", "p99_ms", "ttft", "ttft_ms",
58
+ "max_ms", "duration_ms", "memory_mb", "rss_mb", "heap_mb", "allocs", "bundle_kb",
59
+ "perplexity", "ppl", "wer", "cer", "fpr", "fnr", "max_diff_pixel_ratio", "max_diff_pixels",
60
+ "err", "error", "loss", "tol", "epsilon", "eps",
61
+ ];
62
+ const SKIP_FLAGS: &[&str] = &[
63
+ "--skip-gate",
64
+ "--skip-gates",
65
+ "--skip-verify",
66
+ "--skip-validation",
67
+ "--skip-reference",
68
+ "--skip-fidelity",
69
+ "--bypass-gate",
70
+ "--pass-if-no-tests",
71
+ "--passWithNoTests",
72
+ "--no-cov",
73
+ ];
74
+
75
+ const PRIMITIVE_TOKENS: &[&str] = &[
76
+ "bpy.ops.mesh.primitive_cube_add",
77
+ "bpy.ops.mesh.primitive_cone_add",
78
+ "bpy.ops.mesh.primitive_cylinder_add",
79
+ "bpy.ops.mesh.primitive_uv_sphere_add",
80
+ "bpy.ops.mesh.primitive_ico_sphere_add",
81
+ "bpy.ops.mesh.primitive_torus_add",
82
+ "bpy.ops.mesh.primitive_monkey_add",
83
+ "bpy.ops.mesh.primitive_plane_add",
84
+ "bpy.ops.mesh.primitive_grid_add",
85
+ ];
86
+
87
+ const PRIMITIVE_PATHS: &[&str] = &[
88
+ "/Engine/BasicShapes/Cube",
89
+ "/Engine/BasicShapes/Cone",
90
+ "/Engine/BasicShapes/Cylinder",
91
+ "/Engine/BasicShapes/Sphere",
92
+ ];
93
+
94
+ const PRIMITIVE_FN_CALLS: &[&str] = &[
95
+ "trimesh.creation.box",
96
+ "trimesh.creation.cone",
97
+ "trimesh.creation.cylinder",
98
+ "trimesh.creation.icosphere",
99
+ "trimesh.creation.uv_sphere",
100
+ "trimesh.creation.capsule",
101
+ "trimesh.creation.annulus",
102
+ "create_cube",
103
+ "create_cone",
104
+ "create_cylinder",
105
+ "create_uv_sphere",
106
+ "create_icosphere",
107
+ "THREE.BoxGeometry",
108
+ "THREE.ConeGeometry",
109
+ "THREE.CylinderGeometry",
110
+ "THREE.SphereGeometry",
111
+ "THREE.IcosahedronGeometry",
112
+ "MeshBuilder.CreateBox",
113
+ "MeshBuilder.CreateSphere",
114
+ "MeshBuilder.CreateCylinder",
115
+ "MeshBuilder.CreateCone",
116
+ ];
117
+
118
+ fn git(root: &Path, args: &[&str]) -> Option<(bool, String)> {
119
+ let out = Command::new("git")
120
+ .arg("-c")
121
+ .arg("core.quotePath=false")
122
+ .arg("-C")
123
+ .arg(root)
124
+ .args(args)
125
+ .output()
126
+ .ok()?;
127
+ Some((
128
+ out.status.success(),
129
+ String::from_utf8_lossy(&out.stdout).into_owned(),
130
+ ))
131
+ }
132
+
133
+ fn is_test_file(rel: &str) -> bool {
134
+ let low = rel.to_ascii_lowercase();
135
+ if low.starts_with("tests/")
136
+ || low.starts_with("test/")
137
+ || low.starts_with("spec/")
138
+ || low.starts_with("__tests__/")
139
+ || low.starts_with("evals/")
140
+ || low.contains("/tests/")
141
+ || low.contains("/test/")
142
+ || low.contains("/spec/")
143
+ || low.contains("/__tests__/")
144
+ || low.contains("/evals/")
145
+ {
146
+ return true;
147
+ }
148
+ let fname = low.rsplit('/').next().unwrap_or(&low);
149
+ fname.starts_with("test_")
150
+ || fname.contains("_test.")
151
+ || fname.contains(".test.")
152
+ || fname.contains(".spec.")
153
+ }
154
+
155
+ fn is_gate_or_eval_file(rel: &str) -> bool {
156
+ let low = rel.to_ascii_lowercase();
157
+ if [
158
+ "gate/", "gates/", "eval/", "evals/", "bench/", "benchmark/", "benchmarks/", "validator/", "validators/",
159
+ ]
160
+ .iter()
161
+ .any(|d| low.starts_with(d) || low.contains(&format!("/{}", d)))
162
+ {
163
+ return true;
164
+ }
165
+ let fname = low.rsplit('/').next().unwrap_or(&low);
166
+ let Some((stem, _ext)) = fname.rsplit_once('.') else {
167
+ return false;
168
+ };
169
+ [
170
+ "gate", "eval", "bench", "validator", "fidelity", "metric", "scorer",
171
+ ]
172
+ .iter()
173
+ .any(|k| stem == *k || stem.ends_with(&format!("_{}", k)) || stem.ends_with(&format!("-{}", k)))
174
+ }
175
+
176
+ fn is_migration_file(rel: &str) -> bool {
177
+ let low = rel.to_ascii_lowercase();
178
+ [
179
+ "migration/", "migrations/", "alembic/", "drizzle/", "prisma/migrations/",
180
+ ]
181
+ .iter()
182
+ .any(|d| low.starts_with(d) || low.contains(&format!("/{}", d)))
183
+ || low.contains("migrat")
184
+ }
185
+
186
+ fn strip_trailing_comment<'a>(ext: &str, line: &'a str) -> &'a str {
187
+ let hash_cmt = matches!(
188
+ ext,
189
+ "py" | "sh" | "ps1" | "yml" | "yaml" | "toml" | "ini" | "cfg" | "tf"
190
+ );
191
+ let slash_cmt = matches!(
192
+ ext,
193
+ "js" | "mjs" | "cjs" | "ts" | "tsx" | "jsx" | "rs" | "go" | "json" | "jsonc"
194
+ );
195
+ let dash_cmt = matches!(ext, "sql" | "lean");
196
+ let semi_cmt = ext == "smt2";
197
+ if !hash_cmt && !slash_cmt && !dash_cmt && !semi_cmt {
198
+ return line;
199
+ }
200
+ let bytes = line.as_bytes();
201
+ let mut quote: Option<u8> = None;
202
+ let mut i = 0;
203
+ while i < bytes.len() {
204
+ let b = bytes[i];
205
+ if let Some(q) = quote {
206
+ if b == b'\\' && i + 1 < bytes.len() {
207
+ i += 2;
208
+ continue;
209
+ }
210
+ if b == q {
211
+ quote = None;
212
+ }
213
+ } else if b == b'"' || b == b'\'' {
214
+ quote = Some(b);
215
+ } else if hash_cmt
216
+ && b == b'#'
217
+ && !line[i..].starts_with("#[")
218
+ && !line[i..].starts_with("#![")
219
+ {
220
+ return &line[..i];
221
+ } else if slash_cmt && i + 1 < bytes.len() && b == b'/' && bytes[i + 1] == b'/' {
222
+ return &line[..i];
223
+ } else if dash_cmt && i + 1 < bytes.len() && b == b'-' && bytes[i + 1] == b'-' {
224
+ return &line[..i];
225
+ } else if semi_cmt && b == b';' {
226
+ return &line[..i];
227
+ }
228
+ i += 1;
229
+ }
230
+ line
231
+ }
232
+ fn is_scanner_or_comment(ext: &str, line: &str) -> bool {
233
+ let code = strip_trailing_comment(ext, line).trim();
234
+ let code_low = code.to_ascii_lowercase();
235
+ if code.is_empty()
236
+ || ext == "md"
237
+ || (matches!(ext, "cmd" | "bat") && (code_low.starts_with("rem ") || code_low.starts_with("::")))
238
+ {
239
+ return true;
240
+ }
241
+ for meta in [
242
+ "re.compile(",
243
+ "Regex::new",
244
+ "THRESHOLD_ZERO_RE",
245
+ "CLI_MIN_VAL_RE",
246
+ "SKIP_GATE_RE",
247
+ "PRIMITIVE_STANDIN_RE",
248
+ "PRIMITIVE_CALLS",
249
+ "SKIP_FLAGS",
250
+ "HARDCODED_PASS_RE",
251
+ "TEST_SKIP_RE",
252
+ "TEST_SKIP_DECORATOR_RE",
253
+ "REWARD_HACK_CMD_RE",
254
+ "SNAPSHOT_OVERWRITE_RE",
255
+ "PACKAGE_NOOP_SCRIPT_RE",
256
+ "E2E_API_STUB_RE",
257
+ "ML_EVAL_LEAKAGE_RE",
258
+ "PROD_TLS_BYPASS_RE",
259
+ "PROD_FK_BYPASS_RE",
260
+ "\"rule\":",
261
+ "rule: \"",
262
+ "Zeroed quality threshold",
263
+ "Zero, negative, or near-zero quality threshold",
264
+ "Goodhart / Anti-Reward-Hacking",
265
+ "`--min-",
266
+ ] {
267
+ if code.contains(meta) {
268
+ return true;
269
+ }
270
+ }
271
+ false
272
+ }
273
+
274
+ fn parse_leading_f64(raw: &str) -> Option<f64> {
275
+ let t = raw
276
+ .trim_start()
277
+ .trim_start_matches([',', ' ', '\t'])
278
+ .trim_start_matches(['"', '\''])
279
+ .trim_start();
280
+ let low = t.to_ascii_lowercase();
281
+ for (tok, v) in [
282
+ ("-infinity", f64::NEG_INFINITY),
283
+ ("+infinity", f64::INFINITY),
284
+ ("infinity", f64::INFINITY),
285
+ ("-inf", f64::NEG_INFINITY),
286
+ ("+inf", f64::INFINITY),
287
+ ("inf", f64::INFINITY),
288
+ ("-nan", f64::NAN),
289
+ ("+nan", f64::NAN),
290
+ ("nan", f64::NAN),
291
+ ] {
292
+ if let Some(rest) = low.strip_prefix(tok) {
293
+ if rest.is_empty() || (!rest.as_bytes()[0].is_ascii_alphanumeric() && rest.as_bytes()[0] != b'_') {
294
+ return Some(v);
295
+ }
296
+ }
297
+ }
298
+ let bytes = t.as_bytes();
299
+ let mut i = 0;
300
+ if i < bytes.len() && (bytes[i] == b'-' || bytes[i] == b'+') {
301
+ i += 1;
302
+ }
303
+ let mut digits_seen = 0usize;
304
+ while i < bytes.len() && (bytes[i].is_ascii_digit() || bytes[i] == b'_') {
305
+ if bytes[i].is_ascii_digit() {
306
+ digits_seen += 1;
307
+ }
308
+ i += 1;
309
+ }
310
+ if i < bytes.len() && bytes[i] == b'.' {
311
+ i += 1;
312
+ while i < bytes.len() && (bytes[i].is_ascii_digit() || bytes[i] == b'_') {
313
+ if bytes[i].is_ascii_digit() {
314
+ digits_seen += 1;
315
+ }
316
+ i += 1;
317
+ }
318
+ }
319
+ if digits_seen == 0 {
320
+ return None;
321
+ }
322
+ if i < bytes.len() && (bytes[i] == b'e' || bytes[i] == b'E') {
323
+ let exp_pos = i;
324
+ i += 1;
325
+ if i < bytes.len() && (bytes[i] == b'+' || bytes[i] == b'-') {
326
+ i += 1;
327
+ }
328
+ let exp_digits = i;
329
+ while i < bytes.len() && (bytes[i].is_ascii_digit() || bytes[i] == b'_') {
330
+ i += 1;
331
+ }
332
+ if i == exp_digits {
333
+ i = exp_pos;
334
+ }
335
+ }
336
+ if i < bytes.len() && (bytes[i].is_ascii_alphanumeric() || bytes[i] == b'_') {
337
+ return None;
338
+ }
339
+ let cleaned: String = t[..i].chars().filter(|c| *c != '_').collect();
340
+ cleaned.parse::<f64>().ok()
341
+ }
342
+
343
+ fn prefix_metric_floor(tok: &str) -> Option<f64> {
344
+ let norm = tok.replace('-', "_");
345
+ if matches!(
346
+ norm.as_str(),
347
+ "p" | "k" | "port" | "ports" | "workers" | "threads" | "bytes" | "size" | "len" | "length"
348
+ | "delay" | "wait" | "sleep" | "timeout" | "retries" | "count" | "items" | "nodes"
349
+ | "epochs" | "steps" | "batch"
350
+ ) {
351
+ return None;
352
+ }
353
+ if QUAL_LOWER_METRICS.contains(&norm.as_str()) {
354
+ return Some(metric_min_floor(&norm));
355
+ }
356
+ if norm.is_empty() {
357
+ return None;
358
+ }
359
+ let mut best: Option<f64> = None;
360
+ for m in QUAL_LOWER_METRICS {
361
+ if m.starts_with(&norm) {
362
+ let f = metric_min_floor(m);
363
+ best = Some(best.map_or(f, |b| b.max(f)));
364
+ }
365
+ }
366
+ best
367
+ }
368
+
369
+ pub fn has_threshold_zero_or_skip(line: &str) -> bool {
370
+ let low = line.to_ascii_lowercase();
371
+ for flag_pref in ["--min-", "--gate-min-"] {
372
+ let mut cfrom = 0;
373
+ while let Some(rel) = low[cfrom..].find(flag_pref) {
374
+ let pos = cfrom + rel;
375
+ let name_start = pos + flag_pref.len();
376
+ cfrom = name_start;
377
+ if pos > 0
378
+ && (low.as_bytes()[pos - 1].is_ascii_alphanumeric()
379
+ || low.as_bytes()[pos - 1] == b'_')
380
+ {
381
+ continue;
382
+ }
383
+ let name_len = low[name_start..]
384
+ .bytes()
385
+ .take_while(|b| b.is_ascii_alphanumeric() || *b == b'-' || *b == b'_')
386
+ .count();
387
+ if name_len == 0 {
388
+ continue;
389
+ }
390
+ let tok = &low[name_start..name_start + name_len];
391
+ let Some(floor) = prefix_metric_floor(tok) else {
392
+ continue;
393
+ };
394
+ let tail = low[name_start + name_len..].trim_start_matches(['"', '\'']);
395
+ if let Some(rest) = tail
396
+ .strip_prefix('=')
397
+ .or_else(|| tail.strip_prefix(','))
398
+ .or_else(|| tail.strip_prefix(' '))
399
+ .or_else(|| tail.strip_prefix('\t'))
400
+ {
401
+ if let Some(val) = parse_leading_f64(rest) {
402
+ if !val.is_finite() || val < floor {
403
+ return true;
404
+ }
405
+ }
406
+ }
407
+ }
408
+ }
409
+ for bare_pref in ["--min", "--mi", "--gate-min", "--gate-mi"] {
410
+ let mut bfrom = 0;
411
+ while let Some(rel) = low[bfrom..].find(bare_pref) {
412
+ let pos = bfrom + rel;
413
+ let end = pos + bare_pref.len();
414
+ bfrom = end;
415
+ if pos > 0
416
+ && (low.as_bytes()[pos - 1].is_ascii_alphanumeric()
417
+ || low.as_bytes()[pos - 1] == b'_')
418
+ {
419
+ continue;
420
+ }
421
+ if end < low.len()
422
+ && (low.as_bytes()[end].is_ascii_alphanumeric()
423
+ || low.as_bytes()[end] == b'-'
424
+ || low.as_bytes()[end] == b'_')
425
+ {
426
+ continue;
427
+ }
428
+ let tail = low[end..].trim_start_matches(['"', '\'']);
429
+ if let Some(rest) = tail
430
+ .strip_prefix('=')
431
+ .or_else(|| tail.strip_prefix(','))
432
+ .or_else(|| tail.strip_prefix(' '))
433
+ .or_else(|| tail.strip_prefix('\t'))
434
+ {
435
+ if let Some(val) = parse_leading_f64(rest) {
436
+ if !val.is_finite() || val < 0.50 {
437
+ return true;
438
+ }
439
+ }
440
+ }
441
+ }
442
+ }
443
+ for m in QUAL_LOWER_METRICS {
444
+ let floor = metric_min_floor(m);
445
+ for pref in ["min_", "minimum_"] {
446
+ let kw = format!("{}{}", pref, m);
447
+ let mut from = 0;
448
+ while let Some(rel) = low[from..].find(&kw) {
449
+ let pos = from + rel;
450
+ let end = pos + kw.len();
451
+ from = end;
452
+ let prev_ok = pos == 0
453
+ || (!low.as_bytes()[pos - 1].is_ascii_alphanumeric()
454
+ && low.as_bytes()[pos - 1] != b'_');
455
+ let next_ok = end >= low.len()
456
+ || (!low.as_bytes()[end].is_ascii_alphanumeric()
457
+ && low.as_bytes()[end] != b'_');
458
+ if !prev_ok || !next_ok {
459
+ continue;
460
+ }
461
+ let rest = low[end..].trim_start_matches(['"', '\'']).trim_start();
462
+ if let Some(val_part) = rest
463
+ .strip_prefix('=')
464
+ .filter(|s| !s.starts_with('='))
465
+ .or_else(|| rest.strip_prefix(':'))
466
+ {
467
+ if let Some(val) = parse_leading_f64(val_part) {
468
+ if !val.is_finite() || val < floor {
469
+ return true;
470
+ }
471
+ }
472
+ }
473
+ }
474
+ }
475
+ }
476
+ for flag in SKIP_FLAGS {
477
+ let fl_low = flag.to_ascii_lowercase();
478
+ let mut sfrom = 0;
479
+ while let Some(rel) = low[sfrom..].find(&fl_low) {
480
+ let pos = sfrom + rel;
481
+ let end = pos + fl_low.len();
482
+ sfrom = end;
483
+ let prev_ok = pos == 0
484
+ || (!low.as_bytes()[pos - 1].is_ascii_alphanumeric() && low.as_bytes()[pos - 1] != b'_');
485
+ let next_ok = end >= low.len()
486
+ || (!low.as_bytes()[end].is_ascii_alphanumeric()
487
+ && low.as_bytes()[end] != b'_'
488
+ && low.as_bytes()[end] != b'-');
489
+ if prev_ok && next_ok {
490
+ return true;
491
+ }
492
+ }
493
+ }
494
+ if let Some(cpos) = low.find("git commit") {
495
+ let seg = low[cpos + "git commit".len()..].split([';', '&', '|']).next().unwrap_or("");
496
+ if seg
497
+ .split_ascii_whitespace()
498
+ .any(|t| t == "-n" || t == "--no-verify")
499
+ {
500
+ return true;
501
+ }
502
+ }
503
+ if let Some(pos) = low.find("--cov-fail-under") {
504
+ let tail = low[pos + "--cov-fail-under".len()..].trim_start_matches(['"', '\'']);
505
+ if let Some(rest) = tail
506
+ .strip_prefix('=')
507
+ .or_else(|| tail.strip_prefix(','))
508
+ .or_else(|| tail.strip_prefix(' '))
509
+ .or_else(|| tail.strip_prefix('\t'))
510
+ {
511
+ if let Some(val) = parse_leading_f64(rest) {
512
+ if !val.is_finite() || val < 50.0 {
513
+ return true;
514
+ }
515
+ }
516
+ }
517
+ }
518
+ for (flag_kw, bad_val) in [
519
+ ("--require-spark-receipt", "false"),
520
+ ("--gate-mode", "off"),
521
+ ("--measured-gates", "off"),
522
+ ("--skip-heavy-renders", "true"),
523
+ ("--check-360", "false"),
524
+ ] {
525
+ if let Some(pos) = low.find(flag_kw) {
526
+ let tail = low[pos + flag_kw.len()..].trim_start_matches(['"', '\'']);
527
+ if let Some(rest) = tail
528
+ .strip_prefix('=')
529
+ .or_else(|| tail.strip_prefix(','))
530
+ .or_else(|| tail.strip_prefix(' '))
531
+ {
532
+ let val = rest.trim_start_matches([' ', '"', '\'']);
533
+ if val.starts_with(bad_val) {
534
+ return true;
535
+ }
536
+ }
537
+ }
538
+ }
539
+ for kw in ["skip_reference", "skip_validation", "skip_fidelity", "bypass_gate"] {
540
+ if let Some(pos) = low.find(kw) {
541
+ let rest = low[pos + kw.len()..].trim_start();
542
+ if let Some(v) = rest.strip_prefix('=').or_else(|| rest.strip_prefix(':')) {
543
+ let vt = v.trim_start();
544
+ if vt.starts_with("true") || vt.starts_with('1') {
545
+ return true;
546
+ }
547
+ }
548
+ }
549
+ }
550
+ for kw in ["check_reference", "verify_reference", "enforce_provenance"] {
551
+ if let Some(pos) = low.find(kw) {
552
+ let rest = low[pos + kw.len()..].trim_start();
553
+ if let Some(v) = rest.strip_prefix('=').or_else(|| rest.strip_prefix(':')) {
554
+ let vt = v.trim_start();
555
+ if vt.starts_with("false") || vt.starts_with('0') {
556
+ return true;
557
+ }
558
+ }
559
+ }
560
+ }
561
+ if low.contains("go test")
562
+ && (low.contains("-run=^$")
563
+ || low.contains("-run ^$")
564
+ || low.contains("-run=\"^$\"")
565
+ || low.contains("-run='^$'")
566
+ || low.contains("-run \"^$\"")
567
+ || low.contains("-run '^$'"))
568
+ {
569
+ return true;
570
+ }
571
+ false
572
+ }
573
+
574
+ pub fn has_test_skip(line: &str) -> bool {
575
+ let indent = line.bytes().take_while(|b| *b == b' ').count();
576
+ let t = line.trim_start();
577
+ if t.starts_with('"') || t.starts_with('\'') {
578
+ return false;
579
+ }
580
+ if t.starts_with("#[ignore") || t.starts_with("# [ignore") {
581
+ return true;
582
+ }
583
+ if t.starts_with("@pytest.mark.xfail") && !t.contains("strict=True") && !t.contains("strict = True") {
584
+ return true;
585
+ }
586
+ for pat in ["@pytest.mark.skip", "@unittest.skip"] {
587
+ if let Some(after) = t.strip_prefix(pat) {
588
+ let boundary_ok = after.is_empty()
589
+ || after.starts_with('(')
590
+ || after.starts_with(|c: char| c.is_ascii_whitespace());
591
+ if boundary_ok {
592
+ return true;
593
+ }
594
+ }
595
+ }
596
+ if indent <= 4 && (t.starts_with("pytest.skip(") || t.starts_with("unittest.skip(")) {
597
+ return true;
598
+ }
599
+ for pat in ["it.skip(", "test.skip(", "describe.skip("] {
600
+ if let Some(after) = t.strip_prefix(pat) {
601
+ let arg = after.trim_start();
602
+ if arg.is_empty()
603
+ || arg.starts_with(')')
604
+ || arg.starts_with('\'')
605
+ || arg.starts_with('"')
606
+ || arg.starts_with('`')
607
+ {
608
+ return true;
609
+ }
610
+ }
611
+ }
612
+ false
613
+ }
614
+
615
+ pub fn find_rs_cfg_test_line(txt: &str) -> Option<usize> {
616
+ let lines: Vec<&str> = txt.lines().collect();
617
+ for (idx, fl) in lines.iter().enumerate() {
618
+ if fl.trim().starts_with("#[cfg(test)]") {
619
+ let mut j = idx + 1;
620
+ while j < lines.len() {
621
+ let nxt = lines[j].trim();
622
+ if nxt.is_empty() || nxt.starts_with("//") || nxt.starts_with("#[") {
623
+ j += 1;
624
+ continue;
625
+ }
626
+ if nxt.starts_with("mod ")
627
+ || nxt.starts_with("pub mod ")
628
+ || nxt.starts_with("pub(crate) mod ")
629
+ {
630
+ return Some(idx + 1);
631
+ }
632
+ break;
633
+ }
634
+ }
635
+ }
636
+ None
637
+ }
638
+
639
+ fn is_ident_char(c: char) -> bool {
640
+ c.is_alphanumeric() || c == '_'
641
+ }
642
+
643
+ pub fn has_primitive_standin(line: &str) -> bool {
644
+ if PRIMITIVE_TOKENS.iter().any(|tok| has_word_token(line, tok)) {
645
+ return true;
646
+ }
647
+ for p in PRIMITIVE_PATHS {
648
+ let mut from = 0;
649
+ while let Some(rel) = line[from..].find(p) {
650
+ let end = from + rel + p.len();
651
+ from = end;
652
+ let next_ok = !line[end..].chars().next().is_some_and(is_ident_char);
653
+ if next_ok {
654
+ return true;
655
+ }
656
+ }
657
+ }
658
+ for fn_name in PRIMITIVE_FN_CALLS {
659
+ let mut from = 0;
660
+ while let Some(rel) = line[from..].find(fn_name) {
661
+ let pos = from + rel;
662
+ let end = pos + fn_name.len();
663
+ from = end;
664
+ let prev_ok = !line[..pos].chars().next_back().is_some_and(is_ident_char);
665
+ let next_ok = !line[end..].chars().next().is_some_and(is_ident_char);
666
+ if !prev_ok {
667
+ continue;
668
+ }
669
+ if line[end..].trim_start().starts_with('(') {
670
+ return true;
671
+ }
672
+ if next_ok && (fn_name.starts_with("THREE.") || fn_name.starts_with("MeshBuilder.")) {
673
+ let before_trimmed = line[..pos].trim_end();
674
+ if let Some(before_new) = before_trimmed.strip_suffix("new") {
675
+ let new_boundary = !before_new.chars().next_back().is_some_and(is_ident_char);
676
+ if new_boundary && pos > before_trimmed.len() {
677
+ return true;
678
+ }
679
+ }
680
+ }
681
+ }
682
+ }
683
+ false
684
+ }
685
+
686
+ fn has_word_token(haystack: &str, word: &str) -> bool {
687
+ let mut from = 0;
688
+ while let Some(rel) = haystack[from..].find(word) {
689
+ let pos = from + rel;
690
+ let end = pos + word.len();
691
+ from = end;
692
+ let prev_ok = !haystack[..pos].chars().next_back().is_some_and(is_ident_char);
693
+ let next_ok = !haystack[end..].chars().next().is_some_and(is_ident_char);
694
+ if prev_ok && next_ok {
695
+ return true;
696
+ }
697
+ }
698
+ false
699
+ }
700
+
701
+ fn has_word_prefix(haystack: &str, pref: &str) -> bool {
702
+ let mut from = 0;
703
+ while let Some(rel) = haystack[from..].find(pref) {
704
+ let pos = from + rel;
705
+ from = pos + pref.len();
706
+ if !haystack[..pos].chars().next_back().is_some_and(is_ident_char) {
707
+ return true;
708
+ }
709
+ }
710
+ false
711
+ }
712
+
713
+ fn extract_unquoted_comment<'a>(ext: &str, line: &'a str) -> &'a str {
714
+ let allow_hash = !matches!(
715
+ ext,
716
+ "rs" | "go" | "js" | "mjs" | "cjs" | "ts" | "tsx" | "jsx" | "c" | "cpp" | "java"
717
+ );
718
+ let bytes = line.as_bytes();
719
+ let mut quote: Option<u8> = None;
720
+ let mut i = 0;
721
+ while i < bytes.len() {
722
+ let b = bytes[i];
723
+ if let Some(q) = quote {
724
+ if b == b'\\' && i + 1 < bytes.len() {
725
+ i += 2;
726
+ continue;
727
+ }
728
+ if b == q {
729
+ quote = None;
730
+ }
731
+ } else if b == b'"' || b == b'\'' {
732
+ quote = Some(b);
733
+ } else if allow_hash
734
+ && b == b'#'
735
+ && !line[i..].starts_with("#[")
736
+ && !line[i..].starts_with("#![")
737
+ {
738
+ return &line[i..];
739
+ } else if i + 1 < bytes.len()
740
+ && b == b'/'
741
+ && (bytes[i + 1] == b'/' || bytes[i + 1] == b'*')
742
+ {
743
+ return &line[i..];
744
+ }
745
+ i += 1;
746
+ }
747
+ ""
748
+ }
749
+
750
+ fn quoted_end(text: &str, mut i: usize, delimiter: &str) -> Option<usize> {
751
+ let bytes = text.as_bytes();
752
+ while i < bytes.len() {
753
+ if bytes[i..].starts_with(delimiter.as_bytes()) {
754
+ return Some(i + delimiter.len());
755
+ }
756
+ i += if bytes[i] == b'\\' { 2 } else { 1 };
757
+ }
758
+ None
759
+ }
760
+
761
+ pub fn scrub_proof_text_lines(ext: &str, text: &str) -> BTreeMap<usize, String> {
762
+ let (open_tok, close_tok) = match ext {
763
+ "lean" => ("/-", "-/"),
764
+ "v" => ("(*", "*)"),
765
+ _ => ("", ""),
766
+ };
767
+ let dash_line = ext == "lean";
768
+ let semi_line = ext == "smt2";
769
+ let mut depth: usize = 0;
770
+ let mut out = BTreeMap::new();
771
+ for (idx, raw) in text.lines().enumerate() {
772
+ let bytes = raw.as_bytes();
773
+ let mut buf = String::with_capacity(raw.len());
774
+ let mut i = 0;
775
+ while i < bytes.len() {
776
+ if depth > 0 {
777
+ if !open_tok.is_empty() && raw[i..].starts_with(open_tok) {
778
+ depth += 1;
779
+ i += 2;
780
+ continue;
781
+ }
782
+ if !close_tok.is_empty() && raw[i..].starts_with(close_tok) {
783
+ depth -= 1;
784
+ buf.push(' ');
785
+ i += 2;
786
+ continue;
787
+ }
788
+ if let Some(ch) = raw[i..].chars().next() {
789
+ i += ch.len_utf8();
790
+ } else {
791
+ break;
792
+ }
793
+ continue;
794
+ }
795
+ if bytes[i] == b'"' {
796
+ buf.push_str("\"\"");
797
+ i = quoted_end(raw, i + 1, "\"").unwrap_or(bytes.len());
798
+ continue;
799
+ }
800
+ if dash_line && raw[i..].starts_with("--") {
801
+ break;
802
+ }
803
+ if semi_line && bytes[i] == b';' {
804
+ break;
805
+ }
806
+ if !open_tok.is_empty() && raw[i..].starts_with(open_tok) {
807
+ depth += 1;
808
+ buf.push(' ');
809
+ i += 2;
810
+ continue;
811
+ }
812
+ if let Some(ch) = raw[i..].chars().next() {
813
+ buf.push(ch);
814
+ i += ch.len_utf8();
815
+ } else {
816
+ break;
817
+ }
818
+ }
819
+ out.insert(idx + 1, buf);
820
+ }
821
+ out
822
+ }
823
+
824
+ fn has_kw_ws_ident(trimmed: &str, kw: &str) -> bool {
825
+ let Some(after) = trimmed.strip_prefix(kw) else {
826
+ return false;
827
+ };
828
+ if !after.chars().next().is_some_and(char::is_whitespace) {
829
+ return false;
830
+ }
831
+ after
832
+ .trim_start()
833
+ .chars()
834
+ .next()
835
+ .is_some_and(|c| c.is_ascii_alphabetic() || c == '_')
836
+ }
837
+
838
+ fn has_admitted_dot(line: &str) -> bool {
839
+ let mut from = 0;
840
+ while let Some(rel) = line[from..].find("Admitted") {
841
+ let pos = from + rel;
842
+ let end = pos + "Admitted".len();
843
+ from = end;
844
+ let prev_ok = !line[..pos].chars().next_back().is_some_and(is_ident_char);
845
+ let next_ok = !line[end..].chars().next().is_some_and(is_ident_char);
846
+ if prev_ok && next_ok && line[end..].trim_start().starts_with('.') {
847
+ return true;
848
+ }
849
+ }
850
+ false
851
+ }
852
+
853
+ fn has_smt_assert_false(line: &str) -> bool {
854
+ let low = line.to_ascii_lowercase();
855
+ let mut from = 0;
856
+ while let Some(rel) = low[from..].find('(') {
857
+ let pos = from + rel + 1;
858
+ from = pos;
859
+ let after_paren = low[pos..].trim_start();
860
+ let Some(after_assert) = after_paren.strip_prefix("assert") else {
861
+ continue;
862
+ };
863
+ if !after_assert.chars().next().is_some_and(char::is_whitespace) {
864
+ continue;
865
+ }
866
+ let after_ws = after_assert.trim_start();
867
+ if let Some(after_false) = after_ws.strip_prefix("false") {
868
+ if after_false.trim_start().starts_with(')') {
869
+ return true;
870
+ }
871
+ }
872
+ }
873
+ false
874
+ }
875
+
876
+ fn has_proof_escape_scrubbed(ext: &str, line: &str) -> bool {
877
+ let t = line.trim_start();
878
+ let after_noncomp = t
879
+ .strip_prefix("noncomputable")
880
+ .filter(|r| r.chars().next().is_some_and(char::is_whitespace))
881
+ .map(str::trim_start)
882
+ .unwrap_or(t);
883
+ match ext {
884
+ "lean" => {
885
+ has_word_token(line, "sorry")
886
+ || has_word_token(line, "sorryAx")
887
+ || has_word_token(line, "admit")
888
+ || has_word_token(line, "native_decide")
889
+ || has_kw_ws_ident(after_noncomp, "axiom")
890
+ }
891
+ "v" => {
892
+ has_admitted_dot(line)
893
+ || has_kw_ws_ident(t, "Axiom")
894
+ || has_kw_ws_ident(t, "Parameter")
895
+ }
896
+ "smt2" => has_smt_assert_false(line),
897
+ _ => false,
898
+ }
899
+ }
900
+
901
+ fn has_tla_cfg_commented_invariant(raw_line: &str) -> bool {
902
+ let t = raw_line.trim_start();
903
+ let Some(rest) = t.strip_prefix("\\*") else {
904
+ return false;
905
+ };
906
+ let u = rest.trim_start();
907
+ ["INVARIANT", "INVARIANTS", "PROPERTY", "PROPERTIES"]
908
+ .iter()
909
+ .any(|kw| u.starts_with(kw) && !u[kw.len()..].chars().next().is_some_and(is_ident_char))
910
+ }
911
+
912
+ fn has_iac_sec_suppression(cmt_slice: &str) -> bool {
913
+ if cmt_slice.is_empty() {
914
+ return false;
915
+ }
916
+ let low = cmt_slice.to_ascii_lowercase();
917
+ let norm_ws: String = low.split_whitespace().collect::<Vec<_>>().join(" ");
918
+ has_word_prefix(&low, "tfsec:ignore:")
919
+ || has_word_prefix(&low, "checkov:skip=")
920
+ || has_word_prefix(&low, "trivy:ignore:")
921
+ || has_word_prefix(&low, "terrascan:skip=")
922
+ || has_word_token(&norm_ws, "kics-scan ignore")
923
+ || has_word_token(&low, "nosemgrep")
924
+ }
925
+
926
+ fn has_vacuous_query(line: &str) -> bool {
927
+ let low = line.to_ascii_lowercase();
928
+ let norm_ws: String = low.split_whitespace().collect::<Vec<_>>().join(" ");
929
+ if has_word_token(&norm_ws, "where false") || has_word_token(&norm_ws, "limit 0") {
930
+ return true;
931
+ }
932
+ let mut from = 0;
933
+ while let Some(rel) = low[from..].find("where") {
934
+ let pos = from + rel;
935
+ let end = pos + "where".len();
936
+ from = end;
937
+ let prev_ok = pos == 0
938
+ || (!low.as_bytes()[pos - 1].is_ascii_alphanumeric() && low.as_bytes()[pos - 1] != b'_');
939
+ if !prev_ok || !low[end..].chars().next().is_some_and(char::is_whitespace) {
940
+ continue;
941
+ }
942
+ let after_where = low[end..].trim_start();
943
+ if let Some(after_one) = after_where.strip_prefix('1') {
944
+ let after_one_ws = after_one.trim_start();
945
+ if let Some(after_eq) = after_one_ws.strip_prefix('=') {
946
+ let after_eq_ws = after_eq.trim_start();
947
+ if let Some(after_zero) = after_eq_ws.strip_prefix('0') {
948
+ if !after_zero
949
+ .chars()
950
+ .next()
951
+ .is_some_and(|c| c.is_ascii_alphanumeric() || c == '_')
952
+ {
953
+ return true;
954
+ }
955
+ }
956
+ }
957
+ }
958
+ }
959
+ false
960
+ }
961
+
962
+ pub fn has_hardcoded_pass(line: &str) -> bool {
963
+ let compact: String = line.chars().filter(|c| !c.is_ascii_whitespace()).collect();
964
+ let low = compact.to_ascii_lowercase();
965
+ let Some(rpos) = low.find("return{") else {
966
+ return false;
967
+ };
968
+ let body = &low[rpos + "return{".len()..];
969
+ let mut after_pass: Option<&str> = None;
970
+ for pk in [
971
+ "\"pass\":", "'pass':", "\"passed\":", "'passed':", "\"ok\":", "'ok':", "\"verdict\":", "'verdict':",
972
+ ] {
973
+ if let Some(rest) = body.strip_prefix(pk) {
974
+ for pv in ["true,", "\"pass\",", "'pass',"] {
975
+ if let Some(r2) = rest.strip_prefix(pv) {
976
+ after_pass = Some(r2);
977
+ break;
978
+ }
979
+ }
980
+ }
981
+ }
982
+ let Some(rem) = after_pass else {
983
+ return false;
984
+ };
985
+ for mk in [
986
+ "\"iou\":", "'iou':", "\"ssim\":", "'ssim':", "\"psnr\":", "'psnr':", "\"score\":", "'score':",
987
+ "\"fidelity\":", "'fidelity':", "\"accuracy\":", "'accuracy':", "\"f1\":", "'f1':", "\"auc\":", "'auc':",
988
+ "\"bleu\":", "'bleu':", "\"rouge\":", "'rouge':", "\"ndcg\":", "'ndcg':", "\"pass_rate\":", "'pass_rate':",
989
+ "\"win_rate\":", "'win_rate':", "\"coverage\":", "'coverage':", "\"throughput\":", "'throughput':",
990
+ "\"speedup\":", "'speedup':",
991
+ ] {
992
+ if let Some(vrest) = rem.strip_prefix(mk) {
993
+ for num in ["1.0", "100.0"] {
994
+ if let Some(tail) = vrest.strip_prefix(num) {
995
+ if !tail.chars().next().is_some_and(|c| c.is_ascii_alphanumeric() || c == '_') {
996
+ return true;
997
+ }
998
+ }
999
+ }
1000
+ }
1001
+ }
1002
+ false
1003
+ }
1004
+
1005
+ fn has_prod_test_branch(line: &str) -> bool {
1006
+ if [
1007
+ "PYTEST_CURRENT_TEST",
1008
+ "JEST_WORKER_ID",
1009
+ "VITEST_WORKER_ID",
1010
+ "UNITTEST_RUNNING",
1011
+ "_called_from_test",
1012
+ ]
1013
+ .iter()
1014
+ .any(|m| line.contains(m))
1015
+ {
1016
+ return true;
1017
+ }
1018
+ let norm: String = line.split_whitespace().collect::<Vec<_>>().join(" ");
1019
+ norm.contains("\"pytest\" in sys.modules")
1020
+ || norm.contains("'pytest' in sys.modules")
1021
+ || norm.contains("\"unittest\" in sys.modules")
1022
+ || norm.contains("'unittest' in sys.modules")
1023
+ }
1024
+
1025
+ fn is_e2e_file(rel: &str) -> bool {
1026
+ let low = rel.to_ascii_lowercase();
1027
+ low.starts_with("e2e/")
1028
+ || low.starts_with("cypress/")
1029
+ || low.starts_with("playwright/")
1030
+ || low.contains("/e2e/")
1031
+ || low.contains("/cypress/")
1032
+ || low.contains("/playwright/")
1033
+ || low.contains(".e2e.")
1034
+ || low.contains(".pw.")
1035
+ }
1036
+
1037
+ fn has_snapshot_overwrite(line: &str) -> bool {
1038
+ let low = line.to_ascii_lowercase();
1039
+ for flag in [
1040
+ "--update-snapshots",
1041
+ "--snapshot-update",
1042
+ "--overwrite-snapshots",
1043
+ "--updatesnapshot",
1044
+ ] {
1045
+ if let Some(pos) = low.find(flag) {
1046
+ let prev_ok = pos == 0
1047
+ || (!low.as_bytes()[pos - 1].is_ascii_alphanumeric() && low.as_bytes()[pos - 1] != b'_');
1048
+ let after = &low[pos + flag.len()..];
1049
+ let next_ok = after.is_empty()
1050
+ || after.starts_with('=')
1051
+ || after.starts_with(|c: char| c.is_ascii_whitespace() || matches!(c, ';' | '&' | '|' | ')' | '"' | '\''));
1052
+ if prev_ok && next_ok {
1053
+ return true;
1054
+ }
1055
+ }
1056
+ }
1057
+ if low.contains("cargo ") && low.contains("insta accept") {
1058
+ return true;
1059
+ }
1060
+ for env_k in ["update_snapshots=", "snapshot_update=", "insta_update="] {
1061
+ if let Some(pos) = low.find(env_k) {
1062
+ let v = low[pos + env_k.len()..].trim_start_matches(['"', '\'']);
1063
+ if v.starts_with('1') || v.starts_with("true") || v.starts_with("always") || v.starts_with("all") {
1064
+ return true;
1065
+ }
1066
+ }
1067
+ }
1068
+ for runner in ["jest ", "vitest ", "playwright test "] {
1069
+ let mut from = 0;
1070
+ while let Some(rel) = low[from..].find(runner) {
1071
+ let pos = from + rel;
1072
+ from = pos + runner.len();
1073
+ let prev_ok = pos == 0
1074
+ || (!low.as_bytes()[pos - 1].is_ascii_alphanumeric()
1075
+ && low.as_bytes()[pos - 1] != b'_'
1076
+ && low.as_bytes()[pos - 1] != b'-');
1077
+ if !prev_ok {
1078
+ continue;
1079
+ }
1080
+ let seg = low[pos + runner.len()..].split([';', '&', '|']).next().unwrap_or("");
1081
+ if seg
1082
+ .split(|c: char| c.is_ascii_whitespace() || c == ')')
1083
+ .any(|tok| tok == "-u" || tok == "--update")
1084
+ {
1085
+ return true;
1086
+ }
1087
+ }
1088
+ }
1089
+ false
1090
+ }
1091
+
1092
+ fn is_package_noop_script(line: &str) -> bool {
1093
+ let t = line.trim().trim_end_matches(',').trim();
1094
+ for key in ["\"test\"", "\"check\"", "\"typecheck\"", "\"lint\"", "\"verify\""] {
1095
+ if let Some(rest) = t.strip_prefix(key) {
1096
+ let Some(val_part) = rest.trim_start().strip_prefix(':') else {
1097
+ continue;
1098
+ };
1099
+ let v = val_part.trim();
1100
+ if let Some(inner) = v.strip_prefix('"').and_then(|s| s.strip_suffix('"')) {
1101
+ let cmd = inner.trim().to_ascii_lowercase();
1102
+ if cmd == "true" || cmd == "exit 0" || cmd == ":" {
1103
+ return true;
1104
+ }
1105
+ if (cmd == "echo" || cmd.starts_with("echo "))
1106
+ && !cmd.contains("&&")
1107
+ && !cmd.contains("||")
1108
+ && !cmd.contains(';')
1109
+ && !cmd.contains('|')
1110
+ {
1111
+ return true;
1112
+ }
1113
+ }
1114
+ }
1115
+ }
1116
+ false
1117
+ }
1118
+
1119
+ fn has_json_key_false(line: &str, keys_low: &[&str]) -> bool {
1120
+ let bytes = line.as_bytes();
1121
+ let mut i = 0;
1122
+ while i < bytes.len() {
1123
+ let q = bytes[i];
1124
+ if q != b'"' && q != b'\'' {
1125
+ i += 1;
1126
+ continue;
1127
+ }
1128
+ let prev = line[..i].trim_end();
1129
+ let is_key_pos = prev.is_empty() || prev.ends_with('{') || prev.ends_with(',');
1130
+ let mut j = i + 1;
1131
+ let mut key_buf = String::new();
1132
+ while j < bytes.len() {
1133
+ if bytes[j] == b'\\' && j + 1 < bytes.len() {
1134
+ key_buf.push(bytes[j + 1] as char);
1135
+ j += 2;
1136
+ continue;
1137
+ }
1138
+ if bytes[j] == q {
1139
+ break;
1140
+ }
1141
+ if let Some(ch) = line[j..].chars().next() {
1142
+ key_buf.push(ch);
1143
+ j += ch.len_utf8();
1144
+ } else {
1145
+ break;
1146
+ }
1147
+ }
1148
+ if j >= bytes.len() {
1149
+ break;
1150
+ }
1151
+ let after = line[j + 1..].trim_start();
1152
+ if is_key_pos {
1153
+ if let Some(vpart) = after.strip_prefix(':') {
1154
+ let val = vpart.trim_start().to_ascii_lowercase();
1155
+ let key_low = key_buf.to_ascii_lowercase();
1156
+ if keys_low.contains(&key_low.as_str())
1157
+ && val.starts_with("false")
1158
+ && !val[5..]
1159
+ .chars()
1160
+ .next()
1161
+ .is_some_and(|c| c.is_ascii_alphanumeric() || c == '_')
1162
+ {
1163
+ return true;
1164
+ }
1165
+ }
1166
+ }
1167
+ i = j + 1;
1168
+ }
1169
+ false
1170
+ }
1171
+
1172
+ pub fn find_mypy_section_lines(txt: &str) -> BTreeSet<usize> {
1173
+ let mut out = BTreeSet::new();
1174
+ let mut in_mypy = false;
1175
+ for (idx, raw) in txt.lines().enumerate() {
1176
+ let t = raw.trim();
1177
+ if t.starts_with('[') && t.ends_with(']') {
1178
+ let sec = t[1..t.len() - 1].trim().to_ascii_lowercase();
1179
+ in_mypy = sec == "mypy"
1180
+ || sec.starts_with("mypy-")
1181
+ || sec.starts_with("mypy.")
1182
+ || sec.starts_with("tool.mypy");
1183
+ continue;
1184
+ }
1185
+ if in_mypy {
1186
+ out.insert(idx + 1);
1187
+ }
1188
+ }
1189
+ out
1190
+ }
1191
+
1192
+ fn has_tsconfig_weaken(line: &str) -> bool {
1193
+ has_json_key_false(
1194
+ line,
1195
+ &[
1196
+ "strict",
1197
+ "noimplicitany",
1198
+ "strictnullchecks",
1199
+ "strictfunctiontypes",
1200
+ "strictbindcallapply",
1201
+ "noimplicitreturns",
1202
+ "noemitonerror",
1203
+ "checkjs",
1204
+ ],
1205
+ )
1206
+ }
1207
+
1208
+ fn has_py_typecheck_weaken(trimmed_low: &str, in_mypy_ctx: bool) -> bool {
1209
+ let compact: String = trimmed_low.chars().filter(|c| !c.is_ascii_whitespace()).collect();
1210
+ (in_mypy_ctx && compact.starts_with("ignore_errors=true"))
1211
+ || compact.starts_with("disallow_untyped_defs=false")
1212
+ || compact.starts_with("check_untyped_defs=false")
1213
+ || compact.contains("typecheckingmode=\"off\"")
1214
+ || compact.contains("'typecheckingmode':'off'")
1215
+ || compact.contains("\"typecheckingmode\":\"off\"")
1216
+ }
1217
+
1218
+ fn has_rs_crate_allow(line: &str) -> bool {
1219
+ let compact: String = line.chars().filter(|c| !c.is_ascii_whitespace()).collect();
1220
+ compact.starts_with("#![allow(warnings)]")
1221
+ || compact.starts_with("#![allow(unused)]")
1222
+ || compact.starts_with("#![allow(dead_code)]")
1223
+ || compact.starts_with("#![allow(clippy::all)]")
1224
+ }
1225
+
1226
+ fn has_e2e_api_stub(line: &str) -> bool {
1227
+ let is_route = line.contains("page.route(") || line.contains("context.route(") || line.contains("cy.intercept(");
1228
+ is_route && (line.contains("/api/") || line.contains("/graphql") || line.contains("/trpc"))
1229
+ }
1230
+
1231
+ fn has_inflated_visual_tolerance(line: &str) -> bool {
1232
+ if let Some(pos) = line.find("maxDiffPixelRatio") {
1233
+ if let Some(colon) = line[pos..].find(':') {
1234
+ if let Some(v) = parse_leading_f64(&line[pos + colon + 1..]) {
1235
+ if v > 0.10 {
1236
+ return true;
1237
+ }
1238
+ }
1239
+ }
1240
+ }
1241
+ if let Some(pos) = line.find("maxDiffPixels") {
1242
+ if let Some(colon) = line[pos..].find(':') {
1243
+ if let Some(v) = parse_leading_f64(&line[pos + colon + 1..]) {
1244
+ if v >= 5000.0 {
1245
+ return true;
1246
+ }
1247
+ }
1248
+ }
1249
+ }
1250
+ false
1251
+ }
1252
+
1253
+ fn has_ml_eval_leakage(line: &str, is_train_or_scratch: bool) -> bool {
1254
+ for prefix in [".fit(", ".train_on_batch("] {
1255
+ if let Some(pos) = line.find(prefix) {
1256
+ let arg = line[pos + prefix.len()..].trim_start();
1257
+ if [
1258
+ "X_test", "x_test", "test_x", "test_dataset", "eval_dataset", "val_dataset",
1259
+ ]
1260
+ .iter()
1261
+ .any(|bad| arg.starts_with(bad) && !arg[bad.len()..].chars().next().is_some_and(|c| c.is_ascii_alphanumeric() || c == '_'))
1262
+ {
1263
+ return true;
1264
+ }
1265
+ }
1266
+ }
1267
+ let compact: String = line.chars().filter(|c| !c.is_ascii_whitespace()).collect();
1268
+ if compact.contains("train_dataset=test_dataset") || compact.contains("train_dataset=eval_dataset") {
1269
+ return true;
1270
+ }
1271
+ is_train_or_scratch
1272
+ && line.contains("load_dataset(")
1273
+ && (compact.contains("split=\"test\"") || compact.contains("split='test'"))
1274
+ }
1275
+
1276
+ fn has_prod_integrity_bypass(line: &str, is_migration: bool) -> bool {
1277
+ let compact: String = line.chars().filter(|c| !c.is_ascii_whitespace()).collect();
1278
+ let low = compact.to_ascii_lowercase();
1279
+ if low.contains("node_tls_reject_unauthorized=0")
1280
+ || low.contains("node_tls_reject_unauthorized=\"0\"")
1281
+ || low.contains("node_tls_reject_unauthorized='0'")
1282
+ || low.contains("insecureskipverify:true")
1283
+ || low.contains("danger_accept_invalid_certs(true)")
1284
+ {
1285
+ return true;
1286
+ }
1287
+ if !is_migration
1288
+ && (low.contains("pragmaforeign_keys=off")
1289
+ || low.contains("pragmaforeign_keys=0")
1290
+ || low.contains("setforeign_key_checks=0"))
1291
+ {
1292
+ return true;
1293
+ }
1294
+ for prefix in ["requests.", "httpx."] {
1295
+ for method in ["get(", "post(", "put(", "delete(", "patch(", "request(", "client(", "asyncclient("] {
1296
+ let call = format!("{}{}", prefix, method);
1297
+ if let Some(pos) = low.find(&call) {
1298
+ let inside = low[pos + call.len()..].split(')').next().unwrap_or("");
1299
+ if inside.contains("verify=false") {
1300
+ return true;
1301
+ }
1302
+ }
1303
+ }
1304
+ }
1305
+ false
1306
+ }
1307
+
1308
+ fn has_tautological_assert(line: &str) -> bool {
1309
+ let t = line.trim_start();
1310
+ let py_taut = t.strip_prefix("assert True").is_some_and(|r| {
1311
+ let rt = r.trim_start();
1312
+ rt.is_empty() || rt.starts_with('#') || rt.starts_with(';') || rt.starts_with(',')
1313
+ });
1314
+ if py_taut {
1315
+ return true;
1316
+ }
1317
+ let c: String = t.chars().filter(|ch| !ch.is_ascii_whitespace()).collect();
1318
+ c.contains("self.assertTrue(True)")
1319
+ || ["True", "False", "0", "1"]
1320
+ .iter()
1321
+ .any(|v| c.contains(&format!("self.assertEqual({},{})", v, v)))
1322
+ || ["true", "false", "0", "1"].iter().any(|v| {
1323
+ ["toBe", "toStrictEqual", "toEqual"]
1324
+ .iter()
1325
+ .any(|m| c.contains(&format!("expect({}).{}({})", v, m, v)))
1326
+ })
1327
+ || c.contains("assert!(true)")
1328
+ || ["true", "false", "0", "1"]
1329
+ .iter()
1330
+ .any(|v| c.contains(&format!("assert_eq!({},{})", v, v)))
1331
+ }
1332
+
1333
+ fn is_real_assert_line(line: &str) -> bool {
1334
+ let t = line.trim_start();
1335
+ if t.starts_with('"') || t.starts_with('\'') || has_tautological_assert(t) {
1336
+ return false;
1337
+ }
1338
+ t.starts_with("assert ")
1339
+ || line.contains("self.assert")
1340
+ || line.contains("expect(")
1341
+ || line.contains("assert_eq!(")
1342
+ || line.contains("assert_ne!(")
1343
+ || line.contains("assert!(")
1344
+ }
1345
+
1346
+ fn match_ident_bound(low: &str, cand: &str, upper: bool, allow_assign: bool) -> Option<f64> {
1347
+ let mut from = 0;
1348
+ while let Some(rel) = low[from..].find(cand) {
1349
+ let pos = from + rel;
1350
+ let end = pos + cand.len();
1351
+ from = end;
1352
+ let prev_ok = pos == 0
1353
+ || (!low.as_bytes()[pos - 1].is_ascii_alphanumeric()
1354
+ && low.as_bytes()[pos - 1] != b'_'
1355
+ && low.as_bytes()[pos - 1] != b'.');
1356
+ let next_ok = end >= low.len()
1357
+ || (!low.as_bytes()[end].is_ascii_alphanumeric() && low.as_bytes()[end] != b'_');
1358
+ if !prev_ok || !next_ok {
1359
+ continue;
1360
+ }
1361
+ let rest = low[end..].trim_start();
1362
+ let ineq = if upper {
1363
+ rest.strip_prefix("<=").or_else(|| rest.strip_prefix('<'))
1364
+ } else {
1365
+ rest.strip_prefix(">=").or_else(|| rest.strip_prefix('>'))
1366
+ };
1367
+ if let Some(vs) = ineq {
1368
+ if let Some(val) = parse_leading_f64(vs) {
1369
+ return Some(val);
1370
+ }
1371
+ } else if allow_assign {
1372
+ let assign = rest
1373
+ .strip_prefix('=')
1374
+ .filter(|s| !s.starts_with('='))
1375
+ .or_else(|| rest.strip_prefix(':'));
1376
+ if let Some(vs) = assign {
1377
+ if let Some(val) = parse_leading_f64(vs) {
1378
+ return Some(val);
1379
+ }
1380
+ }
1381
+ }
1382
+ }
1383
+ None
1384
+ }
1385
+ fn extract_metric_bounds(
1386
+ lines: &[String],
1387
+ upper: bool,
1388
+ is_test_or_gate: bool,
1389
+ ) -> BTreeMap<String, f64> {
1390
+ let mut map = BTreeMap::new();
1391
+ let qual_metrics = if upper { QUAL_UPPER_METRICS } else { QUAL_LOWER_METRICS };
1392
+ let bare_metrics = if upper { BARE_UPPER_METRICS } else { BARE_LOWER_METRICS };
1393
+ let cli_prefix = if upper { "max" } else { "min" };
1394
+
1395
+ for line in lines {
1396
+ if is_scanner_or_comment("py", line) {
1397
+ continue;
1398
+ }
1399
+ let low = line.to_ascii_lowercase();
1400
+ if upper {
1401
+ if let Some(pos) = low.find("--tolerance") {
1402
+ let rest = low[pos + "--tolerance".len()..].trim_start_matches(['"', '\'']);
1403
+ if let Some(vp) = rest
1404
+ .strip_prefix('=')
1405
+ .or_else(|| rest.strip_prefix(','))
1406
+ .or_else(|| rest.strip_prefix(' '))
1407
+ {
1408
+ if let Some(val) = parse_leading_f64(vp) {
1409
+ map.insert("tolerance".to_string(), val);
1410
+ }
1411
+ }
1412
+ }
1413
+ if let Some(val) = match_ident_bound(&low, "tolerance", true, true) {
1414
+ map.insert("tolerance".to_string(), val);
1415
+ }
1416
+ }
1417
+ for m in qual_metrics {
1418
+ let cli = format!("--{}-{}", cli_prefix, m.replace('_', "-"));
1419
+ if let Some(pos) = low.find(&cli) {
1420
+ let rest = low[pos + cli.len()..].trim_start_matches(['"', '\'']);
1421
+ if let Some(vpart) = rest
1422
+ .strip_prefix('=')
1423
+ .or_else(|| rest.strip_prefix(','))
1424
+ .or_else(|| rest.strip_prefix(' '))
1425
+ {
1426
+ if let Some(val) = parse_leading_f64(vpart) {
1427
+ map.insert(format!("{}_{}", cli_prefix, m), val);
1428
+ }
1429
+ }
1430
+ }
1431
+ let qual_forms: Vec<String> = if upper {
1432
+ vec![
1433
+ format!("max_{}", m),
1434
+ format!("maximum_{}", m),
1435
+ format!("{}_threshold", m),
1436
+ format!("{}_max", m),
1437
+ format!("{}_ceiling", m),
1438
+ format!("{}_limit", m),
1439
+ ]
1440
+ } else {
1441
+ vec![
1442
+ format!("min_{}", m),
1443
+ format!("minimum_{}", m),
1444
+ format!("{}_threshold", m),
1445
+ format!("{}_min", m),
1446
+ format!("{}_floor", m),
1447
+ ]
1448
+ };
1449
+ for qcand in qual_forms {
1450
+ if let Some(val) = match_ident_bound(&low, &qcand, upper, true) {
1451
+ map.insert(qcand, val);
1452
+ }
1453
+ }
1454
+ }
1455
+ for bm in bare_metrics {
1456
+ if let Some(val) = match_ident_bound(&low, bm, upper, is_test_or_gate) {
1457
+ map.entry((*bm).to_string()).or_insert(val);
1458
+ }
1459
+ }
1460
+ }
1461
+ map
1462
+ }
1463
+
1464
+ pub fn scan_hunk_weakening(
1465
+ rel: &str,
1466
+ hunks: &[(Vec<String>, Vec<(usize, String)>)],
1467
+ is_test_or_gate: bool,
1468
+ is_test: bool,
1469
+ out: &mut Vec<RewardFinding>,
1470
+ ) {
1471
+ for (rem, add) in hunks {
1472
+ if rem.is_empty() {
1473
+ continue;
1474
+ }
1475
+ let ln = add.first().map_or(1, |(l, _)| *l);
1476
+ let add_only: Vec<String> = add.iter().map(|(_, s)| s.clone()).collect();
1477
+ if is_test {
1478
+ let rem_asserts = rem.iter().filter(|r| is_real_assert_line(r)).count();
1479
+ let add_asserts = add_only.iter().filter(|a| is_real_assert_line(a)).count();
1480
+ if rem_asserts >= 2 && add_asserts == 0 {
1481
+ out.push(RewardFinding {
1482
+ severity: "P0",
1483
+ rule: "reward-hack-assertions-deleted",
1484
+ file: rel.to_string(),
1485
+ line: ln,
1486
+ message: format!(
1487
+ "Test hunk deleted {} behavioral assertions and left 0 assertions.",
1488
+ rem_asserts
1489
+ ),
1490
+ fix: "Keep behavioral assertions intact and fix the implementation under test.",
1491
+ });
1492
+ }
1493
+ }
1494
+ if add.is_empty() {
1495
+ continue;
1496
+ }
1497
+ let old_low = extract_metric_bounds(rem, false, is_test_or_gate);
1498
+ let new_low = extract_metric_bounds(&add_only, false, is_test_or_gate);
1499
+ for (k, old_v) in &old_low {
1500
+ if let Some(new_v) = new_low.get(k) {
1501
+ if *old_v > 0.0 && *new_v < *old_v {
1502
+ out.push(RewardFinding {
1503
+ severity: "P0",
1504
+ rule: "reward-hack-assertion-weakened",
1505
+ file: rel.to_string(),
1506
+ line: ln,
1507
+ message: format!(
1508
+ "Quality/fidelity lower bound `{}` weakened from `{}` to `{}`.",
1509
+ k, old_v, new_v
1510
+ ),
1511
+ fix: "Restore the original acceptance threshold and fix the implementation to meet it.",
1512
+ });
1513
+ }
1514
+ }
1515
+ }
1516
+ let old_up = extract_metric_bounds(rem, true, is_test_or_gate);
1517
+ let new_up = extract_metric_bounds(&add_only, true, is_test_or_gate);
1518
+ for (k, old_v) in &old_up {
1519
+ if let Some(new_v) = new_up.get(k) {
1520
+ if *new_v > *old_v {
1521
+ out.push(RewardFinding {
1522
+ severity: "P0",
1523
+ rule: "reward-hack-assertion-weakened",
1524
+ file: rel.to_string(),
1525
+ line: ln,
1526
+ message: format!(
1527
+ "Error/defect upper bound `{}` relaxed from `{}` to `{}`.",
1528
+ k, old_v, new_v
1529
+ ),
1530
+ fix: "Keep the stricter defect/tolerance bound and fix the underlying output.",
1531
+ });
1532
+ }
1533
+ }
1534
+ }
1535
+ }
1536
+ }
1537
+
1538
+ pub fn diff_file_hunks(
1539
+ root: &Path,
1540
+ rel: &str,
1541
+ staged: bool,
1542
+ base: Option<&str>,
1543
+ ) -> (Vec<(usize, String)>, Vec<(Vec<String>, Vec<(usize, String)>)>) {
1544
+ let full = root.join(rel);
1545
+ let Ok(meta) = fs::symlink_metadata(&full) else {
1546
+ return (Vec::new(), Vec::new());
1547
+ };
1548
+ if meta.file_type().is_symlink() || !meta.is_file() || meta.len() > 16 * 1024 * 1024 {
1549
+ return (Vec::new(), Vec::new());
1550
+ }
1551
+ let has_head = git(root, &["rev-parse", "--verify", "HEAD"])
1552
+ .map(|(ok, _)| ok)
1553
+ .unwrap_or(false);
1554
+ let tracked = git(root, &["ls-files", "--error-unmatch", "--", rel])
1555
+ .map(|(ok, _)| ok)
1556
+ .unwrap_or(false);
1557
+ if (!has_head || !tracked) && !staged {
1558
+ let Ok(txt) = fs::read_to_string(&full) else {
1559
+ return (Vec::new(), Vec::new());
1560
+ };
1561
+ let added: Vec<(usize, String)> = txt
1562
+ .lines()
1563
+ .enumerate()
1564
+ .map(|(i, l)| (i + 1, l.to_string()))
1565
+ .collect();
1566
+ return (added.clone(), vec![(Vec::new(), added)]);
1567
+ }
1568
+ let args: Vec<&str> = if staged {
1569
+ vec!["diff", "--cached", "-U0", "--", rel]
1570
+ } else if let Some(b) = base {
1571
+ vec!["diff", b, "-U0", "--", rel]
1572
+ } else {
1573
+ vec!["diff", "HEAD", "-U0", "--", rel]
1574
+ };
1575
+ let Some((true, diff)) = git(root, &args) else {
1576
+ return (Vec::new(), Vec::new());
1577
+ };
1578
+ let mut added = Vec::new();
1579
+ let mut hunks = Vec::new();
1580
+ let mut cur_rem = Vec::new();
1581
+ let mut cur_add = Vec::new();
1582
+ let mut cur_line: usize = 0;
1583
+ for raw in diff.lines() {
1584
+ if let Some(rest) = raw.strip_prefix("@@ ") {
1585
+ if !cur_rem.is_empty() || !cur_add.is_empty() {
1586
+ hunks.push((cur_rem, cur_add));
1587
+ cur_rem = Vec::new();
1588
+ cur_add = Vec::new();
1589
+ }
1590
+ if let Some(plus_idx) = rest.find('+') {
1591
+ let num: String = rest[plus_idx + 1..]
1592
+ .chars()
1593
+ .take_while(|c| c.is_ascii_digit())
1594
+ .collect();
1595
+ cur_line = num.parse::<usize>().unwrap_or(0);
1596
+ }
1597
+ } else if raw.starts_with('-') && !raw.starts_with("---") {
1598
+ cur_rem.push(raw[1..].to_string());
1599
+ } else if raw.starts_with('+') && !raw.starts_with("+++") {
1600
+ let s = raw[1..].to_string();
1601
+ added.push((cur_line, s.clone()));
1602
+ cur_add.push((cur_line, s));
1603
+ cur_line += 1;
1604
+ }
1605
+ }
1606
+ if !cur_rem.is_empty() || !cur_add.is_empty() {
1607
+ hunks.push((cur_rem, cur_add));
1608
+ }
1609
+ (added, hunks)
1610
+ }
1611
+
1612
+ type EvalToken<'a> = (&'a str, usize);
1613
+ type EvalStatement<'a> = (usize, Vec<EvalToken<'a>>);
1614
+
1615
+ const COMPARISON_DUNDERS: &[&str] = &["__eq__", "__ne__", "__lt__", "__le__", "__gt__", "__ge__"];
1616
+ const PYTEST_OVERRIDE_HOOKS: &[&str] = &["pytest_runtest_makereport", "pytest_collection_modifyitems"];
1617
+
1618
+ fn evaluator_statements<'a>(python: bool, lines: &[(usize, &'a str)]) -> Vec<EvalStatement<'a>> {
1619
+ let mut statements = Vec::new();
1620
+ let mut delimiter = "";
1621
+ let mut depth = 0;
1622
+ let mut indent = 0;
1623
+ let mut tokens = Vec::new();
1624
+ let mut previous = 0;
1625
+ for &(ln, raw) in lines {
1626
+ if ln != previous + 1 {
1627
+ if !tokens.is_empty() {
1628
+ statements.push((indent, std::mem::take(&mut tokens)));
1629
+ }
1630
+ delimiter = "";
1631
+ depth = 0;
1632
+ }
1633
+ previous = ln;
1634
+ if tokens.is_empty() {
1635
+ indent = 0;
1636
+ for ch in raw.bytes() {
1637
+ match ch {
1638
+ b' ' => indent += 1,
1639
+ b'\t' => indent = (indent / 8 + 1) * 8,
1640
+ 12 => indent = 0,
1641
+ _ => break,
1642
+ }
1643
+ }
1644
+ }
1645
+ let mut i = 0;
1646
+ while i < raw.len() {
1647
+ if !delimiter.is_empty() {
1648
+ let end = if delimiter == "*/" {
1649
+ raw[i..].find("*/").map(|offset| i + offset + 2)
1650
+ } else {
1651
+ quoted_end(raw, i, delimiter)
1652
+ };
1653
+ let Some(end) = end else { break };
1654
+ i = end;
1655
+ delimiter = "";
1656
+ continue;
1657
+ }
1658
+ let rest = &raw[i..];
1659
+ let Some(ch) = rest.chars().next() else { break };
1660
+ if ch.is_whitespace() {
1661
+ i += ch.len_utf8();
1662
+ continue;
1663
+ }
1664
+ if (python && ch == '#') || (!python && rest.starts_with("//")) {
1665
+ break;
1666
+ }
1667
+ if !python && rest.starts_with("/*") {
1668
+ i += 2;
1669
+ delimiter = "*/";
1670
+ continue;
1671
+ }
1672
+ if matches!(ch, '\'' | '"') || (!python && ch == '`') {
1673
+ let quote = if python && (rest.starts_with("'''") || rest.starts_with("\"\"\"")) {
1674
+ &rest[..3]
1675
+ } else {
1676
+ &rest[..1]
1677
+ };
1678
+ if let Some(end) = quoted_end(raw, i + quote.len(), quote) {
1679
+ tokens.push((&raw[i..end], ln));
1680
+ i = end;
1681
+ continue;
1682
+ }
1683
+ tokens.push(("''", ln));
1684
+ if quote.len() == 3 || quote == "`" || raw.ends_with('\\') {
1685
+ delimiter = quote;
1686
+ }
1687
+ break;
1688
+ }
1689
+ let width = if is_ident_char(ch) {
1690
+ rest.find(|c| !is_ident_char(c)).unwrap_or(rest.len())
1691
+ } else if rest.starts_with("==") {
1692
+ 2
1693
+ } else {
1694
+ ch.len_utf8()
1695
+ };
1696
+ let value = &rest[..width];
1697
+ if python {
1698
+ match value {
1699
+ "(" | "[" | "{" => depth += 1,
1700
+ ")" | "]" | "}" => depth -= 1,
1701
+ _ => {}
1702
+ }
1703
+ }
1704
+ tokens.push((value, ln));
1705
+ i += width;
1706
+ }
1707
+ if tokens.last().is_some_and(|t| t.0 == "\\") {
1708
+ tokens.pop();
1709
+ } else if !tokens.is_empty() && (!python || depth <= 0) {
1710
+ statements.push((indent, std::mem::take(&mut tokens)));
1711
+ depth = 0;
1712
+ }
1713
+ }
1714
+ if !tokens.is_empty() {
1715
+ statements.push((indent, tokens));
1716
+ }
1717
+ statements
1718
+ }
1719
+
1720
+ fn strip_wrapping_parens<'s, 'a>(mut words: &'s [&'a str]) -> &'s [&'a str] {
1721
+ while words.len() > 1 && words.first() == Some(&"(") && words.last() == Some(&")") {
1722
+ let mut depth = 0;
1723
+ let close = words.iter().position(|w| {
1724
+ depth += i32::from(*w == "(") - i32::from(*w == ")");
1725
+ depth == 0
1726
+ });
1727
+ if close != Some(words.len() - 1) {
1728
+ break;
1729
+ }
1730
+ words = &words[1..words.len() - 1];
1731
+ }
1732
+ words
1733
+ }
1734
+
1735
+ fn literal_bool(words: &[&str]) -> Option<bool> {
1736
+ let end = words.iter().position(|w| *w == ";").unwrap_or(words.len());
1737
+ match strip_wrapping_parens(&words[..end]) {
1738
+ ["True"] => Some(true),
1739
+ ["False"] => Some(false),
1740
+ _ => None,
1741
+ }
1742
+ }
1743
+
1744
+ fn suite_start(words: &[&str]) -> usize {
1745
+ let mut depth = 0;
1746
+ for (i, word) in words.iter().enumerate() {
1747
+ match *word {
1748
+ ":" if depth == 0 => return i + 1,
1749
+ "(" | "[" | "{" => depth += 1,
1750
+ ")" | "]" | "}" => depth -= 1,
1751
+ _ => {}
1752
+ }
1753
+ }
1754
+ 0
1755
+ }
1756
+
1757
+ fn pytest_args(line: &str) -> impl Iterator<Item = &str> {
1758
+ line.split(|c: char| c.is_whitespace() || "'\"`\\=,;[](){}".contains(c))
1759
+ .filter(|s| !s.is_empty())
1760
+ }
1761
+
1762
+ fn pytest_option_width(arg: &str, next: &str) -> usize {
1763
+ if matches!(arg, "--deselect" | "--continue-on-collection-errors") || arg.starts_with("-pno:") {
1764
+ 1
1765
+ } else if (arg == "-p" && next.starts_with("no:"))
1766
+ || (arg == "-k" && next == "not")
1767
+ || (arg == "--assert" && next == "plain")
1768
+ || (matches!(arg, "xfail_strict" | "strict_xfail") && next.eq_ignore_ascii_case("false"))
1769
+ {
1770
+ 2
1771
+ } else {
1772
+ 0
1773
+ }
1774
+ }
1775
+
1776
+ fn scan_pytest_options<'a>(
1777
+ tokens: impl IntoIterator<Item = EvalToken<'a>>,
1778
+ mut emit: impl FnMut(&[EvalToken<'a>]),
1779
+ ) {
1780
+ let mut previous = ("", 0);
1781
+ for token in tokens {
1782
+ if pytest_option_width(previous.0, token.0) == 2 {
1783
+ emit(&[previous, token]);
1784
+ }
1785
+ if pytest_option_width(token.0, "") == 1 {
1786
+ emit(&[token]);
1787
+ }
1788
+ previous = token;
1789
+ }
1790
+ }
1791
+
1792
+ fn pytest_config_arguments<'a>(
1793
+ ext: &str,
1794
+ lines: &[(usize, &'a str)],
1795
+ pytest_config: bool,
1796
+ command_config: bool,
1797
+ ) -> Vec<EvalToken<'a>> {
1798
+ let mut opts_indent = None;
1799
+ let mut opts_close = "";
1800
+ let mut continuation = false;
1801
+ let mut previous = 0;
1802
+ let mut tokens = Vec::new();
1803
+ for &(ln, raw) in lines {
1804
+ if ln != previous + 1 {
1805
+ opts_indent = None;
1806
+ opts_close = "";
1807
+ continuation = false;
1808
+ }
1809
+ previous = ln;
1810
+ if is_scanner_or_comment(ext, raw) {
1811
+ continue;
1812
+ }
1813
+ let line = strip_trailing_comment(ext, raw);
1814
+ let stripped = line.trim();
1815
+ let (key, value) = stripped.split_once('=').unwrap_or((stripped, ""));
1816
+ let (key, value) = (key.trim(), value.trim_start());
1817
+ let indent = line.len() - line.trim_start().len();
1818
+ let in_addopts = !opts_close.is_empty() || opts_indent.is_some_and(|n| indent > n);
1819
+ if !opts_close.is_empty() && stripped.contains(opts_close) {
1820
+ opts_close = "";
1821
+ }
1822
+ if !in_addopts {
1823
+ opts_indent = None;
1824
+ }
1825
+ let command = command_config && pytest_args(line)
1826
+ .any(|w| w == "pytest" || w.trim_end_matches(':') == "PYTEST_ADDOPTS");
1827
+ let setting = pytest_config && matches!(key, "addopts" | "xfail_strict" | "strict_xfail");
1828
+ if command || setting {
1829
+ tokens.push(("", 0));
1830
+ }
1831
+ if command || setting || continuation || in_addopts {
1832
+ tokens.extend(pytest_args(line).map(|word| (word, ln)));
1833
+ }
1834
+ if pytest_config && key == "addopts" {
1835
+ opts_indent = Some(indent);
1836
+ for (opener, closer) in [("[", "]"), ("\"\"\"", "\"\"\""), ("'''", "'''")] {
1837
+ if value.strip_prefix(opener).is_some_and(|v| !v.contains(closer)) {
1838
+ opts_close = closer;
1839
+ break;
1840
+ }
1841
+ }
1842
+ }
1843
+ continuation = (command || continuation) && line.trim_end().ends_with('\\');
1844
+ if !continuation && opts_close.is_empty() && opts_indent.is_none() {
1845
+ tokens.push(("", 0));
1846
+ }
1847
+ }
1848
+ tokens
1849
+ }
1850
+
1851
+ fn scan_evaluator_bypasses(
1852
+ rel: &str, norm_rel: &str, ext: &str, added: &[(usize, String)],
1853
+ full_text: Option<&str>, in_test: bool, out: &mut Vec<RewardFinding>,
1854
+ ) {
1855
+ let low = norm_rel.to_ascii_lowercase();
1856
+ let path: Vec<_> = low.split('/').collect();
1857
+ let fname = path.last().copied().unwrap_or_default();
1858
+ let python = ext == "py";
1859
+ let js = matches!(ext, "js" | "mjs" | "cjs" | "ts" | "tsx" | "jsx" | "mts" | "cts");
1860
+ let pytest_config = matches!(fname, "pytest.ini" | ".pytest.ini" | "pytest.toml" | ".pytest.toml" | "pyproject.toml" | "setup.cfg" | "tox.ini");
1861
+ let command_config = matches!(ext, "sh" | "ps1" | "cmd" | "bat" | "yaml" | "yml")
1862
+ || matches!(fname, "makefile" | "package.json" | "tox.ini");
1863
+ let runner_config = fname == "package.json" || ["jest.config.", "vitest.config.", "vite.config."]
1864
+ .iter().any(|prefix| fname.starts_with(prefix));
1865
+ if added.is_empty() || !(python || js || pytest_config || command_config || runner_config) {
1866
+ return;
1867
+ }
1868
+ let lines: Vec<_> = if let Some(text) = full_text.filter(|s| !s.is_empty()) {
1869
+ text.lines().enumerate().map(|(i, line)| (i + 1, line)).collect()
1870
+ } else {
1871
+ let mut lines: Vec<_> = added.iter().map(|(ln, line)| (*ln, line.as_str())).collect();
1872
+ lines.sort_unstable_by_key(|t| t.0);
1873
+ lines
1874
+ };
1875
+ let added_lines: BTreeSet<_> = added.iter().map(|t| t.0).collect();
1876
+ let mut hits = BTreeSet::new();
1877
+ let mut emit = |rule, tokens: &[EvalToken<'_>]| {
1878
+ let ln = tokens.iter().find_map(|(_, ln)| added_lines.contains(ln).then_some(*ln));
1879
+ if let Some(ln) = ln {
1880
+ hits.insert((ln, rule));
1881
+ }
1882
+ ln.is_some()
1883
+ };
1884
+
1885
+ let conftest = fname == "conftest.py";
1886
+ let in_test = in_test || conftest;
1887
+ let entrypoint = !in_test && (
1888
+ fname == "__main__.py" || matches!(path[0], "bin" | "cmd")
1889
+ || path.len() > 1 && matches!(path[path.len() - 2], "bin" | "cli")
1890
+ || matches!(fname.split('.').next(), Some("cli" | "__main__")) || fname.contains(".cli.")
1891
+ || (fname == "main.py" && path.len() == 1)
1892
+ || lines.first().is_some_and(|(ln, s)| *ln == 1 && s.starts_with("#!") &&
1893
+ (if python { &["python"][..] } else { &["node", "bun", "deno"][..] })
1894
+ .iter().any(|word| s.contains(*word)))
1895
+ );
1896
+ let source_terms: &[&str] = if python {
1897
+ &["__", "exit", "outcome", "marker", "pytest", "TestResult", "PYTEST_ADDOPTS"]
1898
+ } else {
1899
+ &["exit", "passWithNoTests", "bail"]
1900
+ };
1901
+ if (python || js || runner_config) && full_text.is_none_or(|text| {
1902
+ text.is_empty() || source_terms.iter().any(|term| text.contains(*term))
1903
+ }) {
1904
+ let mut statements = evaluator_statements(python, &lines);
1905
+ let mut main_indent = None;
1906
+ let mut loops = Vec::new();
1907
+ let plugin = conftest || fname.contains("pytest") || fname.contains("plugin")
1908
+ || python && statements.iter().any(|(_, tokens)| {
1909
+ matches!(tokens[0].0, "import" | "from" | "def" | "async")
1910
+ && tokens.iter().any(|(w, _)| PYTEST_OVERRIDE_HOOKS.contains(w) || matches!(*w, "pytest" | "_pytest"))
1911
+ });
1912
+ let mut collections = None;
1913
+ if js || runner_config {
1914
+ statements = vec![(0, statements.into_iter().flat_map(|(_, tokens)| tokens).collect())];
1915
+ }
1916
+ for (idx, (indent, tokens)) in statements.iter().enumerate() {
1917
+ let words: Vec<_> = tokens.iter().map(|t| t.0).collect();
1918
+ let suite = if python { suite_start(&words) } else { 0 };
1919
+ let def_at = usize::from(words.starts_with(&["async", "def"]));
1920
+ let name = if words.get(def_at) == Some(&"def") {
1921
+ words.get(def_at + 1).copied().unwrap_or_default()
1922
+ } else {
1923
+ ""
1924
+ };
1925
+ if main_indent.is_some_and(|n| *indent <= n) {
1926
+ main_indent = None;
1927
+ }
1928
+ if collections.is_some_and(|n| *indent <= n) {
1929
+ collections = None;
1930
+ }
1931
+ while loops.last().is_some_and(|n| indent <= n) {
1932
+ loops.pop();
1933
+ }
1934
+ let guard = python && suite > 0 && words[0] == "if" && !in_test && matches!(
1935
+ strip_wrapping_parens(&words[1..suite - 1]),
1936
+ ["__name__", "==", "'__main__'" | "\"__main__\""]
1937
+ | ["'__main__'" | "\"__main__\"", "==", "__name__"]
1938
+ );
1939
+ if guard && suite == words.len() {
1940
+ main_indent = Some(*indent);
1941
+ }
1942
+ if python && suite > 0 && suite == words.len() {
1943
+ if words[0] == "for" || words.starts_with(&["async", "for"]) {
1944
+ loops.push(*indent);
1945
+ }
1946
+ if name == "pytest_collection_modifyitems" {
1947
+ collections = Some(*indent);
1948
+ }
1949
+ }
1950
+ if python && !in_test && COMPARISON_DUNDERS.contains(&name) && suite > 0 {
1951
+ let inline = &words[suite..];
1952
+ if let Some(body) = inline.strip_prefix(&["return"]) {
1953
+ if literal_bool(body).is_some() {
1954
+ emit("reward-hack-constant-comparison", tokens);
1955
+ }
1956
+ } else if inline.is_empty() {
1957
+ let body = &statements[idx + 1..];
1958
+ if let Some((body_indent, _)) = body.first().filter(|(n, _)| n > indent) {
1959
+ let mut prior = None;
1960
+ for (inner_indent, inner) in body {
1961
+ if inner_indent <= indent || inner.iter().any(|t| matches!(t.0, "raise" | "yield" | "def")) {
1962
+ break;
1963
+ }
1964
+ if let Some(at) = inner.iter().position(|t| t.0 == "return") {
1965
+ let expr: Vec<_> = inner[at + 1..].iter().map(|t| t.0).collect();
1966
+ let Some(value) = literal_bool(&expr) else { break };
1967
+ if prior.is_some_and(|p| p != value) {
1968
+ break;
1969
+ }
1970
+ prior = Some(value);
1971
+ if at == 0 && inner_indent == body_indent {
1972
+ if !emit("reward-hack-constant-comparison", &tokens[..suite]) {
1973
+ emit("reward-hack-constant-comparison", inner);
1974
+ }
1975
+ break;
1976
+ }
1977
+ }
1978
+ }
1979
+ }
1980
+ }
1981
+ }
1982
+ if python && (
1983
+ (words.contains(&"\"PYTEST_ADDOPTS\"") || words.contains(&"'PYTEST_ADDOPTS'")) && words.contains(&"=")
1984
+ || words.windows(4).any(|w| w == ["pytest", ".", "main", "("])
1985
+ || words.contains(&"subprocess") && words.iter().any(|w| matches!(*w, "'pytest'" | "\"pytest\""))
1986
+ ) {
1987
+ let args = tokens.iter().flat_map(|&(w, ln)| pytest_args(w).map(move |part| (part, ln)));
1988
+ scan_pytest_options(args, |span| { emit("reward-hack-pytest-config-bypass", span); });
1989
+ }
1990
+ for (i, w) in words.iter().copied().enumerate() {
1991
+ let tail = &words[i + 1..];
1992
+ if python && !in_test && COMPARISON_DUNDERS.contains(&w) && tail.starts_with(&["=", "lambda"]) {
1993
+ let colon = suite_start(&words[i + 2..]);
1994
+ if colon > 0 && literal_bool(&words[i + 2 + colon..]).is_some() {
1995
+ emit("reward-hack-constant-comparison", &tokens[i..]);
1996
+ }
1997
+ }
1998
+ if python && PYTEST_OVERRIDE_HOOKS.contains(&w) && (w == name || tail.starts_with(&["="])) {
1999
+ emit("reward-hack-pytest-hook-override", if w == name {
2000
+ tokens
2001
+ } else {
2002
+ &tokens[i..(i + 3).min(tokens.len())]
2003
+ });
2004
+ }
2005
+ let attribute = i > 0 && words[i - 1] == ".";
2006
+ if python && w == "outcome" && attribute
2007
+ && matches!(tail, ["=", "'passed'" | "\"passed\"", ..]) && (plugin || collections.is_some())
2008
+ {
2009
+ emit("reward-hack-test-outcome-rewrite", &tokens[i.saturating_sub(2)..i + 3]);
2010
+ }
2011
+ if python && w == "add_marker" && attribute && tail.starts_with(&["("]) {
2012
+ let mut marker = i + 2;
2013
+ if matches!(&words[marker..], ["pytest" | "_pytest", ".", "mark", ".", ..]) {
2014
+ marker += 4;
2015
+ } else if words[marker..].starts_with(&["mark", "."]) {
2016
+ marker += 2;
2017
+ }
2018
+ if matches!(words.get(marker), Some(&("skip" | "xfail" | "'skip'" | "\"skip\"" | "'xfail'" | "\"xfail\"")))
2019
+ && (!loops.is_empty() || collections.is_some() || name == "pytest_collection_modifyitems"
2020
+ || words[marker + 1..].contains(&"for") || (suite > 0 && words[0] == "for"))
2021
+ {
2022
+ emit("reward-hack-bulk-test-marker", &tokens[i - 1..marker + 1]);
2023
+ }
2024
+ }
2025
+ if python && i >= 2 && tail.starts_with(&["="]) && attribute
2026
+ && ((w == "fail" && words[i - 2] == "pytest")
2027
+ || (matches!(w, "addFailure" | "addError") && words[i - 2] == "TestResult"))
2028
+ {
2029
+ emit("reward-hack-test-outcome-rewrite", &tokens[i - 2..(i + 3).min(tokens.len())]);
2030
+ }
2031
+ if python && w == "setattr" && tail.starts_with(&["("]) {
2032
+ let target = &tail[1..];
2033
+ if matches!(target,
2034
+ ["'pytest.fail'" | "\"pytest.fail\"" | "'unittest.TestResult.addFailure'" | "\"unittest.TestResult.addFailure\""
2035
+ | "'unittest.TestResult.addError'" | "\"unittest.TestResult.addError\"", ",", ..]
2036
+ | ["pytest", ",", "'fail'" | "\"fail\"", ..]
2037
+ | ["unittest", ".", "TestResult", ",", "'addFailure'" | "\"addFailure\"" | "'addError'" | "\"addError\"", ..]
2038
+ | ["TestResult", ",", "'addFailure'" | "\"addFailure\"" | "'addError'" | "\"addError\"", ..]
2039
+ ) {
2040
+ emit("reward-hack-test-outcome-rewrite", &tokens[i..(i + 8).min(tokens.len())]);
2041
+ }
2042
+ }
2043
+ if matches!(w, "exit" | "_exit") && tail.starts_with(&["("])
2044
+ && !entrypoint && main_indent.is_none() && !guard
2045
+ {
2046
+ let start = if attribute {
2047
+ let owner = if i >= 2 && (i < 3 || words[i - 3] != ".") { words[i - 2] } else { "" };
2048
+ if !matches!((python, owner, w), (true, "os", "_exit") | (true, "sys", "exit") | (false, "process", "exit")) {
2049
+ continue;
2050
+ }
2051
+ i - 2
2052
+ } else if !python || w != "exit" || (name == "exit" && i == def_at + 1) {
2053
+ continue;
2054
+ } else {
2055
+ i
2056
+ };
2057
+ let value = i + 2 + words[i + 2..].iter().take_while(|w| **w == "(").count();
2058
+ let closings = value - i - 2;
2059
+ if words.get(value) == Some(&"0")
2060
+ && words.get(value + 1..value + 1 + closings).is_some_and(|s| s.iter().all(|w| *w == ")"))
2061
+ {
2062
+ let mut close = value + 1 + closings;
2063
+ close += usize::from(words.get(close) == Some(&","));
2064
+ if words.get(close) == Some(&")") {
2065
+ emit("reward-hack-zero-exit", &tokens[start..close + 1]);
2066
+ }
2067
+ }
2068
+ }
2069
+ if runner_config {
2070
+ let wanted = match w.trim_matches(['\'', '"']) {
2071
+ "passWithNoTests" => "true",
2072
+ "bail" => "0",
2073
+ _ => continue,
2074
+ };
2075
+ if tail.starts_with(&[":", wanted]) && matches!(tail.get(2), None | Some(&("," | "}" | ";"))) {
2076
+ emit("reward-hack-js-runner-bypass", &tokens[i..i + 3]);
2077
+ }
2078
+ }
2079
+ }
2080
+ }
2081
+ }
2082
+ if pytest_config || command_config {
2083
+ let config_ext = if fname == "makefile" { "sh" } else { ext };
2084
+ let args = pytest_config_arguments(config_ext, &lines, pytest_config, command_config);
2085
+ scan_pytest_options(args, |span| { emit("reward-hack-pytest-config-bypass", span); });
2086
+ }
2087
+ for (line, rule) in hits {
2088
+ let (severity, message, fix) = match rule {
2089
+ "reward-hack-constant-comparison" => ("P1", "Comparison method returns a constant boolean instead of comparing operands.", "Compare the operands and return NotImplemented for unsupported types."),
2090
+ "reward-hack-zero-exit" => ("P0", "A success exit in library or test code can terminate verification before failures are reported.", "Return to the caller or propagate the error; exit only at the CLI boundary."),
2091
+ "reward-hack-pytest-hook-override" => ("P1", "A pytest plugin overrides test reporting or collection.", "Keep collection and reporting intact; do not rewrite evaluator outcomes."),
2092
+ "reward-hack-test-outcome-rewrite" => ("P0", "Evaluator outcomes can be forced to pass or their failure handlers replaced.", "Preserve the evaluator's original outcome and failure handlers."),
2093
+ "reward-hack-bulk-test-marker" => ("P1", "A loop or collection hook applies skip/xfail to collected tests.", "Run the collected tests and fix their failures."),
2094
+ "reward-hack-pytest-config-bypass" => ("P1", "Pytest options suppress collection, plugin checks, assertion rewriting, or strict xfails.", "Keep the evaluator's collection, plugins, assertion rewriting, and strict xfail checks intact."),
2095
+ "reward-hack-js-runner-bypass" => ("P1", "Test runner allows an empty test run or explicitly disables fail-fast with bail: 0.", "Require a nonempty test run and retain the configured failure policy."),
2096
+ _ => unreachable!(),
2097
+ };
2098
+ out.push(RewardFinding { severity, rule, file: rel.to_owned(), line, message: message.to_owned(), fix });
2099
+ }
2100
+ }
2101
+
2102
+ #[cfg(test)]
2103
+ pub fn scan_file_reward_hacks(
2104
+ rel: &str,
2105
+ added: &[(usize, String)],
2106
+ hunks: &[(Vec<String>, Vec<(usize, String)>)],
2107
+ allow_primitives: bool,
2108
+ include_primitives: bool,
2109
+ rs_cfg_test_line: Option<usize>,
2110
+ out: &mut Vec<RewardFinding>,
2111
+ ) {
2112
+ scan_file_reward_hacks_full(rel, added, hunks, allow_primitives, include_primitives, rs_cfg_test_line, None, None, out);
2113
+ }
2114
+
2115
+ pub fn scan_file_reward_hacks_full(
2116
+ rel: &str,
2117
+ added: &[(usize, String)],
2118
+ hunks: &[(Vec<String>, Vec<(usize, String)>)],
2119
+ allow_primitives: bool,
2120
+ include_primitives: bool,
2121
+ rs_cfg_test_line: Option<usize>,
2122
+ mypy_lines: Option<&BTreeSet<usize>>,
2123
+ full_text: Option<&str>,
2124
+ out: &mut Vec<RewardFinding>,
2125
+ ) {
2126
+ let norm_rel = rel.replace('\\', "/");
2127
+ let ext = Path::new(&norm_rel)
2128
+ .extension()
2129
+ .and_then(|e| e.to_str())
2130
+ .map(|s| s.to_ascii_lowercase())
2131
+ .unwrap_or_default();
2132
+ if ext == "md"
2133
+ || norm_rel.ends_with("assets/reward-guard/reward_guard.py")
2134
+ || norm_rel.ends_with("assets/reward-guard/test_reward_guard.py")
2135
+ || norm_rel.ends_with("native/dmb-gate/src/reward.rs")
2136
+ || norm_rel.ends_with("native/dmb-gate/src/main.rs")
2137
+ || norm_rel.ends_with("scripts/antigravity-guard.mjs")
2138
+ || norm_rel.ends_with("assets/contain/claude_guard.py")
2139
+ || norm_rel.ends_with("assets/contain/test_contain.py")
2140
+ || norm_rel.ends_with("assets/contain/test_antigravity_guard.py")
2141
+ || norm_rel.ends_with("assets/git-guardrails/git-guard-patterns.txt")
2142
+ || norm_rel.ends_with("assets/git-guardrails/git-guard.ts")
2143
+ || norm_rel.ends_with("assets/git-guardrails/git-guard.sh")
2144
+ || norm_rel.ends_with("assets/git-guardrails/test_git_guard.py")
2145
+ || norm_rel.ends_with("assets/self-grill/test_self_grill.py")
2146
+ {
2147
+ return;
2148
+ }
2149
+ let is_scratch = norm_rel.starts_with(".scratch/");
2150
+ let test_file = !is_scratch && is_test_file(&norm_rel);
2151
+ let e2e_file = !is_scratch && is_e2e_file(&norm_rel);
2152
+ let gate_file = is_gate_or_eval_file(&norm_rel);
2153
+ let is_ci_yaml = matches!(ext.as_str(), "yml" | "yaml")
2154
+ && (norm_rel.starts_with(".github/workflows/")
2155
+ || norm_rel == ".gitlab-ci.yml"
2156
+ || norm_rel == ".deepmodebot/ci.yml");
2157
+ let file_name_low = Path::new(&norm_rel)
2158
+ .file_name()
2159
+ .and_then(|n| n.to_str())
2160
+ .map(|s| s.to_ascii_lowercase())
2161
+ .unwrap_or_default();
2162
+ let is_tsconfig = file_name_low.starts_with("tsconfig") && ext == "json";
2163
+ let is_pkg_json = file_name_low == "package.json";
2164
+ let is_py_type_cfg = matches!(
2165
+ file_name_low.as_str(),
2166
+ "pyproject.toml" | "mypy.ini" | ".mypy.ini" | "setup.cfg" | "pyrightconfig.json"
2167
+ );
2168
+ let is_mypy_ini = matches!(file_name_low.as_str(), "mypy.ini" | ".mypy.ini");
2169
+ let is_migration = is_migration_file(&norm_rel);
2170
+ let is_biome_cfg = matches!(file_name_low.as_str(), "biome.json" | "biome.jsonc");
2171
+ let is_pw_cfg = file_name_low.starts_with("playwright.config.");
2172
+ let is_train_py = ext == "py"
2173
+ && ["train", "finetune", "sft", "rlhf", "pretrain"]
2174
+ .iter()
2175
+ .any(|p| file_name_low.starts_with(p));
2176
+ let is_prod_code = !is_scratch
2177
+ && !test_file
2178
+ && !e2e_file
2179
+ && !gate_file
2180
+ && matches!(
2181
+ ext.as_str(),
2182
+ "py" | "js" | "mjs" | "cjs" | "ts" | "tsx" | "jsx" | "rs" | "go" | "sql"
2183
+ );
2184
+ let proof_map = if matches!(ext.as_str(), "lean" | "v" | "smt2") {
2185
+ full_text.map(|ft| scrub_proof_text_lines(&ext, ft))
2186
+ } else {
2187
+ None
2188
+ };
2189
+ scan_evaluator_bypasses(rel, &norm_rel, &ext, added, full_text, test_file || e2e_file, out);
2190
+ for (ln, raw_line) in added {
2191
+ let in_test_ctx = !is_scratch
2192
+ && (test_file
2193
+ || e2e_file
2194
+ || rs_cfg_test_line.map(|cfg_ln| *ln >= cfg_ln).unwrap_or(false));
2195
+ if ext == "cfg" && has_tla_cfg_commented_invariant(raw_line) {
2196
+ out.push(RewardFinding {
2197
+ severity: "P0",
2198
+ rule: "reward-hack-proof-escape",
2199
+ file: rel.to_string(),
2200
+ line: *ln,
2201
+ message: "TLA+ `.cfg` comments out `INVARIANT`/`PROPERTY` so model checking passes vacuously.".to_string(),
2202
+ fix: "Keep every TLA+ invariant and temporal property active and fix the specification.",
2203
+ });
2204
+ }
2205
+ let cmt_slice = extract_unquoted_comment(&ext, raw_line);
2206
+ if !in_test_ctx && has_iac_sec_suppression(cmt_slice) {
2207
+ out.push(RewardFinding {
2208
+ severity: "P1",
2209
+ rule: "reward-hack-scanner-suppressed",
2210
+ file: rel.to_string(),
2211
+ line: *ln,
2212
+ message: "Inline security/IaC scanner suppression (`tfsec`/`checkov`/`trivy`/`nosemgrep`) silences a policy check.".to_string(),
2213
+ fix: "Remediate the underlying security or IaC misconfiguration instead of suppressing the scanner.",
2214
+ });
2215
+ }
2216
+ if is_scanner_or_comment(&ext, raw_line) {
2217
+ continue;
2218
+ }
2219
+ let line = strip_trailing_comment(&ext, raw_line);
2220
+ if in_test_ctx || is_pw_cfg || gate_file {
2221
+ if has_inflated_visual_tolerance(line) {
2222
+ out.push(RewardFinding {
2223
+ severity: "P0",
2224
+ rule: "reward-hack-visual-tolerance-inflated",
2225
+ file: rel.to_string(),
2226
+ line: *ln,
2227
+ message: "Visual regression diff tolerance inflated (`maxDiffPixelRatio > 0.10` or `maxDiffPixels >= 5000`) to mask broken UI.".to_string(),
2228
+ fix: "Keep tight screenshot tolerances and fix the visual layout regression.",
2229
+ });
2230
+ }
2231
+ if line.contains(".disableRules([") || line.contains(".disableRules( [") {
2232
+ out.push(RewardFinding {
2233
+ severity: "P1",
2234
+ rule: "reward-hack-a11y-disabled",
2235
+ file: rel.to_string(),
2236
+ line: *ln,
2237
+ message: "Accessibility audit rules disabled (`disableRules([...])`) to force a passing check.".to_string(),
2238
+ fix: "Fix the underlying accessibility violation instead of disabling Axe rules.",
2239
+ });
2240
+ }
2241
+ }
2242
+ if in_test_ctx {
2243
+ if e2e_file && has_e2e_api_stub(line) {
2244
+ out.push(RewardFinding {
2245
+ severity: "P1",
2246
+ rule: "reward-hack-e2e-api-stubbed",
2247
+ file: rel.to_string(),
2248
+ line: *ln,
2249
+ message: "E2E spec intercepts/stubs `/api/`, `/graphql`, or `/trpc` backend routes instead of exercising the real server.".to_string(),
2250
+ fix: "Run E2E specs against the live backend service; reserve route mocks for unit tests or 3rd-party external APIs.",
2251
+ });
2252
+ }
2253
+ if has_test_skip(line) {
2254
+ out.push(RewardFinding {
2255
+ severity: "P1",
2256
+ rule: "reward-hack-test-skip",
2257
+ file: rel.to_string(),
2258
+ line: *ln,
2259
+ message: "Unconditional test skip or non-strict `xfail` added (`skip` / `xfail` / `#[ignore]`) silences a failing check.".to_string(),
2260
+ fix: "Fix the failing behavior instead of skipping or xfailing the test.",
2261
+ });
2262
+ }
2263
+ if has_tautological_assert(line) {
2264
+ out.push(RewardFinding {
2265
+ severity: "P1",
2266
+ rule: "reward-hack-tautological-test",
2267
+ file: rel.to_string(),
2268
+ line: *ln,
2269
+ message: "Tautological assertion (`assert True` / `expect(true).toBe(true)`) passes vacuously without testing behavior.".to_string(),
2270
+ fix: "Assert concrete behavioral outputs of the system under test.",
2271
+ });
2272
+ }
2273
+ continue;
2274
+ }
2275
+ let trimmed_low = line.trim().to_ascii_lowercase();
2276
+ if is_pkg_json && is_package_noop_script(line) {
2277
+ out.push(RewardFinding {
2278
+ severity: "P0",
2279
+ rule: "reward-hack-noop-script",
2280
+ file: rel.to_string(),
2281
+ line: *ln,
2282
+ message: "`package.json` verification script (`test`/`check`/`typecheck`/`lint`) replaced with a no-op (`echo`/`true`/`exit 0`).".to_string(),
2283
+ fix: "Wire `package.json` scripts to the real test runner, typechecker, and linter.",
2284
+ });
2285
+ }
2286
+ let in_mypy_ctx = is_mypy_ini || mypy_lines.is_some_and(|s| s.contains(ln));
2287
+ if (is_ci_yaml
2288
+ && trimmed_low.starts_with("continue-on-error:")
2289
+ && trimmed_low[18..].trim_start().starts_with("true"))
2290
+ || (is_tsconfig && has_tsconfig_weaken(line))
2291
+ || (is_py_type_cfg && has_py_typecheck_weaken(&trimmed_low, in_mypy_ctx))
2292
+ || (is_biome_cfg && has_json_key_false(line, &["enabled"]))
2293
+ || (ext == "rs" && is_prod_code && has_rs_crate_allow(line))
2294
+ {
2295
+ out.push(RewardFinding {
2296
+ severity: "P0",
2297
+ rule: "reward-hack-ci-or-typecheck-neutered",
2298
+ file: rel.to_string(),
2299
+ line: *ln,
2300
+ message: "CI, typechecker, or compiler gate neutered (`continue-on-error: true`, `tsconfig`/`mypy`/`pyright` strictness off, `biome` disabled, or crate `#![allow(...)]`).".to_string(),
2301
+ fix: "Keep strict CI/compiler/typechecker gates enabled and fix the underlying errors.",
2302
+ });
2303
+ }
2304
+ if is_prod_code && has_prod_test_branch(line) {
2305
+ out.push(RewardFinding {
2306
+ severity: "P0",
2307
+ rule: "reward-hack-prod-test-branch",
2308
+ file: rel.to_string(),
2309
+ line: *ln,
2310
+ message: "Production code branches on test-runner state (`PYTEST_CURRENT_TEST` / `JEST_WORKER_ID` / `sys.modules['pytest']`).".to_string(),
2311
+ fix: "Remove test-environment detection from production code; use dependency injection at external boundaries.",
2312
+ });
2313
+ }
2314
+ if is_prod_code && has_prod_integrity_bypass(line, is_migration) {
2315
+ out.push(RewardFinding {
2316
+ severity: "P0",
2317
+ rule: "reward-hack-integrity-bypass",
2318
+ file: rel.to_string(),
2319
+ line: *ln,
2320
+ message: "Production code disables TLS certificate verification (`verify=False` / `InsecureSkipVerify`) or DB foreign-key checks.".to_string(),
2321
+ fix: "Keep TLS verification and relational foreign-key constraints enabled and fix the root configuration/schema bug.",
2322
+ });
2323
+ }
2324
+ if has_ml_eval_leakage(line, is_train_py || is_scratch) {
2325
+ out.push(RewardFinding {
2326
+ severity: "P0",
2327
+ rule: "reward-hack-eval-leakage",
2328
+ file: rel.to_string(),
2329
+ line: *ln,
2330
+ message: "Training script fits on or loads `test`/`eval` split directly (train-on-test data leakage).".to_string(),
2331
+ fix: "Train strictly on training splits and hold out validation/test splits for evaluation only.",
2332
+ });
2333
+ }
2334
+ if has_snapshot_overwrite(line) {
2335
+ out.push(RewardFinding {
2336
+ severity: "P0",
2337
+ rule: "reward-hack-snapshot-overwrite",
2338
+ file: rel.to_string(),
2339
+ line: *ln,
2340
+ message: "Unattended snapshot overwrite flag (`--update-snapshots`, `-u`, `cargo insta accept`, `INSTA_UPDATE=always`) rewrites golden expectations.".to_string(),
2341
+ fix: "Verify outputs against locked snapshots instead of overwriting golden baselines.",
2342
+ });
2343
+ }
2344
+ if has_threshold_zero_or_skip(line) {
2345
+ out.push(RewardFinding {
2346
+ severity: "P0",
2347
+ rule: "reward-hack-threshold-zero",
2348
+ file: rel.to_string(),
2349
+ line: *ln,
2350
+ message: "Sub-floor quality/coverage threshold, gate skip flag, or empty `go test -run=^$` filter bypasses real evaluation.".to_string(),
2351
+ fix: "Keep evaluation thresholds above their floor and run the real test suite.",
2352
+ });
2353
+ }
2354
+ if matches!(ext.as_str(), "lean" | "v" | "smt2") {
2355
+ let single_map;
2356
+ let scrubbed_ln = if let Some(pm) = &proof_map {
2357
+ pm.get(ln).map(String::as_str).unwrap_or("")
2358
+ } else {
2359
+ single_map = scrub_proof_text_lines(&ext, line);
2360
+ single_map.get(&1).map(String::as_str).unwrap_or("")
2361
+ };
2362
+ if has_proof_escape_scrubbed(&ext, scrubbed_ln) {
2363
+ out.push(RewardFinding {
2364
+ severity: "P0",
2365
+ rule: "reward-hack-proof-escape",
2366
+ file: rel.to_string(),
2367
+ line: *ln,
2368
+ message: "Formal proof trust escape (`sorry`/`admit`/`Admitted.`/custom `axiom`/`native_decide`/`(assert false)`) bypasses verification.".to_string(),
2369
+ fix: "Construct a complete kernel-checked proof without axioms, sorry, or contradictory premises.",
2370
+ });
2371
+ }
2372
+ }
2373
+ if (gate_file || (ext == "sql" && !is_migration)) && has_vacuous_query(line) {
2374
+ out.push(RewardFinding {
2375
+ severity: "P0",
2376
+ rule: "reward-hack-vacuous-query",
2377
+ file: rel.to_string(),
2378
+ line: *ln,
2379
+ message: "Vacuous query predicate (`WHERE 1=0` / `WHERE FALSE` / `LIMIT 0`) forces 0 error rows in validation.".to_string(),
2380
+ fix: "Query the real dataset without vacuous filters and fix invalid records.",
2381
+ });
2382
+ }
2383
+ if include_primitives && !allow_primitives && has_primitive_standin(line) {
2384
+ out.push(RewardFinding {
2385
+ severity: "P1",
2386
+ rule: "reward-hack-primitive-standin",
2387
+ file: rel.to_string(),
2388
+ line: *ln,
2389
+ message: "Local procedural primitive geometry (`cube`/`cone`/`sphere`/`cylinder`) added in production/pipeline or scratch code.".to_string(),
2390
+ fix: "Produce the asset via the real upstream generator/solver with a signed provenance receipt, or pass `--allow-primitives` for genuine CAD/procedural geometry.",
2391
+ });
2392
+ }
2393
+ if has_hardcoded_pass(line) {
2394
+ out.push(RewardFinding {
2395
+ severity: "P1",
2396
+ rule: "reward-hack-hardcoded-pass",
2397
+ file: rel.to_string(),
2398
+ line: *ln,
2399
+ message: "Hardcoded pass/perfect-metric return literal spoofs gate evaluation.".to_string(),
2400
+ fix: "Compute the metric from real rendered/runtime output against the reference input.",
2401
+ });
2402
+ }
2403
+ }
2404
+ let has_test_block = test_file || e2e_file || rs_cfg_test_line.is_some();
2405
+ scan_hunk_weakening(rel, hunks, has_test_block || gate_file, has_test_block, out);
2406
+ }
2407
+
2408
+ fn read_json_string(s: &str) -> Option<(String, usize)> {
2409
+ let rest = s.strip_prefix('"')?;
2410
+ let mut out = String::new();
2411
+ let mut chars = rest.char_indices();
2412
+ while let Some((idx, ch)) = chars.next() {
2413
+ if ch == '"' {
2414
+ return Some((out, idx + 2));
2415
+ }
2416
+ if ch == '\\' {
2417
+ let (_, esc) = chars.next()?;
2418
+ match esc {
2419
+ '"' | '\\' | '/' => out.push(esc),
2420
+ 'n' => out.push('\n'),
2421
+ 'r' => out.push('\r'),
2422
+ 't' => out.push('\t'),
2423
+ 'u' => {
2424
+ let mut hex = String::with_capacity(4);
2425
+ for _ in 0..4 {
2426
+ let (_, hc) = chars.next()?;
2427
+ hex.push(hc);
2428
+ }
2429
+ if let Ok(cp) = u32::from_str_radix(&hex, 16) {
2430
+ if let Some(uc) = char::from_u32(cp) {
2431
+ out.push(uc);
2432
+ }
2433
+ }
2434
+ }
2435
+ other => out.push(other),
2436
+ }
2437
+ } else {
2438
+ out.push(ch);
2439
+ }
2440
+ }
2441
+ None
2442
+ }
2443
+
2444
+ fn parse_json_string_map(txt: &str, section_key: &str) -> Vec<(String, String)> {
2445
+ let mut pairs = Vec::new();
2446
+ let needle = format!("\"{}\"", section_key);
2447
+ let Some(pos) = txt.find(&needle) else {
2448
+ return pairs;
2449
+ };
2450
+ let after_key = txt[pos + needle.len()..].trim_start();
2451
+ let Some(after_colon) = after_key.strip_prefix(':') else {
2452
+ return pairs;
2453
+ };
2454
+ let obj_start = after_colon.trim_start();
2455
+ let Some(mut cur) = obj_start.strip_prefix('{') else {
2456
+ return pairs;
2457
+ };
2458
+ loop {
2459
+ cur = cur.trim_start();
2460
+ if let Some(rest) = cur.strip_prefix(',') {
2461
+ cur = rest.trim_start();
2462
+ }
2463
+ if cur.starts_with('}') || cur.is_empty() {
2464
+ break;
2465
+ }
2466
+ let Some((k, klen)) = read_json_string(cur) else {
2467
+ break;
2468
+ };
2469
+ cur = cur[klen..].trim_start();
2470
+ let Some(after_c) = cur.strip_prefix(':') else {
2471
+ break;
2472
+ };
2473
+ cur = after_c.trim_start();
2474
+ let Some((v, vlen)) = read_json_string(cur) else {
2475
+ break;
2476
+ };
2477
+ cur = &cur[vlen..];
2478
+ pairs.push((k, v));
2479
+ }
2480
+ pairs
2481
+ }
2482
+
2483
+ fn check_contract_locks(root: &Path, out: &mut Vec<RewardFinding>) {
2484
+ let rg_dir = root.join(".scratch").join("reward-guard");
2485
+ let Ok(entries) = fs::read_dir(&rg_dir) else {
2486
+ return;
2487
+ };
2488
+ for entry in entries.flatten() {
2489
+ let sdir = entry.path();
2490
+ if !sdir.is_dir() {
2491
+ continue;
2492
+ }
2493
+ let slug = sdir
2494
+ .file_name()
2495
+ .and_then(|n| n.to_str())
2496
+ .unwrap_or("contract");
2497
+ let lock_path = sdir.join("contract-lock.json");
2498
+ let db_path = sdir.join("reward-guard.db");
2499
+ if db_path.is_file() && !lock_path.is_file() {
2500
+ out.push(RewardFinding {
2501
+ severity: "P0",
2502
+ rule: "reward-hack-contract-tampered",
2503
+ file: format!(".scratch/reward-guard/{}/contract-lock.json", slug),
2504
+ line: 1,
2505
+ message: format!("Contract lock file for `{}` was deleted while SQLite contract exists.", slug),
2506
+ fix: "Restore contract-lock.json or re-lock only with explicit operator --force.",
2507
+ });
2508
+ continue;
2509
+ }
2510
+ let Ok(txt) = fs::read_to_string(&lock_path) else {
2511
+ continue;
2512
+ };
2513
+ for section in ["gates", "references"] {
2514
+ for (rel_p, expected_sha) in parse_json_string_map(&txt, section) {
2515
+ if expected_sha.len() == 64 {
2516
+ let live_sha = fs::read(root.join(&rel_p))
2517
+ .map(|b| sha256_hex(&b))
2518
+ .unwrap_or_else(|_| "MISSING".to_string());
2519
+ if live_sha != expected_sha {
2520
+ out.push(RewardFinding {
2521
+ severity: "P0",
2522
+ rule: "reward-hack-contract-tampered",
2523
+ file: rel_p.clone(),
2524
+ line: 1,
2525
+ message: format!(
2526
+ "Locked contract file `{}` was modified or deleted (`{}` != `{}`).",
2527
+ rel_p,
2528
+ &live_sha[..live_sha.len().min(10)],
2529
+ &expected_sha[..10]
2530
+ ),
2531
+ fix: "Revert edits to locked gate/test/reference files so the builder never weakens its own oracle.",
2532
+ });
2533
+ }
2534
+ }
2535
+ }
2536
+ }
2537
+ }
2538
+ }
2539
+
2540
+ fn norm_rel_arg(raw: &str) -> String {
2541
+ let mut s = raw.trim().replace('\\', "/");
2542
+ while let Some(rest) = s.strip_prefix("./") {
2543
+ s = rest.to_string();
2544
+ }
2545
+ s.trim_start_matches('/').to_string()
2546
+ }
2547
+
2548
+ fn discover_scratch_scripts_and_symlinks(root: &Path) -> (Vec<String>, Vec<RewardFinding>) {
2549
+ let scratch = root.join(".scratch");
2550
+ if let Ok(sm) = fs::symlink_metadata(&scratch) {
2551
+ if sm.file_type().is_symlink() {
2552
+ return (
2553
+ Vec::new(),
2554
+ vec![RewardFinding {
2555
+ severity: "P0",
2556
+ rule: "reward-hack-scratch-symlink",
2557
+ file: ".scratch".to_string(),
2558
+ line: 1,
2559
+ message: "`.scratch` is a symlink; scratch symlinks are forbidden to prevent outside-repo gate bypasses.".to_string(),
2560
+ fix: "Replace `.scratch` symlink with a real directory inside the project root.",
2561
+ }],
2562
+ );
2563
+ }
2564
+ }
2565
+ if !scratch.is_dir() {
2566
+ return (Vec::new(), Vec::new());
2567
+ }
2568
+ let skip_top = [
2569
+ "reward-guard",
2570
+ "self-grill",
2571
+ "evidence",
2572
+ "goals",
2573
+ "gen-ui",
2574
+ "agents-md-backup",
2575
+ "quota-guard",
2576
+ ];
2577
+ let mut found = Vec::new();
2578
+ let mut sym_findings = Vec::new();
2579
+ let mut stack = vec![(scratch.clone(), true)];
2580
+ while let Some((dir, is_top)) = stack.pop() {
2581
+ let Ok(entries) = fs::read_dir(&dir) else {
2582
+ continue;
2583
+ };
2584
+ for entry in entries.flatten() {
2585
+ let p = entry.path();
2586
+ let Ok(meta) = fs::symlink_metadata(&p) else {
2587
+ continue;
2588
+ };
2589
+ let name = entry.file_name().to_string_lossy().to_string();
2590
+ let low = name.to_ascii_lowercase();
2591
+ let rel_s = p
2592
+ .strip_prefix(root)
2593
+ .map(|r| r.to_string_lossy().replace('\\', "/"))
2594
+ .unwrap_or_else(|_| name.clone());
2595
+ if meta.file_type().is_symlink() {
2596
+ sym_findings.push(RewardFinding {
2597
+ severity: "P0",
2598
+ rule: "reward-hack-scratch-symlink",
2599
+ file: rel_s,
2600
+ line: 1,
2601
+ message: "Symlink inside `.scratch/` is blocked to prevent external script bypasses.".to_string(),
2602
+ fix: "Remove the symlink from `.scratch/`.",
2603
+ });
2604
+ continue;
2605
+ }
2606
+ if (is_top && skip_top.contains(&name.as_str()))
2607
+ || low.starts_with("check-")
2608
+ || low.starts_with("npm-test-")
2609
+ || low.starts_with("init-cli-test-")
2610
+ || low.starts_with("panel-")
2611
+ || low.starts_with("autoroute-test-")
2612
+ {
2613
+ continue;
2614
+ }
2615
+ if meta.is_dir() {
2616
+ stack.push((p, false));
2617
+ } else if meta.is_file() && meta.len() > 0 {
2618
+ let ext = p
2619
+ .extension()
2620
+ .and_then(|e| e.to_str())
2621
+ .map(|s| s.to_ascii_lowercase())
2622
+ .unwrap_or_default();
2623
+ if matches!(ext.as_str(), "py" | "sh" | "ps1" | "cmd" | "bat" | "js" | "mjs" | "cjs" | "ts") {
2624
+ if meta.len() > 16 * 1024 * 1024 {
2625
+ sym_findings.push(RewardFinding {
2626
+ severity: "P0",
2627
+ rule: "reward-hack-oversized-scratch-script",
2628
+ file: rel_s,
2629
+ line: 1,
2630
+ message: "Scratch script exceeds 16 MiB (padding bypass blocked).".to_string(),
2631
+ fix: "Remove oversized padded script from `.scratch/`.",
2632
+ });
2633
+ } else if found.len() < 500 {
2634
+ found.push(rel_s);
2635
+ }
2636
+ }
2637
+ }
2638
+ }
2639
+ }
2640
+ found.sort();
2641
+ (found, sym_findings)
2642
+ }
2643
+
2644
+ fn discover_scratch_scripts(root: &Path) -> Vec<String> {
2645
+ discover_scratch_scripts_and_symlinks(root).0
2646
+ }
2647
+
2648
+ fn changed_files(
2649
+ root: &Path,
2650
+ staged: bool,
2651
+ explicit: &[String],
2652
+ base: Option<&str>,
2653
+ include_scratch: bool,
2654
+ ) -> Vec<String> {
2655
+ if !explicit.is_empty() {
2656
+ let mut set = BTreeSet::new();
2657
+ for raw in explicit {
2658
+ for part in raw.split(',') {
2659
+ let n = norm_rel_arg(part);
2660
+ if !n.is_empty() {
2661
+ set.insert(n);
2662
+ }
2663
+ }
2664
+ }
2665
+ return set.into_iter().collect();
2666
+ }
2667
+ let mut set = BTreeSet::new();
2668
+ let has_head = git(root, &["rev-parse", "--verify", "HEAD"])
2669
+ .map(|(ok, _)| ok)
2670
+ .unwrap_or(false);
2671
+ if staged {
2672
+ if let Some((true, out)) =
2673
+ git(root, &["diff", "--cached", "--name-only", "--diff-filter=ACMR"])
2674
+ {
2675
+ for l in out.lines().map(str::trim).filter(|l| !l.is_empty()) {
2676
+ set.insert(l.to_string());
2677
+ }
2678
+ }
2679
+ } else {
2680
+ if let Some(b) = base {
2681
+ if let Some((true, out)) = git(root, &["diff", b, "--name-only", "--diff-filter=ACMR"])
2682
+ {
2683
+ for l in out.lines().map(str::trim).filter(|l| !l.is_empty()) {
2684
+ set.insert(l.to_string());
2685
+ }
2686
+ }
2687
+ } else if has_head {
2688
+ if let Some((true, out)) =
2689
+ git(root, &["diff", "HEAD", "--name-only", "--diff-filter=ACMR"])
2690
+ {
2691
+ for l in out.lines().map(str::trim).filter(|l| !l.is_empty()) {
2692
+ set.insert(l.to_string());
2693
+ }
2694
+ }
2695
+ }
2696
+ if let Some((true, out)) = git(root, &["ls-files", "--others", "--exclude-standard"]) {
2697
+ for l in out.lines().map(str::trim).filter(|l| !l.is_empty()) {
2698
+ set.insert(l.to_string());
2699
+ }
2700
+ }
2701
+ }
2702
+ let mut clean: BTreeSet<String> = set
2703
+ .into_iter()
2704
+ .filter(|f| !f.starts_with(".scratch/") && !f.starts_with(".worktrees/"))
2705
+ .collect();
2706
+ if include_scratch && !staged {
2707
+ for sf in discover_scratch_scripts(root) {
2708
+ clean.insert(sf);
2709
+ }
2710
+ }
2711
+ clean.into_iter().collect()
2712
+ }
2713
+
2714
+ pub fn run(args: &[String]) -> ExitCode {
2715
+ let mut root = PathBuf::from(".");
2716
+ let mut base_ref: Option<String> = None;
2717
+ let mut staged = false;
2718
+ let mut allow_primitives = false;
2719
+ let mut include_scratch = true;
2720
+ let mut advisory = false;
2721
+ let mut as_json = false;
2722
+ let mut explicit_files: Vec<String> = Vec::new();
2723
+ let mut i = 0;
2724
+ while i < args.len() {
2725
+ match args[i].as_str() {
2726
+ "scan" => i += 1,
2727
+ "--root" if i + 1 < args.len() => {
2728
+ root = PathBuf::from(&args[i + 1]);
2729
+ i += 2;
2730
+ }
2731
+ "--base" if i + 1 < args.len() => {
2732
+ base_ref = Some(args[i + 1].clone());
2733
+ i += 2;
2734
+ }
2735
+ "--staged" => {
2736
+ staged = true;
2737
+ i += 1;
2738
+ }
2739
+ "--allow-primitives" => {
2740
+ allow_primitives = true;
2741
+ i += 1;
2742
+ }
2743
+ "--no-scratch" => {
2744
+ include_scratch = false;
2745
+ i += 1;
2746
+ }
2747
+ "--advisory" => {
2748
+ advisory = true;
2749
+ i += 1;
2750
+ }
2751
+ "--json" => {
2752
+ as_json = true;
2753
+ i += 1;
2754
+ }
2755
+ "--files" => {
2756
+ i += 1;
2757
+ while i < args.len() && !args[i].starts_with("--") {
2758
+ explicit_files.push(args[i].clone());
2759
+ i += 1;
2760
+ }
2761
+ }
2762
+ other => {
2763
+ eprintln!("dmb-gate reward error: unknown or forbidden argument `{}` (self-reported `record-judge` is banned; use `run-judge`).", other);
2764
+ return ExitCode::from(2);
2765
+ }
2766
+ }
2767
+ }
2768
+
2769
+ let root = fs::canonicalize(&root).unwrap_or(root);
2770
+ let changed = changed_files(&root, staged, &explicit_files, base_ref.as_deref(), include_scratch);
2771
+ let per_file = parallel_map(&changed, |rel| {
2772
+ let mut local = Vec::new();
2773
+ let (mut added, hunks) = diff_file_hunks(&root, rel, staged, base_ref.as_deref());
2774
+ let full_txt = if staged && !added.is_empty() {
2775
+ git(&root, &["show", &format!(":{rel}")]).filter(|(ok, _)| *ok).map(|(_, text)| text)
2776
+ } else {
2777
+ fs::read_to_string(root.join(rel)).ok()
2778
+ };
2779
+ let rs_cfg_ln = if rel.ends_with(".rs") {
2780
+ full_txt.as_deref().and_then(find_rs_cfg_test_line)
2781
+ } else {
2782
+ None
2783
+ };
2784
+ let mypy_set = full_txt.as_deref().map(find_mypy_section_lines);
2785
+ if added.is_empty() && !explicit_files.is_empty() {
2786
+ if let Some(txt) = &full_txt {
2787
+ added = txt
2788
+ .lines()
2789
+ .enumerate()
2790
+ .map(|(idx, s)| (idx + 1, s.to_string()))
2791
+ .collect();
2792
+ }
2793
+ }
2794
+ if !added.is_empty() || !hunks.is_empty() {
2795
+ scan_file_reward_hacks_full(
2796
+ rel,
2797
+ &added,
2798
+ &hunks,
2799
+ allow_primitives,
2800
+ true,
2801
+ rs_cfg_ln,
2802
+ mypy_set.as_ref(),
2803
+ full_txt.as_deref(),
2804
+ &mut local,
2805
+ );
2806
+ }
2807
+ local
2808
+ });
2809
+
2810
+ let mut findings: Vec<RewardFinding> = per_file.into_iter().flatten().collect();
2811
+ check_contract_locks(&root, &mut findings);
2812
+ if include_scratch && !staged && explicit_files.is_empty() {
2813
+ findings.extend(discover_scratch_scripts_and_symlinks(&root).1);
2814
+ }
2815
+
2816
+ let p0 = findings.iter().filter(|f| f.severity == "P0").count();
2817
+ let p1 = findings.iter().filter(|f| f.severity == "P1").count();
2818
+ let p2 = findings.iter().filter(|f| f.severity == "P2").count();
2819
+ let ok = p0 == 0 && p1 == 0;
2820
+
2821
+ if as_json {
2822
+ let items: Vec<String> = findings
2823
+ .iter()
2824
+ .map(|f| {
2825
+ format!(
2826
+ "{{\"severity\":{},\"rule\":{},\"file\":{},\"line\":{},\"message\":{},\"fix\":{}}}",
2827
+ json_escape(f.severity),
2828
+ json_escape(f.rule),
2829
+ json_escape(&f.file),
2830
+ f.line,
2831
+ json_escape(&f.message),
2832
+ json_escape(&f.fix)
2833
+ )
2834
+ })
2835
+ .collect();
2836
+ println!(
2837
+ "{{\"ok\":{},\"engine\":\"rust-parallel\",\"files_checked\":{},\"counts\":{{\"P0\":{},\"P1\":{},\"P2\":{}}},\"findings\":[{}]}}",
2838
+ ok,
2839
+ changed.len(),
2840
+ p0,
2841
+ p1,
2842
+ p2,
2843
+ items.join(",")
2844
+ );
2845
+ } else {
2846
+ println!(
2847
+ "dmb-gate reward [{}]: {} file(s) — P0:{} P1:{} P2:{}",
2848
+ if ok { "OK" } else { "BLOCKED" },
2849
+ changed.len(),
2850
+ p0,
2851
+ p1,
2852
+ p2
2853
+ );
2854
+ for f in &findings {
2855
+ println!(
2856
+ " {}:{} [{}:{}] {} -> {}",
2857
+ f.file, f.line, f.severity, f.rule, f.message, f.fix
2858
+ );
2859
+ }
2860
+ }
2861
+
2862
+ if ok || advisory {
2863
+ ExitCode::SUCCESS
2864
+ } else {
2865
+ ExitCode::from(1)
2866
+ }
2867
+ }