7deadlysinstest / scripts /verify-project.mjs
drewgrant616's picture
Upload 45 files
81b8593 verified
Raw History Blame Contribute Delete
2.65 kB
// Re-extract current sources, then compare independently generated fixtures with live functions.
import assert from 'node:assert/strict';
import fs from 'node:fs/promises';
import path from 'node:path';
import {quiz, analysis, full, characterModule, base} from './extract-project.mjs';
const read = async name => (await fs.readFile(path.join(base, `data/${name}.jsonl`),'utf8')).trim().split('\n').map(JSON.parse);
const snapshot = JSON.parse(await fs.readFile(path.join(base,'source/snapshot.json'),'utf8'));
assert.deepEqual(await read('questions'),snapshot.questions,'Question exports drifted from dataset');
function near(a,b) { assert.ok(Math.abs(a-b) < 1e-9, `${a} != ${b}`); }
let attempts = 0;
for (const row of await read('scoring_cases')) {
const items = row.mode === 'quick' ? quiz.questions : full.fullQuestions;
const answers = Object.fromEntries(row.answers.map(a=>[a.question_id,a.raw]));
const actual = analysis.analyzeAnswers(answers,items,row.minimum_per_dimension);
assert.deepEqual(actual.profile.leaders,row.computed_profile.leaders);
assert.equal(actual.profile.title,row.computed_profile.title);
assert.equal(actual.complete,row.coverage_complete);
assert.deepEqual(actual.sensitivity,row.sensitivity);
for (const [i,s] of actual.scores.entries()) {
assert.equal(s.id,row.scores[i].id); assert.equal(s.count,row.scores[i].count); near(s.value,row.scores[i].value);
near(actual.dimensions[i].possible.low,row.possible_completed_ranges[i].low);
near(actual.dimensions[i].possible.high,row.possible_completed_ranges[i].high);
}
const c = characterModule.characterFor(actual.scores);
assert.deepEqual({id:c.id,name:c.name,title:characterModule.resultTitle(c)},row.computed_character);
if(row.mode==='full') {
const clean=full.cleanFullAttempt({v:full.FULL_VERSION,answers,stage:'result',step:69,flags:[]});
assert.equal(clean.result,row.result_eligible);
} else assert.equal(actual.complete,row.result_eligible);
attempts++;
}
const boundary = await read('classification_cases');
for (const row of boundary) {
const actual=quiz.classify(row.scores);
assert.deepEqual({title:actual.title,leaders:actual.leaders},row.expected_profile);
}
const report = {status:'PASS', tolerance:1e-9, scoring_cases:attempts, classification_cases:boundary.length,
checks:['scores','counts','ordered leaders','analytical title','actual character and UI title','missing ranges','coverage','result eligibility','sensitivity'],
source_snapshot_refreshed:true};
await fs.writeFile(path.join(base,'reports/project-parity.json'),JSON.stringify(report,null,2)+'\n');
console.log(JSON.stringify(report));