Status: Proven Category: Grammar Application First Documented: January 20, 2026 Ratified: January 20, 2026 (Grammar Implementation)
Features need to synthesize information from multiple integrations (GitHub, Calendar, Documents, etc.) to provide holistic context. Common challenges:
This creates slow, fragile features where a single integration failure destroys the entire user experience.
Implement Parallel Place Gathering where:
asyncio.gather() to fetch from all Places simultaneouslyParallel Place Gathering is a concurrent data collection pattern that treats each integration as a distinct Place with its own atmosphere and failure modes. The pattern emphasizes:
asyncio.gather() for concurrent Place fetches_get_[place]_context() handles own errorscontext_source field tracks attributionimport asyncio
from typing import Dict, Any, List
class FeatureService:
async def gather_context(self, user_id: str) -> Dict[str, Any]:
"""
Gather context from multiple Places concurrently.
Returns unified context with source attribution.
"""
# Parallel fetch from all Places
github_activity, calendar_events, documents = await asyncio.gather(
self._get_github_context(user_id),
self._get_calendar_context(user_id),
self._get_document_context(user_id),
)
# Synthesize into unified context
return self._synthesize_context(
github_activity,
calendar_events,
documents
)
async def _get_github_context(self, user_id: str) -> Dict[str, Any]:
"""Fetch from GitHub Place with local error handling."""
try:
return await self.github_service.get_activity(user_id)
except Exception as e:
logger.warning("GitHub Place unavailable", error=str(e))
return {"source": "github", "available": False, "error": str(e)}
async def _get_calendar_context(self, user_id: str) -> Dict[str, Any]:
"""Fetch from Calendar Place with local error handling."""
try:
return await self.calendar_service.get_events(user_id)
except Exception as e:
logger.warning("Calendar Place unavailable", error=str(e))
return {"source": "calendar", "available": False, "error": str(e)}
async def _get_document_context(self, user_id: str) -> Dict[str, Any]:
"""Fetch from Document Place with local error handling."""
try:
return await self.document_service.get_relevant(user_id)
except Exception as e:
logger.warning("Document Place unavailable", error=str(e))
return {"source": "documents", "available": False, "error": str(e)}
def _synthesize_context(
self,
github: Dict[str, Any],
calendar: Dict[str, Any],
documents: Dict[str, Any]
) -> Dict[str, Any]:
"""Synthesize Place-specific data into unified context."""
sources_available = []
if github.get("available", True):
sources_available.append("github")
if calendar.get("available", True):
sources_available.append("calendar")
if documents.get("available", True):
sources_available.append("documents")
return {
"github": github,
"calendar": calendar,
"documents": documents,
"sources_available": sources_available,
"context_quality": len(sources_available) / 3.0 # 0.0 to 1.0
}
File: services/features/morning_standup.py:116-138
async def generate_standup(self, user_id: str) -> StandupResult:
"""Generate morning standup for user using persistent context.
Performance optimized: session context and GitHub activity are
fetched in parallel using asyncio.gather().
"""
import asyncio
start_time = time.time()
try:
# Parallel fetch: session context and GitHub activity (Issue #556 optimization)
session_context, github_activity = await asyncio.gather(
self._get_session_context(user_id),
self._get_github_activity(),
)
# Generate standup content
result = await self._generate_standup_content(
user_id, session_context, github_activity, start_time
)
return result
except Exception as e:
# No fallbacks - fail honestly (see Pattern-054: Honest Failure)
# ... error handling
Performance impact:
File: services/features/morning_standup.py:154-186
async def _get_session_context(self, user_id: str) -> Dict[str, Any]:
"""Get session context using SessionPersistenceManager"""
try:
# Try multiple preference sources
yesterday_context = (
await self.preference_manager.get_preference("yesterday_context", user_id=user_id)
or {}
)
active_repos = await self.preference_manager.get_preference(
"active_repos", user_id=user_id
) or ["piper-morgan"]
# ... gather from session Place
return {
"yesterday_context": yesterday_context,
"active_repos": active_repos,
# ... Place-specific data
}
except Exception:
return {} # Graceful degradation - empty context
async def _get_github_activity(self) -> Dict[str, Any]:
"""Get GitHub activity from last 24 hours"""
try:
recent_issues = await self.github_domain_service.get_recent_issues(limit=5)
return {"commits": [], "issues": recent_issues}
except Exception as e:
# Re-raise integration errors for honest failure
raise StandupIntegrationError(...)
Graceful degradation:
{} → Feature uses defaultsFile: services/features/morning_standup.py:485-523
async def generate_with_trifecta(
self,
user_id: str,
with_issues: bool = True,
with_documents: bool = True,
with_calendar: bool = True,
) -> StandupResult:
"""Generate standup with full intelligence trifecta combination."""
# Get base standup (includes github + session)
base_standup = await self.generate_standup(user_id)
# Add document context if requested
if with_documents:
try:
document_service = get_document_service()
yesterday_context = await document_service.get_relevant_context("yesterday")
recent_decisions = await document_service.find_decisions("", "yesterday")
if yesterday_context.get("context_documents"):
for doc in yesterday_context["context_documents"][:2]:
base_standup.today_priorities.append(f"📄 Review: {doc['title']}")
except Exception as e:
# Graceful degradation - annotate but continue
base_standup.today_priorities.append(
f"⚠️ Document memory unavailable: {str(e)[:50]}..."
)
# Add issue context if requested (similar pattern)
# Add calendar context if requested (similar pattern)
return base_standup
Trifecta pattern characteristics:
✅ Use Parallel Place Gathering when:
❌ Don’t use when:
source field in Place dataservices/features/morning_standup.py - Parallel session + GitHub fetchservices/features/morning_standup.py - Trifecta pattern (issues + documents + calendar)High Priority (should adopt pattern):
Medium Priority:
_get_[place]_context() method for each Placeasyncio.gather() to fetch all Places concurrently_synthesize_context() to combine Place datasources_available list in synthesiscontext_quality metric (0.0 to 1.0)Proven Pattern - Successfully implemented in:
services/features/morning_standup.py:116-138services/features/morning_standup.py:485-615Performance Evidence:
Resilience Evidence:
Pattern Identified: January 19, 2026 (P0 Morning Standup Analysis) Ratified: January 20, 2026 Category: Grammar Application