2.5 KiB
issue, issue_title
| issue | issue_title |
|---|---|
| 33 | sanitizeAvailableToolsSection silently removes content after the last recognised section header |
Retro: #33 — sanitizeAvailableToolsSection silently removes content after the last recognised section header
Final Retrospective (2026-05-03T06:15:00Z)
Session summary
Planned, implemented, and shipped a bug fix for findSection in src/system-prompt-sanitizer.ts.
The function defaulted end to lines.length when no subsequent section header followed, silently deleting all content after the last section.
The fix uses a two-pass strategy: use the next section header as the boundary when one exists, otherwise stop at the first non-body line via a new isSectionBodyLine helper.
Released as v3.0.3.
Observations
What went well
- The plan correctly identified the bug, the affected module, and the general approach (body-line scanning).
- The
test.fails→testflip pattern worked cleanly as a red-phase entry point.
What caused friction (agent side)
-
premature-convergence— The plan proposed a single-passisSectionBodyLine-only approach without checkingtests/permission-system.test.ts, which exercisessanitizeAvailableToolsSectionwith a realistic multi-section prompt containing prose betweenAvailable tools:andGuidelines:. The naive implementation passed all 16 sanitizer-specific tests but broke the integration test at line 446. Impact: required pivoting to a two-pass strategy and a messygit commit --amend+git rebase -icleanup that consumed ~5 minutes of rework. -
wrong-abstraction— Usedgit commit --amendintending to update commit828c907(the intermediate fix), but--amendalways operates on HEAD, which at that point was the edge-case test commit2c994d5. This left a broken intermediate commit in the ancestry, requiring an interactive rebase to drop it. The rebase itself hit two obstacles: neovim launching as$EDITOR(neededGIT_SEQUENCE_EDITOR), and a merge conflict becauseisSectionBodyLinewas defined in the dropped commit. Impact: ~3 minutes of git archaeology; no code-quality impact on the final result.
What caused friction (user side)
None observed. The user's issue description was thorough (root cause, reproducer, proposed fix, impact analysis), which made planning and implementation straightforward.
Changes made
- Added rule to
AGENTS.md§ Testing: run the full test suite before committing when shared helpers change. - Created
docs/retro/0033-fix-findsection-greedy-end.md(this file).