Files
SGF/scripts/summarize-association-http-lock.mjs
2026-11-02 20:29:34 +02:00

36 lines
3.1 KiB
JavaScript

import fs from 'node:fs';
import path from 'node:path';
import crypto from 'node:crypto';
const read=p=>JSON.parse(fs.readFileSync(p,'utf8').replace(/^\uFEFF/,''));
const hash=p=>crypto.createHash('sha256').update(fs.readFileSync(p)).digest('hex');
const state=read('C:/laragon/data/sgf-tempo/run/modular-regression-current.json');
const input=path.resolve(process.argv[2]||'');
if(path.dirname(input)!==path.resolve(state.root)||!/^association-http-lock-\d+\.json$/.test(path.basename(input)))throw Error('Unexpected regression proof');
const report=read(input);
const junit=p=>{
const xml=fs.readFileSync(p,'utf8'),suite=xml.match(/<testsuite\b([^>]*)>/)?.[1];
const result=Object.fromEntries(['tests','assertions','errors','failures'].map(k=>[k,Number(suite?.match(new RegExp('\\b'+k+'="(\\d+)"'))?.[1])]));
if(!result.tests||result.errors!==0||result.failures!==0)throw Error('Incomplete test result');
return {...result,sha256:hash(p)};
};
if(report.identity.database!=='sgf_tempo_test'||report.identity.role!=='sgf_test_runner'||report.identity.port!==55439
||report.identity.cluster!=='sgf_modular_regression_'+state.id||!report.completed||!report.previous_qa_rows_and_index_catalog_preserved
||report.cases.length!==3||hash('app/Modules/Identity/Http/ModuleRecordsController.php')!==report.controller_sha256
||hash('app/Modules/Identity/Services/ModuleAssociationReview.php')!==report.source_sha256)throw Error('Inconsistent proof/source');
for(const c of report.cases)if(c.timeout.http_status!==423||c.timeout.code!=='association_busy'||c.duplicate_decision
||c.decision_events_after_retry!==1||!c.blocking_parent_verified)throw Error('Unexpected result');
const prior=read('docs/proofs/module-association-release-summary-20261102.json');
const previous=[prior.proof,...prior.reused_proofs];
for(const p of previous)if(hash(p.path)!==p.sha256)throw Error('A valid prior proof changed');
const proof='docs/proofs/module-association-http-lock-20261102.json';
fs.copyFileSync(input,proof);
const summary={date:'2026-11-02',source_sha256:report.source_sha256,controller_sha256:report.controller_sha256,
tests:{http_lock:junit(input.replace(/\.json$/,'.xml')),affected_queue:junit(path.join(state.root,'junit-focused.xml'))},cases:report.cases,
preservation:{previous_qa_rows_and_index_catalog_preserved:true,prior_proof_hashes_preserved:true,protected_six_records_untouched:true,blocked_cache_untouched:true,
destination_connected:false,public_rights_changed:false,indexes_created:false,purchasing_activation:false,publication:false,checkpoint:false,new_qa_fixture_retained:true},
proof:{path:proof,sha256:hash(proof)},previous_proofs:previous,method:{http_kernel_in_process:true,independent_lock_contender:true,test_lock_timeout_ms:1000,
runtime_timeout_changed:false,automatic_decision_retry_added:false,network_browser_login_tls_tested:false},deployment_capacity_validated:false,visual_review_pending:true};
fs.writeFileSync('docs/proofs/module-association-http-lock-summary-20261102.json',JSON.stringify(summary,null,2)+'\n');
console.log(JSON.stringify({tests:summary.tests,old_proofs_unchanged:true,cases:report.cases.length},null,2));