29 lines
2.8 KiB
JavaScript
29 lines
2.8 KiB
JavaScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import assert from 'node:assert/strict';
|
|
import { execFileSync, spawnSync } from 'node:child_process';
|
|
import { createHash } from 'node:crypto';
|
|
const hash=bytes=>createHash('sha256').update(bytes).digest('hex');
|
|
const identity=JSON.parse(fs.readFileSync('docs/model-protocols-release-identity.json'));
|
|
assert.equal(identity.success,true);
|
|
const manifest=JSON.parse(fs.readFileSync(identity.evidence.manifest));assert.equal(manifest.files.length,identity.evidence.files);
|
|
let bytes=0,jsonFiles=0;
|
|
for(const row of manifest.files){
|
|
const value=fs.readFileSync(row.archived);assert.equal(value.length,row.bytes);assert.equal(hash(value),row.sha256,row.archived);bytes+=value.length;
|
|
const indexed=execFileSync('git',['show',':'+row.archived],{windowsHide:true,maxBuffer:64*1024*1024});assert.deepEqual(indexed,value,'Git index raw evidence bytes: '+row.archived);
|
|
if(row.archived.endsWith('.json')){JSON.parse(value);jsonFiles++;}
|
|
}
|
|
assert.equal(bytes,manifest.bytes);
|
|
const docs=['README.md','CHANGELOG.md','AGENTS.md','task_plan.md','findings.md','progress.md','docs/QA-1.17.md','docs/RETROSPECTIVE-1.17.md','docs/PLAN-1.17.md','docs/PLAN-1.18.md','docs/PRODUCT-PLAN.md','docs/CAPABILITIES.md','docs/MILESTONE-AUDIT.md','docs/NEXT-STEPS.md','docs/VALIDATION.md'];
|
|
let links=0;
|
|
for(const name of docs){const text=fs.readFileSync(name,'utf8');for(const match of text.matchAll(/\]\(([^)]+)\)/g)){
|
|
const target=match[1].replace(/^<|>$/g,'').split('#')[0];if(!target||/^(?:https?:|codex:|app:|data:|mailto:)/.test(target))continue;
|
|
assert.equal(fs.existsSync(path.resolve(path.dirname(name),decodeURIComponent(target))),true,name+': '+target);links++;
|
|
}}
|
|
const wrappers=fs.readdirSync('.qa').filter(n=>/^(?:protocol-.*|(?:prepare|freeze|package|run|shorten|deploy|verify|audit|seal|record|write|finalize)-protocol-.*)\.mjs$/.test(n));
|
|
for(const name of wrappers){const result=spawnSync(process.execPath,['--check','.qa/'+name],{windowsHide:true,encoding:'utf8'});assert.equal(result.status,0,name+': '+result.stderr);}
|
|
const baseline=JSON.parse(fs.readFileSync('docs/model-protocols-release-code-baseline.json'));
|
|
for(const row of [...baseline.inputs,...baseline.builds,...baseline.benchmarks]){const value=fs.readFileSync(row.path);assert.equal(value.length,row.bytes);assert.equal(hash(value),row.sha256,row.path);}
|
|
const result={success:true,version:'1.17.0',rawEvidenceFiles:manifest.files.length,rawEvidenceBytes:bytes,jsonFiles,docs:docs.length,localLinks:links,wrappers:wrappers.length,frozenInputs:baseline.inputs.length,builds:baseline.builds.length,benchmarks:baseline.benchmarks.length,checkedAt:new Date().toISOString()};
|
|
fs.writeFileSync('.qa/protocol-f-final-check.json',JSON.stringify(result,null,2)+'\n',{flag:'wx'});console.log(JSON.stringify(result));
|