[object Object]

← back to Rentv 2026

pr-intelligence: Cody c6 — multi-state geo merge on exact-domain match (national firms gain AZ footprint instead of dropping it, audited)

6993ec48d8138e7d0c6280ca7fb3e518ce688d94 · 2026-07-30 22:04:45 -0700 · Steve Abrams

Files touched

Diff

commit 6993ec48d8138e7d0c6280ca7fb3e518ce688d94
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Thu Jul 30 22:04:45 2026 -0700

    pr-intelligence: Cody c6 — multi-state geo merge on exact-domain match (national firms gain AZ footprint instead of dropping it, audited)
---
 src/pr/services/organizations.js | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/pr/services/organizations.js b/src/pr/services/organizations.js
index 6b50f405..c6d834d4 100644
--- a/src/pr/services/organizations.js
+++ b/src/pr/services/organizations.js
@@ -46,9 +46,22 @@ async function create(data, { evidence, actor } = {}) {
 
   const exact = matches.find((m) => m.verdict === 'exact');
   if (exact) {
-    // update-not-duplicate: attach any new evidence to the existing row
-    if (evidence && evidence.source) await attachEvidence(exact.org.id, evidence, null);
-    return { org: exact.org, created: false, matched: 'exact', matches };
+    // Multi-state merge (Cody c6): a national firm (same domain) discovered in a NEW
+    // state/metro must GAIN that geography, not silently drop it — union the arrays.
+    const ex = exact.org;
+    const union = (a, b) => [...new Set([...(a || []), ...(b || [])])];
+    const newStates = union(ex.state_presence, data.state_presence);
+    const newMetros = union(ex.metros, data.metros);
+    const newCounties = union(ex.counties, data.counties);
+    if (newStates.length > (ex.state_presence || []).length || newMetros.length > (ex.metros || []).length) {
+      await db.query('UPDATE pr_organizations SET state_presence=$2, metros=$3, counties=$4 WHERE id=$1',
+        [ex.id, newStates, newMetros, newCounties]);
+      await audit.log({ actor, action: 'org.geo_merged', entity_type: 'organization', entity_id: ex.id,
+        detail: { added_states: newStates.filter((s) => !(ex.state_presence || []).includes(s)), added_metros: newMetros.filter((m) => !(ex.metros || []).includes(m)) } });
+      ex.state_presence = newStates; ex.metros = newMetros; ex.counties = newCounties;
+    }
+    if (evidence && evidence.source) await attachEvidence(ex.id, evidence, null);
+    return { org: ex, created: false, matched: 'exact', matches };
   }
 
   const uncertain = matches.filter((m) => m.verdict === 'uncertain');

← 312a68db console: add Developers facet → realestate (usre proxy + AZ  ·  back to Rentv 2026  ·  yoloforever: cycle 6 ledger — Arizona Phase 2 bootstrapped ( 7b2724ce →