فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

reject-empty-holoo-dependency-evidence

Davood Mehraban committed Nov 23, 2026 at 06:34 UTC 793ea6b2d70e70b8cde54ad492bb38b6ba4d4f60
2 files changed +2 -2
src/holoo-procedure-dependency-assessment.cjs
+1 -1
@@ -4,7 +4,7 @@ const TABLES=new Set(['FACTURE','FACTART','SANAD']);
4 function assessProcedureDependencies(e){
5 const fail=(reason)=>({status:'INVALID_EVIDENCE',reason,productionWriteGate:'NO-GO'});
6 if(!e||e.schemaVersion!==1||e.database!==LAB||e.metadataOnly!==true||e.productionWriteGate!=='NO-GO'||e.dependencyCoverageComplete!==false||e.dynamicSqlAndIndirectCallsUnresolved!==true||e.financialSemanticsVerified!==false)return fail('Untrusted LAB evidence or unsupported safety assertions');
7 - if(!Array.isArray(e.dependencyRows)||!Number.isSafeInteger(e.dependencyRowCount)||!Number.isSafeInteger(e.procedureCount)||e.dependencyRowCount!==e.dependencyRows.length)return fail('Invalid dependency counts');
7 + if(!Array.isArray(e.dependencyRows)||!Number.isSafeInteger(e.dependencyRowCount)||!Number.isSafeInteger(e.procedureCount)||e.dependencyRowCount<1||e.procedureCount<1||e.dependencyRowCount!==e.dependencyRows.length)return fail('Invalid dependency counts');
8 const procedures=new Set(),tables=new Set(),unresolved=[];
9 for(const row of e.dependencyRows){
10 if(!row||typeof row.procedure_schema!=='string'||!row.procedure_schema.trim()||typeof row.procedure_name!=='string'||!row.procedure_name.trim()||(typeof row.referenced_entity_name!=='string'||!TABLES.has(row.referenced_entity_name.toUpperCase()))||!Number.isSafeInteger(row.referenced_minor_id)||row.referenced_minor_id<0||![false,true,0,1].includes(row.is_ambiguous)||![false,true,0,1].includes(row.is_caller_dependent))return fail('Malformed catalog dependency row');
tests/holoo-procedure-dependency-assessment.test.mjs
+1 -1
@@ -9,6 +9,6 @@ const row={procedure_schema:'dbo',procedure_name:'p',referenced_entity_name:'FAC
9 const fixture=()=>({schemaVersion:1,database:'HolooBackup_050808_LAB_20261110',metadataOnly:true,productionWriteGate:'NO-GO',dependencyCoverageComplete:false,dynamicSqlAndIndirectCallsUnresolved:true,financialSemanticsVerified:false,dependencyRows:[row],dependencyRowCount:1,procedureCount:1});
10 test('catalog evidence remains NO-GO',()=>{const r=assessProcedureDependencies(fixture());assert.equal(r.status,'CATALOG_ONLY');assert.equal(r.productionWriteGate,'NO-GO');assert.deepEqual(r.referencedTables,['FACTURE']);});
11 test('rejects fabricated completeness and wrong database',()=>{for(const patch of [{dependencyCoverageComplete:true},{database:'Holoo1'},{financialSemanticsVerified:true},{dynamicSqlAndIndirectCallsUnresolved:false}])assert.equal(assessProcedureDependencies({...fixture(),...patch}).status,'INVALID_EVIDENCE');});
12 -test('rejects inconsistent counts and malformed rows',()=>{for(const patch of [{dependencyRowCount:2},{procedureCount:2},{dependencyRows:[{...row,referenced_entity_name:'UNKNOWN'}]},{dependencyRows:[{...row,referenced_minor_id:-1}]}])assert.equal(assessProcedureDependencies({...fixture(),...patch}).status,'INVALID_EVIDENCE');});
12 +test('rejects inconsistent counts and malformed rows',()=>{for(const patch of [{dependencyRowCount:2},{procedureCount:2},{dependencyRowCount:-1},{procedureCount:-1},{dependencyRows:[],dependencyRowCount:0,procedureCount:0},{dependencyRows:[{...row,referenced_entity_name:'UNKNOWN'}]},{dependencyRows:[{...row,referenced_minor_id:-1}]}])assert.equal(assessProcedureDependencies({...fixture(),...patch}).status,'INVALID_EVIDENCE');});
13 test('reports ambiguous dependencies without declaring semantic proof',()=>{const r=assessProcedureDependencies({...fixture(),dependencyRows:[{...row,is_ambiguous:1}]});assert.equal(r.ambiguousOrCallerDependent.length,1);assert.equal(r.financialSemanticsVerified,false);});
14 test('real LAB dependency catalog is structurally consistent', {skip:process.platform!=='win32'||process.env.HOLOO_SQL_INTEGRATION!=='1'},()=>{const script=fileURLToPath(new URL('../scripts/holoo-financial-procedure-dependencies.ps1',import.meta.url));const result=spawnSync('powershell.exe',['-NoProfile','-NonInteractive','-ExecutionPolicy','Bypass','-File',script,'-Json'],{encoding:'utf8',timeout:30000,maxBuffer:4*1024*1024});assert.equal(result.status,0,result.stderr);const assessment=assessProcedureDependencies(JSON.parse(result.stdout));assert.equal(assessment.status,'CATALOG_ONLY',JSON.stringify(assessment));assert.equal(assessment.productionWriteGate,'NO-GO');});