Files
SGF/scripts/summarize-purchasing-focus.mjs
T
2026-11-04 09:37:20 +02:00

8 lines
5.2 KiB
JavaScript

import fs from 'node:fs';import path from 'node:path';import crypto from 'node:crypto';import assert from 'node:assert/strict';
const [readTag,demoTag]=process.argv.slice(2);assert([readTag,demoTag].every(t=>/^[a-f0-9]{12}$/.test(t??'')));const run=JSON.parse(fs.readFileSync('C:/laragon/data/sgf-tempo/run/modular-regression-current.json')),qa=path.join(run.root,'private/purchasing-focus-read-'+readTag),demo=path.join(run.root,'private/receipt-composition-'+demoTag),read=p=>JSON.parse(fs.readFileSync(p,'utf8')),hash=p=>crypto.createHash('sha256').update(fs.readFileSync(p)).digest('hex'),tests={};
for(const [name,base,file,count]of [['read',qa,'purchasing-focus-read-result.json',26],['ui',qa,'purchasing-focus-ui.json',36],['demo',demo,'purchasing-focus-demo.json',12],['assets',demo,'purchasing-focus-assets.json',3]]){const p=path.join(base,file),r=read(p);assert(r.passed);assert.equal(r.checks.length,count);tests[name]={file:'private/'+path.basename(base)+'/'+file,sha256:hash(p),checks:count,result:r};}assert.equal(tests.read.result.before_sha256,tests.read.result.after_sha256);assert.equal(tests.read.result.tables_checked,142);
const files=['app/Modules/Purchasing/ProcessNavigation.php','app/Modules/Purchasing/DossierController.php','config/receipt_qa.php','public/purchasing-focus.mjs',...['request-workspace','sourcing-workspace','order-workspace','receipt-workspace','supplier-invoice-workspace','supplier-obligation-workspace','purchasing-dossier'].flatMap(n=>['public/'+n+'.mjs','resources/views/'+n+'.blade.php'])];for(const base of [qa,demo])for(const f of files)assert.equal(hash(path.join(base,'app',f)),hash(f),f);
const qaState=read(path.join(qa,'state.json')),pins=[];for(const base of [qaState.original_root,demo]){const p={};for(const dir of ['bundle','economic','internal']){p[dir]=hash(path.join(base,dir,'manifest.json'));for(const [f,h]of Object.entries(read(path.join(base,dir,'manifest.json')).files))assert.equal(hash(path.join(base,dir,f)),h);}pins.push(p);}assert.deepEqual(pins[0],pins[1]);assert.deepEqual(pins[0],read('docs/proofs/receipt-documents-composition-20261103.json').pinned_native_manifests);
const previous=['docs/proofs/receipt-documents-composition-20261103.json','docs/proofs/purchasing-dossier-composition-20261103.json','docs/proofs/purchasing-integrated-composition-20261103.json','docs/proofs/module-association-consolidation-summary-20261102.json'].map(file=>({file,sha256:hash(file)})),assoc=read(previous.at(-1).file);assert.equal(hash('app/Modules/Identity/Services/ModuleAssociationReview.php'),assoc.source_sha256);assert.equal(hash('app/Modules/Identity/Http/ModuleRecordsController.php'),assoc.controller_sha256);assert.equal(hash('packages/purchasing/current.json'),read(previous[0].file).preservation.installed_purchasing_sha256);
const count=Object.values(tests).reduce((n,t)=>n+t.checks,0);assert.equal(count,77);const out='docs/proofs/purchasing-focus-composition-20261103.json';assert(!fs.existsSync(out));fs.writeFileSync(out,JSON.stringify({date:new Date().toISOString(),increment:'SGF-PURCHASING-CONTEXTUAL-NAVIGATION-QA-v1',passed:true,functional_code:true,checks:count,tests,sources:files.map(file=>({file,sha256:hash(file)})),pinned_native_manifests:pins[0],authority:{new_right_names:[],new_mutation_endpoints:0,new_business_writers:0,filtered_by_existing_visible_stages:true,destination_authority_rechecked:true,module_company_unit_not_changed_by_link:true,preview_or_confirmation_on_startup:false},regression:{reused_completed_book:'purchasing-integrated-composition-20261103.json',contextual_links:8,tables_preserved:142,sequences_preserved:true,financial_commands_repeated:0,first_page_not_required_for_focus:true,receipt_parent_checked_before_render:true,invoice_parent_checked_before_render:true,dom_simulation_not_browser:true},demo:{port:8078,entry:'http://127.0.0.1:8078/qa/enter/requester?open=1',procurement:'http://127.0.0.1:8078/qa/enter/actor?open=1',finance:'http://127.0.0.1:8078/qa/enter/issuer?open=1',initial_main_requests:0,initial_receipts:0,initial_invoices:0,initial_obligations:0},prior_proofs_preserved:previous,preservation:{installed_purchasing_sha256:hash('packages/purchasing/current.json'),target_database_connected:false,protected_six_records_changed:false,blocked_cache_cleared:false,previous_demo_data_written:false,public_rights_changed:false,publication:false,checkpoint:false},limitations:['This is contextual navigation and read integration. It does not execute, approve or determine readiness of the next business stage.','The same session and current context are used; links do not transfer another actor identity or grant destination access.','Lists retain their own pagination and filters. A focused record is loaded independently by its authorised detail endpoint; no universe scan or automatic first-record fallback.','DOM tests use minimal synthetic read fixtures for the actual seven modules. They are not a browser rendering, visual or accessibility review.','Only the first stage pages shown by the dossier have contextual links; other pages remain independently paginated.','Sustained load, general deployment and real operational/fiscal readiness remain separate.'],visual_review_pending:true,deployment_capacity_validated:false},null,2)+'\n');console.log(JSON.stringify({output:out,checks:count,demo_port:8078}));