deepmodebot 0.0.0-stage → 0.9.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/.claude-plugin/marketplace.json +26 -0
- package/.omp-plugin/marketplace.json +26 -0
- package/LICENSE +24 -0
- package/README.md +377 -2
- package/bin/deepmodebot.mjs +229 -0
- package/lib/autoupdate.mjs +47 -0
- package/lib/clients.mjs +139 -0
- package/lib/run.mjs +32 -0
- package/lib/state.mjs +52 -0
- package/lib/tree.mjs +48 -0
- package/package.json +44 -4
- package/plugins/deepmodebot/.antigravity-plugin/plugin.json +35 -0
- package/plugins/deepmodebot/.antigravity-plugin/skills/deep/SKILL.md +13 -0
- package/plugins/deepmodebot/.antigravity-plugin/skills/land-pr/SKILL.md +23 -0
- package/plugins/deepmodebot/.antigravity-plugin/skills/pr-thread/SKILL.md +17 -0
- package/plugins/deepmodebot/.antigravity-plugin/skills/review-pr/SKILL.md +16 -0
- package/plugins/deepmodebot/.antigravity-plugin/skills/tournament/SKILL.md +14 -0
- package/plugins/deepmodebot/.claude-plugin/plugin.json +27 -0
- package/plugins/deepmodebot/agents/reviewer/agent.md +33 -0
- package/plugins/deepmodebot/agents/scout/agent.md +34 -0
- package/plugins/deepmodebot/agents/security-reviewer/agent.md +30 -0
- package/plugins/deepmodebot/assets/logo.svg +8 -0
- package/plugins/deepmodebot/commands/contribute.md +8 -0
- package/plugins/deepmodebot/commands/deep.md +11 -0
- package/plugins/deepmodebot/commands/land-pr.md +12 -0
- package/plugins/deepmodebot/commands/pr-thread.md +14 -0
- package/plugins/deepmodebot/commands/project-brief.md +8 -0
- package/plugins/deepmodebot/commands/review-pr.md +10 -0
- package/plugins/deepmodebot/commands/tournament.md +12 -0
- package/plugins/deepmodebot/hooks/hooks.json +26 -0
- package/plugins/deepmodebot/hooks.json +24 -0
- package/plugins/deepmodebot/mcp_config.json +11 -0
- package/plugins/deepmodebot/scripts/antigravity-guard.mjs +413 -0
- package/plugins/deepmodebot/scripts/omp-mcp-server.mjs +1091 -0
- package/plugins/deepmodebot/skills/agent-harnesses/SKILL.md +57 -0
- package/plugins/deepmodebot/skills/agent-harnesses/assets/sdks/bun.lock +391 -0
- package/plugins/deepmodebot/skills/agent-harnesses/assets/sdks/check.ts +53 -0
- package/plugins/deepmodebot/skills/agent-harnesses/assets/sdks/check_antigravity.py +38 -0
- package/plugins/deepmodebot/skills/agent-harnesses/assets/sdks/check_claude.mjs +11 -0
- package/plugins/deepmodebot/skills/agent-harnesses/assets/sdks/package.json +11 -0
- package/plugins/deepmodebot/skills/agent-harnesses/assets/sdks/requirements.txt +1 -0
- package/plugins/deepmodebot/skills/agent-harnesses/references/ai-native-tooling.md +190 -0
- package/plugins/deepmodebot/skills/agent-harnesses/references/ai-sdk-selection.md +50 -0
- package/plugins/deepmodebot/skills/agent-harnesses/references/antigravity.md +108 -0
- package/plugins/deepmodebot/skills/agent-harnesses/references/claude-code.md +166 -0
- package/plugins/deepmodebot/skills/agent-harnesses/references/codex.md +151 -0
- package/plugins/deepmodebot/skills/agent-harnesses/references/delegation-efficiency.md +230 -0
- package/plugins/deepmodebot/skills/agent-harnesses/references/langchain-ecosystem.md +124 -0
- package/plugins/deepmodebot/skills/agent-harnesses/references/omp.md +183 -0
- package/plugins/deepmodebot/skills/agent-harnesses/references/protocols.md +172 -0
- package/plugins/deepmodebot/skills/agent-harnesses/references/sdks.md +228 -0
- package/plugins/deepmodebot/skills/agent-harnesses/references/self-authoring.md +171 -0
- package/plugins/deepmodebot/skills/cloud-devsecops/SKILL.md +24 -0
- package/plugins/deepmodebot/skills/cloud-devsecops/references/aws.md +264 -0
- package/plugins/deepmodebot/skills/cloud-devsecops/references/azure.md +261 -0
- package/plugins/deepmodebot/skills/cloud-devsecops/references/containers.md +96 -0
- package/plugins/deepmodebot/skills/cloud-devsecops/references/devops-tools.md +297 -0
- package/plugins/deepmodebot/skills/cloud-devsecops/references/devsecops-pipeline.md +258 -0
- package/plugins/deepmodebot/skills/cloud-devsecops/references/gcp.md +258 -0
- package/plugins/deepmodebot/skills/cloud-devsecops/references/kubernetes.md +74 -0
- package/plugins/deepmodebot/skills/cloud-devsecops/references/local-emulators.md +265 -0
- package/plugins/deepmodebot/skills/contribute/SKILL.md +134 -0
- package/plugins/deepmodebot/skills/create-verification-skill/LICENSE +21 -0
- package/plugins/deepmodebot/skills/create-verification-skill/SKILL.md +101 -0
- package/plugins/deepmodebot/skills/create-verification-skill/references/feature-map-example/README.md +47 -0
- package/plugins/deepmodebot/skills/create-verification-skill/references/feature-map-example/create-note.md +39 -0
- package/plugins/deepmodebot/skills/create-verification-skill/references/feature-map-example/search.md +45 -0
- package/plugins/deepmodebot/skills/deep-stack/SKILL.md +53 -0
- package/plugins/deepmodebot/skills/deep-stack/references/AGENTS.template.md +52 -0
- package/plugins/deepmodebot/skills/deep-stack/references/agentic-workflow.md +114 -0
- package/plugins/deepmodebot/skills/deep-stack/references/any-app-stack.md +51 -0
- package/plugins/deepmodebot/skills/deep-stack/references/design-workflow.md +101 -0
- package/plugins/deepmodebot/skills/deep-stack/references/isolate.md +23 -0
- package/plugins/deepmodebot/skills/deep-stack/references/philosophy.md +306 -0
- package/plugins/deepmodebot/skills/deep-stack/references/prove.md +31 -0
- package/plugins/deepmodebot/skills/deep-stack/references/stack.md +119 -0
- package/plugins/deepmodebot/skills/deep-stack/references/structure.md +22 -0
- package/plugins/deepmodebot/skills/deep-stack/references/unslop/LICENSE +21 -0
- package/plugins/deepmodebot/skills/deep-stack/references/unslop/unslop.md +80 -0
- package/plugins/deepmodebot/skills/deepmodebot/LICENSE +23 -0
- package/plugins/deepmodebot/skills/deepmodebot/SKILL.md +198 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/agents-md/agents_md.py +207 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/agents-md/test_agents_md.py +146 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/architecture-review/report-template.html +92 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/contain/claude-guard.sh +42 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/contain/claude_guard.py +135 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/contain/omp-contain-link.ts +12 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/contain/omp-contain.ts +115 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/contain/test_antigravity_guard.py +483 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/contain/test_audit_regressions.py +139 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/contain/test_contain.py +301 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/contain/test_omp_mcp.py +602 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/design.py +242 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/evidence.py +293 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/record.py +387 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/review.py +339 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/test_design.py +69 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/test_evidence.py +160 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/test_record.py +180 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/e2e/test_review.py +265 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/git-guardrails/git-guard-patterns.txt +44 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/git-guardrails/git-guard.sh +132 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/git-guardrails/git-guard.ts +122 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/git-guardrails/test_git_guard.py +192 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/bot.py +3037 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/brand.json +11 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/brand.py +51 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/ghapp.py +361 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/install.py +274 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/local_updates.py +576 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/review_context.py +204 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/test_bot.py +2182 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/test_brand.py +19 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/test_local_updates.py +691 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/test_review_context.py +127 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/test_workspace_cleanup.py +496 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/github-app/workspace_cleanup.py +351 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/loop/loop.py +2394 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/loop/plan.py +583 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/loop/test_loop.py +1426 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/loop/test_plan.py +320 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/loop/test_windows_job.py +326 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/loop/windows_job.py +244 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/perf-audit/bench_harness.py +165 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/perf-audit/perf_audit.py +240 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/perf-audit/test_bench_harness.py +55 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/perf-audit/test_perf_audit.py +53 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/pr-agent/diff_coverage.py +350 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/pr-agent/pr_agent_local.py +370 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/pr-agent/test_diff_coverage.py +94 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/pr-conversation/arena.html +425 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/pr-conversation/arena.py +579 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/pr-conversation/arena_tui.py +839 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/pr-conversation/font8x8_basic.hex +1 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/pr-conversation/show_thread.py +329 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/pr-conversation/test_arena.py +610 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/repo-references.json +637 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/scrape/test_yt_enrich.py +250 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/scrape/yt_enrich.py +1820 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/scrape/yt_meta.py +156 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/scrape/yt_transcript_relay.js +54 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/security-audit/audit-pr.sh +122 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/security-audit/gate.cjs +155 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/security-audit/prompt.md +13 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/tournament/test_tournament.py +654 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/tournament/tournament.py +1285 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/wizard/wizard.sh +234 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/workspace-map/test_workspace_map.py +879 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/workspace-map/workspace_map.py +2436 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/README.md +61 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/catalog.md +105 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/contain.md +39 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/factory-landscape.md +147 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/flows.md +50 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/authoring-a-skill.md +37 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/babysit.md +77 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/bug-fix.md +34 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/end-to-end.md +50 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/eval.md +39 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/feature.md +60 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/handoff.md +52 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/hillclimb.md +46 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/investigation.md +20 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/opening-a-pr.md +97 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/pause-safely.md +30 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/perf-issue.md +31 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/phased-build.md +146 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/prototype.md +31 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/refactoring.md +60 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/reference-rebuild.md +45 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/run-a-goal.md +143 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/runtime-forensics.md +22 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/self-authoring.md +130 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/session-pickup.md +33 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/setup.md +105 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/shipping.md +52 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/spec.md +67 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/tickets.md +56 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/trace-forensics.md +24 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/triage.md +102 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/visual-parity.md +19 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/wayfinder.md +44 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/work-a-queue.md +189 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/worktree-cleanup.md +35 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/attack-the-premise.md +7 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/boundary-discipline.md +8 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/build-the-lever.md +8 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/encode-lessons-in-structure.md +6 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/exhaust-the-design-space.md +4 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/experience-first.md +7 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/explain-the-number.md +9 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/fix-root-causes.md +6 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/foundational-thinking.md +9 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/guard-the-context-window.md +7 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/laziness-protocol.md +6 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/make-operations-idempotent.md +7 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/migrate-callers-then-delete-legacy-apis.md +5 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/minimize-reader-load.md +7 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/model-the-domain.md +7 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/never-block-on-the-human.md +7 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/outcome-oriented-execution.md +6 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/prove-it-works.md +8 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/redesign-from-first-principles.md +7 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/separate-before-serializing-shared-state.md +6 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/sequence-verifiable-units.md +7 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/subtract-before-you-add.md +6 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/test-behavior-not-implementation.md +7 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/type-system-discipline.md +6 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/rust-migration-case-studies.md +26 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/startup-ideas.md +21 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/agent-collaboration.md +82 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/architect.md +32 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/architecture-review.md +43 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/arena.md +20 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/benchmark-checklist.md +31 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/blast-radius.md +19 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/correct.md +20 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/course.md +47 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/coworkers.md +70 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/domain-model.md +69 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/figure-it-out.md +25 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/git-guardrails.md +44 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/github-app.md +160 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/goal-review.md +156 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/grill.md +27 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/how.md +23 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/in-your-own-words.md +12 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/inner-loop.md +39 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/interrogate.md +16 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/issue-conversation.md +52 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/no-comments.md +29 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/open-design-evidence.md +65 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/panel.md +34 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/pr-agent.md +39 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/pr-conversation.md +135 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/pr-review.md +138 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/pre-commit.md +31 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/prior-art.md +44 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/questionnaire.md +46 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/re-explain.md +23 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/recall.md +19 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/reflect.md +20 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/research.md +99 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/retro.md +30 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/scrape.md +32 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/security-audit.md +40 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/sharpen.md +15 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/show-me-your-work.md +19 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/sme-review.md +49 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/swarm.md +14 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/tdd.md +55 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/teach.md +20 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/technical-writing.md +22 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/tool-routing.md +85 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/tournament.md +44 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/tracker.md +78 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/unslop.md +15 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/visual-e2e.md +78 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/why.md +31 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/wizard.md +25 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/workspace-map.md +35 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/writing-for-agents.md +66 -0
- package/plugins/deepmodebot/skills/deepmodebot/scripts/check_skill.py +93 -0
- package/plugins/deepmodebot/skills/deepmodebot/scripts/trending.py +598 -0
- package/plugins/deepmodebot/skills/domain-rules/SKILL.md +131 -0
- package/plugins/deepmodebot/skills/domain-rules/references/agent-engineering.md +105 -0
- package/plugins/deepmodebot/skills/domain-rules/references/ai-concepts.md +103 -0
- package/plugins/deepmodebot/skills/domain-rules/references/aws-networking.md +121 -0
- package/plugins/deepmodebot/skills/domain-rules/references/backend-system-design.md +162 -0
- package/plugins/deepmodebot/skills/domain-rules/references/data-structures-and-cache-optimization.md +48 -0
- package/plugins/deepmodebot/skills/domain-rules/references/devops-and-fundamentals.md +137 -0
- package/plugins/deepmodebot/skills/domain-rules/references/engineering-practice.md +100 -0
- package/plugins/deepmodebot/skills/domain-rules/references/high-scale-server-optimization.md +181 -0
- package/plugins/deepmodebot/skills/domain-rules/references/language-ecosystems.md +56 -0
- package/plugins/deepmodebot/skills/frontend-ui/SKILL.md +146 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/patterns/live-demos.md +38 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/patterns/mobbin-shipped-apps.md +28 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/patterns/motion-clips.md +269 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/patterns/motion-graphics.md +62 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/patterns/pinterest-animations.md +217 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/patterns/pinterest-patterns.md +101 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/01-workflow.md +25 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/02-review-rubric.md +21 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/03-ai-tells.md +46 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/04-components.md +21 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/04a-agent-ui.md +153 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/05-motion.md +106 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/05a-motion-graphics.md +121 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/06-typography-layout.md +48 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/06a-color.md +26 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/07-copy.md +11 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/08-quality-floor.md +63 -0
- package/plugins/deepmodebot/skills/frontend-ui/references/playbook/09-steering-agents.md +13 -0
- package/plugins/deepmodebot/skills/maintain-verification-skill/LICENSE +21 -0
- package/plugins/deepmodebot/skills/maintain-verification-skill/SKILL.md +47 -0
- package/plugins/deepmodebot/skills/project-brief/SKILL.md +100 -0
- package/plugins/deepmodebot/skills/project-brief/assets/CONTRIBUTING.template.md +124 -0
- package/plugins/deepmodebot/skills/project-brief/assets/ISSUE_TEMPLATE/task.yml +61 -0
- package/plugins/deepmodebot/skills/project-brief/assets/PROJECT_BRIEF.template.md +98 -0
- package/plugins/deepmodebot/skills/project-brief/assets/PULL_REQUEST_TEMPLATE.md +35 -0
- package/plugins/deepmodebot/skills/project-brief/assets/pr-overlap.py +643 -0
- package/plugins/deepmodebot/skills/project-brief/assets/sync-roadmap.py +314 -0
- package/plugins/deepmodebot/skills/secrets-and-auth/SKILL.md +60 -0
- package/plugins/deepmodebot/skills/secrets-and-auth/references/agent-authentication.md +198 -0
- package/plugins/deepmodebot/skills/secrets-and-auth/references/leak-prevention.md +206 -0
- package/plugins/deepmodebot/skills/secrets-and-auth/references/logins-and-passwords.md +165 -0
- package/plugins/deepmodebot/skills/secrets-and-auth/references/secrets-and-env.md +182 -0
- package/plugins/deepmodebot/skills/software-architecture/SKILL.md +47 -0
- package/plugins/deepmodebot/skills/software-architecture/references/backend-infrastructure.md +273 -0
- package/plugins/deepmodebot/skills/software-architecture/references/databases.md +277 -0
- package/plugins/deepmodebot/skills/software-architecture/references/monorepos.md +210 -0
- package/plugins/deepmodebot/skills/software-architecture/references/ontology.md +287 -0
|
@@ -0,0 +1,1426 @@
|
|
|
1
|
+
"""Tests for loop.py, driven through a fake `omp` on PATH.
|
|
2
|
+
|
|
3
|
+
Run: python -m unittest discover -s <this folder> -p "test_*.py"
|
|
4
|
+
Needs git and bash (Git for Windows ships both).
|
|
5
|
+
"""
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import shutil
|
|
9
|
+
import stat
|
|
10
|
+
import subprocess
|
|
11
|
+
import sys
|
|
12
|
+
import tempfile
|
|
13
|
+
import unittest
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
LOOP = Path(__file__).resolve().parent / "loop.py"
|
|
17
|
+
|
|
18
|
+
FAKE = """
|
|
19
|
+
import json, os, re, subprocess, sys, time
|
|
20
|
+
action = os.environ.get("FAKE_ACTION", "noop")
|
|
21
|
+
record = os.environ.get("FAKE_RECORD")
|
|
22
|
+
prompt = sys.stdin.read()
|
|
23
|
+
if record:
|
|
24
|
+
with open(record, "w", encoding="utf-8") as handle:
|
|
25
|
+
json.dump({"env": dict(os.environ), "argv": sys.argv[1:], "cwd": os.getcwd(), "stdin": prompt}, handle)
|
|
26
|
+
if action == "hang":
|
|
27
|
+
time.sleep(120)
|
|
28
|
+
elif action == "forge-cache":
|
|
29
|
+
os.makedirs("tests/__pycache__", exist_ok=True)
|
|
30
|
+
open("tests/__pycache__/test_x.cpython-313.pyc", "w").close()
|
|
31
|
+
if action == "done":
|
|
32
|
+
open("ok.txt", "w").close()
|
|
33
|
+
elif action == "progress":
|
|
34
|
+
with open("progress.txt", "a") as handle:
|
|
35
|
+
handle.write("x")
|
|
36
|
+
elif action == "tamper-goal":
|
|
37
|
+
text = open("goals/g.md", encoding="utf-8").read()
|
|
38
|
+
open("goals/g.md", "w", encoding="utf-8").write(text.replace("max_iterations: ", "max_iterations: 9"))
|
|
39
|
+
elif action == "tamper-protect":
|
|
40
|
+
with open("check.sh", "a") as handle:
|
|
41
|
+
handle.write("exit 0\\n")
|
|
42
|
+
elif action == "create-conftest":
|
|
43
|
+
open("conftest.py", "w").close()
|
|
44
|
+
elif action == "diagnostic-repair":
|
|
45
|
+
log_path = next(line.removeprefix("Complete check output: ") for line in prompt.splitlines()
|
|
46
|
+
if line.startswith("Complete check output: "))
|
|
47
|
+
diagnostic = open(log_path, encoding="utf-8").read()
|
|
48
|
+
missing = re.search(r"missing output artifact: ([a-z.-]+)", diagnostic)
|
|
49
|
+
if missing:
|
|
50
|
+
open(missing.group(1), "w").close()
|
|
51
|
+
elif action in ("revise-plan", "adapt"):
|
|
52
|
+
path = "goals/g.md"
|
|
53
|
+
text = open(path, encoding="utf-8").read()
|
|
54
|
+
if action == "adapt" and "Next action: create the missing output." in prompt and "missing output artifact" in prompt:
|
|
55
|
+
open("ok.txt", "w").close()
|
|
56
|
+
else:
|
|
57
|
+
with open(path, "a", encoding="utf-8") as handle:
|
|
58
|
+
handle.write("\\nObserved missing output. Next action: create the missing output.\\n")
|
|
59
|
+
elif action == "fast-then-check":
|
|
60
|
+
if not os.path.exists("step1.txt"):
|
|
61
|
+
open("step1.txt", "w").close()
|
|
62
|
+
elif "[fast_check failed]" in prompt and not os.path.exists("fast_ok.txt"):
|
|
63
|
+
open("fast_ok.txt", "w").close()
|
|
64
|
+
elif os.path.exists("fast_ok.txt"):
|
|
65
|
+
open("ok.txt", "w").close()
|
|
66
|
+
elif action == "slop-then-clean":
|
|
67
|
+
with open("legacy.py", "r+", encoding="utf-8") as handle:
|
|
68
|
+
old = handle.read()
|
|
69
|
+
handle.seek(0)
|
|
70
|
+
handle.write("HEADER = '# type: ignore in string literal'\\n" + old)
|
|
71
|
+
if "[slop_guard failed]" in prompt:
|
|
72
|
+
open("app.py", "w", encoding="utf-8").write(
|
|
73
|
+
"def parse_num(raw: str) -> int:\\n return int(raw.strip())\\n"
|
|
74
|
+
)
|
|
75
|
+
open("client.ts", "w", encoding="utf-8").write(
|
|
76
|
+
"const note = '@ts-ignore inside string literal';\\nexport function load(): string { return note; }\\n"
|
|
77
|
+
)
|
|
78
|
+
open("ok.txt", "w").close()
|
|
79
|
+
else:
|
|
80
|
+
open("app.py", "w", encoding="utf-8").write(
|
|
81
|
+
"def parse_num(raw: str) -> int:\\n"
|
|
82
|
+
" try:\\n return raw # type: ignore\\n"
|
|
83
|
+
" except Exception:\\n pass\\n return 0\\n"
|
|
84
|
+
)
|
|
85
|
+
open("client.ts", "w", encoding="utf-8").write(
|
|
86
|
+
"// @ts-ignore\\nexport function load() { try { work(); } catch (e) {} }\\n"
|
|
87
|
+
)
|
|
88
|
+
open("ok.txt", "w").close()
|
|
89
|
+
elif action == "weaken-ruff-toml":
|
|
90
|
+
open("ruff.toml", "w", encoding="utf-8").write("line-length = 999\\n")
|
|
91
|
+
elif action == "weaken-pyproject-ruff":
|
|
92
|
+
text = open("pyproject.toml", encoding="utf-8").read()
|
|
93
|
+
open("pyproject.toml", "w", encoding="utf-8").write(text.replace('select = ["E", "F"]', 'select = []'))
|
|
94
|
+
elif action == "edit-pyproject-deps":
|
|
95
|
+
text = open("pyproject.toml", encoding="utf-8").read()
|
|
96
|
+
open("pyproject.toml", "w", encoding="utf-8").write(text.replace("dependencies = []", 'dependencies = ["httpx"]'))
|
|
97
|
+
open("ok.txt", "w").close()
|
|
98
|
+
elif action == "revert-pilot":
|
|
99
|
+
if "Plan after revert: create ok.txt cleanly." in prompt:
|
|
100
|
+
open("ok.txt", "w").close()
|
|
101
|
+
else:
|
|
102
|
+
open("tracked.txt", "w", encoding="utf-8").write("broken edit\\n")
|
|
103
|
+
open("dead_end.py", "w", encoding="utf-8").write("BROKEN = True\\n")
|
|
104
|
+
with open("goals/g.md", "a", encoding="utf-8") as handle:
|
|
105
|
+
handle.write("\\nPlan after revert: create ok.txt cleanly.\\n")
|
|
106
|
+
elif action == "repeat-broken-edit":
|
|
107
|
+
open("tracked.txt", "w", encoding="utf-8").write("same broken edit\\n")
|
|
108
|
+
elif action == "stubs-then-real":
|
|
109
|
+
open("base.py", "w", encoding="utf-8").write(
|
|
110
|
+
"from abc import ABC, abstractmethod\\n"
|
|
111
|
+
"class Store(ABC):\\n"
|
|
112
|
+
" @abstractmethod\\n"
|
|
113
|
+
" def save(self, value: str) -> None:\\n"
|
|
114
|
+
" raise NotImplementedError\\n"
|
|
115
|
+
)
|
|
116
|
+
if "[slop_guard failed]" in prompt:
|
|
117
|
+
open("service.py", "w", encoding="utf-8").write(
|
|
118
|
+
"def export_csv(rows: list[str]) -> str:\\n return '\\n'.join(rows)\\n"
|
|
119
|
+
)
|
|
120
|
+
open("ui.ts", "w", encoding="utf-8").write(
|
|
121
|
+
"const msg = 'not implemented inside string literal';\\nexport function render(): string { return msg; }\\n"
|
|
122
|
+
)
|
|
123
|
+
open("ok.txt", "w").close()
|
|
124
|
+
else:
|
|
125
|
+
open("service.py", "w", encoding="utf-8").write(
|
|
126
|
+
"# TODO: wire CSV export\\n"
|
|
127
|
+
"def export_csv(rows: list[str]) -> str:\\n"
|
|
128
|
+
" raise NotImplementedError('stub')\\n"
|
|
129
|
+
)
|
|
130
|
+
open("ui.ts", "w", encoding="utf-8").write(
|
|
131
|
+
"// FIXME: finish view\\nexport function render(): string { throw new Error('not implemented'); }\\n"
|
|
132
|
+
)
|
|
133
|
+
open("ok.txt", "w").close()
|
|
134
|
+
elif action == "tamper-manifest":
|
|
135
|
+
open("goals/manifest.json", "w", encoding="utf-8").write('{"product": "x", "slices": []}\\n')
|
|
136
|
+
elif action == "manifest-stepwise":
|
|
137
|
+
if not os.path.exists("s1.txt"):
|
|
138
|
+
open("s1.txt", "w").close()
|
|
139
|
+
elif "[manifest 1/3 slices green]" in prompt and not os.path.exists("s2.txt"):
|
|
140
|
+
open("s2.txt", "w").close()
|
|
141
|
+
elif "[manifest 2/3 slices green]" in prompt and not os.path.exists("s3.txt"):
|
|
142
|
+
open("s3.txt", "w").close()
|
|
143
|
+
open("ok.txt", "w").close()
|
|
144
|
+
elif action == "stage-and-commit":
|
|
145
|
+
open("tracked.txt", "w", encoding="utf-8").write("committed broken edit\\n")
|
|
146
|
+
subprocess.run(["git", "-c", "user.name=t", "-c", "user.email=t@example.com", "commit", "-qam", "agent"], check=True)
|
|
147
|
+
open("staged_new.py", "w", encoding="utf-8").write("X = 1\\n")
|
|
148
|
+
subprocess.run(["git", "add", "staged_new.py"], check=True)
|
|
149
|
+
elif action == "link-escape":
|
|
150
|
+
if os.name == "nt":
|
|
151
|
+
subprocess.run(["cmd", "/c", "mklink", "/J", "escape", os.environ["FAKE_OUTSIDE"]], check=True, capture_output=True)
|
|
152
|
+
else:
|
|
153
|
+
os.symlink(os.environ["FAKE_OUTSIDE"], "escape")
|
|
154
|
+
elif action == "create-nested-conftest":
|
|
155
|
+
os.makedirs("src", exist_ok=True)
|
|
156
|
+
open("src/conftest.py", "w", encoding="utf-8").write("collect_ignore_glob = ['*']\\n")
|
|
157
|
+
elif action == "weaken-package-lint":
|
|
158
|
+
data = json.load(open("package.json", encoding="utf-8"))
|
|
159
|
+
data["scripts"]["lint"] = "true"
|
|
160
|
+
json.dump(data, open("package.json", "w", encoding="utf-8"))
|
|
161
|
+
elif action == "rate-limit-then-done":
|
|
162
|
+
marker = "rate_limit_attempts.txt"
|
|
163
|
+
count = int(open(marker).read()) if os.path.exists(marker) else 0
|
|
164
|
+
with open(marker, "w") as handle:
|
|
165
|
+
handle.write(str(count + 1))
|
|
166
|
+
if count == 0:
|
|
167
|
+
print("HTTP 429 rate limit exceeded; Retry-After: 0.01", file=sys.stderr)
|
|
168
|
+
sys.exit(1)
|
|
169
|
+
open("ok.txt", "w").close()
|
|
170
|
+
elif action == "quota-exhausted":
|
|
171
|
+
print("Error: weekly limit reached for current plan", file=sys.stderr)
|
|
172
|
+
sys.exit(1)
|
|
173
|
+
elif action == "escalate-on-strong-model":
|
|
174
|
+
if "strong-model" in sys.argv:
|
|
175
|
+
open("ok.txt", "w").close()
|
|
176
|
+
elif action == "quota-then-fallback":
|
|
177
|
+
if "fallback-model" in sys.argv:
|
|
178
|
+
open("ok.txt", "w").close()
|
|
179
|
+
else:
|
|
180
|
+
print("Error: weekly limit reached for current plan", file=sys.stderr)
|
|
181
|
+
sys.exit(1)
|
|
182
|
+
elif action == "rate-limit-then-fallback":
|
|
183
|
+
if "fallback-model" in sys.argv:
|
|
184
|
+
open("ok.txt", "w").close()
|
|
185
|
+
else:
|
|
186
|
+
print("HTTP 429 rate limit exceeded; Retry-After: 0.01", file=sys.stderr)
|
|
187
|
+
sys.exit(1)
|
|
188
|
+
elif action == "sprint1-done":
|
|
189
|
+
open("s1.txt", "w").close()
|
|
190
|
+
open("ok.txt", "w").close()
|
|
191
|
+
elif action == "sprint2-done":
|
|
192
|
+
open("s2.txt", "w").close()
|
|
193
|
+
open("ok.txt", "w").close()
|
|
194
|
+
if action == "fail":
|
|
195
|
+
sys.exit(3)
|
|
196
|
+
"""
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def git(cwd, *args):
|
|
200
|
+
subprocess.run(["git", "-C", str(cwd), "-c", "user.name=t", "-c", "user.email=t@example.com", *args],
|
|
201
|
+
check=True, capture_output=True)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def remove_tree(path):
|
|
205
|
+
"""git marks its object files read-only, which stops shutil.rmtree on Windows and leaves the folder behind."""
|
|
206
|
+
for folder, _, files in os.walk(path):
|
|
207
|
+
for name in files:
|
|
208
|
+
os.chmod(os.path.join(folder, name), stat.S_IREAD | stat.S_IWRITE)
|
|
209
|
+
shutil.rmtree(path, ignore_errors=True)
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
class LoopCase(unittest.TestCase):
|
|
213
|
+
def setUp(self):
|
|
214
|
+
self.tmp = Path(tempfile.mkdtemp(prefix="loop-test-")).resolve()
|
|
215
|
+
self.addCleanup(remove_tree, self.tmp)
|
|
216
|
+
self.repo = self.tmp / "proj"
|
|
217
|
+
(self.repo / "goals").mkdir(parents=True)
|
|
218
|
+
(self.repo / "check.sh").write_text("test -f ok.txt\n", encoding="utf-8", newline="\n")
|
|
219
|
+
git(self.repo, "init", "-q", "-b", "main")
|
|
220
|
+
git(self.repo, "add", ".")
|
|
221
|
+
git(self.repo, "commit", "-q", "-m", "init")
|
|
222
|
+
bin_dir = self.tmp / "bin"
|
|
223
|
+
bin_dir.mkdir()
|
|
224
|
+
(bin_dir / "fake.py").write_text(FAKE, encoding="utf-8")
|
|
225
|
+
if os.name == "nt":
|
|
226
|
+
(bin_dir / "omp.cmd").write_text(f'@"{sys.executable}" "%~dp0fake.py" %*\r\n', encoding="utf-8")
|
|
227
|
+
else:
|
|
228
|
+
wrapper = bin_dir / "omp"
|
|
229
|
+
wrapper.write_text(f'#!/bin/sh\nexec "{sys.executable}" "$(dirname "$0")/fake.py" "$@"\n', encoding="utf-8")
|
|
230
|
+
wrapper.chmod(wrapper.stat().st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
|
|
231
|
+
self.path = str(bin_dir) + os.pathsep + os.environ["PATH"]
|
|
232
|
+
|
|
233
|
+
def goal(self, **fields):
|
|
234
|
+
merged = {"goal": "ok.txt exists", "check": "sh ./check.sh", "protect": "check.sh", "max_iterations": 3, "max_cost_usd": 1, **fields}
|
|
235
|
+
body = "".join(f"{key}: {value}\n" for key, value in merged.items() if value is not None)
|
|
236
|
+
(self.repo / "goals" / "g.md").write_text(f"---\n{body}---\nCreate ok.txt.\n", encoding="utf-8", newline="\n")
|
|
237
|
+
|
|
238
|
+
def loop(self, *args, action="noop", **env):
|
|
239
|
+
full_env = {**os.environ, "PATH": self.path, "FAKE_ACTION": action, **env}
|
|
240
|
+
return subprocess.run([sys.executable, str(LOOP), *args], cwd=self.repo, env=full_env, capture_output=True, text=True)
|
|
241
|
+
|
|
242
|
+
def trail_rows(self):
|
|
243
|
+
trail = self.repo / ".scratch" / "goals" / "g" / "trail.tsv"
|
|
244
|
+
return trail.read_text(encoding="utf-8").strip().splitlines()[1:]
|
|
245
|
+
|
|
246
|
+
def latest_summary(self):
|
|
247
|
+
logs = self.repo / ".scratch" / "goals" / "g"
|
|
248
|
+
latest = logs / "latest-summary.json"
|
|
249
|
+
data = json.loads(latest.read_text(encoding="utf-8"))
|
|
250
|
+
run_summary = logs / f"{data['run_id']}-summary.json"
|
|
251
|
+
self.assertTrue(run_summary.is_file())
|
|
252
|
+
self.assertEqual(json.loads(run_summary.read_text(encoding="utf-8")), data)
|
|
253
|
+
return data
|
|
254
|
+
|
|
255
|
+
def test_stops_with_0_when_the_check_passes(self):
|
|
256
|
+
self.goal()
|
|
257
|
+
run = self.loop("run", "goals/g.md", action="done")
|
|
258
|
+
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
|
|
259
|
+
self.assertIn("goal met", run.stdout)
|
|
260
|
+
self.assertEqual(len(self.trail_rows()), 1)
|
|
261
|
+
|
|
262
|
+
def test_nothing_runs_when_the_check_already_passes(self):
|
|
263
|
+
self.goal()
|
|
264
|
+
(self.repo / "ok.txt").write_text("", encoding="utf-8")
|
|
265
|
+
run = self.loop("run", "goals/g.md", action="fail")
|
|
266
|
+
self.assertEqual(run.returncode, 0)
|
|
267
|
+
self.assertIn("already passes", run.stdout)
|
|
268
|
+
summary = self.latest_summary()
|
|
269
|
+
self.assertEqual(summary["exit_code"], 0)
|
|
270
|
+
self.assertEqual(summary["exit_reason"], "already_passed")
|
|
271
|
+
self.assertEqual(summary["iterations_run"], 0)
|
|
272
|
+
|
|
273
|
+
def test_already_passing_sprint_run_writes_latest_summary_with_scope(self):
|
|
274
|
+
manifest = {
|
|
275
|
+
"product": "Already Passing Sprint",
|
|
276
|
+
"slices": [
|
|
277
|
+
{"id": "s1", "title": "Core", "sprint": 1, "check": "test -f s1.txt"},
|
|
278
|
+
{"id": "s2", "title": "Later", "sprint": 2, "check": "test -f s2.txt"},
|
|
279
|
+
],
|
|
280
|
+
}
|
|
281
|
+
(self.repo / "goals" / "manifest.json").write_text(json.dumps(manifest, indent=2), encoding="utf-8")
|
|
282
|
+
(self.repo / "s1.txt").write_text("", encoding="utf-8")
|
|
283
|
+
(self.repo / "ok.txt").write_text("", encoding="utf-8")
|
|
284
|
+
self.goal(manifest="goals/manifest.json", active_sprint=1)
|
|
285
|
+
run = self.loop("run", "goals/g.md", action="fail")
|
|
286
|
+
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
|
|
287
|
+
self.assertIn("sprint 1 check already passes", run.stdout)
|
|
288
|
+
summary = self.latest_summary()
|
|
289
|
+
self.assertEqual(summary["exit_code"], 0)
|
|
290
|
+
self.assertEqual(summary["exit_reason"], "sprint_already_passed")
|
|
291
|
+
self.assertEqual(summary["iterations_run"], 0)
|
|
292
|
+
self.assertEqual(summary["scope"]["active_sprint"], 1)
|
|
293
|
+
self.assertEqual(summary["scope"]["passed_slices"], 1)
|
|
294
|
+
self.assertEqual(summary["scope"]["deferred_slices"], ["s2"])
|
|
295
|
+
|
|
296
|
+
def test_iteration_cap_exits_2(self):
|
|
297
|
+
self.goal(max_iterations=2, stall_after=9)
|
|
298
|
+
run = self.loop("run", "goals/g.md", action="progress")
|
|
299
|
+
self.assertEqual(run.returncode, 2, run.stdout + run.stderr)
|
|
300
|
+
self.assertEqual(len(self.trail_rows()), 2)
|
|
301
|
+
|
|
302
|
+
def test_no_progress_exits_3_as_stalled(self):
|
|
303
|
+
self.goal(max_iterations=5, stall_after=2)
|
|
304
|
+
run = self.loop("run", "goals/g.md", action="noop")
|
|
305
|
+
self.assertEqual(run.returncode, 3, run.stdout + run.stderr)
|
|
306
|
+
self.assertEqual(len(self.trail_rows()), 2)
|
|
307
|
+
|
|
308
|
+
def test_revised_plan_and_check_feedback_drive_the_next_iteration(self):
|
|
309
|
+
(self.repo / "check.sh").write_text(
|
|
310
|
+
"test -f ok.txt || { echo 'missing output artifact'; exit 1; }\n", encoding="utf-8")
|
|
311
|
+
self.goal()
|
|
312
|
+
run = self.loop("run", "goals/g.md", action="adapt")
|
|
313
|
+
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
|
|
314
|
+
self.assertEqual(len(self.trail_rows()), 2)
|
|
315
|
+
logs = self.repo / ".scratch" / "goals" / "g"
|
|
316
|
+
first = next(logs.glob("*-iteration-1-prompt.txt")).read_text(encoding="utf-8")
|
|
317
|
+
second = next(logs.glob("*-iteration-2-prompt.txt")).read_text(encoding="utf-8")
|
|
318
|
+
self.assertNotIn("Next action: create the missing output.", first)
|
|
319
|
+
self.assertIn("Next action: create the missing output.", second)
|
|
320
|
+
self.assertIn("missing output artifact", second)
|
|
321
|
+
self.assertTrue((self.repo / "ok.txt").exists())
|
|
322
|
+
|
|
323
|
+
def test_complete_check_evidence_survives_bounded_prompt_feedback(self):
|
|
324
|
+
diagnostic = "early failure\n" + "head noise\n" * 250 + "middle evidence\n" + "tail noise\n" * 250 + "final failure\n"
|
|
325
|
+
(self.repo / "check.sh").write_text(
|
|
326
|
+
"cat <<'DIAGNOSTIC'\n" + diagnostic + "DIAGNOSTIC\nexit 1\n", encoding="utf-8", newline="\n")
|
|
327
|
+
self.goal(max_iterations=1)
|
|
328
|
+
record = self.tmp / "seen.json"
|
|
329
|
+
run = self.loop("run", "goals/g.md", FAKE_RECORD=str(record))
|
|
330
|
+
self.assertEqual(run.returncode, 2, run.stdout + run.stderr)
|
|
331
|
+
logs = self.repo / ".scratch" / "goals" / "g"
|
|
332
|
+
input_log = next(logs.glob("*-iteration-1-input-check.log"))
|
|
333
|
+
output_log = next(logs.glob("*-iteration-1-check.log"))
|
|
334
|
+
self.assertEqual(input_log.read_text(encoding="utf-8"), "exit: 1\n" + diagnostic)
|
|
335
|
+
self.assertEqual(output_log.read_text(encoding="utf-8"), "exit: 1\n" + diagnostic)
|
|
336
|
+
prompt = next(logs.glob("*-iteration-1-prompt.txt")).read_text(encoding="utf-8")
|
|
337
|
+
self.assertEqual(prompt, json.loads(record.read_text(encoding="utf-8"))["stdin"])
|
|
338
|
+
feedback = prompt.split("<check-output>\n", 1)[1].split("\n</check-output>", 1)[0]
|
|
339
|
+
head, tail = feedback.split("\n[check output truncated; middle omitted]\n")
|
|
340
|
+
self.assertEqual(head, diagnostic[:2000])
|
|
341
|
+
self.assertEqual(tail, diagnostic[-2000:])
|
|
342
|
+
self.assertNotIn("middle evidence", feedback)
|
|
343
|
+
log_path = next(line.removeprefix("Complete check output: ") for line in prompt.splitlines()
|
|
344
|
+
if line.startswith("Complete check output: "))
|
|
345
|
+
self.assertEqual((self.repo / log_path).resolve(), input_log.resolve())
|
|
346
|
+
|
|
347
|
+
def test_full_diagnostics_direct_repair_despite_noisy_trailing_output(self):
|
|
348
|
+
diagnostic = "startup noise\n" * 250 + "missing output artifact: repaired.txt\n" + "trailing noise\n" * 400
|
|
349
|
+
(self.repo / "check.sh").write_text(
|
|
350
|
+
"test -f repaired.txt && exit 0\ncat <<'DIAGNOSTIC'\n" + diagnostic + "DIAGNOSTIC\nexit 1\n",
|
|
351
|
+
encoding="utf-8", newline="\n")
|
|
352
|
+
self.goal(max_iterations=1)
|
|
353
|
+
run = self.loop("run", "goals/g.md", action="diagnostic-repair")
|
|
354
|
+
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
|
|
355
|
+
self.assertIn("goal met", run.stdout)
|
|
356
|
+
self.assertTrue((self.repo / "repaired.txt").exists())
|
|
357
|
+
self.assertEqual(len(self.trail_rows()), 1)
|
|
358
|
+
prompt = next((self.repo / ".scratch" / "goals" / "g").glob("*-prompt.txt")).read_text(encoding="utf-8")
|
|
359
|
+
self.assertNotIn("missing output artifact: repaired.txt", prompt)
|
|
360
|
+
|
|
361
|
+
def test_plan_only_revisions_do_not_avoid_the_stall_stop(self):
|
|
362
|
+
self.goal(max_iterations=5, stall_after=2)
|
|
363
|
+
run = self.loop("run", "goals/g.md", action="revise-plan")
|
|
364
|
+
self.assertEqual(run.returncode, 3, run.stdout + run.stderr)
|
|
365
|
+
self.assertEqual(len(self.trail_rows()), 2)
|
|
366
|
+
self.assertFalse((self.repo / "ok.txt").exists())
|
|
367
|
+
|
|
368
|
+
@unittest.skipUnless(os.name == "nt", "Windows paths are case-insensitive")
|
|
369
|
+
def test_case_aliased_goal_plan_edits_still_stall(self):
|
|
370
|
+
self.goal(max_iterations=3, stall_after=1)
|
|
371
|
+
run = self.loop("run", "GOALS/G.MD", action="revise-plan")
|
|
372
|
+
self.assertEqual(run.returncode, 3, run.stdout + run.stderr)
|
|
373
|
+
trail = self.repo / ".scratch" / "goals" / "G" / "trail.tsv"
|
|
374
|
+
self.assertEqual(len(trail.read_text(encoding="utf-8").strip().splitlines()), 2)
|
|
375
|
+
self.assertFalse((self.repo / "ok.txt").exists())
|
|
376
|
+
|
|
377
|
+
def test_editing_the_goal_or_a_protected_file_exits_4(self):
|
|
378
|
+
for action in ("tamper-goal", "tamper-protect"):
|
|
379
|
+
with self.subTest(action=action):
|
|
380
|
+
self.goal()
|
|
381
|
+
git(self.repo, "checkout", "-q", "--", "check.sh")
|
|
382
|
+
run = self.loop("run", "goals/g.md", action=action)
|
|
383
|
+
self.assertEqual(run.returncode, 4, run.stdout + run.stderr)
|
|
384
|
+
|
|
385
|
+
def test_a_failing_harness_exits_5(self):
|
|
386
|
+
self.goal()
|
|
387
|
+
run = self.loop("run", "goals/g.md", action="fail")
|
|
388
|
+
self.assertEqual(run.returncode, 5, run.stdout + run.stderr)
|
|
389
|
+
|
|
390
|
+
def test_creating_a_path_declared_absent_exits_4(self):
|
|
391
|
+
self.goal(protect="check.sh absent:conftest.py")
|
|
392
|
+
check = self.loop("check", "goals/g.md")
|
|
393
|
+
self.assertIn("absent, must stay absent: conftest.py", check.stdout)
|
|
394
|
+
run = self.loop("run", "goals/g.md", action="create-conftest")
|
|
395
|
+
self.assertEqual(run.returncode, 4, run.stdout + run.stderr)
|
|
396
|
+
self.assertIn("conftest.py", run.stdout)
|
|
397
|
+
|
|
398
|
+
def test_a_protect_typo_is_an_error_not_a_silently_absent_path(self):
|
|
399
|
+
self.goal(protect="chekc.sh")
|
|
400
|
+
run = self.loop("run", "goals/g.md", action="done")
|
|
401
|
+
self.assertNotEqual(run.returncode, 0)
|
|
402
|
+
self.assertIn("does not exist", run.stdout + run.stderr)
|
|
403
|
+
self.goal(protect="absent:check.sh")
|
|
404
|
+
run = self.loop("check", "goals/g.md")
|
|
405
|
+
self.assertIn("exists; drop its `absent:` prefix", run.stdout + run.stderr)
|
|
406
|
+
|
|
407
|
+
def test_goal_files_need_protect_and_a_cost_cap(self):
|
|
408
|
+
self.goal(protect=None)
|
|
409
|
+
run = self.loop("check", "goals/g.md")
|
|
410
|
+
self.assertNotEqual(run.returncode, 0)
|
|
411
|
+
self.assertIn("protect", run.stdout + run.stderr)
|
|
412
|
+
self.goal(max_cost_usd=None)
|
|
413
|
+
run = self.loop("run", "goals/g.md")
|
|
414
|
+
self.assertNotEqual(run.returncode, 0)
|
|
415
|
+
self.assertIn("max_cost_usd", run.stdout + run.stderr)
|
|
416
|
+
|
|
417
|
+
def test_nonfinite_cost_caps_are_rejected_before_harness_execution(self):
|
|
418
|
+
record = self.tmp / "seen.json"
|
|
419
|
+
for harness in ("omp", "claude"):
|
|
420
|
+
for value in ("nan", "inf", "-inf"):
|
|
421
|
+
with self.subTest(harness=harness, value=value):
|
|
422
|
+
self.goal(harness=harness, max_cost_usd=value)
|
|
423
|
+
run = self.loop("run", "goals/g.md", action="done", FAKE_RECORD=str(record))
|
|
424
|
+
self.assertEqual(run.returncode, 1, run.stdout + run.stderr)
|
|
425
|
+
self.assertIn("max_cost_usd must be a positive number", run.stdout + run.stderr)
|
|
426
|
+
self.assertFalse(record.exists())
|
|
427
|
+
self.assertFalse((self.repo / "ok.txt").exists())
|
|
428
|
+
self.assertFalse((self.repo / ".scratch").exists())
|
|
429
|
+
|
|
430
|
+
def test_check_reports_without_running_the_harness(self):
|
|
431
|
+
self.goal()
|
|
432
|
+
run = self.loop("check", "goals/g.md", action="done")
|
|
433
|
+
self.assertEqual(run.returncode, 0)
|
|
434
|
+
self.assertIn("check exit 1", run.stdout)
|
|
435
|
+
self.assertFalse((self.repo / "ok.txt").exists())
|
|
436
|
+
|
|
437
|
+
def test_dry_run_prints_the_command_and_touches_nothing(self):
|
|
438
|
+
self.goal()
|
|
439
|
+
run = self.loop("run", "goals/g.md", "--dry-run", action="done")
|
|
440
|
+
self.assertEqual(run.returncode, 0)
|
|
441
|
+
self.assertIn("--max-cost", run.stdout)
|
|
442
|
+
self.assertFalse((self.repo / "ok.txt").exists())
|
|
443
|
+
self.assertFalse((self.repo / ".scratch").exists())
|
|
444
|
+
|
|
445
|
+
def test_the_harness_runs_in_the_root_without_api_keys_and_with_in_repo_temp(self):
|
|
446
|
+
self.goal()
|
|
447
|
+
record = self.tmp / "record.json"
|
|
448
|
+
run = self.loop("run", "goals/g.md", action="done", FAKE_RECORD=str(record),
|
|
449
|
+
ANTHROPIC_API_KEY="k", OPENAI_API_KEY="k", CODEX_API_KEY="k")
|
|
450
|
+
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
|
|
451
|
+
seen = json.loads(record.read_text(encoding="utf-8"))
|
|
452
|
+
for key in ("ANTHROPIC_API_KEY", "OPENAI_API_KEY", "CODEX_API_KEY"):
|
|
453
|
+
self.assertNotIn(key, seen["env"])
|
|
454
|
+
self.assertEqual(Path(seen["cwd"]).resolve(), self.repo)
|
|
455
|
+
self.assertEqual(Path(seen["env"]["TMPDIR"]).resolve(), self.repo / ".scratch" / "tmp")
|
|
456
|
+
self.assertIn("--max-cost", seen["argv"])
|
|
457
|
+
|
|
458
|
+
def test_the_prompt_travels_on_stdin_not_in_the_command(self):
|
|
459
|
+
# On Windows the harness is a .cmd shim: cmd.exe would run `& echo INJECTED` if the prompt were an argument.
|
|
460
|
+
self.goal(check='sh ./check.sh || { echo "a" & echo INJECTED >/dev/null; false; }', max_iterations=1)
|
|
461
|
+
record = self.tmp / "seen.json"
|
|
462
|
+
run = self.loop("run", "goals/g.md", FAKE_RECORD=str(record))
|
|
463
|
+
self.assertEqual(run.returncode, 2, run.stdout + run.stderr)
|
|
464
|
+
seen = json.loads(record.read_text(encoding="utf-8"))
|
|
465
|
+
self.assertIn("echo INJECTED", seen["stdin"])
|
|
466
|
+
self.assertIn("goals/g.md", seen["stdin"])
|
|
467
|
+
self.assertFalse([arg for arg in seen["argv"] if "INJECTED" in arg or "goals/g.md" in arg])
|
|
468
|
+
|
|
469
|
+
def test_a_hung_harness_is_stopped_and_exits_5(self):
|
|
470
|
+
self.goal(iteration_minutes=0.03)
|
|
471
|
+
run = self.loop("run", "goals/g.md", action="hang")
|
|
472
|
+
self.assertEqual(run.returncode, 5, run.stdout + run.stderr)
|
|
473
|
+
self.assertIn("ran past 0.03 minutes", run.stdout)
|
|
474
|
+
|
|
475
|
+
def test_a_hung_check_stops_the_run_before_any_harness_call(self):
|
|
476
|
+
self.goal(check="sleep 120", check_minutes=0.02, protect="none")
|
|
477
|
+
record = self.tmp / "seen.json"
|
|
478
|
+
run = self.loop("run", "goals/g.md", FAKE_RECORD=str(record))
|
|
479
|
+
self.assertEqual(run.returncode, 5, run.stdout + run.stderr)
|
|
480
|
+
self.assertIn("check ran past 0.02 minutes", run.stdout)
|
|
481
|
+
self.assertFalse(record.exists())
|
|
482
|
+
|
|
483
|
+
def test_a_check_that_exits_124_is_a_failing_check_not_a_timeout(self):
|
|
484
|
+
self.goal(check="exit 124", protect="none", max_iterations=1)
|
|
485
|
+
run = self.loop("run", "goals/g.md")
|
|
486
|
+
self.assertEqual(run.returncode, 2, run.stdout + run.stderr)
|
|
487
|
+
|
|
488
|
+
def test_time_limits_must_be_finite(self):
|
|
489
|
+
for value in ("inf", "nan", "0", "-1", "soon"):
|
|
490
|
+
with self.subTest(value=value):
|
|
491
|
+
self.goal(check_minutes=value)
|
|
492
|
+
run = self.loop("check", "goals/g.md")
|
|
493
|
+
self.assertNotEqual(run.returncode, 0)
|
|
494
|
+
self.assertIn("check_minutes must be a positive number", run.stdout + run.stderr)
|
|
495
|
+
|
|
496
|
+
def test_caches_under_protected_paths_are_cleared_before_the_check(self):
|
|
497
|
+
(self.repo / "tests").mkdir()
|
|
498
|
+
(self.repo / "tests" / "test_x.py").write_text("", encoding="utf-8")
|
|
499
|
+
self.goal(protect="check.sh tests", max_iterations=1)
|
|
500
|
+
run = self.loop("run", "goals/g.md", action="forge-cache")
|
|
501
|
+
self.assertEqual(run.returncode, 2, run.stdout + run.stderr)
|
|
502
|
+
self.assertFalse((self.repo / "tests" / "__pycache__").exists())
|
|
503
|
+
|
|
504
|
+
def test_caches_beside_a_protected_file_are_cleared_too(self):
|
|
505
|
+
(self.repo / "tests").mkdir()
|
|
506
|
+
(self.repo / "tests" / "test_x.py").write_text("", encoding="utf-8")
|
|
507
|
+
self.goal(protect="check.sh tests/test_x.py", max_iterations=1)
|
|
508
|
+
run = self.loop("run", "goals/g.md", action="forge-cache")
|
|
509
|
+
self.assertEqual(run.returncode, 2, run.stdout + run.stderr)
|
|
510
|
+
self.assertFalse((self.repo / "tests" / "__pycache__").exists())
|
|
511
|
+
|
|
512
|
+
def test_audit_reports_layers_gaps_and_scaffolds_a_goal_contract(self):
|
|
513
|
+
initial = self.loop("audit", "--json")
|
|
514
|
+
self.assertEqual(initial.returncode, 0, initial.stdout + initial.stderr)
|
|
515
|
+
report = json.loads(initial.stdout)
|
|
516
|
+
self.assertFalse(report["ready"])
|
|
517
|
+
self.assertGreaterEqual(len(report["gaps"]), 2)
|
|
518
|
+
strict_fail = self.loop("audit", "--strict")
|
|
519
|
+
self.assertEqual(strict_fail.returncode, 1)
|
|
520
|
+
|
|
521
|
+
(self.repo / "ruff.toml").write_text("line-length = 100\n", encoding="utf-8")
|
|
522
|
+
(self.repo / "pyproject.toml").write_text(
|
|
523
|
+
"[tool.mypy]\nstrict = true\n[tool.pytest.ini_options]\ntestpaths = [\"tests\"]\n",
|
|
524
|
+
encoding="utf-8",
|
|
525
|
+
)
|
|
526
|
+
(self.repo / "tests").mkdir()
|
|
527
|
+
(self.repo / "tests" / "test_app.py").write_text("def test_ok(): assert True\n", encoding="utf-8")
|
|
528
|
+
(self.repo / ".pre-commit-config.yaml").write_text("repos: []\n", encoding="utf-8")
|
|
529
|
+
(self.repo / ".omp" / "skills" / "verify-demo").mkdir(parents=True)
|
|
530
|
+
(self.repo / ".omp" / "skills" / "verify-demo" / "SKILL.md").write_text("---\nname: verify-demo\n---\n", encoding="utf-8")
|
|
531
|
+
|
|
532
|
+
ready = self.loop("audit", "--json", "--strict", "--write-goal", "goals/scaffold.md")
|
|
533
|
+
self.assertEqual(ready.returncode, 0, ready.stdout + ready.stderr)
|
|
534
|
+
ready_report = json.loads(ready.stdout)
|
|
535
|
+
self.assertTrue(ready_report["ready"])
|
|
536
|
+
self.assertEqual(ready_report["gaps"], [])
|
|
537
|
+
self.assertIn("ruff check .", ready_report["layers"]["static_checks"])
|
|
538
|
+
self.assertIn("mypy .", ready_report["layers"]["static_checks"])
|
|
539
|
+
self.assertEqual(ready_report["layers"]["test_checks"], ["pytest"])
|
|
540
|
+
self.assertEqual(ready_report["layers"]["runtime_verify"], [".omp/skills/verify-demo"])
|
|
541
|
+
scaffold = (self.repo / "goals" / "scaffold.md").read_text(encoding="utf-8")
|
|
542
|
+
self.assertIn("fast_check: ruff check . && mypy .", scaffold)
|
|
543
|
+
self.assertIn("check: pytest", scaffold)
|
|
544
|
+
self.assertIn("ruff.toml", scaffold)
|
|
545
|
+
|
|
546
|
+
dup = self.loop("audit", "--write-goal", "goals/scaffold.md")
|
|
547
|
+
self.assertNotEqual(dup.returncode, 0)
|
|
548
|
+
outside = self.loop("audit", "--write-goal", str(self.tmp / "outside.md"))
|
|
549
|
+
self.assertNotEqual(outside.returncode, 0)
|
|
550
|
+
|
|
551
|
+
def test_fast_check_short_circuits_before_slow_acceptance_check(self):
|
|
552
|
+
(self.repo / "fast.sh").write_text(
|
|
553
|
+
"test -f fast_ok.txt || { echo 'typecheck error: bad return'; exit 1; }\n",
|
|
554
|
+
encoding="utf-8", newline="\n",
|
|
555
|
+
)
|
|
556
|
+
(self.repo / "check.sh").write_text(
|
|
557
|
+
"echo ran >> check_runs.txt\ntest -f ok.txt\n",
|
|
558
|
+
encoding="utf-8", newline="\n",
|
|
559
|
+
)
|
|
560
|
+
self.goal(fast_check="sh ./fast.sh", protect="fast.sh check.sh", max_iterations=4)
|
|
561
|
+
run = self.loop("run", "goals/g.md", action="fast-then-check")
|
|
562
|
+
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
|
|
563
|
+
rows = self.trail_rows()
|
|
564
|
+
self.assertEqual(len(rows), 3)
|
|
565
|
+
self.assertTrue(rows[0].endswith("\tfast_check"), rows)
|
|
566
|
+
self.assertTrue(rows[1].endswith("\tcheck"), rows)
|
|
567
|
+
self.assertTrue(rows[2].endswith("\tpass"), rows)
|
|
568
|
+
self.assertEqual(len((self.repo / "check_runs.txt").read_text(encoding="utf-8").splitlines()), 2)
|
|
569
|
+
|
|
570
|
+
def test_forbid_slop_blocks_newly_added_suppressions_and_swallowed_exceptions_until_cleaned(self):
|
|
571
|
+
(self.repo / "legacy.py").write_text("import sys # noqa: E402\n", encoding="utf-8", newline="\n")
|
|
572
|
+
git(self.repo, "add", "legacy.py")
|
|
573
|
+
git(self.repo, "commit", "-q", "-m", "legacy")
|
|
574
|
+
self.goal(max_iterations=3)
|
|
575
|
+
run = self.loop("run", "goals/g.md", action="slop-then-clean")
|
|
576
|
+
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
|
|
577
|
+
rows = self.trail_rows()
|
|
578
|
+
self.assertEqual(len(rows), 2)
|
|
579
|
+
self.assertTrue(rows[0].endswith("\tslop_guard"), rows)
|
|
580
|
+
self.assertTrue(rows[1].endswith("\tpass"), rows)
|
|
581
|
+
second_prompt = next((self.repo / ".scratch" / "goals" / "g").glob("*-iteration-2-prompt.txt")).read_text(encoding="utf-8")
|
|
582
|
+
self.assertIn("[slop_guard failed]", second_prompt)
|
|
583
|
+
self.assertIn("app.py:3: [suppression-comment]", second_prompt)
|
|
584
|
+
self.assertIn("app.py:4: [swallowed-exception]", second_prompt)
|
|
585
|
+
self.assertIn("client.ts:1: [suppression-comment]", second_prompt)
|
|
586
|
+
self.assertIn("client.ts:2: [swallowed-exception]", second_prompt)
|
|
587
|
+
self.assertNotIn("legacy.py", second_prompt)
|
|
588
|
+
|
|
589
|
+
def test_forbid_slop_can_be_disabled_explicitly(self):
|
|
590
|
+
(self.repo / "legacy.py").write_text("x = 1\n", encoding="utf-8")
|
|
591
|
+
self.goal(forbid_slop="false", max_iterations=2)
|
|
592
|
+
run = self.loop("run", "goals/g.md", action="slop-then-clean")
|
|
593
|
+
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
|
|
594
|
+
self.assertEqual(len(self.trail_rows()), 1)
|
|
595
|
+
|
|
596
|
+
def test_protect_configs_guards_linter_configs_and_pyproject_tool_tables(self):
|
|
597
|
+
(self.repo / "ruff.toml").write_text("line-length = 100\n", encoding="utf-8")
|
|
598
|
+
(self.repo / "pyproject.toml").write_text(
|
|
599
|
+
'[project]\nname = "demo"\ndependencies = []\n\n[tool.ruff]\nselect = ["E", "F"]\n',
|
|
600
|
+
encoding="utf-8",
|
|
601
|
+
)
|
|
602
|
+
git(self.repo, "add", "ruff.toml", "pyproject.toml")
|
|
603
|
+
git(self.repo, "commit", "-q", "-m", "configs")
|
|
604
|
+
|
|
605
|
+
self.goal()
|
|
606
|
+
tamper_cfg = self.loop("run", "goals/g.md", action="weaken-ruff-toml")
|
|
607
|
+
self.assertEqual(tamper_cfg.returncode, 4, tamper_cfg.stdout + tamper_cfg.stderr)
|
|
608
|
+
self.assertIn("ruff.toml", tamper_cfg.stdout)
|
|
609
|
+
git(self.repo, "checkout", "-q", "--", "ruff.toml")
|
|
610
|
+
|
|
611
|
+
self.goal()
|
|
612
|
+
tamper_py = self.loop("run", "goals/g.md", action="weaken-pyproject-ruff")
|
|
613
|
+
self.assertEqual(tamper_py.returncode, 4, tamper_py.stdout + tamper_py.stderr)
|
|
614
|
+
self.assertIn("pyproject.toml", tamper_py.stdout)
|
|
615
|
+
git(self.repo, "checkout", "-q", "--", "pyproject.toml")
|
|
616
|
+
|
|
617
|
+
self.goal()
|
|
618
|
+
allow_deps = self.loop("run", "goals/g.md", action="edit-pyproject-deps")
|
|
619
|
+
self.assertEqual(allow_deps.returncode, 0, allow_deps.stdout + allow_deps.stderr)
|
|
620
|
+
self.assertIn('"httpx"', (self.repo / "pyproject.toml").read_text(encoding="utf-8"))
|
|
621
|
+
(self.repo / "ok.txt").unlink()
|
|
622
|
+
git(self.repo, "checkout", "-q", "--", "pyproject.toml")
|
|
623
|
+
|
|
624
|
+
self.goal(protect_configs="false", max_iterations=1)
|
|
625
|
+
opt_out = self.loop("run", "goals/g.md", action="weaken-ruff-toml")
|
|
626
|
+
self.assertEqual(opt_out.returncode, 2, opt_out.stdout + opt_out.stderr)
|
|
627
|
+
|
|
628
|
+
def test_revert_on_fail_resets_failed_edits_keeps_plan_and_stalls_on_identical_repeats(self):
|
|
629
|
+
(self.repo / "tracked.txt").write_text("clean\n", encoding="utf-8")
|
|
630
|
+
git(self.repo, "add", "tracked.txt")
|
|
631
|
+
git(self.repo, "commit", "-q", "-m", "tracked")
|
|
632
|
+
|
|
633
|
+
(self.repo / "dirty.txt").write_text("user work\n", encoding="utf-8")
|
|
634
|
+
self.goal(revert_on_fail="true")
|
|
635
|
+
refused = self.loop("run", "goals/g.md", action="done")
|
|
636
|
+
self.assertEqual(refused.returncode, 1)
|
|
637
|
+
self.assertIn("clean working tree", refused.stdout + refused.stderr)
|
|
638
|
+
self.assertTrue((self.repo / "dirty.txt").exists())
|
|
639
|
+
(self.repo / "dirty.txt").unlink()
|
|
640
|
+
|
|
641
|
+
self.goal(revert_on_fail="true", max_iterations=3)
|
|
642
|
+
recovered = self.loop("run", "goals/g.md", action="revert-pilot")
|
|
643
|
+
self.assertEqual(recovered.returncode, 0, recovered.stdout + recovered.stderr)
|
|
644
|
+
self.assertEqual(len(self.trail_rows()), 2)
|
|
645
|
+
self.assertEqual((self.repo / "tracked.txt").read_text(encoding="utf-8"), "clean\n")
|
|
646
|
+
self.assertFalse((self.repo / "dead_end.py").exists())
|
|
647
|
+
self.assertTrue((self.repo / "ok.txt").exists())
|
|
648
|
+
(self.repo / "ok.txt").unlink()
|
|
649
|
+
shutil.rmtree(self.repo / ".scratch" / "goals" / "g")
|
|
650
|
+
|
|
651
|
+
self.goal(revert_on_fail="true", max_iterations=5, stall_after=2)
|
|
652
|
+
stalled = self.loop("run", "goals/g.md", action="repeat-broken-edit")
|
|
653
|
+
self.assertEqual(stalled.returncode, 3, stalled.stdout + stalled.stderr)
|
|
654
|
+
self.assertEqual(len(self.trail_rows()), 3)
|
|
655
|
+
self.assertEqual((self.repo / "tracked.txt").read_text(encoding="utf-8"), "clean\n")
|
|
656
|
+
|
|
657
|
+
def test_stub_placeholders_block_todos_and_not_implemented_while_allowing_abstract_methods(self):
|
|
658
|
+
self.goal(max_iterations=3)
|
|
659
|
+
run = self.loop("run", "goals/g.md", action="stubs-then-real")
|
|
660
|
+
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
|
|
661
|
+
rows = self.trail_rows()
|
|
662
|
+
self.assertEqual(len(rows), 2)
|
|
663
|
+
self.assertTrue(rows[0].endswith("\tslop_guard"), rows)
|
|
664
|
+
self.assertTrue(rows[1].endswith("\tpass"), rows)
|
|
665
|
+
second_prompt = next((self.repo / ".scratch" / "goals" / "g").glob("*-iteration-2-prompt.txt")).read_text(encoding="utf-8")
|
|
666
|
+
self.assertNotIn("base.py", second_prompt)
|
|
667
|
+
self.assertIn("service.py:1: [stub-placeholder]", second_prompt)
|
|
668
|
+
self.assertIn("service.py:3: [stub-placeholder]", second_prompt)
|
|
669
|
+
self.assertIn("ui.ts:1: [stub-placeholder]", second_prompt)
|
|
670
|
+
self.assertIn("ui.ts:2: [stub-placeholder]", second_prompt)
|
|
671
|
+
|
|
672
|
+
def test_manifest_drives_all_slices_to_completion_and_auto_protects_manifest_file(self):
|
|
673
|
+
manifest = {
|
|
674
|
+
"product": "Complete three-slice CLI",
|
|
675
|
+
"slices": [
|
|
676
|
+
{"id": "slice-1", "title": "Storage layer", "check": "test -f s1.txt"},
|
|
677
|
+
{"id": "slice-2", "title": "Command layer", "check": "test -f s2.txt"},
|
|
678
|
+
{"id": "slice-3", "title": "End-to-end persistence", "check": "test -f s3.txt"},
|
|
679
|
+
],
|
|
680
|
+
}
|
|
681
|
+
(self.repo / "goals" / "manifest.json").write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8")
|
|
682
|
+
|
|
683
|
+
initial = self.loop("manifest", "goals/manifest.json", "--json")
|
|
684
|
+
self.assertEqual(initial.returncode, 1)
|
|
685
|
+
summary = json.loads(initial.stdout)
|
|
686
|
+
self.assertEqual((summary["passed"], summary["total"], summary["ready"]), (0, 3, False))
|
|
687
|
+
|
|
688
|
+
self.goal(manifest="goals/manifest.json", max_iterations=5)
|
|
689
|
+
tamper = self.loop("run", "goals/g.md", action="tamper-manifest")
|
|
690
|
+
self.assertEqual(tamper.returncode, 4, tamper.stdout + tamper.stderr)
|
|
691
|
+
self.assertIn("goals/manifest.json", tamper.stdout)
|
|
692
|
+
(self.repo / "goals" / "manifest.json").write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8")
|
|
693
|
+
shutil.rmtree(self.repo / ".scratch")
|
|
694
|
+
|
|
695
|
+
self.goal(manifest="goals/manifest.json", max_iterations=5)
|
|
696
|
+
run = self.loop("run", "goals/g.md", action="manifest-stepwise")
|
|
697
|
+
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
|
|
698
|
+
rows = self.trail_rows()
|
|
699
|
+
self.assertEqual(len(rows), 3)
|
|
700
|
+
self.assertTrue(rows[0].endswith("\tmanifest"), rows)
|
|
701
|
+
self.assertTrue(rows[1].endswith("\tmanifest"), rows)
|
|
702
|
+
self.assertTrue(rows[2].endswith("\tpass"), rows)
|
|
703
|
+
green = self.loop("manifest", "goals/manifest.json", "--json")
|
|
704
|
+
self.assertEqual(green.returncode, 0)
|
|
705
|
+
self.assertTrue(json.loads(green.stdout)["ready"])
|
|
706
|
+
|
|
707
|
+
def test_revert_on_fail_undoes_agent_commits_and_staged_files(self):
|
|
708
|
+
(self.repo / "tracked.txt").write_text("clean\n", encoding="utf-8")
|
|
709
|
+
git(self.repo, "add", "tracked.txt")
|
|
710
|
+
git(self.repo, "commit", "-q", "-m", "tracked")
|
|
711
|
+
base = subprocess.run(["git", "-C", str(self.repo), "rev-parse", "HEAD"], capture_output=True, text=True).stdout
|
|
712
|
+
self.goal(revert_on_fail="true", max_iterations=1)
|
|
713
|
+
run = self.loop("run", "goals/g.md", action="stage-and-commit")
|
|
714
|
+
self.assertEqual(run.returncode, 2, run.stdout + run.stderr)
|
|
715
|
+
head = subprocess.run(["git", "-C", str(self.repo), "rev-parse", "HEAD"], capture_output=True, text=True).stdout
|
|
716
|
+
self.assertEqual(head, base)
|
|
717
|
+
self.assertEqual((self.repo / "tracked.txt").read_text(encoding="utf-8"), "clean\n")
|
|
718
|
+
self.assertFalse((self.repo / "staged_new.py").exists())
|
|
719
|
+
status = subprocess.run(["git", "-C", str(self.repo), "status", "--porcelain", "-uall"], capture_output=True, text=True).stdout
|
|
720
|
+
self.assertEqual(status.split(), ["??", "goals/g.md"])
|
|
721
|
+
|
|
722
|
+
def test_revert_on_fail_removes_an_escaping_link_without_touching_its_target(self):
|
|
723
|
+
outside = self.tmp / "outside"
|
|
724
|
+
outside.mkdir()
|
|
725
|
+
(outside / "victim.txt").write_text("keep me\n", encoding="utf-8")
|
|
726
|
+
self.goal(revert_on_fail="true", max_iterations=1)
|
|
727
|
+
run = self.loop("run", "goals/g.md", action="link-escape", FAKE_OUTSIDE=str(outside))
|
|
728
|
+
self.assertEqual(run.returncode, 2, run.stdout + run.stderr)
|
|
729
|
+
self.assertEqual((outside / "victim.txt").read_text(encoding="utf-8"), "keep me\n")
|
|
730
|
+
self.assertFalse(os.path.lexists(self.repo / "escape"))
|
|
731
|
+
|
|
732
|
+
def test_protect_configs_blocks_creating_new_guardrail_configs(self):
|
|
733
|
+
self.goal()
|
|
734
|
+
root_cfg = self.loop("run", "goals/g.md", action="weaken-ruff-toml")
|
|
735
|
+
self.assertEqual(root_cfg.returncode, 4, root_cfg.stdout + root_cfg.stderr)
|
|
736
|
+
self.assertIn("ruff.toml", root_cfg.stdout)
|
|
737
|
+
(self.repo / "ruff.toml").unlink()
|
|
738
|
+
|
|
739
|
+
self.goal()
|
|
740
|
+
nested = self.loop("run", "goals/g.md", action="create-nested-conftest")
|
|
741
|
+
self.assertEqual(nested.returncode, 4, nested.stdout + nested.stderr)
|
|
742
|
+
self.assertIn("src/conftest.py", nested.stdout)
|
|
743
|
+
|
|
744
|
+
shutil.rmtree(self.repo / "src")
|
|
745
|
+
self.goal(protect_configs="false", max_iterations=1)
|
|
746
|
+
opt_out = self.loop("run", "goals/g.md", action="create-nested-conftest")
|
|
747
|
+
self.assertEqual(opt_out.returncode, 2, opt_out.stdout + opt_out.stderr)
|
|
748
|
+
|
|
749
|
+
def test_manifest_dry_run_validates_from_any_cwd_without_running_slices(self):
|
|
750
|
+
manifest = {"product": "demo", "slices": [{"id": "s1", "title": "never run", "check": "touch ran.txt; exit 1"}]}
|
|
751
|
+
(self.repo / "goals" / "manifest.json").write_text(json.dumps(manifest), encoding="utf-8")
|
|
752
|
+
full_env = {**os.environ, "PATH": self.path}
|
|
753
|
+
run = subprocess.run([sys.executable, str(LOOP), "manifest", "manifest.json", "--dry-run", "--json"],
|
|
754
|
+
cwd=self.repo / "goals", env=full_env, capture_output=True, text=True)
|
|
755
|
+
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
|
|
756
|
+
self.assertEqual(json.loads(run.stdout), {"manifest": "goals/manifest.json", "product": "demo", "total": 1, "valid": True})
|
|
757
|
+
self.assertFalse((self.repo / "ran.txt").exists())
|
|
758
|
+
|
|
759
|
+
def test_protect_configs_guards_package_json_scripts_but_not_dependencies(self):
|
|
760
|
+
(self.repo / "package.json").write_text(json.dumps({"scripts": {"lint": "eslint ."}, "dependencies": {}}), encoding="utf-8")
|
|
761
|
+
git(self.repo, "add", "package.json")
|
|
762
|
+
git(self.repo, "commit", "-q", "-m", "pkg")
|
|
763
|
+
self.goal()
|
|
764
|
+
run = self.loop("run", "goals/g.md", action="weaken-package-lint")
|
|
765
|
+
self.assertEqual(run.returncode, 4, run.stdout + run.stderr)
|
|
766
|
+
self.assertIn("package.json scripts", run.stdout)
|
|
767
|
+
|
|
768
|
+
def test_slop_in_nested_vendored_folders_is_ignored(self):
|
|
769
|
+
vendored = self.repo / "packages" / "web" / "node_modules" / "dep"
|
|
770
|
+
vendored.mkdir(parents=True)
|
|
771
|
+
(vendored / "index.js").write_text("// @ts-ignore\ntry { a(); } catch (e) {}\n", encoding="utf-8")
|
|
772
|
+
self.goal()
|
|
773
|
+
run = self.loop("check", "goals/g.md")
|
|
774
|
+
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
|
|
775
|
+
self.assertNotIn("slop_guard", run.stdout)
|
|
776
|
+
|
|
777
|
+
def test_transient_rate_limit_backs_off_and_retries_without_burning_iteration(self):
|
|
778
|
+
self.goal(max_iterations=1, rate_limit_retries=2, rate_limit_backoff_seconds=0.01)
|
|
779
|
+
run = self.loop("run", "goals/g.md", action="rate-limit-then-done")
|
|
780
|
+
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
|
|
781
|
+
self.assertIn("transient rate limit; backing off", run.stdout)
|
|
782
|
+
self.assertIn("goal met", run.stdout)
|
|
783
|
+
rows = self.trail_rows()
|
|
784
|
+
self.assertEqual(len(rows), 2)
|
|
785
|
+
self.assertIn("\trate_limited\t", rows[0])
|
|
786
|
+
self.assertIn("\t0\t", rows[1])
|
|
787
|
+
summary = self.latest_summary()
|
|
788
|
+
self.assertEqual(summary["rate_limit_retries_used"], 1)
|
|
789
|
+
self.assertEqual(summary["exit_code"], 0)
|
|
790
|
+
|
|
791
|
+
def test_hard_quota_exhaustion_stops_without_retrying(self):
|
|
792
|
+
self.goal(max_iterations=3, rate_limit_retries=3, rate_limit_backoff_seconds=0.01)
|
|
793
|
+
run = self.loop("run", "goals/g.md", action="quota-exhausted")
|
|
794
|
+
self.assertEqual(run.returncode, 5, run.stdout + run.stderr)
|
|
795
|
+
self.assertIn("quota exhausted", run.stdout)
|
|
796
|
+
rows = self.trail_rows()
|
|
797
|
+
self.assertEqual(len(rows), 1)
|
|
798
|
+
self.assertIn("\tquota\t", rows[0])
|
|
799
|
+
summary = self.latest_summary()
|
|
800
|
+
self.assertEqual(summary["exit_code"], 5)
|
|
801
|
+
self.assertEqual(summary["exit_reason"], "quota_exhausted")
|
|
802
|
+
|
|
803
|
+
def test_invalid_rate_limit_settings_are_rejected(self):
|
|
804
|
+
for field, value in [("cooldown_seconds", "-1"), ("rate_limit_retries", "-1"), ("rate_limit_backoff_seconds", "0")]:
|
|
805
|
+
with self.subTest(field=field, value=value):
|
|
806
|
+
self.goal(**{field: value})
|
|
807
|
+
run = self.loop("check", "goals/g.md")
|
|
808
|
+
self.assertNotEqual(run.returncode, 0)
|
|
809
|
+
|
|
810
|
+
def test_escalate_after_switches_harness_args_and_succeeds(self):
|
|
811
|
+
self.goal(
|
|
812
|
+
max_iterations=4,
|
|
813
|
+
stall_after=2,
|
|
814
|
+
harness_args="--model cheap-model",
|
|
815
|
+
escalate_after=2,
|
|
816
|
+
escalate_harness_args="--model strong-model",
|
|
817
|
+
)
|
|
818
|
+
run = self.loop("run", "goals/g.md", action="escalate-on-strong-model")
|
|
819
|
+
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
|
|
820
|
+
self.assertIn("escalating to escalate_harness_args", run.stdout)
|
|
821
|
+
self.assertIn("goal met", run.stdout)
|
|
822
|
+
self.assertTrue((self.repo / "ok.txt").exists())
|
|
823
|
+
rows = self.trail_rows()
|
|
824
|
+
self.assertTrue(any("switch:escalated(--model strong-model)" in row for row in rows))
|
|
825
|
+
summary = self.latest_summary()
|
|
826
|
+
self.assertEqual(summary["goal"], "ok.txt exists")
|
|
827
|
+
self.assertEqual(summary["harness"], "omp")
|
|
828
|
+
self.assertEqual(summary["iterations_run"], 3)
|
|
829
|
+
self.assertEqual(summary["exit_code"], 0)
|
|
830
|
+
self.assertEqual(summary["exit_reason"], "goal_met")
|
|
831
|
+
self.assertEqual(summary["check_exit"], 0)
|
|
832
|
+
self.assertEqual(summary["rate_limit_retries_used"], 0)
|
|
833
|
+
self.assertEqual(summary["trail"], ".scratch/goals/g/trail.tsv")
|
|
834
|
+
self.assertIsInstance(summary["elapsed_seconds"], (int, float))
|
|
835
|
+
self.assertEqual(len(summary["active_args_history"]), 2)
|
|
836
|
+
self.assertEqual(summary["active_args_history"][0]["tier"], "default")
|
|
837
|
+
self.assertEqual(summary["active_args_history"][0]["args"], "--model cheap-model")
|
|
838
|
+
self.assertEqual(summary["active_args_history"][1]["tier"], "escalated")
|
|
839
|
+
self.assertEqual(summary["active_args_history"][1]["args"], "--model strong-model")
|
|
840
|
+
self.assertEqual(summary["active_args_history"][1]["reason"], "escalate_after")
|
|
841
|
+
self.assertEqual(summary["active_args_history"][1]["iteration"], 3)
|
|
842
|
+
|
|
843
|
+
def test_fallback_harness_args_recovers_from_hard_quota_error(self):
|
|
844
|
+
self.goal(
|
|
845
|
+
max_iterations=2,
|
|
846
|
+
harness_args="--model primary-model",
|
|
847
|
+
fallback_harness_args="--model fallback-model",
|
|
848
|
+
)
|
|
849
|
+
run = self.loop("run", "goals/g.md", action="quota-then-fallback")
|
|
850
|
+
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
|
|
851
|
+
self.assertIn("switching to fallback_harness_args", run.stdout)
|
|
852
|
+
self.assertIn("goal met", run.stdout)
|
|
853
|
+
self.assertTrue((self.repo / "ok.txt").exists())
|
|
854
|
+
rows = self.trail_rows()
|
|
855
|
+
self.assertTrue(any("\tquota\t" in row for row in rows))
|
|
856
|
+
self.assertTrue(any("switch:fallback(--model fallback-model)" in row for row in rows))
|
|
857
|
+
summary = self.latest_summary()
|
|
858
|
+
self.assertEqual(summary["iterations_run"], 1)
|
|
859
|
+
self.assertEqual(summary["exit_code"], 0)
|
|
860
|
+
self.assertEqual(summary["exit_reason"], "goal_met")
|
|
861
|
+
self.assertEqual(len(summary["active_args_history"]), 2)
|
|
862
|
+
self.assertEqual(summary["active_args_history"][1]["tier"], "fallback")
|
|
863
|
+
self.assertEqual(summary["active_args_history"][1]["args"], "--model fallback-model")
|
|
864
|
+
self.assertEqual(summary["active_args_history"][1]["reason"], "quota")
|
|
865
|
+
|
|
866
|
+
def test_fallback_harness_args_recovers_from_persistent_rate_limit_and_aborts_if_fallback_fails(self):
|
|
867
|
+
self.goal(
|
|
868
|
+
max_iterations=2,
|
|
869
|
+
rate_limit_retries=1,
|
|
870
|
+
rate_limit_backoff_seconds=0.01,
|
|
871
|
+
harness_args="--model primary-model",
|
|
872
|
+
fallback_harness_args="--model fallback-model",
|
|
873
|
+
)
|
|
874
|
+
run = self.loop("run", "goals/g.md", action="rate-limit-then-fallback")
|
|
875
|
+
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
|
|
876
|
+
summary = self.latest_summary()
|
|
877
|
+
self.assertEqual(summary["rate_limit_retries_used"], 1)
|
|
878
|
+
self.assertEqual(summary["active_args_history"][1]["tier"], "fallback")
|
|
879
|
+
self.assertEqual(summary["active_args_history"][1]["reason"], "rate_limit")
|
|
880
|
+
|
|
881
|
+
(self.repo / "ok.txt").unlink()
|
|
882
|
+
run_both_fail = self.loop("run", "goals/g.md", action="quota-exhausted")
|
|
883
|
+
self.assertEqual(run_both_fail.returncode, 5, run_both_fail.stdout + run_both_fail.stderr)
|
|
884
|
+
summary_fail = self.latest_summary()
|
|
885
|
+
self.assertEqual(summary_fail["exit_code"], 5)
|
|
886
|
+
self.assertEqual(summary_fail["exit_reason"], "quota_exhausted")
|
|
887
|
+
self.assertEqual(len(summary_fail["active_args_history"]), 2)
|
|
888
|
+
|
|
889
|
+
def test_checkpoint_every_pauses_with_exit_6_and_writes_summary(self):
|
|
890
|
+
self.goal(max_iterations=5, stall_after=9, checkpoint_every=2)
|
|
891
|
+
run = self.loop("run", "goals/g.md", action="progress")
|
|
892
|
+
self.assertEqual(run.returncode, 6, run.stdout + run.stderr)
|
|
893
|
+
self.assertIn("checkpoint reached after 2 iterations", run.stdout)
|
|
894
|
+
self.assertIn("latest-summary.json", run.stdout)
|
|
895
|
+
self.assertEqual(len(self.trail_rows()), 2)
|
|
896
|
+
summary = self.latest_summary()
|
|
897
|
+
self.assertEqual(summary["iterations_run"], 2)
|
|
898
|
+
self.assertEqual(summary["exit_code"], 6)
|
|
899
|
+
self.assertEqual(summary["exit_reason"], "checkpoint")
|
|
900
|
+
self.assertEqual(summary["check_exit"], 1)
|
|
901
|
+
self.assertEqual(summary["trail"], ".scratch/goals/g/trail.tsv")
|
|
902
|
+
|
|
903
|
+
def test_invalid_escalation_fallback_and_checkpoint_settings_are_rejected(self):
|
|
904
|
+
cases = [
|
|
905
|
+
({"escalate_after": "0", "escalate_harness_args": "--model opus"}, "escalate_after must be a positive integer"),
|
|
906
|
+
({"escalate_after": "-2", "escalate_harness_args": "--model opus"}, "escalate_after must be a positive integer"),
|
|
907
|
+
({"escalate_after": "two", "escalate_harness_args": "--model opus"}, "escalate_after must be a positive integer"),
|
|
908
|
+
({"escalate_after": "2"}, "escalate_after requires escalate_harness_args"),
|
|
909
|
+
({"escalate_harness_args": "--model opus"}, "escalate_harness_args requires escalate_after"),
|
|
910
|
+
({"fallback_harness_args": ""}, "fallback_harness_args must not be empty"),
|
|
911
|
+
({"fallback_harness_args": "--model 'unterminated"}, "invalid shell quoting"),
|
|
912
|
+
({"checkpoint_every": "0"}, "checkpoint_every must be a positive integer"),
|
|
913
|
+
({"checkpoint_every": "-1"}, "checkpoint_every must be a positive integer"),
|
|
914
|
+
({"checkpoint_every": "soon"}, "checkpoint_every must be a positive integer"),
|
|
915
|
+
({"active_sprint": "0"}, "active_sprint must be a positive integer"),
|
|
916
|
+
({"active_sprint": "-1"}, "active_sprint must be a positive integer"),
|
|
917
|
+
({"active_sprint": "one"}, "active_sprint must be a positive integer"),
|
|
918
|
+
]
|
|
919
|
+
for fields, expected in cases:
|
|
920
|
+
with self.subTest(fields=fields):
|
|
921
|
+
self.goal(**fields)
|
|
922
|
+
run = self.loop("check", "goals/g.md")
|
|
923
|
+
self.assertNotEqual(run.returncode, 0)
|
|
924
|
+
self.assertIn(expected, run.stdout + run.stderr)
|
|
925
|
+
|
|
926
|
+
def test_sprint_scoped_manifest_defers_later_sprints_and_catches_earlier_regressions(self):
|
|
927
|
+
manifest = {
|
|
928
|
+
"product": "Two-sprint app",
|
|
929
|
+
"slices": [
|
|
930
|
+
{"id": "slice-1", "title": "Core flow", "sprint": 1, "check": "test -f s1.txt"},
|
|
931
|
+
{"id": "slice-2", "title": "Admin export", "sprint": 2, "check": "test -f s2.txt"},
|
|
932
|
+
],
|
|
933
|
+
"inventory": [
|
|
934
|
+
{"id": "inv-1", "status": "included", "slice": "slice-1"},
|
|
935
|
+
{"id": "inv-2", "status": "included", "slice": "slice-2"},
|
|
936
|
+
],
|
|
937
|
+
}
|
|
938
|
+
(self.repo / "goals" / "manifest.json").write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8")
|
|
939
|
+
|
|
940
|
+
# Sprint 1 runs and passes while explicitly reporting Sprint 2 deferred (total scope incomplete).
|
|
941
|
+
self.goal(manifest="goals/manifest.json", active_sprint=1, max_iterations=2)
|
|
942
|
+
run_s1 = self.loop("run", "goals/g.md", action="sprint1-done")
|
|
943
|
+
self.assertEqual(run_s1.returncode, 0, run_s1.stdout + run_s1.stderr)
|
|
944
|
+
self.assertIn("total scope incomplete", run_s1.stdout)
|
|
945
|
+
self.assertIn("slice-2", run_s1.stdout)
|
|
946
|
+
summary_s1 = self.latest_summary()
|
|
947
|
+
self.assertEqual(summary_s1["exit_code"], 0)
|
|
948
|
+
scope_s1 = summary_s1["scope"]
|
|
949
|
+
self.assertEqual(scope_s1["active_sprint"], 1)
|
|
950
|
+
self.assertEqual(scope_s1["deferred_slices"], ["slice-2"])
|
|
951
|
+
self.assertEqual(scope_s1["total_slices"], 2)
|
|
952
|
+
self.assertFalse(scope_s1["scope_complete"])
|
|
953
|
+
self.assertFalse(scope_s1["sme_gate_blocked"])
|
|
954
|
+
self.assertEqual(scope_s1["inventory_counts"]["included"], 2)
|
|
955
|
+
|
|
956
|
+
cli_s1 = self.loop("manifest", "goals/manifest.json", "--sprint", "1", "--json")
|
|
957
|
+
self.assertEqual(cli_s1.returncode, 0, cli_s1.stdout + cli_s1.stderr)
|
|
958
|
+
s1_json = json.loads(cli_s1.stdout)
|
|
959
|
+
self.assertEqual((s1_json["passed"], s1_json["total"], s1_json["total_slices"]), (1, 1, 2))
|
|
960
|
+
self.assertEqual(s1_json["active_sprint"], 1)
|
|
961
|
+
self.assertEqual(s1_json["deferred_slices"], ["slice-2"])
|
|
962
|
+
self.assertTrue(s1_json["ready"])
|
|
963
|
+
self.assertFalse(s1_json["scope_complete"])
|
|
964
|
+
|
|
965
|
+
# Regressing Sprint 1 while targeting Sprint 2 must fail even when Sprint 2 passes.
|
|
966
|
+
(self.repo / "s1.txt").unlink()
|
|
967
|
+
(self.repo / "s2.txt").write_text("", encoding="utf-8")
|
|
968
|
+
cli_reg = self.loop("manifest", "goals/manifest.json", "--sprint", "2", "--json")
|
|
969
|
+
self.assertEqual(cli_reg.returncode, 1, cli_reg.stdout + cli_reg.stderr)
|
|
970
|
+
reg_json = json.loads(cli_reg.stdout)
|
|
971
|
+
self.assertEqual((reg_json["passed"], reg_json["total"], reg_json["deferred_slices"]), (1, 2, []))
|
|
972
|
+
self.assertFalse(reg_json["ready"])
|
|
973
|
+
self.assertFalse(reg_json["scope_complete"])
|
|
974
|
+
|
|
975
|
+
# Restoring Sprint 1 makes Sprint 2 (and total scope) complete.
|
|
976
|
+
(self.repo / "s1.txt").write_text("", encoding="utf-8")
|
|
977
|
+
(self.repo / "ok.txt").unlink()
|
|
978
|
+
self.goal(manifest="goals/manifest.json", active_sprint=2, max_iterations=2)
|
|
979
|
+
run_s2 = self.loop("run", "goals/g.md", action="sprint2-done")
|
|
980
|
+
self.assertEqual(run_s2.returncode, 0, run_s2.stdout + run_s2.stderr)
|
|
981
|
+
self.assertIn("goal met", run_s2.stdout)
|
|
982
|
+
self.assertNotIn("total scope incomplete", run_s2.stdout)
|
|
983
|
+
summary_s2 = self.latest_summary()
|
|
984
|
+
self.assertTrue(summary_s2["scope"]["scope_complete"])
|
|
985
|
+
self.assertEqual(summary_s2["scope"]["deferred_slices"], [])
|
|
986
|
+
self.assertEqual(summary_s2["scope"]["active_sprint"], 2)
|
|
987
|
+
|
|
988
|
+
bad_sprint = self.loop("manifest", "goals/manifest.json", "--sprint", "0")
|
|
989
|
+
self.assertNotEqual(bad_sprint.returncode, 0)
|
|
990
|
+
self.assertIn("--sprint must be a positive integer", bad_sprint.stdout + bad_sprint.stderr)
|
|
991
|
+
|
|
992
|
+
def test_manifest_inventory_schema_validation_and_pending_gate(self):
|
|
993
|
+
base_slices = [{"id": "s1", "title": "Slice 1", "check": "test -f s1.txt"}]
|
|
994
|
+
invalid_cases = [
|
|
995
|
+
({"product": "p", "slices": [{**base_slices[0], "sprint": 0}]}, "'sprint' must be a positive integer"),
|
|
996
|
+
({"product": "p", "slices": [{**base_slices[0], "sprint": True}]}, "'sprint' must be a positive integer"),
|
|
997
|
+
({"product": "p", "slices": base_slices, "inventory": "bad"}, "'inventory' must be a list"),
|
|
998
|
+
({"product": "p", "slices": base_slices, "inventory": [{"id": "a", "status": "bogus"}]}, "'status' must be one of"),
|
|
999
|
+
({"product": "p", "slices": base_slices, "inventory": [
|
|
1000
|
+
{"id": "a", "status": "pending"}, {"id": "a", "status": "pending"}
|
|
1001
|
+
]}, "duplicate inventory id"),
|
|
1002
|
+
({"product": "p", "slices": base_slices, "inventory": [
|
|
1003
|
+
{"id": "d1", "status": "duplicate"}
|
|
1004
|
+
]}, "requires a non-empty 'representative'"),
|
|
1005
|
+
({"product": "p", "slices": base_slices, "inventory": [
|
|
1006
|
+
{"id": "d1", "status": "duplicate", "representative": "d1"}
|
|
1007
|
+
]}, "cannot reference itself"),
|
|
1008
|
+
({"product": "p", "slices": base_slices, "inventory": [
|
|
1009
|
+
{"id": "d1", "status": "duplicate", "representative": "missing"}
|
|
1010
|
+
]}, "must match an inventory or slice id"),
|
|
1011
|
+
({"product": "p", "slices": base_slices, "inventory": [
|
|
1012
|
+
{"id": "n1", "status": "non_target"}
|
|
1013
|
+
]}, "requires a non-empty 'reason'"),
|
|
1014
|
+
({"product": "p", "slices": base_slices, "inventory": [
|
|
1015
|
+
{"id": "b1", "status": "blocked", "evidence": "403 log"}
|
|
1016
|
+
]}, "requires a non-empty 'unblock'"),
|
|
1017
|
+
({"product": "p", "slices": base_slices, "inventory": [
|
|
1018
|
+
{"id": "b1", "status": "blocked", "unblock": "grant token"}
|
|
1019
|
+
]}, "requires a non-empty 'evidence'"),
|
|
1020
|
+
({"product": "p", "slices": base_slices, "inventory": [
|
|
1021
|
+
{"id": "i1", "status": "included", "slice": "no-such-slice"}
|
|
1022
|
+
]}, "must match a slice id"),
|
|
1023
|
+
]
|
|
1024
|
+
mpath = self.repo / "goals" / "manifest.json"
|
|
1025
|
+
for payload, expected in invalid_cases:
|
|
1026
|
+
with self.subTest(expected=expected):
|
|
1027
|
+
mpath.write_text(json.dumps(payload), encoding="utf-8")
|
|
1028
|
+
res = self.loop("manifest", "goals/manifest.json", "--dry-run")
|
|
1029
|
+
self.assertNotEqual(res.returncode, 0)
|
|
1030
|
+
self.assertIn(expected, res.stdout + res.stderr)
|
|
1031
|
+
|
|
1032
|
+
# Valid schema with an unclassified pending item fails the manifest gate even when slices pass.
|
|
1033
|
+
(self.repo / "s1.txt").write_text("", encoding="utf-8")
|
|
1034
|
+
(self.repo / "ok.txt").write_text("", encoding="utf-8")
|
|
1035
|
+
pending_manifest = {
|
|
1036
|
+
"product": "Inventory app",
|
|
1037
|
+
"slices": base_slices,
|
|
1038
|
+
"inventory": [
|
|
1039
|
+
{"id": "item-1", "status": "included", "slice": "s1"},
|
|
1040
|
+
{"id": "item-2", "status": "pending"},
|
|
1041
|
+
],
|
|
1042
|
+
}
|
|
1043
|
+
mpath.write_text(json.dumps(pending_manifest, indent=2), encoding="utf-8")
|
|
1044
|
+
dry = self.loop("manifest", "goals/manifest.json", "--dry-run", "--json")
|
|
1045
|
+
self.assertEqual(dry.returncode, 0, dry.stdout + dry.stderr)
|
|
1046
|
+
self.assertEqual(json.loads(dry.stdout)["inventory_counts"]["pending"], 1)
|
|
1047
|
+
|
|
1048
|
+
blocked_pending = self.loop("manifest", "goals/manifest.json", "--json")
|
|
1049
|
+
self.assertEqual(blocked_pending.returncode, 1, blocked_pending.stdout + blocked_pending.stderr)
|
|
1050
|
+
p_json = json.loads(blocked_pending.stdout)
|
|
1051
|
+
self.assertFalse(p_json["ready"])
|
|
1052
|
+
self.assertEqual(p_json["pending_inventory"], ["item-2"])
|
|
1053
|
+
self.assertEqual(p_json["inventory_counts"], {
|
|
1054
|
+
"included": 1, "duplicate": 0, "non_target": 0, "blocked": 0, "pending": 1,
|
|
1055
|
+
})
|
|
1056
|
+
|
|
1057
|
+
# Classifying all items passes the gate and reports exact inventory counts.
|
|
1058
|
+
classified_manifest = {
|
|
1059
|
+
"product": "Inventory app",
|
|
1060
|
+
"slices": base_slices,
|
|
1061
|
+
"inventory": [
|
|
1062
|
+
{"id": "item-1", "status": "included", "slice": "s1"},
|
|
1063
|
+
{"id": "item-2", "status": "duplicate", "representative": "item-1"},
|
|
1064
|
+
{"id": "item-3", "status": "non_target", "reason": "legacy archive excluded by spec"},
|
|
1065
|
+
{"id": "item-4", "status": "blocked", "evidence": "401 from partner API", "unblock": "provision key", "attempts": 2},
|
|
1066
|
+
],
|
|
1067
|
+
}
|
|
1068
|
+
mpath.write_text(json.dumps(classified_manifest, indent=2), encoding="utf-8")
|
|
1069
|
+
ok_res = self.loop("manifest", "goals/manifest.json", "--json")
|
|
1070
|
+
self.assertEqual(ok_res.returncode, 0, ok_res.stdout + ok_res.stderr)
|
|
1071
|
+
ok_json = json.loads(ok_res.stdout)
|
|
1072
|
+
self.assertTrue(ok_json["ready"])
|
|
1073
|
+
self.assertTrue(ok_json["scope_complete"])
|
|
1074
|
+
self.assertEqual(ok_json["inventory_counts"], {
|
|
1075
|
+
"included": 1, "duplicate": 1, "non_target": 1, "blocked": 1, "pending": 0,
|
|
1076
|
+
})
|
|
1077
|
+
|
|
1078
|
+
def test_sme_gate_blocks_manifest_check_and_run_until_cleared(self):
|
|
1079
|
+
(self.repo / "s1.txt").write_text("", encoding="utf-8")
|
|
1080
|
+
(self.repo / "s2.txt").write_text("", encoding="utf-8")
|
|
1081
|
+
(self.repo / "ok.txt").write_text("", encoding="utf-8")
|
|
1082
|
+
mpath = self.repo / "goals" / "manifest.json"
|
|
1083
|
+
|
|
1084
|
+
# Invalid sme_gate rejected.
|
|
1085
|
+
mpath.write_text(json.dumps({
|
|
1086
|
+
"product": "Complex domain",
|
|
1087
|
+
"sme_gate": "maybe",
|
|
1088
|
+
"slices": [{"id": "s1", "title": "Core", "check": "test -f s1.txt"}],
|
|
1089
|
+
}), encoding="utf-8")
|
|
1090
|
+
bad = self.loop("manifest", "goals/manifest.json", "--dry-run")
|
|
1091
|
+
self.assertNotEqual(bad.returncode, 0)
|
|
1092
|
+
self.assertIn("'sme_gate' must be one of", bad.stdout + bad.stderr)
|
|
1093
|
+
|
|
1094
|
+
# Manifest-level sme_gate: required blocks manifest, check, and run (without invoking harness).
|
|
1095
|
+
manifest = {
|
|
1096
|
+
"product": "Complex domain",
|
|
1097
|
+
"sme_gate": "required",
|
|
1098
|
+
"slices": [
|
|
1099
|
+
{"id": "s1", "title": "Sprint 1", "sprint": 1, "check": "test -f s1.txt"},
|
|
1100
|
+
{"id": "s2", "title": "Sprint 2", "sprint": 2, "sme_gate": "required", "check": "test -f s2.txt"},
|
|
1101
|
+
],
|
|
1102
|
+
}
|
|
1103
|
+
mpath.write_text(json.dumps(manifest, indent=2), encoding="utf-8")
|
|
1104
|
+
m_blocked = self.loop("manifest", "goals/manifest.json", "--json")
|
|
1105
|
+
self.assertEqual(m_blocked.returncode, 1)
|
|
1106
|
+
m_data = json.loads(m_blocked.stdout)
|
|
1107
|
+
self.assertTrue(m_data["sme_gate_blocked"])
|
|
1108
|
+
self.assertFalse(m_data["ready"])
|
|
1109
|
+
self.assertIn("manifest", m_data["sme_gate_blockers"])
|
|
1110
|
+
|
|
1111
|
+
self.goal(manifest="goals/manifest.json", max_iterations=2)
|
|
1112
|
+
chk_blocked = self.loop("check", "goals/g.md")
|
|
1113
|
+
self.assertEqual(chk_blocked.returncode, 0)
|
|
1114
|
+
self.assertIn("check exit 1 (sme_gate)", chk_blocked.stdout)
|
|
1115
|
+
self.assertIn("SME gate required before advancing", chk_blocked.stdout)
|
|
1116
|
+
|
|
1117
|
+
record = self.tmp / "sme_harness.json"
|
|
1118
|
+
run_blocked = self.loop("run", "goals/g.md", action="done", FAKE_RECORD=str(record))
|
|
1119
|
+
self.assertEqual(run_blocked.returncode, 6, run_blocked.stdout + run_blocked.stderr)
|
|
1120
|
+
self.assertIn("SME gate required before advancing", run_blocked.stdout)
|
|
1121
|
+
self.assertFalse(record.exists())
|
|
1122
|
+
summary = self.latest_summary()
|
|
1123
|
+
self.assertEqual(summary["exit_code"], 6)
|
|
1124
|
+
self.assertEqual(summary["exit_reason"], "sme_gate_required")
|
|
1125
|
+
self.assertTrue(summary["scope"]["sme_gate_blocked"])
|
|
1126
|
+
|
|
1127
|
+
# Clearing manifest sme_gate lets Sprint 1 pass while Sprint 2's slice sme_gate still blocks Sprint 2.
|
|
1128
|
+
manifest["sme_gate"] = "cleared"
|
|
1129
|
+
mpath.write_text(json.dumps(manifest, indent=2), encoding="utf-8")
|
|
1130
|
+
s1_ok = self.loop("manifest", "goals/manifest.json", "--sprint", "1", "--json")
|
|
1131
|
+
self.assertEqual(s1_ok.returncode, 0, s1_ok.stdout + s1_ok.stderr)
|
|
1132
|
+
self.assertFalse(json.loads(s1_ok.stdout)["sme_gate_blocked"])
|
|
1133
|
+
|
|
1134
|
+
s2_blocked = self.loop("manifest", "goals/manifest.json", "--sprint", "2", "--json")
|
|
1135
|
+
self.assertEqual(s2_blocked.returncode, 1)
|
|
1136
|
+
self.assertEqual(json.loads(s2_blocked.stdout)["sme_gate_blockers"], ["slice:s2"])
|
|
1137
|
+
|
|
1138
|
+
# Clearing Sprint 2's sme_gate unblocks both manifest and check.
|
|
1139
|
+
manifest["slices"][1]["sme_gate"] = "cleared"
|
|
1140
|
+
mpath.write_text(json.dumps(manifest, indent=2), encoding="utf-8")
|
|
1141
|
+
s2_ok = self.loop("manifest", "goals/manifest.json", "--sprint", "2", "--json")
|
|
1142
|
+
self.assertEqual(s2_ok.returncode, 0, s2_ok.stdout + s2_ok.stderr)
|
|
1143
|
+
self.assertTrue(json.loads(s2_ok.stdout)["scope_complete"])
|
|
1144
|
+
|
|
1145
|
+
chk_ok = self.loop("check", "goals/g.md")
|
|
1146
|
+
self.assertEqual(chk_ok.returncode, 0)
|
|
1147
|
+
self.assertIn("check exit 0 (pass) (already done)", chk_ok.stdout)
|
|
1148
|
+
|
|
1149
|
+
def test_status_reports_not_started_checkpoint_sprint_and_sme_resume_commands(self):
|
|
1150
|
+
manifest = {
|
|
1151
|
+
"product": "Status demo",
|
|
1152
|
+
"slices": [
|
|
1153
|
+
{"id": "slice-1", "title": "Core", "sprint": 1, "check": "test -f s1.txt"},
|
|
1154
|
+
{"id": "slice-2", "title": "Admin", "sprint": 2, "sme_gate": "required", "check": "test -f s2.txt"},
|
|
1155
|
+
],
|
|
1156
|
+
"inventory": [
|
|
1157
|
+
{"id": "i1", "status": "included", "slice": "slice-1"},
|
|
1158
|
+
{"id": "i2", "status": "included", "slice": "slice-2"},
|
|
1159
|
+
],
|
|
1160
|
+
}
|
|
1161
|
+
(self.repo / "goals" / "manifest.json").write_text(json.dumps(manifest, indent=2), encoding="utf-8")
|
|
1162
|
+
self.goal(manifest="goals/manifest.json", active_sprint=1, max_iterations=4, stall_after=9, checkpoint_every=1)
|
|
1163
|
+
|
|
1164
|
+
expected_launcher = "py -3 -B" if os.name == "nt" else "python -B"
|
|
1165
|
+
expected_script = f'"{LOOP}"' if any(ch.isspace() for ch in str(LOOP)) else str(LOOP)
|
|
1166
|
+
expected_s1_cmd = f"{expected_launcher} {expected_script} run goals/g.md --sprint 1"
|
|
1167
|
+
expected_s2_cmd = f"{expected_launcher} {expected_script} run goals/g.md --sprint 2"
|
|
1168
|
+
|
|
1169
|
+
pre_json_run = self.loop("status", "goals/g.md", "--json")
|
|
1170
|
+
self.assertEqual(pre_json_run.returncode, 0, pre_json_run.stdout + pre_json_run.stderr)
|
|
1171
|
+
pre = json.loads(pre_json_run.stdout)
|
|
1172
|
+
self.assertEqual(pre["status"], "not_started")
|
|
1173
|
+
self.assertEqual(pre["iterations_run"], 0)
|
|
1174
|
+
self.assertIsNone(pre["last_exit_code"])
|
|
1175
|
+
self.assertEqual(pre["scope"]["active_sprint"], 1)
|
|
1176
|
+
self.assertEqual(pre["scope"]["deferred_slices"], ["slice-2"])
|
|
1177
|
+
self.assertEqual(pre["scope"]["inventory_counts"]["included"], 2)
|
|
1178
|
+
self.assertEqual(pre["resume_command"], expected_s1_cmd)
|
|
1179
|
+
|
|
1180
|
+
pre_text = self.loop("status", "goals/g.md")
|
|
1181
|
+
self.assertEqual(pre_text.returncode, 0)
|
|
1182
|
+
self.assertIn("goal status (not_started)", pre_text.stdout)
|
|
1183
|
+
self.assertIn(f"resume: {expected_s1_cmd}", pre_text.stdout)
|
|
1184
|
+
|
|
1185
|
+
chkpt = self.loop("run", "goals/g.md", action="progress")
|
|
1186
|
+
self.assertEqual(chkpt.returncode, 6, chkpt.stdout + chkpt.stderr)
|
|
1187
|
+
post_chkpt = json.loads(self.loop("status", "goals/g.md", "--json").stdout)
|
|
1188
|
+
self.assertEqual(post_chkpt["status"], "checkpoint")
|
|
1189
|
+
self.assertEqual(post_chkpt["last_exit_code"], 6)
|
|
1190
|
+
self.assertEqual(post_chkpt["last_exit_reason"], "checkpoint")
|
|
1191
|
+
self.assertEqual(post_chkpt["iterations_run"], 1)
|
|
1192
|
+
self.assertIsNotNone(post_chkpt["last_trail"])
|
|
1193
|
+
self.assertEqual(post_chkpt["resume_command"], expected_s1_cmd)
|
|
1194
|
+
|
|
1195
|
+
s1 = self.loop("run", "goals/g.md", action="sprint1-done")
|
|
1196
|
+
self.assertEqual(s1.returncode, 0, s1.stdout + s1.stderr)
|
|
1197
|
+
post_s1 = json.loads(self.loop("status", "goals/g.md", "--json").stdout)
|
|
1198
|
+
self.assertEqual(post_s1["status"], "sprint_complete")
|
|
1199
|
+
self.assertEqual(post_s1["last_exit_code"], 0)
|
|
1200
|
+
self.assertEqual(post_s1["scope"]["next_sprint"], 2)
|
|
1201
|
+
self.assertEqual(post_s1["resume_command"], expected_s2_cmd)
|
|
1202
|
+
|
|
1203
|
+
s2_sme = json.loads(self.loop("status", "goals/g.md", "--sprint", "2", "--json").stdout)
|
|
1204
|
+
self.assertTrue(s2_sme["scope"]["sme_gate_blocked"])
|
|
1205
|
+
self.assertIn("SME gate required before advancing", s2_sme["resume_note"])
|
|
1206
|
+
|
|
1207
|
+
def test_sprint_cli_override_on_check_and_run_without_editing_frontmatter(self):
|
|
1208
|
+
manifest = {
|
|
1209
|
+
"product": "CLI sprint override",
|
|
1210
|
+
"slices": [
|
|
1211
|
+
{"id": "slice-1", "title": "Core", "sprint": 1, "check": "test -f s1.txt"},
|
|
1212
|
+
{"id": "slice-2", "title": "Extra", "sprint": 2, "check": "test -f s2.txt"},
|
|
1213
|
+
],
|
|
1214
|
+
}
|
|
1215
|
+
(self.repo / "goals" / "manifest.json").write_text(json.dumps(manifest, indent=2), encoding="utf-8")
|
|
1216
|
+
(self.repo / "s1.txt").write_text("", encoding="utf-8")
|
|
1217
|
+
(self.repo / "ok.txt").write_text("", encoding="utf-8")
|
|
1218
|
+
self.goal(manifest="goals/manifest.json", active_sprint=1, max_iterations=2)
|
|
1219
|
+
original_goal = (self.repo / "goals" / "g.md").read_text(encoding="utf-8")
|
|
1220
|
+
|
|
1221
|
+
chk_s1 = self.loop("check", "goals/g.md")
|
|
1222
|
+
self.assertEqual(chk_s1.returncode, 0)
|
|
1223
|
+
self.assertIn("check exit 0 (pass) (already done)", chk_s1.stdout)
|
|
1224
|
+
|
|
1225
|
+
chk_s2 = self.loop("check", "goals/g.md", "--sprint", "2")
|
|
1226
|
+
self.assertEqual(chk_s2.returncode, 0)
|
|
1227
|
+
self.assertIn("active_sprint=2 (CLI override)", chk_s2.stdout)
|
|
1228
|
+
self.assertIn("check exit 1 (manifest)", chk_s2.stdout)
|
|
1229
|
+
|
|
1230
|
+
run_s2 = self.loop("run", "goals/g.md", "--sprint", "2", action="sprint2-done")
|
|
1231
|
+
self.assertEqual(run_s2.returncode, 0, run_s2.stdout + run_s2.stderr)
|
|
1232
|
+
self.assertIn("using CLI --sprint 2 override", run_s2.stdout)
|
|
1233
|
+
self.assertIn("goal met", run_s2.stdout)
|
|
1234
|
+
self.assertEqual((self.repo / "goals" / "g.md").read_text(encoding="utf-8"), original_goal)
|
|
1235
|
+
summary = self.latest_summary()
|
|
1236
|
+
self.assertEqual(summary["scope"]["active_sprint"], 2)
|
|
1237
|
+
self.assertEqual(summary["scope"]["active_sprint_source"], "cli")
|
|
1238
|
+
self.assertTrue(summary["scope"]["scope_complete"])
|
|
1239
|
+
self.assertEqual(summary["scope"]["deferred_slices"], [])
|
|
1240
|
+
|
|
1241
|
+
# Passing --sprint on a goal without a manifest fails cleanly.
|
|
1242
|
+
self.goal(manifest=None)
|
|
1243
|
+
no_manifest = self.loop("check", "goals/g.md", "--sprint", "1")
|
|
1244
|
+
self.assertNotEqual(no_manifest.returncode, 0)
|
|
1245
|
+
self.assertIn("--sprint requires a manifest", no_manifest.stdout + no_manifest.stderr)
|
|
1246
|
+
|
|
1247
|
+
def test_audit_write_goal_auto_detects_single_valid_manifest_and_skips_ambiguous_or_invalid(self):
|
|
1248
|
+
specs = self.repo / "docs" / "specs"
|
|
1249
|
+
specs.mkdir(parents=True)
|
|
1250
|
+
valid_manifest = {"product": "Demo", "slices": [{"id": "s1", "title": "Core", "check": "true"}]}
|
|
1251
|
+
(specs / "app-manifest.json").write_text(json.dumps(valid_manifest), encoding="utf-8")
|
|
1252
|
+
# Invalid manifest should be ignored rather than crashing audit.
|
|
1253
|
+
(specs / "broken-manifest.json").write_text("{not json", encoding="utf-8")
|
|
1254
|
+
|
|
1255
|
+
single = self.loop("audit", "--json", "--write-goal", "goals/auto.md")
|
|
1256
|
+
self.assertEqual(single.returncode, 0, single.stdout + single.stderr)
|
|
1257
|
+
report = json.loads(single.stdout)
|
|
1258
|
+
self.assertEqual(report["guardrails"]["manifests"], ["docs/specs/app-manifest.json"])
|
|
1259
|
+
self.assertEqual(report["recommended"]["manifest"], "docs/specs/app-manifest.json")
|
|
1260
|
+
scaffold = (self.repo / "goals" / "auto.md").read_text(encoding="utf-8")
|
|
1261
|
+
self.assertIn("manifest: docs/specs/app-manifest.json", scaffold)
|
|
1262
|
+
self.assertIn("docs/specs/app-manifest.json", [line for line in scaffold.splitlines() if line.startswith("protect:")][0])
|
|
1263
|
+
|
|
1264
|
+
# Adding a second valid manifest makes selection ambiguous, so audit lists both without guessing.
|
|
1265
|
+
scratch_goals = self.repo / ".scratch" / "goals"
|
|
1266
|
+
scratch_goals.mkdir(parents=True)
|
|
1267
|
+
(scratch_goals / "other-manifest.json").write_text(json.dumps(valid_manifest), encoding="utf-8")
|
|
1268
|
+
multi = self.loop("audit", "--json", "--write-goal", "goals/auto2.md")
|
|
1269
|
+
self.assertEqual(multi.returncode, 0, multi.stdout + multi.stderr)
|
|
1270
|
+
multi_report = json.loads(multi.stdout)
|
|
1271
|
+
self.assertEqual(
|
|
1272
|
+
multi_report["guardrails"]["manifests"],
|
|
1273
|
+
["docs/specs/app-manifest.json", ".scratch/goals/other-manifest.json"],
|
|
1274
|
+
)
|
|
1275
|
+
self.assertNotIn("manifest", multi_report["recommended"])
|
|
1276
|
+
scaffold2 = (self.repo / "goals" / "auto2.md").read_text(encoding="utf-8")
|
|
1277
|
+
self.assertNotIn("\nmanifest:", scaffold2)
|
|
1278
|
+
|
|
1279
|
+
|
|
1280
|
+
class ScanTextSlopCase(unittest.TestCase):
|
|
1281
|
+
def scan(self, name, text):
|
|
1282
|
+
sys.path.insert(0, str(LOOP.parent))
|
|
1283
|
+
self.addCleanup(sys.path.remove, str(LOOP.parent))
|
|
1284
|
+
import loop
|
|
1285
|
+
return [(line, rule) for _, line, rule, _, _ in loop.scan_text_slop(name, text)]
|
|
1286
|
+
|
|
1287
|
+
def test_rust_lifetimes_char_literals_and_raw_strings_do_not_hide_later_slop(self):
|
|
1288
|
+
text = ("fn first<'a>(x: &'a str) -> &'a str { x }\n#[allow(dead_code)]\nfn unused() { todo!() }\n"
|
|
1289
|
+
"let c = '\'';\nlet r = r#\"// TODO inside a raw string\"#;\n")
|
|
1290
|
+
self.assertEqual(self.scan("lib.rs", text), [(2, "suppression-comment"), (3, "stub-placeholder")])
|
|
1291
|
+
|
|
1292
|
+
def test_stray_quotes_in_jsx_and_regex_literals_do_not_hide_later_slop(self):
|
|
1293
|
+
self.assertEqual(self.scan("view.tsx", "const A = () => <p>Don't stop</p>;\n// @ts-ignore\nconst x = 1;\n"),
|
|
1294
|
+
[(2, "suppression-comment")])
|
|
1295
|
+
self.assertEqual(self.scan("re.js", "s.replace(/['\"]/g, '');\ntry { go(); } catch (e) {}\n"),
|
|
1296
|
+
[(2, "swallowed-exception")])
|
|
1297
|
+
|
|
1298
|
+
def test_go_raw_strings_have_no_escapes(self):
|
|
1299
|
+
self.assertEqual(self.scan("raw.go", "var p = `C:\\path\\`\n// nolint\n"), [(2, "suppression-comment")])
|
|
1300
|
+
|
|
1301
|
+
def test_prose_mentioning_placeholder_is_not_a_stub_but_leading_markers_are(self):
|
|
1302
|
+
self.assertEqual(self.scan("ui.ts", "// Renders the placeholder text when empty\n"), [])
|
|
1303
|
+
self.assertEqual(self.scan("ui.ts", "// placeholder until the API lands\n// later TODO wire it\n"),
|
|
1304
|
+
[(1, "stub-placeholder"), (2, "stub-placeholder")])
|
|
1305
|
+
def test_broad_catches_that_only_continue_return_or_break_are_swallowed(self):
|
|
1306
|
+
text = ("def a(xs):\n for x in xs:\n try:\n go(x)\n except Exception:\n continue\n"
|
|
1307
|
+
"def b():\n try:\n return go()\n except Exception:\n return None\n"
|
|
1308
|
+
"def c():\n with contextlib.suppress(Exception):\n go()\n"
|
|
1309
|
+
"def d():\n try:\n go()\n except Exception:\n log.exception('x')\n raise\n")
|
|
1310
|
+
self.assertEqual(self.scan("m.py", text), [(5, "swallowed-exception"), (10, "swallowed-exception"),
|
|
1311
|
+
(13, "swallowed-exception")])
|
|
1312
|
+
|
|
1313
|
+
def test_bare_except_that_reraises_is_allowed(self):
|
|
1314
|
+
self.assertEqual(self.scan("m.py", "try:\n go()\nexcept:\n cleanup()\n raise\n"), [])
|
|
1315
|
+
|
|
1316
|
+
def test_not_implemented_stubs_inside_handlers_and_match_cases_are_found_but_dispatch_fallbacks_are_not(self):
|
|
1317
|
+
text = ("def a(x):\n try:\n return go(x)\n except KeyError:\n raise NotImplementedError\n"
|
|
1318
|
+
"def b(kind):\n match kind:\n case 'csv':\n raise NotImplementedError('todo: csv')\n"
|
|
1319
|
+
"def c(kind):\n if kind == 'json':\n return 1\n raise NotImplementedError(f'unsupported kind {kind}')\n")
|
|
1320
|
+
self.assertEqual(self.scan("m.py", text), [(5, "stub-placeholder"), (9, "stub-placeholder")])
|
|
1321
|
+
|
|
1322
|
+
def test_more_python_and_rust_suppressions_are_recognized(self):
|
|
1323
|
+
text = ("x = 1 # pylint: disable=unused-variable\ny = eval(s) # nosec\n"
|
|
1324
|
+
"def z(): # pragma: no cover\n return 1\n# mypy: ignore-errors\n")
|
|
1325
|
+
self.assertEqual([r for _, r in self.scan("m.py", text)], ["suppression-comment"] * 4)
|
|
1326
|
+
self.assertEqual(self.scan("lib.rs", "#[expect(dead_code)]\nfn f() {}\n"), [(1, "suppression-comment")])
|
|
1327
|
+
|
|
1328
|
+
def test_block_comment_continuation_lines_are_scanned(self):
|
|
1329
|
+
text = "/**\n * Loads the view.\n * TODO wire the cache\n * eslint-disable no-console\n */\nexport const a = 1;\n"
|
|
1330
|
+
self.assertEqual(self.scan("ui.ts", text), [(3, "stub-placeholder"), (4, "suppression-comment")])
|
|
1331
|
+
|
|
1332
|
+
def test_inline_block_comment_rust_stub_multi_comment_and_js_regex_slop(self):
|
|
1333
|
+
self.assertEqual(self.scan("lib.rs", "/* ok */ todo!();\n"), [(1, "stub-placeholder")])
|
|
1334
|
+
self.assertEqual(
|
|
1335
|
+
self.scan("multi.ts", "/* a */ const x = 1; /* b\n * TODO finish\n */\n"),
|
|
1336
|
+
[(2, "stub-placeholder")],
|
|
1337
|
+
)
|
|
1338
|
+
self.assertEqual(
|
|
1339
|
+
self.scan("re.js", "const re = /https?:\\/\\//; try { go(); } catch (e) {}\n"),
|
|
1340
|
+
[(1, "swallowed-exception")],
|
|
1341
|
+
)
|
|
1342
|
+
|
|
1343
|
+
def test_nested_pyproject_and_package_json_and_root_tool_sections_protected(self):
|
|
1344
|
+
sys.path.insert(0, str(LOOP.parent))
|
|
1345
|
+
self.addCleanup(sys.path.remove, str(LOOP.parent))
|
|
1346
|
+
import loop
|
|
1347
|
+
with tempfile.TemporaryDirectory(prefix="loop-guard-") as tmp:
|
|
1348
|
+
root = Path(tmp)
|
|
1349
|
+
(root / "package.json").write_text(
|
|
1350
|
+
json.dumps({"name": "root", "eslintConfig": {"rules": {"no-console": "error"}}}),
|
|
1351
|
+
encoding="utf-8",
|
|
1352
|
+
)
|
|
1353
|
+
(root / "subpkg").mkdir()
|
|
1354
|
+
(root / "subpkg" / "pyproject.toml").write_text('[tool.ruff]\nselect = ["E"]\n', encoding="utf-8")
|
|
1355
|
+
(root / "packages" / "app").mkdir(parents=True)
|
|
1356
|
+
(root / "packages" / "app" / "package.json").write_text(
|
|
1357
|
+
json.dumps({"name": "app", "scripts": {"lint": "eslint ."}}),
|
|
1358
|
+
encoding="utf-8",
|
|
1359
|
+
)
|
|
1360
|
+
before = loop.guardrail_state(str(root), set())
|
|
1361
|
+
self.assertIn("package.json scripts", before)
|
|
1362
|
+
self.assertIn("subpkg/pyproject.toml [tool.*]", before)
|
|
1363
|
+
self.assertIn("packages/app/package.json [guardrails]", before)
|
|
1364
|
+
|
|
1365
|
+
# Weakening root eslintConfig, nested pyproject.toml, or nested package.json scripts must change state.
|
|
1366
|
+
(root / "package.json").write_text(
|
|
1367
|
+
json.dumps({"name": "root", "eslintConfig": {"rules": {}}}),
|
|
1368
|
+
encoding="utf-8",
|
|
1369
|
+
)
|
|
1370
|
+
self.assertNotEqual(before, loop.guardrail_state(str(root), set()))
|
|
1371
|
+
|
|
1372
|
+
(root / "subpkg" / "pyproject.toml").write_text("[tool.ruff]\nselect = []\n", encoding="utf-8")
|
|
1373
|
+
after_sub = loop.guardrail_state(str(root), set())
|
|
1374
|
+
self.assertNotEqual(before["subpkg/pyproject.toml [tool.*]"], after_sub["subpkg/pyproject.toml [tool.*]"])
|
|
1375
|
+
|
|
1376
|
+
(root / "packages" / "app" / "package.json").write_text(
|
|
1377
|
+
json.dumps({"name": "app", "scripts": {"lint": "true"}}),
|
|
1378
|
+
encoding="utf-8",
|
|
1379
|
+
)
|
|
1380
|
+
after_pkg = loop.guardrail_state(str(root), set())
|
|
1381
|
+
self.assertNotEqual(
|
|
1382
|
+
before["packages/app/package.json [guardrails]"],
|
|
1383
|
+
after_pkg["packages/app/package.json [guardrails]"],
|
|
1384
|
+
)
|
|
1385
|
+
|
|
1386
|
+
# _rel_inside_root allows `..env` inside root and rejects `../outside`.
|
|
1387
|
+
self.assertEqual(loop._rel_inside_root(str(root / "..env"), str(root)), "..env")
|
|
1388
|
+
self.assertIsNone(loop._rel_inside_root(str(root.parent / "outside.txt"), str(root)))
|
|
1389
|
+
|
|
1390
|
+
def test_corrupted_goal_frontmatter_exits_4_and_writes_summary(self):
|
|
1391
|
+
with tempfile.TemporaryDirectory(prefix="loop-corrupt-") as tmp:
|
|
1392
|
+
root = Path(tmp)
|
|
1393
|
+
subprocess.run(["git", "init", "-q", "-b", "main", str(root)], check=True, capture_output=True)
|
|
1394
|
+
bin_dir = root / "bin"
|
|
1395
|
+
bin_dir.mkdir()
|
|
1396
|
+
(root / "check.sh").write_text("#!/bin/sh\ntest -f ok.txt\n", encoding="utf-8")
|
|
1397
|
+
(root / "goals").mkdir()
|
|
1398
|
+
goal = root / "goals" / "g.md"
|
|
1399
|
+
goal.write_text(
|
|
1400
|
+
"---\ngoal: test corrupt\ncheck: test -f ok.txt\nprotect: check.sh\nmax_iterations: 2\nmax_cost_usd: 1\n---\nPlan.\n",
|
|
1401
|
+
encoding="utf-8",
|
|
1402
|
+
)
|
|
1403
|
+
corrupt_script = bin_dir / "corrupt_omp.py"
|
|
1404
|
+
corrupt_script.write_text(
|
|
1405
|
+
'import sys; sys.stdin.read(); open("goals/g.md", "w", encoding="utf-8").write("no frontmatter\\n")\n',
|
|
1406
|
+
encoding="utf-8",
|
|
1407
|
+
)
|
|
1408
|
+
if os.name == "nt":
|
|
1409
|
+
(bin_dir / "omp.cmd").write_text(f'@"{sys.executable}" "{corrupt_script}" %*\r\n', encoding="utf-8")
|
|
1410
|
+
else:
|
|
1411
|
+
omp = bin_dir / "omp"
|
|
1412
|
+
omp.write_text(f'#!/bin/sh\nexec "{sys.executable}" "{corrupt_script}" "$@"\n', encoding="utf-8")
|
|
1413
|
+
omp.chmod(0o755)
|
|
1414
|
+
env = {**os.environ, "PATH": str(bin_dir) + os.pathsep + os.environ.get("PATH", "")}
|
|
1415
|
+
proc = subprocess.run(
|
|
1416
|
+
[sys.executable, "-B", str(LOOP), "run", "goals/g.md", "--harness", "omp"],
|
|
1417
|
+
cwd=str(root), capture_output=True, text=True, env=env,
|
|
1418
|
+
)
|
|
1419
|
+
self.assertEqual(proc.returncode, 4, proc.stdout + proc.stderr)
|
|
1420
|
+
summary = json.loads((root / ".scratch" / "goals" / "g" / "latest-summary.json").read_text(encoding="utf-8"))
|
|
1421
|
+
self.assertEqual(summary["exit_code"], 4)
|
|
1422
|
+
self.assertEqual(summary["exit_reason"], "tampered_frontmatter")
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
if __name__ == "__main__":
|
|
1426
|
+
unittest.main()
|