Skip to content

fix(advisor): preserve long consult audit records - #652

Open
rudycelekli wants to merge 1 commit into
cursor:mainfrom
rudycelekli:fix/advisor-long-consult-summary-20261016
Open

rudycelekli wants to merge 1 commit into
cursor:mainfrom
rudycelekli:fix/advisor-long-consult-summary-20261016

Conversation

@rudycelekli

@rudycelekli rudycelekli commented Oct 16, 2026 •

Copy link
Copy Markdown

A completed Advisor consult with a long summary can exit with SIGPIPE before writing its advice: jq | head -c 6000 runs under pipefail. The hook has already incremented the consult count and cleared pending edits, so the user loses the audit record while the state reports completion.

Consume the summary before applying the existing 6,000-byte bound, append the record first, and only then mark the consult complete. A failed log append now leaves it pending and uncounted. This does not add a general transaction or concurrency lock.

Validation: all nine actual hook-subprocess tests pass under macOS Bash 3.2 and jq; identical tests against main pass seven and fail two. Coverage includes a 500,000-character summary, a Unicode boundary, missing summaries, a real failed log append, and unrelated/unfinished consults. A focused Ubuntu workflow runs the suite. AI-assisted implementation and testing; no model calls required.


Note

Low Risk
Localized hook ordering and piping fix with regression tests; no auth or broad infrastructure changes.

Overview
Fixes a data-loss bug in the Advisor record-consult hook where very long consult summaries could cause jq | head to hit SIGPIPE under pipefail, failing the script after the consult was already counted and pending was cleared.

The hook now fully reads the summary, applies the existing 6,000-byte cap in a second step, appends to log.md first (with || exit 1), and only then increments consult state and removes the pending marker—so failed writes stay pending and uncounted.

Adds a Node test suite (record-consult.test.mjs) covering long/Unicode summaries, missing summaries, failed log writes, and ignored non-completed consults, plus a PR workflow that runs those tests when advisor/hooks/** changes.

Reviewed by Cursor Bugbot for commit 6b02360. Bugbot is set up for automated code reviews on this repo. Configure here.

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.

1 participant