P0 fix: content/ not in image crashed API boot; harden garnish + preflight
ROOT CAUSE: the Dockerfile copied src/poller/scripts/supabase but NOT content/. mediaEngine.js read content/stark-lines.json with an unguarded module-load readFileSync; ENOENT in the image threw at require time, and via app.js → routes/desk → deskService → mediaEngine that crashed the ENTIRE API at boot. The Coolify healthcheck rolled back to the last healthy image (4d2b27d), so every deploy since219167esilently served a 14-hour-old build — S11 live tracking, S6 API code, the settlement boot line, and SNAPSHOT_EXPECTED_INTERVAL were all merged but NOT running. FIX (one train): 1. Dockerfile COPYs content/ into the runner image. 2. mediaEngine: stark-lines.json is OPTIONAL (garnish, never load-bearing) — loadStark() try/catch → {} → posts render without the Stark kicker, never a crash. Belt AND suspenders with #1. 3. src/preflight.js (§A4): boot prints '[preflight] OK' or 'DEGRADED' naming exactly what content/env is missing — before the healthcheck can fail silently. Run first in server.js. 4. Full fragility sweep: mediaEngine was the ONLY unguarded module-load file read; coachSignals (config/coaches.json) was already lazy + try/catch + copied. No others. Verified: requiring app.js + deskService + mediaEngine with stark-lines.json ABSENT now boots clean (reproduced the exact prod failure). 2757 -> 2763 tests (tests/unit/bootResilience.test.js). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -20,7 +20,24 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const STARK = JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'content', 'stark-lines.json'), 'utf8'));
|
||||
// Session 65 (P0 deploy fix) — the Stark-layer library is a GARNISH, never
|
||||
// load-bearing. This used to be an unguarded module-load readFileSync; when
|
||||
// the file wasn't in the container image it threw at require time, which
|
||||
// (via app.js → routes/desk → deskService → here) crashed the WHOLE API at
|
||||
// boot and silently rolled the deploy back for 14 hours. A witty kicker is
|
||||
// not allowed to take down the record. Missing/corrupt file → empty library
|
||||
// → every format posts WITHOUT the Stark line (starkLine returns null),
|
||||
// which is a valid, still-VOICE-compliant post. Never throws.
|
||||
const STARK_PATH = path.join(__dirname, '..', '..', 'content', 'stark-lines.json');
|
||||
function loadStark() {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(STARK_PATH, 'utf8'));
|
||||
} catch (e) {
|
||||
console.warn(`[mediaEngine] stark-lines.json unavailable (${e.code || e.message}); posting without the Stark layer.`);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
const STARK = loadStark();
|
||||
|
||||
// ---- VOICE lint -----------------------------------------------------------
|
||||
const BANNED_PATTERNS = [
|
||||
|
||||
Reference in New Issue
Block a user