Paper Management Protocol¶
Applies to all sessions and tools (Claude Code, Codex, Cursor, etc.)
0. Core Principle¶
Research Harness uses a single paper database (pool.db). All tools ingest papers via paper_ingest. PDFs are stored in a single directory. All paths must be absolute.
Database Layout¶
By default, a checkout stores local RH state under the repository root:
<repo>/.research-harness/
├── pool.db <- Main local database
└── downloads/ <- PDF storage managed by RH
└── {paper_id}_{title_slug}.pdf <- Naming convention, auto-generated by paper_ingest
You may instead set RESEARCH_HARNESS_DB_PATH to an absolute database path. The key invariant is that all clients in one project point to the same database and PDF storage policy.
2. Ingest Rules¶
2.1 Ingesting New Papers (use MCP tool)¶
# Method A: via arxiv ID (recommended, auto-downloads PDF)
paper_ingest(source="arxiv:2401.12345", topic_id=<N>)
# Method B: via DOI
paper_ingest(source="doi:10.1145/XXXXXXX", topic_id=<N>)
# Method C: via Semantic Scholar ID
paper_ingest(source="s2:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", topic_id=<N>)
# Method D: local PDF (already downloaded)
paper_ingest(source="file:///absolute/path/to/paper.pdf", topic_id=<N>, title="...")
Never: UPDATE papers SET pdf_path = ... directly — always use paper_ingest.
2.2 Batch Download & PDF Discovery¶
# Batch-download all papers in a topic that are missing PDFs
rh paper acquire <topic_id>
# Discover existing PDFs on disk and link them to DB records (matches by arxiv_id / filename)
rh paper resolve-pdfs --topic <topic_name>
# Dry-run first to preview matches
rh paper resolve-pdfs --topic <topic_name> --dry-run
# Ingest manually downloaded PDFs in batch
rh paper ingest-manual
2.2b External Acquisition & Diagnosis (optional)¶
For papers native routes cannot get (paywalls, browser challenges), RH can
round-trip through paperfetch as an optional external provider —
see SPC_INTEGRATION.md for the full protocol and environment variables.
# Export papers still missing fulltext as SPC manual seeds
rh paper export-spc-wants <topic_id>
# Import an SPC seed pack (papers + PDFs + parse artifacts, all audited)
rh paper import-seed-pack <pack_dir> --topic <topic_id>
# Aggregate route audits: coverage, failure clustering, uncovered papers
rh paper diagnose-acquisition <topic_id>
Opt-in acquisition caches (RESEARCH_HARNESS_PDF_CACHE_DIR) and the
PaperVault local metadata source (RESEARCH_HARNESS_PAPERVAULT_DB) are
also documented in SPC_INTEGRATION.md.
2.3 What paper_ingest Does (automatic)¶
- Downloads PDF -> saves to
.research-harness/downloads/{id}_{slug}.pdf - Creates/updates record in
paperstable; setspdf_pathto absolute path - Associates paper with topic in
paper_topicstable - Extracts metadata (title, authors, year, venue, abstract)
3. Session Checklist¶
At the start of each new session, before starting work:
# 1. Check available topics
rh topic list
# 2. Check current state of the target topic
rh topic overview <topic-name>
# 3. Check for pending papers
rh paper queue --topic <topic-name> --only-actionable
# 4. (Optional) Discover and link PDFs already on disk
rh paper resolve-pdfs --topic <topic-name> --dry-run
4. Path Convention¶
| Convention | Description |
|---|---|
| Absolute paths only | All pdf_path values must be absolute |
| Store only in downloads/ | New PDFs must go in .research-harness/downloads/ |
| Naming format | {paper_id}_{title_slug_max40chars}.pdf |
| No relative paths | ./downloads/... or .research-harness/... are not allowed |
5. DB Health Maintenance¶
# Check DB vs filesystem consistency (run from the repo root; respects the env override)
python3 -c "
import sqlite3, os
db = os.environ.get('RESEARCH_HARNESS_DB_PATH') or '.research-harness/pool.db'
conn = sqlite3.connect(db)
c = conn.cursor()
c.execute('SELECT COUNT(*) FROM papers WHERE pdf_path IS NOT NULL AND pdf_path != \"\"')
total = c.fetchone()[0]
c.execute('SELECT pdf_path FROM papers WHERE pdf_path IS NOT NULL AND pdf_path != \"\"')
broken = [r[0] for r in c.fetchall() if not os.path.exists(r[0])]
print(f'Records with pdf_path: {total}')
print(f'Broken links: {len(broken)}')
if broken:
for p in broken[:5]: print(f' {p}')
conn.close()
"
6. Prohibited Actions¶
| Prohibited | Reason |
|---|---|
Direct SQL UPDATE pdf_path |
Bypasses path validation |
Storing PDFs outside downloads/ |
Creates fragmentation |
| Using relative paths in DB | Breaks across sessions |
Ingesting without topic_id |
Paper becomes orphaned |