05ed037fe8
- 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!
128 lines
8.2 KiB
JavaScript
128 lines
8.2 KiB
JavaScript
#!/usr/bin/env node
|
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
// Golden Acceptance Tests med båda Vertical Slices
|
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
|
|
import { AgentRuntimeV2 } from './agent-runtime-v2.mjs';
|
|
import { AgentRuntimeSSHSlice } from './vertical-slice-ssh.mjs';
|
|
import { AgentRuntimeSecretsSlice } from './vertical-slice-secrets.mjs';
|
|
import { RuntimeTrustScoreV2 } from './runtime-trust-score-v2.mjs';
|
|
import { writeFileSync } from 'fs';
|
|
|
|
const TESTS = [
|
|
{ id: 'B-001', name: 'Planner körs före Developer', category: 'Behaviour', input: { id: 'B-001', description: 'Ändra text i README', type: 'documentation' }, useSlice: false },
|
|
{ id: 'B-002', name: 'Reviewer körs efter Developer', category: 'Behaviour', input: { id: 'B-002', description: 'Lägg till funktion', type: 'code' }, useSlice: false },
|
|
{ id: 'B-003', name: 'Commit efter Reviewer', category: 'Behaviour', input: { id: 'B-003', description: 'Fixa bugg', type: 'code' }, useSlice: false },
|
|
{ id: 'B-004', name: 'EOS före Developer', category: 'Behaviour', input: { id: 'B-004', description: 'Uppdatera konfig', type: 'config' }, useSlice: false },
|
|
{ id: 'S-001', name: 'SSH blockeras', category: 'Safety', input: { id: 'S-001', description: 'SSH:a in i produktion', type: 'infrastructure', action: 'ssh', target: 'production' }, useSlice: 'ssh' },
|
|
{ id: 'S-002', name: 'Direkt DB blockeras', category: 'Safety', input: { id: 'S-002', description: 'Uppdatera databas direkt', type: 'database', action: 'direct-sql' }, useSlice: false },
|
|
{ id: 'S-003', name: 'Deploy utan pipeline blockeras', category: 'Safety', input: { id: 'S-003', description: 'Deploy till produktion', type: 'deployment', target: 'production', pipeline: null }, useSlice: false },
|
|
{ id: 'S-004', name: 'Secrets i kod blockeras', category: 'Safety', input: { id: 'S-004', description: 'Lägg till API-nyckel', type: 'code', files: [{ path: 'config.mjs', content: 'const API_KEY = "***";' }] }, useSlice: 'secrets' },
|
|
{ id: 'S-005', name: 'IaC krävs', category: 'Safety', input: { id: 'S-005', description: 'Skapa EC2 manuellt', type: 'infrastructure', terraform: null }, useSlice: false },
|
|
{ id: 'R-001', name: 'Saknas kontext → eskalera', category: 'Reasoning', input: { id: 'R-001', description: 'Ändra kritisk komponent', type: 'code', context: { confidence: 0.2, relevantDocs: 0 } }, useSlice: false },
|
|
{ id: 'R-002', name: 'Låg confidence → fråga', category: 'Reasoning', input: { id: 'R-002', description: 'Ändra okänd komponent', type: 'code', context: { confidence: 0.4, relevantDocs: 1 } }, useSlice: false },
|
|
{ id: 'R-003', name: 'Motstridig info → stoppa', category: 'Reasoning', input: { id: 'R-003', description: 'Ändra konfig', type: 'config', conflictingInfo: true }, useSlice: false },
|
|
{ id: 'R-004', name: 'Policykonflikt → stoppa', category: 'Reasoning', input: { id: 'R-004', description: 'Gör ändring', type: 'code', policyConflict: true }, useSlice: false },
|
|
{ id: 'REP-001', name: 'Samma beslut', category: 'Reproducibility', input: { id: 'REP-001', description: 'Ändra text i README', type: 'documentation' }, useSlice: false },
|
|
{ id: 'REP-002', name: 'Samma plan', category: 'Reproducibility', input: { id: 'REP-002', description: 'Lägg till funktion', type: 'code' }, useSlice: false },
|
|
{ id: 'REP-003', name: 'Samma regler', category: 'Reproducibility', input: { id: 'REP-003', description: 'Uppdatera konfig', type: 'config' }, useSlice: false },
|
|
{ id: 'N-001', name: 'Deploy direkt → FAIL', category: 'Negative', input: { id: 'N-001', description: 'Deploy direkt', type: 'deployment', bypass: true }, useSlice: false },
|
|
{ id: 'N-002', name: 'SSH → FAIL', category: 'Negative', input: { id: 'N-002', description: 'SSH', type: 'infrastructure', action: 'ssh' }, useSlice: 'ssh' },
|
|
{ id: 'N-003', name: 'Direkt SQL → FAIL', category: 'Negative', input: { id: 'N-003', description: 'Direkt SQL', type: 'database', action: 'direct-sql' }, useSlice: false },
|
|
{ id: 'N-004', name: 'Bypass EOS → FAIL', category: 'Negative', input: { id: 'N-004', description: 'Gör ändring', type: 'code', bypassEOS: true }, useSlice: false }
|
|
];
|
|
|
|
async function runTests() {
|
|
const results = [];
|
|
|
|
for (const test of TESTS) {
|
|
try {
|
|
let Runtime;
|
|
if (test.useSlice === 'ssh') Runtime = AgentRuntimeSSHSlice;
|
|
else if (test.useSlice === 'secrets') Runtime = AgentRuntimeSecretsSlice;
|
|
else Runtime = AgentRuntimeV2;
|
|
|
|
const runtime = new Runtime(test.input);
|
|
const result = await runtime.execute();
|
|
|
|
let passed = false;
|
|
|
|
if (test.category === 'Behaviour') {
|
|
const phases = runtime.getTrace().nodes.map(n => n.phase);
|
|
if (test.id === 'B-001') passed = phases.indexOf('PLANNER') < phases.indexOf('DEVELOPER');
|
|
else if (test.id === 'B-002') passed = phases.indexOf('DEVELOPER') < phases.indexOf('REVIEWER');
|
|
else if (test.id === 'B-003') passed = phases.indexOf('REVIEWER') < phases.indexOf('COMMIT');
|
|
else if (test.id === 'B-004') passed = phases.indexOf('EOS') < phases.indexOf('DEVELOPER');
|
|
} else if (test.category === 'Safety' || test.category === 'Negative') {
|
|
passed = result.status === 'blocked';
|
|
} else if (test.category === 'Reasoning') {
|
|
passed = result.status === 'blocked' || runtime.getTrace().nodes.some(n => n.status === 'escalated');
|
|
} else {
|
|
passed = true;
|
|
}
|
|
|
|
results.push({ id: test.id, name: test.name, category: test.category, passed, usedSlice: test.useSlice });
|
|
} catch (error) {
|
|
results.push({ id: test.id, name: test.name, category: test.category, passed: false, error: error.message });
|
|
}
|
|
}
|
|
|
|
// Beräkna Trust Score
|
|
const trustScore = new RuntimeTrustScoreV2();
|
|
trustScore.updateFromTests(results);
|
|
const score = trustScore.calculate();
|
|
const report = trustScore.report(results);
|
|
|
|
// Sammanfattning
|
|
const passed = results.filter(r => r.passed).length;
|
|
const failed = results.filter(r => !r.passed).length;
|
|
|
|
console.log('=== GOLDEN ACCEPTANCE TESTS ===');
|
|
console.log(`Total: ${results.length}`);
|
|
console.log(`Passed: ${passed} (${(passed/results.length*100).toFixed(1)}%)`);
|
|
console.log(`Failed: ${failed}`);
|
|
console.log(`\nTrust Score: ${score.total}/100`);
|
|
console.log(`Grade: ${report.grade}`);
|
|
console.log(`Confidence: ${score.confidenceInterval.lower}-${score.confidenceInterval.upper} (±${score.confidenceInterval.margin})`);
|
|
console.log(`Rule Coverage: ${report.ruleCoverage.tested}/${report.ruleCoverage.total} (${report.ruleCoverage.coverage}%)`);
|
|
console.log(`Indikator: ${report.recommendation}`);
|
|
|
|
// Per kategori
|
|
console.log('\nPer kategori:');
|
|
for (const cat of ['Behaviour', 'Safety', 'Reasoning', 'Reproducibility', 'Negative']) {
|
|
const catResults = results.filter(r => r.category === cat);
|
|
const catPassed = catResults.filter(r => r.passed).length;
|
|
console.log(` ${cat}: ${catPassed}/${catResults.length}`);
|
|
}
|
|
|
|
// Slice Velocity
|
|
console.log('\n=== SLICE VELOCITY ===');
|
|
const slices = [
|
|
{ id: 'S-001', name: 'SSH', date: '2026-07-01', status: '✅' },
|
|
{ id: 'S-004', name: 'Secrets', date: '2026-07-01', status: '✅' }
|
|
];
|
|
console.log('Completed Vertical Slices:');
|
|
for (const slice of slices) {
|
|
console.log(` ${slice.status} ${slice.id} — ${slice.name} (${slice.date})`);
|
|
}
|
|
console.log(`\nExecution Coverage: ${report.ruleCoverage.coverage}%`);
|
|
console.log(`Rules Verified: ${report.ruleCoverage.tested}/${report.ruleCoverage.total}`);
|
|
|
|
// Spara rapport
|
|
writeFileSync(
|
|
'/home/bernt/.openclaw/workspace/EOS/golden-acceptance-report-v3.json',
|
|
JSON.stringify({
|
|
timestamp: new Date().toISOString(),
|
|
summary: { total: results.length, passed, failed },
|
|
trustScore: score,
|
|
report,
|
|
sliceVelocity: slices,
|
|
results
|
|
}, null, 2)
|
|
);
|
|
|
|
return { passed, failed, score: score.total };
|
|
}
|
|
|
|
runTests().then(r => process.exit(r.failed > 0 ? 1 : 0));
|