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

test(holoo): emit explicit production write NO-GO gate

Davood Mehraban committed Nov 22, 2026 at 21:24 UTC 44fdfe158c794439f56b838304c105f38be56d24
2 files changed +8 -1
scripts/holoo-schema-audit.ps1
+4 -1
@@ -48,7 +48,9 @@ try {
48 $procedures += [pscustomobject]@{name=$r.GetString(0);usesCursor=($definition -match '(?i)\bCURSOR\b');hasUpdateLock=($definition -match '(?i)\bUPDLOCK\b');hasSerializable=($definition -match '(?i)\bSERIALIZABLE\b');hasBeginTransaction=($definition -match '(?i)\bBEGIN\s+TRAN(?:SACTION)?\b');readsLastInvoiceNumber=($definition -match '(?is)FETCH\s+LAST\s+FROM\s+FacCursor');insertsInvoiceHeader=($definition -match '(?is)INSERT\s+INTO\s+Facture\s*\(');allocatesNumberWithoutVisibleLock=([bool](($definition -match '(?is)FETCH\s+LAST\s+FROM\s+FacCursor') -and ($definition -match '(?is)INSERT\s+INTO\s+Facture\s*\(') -and ($definition -notmatch '(?i)\bUPDLOCK\b|\bSERIALIZABLE\b|\bBEGIN\s+TRAN(?:SACTION)?\b')))}
49 }
50 } finally {$r.Close()}
51 - $result=[pscustomobject]@{schemaVersion=1;database='HolooBackup_050808_LAB_20261110';readOnlyAudit=$true;tables=$tables;integrity=$integrity;procedureConcurrencySignals=$procedures;complete=($tables.Count -eq 3 -and $procedures.Count -eq 3);note='Candidate sentinel classification is unverified; raw orphan count retained. No application-level invariants or concurrency claims'}
51 + $riskProcedures=@($procedures | Where-Object {$_.allocatesNumberWithoutVisibleLock} | ForEach-Object {$_.name})
52 + $gate=[pscustomobject]@{productionWritesAuthorized=$false;status='NO-GO';blockingReasons=@('No controlled concurrent invoice insertion test has been completed','No verified transaction rollback and inventory/accounting reconciliation evidence exists') + $(if($riskProcedures.Count -gt 0){@('Potential read-last-then-insert race in: '+($riskProcedures -join ', '))}else{@()});evidenceLevel='static SQL definition and read-only lab data audit only'}
53 + $result=[pscustomobject]@{schemaVersion=1;database='HolooBackup_050808_LAB_20261110';readOnlyAudit=$true;tables=$tables;integrity=$integrity;procedureConcurrencySignals=$procedures;productionWriteGate=$gate;complete=($tables.Count -eq 3 -and $procedures.Count -eq 3);note='Candidate sentinel classification is unverified; raw orphan count retained. No application-level invariants or concurrency claims'}
54 if($Json){$result|ConvertTo-Json -Depth 6}else{$tables|Format-Table -AutoSize;Write-Output ('COMPLETE='+$result.complete)}
55 if(-not $result.complete){exit 2}
56 } finally {$c.Dispose()}
@@ -58,3 +60,4 @@ try {
60
61
62
63 +
tests/holoo-schema-audit.test.mjs
+4
@@ -20,6 +20,9 @@ test('real lab structural audit returns three complete primary-keyed tables', {s
20 const audit = JSON.parse(result.stdout);
21 assert.equal(audit.complete, true);
22 assert.equal(audit.readOnlyAudit, true);
23 + assert.equal(audit.productionWriteGate.status, 'NO-GO');
24 + assert.equal(audit.productionWriteGate.productionWritesAuthorized, false);
25 + assert.ok(audit.productionWriteGate.blockingReasons.length >= 2);
26 for (const key of ['invoiceHeaders','invoiceLines','accountingDocuments','orphanInvoiceLines']) assert.ok(Number.isSafeInteger(audit.integrity[key]) && audit.integrity[key] >= 0, key);
27 assert.ok(audit.integrity.orphanInvoiceLines <= audit.integrity.invoiceLines);
28 for(const key of ['orphanInvoiceLinesExcludingCandidateSentinel','candidateSentinelRows','missingReferencedAccountingDocuments','duplicateInvoiceTypeNumberGroups','invoiceHeadersWithoutAccountingCode']) assert.ok(Number.isSafeInteger(audit.integrity[key]) && audit.integrity[key] >= 0, key);
@@ -38,3 +41,4 @@ test('real lab structural audit returns three complete primary-keyed tables', {s
41
42
43
44 +