fix: runAutoCommit detached HEAD + blocker OrgEvent on exit 2 (ops-71)#134
Merged
fix: runAutoCommit detached HEAD + blocker OrgEvent on exit 2 (ops-71)#134
Conversation
…s-71) Two bugs in the auto-commit pipeline: 1. Detached HEAD state: git worktrees can be in detached HEAD after codex finishes. Now checks git symbolic-ref --quiet HEAD first; if detached, runs git checkout -b <branch> before committing. 2. PR creation failure (exit 2): tps agent commit now exits 2 when push succeeds but gh pr create fails. Previously this was swallowed silently. Now publishes a blocker OrgEvent with the branch name so team can see it and manually run gh pr create --head <branch>. Also exports runAutoCommit with clean dependency injection (spawnSyncImpl, tpsCommand) for testability. Internal _runAutoCommitLegacy wraps it for the existing mail loop call site. Ember implemented. Anvil integrated. 547/547 tests pass.
tps-sherlock
approved these changes
Mar 7, 2026
Contributor
tps-sherlock
left a comment
There was a problem hiding this comment.
LGTM. Fixed the detached HEAD issue and added visibility into PR creation failures via the blocker OrgEvent. Non-fatal handling in the loop is still preserved.
tps-sherlock
approved these changes
Mar 7, 2026
Contributor
tps-sherlock
left a comment
There was a problem hiding this comment.
Security and architecture review:
- The
runAutoCommitlogic safely checks for a detached HEAD state viasymbolic-refbefore committing, ensuring commits aren't orphaned. - Exit code 2 from
tps agent commit(PR creation failure) is correctly caught and mapped to ablockerOrgEvent, providing visibility into the failure without silent drops. - The unit tests accurately cover the spawn branches and the new failure injection.
LGTM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two bugs in the auto-commit pipeline that blocked Ember's autonomous PR creation:
1. Detached HEAD state
Git worktrees land in detached HEAD after Codex finishes execution.
tps agent commitcouldn't create a branch from there. Now checksgit symbolic-ref --quiet HEADbefore committing; if detached, runsgit checkout -b <branch>first.2. Silent PR creation failure
tps agent commitexits code 2 when push succeeds butgh pr createfails. Previously the auto-commit loop swallowed this silently. Now publishes ablockerOrgEvent with the branch name so the team can see it and manually rungh pr create --head <branch>.Also: exports
runAutoCommitwith dependency injection (spawnSyncImpl,tpsCommand) for testability. Internal_runAutoCommitLegacywraps it for the existing call site.Ember implemented, Anvil integrated. Closes ops-71. 547/547 tests pass.