Commit 4a63ad0
fix(agent): deploy_change pushes branch + opens PR (no more ghost-deploy)
Strategy-agent end-to-end audit (post-PR-A1..A12) caught a critical bug
that hadn't fired yet because no agent deploy has succeeded since the
agent was built (24 trades < 50-trade safety floor, so all weekly runs
have been "no-deploy diagnostic"). The first time it tries to deploy:
agent_writes.deploy_change does:
1. git checkout -b agent/change-<timestamp>
2. git add <files> && git commit
3. git checkout main
4. git merge agent/change-<timestamp> --no-ff ← LOCAL only
5. git branch -d agent/change-<timestamp>
Step 4's merge commit lives only on the runner's local checkout of
main. There is NO `git push`. When the runner shuts down, the merge
commit is discarded.
Meanwhile the workflow's "Open PR for agent code changes" step
(added in PR #160) does:
git add <agent-modifiable-files>
git diff --cached --quiet → exit deployed=false if no staged diff
Because the agent already committed and merged locally, there are no
staged changes. The workflow exits deployed=false. No PR is opened.
No notification fires. The agent's changelog records status=deployed
with a commit_sha that points at the discarded local merge commit.
Net effect: ghost deploy. Changelog says deployed; live code is
unchanged. compute_measured_impact 5 days later compares equal-state
windows, reports no effect. The agent may re-attempt the same change
on the next eligible cycle (after 14d cooling), perpetually
ghost-deploying.
Fix: deploy_change does the push and opens the PR itself.
- After commit on the feature branch, `git push origin <branch>
--force-with-lease`.
- `gh pr create` to open the PR; on failure (re-run same day; PR
already exists), recover URL via `gh pr view`.
- Persist PR URL to data/agent/last_pr_url.txt for the workflow's
Telegram step to pick up.
- DO NOT merge to local main. main is protected — the PR is the
deploy gate, CI runs on it, merging requires the operator (or an
auto-merge rule).
Workflow change: the "Open PR for agent code changes" step is renamed
to "Surface agent deploy PR" and rewritten to read the PR URL the
agent persisted. It no longer does its own push or pr-create — that
responsibility now lives entirely in agent_writes.deploy_change. The
"Run Strategy Agent" step gets GH_TOKEN env so the agent's gh CLI
calls authenticate.
Tests: 3 new in TestDeployChange covering the new push+PR path —
successful PR creation, gh pr create fails (PR already exists)
recovery via gh pr view, git push failure aborts cleanly.
The obsolete test_merge_failure was removed (no merge step anymore).
Verified locally: 2820 tests pass (was 2818; net +2).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 9607917 commit 4a63ad0
3 files changed
Lines changed: 213 additions & 84 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
101 | 107 | | |
102 | 108 | | |
103 | 109 | | |
| |||
134 | 140 | | |
135 | 141 | | |
136 | 142 | | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
141 | 151 | | |
142 | 152 | | |
143 | 153 | | |
144 | 154 | | |
145 | 155 | | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
190 | 178 | | |
191 | 179 | | |
192 | 180 | | |
193 | 181 | | |
194 | 182 | | |
195 | 183 | | |
196 | 184 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | 185 | | |
201 | 186 | | |
202 | 187 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
550 | 550 | | |
551 | 551 | | |
552 | 552 | | |
553 | | - | |
| 553 | + | |
| 554 | + | |
554 | 555 | | |
555 | 556 | | |
556 | 557 | | |
557 | 558 | | |
558 | 559 | | |
559 | 560 | | |
| 561 | + | |
| 562 | + | |
560 | 563 | | |
561 | 564 | | |
562 | 565 | | |
| |||
591 | 594 | | |
592 | 595 | | |
593 | 596 | | |
594 | | - | |
595 | | - | |
596 | | - | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
597 | 612 | | |
598 | 613 | | |
599 | | - | |
600 | | - | |
| 614 | + | |
601 | 615 | | |
| 616 | + | |
602 | 617 | | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
608 | 628 | | |
609 | | - | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
610 | 643 | | |
611 | | - | |
612 | | - | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
613 | 657 | | |
614 | 658 | | |
615 | 659 | | |
616 | 660 | | |
617 | | - | |
618 | | - | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
619 | 667 | | |
620 | 668 | | |
621 | 669 | | |
622 | 670 | | |
623 | | - | |
| 671 | + | |
624 | 672 | | |
625 | 673 | | |
626 | | - | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
627 | 679 | | |
628 | | - | |
| 680 | + | |
629 | 681 | | |
630 | 682 | | |
631 | 683 | | |
632 | 684 | | |
| 685 | + | |
| 686 | + | |
633 | 687 | | |
634 | 688 | | |
635 | 689 | | |
| |||
0 commit comments