feat(deepdive): integrate Phase 0 fleet context into synthesis (#830)
Some checks failed
Deploy Nexus / deploy (push) Has been cancelled

This commit is contained in:
2026-04-05 17:32:23 +00:00
parent 7189565d4d
commit ca1a11f66b

View File

@@ -52,6 +52,15 @@ except ImportError:
np = None
SentenceTransformer = None
# Phase 0: Fleet context grounding
try:
from fleet_context import build_fleet_context, FleetContext
HAS_FLEET_CONTEXT = True
except ImportError:
HAS_FLEET_CONTEXT = False
build_fleet_context = None
FleetContext = None
# Setup logging
logging.basicConfig(
level=logging.INFO,
@@ -371,7 +380,9 @@ Guidelines:
- Keep tone professional but urgent
- Structure: Headlines → Deep Dive → Implications
Context: Hermes agents run locally with Gemma 4, sovereign infrastructure."""
Context: Hermes agents run locally with Gemma 4, sovereign infrastructure.
If Fleet Context is provided above, use it to explain how external developments
impact our live repos, open issues, and current architecture."""
def _call_llm(self, prompt: str) -> str:
if not HAS_HTTPX or not httpx:
@@ -411,7 +422,8 @@ Context: Hermes agents run locally with Gemma 4, sovereign infrastructure."""
lines.append("*Generated by Deep Dive pipeline*")
return "\n".join(lines)
def generate_structured(self, items: List[tuple]) -> Dict[str, Any]:
def generate_structured(self, items: List[tuple],
fleet_context: Optional[FleetContext] = None) -> Dict[str, Any]:
if not items:
return {
'headline': 'No relevant intelligence today',
@@ -419,7 +431,14 @@ Context: Hermes agents run locally with Gemma 4, sovereign infrastructure."""
'sources': []
}
lines = ["Generate an intelligence briefing from these research items:", ""]
lines = []
if fleet_context:
lines.append("FLEET CONTEXT:")
lines.append(fleet_context.to_prompt_text(max_items_per_section=5))
lines.append("")
lines.append("Generate an intelligence briefing from these research items:")
lines.append("")
for i, (item, score) in enumerate(items, 1):
lines.append(f"{i}. [{item.source}] {item.title}")
lines.append(f" Score: {score}")
@@ -632,9 +651,22 @@ class DeepDivePipeline:
if not ranked and not force:
return {'status': 'filtered', 'items_count': len(items), 'ranked_count': 0}
# Phase 0 — injected before Phase 3
logger.info("Phase 0: Fleet Context Grounding")
fleet_ctx = None
if HAS_FLEET_CONTEXT:
try:
fleet_ctx = build_fleet_context(self.cfg)
if fleet_ctx:
logger.info(f"Fleet context built: {len(fleet_ctx.repos)} repos, "
f"{len(fleet_ctx.open_issues)} issues/PRs, "
f"{len(fleet_ctx.recent_commits)} recent commits")
except Exception as e:
logger.warning(f"Fleet context build failed: {e}")
# Phase 3
logger.info("Phase 3: Synthesis")
briefing = self.synthesizer.generate_structured(ranked)
briefing = self.synthesizer.generate_structured(ranked, fleet_context=fleet_ctx)
timestamp = datetime.now(timezone.utc).strftime("%Y%m%d_%H%M%S")
briefing_path = self.cache_dir / f"briefing_{timestamp}.json"