trace-write-targetlisted
Install: claude install-skill iansteitz1-eng/aria-skills
# Trace Write Target — which DB/table does this writer actually hit?
The Aria stack has **multiple Postgres databases** and writers that each pick
their own via a DSN env var. The trap: query the obvious connection pool
(`db.get_conn()` → the `aria_field_view` DB) for rows a writer produced, get
`relation "X" does not exist`, and burn several round-trips before realizing the
writer selected a **different** DB through `V4_DB_URL`.
This tool reads the writer's source the way the running app sees it and reports
the target table(s) **and** the database that the env var selects — so you query
the right DB the first time.
## Run it
```sh
python3 ~/.claude/skills/trace-write-target/trace_write_target.py \
--module splat_emitter --func emit_external_splat --host <your-server>
```
- `--module` — the module to inspect (e.g. `splat_emitter`, `billing`, `db`).
- `--func` — optional; narrows the source read to one function.
- `--search-paths` — dirs prepended to `sys.path` so the module resolves like the
service does (default `/opt/aria,/opt/aria/ac_gateway,/opt/aria/v4`).
- `--env-file` — service env sourced before the probe (default `/opt/aria/.env`)
so env-var resolution matches the running app.
## What it reports
1. **source file** — the actual file the import resolves to (catches "there are
two `splat_emitter.py` on the box" ambiguity).
2. **target tables** — every `INSERT INTO` / `UPDATE` / `DELETE FROM` in scope.
3. **database selected by env var** — the DSN env v