'use strict'; const assert = require('assert/strict'); const crypto = require('crypto'); const fs = require('fs'); const path = require('path'); const corpus = require('./generator/corpus'); const generator = require('./generator/questions'); const pinned = { 'generator/questions.js': 'eeaf28829ff0e2d8bfdd85f63444f3a54b0367984628ac855b66983933738325', 'QUESTIONS.md': 'a3e0737245bfe67a62e29a1047dfe4e96960dd70043a049fc5fa973089457a60', 'recon-0830-smooth-aps.md': 'b64900a74c7649dbc91e4f8efc5e181d705150ffd3db4db115447a8ef0eab38e', }; for (const [name, sha] of Object.entries(pinned)) { assert.equal(crypto.createHash('sha256') .update(fs.readFileSync(path.join(__dirname, name))).digest('hex'), sha, name); } const id = '`Q-recon-0830-smooth-aps`'; const rowsOf = text => text.split('\n').filter(line => line.startsWith('|') && line.includes(id)); const rendered = []; const blocks = []; for (const name of ['recon-0830-smooth-aps.md', 'recon-0830-smooth-aps.revised.md']) { corpus.historyMarkdown = [path.join(__dirname, name)]; const result = generator.renderQuestions(); assert.equal(result.questions, 1); assert.equal(result.notes, 1); assert.equal(result.unindexed, 0); const rows = rowsOf(result.text); assert.equal(rows.length, 2); rendered.push(rows); const parsed = generator.collect().rows[0]; assert.deepEqual(parsed.problems, []); blocks.push(parsed.block); } for (const key of ['id', 'status', 'todo', 'question']) { assert.deepEqual(blocks[0][key], blocks[1][key], key); } assert.equal(blocks[1].status, 'PARTIAL'); assert.match(blocks[1].verdict, /prefix hypothesis \(H_w\) is REFUTED/); const original = fs.readFileSync(path.join(__dirname, 'QUESTIONS.md'), 'utf8'); assert.deepEqual(rowsOf(original), rendered[0]); let changed = 0; const text = original.split('\n').map(line => { if (!line.startsWith('|') || !line.includes(id)) return line; assert.equal(line, rendered[0][changed]); return rendered[1][changed++]; }).join('\n'); assert.equal(changed, 2); assert.deepEqual(rowsOf(text), rendered[1]); const unrelated = value => value.split('\n').filter(line => !line.includes(id)).join('\n'); assert.equal(unrelated(text), unrelated(original)); console.log(JSON.stringify({ checks: { pinnedInputs: 3, baselineRowsMatched: 2, generatedRowsChanged: 2, unrelatedRegistryBytesPreserved: true, questionStatus: 'PARTIAL', }, scope: 'One-note pinned official renderer; not a full-corpus regeneration or live integration', sha256: crypto.createHash('sha256').update(text).digest('hex'), text, }));