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;
48pub mod ai_response;
49pub mod ai_studio;
50pub mod behavioral_cloning;
51pub mod behavioral_economics;
52/// Cross-protocol consistency engine (#555 phase 7 — moved from
53/// `mockforge_core::consistency` because its only foreign-to-core deps
54/// (`Protocol`, `RealityLevel`, `mockforge-data` persona types) were
55/// all available from foundation / intelligence / data, and the
56/// consistency HTTP handler needed to follow into intelligence under
57/// the #555 bucket plan).
58#[cfg(feature = "advanced")]
59pub mod consistency;
60pub mod contract_validation;
61/// Postgres pool wrapper used by HTTP handlers that persist drift
62/// budgets / incidents / consumer contracts. Moved here from
63/// `mockforge_http::database` under #555 (prereq for handler moves —
64/// once handlers leave `mockforge-http`, they pick up this dep without
65/// re-introducing a cycle). Gated by the `database` feature.
66#[cfg(feature = "database")]
67pub mod database;
68/// Deceptive-canary endpoint configuration types (#555 phase 6 — moved
69/// out of `mockforge-core` because its only callers are the (still in
70/// http) middleware + the deceptive_canary HTTP handler, and keeping
71/// the module here lets the eventual handler move follow). Self-contained.
72pub mod deceptive_canary;
73pub mod failure_analysis;
74/// Mock-quality fidelity scoring (#555 phase 6 — moved out of
75/// `mockforge-core`). Self-contained pure-Rust scoring with no foreign
76/// deps.
77pub mod fidelity;
78/// HTTP handlers for AI-coupled features. New in #555 phase 2 — see
79/// `handlers/mod.rs` for migration progress.
80pub mod handlers;
81pub mod incidents;
82pub mod intelligent_behavior;
83pub mod pr_generation;
84pub mod reality;
85/// Scenario Studio — visual editor for co-editing business flows
86/// (#555 phase 7 — moved out of `mockforge-core`; only foreign ref was
87/// `crate::error::{Error, Result}` which is already a re-export of
88/// `mockforge_foundation::error`).
89#[cfg(feature = "advanced")]
90pub mod scenario_studio;
91pub mod threat_modeling;
92pub mod voice;