[object Object]

← back to AbramsOS

abramsos: CNCP parking-lot fallback fires only when George unavailable

fca604e7ccd9385f90380aec0c27fa0105bbd9f5 · 2026-08-19 04:17:19 -0700 · Steve Abrams

Cody catch: unconditional post 4x/day would flood the parking-lot board.
Also replace global fetch() with http.request() for Node 18 compat.

Files touched

Diff

commit fca604e7ccd9385f90380aec0c27fa0105bbd9f5
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Wed Aug 19 04:17:19 2026 -0700

    abramsos: CNCP parking-lot fallback fires only when George unavailable
    
    Cody catch: unconditional post 4x/day would flood the parking-lot board.
    Also replace global fetch() with http.request() for Node 18 compat.
---
 lib/scheduler.js | 49 +++++++++++++++++++++++++++----------------------
 1 file changed, 27 insertions(+), 22 deletions(-)

diff --git a/lib/scheduler.js b/lib/scheduler.js
index b1519ac..af30d29 100644
--- a/lib/scheduler.js
+++ b/lib/scheduler.js
@@ -101,35 +101,40 @@ async function runClaimsAutopilot() {
   }
 
   // Alert pass — George 401/config issues are expected until cred is set; log as WARN, not FAILED.
-  // Also push urgent items to CNCP parking lot as a local fallback so deadlines are never silent.
+  // CNCP parking-lot fallback fires ONLY when George is unavailable.
+  let georgeOk = false;
   try {
     const a = await claimsAlert.sendClaimsAlert();
     logLine(`claims-alert: ${a.sent ? `SENT total=${a.total} urgent=${a.urgent}` : 'skipped — ' + a.skipped}`);
+    georgeOk = true;
   } catch (err) {
     logLine(`claims-alert WARN (George unavailable): ${err.message} — pushing urgent items to CNCP`);
   }
 
-  // CNCP parking-lot fallback: always post claims due ≤7 days for visibility on the command center.
-  try {
-    const db2 = require('./db');
-    const urgent = await db2.query(
-      `SELECT name, deadline, (deadline::date - current_date) days_left, fill_state
-         FROM settlement_claim WHERE user_id=$1 AND deadline IS NOT NULL
-           AND deadline >= current_date AND deadline <= current_date + 7
-           AND eligibility_state='eligible'
-         ORDER BY deadline ASC`, [autopilot.USER]);
-    if (urgent.rows.length) {
-      const lines = urgent.rows.map(c =>
-        `${c.days_left === 0 ? '🔴 TODAY' : c.days_left === 1 ? '🟡 TOMORROW' : `🟠 ${c.days_left}d`} · ${c.name} (${c.fill_state})`
-      ).join('\n');
-      await fetch('http://127.0.0.1:3333/api/parking-lot', {
-        method: 'POST',
-        headers: { 'Content-Type': 'application/json' },
-        body: JSON.stringify({ title: `⚖️ ${urgent.rows.length} claim(s) due ≤7 days`, body: lines, source: 'claims-autopilot' })
-      }).catch(() => {});
-      logLine(`claims-alert CNCP: posted ${urgent.rows.length} urgent claims to parking lot`);
-    }
-  } catch (e) { /* CNCP fallback is best-effort */ }
+  // CNCP parking-lot fallback: only when George fails so the board doesn't flood on every 6h run.
+  if (!georgeOk) {
+    try {
+      const db2 = require('./db');
+      const urgent = await db2.query(
+        `SELECT name, deadline, (deadline::date - current_date) days_left, fill_state
+           FROM settlement_claim WHERE user_id=$1 AND deadline IS NOT NULL
+             AND deadline >= current_date AND deadline <= current_date + 7
+             AND eligibility_state='eligible'
+           ORDER BY deadline ASC`, [autopilot.USER]);
+      if (urgent.rows.length) {
+        const lines = urgent.rows.map(c =>
+          `${c.days_left === 0 ? '🔴 TODAY' : c.days_left === 1 ? '🟡 TOMORROW' : `🟠 ${c.days_left}d`} · ${c.name} (${c.fill_state})`
+        ).join('\n');
+        const http = require('http');
+        const body = JSON.stringify({ title: `⚖️ ${urgent.rows.length} claim(s) due ≤7 days`, body: lines, source: 'claims-autopilot' });
+        await new Promise(res => {
+          const req = http.request({ hostname: '127.0.0.1', port: 3333, path: '/api/parking-lot', method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) } }, res);
+          req.on('error', res); req.end(body);
+        }).catch(() => {});
+        logLine(`claims-alert CNCP: posted ${urgent.rows.length} urgent claims to parking lot`);
+      }
+    } catch (e) { /* CNCP fallback is best-effort */ }
+  }
 }
 
 async function runAmazonOrders() {

← 6f0e9fc abramsos: fix claims-autopilot scheduler — separate alert er  ·  back to AbramsOS  ·  abramsos: add app-level defense-in-depth Basic Auth (401 wit 8aca6e8 →