uslap commited on
Commit
7cc8e29
·
verified ·
1 Parent(s): 0067ef0

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +15 -0
  2. Code_files/.DS_Store +0 -0
  3. Code_files/.db_sync_state +1 -0
  4. Code_files/.stop_hook_errors.log +0 -0
  5. Code_files/.uslap_init_lock +1 -0
  6. Code_files/CONSOLIDATION_ISSUES.md +75 -0
  7. Code_files/MIGRATION_GUIDE.md +418 -0
  8. Code_files/SESSION_44_PROMPT.md +127 -0
  9. Code_files/SESSION_47_HANDOFF.md +143 -0
  10. Code_files/__pycache__/USLaP_Engine.cpython-314.pyc +3 -0
  11. Code_files/__pycache__/amr_al_masudi.cpython-314.pyc +0 -0
  12. Code_files/__pycache__/amr_algorithm_audit.cpython-314.pyc +0 -0
  13. Code_files/__pycache__/amr_algorithm_repair.cpython-314.pyc +0 -0
  14. Code_files/__pycache__/amr_alphabet.cpython-314.pyc +0 -0
  15. Code_files/__pycache__/amr_alphabet_i18n_export.cpython-314.pyc +0 -0
  16. Code_files/__pycache__/amr_aql.cpython-314.pyc +3 -0
  17. Code_files/__pycache__/amr_ard.cpython-314.pyc +0 -0
  18. Code_files/__pycache__/amr_basar.cpython-314.pyc +0 -0
  19. Code_files/__pycache__/amr_bitig_alphabet.cpython-314.pyc +0 -0
  20. Code_files/__pycache__/amr_bitig_tasrif.cpython-314.pyc +0 -0
  21. Code_files/__pycache__/amr_cli.cpython-314.pyc +0 -0
  22. Code_files/__pycache__/amr_dereference_audit.cpython-314.pyc +0 -0
  23. Code_files/__pycache__/amr_dhakaa.cpython-314.pyc +0 -0
  24. Code_files/__pycache__/amr_emitter.cpython-314.pyc +0 -0
  25. Code_files/__pycache__/amr_hisab.cpython-314.pyc +0 -0
  26. Code_files/__pycache__/amr_ibn_hawqal.cpython-314.pyc +0 -0
  27. Code_files/__pycache__/amr_intake.cpython-314.pyc +0 -0
  28. Code_files/__pycache__/amr_istakhbarat.cpython-314.pyc +0 -0
  29. Code_files/__pycache__/amr_jism.cpython-314.pyc +0 -0
  30. Code_files/__pycache__/amr_keywords.cpython-314.pyc +0 -0
  31. Code_files/__pycache__/amr_khordadbeh.cpython-314.pyc +0 -0
  32. Code_files/__pycache__/amr_lawh.cpython-314.pyc +0 -0
  33. Code_files/__pycache__/amr_lexer.cpython-314.pyc +0 -0
  34. Code_files/__pycache__/amr_nasij.cpython-314.pyc +0 -0
  35. Code_files/__pycache__/amr_neighbourhood_expander.cpython-314.pyc +0 -0
  36. Code_files/__pycache__/amr_nutq.cpython-314.pyc +0 -0
  37. Code_files/__pycache__/amr_output_templates.cpython-314.pyc +0 -0
  38. Code_files/__pycache__/amr_parser.cpython-314.pyc +0 -0
  39. Code_files/__pycache__/amr_quf.cpython-314.pyc +0 -0
  40. Code_files/__pycache__/amr_runtime.cpython-314.pyc +0 -0
  41. Code_files/__pycache__/amr_tarikh.cpython-314.pyc +0 -0
  42. Code_files/__pycache__/amr_tarjama.cpython-314.pyc +0 -0
  43. Code_files/__pycache__/amr_tasrif.cpython-314.pyc +0 -0
  44. Code_files/__pycache__/amr_uzbek.cpython-314.pyc +0 -0
  45. Code_files/__pycache__/batch_runner.cpython-314.pyc +0 -0
  46. Code_files/__pycache__/batch_runner_ru.cpython-314.pyc +0 -0
  47. Code_files/__pycache__/ocr_dot_disambiguator.cpython-314.pyc +0 -0
  48. Code_files/__pycache__/sibaha_audit.cpython-314.pyc +0 -0
  49. Code_files/__pycache__/uslap.cpython-314.pyc +0 -0
  50. Code_files/__pycache__/uslap_compiler.cpython-314.pyc +0 -0
.gitattributes CHANGED
@@ -33,3 +33,18 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ Code_files/__pycache__/USLaP_Engine.cpython-314.pyc filter=lfs diff=lfs merge=lfs -text
37
+ Code_files/__pycache__/amr_aql.cpython-314.pyc filter=lfs diff=lfs merge=lfs -text
38
+ Code_files/__pycache__/uslap_quf.cpython-314.pyc filter=lfs diff=lfs merge=lfs -text
39
+ Code_files/backups/uslap_database_v3_pre_aa_migration_20260329_1306.db filter=lfs diff=lfs merge=lfs -text
40
+ Code_files/backups/uslap_v3_backup_20260316_035513.db filter=lfs diff=lfs merge=lfs -text
41
+ Code_files/backups/uslap_v3_backup_20260316_040701.db filter=lfs diff=lfs merge=lfs -text
42
+ Code_files/backups/uslap_v3_backup_20260316_162512.db filter=lfs diff=lfs merge=lfs -text
43
+ Code_files/backups/uslap_v3_backup_20260318_063949.db filter=lfs diff=lfs merge=lfs -text
44
+ Code_files/backups/uslap_v3_backup_20260327_134853.db filter=lfs diff=lfs merge=lfs -text
45
+ Code_files/backups/uslap_v3_pre_strip_20260328_073602.db filter=lfs diff=lfs merge=lfs -text
46
+ Code_files/uslap_database.db filter=lfs diff=lfs merge=lfs -text
47
+ Code_files/uslap_database_v3.db filter=lfs diff=lfs merge=lfs -text
48
+ Code_files/uslap_database_v3_OLD.db filter=lfs diff=lfs merge=lfs -text
49
+ Code_files/uslap_database_v3_pre_v4.db filter=lfs diff=lfs merge=lfs -text
50
+ Code_files/uslap_lattice.db filter=lfs diff=lfs merge=lfs -text
Code_files/.DS_Store ADDED
Binary file (6.15 kB). View file
 
Code_files/.db_sync_state ADDED
@@ -0,0 +1 @@
 
 
1
+ 4fa516ae7aff11b6e221bd1f65739df4
Code_files/.stop_hook_errors.log ADDED
File without changes
Code_files/.uslap_init_lock ADDED
@@ -0,0 +1 @@
 
 
1
+
Code_files/CONSOLIDATION_ISSUES.md ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Schema Consolidation — Issues Found (2026-03-27)
2
+
3
+ ## Status: BLOCKED — needs fixes before re-run
4
+
5
+ Backup: `backups/v3_pre_consolidation_20260327_1643.db` (85MB)
6
+ DB restored to pre-consolidation state. All other session work intact.
7
+
8
+ ## Blocker 1: PK Conflicts on RU Mirror Tables
9
+
10
+ RU tables use the SAME primary keys as EN tables (they're translations, not new data):
11
+ - `a2_имена_аллаха`: allah_id 1-99 = same as `names_of_allah` allah_id 1-99
12
+ - `a4_производные`: deriv_id = same as `a4_derivatives` deriv_id
13
+ - `a5_перекрёстные_ссылки`: xref_id = same as `a5_cross_refs` xref_id
14
+
15
+ **Fix options:**
16
+ 1. **UPDATE existing rows** — add RU content to the EN row (e.g., add `ru_meaning` column to `names_of_allah`). Preserves PK.
17
+ 2. **Offset PKs** — insert RU rows with PK + 100000 offset. Avoids conflict but breaks ID meaning.
18
+ 3. **Separate lang column** — generate NEW integer PKs for RU rows, add `lang='RU'` column. Original RU PK stored in `orig_ru_id` column.
19
+
20
+ **Recommended: Option 1** for Names of Allah (same 99 names, just add RU fields). **Option 3** for derivatives/cross-refs (genuinely different data rows).
21
+
22
+ ## Blocker 2: Orphaned Views
23
+
24
+ Several views reference tables that don't exist or have been renamed:
25
+ - `m1_phonetic_shifts` → references `phonetic_shifts` (doesn't exist — data is in `shift_lookup`)
26
+ - `a3_quran_refs` → is a VIEW, not a table
27
+ - `a6_country_names` → is a VIEW, not a table
28
+ - `a1_записи` → is a VIEW (data already in `entries`)
29
+ - `a1_entries` → is a VIEW
30
+
31
+ **Fix:** Drop orphaned views BEFORE dropping triggers. Current script drops triggers first, which causes ALTER TABLE to fail when it touches a table referenced by a view.
32
+
33
+ **Correct order:**
34
+ 1. Save all triggers + views (SQL)
35
+ 2. Drop ALL views
36
+ 3. Drop ALL triggers
37
+ 4. Run migration
38
+ 5. Recreate views (new definitions)
39
+ 6. Recreate triggers (only for surviving tables)
40
+
41
+ ## Blocker 3: UNIQUE Constraints from Hardening
42
+
43
+ `harden_v4_schema.py` added UNIQUE indexes:
44
+ - `uq_entries_en_root` on `entries(en_term, root_id)`
45
+ - `uq_bitig_orig2` on `bitig_a1_entries(orig2_term, root_letters)`
46
+ - `uq_eu_lang_term` on `european_a1_entries(lang, term)`
47
+ - `uq_lat_term` on `latin_a1_entries(lat_term)`
48
+ - `uq_roots_letters` on `roots(root_letters)`
49
+
50
+ These may block RU data insertion if values collide. Need to check each before INSERT.
51
+
52
+ ## Migration Script
53
+
54
+ `consolidate_v5_clean.py` — handles Phases 1-3 but needs the above fixes.
55
+ `consolidate_schema_v5.py` — original version, same issues.
56
+
57
+ ## What Was Completed This Session
58
+
59
+ 1. Domain-specific QUF (12 lattice layers) — 97% pass, 102K rows, 27 tables
60
+ 2. Extended QUF to 130 remaining tables — 40% pass
61
+ 3. 4 new AMR AI modules (jism, hisab, tarikh, istakhbarat) — all with domain QUF colours
62
+ 4. Schema hardening (indexes, views, health check)
63
+ 5. amr_lawh.py QUF filtering wired
64
+ 6. Automated backup script created
65
+ 7. Banned term "theological" removed from all code
66
+ 8. 12-layer lattice architecture defined (replaces 8 academic categories)
67
+
68
+ ## Next Session: Consolidation
69
+
70
+ 1. Fix Blocker 1: per-table PK strategy (UPDATE for names, new PKs for derivatives)
71
+ 2. Fix Blocker 2: drop views BEFORE triggers
72
+ 3. Fix Blocker 3: handle UNIQUE constraints
73
+ 4. Re-run consolidation
74
+ 5. Update code references (amr_jism.py, uslap_quf.py, uslap_handler.py, etc.)
75
+ 6. Re-run domain QUF on consolidated structure
Code_files/MIGRATION_GUIDE.md ADDED
@@ -0,0 +1,418 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # USLaP Database Migration Guide
2
+
3
+ **بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ**
4
+
5
+ This guide provides step-by-step instructions for migrating data from the Excel master file to the full USLaP SQLite relational database. The migration creates a normalized schema designed for world-vocabulary scale (target: 25,000+ entries, 1M+ searchable objects).
6
+
7
+ ## Overview
8
+
9
+ The migration process:
10
+ 1. Creates a fresh SQLite database with the full relational schema (`uslap_lattice.db`)
11
+ 2. Reads data from structured Excel sheets (skips the consolidated echo sheet)
12
+ 3. Normalizes data into proper relational tables with foreign key relationships
13
+ 4. Registers the `extract_consonants()` Python UDF for phonetic search
14
+ 5. Generates the `word_fingerprints` table for O(log n) cluster expansion
15
+ 6. Creates backups of any existing databases
16
+ 7. Verifies data integrity and foreign key constraints
17
+
18
+ ## Prerequisites
19
+
20
+ ### Required Files
21
+ - `USLaP_Final_Data_Consolidated_Master_v3.xlsx` – Master Excel file (in workplace root)
22
+ - `create_uslap_db.sql` – Complete SQLite schema (in `Code_files/`)
23
+ - `migrate_to_sqlite.py` – Migration script (in `Code_files/`)
24
+ - `USLaP_Engine.py` – Contains consonant extraction logic (in `Code_files/`)
25
+
26
+ ### Python Dependencies
27
+ ```bash
28
+ pip install openpyxl
29
+ ```
30
+ The script requires Python 3.6+ and the `openpyxl` library for reading Excel files. All other dependencies are in the Python standard library.
31
+
32
+ ## Running the Migration
33
+
34
+ ### Step 1: Verify File Locations
35
+ Ensure all files are in the correct locations:
36
+ ```
37
+ USLaP workplace/
38
+ ├── USLaP_Final_Data_Consolidated_Master_v3.xlsx
39
+ └── Code_files/
40
+ ├── create_uslap_db.sql
41
+ ├── migrate_to_sqlite.py
42
+ ├── USLaP_Engine.py
43
+ └── [existing .db files]
44
+ ```
45
+
46
+ ### Step 2: Run the Migration Script
47
+ From the `USLaP workplace` directory, run:
48
+ ```bash
49
+ cd "/Users/mmsetubal/Documents/USLaP workplace"
50
+ python3 "Code_files/migrate_to_sqlite.py"
51
+ ```
52
+
53
+ **Important Notes:**
54
+ - The script will automatically create a backup of any existing `uslap_lattice.db` file
55
+ - Migration may take 1-2 minutes depending on Excel file size
56
+ - All operations are wrapped in a transaction; on failure, the database is rolled back
57
+
58
+ ### Step 3: Monitor Migration Output
59
+ The script provides real-time progress:
60
+ ```
61
+ ══════════════════════════════════════════════════════════════════════
62
+ USLaP Migration: Excel → SQLite Relational Database
63
+ بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ
64
+ ══════════════════════════════════════════════════════════════════════
65
+
66
+ 📖 Loading Excel file: USLaP_Final_Data_Consolidated_Master_v3.xlsx
67
+ Found 62 sheets
68
+
69
+ 🗄️ Creating database: Code_files/uslap_lattice.db
70
+ Executing schema...
71
+ Registering extract_consonants() UDF...
72
+
73
+ 📊 Migrating data...
74
+ Migrating A1_ENTRIES...
75
+ Migrated 59 entries
76
+ Migrating A1_ЗАПИСИ (Russian entries)...
77
+ Migrated 0 entries
78
+ [Additional sheets...]
79
+
80
+ 📈 Migration Statistics:
81
+ ────────────────────────────────────────
82
+ Total entries: 59
83
+ Total roots: 0
84
+ Child entries: 3
85
+ Word fingerprints: 6
86
+ Engine queue items: 0
87
+
88
+ 🔍 Verifying foreign key constraints...
89
+ ✓ All foreign key constraints satisfied
90
+
91
+ ══════════════════════════════════════════════════════════════════════
92
+ ✅ MIGRATION COMPLETED SUCCESSFULLY
93
+ ✅ Database: Code_files/uslap_lattice.db
94
+ ══════════════════════════════════════════════════════════════════════
95
+ ```
96
+
97
+ ## Verification Steps
98
+
99
+ ### Verify Database Structure
100
+ After migration, verify all tables were created:
101
+ ```bash
102
+ sqlite3 "Code_files/uslap_lattice.db" ".tables"
103
+ ```
104
+
105
+ Expected output (30+ tables):
106
+ ```
107
+ child_entries decay_levels operation_cycles
108
+ child_entry_links derivatives operators
109
+ cluster_cache detection_patterns operator_aliases
110
+ country_names engine_queue operation_codes
111
+ cross_refs entries phonetic_mappings
112
+ change_log events phonetic_shifts
113
+ dp_codes host_civilizations quran_refs
114
+ intel_reports languages roots
115
+ names_of_allah networks scholars
116
+ nt_codes op_codes script_corridors
117
+ qur_verification session_index sync_status
118
+ word_fingerprints
119
+ ```
120
+
121
+ ### Verify Row Counts
122
+ Run the verification queries in the database:
123
+ ```sql
124
+ -- Check entry counts
125
+ SELECT 'entries' as tbl, COUNT(*) FROM entries
126
+ UNION ALL SELECT 'roots', COUNT(*) FROM roots
127
+ UNION ALL SELECT 'derivatives', COUNT(*) FROM derivatives
128
+ UNION ALL SELECT 'cross_refs', COUNT(*) FROM cross_refs
129
+ UNION ALL SELECT 'child_entries', COUNT(*) FROM child_entries
130
+ UNION ALL SELECT 'word_fingerprints', COUNT(*) FROM word_fingerprints;
131
+
132
+ -- Check FK integrity
133
+ PRAGMA integrity_check;
134
+ PRAGMA foreign_key_check;
135
+
136
+ -- Check fingerprint coverage
137
+ SELECT COUNT(DISTINCT entry_id) as entries_with_fingerprints FROM word_fingerprints;
138
+ ```
139
+
140
+ **Expected Results:**
141
+ - `entries`: ~390–404 entries total across all languages
142
+ - `roots`: ~200 unique roots
143
+ - `derivatives`: ~632 word forms
144
+ - `cross_refs`: ~155 relationships
145
+ - `child_entries`: ~12 operational intelligence entries
146
+ - `word_fingerprints`: ~1,400+ entries (covers all searchable terms)
147
+
148
+ ### Test the UDF Function
149
+ Verify the `extract_consonants()` function works:
150
+ ```bash
151
+ sqlite3 "Code_files/uslap_lattice.db" "SELECT extract_consonants('example')"
152
+ ```
153
+ Expected output: `xmpl`
154
+
155
+ ### Test Basic Queries
156
+ ```sql
157
+ -- Get entries with high confidence scores
158
+ SELECT entry_id, en_term, score FROM entries WHERE score >= 8 ORDER BY score DESC LIMIT 10;
159
+
160
+ -- Test phonetic search via word_fingerprints
161
+ SELECT wf.raw_word, wf.consonant_skeleton, e.en_term, e.score
162
+ FROM word_fingerprints wf
163
+ LEFT JOIN entries e ON wf.entry_id = e.entry_id
164
+ WHERE wf.consonant_skeleton = extract_consonants('test')
165
+ LIMIT 5;
166
+
167
+ -- View operational intelligence (CHILD schema)
168
+ SELECT child_id, shell_name, operation_role, parent_op FROM child_entries;
169
+ ```
170
+
171
+ ## Database Schema Details
172
+
173
+ ### Critical Tables for Engine Operations
174
+
175
+ #### 1. `word_fingerprints` – Phonetic Search Index
176
+ The most critical table for performance. Enables O(log n) cluster expansion via the composite index on `(consonant_skeleton, language)`.
177
+
178
+ **Triggers:** Automatic population when entries/derivatives/child entries are inserted or updated.
179
+
180
+ **Index:** `idx_fingerprints_lookup` enables instant phonetic matching.
181
+
182
+ #### 2. `engine_queue` – Write Conflict Prevention
183
+ Prevents direct writes from the engine to core tables. All proposed changes go through this queue for user approval via the Oversight Dashboard.
184
+
185
+ **Purpose:** Maintains Excel as the primary write interface while enabling engine proposals.
186
+
187
+ #### 3. `session_index` – Engine Session Tracking
188
+ Tracks every engine run with performance metrics and error logging.
189
+
190
+ #### 4. `child_entries` & `child_entry_links` – Operational Intelligence
191
+ CHILD schema integration links operational intelligence (SLV, SQLB, RUS entries) with main A1 entries.
192
+
193
+ ### Foreign Key Enforcement
194
+ Foreign keys are strictly enforced (`PRAGMA foreign_keys = ON`). The migration script temporarily disables them during data insertion to avoid constraint violations, then re-enables and verifies all constraints.
195
+
196
+ ## Python UDF: `extract_consonants()`
197
+
198
+ ### Registration
199
+ The UDF is automatically registered on every database connection via:
200
+ ```python
201
+ conn.create_function("extract_consonants", 1, extract_consonants)
202
+ ```
203
+
204
+ **CRITICAL:** Must be registered BEFORE any INSERT operations or trigger execution.
205
+
206
+ ### Implementation
207
+ The function extracts consonant skeletons from words:
208
+ - Removes vowels (a, e, i, o, u)
209
+ - Handles digraphs (sh, ch, gh, th, ph, wh, qu) as single units
210
+ - Normalizes to lowercase
211
+ - Returns empty string for null/empty input
212
+
213
+ **Source:** Logic matches `PhoneticReversal.extract_consonants()` in `USLaP_Engine.py`.
214
+
215
+ ### SQL Triggers Using the UDF
216
+ The schema includes triggers that automatically populate `word_fingerprints`:
217
+ ```sql
218
+ CREATE TRIGGER update_fingerprints_on_entry_insert
219
+ AFTER INSERT ON entries
220
+ BEGIN
221
+ INSERT INTO word_fingerprints (entry_id, language, raw_word, consonant_skeleton)
222
+ SELECT NEW.entry_id, 'en', NEW.en_term, extract_consonants(NEW.en_term)
223
+ WHERE NEW.en_term IS NOT NULL AND NEW.en_term != '';
224
+ -- ... similar for ru_term, fa_term, ar_word
225
+ END;
226
+ ```
227
+
228
+ ## Excel ↔ Database Sync Strategy
229
+
230
+ ### Current Architecture
231
+ - **Excel is primary write interface:** All user-facing writes go through Excel
232
+ - **Database is read/query layer:** Engine reads from database, proposes changes via queue
233
+ - **Sync direction:** Excel → Database (one-way during migration)
234
+
235
+ ### Maintaining Sync
236
+ After migration, keep databases in sync:
237
+
238
+ 1. **Engine proposals:** When USLaP_Engine.py detects new patterns, it writes to `engine_queue`
239
+ 2. **User approval:** User reviews proposals in Oversight Dashboard (`USLaP_Oversight_Dashboard.html`)
240
+ 3. **Approved changes:** User applies approved changes to Excel manually
241
+ 4. **Re-sync:** Run migration script periodically to update database with Excel changes
242
+
243
+ ### Migration Script Updates
244
+ The `migrate_to_sqlite.py` script can be re-run at any time. It will:
245
+ 1. Create timestamped backup of existing database
246
+ 2. Start fresh with current Excel data
247
+ 3. Preserve any `engine_queue` items that haven't been processed
248
+
249
+ ## Switching USLaP_Engine.py to SQLite Reads
250
+
251
+ ### Current State
252
+ `USLaP_Engine.py` currently reads directly from Excel via openpyxl.
253
+
254
+ ### Target State
255
+ Update `USLaP_Engine.py` to use the database access layer (`db_access_layer.py`) for:
256
+ 1. Entry lookups (instead of reading Excel sheets)
257
+ 2. Phonetic search (using `word_fingerprints` table)
258
+ 3. Cluster expansion (O(log n) via indexed searches)
259
+ 4. Queue operations (proposing changes via `engine_queue`)
260
+
261
+ ### Implementation Steps
262
+ 1. Import `db_access_layer` module
263
+ 2. Replace Excel reading with database queries:
264
+ ```python
265
+ # Old: reading from Excel
266
+ # New: using database
267
+ from db_access_layer import search_word, PhoneticSearchOperations
268
+
269
+ results = search_word("example")
270
+ similar = PhoneticSearchOperations.find_similar_words("example", conn)
271
+ ```
272
+ 3. Update cluster expansion to use `word_fingerprints` index
273
+ 4. Route all proposed changes through `engine_queue` instead of direct writes
274
+
275
+ ### Performance Benefits
276
+ - **Phonetic search:** O(log n) vs O(n) linear scan
277
+ - **Cluster expansion:** Instant via pre-computed fingerprints
278
+ - **Memory usage:** Database queries vs loading entire Excel file
279
+ - **Concurrency:** Multiple engine sessions can query simultaneously
280
+
281
+ ## Troubleshooting
282
+
283
+ ### Common Issues
284
+
285
+ #### 1. "Excel file not found"
286
+ **Solution:** Ensure `USLaP_Final_Data_Consolidated_Master_v3.xlsx` is in the workplace root directory.
287
+
288
+ #### 2. "Schema file not found"
289
+ **Solution:** Ensure `create_uslap_db.sql` is in `Code_files/` directory.
290
+
291
+ #### 3. Foreign key constraint violations
292
+ **Solution:** The migration script temporarily disables foreign keys during insertion. If errors persist:
293
+ ```bash
294
+ sqlite3 "Code_files/uslap_lattice.db" "PRAGMA foreign_key_check"
295
+ ```
296
+ Check for circular dependencies or missing reference data.
297
+
298
+ #### 4. UDF not registered
299
+ **Solution:** Ensure `extract_consonants()` is registered before any inserts. The migration script does this automatically. For custom connections, use:
300
+ ```python
301
+ from migrate_to_sqlite import extract_consonants
302
+ conn.create_function("extract_consonants", 1, extract_consonants)
303
+ ```
304
+
305
+ #### 5. Low row counts after migration
306
+ **Possible causes:**
307
+ - Excel sheet names don't match expected names
308
+ - Header row detection failed
309
+ - Data is in unexpected format
310
+
311
+ **Debug:** Run the migration script with additional print statements or examine the Excel sheet structure.
312
+
313
+ ### Recovery Procedures
314
+
315
+ #### Database Corruption
316
+ If the database becomes corrupted:
317
+ 1. Restore from latest backup in `Code_files/backups/`
318
+ 2. Or re-run migration script (creates fresh database)
319
+
320
+ #### Failed Migration
321
+ If migration fails mid-process:
322
+ 1. Script automatically rolls back transaction
323
+ 2. Old database remains unchanged (if backup was created)
324
+ 3. Check error output for specific issue
325
+ 4. Fix underlying problem (Excel format, disk space, permissions)
326
+ 5. Re-run migration
327
+
328
+ #### Data Loss Prevention
329
+ - Migration always creates timestamped backups
330
+ - Excel master file remains unchanged (read-only during migration)
331
+ - Transaction rollback on any error
332
+
333
+ ## Performance Optimization
334
+
335
+ ### Index Usage
336
+ The schema includes optimal indexes for:
337
+ 1. **Phonetic search:** `idx_fingerprints_lookup` on `(consonant_skeleton, language)`
338
+ 2. **Root-based queries:** `idx_entries_root` on `entries(root_id)`
339
+ 3. **Score sorting:** `idx_entries_score` on `entries(score DESC)`
340
+ 4. **Full-text search:** FTS5 virtual table `entries_fts`
341
+
342
+ ### Query Patterns
343
+ For best performance:
344
+ - Use `word_fingerprints` for phonetic searches
345
+ - Use `entries_fts` for full-text keyword searches
346
+ - Use `cluster_cache` for repeated expansion of same roots
347
+ - Limit results with `LIMIT` clauses for UI responsiveness
348
+
349
+ ### Scaling Considerations
350
+ The schema is designed for 1M+ searchable objects. At that scale:
351
+ - Consider increasing SQLite cache size: `PRAGMA cache_size = -2000;` (2GB)
352
+ - Use WAL mode for concurrent reads: `PRAGMA journal_mode = WAL;`
353
+ - Regular VACUUM to maintain performance: `VACUUM;`
354
+
355
+ ## Appendix A: Migration Script Details
356
+
357
+ ### Sheets Migrated
358
+ The script reads from these structured sheets only:
359
+ - `A1_ENTRIES` – English entries
360
+ - `A1_ЗАПИСИ` – Russian entries
361
+ - `PERSIAN_A1_MADĀKHIL` – Persian entries
362
+ - `BITIG_A1_ENTRIES` – ORIG2/Turkic entries
363
+ - `CHILD_SCHEMA` – Operational intelligence
364
+ - `A4_DERIVATIVES` – Word forms
365
+ - `A5_CROSS_REFS` – Entry relationships
366
+ - `A3_QURAN_REFS` – Verse references
367
+ - `M1_PHONETIC_SHIFTS` – Phonetic mechanism
368
+ - `M2_DETECTION_PATTERNS` – Detection patterns
369
+ - `M4_NETWORKS` – Network definitions
370
+ - `M3_SCHOLARS` – Scholar biographies
371
+ - `M5_QUR_VERIFICATION` – Qur'an verification
372
+
373
+ ### Sheets Skipped
374
+ - `EXCEL_DATA_CONSOLIDATED` – Echo sheet (not a primary source)
375
+ - Various protocol, correction, and warning sheets
376
+
377
+ ### Data Flow
378
+ 1. Read Excel sheet → Clean column names → Map to schema → Insert
379
+ 2. Extract unique roots from entries → Create `roots` table entries
380
+ 3. Triggers automatically create `word_fingerprints`
381
+ 4. Verify foreign key integrity
382
+ 5. Commit transaction
383
+
384
+ ## Appendix B: Database Access Layer
385
+
386
+ The `db_access_layer.py` module provides:
387
+ - `DatabaseConnection` – Context manager for connections
388
+ - `EntryOperations`, `RootOperations` – CRUD operations
389
+ - `PhoneticSearchOperations` – O(log n) cluster expansion
390
+ - `EngineQueueOperations`, `SessionOperations` – Engine control
391
+ - `AnalyticsOperations` – Statistics and analysis
392
+ - High-level API functions: `search_word()`, `add_new_entry()`, `run_engine_session()`
393
+
394
+ ### Example Usage
395
+ ```python
396
+ from db_access_layer import search_word, get_connection, EntryOperations
397
+
398
+ # High-level search
399
+ results = search_word("example")
400
+ print(f"Found {len(results['exact_matches'])} exact matches")
401
+
402
+ # Direct operations
403
+ with get_connection() as conn:
404
+ entries = EntryOperations.get_high_score_entries(conn, min_score=8)
405
+ print(f"High-score entries: {len(entries)}")
406
+ ```
407
+
408
+ ## Support
409
+
410
+ For issues with migration:
411
+ 1. Check error messages in console output
412
+ 2. Verify file permissions and locations
413
+ 3. Ensure Excel file isn't open in another program
414
+ 4. Check Python version and openpyxl installation
415
+
416
+ To report bugs or request enhancements, use the project's issue tracking system.
417
+
418
+ **وَاللَّهُ أَعْلَمُ**
Code_files/SESSION_44_PROMPT.md ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SESSION 44 — Canon الواح Disease↔Cure Addressing System
2
+
3
+ ## بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ
4
+
5
+ ## MANDATORY FIRST ACTION
6
+ ```bash
7
+ python3 Code_files/uslap_session_init.py
8
+ ```
9
+
10
+ ---
11
+
12
+ ## WHERE SESSION 43 LEFT OFF
13
+
14
+ ### Canon Book 2 — EXTRACTION COMPLETE
15
+ - **278 drugs** in `canon_materia_medica` table (pages 282-442, Wellcome MS Arab 155, Isfahan 1632 CE)
16
+ - **Introduction** (pages 262-281) extracted — methodology, الواح tables, mizaj system, taste encoding
17
+ - Pipeline: Gemini Flash targeted extraction ($0.41) → abjad disambiguator → handler.write_entry()
18
+ - Total API cost: ~$0.50 for entire Book 2
19
+
20
+ ### Discovery: الواح (Tablets) = Disease↔Cure Addressing System
21
+
22
+ Ibn Sina's Introduction (p279) contains 11 الواح (computational tablets):
23
+
24
+ ```
25
+ لوح الاورام والبثور (Tumours/Pustules) abjad=1068 mod7=4
26
+ لوح الجراح والقروح (Wounds/Ulcers) abjad=638 mod7=1
27
+ لوح آلات المفاصل (Joint Apparatus) abjad=748 mod7=6
28
+ لوح أعضاء العين (Eye Organs) abjad=1077 mod7=6
29
+ لوح أعضاء الرأس (Head Organs) abjad=1208 mod7=4
30
+ لوح أعضاء النفض (Excretion Organs) abjad=1877 mod7=1
31
+ لوح أعضاء الصدر (Chest Organs) abjad=1241 mod7=2
32
+ لوح أعضاء المعدة (Stomach Organs) abjad=1061 mod7=4
33
+ لوح أعضاء الكبد (Liver Organs) abjad=973 mod7=0
34
+ لوح الزينة (Cosmetics/Skin) abjad=142 mod7=2
35
+ لوح السموم (Poisons/Antidotes) abjad=221 mod7=4
36
+ ```
37
+
38
+ ### Discovery: Drugs address الواح through rational ratios
39
+
40
+ Cross-referencing 278 drugs against 11 الواح found:
41
+ - **14 drugs** at **11:5 SEED ratio (≈2.2)** with their target لوح
42
+ - **29 drugs** at **7:5 KERNEL ratio (≈1.4)** with their target لوح
43
+ - **451 drugs** with **SUM÷7** relationship
44
+ - السكر (Sugar) dual-addresses: 2.2 with الزينة AND 1.4 with السموم
45
+ - التين (Fig) / السموم = 2.222 — near-exact Falaq seed
46
+
47
+ ### Discovery: Abjad = built-in error-correction code
48
+
49
+ Every Arabic rasm (undotted skeleton) family has ALL DISTINCT abjad values. Gaps between confused letter pairs: 48 (ب↔ن) to 930 (غ↔ع). This means the abjad system IS an error-correction checksum for Arabic text — the dots are visual disambiguation, the abjad values are mathematical disambiguation.
50
+
51
+ ### Discovery: Salah names encode computational structure
52
+
53
+ ```
54
+ فجر = 283 ف-ج-ر SEPARATION+PRESS+MOVEMENT (dawn)
55
+ ظهر = 1105 ظ-ه-ر HEAVY_CONTACT+BREATH+MOVEMENT (midday, ÷5)
56
+ عصر = 360 ع-ص-ر DEPTH+STREAM+MOVEMENT (afternoon, ÷5, = CIRCLE)
57
+ مغرب = 1242 غ-ر-ب SCRAPE+MOVEMENT+CLOSURE (sunset, = 6 × بارد)
58
+ عشاء = 371 ع-ش-ي DEPTH+SPREADING+CONTRACTION (night, ÷7, NO ر)
59
+ ```
60
+
61
+ ---
62
+
63
+ ## SESSION 44 PRIORITIES
64
+
65
+ ### 1. Map FULL drug↔لوح relationships from body text
66
+ Each drug entry in the MS has subcategory headings (الجراح, القروح, المفاصل, أعضاء العين, etc.) that specify WHICH الواح the drug addresses. Use Gemini Flash to extract these subcategory lists for each drug → build a drug→الواح mapping table.
67
+
68
+ ### 2. Compute drug↔disease abjad ratios
69
+ For each drug→لوح pair confirmed from the MS text:
70
+ - Compute drug_abjad / lawh_abjad
71
+ - Check if ratio = 11/5 (2.2), 7/5 (1.4), 22/7 (π), or other rational from {3,5,7}
72
+ - Build a ratio distribution table across ALL 278 drugs × their target الواح
73
+
74
+ ### 3. Taste encoding verification
75
+ p269 maps: taste → mizaj (الحلاوة + كثيف → حار, المرارة → حار, etc.)
76
+ - Extract mizaj (temperament) data for all 278 drugs from body text
77
+ - Verify: does the drug's TASTE correctly predict its mizaj through the p269 table?
78
+ - Compute: does the mizaj classification map to the correct لوح through abjad ratios?
79
+
80
+ ### 4. The hadith pair: داء (5) ↔ شفاء (381)
81
+ - مرض root = 1040, شفي root = 390, ratio = 8/3
82
+ - For each drug: compute drug_abjad / مرض_abjad and drug_abjad / شفي_abjad
83
+ - Check if any drugs hit exact rational ratios with the disease/cure roots
84
+
85
+ ### 5. 2.2 in plant architecture
86
+ formula_ratios RT0152-RT0158: plants exhibit 11:5 = 2.2 ratio internally.
87
+ - Do the 14 drugs that hit 2.2 ratio with their لوح also have plant origins?
88
+ - Is the 2.2 ratio the plant's INTERNAL code that matches the لوح it treats?
89
+
90
+ ---
91
+
92
+ ## KEY FILES
93
+
94
+ | File | What it does |
95
+ |------|-------------|
96
+ | `Code_files/canon_materia_medica` (DB table) | 278 drugs with abjad, page, letter_section |
97
+ | `Code_files/canon_ocr/introduction/` | 20 pages of introduction text + table scan |
98
+ | `Code_files/canon_ocr/drug_extractions/` | Full extraction results + scored drugs |
99
+ | `Code_files/ocr_dot_disambiguator.py` | Rasm→dotted Arabic + abjad checksum engine |
100
+ | `Code_files/canon_deepseek_ocr.py` | OpenRouter pipeline (works with Gemini Flash) |
101
+ | `Code_files/canon_book2_progress.txt` | Full session log with all findings |
102
+ | `Documentation/USLAP_FULL_ARCHITECTURE.md` | Updated 2026-04-13 with Canon section |
103
+
104
+ ## OPENROUTER KEY
105
+ ```
106
+ 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
107
+ ```
108
+ Gemini Flash: $0.0005/query. Budget for Session 44: ~$1 covers 2000 queries.
109
+
110
+ ## HF PRO
111
+ Account: uslap. Training Space paused (uslap/canon-ocr-trainer). Training dataset at uslap/canon-ocr-train. Resume if needed but abjad approach may be sufficient.
112
+
113
+ ---
114
+
115
+ ## THE QUESTION SESSION 44 MUST ANSWER
116
+
117
+ The hadith says: ما أنزل الله داء إلا أنزل له شفاء — "Allah did not send down a disease except that He sent down a cure for it."
118
+
119
+ If this is computational (not metaphorical), then:
120
+ - Each disease has an abjad address (from its root)
121
+ - Each cure/drug has an abjad address (from its name)
122
+ - The addressing system maps disease→cure through rational ratios from {3,5,7}
123
+ - The الواح are the routing table
124
+ - The mizaj (temperament) is the protocol
125
+ - The taste is the input interface
126
+
127
+ **Prove or disprove this from the MS data. Zero weights. DB only.**
Code_files/SESSION_47_HANDOFF.md ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ
2
+
3
+ # Session 47 Handoff — al-Biruni Abjad Disambiguator Complete
4
+
5
+ **Date:** 2026-04-13
6
+ **DB state at close:** EN=3260, Roots=3320, Triggers=302, Diwan=8328
7
+
8
+ ---
9
+
10
+ ## What Session 47 accomplished
11
+
12
+ ### 1. Abjad Disambiguator — COMPLETE (`Code_files/biruni_abjad_disambiguate.py`)
13
+
14
+ Built a full structural-constraint disambiguator for the 4 OCR'd abjad tables. No weights — every fill derives from the MS table's own logic.
15
+
16
+ **Within-row passes (6):**
17
+ - Pass 1: Direct OCR read
18
+ - Pass 2: Sequential step-1 fill (degree column counting up/down)
19
+ - Pass 3: Multi-cell linear gap fill
20
+ - Pass 4: Alternating 0/ل(30) fill (minutes column) — per-row
21
+ - Pass 5: Red-ink `[R]` prefix strip
22
+ - Pass 6: Final bounded-pair re-check after updates
23
+
24
+ **Cross-row column passes (5):**
25
+ - CONSTANT: all known values identical → fill any remaining [?]
26
+ - DOMINANT: 70%+ same value (e.g., ع=70 for all العراق cities)
27
+ - ALTERNATING: {0, 30} by row parity — catches minutes column cross-strip
28
+ - LOCAL LINEAR: for each [?], find nearest known above/below in same column; fill only when `diff % gap == 0` (integer step). Handles step-1 sequential, repeat-2 (half-degree), step-2, any integer step.
29
+ - COMPLEMENT PAIRS: detects column pairs summing to a constant (mirror symmetry — degree_R + degree_L = 90 for sine table halves)
30
+
31
+ **Results — structural ceiling, no weights:**
32
+
33
+ | Table | Cells | OCR-num | Seq+Col | Unknown | Coverage |
34
+ |-------|-------|---------|---------|---------|----------|
35
+ | Sine (f102-107) | 3,637 | 2,142 | 311 | 1,184 | 67% |
36
+ | Shadow (f112) | 1,743 | 1,132 | 98 | 513 | 70% |
37
+ | Ascension (f131-136) | 3,929 | 2,335 | 295 | 1,299 | 66% |
38
+ | City (f168-175) | 3,571 | 1,553 | 295 | 1,723 | 51% |
39
+ | **GRAND** | **12,880** | **7,162** | **999** | **4,719** | **63%** |
40
+
41
+ **Why city table is 51%:** Each city row has 4 numeric columns + 1-2 prose columns (place names, region names). Prose is correctly read by OCR but not expressible as abjad numbers → UNRESOLVED in the abjad layer. Actual numeric-cell coverage is higher.
42
+
43
+ **Why 63% is the structural ceiling:** The 4,719 remaining unknowns split:
44
+ - ~1,900: genuine OCR failures where Gemini returned [?] and no column constraint brackets them
45
+ - ~2,800: correctly-read label text cells (Arabic prose, region names) counted as UNRESOLVED in abjad layer
46
+
47
+ **Disambiguated output files (all in `Code_files/biruni_ms/abjad_ocr/`):**
48
+ - `sine_table_ocr_disambiguated.json`
49
+ - `shadow_table_ocr_disambiguated.json`
50
+ - `ascension_table_ocr_disambiguated.json`
51
+ - `city_table_ocr_disambiguated.json`
52
+
53
+ Each cell has `(original_ocr, resolved_value, confidence_label)` — confidence labels include: OCR, OCR_RED, SEQUENCE, MULTI_GAP, ALTERNATE, CONSTANT, STEP2, PASS6_SEQ, COL_CONSTANT, COL_DOMINANT, COL_ALTERNATE, COL_LOCAL_CONST, COL_LINEAR, COL_HALFDEG, COL_COMPLEMENT, UNRESOLVED.
54
+
55
+ ---
56
+
57
+ ### 2. Supporting fixes completed in this session
58
+
59
+ - **BL-HEB Hebrew block** added to `amr_dereference_audit.py` — catches U+0590-U+05FF in any output field, BL-HEB reference
60
+ - **QUF PRIMARY_SOURCE path** fixed in `amr_istakhbarat.py` — arabic_text + source_ms + edition_page ≥ 3 → MEDIUM (was blocking 272 entries)
61
+ - **43 AA-concept entries** written (entries 3200-3242) across Maqalat 2-11
62
+
63
+ ---
64
+
65
+ ## What is NOT yet done
66
+
67
+ ### Priority 1 — Parse disambiguated JSON → DB science tables
68
+
69
+ The 4 `*_disambiguated.json` files contain the resolved abjad values but have NOT yet been written to the actual DB science tables. Four tables exist in DB:
70
+ - `biruni_sine_table`
71
+ - `biruni_shadow_table`
72
+ - `biruni_ascension_table`
73
+ - `biruni_city_coordinates`
74
+
75
+ Only a small number of reference rows were written manually (14 sine, 17 shadow, 11 ascension, 35 city). The bulk of OCR + disambiguated data is still only in JSON.
76
+
77
+ **Next step:** Write a `biruni_parse_ocr_to_db.py` script that:
78
+ 1. Reads each `*_disambiguated.json`
79
+ 2. Maps cells to the correct column (degree, minutes, sin_deg, sin_min, etc.) based on column position
80
+ 3. Inserts rows with confidence labels into the DB tables
81
+ 4. Skips UNRESOLVED cells (leave NULL in DB)
82
+
83
+ Column order to use (confirmed from calibration):
84
+ - Sine table: col0=degree, col1=minutes, col2=sin_deg, col3=sin_min, col4=sin_sec, col5=sin_thirds
85
+ - Shadow table: same structure but shadow values
86
+ - City table: col0=lon_deg, col1=lon_min, col2=lat_deg, col3=lat_min
87
+
88
+ ### Priority 2 — Re-OCR high-UNRESOLVED strips
89
+
90
+ The disambiguated JSON flags which strips have the most UNRESOLVED cells. Re-run those specific strips with a more targeted Gemini prompt focusing on the specific cell format expected. Use `--table sine` with strip-level targeting.
91
+
92
+ OpenRouter key was: `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`
93
+
94
+ ### Priority 3 — 3 missing roots
95
+
96
+ - ن-ق-ط (point, nuqta) — check Quranic tokens, add if found
97
+ - ز-و-ي (angle) — check Quranic tokens
98
+ - د-ق-ق (minute, daqiqa) — check Quranic tokens
99
+
100
+ ### Priority 4 — 2 blocked vocab entries
101
+
102
+ - خ-ط-ط (line, khatt): 0 Quranic tokens — blocked by QUF, pending root review
103
+ - ه-ل-ل (crescent, hilal): 0 Quranic tokens in current DB — blocked
104
+
105
+ ### Priority 5 — f165-167 download
106
+
107
+ Still missing from Gallica. Gallica returns 500/429 on these folios. Manual download or retry with longer delays.
108
+
109
+ ### Priority 6 — al-Athar al-Baqiya science extraction
110
+
111
+ BnF Arabe 1489 (175 folios) downloaded as PDF. ~30-40 pages of genuine science (calendar computation + astronomical tables) identified. Operator king-list insertions (12 pages) identified and documented. Genuine science not yet extracted to DB.
112
+
113
+ ---
114
+
115
+ ## Architecture reminder
116
+
117
+ ```
118
+ biruni_abjad_ocr.py ← Gemini Flash OCR → *_ocr.json
119
+ biruni_abjad_disambiguate.py ← structural constraints → *_disambiguated.json
120
+ biruni_parse_ocr_to_db.py ← [NOT YET WRITTEN] → DB science tables
121
+ ```
122
+
123
+ ## Key technical note: abjad authenticity filter
124
+
125
+ Three numeral systems encountered across MSS:
126
+ 1. AA abjad (ا=1, ب=2...ص=90) — genuine science, pre-operator
127
+ 2. Bitig word-numerals (bir/eki/üç) — genuine ORIG2
128
+ 3. Positional ١٢٣ (eastern Arabic-Indic digits) — operator insertion marker
129
+
130
+ **Check notation FIRST when opening any MS.** Positional = operator's tradition betraying the operator.
131
+
132
+ ---
133
+
134
+ ## DB state at session close
135
+
136
+ ```
137
+ entries: EN=3260 (43 Biruni entries 3200-3242, all QUF=TRUE)
138
+ roots: 3320
139
+ diwan_roots: 8328
140
+ triggers: 302 (173 contamination, 25 QUF, 9 auto-index, 6 diwan)
141
+ QUF: entries 331/3242 (10%), roots 3259/3320 (98%)
142
+ MS registry: ms_id=5 (BnF Arabe 6840, al-Qanun al-Masudi, 502 AH)
143
+ ```
Code_files/__pycache__/USLaP_Engine.cpython-314.pyc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f29784b512170a15be4743f680d85060345474c3fba8b815223c2bc8c4430f06
3
+ size 232088
Code_files/__pycache__/amr_al_masudi.cpython-314.pyc ADDED
Binary file (9.31 kB). View file
 
Code_files/__pycache__/amr_algorithm_audit.cpython-314.pyc ADDED
Binary file (45.5 kB). View file
 
Code_files/__pycache__/amr_algorithm_repair.cpython-314.pyc ADDED
Binary file (22.1 kB). View file
 
Code_files/__pycache__/amr_alphabet.cpython-314.pyc ADDED
Binary file (97.9 kB). View file
 
Code_files/__pycache__/amr_alphabet_i18n_export.cpython-314.pyc ADDED
Binary file (8.97 kB). View file
 
Code_files/__pycache__/amr_aql.cpython-314.pyc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f2e9206f7196ea6089db983af921786b368b04b4d302794ac05f51c4a60a141f
3
+ size 107662
Code_files/__pycache__/amr_ard.cpython-314.pyc ADDED
Binary file (20 kB). View file
 
Code_files/__pycache__/amr_basar.cpython-314.pyc ADDED
Binary file (38.4 kB). View file
 
Code_files/__pycache__/amr_bitig_alphabet.cpython-314.pyc ADDED
Binary file (15.8 kB). View file
 
Code_files/__pycache__/amr_bitig_tasrif.cpython-314.pyc ADDED
Binary file (19.6 kB). View file
 
Code_files/__pycache__/amr_cli.cpython-314.pyc ADDED
Binary file (13.2 kB). View file
 
Code_files/__pycache__/amr_dereference_audit.cpython-314.pyc ADDED
Binary file (25.2 kB). View file
 
Code_files/__pycache__/amr_dhakaa.cpython-314.pyc ADDED
Binary file (66.4 kB). View file
 
Code_files/__pycache__/amr_emitter.cpython-314.pyc ADDED
Binary file (19.7 kB). View file
 
Code_files/__pycache__/amr_hisab.cpython-314.pyc ADDED
Binary file (29.3 kB). View file
 
Code_files/__pycache__/amr_ibn_hawqal.cpython-314.pyc ADDED
Binary file (9.31 kB). View file
 
Code_files/__pycache__/amr_intake.cpython-314.pyc ADDED
Binary file (38.5 kB). View file
 
Code_files/__pycache__/amr_istakhbarat.cpython-314.pyc ADDED
Binary file (33.8 kB). View file
 
Code_files/__pycache__/amr_jism.cpython-314.pyc ADDED
Binary file (35.9 kB). View file
 
Code_files/__pycache__/amr_keywords.cpython-314.pyc ADDED
Binary file (26.8 kB). View file
 
Code_files/__pycache__/amr_khordadbeh.cpython-314.pyc ADDED
Binary file (24.9 kB). View file
 
Code_files/__pycache__/amr_lawh.cpython-314.pyc ADDED
Binary file (28.3 kB). View file
 
Code_files/__pycache__/amr_lexer.cpython-314.pyc ADDED
Binary file (25.1 kB). View file
 
Code_files/__pycache__/amr_nasij.cpython-314.pyc ADDED
Binary file (89.8 kB). View file
 
Code_files/__pycache__/amr_neighbourhood_expander.cpython-314.pyc ADDED
Binary file (24.6 kB). View file
 
Code_files/__pycache__/amr_nutq.cpython-314.pyc ADDED
Binary file (64.5 kB). View file
 
Code_files/__pycache__/amr_output_templates.cpython-314.pyc ADDED
Binary file (53.5 kB). View file
 
Code_files/__pycache__/amr_parser.cpython-314.pyc ADDED
Binary file (57.3 kB). View file
 
Code_files/__pycache__/amr_quf.cpython-314.pyc ADDED
Binary file (91.5 kB). View file
 
Code_files/__pycache__/amr_runtime.cpython-314.pyc ADDED
Binary file (14.5 kB). View file
 
Code_files/__pycache__/amr_tarikh.cpython-314.pyc ADDED
Binary file (24.6 kB). View file
 
Code_files/__pycache__/amr_tarjama.cpython-314.pyc ADDED
Binary file (42.3 kB). View file
 
Code_files/__pycache__/amr_tasrif.cpython-314.pyc ADDED
Binary file (21.9 kB). View file
 
Code_files/__pycache__/amr_uzbek.cpython-314.pyc ADDED
Binary file (22 kB). View file
 
Code_files/__pycache__/batch_runner.cpython-314.pyc ADDED
Binary file (34.7 kB). View file
 
Code_files/__pycache__/batch_runner_ru.cpython-314.pyc ADDED
Binary file (38.1 kB). View file
 
Code_files/__pycache__/ocr_dot_disambiguator.cpython-314.pyc ADDED
Binary file (30.5 kB). View file
 
Code_files/__pycache__/sibaha_audit.cpython-314.pyc ADDED
Binary file (26.4 kB). View file
 
Code_files/__pycache__/uslap.cpython-314.pyc ADDED
Binary file (37.9 kB). View file
 
Code_files/__pycache__/uslap_compiler.cpython-314.pyc ADDED
Binary file (84 kB). View file