fix: autoapprove Tee buffer is unbounded and re-parsed from offset 0 on every write #462
Labels
No labels
backend
bug
chore
duplication
effort:complex
effort:medium
effort:trivial
enhancement
frontend
fullstack
priority:high
ready-for-agent
refactor
security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dries/ocman#462
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Code-quality audit (P2).
internal/autoapprove/tee.go:75-87and:110-142.draincallssplitSSELines(data)over the whole buffer and only advancesconsumedon a blank-line event terminator:Why it matters
Two failure modes on the SSE tee that feeds the auto-approve pipeline:
bufgrow without limit. Nothing caps it.Writere-splits the full buffer from offset 0. With a large pending event, per-token writes turn into quadratic work on the OpenCode event hot path.The two compound: the bigger the un-terminated buffer gets, the more expensive each subsequent write becomes.
Suggested fix
Acceptance criteria
Writeis proportional to the new bytes, not the buffer size.Effort: M.