Guide¶
Guide component — AI consultant for optimal G6 system usage.
Cluster: Goal & Planning | Type: component | MCP Tools: 26
Overview¶
Lightweight routing and query-answering block that acts as an AI consultant for optimal G6 system usage. Records all incoming queries in in-block state and responds with structured GuideOutput answers, delegating routing logic and richer advisory operations to an inner guide_mcp layer with 26 tools covering component recommendations, usage patterns, feedback, and system navigation.
When to use:
- Answering "which G6 component should I use?" questions programmatically within a pipeline
- Routing operator queries to the right documentation, MCP tool, or component at runtime
- Embedding a thin advisory layer that can be replaced or upgraded without changing callers
Example:
from mvp.guide import GuideBlock
from mvp.guide.guide_mcp.schema import GuideInput
block = GuideBlock(name="guide")
result = block.infer(GuideInput(op="guide_ask", query="Which block should I use for web scraping?"))
# result.ok → True; result.value → GuideOutput with answer, count, success
Works well with: navigator, goal_engine, recursive_architect
Public API¶
GuideBlock(AIBlock['GuideInput', 'GuideOutput', dict])¶
Lightweight guide that answers routing queries using in-memory state.
| Field | Type | Default |
|---|---|---|
name | str | 'guide' |
state | dict \| None | None |
Methods:
infer(data: Any) -> Result¶
list_patterns() -> dict[str, object]¶
Return the applied deterministic-reliability pattern catalog.
GuideClassifier¶
Fast O(log n) task classifier using decision tree over 7D epistemic vectors.
Methods:
classify(vector_array: list[float]) -> tuple[str, float]¶
Classify a 7D epistemic vector. Returns (cluster, confidence).
classify_by_keywords(query: str) -> tuple[str, float]¶
Rule-based keyword classification (zero training data).
fit(vectors: list[list[float]], labels: list[str]) -> bool¶
Fit decision tree on labeled training data. Returns True if successful.
is_fitted() -> bool¶
EpistemicVector¶
7-dimensional epistemic fingerprint.
| Field | Type | Default |
|---|---|---|
compressibility | float | required |
origin | float | required |
definition | float | required |
tacitness | float | required |
normativity | float | required |
certainty | float | required |
subjectivity | float | required |
Methods:
to_array() -> list[float]¶
from_array(arr: list[float]) -> EpistemicVector¶
neutral() -> EpistemicVector¶
EpistemicHash¶
Hash tasks and components to 7D epistemic vectors, then match.
Methods:
hash_task(query: str) -> EpistemicVector¶
Convert a natural-language task description into a 7D vector.
find_nearest(task_vector: EpistemicVector, k: int = 5, metric: str = 'l2') -> list[tuple[str, float]]¶
Return the k nearest component names with distances.
get_vector(component: str) -> EpistemicVector | None¶
Look up the pre-assigned vector for component.
get_or_default(component: str) -> EpistemicVector¶
Return the vector for component, inferring a default if unknown.
GuideMCPBlock(AIBlock[GuideInput, GuideOutput, dict])¶
Full-featured guide with 26 MCP operations.
| Field | Type | Default |
|---|---|---|
name | str | 'guide_mcp' |
state | dict \| None | None |
db_path | str | ':memory:' |
resource_bounds | ResourceBounds \| None | None |
usage | ResourceUsage | field(default_factory=ResourceUsage) |
Methods:
infer(data: Any) -> Result[GuideOutput]¶
GuideIndex¶
Searchable TF-IDF index of G6 components, tools, and clusters.
Methods:
get_corpus() -> list[dict[str, Any]]¶
Return the indexed corpus entries.
find_by_name(name: str, entry_type: str | None = None) -> list[dict[str, Any]]¶
Find corpus entries by name, optionally filtered by type.
build(components_root: Path | None = None) -> None¶
Scan components, tools, and clusters to populate the index.
search(query: str, top_k: int = 10) -> list[tuple[dict[str, Any], float]]¶
Cosine similarity search. Returns (metadata, score) descending.
boost_query(query: str, score: float) -> None¶
Record positive feedback for a query to influence future ranking.
get_boosts() -> dict[str, float]¶
Return accumulated query boosts from feedback.
stats() -> dict[str, Any]¶
Return index statistics.
GuideInput(BaseModel)¶
| Field | Type | Default |
|---|---|---|
op | GuideOp | required |
query | str | '' |
component | str | '' |
template_name | str | '' |
steps_json | str | '[]' |
top_k | int | 5 |
include_examples | bool | True |
output_format | str | 'json' |
tier | str | '' |
feedback_score | float | 0.0 |
feedback_text | str | '' |
reference_query | str | '' |
GuideOutput(BaseModel)¶
| Field | Type | Default |
|---|---|---|
op | str | required |
answer | str | '' |
recommendations | list[str] | Field(default_factory=list) |
scores | list[float] | Field(default_factory=list) |
template | dict[str, Any] | Field(default_factory=dict) |
pipeline_steps | list[dict[str, Any]] | Field(default_factory=list) |
diagram | str | '' |
metadata | dict[str, Any] | Field(default_factory=dict) |
count | int | 0 |
success | bool | True |
reasoning_trace | list[str] | Field(default_factory=list) |
degraded | bool | False |
degradation_reason | str \| None | None |
completion_state | Literal['verified', 'qualified-draft', 'blocked-escalated'] | 'qualified-draft' |
warning_card | dict[str, Any] | Field(default_factory=dict) |
evidence | dict[str, Any] | Field(default_factory=dict) |
request_id | str | '' |
task_id | str | '' |
run_id | str | '' |
GuideStore¶
Constructor:
| Parameter | Type | Default |
|---|---|---|
db_path | str | ':memory:' |
Methods:
save_template(name: str, description: str, steps: list[dict[str, Any]], effect_budget: dict[str, Any] | None = None) -> str¶
get_template(name: str) -> dict[str, Any] | None¶
list_templates(limit: int = 50) -> list[dict[str, Any]]¶
delete_template(name: str) -> bool¶
log_query(query: str, vector: list[float], results: list[dict[str, Any]]) -> str¶
save_training_data(query: str, vector: list[float], cluster: str, feedback: str) -> str¶
get_training_data(limit: int = 500) -> list[dict[str, Any]]¶
save_component_vector(component: str, vector: list[float]) -> str¶
get_component_vectors() -> dict[str, list[float]]¶
cache_explanation(key: str, explanation: str) -> str¶
get_explanation(key: str) -> str | None¶
get_recent_queries(limit: int = 20) -> list[dict[str, Any]]¶
Return recent queries from query_log, newest first.
count_all() -> dict[str, int]¶
MCP Tools¶
| Operation | Source |
|---|---|
guide_ask | guide_mcp |
guide_how_to | guide_mcp |
guide_find_tool | guide_mcp |
guide_find_component | guide_mcp |
guide_classify_task | guide_mcp |
guide_template_list | guide_mcp |
guide_template_get | guide_mcp |
guide_template_run | guide_mcp |
guide_template_create | guide_mcp |
guide_template_suggest | guide_mcp |
guide_index_rebuild | guide_mcp |
guide_index_stats | guide_mcp |
guide_explain_component | guide_mcp |
guide_explain_cluster | guide_mcp |
guide_explain_pipeline | guide_mcp |
guide_plan_workflow | guide_mcp |
guide_check_compatibility | guide_mcp |
guide_estimate_cost | guide_mcp |
guide_suggest_alternatives | guide_mcp |
guide_optimize_plan | guide_mcp |
guide_system_overview | guide_mcp |
guide_capability_map | guide_mcp |
guide_dependency_graph | guide_mcp |
guide_health_summary | guide_mcp |
guide_changelog | guide_mcp |
guide_reasoning_feedback | guide_mcp |