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.
- package/.agents/plugins/marketplace.json +20 -0
- package/.claude-plugin/marketplace.json +2 -2
- package/.omp-plugin/marketplace.json +2 -2
- package/README.md +38 -5
- package/bin/deepmodebot.mjs +257 -4
- package/lib/clients.mjs +50 -3
- package/lib/tree.mjs +64 -10
- package/native/dmb-gate/Cargo.toml +13 -0
- package/native/dmb-gate/src/agents.rs +110 -0
- package/native/dmb-gate/src/ci.rs +1032 -0
- package/native/dmb-gate/src/cleanup.rs +198 -0
- package/native/dmb-gate/src/gap.rs +1376 -0
- package/native/dmb-gate/src/guard.rs +135 -0
- package/native/dmb-gate/src/main.rs +535 -0
- package/native/dmb-gate/src/map.rs +173 -0
- package/native/dmb-gate/src/perf.rs +347 -0
- package/native/dmb-gate/src/reward.rs +2867 -0
- package/native/dmb-gate/src/sim.rs +969 -0
- package/native/dmb-gate/src/skill_check.rs +171 -0
- package/native/dmb-gate/src/slop.rs +2004 -0
- package/native/dmb-gate/src/ui.rs +842 -0
- package/native/dmb-gate/src/util.rs +260 -0
- package/native/dmb-net/go.mod +3 -0
- package/native/dmb-net/main.go +624 -0
- package/native/dmb-net/main_test.go +122 -0
- package/package.json +12 -2
- package/plugins/deepmodebot/.antigravity-plugin/plugin.json +1 -1
- package/plugins/deepmodebot/.antigravity-plugin/skills/deep/SKILL.md +5 -5
- package/plugins/deepmodebot/.antigravity-plugin/skills/pr-thread/SKILL.md +1 -1
- package/plugins/deepmodebot/.antigravity-plugin/skills/review-pr/SKILL.md +2 -2
- package/plugins/deepmodebot/.antigravity-plugin/skills/suggest/SKILL.md +13 -0
- package/plugins/deepmodebot/.antigravity-plugin/skills/tournament/SKILL.md +2 -2
- package/plugins/deepmodebot/.claude-plugin/plugin.json +1 -1
- package/plugins/deepmodebot/.codex-plugin/plugin.json +46 -0
- package/plugins/deepmodebot/agents/comment-sicko.md +29 -0
- package/plugins/deepmodebot/agents/researcher.md +29 -0
- package/plugins/deepmodebot/agents/reviewer.md +29 -0
- package/plugins/deepmodebot/agents/scout.md +28 -0
- package/plugins/deepmodebot/agents/security-reviewer.md +27 -0
- package/plugins/deepmodebot/commands/deep.md +7 -6
- package/plugins/deepmodebot/commands/research.md +8 -0
- package/plugins/deepmodebot/commands/suggest.md +10 -0
- package/plugins/deepmodebot/commands/tournament.md +2 -2
- package/plugins/deepmodebot/hooks/hooks.json +12 -2
- package/plugins/deepmodebot/hooks.json +1 -1
- package/plugins/deepmodebot/scripts/antigravity-guard.mjs +862 -26
- package/plugins/deepmodebot/scripts/omp-mcp-server.mjs +179 -47
- package/plugins/deepmodebot/skills/agent-harnesses/SKILL.md +4 -6
- package/plugins/deepmodebot/skills/agent-harnesses/assets/sdks/check_antigravity.py +3 -0
- package/plugins/deepmodebot/skills/agent-harnesses/references/ai-native-tooling.md +4 -0
- package/plugins/deepmodebot/skills/agent-harnesses/references/ai-sdk-selection.md +3 -1
- package/plugins/deepmodebot/skills/agent-harnesses/references/antigravity.md +3 -3
- package/plugins/deepmodebot/skills/agent-harnesses/references/delegation-efficiency.md +12 -2
- package/plugins/deepmodebot/skills/agent-harnesses/references/protocols.md +11 -3
- package/plugins/deepmodebot/skills/app-automation-relay/SKILL.md +17 -0
- package/plugins/deepmodebot/skills/app-automation-relay/assets/relay_server.ts +364 -0
- package/plugins/deepmodebot/skills/app-automation-relay/references/adapter-cookbook.md +15 -0
- package/plugins/deepmodebot/skills/app-automation-relay/references/wire-protocol.md +23 -0
- package/plugins/deepmodebot/skills/cloud-devsecops/SKILL.md +4 -3
- package/plugins/deepmodebot/skills/cloud-devsecops/references/cloudflare-edge.md +43 -0
- package/plugins/deepmodebot/skills/cloud-devsecops/references/local-emulators.md +15 -2
- package/plugins/deepmodebot/skills/contribute/SKILL.md +3 -35
- package/plugins/deepmodebot/skills/create-formal-verification-skill/LICENSE +21 -0
- package/plugins/deepmodebot/skills/create-formal-verification-skill/NOTICE.md +16 -0
- package/plugins/deepmodebot/skills/create-formal-verification-skill/SKILL.md +71 -0
- package/plugins/deepmodebot/skills/create-verification-skill/SKILL.md +2 -2
- package/plugins/deepmodebot/skills/deep-learning/LICENSE +21 -0
- package/plugins/deepmodebot/skills/deep-learning/SKILL.md +33 -0
- package/plugins/deepmodebot/skills/deep-learning/references/neural-architectures.md +43 -0
- package/plugins/deepmodebot/skills/deep-learning/references/papers-and-repos.md +128 -0
- package/plugins/deepmodebot/skills/deep-learning/references/reinforcement-learning.md +57 -0
- package/plugins/deepmodebot/skills/deep-learning/references/training-optimization.md +40 -0
- package/plugins/deepmodebot/skills/deep-learning/references/weight-space-programming.md +76 -0
- package/plugins/deepmodebot/skills/deep-learning/scripts/hf_passes.py +166 -0
- package/plugins/deepmodebot/skills/deep-learning/scripts/wsp.py +493 -0
- package/plugins/deepmodebot/skills/deep-stack/SKILL.md +1 -1
- package/plugins/deepmodebot/skills/deep-stack/references/design-workflow.md +46 -92
- package/plugins/deepmodebot/skills/deep-stack/references/isolate.md +1 -0
- package/plugins/deepmodebot/skills/deep-stack/references/prove.md +6 -0
- package/plugins/deepmodebot/skills/deep-stack/references/stack.md +11 -1
- package/plugins/deepmodebot/skills/deepmodebot/SKILL.md +83 -146
- package/plugins/deepmodebot/skills/deepmodebot/assets/agents-md/agents_md.py +67 -24
- package/plugins/deepmodebot/skills/deepmodebot/assets/autoroute/autoroute.py +1026 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/cleanup/self_cleanup.py +305 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/contain/claude-guard.sh +4 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/contain/claude_guard.py +736 -6
- package/plugins/deepmodebot/skills/deepmodebot/assets/contain/holdout_guard_cases.json +272 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/contain/omp-contain.ts +861 -9
- package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/design.py +3 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/record.py +2 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/rehearsal_gate.py +536 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/review.py +2 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/f2p-gate/f2p_gate.py +547 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/formal-verification/verify_proof.py +638 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/gap-audit/gap_audit.py +1047 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/gen-ui/gen_ui.py +1782 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/git-guardrails/git-guard-patterns.txt +7 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/git-guardrails/git-guard.sh +55 -7
- package/plugins/deepmodebot/skills/deepmodebot/assets/git-guardrails/git-guard.ts +55 -5
- package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/ghapp.py +2 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/install.py +2 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/local-ci/local_ci.py +796 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/local-ci/slop_gate.py +1049 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/loop/loop.py +748 -46
- package/plugins/deepmodebot/skills/deepmodebot/assets/loop/plan.py +2 -1
- package/plugins/deepmodebot/skills/deepmodebot/assets/loop/windows_job.py +2 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/memory/project_memory.py +928 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/mutation/mutation_gate.py +798 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/perf-audit/bench_harness.py +48 -21
- package/plugins/deepmodebot/skills/deepmodebot/assets/perf-audit/perf_audit.py +339 -5
- package/plugins/deepmodebot/skills/deepmodebot/assets/pr-agent/diff_coverage.py +96 -6
- package/plugins/deepmodebot/skills/deepmodebot/assets/pr-agent/pr_agent_local.py +2 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/pr-conversation/arena.py +2 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/pr-conversation/show_thread.py +2 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/prompt-tools/prompt_tools.py +1239 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/quota-guard/quota_guard.py +424 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/repo-references.json +477 -1
- package/plugins/deepmodebot/skills/deepmodebot/assets/reward-guard/reward_guard.py +3447 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/rules/rule-paths.json +100 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/rules/rule_ledger.py +1671 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/rules/rules_watch.py +436 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/scrape/yt_enrich.py +2 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/scrape/yt_meta.py +2 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/scrape/yt_transcript_relay.js +13 -10
- package/plugins/deepmodebot/skills/deepmodebot/assets/security-audit/static_sec_audit.py +275 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/self-grill/self_grill.py +2049 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/setup/model_setup.py +329 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/setup/project_setup.py +348 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/sim/sim.py +856 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/tournament/tournament.py +304 -18
- package/plugins/deepmodebot/skills/deepmodebot/assets/worker-gate/worker_gate.py +237 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/workspace-map/workspace_map.py +121 -78
- package/plugins/deepmodebot/skills/deepmodebot/references/README.md +14 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/catalog.md +17 -11
- package/plugins/deepmodebot/skills/deepmodebot/references/contain.md +2 -1
- package/plugins/deepmodebot/skills/deepmodebot/references/delegation.md +18 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/flows.md +2 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/full-scope.md +9 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/authoring-a-skill.md +1 -1
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/babysit.md +2 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/end-to-end.md +12 -9
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/feature.md +7 -3
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/hillclimb.md +3 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/investigation.md +4 -4
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/opening-a-pr.md +1 -1
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/perf-issue.md +13 -10
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/refactoring.md +6 -6
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/reference-rebuild.md +1 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/run-a-goal.md +3 -1
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/self-authoring.md +1 -1
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/setup.md +1 -2
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/visual-parity.md +1 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/work-a-queue.md +4 -2
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/hardcore-mode.md +7 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/no-reward-hacking.md +8 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/test-behavior-not-implementation.md +2 -1
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/type-system-discipline.md +2 -2
- package/plugins/deepmodebot/skills/deepmodebot/references/rule-approval.md +71 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/architect.md +10 -24
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/architecture-review.md +5 -4
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/arena.md +3 -3
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/autoroute.md +50 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/blast-radius.md +1 -1
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/catchup-video.md +13 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/correct.md +9 -7
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/course.md +2 -1
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/devex-review.md +13 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/expand-contract.md +13 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/formal-verification.md +33 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/gen-ui.md +60 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/grill.md +2 -1
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/how.md +7 -18
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/inner-loop.md +12 -8
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/model-setup.md +14 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/modernize-pr.md +15 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/mutation-testing.md +35 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/no-comments.md +5 -5
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/panel.md +9 -5
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/pr-conversation.md +1 -1
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/pr-review.md +8 -5
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/pre-commit.md +1 -2
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/prior-art.md +33 -38
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/product-lens.md +12 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/prompt-upgrade.md +30 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/recall.md +1 -1
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/reframe.md +18 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/release-and-canary.md +10 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/research.md +62 -89
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/security-audit.md +5 -1
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/self-grill.md +54 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/sharpen.md +3 -3
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/show-me-your-work.md +7 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/sim.md +41 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/sme-review.md +3 -2
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/suggest.md +24 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/swarm.md +7 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/tdd.md +12 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/teach.md +2 -2
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/tournament.md +30 -18
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/variant-analysis.md +11 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/video-forensics.md +46 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/visual-e2e.md +10 -1
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/webhook-ui.md +11 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/writing-for-agents.md +6 -0
- package/plugins/deepmodebot/skills/deepmodebot/scripts/check_skill.py +7 -0
- package/plugins/deepmodebot/skills/deepmodebot/scripts/trending.py +141 -18
- package/plugins/deepmodebot/skills/deepmodebot/worker.md +28 -0
- package/plugins/deepmodebot/skills/domain-rules/SKILL.md +13 -119
- package/plugins/deepmodebot/skills/domain-rules/references/backend-system-design.md +19 -1
- package/plugins/deepmodebot/skills/domain-rules/references/engineering-practice.md +7 -0
- package/plugins/deepmodebot/skills/domain-rules/references/language-ecosystems.md +11 -0
- package/plugins/deepmodebot/skills/domain-rules/references/sources.md +108 -0
- package/plugins/deepmodebot/skills/frontend-ui/SKILL.md +30 -131
- package/plugins/deepmodebot/skills/frontend-ui/assets/themes/canvas.css +42 -0
- package/plugins/deepmodebot/skills/frontend-ui/assets/themes/editorial.css +39 -0
- package/plugins/deepmodebot/skills/frontend-ui/assets/themes/layouts.css +95 -0
- package/plugins/deepmodebot/skills/frontend-ui/assets/themes/swiss.css +40 -0
- package/plugins/deepmodebot/skills/frontend-ui/assets/themes/tactile.css +41 -0
- package/plugins/deepmodebot/skills/frontend-ui/assets/themes/workbench.css +50 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/patterns/mobbin-animations.md +49 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/patterns/mobbin-shipped-apps.md +46 -24
- package/plugins/deepmodebot/skills/frontend-ui/references/patterns/motion-clips.md +27 -258
- package/plugins/deepmodebot/skills/frontend-ui/references/patterns/motion-graphics.md +26 -51
- package/plugins/deepmodebot/skills/frontend-ui/references/patterns/pinterest-animations.md +22 -195
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/00-art-direction.md +39 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/01-workflow.md +27 -24
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/02-review-rubric.md +23 -17
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/03-ai-tells.md +22 -45
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/04-components.md +11 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/04a-agent-ui.md +32 -152
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/05-motion.md +36 -91
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/05a-motion-graphics.md +14 -120
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/06-typography-layout.md +11 -10
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/06a-color.md +9 -9
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/06b-media-icons-charts.md +19 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/06c-product-shots-craft.md +42 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/07-copy.md +5 -6
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/08-quality-floor.md +28 -56
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/09-steering-agents.md +9 -7
- package/plugins/deepmodebot/skills/frontend-ui/scripts/motion_diff.py +259 -0
- package/plugins/deepmodebot/skills/frontend-ui/scripts/ui_audit.py +496 -0
- package/plugins/deepmodebot/skills/maintain-formal-verification-skill/LICENSE +21 -0
- package/plugins/deepmodebot/skills/maintain-formal-verification-skill/NOTICE.md +16 -0
- package/plugins/deepmodebot/skills/maintain-formal-verification-skill/SKILL.md +68 -0
- package/plugins/deepmodebot/skills/maintain-verification-skill/SKILL.md +1 -1
- package/plugins/deepmodebot/skills/office-documents/SKILL.md +24 -0
- package/plugins/deepmodebot/skills/office-documents/references/documents-docx-pdf.md +15 -0
- package/plugins/deepmodebot/skills/office-documents/references/presentations-pptx.md +15 -0
- package/plugins/deepmodebot/skills/office-documents/references/spreadsheets-xlsx.md +15 -0
- package/plugins/deepmodebot/skills/office-documents/scripts/doc_audit.py +230 -0
- package/plugins/deepmodebot/skills/project-brief/SKILL.md +2 -19
- package/plugins/deepmodebot/skills/project-brief/assets/pr-overlap.py +4 -0
- package/plugins/deepmodebot/skills/project-brief/assets/sync-roadmap.py +4 -0
- package/plugins/deepmodebot/skills/project-brief/references/claim-contract.md +55 -0
- package/plugins/deepmodebot/skills/research/SKILL.md +18 -0
- package/plugins/deepmodebot/skills/secrets-and-auth/SKILL.md +1 -1
- package/plugins/deepmodebot/skills/seo-and-geo/SKILL.md +29 -0
- package/plugins/deepmodebot/skills/seo-and-geo/references/geo-and-agentic-web.md +30 -0
- package/plugins/deepmodebot/skills/seo-and-geo/references/technical-and-schema.md +25 -0
- package/plugins/deepmodebot/skills/seo-and-geo/scripts/seo_audit.py +282 -0
- package/plugins/deepmodebot/skills/software-architecture/SKILL.md +2 -2
- package/plugins/deepmodebot/skills/software-architecture/references/backend-infrastructure.md +5 -0
- package/plugins/deepmodebot/skills/software-architecture/references/monorepos.md +1 -0
- package/plugins/deepmodebot/skills/statechart/LICENSE +21 -0
- package/plugins/deepmodebot/skills/statechart/NOTICE.md +21 -0
- package/plugins/deepmodebot/skills/statechart/SKILL.md +106 -0
- package/plugins/deepmodebot/skills/statechart/references/render.md +93 -0
- package/plugins/deepmodebot/skills/statechart/references/tooling.md +78 -0
- package/plugins/deepmodebot/skills/statechart/scripts/backends/cfg.ts +33 -0
- package/plugins/deepmodebot/skills/statechart/scripts/backends/mermaid.ts +249 -0
- package/plugins/deepmodebot/skills/statechart/scripts/backends/plain-text.ts +72 -0
- package/plugins/deepmodebot/skills/statechart/scripts/backends/report.ts +177 -0
- package/plugins/deepmodebot/skills/statechart/scripts/frontends/config.ts +276 -0
- package/plugins/deepmodebot/skills/statechart/scripts/frontends/dot.ts +77 -0
- package/plugins/deepmodebot/skills/statechart/scripts/frontends/marks.ts +93 -0
- package/plugins/deepmodebot/skills/statechart/scripts/frontends/messages.ts +52 -0
- package/plugins/deepmodebot/skills/statechart/scripts/frontends/spec.ts +114 -0
- package/plugins/deepmodebot/skills/statechart/scripts/frontends/trace.ts +24 -0
- package/plugins/deepmodebot/skills/statechart/scripts/frontends/value.ts +166 -0
- package/plugins/deepmodebot/skills/statechart/scripts/frontends/verdict.ts +40 -0
- package/plugins/deepmodebot/skills/statechart/scripts/frontends/view.ts +119 -0
- package/plugins/deepmodebot/skills/statechart/scripts/ir.ts +547 -0
- package/plugins/deepmodebot/skills/statechart/scripts/janitor.ts +13 -0
- package/plugins/deepmodebot/skills/statechart/scripts/kill.ts +15 -0
- package/plugins/deepmodebot/skills/statechart/scripts/package.json +11 -0
- package/plugins/deepmodebot/skills/statechart/scripts/passes/annotate.ts +128 -0
- package/plugins/deepmodebot/skills/statechart/scripts/passes/label.ts +269 -0
- package/plugins/deepmodebot/skills/statechart/scripts/passes/lift.ts +85 -0
- package/plugins/deepmodebot/skills/statechart/scripts/passes/loop-check.ts +68 -0
- package/plugins/deepmodebot/skills/statechart/scripts/passes/paths.ts +60 -0
- package/plugins/deepmodebot/skills/statechart/scripts/passes/reach.ts +135 -0
- package/plugins/deepmodebot/skills/statechart/scripts/passes/region-check.ts +97 -0
- package/plugins/deepmodebot/skills/statechart/scripts/passes/regions.ts +295 -0
- package/plugins/deepmodebot/skills/statechart/scripts/pipeline.ts +76 -0
- package/plugins/deepmodebot/skills/statechart/scripts/run.ts +500 -0
- package/plugins/deepmodebot/skills/statechart/scripts/statechart +29 -0
- package/plugins/deepmodebot/skills/statechart/scripts/statechart.ts +165 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/ConfigOracle.java +63 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/chart.test.ts +1253 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/charts/Braces.mmd +7 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/charts/Escapes.mmd +11 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/charts/Phases.mmd +29 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/cli.test.ts +1344 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/config-fuzz.test.ts +263 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Counter/ChartRun.out +57 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Counter/Counter.cfg +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Counter/Counter.tla +10 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Counter/chart.mmd +9 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Counter/graph.dot +16 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Counter/report.md +7 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Counter/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Counter/verdict-1.out +49 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/ChartRun.out +60 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/CounterAction.cfg +4 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/CounterAction.tla +22 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/chart.mmd +26 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/graph.dot +19 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/report.md +20 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/verdict-1.out +56 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/verdict-2.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/verdict-2.out +82 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterAction/verdict-3.out +57 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/ChartRun.out +59 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/CounterDeadlock.cfg +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/CounterDeadlock.tla +11 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/chart.mmd +22 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/graph.dot +16 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/report.md +17 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/verdict-1.out +56 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/verdict-2.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterDeadlock/verdict-2.out +77 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterFan/ChartRun.out +69 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterFan/CounterFan.cfg +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterFan/CounterFan.tla +11 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterFan/chart.mmd +85 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterFan/graph.dot +70 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterFan/report.md +12 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterFan/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterFan/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterFan/verdict-1.out +67 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterFan/verdict-2.out +57 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/ChartRun.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/ChartRun.out +85 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/CounterGuard.cfg +6 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/CounterGuard.tla +13 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/chart.mmd +5 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/graph.dot +10 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/report.md +31 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/verdict-1.out +64 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/verdict-2.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterGuard/verdict-2.out +77 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPast/ChartRun.out +55 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPast/CounterInitPast.cfg +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPast/CounterInitPast.tla +10 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPast/chart.mmd +12 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPast/graph.dot +6 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPast/report.md +12 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPast/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPast/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPast/verdict-1.out +33 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPast/verdict-2.out +54 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPastHolds/ChartRun.out +54 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPastHolds/CounterInitPastHolds.cfg +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPastHolds/CounterInitPastHolds.tla +10 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPastHolds/chart.mmd +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPastHolds/graph.dot +6 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPastHolds/report.md +7 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPastHolds/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInitPastHolds/verdict-1.out +46 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInstance/ChartRun.out +59 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInstance/CounterInstance.cfg +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInstance/CounterInstance.tla +10 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInstance/CounterSteps.tla +6 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInstance/chart.mmd +17 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInstance/graph.dot +15 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInstance/report.md +14 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInstance/sany.out +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInstance/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterInstance/verdict-1.out +78 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterJump/ChartRun.out +59 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterJump/CounterJump.cfg +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterJump/CounterJump.tla +19 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterJump/chart.mmd +26 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterJump/graph.dot +22 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterJump/report.md +12 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterJump/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterJump/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterJump/verdict-1.out +58 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterJump/verdict-2.out +57 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterLoop/ChartRun.out +57 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterLoop/CounterLoop.cfg +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterLoop/CounterLoop.tla +11 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterLoop/chart.mmd +17 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterLoop/graph.dot +15 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterLoop/report.md +14 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterLoop/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterLoop/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterLoop/verdict-1.out +76 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/ChartRun.out +59 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/CounterOrder.cfg +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/CounterOrder.tla +11 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/chart.mmd +19 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/graph.dot +10 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/report.md +15 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/verdict-1.out +56 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/verdict-2.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterOrder/verdict-2.out +67 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/ChartRun.out +62 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/CounterRules.cfg +6 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/CounterRules.tla +24 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/Moves.tla +5 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/chart.mmd +22 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/graph.dot +10 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/report.md +23 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/sany.out +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/verdict-1.out +58 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/verdict-2.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/verdict-2.out +66 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/verdict-3.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/verdict-3.out +74 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterRules/verdict-4.out +59 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStart/ChartRun.out +58 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStart/CounterStart.cfg +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStart/CounterStart.tla +15 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStart/chart.mmd +18 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStart/graph.dot +13 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStart/report.md +11 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStart/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStart/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStart/verdict-1.out +33 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStart/verdict-2.out +57 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStop/ChartRun.out +57 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStop/CounterStop.cfg +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStop/CounterStop.tla +15 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStop/chart.mmd +7 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStop/graph.dot +13 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStop/report.md +6 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStop/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterStop/verdict-1.out +49 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/ChartRun.out +61 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/CounterTie.cfg +4 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/CounterTie.tla +14 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/chart.mmd +30 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/graph.dot +19 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/report.md +27 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/verdict-1.out +56 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/verdict-2.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/verdict-2.out +64 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/verdict-3.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/verdict-3.out +87 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTie/verdict-4.out +57 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTieInGraph/ChartRun.out +60 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTieInGraph/CounterTieInGraph.cfg +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTieInGraph/CounterTieInGraph.tla +12 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTieInGraph/chart.mmd +23 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTieInGraph/graph.dot +19 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTieInGraph/report.md +11 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTieInGraph/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTieInGraph/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTieInGraph/verdict-1.out +56 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterTieInGraph/verdict-2.out +57 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/ChartRun.out +61 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/CounterView.cfg +4 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/CounterView.tla +14 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/chart.mmd +23 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/graph.dot +19 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/report.md +27 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/verdict-1.out +56 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/verdict-2.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/verdict-2.out +64 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/verdict-3.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/verdict-3.out +87 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/verdict-4.out +57 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/CounterView/view.mjs +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/DieHard/ChartRun.out +59 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/DieHard/DieHard.cfg +4 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/DieHard/DieHard.tla +38 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/DieHard/chart.mmd +92 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/DieHard/graph.dot +126 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/DieHard/report.md +17 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/DieHard/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/DieHard/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/DieHard/verdict-1.out +91 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/DieHard/verdict-2.out +57 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/ChartRun.out +61 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/FirstRule.cfg +6 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/FirstRule.tla +11 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/chart.mmd +22 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/graph.dot +16 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/report.md +25 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/verdict-1.out +56 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/verdict-2.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/verdict-2.out +64 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/verdict-3.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/verdict-3.out +64 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/verdict-4.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/FirstRule/verdict-4.out +77 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/HiddenClock/ChartRun.out +57 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/HiddenClock/HiddenClock.cfg +4 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/HiddenClock/HiddenClock.tla +11 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/HiddenClock/chart.mmd +13 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/HiddenClock/graph.dot +12 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/HiddenClock/report.md +11 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/HiddenClock/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/HiddenClock/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/HiddenClock/verdict-1.out +72 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Login/ChartRun.out +57 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Login/Login.cfg +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Login/Login.tla +62 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Login/chart.mmd +28 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Login/graph.dot +40 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Login/report.md +7 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Login/sany.out +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Login/verdict-1.out +47 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Login/view.mjs +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginGuarded/ChartRun.out +57 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginGuarded/LoginGuarded.cfg +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginGuarded/LoginGuarded.tla +64 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginGuarded/chart.mmd +28 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginGuarded/graph.dot +37 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginGuarded/report.md +8 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginGuarded/sany.out +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginGuarded/verdict-1.out +47 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginGuarded/view.mjs +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/ChartRun.out +60 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/LoginParallel.cfg +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/LoginParallel.tla +64 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/chart.mmd +44 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/graph.dot +58 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/report.md +17 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/sany.out +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/verdict-1.out +83 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/verdict-2.out +57 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/LoginParallel/view.mjs +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/ChartRun.out +60 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/MediaPlayer.cfg +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/MediaPlayer.tla +103 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/chart.mmd +43 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/graph.dot +93 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/report.md +14 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/sany.out +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/verdict-1.out +59 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/verdict-2.out +72 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayer/view.mjs +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerFixed/ChartRun.out +57 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerFixed/MediaPlayerFixed.cfg +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerFixed/MediaPlayerFixed.tla +100 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerFixed/chart.mmd +31 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerFixed/graph.dot +85 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerFixed/report.md +9 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerFixed/sany.out +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerFixed/verdict-1.out +47 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerFixed/view.mjs +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/ChartRun.out +59 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/MediaPlayer.tla +103 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/MediaPlayerProps.cfg +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/MediaPlayerProps.tla +6 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/chart.mmd +42 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/graph.dot +93 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/report.md +19 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-1.out +61 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-2.out +59 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-3.out +61 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-4.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-4.out +66 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-5.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-5.out +58 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/verdict-6.out +49 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/MediaPlayerProps/view.mjs +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/PickWorker/ChartRun.out +57 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/PickWorker/PickWorker.cfg +6 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/PickWorker/PickWorker.tla +11 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/PickWorker/chart.mmd +5 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/PickWorker/graph.dot +11 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/PickWorker/report.md +7 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/PickWorker/sany.out +5 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/PickWorker/verdict-1.out +70 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Shadow/ChartRun.out +61 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Shadow/Shadow.cfg +4 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Shadow/Shadow.tla +11 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Shadow/ShadowLib.tla +6 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Shadow/ShadowSub.tla +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Shadow/chart.mmd +9 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Shadow/graph.dot +16 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Shadow/report.md +8 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Shadow/sany.out +4 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/Shadow/verdict-1.out +65 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/ChartRun.out +59 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/SpacedNames.cfg +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/SpacedNames.tla +9 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/chart.mmd +23 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/graph.dot +17 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/report.md +15 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/sany.out +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/verdict-1.out +65 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/verdict-2.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/SpacedNames/verdict-2.out +75 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/ChartRun.out +69 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/TwoPhase.cfg +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/TwoPhase.tla +75 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/chart.mmd +60 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/graph.dot +297 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/report.md +20 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/sany.out +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/verdict-1.out +95 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/verdict-2.out +57 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhase/view.mjs +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhaseFixed/ChartRun.out +57 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhaseFixed/TwoPhaseFixed.cfg +3 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhaseFixed/TwoPhaseFixed.tla +75 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhaseFixed/chart.mmd +37 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhaseFixed/graph.dot +223 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhaseFixed/report.md +11 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhaseFixed/sany.out +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhaseFixed/verdict-1.out +47 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TwoPhaseFixed/view.mjs +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/ChartRun.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/ChartRun.out +75 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/TypeGuard.cfg +5 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/TypeGuard.tla +11 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/chart.mmd +18 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/graph.dot +14 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/report.md +29 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/verdict-1.out +64 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/verdict-2.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/TypeGuard/verdict-2.out +75 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/ChartRun.out +58 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/UserNoDeadlock.cfg +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/UserNoDeadlock.tla +8 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/chart.mmd +22 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/graph.dot +16 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/report.md +15 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/verdict-1.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/verdict-1.out +56 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/verdict-2.exit +1 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus/UserNoDeadlock/verdict-2.out +77 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/corpus.test.ts +441 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/differential.test.ts +565 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/drawn.ts +20 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/grid/Grid.cfg +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/grid/Grid.tla +9 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/grid/sany.out +2 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/java.ts +63 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/labels.ts +648 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/messages.test.ts +226 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/pipeline.test.ts +270 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/plain-tlc.test.ts +255 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/render.test.ts +145 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/tlc-out.test.ts +90 -0
- package/plugins/deepmodebot/skills/statechart/scripts/test/tlc.ts +158 -0
- package/plugins/deepmodebot/skills/statechart/scripts/tsconfig.json +11 -0
- package/plugins/deepmodebot/skills/statechart/scripts/worker.ts +35 -0
- package/plugins/deepmodebot/agents/reviewer/agent.md +0 -33
- package/plugins/deepmodebot/agents/scout/agent.md +0 -34
- package/plugins/deepmodebot/agents/security-reviewer/agent.md +0 -30
- package/plugins/deepmodebot/skills/agent-harnesses/assets/sdks/bun.lock +0 -391
- package/plugins/deepmodebot/skills/deepmodebot/assets/agents-md/test_agents_md.py +0 -146
- package/plugins/deepmodebot/skills/deepmodebot/assets/contain/test_antigravity_guard.py +0 -483
- package/plugins/deepmodebot/skills/deepmodebot/assets/contain/test_audit_regressions.py +0 -139
- package/plugins/deepmodebot/skills/deepmodebot/assets/contain/test_contain.py +0 -301
- package/plugins/deepmodebot/skills/deepmodebot/assets/contain/test_omp_mcp.py +0 -602
- package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/test_design.py +0 -69
- package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/test_evidence.py +0 -160
- package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/test_record.py +0 -180
- package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/test_review.py +0 -265
- package/plugins/deepmodebot/skills/deepmodebot/assets/git-guardrails/test_git_guard.py +0 -192
- package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/test_bot.py +0 -2182
- package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/test_brand.py +0 -19
- package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/test_local_updates.py +0 -691
- package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/test_review_context.py +0 -127
- package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/test_workspace_cleanup.py +0 -496
- package/plugins/deepmodebot/skills/deepmodebot/assets/loop/test_loop.py +0 -1426
- package/plugins/deepmodebot/skills/deepmodebot/assets/loop/test_plan.py +0 -320
- package/plugins/deepmodebot/skills/deepmodebot/assets/loop/test_windows_job.py +0 -326
- package/plugins/deepmodebot/skills/deepmodebot/assets/perf-audit/test_bench_harness.py +0 -55
- package/plugins/deepmodebot/skills/deepmodebot/assets/perf-audit/test_perf_audit.py +0 -53
- package/plugins/deepmodebot/skills/deepmodebot/assets/pr-agent/test_diff_coverage.py +0 -94
- package/plugins/deepmodebot/skills/deepmodebot/assets/pr-conversation/test_arena.py +0 -610
- package/plugins/deepmodebot/skills/deepmodebot/assets/scrape/test_yt_enrich.py +0 -250
- package/plugins/deepmodebot/skills/deepmodebot/assets/tournament/test_tournament.py +0 -654
- package/plugins/deepmodebot/skills/deepmodebot/assets/workspace-map/test_workspace_map.py +0 -879
|
@@ -0,0 +1,2004 @@
|
|
|
1
|
+
use crate::util::{glob_match, json_escape, parallel_map};
|
|
2
|
+
use std::collections::BTreeSet;
|
|
3
|
+
use std::fs;
|
|
4
|
+
use std::path::{Path, PathBuf};
|
|
5
|
+
use std::io::Read;
|
|
6
|
+
use std::process::{Command, ExitCode, Stdio};
|
|
7
|
+
use std::thread;
|
|
8
|
+
use std::time::{Duration, Instant};
|
|
9
|
+
|
|
10
|
+
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
11
|
+
pub struct Finding {
|
|
12
|
+
pub severity: &'static str,
|
|
13
|
+
pub rule: &'static str,
|
|
14
|
+
pub file: String,
|
|
15
|
+
pub line: usize,
|
|
16
|
+
pub message: String,
|
|
17
|
+
pub fix: &'static str,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const BRANCH_BASES: &[&str] = &["origin/HEAD", "origin/main", "origin/master", "main", "master"];
|
|
21
|
+
const JS_EXTS: &[&str] = &["js", "mjs", "cjs", "jsx", "ts", "tsx"];
|
|
22
|
+
const DIFF_EXEMPT_DIRS: &[&str] = &[".deepmodebot", "scripts", "docs", "evals"];
|
|
23
|
+
|
|
24
|
+
fn extension(rel: &str) -> &str {
|
|
25
|
+
Path::new(rel).extension().and_then(|s| s.to_str()).unwrap_or("")
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const GUARDRAIL_CONFIGS: &[&str] = &[
|
|
29
|
+
".deepmodebot/ci.yml",
|
|
30
|
+
".deepmodebot/policy.xml",
|
|
31
|
+
".github/dependabot.yml",
|
|
32
|
+
"ruff.toml",
|
|
33
|
+
".ruff.toml",
|
|
34
|
+
"pyproject.toml",
|
|
35
|
+
"tsconfig.json",
|
|
36
|
+
"biome.json",
|
|
37
|
+
"eslint.config.js",
|
|
38
|
+
"eslint.config.mjs",
|
|
39
|
+
".eslintrc.json",
|
|
40
|
+
".prettierrc",
|
|
41
|
+
".pre-commit-config.yaml",
|
|
42
|
+
"lefthook.yml",
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
fn git(root: &Path, args: &[&str]) -> Option<(bool, String)> {
|
|
46
|
+
let out = Command::new("git")
|
|
47
|
+
.arg("-C")
|
|
48
|
+
.arg(root)
|
|
49
|
+
.args(args)
|
|
50
|
+
.output()
|
|
51
|
+
.ok()?;
|
|
52
|
+
Some((
|
|
53
|
+
out.status.success(),
|
|
54
|
+
String::from_utf8_lossy(&out.stdout).into_owned(),
|
|
55
|
+
))
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
fn merge_base(root: &Path, base: &str) -> Option<String> {
|
|
59
|
+
if base.starts_with('-') {
|
|
60
|
+
return None;
|
|
61
|
+
}
|
|
62
|
+
let (ok, id) = git(root, &["merge-base", "HEAD", base])?;
|
|
63
|
+
ok.then(|| id.trim().to_owned())
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
fn git_paths(root: &Path, args: &[&str]) -> impl Iterator<Item = String> {
|
|
67
|
+
git(root, args)
|
|
68
|
+
.filter(|(ok, _)| *ok)
|
|
69
|
+
.into_iter()
|
|
70
|
+
.flat_map(|(_, paths)| {
|
|
71
|
+
paths.split_terminator('\0').map(str::to_owned).collect::<Vec<_>>()
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
fn change_scope(
|
|
76
|
+
root: &Path,
|
|
77
|
+
staged: bool,
|
|
78
|
+
explicit: &[String],
|
|
79
|
+
base: Option<&str>,
|
|
80
|
+
) -> Result<(Vec<String>, Option<String>), String> {
|
|
81
|
+
let head = git(root, &["rev-parse", "--verify", "HEAD"])
|
|
82
|
+
.and_then(|(ok, id)| ok.then(|| id.trim().to_owned()));
|
|
83
|
+
if !explicit.is_empty() {
|
|
84
|
+
let mut set = BTreeSet::new();
|
|
85
|
+
for raw in explicit {
|
|
86
|
+
for part in raw.split(',') {
|
|
87
|
+
let mut n = part.trim().replace('\\', "/");
|
|
88
|
+
while let Some(rest) = n.strip_prefix("./") {
|
|
89
|
+
n = rest.to_string();
|
|
90
|
+
}
|
|
91
|
+
let n = n.trim_start_matches('/').to_string();
|
|
92
|
+
if !n.is_empty() {
|
|
93
|
+
set.insert(n);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return Ok((set.into_iter().collect(), head));
|
|
98
|
+
}
|
|
99
|
+
if staged {
|
|
100
|
+
let files = git_paths(root, &["diff", "--cached", "--name-only", "-z", "--diff-filter=ACMR"]).collect();
|
|
101
|
+
return Ok((files, head));
|
|
102
|
+
}
|
|
103
|
+
let mut paths: BTreeSet<_> = git_paths(root, &["ls-files", "--others", "--exclude-standard", "-z"]).collect();
|
|
104
|
+
let branch_base = if let Some(base) = base {
|
|
105
|
+
Some(merge_base(root, base).ok_or_else(|| format!("cannot resolve a merge base for {base:?}"))?)
|
|
106
|
+
} else if let Some(head) = head.as_deref().filter(|_| paths.is_empty()) {
|
|
107
|
+
if git_paths(root, &["diff", head, "--name-only", "-z"]).next().is_none() {
|
|
108
|
+
BRANCH_BASES.iter().filter_map(|base| merge_base(root, base)).find(|base| base != head)
|
|
109
|
+
} else {
|
|
110
|
+
None
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
None
|
|
114
|
+
};
|
|
115
|
+
if let Some(base) = branch_base.as_deref().filter(|b| Some(*b) != head.as_deref()) {
|
|
116
|
+
let range = format!("{base}..HEAD");
|
|
117
|
+
paths.extend(git_paths(root, &["diff", &range, "--name-only", "-z", "--diff-filter=ACMR"]));
|
|
118
|
+
}
|
|
119
|
+
let baseline = branch_base.or(head);
|
|
120
|
+
paths.extend(git_paths(root, &[
|
|
121
|
+
"diff", baseline.as_deref().unwrap_or("--cached"), "--name-only", "-z", "--diff-filter=ACMR",
|
|
122
|
+
]));
|
|
123
|
+
Ok((paths.into_iter().collect(), baseline))
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
fn added_lines_for_file(root: &Path, rel: &str, staged: bool, baseline: Option<&str>, text: &str) -> Vec<(usize, String)> {
|
|
127
|
+
let full = root.join(rel);
|
|
128
|
+
let Ok(meta) = fs::symlink_metadata(&full) else {
|
|
129
|
+
return Vec::new();
|
|
130
|
+
};
|
|
131
|
+
if meta.file_type().is_symlink() || !meta.is_file() || meta.len() > 1_048_576 {
|
|
132
|
+
return Vec::new();
|
|
133
|
+
}
|
|
134
|
+
if !staged && (baseline.is_none() || !matches!(git(root, &["ls-files", "--error-unmatch", "--", rel]), Some((true, _)))) {
|
|
135
|
+
return text.lines().enumerate().map(|(i, l)| (i + 1, l.to_owned())).collect();
|
|
136
|
+
}
|
|
137
|
+
let args: Vec<&str> = if staged {
|
|
138
|
+
vec!["diff", "--cached", "-U0", "--", rel]
|
|
139
|
+
} else {
|
|
140
|
+
vec!["diff", baseline.unwrap_or("HEAD"), "-U0", "--", rel]
|
|
141
|
+
};
|
|
142
|
+
let Some((true, diff)) = git(root, &args) else {
|
|
143
|
+
return Vec::new();
|
|
144
|
+
};
|
|
145
|
+
let mut out = Vec::new();
|
|
146
|
+
let mut cur_line: usize = 0;
|
|
147
|
+
for raw in diff.lines() {
|
|
148
|
+
if let Some(rest) = raw.strip_prefix("@@ ") {
|
|
149
|
+
if let Some(plus_idx) = rest.find('+') {
|
|
150
|
+
let after = &rest[plus_idx + 1..];
|
|
151
|
+
let num: String = after.chars().take_while(|c| c.is_ascii_digit()).collect();
|
|
152
|
+
if let Ok(n) = num.parse::<usize>() {
|
|
153
|
+
cur_line = n;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
} else if cur_line != 0 && raw.starts_with('+') {
|
|
157
|
+
out.push((cur_line, raw[1..].to_string()));
|
|
158
|
+
cur_line += 1;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
out
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
fn is_test_file(rel: &str) -> bool {
|
|
165
|
+
let low = rel.to_ascii_lowercase();
|
|
166
|
+
let (dirs, file) = low.rsplit_once('/').unwrap_or(("", &low));
|
|
167
|
+
dirs.split('/').any(|dir| matches!(dir, "test" | "tests" | "spec" | "__tests__"))
|
|
168
|
+
|| file.rsplit_once('.').is_some_and(|(stem, ext)| {
|
|
169
|
+
!ext.is_empty() && (stem.strip_prefix("test_").is_some_and(|s| !s.is_empty())
|
|
170
|
+
|| ["_test", ".test", ".spec"].iter().any(|suffix| stem.strip_suffix(suffix).is_some_and(|s| !s.is_empty())))
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
fn is_test_target(rel: &str, ext: &str) -> bool {
|
|
175
|
+
if !matches!(ext, "py" | "go" | "rs") && !JS_EXTS.contains(&ext) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
let low = rel.to_ascii_lowercase();
|
|
179
|
+
let mut parts = low.rsplit('/');
|
|
180
|
+
let stem = parts.next().and_then(|file| file.rsplit_once('.')).map_or("", |(stem, _)| stem);
|
|
181
|
+
if ext == "go" {
|
|
182
|
+
return stem.ends_with("_test");
|
|
183
|
+
}
|
|
184
|
+
if stem.starts_with("test_") || ["_test", ".test", ".spec"].iter().any(|suffix| stem.ends_with(suffix)) {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
if JS_EXTS.contains(&ext) {
|
|
188
|
+
return parts.any(|dir| dir == "__tests__");
|
|
189
|
+
}
|
|
190
|
+
ext == "rs" && (parts.next() == Some("tests") || stem == "main" && parts.next() == Some("tests"))
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
fn empty_test_finding(rel: &str) -> Finding {
|
|
194
|
+
Finding {
|
|
195
|
+
severity: "P1",
|
|
196
|
+
rule: "empty-test-file",
|
|
197
|
+
file: rel.to_owned(),
|
|
198
|
+
line: 1,
|
|
199
|
+
message: "Test file contains no test definitions.".into(),
|
|
200
|
+
fix: "Add a behavioral test or move helpers out of the test target.",
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
fn is_alnum_run(s: &str, min_len: usize) -> bool {
|
|
205
|
+
s.len() >= min_len
|
|
206
|
+
&& s.bytes()
|
|
207
|
+
.take(min_len)
|
|
208
|
+
.all(|b| b.is_ascii_alphanumeric() || b == b'_' || b == b'-')
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
fn has_secret(line: &str) -> Option<(&'static str, &'static str)> {
|
|
212
|
+
let trim = line.trim();
|
|
213
|
+
if trim.starts_with("re.compile(") || trim.contains("SECRET_PATTERNS") {
|
|
214
|
+
return None;
|
|
215
|
+
}
|
|
216
|
+
if line.contains("-----BEGIN ") && line.contains("PRIVATE KEY-----") {
|
|
217
|
+
let idx = line.find("-----BEGIN ").unwrap_or(0);
|
|
218
|
+
let before = line[..idx].trim_end();
|
|
219
|
+
if !before.ends_with('"') && !before.ends_with('\'') && !before.ends_with("r\"") {
|
|
220
|
+
return Some(("secret-private-key", "Private key PEM block detected."));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if let Some(pos) = line.find("AKIA") {
|
|
224
|
+
let tail = &line[pos + 4..];
|
|
225
|
+
if tail.len() >= 16
|
|
226
|
+
&& tail
|
|
227
|
+
.bytes()
|
|
228
|
+
.take(16)
|
|
229
|
+
.all(|b| b.is_ascii_uppercase() || b.is_ascii_digit())
|
|
230
|
+
{
|
|
231
|
+
return Some(("secret-aws-key", "Hardcoded AWS access key detected."));
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
for (prefix, min_len, rule, msg) in [
|
|
235
|
+
("ghp_", 30usize, "secret-github-token", "Hardcoded GitHub PAT detected."),
|
|
236
|
+
("github_pat_", 20, "secret-github-token", "Hardcoded GitHub PAT detected."),
|
|
237
|
+
("sk-ant-", 20, "secret-anthropic-key", "Hardcoded Anthropic API key detected."),
|
|
238
|
+
("sk-proj-", 20, "secret-openai-key", "Hardcoded OpenAI API key detected."),
|
|
239
|
+
("AIza", 35, "secret-google-key", "Hardcoded Google API key detected."),
|
|
240
|
+
("sk_live_", 16, "secret-stripe-key", "Hardcoded Stripe live key detected."),
|
|
241
|
+
] {
|
|
242
|
+
if let Some(pos) = line.find(prefix) {
|
|
243
|
+
let tail = &line[pos + prefix.len()..];
|
|
244
|
+
if is_alnum_run(tail, min_len) {
|
|
245
|
+
return Some((rule, msg));
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
None
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
fn contains_unquoted(line: &str, needle: &str) -> bool {
|
|
253
|
+
let mut start = 0;
|
|
254
|
+
while let Some(rel) = line[start..].find(needle) {
|
|
255
|
+
let idx = start + rel;
|
|
256
|
+
let prev = line[..idx].chars().next_back();
|
|
257
|
+
let next = line[idx + needle.len()..].chars().next();
|
|
258
|
+
let quoted = matches!(prev, Some('"' | '\'' | '`'))
|
|
259
|
+
&& matches!(next, Some('"' | '\'' | '`'));
|
|
260
|
+
if !quoted {
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
263
|
+
start = idx + needle.len();
|
|
264
|
+
}
|
|
265
|
+
false
|
|
266
|
+
}
|
|
267
|
+
fn is_js_ident_byte(b: u8) -> bool {
|
|
268
|
+
b.is_ascii_alphanumeric() || b == b'_' || b == b'$'
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
fn scrub_js_code_line(line: &str) -> String {
|
|
272
|
+
let bytes = line.as_bytes();
|
|
273
|
+
let mut out = String::with_capacity(line.len());
|
|
274
|
+
let mut quote: Option<u8> = None;
|
|
275
|
+
let mut i = 0;
|
|
276
|
+
while i < bytes.len() {
|
|
277
|
+
let b = bytes[i];
|
|
278
|
+
if let Some(q) = quote {
|
|
279
|
+
if b == b'\\' && i + 1 < bytes.len() {
|
|
280
|
+
out.push_str(" ");
|
|
281
|
+
i += 2;
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
if b == q {
|
|
285
|
+
out.push(b as char);
|
|
286
|
+
quote = None;
|
|
287
|
+
} else {
|
|
288
|
+
out.push(' ');
|
|
289
|
+
}
|
|
290
|
+
i += 1;
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
if b == b'/' && i + 1 < bytes.len() && bytes[i + 1] == b'/' {
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
if b == b'/' && i + 1 < bytes.len() && bytes[i + 1] == b'*' {
|
|
297
|
+
if let Some(rel_end) = line[i + 2..].find("*/") {
|
|
298
|
+
let span = rel_end + 4;
|
|
299
|
+
for _ in 0..span {
|
|
300
|
+
out.push(' ');
|
|
301
|
+
}
|
|
302
|
+
i += span;
|
|
303
|
+
continue;
|
|
304
|
+
} else {
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if matches!(b, b'\'' | b'"' | b'`') {
|
|
309
|
+
quote = Some(b);
|
|
310
|
+
out.push(b as char);
|
|
311
|
+
i += 1;
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
let ch = line[i..].chars().next().unwrap_or(' ');
|
|
315
|
+
out.push(ch);
|
|
316
|
+
i += ch.len_utf8();
|
|
317
|
+
}
|
|
318
|
+
out
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
fn has_exact_word(haystack: &str, word: &str) -> bool {
|
|
322
|
+
let bytes = haystack.as_bytes();
|
|
323
|
+
let mut from = 0;
|
|
324
|
+
while let Some(rel) = haystack[from..].find(word) {
|
|
325
|
+
let pos = from + rel;
|
|
326
|
+
let end = pos + word.len();
|
|
327
|
+
from = end;
|
|
328
|
+
let prev_ok = pos == 0 || !is_js_ident_byte(bytes[pos - 1]);
|
|
329
|
+
let next_ok = end >= bytes.len() || !is_js_ident_byte(bytes[end]);
|
|
330
|
+
if prev_ok && next_ok {
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
false
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
fn has_client_env_secret(line: &str) -> bool {
|
|
338
|
+
let bytes = line.as_bytes();
|
|
339
|
+
for prefix in ["NEXT_PUBLIC_", "VITE_", "EXPO_PUBLIC_", "NUXT_PUBLIC_"] {
|
|
340
|
+
let mut from = 0;
|
|
341
|
+
while let Some(rel) = line[from..].find(prefix) {
|
|
342
|
+
let pos = from + rel;
|
|
343
|
+
from = pos + prefix.len();
|
|
344
|
+
if pos > 0 && is_js_ident_byte(bytes[pos - 1]) {
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
let ident: String = line[pos..]
|
|
348
|
+
.chars()
|
|
349
|
+
.take_while(|c| c.is_ascii_alphanumeric() || *c == '_' || *c == '$')
|
|
350
|
+
.collect();
|
|
351
|
+
if ident
|
|
352
|
+
.bytes()
|
|
353
|
+
.all(|b| b.is_ascii_uppercase() || b.is_ascii_digit() || b == b'_')
|
|
354
|
+
&& ["SECRET", "PRIVATE_KEY", "SERVICE_ROLE", "DATABASE_URL", "WEBHOOK_SECRET"]
|
|
355
|
+
.iter()
|
|
356
|
+
.any(|suf| ident.contains(suf))
|
|
357
|
+
{
|
|
358
|
+
return true;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
false
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
fn has_llm_browser_key(js: &str) -> bool {
|
|
366
|
+
let needle = "dangerouslyAllowBrowser";
|
|
367
|
+
let bytes = js.as_bytes();
|
|
368
|
+
let mut from = 0;
|
|
369
|
+
while let Some(rel) = js[from..].find(needle) {
|
|
370
|
+
let pos = from + rel;
|
|
371
|
+
let end = pos + needle.len();
|
|
372
|
+
from = end;
|
|
373
|
+
if pos > 0 && is_js_ident_byte(bytes[pos - 1]) {
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
let rest = js[end..].trim_start();
|
|
377
|
+
let Some(after_colon) = rest.strip_prefix(':') else { continue };
|
|
378
|
+
let val = after_colon.trim_start();
|
|
379
|
+
if let Some(after_true) = val.strip_prefix("true") {
|
|
380
|
+
if !after_true.bytes().next().map(is_js_ident_byte).unwrap_or(false) {
|
|
381
|
+
return true;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
false
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
fn has_legacy_implements_do(js: &str) -> bool {
|
|
389
|
+
let bytes = js.as_bytes();
|
|
390
|
+
let mut from = 0;
|
|
391
|
+
while let Some(rel) = js[from..].find("class") {
|
|
392
|
+
let pos = from + rel;
|
|
393
|
+
let end = pos + "class".len();
|
|
394
|
+
from = end;
|
|
395
|
+
if pos > 0 && is_js_ident_byte(bytes[pos - 1]) {
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
if !matches!(bytes.get(end), Some(b' ' | b'\t')) {
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
let header_end = js[end..].find('{').map(|i| end + i).unwrap_or(js.len());
|
|
402
|
+
let header = &js[end..header_end];
|
|
403
|
+
let hbytes = header.as_bytes();
|
|
404
|
+
let mut hfrom = 0;
|
|
405
|
+
while let Some(irel) = header[hfrom..].find("implements") {
|
|
406
|
+
let ipos = hfrom + irel;
|
|
407
|
+
let iend = ipos + "implements".len();
|
|
408
|
+
hfrom = iend;
|
|
409
|
+
let prev_ok = ipos == 0 || !is_js_ident_byte(hbytes[ipos - 1]);
|
|
410
|
+
let next_ok = matches!(hbytes.get(iend), Some(b' ' | b'\t'));
|
|
411
|
+
if prev_ok && next_ok && has_exact_word(&header[iend..], "DurableObject") {
|
|
412
|
+
return true;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
false
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
fn has_workers_ctx_destructure(js: &str) -> bool {
|
|
420
|
+
let bytes = js.as_bytes();
|
|
421
|
+
for kw in ["const", "let", "var"] {
|
|
422
|
+
let mut from = 0;
|
|
423
|
+
while let Some(rel) = js[from..].find(kw) {
|
|
424
|
+
let pos = from + rel;
|
|
425
|
+
let end = pos + kw.len();
|
|
426
|
+
from = end;
|
|
427
|
+
if pos > 0 && is_js_ident_byte(bytes[pos - 1]) {
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
if end < bytes.len() && is_js_ident_byte(bytes[end]) {
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
let rest = js[end..].trim_start();
|
|
434
|
+
let Some(after_open) = rest.strip_prefix('{') else { continue };
|
|
435
|
+
let Some(close_idx) = after_open.find('}') else { continue };
|
|
436
|
+
let inner = &after_open[..close_idx];
|
|
437
|
+
if !has_exact_word(inner, "waitUntil") {
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
let after_brace = after_open[close_idx + 1..].trim_start();
|
|
441
|
+
let Some(after_eq) = after_brace.strip_prefix('=') else { continue };
|
|
442
|
+
if after_eq.starts_with('=') {
|
|
443
|
+
continue;
|
|
444
|
+
}
|
|
445
|
+
let rhs = after_eq.trim_start();
|
|
446
|
+
if let Some(after_ctx) = rhs.strip_prefix("ctx") {
|
|
447
|
+
if !after_ctx.bytes().next().map(is_js_ident_byte).unwrap_or(false) {
|
|
448
|
+
return true;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
false
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
pub fn scan_added_lines(rel: &str, lines: &[(usize, String)], out: &mut Vec<Finding>) {
|
|
457
|
+
scan_added_lines_ctx(rel, lines, None, out);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
fn scan_added_lines_ctx(
|
|
461
|
+
rel: &str,
|
|
462
|
+
lines: &[(usize, String)],
|
|
463
|
+
rs_cfg_ln: Option<usize>,
|
|
464
|
+
out: &mut Vec<Finding>,
|
|
465
|
+
) {
|
|
466
|
+
let ext = Path::new(rel)
|
|
467
|
+
.extension()
|
|
468
|
+
.and_then(|e| e.to_str())
|
|
469
|
+
.map(|s| s.to_ascii_lowercase())
|
|
470
|
+
.unwrap_or_default();
|
|
471
|
+
let test_file = is_test_file(rel);
|
|
472
|
+
|
|
473
|
+
for (ln, line) in lines {
|
|
474
|
+
let in_test_ctx = test_file || rs_cfg_ln.is_some_and(|cfg| *ln >= cfg);
|
|
475
|
+
if let Some((rule, msg)) = has_secret(line) {
|
|
476
|
+
out.push(Finding {
|
|
477
|
+
severity: "P0",
|
|
478
|
+
rule,
|
|
479
|
+
file: rel.to_string(),
|
|
480
|
+
line: *ln,
|
|
481
|
+
message: msg.to_string(),
|
|
482
|
+
fix: "Remove key material and rotate; load from env or secret manager.",
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
if (ext == "yml" || ext == "yaml")
|
|
486
|
+
&& rel.starts_with(".github/workflows/")
|
|
487
|
+
&& line.contains("uses:")
|
|
488
|
+
&& (line.contains("@main") || line.contains("@master"))
|
|
489
|
+
{
|
|
490
|
+
out.push(Finding {
|
|
491
|
+
severity: "P1",
|
|
492
|
+
rule: "supply-chain-unpinned-action",
|
|
493
|
+
file: rel.to_string(),
|
|
494
|
+
line: *ln,
|
|
495
|
+
message: "GitHub Action pinned to mutable @main/@master branch.".to_string(),
|
|
496
|
+
fix: "Pin to full 40-char commit SHA with version comment.",
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
if !test_file && ext == "py"
|
|
500
|
+
&& (contains_unquoted(line, "# noqa")
|
|
501
|
+
|| contains_unquoted(line, "# type: ignore")
|
|
502
|
+
|| contains_unquoted(line, "# pyright: ignore"))
|
|
503
|
+
{
|
|
504
|
+
out.push(Finding {
|
|
505
|
+
severity: "P1",
|
|
506
|
+
rule: "suppression-comment",
|
|
507
|
+
file: rel.to_string(),
|
|
508
|
+
line: *ln,
|
|
509
|
+
message: "Inline Python lint/type suppression added.".to_string(),
|
|
510
|
+
fix: "Fix root cause instead of suppressing.",
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
if !test_file && matches!(ext.as_str(), "ts" | "tsx" | "js" | "jsx" | "mjs")
|
|
514
|
+
&& (contains_unquoted(line, "@ts-ignore")
|
|
515
|
+
|| contains_unquoted(line, "@ts-expect-error")
|
|
516
|
+
|| contains_unquoted(line, "eslint-disable"))
|
|
517
|
+
{
|
|
518
|
+
out.push(Finding {
|
|
519
|
+
severity: "P1",
|
|
520
|
+
rule: "suppression-comment",
|
|
521
|
+
file: rel.to_string(),
|
|
522
|
+
line: *ln,
|
|
523
|
+
message: "Inline JS/TS lint/type suppression added.".to_string(),
|
|
524
|
+
fix: "Fix root cause instead of suppressing.",
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
if !in_test_ctx && matches!(ext.as_str(), "ts" | "tsx")
|
|
528
|
+
&& (contains_unquoted(line, " as any")
|
|
529
|
+
|| contains_unquoted(line, " as unknown as "))
|
|
530
|
+
{
|
|
531
|
+
out.push(Finding {
|
|
532
|
+
severity: "P1",
|
|
533
|
+
rule: "ts-unsafe-cast",
|
|
534
|
+
file: rel.to_string(),
|
|
535
|
+
line: *ln,
|
|
536
|
+
message: "Unsafe TypeScript cast added.".to_string(),
|
|
537
|
+
fix: "Use a type guard or validated schema.",
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
if !in_test_ctx && ext == "rs" && contains_unquoted(line, ".unwrap()") {
|
|
541
|
+
out.push(Finding {
|
|
542
|
+
severity: "P1",
|
|
543
|
+
rule: "rust-prod-unwrap",
|
|
544
|
+
file: rel.to_string(),
|
|
545
|
+
line: *ln,
|
|
546
|
+
message: "Unwrap call in non-test Rust code.".to_string(),
|
|
547
|
+
fix: "Propagate with `?` or handle explicitly.",
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
if !test_file && ext == "go" && contains_unquoted(line, "_ = err") {
|
|
551
|
+
out.push(Finding {
|
|
552
|
+
severity: "P1",
|
|
553
|
+
rule: "go-ignored-err",
|
|
554
|
+
file: rel.to_string(),
|
|
555
|
+
line: *ln,
|
|
556
|
+
message: "Swallowed Go error (`_ = err`).".to_string(),
|
|
557
|
+
fix: "Check and return or handle `err`.",
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
if !in_test_ctx && has_client_env_secret(line) {
|
|
561
|
+
out.push(Finding {
|
|
562
|
+
severity: "P0",
|
|
563
|
+
rule: "client-env-secret",
|
|
564
|
+
file: rel.to_string(),
|
|
565
|
+
line: *ln,
|
|
566
|
+
message: "Client-exposed env prefix names a secret/private/DB credential.".to_string(),
|
|
567
|
+
fix: "Keep secrets in server-only env vars behind a server route or Action.",
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
let js_code = if !in_test_ctx && matches!(ext.as_str(), "js" | "mjs" | "cjs" | "ts" | "tsx" | "jsx" | "svelte" | "vue") {
|
|
571
|
+
scrub_js_code_line(line)
|
|
572
|
+
} else {
|
|
573
|
+
String::new()
|
|
574
|
+
};
|
|
575
|
+
if !in_test_ctx && !js_code.is_empty() && has_llm_browser_key(&js_code) {
|
|
576
|
+
out.push(Finding {
|
|
577
|
+
severity: "P0",
|
|
578
|
+
rule: "llm-browser-key-exposure",
|
|
579
|
+
file: rel.to_string(),
|
|
580
|
+
line: *ln,
|
|
581
|
+
message: "`dangerouslyAllowBrowser: true` exposes provider API keys in client bundles.".to_string(),
|
|
582
|
+
fix: "Proxy LLM SDK calls through a server route or Durable Object.",
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
if !in_test_ctx && matches!(ext.as_str(), "js" | "mjs" | "ts" | "tsx") && has_legacy_implements_do(&js_code) {
|
|
586
|
+
out.push(Finding {
|
|
587
|
+
severity: "P1",
|
|
588
|
+
rule: "workers-legacy-implements-do",
|
|
589
|
+
file: rel.to_string(),
|
|
590
|
+
line: *ln,
|
|
591
|
+
message: "Legacy `implements DurableObject` omits `this.ctx` and `this.env`.".to_string(),
|
|
592
|
+
fix: "Import `DurableObject` from `cloudflare:workers` and use `extends DurableObject<Env>`.",
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
if !in_test_ctx && matches!(ext.as_str(), "js" | "mjs" | "ts" | "tsx") && has_workers_ctx_destructure(&js_code) {
|
|
596
|
+
out.push(Finding {
|
|
597
|
+
severity: "P1",
|
|
598
|
+
rule: "workers-ctx-destructure",
|
|
599
|
+
file: rel.to_string(),
|
|
600
|
+
line: *ln,
|
|
601
|
+
message: "Destructuring `waitUntil` from `ctx` throws `Illegal invocation` at runtime.".to_string(),
|
|
602
|
+
fix: "Call `ctx.waitUntil(...)` directly on `ctx`.",
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
if !in_test_ctx && matches!(ext.as_str(), "js" | "mjs" | "cjs" | "ts" | "tsx" | "jsx")
|
|
606
|
+
&& (contains_unquoted(line, ".innerHTML =")
|
|
607
|
+
|| contains_unquoted(line, "dangerouslySetInnerHTML")
|
|
608
|
+
|| contains_unquoted(line, "eval("))
|
|
609
|
+
{
|
|
610
|
+
out.push(Finding {
|
|
611
|
+
severity: "P1",
|
|
612
|
+
rule: "security-unsafe-sink",
|
|
613
|
+
file: rel.to_string(),
|
|
614
|
+
line: *ln,
|
|
615
|
+
message: "Unsafe dynamic sink (`eval`/`innerHTML`/`dangerouslySetInnerHTML`)."
|
|
616
|
+
.to_string(),
|
|
617
|
+
fix: "Use textContent or sanitized DOM nodes.",
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
if ext == "yml" || ext == "yaml" {
|
|
622
|
+
let norm = rel.replace('\\', "/");
|
|
623
|
+
if norm == ".github/dependabot.yml" || norm == ".github/dependabot.yaml" {
|
|
624
|
+
for (ln, line) in lines {
|
|
625
|
+
let eco_line = line
|
|
626
|
+
.trim_start()
|
|
627
|
+
.trim_start_matches('-')
|
|
628
|
+
.trim_start()
|
|
629
|
+
.starts_with("package-ecosystem:");
|
|
630
|
+
if eco_line {
|
|
631
|
+
let full = lines
|
|
632
|
+
.iter()
|
|
633
|
+
.map(|(_, s)| s.as_str())
|
|
634
|
+
.collect::<Vec<_>>()
|
|
635
|
+
.join("\n");
|
|
636
|
+
if !full.contains("cooldown:") {
|
|
637
|
+
out.push(Finding {
|
|
638
|
+
severity: "P2",
|
|
639
|
+
rule: "supply-chain-dependabot-cooldown",
|
|
640
|
+
file: rel.to_string(),
|
|
641
|
+
line: *ln,
|
|
642
|
+
message: "Dependabot config adds ecosystem without `cooldown` window.".to_string(),
|
|
643
|
+
fix: "Add `cooldown: { default-days: 7 }` to mitigate freshly published package compromises.",
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
break;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
#[derive(Clone, Copy)]
|
|
654
|
+
struct Token<'a> {
|
|
655
|
+
value: &'a str,
|
|
656
|
+
line: usize,
|
|
657
|
+
pair: Option<usize>,
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
fn source_tokens<'a>(text: &'a str, ext: &str) -> Vec<Token<'a>> {
|
|
661
|
+
let rust = ext == "rs";
|
|
662
|
+
let python = ext == "py";
|
|
663
|
+
let bytes = text.as_bytes();
|
|
664
|
+
let mut tokens: Vec<Token<'_>> = Vec::new();
|
|
665
|
+
let mut stack = Vec::new();
|
|
666
|
+
let (mut i, mut line) = (0, 1);
|
|
667
|
+
while i < bytes.len() {
|
|
668
|
+
let start = i;
|
|
669
|
+
let c = bytes[i];
|
|
670
|
+
i += 1;
|
|
671
|
+
let mut literal = false;
|
|
672
|
+
if c.is_ascii_whitespace() {
|
|
673
|
+
line += usize::from(c == b'\n');
|
|
674
|
+
continue;
|
|
675
|
+
}
|
|
676
|
+
if if python { c == b'#' } else { bytes[start..].starts_with(b"//") } {
|
|
677
|
+
while i < bytes.len() && bytes[i] != b'\n' {
|
|
678
|
+
i += 1;
|
|
679
|
+
}
|
|
680
|
+
continue;
|
|
681
|
+
}
|
|
682
|
+
if !python && bytes[start..].starts_with(b"/*") {
|
|
683
|
+
i += 1;
|
|
684
|
+
let mut depth = 1;
|
|
685
|
+
while i < bytes.len() && depth != 0 {
|
|
686
|
+
if bytes[i..].starts_with(b"*/") {
|
|
687
|
+
depth -= 1;
|
|
688
|
+
i += 2;
|
|
689
|
+
} else if rust && bytes[i..].starts_with(b"/*") {
|
|
690
|
+
depth += 1;
|
|
691
|
+
i += 2;
|
|
692
|
+
} else {
|
|
693
|
+
line += usize::from(bytes[i] == b'\n');
|
|
694
|
+
i += 1;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
continue;
|
|
698
|
+
}
|
|
699
|
+
let quote = if rust && c == b'r' {
|
|
700
|
+
i + bytes[i..].iter().take_while(|b| **b == b'#').count()
|
|
701
|
+
} else {
|
|
702
|
+
start
|
|
703
|
+
};
|
|
704
|
+
if quote != start && bytes.get(quote) == Some(&b'"') {
|
|
705
|
+
literal = true;
|
|
706
|
+
let hashes = &bytes[start + 1..quote];
|
|
707
|
+
i = quote + 1;
|
|
708
|
+
while i < bytes.len() {
|
|
709
|
+
i += 1;
|
|
710
|
+
if bytes[i - 1] == b'"' && bytes[i..].starts_with(hashes) {
|
|
711
|
+
i += hashes.len();
|
|
712
|
+
break;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
} else if python && matches!(c, b'\'' | b'"') && bytes.get(i..i + 2) == Some(&[c, c]) {
|
|
716
|
+
literal = true;
|
|
717
|
+
i += 2;
|
|
718
|
+
while i < bytes.len() {
|
|
719
|
+
if bytes.get(i..i + 3) == Some(&[c, c, c]) {
|
|
720
|
+
i += 3;
|
|
721
|
+
break;
|
|
722
|
+
}
|
|
723
|
+
i += if bytes[i] == b'\\' && i + 1 < bytes.len() { 2 } else { 1 };
|
|
724
|
+
}
|
|
725
|
+
} else if c == b'"' || c == b'`' || c == b'\'' && !rust {
|
|
726
|
+
literal = true;
|
|
727
|
+
while i < bytes.len() {
|
|
728
|
+
let b = bytes[i];
|
|
729
|
+
i += 1;
|
|
730
|
+
if b == c {
|
|
731
|
+
break;
|
|
732
|
+
}
|
|
733
|
+
if b == b'\\' && !(c == b'`' && ext == "go") && i < bytes.len() {
|
|
734
|
+
i += 1;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
} else if rust && c == b'\'' {
|
|
738
|
+
let char_end = if bytes.get(i) == Some(&b'\\') {
|
|
739
|
+
bytes[i + 1..].iter().take(12).position(|b| *b == b'\'').map(|n| i + n + 1)
|
|
740
|
+
} else {
|
|
741
|
+
text[i..].chars().next().map(|ch| i + ch.len_utf8())
|
|
742
|
+
};
|
|
743
|
+
if let Some(end) = char_end.filter(|end| bytes.get(*end) == Some(&b'\'')) {
|
|
744
|
+
literal = true;
|
|
745
|
+
i = end + 1;
|
|
746
|
+
}
|
|
747
|
+
} else if is_js_ident_byte(c) || !c.is_ascii() {
|
|
748
|
+
while i < bytes.len() && (is_js_ident_byte(bytes[i]) || !bytes[i].is_ascii()) {
|
|
749
|
+
i += 1;
|
|
750
|
+
}
|
|
751
|
+
} else if matches!(bytes.get(start..start + 2), Some(b"=>" | b"->" | b"::")) {
|
|
752
|
+
i += 1;
|
|
753
|
+
}
|
|
754
|
+
let value = if literal { "<literal>" } else { &text[start..i] };
|
|
755
|
+
let index = tokens.len();
|
|
756
|
+
let mut pair = None;
|
|
757
|
+
match value {
|
|
758
|
+
"{" | "(" | "[" => stack.push(index),
|
|
759
|
+
"}" | ")" | "]" => {
|
|
760
|
+
if let Some(&open) = stack.last() {
|
|
761
|
+
if matches!((tokens[open].value, value), ("{", "}") | ("(", ")") | ("[", "]")) {
|
|
762
|
+
stack.pop();
|
|
763
|
+
tokens[open].pair = Some(index);
|
|
764
|
+
pair = Some(open);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
_ => {}
|
|
769
|
+
}
|
|
770
|
+
tokens.push(Token { value, line, pair });
|
|
771
|
+
if literal {
|
|
772
|
+
line += bytes[start..i].iter().filter(|b| **b == b'\n').count();
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
tokens
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
fn token_sequence(tokens: &[Token<'_>], at: usize, pattern: &[&str]) -> bool {
|
|
779
|
+
tokens.get(at..at + pattern.len()).is_some_and(|items| {
|
|
780
|
+
items.iter().zip(pattern).all(|(token, expected)| token.value == *expected)
|
|
781
|
+
})
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
fn next_top_level(tokens: &[Token<'_>], mut at: usize, end: usize, stops: &[&str]) -> usize {
|
|
785
|
+
while at < end && !stops.contains(&tokens[at].value) {
|
|
786
|
+
at = tokens[at].pair.filter(|pair| *pair > at).unwrap_or(at) + 1;
|
|
787
|
+
}
|
|
788
|
+
at.min(end)
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
fn rust_after_attributes(tokens: &[Token<'_>], mut at: usize) -> usize {
|
|
792
|
+
while token_sequence(tokens, at, &["#", "["]) {
|
|
793
|
+
let Some(end) = tokens[at + 1].pair else { break };
|
|
794
|
+
at = end + 1;
|
|
795
|
+
}
|
|
796
|
+
at
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
fn rust_test_ranges<'a>(tokens: &'a [Token<'a>]) -> impl Iterator<Item = (usize, usize)> + 'a {
|
|
800
|
+
tokens.iter().enumerate().filter_map(|(i, token)| {
|
|
801
|
+
if token.value != "#" || !token_sequence(tokens, i, &["#", "[", "cfg", "(", "test", ")", "]"]) {
|
|
802
|
+
return None;
|
|
803
|
+
}
|
|
804
|
+
let start = rust_after_attributes(tokens, i + 7);
|
|
805
|
+
let end = next_top_level(tokens, start, tokens.len(), &["{", ";"]);
|
|
806
|
+
let end = tokens.get(end)?.pair.unwrap_or(end);
|
|
807
|
+
Some((token.line, tokens[end].line))
|
|
808
|
+
})
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
fn test_body(tokens: &[Token<'_>], i: usize, ext: &str) -> Option<(usize, usize, bool)> {
|
|
812
|
+
let value = tokens[i].value;
|
|
813
|
+
let next = tokens.get(i + 1)?;
|
|
814
|
+
if JS_EXTS.contains(&ext) {
|
|
815
|
+
if !matches!(value, "it" | "test") || next.value != "(" {
|
|
816
|
+
return None;
|
|
817
|
+
}
|
|
818
|
+
let end = next.pair?;
|
|
819
|
+
let marker = next_top_level(tokens, i + 2, end, &["=>", "function"]);
|
|
820
|
+
if marker == end {
|
|
821
|
+
return None;
|
|
822
|
+
}
|
|
823
|
+
let body = if tokens[marker].value == "function" {
|
|
824
|
+
next_top_level(tokens, marker + 1, end, &["{"])
|
|
825
|
+
} else {
|
|
826
|
+
marker + 1
|
|
827
|
+
};
|
|
828
|
+
if body >= end {
|
|
829
|
+
return None;
|
|
830
|
+
}
|
|
831
|
+
return if tokens[body].value == "{" {
|
|
832
|
+
Some((body + 1, tokens[body].pair?, false))
|
|
833
|
+
} else {
|
|
834
|
+
Some((body, next_top_level(tokens, body, end, &[","]), false))
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
if ext == "go" {
|
|
838
|
+
if value != "func" || !next.value.starts_with("Test") || !token_sequence(tokens, i + 2, &["("]) {
|
|
839
|
+
return None;
|
|
840
|
+
}
|
|
841
|
+
let body = tokens.get(i + 2)?.pair? + 1;
|
|
842
|
+
return token_sequence(tokens, body, &["{"]).then(|| (body + 1, tokens[body].pair, false))
|
|
843
|
+
.and_then(|(start, end, oracle)| Some((start, end?, oracle)));
|
|
844
|
+
}
|
|
845
|
+
if value != "#" || next.value != "[" {
|
|
846
|
+
return None;
|
|
847
|
+
}
|
|
848
|
+
let attr_end = next.pair?;
|
|
849
|
+
if !token_sequence(tokens, i + 2, &["test", "]"])
|
|
850
|
+
&& !token_sequence(tokens, i + 2, &["tokio", "::", "test", "]"])
|
|
851
|
+
&& !token_sequence(tokens, i + 2, &["tokio", "::", "test", "("])
|
|
852
|
+
{
|
|
853
|
+
return None;
|
|
854
|
+
}
|
|
855
|
+
let start = rust_after_attributes(tokens, attr_end + 1);
|
|
856
|
+
let fun = next_top_level(tokens, start, tokens.len(), &["fn", "{", ";", "}"]);
|
|
857
|
+
if !token_sequence(tokens, fun, &["fn"]) {
|
|
858
|
+
return None;
|
|
859
|
+
}
|
|
860
|
+
let body = next_top_level(tokens, fun + 1, tokens.len(), &["{", ";", "}"]);
|
|
861
|
+
if !token_sequence(tokens, body, &["{"]) {
|
|
862
|
+
return None;
|
|
863
|
+
}
|
|
864
|
+
let mut prior = i;
|
|
865
|
+
while prior >= 2 && tokens[prior - 1].value == "]" {
|
|
866
|
+
let Some(open) = tokens[prior - 1].pair else { break };
|
|
867
|
+
if open == 0 || tokens[open - 1].value != "#" {
|
|
868
|
+
break;
|
|
869
|
+
}
|
|
870
|
+
prior = open - 1;
|
|
871
|
+
}
|
|
872
|
+
let oracle = (prior..fun).any(|j| token_sequence(tokens, j, &["#", "[", "should_panic"]))
|
|
873
|
+
|| (fun + 1..body).any(|j| token_sequence(tokens, j, &["->", "Result", "<"]));
|
|
874
|
+
Some((body + 1, tokens[body].pair?, oracle))
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
fn brace_declares_tests(tokens: &[Token<'_>], ext: &str) -> bool {
|
|
878
|
+
if !JS_EXTS.contains(&ext) {
|
|
879
|
+
return (0..tokens.len()).any(|i| test_body(tokens, i, ext).is_some());
|
|
880
|
+
}
|
|
881
|
+
for (i, token) in tokens.iter().enumerate() {
|
|
882
|
+
if !matches!(token.value, "test" | "it") || i > 0 && tokens[i - 1].value == "function" {
|
|
883
|
+
continue;
|
|
884
|
+
}
|
|
885
|
+
let mut start = i + 1;
|
|
886
|
+
while token_sequence(tokens, start, &["."]) && tokens.get(start + 1)
|
|
887
|
+
.is_some_and(|t| matches!(t.value, "only" | "skip" | "todo" | "concurrent" | "each"))
|
|
888
|
+
{
|
|
889
|
+
start += 2;
|
|
890
|
+
}
|
|
891
|
+
if token_sequence(tokens, start, &["("]) && tokens[start].pair.is_some_and(|end|
|
|
892
|
+
end > start + 1 && !token_sequence(tokens, end + 1, &["{"]))
|
|
893
|
+
{
|
|
894
|
+
return true;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
false
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
fn python_declares_tests(text: &str) -> bool {
|
|
901
|
+
let tokens = source_tokens(text, "py");
|
|
902
|
+
let mut lines = text.lines();
|
|
903
|
+
let (mut line, mut indent, mut i) = (0, 0, 0);
|
|
904
|
+
let mut classes = Vec::new();
|
|
905
|
+
while let Some(token) = tokens.get(i) {
|
|
906
|
+
if token.line > line {
|
|
907
|
+
let source = lines.nth(token.line - line - 1).unwrap_or("");
|
|
908
|
+
line = token.line;
|
|
909
|
+
indent = source.len() - source.trim_start().len();
|
|
910
|
+
while classes.last().is_some_and(|&(depth, _)| depth >= indent) {
|
|
911
|
+
classes.pop();
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
if let Some(name) = tokens.get(i + 1).map(|t| t.value) {
|
|
915
|
+
let mut next = i + 2;
|
|
916
|
+
if token_sequence(&tokens, next, &["["]) {
|
|
917
|
+
next = tokens[next].pair.map_or(next, |end| end + 1);
|
|
918
|
+
}
|
|
919
|
+
if token.value == "def" && token_sequence(&tokens, next, &["("])
|
|
920
|
+
&& (name.starts_with("test_") || name.starts_with("test") && classes.last().is_some_and(|&(_, case)| case))
|
|
921
|
+
{
|
|
922
|
+
return true;
|
|
923
|
+
}
|
|
924
|
+
if token.value == "class" {
|
|
925
|
+
if name.starts_with("Test") && tokens.get(next).is_some_and(|t| matches!(t.value, "(" | ":")) {
|
|
926
|
+
return true;
|
|
927
|
+
}
|
|
928
|
+
let mut case = false;
|
|
929
|
+
if token_sequence(&tokens, next, &["("]) {
|
|
930
|
+
if let Some(end) = tokens[next].pair {
|
|
931
|
+
let mut base = next + 1;
|
|
932
|
+
while base < end {
|
|
933
|
+
let boundary = next_top_level(&tokens, base, end, &[","]);
|
|
934
|
+
case |= boundary > base && tokens[boundary - 1].value == "TestCase"
|
|
935
|
+
&& (boundary == base + 1 || tokens[boundary - 2].value == ".");
|
|
936
|
+
base = boundary + 1;
|
|
937
|
+
}
|
|
938
|
+
next = end + 1;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
if token_sequence(&tokens, next, &[":"]) {
|
|
942
|
+
let header_end = tokens[next].line;
|
|
943
|
+
if header_end > line {
|
|
944
|
+
lines.nth(header_end - line - 1);
|
|
945
|
+
line = header_end;
|
|
946
|
+
}
|
|
947
|
+
classes.push((indent, case));
|
|
948
|
+
i = next;
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
i += 1;
|
|
953
|
+
}
|
|
954
|
+
false
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
fn staged_test_target_is_empty(root: &Path, rel: &str, ext: &str) -> bool {
|
|
958
|
+
let Some((true, text)) = git(root, &["show", &format!(":{rel}")]) else { return false };
|
|
959
|
+
text.len() <= 1_048_576 && if ext == "py" {
|
|
960
|
+
!python_declares_tests(&text)
|
|
961
|
+
} else {
|
|
962
|
+
!brace_declares_tests(&source_tokens(&text, ext), ext)
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
fn test_theater(rel: &str, line: usize, rule: &'static str, message: &str) -> Finding {
|
|
967
|
+
Finding {
|
|
968
|
+
severity: "P1",
|
|
969
|
+
rule,
|
|
970
|
+
file: rel.to_owned(),
|
|
971
|
+
line,
|
|
972
|
+
message: message.to_owned(),
|
|
973
|
+
fix: "Assert an observable behavior that fails when the implementation regresses.",
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
fn scan_brace_tests(rel: &str, ext: &str, tokens: &[Token<'_>], added: &BTreeSet<usize>, out: &mut Vec<Finding>) {
|
|
978
|
+
let js = JS_EXTS.contains(&ext);
|
|
979
|
+
for (i, token) in tokens.iter().enumerate() {
|
|
980
|
+
let Some((start, end, mut oracle)) = test_body(tokens, i, ext) else { continue };
|
|
981
|
+
if added.range(token.line..=tokens[end].line).next().is_none() {
|
|
982
|
+
continue;
|
|
983
|
+
}
|
|
984
|
+
if start == end {
|
|
985
|
+
out.push(test_theater(rel, token.line, "test-theater-empty", "Empty test proves nothing."));
|
|
986
|
+
continue;
|
|
987
|
+
}
|
|
988
|
+
for j in start..end {
|
|
989
|
+
let name = tokens[j].value;
|
|
990
|
+
let next = tokens.get(j + 1).map(|t| t.value);
|
|
991
|
+
let tautology = if js {
|
|
992
|
+
oracle |= (matches!(name, "expect" | "assert" | "rejects" | "throws" | "verify")
|
|
993
|
+
&& matches!(next, Some("(" | ".")))
|
|
994
|
+
|| (matches!(name, "rejects" | "throws") && tokens[j - 1].value == ".");
|
|
995
|
+
name == "expect" && tokens.get(j + 2).is_some_and(|t| {
|
|
996
|
+
let literal = t.value;
|
|
997
|
+
matches!(literal, "true" | "false" | "1")
|
|
998
|
+
&& token_sequence(tokens, j + 1, &["(", literal, ")", ".", "toBe", "(", literal, ")"])
|
|
999
|
+
})
|
|
1000
|
+
} else if ext == "rs" {
|
|
1001
|
+
oracle |= (name.starts_with("assert") || name.starts_with("debug_assert") || name == "panic") && next == Some("!");
|
|
1002
|
+
(name == "assert" && token_sequence(tokens, j + 1, &["!", "(", "true", ")"]))
|
|
1003
|
+
|| (name == "assert_eq" && token_sequence(tokens, j + 1, &["!", "(", "1", ",", "1", ")"]))
|
|
1004
|
+
} else {
|
|
1005
|
+
oracle |= next == Some(".") && (matches!(name, "assert" | "require") || name == "t"
|
|
1006
|
+
&& tokens.get(j + 2).is_some_and(|t| matches!(t.value, "Fatal" | "Fatalf" | "Error" | "Errorf" | "Fail" | "FailNow")));
|
|
1007
|
+
false
|
|
1008
|
+
};
|
|
1009
|
+
if tautology && added.contains(&tokens[j].line) {
|
|
1010
|
+
out.push(test_theater(rel, tokens[j].line, "test-theater-tautology", "Test assertion always passes."));
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
if !oracle {
|
|
1014
|
+
out.push(test_theater(rel, token.line, "test-theater-no-assert", "Test has zero behavioral assertions."));
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
fn python_tautology(line: &str) -> bool {
|
|
1020
|
+
if let Some(assertion) = line.strip_prefix("assert ") {
|
|
1021
|
+
let assertion = assertion.trim();
|
|
1022
|
+
if assertion == "True" || assertion.starts_with("True,") {
|
|
1023
|
+
return true;
|
|
1024
|
+
}
|
|
1025
|
+
if let Some((left, right)) = assertion.split_once("==") {
|
|
1026
|
+
return left.trim() == right.split(',').next().unwrap_or("").trim();
|
|
1027
|
+
}
|
|
1028
|
+
let compact: String = assertion.chars().filter(|ch| !ch.is_whitespace()).collect();
|
|
1029
|
+
return (compact.starts_with("isinstance(") && compact.ends_with(",object)"))
|
|
1030
|
+
|| (compact.starts_with("len(") && compact.ends_with(")>=0"))
|
|
1031
|
+
|| (compact.starts_with("0<=len(") && compact.ends_with(')'));
|
|
1032
|
+
}
|
|
1033
|
+
let compact: String = line.chars().filter(|ch| !ch.is_whitespace()).collect();
|
|
1034
|
+
if compact.contains(".assertTrue(True)") {
|
|
1035
|
+
return true;
|
|
1036
|
+
}
|
|
1037
|
+
compact.split_once(".assertEqual(").and_then(|(_, args)| {
|
|
1038
|
+
args.strip_suffix(')')?.split_once(',')
|
|
1039
|
+
}).is_some_and(|(a, b)| a == b)
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
fn scan_python_structural(
|
|
1043
|
+
rel: &str,
|
|
1044
|
+
txt: &str,
|
|
1045
|
+
added: &[(usize, String)],
|
|
1046
|
+
out: &mut Vec<Finding>,
|
|
1047
|
+
) {
|
|
1048
|
+
let added_lines: BTreeSet<usize> = added.iter().map(|(ln, _)| *ln).collect();
|
|
1049
|
+
let is_test = is_test_file(rel);
|
|
1050
|
+
let all_lines: Vec<&str> = txt.lines().collect();
|
|
1051
|
+
|
|
1052
|
+
if !is_test {
|
|
1053
|
+
for &ln in &added_lines {
|
|
1054
|
+
if ln == 0 || ln > all_lines.len() {
|
|
1055
|
+
continue;
|
|
1056
|
+
}
|
|
1057
|
+
let line = all_lines[ln - 1];
|
|
1058
|
+
let code = line.split('#').next().unwrap_or("");
|
|
1059
|
+
if let Some(pos) = code.find("subprocess.run(") {
|
|
1060
|
+
let mut depth = 0i32;
|
|
1061
|
+
let mut call_buf = String::new();
|
|
1062
|
+
for j in (ln - 1)..all_lines.len().min(ln + 25) {
|
|
1063
|
+
let seg = if j == ln - 1 { &all_lines[j][pos..] } else { all_lines[j] };
|
|
1064
|
+
let seg_clean = seg.split('#').next().unwrap_or("");
|
|
1065
|
+
call_buf.push_str(seg_clean);
|
|
1066
|
+
call_buf.push(' ');
|
|
1067
|
+
for ch in seg_clean.chars() {
|
|
1068
|
+
if ch == '(' {
|
|
1069
|
+
depth += 1;
|
|
1070
|
+
} else if ch == ')' {
|
|
1071
|
+
depth -= 1;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
if depth <= 0 {
|
|
1075
|
+
break;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
if !call_buf.contains("timeout=") && !call_buf.contains("timeout =") && !call_buf.contains("**") {
|
|
1079
|
+
out.push(Finding {
|
|
1080
|
+
severity: "P1",
|
|
1081
|
+
rule: "safety-subprocess-timeout",
|
|
1082
|
+
file: rel.to_string(),
|
|
1083
|
+
line: ln,
|
|
1084
|
+
message: "`subprocess.run()` called without `timeout=`.".to_string(),
|
|
1085
|
+
fix: "Pass an explicit `timeout=` bound so child commands cannot hang forever.",
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
return;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
let mut i = 0;
|
|
1094
|
+
while i < all_lines.len() {
|
|
1095
|
+
let raw = all_lines[i];
|
|
1096
|
+
let trimmed = raw.trim_start();
|
|
1097
|
+
let def_rest = trimmed
|
|
1098
|
+
.strip_prefix("def ")
|
|
1099
|
+
.or_else(|| trimmed.strip_prefix("async def "));
|
|
1100
|
+
if let Some(drest) = def_rest {
|
|
1101
|
+
if drest.starts_with("test_") {
|
|
1102
|
+
let fname: String = drest
|
|
1103
|
+
.chars()
|
|
1104
|
+
.take_while(|c| c.is_ascii_alphanumeric() || *c == '_')
|
|
1105
|
+
.collect();
|
|
1106
|
+
let def_ind = raw.len() - trimmed.len();
|
|
1107
|
+
let start_ln = i + 1;
|
|
1108
|
+
let mut j = i + 1;
|
|
1109
|
+
let mut body_lines: Vec<(usize, &str)> = Vec::new();
|
|
1110
|
+
let mut in_triple: Option<&str> = None;
|
|
1111
|
+
while j < all_lines.len() {
|
|
1112
|
+
let bl = all_lines[j];
|
|
1113
|
+
let bc = bl.split('#').next().unwrap_or("").trim();
|
|
1114
|
+
let continued_string = in_triple.is_some();
|
|
1115
|
+
if !continued_string && bc.is_empty() {
|
|
1116
|
+
j += 1;
|
|
1117
|
+
continue;
|
|
1118
|
+
}
|
|
1119
|
+
let b_ind = bl.len() - bl.trim_start().len();
|
|
1120
|
+
if !continued_string && b_ind <= def_ind {
|
|
1121
|
+
break;
|
|
1122
|
+
}
|
|
1123
|
+
let mut rest = if continued_string { bl } else { bl.split('#').next().unwrap_or("") };
|
|
1124
|
+
while let Some((at, quote)) = ["\"\"\"", "'''"]
|
|
1125
|
+
.into_iter()
|
|
1126
|
+
.filter(|quote| in_triple.is_none_or(|open| open == *quote))
|
|
1127
|
+
.flat_map(|quote| rest.match_indices(quote))
|
|
1128
|
+
.filter(|(at, _)| rest.as_bytes()[..*at].iter().rev().take_while(|&&b| b == b'\\').count() % 2 == 0)
|
|
1129
|
+
.min_by_key(|(at, _)| *at)
|
|
1130
|
+
{
|
|
1131
|
+
in_triple = if in_triple.is_some() { None } else { Some(quote) };
|
|
1132
|
+
rest = &rest[at + quote.len()..];
|
|
1133
|
+
}
|
|
1134
|
+
body_lines.push((j + 1, if continued_string { "" } else { bc }));
|
|
1135
|
+
j += 1;
|
|
1136
|
+
}
|
|
1137
|
+
let end_ln = body_lines.last().map(|(l, _)| *l).unwrap_or(start_ln);
|
|
1138
|
+
let touched = (start_ln..=end_ln).any(|l| added_lines.contains(&l));
|
|
1139
|
+
if touched {
|
|
1140
|
+
if body_lines.is_empty()
|
|
1141
|
+
|| body_lines.iter().all(|(_, s)| *s == "pass" || *s == "...")
|
|
1142
|
+
{
|
|
1143
|
+
out.push(Finding {
|
|
1144
|
+
severity: "P1",
|
|
1145
|
+
rule: "test-theater-empty",
|
|
1146
|
+
file: rel.to_string(),
|
|
1147
|
+
line: start_ln,
|
|
1148
|
+
message: format!("Empty test `{}` proves nothing.", fname),
|
|
1149
|
+
fix: "Assert real observable behavior or delete the placeholder test.",
|
|
1150
|
+
});
|
|
1151
|
+
} else {
|
|
1152
|
+
let mut has_oracle = false;
|
|
1153
|
+
for (bln, bs) in &body_lines {
|
|
1154
|
+
if added_lines.contains(bln) && python_tautology(bs) {
|
|
1155
|
+
out.push(test_theater(rel, *bln, "test-theater-tautology", "Test assertion always passes."));
|
|
1156
|
+
}
|
|
1157
|
+
let mut parts = bs.split('(').peekable();
|
|
1158
|
+
while let Some(part) = parts.next().filter(|_| parts.peek().is_some()) {
|
|
1159
|
+
let name = part.trim_end().rsplit(|ch: char| !ch.is_alphanumeric() && ch != '_')
|
|
1160
|
+
.next().unwrap_or("");
|
|
1161
|
+
has_oracle |= name.starts_with("assert") || name.starts_with("check_")
|
|
1162
|
+
|| matches!(name, "fail" | "raises" | "warns" | "called");
|
|
1163
|
+
}
|
|
1164
|
+
has_oracle |= bs.starts_with("assert ");
|
|
1165
|
+
}
|
|
1166
|
+
if !has_oracle {
|
|
1167
|
+
out.push(Finding {
|
|
1168
|
+
severity: "P1",
|
|
1169
|
+
rule: "test-theater-no-assert",
|
|
1170
|
+
file: rel.to_string(),
|
|
1171
|
+
line: start_ln,
|
|
1172
|
+
message: format!("Test `{}` has zero assertions.", fname),
|
|
1173
|
+
fix: "Add concrete behavioral assertions or delete the dead test.",
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
i = j;
|
|
1179
|
+
continue;
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
i += 1;
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
fn parse_xml_attr(tag: &str, key: &str) -> Option<String> {
|
|
1187
|
+
let needle = format!("{}=\"", key);
|
|
1188
|
+
let idx = tag.find(&needle)?;
|
|
1189
|
+
let rest = &tag[idx + needle.len()..];
|
|
1190
|
+
let end = rest.find('"')?;
|
|
1191
|
+
Some(rest[..end].to_string())
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
fn check_policy_xml(root: &Path, changed: &[String], out: &mut Vec<Finding>) {
|
|
1195
|
+
let policy_path = root.join(".deepmodebot/policy.xml");
|
|
1196
|
+
let Ok(xml) = fs::read_to_string(&policy_path) else {
|
|
1197
|
+
return;
|
|
1198
|
+
};
|
|
1199
|
+
let mut forbids: Vec<(String, String, String)> = Vec::new();
|
|
1200
|
+
for line in xml.lines() {
|
|
1201
|
+
let trim = line.trim();
|
|
1202
|
+
if trim.starts_with("<file ") {
|
|
1203
|
+
if let Some(p) = parse_xml_attr(trim, "path") {
|
|
1204
|
+
let target = root.join(&p);
|
|
1205
|
+
if let Ok(meta) = fs::metadata(&target) {
|
|
1206
|
+
if let Some(mb) = parse_xml_attr(trim, "max-bytes")
|
|
1207
|
+
.and_then(|v| v.parse::<u64>().ok())
|
|
1208
|
+
{
|
|
1209
|
+
if meta.len() > mb {
|
|
1210
|
+
out.push(Finding {
|
|
1211
|
+
severity: "P1",
|
|
1212
|
+
rule: "budget-max-bytes",
|
|
1213
|
+
file: p.clone(),
|
|
1214
|
+
line: 1,
|
|
1215
|
+
message: format!("{} is {} B > budget {} B.", p, meta.len(), mb),
|
|
1216
|
+
fix: "Trim file or split into references.",
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
if let Some(ml) = parse_xml_attr(trim, "max-lines")
|
|
1221
|
+
.and_then(|v| v.parse::<usize>().ok())
|
|
1222
|
+
{
|
|
1223
|
+
if let Ok(txt) = fs::read_to_string(&target) {
|
|
1224
|
+
let lc = txt.lines().count();
|
|
1225
|
+
if lc > ml {
|
|
1226
|
+
out.push(Finding {
|
|
1227
|
+
severity: "P1",
|
|
1228
|
+
rule: "budget-max-lines",
|
|
1229
|
+
file: p.clone(),
|
|
1230
|
+
line: 1,
|
|
1231
|
+
message: format!("{} is {} L > budget {} L.", p, lc, ml),
|
|
1232
|
+
fix: "Trim file to stay within policy.xml budget.",
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
} else if trim.starts_with("<forbid ") {
|
|
1240
|
+
if let (Some(f), Some(t)) = (parse_xml_attr(trim, "from"), parse_xml_attr(trim, "to")) {
|
|
1241
|
+
let reason = parse_xml_attr(trim, "reason")
|
|
1242
|
+
.unwrap_or_else(|| format!("{} must not import {}", f, t));
|
|
1243
|
+
forbids.push((f, t, reason));
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
if forbids.is_empty() {
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
1250
|
+
let per_file = parallel_map(changed, |rel| {
|
|
1251
|
+
let mut local = Vec::new();
|
|
1252
|
+
let active: Vec<&(String, String, String)> = forbids
|
|
1253
|
+
.iter()
|
|
1254
|
+
.filter(|(f, _, _)| glob_match(f, rel))
|
|
1255
|
+
.collect();
|
|
1256
|
+
if active.is_empty() {
|
|
1257
|
+
return local;
|
|
1258
|
+
}
|
|
1259
|
+
let Ok(txt) = fs::read_to_string(root.join(rel)) else {
|
|
1260
|
+
return local;
|
|
1261
|
+
};
|
|
1262
|
+
for (idx, line) in txt.lines().enumerate() {
|
|
1263
|
+
let t = line.trim();
|
|
1264
|
+
let imp = if let Some(rest) = t.strip_prefix("import ") {
|
|
1265
|
+
Some(rest.split_whitespace().next().unwrap_or("").replace('.', "/"))
|
|
1266
|
+
} else if let Some(rest) = t.strip_prefix("from ") {
|
|
1267
|
+
Some(rest.split_whitespace().next().unwrap_or("").replace('.', "/"))
|
|
1268
|
+
} else {
|
|
1269
|
+
None
|
|
1270
|
+
};
|
|
1271
|
+
if let Some(target_mod) = imp {
|
|
1272
|
+
for (_, to_pat, reason) in &active {
|
|
1273
|
+
if glob_match(to_pat, &target_mod) {
|
|
1274
|
+
local.push(Finding {
|
|
1275
|
+
severity: "P1",
|
|
1276
|
+
rule: "arch-boundary",
|
|
1277
|
+
file: rel.clone(),
|
|
1278
|
+
line: idx + 1,
|
|
1279
|
+
message: format!(
|
|
1280
|
+
"Forbidden import `{}` violates policy.xml ({}).",
|
|
1281
|
+
target_mod, reason
|
|
1282
|
+
),
|
|
1283
|
+
fix: "Route through an allowed interface/service layer.",
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
local
|
|
1290
|
+
});
|
|
1291
|
+
for chunk in per_file {
|
|
1292
|
+
out.extend(chunk);
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
fn tool_path(name: &str, directory: Option<&Path>) -> Option<PathBuf> {
|
|
1297
|
+
fn in_dir(dir: &Path, name: &str) -> Option<PathBuf> {
|
|
1298
|
+
#[cfg(windows)]
|
|
1299
|
+
{
|
|
1300
|
+
let extensions = std::env::var("PATHEXT").unwrap_or_else(|_| ".COM;.EXE;.BAT;.CMD".into());
|
|
1301
|
+
extensions.split(';').filter(|ext| !ext.is_empty())
|
|
1302
|
+
.map(|ext| dir.join(format!("{name}{ext}"))).find(|path| path.is_file())
|
|
1303
|
+
}
|
|
1304
|
+
#[cfg(not(windows))]
|
|
1305
|
+
{
|
|
1306
|
+
use std::os::unix::fs::PermissionsExt;
|
|
1307
|
+
let path = dir.join(name);
|
|
1308
|
+
fs::metadata(&path).ok()
|
|
1309
|
+
.filter(|meta| meta.is_file() && meta.permissions().mode() & 0o111 != 0)
|
|
1310
|
+
.map(|_| path)
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
directory.and_then(|d| in_dir(d, name)).or_else(|| {
|
|
1314
|
+
std::env::split_paths(&std::env::var_os("PATH")?).find_map(|d| in_dir(&d, name))
|
|
1315
|
+
})
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
fn run_linter(mut cmd: Command, seconds: u64) -> Result<(), String> {
|
|
1319
|
+
let deadline = Instant::now() + Duration::from_secs(seconds);
|
|
1320
|
+
let mut child = cmd.stdin(Stdio::null()).stdout(Stdio::piped()).stderr(Stdio::piped())
|
|
1321
|
+
.spawn().map_err(|err| err.to_string())?;
|
|
1322
|
+
fn drain(mut pipe: impl Read + Send + 'static) -> std::sync::mpsc::Receiver<Vec<u8>> {
|
|
1323
|
+
let (tx, rx) = std::sync::mpsc::channel();
|
|
1324
|
+
thread::spawn(move || {
|
|
1325
|
+
let mut output = Vec::new();
|
|
1326
|
+
let _ = pipe.read_to_end(&mut output);
|
|
1327
|
+
let _ = tx.send(output);
|
|
1328
|
+
});
|
|
1329
|
+
rx
|
|
1330
|
+
}
|
|
1331
|
+
let stdout = drain(child.stdout.take().expect("piped stdout"));
|
|
1332
|
+
let stderr = drain(child.stderr.take().expect("piped stderr"));
|
|
1333
|
+
let timed_out = || format!("timed out after {seconds}s");
|
|
1334
|
+
let status = loop {
|
|
1335
|
+
if let Some(status) = child.try_wait().map_err(|err| err.to_string())? {
|
|
1336
|
+
break status;
|
|
1337
|
+
}
|
|
1338
|
+
if Instant::now() >= deadline {
|
|
1339
|
+
let _ = child.kill();
|
|
1340
|
+
let _ = child.wait();
|
|
1341
|
+
return Err(timed_out());
|
|
1342
|
+
}
|
|
1343
|
+
thread::sleep(Duration::from_millis(10));
|
|
1344
|
+
};
|
|
1345
|
+
let output = stdout.recv_timeout(deadline.saturating_duration_since(Instant::now())).map_err(|_| timed_out())?;
|
|
1346
|
+
let errors = stderr.recv_timeout(deadline.saturating_duration_since(Instant::now())).map_err(|_| timed_out())?;
|
|
1347
|
+
if status.success() {
|
|
1348
|
+
Ok(())
|
|
1349
|
+
} else if output.is_empty() && errors.is_empty() {
|
|
1350
|
+
Err(status.to_string())
|
|
1351
|
+
} else {
|
|
1352
|
+
Err(format!("{}\n{}", String::from_utf8_lossy(&output), String::from_utf8_lossy(&errors)))
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
struct Linter<'a> {
|
|
1357
|
+
name: &'static str,
|
|
1358
|
+
rule: &'static str,
|
|
1359
|
+
files: Vec<&'a str>,
|
|
1360
|
+
tool: PathBuf,
|
|
1361
|
+
args: &'static [&'static str],
|
|
1362
|
+
with_files: bool,
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
fn tsc_diagnostic(line: &str) -> Option<(&str, usize, &str)> {
|
|
1366
|
+
let (location, message) = line.split_once("): error TS")?;
|
|
1367
|
+
let (file, position) = location.rsplit_once('(')?;
|
|
1368
|
+
let (row, _) = position.split_once(',')?;
|
|
1369
|
+
Some((file, row.parse().ok()?, message.split_once(": ")?.1))
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
fn run_parallel_linters(root: &Path, changed: &[String]) -> (Vec<&'static str>, Vec<Finding>) {
|
|
1373
|
+
let mut linters = Vec::new();
|
|
1374
|
+
let files: Vec<&str> = changed.iter().map(String::as_str).filter(|file| {
|
|
1375
|
+
fs::symlink_metadata(root.join(file)).is_ok_and(|meta| meta.is_file())
|
|
1376
|
+
}).collect();
|
|
1377
|
+
let select = |exts: &[&str]| files.iter().copied().filter(|file| {
|
|
1378
|
+
exts.iter().any(|ext| extension(file).eq_ignore_ascii_case(ext))
|
|
1379
|
+
}).collect::<Vec<_>>();
|
|
1380
|
+
let mut add = |name, rule, files, tool, args: &'static [&'static str], with_files| {
|
|
1381
|
+
linters.push(Linter { name, rule, files, tool, args, with_files });
|
|
1382
|
+
};
|
|
1383
|
+
let py = select(&["py"]);
|
|
1384
|
+
if !py.is_empty() {
|
|
1385
|
+
if let Some(tool) = tool_path("ruff", None) {
|
|
1386
|
+
add("ruff", "ruff", py.clone(), tool, &[
|
|
1387
|
+
"check", "--no-cache", "--select", "E9,F63,F7,F82,F401,F811,F841,B006,B007,B012,B023,S102,S307",
|
|
1388
|
+
"--output-format", "concise", "--",
|
|
1389
|
+
][..], true);
|
|
1390
|
+
}
|
|
1391
|
+
if root.join("pyrightconfig.json").is_file() {
|
|
1392
|
+
if let Some(tool) = tool_path("pyright", None) {
|
|
1393
|
+
add("pyright", "pyright", py, tool, &[], true);
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
let js = select(JS_EXTS);
|
|
1398
|
+
if !js.is_empty() {
|
|
1399
|
+
let node_files = select(&["js", "mjs", "cjs"]);
|
|
1400
|
+
if !node_files.is_empty() {
|
|
1401
|
+
if let Some(tool) = tool_path("node", None) {
|
|
1402
|
+
for file in node_files {
|
|
1403
|
+
add("node-check", "node-syntax", vec![file], tool.clone(), &["--check"], true);
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
if let Some(tool) = tool_path("oxlint", None) {
|
|
1408
|
+
add("oxlint", "oxlint", js, tool, &["-D", "correctness", "-D", "suspicious", "--"], true);
|
|
1409
|
+
} else if ["biome.json", "biome.jsonc"].iter().any(|file| root.join(file).is_file()) {
|
|
1410
|
+
if let Some(tool) = tool_path("biome", None) {
|
|
1411
|
+
add("biome", "biome", js, tool, &["lint", "--"], true);
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
let ts = select(&["ts", "tsx"]);
|
|
1415
|
+
if !ts.is_empty() && root.join("tsconfig.json").is_file() {
|
|
1416
|
+
if let Some(tool) = tool_path("tsc", Some(&root.join("node_modules/.bin"))) {
|
|
1417
|
+
add("tsc", "ts-typecheck", ts, tool, &["--noEmit", "--pretty", "false"], false);
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
let go = select(&["go"]);
|
|
1422
|
+
if !go.is_empty() && root.join("go.mod").is_file() {
|
|
1423
|
+
if let Some(tool) = tool_path("go", None) {
|
|
1424
|
+
add("go-vet", "go-vet", go, tool, &["vet", "./..."], false);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
let sh = select(&["sh"]);
|
|
1428
|
+
if !sh.is_empty() {
|
|
1429
|
+
if let Some(tool) = tool_path("shellcheck", None) {
|
|
1430
|
+
add("shellcheck", "shellcheck", sh, tool, &["-S", "error", "-f", "gcc", "--"], true);
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
let mut names = Vec::new();
|
|
1435
|
+
for linter in &linters {
|
|
1436
|
+
if !names.contains(&linter.name) {
|
|
1437
|
+
names.push(linter.name);
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
let results = parallel_map(&linters, |linter| {
|
|
1441
|
+
let mut command = Command::new(&linter.tool);
|
|
1442
|
+
command.current_dir(root).args(linter.args);
|
|
1443
|
+
if linter.with_files {
|
|
1444
|
+
command.args(linter.files.iter().map(|file| format!("./{file}")));
|
|
1445
|
+
}
|
|
1446
|
+
let mut findings = Vec::new();
|
|
1447
|
+
if let Err(output) = run_linter(command, if linter.name == "node-check" { 15 } else { 30 }) {
|
|
1448
|
+
let mut add = |file: &str, line, message: &str| findings.push(Finding {
|
|
1449
|
+
severity: if linter.name == "node-check" { "P0" } else { "P1" },
|
|
1450
|
+
rule: linter.rule,
|
|
1451
|
+
file: file.to_owned(),
|
|
1452
|
+
line,
|
|
1453
|
+
message: message.to_owned(),
|
|
1454
|
+
fix: "Resolve the linter diagnostic.",
|
|
1455
|
+
});
|
|
1456
|
+
let mut saw_file = false;
|
|
1457
|
+
if linter.name == "tsc" {
|
|
1458
|
+
for (file, line, msg) in output.lines().filter_map(tsc_diagnostic) {
|
|
1459
|
+
saw_file = true;
|
|
1460
|
+
let file = crate::util::normalize_rel(root, &root.join(file));
|
|
1461
|
+
if let Some(file) = linter.files.iter().find(|candidate| **candidate == file
|
|
1462
|
+
|| cfg!(windows) && candidate.eq_ignore_ascii_case(&file))
|
|
1463
|
+
{
|
|
1464
|
+
add(file, line, msg);
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
if !saw_file {
|
|
1469
|
+
let start = output.char_indices().rev().nth(1499).map_or(0, |(i, _)| i);
|
|
1470
|
+
add(linter.files[0], 1, output[start..].trim());
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
findings
|
|
1474
|
+
});
|
|
1475
|
+
(names, results.into_iter().flatten().collect())
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
fn read_source(path: &Path, max_bytes: u64) -> Option<String> {
|
|
1479
|
+
let meta = fs::symlink_metadata(path).ok()?;
|
|
1480
|
+
if !meta.is_file() || meta.len() > max_bytes {
|
|
1481
|
+
return None;
|
|
1482
|
+
}
|
|
1483
|
+
fs::read(path).ok().map(|bytes| match String::from_utf8(bytes) {
|
|
1484
|
+
Ok(text) => text,
|
|
1485
|
+
Err(err) => String::from_utf8_lossy(err.as_bytes()).into_owned(),
|
|
1486
|
+
})
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
fn append_reward(out: &mut Vec<Finding>, findings: Vec<crate::reward::RewardFinding>) {
|
|
1490
|
+
out.extend(findings.into_iter().map(|f| Finding {
|
|
1491
|
+
severity: f.severity, rule: f.rule, file: f.file, line: f.line, message: f.message, fix: f.fix,
|
|
1492
|
+
}));
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
fn scan_scratch_reward(root: &Path, out: &mut Vec<Finding>) {
|
|
1496
|
+
const LIMIT: u64 = 16 * 1024 * 1024;
|
|
1497
|
+
const SKIP: &[&str] = &["reward-guard", "self-grill", "evidence", "goals", "gen-ui", "agents-md-backup", "quota-guard"];
|
|
1498
|
+
const PREFIXES: &[&str] = &["check-", "npm-test-", "init-cli-test-", "panel-", "autoroute-test-"];
|
|
1499
|
+
let scratch = root.join(".scratch");
|
|
1500
|
+
let mut pending = vec![scratch.clone()];
|
|
1501
|
+
let mut scripts = 0;
|
|
1502
|
+
while let Some(path) = pending.pop() {
|
|
1503
|
+
let Ok(meta) = fs::symlink_metadata(&path) else { continue };
|
|
1504
|
+
let rel = crate::util::normalize_rel(root, &path);
|
|
1505
|
+
if meta.file_type().is_symlink() {
|
|
1506
|
+
out.push(Finding {
|
|
1507
|
+
severity: "P0", rule: "reward-hack-scratch-symlink", file: rel, line: 1,
|
|
1508
|
+
message: "Symlink inside `.scratch/` can hide an external script.".into(),
|
|
1509
|
+
fix: "Remove the symlink and keep scripts inside the project root.",
|
|
1510
|
+
});
|
|
1511
|
+
continue;
|
|
1512
|
+
}
|
|
1513
|
+
if meta.is_dir() {
|
|
1514
|
+
let name = path.file_name().and_then(|name| name.to_str()).unwrap_or("");
|
|
1515
|
+
if (path.parent() == Some(&scratch) && SKIP.contains(&name))
|
|
1516
|
+
|| PREFIXES.iter().any(|prefix| name.starts_with(prefix))
|
|
1517
|
+
{
|
|
1518
|
+
continue;
|
|
1519
|
+
}
|
|
1520
|
+
if let Ok(entries) = fs::read_dir(path) {
|
|
1521
|
+
let mut children: Vec<_> = entries.flatten().map(|entry| entry.path()).collect();
|
|
1522
|
+
children.sort_unstable_by(|a, b| b.cmp(a));
|
|
1523
|
+
pending.extend(children);
|
|
1524
|
+
}
|
|
1525
|
+
} else if meta.is_file() && matches!(extension(&rel).to_ascii_lowercase().as_str(), "py" | "sh" | "ps1" | "cmd" | "bat" | "js" | "mjs" | "cjs" | "ts") {
|
|
1526
|
+
if meta.len() > LIMIT {
|
|
1527
|
+
out.push(Finding {
|
|
1528
|
+
severity: "P0", rule: "reward-hack-oversized-scratch-script", file: rel, line: 1,
|
|
1529
|
+
message: "Scratch script exceeds 16 MiB (padding bypass blocked).".into(),
|
|
1530
|
+
fix: "Remove the oversized script.",
|
|
1531
|
+
});
|
|
1532
|
+
} else if scripts < 500 && meta.len() != 0 {
|
|
1533
|
+
scripts += 1;
|
|
1534
|
+
if let Some(text) = read_source(&path, LIMIT) {
|
|
1535
|
+
let added: Vec<_> = text.lines().enumerate().map(|(i, line)| (i + 1, line.to_owned())).collect();
|
|
1536
|
+
let mut findings = Vec::new();
|
|
1537
|
+
crate::reward::scan_file_reward_hacks_full(&rel, &added, &[], true, false, None, None, Some(&text), &mut findings);
|
|
1538
|
+
append_reward(out, findings);
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
fn scan_stub_slop(rel: &str, ext: &str, baseline: &str, text: &str, out: &mut Vec<Finding>) {
|
|
1546
|
+
fn key(ext: &str, line: &str) -> Option<&'static str> {
|
|
1547
|
+
let line = line.trim();
|
|
1548
|
+
let text = match ext {
|
|
1549
|
+
"py" if line.starts_with("raise NotImplementedError") => return Some("NotImplementedError"),
|
|
1550
|
+
"rs" => scrub_js_code_line(line),
|
|
1551
|
+
_ => return None,
|
|
1552
|
+
};
|
|
1553
|
+
["todo!", "unimplemented!"].into_iter().find(|needle| {
|
|
1554
|
+
text.match_indices(needle).any(|(i, code)| text[i + code.len()..].trim_start().starts_with('('))
|
|
1555
|
+
})
|
|
1556
|
+
}
|
|
1557
|
+
let mut old = std::collections::BTreeMap::new();
|
|
1558
|
+
for line in baseline.lines().filter_map(|line| key(ext, line)) {
|
|
1559
|
+
*old.entry(line).or_insert(0usize) += 1;
|
|
1560
|
+
}
|
|
1561
|
+
for (i, line) in text.lines().enumerate() {
|
|
1562
|
+
if let Some(marker) = key(ext, line) {
|
|
1563
|
+
if let Some(n) = old.get_mut(marker).filter(|n| **n > 0) {
|
|
1564
|
+
*n -= 1;
|
|
1565
|
+
} else {
|
|
1566
|
+
out.push(Finding {
|
|
1567
|
+
severity: "P1", rule: "stub-placeholder", file: rel.to_owned(), line: i + 1,
|
|
1568
|
+
message: format!("New `{marker}` placeholder."),
|
|
1569
|
+
fix: "Implement the behavior rather than leaving a placeholder.",
|
|
1570
|
+
});
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
|
|
1577
|
+
pub fn run(args: &[String]) -> ExitCode {
|
|
1578
|
+
let mut root = PathBuf::from(".");
|
|
1579
|
+
let mut staged = false;
|
|
1580
|
+
let mut allow_config = false;
|
|
1581
|
+
let mut base = None;
|
|
1582
|
+
let mut allow_untested = false;
|
|
1583
|
+
let mut no_linters = false;
|
|
1584
|
+
let mut as_json = false;
|
|
1585
|
+
let mut explicit_files: Vec<String> = Vec::new();
|
|
1586
|
+
|
|
1587
|
+
let mut i = 0;
|
|
1588
|
+
while i < args.len() {
|
|
1589
|
+
match args[i].as_str() {
|
|
1590
|
+
"--root" if i + 1 < args.len() => {
|
|
1591
|
+
root = PathBuf::from(&args[i + 1]);
|
|
1592
|
+
i += 2;
|
|
1593
|
+
}
|
|
1594
|
+
"--staged" => {
|
|
1595
|
+
staged = true;
|
|
1596
|
+
i += 1;
|
|
1597
|
+
}
|
|
1598
|
+
"--base" if i + 1 < args.len() && !args[i + 1].starts_with("--") => {
|
|
1599
|
+
base = Some(args[i + 1].as_str());
|
|
1600
|
+
i += 2;
|
|
1601
|
+
}
|
|
1602
|
+
"--base" => {
|
|
1603
|
+
eprintln!("dmb-gate slop: --base requires a ref");
|
|
1604
|
+
return ExitCode::from(2);
|
|
1605
|
+
}
|
|
1606
|
+
"--allow-untested" => {
|
|
1607
|
+
allow_untested = true;
|
|
1608
|
+
i += 1;
|
|
1609
|
+
}
|
|
1610
|
+
"--allow-config-change" => {
|
|
1611
|
+
allow_config = true;
|
|
1612
|
+
i += 1;
|
|
1613
|
+
}
|
|
1614
|
+
"--no-linters" => {
|
|
1615
|
+
no_linters = true;
|
|
1616
|
+
i += 1;
|
|
1617
|
+
}
|
|
1618
|
+
"--json" => {
|
|
1619
|
+
as_json = true;
|
|
1620
|
+
i += 1;
|
|
1621
|
+
}
|
|
1622
|
+
"--files" => {
|
|
1623
|
+
i += 1;
|
|
1624
|
+
while i < args.len() && !args[i].starts_with("--") {
|
|
1625
|
+
explicit_files.push(args[i].clone());
|
|
1626
|
+
i += 1;
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
_ => {
|
|
1630
|
+
i += 1;
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
let root = fs::canonicalize(&root).unwrap_or(root);
|
|
1635
|
+
let (changed, baseline) = match change_scope(&root, staged, &explicit_files, base) {
|
|
1636
|
+
Ok(scope) => scope,
|
|
1637
|
+
Err(error) => {
|
|
1638
|
+
eprintln!("dmb-gate slop: {error}");
|
|
1639
|
+
return ExitCode::from(2);
|
|
1640
|
+
}
|
|
1641
|
+
};
|
|
1642
|
+
let baseline = baseline.as_deref();
|
|
1643
|
+
let scan_scratch = !staged && explicit_files.is_empty();
|
|
1644
|
+
let count_prod = !allow_untested && explicit_files.is_empty() && !changed.iter().any(|f| is_test_file(f));
|
|
1645
|
+
|
|
1646
|
+
// Parallel diff & line scanning across all changed files
|
|
1647
|
+
let per_file_findings = parallel_map(&changed, |rel| {
|
|
1648
|
+
let mut local = Vec::new();
|
|
1649
|
+
if !allow_config && GUARDRAIL_CONFIGS.contains(&rel.as_str()) {
|
|
1650
|
+
local.push(Finding {
|
|
1651
|
+
severity: "P1",
|
|
1652
|
+
rule: "config-tamper",
|
|
1653
|
+
file: rel.clone(),
|
|
1654
|
+
line: 1,
|
|
1655
|
+
message: format!("Guardrail config `{}` modified without opt-in.", rel),
|
|
1656
|
+
fix: "Fix code instead of loosening guardrails, or pass --allow-config-change.",
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1659
|
+
let ext = extension(rel).to_ascii_lowercase();
|
|
1660
|
+
let ext = ext.as_str();
|
|
1661
|
+
let test_target = is_test_target(rel, ext);
|
|
1662
|
+
if staged && test_target && staged_test_target_is_empty(&root, rel, ext) {
|
|
1663
|
+
local.push(empty_test_finding(rel));
|
|
1664
|
+
}
|
|
1665
|
+
let file = root.join(rel);
|
|
1666
|
+
let Some(text) = read_source(&file, 1_048_576) else { return (local, 0, false) };
|
|
1667
|
+
if !staged && test_target && ext == "py" && !python_declares_tests(&text) {
|
|
1668
|
+
local.push(empty_test_finding(rel));
|
|
1669
|
+
}
|
|
1670
|
+
let mut added = added_lines_for_file(&root, rel, staged, baseline, &text);
|
|
1671
|
+
if added.is_empty() && !explicit_files.is_empty() {
|
|
1672
|
+
added = text.lines().enumerate().map(|(i, line)| (i + 1, line.to_owned())).collect();
|
|
1673
|
+
}
|
|
1674
|
+
let rs_cfg_ln = if ext == "rs" { crate::reward::find_rs_cfg_test_line(&text) } else { None };
|
|
1675
|
+
scan_added_lines_ctx(rel, &added, rs_cfg_ln, &mut local);
|
|
1676
|
+
|
|
1677
|
+
if !scan_scratch || !rel.starts_with(".scratch/") {
|
|
1678
|
+
let (_, r_hunks) = crate::reward::diff_file_hunks(&root, rel, staged, baseline);
|
|
1679
|
+
if !added.is_empty() || !r_hunks.is_empty() {
|
|
1680
|
+
let mypy_lines = (ext == "ini" || ext == "cfg").then(|| crate::reward::find_mypy_section_lines(&text));
|
|
1681
|
+
let mut r_findings = Vec::new();
|
|
1682
|
+
crate::reward::scan_file_reward_hacks_full(
|
|
1683
|
+
rel, &added, &r_hunks, true, false, rs_cfg_ln, mypy_lines.as_ref(), Some(&text), &mut r_findings,
|
|
1684
|
+
);
|
|
1685
|
+
append_reward(&mut local, r_findings);
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
if !is_test_file(rel) && ((ext == "py" && text.contains("NotImplementedError"))
|
|
1689
|
+
|| (ext == "rs" && (text.contains("todo!") || text.contains("unimplemented!"))))
|
|
1690
|
+
{
|
|
1691
|
+
let base = baseline.and_then(|base| git(&root, &["show", &format!("{base}:{rel}")]))
|
|
1692
|
+
.filter(|(ok, _)| *ok).map(|(_, text)| text).unwrap_or_default();
|
|
1693
|
+
scan_stub_slop(rel, ext, &base, &text, &mut local);
|
|
1694
|
+
}
|
|
1695
|
+
if matches!(rel.as_str(), ".github/dependabot.yml" | ".github/dependabot.yaml") && !added.is_empty() {
|
|
1696
|
+
if text.contains("cooldown:") {
|
|
1697
|
+
local.retain(|f| f.rule != "supply-chain-dependabot-cooldown");
|
|
1698
|
+
} else if !local.iter().any(|f| f.rule == "supply-chain-dependabot-cooldown") {
|
|
1699
|
+
local.push(Finding {
|
|
1700
|
+
severity: "P2",
|
|
1701
|
+
rule: "supply-chain-dependabot-cooldown",
|
|
1702
|
+
file: rel.clone(),
|
|
1703
|
+
line: 1,
|
|
1704
|
+
message: "`.github/dependabot.yml` has no `cooldown:` window.".to_string(),
|
|
1705
|
+
fix: "Add `cooldown: { default-days: 7 }` to reduce zero-day supply-chain exposure.",
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
if ext == "py" && !added.is_empty() {
|
|
1710
|
+
scan_python_structural(rel, &text, &added, &mut local);
|
|
1711
|
+
}
|
|
1712
|
+
let test_file = is_test_file(rel);
|
|
1713
|
+
if !test_file && (JS_EXTS.contains(&ext) || matches!(ext, "py" | "rs" | "go" | "sh" | "css" | "html" | "svelte")) {
|
|
1714
|
+
local.extend(crate::perf::scan_text(rel, &text).into_iter().filter(|f| f.severity == "high").map(|f| Finding {
|
|
1715
|
+
severity: "P1", rule: f.rule_id, file: f.file, line: f.line, message: f.message.into(),
|
|
1716
|
+
fix: "Batch DB/async calls or move sync I/O off the hot loop.",
|
|
1717
|
+
}));
|
|
1718
|
+
}
|
|
1719
|
+
if crate::ui::UI_EXTS.contains(&ext) {
|
|
1720
|
+
for uf in crate::ui::scan_ui(rel, &text) {
|
|
1721
|
+
if uf.severity == "P0" || uf.severity == "P1" {
|
|
1722
|
+
local.push(Finding {
|
|
1723
|
+
severity: uf.severity,
|
|
1724
|
+
rule: uf.rule,
|
|
1725
|
+
file: uf.file,
|
|
1726
|
+
line: uf.line,
|
|
1727
|
+
message: uf.message.to_string(),
|
|
1728
|
+
fix: "Fix UI token/a11y/motion violation per frontend-ui.",
|
|
1729
|
+
});
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
let count_file = count_prod && !DIFF_EXEMPT_DIRS.contains(&rel.split('/').next().unwrap_or(""));
|
|
1734
|
+
let (mut production, mut test_touched) = (0, false);
|
|
1735
|
+
if (ext == "rs" || ext == "go" || JS_EXTS.contains(&ext))
|
|
1736
|
+
&& (test_target && !staged || !added.is_empty() && (ext == "rs" || test_file || count_file))
|
|
1737
|
+
{
|
|
1738
|
+
let tokens = source_tokens(&text, ext);
|
|
1739
|
+
if !staged && test_target && !brace_declares_tests(&tokens, ext) {
|
|
1740
|
+
local.push(empty_test_finding(rel));
|
|
1741
|
+
}
|
|
1742
|
+
let added_lines: BTreeSet<_> = added.iter().map(|(line, _)| *line).collect();
|
|
1743
|
+
let mut rust_tests = false;
|
|
1744
|
+
if ext == "rs" {
|
|
1745
|
+
for (start, end) in rust_test_ranges(&tokens) {
|
|
1746
|
+
rust_tests = true;
|
|
1747
|
+
test_touched |= added_lines.range(start..=end).next().is_some();
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
if test_file || rust_tests {
|
|
1751
|
+
scan_brace_tests(rel, ext, &tokens, &added_lines, &mut local);
|
|
1752
|
+
}
|
|
1753
|
+
if count_file {
|
|
1754
|
+
let mut last = 0;
|
|
1755
|
+
production = tokens.iter().filter(|t| {
|
|
1756
|
+
let first = t.line != last;
|
|
1757
|
+
last = t.line;
|
|
1758
|
+
first && added_lines.contains(&t.line)
|
|
1759
|
+
}).count();
|
|
1760
|
+
}
|
|
1761
|
+
} else if count_file && ext == "py" {
|
|
1762
|
+
production = added.iter().filter(|(_, line)| {
|
|
1763
|
+
let code = line.trim_start();
|
|
1764
|
+
!code.is_empty() && !code.starts_with('#')
|
|
1765
|
+
}).count();
|
|
1766
|
+
}
|
|
1767
|
+
(local, production, test_touched)
|
|
1768
|
+
});
|
|
1769
|
+
|
|
1770
|
+
let mut findings = Vec::new();
|
|
1771
|
+
let (mut total, mut largest, mut test_touched) = (0, ("", 0), false);
|
|
1772
|
+
for (file, (local, production, tests)) in changed.iter().zip(per_file_findings) {
|
|
1773
|
+
findings.extend(local);
|
|
1774
|
+
total += production;
|
|
1775
|
+
test_touched |= tests;
|
|
1776
|
+
if production > largest.1 {
|
|
1777
|
+
largest = (file.as_str(), production);
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
if total >= 30 && !test_touched && git_paths(&root, &["ls-files", "-z"]).any(|f| is_test_file(&f)) {
|
|
1781
|
+
findings.push(Finding {
|
|
1782
|
+
severity: "P1", rule: "untested-code-diff", file: largest.0.to_owned(), line: 1,
|
|
1783
|
+
message: "At least 30 production lines were added without changing any tests.".into(),
|
|
1784
|
+
fix: "Add behavioral regression tests or pass --allow-untested for an approved exception.",
|
|
1785
|
+
});
|
|
1786
|
+
}
|
|
1787
|
+
if scan_scratch {
|
|
1788
|
+
scan_scratch_reward(&root, &mut findings);
|
|
1789
|
+
}
|
|
1790
|
+
check_policy_xml(&root, &changed, &mut findings);
|
|
1791
|
+
let sim_changed = if explicit_files.is_empty() { None } else { Some(changed.as_slice()) };
|
|
1792
|
+
let sim_base = if staged || !explicit_files.is_empty() { None } else { baseline };
|
|
1793
|
+
findings.extend(crate::sim::check(&root, sim_changed, staged, sim_base).findings);
|
|
1794
|
+
|
|
1795
|
+
let linters = if no_linters {
|
|
1796
|
+
Vec::new()
|
|
1797
|
+
} else {
|
|
1798
|
+
let (names, l_findings) = run_parallel_linters(&root, &changed);
|
|
1799
|
+
findings.extend(l_findings);
|
|
1800
|
+
names
|
|
1801
|
+
};
|
|
1802
|
+
|
|
1803
|
+
findings.sort_by(|a, b| {
|
|
1804
|
+
a.severity
|
|
1805
|
+
.cmp(b.severity)
|
|
1806
|
+
.then_with(|| a.file.cmp(&b.file))
|
|
1807
|
+
.then_with(|| a.line.cmp(&b.line))
|
|
1808
|
+
.then_with(|| a.rule.cmp(b.rule))
|
|
1809
|
+
});
|
|
1810
|
+
|
|
1811
|
+
let p0 = findings.iter().filter(|f| f.severity == "P0").count();
|
|
1812
|
+
let p1 = findings.iter().filter(|f| f.severity == "P1").count();
|
|
1813
|
+
let p2 = findings.iter().filter(|f| f.severity == "P2").count();
|
|
1814
|
+
let ok = p0 == 0 && p1 == 0;
|
|
1815
|
+
|
|
1816
|
+
if as_json {
|
|
1817
|
+
let items: Vec<String> = findings
|
|
1818
|
+
.iter()
|
|
1819
|
+
.map(|f| {
|
|
1820
|
+
format!(
|
|
1821
|
+
"{{\"severity\":{},\"rule\":{},\"file\":{},\"line\":{},\"message\":{},\"fix\":{}}}",
|
|
1822
|
+
json_escape(f.severity),
|
|
1823
|
+
json_escape(f.rule),
|
|
1824
|
+
json_escape(&f.file),
|
|
1825
|
+
f.line,
|
|
1826
|
+
json_escape(&f.message),
|
|
1827
|
+
json_escape(f.fix)
|
|
1828
|
+
)
|
|
1829
|
+
})
|
|
1830
|
+
.collect();
|
|
1831
|
+
let l_json: Vec<String> = linters.iter().map(|l| json_escape(l)).collect();
|
|
1832
|
+
println!(
|
|
1833
|
+
"{{\"ok\":{},\"engine\":\"rust-parallel\",\"files_checked\":{},\"linters\":[{}],\"counts\":{{\"P0\":{},\"P1\":{},\"P2\":{}}},\"findings\":[{}]}}",
|
|
1834
|
+
ok,
|
|
1835
|
+
changed.len(),
|
|
1836
|
+
l_json.join(","),
|
|
1837
|
+
p0,
|
|
1838
|
+
p1,
|
|
1839
|
+
p2,
|
|
1840
|
+
items.join(",")
|
|
1841
|
+
);
|
|
1842
|
+
} else {
|
|
1843
|
+
println!(
|
|
1844
|
+
"dmb-gate slop [{}]: {} file(s), linters=[{}] — P0:{} P1:{} P2:{}",
|
|
1845
|
+
if ok { "OK" } else { "BLOCKED" },
|
|
1846
|
+
changed.len(),
|
|
1847
|
+
linters.join(", "),
|
|
1848
|
+
p0,
|
|
1849
|
+
p1,
|
|
1850
|
+
p2
|
|
1851
|
+
);
|
|
1852
|
+
for f in &findings {
|
|
1853
|
+
println!(
|
|
1854
|
+
" {}:{} [{}:{}] {} -> {}",
|
|
1855
|
+
f.file, f.line, f.severity, f.rule, f.message, f.fix
|
|
1856
|
+
);
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
if ok {
|
|
1860
|
+
ExitCode::SUCCESS
|
|
1861
|
+
} else {
|
|
1862
|
+
ExitCode::from(1)
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
#[cfg(test)]
|
|
1867
|
+
mod tests {
|
|
1868
|
+
use super::*;
|
|
1869
|
+
|
|
1870
|
+
#[test]
|
|
1871
|
+
fn dependabot_yaml_list_item_and_dotfile_explicit_files() {
|
|
1872
|
+
let mut out = Vec::new();
|
|
1873
|
+
let lines = vec![
|
|
1874
|
+
(1, "version: 2".to_string()),
|
|
1875
|
+
(2, "updates:".to_string()),
|
|
1876
|
+
(3, " - package-ecosystem: \"npm\"".to_string()),
|
|
1877
|
+
];
|
|
1878
|
+
scan_added_lines(".github/dependabot.yml", &lines, &mut out);
|
|
1879
|
+
assert_eq!(out.len(), 1);
|
|
1880
|
+
assert_eq!(out[0].rule, "supply-chain-dependabot-cooldown");
|
|
1881
|
+
|
|
1882
|
+
let explicit = vec![".github/dependabot.yml,./src/a.py".to_string()];
|
|
1883
|
+
let (norm, _) = change_scope(Path::new("."), false, &explicit, None).unwrap();
|
|
1884
|
+
assert_eq!(norm, vec![".github/dependabot.yml", "src/a.py"]);
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
fn git_ok(root: &Path, args: &[&str]) {
|
|
1888
|
+
let status = Command::new("git")
|
|
1889
|
+
.args(["-c", "core.hooksPath=disabled-hooks", "-c", "commit.gpgsign=false", "-C"])
|
|
1890
|
+
.arg(root).args(args).status().unwrap();
|
|
1891
|
+
assert!(status.success(), "git {args:?}");
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
#[test]
|
|
1895
|
+
fn clean_feature_commit_and_explicit_base_include_the_right_changes() {
|
|
1896
|
+
let root = crate::tests::TestRepo::new("branch");
|
|
1897
|
+
let root = &root.0;
|
|
1898
|
+
git_ok(root, &["init", "-q", "-b", "main"]);
|
|
1899
|
+
git_ok(root, &["config", "user.email", "test@example.com"]);
|
|
1900
|
+
git_ok(root, &["config", "user.name", "Gate Test"]);
|
|
1901
|
+
let path = root.join("app.py");
|
|
1902
|
+
fs::write(&path, "def legacy():\n raise NotImplementedError\n").unwrap();
|
|
1903
|
+
git_ok(root, &["add", "."]);
|
|
1904
|
+
git_ok(root, &["commit", "-qm", "main"]);
|
|
1905
|
+
let (files, _) = change_scope(root, false, &[], None).unwrap();
|
|
1906
|
+
assert!(files.is_empty(), "{files:?}");
|
|
1907
|
+
git_ok(root, &["switch", "-qc", "feature"]);
|
|
1908
|
+
let text = "def legacy():\n raise NotImplementedError\n\ndef added():\n raise NotImplementedError\n";
|
|
1909
|
+
fs::write(&path, text).unwrap();
|
|
1910
|
+
git_ok(root, &["add", "."]);
|
|
1911
|
+
git_ok(root, &["commit", "-qm", "feature"]);
|
|
1912
|
+
let (files, baseline) = change_scope(root, false, &[], None).unwrap();
|
|
1913
|
+
assert_eq!(files, ["app.py"]);
|
|
1914
|
+
let baseline = baseline.unwrap();
|
|
1915
|
+
let added = added_lines_for_file(root, "app.py", false, Some(&baseline), text);
|
|
1916
|
+
assert_eq!(added.last().map(|(line, _)| *line), Some(5));
|
|
1917
|
+
let mut findings = Vec::new();
|
|
1918
|
+
let (_, old) = git(root, &["show", &format!("{baseline}:app.py")]).unwrap();
|
|
1919
|
+
scan_stub_slop("app.py", "py", &old, text, &mut findings);
|
|
1920
|
+
assert_eq!(findings.iter().map(|f| (f.rule, f.line)).collect::<Vec<_>>(), [("stub-placeholder", 5)]);
|
|
1921
|
+
let args = ["--root".into(), root.to_string_lossy().into_owned(), "--no-linters".into(), "--json".into()];
|
|
1922
|
+
assert_eq!(run(&args), ExitCode::from(1));
|
|
1923
|
+
|
|
1924
|
+
fs::write(root.join("local.go"), "package demo\n").unwrap();
|
|
1925
|
+
let (files, _) = change_scope(root, false, &[], Some("main")).unwrap();
|
|
1926
|
+
assert_eq!(files, ["app.py", "local.go"]);
|
|
1927
|
+
let (files, _) = change_scope(root, false, &[], None).unwrap();
|
|
1928
|
+
assert_eq!(files, ["local.go"]);
|
|
1929
|
+
assert!(change_scope(root, false, &[], Some("bad-ref")).is_err());
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
fn declares_tests(rel: &str, text: &str) -> bool {
|
|
1933
|
+
let ext = extension(rel).to_ascii_lowercase();
|
|
1934
|
+
assert!(is_test_target(rel, &ext), "{rel}");
|
|
1935
|
+
if ext == "py" {
|
|
1936
|
+
python_declares_tests(text)
|
|
1937
|
+
} else {
|
|
1938
|
+
brace_declares_tests(&source_tokens(text, &ext), &ext)
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
#[test]
|
|
1943
|
+
fn empty_test_targets_ignore_comments_strings_and_non_target_helpers() {
|
|
1944
|
+
for (rel, text) in [
|
|
1945
|
+
("empty.test.mjs", ""),
|
|
1946
|
+
("fake.spec.ts", "/* it('fake', () => {}); */\nconst text = `test('fake', () => {});`;\n"),
|
|
1947
|
+
("test_fake.py", "# def test_fake(): ...\ntext = \"\"\"\nclass TestFake:\n def test_fake(self): ...\n\"\"\"\n"),
|
|
1948
|
+
("fake_test.go", "package demo\n/* func TestFake(t *testing.T) {} */\nvar raw = `func TestFake(t *testing.T) {}`\n"),
|
|
1949
|
+
("tests/fake.rs", "/* outer /* nested */ #[test] fn fake() {} */\nconst RAW: &str = r##\"#[test] fn fake() {}\"##;\n"),
|
|
1950
|
+
] {
|
|
1951
|
+
assert!(!declares_tests(rel, text), "{rel}");
|
|
1952
|
+
}
|
|
1953
|
+
for (rel, text) in [
|
|
1954
|
+
("real.test.mjs", "import {test} from 'node:test';\nfunction checks() { assert.equal(Number('7'), 7); }\ntest('parses a digit', checks);\n"),
|
|
1955
|
+
("test_real.py", "import unittest\nclass Contract(unittest.TestCase):\n def testRoundTrip(self):\n self.assertEqual(bytes.fromhex('71'), b'q')\n"),
|
|
1956
|
+
("real_test.go", "package demo\nimport \"testing\"\nfunc TestContract(t *testing.T) { if parse() != 7 { t.Fatal(\"parse\") } }\n"),
|
|
1957
|
+
("tests/real.rs", "#[test]\nfn contract() { assert_eq!(\"7\".parse::<u32>().unwrap(), 7); }\n"),
|
|
1958
|
+
] {
|
|
1959
|
+
assert!(declares_tests(rel, text), "{rel}");
|
|
1960
|
+
}
|
|
1961
|
+
assert!(!is_test_target("tests/helper.py", "py"));
|
|
1962
|
+
assert!(!is_test_target("tests/common/mod.rs", "rs"));
|
|
1963
|
+
assert!(is_test_target("tests/real.rs", "rs"));
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
#[test]
|
|
1967
|
+
fn brace_test_theater_distinguishes_comments_literals_and_oracles() {
|
|
1968
|
+
for (rel, text, expected) in [
|
|
1969
|
+
("test/example.mjs", format!("test('}}', () => {{ /* expect({t}) }} */ }});\nit('no', () => {{ const x = 'expect({t})'; }});\nit('fake', () => expect({t}).toBe({t}));\nit('real', () => assert.equal(get(), 7));", t = "true"), vec![(1, "test-theater-empty"), (2, "test-theater-no-assert"), (3, "test-theater-tautology")]),
|
|
1970
|
+
("example.test.ts", format!("test('empty', async ({{ obj }}) => {{}});\ntest('bad', function () {{ run(); }});\ntest('false', () => expect({f}).toBe({f}));\ntest('one', () => expect({n}).toBe({n}));", f = "false", n = 1), vec![(1, "test-theater-empty"), (2, "test-theater-no-assert"), (3, "test-theater-tautology"), (4, "test-theater-tautology")]),
|
|
1971
|
+
("src/lib.rs", format!("#[cfg(test)] mod tests {{\n#[test] fn empty() {{ /* assert!({t}) */ }}\n#[tokio::test] async fn no_oracle() {{ run(); }}\n#[test] fn fake() {{ assert!({t}); assert_eq!({n}, {n}); }}\n#[should_panic] #[test] fn contract() {{ rejects_bad_input(); }}\n#[test] fn result() -> Result<(), Error> {{ verify_operation()?; Ok(()) }}\n}}", t = "true", n = 1), vec![(2, "test-theater-empty"), (3, "test-theater-no-assert"), (4, "test-theater-tautology"), (4, "test-theater-tautology")]),
|
|
1972
|
+
("app_test.go", "func TestEmpty(t *testing.T) { // t.Error()\n}\nfunc TestNoOracle(t *testing.T) { _ = `t.Fatal(\"}\")` }\nfunc TestReal(t *testing.T) { if x() != 2 { t.Errorf(\"unexpected result\") } }".to_owned(), vec![(1, "test-theater-empty"), (3, "test-theater-no-assert")]),
|
|
1973
|
+
] {
|
|
1974
|
+
let ext = extension(rel);
|
|
1975
|
+
let tokens = source_tokens(&text, ext);
|
|
1976
|
+
let added = (1..=text.lines().count()).collect();
|
|
1977
|
+
let mut findings = Vec::new();
|
|
1978
|
+
scan_brace_tests(rel, ext, &tokens, &added, &mut findings);
|
|
1979
|
+
assert_eq!(findings.iter().map(|f| (f.line, f.rule)).collect::<Vec<_>>(), expected, "{rel}");
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
#[test]
|
|
1984
|
+
fn slop_blocks_untested_code_and_scans_ignored_scratch_reward_hacks() {
|
|
1985
|
+
let root = crate::tests::TestRepo::new("slop");
|
|
1986
|
+
let root = &root.0;
|
|
1987
|
+
git_ok(root, &["init", "-q", "-b", "main"]);
|
|
1988
|
+
fs::write(root.join(".gitignore"), ".scratch/\n").unwrap();
|
|
1989
|
+
fs::write(root.join("test_app.py"), "def test_contract():\n assert produced() == 'expected'\n").unwrap();
|
|
1990
|
+
git_ok(root, &["add", "."]);
|
|
1991
|
+
git_ok(root, &["-c", "user.name=Gate Test", "-c", "user.email=test@example.com", "commit", "-qm", "base"]);
|
|
1992
|
+
fs::write(root.join("app.py"), (0..30).map(|i| format!("value_{i} = {i}\n")).collect::<String>()).unwrap();
|
|
1993
|
+
let mut args = vec!["--root".into(), root.to_string_lossy().into_owned(), "--no-linters".into()];
|
|
1994
|
+
assert_eq!(run(&args), ExitCode::from(1));
|
|
1995
|
+
args.push("--allow-untested".into());
|
|
1996
|
+
assert_eq!(run(&args), ExitCode::SUCCESS);
|
|
1997
|
+
fs::create_dir(root.join(".scratch")).unwrap();
|
|
1998
|
+
fs::write(root.join(".scratch/score.ps1"), "npx playwright test --update-snapshots=all\n").unwrap();
|
|
1999
|
+
assert_eq!(run(&args), ExitCode::from(1));
|
|
2000
|
+
let mut findings = Vec::new();
|
|
2001
|
+
scan_scratch_reward(root, &mut findings);
|
|
2002
|
+
assert!(findings.iter().any(|f| f.rule == "reward-hack-snapshot-overwrite" && f.file == ".scratch/score.ps1"));
|
|
2003
|
+
}
|
|
2004
|
+
}
|