|
58 | 58 | RULES_SCRIPT = REPO_ROOT / "scripts" / "rules_command.py" |
59 | 59 | RESILIENCE_SCRIPT = REPO_ROOT / "scripts" / "context_resilience_command.py" |
60 | 60 | BROWSER_SCRIPT = REPO_ROOT / "scripts" / "browser_command.py" |
| 61 | +START_WORK_SCRIPT = REPO_ROOT / "scripts" / "start_work_command.py" |
61 | 62 | BASE_CONFIG = REPO_ROOT / "opencode.json" |
62 | 63 |
|
63 | 64 |
|
@@ -1649,6 +1650,122 @@ def run_bg(*args: str) -> subprocess.CompletedProcess[str]: |
1649 | 1650 | "browser doctor should report ready selected provider after reset", |
1650 | 1651 | ) |
1651 | 1652 |
|
| 1653 | + plan_path = tmp / "plan_execution_selftest.md" |
| 1654 | + plan_path.write_text( |
| 1655 | + """--- |
| 1656 | +id: selftest-plan-001 |
| 1657 | +title: Selftest Plan |
| 1658 | +owner: selftest |
| 1659 | +created_at: 2026-02-13T00:00:00Z |
| 1660 | +version: 1 |
| 1661 | +--- |
| 1662 | +
|
| 1663 | +# Plan |
| 1664 | +
|
| 1665 | +- [x] 1. Preserve previously completed setup |
| 1666 | +- [ ] 2. Execute pending task |
| 1667 | +- [ ] 3. Capture final checkpoint |
| 1668 | +""", |
| 1669 | + encoding="utf-8", |
| 1670 | + ) |
| 1671 | + |
| 1672 | + start_work = subprocess.run( |
| 1673 | + [ |
| 1674 | + sys.executable, |
| 1675 | + str(START_WORK_SCRIPT), |
| 1676 | + str(plan_path), |
| 1677 | + "--deviation", |
| 1678 | + "manual verification note", |
| 1679 | + "--json", |
| 1680 | + ], |
| 1681 | + capture_output=True, |
| 1682 | + text=True, |
| 1683 | + env=refactor_env, |
| 1684 | + check=False, |
| 1685 | + cwd=REPO_ROOT, |
| 1686 | + ) |
| 1687 | + expect(start_work.returncode == 0, "start-work should execute valid plan") |
| 1688 | + start_work_report = parse_json_output(start_work.stdout) |
| 1689 | + expect( |
| 1690 | + start_work_report.get("status") == "completed", |
| 1691 | + "start-work should report completed status for fully executed plan", |
| 1692 | + ) |
| 1693 | + expect( |
| 1694 | + start_work_report.get("step_counts", {}).get("completed") == 3, |
| 1695 | + "start-work should complete all plan steps", |
| 1696 | + ) |
| 1697 | + expect( |
| 1698 | + start_work_report.get("deviation_count", 0) >= 2, |
| 1699 | + "start-work should capture precompleted and manual deviations", |
| 1700 | + ) |
| 1701 | + |
| 1702 | + start_work_status = subprocess.run( |
| 1703 | + [sys.executable, str(START_WORK_SCRIPT), "status", "--json"], |
| 1704 | + capture_output=True, |
| 1705 | + text=True, |
| 1706 | + env=refactor_env, |
| 1707 | + check=False, |
| 1708 | + cwd=REPO_ROOT, |
| 1709 | + ) |
| 1710 | + expect(start_work_status.returncode == 0, "start-work status should succeed") |
| 1711 | + start_work_status_report = parse_json_output(start_work_status.stdout) |
| 1712 | + expect( |
| 1713 | + start_work_status_report.get("status") == "completed", |
| 1714 | + "start-work status should persist latest run status", |
| 1715 | + ) |
| 1716 | + |
| 1717 | + start_work_deviations = subprocess.run( |
| 1718 | + [sys.executable, str(START_WORK_SCRIPT), "deviations", "--json"], |
| 1719 | + capture_output=True, |
| 1720 | + text=True, |
| 1721 | + env=refactor_env, |
| 1722 | + check=False, |
| 1723 | + cwd=REPO_ROOT, |
| 1724 | + ) |
| 1725 | + expect( |
| 1726 | + start_work_deviations.returncode == 0, |
| 1727 | + "start-work deviations should succeed", |
| 1728 | + ) |
| 1729 | + start_work_deviation_report = parse_json_output(start_work_deviations.stdout) |
| 1730 | + expect( |
| 1731 | + start_work_deviation_report.get("count", 0) >= 2, |
| 1732 | + "start-work deviations should return captured deviation entries", |
| 1733 | + ) |
| 1734 | + |
| 1735 | + invalid_plan_path = tmp / "invalid_plan_execution_selftest.md" |
| 1736 | + invalid_plan_path.write_text( |
| 1737 | + """--- |
| 1738 | +id: invalid-plan-001 |
| 1739 | +title: Invalid Plan |
| 1740 | +owner: selftest |
| 1741 | +created_at: 2026-02-13T00:00:00Z |
| 1742 | +version: 1 |
| 1743 | +--- |
| 1744 | +
|
| 1745 | +# Plan |
| 1746 | +
|
| 1747 | +- [ ] validate command wiring without ordinal |
| 1748 | +""", |
| 1749 | + encoding="utf-8", |
| 1750 | + ) |
| 1751 | + invalid_start_work = subprocess.run( |
| 1752 | + [sys.executable, str(START_WORK_SCRIPT), str(invalid_plan_path), "--json"], |
| 1753 | + capture_output=True, |
| 1754 | + text=True, |
| 1755 | + env=refactor_env, |
| 1756 | + check=False, |
| 1757 | + cwd=REPO_ROOT, |
| 1758 | + ) |
| 1759 | + expect( |
| 1760 | + invalid_start_work.returncode == 1, |
| 1761 | + "start-work should fail invalid plan artifacts", |
| 1762 | + ) |
| 1763 | + invalid_start_work_report = parse_json_output(invalid_start_work.stdout) |
| 1764 | + expect( |
| 1765 | + invalid_start_work_report.get("code") == "validation_failed", |
| 1766 | + "start-work should report validation_failed for invalid plan format", |
| 1767 | + ) |
| 1768 | + |
1652 | 1769 | keyword_report = resolve_prompt_modes( |
1653 | 1770 | "Please safe-apply and deep-analyze this migration; ulw can wait.", |
1654 | 1771 | enabled=True, |
|
0 commit comments