cos_doc_search
Search project documentation by combining semantic and lexical matching with metadata filters for domain, layer, and date, so you retrieve current, relevant chunks instead of stale or off-topic ones.
Instructions
Semantic + lexical search over project documentation chunks.
Stage-1 metadata pre-filter (since migration v22):
domain, layer, since_iso, and include_inactive narrow the
chunk universe BEFORE vector / FTS ranking. Vector search finds
meaning; metadata enforces reality (correct era, correct domain,
not superseded). Combine with source_types for cheap, indexed
pre-filtering.
Args:
query: Natural language search query (e.g. "commission rate calculation").
source_types: Optional comma-separated filter — restrict to specific
source types (e.g. "prd,architecture,adr"). Empty = all types.
limit: Maximum results (1-50, default 5).
mode: "auto" (default) | "semantic" | "lexical".
domain: Frontmatter domain: filter (BACKEND, FRONTEND, OPS,
DOCS, …). Empty = any. Indexed.
layer: Frontmatter layer: filter (adr, playbook, spec, policy,
reference, runbook, postmortem, task). Empty = any. Indexed.
since_iso: Lower bound on frontmatter updated: (YYYY-MM-DD).
Use when the agent asks about "recent" or "current" state and
a stale older doc would be the wrong answer. Empty = any age.
include_inactive: When False (default), hide chunks marked
is_active=0 because the source doc was deleted or superseded.
Set True for decision-history retrieval that must surface
superseded specs.
auto_context: When True (default), soft-default domain from the
active task's swimlane ($COS_AGENT_DIR/.swimlane). Explicit
domain argument always wins. Set False to disable.
Response meta carries filter_hints — heuristic suggestions
extracted from the query (date phrasing, domain keywords, layer
cues). Suggestions are NEVER auto-applied; the agent decides
whether to re-query with them. Mental model: Filter → Search →
Summarize. Vector finds meaning, metadata enforces correctness.
Returns: str: JSON envelope with results list and count. Each result carries source_path, source_type, heading_path, content, score, priority, mtime, chunk_index, retrieval_source.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | auto | |
| layer | No | ||
| limit | No | ||
| query | Yes | ||
| domain | No | ||
| since_iso | No | ||
| auto_context | No | ||
| source_types | No | ||
| include_inactive | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |