فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(holoo): require structural audit evidence for lab reads
Davood Mehraban committed
Nov 22, 2026 at 21:36 UTC
a8a8f8522d1b7ff20e9b0654c6bd173e6869bb55
2 files changed
+5
-3
src/holoo-write-policy.cjs
+2
-1
@@ -3,7 +3,8 @@
3
function evaluateHolooWrite({ operation, database, audit } = {}) {
4
if (operation !== 'read') return Object.freeze({ allowed: false, reason: 'Holoo writes are not authorized: no behavioral/concurrency acceptance evidence' });
5
if (database !== 'HolooBackup_050808_LAB_20261110') return Object.freeze({ allowed: false, reason: 'Only the approved backup lab may be read through this policy' });
6
- if (!audit || audit.readOnlyAudit !== true || audit.complete !== true || audit.database !== database || audit.productionWriteGate?.status !== 'NO-GO' || audit.productionWriteGate?.productionWritesAuthorized !== false) return Object.freeze({ allowed: false, reason: 'Verified lab audit is required' });
6
+ if (!audit || audit.readOnlyAudit !== true || audit.complete !== true || audit.database !== database || audit.schemaVersion !== 1 || !Array.isArray(audit.tables) || !['FACTART','FACTURE','SANAD'].every(name => audit.tables.some(table => table.table === name && table.primaryKeys === 1)) || !Array.isArray(audit.procedureConcurrencySignals) || !['InsertInFacture','InsertInFactureCode'].every(name => audit.procedureConcurrencySignals.some(proc => proc.name === name && proc.allocatesNumberWithoutVisibleLock === true)) || audit.productionWriteGate?.status !== 'NO-GO' || audit.productionWriteGate?.productionWritesAuthorized !== false) return Object.freeze({ allowed: false, reason: 'Verified lab audit is required' });
7
return Object.freeze({ allowed: true, reason: 'Read-only approved lab operation' });
8
}
9
module.exports = { evaluateHolooWrite };
10
+
tests/holoo-write-policy.test.mjs
+3
-2
@@ -4,7 +4,7 @@ import { createRequire } from 'node:module';
4
const require = createRequire(import.meta.url);
5
const { evaluateHolooWrite } = require('../src/holoo-write-policy.cjs');
6
const database = 'HolooBackup_050808_LAB_20261110';
7
-const audit = { database, readOnlyAudit: true, complete: true, productionWriteGate: { status: 'NO-GO', productionWritesAuthorized: false } };
7
+const audit = { database, schemaVersion: 1, tables: ['FACTART','FACTURE','SANAD'].map(table => ({table,primaryKeys:1})), procedureConcurrencySignals: ['InsertInFacture','InsertInFactureCode'].map(name => ({name,allocatesNumberWithoutVisibleLock:true})), readOnlyAudit: true, complete: true, productionWriteGate: { status: 'NO-GO', productionWritesAuthorized: false } };
8
test('deny all write attempts even with approved lab audit', () => {
9
for (const operation of ['insert','update','delete','execute','write',undefined]) assert.equal(evaluateHolooWrite({ operation, database, audit }).allowed, false);
10
});
@@ -12,8 +12,9 @@ test('deny production database even for reads', () => {
12
assert.equal(evaluateHolooWrite({ operation:'read', database:'Holoo1', audit }).allowed, false);
13
});
14
test('deny missing or malformed audit', () => {
15
- for (const bad of [undefined, {}, {...audit,complete:false}, {...audit,productionWriteGate:{status:'GO',productionWritesAuthorized:true}}]) assert.equal(evaluateHolooWrite({ operation:'read', database, audit:bad }).allowed, false);
15
+ for (const bad of [undefined, {}, {...audit,complete:false}, {...audit,tables:[]}, {...audit,procedureConcurrencySignals:[]}, {...audit,schemaVersion:2}, {...audit,productionWriteGate:{status:'GO',productionWritesAuthorized:true}}]) assert.equal(evaluateHolooWrite({ operation:'read', database, audit:bad }).allowed, false);
16
});
17
test('allow only audited approved lab read operation', () => {
18
assert.equal(evaluateHolooWrite({ operation:'read', database, audit }).allowed, true);
19
});
20
+