Skip to content

systems context packs

Bryan edited this page Jun 13, 2026 · 1 revision

Context packs

Active contributors: Bryan

Context packs are compact bundles of code references for agents. src/lode/context.py searches indexed nodes, ranks them, budgets must-read items, and attaches graph neighbors for the strongest hits.

Directory layout

src/lode/context.py # context pack construction
src/lode/storage.py # search and neighbor queries
tests/test_lode.py  # context command tests

Key abstractions

Name File Description
build_context_pack() src/lode/context.py Builds the response object for a query.
context_item() src/lode/context.py Converts a node into a must-read item.
compact_neighbors() src/lode/context.py Converts neighbor rows into compact edge summaries.
context_rank() src/lode/context.py Pushes external placeholders below local code.
summarize_hits() src/lode/context.py Produces a short result summary.

How it works

graph LR
    Query --> Search[search_nodes]
    Search --> Rank[context_rank]
    Rank --> Budget[budget must_read]
    Rank --> Related[get_neighbors]
    Budget --> Pack[context pack JSON]
    Related --> Pack
Loading

build_context_pack() uses repo_filter() and search_nodes() from src/lode/storage.py, then sorts by context_rank(). It builds must_read entries until the token budget is used and includes related incoming/outgoing graph summaries for the top five hits.

Integration points

  • The CLI exposes this as lode context from src/lode/cli.py.
  • The daemon exposes this as POST /context from src/lode/daemon.py.
  • Storage provides FTS search and graph neighbors through src/lode/storage.py.

Entry points for modification

Tune ranking in context_rank() or budget estimation in estimate_item_cost() in src/lode/context.py. If the response shape changes, update tests in tests/test_lode.py and downstream API docs in docs/api/loded.md if daemon responses change.

Key source files

File Purpose
src/lode/context.py Context pack assembly.
src/lode/storage.py Search and neighbor helpers.
src/lode/cli.py CLI command handler.
src/lode/daemon.py HTTP endpoint.

Related pages

Clone this wiki locally