mockforge_intelligence/lib.rs
1// Some ai_response helpers are themselves deprecated in favor of
2// mockforge-template-expansion; internal tests still reference them.
3#![allow(deprecated)]
4
5//! AI-powered intelligence for MockForge
6//!
7//! This crate contains modules extracted from `mockforge-core` related to
8//! intelligent behavior, AI response generation, and behavioral cloning.
9//!
10//! Currently migrated:
11//! - `ai_response`: Typed AI response generation helpers
12//! - `behavioral_cloning`: Probability models, sequence learning, edge amplification
13//! - `pr_generation`: GitHub/GitLab PR generation client (Issue #562 phase 1 —
14//! moved out of `mockforge-core` because it only depends on
15//! `mockforge_foundation::Error`, no other core internals)
16//! - `intelligent_behavior`: LLM-driven behavior model, persona-aware response
17//! generation, OpenAPI-backed example/rule generation (Issue #562 phase 2 —
18//! the AI cluster's leaf module, depends only on `mockforge-openapi` and
19//! `mockforge-foundation`)
20//! - `threat_modeling`: LLM-driven security analyzer (DoS / PII / schema /
21//! error / threat / remediation generators) for the contract-drift pillar
22//! (Issue #562 phase 3). Depends only on sibling `intelligent_behavior` +
23//! `mockforge-openapi` + `mockforge-foundation`.
24//! - `ai_contract_diff`: LLM-assisted OpenAPI diff with semantic analysis,
25//! confidence scoring, recommendations, and correction proposals (Issue #562
26//! phase 4). Records `ai_generation` pillar usage via the now-foundation
27//! `pillar_tracking` global, so the analytics dashboard keeps reflecting
28//! contract-diff activity unchanged.
29//! - `contract_validation`: OpenAPI-spec-to-response contract validator (Issue
30//! #562 phase 5). Single file; depends only on `serde` + `mockforge-openapi`
31//! + `mockforge-foundation::pillar_tracking`.
32//! - `failure_analysis`: LLM-driven failure context + narrative generator
33//! (Issue #562 phase 5). Depends only on sibling `intelligent_behavior`.
34//! - `behavioral_economics`: Declarative + scriptable rule engine that makes
35//! mocks react to pressure, load, pricing, fraud, and customer segments
36//! (Issue #562 phase 8). Self-contained — the only core-side dep was
37//! `crate::Result`, now sourced from `mockforge-foundation` directly.
38//! - `incidents`: AI-coupled pieces of drift-incident management — semantic
39//! incident manager (built on `ai_contract_diff::semantic_analyzer`) and
40//! Jira/Slack/webhook integrations (Issue #562 phase 9). The structural
41//! `IncidentManager` and in-memory `IncidentStore` stay in `mockforge-core`;
42//! the shared types (`DriftIncident`, `IncidentSeverity`, ...) live in
43//! `mockforge_foundation::incidents_types`. Core re-exports this module so
44//! the legacy `mockforge_core::incidents::{semantic_manager, integrations,
45//! slack_formatter, jira_formatter}` paths keep resolving.
46
47pub mod ai_contract_diff;
48/// HTTP-side AI response handler combining `IntelligentMockGenerator`
49/// + `DataDriftEngine` (#656 — post-#555 follow-up). Moved from
50/// `mockforge_http::ai_handler`; original `mockforge_core::{Result,
51/// Error}` imports now resolve directly to `mockforge_foundation`, so
52/// the move is cycle-safe.
53pub mod ai_handler;
54pub mod ai_response;
55pub mod ai_studio;
56pub mod behavioral_cloning;
57pub mod behavioral_economics;
58/// Cross-protocol consistency engine (#555 phase 7 — moved from
59/// `mockforge_core::consistency` because its only foreign-to-core deps
60/// (`Protocol`, `RealityLevel`, `mockforge-data` persona types) were
61/// all available from foundation / intelligence / data, and the
62/// consistency HTTP handler needed to follow into intelligence under
63/// the #555 bucket plan).
64#[cfg(feature = "advanced")]
65pub mod consistency;
66pub mod contract_validation;
67/// Postgres pool wrapper used by HTTP handlers that persist drift
68/// budgets / incidents / consumer contracts. Moved here from
69/// `mockforge_http::database` under #555 (prereq for handler moves —
70/// once handlers leave `mockforge-http`, they pick up this dep without
71/// re-introducing a cycle). Gated by the `database` feature.
72#[cfg(feature = "database")]
73pub mod database;
74/// Deceptive-canary endpoint configuration types (#555 phase 6 — moved
75/// out of `mockforge-core` because its only callers are the (still in
76/// http) middleware + the deceptive_canary HTTP handler, and keeping
77/// the module here lets the eventual handler move follow). Self-contained.
78pub mod deceptive_canary;
79pub mod failure_analysis;
80/// Mock-quality fidelity scoring (#555 phase 6 — moved out of
81/// `mockforge-core`). Self-contained pure-Rust scoring with no foreign
82/// deps.
83pub mod fidelity;
84/// HTTP handlers for AI-coupled features. New in #555 phase 2 — see
85/// `handlers/mod.rs` for migration progress.
86pub mod handlers;
87pub mod incidents;
88pub mod intelligent_behavior;
89pub mod pr_generation;
90/// RAG-based `AiGenerator` implementation (#555 phase 10 — moved from
91/// `mockforge_http::rag_ai_generator`). Both foreign deps
92/// (`AiResponseConfig`, `AiGenerator` trait) were promoted out of
93/// `mockforge-core` to `mockforge-foundation` and `mockforge-openapi`
94/// respectively, so this move stays cycle-safe with the Issue #562
95/// cycle-break.
96pub mod rag_ai_generator;
97pub mod reality;
98/// Scenario Studio — visual editor for co-editing business flows
99/// (#555 phase 7 — moved out of `mockforge-core`; only foreign ref was
100/// `crate::error::{Error, Result}` which is already a re-export of
101/// `mockforge_foundation::error`).
102#[cfg(feature = "advanced")]
103pub mod scenario_studio;
104pub mod threat_modeling;
105pub mod voice;