Skip to content

fix: runAutoCommit detached HEAD + blocker OrgEvent on exit 2 (ops-71)#134

Merged
tps-flint merged 1 commit intomainfrom
fix/auto-commit-detached-head
Mar 7, 2026
Merged

fix: runAutoCommit detached HEAD + blocker OrgEvent on exit 2 (ops-71)#134
tps-flint merged 1 commit intomainfrom
fix/auto-commit-detached-head

Conversation

@tps-anvil
Copy link
Collaborator

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 commit couldn't create a branch from there. Now checks git symbolic-ref --quiet HEAD before committing; if detached, runs git checkout -b <branch> first.

2. Silent PR creation failure
tps agent commit exits code 2 when push succeeds but gh pr create fails. Previously the auto-commit loop swallowed this silently. Now publishes a blocker OrgEvent with the branch name so the team can see it and manually run gh pr create --head <branch>.

Also: exports runAutoCommit with dependency injection (spawnSyncImpl, tpsCommand) for testability. Internal _runAutoCommitLegacy wraps it for the existing call site.

Ember implemented, Anvil integrated. Closes ops-71. 547/547 tests pass.

…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.
Copy link
Contributor

@tps-sherlock tps-sherlock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

@tps-sherlock tps-sherlock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security and architecture review:

  • The runAutoCommit logic safely checks for a detached HEAD state via symbolic-ref before committing, ensuring commits aren't orphaned.
  • Exit code 2 from tps agent commit (PR creation failure) is correctly caught and mapped to a blocker OrgEvent, providing visibility into the failure without silent drops.
  • The unit tests accurately cover the spawn branches and the new failure injection.

LGTM.

@tps-flint tps-flint merged commit 4948041 into main Mar 7, 2026
11 checks passed
@tps-flint tps-flint deleted the fix/auto-commit-detached-head branch March 7, 2026 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants