agnes-the-ai-analyst/cli/commands
ZdenekSrotyr 5458ccc41b
hygiene: BQ error hint dispatch + catalog ENTITY column (#274)
Two analyst-UX papercuts surfaced by the v0.53.4 onboarding smoke test.

1) /api/query remote_estimate_failed hint now branches on the BigQuery
   error class instead of always claiming a column doesn't exist. The
   previous hardcoded "Most often this means a column referenced …
   doesn't exist" misled analysts whenever BigQuery actually rejected
   on syntax — concretely, `SELECT COUNT(*) AS rows FROM …` fails with
   `Syntax error: Unexpected keyword ROWS at [1:20]` (`rows` is a BQ
   reserved word) and the hint pointed at non-existent columns.

   New _hint_for_bq_bad_request() helper dispatches:
   - "Syntax error" / "Unexpected keyword" → reserved-keyword alias hint
     with `AS row_count` workaround
   - "Unrecognized name" / "not found inside" → `agnes schema <id>`
   - "Table not found" → `agnes catalog`
   - fallback → enumerate all three

   4 unit tests in TestHintForBqBadRequest pin each branch. Existing
   guardrail tests (test_fallback_fails_fast_on_pure_duckdb_syntax,
   test_remote_estimate_failed_surfaces_first_error_when_attempts_differ)
   continue to pass — both hint substrings they assert on still appear in
   the relevant branches.

2) `agnes catalog` replaces the FLAVOR column with ENTITY. FLAVOR
   rendered t['sql_flavor'] which duplicated SOURCE for any catalog
   dominated by one source type — analysts saw `SOURCE=bigquery
   FLAVOR=bigquery` on every row. ENTITY instead surfaces the upstream
   BigQuery entity_type (BASE TABLE / VIEW / MATERIALIZED_VIEW) for
   remote rows; non-remote rows render `-`. The distinction matters
   operationally: views don't support predicate pushdown, so `agnes
   query --remote` against a view trips the cost guardrail where the
   same query against a BASE TABLE pushes down cleanly. The
   entity_type field has been in the v2 catalog response since 0.51.0;
   this PR just stops hiding it behind a column header that conveyed
   no information.

JSON output (`agnes catalog --json`) is unchanged — only the human-
readable column changed. No DB migration; no API change.

Verified: 4161 tests pass locally; 25 in test_api_query_guardrail.py
green; the 4 new TestHintForBqBadRequest cases pin each branch.
2026-05-12 18:32:29 +00:00
..
__init__.py feat: add Docker, CLI tool, scheduler, and agent skills 2026-03-27 15:30:03 +01:00
admin.py feat(home): state-aware /home + /setup-advanced + schema v26 (#228) 2026-05-08 18:28:47 +02:00
admin_metrics.py feat(cli): agnes admin metrics {import,export,validate} 2026-05-04 18:39:05 +02:00
admin_news.py feat(home): state-aware /home + /setup-advanced + schema v26 (#228) 2026-05-08 18:28:47 +02:00
admin_store.py refactor(cli-store): pull/info → agnes admin store; add agnes store mine 2026-05-05 13:49:18 +02:00
auth.py fix: address Devin Review findings — incomplete renames + estimate guard 2026-05-04 20:05:06 +02:00
capture_session.py Session capture queue, private session, and setup-prompt fixes (#242) 2026-05-11 13:31:16 +00:00
catalog.py hygiene: BQ error hint dispatch + catalog ENTITY column (#274) 2026-05-12 18:32:29 +00:00
describe.py release: 0.46.5 — agnes describe -n parses, server sanitizes NaN (#224) 2026-05-07 18:16:21 +02:00
diagnose.py release: 0.53.2 — diagnose silent-capture check + urllib3 2.7.0 + flaky-test fix (#270) 2026-05-12 18:28:04 +02:00
disk_info.py chore(cli-rename): replace stale da verbs in active code paths 2026-05-04 21:10:43 +02:00
explore.py fix(cli): hint text 'Run: da sync' → 'Run: agnes pull' 2026-05-04 18:42:21 +02:00
init.py release: 0.53.0 — close Tier B trackers (#259-#261) + admin UI fix (#265) (#267) 2026-05-12 16:28:41 +02:00
mark_private.py Session capture queue, private session, and setup-prompt fixes (#242) 2026-05-11 13:31:16 +00:00
memory_admin.py refactor(cli): hard-cutover env vars + config dir to AGNES_* 2026-05-04 16:35:44 +02:00
my_stack.py Add /marketplace browse page + Model B opt-in stack composition (#230) 2026-05-08 14:22:19 +02:00
onboarded.py feat(home): state-aware /home + /setup-advanced + schema v26 (#228) 2026-05-08 18:28:47 +02:00
pull.py feat: clean CLI errors + init progress + skip-materialize + claude.md catalog pointer 2026-05-05 18:11:59 +02:00
push.py Session capture queue, private session, and setup-prompt fixes (#242) 2026-05-11 13:31:16 +00:00
query.py remove agnes query --register-bq from client CLI 2026-05-12 18:18:13 +02:00
refresh_marketplace.py Setup-prompt + bootstrap fixes from 2026-05-10 init report (#240) 2026-05-10 20:24:00 +02:00
sample.py release: 0.52.0 — UX/hygiene round (5 fixes from 0.51.0 retro) 2026-05-12 15:09:14 +02:00
schema.py refactor(cli): hard-cutover env vars + config dir to AGNES_* 2026-05-04 16:35:44 +02:00
self_upgrade.py Session capture queue, private session, and setup-prompt fixes (#242) 2026-05-11 13:31:16 +00:00
server.py refactor(cli): hard-cutover env vars + config dir to AGNES_* 2026-05-04 16:35:44 +02:00
setup.py fix(cli): Windows console crash on cs-CZ codepage (port + broaden #172) 2026-05-04 20:45:29 +02:00
skills.py fix(cli): Windows console crash on cs-CZ codepage (port + broaden #172) 2026-05-04 20:45:29 +02:00
snapshot.py fix(snapshot): catch httpx transport errors in --estimate path 2026-05-04 20:36:30 +02:00
status.py fix(devin-review): stale-token override + status sessions counter + lock comment 2026-05-04 21:26:30 +02:00
statusline.py Session capture queue, private session, and setup-prompt fixes (#242) 2026-05-11 13:31:16 +00:00
store.py refactor(cli-store): pull/info → agnes admin store; add agnes store mine 2026-05-05 13:49:18 +02:00
tokens.py fix: address Devin Review findings — incomplete renames + estimate guard 2026-05-04 20:05:06 +02:00