Files
SGF/scripts/summarize-payable-history-sgf.mjs
T
2026-11-02 20:29:34 +02:00

32 lines
5.8 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'),tag=process.argv[2];
if(state.port!==55439||!/^[a-f0-9]{12}$/.test(tag||''))throw Error('Wrong isolated context');
const root=path.join(state.root,'private/payable-history-'+tag),regression=read(path.join(root,'regression.json')),http=read(path.join(root,'http-proof.json')),native=read(path.join(root,'native-post.json')),sgf=read(path.join(root,'sgf-post.json'));
if(regression.tests!==10||regression.cases.some(c=>!c.passed)||!http.passed||!native.originals_unchanged||native.native_obligations!==0||!sgf.one_obligation||!sgf.one_history_import||!sgf.original_source_unchanged||sgf.default_feature_enabled||sgf.pending_decision_schema_installed||sgf.recognition_events!==1||sgf.history_events!==1)throw Error('Evidence incomplete or inconsistent');
const source=read(path.join(root,'source.json'));
if(source.native_originals_sha256!==native.originals_sha256||source.capture.confirmed_minor!==3000||source.capture.pending_minor!==1000||source.capture.rejected_minor!==500||source.source.total_minor!==6000||source.source.status!=='validated'||!source.source.validation_audit_id)throw Error('Actual conferred native source differs');
const old=read('docs/proofs/module-association-http-lock-summary-20261102.json');
for(const p of [old.proof,...old.previous_proofs])if(hash(p.path)!==p.sha256)throw Error('Association evidence changed');
const files=['app/Modules/Purchasing/SupplierHistoryReceipts.php','app/Modules/Purchasing/SupplierPayables.php','config/supplier_payable_history.php','app/Modules/Purchasing/SupplierPayablesController.php','routes/web.php','packages/payables/src/Payables.php','packages/payables/src/HistoricalPayments.php','packages/payables/ui/page.php','scripts/payable-history-sgf-run.mjs','scripts/payable-history-sgf-proof.php','scripts/payable-history-sgf-cases.php','scripts/payable-history-sgf-http.mjs','scripts/payable-history-sgf-http-router.php'];
if(!fs.readFileSync('config/supplier_payable_history.php','utf8').includes("'synthetic_enabled' => false"))throw Error('Unexpected operational activation');
const report={date:'2026-11-02',increment:'SGF-PAYABLE-HISTORY-RECEIPT-SIM-v1',status:'local_synthetic_adapter_implemented',
regression,actual_http:http,postchecks:{native,sgf},
private_evidence_sha256:Object.fromEntries(['source.json','regression.json','http-proof.json','native-post.json','sgf-post.json'].map(f=>[f,hash(path.join(root,f))])),
source_provenance:{actual_native_receipt_and_invoice_workflows:true,actual_original_payment_registration_and_independent_review:true,native_history_capture_by_existing_engine:true,native_common_obligation_recognised:false,source_only_fresh_owned_qa_database:true,bank_details_and_encrypted_references_not_exported:true,receipt_checksum_proves_integrity_not_external_authenticity:true,sgf_receipt_mapping_explicit_in_qa_seed:true},
scenario:{currency:'MZN',principal_minor:6000,confirmed_minor:3000,pending_minor:1000,rejected_minor:500,balance_minor:3000,due_on:null,days_overdue:null,no_pending_payment_decision:true,no_new_financial_engine:true},
concurrency:{processes:2,company_row_blocker_observed_with_pg_blocking_pids:true,second_waited_then_replayed_original:true,obligations:1,history_imports:1,imported_payments:3},
isolation:{dedicated_native_and_sgf_databases:true,port:55439,restricted_qa_roles:true,read_write_permission_and_company_context_revalidated:true,no_real_or_demo_access_grants:true},
source_sha256:Object.fromEntries(files.map(f=>[f,hash(f)])),
reused_proofs:Object.fromEntries(['docs/proofs/workshop-stock-closure-20261102.json','docs/proofs/native-warehouse-return-20261102.json','docs/proofs/module-association-http-lock-summary-20261102.json'].map(f=>[f,hash(f)])),
verification_scope:'Ten directed scenarios (56 assertions) plus 17 actual HTTP checks. Current adapter callbacks, shared controller/UI, receipt validation and concurrency exercised. Native original facts postchecked read-only. Earlier suites not repeated; no JavaScript or Vite build required for this PHP/template change.',
preservation:{six_pending_associations_untouched:true,blocked_cache_untouched:true,demos_and_installed_databases_untouched:true,previous_proofs_preserved:true,no_real_migration_or_rights:true,qa_databases_and_evidence_retained:true,purchasing_activation:false,publication:false,checkpoint:false},
limits:['Reads explicitly seeded immutable historical receipts, not live native payment history.','No operational receipt publisher/importer, authentication of external provenance or responsibility cutover installed. Hashes alone do not authenticate an external source.','No common financial obligation was recognised in the native source; this is QA adapter evidence, not proof that simultaneously operated native/SGF installations share financial authority.','Pending/rejected original payments retain state; imported pending-payment decisions, new payments and banking are not added in SGF.','Existing financial listing remains unpaginated; no load/capacity claim or general financial consolidation claim.','No accounting postings, operational activation, browser interaction or visual review.'],
visual_review_pending:true,deployment_capacity_validated:false};
fs.writeFileSync('docs/proofs/sgf-payable-history-receipt-20261102.json',JSON.stringify(report,null,2)+'\n');
console.log(JSON.stringify({scenarios:regression.tests,assertions:regression.assertions,http_checks:http.assertions,native_originals_unchanged:native.originals_unchanged,default_feature_enabled:false,operational_cutover_validated:false}));