Skip to content

fix(#1148): derive PR title from first commit when agent makes multiple commits - #1150

Merged
ralphbean merged 3 commits into
mainfrom
agent/1148-pr-title-first-commit
Sep 2, 2026
Merged

fix(#1148): derive PR title from first commit when agent makes multiple commits#1150
ralphbean merged 3 commits into
mainfrom
agent/1148-pr-title-first-commit

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

Summary

The post-code script (scripts/post-code.src.sh) derived PR titles using git 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 single git log -1 with commit-count check — use first commit's subject when multiple commits exist, preserving existing behavior for single-commit cases
  • scripts/post-code.sh: Regenerated bundle via make script-build
  • scripts/post-code-test.sh: Added 4 new tests (3 unit + 1 git integration) covering single-commit, multi-commit, and three-commit scenarios

Testing

  • All 164 existing + new tests pass (bash scripts/post-code-test.sh)
  • make check-bundle confirms bundled script matches source
  • shellcheck passes on changed files
  • Secret scan passes on all changed files and staged content

Closes #1148

Post-script verification

  • Branch is not main/master (agent/1148-pr-title-first-commit)
  • Secret scan passed (gitleaks — 995e6c671328063ed0bc6d2f85ac7818cf425555..HEAD)
  • PR body secret scan passed (gitleaks — no-git)

…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
@fullsend-ai-coder
fullsend-ai-coder Bot requested a review from a team as a code owner September 2, 2026 17:35
@fullsend-ai-coder fullsend-ai-coder Bot added the ready-for-review Triggers review agent dispatch label Sep 2, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Sep 2, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 5:37 PM UTC · Completed 5:54 PM UTC

Commit: 0a50581 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $4.14

@fullsend-ai-review fullsend-ai-review Bot added the risk/moderate PR risk: moderate label Sep 2, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Sep 2, 2026

Copy link
Copy Markdown

Risk Assessment: moderate (2/5)

Details

Focused 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

Risk Assessment: moderate (2/5)

Details

Focused 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)

Details

Focused 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.

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 2, 2026

Copy link
Copy Markdown

Review

Findings

Medium

Previous run

Review

Findings

Medium

  • [test fidelity] scripts/post-code-test.sh:196 — The select_commit_subject test helper has identical logic in both branches of its if/else — both execute echo "${commit_subjects}" | head -1 regardless of commit_count. This makes the conditional dead code and means the unit tests do not actually verify that different code paths are taken for single-commit vs. multi-commit cases. The integration tests below mirror the production code correctly and would catch regressions, partially mitigating the risk.
    Remediation: Either collapse the if/else into a single echo "${commit_subjects}" | head -1, or differentiate the branches to model the production semantics more faithfully.

  • [protected-path] scripts/post-code.src.sh — This PR modifies files under the protected scripts/ path: scripts/post-code.src.sh, scripts/post-code.sh, scripts/post-code-test.sh. The PR links to issue Post-code script should derive PR title from primary commit, not last commit #1148 and explains the rationale for the change. Human approval is always required for protected-path changes, regardless of context.

Low

  • [naming-convention] scripts/post-code-test.sh:233 — The temp directory variable MULTI_COMMIT_TMPDIR uses a long-form prefix while all other variables in the same test section use the abbreviated MC_ prefix (MC_REAL_GIT, _mc_repo, _mc_merge_base, etc.). The established convention in this file is to use a consistent short prefix across all variables in a section.
    Remediation: Rename MULTI_COMMIT_TMPDIR to MC_TMPDIR for consistency with the MC_ prefix used by all other variables in this section.

Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR
Previous run (2)

Review

Findings

Medium

Low

  • [naming-convention] scripts/post-code-test.sh:233 — The variable REAL_GIT_MC places the section prefix after REAL_GIT, whereas the established convention places it before: GL_REAL_GIT. The expected form is MC_REAL_GIT.
    Remediation: Rename REAL_GIT_MC to MC_REAL_GIT to match the GL_REAL_GIT precedent.

  • [test fidelity] scripts/post-code-test.sh:196 — The test helper select_commit_subject uses tail -1 for the single-commit branch, but the production code uses git log -1 --format='%s' HEAD. While functionally equivalent for single-line input, tail -1 models the wrong semantic intent — the production code always returns the HEAD commit regardless of count, not the "last" of a list. Using head -1 or echo would more faithfully represent the production code's behavior.


Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-coder

fullsend-ai-coder Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Finished Fix · ✅ Success · Started 5:56 PM UTC · Completed 6:01 PM UTC

Commit: 0a50581 · View workflow run →

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
@fullsend-ai-coder

Copy link
Copy Markdown
Contributor Author

🔧 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):

  1. Variable REAL_GIT_MC does not follow GL_REAL_GIT naming convention (scripts/post-code-test.sh): Renamed REAL_GIT_MC to MC_REAL_GIT across all 18 occurrences in the integration test section to match the established PREFIX_REAL_GIT convention (e.g. GL_REAL_GIT).
  2. Test helper select_commit_subject uses tail -1 which models wrong semantic intent (scripts/post-code-test.sh): Replaced tail -1 with head -1 in the single-commit branch of select_commit_subject. For single-line input both are equivalent, but head -1 more faithfully represents the production code's intent of returning the HEAD commit subject rather than the 'last' of a list.

Disagreed (1):

  1. Protected-path modification requires human approval: This is a governance/process finding, not a code change request. The PR intentionally modifies scripts/ files to fix issue Post-code script should derive PR title from primary commit, not last commit #1148. Human approval is required by policy and cannot be addressed by the fix agent.

Tests: passed

Next steps:

  • /fs-review — request a re-review of the changes
  • /fs-fix <your instruction> — run another fix pass with specific guidance
  • Push commits directly — review re-runs automatically on push
    Updated by fullsend fix agent

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 2, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 6:03 PM UTC · Completed 6:20 PM UTC

Commit: e8a7aef · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $4.02

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-coder

fullsend-ai-coder Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Finished Fix · ✅ Success · Started 6:22 PM UTC · Completed 6:28 PM UTC

Commit: e8a7aef · View workflow run →

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
@fullsend-ai-coder

Copy link
Copy Markdown
Contributor Author

🔧 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):

  1. Test helper select_commit_subject has identical logic in both if/else branches (dead code) (scripts/post-code-test.sh): Collapsed the dead-code if/else into a single echo "${commit_subjects}" | head -1 with a comment explaining the production semantics. Both branches were identical after iteration 1 changed tail -1 to head -1, making the conditional meaningless.
  2. MULTI_COMMIT_TMPDIR uses long-form prefix instead of MC_ convention (scripts/post-code-test.sh): Renamed MULTI_COMMIT_TMPDIR to MC_TMPDIR across all 3 occurrences (declaration, usage in mc_repo, and cleanup rm -rf) to match the MC prefix convention used by all other variables in the integration test section.

Disagreed (1):

  1. Protected-path modification requires human approval: This is a governance/process finding, not a code change request. The PR intentionally modifies scripts/ files to fix issue Post-code script should derive PR title from primary commit, not last commit #1148. Human approval is required by policy and cannot be addressed by the fix agent.

Tests: passed

Next steps:

  • /fs-review — request a re-review of the changes
  • /fs-fix <your instruction> — run another fix pass with specific guidance
  • Push commits directly — review re-runs automatically on push
    Updated by fullsend fix agent

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 2, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 6:29 PM UTC · Completed 6:45 PM UTC

Commit: 50eac6d · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $3.91

@fullsend-ai-review
fullsend-ai-review Bot dismissed stale reviews from themself September 2, 2026 18:45

Superseded by updated review

@fullsend-ai-review fullsend-ai-review Bot added the requires-manual-review Review requires human judgment label Sep 2, 2026
@ralphbean ralphbean self-assigned this Sep 2, 2026
@ralphbean
ralphbean added this pull request to the merge queue Sep 2, 2026
Merged via the queue into main with commit daa53e0 Sep 2, 2026
43 checks passed
@ralphbean
ralphbean deleted the agent/1148-pr-title-first-commit branch September 2, 2026 21:13
@fullsend-ai-retro

fullsend-ai-retro Bot commented Sep 2, 2026

Copy link
Copy Markdown

🤖 Finished Retro · ✅ Success · Started 9:14 PM UTC · Completed 9:28 PM UTC

Commit: 50eac6d · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $5.94

@fullsend-ai-retro

Copy link
Copy Markdown

Pipeline validation: This PR demonstrates the retro-to-issue-to-code pipeline working as intended. The retro agent on PR #1125 correctly identified that git log -1 --format='%s' HEAD in post-code.src.sh always selected the last commit's subject, causing misleading PR titles when agents make multiple commits. It filed #1148 with a precise root cause, an accurate cost estimate ($45.65), and cross-references to three related issues (#519, #636, #1110). The code agent implemented the fix cleanly on first attempt with 4 new tests.

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 tail -1 vs head -1 semantic intent in a test helper). Fix 1 addressed both but introduced two new issues: (1) changing tail -1 to head -1 in the else branch made both if/else branches identical (dead code), and (2) renaming REAL_GIT_MC to MC_REAL_GIT established a new MC_ prefix convention that made MULTI_COMMIT_TMPDIR inconsistent. Review 2 caught these regressions, Fix 2 resolved them, and Review 3 approved. The protected-path governance finding was raised identically in all 3 reviews and disagreed with by the fix agent each time.

Evidence for existing issues:

  • #1141 (APPROVE for nit-only reviews): Highest-impact fix for this pattern. The entire cascade would have been avoided if Review 1 approved with inline comments instead of requesting changes for two low-severity cosmetic nits.
  • #464 (Fix agent self-review for dead code): Fix 1 changed tail -1 to head -1 without noticing both if/else branches became identical. A self-review step would have caught this structural regression before committing.
  • #543 (Cascading-fix detection): Both Review 2 findings were direct consequences of Fix 1's changes, not pre-existing issues. This is a textbook cascading-fix anti-pattern.
  • #1110 (COMMENT for human-only findings): The protected-path finding triggered fix agent dispatch in 2 iterations despite being unfixable by code changes. COMMENT verdict would have prevented the wasted fix agent cycles on this finding.
  • #1105 (Filter low-severity findings): Both initial code findings were low severity. Filtering would have eliminated the cascade at its source.

Proposals filed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Triggers review agent dispatch requires-manual-review Review requires human judgment risk/moderate PR risk: moderate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Post-code script should derive PR title from primary commit, not last commit

1 participant