fix(#1148): derive PR title from first commit when agent makes multiple commits - #1150
Conversation
…le commits The post-code script used `git log -1 --format='%s' HEAD` to derive the PR title, which always selected the last commit's subject. When agents make multiple commits, the last one may be a minor follow-up (e.g. shellcheck suppression) rather than the primary feature commit. This produced misleading PR titles that led to reviewer confusion and wasted agent costs. When the commit range between merge-base and HEAD contains more than one commit, the script now uses the first commit's subject instead. The first commit is typically the primary work; subsequent commits are follow-ups like lint fixes or test adjustments. Changed files: - scripts/post-code.src.sh: multi-commit title selection logic - scripts/post-code.sh: regenerated bundle (make script-build) - scripts/post-code-test.sh: unit tests and git integration tests for single-commit and multi-commit title selection Note: pre-commit could not run (network-restricted sandbox). Hooks were run directly: shellcheck passed, trailing-whitespace clean, end-of-file-fixer clean. Closes #1148
|
🤖 Finished Review · ✅ Success · Started 5:37 PM UTC · Completed 5:54 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $4.14 |
|
Risk Assessment: moderate (2/5) DetailsFocused bot-authored bug fix in 3 script files (protected paths) with moderate line count and good test coverage; git history shows extreme churn, many authors, and frequent fix commits but the change is well-scoped and issue-aligned, preserving prior moderate score as Tier 1 signals are unchanged. Previous runRisk Assessment: moderate (2/5) DetailsFocused bot-authored bug fix in 3 script files (protected paths) with moderate line count and good test coverage; git history shows extreme churn, many authors, and frequent fix commits but the change is well-scoped and issue-aligned, preserving prior moderate score as Tier 1 signals are unchanged. Previous run (2)Risk Assessment: moderate (2/5) DetailsFocused bot-authored bug fix in 3 scripts files (protected path) with moderate line count and good test coverage, but the affected files show extremely high churn, many authors, and frequent regression fixes in recent history, pushing git-history risk to near-maximum; composite settles at moderate given the well-scoped change and clear issue alignment. |
ReviewFindingsMedium
Previous runReviewFindingsMedium
Low
Next steps:
Previous run (2)ReviewFindingsMedium
Low
Next steps:
|
|
🤖 Finished Fix · ✅ Success · Started 5:56 PM UTC · Completed 6:01 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $1.21 |
- Rename REAL_GIT_MC to MC_REAL_GIT to match GL_REAL_GIT naming convention - Replace tail -1 with head -1 in select_commit_subject single-commit branch to faithfully model production code's HEAD-based semantics Addresses #1150
🔧 Fix agent — iteration 1 (bot-triggered)Addressed all three review findings: (1) acknowledged protected-path governance requirement as out-of-scope for code fix, (2) renamed REAL_GIT_MC to MC_REAL_GIT to follow GL_REAL_GIT naming convention, (3) replaced tail -1 with head -1 in test helper to match production semantics. All tests pass. Fixed (2):
Disagreed (1):
Tests: passedNext steps:
|
|
🤖 Finished Review · ✅ Success · Started 6:03 PM UTC · Completed 6:20 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $4.02 |
|
🤖 Finished Fix · ✅ Success · Started 6:22 PM UTC · Completed 6:28 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $1.32 |
Collapse dead-code if/else in select_commit_subject test helper — both branches were identical (head -1). Rename MULTI_COMMIT_TMPDIR to MC_TMPDIR for consistency with the MC_ prefix convention used by all other variables in the integration test section. Addresses #1150
🔧 Fix agent — iteration 2 (bot-triggered)Addressed all three review findings: (1) collapsed dead-code if/else in select_commit_subject test helper into a single expression since both branches were identical, (2) renamed MULTI_COMMIT_TMPDIR to MC_TMPDIR for naming consistency with MC_ prefix convention, (3) acknowledged protected-path governance requirement as out-of-scope for code fix. All tests pass. Fixed (2):
Disagreed (1):
Tests: passedNext steps:
|
|
🤖 Finished Review · ✅ Success · Started 6:29 PM UTC · Completed 6:45 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $3.91 |
Superseded by updated review
|
🤖 Finished Retro · ✅ Success · Started 9:14 PM UTC · Completed 9:28 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $5.94 |
|
Pipeline validation: This PR demonstrates the retro-to-issue-to-code pipeline working as intended. The retro agent on PR #1125 correctly identified that Review-fix cost amplification: The review-fix cycle cost $14.60 across 3 reviews ($12.07) and 2 fix iterations ($2.53), with approximately $9.25 (63%) spent resolving cascading issues introduced by Fix 1. Review 1 found two low-severity cosmetic findings (variable naming convention and Evidence for existing issues:
Proposals filed
|
Summary
The post-code script (
scripts/post-code.src.sh) derived PR titles usinggit log -1 --format='%s' HEAD, which always selected the last commit's subject. When agents make multiple commits, the last one is often a minor follow-up (e.g. shellcheck suppression, lint fix) rather than the primary feature commit. This produced misleading PR titles — the exact cause of PR #1125 being closed, wasting $45.65 in agent costs.Fix: When the commit range between merge-base and HEAD contains more than one commit, the script now uses the first commit's subject. The first commit is typically the primary work; subsequent commits are follow-ups.
Changes
scripts/post-code.src.sh(line 662): Replace singlegit log -1with commit-count check — use first commit's subject when multiple commits exist, preserving existing behavior for single-commit casesscripts/post-code.sh: Regenerated bundle viamake script-buildscripts/post-code-test.sh: Added 4 new tests (3 unit + 1 git integration) covering single-commit, multi-commit, and three-commit scenariosTesting
bash scripts/post-code-test.sh)make check-bundleconfirms bundled script matches sourceCloses #1148
Post-script verification
agent/1148-pr-title-first-commit)995e6c671328063ed0bc6d2f85ac7818cf425555..HEAD)