سامانه صدور فاکتور و حسابداری

Add Office C7 invariant coverage

davoodmehraban89 committed Oct 1, 2026 at 00:22 UTC 05a044d22f0d5479871afcd3fc4d27264f51b9c4
1 file changed +21
scripts/office-slice-c7-check.mjs new
+21
@@ -0,0 +1,21 @@
1 +import fs from 'node:fs';import path from 'node:path';
2 +const need=(t,r,l)=>{if(!r.test(t))throw new Error('Office C7 invariant missing: '+l)};
3 +const dir=path.join(process.cwd(),'supabase','migrations');
4 +const files=fs.readdirSync(dir).filter(x=>/office_slice_c7_.*\.sql$/.test(x));
5 +if(!files.length)throw new Error('Office C7 invariant missing: archive/OCR migration');
6 +const m=files.map(x=>fs.readFileSync(path.join(dir,x),'utf8')).join('\n');
7 +need(m,/office_record_ocr_text/i,'OCR evidence RPC');
8 +need(m,/ocr_text_recorded/i,'append-only OCR evidence');
9 +need(m,/human_correction/i,'human correction lineage');
10 +need(m,/previousOcrEventId/i,'correction parent evidence');
11 +need(m,/office_latest_ocr_text/i,'latest OCR RPC');
12 +need(m,/office_archive_full_text_search/i,'ranked archive search RPC');
13 +need(m,/websearch_to_tsquery\('simple'/i,'user-facing full-text query');
14 +need(m,/to_tsvector\('simple'/i,'Persian-safe simple token vector');
15 +need(m,/security invoker/i,'public invoker boundary');
16 +need(m,/accuracy.*unverified|no.*accuracy/i,'real OCR accuracy boundary');
17 +const ui=fs.readFileSync('js/office-mature.js','utf8');
18 +need(ui,/officeRecordOcrText/i,'OCR provenance UI');
19 +need(ui,/officeCorrectOcrText/i,'OCR correction UI');
20 +need(ui,/office_archive_full_text_search/i,'archive UI uses C7 search');
21 +console.log('Office Slice C7 full-text/OCR provenance contract: PASS');