Skip to content

Commit 23006b4

Browse files
committed
docs: remove obsolete __hints__ references
The hints cache feature was removed in prior refactoring. Updated all documentation to reflect the simplified 2-file data model (upstream_versions.json + local_state.json).
1 parent 2551e7b commit 23006b4

8 files changed

Lines changed: 65 additions & 266 deletions

docs/ARCHITECTURE.md

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ def _classify_install_method(path: str, tool_name: str) -> tuple[str, str]:
171171
1. **GitHub:**
172172
- Try `/repos/{owner}/{repo}/releases/latest` with redirect following
173173
- Fallback to Atom feed parsing if API fails
174-
- Store successful method in hints for speed
175174

176175
2. **PyPI:**
177176
- Query `https://pypi.org/pypi/{package}/json`
@@ -202,55 +201,31 @@ sleep_time = base * (2 ** attempt) + random.uniform(0, jitter)
202201
# Example: attempt 1 → 200ms + 0-100ms = 200-300ms
203202
```
204203

205-
### 6. Cache Layer (Multi-Tier)
204+
### 6. Data Files
206205

207-
**Cache Hierarchy (fastest → slowest):**
206+
**Two-file model:**
208207

209-
1. **Hints Cache** (`__hints__` in `upstream_versions.json`)
210-
- Stores which API method worked last per tool
211-
- Example: `"gh:BurntSushi/ripgrep": "latest_redirect"`
212-
- Purpose: Skip failed methods, try successful ones first
213-
- Lock: `HINTS_LOCK` (acquired after `MANUAL_LOCK`)
214-
215-
2. **Manual Cache** (`upstream_versions.json`)
216-
- Committed to repository
208+
1. **Upstream Cache** (`upstream_versions.json`) - Committed
209+
- Latest available versions from upstream sources
217210
- Used in offline mode (`CLI_AUDIT_OFFLINE=1`)
218-
- Updated on successful upstream fetches (unless `CLI_AUDIT_WRITE_MANUAL=0`)
219-
- Lock: `MANUAL_LOCK` (acquired first)
220-
221-
3. **Snapshot** (`tools_snapshot.json`)
222-
- Complete audit results with metadata
223-
- Schema version 1 with `__meta__` object
224-
- Used for render-only mode
225-
- Written atomically after collection
211+
- Updated via `--update-baseline`
226212

227-
**Lock Ordering Rule:**
228-
```python
229-
with MANUAL_LOCK:
230-
# Update upstream_versions.json
231-
with HINTS_LOCK:
232-
# Update __hints__ section
233-
```
234-
**Critical:** MANUAL_LOCK must be acquired before HINTS_LOCK to prevent deadlock.
213+
2. **Local State** (`local_state.json`) - Gitignored
214+
- Machine-specific installed tool versions
215+
- Updated via `--update-local`
235216

236217
### 7. Threading Model & Synchronization
237218

238219
**Concurrency Strategy:**
239220

240221
```python
241-
# Global locks for cache writes
242-
MANUAL_LOCK = threading.Lock() # For upstream_versions.json
243-
HINTS_LOCK = threading.Lock() # For __hints__ in upstream_versions.json (nested)
244-
245222
# ThreadPoolExecutor for parallel tool audits
246223
with ThreadPoolExecutor(max_workers=MAX_WORKERS) as executor:
247224
# Each worker calls audit_tool(tool)
248-
# Workers may update caches (with locks)
249225
```
250226

251227
**Thread Safety:**
252-
- Tool audits run in parallel (no shared state except caches)
253-
- Cache updates are serialized via locks
228+
- Tool audits run in parallel (no shared state)
254229
- Atomic file writes prevent corruption (write to temp, then rename)
255230

256231
**Performance Considerations:**
@@ -367,9 +342,7 @@ for attempt in range(retries + 1):
367342
```
368343
Attempt 1: Try upstream API (with retries)
369344
↓ (on failure)
370-
Attempt 2: Check hints cache for alternative method
371-
↓ (on failure)
372-
Attempt 3: Use manual cache (upstream_versions.json)
345+
Attempt 2: Use cached upstream (upstream_versions.json)
373346
↓ (on failure)
374347
Result: Mark as UNKNOWN, continue audit
375348
```

docs/ARCHITECTURE_DIAGRAM.md

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -473,19 +473,13 @@ NOT ProcessPoolExecutor (GIL not a bottleneck)
473473
474474
get_available_version(tool, pm, cache_ttl)
475475
476-
├─→ Check in-memory cache (TTL: 1 hour)
477-
│ └─→ HIT → return cached version
478-
479-
├─→ MISS → Query upstream API
476+
├─→ Query upstream API
480477
│ │
481-
│ ├─→ Check hints cache (last working method)
482-
│ │ └─→ Try: github/pypi/crates/npm
478+
│ ├─→ Try: github/pypi/crates/npm
483479
│ │
484480
│ ├─→ Retry with exponential backoff (2x)
485481
│ │
486482
│ ├─→ SUCCESS:
487-
│ │ ├─→ Update in-memory cache
488-
│ │ ├─→ Update hints cache
489483
│ │ └─→ Write to upstream_versions.json
490484
│ │
491485
│ └─→ FAILURE:
@@ -494,26 +488,9 @@ get_available_version(tool, pm, cache_ttl)
494488
495489
└─→ Returns: version string
496490
497-
Multi-Tier Cache Hierarchy:
498-
1. In-memory (fastest)
499-
2. Hints (method preference)
500-
3. Manual cache (upstream_versions.json)
501-
4. Snapshot (tools_snapshot.json)
502-
```
503-
504-
### Lock Hierarchy
505-
506-
```
507-
MANUAL_LOCK (file-level cache updates)
508-
└─→ HINTS_LOCK (hints section updates)
509-
510-
Rule: Always acquire MANUAL_LOCK before HINTS_LOCK
511-
Prevents: Deadlocks
512-
513-
with MANUAL_LOCK:
514-
# Update upstream_versions.json
515-
with HINTS_LOCK:
516-
# Update __hints__ section
491+
Data Files:
492+
1. upstream_versions.json (committed) - latest available versions
493+
2. local_state.json (gitignored) - machine-specific state
517494
```
518495

519496
---

docs/DEPLOYMENT.md

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -548,28 +548,13 @@ CLI_AUDIT_OFFLINE=1 python3 cli_audit.py --only python
548548

549549
### Offline Cache Management
550550

551-
**Cache File:** `upstream_versions.json` (override with `CLI_AUDIT_MANUAL_FILE`)
551+
**Data Files:**
552+
- `upstream_versions.json` - Latest available versions (committed)
553+
- `local_state.json` - Machine-specific state (gitignored)
552554

553-
**Structure:**
554-
```json
555-
{
556-
"__hints__": {
557-
"gh:BurntSushi/ripgrep": "latest_redirect",
558-
"gh:sharkdp/fd": "latest_redirect"
559-
},
560-
"__methods__": {
561-
"pip": "pypi",
562-
"pipx": "pypi"
563-
},
564-
"ripgrep": "14.1.1",
565-
"fd": "10.3.0",
566-
"python": "3.14.0"
567-
}
568-
```
569-
570-
**Update Behavior:**
571-
- Online lookups automatically update cache (default)
572-
- Disable auto-update: `CLI_AUDIT_WRITE_MANUAL=0`
555+
**Update Commands:**
556+
- `python audit.py --update-baseline` - Refresh upstream versions
557+
- `python audit.py --update-local` - Refresh local state
573558

574559
## Environment Variable Configuration
575560

docs/DEVELOPER_GUIDE.md

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -246,20 +246,7 @@ def risky_operation():
246246

247247
### Threading Safety
248248

249-
When updating caches, always use locks:
250-
251-
```python
252-
# ALWAYS acquire MANUAL_LOCK before HINTS_LOCK
253-
with MANUAL_LOCK:
254-
# Update upstream_versions.json
255-
set_manual_latest(tool_name, version)
256-
257-
with HINTS_LOCK:
258-
# Update __hints__ section
259-
set_hint(f"gh:{owner}/{repo}", method)
260-
```
261-
262-
**Lock Ordering Rule:** MANUAL_LOCK → HINTS_LOCK (never reversed)
249+
File writes use atomic operations (write to temp, then rename) to prevent corruption.
263250

264251
## Testing Strategies
265252

@@ -417,14 +404,11 @@ CLI_AUDIT_DEBUG=1 python3 cli_audit.py --only problematic-tool 2>&1 | tee debug.
417404
### Check Cache State
418405

419406
```bash
420-
# View manual cache
407+
# View upstream versions
421408
jq '.' upstream_versions.json
422409

423-
# View hints
424-
jq '.__hints__' upstream_versions.json
425-
426-
# View snapshot metadata
427-
jq '.__meta__' tools_snapshot.json
410+
# View local state
411+
jq '.' local_state.json
428412
```
429413

430414
## Git Workflow Best Practices
@@ -494,22 +478,6 @@ CLI_AUDIT_FAST=1 python3 cli_audit.py
494478

495479
## Common Pitfalls
496480

497-
### ❌ Wrong Lock Ordering
498-
499-
```python
500-
# WRONG - Can deadlock
501-
with HINTS_LOCK:
502-
with MANUAL_LOCK: # Bad order
503-
...
504-
```
505-
506-
```python
507-
# CORRECT
508-
with MANUAL_LOCK:
509-
with HINTS_LOCK: # Good order
510-
...
511-
```
512-
513481
### ❌ Unhandled Exceptions in Workers
514482

515483
```python

docs/FUNCTION_REFERENCE.md

Lines changed: 5 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Quick lookup reference for functions in `cli_audit.py`, organized by category.
1111
| **Classification** | `detect_install_method`, `_classify_install_method` | Installation method detection |
1212
| **Upstream APIs** | `latest_github`, `latest_pypi`, `latest_crates`, `latest_npm`, `latest_gnu` | Fetch upstream versions |
1313
| **HTTP** | `http_fetch`, `http_get` | Network layer with retries |
14-
| **Cache** | `load_manual_versions`, `get_manual_latest`, `set_manual_latest`, `load_hints`, `get_hint`, `set_hint` | Multi-tier cache management |
14+
| **Cache** | `load_manual_versions`, `get_manual_latest`, `set_manual_latest` | Cache management |
1515
| **Core** | `audit_tool`, `get_latest`, `main` | Main audit logic |
1616

1717
---
@@ -134,7 +134,6 @@ Extract version string from executable.
134134
- Most tools: `<path> --version`
135135
- `go`, `curlie`, `isort`: Custom version flags
136136
- `entr`, `sponge`: No version flag (returns empty)
137-
- Uses hints cache to remember working flags
138137

139138
**Usage:**
140139
```python
@@ -335,8 +334,6 @@ Fetch latest GitHub release.
335334
**Strategies:**
336335
1. Try `/repos/{owner}/{repo}/releases/latest` with redirect following
337336
2. On failure, try Atom feed at `/releases.atom`
338-
3. Use hints cache to skip failed methods
339-
4. Store successful method as hint for next run
340337

341338
**Usage:**
342339
```python
@@ -345,9 +342,6 @@ tag, method = latest_github("sharkdp", "fd")
345342

346343
tag, method = latest_github("BurntSushi", "ripgrep")
347344
# ("14.1.1", "latest_redirect")
348-
349-
# Hint is stored automatically for next run
350-
hint = get_hint("gh:sharkdp/fd")
351345
# "latest_redirect"
352346
```
353347

@@ -603,76 +597,6 @@ set_manual_latest("ripgrep", "14.1.1")
603597

604598
---
605599

606-
### `load_hints() -> None`
607-
608-
Load API method hints from `__hints__` in `upstream_versions.json`.
609-
610-
**Side Effects:** Populates global `HINTS` dict
611-
612-
**Usage:**
613-
```python
614-
load_hints()
615-
method = HINTS.get("gh:owner/repo", "")
616-
```
617-
618-
**See:** [API_REFERENCE.md#load_hints](API_REFERENCE.md#load_hints)
619-
620-
---
621-
622-
### `get_hint(key) -> str`
623-
624-
Get cached API method for a source.
625-
626-
**Parameters:**
627-
- `key` (`str`) - Hint key formats:
628-
- `"gh:owner/repo"` - GitHub API method
629-
- `"local_flag:tool"` - Version flag that worked
630-
631-
**Returns:**
632-
- `str` - Method string (e.g., `"latest_redirect"`, `"--version"`) or empty
633-
634-
**Usage:**
635-
```python
636-
# Get GitHub API method
637-
method = get_hint("gh:sharkdp/fd")
638-
if method == "latest_redirect":
639-
# Try latest redirect first
640-
641-
# Get version flag
642-
flag = get_hint("local_flag:ripgrep")
643-
if flag == "-V":
644-
# Use -V instead of --version
645-
```
646-
647-
**See:** [API_REFERENCE.md#get_hint](API_REFERENCE.md#get_hint)
648-
649-
---
650-
651-
### `set_hint(key, value) -> None`
652-
653-
Store API method hint for future runs.
654-
655-
**Parameters:**
656-
- `key` (`str`) - Hint key
657-
- `value` (`str`) - Method that worked
658-
659-
**Side Effects:** Writes to `__hints__` in `upstream_versions.json`
660-
661-
**Lock Ordering:** Requires `MANUAL_LOCK``HINTS_LOCK`
662-
663-
**Usage:**
664-
```python
665-
# Store successful GitHub method
666-
set_hint("gh:owner/repo", "latest_redirect")
667-
668-
# Store working version flag
669-
set_hint("local_flag:ripgrep", "-V")
670-
```
671-
672-
**See:** [API_REFERENCE.md#set_hint](API_REFERENCE.md#set_hint)
673-
674-
---
675-
676600
## Core Audit Functions
677601

678602
Main audit logic coordinating all subsystems.
@@ -732,12 +656,10 @@ Get latest upstream version for a tool.
732656
- `tuple[str, str]` - `(version, method)` - version string and source method
733657

734658
**Cache Strategy:**
735-
1. If `MANUAL_FIRST=1`, check manual cache first
736-
2. Check hints cache for fastest method
737-
3. Try upstream API (with retries)
738-
4. On success, update hints and manual caches
739-
5. On failure, fall back to manual cache
740-
6. Final fallback: return `("", "")`
659+
1. Try upstream API (with retries)
660+
2. On success, update cache
661+
3. On failure, fall back to cached upstream
662+
4. Final fallback: return `("", "")`
741663

742664
**Usage:**
743665
```python

docs/PRD.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,11 @@ AI CLI Preparation is a specialized environment audit and installation managemen
7575

7676
**Threading Model:**
7777
- ThreadPoolExecutor with configurable workers (default: 16)
78-
- Lock ordering enforcement (MANUAL_LOCK → HINTS_LOCK for safety)
7978
- Independent tool audits (failures isolated)
8079

81-
**Cache Hierarchy:**
82-
- **Hints**: Optimization hints for faster lookups (__hints__ in upstream_versions.json)
83-
- **Manual**: User-committed versions (upstream_versions.json)
84-
- **Upstream**: Live API queries (fallback)
80+
**Data Model:**
81+
- **upstream_versions.json**: Cached upstream versions (committed)
82+
- **local_state.json**: Machine-specific state (gitignored)
8583

8684
**Resilience Patterns:**
8785
- Network failures → fallback to cache

0 commit comments

Comments
 (0)