Files
boc/EOS/operational-truth.mjs
T
Bernt 05ed037fe8 pilot.landvex.com: HTTPS + Full Stack Verified
- DNS: pilot.landvex.com -> 16.170.83.169
- TLS: Let's Encrypt certificate (expires 2026-09-30)
- Nginx: reverse proxy with SSL termination
- API: https://pilot.landvex.com/api/v1/missions
- UI: https://pilot.landvex.com/
- Upload: POST /api/v1/missions/import (multipart/form-data)

Verified:
 https://pilot.landvex.com/health
 https://pilot.landvex.com/version
 https://pilot.landvex.com/api/v1/missions (list)
 https://pilot.landvex.com/api/v1/missions/:id (get)
 POST /api/v1/missions/import (video upload)
 UI loads with title 'LandveX Intelligence Lab'

Next: Pilot 001 — Break the system!
2026-07-02 17:34:19 +00:00

182 lines
5.7 KiB
JavaScript

#!/usr/bin/env node
// ═══════════════════════════════════════════════════════════════════════════
// Operational Truth — EOS Extension
// "Det här har faktiskt verifierats fungera i drift."
// ═══════════════════════════════════════════════════════════════════════════
/**
* Operational Truth är en utökning av Immutable Truth och Latest Truth.
*
* Immutable Truth: Kod är sanningen (Git)
* Latest Truth: Senaste versionen är sanningen
* Operational Truth: Det har faktiskt verifierats fungera
*
* Nivåer:
* - Observed: Fil/kod finns
* - Validated: Funktionellt testat
* - Operational: Verifierat i drift under realistiska förhållanden
*
* Varje Operational Truth har:
* - verified_at: När det senast verifierades
* - valid_until: När det måste verifieras igen
* - verifier: Vem/vad som verifierade
*/
const OPERATIONAL_TRUTH_LEVELS = {
NONE: 0, // Finns inte
OBSERVED: 1, // Filen finns
VALIDATED: 2, // Funktionellt testat
OPERATIONAL: 3 // Verifierat i drift
};
const DEFAULT_VALIDITY_DAYS = {
OBSERVED: 7, // Observed blir stale efter 7 dagar
VALIDATED: 30, // Validated blir stale efter 30 dagar
OPERATIONAL: 90 // Operational blir stale efter 90 dagar
};
/**
* Verifiera Operational Truth för en komponent
*/
export function verifyOperationalTruth(component, checks, options = {}) {
const now = new Date();
const results = {
component,
timestamp: now.toISOString(),
levels: {},
overall: {
level: OPERATIONAL_TRUTH_LEVELS.NONE,
status: 'UNKNOWN',
verified_at: null,
valid_until: null,
verifier: options.verifier || 'unknown'
}
};
let minLevel = OPERATIONAL_TRUTH_LEVELS.OPERATIONAL;
let latestVerification = null;
for (const [check, { level, evidence, verified_at, verifier }] of Object.entries(checks)) {
const checkVerifiedAt = verified_at ? new Date(verified_at) : now;
const validityDays = options.validityDays || DEFAULT_VALIDITY_DAYS;
const validUntil = new Date(checkVerifiedAt);
validUntil.setDate(validUntil.getDate() + (validityDays[level] || 30));
const isStale = now > validUntil;
results.levels[check] = {
level,
evidence,
verified_at: checkVerifiedAt.toISOString(),
valid_until: validUntil.toISOString(),
verifier: verifier || options.verifier || 'unknown',
is_stale: isStale,
status: isStale ? 'STALE' : (level >= OPERATIONAL_TRUTH_LEVELS.VALIDATED ? 'VALID' : 'INSUFFICIENT')
};
minLevel = Math.min(minLevel, level);
if (!latestVerification || checkVerifiedAt > latestVerification) {
latestVerification = checkVerifiedAt;
}
}
// Overall är minsta nivån av alla checks
results.overall.level = minLevel;
results.overall.verified_at = latestVerification ? latestVerification.toISOString() : null;
const overallValidUntil = new Date(latestVerification || now);
overallValidUntil.setDate(overallValidUntil.getDate() + DEFAULT_VALIDITY_DAYS[minLevel]);
results.overall.valid_until = overallValidUntil.toISOString();
results.overall.status = minLevel >= OPERATIONAL_TRUTH_LEVELS.OPERATIONAL ? 'OPERATIONAL' :
minLevel >= OPERATIONAL_TRUTH_LEVELS.VALIDATED ? 'VALIDATED' :
minLevel >= OPERATIONAL_TRUTH_LEVELS.OBSERVED ? 'OBSERVED' : 'NONE';
return results;
}
/**
* Exempel: Terraform
*/
export function verifyTerraform() {
return verifyOperationalTruth('terraform', {
filesExist: {
level: OPERATIONAL_TRUTH_LEVELS.OBSERVED,
evidence: 'find *.tf returns files',
verified_at: '2026-07-01T13:19Z',
verifier: 'autonomous-audit'
},
planWorks: {
level: OPERATIONAL_TRUTH_LEVELS.NONE,
evidence: 'Not yet tested',
verified_at: null,
verifier: null
},
provisionsEnvironment: {
level: OPERATIONAL_TRUTH_LEVELS.NONE,
evidence: 'Not yet tested',
verified_at: null,
verifier: null
}
});
}
/**
* Exempel: Rollback
*/
export function verifyRollback() {
return verifyOperationalTruth('rollback', {
scriptExists: {
level: OPERATIONAL_TRUTH_LEVELS.OBSERVED,
evidence: 'Rollback script exists',
verified_at: '2026-07-01T13:19Z',
verifier: 'autonomous-audit'
},
syntaxValid: {
level: OPERATIONAL_TRUTH_LEVELS.NONE,
evidence: 'Not yet tested',
verified_at: null,
verifier: null
},
testedInStaging: {
level: OPERATIONAL_TRUTH_LEVELS.NONE,
evidence: 'Not yet tested',
verified_at: null,
verifier: null
}
});
}
/**
* Exempel: EOS Blocker
*/
export function verifyEOSBlocker() {
return verifyOperationalTruth('eos-blocker', {
codeExists: {
level: OPERATIONAL_TRUTH_LEVELS.OBSERVED,
evidence: 'engineering-contract.mjs exists',
verified_at: '2026-07-01T13:19Z',
verifier: 'autonomous-audit'
},
integrationTested: {
level: OPERATIONAL_TRUTH_LEVELS.NONE,
evidence: 'Not yet tested',
verified_at: null,
verifier: null
},
blockedRealDeployment: {
level: OPERATIONAL_TRUTH_LEVELS.NONE,
evidence: 'Not yet tested',
verified_at: null,
verifier: null
}
});
}
// CLI
if (process.argv[1] === new URL(import.meta.url).pathname) {
console.log('Terraform:', JSON.stringify(verifyTerraform(), null, 2));
console.log('Rollback:', JSON.stringify(verifyRollback(), null, 2));
console.log('EOS Blocker:', JSON.stringify(verifyEOSBlocker(), null, 2));
}