[object Object]

← back to Homesonspec

KB Home: key community seen-set on name+state (Cody: cross-state name collision) + docstring

1f76088e03acb01827db66a87e6ff14b143a3114 · 2026-07-28 11:50:12 -0700 · Steve Abrams

Files touched

Diff

commit 1f76088e03acb01827db66a87e6ff14b143a3114
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Tue Jul 28 11:50:12 2026 -0700

    KB Home: key community seen-set on name+state (Cody: cross-state name collision) + docstring
---
 collectors/kb-home/src/index.ts | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/collectors/kb-home/src/index.ts b/collectors/kb-home/src/index.ts
index 29985e16..2fb0529a 100644
--- a/collectors/kb-home/src/index.ts
+++ b/collectors/kb-home/src/index.ts
@@ -12,8 +12,10 @@ import {
  * KB Home adapter — SINGLE_FEED source (recon 2026-07-23).
  * AEM/Handlebars, server-rendered. The whole national move-in-ready inventory
  * ships in ONE page (/move-in-ready) as `var allMIRs = JSON.parse("...")` — a
- * double-encoded JSON string. One fetch yields every home; we filter to the
- * target state (KBHOME_STATE, default CA). Plain HTTP, no anti-bot.
+ * double-encoded JSON string. One fetch yields every home. DEFAULT = national
+ * (all states, each home tagged by its own r.State); set KBHOME_STATE=XX to filter
+ * to one state. Run this ONCE per sweep — per-state iteration is a no-op after the
+ * first state (page-dedup on the identical feed). Plain HTTP, no anti-bot.
  */
 const FEED_URL = "https://www.kbhome.com/move-in-ready";
 const ORIGIN = "https://www.kbhome.com";
@@ -90,8 +92,11 @@ export const kbHomeAdapter: SourceAdapter = {
       const seen = new Set<string>();
       for (const r of rows) {
         const communityName = str(r.CommunityName);
-        if (!communityName || seen.has(communityName)) continue;
-        seen.add(communityName);
+        // key on name+state: in national mode, same-named communities in different states
+        // must NOT collide into one (Cody-gated) — else the 2nd state's community is dropped.
+        const ckey = `${communityName}|${str(r.State)?.toUpperCase() ?? ""}`;
+        if (!communityName || seen.has(ckey)) continue;
+        seen.add(ckey);
         const phone = str(r.CommunityOfficePhone);
         records.push({
           entityType: "community",

← c7715e27 KB Home: national single-run adapter (all-states extract, pe  ·  back to Homesonspec  ·  build-loop: Lennar uses LENNAR_STATE_FILTER=slug(state) not ab43eec2 →