Skip to content

Search and Context

JanYork edited this page Aug 14, 2026 · 1 revision

Search and context

Language: English · 简体中文

LWC recall is deliberately bounded. Agents start from compact context, use deterministic lexical search to find maintained knowledge, and open exact Pages, Sources, or spans only when needed.

Choose the smallest recall tool

Need Command
Purpose, Schema, Page index, and recent operations lwc context
Maintained knowledge or source fallback lwc search
One complete Page lwc page show
Exact immutable evidence window lwc source show
Exact sentence or passage text lwc span get
Nearby span context lwc span expand
Complete core Pages without search lwc load tag

Start narrow. Do not load the entire Wiki to answer a focused question.

Bounded context

lwc --scope all context --limit 25

Each selected store returns:

  • Purpose and Schema;
  • Page metadata and summaries up to the limit;
  • recent operations up to the limit;
  • the exact scope and database identity.

context does not return every full Page body. Use the index to choose what to open.

Search layers

lwc search "question keywords" --limit 20

Search terms are plain text. LWC escapes raw FTS syntax automatically.

Type Behavior
auto Default: rank maintained Pages first, hide a raw Source paired with a matching source-summary Page, and fall back to Sources
page Search maintained Pages only
source Search immutable Sources only
all Audit both layers

Repeat --kind to restrict Page results:

lwc search "storage policy" --type page --kind concept --kind synthesis --limit 10

Use --type source when exact evidence matters; do not use raw Sources as a substitute for maintained synthesis.

Scope behavior

lwc --scope project search "local architecture"
lwc --scope global search "reusable release practice"
lwc --scope all search "shared convention"

all merges project and global results on one deterministic scale; project wins exact ties. It is valid only for supported reads. Citations and Wiki links never cross stores implicitly.

Granularity

Document search is the default. Request a smaller unit only when the whole-document result is too coarse:

lwc search "projection consistency" --granularity passage
lwc search "projection consistency" --granularity sentence --type page
lwc search "projection consistency" --granularity all --group-by document

all granularity combines document, passage, and sentence candidates with deterministic reciprocal-rank fusion. Grouping by document avoids flooding the result set with several spans from the same owner.

Resolve one locator:

lwc span get <span-id>
lwc span expand <span-id> --before 1 --after 1 --children 20

Span IDs contain the document fingerprint and segmentation version. stale_span means the document changed; search the current content deliberately instead of silently reusing similar text.

CJK search

Multi-character CJK queries use adjacent bigrams and retain non-stopword unigrams. Latin text uses lowercased alphanumeric tokens. This keeps Chinese technical search deterministic without requiring a dictionary or embedding service.

Write natural terms. Do not manually construct FTS expressions.

Ranking and explanation

A lower numeric rank is more relevant. Diagnose surprising order with:

lwc search "payment rules" --limit 20 --explain

--explain shows exact bounded title, path, generic, graph, document-weight, and query-feedback signals. It is read-only and does not prove that a high-ranked claim is correct.

Retrieval weights and feedback

Use adjustments only after improving Page titles, summaries, bodies, and links and inspecting --explain.

A document weight is query-independent:

lwc weight set page payment-rules \
  --value 2 \
  --reason "Current canonical specification" \
  --provenance agent-observed

Query feedback applies only to the same ordered tokenizer fingerprint:

lwc weight feedback page payment-rules \
  --query "payment rules" \
  --signal relevant \
  --reason "Expected page and evidence verified" \
  --provenance agent-observed

Document values are limited to -2, -1, 1, and 2. Feedback is relevant or irrelevant. Both rerank only existing lexical candidates; neither creates semantic matches.

Use user-provided only for an explicit user judgment. Clear obsolete rows instead of stacking compensating adjustments. Do not put sensitive query text in durable reason fields.

Recorded and private search

Search is read-only and private by default. Add --record only when the query wording itself belongs in durable operation history:

lwc search "durable research question" --record

Do not record sensitive queries. With --scope all, a recorded search writes one operation to each selected store.

Recall workflow

  1. Run bounded context once.
  2. Run one task-focused search.
  3. Open one to five relevant Pages.
  4. Inspect cited Sources only for claims that need exact evidence or freshness.
  5. Widen one dimension at a time after a miss.
  6. Solve the task from current evidence.
  7. Preserve a verified reusable result when appropriate.

An empty result is not proof that knowledge does not exist. Check terminology, Page summaries, scope, kind, and evidence before drawing that conclusion.

Retrieval acceptance

After material Page changes, predeclare an expected Page for each test topic. Use one representative question and one natural paraphrase:

lwc lint
lwc search "original question" --type auto --limit 5
lwc search "natural paraphrase" --type auto --limit 5
lwc page show <expected-page>

Pass only when both forms return the expected Page in the top five and the opened Page supports the answer through predeclared Sources or provenance. Do not rewrite a failed query after seeing results.

Completion evidence

Recall is successful when:

  • the selected scope and limits are explicit;
  • the Agent opened only task-relevant documents;
  • stale spans and stale Sources were not silently reused;
  • ranking adjustments, if any, were evidence-based and bounded;
  • material Wiki updates passed fixed retrieval acceptance.

Next: Document knowledge graph

LWC Wiki

English · 简体中文


Start here · 开始使用

Core capabilities · 核心能力

Practical guides · 实战指南

Capability configuration · 能力配置

Technical design · 技术设计

Operations · 运行与维护

Reference · 参考资料

Contributing · 参与贡献


Repository · Releases

Clone this wiki locally