Query Console โ
- Status: in progress, opened 2026-08-24. Built 2026-08-24, bug-fixed and design-verified 2026-08-27.
- Issue:
#958: feat(admin/analytics): promote Query Console to its own surface and teach it to query Firestore - Launch plan:
docs/business/launches/PROTOTYPE.md, Phase 2 (Build), "Analytics hardening". The row does NOT exist yet: the PM lane guard blocks a write to the launch pages, so the row text is drafted and waiting on the operator or a builder session. (Was ALPHA.md Phase 1 before the 2026-08-31 timeline shift moved Build into Prototype.)
What is this? โ
The Query Console becomes its own Analytics surface, and learns to query Firestore as well as BigQuery. โ
- It is currently a tab buried under Analytics > BigQuery, which makes it read as a BigQuery feature rather than the place you go to ask the data a question.
- BigQuery only holds events. Anything about current state (an offer awaiting moderation, a merchant profile, a feature flag) lives in Firestore and is reachable from no console at all.
- The operator's framing on 2026-08-24: "This essentially could also become a users custom report builder essentially." That is the direction this surface is pointed, and it is why the structured builder was chosen over raw SQL.
Firestore gets a structured query builder, not SQL. โ
- Firestore has no query language, so "the same way we do with BigQuery" cannot mean a SQL box. It means collection plus filters plus order plus limit, executed server side against a field allowlist.
- The rejected alternative was installing the Firebase Stream Firestore to BigQuery extension. It would have given real SQL with zero new UI, and it was turned down because it keeps a second live copy of user documents outside Firestore, which cuts against the prefer-losing-data-over-leaking-it axiom.
The Assistant gets grounded in the same task. โ
- The Assistant has no BigQuery awareness at all: its system prompt at
services/api/assistant/src/services/anthropic.jscontains the word BigQuery zero times, and none of its six tools can read a schema. - Asked for a query on 2026-08-24 it produced
your-project.firestore_export.offers, which is a generic placeholder project plus the default dataset name of a Firebase extension this project has never installed. Neither exists. - Its own guardrail says never invent file paths, function names, or Firestore field names. BigQuery tables are not on that list, so the rule did not cover the thing it got wrong.
- It also already had a correct route to the answer and did not take it:
query_firestoreallowlistsofferswithtitle,status,merchantId,venueId,audience,startsAt,expiresAt.
What is the current state? โ
Slices 1 to 4 are built. Slice 5, grounding the Assistant, is not. โ
- The console is its own Analytics line item, it has a BigQuery and Firestore tab strip, the structured Firestore endpoint is on analytics-api, and the builder UI works. Slice 5 in planning.md has not been started.
- The allowlist was settled and now carries a per-collection decision on the document KEY as well as the fields.
A 2026-08-24 code review filed two bugs, and both are fixed as of 2026-08-27. โ
#970: bug(analytics-api): the Firestore console ships every document id, which no allowlist reviews. Fixed.merchantProfileswas enumerating Firebase Auth UIDs 500 rows per request under an allowlist that had been reviewed and approved.#971: bug(admin/analytics): a recovered schema fetch still shows the error, and Cmd+Enter bypasses the disabled Run button. Fixed. The held-shortcut storm measured 65 to 87 concurrent queries, not the 30 the issue estimated.- Four more were found during the fix and are listed in implementation.md.
The design verification found the surface mechanically compliant and functionally undiscoverable, and the second half is now fixed. โ
- design.md has the audit. Tokens, dropdowns, icons and structure all passed. What was missing was any statement of what each source is FOR, what question a field answers, or why an absent collection is absent.
- The operator's own example made the case: "how many lanterns are lit at venue X" IS answerable, via
venues.activeLanternCount, and nothing led anyone to it. - Fixed on 2026-08-27 as slice 6 in planning.md: a Firestore rail, descriptions inside the pickers, the refused collections with reasons, saved inquiries, and a reference doc linked first in the tab strip.
The console reads as broken on a stack proxied to the deployed analytics-api. โ
- These endpoints exist only on this branch, so
ANALYTICS_API_ORIGINpointing at Cloud Run answers 404 and the Firestore tab shows a failure. Point it at a local analytics-api and it works. Detail in implementation.md.
What is already verified about the ground truth โ
- The nine BigQuery datasets in
lantern-app-devareanalytics,billing_attrib,billing_export_gcp,billing_exports_gcp,billing_marts,billing_norm,billing_raw,logs,ops. There is nofirestore_exportand no Firestore export of any kind. analyticsholds five objects:ad_delivery_daily,event_counts_daily,events, plus therecent_system_eventsandrecent_user_eventsviews.analytics.eventsis day partitioned ontimestampand REJECTS any query without a filter on it. Any console guidance or Assistant prompt has to say so, because the failure message names partition elimination rather than a missing filter.- Offer-shaped events in the last 90 days are
sponsored_offer_filled(155),offer_claimed(5),offer_redeemed(2). There is no submission or moderation state in BigQuery, so the question that started this cannot be answered there at all.
What else is related? โ
#333: Assistant: BigQuery analytics integration (canned queries), the closest existing issue. It covers canned BigQuery queries for the Assistant, which overlaps the grounding slice but is not the same work.#373: feat(admin/bq): scheduled-query CRUD from the BigQuery console, adjacent console work that shares the saved-query storage this project extends.#874: design(privacy): one data-classification and egress policy, before search, the assistant, and the apps platform each invent their own. The Firestore field allowlist is exactly the decision that issue says should not be invented per surface.- 2026-04-30 BigQuery query infrastructure design and 2026-05-03 BigQuery query console redesign design, the console's design lineage. Read both before reshaping the shell.