← back to Ventura Claw Leads
Fix 3 bugs in backfill-corridor-geo.js caught by codex-3way debate
199f582bc5b996f83fbeb09fa52036d7c14bab25 · 2026-05-07 13:06:54 -0700 · Steve Abrams
PROSECUTOR (kimi-k2.5) flagged these in round 1 of the 3-way debate;
DEFENDER (qwen3:14b) said ship and PRAGMATIST (gemma3:12b) blocked on
a hallucinated SQL injection. After per-finding adjudication against
the actual code, three of PROSECUTOR's findings were genuine:
1. streetKey('') returns '' which collapses every empty-addr row into
a single |city bucket. If both a VC row and a corridor row had
empty street, they'd match incorrectly. Now skipped on both index
and lookup sides.
2. Catch handler called process.exit(1) without closing PG pools.
Could hang the process up to idleTimeoutMillis. Now best-effort
close before exit.
3. (Marginally) the 244-row UPDATE loop has no transaction. Idempotent
on retry so deferred to a follow-up — not blocking ship.
Two of PROSECUTOR's findings were false positives (m.zip.slice was
already guarded; missing PGPASSWORD doesn't affect Mac trust auth)
and got correctly knocked down by DEFENDER.
Files touched
M scripts/backfill-corridor-geo.js
Diff
commit 199f582bc5b996f83fbeb09fa52036d7c14bab25
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Thu May 7 13:06:54 2026 -0700
Fix 3 bugs in backfill-corridor-geo.js caught by codex-3way debate
PROSECUTOR (kimi-k2.5) flagged these in round 1 of the 3-way debate;
DEFENDER (qwen3:14b) said ship and PRAGMATIST (gemma3:12b) blocked on
a hallucinated SQL injection. After per-finding adjudication against
the actual code, three of PROSECUTOR's findings were genuine:
1. streetKey('') returns '' which collapses every empty-addr row into
a single |city bucket. If both a VC row and a corridor row had
empty street, they'd match incorrectly. Now skipped on both index
and lookup sides.
2. Catch handler called process.exit(1) without closing PG pools.
Could hang the process up to idleTimeoutMillis. Now best-effort
close before exit.
3. (Marginally) the 244-row UPDATE loop has no transaction. Idempotent
on retry so deferred to a follow-up — not blocking ship.
Two of PROSECUTOR's findings were false positives (m.zip.slice was
already guarded; missing PGPASSWORD doesn't affect Mac trust auth)
and got correctly knocked down by DEFENDER.
---
scripts/backfill-corridor-geo.js | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/scripts/backfill-corridor-geo.js b/scripts/backfill-corridor-geo.js
index 1b74742..ed878ab 100644
--- a/scripts/backfill-corridor-geo.js
+++ b/scripts/backfill-corridor-geo.js
@@ -54,11 +54,17 @@ function streetKey(s) {
`)).rows;
console.log(`[geo-backfill] ${corrRows.length} corridor rows with lat/lng`);
- // Index by street-key + city for fast lookup
+ // Index by street-key + city for fast lookup. Skip rows whose
+ // streetKey() comes back empty — otherwise every empty-addr row
+ // collapses into a single "|city" bucket and matches unrelated
+ // corridor entries with the same gap, producing wrong lat/lng.
+ // (PROSECUTOR caught this in the codex-3way debate.)
const byAddr = new Map();
for (const c of corrRows) {
const addr = c.address || [c.street_number, c.street_name].filter(Boolean).join(' ');
- const k = `${streetKey(addr)}|${(c.city || '').toLowerCase().trim()}`;
+ const sk = streetKey(addr);
+ if (!sk) continue;
+ const k = `${sk}|${(c.city || '').toLowerCase().trim()}`;
if (!byAddr.has(k)) byAddr.set(k, []);
byAddr.get(k).push(c);
}
@@ -73,8 +79,11 @@ function streetKey(s) {
let backfilled_addr = 0, backfilled_name = 0, no_match = 0;
for (const m of missing) {
let lat = null, lng = null, why = null;
- const k = `${streetKey(m.street)}|${(m.city || '').toLowerCase().trim()}`;
- if (byAddr.has(k)) {
+ const msk = streetKey(m.street);
+ // Same null-street-key guard on the lookup side — otherwise empty-addr
+ // VC rows match the wrong corridor row.
+ const k = msk ? `${msk}|${(m.city || '').toLowerCase().trim()}` : null;
+ if (k && byAddr.has(k)) {
const cand = byAddr.get(k)[0];
lat = cand.lat; lng = cand.lng; why = 'address';
backfilled_addr++;
@@ -107,7 +116,12 @@ function streetKey(s) {
await corridor.end();
await target.pool.end();
process.exit(0);
-})().catch(err => {
+})().catch(async (err) => {
console.error('[geo-backfill] fatal', err);
+ // Close pools before exit — leaving them open can hold the process up to
+ // the idleTimeoutMillis. Best-effort: catch and swallow close errors.
+ // (PROSECUTOR caught this in the codex-3way debate.)
+ try { await corridor.end(); } catch (_) {}
+ try { await target.pool.end(); } catch (_) {}
process.exit(1);
});
← 6e61684 Backfill 206/244 missing lat/lng on corridor-seeded rows
·
back to Ventura Claw Leads
·
Tighten falsy-zero check in neighborhood.ejs total display a8cee0a →