fix(brain): overhaul gist quality — 3-pass research loop, strict novelty gates#300
Merged
fix(brain): overhaul gist quality — 3-pass research loop, strict novelty gates#300
Conversation
…y gates Problems fixed: - Every gist was "X shows weak co-occurrence with Y (confidence: 50%)" - Same generic cluster labels (debug, architecture, geopolitics) recycled - Novelty thresholds too low (2 inferences, 100 evidence, 0.008 strange loop) - Rate limit too permissive (4 hours = 6 gists/day of noise) - No content-level dedup Changes: - Raise novelty thresholds: 5 inferences, 500 evidence, 0.05 strange loop - Add MIN_INFERENCE_CONFIDENCE (60%) — filter out weak signals before publishing - Add strong_inferences() / strong_propositions() quality filters - Raise cross-domain similarity threshold from 0.3 to 0.45 at source - Raise predicate thresholds (may_influence: 0.75, associated_with: 0.55) - Rate limit: 24 hours between gists (was 4 hours) - Content-based dedup (category + dominant inference, not just title) - 3-pass research loop: (1) Gemini grounded research on topics, (2) brain memory search for internal context, (3) Gemini synthesis - Deleted all 45 old repetitive gists Co-Authored-By: claude-flow <ruv@ruv.net>
Co-Authored-By: claude-flow <ruv@ruv.net>
Google Workspace Add-ons expect responses wrapped in:
{ "hostAppDataAction": { "chatDataActionMarkup": { "createMessageAction": { "message": {...} } } } }
Returning a raw Message object causes Google Chat to show "not responding"
even though the HTTP status is 200. The endpoint was receiving requests
correctly (confirmed via Cloud Run logs) but responses were being silently
dropped by the Add-ons framework.
Ref: https://developers.google.com/workspace/add-ons/chat/build
Co-Authored-By: claude-flow <ruv@ruv.net>
Revert DataActions wrapper — HTTP endpoint Chat apps should return plain Message objects. Added raw payload logging to debug why Google Chat shows "not responding" despite 200 OK responses. Co-Authored-By: claude-flow <ruv@ruv.net>
The correct Add-ons envelope uses `chatDataAction` (NOT `chatDataActionMarkup`):
{ "hostAppDataAction": { "chatDataAction": { "createMessageAction": { "message": {...} } } } }
Previous attempts:
1. Plain Message → 200 OK but "not responding" (wrong format for Add-ons)
2. chatDataActionMarkup → 200 OK but "not responding" (wrong field name)
3. chatDataAction → this should work per quickstart-http docs
Ref: https://developers.google.com/workspace/add-ons/chat/quickstart-http
Co-Authored-By: claude-flow <ruv@ruv.net>
Google Workspace Add-ons wrap the Chat event differently than legacy Chat API:
- Add-on: { "chat": { "messagePayload": { "message": {...} } } }
- Legacy: { "type": "MESSAGE", "message": {...} }
The handler now detects which format is used and parses accordingly.
Also handles appCommandPayload for slash commands.
Response uses confirmed correct format:
{ "hostAppDataAction": { "chatDataAction": { "createMessageAction": { "message": {...} } } } }
Ref: https://developers.google.com/workspace/add-ons/chat/quickstart-http
Co-Authored-By: claude-flow <ruv@ruv.net>
Replace raw search fallback with Gemini Flash + Google Grounding for non-command messages. Gemini receives: - Brain context (memory count, edges, drift) - Semantic search results from the query - Recent brain activity - Google Search grounding for real-world context Synthesizes conversational HTML responses for Google Chat cards. Falls back to raw search if Gemini is unavailable. 25s timeout to stay within Chat's 30s limit. Slash commands (status, drift, search, recent, help) still use direct handlers for instant response. Co-Authored-By: claude-flow <ruv@ruv.net>
…ions - Expand search context from 300 to 600 chars per memory - Include tags in search results - Directive prompt: speak as the brain, cite memories by title, synthesize across results, add Google Search context - Increase max output from 1024 to 2048 tokens - Increase truncation limit from 1500 to 3000 chars - Add "Ask me about..." follow-up suggestions - Temperature 0.4 → 0.5 for more engaging responses Co-Authored-By: claude-flow <ruv@ruv.net>
Problem: gists still publishing recycled "X associated_with Y" noise. Threshold changes: - MIN_NEW_INFERENCES: 5 → 10 - MIN_EVIDENCE: 500 → 1000 - MIN_STRANGE_LOOP_SCORE: 0.05 → 0.1 - MIN_PROPOSITIONS: 10 → 20 - MIN_SONA_PATTERNS: 0 → 1 (require SONA learning) - MIN_PARETO_GROWTH: 2 → 3 - MIN_INFERENCE_CONFIDENCE: 0.60 → 0.70 - New: MIN_UNIQUE_CATEGORIES = 4 (prevent recycling same domains) - Rate limit: 24h → 72h (3 days between gists) - Cross-domain similarity: 0.45 → 0.55 Quality filters: - Reject ALL "may be associated with", "co-occurs with", "similar_to" - Reject inferences < 50 chars - Require 3+ strong inferences, 5+ strong propositions, 4+ unique categories - Kill co_occurs_with and similar_to entirely from publishable set Target: ~1 gist per week, only for genuinely novel cross-domain discoveries. Co-Authored-By: claude-flow <ruv@ruv.net>
Previous categories (architecture, pattern, solution, convention, security, performance, tooling, debug) were too generic — every discovery was just "debug associated_with architecture" noise. New categories span practical to exotic: - Research: sota, discovery, hypothesis, cross_domain - AI/ML: neural_architecture, compression, self_learning, reinforcement_learning, graph_intelligence - Systems: distributed_systems, edge_computing, hardware_acceleration - Frontier: quantum, neuromorphic, bio_computing, cognitive_science, formal_methods - Applied: geopolitics, climate, biomedical, space, finance - Meta: meta_cognition, benchmark Backward compatible — serde snake_case, existing memories still deserialize. Custom(String) still accepted for any unlisted category. Co-Authored-By: claude-flow <ruv@ruv.net>
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.
Summary
Complete overhaul of brain gist publisher quality, Google Chat bot fix, and Gemini Flash conversational handler.
Gist Quality Overhaul
Google Chat Bot Fix
body.chat.messagePayload(not top-level)hostAppDataAction.chatDataAction.createMessageAction.messagewrapperappCommandPayloadfor slash commandsGemini Flash Conversational Handler
35 Brain Categories (was 8)
sota,discovery,hypothesis,cross_domainneural_architecture,compression,self_learning,reinforcement_learning,graph_intelligencedistributed_systems,edge_computing,hardware_accelerationquantum,neuromorphic,bio_computing,cognitive_science,formal_methodsgeopolitics,climate,biomedical,space,financemeta_cognition,benchmarkTest plan
cargo check -p mcp-brain-serverpasses🤖 Generated with claude-flow