# How to Disable the Workaround (If BP102 Issue is Worse)

## ⚠️ When to Disable

Disable the workaround if:
- PL11089 showing BP102 is WORSE than showing PL689
- You need time to investigate the full scope of wrong associations
- The workaround is causing more problems than it solves

## 🔧 Quick Disable (30 seconds)

### Step 1: Edit the File

Open `aumentum_browser_service.py` and find line 808:

```bash
nano /home/plagis/workspace/plagis_aumentum/aumentum_browser_service.py +808
# Or use your preferred editor
```

### Step 2: Comment Out the Workaround

Change this:

```python
ASSOCIATION_FIXES = {
    'PL11089': {
        'wrong_store_url': 'store://2015/3/26/15/8/3eee6f3f-0b98-41b9-a6cb-2c4488152fed.bin',
        'correct_store_url': 'store://2015/3/17/10/10/879dcd53-f552-4e82-858f-7e868e60a275.bin',
        'reason': 'File tagged as PL11089 actually contains PL689 content'
    },
    'PL689': {
        'wrong_store_url': 'store://2015/3/17/10/10/879dcd53-f552-4e82-858f-7e868e60a275.bin',
        'correct_store_url': 'store://2015/3/26/15/8/3eee6f3f-0b98-41b9-a6cb-2c4488152fed.bin',
        'reason': 'File tagged as PL689 actually contains PL11089 content'
    }
}
```

To this:

```python
# WORKAROUND TEMPORARILY DISABLED - causing BP102 issue
# Need to investigate full scope of wrong associations
ASSOCIATION_FIXES = {}
```

### Step 3: Restart the API Server

```bash
pkill -f "python.*aumentum_api.py"
cd /home/plagis/workspace/plagis_aumentum
python3 aumentum_api.py
```

### Step 4: Clear Cache

```bash
rm -rf /tmp/aumentum_pdfs/*
```

### Step 5: Test

```bash
curl "http://localhost:8001/documents/pdf-by-document-number?document_number=PL11089&document_id=10000000013787" \
  -o /tmp/PL11089_workaround_disabled.pdf

xdg-open /tmp/PL11089_workaround_disabled.pdf
```

**Expected Result**: Should go back to showing PL689 content (original problem)

## 🔄 Result After Disabling

| Document | Will Show | Status |
|----------|-----------|--------|
| PL11089 | PL689 content | ❌ Wrong (but at least not BP102) |
| PL689 | PL689 content | ✅ Correct |
| BP102 | BP102 content | ✅ Correct |

## 🔍 Investigation While Disabled

With the workaround disabled, we can investigate properly:

### 1. Check All Three Documents

```bash
# PL11089 (should show PL689 content)
curl -s "http://localhost:8001/documents/pdf-by-document-number?document_number=PL11089&document_id=10000000013787" \
  -o /tmp/investigation_PL11089.pdf

# PL689 (should show PL689 content - correct)
curl -s "http://localhost:8001/documents/pdf-by-document-number?document_number=PL689&document_id=10000000012415" \
  -o /tmp/investigation_PL689.pdf

# BP102 (should show BP102 content - correct)
curl -s "http://localhost:8001/documents/pdf-by-document-number?document_number=BP102&document_id=XXX" \
  -o /tmp/investigation_BP102.pdf
```

### 2. Document What Each File Contains

Open each PDF and note the actual document number shown:

```bash
xdg-open /tmp/investigation_PL11089.pdf  # What does it actually say?
xdg-open /tmp/investigation_PL689.pdf    # What does it actually say?
xdg-open /tmp/investigation_BP102.pdf    # What does it actually say?
```

### 3. Create Mapping Table

| Query | File Used | Actual Content |
|-------|-----------|----------------|
| PL11089 | 3eee6f3f...fed.bin | ??? |
| PL689 | 879dcd53...275.bin | ??? |
| BP102 | ??? | ??? |

## 📋 Decision Matrix

### Option 1: Keep Workaround Disabled

**Choose this if:**
- PL11089 showing PL689 is "good enough" for now
- You need time to investigate properly
- There might be many more affected documents

**Action**: Leave it disabled, plan a comprehensive audit

### Option 2: Fix the Workaround

**Choose this if:**
- You've identified the correct file for PL11089
- You know where BP102's content actually is
- The scope is limited to these 3 documents

**Action**: Update ASSOCIATION_FIXES with correct mappings

### Option 3: Database Correction

**Choose this if:**
- You have database admin access
- You've verified the correct associations
- You want a permanent fix

**Action**: Run SQL UPDATE statements to fix database

## 🔧 If You Want to Re-Enable with Correct Mappings

Once you know the correct files:

```python
ASSOCIATION_FIXES = {
    'PL11089': {
        'wrong_store_url': 'store://WRONG_FILE',
        'correct_store_url': 'store://CORRECT_FILE_FOR_PL11089',
        'reason': 'Based on manual verification'
    },
    # Add more as needed
}
```

## 📞 Get Help

If you're unsure what to do:

1. **Disable the workaround** (safer)
2. **Run the diagnostic**: `./check_pl11089_current_state.sh`
3. **Report findings**: What content does each PDF show?
4. **Ask for guidance**: Based on findings, decide next steps

---

**Quick Disable Command**:
```bash
cd /home/plagis/workspace/plagis_aumentum && \
sed -i '808,819s/^/# /' aumentum_browser_service.py && \
sed -i '808a\ASSOCIATION_FIXES = {}  # Disabled' aumentum_browser_service.py && \
pkill -f "python.*aumentum_api.py" && \
python3 aumentum_api.py > /tmp/api.log 2>&1 &
```

**Current Status**: ⏳ Awaiting your decision  
**Recommendation**: Run diagnostic first, then decide

