fix: enforceable Agent writes plus non-blocking save bubbles - #75
Merged
Conversation
The Agent volunteered "save this as a shared DeepSQL brain note" after answering a metric, then 403'd for users without manage-content. Stamp callerCapabilities on get_brain_context / list_connections, fail-close save_brain_note before the POST, and stop SOUL.md from asking whether to persist a definition the current account cannot write. Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
venkateshsakamuri-lab
marked this pull request as ready for review
August 22, 2026 07:48
venkateshsakamuri-lab
requested review from
a team and
geekypunk
as code owners
August 22, 2026 07:48
After an Agent turn, admins see a chip they can open for the excerpt of the shared note that would be created. Overlaps with existing notes or business rules merge into one intent; identical intent is not offered. Propose/accept never blocks the composer. Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
CodeQL flagged QUALIFIED_TABLE as polynomial ReDoS on Agent Q&A (long runs of 'A'). Walk the string once instead. Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
Clean first-turn answers stay quiet. A chip appears only when the user corrects or teaches after a prior Agent reply. One unsaved chip at a time; dismissed targets stay suppressed for the session. Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Agent chat answered a metric, then offered “Should I save this as a shared DeepSQL brain note?” A user without
canManageContentclicked Yes and got a 403. The offer itself is the bug.Admins still need a way to persist a useful definition — without the Agent asking, without blocking chat, and without creating a second note that overlaps an existing brain note or business rule. Chips must stay quiet when the Agent already got it right.
Fix
Capability gating
callerCapabilities(includingdoNotOfferandcanWriteSharedBrainNotes) onget_brain_context,list_connections,list_brain_recommendations, andget_current_user.save_brain_notefail-closes beforePOST /brain/noteswhencanManageContentis false.SOUL.md/bi-queryskill: never volunteer a write listed indoNotOffer.Suggestion bubbles — only after correction or teaching
that's wrong,always filter,remember this, …) after a prior Agent reply.schema.tableextraction is a linear scan (no ReDoS regex).Verify
cd backend && ./mvnw test -Dtest=BrainNoteIntentServiceTest,BrainControllerAuthorizationSafetyTestnode --test src/components/AgentChat/shouldOfferBrainSuggestion.test.js src/components/AgentChat/AgentRecommendationBubbles.test.jsPOST /brain/notes/propose: first-turn and thanks →204; correction withpriorAnswer→200NEW/MERGESuggestion chip opens an excerpt of the brain note
After save the chip is gone and the composer stays usable
brain_note_suggestion_bubble.mp4
To show artifacts inline, enable in settings.