Skip to content

feat(chat): hard-scope Ask to a conversation or timeframe (#4515) - #11206

Open
aryanorastar wants to merge 11 commits into
BasedHardware:mainfrom
aryanorastar:feat/4515-scoped-chat
Open

feat(chat): hard-scope Ask to a conversation or timeframe (#4515)#11206
aryanorastar wants to merge 11 commits into
BasedHardware:mainfrom
aryanorastar:feat/4515-scoped-chat

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes #4515: chat could only hint at the open conversation; tools still searched all memory.
  • Backend: PageContext gains optional start_date/end_date; chat_scope on the agent config fail-closes get_conversations_tool / search_conversations_tool to that conversation and/or window; prompt matches.
  • Web: Today / This week chips (+ clear); existing conversation context now hard-scopes.
  • Flutter: Ask on conversation detail + Today / This week chips; POST /v2/messages sends context.

Honest gaps

  • Claude Agent VM path (claudeAgentEnabled) still unscoped — standard /v2/messages only.
  • Desktop macOS PageContext not wired in this PR.
  • No custom date-range picker (Today / This week only).
  • Flutter Ask/chips UI not device-smoked in this PR.

Test plan

  • pytest tests/unit/test_chat_scope.py (9 passed: conversation scope, discarded hide, timeframe fail-closed, PageContext date validation)
  • pytest tests/unit/test_conversation_tool_date_range_bound.py (8 passed; chat_scope stub pass-through)
  • pytest tests/unit/test_kg_user_type_mismatch.py (11 passed; transcript_for_llm stub)
  • pytest tests/unit/test_prompt_cache_integration.py::test_page_context_in_dynamic_section (MagicMock-safe date normalize)
  • App-client OpenAPI + TS clients regenerated (prior commit)
  • Web chip highlight derived from currentContext dates; title preserved for conversation/task/memory
  • Flutter scope is page-local; chips/tooltip via l10n; end-of-day uses next-midnight − 1µs
  • Physical / Flutter device smoke — not run (no kit); Claude Agent VM path still unscoped; desktop macOS PageContext not wired

Failure-Class: none

…are#4515)

PageContext was only a soft prompt hint; tools still searched the whole bank.
Fail-closed chat_scope clamps get/search conversation tools, strengthens the
prompt, and wires Ask-about-this + Today/This week chips on web and Flutter.

Co-authored-by: Cursor <cursoragent@cursor.com>
@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.

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 18 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread backend/utils/retrieval/tools/conversation_tools.py
Comment thread backend/models/chat.py
Comment thread app/lib/pages/chat/page.dart Outdated
Comment thread backend/utils/llm/chat.py Outdated
Comment thread app/lib/pages/chat/page.dart Outdated
Comment thread web/app/src/components/chat/ChatPanel.tsx Outdated
Comment thread app/lib/providers/message_provider.dart Outdated
Comment thread app/lib/pages/conversation_detail/page.dart Outdated
Comment thread backend/tests/unit/test_chat_scope.py
Comment thread web/app/src/components/chat/ChatPanel.tsx Outdated
Fail-closed scoped fetch respects discarded/statuses; gate memory tools
under conversation scope; validate aware PageContext dates; page-local
Flutter scope + l10n chips; derive web chip state from context; expand
unit coverage and bump the agentic line-count ratchet.

Failure-Class: none
Co-authored-by: Cursor <cursoragent@cursor.com>
@aryanorastar

Copy link
Copy Markdown
Contributor Author

Pushed @03b6753a0c addressing cubic + CI:

  • P1 scoped fetch honors discarded/statuses
  • Memory tools gated under conversation scope; dates applied for timeframe scope
  • PageContext aware-date validation; MagicMock-safe prompt dates
  • Flutter page-local scope + l10n + inclusive end-of-day; web chips derived from context; titles preserved
  • Unit coverage expanded; agentic line ratchet bumped; isolation stubs fixed

Test plan updated to checked automated boxes. Physical/Flutter device smoke left honest (no kit).

@Git-on-my-level Git-on-my-level added needs-tests PR introduces logic that should be covered by tests needs-maintainer-review Needs a human maintainer to sign off before merge backend Backend Task (python) labels Aug 7, 2026

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the thorough work here. The hard-scope direction looks useful, and I like that the backend retrieval path is trying to fail closed instead of leaving this as prompt-only context.

I need to request changes before this can move forward because the current head still has merge-blocking validation failures:

  • Backend type checking is failing in backend/models/chat.py around the new PageContext validator typing. Please clean up the pyright errors in the new date validation path.
  • Generated-file validation is failing for the app localization/API-generated outputs. Please regenerate/format those using the repo’s expected generator flow so the checked-in generated files match CI.
  • Repo hygiene/metadata is failing because backend/utils/retrieval grew a new source file without the required package-root architecture map. Please either add/update the required ARCHITECTURE.md/README.md map or keep the scope helper inside an existing mapped module.

Given this changes chat retrieval scoping across backend tools plus mobile/web UX, a human maintainer should still review the product/UX behavior after CI is green, especially the exact semantics for combining conversation scope with Today/This week and how unsupported memory tools should surface to users.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

…RCHITECTURE

Fix PageContext date validator typing for pyright, dart-format
message_provider, and add backend/utils/retrieval/ARCHITECTURE.md so the
new chat_scope module passes architecture guardrails.

Failure-Class: none
Co-authored-by: Cursor <cursoragent@cursor.com>
@aryanorastar

aryanorastar commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks — merge-blocking items addressed in 5739f321f3:

  1. PyrightPageContext date validator cleaned (_require_aware_iso(value: str, …); info.field_name narrowed). Local: pyright models/chat.py0 errors.
  2. Formattingapp/lib/providers/message_provider.dart dart-formatted (--line-length 120).
  3. Architecture map — added backend/utils/retrieval/ARCHITECTURE.md documenting chat_scope.py + package boundaries (fixes architecture-guardrails growth from 30→31 files).

Generated l10n: local flutter gen-l10n on Flutter 3.44.5 and 3.44.8 is clean against this tip (no diff). If CI’s unpinned stable still rewrites locale outputs, I’ll match that tip’s generator output in a follow-up.

Product/UX (for human pass after green CI):

  • Conversation scope + Today/This week: dates apply as an intersection with conversation scope (fail-closed); conversation id alone scopes without dates.
  • Memory tools under conversation scope are gated/refuse rather than searching all memory (same hard-scope intent as conversation tools).
  • Honest gaps unchanged: Claude Agent VM path unscoped; desktop macOS PageContext not wired; no custom date picker; Flutter UI not device-smoked.

Local: pytest tests/unit/test_chat_scope.py → 9 passed. Ready for CI re-check + product/UX glance when you have a moment.

Match app/analysis_options.yaml page_width so flutter gen-l10n on
CI's Flutter 3.44.9 stable tip is a no-op against checked-in files.

Co-authored-by: Cursor <cursoragent@cursor.com>
@aryanorastar

Copy link
Copy Markdown
Contributor Author

@Git-on-my-level pushed 904390b8d9 for the remaining CI blockers:

  1. Pyright — already cleared on prior tip (PageContext aware-date validator typing).
  2. Generated Files — regenerated/formatted app/lib/l10n/app_localizations*.dart at page_width: 120 (matches app/analysis_options.yaml) so CI flutter gen-l10n on Flutter 3.44.9 is a no-op.
  3. Hygiene / Failure-Class — PR body now declares Failure-Class: none (required because the branch has fix: commits). Retrieval ARCHITECTURE.md remains for the new chat_scope module.

Local: scripts/failure-class validate OK with the PR body; l10n format idempotent at 120.

Product/UX notes for the maintainer re-pass once CI is green:

  • Conversation scope ∩ Today/This week: both applied (single conversation, fail-closed to the date window).
  • Memory tools under conversation scope: gated/refuse (not silent all-memory search).

Honest gaps unchanged: no Flutter device smoke (no kit); Claude Agent VM path still unscoped; desktop macOS PageContext not wired.

Generated Files wants Flutter 3.44.9 gen-l10n output (expanded
pluralLogic, no trailing comma on last Locale), not dart-format
rewrites. Restore that style from the previously green tip and keep
the new chatScope keys. Format message_provider with page_width 120
after pub get for the Formatting check.

Failure-Class: none
Co-authored-by: Cursor <cursoragent@cursor.com>
@aryanorastar

aryanorastar commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

tip 904390b8d9 still failed Generated Files + Formatting — fixed on this push:

  1. Generated Filesdart format on app_localizations*.dart had rewritten gen-l10n output (compact plurals + trailing commas). Restored Flutter 3.44.9 gen-l10n style (matches the tip that was previously green) and kept the new chatScope* / askAboutThisConversation keys.
  2. Formattingmessage_provider.dart reformatted with page_width: 120 after flutter pub get (CI Flutter 3.44.5).

Ready for CI re-check + product/UX re-pass when green.

Repo Formatting check requires black 26.5.1 at line-length 120 on the
PageContext / chat_scope surfaces.

Failure-Class: none
Co-authored-by: Cursor <cursoragent@cursor.com>
@aryanorastar

aryanorastar commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Generated Files is green on 69295040d2. Remaining miss was Formatting (Python black, not Dart) — reformatted:

  • backend/models/chat.py
  • backend/tests/unit/test_chat_scope.py
  • backend/utils/retrieval/tools/conversation_tools.py
  • backend/utils/retrieval/tools/memory_tools.py

Pushed. Ready for green CI + product/UX re-pass.

Repo Formatting ARB check requires json.dumps(..., indent=4).

Failure-Class: none
Co-authored-by: Cursor <cursoragent@cursor.com>
@aryanorastar

aryanorastar commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

tip bfff106 left one Formatting miss: ARB (not Python) — app/lib/l10n/app_en.arb wasn’t 4-space indented.

Pushed a tip that runs jq --indent 4 on app_en.arb. Generated Files / black / Hygiene were already green. Ready for CI re-check + product/UX re-pass.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hard-scoped Ask — feature, approve only; needs a rebase (conflicts with main).

Union chatScope l10n keys with main ARBs, regenerate gen-l10n on Flutter 3.44.9,
combine backend-utils ratchet justifications, and harden date-range stub isolation.

Co-authored-by: Cursor <cursoragent@cursor.com>
@aryanorastar

Copy link
Copy Markdown
Contributor Author

@Git-on-my-level @kodjima33 conflicts with main resolved on tip a5f0861715:

  • Merged main into feat/4515-scoped-chat
  • ARBs: union of main locale keys + chatScope* / askAboutThisConversation (kept); regenerated app_localizations*.dart with Flutter 3.44.9 gen-l10n
  • backend-utils ratchet: kept AI Chat with a specific conversation or timeframe #4515 agentic justification + main’s stt/streaming entry
  • Stub isolation: test_conversation_tool_date_range_bound rebinds keyword_search_conversation_ids so sibling unit loads don’t trip reset_mock

Local: pytest tests/unit/test_chat_scope.py + test_conversation_tool_date_range_bound.py17 passed.

Prior merge-blocking CI items (pyright / Generated Files / Formatting / architecture map) were already addressed on the pre-rebase tip. Ready for CI re-check + product/UX re-pass; please dismiss the stale CHANGES_REQUESTED when green. kodjima size-gate APPROVE already on file.

Honest gaps unchanged: Claude Agent VM path unscoped; desktop macOS PageContext not wired; no custom date picker; Flutter UI not device-smoked (no kit).

@cubic-dev-ai cubic-dev-ai Bot 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.

40 issues found across 121 files

Confidence score: 2/5

  • In backend/utils/retrieval/tools/memory_tools.py, timeframe-scoped search_memories_tool and get_memories_tool can fall back to unbounded default-memory retrieval when rollout selects USE_MEMORY, which risks exposing memories outside Today/This week filters. Route these code paths through date-filtered retrieval only (or fail closed) before returning results.
  • In backend/utils/retrieval/chat_scope.py, conversation-scoped Ask still allows tools like get_action_items_tool to ignore the active conversation boundary, so tool calls may return unrelated user data. Enforce conversation scope at tool-dispatch time (or disable non-compliant tools for this scope).
  • In backend/utils/retrieval/tools/conversation_tools.py, integer end-bound conversion for Today/This week can exclude conversations created in the final fractional second, causing missing results at scope edges. Preserve full timestamp precision for end bounds to avoid off-by-fraction omissions.
  • Localization updates for new scope labels/tooltips are incomplete across ARBs (e.g., app/lib/l10n/app_ar.arb, app/lib/l10n/app_fi.arb, app/lib/l10n/app_pt.arb, app/lib/l10n/app_vi.arb, app/lib/l10n/app_fa.arb, and placeholders reflected via app/lib/l10n/app_localizations_en.dart), so users in many locales will see English strings. Replace placeholders with locale-specific translations before release.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="backend/utils/retrieval/tools/memory_tools.py">

<violation number="1" location="backend/utils/retrieval/tools/memory_tools.py:169">
P1: Timeframe-scoped `get_memories_tool` still returns unbounded default-memory results when rollout selects `USE_MEMORY`; bypass this adapter or add bounded filtering before returning so Today/This week cannot expose facts outside scope.</violation>

<violation number="2" location="backend/utils/retrieval/tools/memory_tools.py:387">
P1: Timeframe-scoped `search_memories_tool` leaks unfiltered default-memory vector matches when rollout selects `USE_MEMORY`; route scoped searches through a date-filtered retrieval path or fail closed for this backend.</violation>
</file>

<file name="backend/utils/retrieval/chat_scope.py">

<violation number="1" location="backend/utils/retrieval/chat_scope.py:31">
P1: Conversation-scoped Ask can still retrieve unrelated user data: `get_action_items_tool` (and other enabled retrieval tools) ignore this scope, so an agent tool call can return items outside the selected conversation despite the hard-scope contract. Add a central scoped-tool allowlist or make every unsupported retrieval tool reject/filter `chat_scope` before querying.</violation>
</file>

<file name="backend/utils/retrieval/tools/conversation_tools.py">

<violation number="1" location="backend/utils/retrieval/tools/conversation_tools.py:66">
P2: Today/This week conversation scopes drop conversations created during the final fractional second because these integer conversions narrow the end bound; preserve timestamp precision so scoped fetch matches list date filtering.</violation>
</file>

<file name="app/lib/l10n/app_ar.arb">

<violation number="1" location="app/lib/l10n/app_ar.arb:3194">
P2: New keys in the Arabic locale are untranslated English strings, so Arabic users will see the chat scope chips and Ask tooltip in English. Provide Arabic translations (e.g. اليوم، هذا الأسبوع، عن: {title}، اسأل عن هذا) and re-run `flutter gen-l10n`.</violation>
</file>

<file name="app/lib/l10n/app_fi.arb">

<violation number="1" location="app/lib/l10n/app_fi.arb:3218">
P2: The new keys added to the Finnish localization file carry English values instead of Finnish translations, so Finnish users will see English chip/tooltip text for the new chat-scope feature. Please localize: Tänään / Tällä viikolla / Aihe: {title} / Kysy tästä. (Note: full-language key coverage and mirrored @metadata are handled by gen-l10n/skill from the template, which is correct here.)</violation>
</file>

<file name="app/lib/l10n/app_localizations_en.dart">

<violation number="1" location="app/lib/l10n/app_localizations_en.dart:9837">
P2: The three new chat-scope keys plus `askAboutThisConversation` were added to all 49 locale ARBs as English placeholders ('Today', 'This week', 'About: {title}', 'Ask about this') instead of real translations — e.g. app_zh.arb and app_ja.arb carry English values while every surrounding key is translated. Non-English users will see the new Ask/chips UI in English, and `flutter gen-l10n` will emit untranslated-message warnings that break the analyzer ratchet. Translate these keys in each locale (per AGENTS.md: 'Translate all locales') before regenerating.</violation>
</file>

<file name="app/lib/l10n/app_pt.arb">

<violation number="1" location="app/lib/l10n/app_pt.arb:3254">
P2: These new keys in the Portuguese ARB are copied verbatim in English instead of being translated; PT users will see "Today"/"This week"/"About:"/"Ask about this" in the chat scope chips and Ask tooltip. Provide proper Portuguese translations, e.g. "Hoje", "Esta semana", "Sobre: {title}", "Pergunte sobre esta conversa".</violation>
</file>

<file name="app/lib/l10n/app_vi.arb">

<violation number="1" location="app/lib/l10n/app_vi.arb:3223">
P2: Vietnamese locale ships the new scope keys in English ('Today', 'This week', 'About: {title}', 'Ask about this') instead of translated Vietnamese, so Vietnamese users see English chip labels and tooltip. Translate these values into Vietnamese, e.g. 'Hôm nay', 'Tuần này', 'Về: {title}', 'Hỏi về cuộc trò chuyện này'.</violation>
</file>

<file name="app/lib/l10n/app_fa.arb">

<violation number="1" location="app/lib/l10n/app_fa.arb:10784">
P2: The new chat-scope keys are untranslated: app_fa.arb is the Persian locale yet these values are English ("Today", "This week", "About: {title}", "Ask about this"), so Farsi users see English UI. Because the keys are present (just in English), flutter gen-l10n won't warn, masking the missing translation — please provide real Persian strings, e.g. "امروز", "این هفته", "درباره: {title}", "درباره این مکالمه بپرس".</violation>
</file>

<file name="app/lib/l10n/app_hu.arb">

<violation number="1" location="app/lib/l10n/app_hu.arb:3314">
P2: The new keys in app_hu.arb contain untranslated English strings ("Today", "This week", "About: {title}", "Ask about this"), so Hungarian users will see English text for the new chat-scope chips. Please provide Hungarian translations; also add the "@chatScopeAbout" placeholder metadata for {title} to match the template convention.</violation>
</file>

<file name="app/lib/l10n/app_zh.arb">

<violation number="1" location="app/lib/l10n/app_zh.arb:3240">
P2: These new keys in app_zh.arb are untranslated English strings, so Chinese-locale users will see "Today / This week / About: {title} / Ask about this" in the chat scope UI instead of Chinese. Translate them (e.g. "今天", "本周", "关于:{title}", "就此对话提问") to match the existing zh localizations.</violation>
</file>

<file name="app/lib/l10n/app_lv.arb">

<violation number="1" location="app/lib/l10n/app_lv.arb:3218">
P2: New chat-scope keys are added to the Latvian locale (app_lv.arb) with English values, so Latvian users will see English chips/tooltips. Translate them, e.g. "Šodien", "Šī nedēļa", "Par: {title}", "Jautājiet par šo".</violation>
</file>

<file name="app/lib/l10n/app_ca.arb">

<violation number="1" location="app/lib/l10n/app_ca.arb:3196">
P2: These four keys were added to the Catalan locale file with English values ("Today", "This week", "About: {title}", "Ask about this"). Since every other entry in app_ca.arb is Catalan and gen-l10n only flags *missing* keys (not wrong values), Catalan users will see English UI text. Translate them, e.g. "Avui", "Aquesta setmana", "Sobre: {title}", "Pregunta sobre aquesta conversa".</violation>
</file>

<file name="app/lib/l10n/app_da.arb">

<violation number="1" location="app/lib/l10n/app_da.arb:3236">
P2: The new keys added to the Danish locale are English placeholder strings rather than Danish translations, so Danish users will see chips/tooltips in English (Today, This week, About: {title}, Ask about this). Translate them to Danish, e.g. "I dag", "Denne uge", "Om: {title}", "Spørg om dette", to match the l10n requirement for real translations.</violation>
</file>

<file name="app/lib/l10n/app_he.arb">

<violation number="1" location="app/lib/l10n/app_he.arb:10784">
P2: The new chat-scope keys in app_he.arb are untranslated English strings, so Hebrew users will see English for the Today/This week chips, the About chip, and the Ask tooltip. Translate these values to Hebrew (e.g. chatScopeToday: "היום", chatScopeThisWeek: "השבוע", askAboutThisConversation: "שאל על זה") for consistency with the rest of the file.</violation>
</file>

<file name="app/lib/l10n/app_tr.arb">

<violation number="1" location="app/lib/l10n/app_tr.arb:3253">
P2: The four new l10n keys added to the Turkish arb (app_tr.arb) contain English strings, so Turkish users will see untranslated UI text for the chat scope chips and Ask tooltip. Translate them: chatScopeToday → "Bugün", chatScopeThisWeek → "Bu hafta", chatScopeAbout → "Hakkında: {title}", askAboutThisConversation → "Bunun hakkında sor".</violation>
</file>

<file name="app/lib/l10n/app_localizations_ta.dart">

<violation number="1" location="app/lib/l10n/app_localizations_ta.dart:9914">
P2: The four new chat-scope strings are left in English inside the Tamil localization: 'Today', 'This week', 'About: {title}', 'Ask about this'. Tamil users of the new Ask/timeframe chips will see English UI. Translate them in app_ta.arb (and the other non-English ARBs, which all mirror the same English values) and regenerate.</violation>
</file>

<file name="app/lib/l10n/app_nl.arb">

<violation number="1" location="app/lib/l10n/app_nl.arb:3218">
P2: The new chat-scope strings are untranslated in the Dutch ARB - all four values are English ("Today", "This week", "About: {title}", "Ask about this") instead of Dutch. These are user-facing in the Ask-scope UI (Today/This week chips, the "About: {title}" scope chip, and the conversation-detail Ask tooltip), so Dutch users will see English text. Since the keys exist in every locale file, gen-l10n emits no untranslated warning and the English ships silently. Translate them, e.g. Vandaag / Deze week / Over: {title} / Vraag hierover.</violation>
</file>

<file name="app/lib/l10n/app_es.arb">

<violation number="1" location="app/lib/l10n/app_es.arb:3219">
P2: The four new keys in the Spanish ARB are left in English instead of being translated, so Spanish-locale users will see the English chat-scope chips/main were copied verbatim from app_en.arb. Translate these values: chatScopeToday→"Hoy", chatScopeThisWeek→"Esta semana", chatScopeAbout→"Acerca de: {title}", askAboutThisConversation→"Pregunta sobre esta conversación", and drop the placeholder-metadata note is fine since the template already defines it.</violation>
</file>

<file name="app/lib/l10n/app_sv.arb">

<violation number="1" location="app/lib/l10n/app_sv.arb:3218">
P2: New l10n strings are untranslated English values in the Swedish ARB (and copied verbatim into all other locales), so Swedish users will see "Today", "This week", "About: {title}", and "Ask about this" in English. Translate these chat-scope strings to Swedish (e.g. "Idag", "Den här veckan", "Om: {title}", "Fråga om detta") after adding keys.</violation>
</file>

<file name="app/lib/l10n/app_sr.arb">

<violation number="1" location="app/lib/l10n/app_sr.arb:10784">
P2: These new strings in the Serbian locale are untranslated English, so Serbian-speaking users will see the chat scope chips and the "Ask about this" tooltip in English while the rest of the app renders in Serbian. Please provide actual Serbian translations (e.g. "Данас", "Ове недеље", "О: {title}", "Питај о овоме") before merge.</violation>
</file>

<file name="app/lib/l10n/app_el.arb">

<violation number="1" location="app/lib/l10n/app_el.arb:3218">
P2: New l10n keys were added to app_el.arb with English values instead of Greek translations: "chatScopeToday": "Today", "chatScopeThisWeek": "This week", "chatScopeAbout": "About: {title}", "askAboutThisConversation": "Ask about this". Greek users will see these chip/tooltip strings in English; translate them to Greek in this locale file.</violation>
</file>

<file name="app/lib/l10n/app_de.arb">

<violation number="1" location="app/lib/l10n/app_de.arb:3195">
P2: New keys in app_de.arb (German locale) have untranslated English values ("Today", "This week", "About: {title}", "Ask about this") while every other string in this file is German. German users will see English UI text. Translate to German, e.g. "Heute", "Diese Woche", "Über: {title}", "Hierzu fragen".</violation>
</file>

<file name="app/lib/l10n/app_it.arb">

<violation number="1" location="app/lib/l10n/app_it.arb:3218">
P2: The new keys in the Italian ARB are English literals ("Today", "This week", "About: {title}", "Ask about this"), so Italian-locale users will see the chat scope chips, title and tooltip in English. Translate them to Italian (e.g. "Oggi", "Questa settimana", "Su: {title}", "Chiedi su questa conversazione") to match the rest of the file.</violation>
</file>

<file name="app/lib/l10n/app_fr.arb">

<violation number="1" location="app/lib/l10n/app_fr.arb:3253">
P2: The new French-localized keys still contain English text, so French users will see "Today", "This week", "About: …", and "Ask about this" instead of translations. Provide real French translations for these four keys, e.g. "Aujourd'hui", "Cette semaine", "À propos : {title}", and "Interroger sur cette conversation".</violation>
</file>

<file name="app/lib/l10n/app_et.arb">

<violation number="1" location="app/lib/l10n/app_et.arb:3218">
P2: The four new keys in the Estonian ARB were added with untranslated English values ("Today", "This week", "About: {title}", "Ask about this") instead of Estonian translations. Estonian users of the new Ask/timeframe scope chips will see English text; translate these values (and mirror the genre metadata) so the chat-scope UI is localized like the rest of app_et.arb.</violation>
</file>

<file name="app/lib/l10n/app_localizations_th.dart">

<violation number="1" location="app/lib/l10n/app_localizations_th.dart:9789">
P2: These new strings are untranslated English in the Thai locale, so Thai users will see 'Today', 'This week', 'About: …', and 'Ask about this' in English on the new chat-scope chips and tooltip while the rest of the app is Thai. Translate the four values in app_th.arb (the dart file is generated from it) — e.g. 'วันนี้', 'สัปดาห์นี้', 'ถามเกี่ยวกับ: $title', 'ถามเกี่ยวกับเรื่องนี้' — and regenerate with flutter gen-l10n.</violation>
</file>

<file name="app/lib/l10n/app_no.arb">

<violation number="1" location="app/lib/l10n/app_no.arb:3218">
P2: The newly added keys in the Norwegian locale are untranslated English strings, so Norwegian users will see “Today / This week / About: / Ask about this” in English instead of norsk. Translate them (e.g. “I dag”, “Denne uken”, “Om: {title}”, “Spør om denne samtalen”) to match the other localized keys in this file.</violation>
</file>

<file name="app/lib/l10n/app_localizations_kn.dart">

<violation number="1" location="app/lib/l10n/app_localizations_kn.dart:9876">
P2: These new localization values are left in English ('Today', 'This week', 'Ask about this', 'About: …') in the Kannada file, so Kannada users will see English UI for the new chat-scope chips and Ask tooltip. Translate each value into Kannada in app_kn.arb (and regenerate) rather than mirroring the template text.</violation>
</file>

<file name="app/lib/l10n/app_cs.arb">

<violation number="1" location="app/lib/l10n/app_cs.arb:3196">
P2: The Czech locale file carries English values for the new chat scope strings ("Today", "This week", "About: {title}", "Ask about this") instead of Czech translations, so Czech users will see the chips/tooltip in English. Translate these (e.g. "Dnes", "Tento týden", "O: {title}", "Zeptat se na toto") to match the rest of the file.</violation>
</file>

<file name="app/lib/l10n/app_lt.arb">

<violation number="1" location="app/lib/l10n/app_lt.arb:3218">
P2: The new chat-scope keys are added to the Lithuanian ARB (app_lt.arb) with English values ("Today", "This week", "About: {title}", "Ask about this") instead of Lithuanian translations, so Lithuanian users will see English text on the chat-scope chips/Ask tooltip. Translate these values (e.g. Šiandien, Šią savaitę, Apie: {title}, Klausti šio pokalbio) to match the locale.</violation>
</file>

<file name="app/lib/l10n/app_te.arb">

<violation number="1" location="app/lib/l10n/app_te.arb:10784">
P2: These new keys are added to the Telugu locale with hardcoded English values instead of Telugu translations, so Telugu users will see "Today"/"This week"/"About: ..."/"Ask about this" in English. Translate the values (and mirror the @chatScopeAbout placeholder metadata) in the Telugu ARB per the l10n workflow that requires real translations in every locale.</violation>
</file>

<file name="backend/models/chat.py">

<violation number="1" location="backend/models/chat.py:227">
P2: Scope bounds remain raw strings and require duplicate parsing after request validation; type both fields as timezone-aware `datetime` and serialize canonical values at the tool boundary.

(Based on your team's feedback about typed backend API date fields.)</violation>
</file>

<file name="app/lib/l10n/app_localizations_pl.dart">

<violation number="1" location="app/lib/l10n/app_localizations_pl.dart:9874">
P2: The four new Polish localization strings ('Today', 'This week', 'About: {title}', 'Ask about this') are untranslated English placeholders left in app_pl.arb, so Polish-speaking users will see English text in the new Ask/chips UI instead of Polish. Translate these values in app/lib/l10n/app_pl.arb and regenerate (e.g. chatScopeToday: 'Dziś', chatScopeThisWeek: 'W tym tygodniu', chatScopeAbout: 'Zapytaj o: {title}', askAboutThisConversation: 'Zapytaj o tę rozmowę').</violation>
</file>

<file name="app/lib/l10n/app_mk.arb">

<violation number="1" location="app/lib/l10n/app_mk.arb:10784">
P2: The new chat-scope strings are added to the Macedonian (mk) ARB but left in English: "Today", "This week", "About: {title}", "Ask about this". Macedonian users will see these UI labels/chips in English. Translate them (e.g. "Денес", "Оваа недела", "За: {title}", "Прашај за ова") and regenerate with flutter gen-l10n.</violation>
</file>

<file name="app/lib/l10n/app_ja.arb">

<violation number="1" location="app/lib/l10n/app_ja.arb:3194">
P2: These new user-facing strings are left in English in the Japanese locale file ("Today", "This week", "About: {title}", "Ask about this"), so Japanese users will see English chips/tooltips instead of translated text. Translate all four keys to Japanese (per AGENTS.md: translate all locales) and mirror the @-metadata (description/placeholders) to match the template.</violation>
</file>

<file name="app/lib/l10n/app_be.arb">

<violation number="1" location="app/lib/l10n/app_be.arb:10784">
P2: These new user-facing strings are added to the Belarusian locale as English placeholders ("Today", "This week", "About: {title}", "Ask about this") instead of Belarusian translations. Per the app's localization rules all user-facing strings must be translated per locale, so Belarusian-speaking users will see English chips and tooltips for the new chat-scope UI.</violation>
</file>

<file name="app/lib/l10n/app_ur.arb">

<violation number="1" location="app/lib/l10n/app_ur.arb:10784">
P2: New Urdu ARB keys are inserted as untranslated English strings, so Urdu UI will show English chips/tooltip instead of Urdu; the surrounding keys in this file are native Urdu. Translate the four values to Urdu (and mirror the metadata from the template) per the l10n convention.</violation>
</file>

<file name="app/lib/l10n/app_sk.arb">

<violation number="1" location="app/lib/l10n/app_sk.arb:3223">
P2: These new user-facing chip/tooltip strings are left in English inside the Slovak locale file (app_sk.arb), so Slovak users will see "Today", "This week", "About: {title}" and "Ask about this" in English. Since all other keys in this file are translated to Slovak, provide actual Slovak translations here (and confirm the other locale files don't ship English placeholders either).</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

if blocked:
return blocked

scope = chat_scope_from_config(configurable) or {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: Timeframe-scoped search_memories_tool leaks unfiltered default-memory vector matches when rollout selects USE_MEMORY; route scoped searches through a date-filtered retrieval path or fail closed for this backend.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/utils/retrieval/tools/memory_tools.py, line 387:

<comment>Timeframe-scoped `search_memories_tool` leaks unfiltered default-memory vector matches when rollout selects `USE_MEMORY`; route scoped searches through a date-filtered retrieval path or fail closed for this backend.</comment>

<file context>
@@ -340,6 +380,20 @@ def search_memories_tool(
+    if blocked:
+        return blocked
+
+    scope = chat_scope_from_config(configurable) or {}
+    _, _, scope_err = apply_chat_scope_dates(scope, None, None)
+    if scope_err:
</file context>

if blocked:
return blocked

start_date, end_date, scope_err = apply_chat_scope_dates(chat_scope_from_config(configurable), start_date, end_date)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: Timeframe-scoped get_memories_tool still returns unbounded default-memory results when rollout selects USE_MEMORY; bypass this adapter or add bounded filtering before returning so Today/This week cannot expose facts outside scope.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/utils/retrieval/tools/memory_tools.py, line 169:

<comment>Timeframe-scoped `get_memories_tool` still returns unbounded default-memory results when rollout selects `USE_MEMORY`; bypass this adapter or add bounded filtering before returning so Today/This week cannot expose facts outside scope.</comment>

<file context>
@@ -130,6 +162,14 @@ def get_memories_tool(
+    if blocked:
+        return blocked
+
+    start_date, end_date, scope_err = apply_chat_scope_dates(chat_scope_from_config(configurable), start_date, end_date)
+    if scope_err:
+        return f"Error: {scope_err}"
</file context>

if end_date.strip():
scope["end_date"] = end_date.strip()

return scope or None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: Conversation-scoped Ask can still retrieve unrelated user data: get_action_items_tool (and other enabled retrieval tools) ignore this scope, so an agent tool call can return items outside the selected conversation despite the hard-scope contract. Add a central scoped-tool allowlist or make every unsupported retrieval tool reject/filter chat_scope before querying.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/utils/retrieval/chat_scope.py, line 31:

<comment>Conversation-scoped Ask can still retrieve unrelated user data: `get_action_items_tool` (and other enabled retrieval tools) ignore this scope, so an agent tool call can return items outside the selected conversation despite the hard-scope contract. Add a central scoped-tool allowlist or make every unsupported retrieval tool reject/filter `chat_scope` before querying.</comment>

<file context>
@@ -0,0 +1,98 @@
+    if end_date.strip():
+        scope["end_date"] = end_date.strip()
+
+    return scope or None
+
+
</file context>

Comment on lines +66 to +67
start_ts = int(start_dt.timestamp()) if start_dt is not None else None
end_ts = int(end_dt.timestamp()) if end_dt is not None else None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Today/This week conversation scopes drop conversations created during the final fractional second because these integer conversions narrow the end bound; preserve timestamp precision so scoped fetch matches list date filtering.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/utils/retrieval/tools/conversation_tools.py, line 66:

<comment>Today/This week conversation scopes drop conversations created during the final fractional second because these integer conversions narrow the end bound; preserve timestamp precision so scoped fetch matches list date filtering.</comment>

<file context>
@@ -42,6 +43,37 @@ def _agent_config() -> Optional[Dict[str, Any]]:
+        status_val = getattr(raw_status, 'value', raw_status)
+        if status_val is not None and str(status_val) not in statuses:
+            return [], f"No accessible conversation found for scoped id {conversation_id}."
+    start_ts = int(start_dt.timestamp()) if start_dt is not None else None
+    end_ts = int(end_dt.timestamp()) if end_dt is not None else None
+    if start_ts is not None or end_ts is not None:
</file context>
Suggested change
start_ts = int(start_dt.timestamp()) if start_dt is not None else None
end_ts = int(end_dt.timestamp()) if end_dt is not None else None
start_ts = start_dt.timestamp() if start_dt is not None else None
end_ts = end_dt.timestamp() if end_dt is not None else None

Comment thread app/lib/l10n/app_ar.arb
Comment on lines +3194 to +3197
"chatScopeToday": "Today",
"chatScopeThisWeek": "This week",
"chatScopeAbout": "About: {title}",
"askAboutThisConversation": "Ask about this"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: New keys in the Arabic locale are untranslated English strings, so Arabic users will see the chat scope chips and Ask tooltip in English. Provide Arabic translations (e.g. اليوم، هذا الأسبوع، عن: {title}، اسأل عن هذا) and re-run flutter gen-l10n.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/lib/l10n/app_ar.arb, line 3194:

<comment>New keys in the Arabic locale are untranslated English strings, so Arabic users will see the chat scope chips and Ask tooltip in English. Provide Arabic translations (e.g. اليوم، هذا الأسبوع، عن: {title}، اسأل عن هذا) and re-run `flutter gen-l10n`.</comment>

<file context>
@@ -3190,5 +3190,9 @@
     "accountCutoverMigrationRollbackMessage": "حسابك قيد الصيانة بعد التراجع عن الترحيل. قد تُعزل بعض البيانات الأحدث.",
-    "accountCutoverOpenStore": "فتح المتجر"
+    "accountCutoverOpenStore": "فتح المتجر",
+    "chatScopeToday": "Today",
+    "chatScopeThisWeek": "This week",
+    "chatScopeAbout": "About: {title}",
</file context>
Suggested change
"chatScopeToday": "Today",
"chatScopeThisWeek": "This week",
"chatScopeAbout": "About: {title}",
"askAboutThisConversation": "Ask about this"
"chatScopeToday": "اليوم",
"chatScopeThisWeek": "هذا الأسبوع",
"chatScopeAbout": "عن: {title}",
"askAboutThisConversation": "اسأل عن هذا"

Comment thread app/lib/l10n/app_mk.arb
Comment on lines +10784 to +10787
"chatScopeToday": "Today",
"chatScopeThisWeek": "This week",
"chatScopeAbout": "About: {title}",
"askAboutThisConversation": "Ask about this"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The new chat-scope strings are added to the Macedonian (mk) ARB but left in English: "Today", "This week", "About: {title}", "Ask about this". Macedonian users will see these UI labels/chips in English. Translate them (e.g. "Денес", "Оваа недела", "За: {title}", "Прашај за ова") and regenerate with flutter gen-l10n.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/lib/l10n/app_mk.arb, line 10784:

<comment>The new chat-scope strings are added to the Macedonian (mk) ARB but left in English: "Today", "This week", "About: {title}", "Ask about this". Macedonian users will see these UI labels/chips in English. Translate them (e.g. "Денес", "Оваа недела", "За: {title}", "Прашај за ова") and regenerate with flutter gen-l10n.</comment>

<file context>
@@ -10780,5 +10780,9 @@
     "accountCutoverMigrationRollbackMessage": "Váš účet je po vrácení migrace v režimu údržby. Novější data mohou být izolována.",
-    "accountCutoverOpenStore": "Otevřít obchod"
+    "accountCutoverOpenStore": "Otevřít obchod",
+    "chatScopeToday": "Today",
+    "chatScopeThisWeek": "This week",
+    "chatScopeAbout": "About: {title}",
</file context>
Suggested change
"chatScopeToday": "Today",
"chatScopeThisWeek": "This week",
"chatScopeAbout": "About: {title}",
"askAboutThisConversation": "Ask about this"
"chatScopeToday": "Денес",
"chatScopeThisWeek": "Оваа недела",
"chatScopeAbout": "За: {title}",
"askAboutThisConversation": "Прашај за ова"

Comment thread app/lib/l10n/app_ja.arb
"accountCutoverMigrationRollbackMessage": "移行のロールバック後、アカウントはメンテナンス中です。新しいデータの一部が孤立している可能性があります。",
"accountCutoverOpenStore": "ストアを開く"
"accountCutoverOpenStore": "ストアを開く",
"chatScopeToday": "Today",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: These new user-facing strings are left in English in the Japanese locale file ("Today", "This week", "About: {title}", "Ask about this"), so Japanese users will see English chips/tooltips instead of translated text. Translate all four keys to Japanese (per AGENTS.md: translate all locales) and mirror the @-metadata (description/placeholders) to match the template.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/lib/l10n/app_ja.arb, line 3194:

<comment>These new user-facing strings are left in English in the Japanese locale file ("Today", "This week", "About: {title}", "Ask about this"), so Japanese users will see English chips/tooltips instead of translated text. Translate all four keys to Japanese (per AGENTS.md: translate all locales) and mirror the @-metadata (description/placeholders) to match the template.</comment>

<file context>
@@ -3190,5 +3190,9 @@
     "accountCutoverMigrationRollbackMessage": "移行のロールバック後、アカウントはメンテナンス中です。新しいデータの一部が孤立している可能性があります。",
-    "accountCutoverOpenStore": "ストアを開く"
+    "accountCutoverOpenStore": "ストアを開く",
+    "chatScopeToday": "Today",
+    "chatScopeThisWeek": "This week",
+    "chatScopeAbout": "About: {title}",
</file context>

Comment thread app/lib/l10n/app_be.arb
"accountCutoverMigrationRollbackMessage": "Ваш аккаунт на обслуживании после отката миграции. Часть более новых данных может быть изолирована.",
"accountCutoverOpenStore": "Открыть магазин"
"accountCutoverOpenStore": "Открыть магазин",
"chatScopeToday": "Today",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: These new user-facing strings are added to the Belarusian locale as English placeholders ("Today", "This week", "About: {title}", "Ask about this") instead of Belarusian translations. Per the app's localization rules all user-facing strings must be translated per locale, so Belarusian-speaking users will see English chips and tooltips for the new chat-scope UI.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/lib/l10n/app_be.arb, line 10784:

<comment>These new user-facing strings are added to the Belarusian locale as English placeholders ("Today", "This week", "About: {title}", "Ask about this") instead of Belarusian translations. Per the app's localization rules all user-facing strings must be translated per locale, so Belarusian-speaking users will see English chips and tooltips for the new chat-scope UI.</comment>

<file context>
@@ -10780,5 +10780,9 @@
     "accountCutoverMigrationRollbackMessage": "Ваш аккаунт на обслуживании после отката миграции. Часть более новых данных может быть изолирована.",
-    "accountCutoverOpenStore": "Открыть магазин"
+    "accountCutoverOpenStore": "Открыть магазин",
+    "chatScopeToday": "Today",
+    "chatScopeThisWeek": "This week",
+    "chatScopeAbout": "About: {title}",
</file context>

Comment thread app/lib/l10n/app_ur.arb
"accountCutoverMigrationRollbackMessage": "حسابك قيد الصيانة بعد التراجع عن الترحيل. قد تُعزل بعض البيانات الأحدث.",
"accountCutoverOpenStore": "فتح المتجر"
"accountCutoverOpenStore": "فتح المتجر",
"chatScopeToday": "Today",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: New Urdu ARB keys are inserted as untranslated English strings, so Urdu UI will show English chips/tooltip instead of Urdu; the surrounding keys in this file are native Urdu. Translate the four values to Urdu (and mirror the metadata from the template) per the l10n convention.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/lib/l10n/app_ur.arb, line 10784:

<comment>New Urdu ARB keys are inserted as untranslated English strings, so Urdu UI will show English chips/tooltip instead of Urdu; the surrounding keys in this file are native Urdu. Translate the four values to Urdu (and mirror the metadata from the template) per the l10n convention.</comment>

<file context>
@@ -10780,5 +10780,9 @@
     "accountCutoverMigrationRollbackMessage": "حسابك قيد الصيانة بعد التراجع عن الترحيل. قد تُعزل بعض البيانات الأحدث.",
-    "accountCutoverOpenStore": "فتح المتجر"
+    "accountCutoverOpenStore": "فتح المتجر",
+    "chatScopeToday": "Today",
+    "chatScopeThisWeek": "This week",
+    "chatScopeAbout": "About: {title}",
</file context>

Comment thread app/lib/l10n/app_sk.arb
Comment on lines +3223 to +3226
"chatScopeToday": "Today",
"chatScopeThisWeek": "This week",
"chatScopeAbout": "About: {title}",
"askAboutThisConversation": "Ask about this"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: These new user-facing chip/tooltip strings are left in English inside the Slovak locale file (app_sk.arb), so Slovak users will see "Today", "This week", "About: {title}" and "Ask about this" in English. Since all other keys in this file are translated to Slovak, provide actual Slovak translations here (and confirm the other locale files don't ship English placeholders either).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/lib/l10n/app_sk.arb, line 3223:

<comment>These new user-facing chip/tooltip strings are left in English inside the Slovak locale file (app_sk.arb), so Slovak users will see "Today", "This week", "About: {title}" and "Ask about this" in English. Since all other keys in this file are translated to Slovak, provide actual Slovak translations here (and confirm the other locale files don't ship English placeholders either).</comment>

<file context>
@@ -3219,5 +3219,9 @@
     "accountCutoverMigrationRollbackMessage": "Váš účet je po vrácení migrace v režimu údržby. Novější data mohou být izolována.",
-    "accountCutoverOpenStore": "Otevřít obchod"
+    "accountCutoverOpenStore": "Otevřít obchod",
+    "chatScopeToday": "Today",
+    "chatScopeThisWeek": "This week",
+    "chatScopeAbout": "About: {title}",
</file context>
Suggested change
"chatScopeToday": "Today",
"chatScopeThisWeek": "This week",
"chatScopeAbout": "About: {title}",
"askAboutThisConversation": "Ask about this"
"chatScopeToday": "Dnes",
"chatScopeThisWeek": "Tento týždeň",
"chatScopeAbout": "O {title}",
"askAboutThisConversation": "Opýtať sa na to"

@Git-on-my-level Git-on-my-level removed the needs-tests PR introduces logic that should be covered by tests label Aug 8, 2026
@Git-on-my-level
Git-on-my-level dismissed their stale review August 8, 2026 22:55

Resolved on current head: backend typecheck/generator/architecture-map validation blockers are green, and this pass is non-blocking.

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the updates here. I re-reviewed the current head and the earlier validation blockers look resolved: backend/models/chat.py now validates timezone-aware PageContext.start_date / end_date, the generated Flutter/API files are checked in, and backend/utils/retrieval/ARCHITECTURE.md now documents the new retrieval package boundary.

Code-specific notes from this pass:

  • backend/utils/retrieval/chat_scope.py now centralizes scope construction and date-bound intersection; the fail-closed empty-intersection error is a good guard for the tool layer.
  • backend/utils/retrieval/tools/conversation_tools.py routes scoped conversation requests through get_conversation() and refuses discarded/locked/out-of-window conversations instead of falling back to broad search.
  • backend/utils/retrieval/tools/memory_tools.py blocks global memory fact tools when a specific conversation scope is active, which avoids silently answering from unrelated memories.
  • backend/utils/llm/chat.py now makes the hard-scope semantics explicit in the system prompt, while backend/utils/retrieval/agentic.py passes the computed chat_scope through tool config.
  • On the clients, app/lib/backend/http/api/messages.dart, app/lib/pages/chat/page.dart, web/app/src/components/chat/ChatPanel.tsx, and web/app/src/lib/api.ts consistently send context.start_date / context.end_date with the chat request.
  • backend/tests/unit/test_chat_scope.py covers scope construction, timezone validation, scoped conversation fetch, discarded/out-of-window failures, and exact-reference escape attempts.

I’m not re-requesting changes. I am leaving this for human maintainer review because the feature changes product/UX semantics for combining “Ask about this conversation” with Today/This week, and non-English localization entries currently use English fallback copy across the generated ARB/localization files.

Agent-behavior note: backend/utils/retrieval/ARCHITECTURE.md is new guidance that coding/review agents may read for this backend package. The guidance is narrow and seems accurate: it documents that standard /v2/messages retrieval should fail closed under chat_scope, that unsupported tools should refuse rather than search globally, and that the Claude Agent VM path is intentionally out of scope until wired. That is safe as repo guidance, but it does mean future agents will treat this scoping contract as authoritative, so maintainer sign-off on those boundaries is worthwhile.

I could not reproduce the focused backend tests locally in this sandbox because the checkout is missing backend test dependencies (ModuleNotFoundError: No module named 'google' from tests/unit/conftest.py), but the PR’s current GitHub checks in the supplied context are green.


by AI on behalf of David — leaving for human maintainer review on the chat-scope product/UX boundary.

…pe fail-closed

Keep agentic.py baseline at measured 1517 with the BasedHardware#4515 justification.
Refuse USE_MEMORY under timeframe scope, force action-item conversation
scope, and preserve fractional end-bound timestamps for scoped fetch.

Co-authored-by: Cursor <cursoragent@cursor.com>
@aryanorastar

Copy link
Copy Markdown
Contributor Author

Addressed @9b57a1fc61ea

@Git-on-my-level @kodjima33 conflicts cleared + cubic P1 fail-closed tightenings.

Conflict

Scope harden (cubic P1s / hire-bar)

  • Memory USE_MEMORY under timeframeget_memories_tool / search_memories_tool now refuse the unbounded default-memory adapter when Today/This week dates are active (no silent all-memory leak).
  • Action items under conversation scopeget_action_items_tool forces conversation_id from chat_scope and rejects foreign ids.
  • Fractional end bounds — scoped conversation fetch keeps float timestamps (no int() truncation of the final second).

Tests

pytest tests/unit/test_chat_scope.py12 passed (incl. action-item force/reject + USE_MEMORY timeframe refuse).

Non-English ARB chips still English fallbacks (called out earlier) — leaving that for product/l10n follow-up rather than blocking this tip. Honest gaps unchanged (Claude Agent VM unscoped; desktop macOS PageContext unwired; no kit smoke).

Ready for CI re-check + product/UX merge call when green.

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 123 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread backend/utils/retrieval/tools/conversation_tools.py Outdated
Comment thread backend/utils/retrieval/agentic.py Outdated
Comment thread backend/tests/unit/test_chat_scope.py Outdated
…ad nits

Co-authored-by: Cursor <cursoragent@cursor.com>
@aryanorastar

Copy link
Copy Markdown
Contributor Author

CI + cubic tip @e8f1506ef7

@Git-on-my-level @kodjima33 tip 9b57a1fc61 was red on Formatting + Backend unit suite. Fixed on e8f1506ef7:

CI

  • Formatting — black test_chat_scope.py
  • Backend unit — isolation stubs for utils.retrieval.chat_scope in action-item hermetic loaders (test_action_item_date_validation / tool_result_bound / timezone) so ModuleNotFoundError: chat_scope no longer breaks those files when loading action_item_tools

Cubic nits

  • P2 scoped fetch uses get_conversations_by_id(..., include_discarded=True) then applies discarded/locked/status filters (id backfill from doc key)
  • P3 build_chat_scope imported at module scope in agentic.py
  • P3 action-item empty-result assert tightened to "no action items found"

Local (isolated, matching CI file runner):

  • test_chat_scope.py → 12 passed
  • test_action_item_date_validation.py → 26 passed
  • test_action_item_tool_result_bound.py → 7 passed
  • test_action_items_timezone.py → 11 passed

Ready for CI re-check + product/UX merge when green. Honest gaps unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
@aryanorastar

Copy link
Copy Markdown
Contributor Author

Tip @6808fc9c29 — Hygiene + prompt-cache isolation

@Git-on-my-level @kodjima33 tip e8f1506ef7 left two reds:

Hygiene

  • agentic.py baseline 1517 → 1516 (exact match after module-scope build_chat_scope hoist removed one line)

Backend unit

  • test_prompt_cache_integration.py hermetic loader now stubs utils.retrieval.chat_scope before loading agentic.py (module-scope import; was ModuleNotFoundError)
  • Local: pytest tests/unit/test_prompt_cache_integration.py32 passed

Ready for CI re-check + product/UX merge when green.

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the continued fixes here. I re-reviewed the current head (6808fc9c29) and I do not see a new merge-blocking implementation issue; keeping this as maintainer-review rather than formal approval because this is still a product/UX hard-scope feature with agent-behavior documentation changes.

Code-specific notes from this pass:

  • backend/models/chat.py now makes PageContext.start_date / end_date timezone-aware ISO strings, so invalid or naive scope dates fail during request validation instead of becoming ambiguous tool bounds.
  • backend/utils/retrieval/chat_scope.py centralizes the hard-scope contract: conversation ids become conversation_id, date bounds are intersected fail-closed, and empty intersections return a clear scoped-error path.
  • backend/utils/retrieval/tools/conversation_tools.py applies that scope in both direct conversation retrieval and semantic/exact conversation search; exact references to a different conversation are refused while scoped searches fetch only the scoped conversation.
  • backend/utils/retrieval/tools/memory_tools.py blocks global memory tools under conversation scope and fails closed for default-memory paths that cannot honor timeframe filters, which addresses the main leakage risk I was looking for.
  • backend/utils/retrieval/tools/action_item_tools.py forces the scoped conversation id and rejects mismatched explicit ids, so action-item retrieval does not silently escape the active conversation.
  • app/lib/pages/chat/page.dart and app/lib/pages/conversation_detail/page.dart wire the mobile “Ask about this” entry point plus Today/This week chips into the structured ChatPageContext payload instead of relying only on prompt text.
  • web/app/src/components/chat/ChatPanel.tsx / web/app/src/lib/api.ts do the same for web by preserving current context, deriving timeframe chips from start_date / end_date, and sending context in POST /v2/messages.
  • backend/tests/unit/test_chat_scope.py covers the important fail-closed paths, including scoped conversation fetches, date intersection, foreign exact-reference rejection, action-item scoping, and default-memory timeframe refusal.
  • backend/utils/retrieval/ARCHITECTURE.md is an agent-facing/reviewer-facing package map. Maintainer consequence: it tells future coding/review agents that chat_scope is intended to be fail-closed and that unsupported scoped tools should refuse rather than search broadly. That guidance looks safe and consistent with this diff, but it is still behavior-shaping documentation and should stay under human maintainer review when this feature is merged.

Validation note: GitHub checks are green on this head. I attempted the focused backend scope test locally, but this checkout’s backend test environment is missing the google Python package at conftest.py import time, so I did not treat that local harness setup failure as a production-code blocker.

Leaving this for human maintainer review because the remaining decision is the product/UX contract for hard-scoped chat behavior and the agent-facing retrieval guidance, not a concrete code defect I can verify on this head.


Automated maintainer review by glm-5.2.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@aryanorastar

Copy link
Copy Markdown
Contributor Author

@kodjima33 @beastoin @Git-on-my-level need human response — product/UX merge call for #11206 / #4515.

Author-clear on 6808fc9c29:

  • APPROVED (kodjima33) + MERGEABLE CLEAN + all checks green (27 success)
  • David: no merge-blocking implementation issue; remaining call is product/UX hard-scope semantics + agent-facing retrieval guidance
  • Fail-closed scope intact: conversation ∩ Today/This week, memory tools refuse under conversation scope / unbounded USE_MEMORY under timeframe, action items forced to scoped conversation id, float end bounds
  • Honest gaps unchanged: Claude Agent VM path unscoped; desktop macOS PageContext not wired; no custom date picker; Flutter UI not device-smoked (no kit)

Please merge when the product/UX call is accepted, or state an explicit hold.

@undivisible undivisible added human Human-authored pull request app flutter flutter work mobile workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior labels Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app backend Backend Task (python) flutter flutter work human Human-authored pull request mobile needs-maintainer-review Needs a human maintainer to sign off before merge workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AI Chat with a specific conversation or timeframe

4 participants