Skip to content

fix(brainbar): make digest and ack truthful - #635

Merged
EtanHey merged 4 commits into
mainfrom
fix/owed-digest-ack-sol
Aug 1, 2026
Merged

fix(brainbar): make digest and ack truthful#635
EtanHey merged 4 commits into
mainfrom
fix/owed-digest-ack-sol

Conversation

@EtanHey

@EtanHey EtanHey commented Aug 1, 2026

Copy link
Copy Markdown
Owner

What broke and how it was found

brain_digest silently truncated input to 500 characters while returning success, and brain_ack acknowledged unknown inboxes by auto-creating cursor state. Direct socket reproduction measured the digest cutoff and the false-ack row creation.

Evidence

  • A 701-character digest stored only 503 characters at the defective baseline; the fixed path stores the full input.
  • 298 truncated digest stubs were identified; 198 full source inputs were recovered from local transcripts.
  • The false-ack path now returns an error for an unsubscribed agent and creates no row. Changed suites: MCPRouterTests 74/74 and SocketIntegrationTests 21/21.

Review

This branch was pair-reviewed by a separate agent under the taste gate: smallest correct solution, behavioural tests, and no speculative machinery.

Operational note

Enrichment and drain are currently disabled with launchctl to prevent provenance-tag decay. Re-enable deliberately after the provenance-column ownership question is settled.


Note

Medium Risk
Changes MCP persistence and inbox cursor semantics; callers that relied on ack succeeding for unsubscribed agents will now see errors, while digest storage size grows for long inputs.

Overview
brain_digest no longer truncates stored text to 500 characters plus ...; the Swift digest path now persists the full input (with an optional title prefix), matching the schema’s much larger limit and stopping silent loss on long tool payloads.

brain_ack on the socket server now requires an existing BrainBar subscription before calling acknowledge. Unsubscribed agents get a JSON-RPC tool error (No BrainBar subscription for agent: …) and no new agent/cursor row from the old auto-create path.

Adds REPORT.md documenting measured digest cutoff, stub counts, recovery notes, and false-ack reproduction. New MCPRouterTests and SocketIntegrationTests lock in full-length digest storage and ack rejection for unknown agents.

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

Note

Fix brain_digest truncation and brain_ack false acknowledgment in BrainBar

  • brain_digest now stores the full input content (with optional title prepended) instead of truncating to 500 characters with an ellipsis, fixing data loss on long inputs.
  • brain_ack now checks for an existing subscription before acknowledging; if no subscription exists for the agent, it returns an error and does not implicitly create a record.
  • New unit test in MCPRouterTests.swift asserts full content is stored for a 701-character input.
  • New socket integration test in SocketIntegrationTests.swift asserts brain_ack rejects unknown agents and leaves the database unchanged.
  • Behavioral Change: brain_ack calls that previously silently succeeded for unregistered agents now return a JSON-RPC error response.
📊 Macroscope summarized 1628b63. 3 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted

🗂️ Filtered Issues

No issues evaluated.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@EtanHey, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 16 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1e957f3a-94dc-4d6b-84dd-344d9a07e41b

📥 Commits

Reviewing files that changed from the base of the PR and between e6bd25d and 1628b63.

📒 Files selected for processing (5)
  • REPORT.md
  • brain-bar/Sources/BrainBar/BrainBarServer.swift
  • brain-bar/Sources/BrainBar/BrainDatabase.swift
  • brain-bar/Tests/BrainBarTests/MCPRouterTests.swift
  • brain-bar/Tests/BrainBarTests/SocketIntegrationTests.swift

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a34a4c90ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

do {
guard try database.subscription(agentID: agentID) != nil else {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject rows left behind by false acknowledgements

On an upgraded database, this guard still accepts every agent row that the old false-ack path created because subscription() checks brainbar_agents, while the former acknowledge() inserted that row before advancing its cursors. REPORT.md:29 confirms that production already contains acknowledged agent rows with zero subscription tags, so subsequent acknowledgements for those IDs will still return acked and advance their cursors. Validate actual brainbar_subscriptions membership and handle legacy zero-tag rows before acknowledging.

AGENTS.md reference: AGENTS.md:L6-L7

Useful? React with 👍 / 👎.

@EtanHey

EtanHey commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

VERDICT: APPROVE
TASTE: The change is the smallest correct repair: digest persistence now retains the supplied content, and ack rejects an unregistered agent before acknowledge can create state. The existing happy-path ack integration test also remains green.
TESTS: Baseline targeted tests passed (digest full-content, invalid-agent ack, and existing subscribed ack path). Mutation: restored the former 500-character-plus-ellipsis digest behavior; the new digest test failed (503 stored versus 701 expected). Mutation: removed the subscription guard; the new ack test failed (no error and an unintended subscriber record). Restored both mutations; the two new tests passed again.
MISSED BY FIRST REVIEW: None. The regression tests exercise the MCP route and persisted database state, not only a helper.
BLOCKERS: None.

@cursor

cursor Bot commented Aug 1, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_d0cbddf7-ad10-45fb-87d1-b963759474c5)

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

@cursor

cursor Bot commented Aug 1, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_68a35fcf-cc57-477c-b68a-f9dc302184e0)

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

@cursor

cursor Bot commented Aug 1, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_2573b0fe-dc25-405d-9c88-b978dce9fede)

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

@EtanHey
EtanHey merged commit c99fabb into main Aug 1, 2026
9 checks passed
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