Skip to content

fix(chat): restrict Ask DRIFT citations to grounded insights - #5

Merged
iarjunganesh merged 1 commit into
mainfrom
feature/v0.9.0-final-evidence
Jul 17, 2026
Merged

fix(chat): restrict Ask DRIFT citations to grounded insights#5
iarjunganesh merged 1 commit into
mainfrom
feature/v0.9.0-final-evidence

Conversation

@iarjunganesh

Copy link
Copy Markdown
Owner

What changed

  • Make live Ask DRIFT responses structured with the Insight IDs actually used by the model.
  • Restrict API citations and grounded IDs to that subset, filtering stray IDs and falling back safely when none are returned.
  • Add malformed-response, blank-answer, subset-citation, router-schema, and lifespan coverage.
  • Bump source and frontend metadata to 0.8.1 and synchronize release records.

Why

A question-specific answer could previously present every retrieved source link, including unrelated Insights. This patch makes the citation set answer-specific while preserving the retrieve-first, evidence-only boundary.

Validation

  • Ruff
  • mypy
  • 153 pytest tests with 100% backend coverage
  • Frontend production build

Hosted verification remains explicitly at v0.8.0 until deployment is independently checked. Unrelated v0.9.0 planning and screenshot changes remain outside this PR.

Make live Ask DRIFT responses structured so the model reports the Insight IDs it used and the API cites only those sources. Add malformed-response and subset-citation coverage, bump source and frontend metadata to 0.8.1, and synchronize release records while keeping hosted v0.8.0 verification explicit.
@iarjunganesh iarjunganesh added the enhancement New feature or request label Jul 17, 2026
Copilot AI review requested due to automatic review settings July 17, 2026 20:42
@iarjunganesh iarjunganesh added the enhancement New feature or request label Jul 17, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
drift Ready Ready Preview, Comment Jul 17, 2026 8:42pm

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@iarjunganesh
iarjunganesh merged commit 4868f6b into main Jul 17, 2026
9 checks passed
@iarjunganesh
iarjunganesh deleted the feature/v0.9.0-final-evidence branch July 17, 2026 20:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens DRIFT’s live /chat grounding by making the model return a structured payload that explicitly lists which Insight IDs it actually used, and then restricting citations/grounded IDs to that subset (with a safe fallback when none are returned). It also bumps the project version to 0.8.1 and synchronizes documentation/release records around the patch.

Changes:

  • Enforce structured live-chat responses (answer + grounded_insight_ids) with strict validation and filtering to the supplied Insight window.
  • Restrict /chat citations and returned grounded_insight_ids to the grounded subset (fallback to full retrieval window when none are returned).
  • Add regression tests for subset-citation behavior, malformed/blank structured responses, router schema forwarding, and lifespan integration; bump versions + update docs/changelog.

Reviewed changes

Copilot reviewed 14 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
uv.lock Bumps backend package version to 0.8.1.
pyproject.toml Updates backend project version to 0.8.1.
backend/agents/briefing.py Introduces strict structured chat output schema + parsing; returns grounded IDs alongside text.
backend/core/model_router.py Adds optional text_format to request strict JSON schema responses via the Responses API.
backend/main.py Filters /chat citations/grounded IDs to the grounded subset with fallback behavior.
tests/unit/test_live_chat.py Expands unit coverage for structured output, subset filtering, malformed/blank responses, and schema forwarding.
tests/integration/test_lifespan.py Updates integration to reflect structured live-chat output.
frontend/package.json Bumps frontend version to 0.8.1.
frontend/package-lock.json Bumps frontend lock metadata to 0.8.1.
README.md Synchronizes initiative count and records the v0.8.1 source patch boundary.
docs/RUNBOOK.md Documents v0.8.1 as source-only patch pending hosted verification; updates initiative count.
docs/BUILD_SEQUENCE.md Records v0.8.1 patch and adds planning notes for targeted releases.
docs/ARCHITECTURE.md Documents structured grounding ID behavior and hosted-verification boundary.
docs/adr/008-live-grounded-chat.md Adds dated implementation addendum describing structured grounding/citation filtering.
CHANGELOG.md Adds 0.8.1 entry describing grounding/citation fix and related test coverage; clarifies planned targets.
AGENTS.md Synchronizes status notes for the v0.8.1 source patch and documentation session.
Files not reviewed (1)
  • frontend/package-lock.json: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +218 to +222
supplied_ids = {insight.id for insight in relevant_insights if insight.id is not None}
grounded_ids = [
insight_id for insight_id in payload.grounded_insight_ids if insight_id in supplied_ids
]
return GroundedAnswer(payload.answer.strip(), grounded_ids)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants