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

8 lines
6.9 KiB
JavaScript

import fs from 'node:fs';import path from 'node:path';import crypto from 'node:crypto';import assert from 'node:assert/strict';
const [qaTag,demoTag]=process.argv.slice(2);assert([qaTag,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/receipt-composition-'+qaTag),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 [['integration',qa,'geography-result.json',41],['pagination',qa,'geography-pagination.json',5],['guards',qa,'geography-guards.json',12],['demonstration',demo,'geography-demo-smoke.json',14],['assets',demo,'geography-demo-assets.json',3],['links','.','docs/proofs/geography-links-20261103.json',8]]){const filePath=path.join(base,file),r=read(filePath);assert(r.passed);assert.equal(Array.isArray(r.checks)?r.checks.length:r.checks,count);tests[name]={file:base==='.'?file:'private/'+path.basename(base)+'/'+file,sha256:hash(filePath),checks:count,result:r};}assert.equal(Object.values(tests).reduce((n,t)=>n+t.checks,0),83);
const files=['app/Shared/Geography/Cartography.php','app/Shared/Geography/Catalogue.php','app/Shared/Geography/Locations.php','app/Shared/Geography/Segments.php','app/Shared/Geography/GeographyController.php','config/geography.php','routes/web.php','app/Shared/Context/ModuleNavigation.php','app/Modules/Identity/Services/IdentityWorkflow.php','app/Modules/Purchasing/SupplierController.php','resources/js/GeographyLink.jsx','resources/js/app.jsx','resources/js/ServicesWorkspace.jsx','resources/views/geography-workspace.blade.php','public/geography-workspace.mjs','public/supplier-workspace.mjs','scripts/geography-host-setup.php','scripts/geography-composition-proof.php','scripts/geography-proof-body.php','scripts/geography-pagination-proof.php','scripts/geography-pagination-body.php','scripts/geography-guard-proof.php','scripts/geography-links-check.mjs','scripts/geography-demo-smoke.php','scripts/geography-demo-assets.mjs','scripts/receipt-composition-run.mjs','scripts/receipt-composition-http.php','scripts/receipt-composition-extra.mjs'];const sources=files.map(file=>({file,sha256:hash(file)}));for(const base of [qa,demo])for(const file of files.filter(f=>!f.startsWith('scripts/')))assert.equal(hash(path.join(base,'app',file)),hash(file));
const manifests=[];for(const base of [qa,demo]){const pins={};for(const dir of ['bundle','economic','internal']){const manifest=path.join(base,dir,'manifest.json');pins[dir]=hash(manifest);for(const [file,pin]of Object.entries(read(manifest).files))assert.equal(hash(path.join(base,dir,file)),pin);}manifests.push(pins);}assert.deepEqual(manifests[0],manifests[1]);assert.deepEqual(manifests[0],read('docs/proofs/request-to-receipt-composition-20261103.json').pinned_manifests);
const reference=read('docs/proofs/cartography-preparation-20261103.json');assert.equal(hash('app/Shared/Geography/Cartography.php'),reference.implementation_sha256);assert.equal(reference.total,20407);assert.equal(reference.checks,16);const previous=['docs/proofs/cartography-preparation-20261103.json','docs/proofs/request-to-receipt-composition-20261103.json','docs/proofs/supplier-composition-20261103.json','docs/proofs/module-association-consolidation-summary-20261102.json'].map(file=>({file,sha256:hash(file)})),association=read(previous.at(-1).file);assert.equal(hash('app/Modules/Identity/Services/ModuleAssociationReview.php'),association.source_sha256);assert.equal(hash('app/Modules/Identity/Http/ModuleRecordsController.php'),association.controller_sha256);assert.equal(hash('packages/purchasing/current.json'),read(previous[1].file).preservation.installed_purchasing_sha256);
const out='docs/proofs/geography-composition-20261103.json';assert(!fs.existsSync(out));fs.writeFileSync(out,JSON.stringify({date:new Date().toISOString(),increment:'SGF-GEOGRAPHY-SEGMENTATION-QA-v1',passed:true,functional_code:true,checks:83,tests,sources,reference:{source_sha256:reference.source.sha256,prepared_sha256:reference.prepared_sha256,rows:20407,source_checks_reused:16,source_workbook_modified:false},pinned_native_manifests:manifests[0],entity_types:['company','unit','client','supplier'],scope:{purpose:'segmentation_only',canonical_addresses_changed:false,supplier_financial_review_changed:false,dependent_records_propagated:false,new_public_rights:[],real_grants_applied:false},demo:{company_url:'http://127.0.0.1:8069/qa/enter/actor?open=1&geography=company',unit_url:'http://127.0.0.1:8069/qa/enter/actor?open=1&geography=unit',client_url:'http://127.0.0.1:8069/qa/enter/actor?module=commercial&open=1&geography=client',supplier_url:'http://127.0.0.1:8069/qa/enter/actor?open=1',readonly_company_url:'http://127.0.0.1:8069/qa/enter/validator?open=1&geography=company',initial_assignments:0},prior_proofs_preserved:previous,verification_scope:'41 command/access checks retained. Five additional pagination/visibility boundaries use26 prepared reader fixtures. The later country_code=MZ response field is checked by the14 demo probes; the41 checks were not repeated.',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,concurrent_compras_sources_written:false,public_rights_changed:false,purchasing_activated_at_destination:false,publication:false,checkpoint:false},limitations:['Only the new, physically guarded QA composition is enabled. No general destination migration or deployment validation.','The supplied workbook is a versioned reference declared INE-validated by the user; its current legal/administrative vigency is not independently verified. Source issues remain blocked and visible.','CountryMZ and source identity/version are attached only after an explicit geographic selection. No canonical fiscal/delivery address or supplier eligibility is changed.','Client location is company-shared within the authorised module; supplier location uses an explicit native provider and current host unit binding. No cross-unit or cross-provider equivalence is inferred.','Segmentation reports explicit current-version locations only; they do not represent counts of all registered clients or suppliers.','Catalogue pages25, history pages15; cross-book supplier reports validate authorised names in bounded batches100 and expose up to25 entries with a cursor. Sustained-load capability is not validated.','No source-correction/version-publication workflow, historical-location migration, foreign-country catalogue or integration with unrelated financial reports is declared delivered.','Owner/runtime least privilege separation and visual review remain pending.'],visual_review_pending:true,deployment_capacity_validated:false},null,2)+'\n');console.log(JSON.stringify({output:out,checks:83,demo_port:8069}));