# Store Operations

## Indexing

### Initial Indexing

When creating a store, indexing happens automatically in the background:

```
create_store(url, name) → Returns: job_id
→ Background: clone/download → analyze → index
→ Status: pending → running → completed
```

**Time estimates:**
- Small library (<1k files): 30-60 seconds
- Medium library (1k-5k files): 1-3 minutes
- Large library (>5k files): 3-10 minutes
- Documentation crawl (100 pages): 1-2 minutes

### Re-indexing

Re-indexing is incremental — only changed files are re-processed.

**When to re-index:**
- Library released new version
- You modified local folder content
- Search results seem outdated

### Selective Indexing

For large repos, index specific directories:

```
git clone https://github.com/microsoft/vscode
/bluera-knowledge:add-folder ./vscode/src/vs/editor --name=vscode-editor
/bluera-knowledge:add-folder ./vscode/src/vs/workbench --name=vscode-workbench
```

## Background Job Monitoring

```
1. create_store() or index_store() → Returns job_id
2. Job states: pending → running → completed | failed
3. Monitor: check_job_status(job_id) → state, percentage, current file
4. List all: list_jobs() → pending, running, completed jobs
5. Cancel: cancel_job(job_id) → stops and cleans up
```

**Polling:** Every 15 seconds is reasonable. Don't poll every second.

## Common Failure Scenarios

| Error | Cause | Fix |
|-------|-------|-----|
| Authentication required | Private repo | Use SSH URL or HTTPS with token |
| Repository not found | Typo in URL | Verify URL |
| No space left | Disk full | Delete unused stores |
| Connection timeout | Network issue | Retry, or clone manually then add-folder |
| Skipped binary files | Normal behavior | Only text files are indexed |

## Storage Management

```
list_stores()
→ vue: 487 files, 2.3 MB
→ react: 312 files, 1.8 MB

get_store_info('vue')
→ Location, indexed files, size, last indexed
```

**Delete when:** Library no longer relevant, documentation outdated, duplicates exist, disk space needed.

**Cannot undo deletion!**
