← back to Commercialrealestate
warrantability: reclassify lapsed FHA certs as expired at request time (yoloforever c4)
8ba940e10ec8ea698817db1047979a57020f047c · 2026-07-31 12:15:08 -0700 · Steve
Data-integrity fix. warrant_signal is frozen at fetch-time; 9/358 fha_approved
projects had an expiration_date already in the past (up to 22d lapsed) yet were
still counted as FHA-approved (warrantable proxy) — over-reporting the tool's
core signal. /api/warrantability now re-derives at request time: an approved
cert with days<0 counts as expired and drops from approved-by-city.
Verified live (throwaway instance): fha_approved 358→349, fha_expired 2303→2312.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Files touched
Diff
commit 8ba940e10ec8ea698817db1047979a57020f047c
Author: Steve <steve@designerwallcoverings.com>
Date: Fri Jul 31 12:15:08 2026 -0700
warrantability: reclassify lapsed FHA certs as expired at request time (yoloforever c4)
Data-integrity fix. warrant_signal is frozen at fetch-time; 9/358 fha_approved
projects had an expiration_date already in the past (up to 22d lapsed) yet were
still counted as FHA-approved (warrantable proxy) — over-reporting the tool's
core signal. /api/warrantability now re-derives at request time: an approved
cert with days<0 counts as expired and drops from approved-by-city.
Verified live (throwaway instance): fha_approved 358→349, fha_expired 2303→2312.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
scripts/serve.js | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/scripts/serve.js b/scripts/serve.js
index d8a2d1a..10ca8a3 100644
--- a/scripts/serve.js
+++ b/scripts/serve.js
@@ -606,15 +606,19 @@ app.get('/api/warrantability', (req, res) => {
const expiring = [];
const now = new Date();
for (const c of condos) {
- byStatus[c.warrant_signal] = (byStatus[c.warrant_signal] || 0) + 1;
- if (c.warrant_signal === 'fha_approved') {
+ // Re-derive at request time: warrant_signal is frozen at fetch-time and silently goes
+ // stale as certs lapse. An 'fha_approved' project whose expiration_date is already in the
+ // past is NOT FHA-eligible today — count it as expired, not approved (else the warrantable
+ // proxy over-reports). Only the approved bucket is date-gated; others pass through.
+ const m = (c.expiration_date || '').match(/(\d{2})\/(\d{2})\/(\d{4})/);
+ let days = null;
+ if (m) { const exp = new Date(+m[3], +m[1] - 1, +m[2]); days = Math.round((exp - now) / 86400000); }
+ let sig = c.warrant_signal;
+ if (sig === 'fha_approved' && days !== null && days < 0) sig = 'fha_expired';
+ byStatus[sig] = (byStatus[sig] || 0) + 1;
+ if (sig === 'fha_approved') {
if (c.city) byCity[c.city] = (byCity[c.city] || 0) + 1;
- const m = (c.expiration_date || '').match(/(\d{2})\/(\d{2})\/(\d{4})/);
- if (m) {
- const exp = new Date(+m[3], +m[1] - 1, +m[2]);
- const days = Math.round((exp - now) / 86400000);
- if (days >= 0 && days <= 365) expiring.push({ project: c.project_name, city: c.city, zip: c.zip, expiration: c.expiration_date, days });
- }
+ if (days !== null && days >= 0 && days <= 365) expiring.push({ project: c.project_name, city: c.city, zip: c.zip, expiration: c.expiration_date, days });
}
}
const cities = Object.entries(byCity).sort((a, b) => b[1] - a[1]).slice(0, 12).map(([city, n]) => ({ city, n }));
← ac74530 auto-save: 2026-07-31T11:57:35 (2 files) — data/crcp-drift-s
·
back to Commercialrealestate
·
warrantability: extract fhaEffectiveSignal helper, wire all ebb3d7b →