Skip to content

[Duplicate] Feature/194 insights knowledge gaps#144

Merged
Tanzkalmar35 merged 8 commits into
devfrom
feature/194-insights-knowledge-gaps
Jul 19, 2026
Merged

[Duplicate] Feature/194 insights knowledge gaps#144
Tanzkalmar35 merged 8 commits into
devfrom
feature/194-insights-knowledge-gaps

Conversation

@Tanzkalmar35

Copy link
Copy Markdown
Collaborator

Important

Duplicate of #116

Related issue

#66

Short summary

Adds a knowledge-gaps panel backend in the insights module for project
managers: it surfaces components that are missing critical documentation
(runbooks/ADRs), ranked by severity, backed by a rebuildable cache of AI-classified
gaps.

  • PM knowledge-gaps endpoints (new insights feature)
    • Entities KnowledgeGap (+ KnowledgeGapSeverity enum with lowercase api
      mapping); missingTypes/presentTypes as free-form strings; tables via ddl-auto.
    • KnowledgeGapsAiClient: outbound pull to the AI service
      POST /api/v1/insights/knowledge-gaps/detect (mirrors ChatAiClient). The AI
      owns detection and sources artifacts from its own index, so no data is sent.
    • KnowledgeGapsService: cached reads (read-only tx, sorted by severity then
      component/related items); refresh replaces the cache from the AI result.
    • KnowledgeGapsController (PM/ADMIN only):
      • GET /api/v1/insights/knowledge-gaps — overview, most severe first
      • GET /api/v1/insights/knowledge-gaps/{gapId} — detail (404 if missing)
      • POST /api/v1/insights/knowledge-gaps/refresh — trigger AI classification
    • Distinct class/file names from the FAQ feature (#181) to keep branch merges clean.
  • Aligned with the real AI contract
    • AI response now carries presentTypes and drops owners/related-question count, matching the AI /insights/knowledge-gaps/detect endpoint (the index holds no user/ownership or question-history data). Mapper/service/tests updated.
  • Component ownership (backend-owned, independent of the AI cache)
    • ComponentOwner entity + repository (component → userId).
    • Owners resolved at read time: a gap's component is matched to the ownership
      mapping and users resolved via the user module (UserApi); the owner's role is
      derived from the user's first project role. Refresh leaves ownership intact.
    • Endpoints (PM/ADMIN): GET/PUT /insights/knowledge-gaps/component-owners.
  • Ingestion/analysis timestamps
    • Response now exposes lastIngested (renamed from lastUpdated),
      firstIngested and refreshedAt, so the UI can distinguish "first/last
      ingested" from "last analyzed".
    • New read-only ingestion-module API (ArtifactIngestionApi) resolves a
      component's first-ingested time as MIN(ingestedAt) over its artifacts
      (stable across re-ingestion). Purely additive — no change to the ingestion
      write path.

Checks

  • I verified the code makes sense intuitively
  • The PR changes affect only this issue, no unrelated/unwanted code changes to other modules/code segments
  • CI runs (./gradlew clean build, keycloack)
  • New business logic is unit tested, including WebMvcTest for api controllers
  • The new functionality is tested manually

Additional notes

  • Architecture: cross-module access stays explicit via exported module APIs
    (UserApi, new ArtifactIngestionApi) — no direct repository access across
    modules. The insights module stays loosely coupled.
  • The AI service is stateless and pull-based: the backend triggers detection and
    caches the result; the cache is fully rebuildable via the refresh endpoint, and
    component ownership survives refreshes.
  • Severity is rendered lowercase in the API; owner id exposes the upstream user
    reference and the owner DTO surfaces the project role.
  • Test coverage: controller slice tests (401/403/404/200, including
    @PreAuthorize on the coroutine endpoint via async dispatch) plus service unit
    tests for detection caching, owner enrichment/set, and timestamp resolution.
    detekt clean.
  • Contains a small follow-up "klint fix" commit for a detekt/lint issue in
    KnowledgeGapsAiException.
  • Builds on Feature/181 insights faq #115 (pull-based AI insights) and shares the insights module with the
    FAQ feature (#181).

DavidLeuter and others added 8 commits July 9, 2026 20:18
Adds a knowledge-gaps panel backend in the `insights` module, surfacing
components missing runbooks/ADRs for project managers, backed by a
rebuildable cache of AI-classified gaps (pull-based, uses #115).

- Entities KnowledgeGap/KnowledgeGapOwner (+ KnowledgeGapSeverity enum with
  lowercase api mapping); missingTypes as free-form strings; tables via ddl-auto.
- KnowledgeGapsAiClient: outbound pull to AI service
  POST /api/v1/insights/knowledge-gaps/detect (mirrors ChatAiClient). AI owns
  detection and sources artifacts from its own index, so no data is sent.
- KnowledgeGapsService: cached reads (readOnly tx, sorted by severity then
  related questions); refresh replaces the cache from the AI result. Mappers
  AI->entity (severity + ISO timestamp parsing) and entity->response DTOs.
- KnowledgeGapsController (PM/ADMIN only):
    GET  /api/v1/insights/knowledge-gaps            overview, most severe first
    GET  /api/v1/insights/knowledge-gaps/{gapId}    detail (404 if missing)
    POST /api/v1/insights/knowledge-gaps/refresh    trigger AI classification
- Response DTOs match the frontend contract; owner id exposes the upstream
  user reference, severity is rendered lowercase.
- Distinct class/file names from the FAQ feature to keep branch merges clean.
- Tests: controller slice (401/403/404/200, incl. @PreAuthorize on the
  coroutine endpoint via async dispatch) + service unit tests. detekt clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- AI response now carries presentTypes and drops owners/relatedQuestions,
  matching the AI /insights/knowledge-gaps/detect endpoint (owners are the
  backend's to enrich; the index holds no question history).
- Entity: add presentTypes, remove relatedQuestions and the KnowledgeGapOwner
  relationship/entity; sort by severity then component.
- Response DTO: add presentTypes, drop relatedQuestions; owners kept but empty
  until component ownership is assigned.
- Update mapper, service and tests accordingly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Lets PMs assign owners to a component (owner/repo) and surfaces them on the
knowledge-gaps panel, independent of the AI classification cache.

- ComponentOwner entity + repository (component -> userId).
- Resolve owners at read time: match a gap's component to the ownership
  mapping and resolve users via the user module (UserApi); the owner's role is
  derived from the user's first project role. Refresh leaves ownership intact.
- Endpoints (PM/Admin): GET/PUT /insights/knowledge-gaps/component-owners.
- Owner DTO exposes the project role instead of a non-existent working area.
- Tests for owner enrichment, set, and the new endpoints.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…s (#194)

- Response now carries lastIngested (renamed from lastUpdated), firstIngested
  and refreshedAt so the UI can distinguish "first/last ingested" from
  "last analyzed".
- Add a read-only ingestion-module API (ArtifactIngestionApi) resolving a
  component's first-ingested time as MIN(ingestedAt) over its artifacts; the
  timestamp is stable across re-ingestion. Purely additive, no change to the
  ingestion write path.
- Resolve firstIngested per component in the service; update mapper and tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
After merging dev, UserDto gained a required profileIcon field. The
buildUser helper in KnowledgeGapsServiceTest constructed a UserDto without
it, breaking compileTestKotlin on the PR merge. Pass profileIcon = null.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
revert of Fabian change
@Tanzkalmar35 Tanzkalmar35 changed the title Feature/194 insights knowledge gaps [Duplicate] Feature/194 insights knowledge gaps Jul 16, 2026
@Tanzkalmar35
Tanzkalmar35 merged commit 8268091 into dev Jul 19, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants