[NOTICKET] check: read documents from analysis-scope catalog
Browse filesDocuments live ONLY in the analysis-scope catalog row (verified via the
`data_catalog` table: `scope_type='analysis'` rows carry `unstructured`
sources; user-scope rows have none). So the first cut — scoping only
`structured` reads to analysis and leaving documents on the user-scope reader —
made `check_knowledge` always return empty ("not listed"), because user-scope
has zero documents.
Fix: `AnalysisScopedCatalogReader` now reads analysis-scope for BOTH structured
and unstructured, falling back to the user-scope reader only when the analysis
has no catalog row. No regression risk: user-scope carried no documents anyway.
A document not bound to the current analysis still won't appear in that room —
there is no user-level document inventory in `data_catalog`.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- src/catalog/reader.py +15 -11
|
@@ -77,10 +77,12 @@ class AnalysisScopedCatalogReader(CatalogReader):
|
|
| 77 |
"""Reads the analysis-scope catalog, falling back to the user-scope reader.
|
| 78 |
|
| 79 |
Used by the `check` skill so "what data do I have" inside a room reflects
|
| 80 |
-
that analysis's bound sources
|
| 81 |
-
"xl test" (analysis-scope) instead of the
|
| 82 |
-
|
| 83 |
-
|
|
|
|
|
|
|
| 84 |
user-scope reader, so unbound rooms behave exactly as before.
|
| 85 |
"""
|
| 86 |
|
|
@@ -92,13 +94,15 @@ class AnalysisScopedCatalogReader(CatalogReader):
|
|
| 92 |
self._analysis_id = analysis_id
|
| 93 |
|
| 94 |
async def read(self, user_id: str, source_hint: SourceHint) -> Catalog:
|
| 95 |
-
#
|
| 96 |
-
#
|
| 97 |
-
#
|
| 98 |
-
#
|
| 99 |
-
#
|
| 100 |
-
#
|
| 101 |
-
|
|
|
|
|
|
|
| 102 |
try:
|
| 103 |
catalog = await self._store.get_by_analysis(self._analysis_id)
|
| 104 |
except Exception: # noqa: BLE001 — never block check on the analysis read
|
|
|
|
| 77 |
"""Reads the analysis-scope catalog, falling back to the user-scope reader.
|
| 78 |
|
| 79 |
Used by the `check` skill so "what data do I have" inside a room reflects
|
| 80 |
+
that analysis's bound sources — structured AND documents — with their real
|
| 81 |
+
names. A database shows as "xl test" (analysis-scope) instead of the
|
| 82 |
+
auto-generated `postgres_<hash>` placeholder, and documents show at all
|
| 83 |
+
(the user-scope catalog holds no `unstructured` sources, so reading them from
|
| 84 |
+
user-scope always came back empty). When the analysis has no catalog row
|
| 85 |
+
(legacy / not yet bound) or the read fails, it degrades to the wrapped
|
| 86 |
user-scope reader, so unbound rooms behave exactly as before.
|
| 87 |
"""
|
| 88 |
|
|
|
|
| 94 |
self._analysis_id = analysis_id
|
| 95 |
|
| 96 |
async def read(self, user_id: str, source_hint: SourceHint) -> Catalog:
|
| 97 |
+
# Read analysis-scope for BOTH structured and unstructured. Verified via
|
| 98 |
+
# the dedorch `data_catalog` table: the analysis-scope rows carry the real
|
| 99 |
+
# DB names AND the room's documents (`source_type='unstructured'`), whereas
|
| 100 |
+
# the user-scope rows hold only structured sources with `postgres_<hash>`
|
| 101 |
+
# placeholder names and NO documents at all — so reading documents from
|
| 102 |
+
# user-scope always returned empty ("not listed"). Fall back to the
|
| 103 |
+
# user-scope reader only when the analysis has no catalog row (legacy /
|
| 104 |
+
# unbound room).
|
| 105 |
+
if self._analysis_id:
|
| 106 |
try:
|
| 107 |
catalog = await self._store.get_by_analysis(self._analysis_id)
|
| 108 |
except Exception: # noqa: BLE001 — never block check on the analysis read
|