Skip to content

Walkthrough: Crawling PDFs & Querying Knowledge Graphs (Local & Remote) ​

This walkthrough shows how a developer actually goes from a folder of PDFs (text-native, scanned, or mixed) to a searchable, verifiable Knowledge Graph (.kgraph) using the Kompile harness — without hand-writing JSON payloads or REST requests.

You talk to the harness in plain English (or run a couple of short CLI commands), and the agent handles capability discovery, dry-run previews, PDF OCR routing, asynchronous job tracking, and graph queries behind the scenes — in both modes:

  1. Local Mode (Offline, Zero Server) — runs directly inside your repository using the local-runtime overlay (<project>/data/crawls/ + <project>/.kompile/graph.kgraph).
  2. Remote Runtime Mode (kompile-app) — connects your harness (--url) to a remote kompile-app server for shared team indices, Neo4j/pgvector persistence, scheduled crawls, or remote GPU OCR/embeddings.
mermaid
flowchart LR
    PDF["Your PDFs\n(Text, Scanned, Mixed)"] --> CHAT["You Ask in Kompile Chat\n(Terminal or Web Harness)"]
    CHAT --> ROUTE{"Where It Runs"}
    ROUTE -->|"Local Mode\n(cli-harness + local-runtime)"| LOC["Project-Local Pipeline\nPDFBox+Tabula / VLM OCR\n<project>/data/crawls/\n<project>/.kompile/graph.kgraph"]
    ROUTE -->|"Remote Runtime\n(--url http://host:8080)"| REM["kompile-app Stack\nCrawl Manager (:8082)\nGraph Engine (:8094) / Staging (:8090)"]
    LOC --> ASK["Ask & Verify in Plain English\n• Hybrid passage + graph search\n• Claim verification & evidence\n• Multi-hop paths & portable .kgraph"]
    REM --> ASK

Step 0: Check your tier & how PDF routing works ​

Kompile keeps the default cli-harness lightweight (zero ND4J, DL4J, PDF/Office loaders, or Spring dependencies):

Installed TierLocal Offline PDF Crawling & .kgraphRemote Server (kompile chat --url / kompile crawl --url)Remote MCP Stdio (kompile mcp-stdio --url)
Slim cli-harness only (default install.sh)Install local-runtime first (kompile install local-runtime)Works out of the box over pure-JDK HTTP & MCP SSEWorks out of the box (30 remote crawl, RAG & graph tools; local-only graph_psl, graph_reasoning_query, model_runtime, pipeline need local-runtime)
cli-harness + local-runtimeAll 33 crawl, RAG, pipeline & graph tools active out of the boxWorks out of the boxWorks out of the box
Full platform (full / GPU variants)All 33 crawl, RAG, pipeline & graph tools active out of the boxWorks out of the boxWorks out of the box

If you want to crawl PDFs and query .kgraph files locally with no server, overlay local-runtime once:

bash
kompile install local-runtime     # Auto-detects CPU/GPU backend and installs ~/.kompile/lib/kompile-local-runtime.jar
kompile doctor                    # Verify installation

What the harness handles automatically ​

  • Progressive tool loading: Crawl and graph tools live in deferred groups (crawl, graph_query, graph_analysis, graph_write) so they don't bloat normal coding turns. As soon as you ask to crawl a PDF or inspect a graph, the agent activates the right group on its own.
  • Automatic PDF classification (AUTO routing): Both local and remote runtimes inspect each PDF page before extraction (using a 50 chars/page scanned-page threshold):
PDF TypeDetected AsPipeline SelectedHow Text & Tables Are Extracted
Text-native PDFExtractable text, no full-page scan imagesstandard-textPDFBox + Tabula (text + structured tables)
Scanned / image PDFRaster page images with <50 chars/pagevlm-ocr-pdf (or multimodal chat model)Local VLM (smoldocling-256m) or your configured multimodal chat model
Mixed PDFSome text pages, some scanned pagesvlm-ocr-pdf (AUTO)Per-page split: VLM OCR on scanned pages, PDFBox+Tabula on text pages

Part 1: Project-Local PDF Crawl & Knowledge Graph (No Server) ​

Use this when working inside a local repository or private document folder with local-runtime installed.

1. Put your PDFs in the project & open Kompile ​

bash
mkdir -p ./papers
cp ~/Downloads/architecture-spec.pdf ~/Downloads/scanned-appendix.pdf ./papers/

# Optional: generate kompile.project.json + AUTO PDF/VLM routing config in one command
kompile project init --pdf-routing AUTO

# Launch the harness (terminal or browser)
kompile chat
# or
kompile chat --web

2. Preview the crawl in plain English (dry run first) ​

Before writing anything to disk, ask the agent to inspect your local crawl capabilities and preview how each PDF will be routed:

"Check what crawl pipelines are available here and run a dry-run preview on the PDFs in ./papers so I can see which files will use text extraction vs. VLM OCR before indexing anything."

What you see:

  • The agent activates the crawl tool group, inspects local loaders/pipelines (crawl_discover), and runs a zero-persistence preview (dryRun).
  • It reports back each discovered PDF, whether it is text-native, scanned, or mixed, and which pipeline (standard-text vs. vlm-ocr-pdf / multimodal chat) will process it.

3. Run the crawl & watch live progress ​

Once the preview looks right, tell the agent to run the real crawl:

"Crawl ./papers into this project's local knowledge base with full graph extraction and learning. If no local extraction LLM is staged, use my active chat provider for entity extraction."

What happens behind the scenes:

  • The harness submits an asynchronous crawl job (crawl_documents for a folder, or crawl_source for one file) covering loading, markdown/table extraction, chunking, lexical + vector indexing, entity/relation extraction, entity resolution, enrichment, and graph learning.
  • You don't need to wait passively: the job runs asynchronously while you can keep chatting, inspect progress in the Activity Pane (↓ in terminal) or Web /processes tab, or run /dashboard-crawl to see live throughput and stage status.
  • When the job finishes, the agent pulls the structured result handle (crawl_result) and gives you a concise summary of indexed documents, chunks, entities, and relationships.

(Prefer a non-interactive shell run without opening chat? Run kompile crawl --offline --local-agent crawl-worker.)

Where your local artifacts live ​

  • <project>/data/crawls/ — extracted markdown, chunks, lexical/dense search index, and job history.
  • <project>/.kompile/graph.kgraph — self-contained project knowledge graph (COMPACT_V3) holding entities, relationships, source provenance, subjective-logic opinions, and learned weights.

Part 2: Remote Runtime PDF Crawl (kompile-app) ​

Use remote runtime mode when you want a shared team knowledge base, Neo4j/pgvector storage, scheduled crawls, or a dedicated GPU box running VLM OCR and embeddings.

1. Connect the harness to your remote server ​

Even a bare slim cli-harness (without local-runtime) connects directly over pure-JDK HTTP:

bash
# Option A — Interactive terminal chat against the remote runtime
kompile chat --url http://<server-host>:8080

# Option B — Dedicated crawl-and-reason REPL
kompile crawl --url http://<server-host>:8080 --mode supervised

# Option C — MCP stdio bridge for external agents (Claude Code, Codex, Antigravity)
kompile mcp-stdio --url http://<server-host>:8080

(By default --url auto-discovers the three server personas: admin :8080, crawl manager :8082, and graph engine :8094. You can override them explicitly with --crawl-url and --graph-url. Quick readiness check from any shell: curl -sf http://<server-host>:8082/api/setup/status.)

2. Preflight & launch the remote crawl in plain English ​

Inside chat, ask the agent using the exact same workflow as local mode:

"Preflight the remote crawl server, show me the existing fact sheets and registered OCR pipelines, then crawl /data/input_documents/pdfs into the architecture fact sheet with lenient graph extraction."

What you see:

  • The harness runs a preflight check against kompile-app-crawl-manager (:8082), discovers remote source types and fact sheets, and submits the remote crawl job.
  • Track progress live with /dashboard-crawl and /dashboard-graph in chat (or open the Project, Fact Sheets, and Graph tabs in kompile chat --web).
  • If your remote server sits behind a reverse proxy with a strict read timeout, the harness's default asynchronous job mode avoids long blocking HTTP connections automatically.

Part 3: Query, Verify & Reason Over Your Graph (Both Modes) ​

Once the crawl finishes, the workflow is identical whether your graph lives in local <project>/.kompile/graph.kgraph or on a remote kompile-app server. Just ask in plain English:

1. Inspect what was extracted before querying ​

"Show me the entity types, node/edge counts, and predicate names extracted from these PDFs."

The harness inspects the live graph schema (knowledge_graph, graph_reasoning_query) so neither you nor the agent ever guesses predicate names.

"What do these specs say about failover timeout budgets, and which services are linked to them?"

The agent runs hybrid passage retrieval (rag_search) alongside graph-neighborhood lookup (graph_search), returning grounded answers with exact source-document attribution.

3. Verify claims & inspect evidence ​

"Verify whether ServiceA depends on QueueB based on the crawled PDFs, and show me the supporting evidence, any counter-evidence, and the reasoning trace."

The harness checks the claim (ask_graph_verify, graph_reason, ask_graph_explain) and reports a plain-English verdict — SUPPORTED, REFUTED, or UNKNOWN — along with confidence, uncertainty, evidence bullets, and the rule-derivation chain.

4. Multi-hop paths, pattern queries & structural analysis ​

"List every service that depends on QueueB, trace the shortest dependency path from ServiceA to DatabaseC, and highlight the highest-centrality components in the graph."

Under the hood, the agent translates your question into pattern queries (ask_graph_query), shortest-path / WHY / WHY_NOT reasoning (graph_reasoning_query), and structural or probabilistic analysis (graph_centrality, graph_bayes, graph_embeddings, graph_psl, ask_graph_mebn).

5. Move a graph between machines (.kgraph portability) ​

Crawl heavy PDFs once on a GPU workstation or remote server, then bring the graph to your laptop for offline work:

  • On the GPU host / remote session:

    "Export this knowledge graph as a portable .kgraph to ./exports/architecture-pdfs.kgraph."

  • On your laptop (with local-runtime):

    "Import ./exports/architecture-pdfs.kgraph into my local graph so I can query and verify claims offline."


Troubleshooting ​

SymptomLikely CauseWhat to Do
"Tool requires the local embeddings/graph/crawl runtime"Running bare cli-harness with no --url and no local-runtimeRun kompile install local-runtime for offline local crawling, or connect to a server with kompile chat --url http://<host>:8080
Scanned PDF yields little or no textPages are raster images and text-only extraction ranRun kompile project init --pdf-routing AUTO or ask the agent to re-crawl that file using the vlm-ocr-pdf (or multimodal chat) pipeline
Crawl job appears to run twiceStarting a second crawl while the first job is still in progressCheck /dashboard-crawl or ask "What is the status of the active crawl job?" instead of re-submitting
Graph query returns empty resultsPredicate or entity name didn't match extracted vocabularyAsk "List the predicates and top entities in this graph" first, then re-query using the discovered names
Remote crawl endpoints return 404 on :8080Crawl APIs live on kompile-app-crawl-manager (:8082)Pass --url http://<host>:8080 (auto-routes crawl calls) or explicitly pass --crawl-url http://<host>:8082

Released under the Apache-2.0 License.