Files
SGF/scripts/summarize-stock-ledger.mjs
2026-11-04 09:37:20 +02:00

15 lines
6.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 state=JSON.parse(fs.readFileSync('C:/laragon/data/sgf-tempo/run/modular-regression-current.json')),base=path.join(state.root,'private'),hash=f=>crypto.createHash('sha256').update(fs.readFileSync(f)).digest('hex'),read=f=>JSON.parse(fs.readFileSync(f)),output='docs/proofs/common-ledger-stock-valuation-20261103.json';assert(!fs.existsSync(output));
const tests={};for(const [name,file]of Object.entries({cases:'stock-ledger-b6b0e5d2fbc5/cases.json',concurrency:'stock-ledger-b6b0e5d2fbc5/race.json',workflow:'stock-ledger-b6b0e5d2fbc5/workflow.json',isolation_sql:'stock-ledger-b6b0e5d2fbc5/extra.json',sql_predecessor:'stock-ledger-255565a5f62d/order-guard.json',http:'stock-ledger-255565a5f62d/http-proof.json',sgf_observer:'stock-ledger-observer-0f9fe83534bd/proof.json',sgf_metadata:'stock-ledger-observer-0f9fe83534bd/proof-final.json',demo:'stock-ledger-cf1b85f9a040/demo-check.json'})){const value=read(path.join(base,file));assert.equal(value.passed,true);tests[name]={file:'private/'+file,sha256:hash(path.join(base,file)),checks:Array.isArray(value.checks)?value.checks.length:value.checks,result:value};}
for(const [name,file]of Object.entries({ui:'docs/proofs/stock-ledger-ui-20261103.json',menu:'docs/proofs/stock-ledger-menu-final-20261103.json'})){const value=read(file);assert.equal(value.passed,true);tests[name]={file,sha256:hash(file),checks:value.checks,result:value};}
assert.equal(Object.values(tests).reduce((n,t)=>n+t.checks,0),146);
const legacyPath=path.join(base,'ledger-native-4ca15d915362/native-cycle-cases.json'),legacy=read(legacyPath);assert.equal(legacy.passed,true);assert.equal(Array.isArray(legacy.checks)?legacy.checks.length:legacy.checks,23);
const contracts=['stock-ledger-b6b0e5d2fbc5','stock-ledger-255565a5f62d','stock-ledger-cf1b85f9a040'].map(dir=>{const file=path.join(base,dir,'contract.json'),r=read(file);assert(r.passed&&r.predecessor_required);return {file:'private/'+dir+'/contract.json',sha256:hash(file),...r};});assert(contracts.every(c=>c.sql_contract_sha256===contracts[0].sql_contract_sha256&&c.source_class_sha256===contracts[0].source_class_sha256));
const sources=[];const add=file=>sources.push({file,sha256:hash(file)});for(const file of ['packages/general-ledger/bootstrap.php','packages/general-ledger/src/PayableJournal.php','packages/general-ledger/src/LedgerCycle.php','packages/general-ledger/src/StockSchema.php','packages/general-ledger/src/StockValuation.php','packages/general-ledger/src/StockComposition.php','packages/general-ledger/src/StockWorkspace.php','packages/general-ledger/ui/stock.php','integrations/purchasing/StockValuationAdapter.php','app/Modules/Accounting/StockValuationRead.php','resources/views/accounting/stock-valuation-read.blade.php','config/stock_ledger.php','app/Modules/Identity/Services/IdentityWorkflow.php','app/Shared/Context/ModuleNavigation.php','resources/js/AccountingMenuWorkspace.jsx','routes/web.php'])add(file);
for(const file of ['app/Services/ReceiptWorkflow.php','app/Services/ReceiptStockMovement.php','app/Services/WarehouseRequests.php','app/Services/WarehouseFulfilment.php','app/Services/WarehouseReturns.php','app/Services/WarehouseReturnMovement.php','app/Services/StockIssueMovement.php'])add('../compras/'+file);
const demoRoot=path.join(base,'stock-ledger-cf1b85f9a040'),bundleFile=path.join(demoRoot,'bundle/manifest.json'),bundle=read(bundleFile);for(const [file,pin]of Object.entries(bundle.files))assert.equal(hash(path.join(demoRoot,'bundle',file)),pin);assert.equal(hash(bundleFile),tests.demo.result.pinned_bundle_manifest);const servers=read(path.join(demoRoot,'demo-servers.json'));
const preserved=['docs/proofs/requisition-composition-20261103.json','docs/proofs/common-ledger-industrial-correction-20261103.json','docs/proofs/financial-receipt-recovery-20261103.json','docs/proofs/module-association-consolidation-summary-20261102.json','docs/proofs/sgf-demo-8039-reconciliation.json'].map(file=>({file,sha256:hash(file)}));
const associations=read('docs/proofs/module-association-consolidation-summary-20261102.json');assert.equal(hash('app/Modules/Identity/Services/ModuleAssociationReview.php'),associations.source_sha256);assert.equal(hash('app/Modules/Identity/Http/ModuleRecordsController.php'),associations.controller_sha256);
const pointer=read('packages/purchasing/current.json');assert.equal(pointer.version,'0.1.1');assert.equal(pointer.manifest_sha256,'91ba35ee3aa1ca226052c94ed682e430cb7870beb241f16b17d889046e1f711d');
fs.writeFileSync(output,JSON.stringify({date:new Date().toISOString(),increment:'COMMON-LEDGER-STOCK-VALUATION-SIM-v1',functional_code:true,passed:true,targeted_checks:146,tests,affected_legacy_regression:{file:'private/ledger-native-4ca15d915362/native-cycle-cases.json',sha256:hash(legacyPath),checks:23,passed:true},sql_contracts:contracts,sources,demo:{native:servers.native.entry,sgf:servers.sgf.entry,pinned_common_manifest_sha256:hash(bundleFile),initial_rates:0,initial_journals:0,initial_closures:0,physical_quantity_milli:1500},prior_proofs_preserved:preserved,incomplete_or_superseded_qa_runs_preserved:['716e93985fae','f6f4a1639d23','3723aba6c497','d064fa825119','9dbef750c208','68efce228a56'],limitations:['SGF observes the canonical native book through SELECT-only access; confirmations and full source revalidation execute in the native QA composition.','Observer reconciliation covers movement coverage and rate IDs, not independent validation of every current source dependency.','No hybrid posting of the same materials as direct/industrial cost; integration of already posted materials with these costs remains separate.','Selected fixed synthetic rate is not a real inventory valuation method or tax/accounting policy.','QA roles own their new databases; deployment owner/runtime separation and capacity are not validated.','No sustained load/throughput or visual review.'],preservation:{existing_demos_or_protected_six_records_written:false,blocked_cache_cleared:false,destination_migrations:false,real_or_public_rights_changed:false,purchasing_candidate_activated:false,publication:false,checkpoint:false}},null,2));console.log(JSON.stringify({output,targeted_checks:146,affected_legacy_checks:23,native:servers.native.entry,sgf:servers.sgf.entry}));