feat(chat): hard-scope Ask to a conversation or timeframe (#4515) - #11206
feat(chat): hard-scope Ask to a conversation or timeframe (#4515)#11206aryanorastar wants to merge 11 commits into
Conversation
…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>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
All reported issues were addressed across 18 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
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>
|
Pushed
Test plan updated to checked automated boxes. Physical/Flutter device smoke left honest (no kit). |
Git-on-my-level
left a comment
There was a problem hiding this comment.
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.pyaround the newPageContextvalidator 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/retrievalgrew a new source file without the required package-root architecture map. Please either add/update the requiredARCHITECTURE.md/README.mdmap 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>
|
Thanks — merge-blocking items addressed in
Generated l10n: local Product/UX (for human pass after green CI):
Local: |
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>
|
@Git-on-my-level pushed
Local: Product/UX notes for the maintainer re-pass once CI is green:
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>
|
tip
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>
|
Generated Files is green on
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>
|
tip Pushed a tip that runs |
kodjima33
left a comment
There was a problem hiding this comment.
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>
|
@Git-on-my-level @kodjima33 conflicts with
Local: 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). |
There was a problem hiding this comment.
40 issues found across 121 files
Confidence score: 2/5
- In
backend/utils/retrieval/tools/memory_tools.py, timeframe-scopedsearch_memories_toolandget_memories_toolcan fall back to unbounded default-memory retrieval when rollout selectsUSE_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 likeget_action_items_toolto 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 viaapp/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 {} |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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>
| 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 |
There was a problem hiding this comment.
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>
| 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 |
| "chatScopeToday": "Today", | ||
| "chatScopeThisWeek": "This week", | ||
| "chatScopeAbout": "About: {title}", | ||
| "askAboutThisConversation": "Ask about this" |
There was a problem hiding this comment.
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>
| "chatScopeToday": "Today", | |
| "chatScopeThisWeek": "This week", | |
| "chatScopeAbout": "About: {title}", | |
| "askAboutThisConversation": "Ask about this" | |
| "chatScopeToday": "اليوم", | |
| "chatScopeThisWeek": "هذا الأسبوع", | |
| "chatScopeAbout": "عن: {title}", | |
| "askAboutThisConversation": "اسأل عن هذا" |
| "chatScopeToday": "Today", | ||
| "chatScopeThisWeek": "This week", | ||
| "chatScopeAbout": "About: {title}", | ||
| "askAboutThisConversation": "Ask about this" |
There was a problem hiding this comment.
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>
| "chatScopeToday": "Today", | |
| "chatScopeThisWeek": "This week", | |
| "chatScopeAbout": "About: {title}", | |
| "askAboutThisConversation": "Ask about this" | |
| "chatScopeToday": "Денес", | |
| "chatScopeThisWeek": "Оваа недела", | |
| "chatScopeAbout": "За: {title}", | |
| "askAboutThisConversation": "Прашај за ова" |
| "accountCutoverMigrationRollbackMessage": "移行のロールバック後、アカウントはメンテナンス中です。新しいデータの一部が孤立している可能性があります。", | ||
| "accountCutoverOpenStore": "ストアを開く" | ||
| "accountCutoverOpenStore": "ストアを開く", | ||
| "chatScopeToday": "Today", |
There was a problem hiding this comment.
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>
| "accountCutoverMigrationRollbackMessage": "Ваш аккаунт на обслуживании после отката миграции. Часть более новых данных может быть изолирована.", | ||
| "accountCutoverOpenStore": "Открыть магазин" | ||
| "accountCutoverOpenStore": "Открыть магазин", | ||
| "chatScopeToday": "Today", |
There was a problem hiding this comment.
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>
| "accountCutoverMigrationRollbackMessage": "حسابك قيد الصيانة بعد التراجع عن الترحيل. قد تُعزل بعض البيانات الأحدث.", | ||
| "accountCutoverOpenStore": "فتح المتجر" | ||
| "accountCutoverOpenStore": "فتح المتجر", | ||
| "chatScopeToday": "Today", |
There was a problem hiding this comment.
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>
| "chatScopeToday": "Today", | ||
| "chatScopeThisWeek": "This week", | ||
| "chatScopeAbout": "About: {title}", | ||
| "askAboutThisConversation": "Ask about this" |
There was a problem hiding this comment.
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>
| "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" |
Resolved on current head: backend typecheck/generator/architecture-map validation blockers are green, and this pass is non-blocking.
Git-on-my-level
left a comment
There was a problem hiding this comment.
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.pynow 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.pyroutes scoped conversation requests throughget_conversation()and refuses discarded/locked/out-of-window conversations instead of falling back to broad search.backend/utils/retrieval/tools/memory_tools.pyblocks global memory fact tools when a specific conversation scope is active, which avoids silently answering from unrelated memories.backend/utils/llm/chat.pynow makes the hard-scope semantics explicit in the system prompt, whilebackend/utils/retrieval/agentic.pypasses the computedchat_scopethrough 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, andweb/app/src/lib/api.tsconsistently sendcontext.start_date/context.end_datewith the chat request. backend/tests/unit/test_chat_scope.pycovers 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>
Addressed @9b57a1fc61ea@Git-on-my-level @kodjima33 conflicts cleared + cubic P1 fail-closed tightenings. Conflict
Scope harden (cubic P1s / hire-bar)
Tests
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. |
There was a problem hiding this comment.
All reported issues were addressed across 123 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…ad nits Co-authored-by: Cursor <cursoragent@cursor.com>
CI + cubic tip @e8f1506ef7@Git-on-my-level @kodjima33 tip CI
Cubic nits
Local (isolated, matching CI file runner):
Ready for CI re-check + product/UX merge when green. Honest gaps unchanged. |
Co-authored-by: Cursor <cursoragent@cursor.com>
Tip @6808fc9c29 — Hygiene + prompt-cache isolation@Git-on-my-level @kodjima33 tip Hygiene
Backend unit
Ready for CI re-check + product/UX merge when green. |
Git-on-my-level
left a comment
There was a problem hiding this comment.
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.pynow makesPageContext.start_date/end_datetimezone-aware ISO strings, so invalid or naive scope dates fail during request validation instead of becoming ambiguous tool bounds.backend/utils/retrieval/chat_scope.pycentralizes the hard-scope contract: conversation ids becomeconversation_id, date bounds are intersected fail-closed, and empty intersections return a clear scoped-error path.backend/utils/retrieval/tools/conversation_tools.pyapplies 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.pyblocks 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.pyforces 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.dartandapp/lib/pages/conversation_detail/page.dartwire the mobile “Ask about this” entry point plus Today/This week chips into the structuredChatPageContextpayload instead of relying only on prompt text.web/app/src/components/chat/ChatPanel.tsx/web/app/src/lib/api.tsdo the same for web by preserving current context, deriving timeframe chips fromstart_date/end_date, and sendingcontextinPOST /v2/messages.backend/tests/unit/test_chat_scope.pycovers 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.mdis an agent-facing/reviewer-facing package map. Maintainer consequence: it tells future coding/review agents thatchat_scopeis 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.
|
@kodjima33 @beastoin @Git-on-my-level need human response — product/UX merge call for #11206 / #4515. Author-clear on
Please merge when the product/UX call is accepted, or state an explicit hold. |
Summary
PageContextgains optionalstart_date/end_date;chat_scopeon the agent config fail-closesget_conversations_tool/search_conversations_toolto that conversation and/or window; prompt matches.POST /v2/messagessendscontext.Honest gaps
claudeAgentEnabled) still unscoped — standard/v2/messagesonly.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)currentContextdates; title preserved for conversation/task/memoryFailure-Class: none