Sangeetha-Grantha

Metadata Value
Status Completed
Version 2.1.0
Last Updated 2026-11-01
Author Sangeetha Grantha Team

Track: Temple Google Place IDs

ID: TRACK-154 Status: Complete — Intent, Spec and Plan Accepted; all Plan steps done Owner: Seshadri Created: 2026-10-16 Updated: 2026-11-01

Goal

Give each temple in the catalogue a reviewed Google place_id, so TRACK-151 can open or draw the temple on Google Maps without our database storing Google-derived coordinates.

Context

Intent

Status: Accepted Accepted by: Seshadri (2026-10-24)

Problem

A kshetra map needs correct places. Matching a temple by name can pick a different temple of the same name (there are several Subrahmanya Swamy and Kasi Viswanatha temples), a town, or a nearby business. Google’s terms stop us storing its coordinates, so the durable thing to keep is a verified place_id. Without recorded review, nobody can tell a checked match from a guess.

Proposed outcome

  1. One-time candidate lookup. An offline script runs Places Text Search for each non-sannidhi temple, using the catalogue name, city and state, and writes candidates (place id, Google’s name and address, match score, rank) to a candidate file. It runs server-side or locally, never from the app, with the API key supplied through an environment variable that is never committed or logged.
  2. Review. Each temple ends CONFIRMED, LOCALITY_ONLY (the place is the town, not the temple) or UNRESOLVED, with an approver. Automatic confirmation only when Google’s name and locality match the catalogue exactly after normalisation and there is a single candidate; everything else is a short curator review list.
  3. Sub-shrines inherit. Sannidhis and mandapams link to their parent’s place and say so; they do not get their own Google place.
  4. Storage. A new versioned migration adds google_place_id and a place review state to temples; a repeatable seed applies the reviewed file with system-attributed audit rows. No Google name, address or coordinate is stored beyond the place id. Hand-entered coordinates, if any, are never overwritten.
  5. Public contract. The V2 temple payload exposes the place id and its precision only for CONFIRMED rows. A consumer never receives a guessed place.

Constraints

Open questions

  1. Who supplies and rotates the API key for the lookup, and where is it held (a local environment variable only)?
  2. Review tool: the admin Temple modal (needs a place-id field) or a reviewed JSON file in database/data/?
  3. Is a Google Cloud billing account with a spending cap already in place?
  4. Do we also want hand-measured coordinates stored for temples where Google has no match, and by whom?
  5. Place data refresh: how often do we re-verify place ids (they can change), and who owns it?

Decisions on open questions (2026-10-24)

  1. The lookup API key is supplied by Seshadri as a local environment variable only (never committed or logged).
  2. Review uses a reviewed JSON file in database/data/, applied by a repeatable seed; no admin UI change.
  3. A Google Cloud billing account with a spending cap is in place; the Spec states the call count against it.
  4. Hand-measured coordinates for no-match temples: deferred.
  5. Place-id refresh cadence and owner: deferred.

Completion evidence (fixed in Plan)

Candidate script with recorded-response fixtures and tests, a coverage report by review state, a reviewed data file with approvals, migration and seed tests (rerun, hand-entry protection, no coordinate writes from Google), make test, make test-integration, make check-docs.

(Superseded by the fixed list in the Plan below: fixtures are synthetic, not recorded, for the terms reason in Flagged concerns.)

Spec

Status: Accepted Accepted by: Seshadri (chat instruction) Accepted at: 2026-10-25

Requirements

R1. Candidate lookup (offline, one-time).

  1. A script queries Places API (New) Text Search once per lookup target, using "<catalogue name>, <city>, <state>", and writes ranked candidates to a local working file outside version control (storage/ is gitignored; confirm in the Plan).
  2. Lookup targets are temples rows whose place_kind is not SANNIDHI or MANDAPAM (sub-shrines never get their own lookup).
  3. The API key comes only from the environment (GOOGLE_PLACES_API_KEY), is sent in the request header (never the URL), and is never logged, written to a file, or placed in a DTO or the mobile config. Error messages and the call log redact it.
  4. The request uses a minimal field mask (place id, display name, formatted address) and pageSize of 5 or fewer. The script requests no location or geometry fields.
  5. The script enforces a hard call ceiling (PLACES_MAX_CALLS, default 150) and stops before exceeding it; it is resumable from the working file so a rerun does not repeat answered queries.

R2. Expected call count against the spending cap.

R3. Review states and rules.

R4. Sub-shrines inherit.

R5. Storage.

R6. Reviewed file and repeatable seed.

R7. V2 contract (jointly with TRACK-151).

R8. Out of scope. Admin UI changes, hand-measured coordinates, refresh cadence, the Google Maps SDK map, and the V1 API (no place id in V1).

Design

Flagged concerns

  1. Google terms (must be confirmed before the first live call, in writing in the Plan). (a) Storing only place_id is permitted indefinitely; (b) the candidate file holds Google names and addresses, which is caching/storing Google content, so it stays local and is deleted after the review rather than committed; (c) Places results used for a map must appear on a Google Map with attribution, and a plain link to Google Maps is the TRACK-151 phase-one path; (d) whether a temporary working copy during review is acceptable, and any short caching allowance, which the Intent notes was not readable in full; (e) place ids can go stale and Google asks that they be refreshed, so the app must tolerate a link that no longer resolves (refresh cadence is deferred, see Open questions). Anything not confirmed is treated as forbidden.
  2. “Recorded-response fixtures” in the Intent’s evidence conflict with (b). Real recorded responses are stored Google content. The Plan uses hand-written synthetic responses in the API’s shape.
  3. The “TRACK-139 marker rules” are not defined in TRACK-139’s text. What TRACK-139 does say is that corpus content never goes in V__ and that reference data lives in idempotent R__ seeds with provenance and system attribution. R6 is written to that reading; if a specific marker convention was meant (for example a header comment or provenance tag), name it before the Spec is accepted.
  4. Count discrepancy in the Intent’s kind breakdown (R2).
  5. Audit: the seed writes AUDIT_LOG rows with a system actor, as R__seed_11 does. No admin or API write path exists, so no other audit gap arises.
  6. Contract risk with TRACK-151: that session is editing TRACK-151 now. If its Spec defines a different DTO shape, R7 must be reconciled before either Spec is accepted. A hand-over note is in the shared notes folder.
  7. Lakshana (Domain Model §6) does not apply: no krithi, raga, tala or composition data changes. The reviewed file does carry curator judgement about which shrine a place is; where a temple name is ambiguous (several Subrahmanya Swamy or Kasi Viswanatha temples), the curator checks the deity, town and parent complex, and may consult the carnatic-musicologist subagent for doubtful kshetra identity. It was not run on this Spec, since nothing here is musicological content.
  8. Junction tables: none involved. krithis.temple_id stays as is.

Open questions carried forward

  1. Deferred (Intent 4): hand-measured coordinates for no-match temples.
  2. Deferred (Intent 5): place-id refresh cadence and owner. Needs an owner before the app relies on a stored id for long.
  3. New: do the 2 LOCALITY-kind rows count as temples for review? Proposed: yes, they are looked up like the others; a confirmed place on a locality-kind row is the locality, which is correct for that row, but TRACK-151 should decide whether to show it as a temple map pin.
  4. New: the exact marker convention from TRACK-139 (flagged concern 3).
  5. New: whether TRACK-151 accepts the R7 shape.

Plan

Status: Accepted Accepted by: Seshadri Accepted at: 2026-10-25

Written ahead of Spec acceptance at the requesting session’s direction. Nothing here is implemented, and no work starts until the Spec and this Plan are both Accepted.

Files that change

Area File Change
Migration database/migrations/V68__temple_google_place_review.sql (number confirmed at write time) New enum, four columns, CHECKs, partial unique index, column comments. Schema only.
Seed database/migrations/R__seed_12_temple_place_review.sql Generated; embeds the reviewed JSON; guarded, audited, idempotent.
Data database/data/track154-temple-place-review.json Reviewed placements with approvals. No Google content.
Script tools/krithi-extract-enrich-worker/scripts/temple_place_lookup.py (and src/ helper if the worker layout needs it) lookup, triage, build.
Script tests tools/krithi-extract-enrich-worker/tests/test_temple_place_lookup.py + synthetic fixtures See Proof.
DAL modules/backend/dal/.../tables/CoreTables.kt, a PlaceReviewState enum, TempleRepository.kt New columns; read path for V2 with parent resolution.
Shared domain V2 temple DTO (owned by TRACK-151) Only the place field and PlacePrecision, coordinated with TRACK-151.
Backend tests dal/api tests and a migration/seed integration test See Proof.
Docs application_documentation/04-database/schema.md, 10-implementations/ note, OpenAPI via TRACK-151, conductor/tracks.md Sync.
Ignore rules .gitignore Only if storage/ does not already cover the candidate file.

Not touched: latitude/longitude writers, the admin Temple modal, V1 routes, the mobile binary’s config.

Order of work

  1. Pre-flight (no code): re-measure temple counts by kind; settle the Google terms points (flagged concern 1) and record the answers in this track; Seshadri confirms the cap, key restriction and SKU; reconcile the R7 shape with TRACK-151.
  2. Migration and Exposed table (R5), with a migration test on a fresh Testcontainers database and on a database at V67.
  3. Script and synthetic-fixture tests (R1–R3); run against fixtures only.
  4. Live lookup pass 1 by Seshadri with the key in the environment; review the printed call count; pass 2 retries; local candidate file stays local.
  5. Triage and curator review to produce the reviewed JSON with approvals.
  6. Generate the seed, drift test, rerun and protection tests, then apply on the dev database with make migrate.
  7. Repository mapping and V2 rule tests, in step with TRACK-151’s endpoints.
  8. Docs sync, delete the local candidate file, record the final call count and state coverage in the Progress Log.

Risks

Proof (completion evidence, fixed)

  1. Script unit tests on synthetic fixtures: auto-confirm rule, single versus multiple candidates, key redaction (no key in logs or errors), call ceiling stops the run, resume skips answered queries, field mask contains no geometry fields.
  2. Coverage report by review state (CONFIRMED / LOCALITY_ONLY / UNRESOLVED / unreviewed) pasted into the Progress Log, with the final call count.
  3. The reviewed JSON present with an approver and date on every entry.
  4. Migration test: columns, CHECKs and unique index behave; rerunning make migrate is a no-op.
  5. Seed tests: idempotent rerun produces no new audit rows; a hand-set latitude/longitude survives; a row reviewed by another actor is not overwritten; no coordinate column is written; a sub-shrine with its own place id fails the seed; the embedded SQL matches the JSON.
  6. V2 mapping tests: place present only for CONFIRMED, absent for LOCALITY_ONLY, UNRESOLVED and unreviewed; sub-shrine inherits PARENT_COMPLEX from a confirmed parent and gets nothing from an unconfirmed one.
  7. Live check: make db-reset then the V2 temple detail for Tiruvarur and one of its sannidhis, showing the expected place.
  8. Commands: make test, make test-integration, make check-docs, and make agent-evals if any agent-config file changed.

Progress Log