Reasoning Engine

Architecture

All components are implemented in core/reasoning/.

1. engine.py — ReasoningOrchestrator

Single entry point for all AI operations. Processes goals through the pipeline: goal -> plan -> prompt -> AI -> validate -> result. Provides inspect_reasoning(goal_id) to retrieve cached results.

2. goals.py — Goal System

GoalType (18 enums): threat_modeling, payload_selection, verification, risk_assessment, planning, executive_report, technical_report, mitigation_recommendation, classification, summarization, purple_team, recon, fingerprint, exploit_dev, coverage_analysis, gap_analysis, custom, learning

GoalPriority (5 levels): critical, high, medium, low, info

GoalStatus lifecycle: PENDING -> PLANNING -> PROCESSING -> COMPLETED | FAILED | CANCELLED

Goal dataclass fields: id, type, priority, status, objective, context, reasoning_result, created_at, completed_at, error

3. planner.py — ReasoningPlanner

4. prompts.py — ReasoningPromptManager

5. validator.py — OutputValidator

6. formatter.py — ReasoningResult

Structured result containing: content, goal_type, confidence, evidence, consensus, decision_trace, provider, model, latency_ms, token_usage, cost_estimate

Supports to_dict() and from_dict() serialization.

7. policies.py — PolicyManager & ReasoningSafetyLevel

Safety levels (5): SAFEST, SAFE, BALANCED, ADVENTUROUS, RESEARCH

Each level defines: allowed_topics, max_confidence_threshold, require_citation, require_human_review, allowed_providers, max_tokens, max_cost

Uses PRESET_POLICIES for each level.

8. consensus.py — ConsensusEngine

9. confidence.py — ConfidenceScorer

Confidence levels (7): NONE, VERY_LOW, LOW, MEDIUM, HIGH, VERY_HIGH, CERTAIN

Aggregation strategies: mean, median, max, min, weighted

Method: combine(results, strategy) returns aggregated confidence score.

10. memory.py — ReasoningMemory


Flow

  1. Agent creates a Goal
  2. ReasoningOrchestrator receives the goal
  3. ReasoningPlanner creates a plan
  4. ReasoningPromptManager builds the prompt
  5. AIProvider executes the request
  6. OutputValidator validates the response
  7. (Optional) ConsensusEngine aggregates multi-provider results
  8. ConfidenceScorer scores the result
  9. ReasoningResult is returned
  10. Agent consumes the result

Safety


CLI

hunterx reasoning inspect <goal_id>
hunterx reasoning validate --output "..."

REST API

Method Endpoint Description
POST /goals Create a goal
GET /reasoning/{goal_id} Get reasoning result
POST /reasoning/validate Validate output