[PR #358] [MERGED] Implement evidence-based semantic gap analysis across SIF strategy flows #325

Closed
opened 2026-03-02 23:35:08 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/AJaySi/ALwrity/pull/358
Author: @AJaySi
Created: 3/1/2026
Status: Merged
Merged: 3/1/2026
Merged by: @AJaySi

Base: mainHead: codex/implement-find_semantic_gaps-in-agents


📝 Commits (1)

  • 77088bf Implement evidence-driven semantic gap detection

📊 Changes

4 files changed (+413 additions, -78 deletions)

View changed files

📝 backend/services/intelligence/agents/specialized_agents.py (+183 -12)
📝 backend/services/intelligence/sif_agents.py (+183 -11)
📝 backend/services/intelligence/sif_integration.py (+26 -50)
📝 backend/services/sif_onboarding_service.py (+21 -5)

📄 Description

Motivation

  • Replace stubbed semantic-gap outputs with real, evidence-driven analysis sourced from the txtai index to make onboarding/dashboard recommendations actionable.
  • Provide a stable gap schema (topic, priority, reason, confidence, topic_density, evidence) so downstream consumers can reliably surface evidence and prioritize work.
  • Align agent initialization in onboarding so agents have the required user_id context for index-aware operations.

Description

  • Implemented find_semantic_gaps in StrategyArchitectAgent (both sif_agents.py and agents/specialized_agents.py) to pull documents from the txtai index, split user vs competitor docs by metadata, extract topic densities, compute density gaps, and produce ranked gap results with topic, priority, reason, confidence, topic_density, and evidence fields.
  • Added helper utilities on agents for index harvesting and normalization: _fetch_index_documents, _normalize_metadata, _extract_topic_density, and _sample_titles_for_topic to handle varied txtai row shapes and produce topic density scoring.
  • Updated onboarding (backend/services/sif_onboarding_service.py) to initialize agents with user_id and to include richer evidence and actionable phrasing in semantic-gap-based recommendations (action items + evidence payloads).
  • Updated SIFIntegrationService (backend/services/intelligence/sif_integration.py) to consume StrategyArchitectAgent outputs, normalize fields for backward compatibility (e.g. current_coverage_score) and expose the richer evidence payload for dashboards and API consumers.

Testing

  • Ran byte-compile checks with python -m py_compile backend/services/intelligence/sif_agents.py backend/services/intelligence/agents/specialized_agents.py backend/services/sif_onboarding_service.py backend/services/intelligence/sif_integration.py, which completed successfully.
  • No unit tests were modified; changes were limited to new implementations and compatibility-preserving normalization for downstream callers.

Codex Task


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/AJaySi/ALwrity/pull/358 **Author:** [@AJaySi](https://github.com/AJaySi) **Created:** 3/1/2026 **Status:** ✅ Merged **Merged:** 3/1/2026 **Merged by:** [@AJaySi](https://github.com/AJaySi) **Base:** `main` ← **Head:** `codex/implement-find_semantic_gaps-in-agents` --- ### 📝 Commits (1) - [`77088bf`](https://github.com/AJaySi/ALwrity/commit/77088bfc53ff728a9c489ef4d8f0e4324247320f) Implement evidence-driven semantic gap detection ### 📊 Changes **4 files changed** (+413 additions, -78 deletions) <details> <summary>View changed files</summary> 📝 `backend/services/intelligence/agents/specialized_agents.py` (+183 -12) 📝 `backend/services/intelligence/sif_agents.py` (+183 -11) 📝 `backend/services/intelligence/sif_integration.py` (+26 -50) 📝 `backend/services/sif_onboarding_service.py` (+21 -5) </details> ### 📄 Description ### Motivation - Replace stubbed semantic-gap outputs with real, evidence-driven analysis sourced from the txtai index to make onboarding/dashboard recommendations actionable. - Provide a stable gap schema (topic, priority, reason, confidence, topic_density, evidence) so downstream consumers can reliably surface evidence and prioritize work. - Align agent initialization in onboarding so agents have the required `user_id` context for index-aware operations. ### Description - Implemented `find_semantic_gaps` in `StrategyArchitectAgent` (both `sif_agents.py` and `agents/specialized_agents.py`) to pull documents from the txtai index, split user vs competitor docs by metadata, extract topic densities, compute density gaps, and produce ranked gap results with `topic`, `priority`, `reason`, `confidence`, `topic_density`, and `evidence` fields. - Added helper utilities on agents for index harvesting and normalization: `_fetch_index_documents`, `_normalize_metadata`, `_extract_topic_density`, and `_sample_titles_for_topic` to handle varied txtai row shapes and produce topic density scoring. - Updated onboarding (`backend/services/sif_onboarding_service.py`) to initialize agents with `user_id` and to include richer evidence and actionable phrasing in semantic-gap-based recommendations (action items + `evidence` payloads). - Updated `SIFIntegrationService` (`backend/services/intelligence/sif_integration.py`) to consume `StrategyArchitectAgent` outputs, normalize fields for backward compatibility (e.g. `current_coverage_score`) and expose the richer evidence payload for dashboards and API consumers. ### Testing - Ran byte-compile checks with `python -m py_compile backend/services/intelligence/sif_agents.py backend/services/intelligence/agents/specialized_agents.py backend/services/sif_onboarding_service.py backend/services/intelligence/sif_integration.py`, which completed successfully. - No unit tests were modified; changes were limited to new implementations and compatibility-preserving normalization for downstream callers. ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_69a46181dc6083288265984e62d79dcc) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 23:35:08 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ALwrity#325
No description provided.