AGENTS.md
Guidance for coding agents working on LMSSEP Counterfactual Reasoning MCP Server. This server supports structured what-if analysis for incidents, risks, and improvement planning.
Project overview
The counterfactual workflow starts from an actual situation, generates alternative scenarios, performs deep reasoning, compares outcomes, and writes a Markdown session report. It supports diagnostic, predictive, preventive, and optimization scenario types.
Setup commands
bashcd <project-root>/genesis/LMSSEP/counterfactual_reasoning
pip install -r requirements.txt
python main.py
Configure server name, version, transport, log level, and optional HTTP port through environment variables. Use <PORT> in public docs.
Tool workflow
counterfactual_initializecreates a session and initial Markdown report.counterfactual_phase1records actual state and causal chain.counterfactual_phase2provides diagnostic, predictive, preventive, and optimization scenarios, selecting the next scenario type.counterfactual_phase3_step1applies minimal change, causal consistency, and proximity principles.counterfactual_phase3_step2throughstep5analyze direct impact, ripple effects, multidimensional effects, long-term evolution, and outcomes.counterfactual_phase4compares actual and counterfactual outcomes and records actions.counterfactual_get_result,reset, andlist_sessionssupport review and lifecycle management.
Code map
src/tools/counterfactual_reasoning.pyowns sessions, phase validation, Markdown updates, and result retrieval.configs/config.pyowns server and output configuration.src/utils/session_persistence.pyand validators provide shared utilities.
Testing and verification
Test the full happy path for one scenario type, an invalid phase order, missing required phase keys, completion of all scenario types, result retrieval, session listing, and reset.
Safety and output hygiene
Counterfactual reports often describe incidents. Remove customer names, private system names, endpoints, secrets, and internal timings before publishing. Treat recommendations as hypotheses until validated against real evidence.
Commit and PR rules
Changes to phase schema or Markdown report shape need a migration note and a sample sanitized output. Preserve strict phase ordering.