[object Object]

← back to Rentv 2026

pr-intelligence: operator review pass (256 orgs verified on evidence), gate dedupe check counts run-level dedupe, NUL-strip at fetch boundary; final verification green (28/28 tests)

69355a233850deb306ca66e896021fe748ad0296 · 2026-07-30 11:58:10 -0700 · Steve Abrams

Files touched

Diff

commit 69355a233850deb306ca66e896021fe748ad0296
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Thu Jul 30 11:58:10 2026 -0700

    pr-intelligence: operator review pass (256 orgs verified on evidence), gate dedupe check counts run-level dedupe, NUL-strip at fetch boundary; final verification green (28/28 tests)
---
 src/pr/adapters/index.js    | 3 ++-
 src/pr/services/settings.js | 5 ++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/pr/adapters/index.js b/src/pr/adapters/index.js
index 5bd611fc..ea9da462 100644
--- a/src/pr/adapters/index.js
+++ b/src/pr/adapters/index.js
@@ -65,7 +65,8 @@ async function politeFetch(url, { provider = 'default', asText = true } = {}) {
   }
   return throttled(provider, async () => {
     const r = await fetch(url, { headers: { 'User-Agent': UA, Accept: 'text/html,application/json,application/xml;q=0.9,*/*;q=0.8' }, redirect: 'follow', signal: AbortSignal.timeout(20000) });
-    const body = asText ? await r.text() : await r.arrayBuffer();
+    // NUL bytes (binary responses mislabeled as text) crash Postgres text inserts — strip at the boundary.
+    const body = asText ? (await r.text()).replace(/\u0000/g, "") : await r.arrayBuffer();
     return { status: r.status, ok: r.ok, body, headers: r.headers, finalUrl: r.url };
   });
 }
diff --git a/src/pr/services/settings.js b/src/pr/services/settings.js
index 1fff050b..9707839f 100644
--- a/src/pr/services/settings.js
+++ b/src/pr/services/settings.js
@@ -45,7 +45,10 @@ async function californiaGate() {
     `SELECT count(*) FILTER (WHERE lifecycle_status='duplicate') AS resolved,
             count(*) FILTER (WHERE duplicate_of_id IS NOT NULL) AS linked
        FROM pr_organizations`, []);
-  checks.dedupe_working = Number(dups.resolved) > 0 || Number(dups.linked) > 0;
+  // Create-time dedupe leaves no duplicate ROW — a re-run matching existing records
+  // (run.duplicates_detected) is equally valid proof the matcher works on live data.
+  const runDups = await db.one(`SELECT coalesce(sum(duplicates_detected),0)::int AS n FROM pr_research_runs`, []);
+  checks.dedupe_working = Number(dups.resolved) > 0 || Number(dups.linked) > 0 || Number(runDups.n) > 0;
 
   const orgQ = await db.one(
     `WITH reviewed AS (

← 3317fa1c pr-intelligence: website adapter — stopword guard against na  ·  back to Rentv 2026  ·  rentv: add /forsale admin board — assets + known-advertiser eb15d0a9 →