13 lines
8.7 KiB
JavaScript
13 lines
8.7 KiB
JavaScript
import fs from 'node:fs';import path from 'node:path';import crypto from 'node:crypto';import {spawnSync} from 'node:child_process';
|
|
const read=p=>JSON.parse(fs.readFileSync(p,'utf8').replace(/^\uFEFF/,'')),sha=p=>crypto.createHash('sha256').update(fs.readFileSync(p)).digest('hex'),state=read('C:/laragon/data/sgf-tempo/run/modular-regression-current.json'),output='docs/proofs/common-ledger-industrial-20261103.json';if(state.port!==55439||fs.existsSync(output))throw Error('Fresh isolated industrial consolidation required');
|
|
const names={actual_owner_fixture:'ledger-9784b53db6ec/industrial-fixture.json',actual_industrial_workflow:'ledger-9784b53db6ec/industrial-workflow.json',regression:'ledger-1aa5762a0c16/industrial-cases.json',extra_boundaries:'ledger-1aa5762a0c16/industrial-extra-cases.json',actual_http:'ledger-1aa5762a0c16/industrial-http.json',industrial_rendered_form:'ledger-1aa5762a0c16/industrial-form-check.json',joint_workflow:'ledger-1aa5762a0c16/composition-workflow.json',joint_final:'ledger-1aa5762a0c16/industrial-final.json',concurrency:'ledger-e3009c989fb2/industrial-race.json',concurrency_final:'ledger-e3009c989fb2/industrial-final.json',team_readiness:'ledger-072ef8124ab4/industrial-demo-http.json',team_preservation:'ledger-072ef8124ab4/industrial-demo-preservation.json',old8057_preservation:'ledger-fe42e1169ce6/composition-industrial-compatibility.json'};const tests={},evidence=[];for(const [name,file]of Object.entries(names)){const p=path.join(state.root,'private',file),v=read(p);if(!v.passed)throw Error('Invalid industrial evidence '+name);tests[name]=v;evidence.push({file:'private/'+file,sha256:sha(p)});}
|
|
if(tests.regression.checks!==31||tests.extra_boundaries.checks!==10||tests.actual_http.checks!==43||tests.industrial_rendered_form.checks!==5||tests.joint_workflow.combined_checks!==33||tests.team_readiness.checks!==40||tests.concurrency.workers!==6||tests.joint_final.gross_debit_minor!==510500||tests.joint_final.lines!==19||!tests.old8057_preservation.two_provider_packet_hash_unchanged)throw Error('Expected authorised industrial evidence missing');
|
|
const priorFiles=['docs/proofs/common-ledger-composition-20261103.json','docs/proofs/common-ledger-direct-cost-correction-20261103.json','docs/proofs/common-ledger-direct-cost-20261103.json','docs/proofs/common-ledger-sales-receivable-20261103.json','docs/proofs/common-ledger-reports-20261103.json','docs/proofs/common-ledger-complete-cycle-20261102.json','docs/proofs/common-finance-bundle-20261103.json'];const reused=[];let checked=0;for(const file of priorFiles){const old=read(file);for(const e of old.private_evidence??old.evidence??[]){const p=path.resolve(state.root,e.file);if(!p.startsWith(path.resolve(state.root)+path.sep)||sha(p)!==e.sha256)throw Error('Previously valid private artifact changed '+e.file);checked++;}reused.push({file,sha256:sha(file),private_artifacts_reused:true});}
|
|
const archive='private/ledger-industrial-approved-scope.md',approvedHash=sha(path.join(state.root,archive));if(approvedHash!==read(priorFiles[0]).next_proposed_scope.sha256)throw Error('Approved scope differs from presented proposal');evidence.push({file:archive,sha256:approvedHash});
|
|
const packages=[];for(const [tag,pin,n]of [['760a92655dc1','6a507ea7d708a12a8e526e4c610696d8db84079d18aede470237b65505630e7e',25],['b06aa4315783','cbc4ddbea15f5e396c92bc2e664b973138551928980f334bcf3eb0cf097cacb1',30]]){const root=path.join(state.root,'private/finance-bundle-'+tag),m=read(path.join(root,'manifest.json'));if(sha(path.join(root,'manifest.json'))!==pin||m.files.length!==n)throw Error('Frozen package changed');for(const f of m.files)if(sha(path.join(root,f.file))!==f.sha256)throw Error('Frozen runtime bytes changed');packages.push({files:n,manifest_sha256:pin,all_bytes_preserved:true});}
|
|
const files=['AGENTS.md','config/industrial_ledger.php','app/Modules/Industry/IndustrialCosts.php','app/Modules/Accounting/IndustrialLedgerSource.php','app/Modules/Accounting/IndustrialLedgerController.php','app/Modules/Accounting/GeneralLedger.php','app/Modules/Accounting/GeneralLedgerController.php','app/Modules/Accounting/CostLedgerSource.php','app/Modules/Accounting/LedgerComposition.php','app/Modules/Accounting/LedgerCompositionController.php','app/Shared/Testing/TestingDatabaseGuard.php','packages/general-ledger/bootstrap.php','packages/general-ledger/README.md',...['IndustrialSchema','PayableJournal','LedgerCycle','LedgerReports'].map(n=>'packages/general-ledger/src/'+n+'.php'),'packages/general-ledger/ui/reports.php','resources/views/accounting/industrial-ledger.blade.php','resources/views/accounting/industrial-ledger-demo-entry.blade.php','resources/views/accounting/general-ledger.blade.php','resources/views/accounting/ledger-composition.blade.php','routes/web.php','scripts/payable-history-sgf-proof.php','scripts/ledger-cost-proof.php','scripts/ledger-cost-http-entry.php','scripts/ledger-cost-demo.mjs','scripts/ledger-run.mjs','scripts/ledger-composition-proof.php','scripts/ledger-composition-workflow.php',...fs.readdirSync('scripts').filter(n=>n.startsWith('ledger-industrial-')).map(n=>'scripts/'+n),'scripts/summarize-ledger-industrial.mjs','scripts/inspect-module-flow-plan.mjs','docs/integration/sgf-flow-plan.json','docs/GENERAL_LEDGER_INDUSTRIAL_SCOPE.md','docs/GENERAL_LEDGER_INDUSTRIAL_DELIVERY.md','docs/GENERAL_LEDGER_COMPOSITION_DELIVERY.md','README.md','docs/PRODUCT_DEMO.md','docs/SGF_MODULE_FLOW_PREPARATION.md'];let php=0,js=0;for(const file of files){if(file.endsWith('.blade.php')||(!file.endsWith('.php')&&!file.endsWith('.mjs')))continue;const isPhp=file.endsWith('.php'),r=spawnSync(isPhp?'C:/laragon/tools/sgf-tempo/php-8.4.27/php.exe':process.execPath,[isPhp?'-l':'--check',file],{windowsHide:true,encoding:'utf8'});if(r.status!==0)throw Error('Syntax failed '+file);isPhp?php++:js++;}for(const cwd of [process.cwd(),path.resolve('../compras')])if(spawnSync('git',['diff','--check'],{cwd,windowsHide:true,encoding:'utf8'}).status!==0)throw Error('Diff check failed');
|
|
const team=read(path.join(state.root,'private/ledger-072ef8124ab4/cost-demo.json'));for(const [url,tag]of [[team.url,team.tag],['http://127.0.0.1:8057/qa/cost-demo','fe42e1169ce6'],['http://127.0.0.1:8055/qa/cost-demo','f3e0a05eb2ad']]){const r=await fetch(url,{signal:AbortSignal.timeout(15000)});if(!r.ok||!(await r.text()).includes('data-cost-demo="'+tag+'"'))throw Error('Independent preserved demo unavailable '+url);}
|
|
const graphFile='docs/proofs/module-flow-industrial-update-20261103.json',graph=read(graphFile);if(!graph.checks.mandatory_dependency_graph_acyclic||graph.preservation.database_connections!==0||graph.stages.find(s=>s.id==='general_ledger').operational_integration_validated!==false)throw Error('Static flow inventory exceeded evidence');
|
|
const result={increment:'COMMON-LEDGER-INDUSTRIAL-SIM-v1',consolidated_at_utc:new Date().toISOString(),authorization:{answer:'Autorizar o ciclo industrial sintético proposto',approved_scope_archive_sha256:approvedHash,matches_presented_proposal:true},functional_code:true,synthetic_only:true,status:'implemented_and_tested_with_limits',targeted_checks:162,rendered_form_vm_checks:9,concurrency_workers:6,tests,private_evidence:evidence,reused_manifests:reused,previous_private_artifacts_verified:checked,frozen_bundles:packages,quality:{syntax:{php,js},diff_check_both_repositories:true,unrelated_business_suites_not_repeated:true},source_files:files.map(file=>({file,sha256:sha(file)})),static_flow_inventory:{file:graphFile,sha256:sha(graphFile),modules:6,stages:13,sources:32,mandatory_cycles:0,database_connections:0,operational_validation:false},team_demo:team,observed_result:{industrial_journals:1,industrial_lines:2,industrial_minor:180000,units:'10',unit_cost_exact:'180',unposted_residual_exact:'300',joint_journals:9,joint_lines:19,joint_debit_minor:510500,joint_credit_minor:510500,client_balance_minor:40000,direct_cost_balance_minor:29500,supplier_balance_minor:6000,joint_closures:1},preservation:{old8057_source_outbox_rights_match_original_baseline:true,old_composition_provider_packet_unchanged:true,six_pending_records_untouched:true,blocked_cache_untouched:true,old_demos_not_reset:true,destination_unchanged:true,private_credentials_not_versioned:true,unrelated_work_preserved:true},limits:{visual_review_pending:true,actual_browser:false,large_volume_measurements:false,deployment_capacity_validated:false,all_six_modules_operationally_complete:false,industrial_correction:false,period_reopening:false,stock_valuation_or_payroll:false,real_financial_operations:false,destination_migrations_or_grants:false,purchasing_activation:false,publication:false,checkpoint:false,acceptance_presumed:false}};
|
|
fs.writeFileSync(output,JSON.stringify(result,null,2)+'\n');console.log(JSON.stringify({output,checks:162,concurrent_workers:6,previous_artifacts_verified:checked,syntax:result.quality.syntax,demo:team.url}));
|