verify_hallucination_guard
Verify proposed Python code against local AST signatures to catch hallucinated imports and wrong function/method call contracts before applying AI-generated changes.
Instructions
Eliminates AI coding hallucinations before code is written or applied. Parses proposed code and verifies all internal imports and function/method call contracts (argument counts and keyword parameter names) against known workspace AST signatures.
Behavior:
Read-only: Compares AST call signatures against local symbol catalog; does not modify source files.
Idempotent: Deterministic contract verification.
100% Offline: Uses local AST indices without remote queries.
Usage Guidelines:
When to use: Run BEFORE applying AI-generated code to prevent hallucinated module imports, missing functions, or wrong argument counts.
Sibling Routing: To enforce layer boundary separation rules, use 'enforce_architecture_boundaries'.
Returns: Verification status report with specific contract mismatches and 'did you mean' fuzzy suggestions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target_file | No | Optional path of the target file being modified to resolve relative imports. | |
| project_root | No | Workspace root directory providing the ground-truth AST symbol catalog (default: current directory). | . |
| proposed_code | Yes | Python code proposed to be written or edited. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |