Skip to main content

MGIA 4.0 — Strategic Macro-Geopolitical Intelligence OS (autonomous agent)

Project description

MGIA 4.0 — Strategic Macro-Geopolitical Intelligence OS

CI codecov python license

Autonomous intelligence agent built on the principle:

The LLM is not the system's intelligence. It is an analytical interface over an intelligence infrastructure. DATA → EVIDENCE → CAUSALITY → SCENARIOS → ADVERSARIAL → MEMORY → ANALYSIS

See ARCHITECTURE.md for the full technical reference and magi v4.txt for the source spec.

Status

v0.2.1 — platform complete, first PyPI release. All 6 layers + orchestration, governance, observability, live data, and delivery surfaces. 233 tests passing (ruff + mypy clean).

Layer / Component Status
L1 Data Collection (JSON file · RSS/Atom · JSON-API/NewsAPI · Reddit · GDELT)
L2 Trust & Validation
L3 Causal Intelligence
L4 Scenario Intelligence
L5 Institutional Memory
L6 Strategic Analysis (Mock + real DeepSeek/OpenAI-compat LLM)
Observability + Governance engines
Master Orchestrator + CLI
Reproducibility cache · fault-tolerant collection
HTTP serve (auth · rate-limit · HTML dashboard)
Report export (Markdown · HTML · PDF)
Packaged wheel/sdist (BUSL-1.1)

Verified on a live provider

In addition to the mock-based automated test suite, MGIA has been validated end-to-end against a live DeepSeek endpoint.

The validation exercised the complete six-layer pipeline, including governance (validated=True). Numerical metrics (including confidence) are produced deterministically by the pipeline, while the LLM is used only to generate the narrative report.

See docs/live-smoke-v0.2.1.md.

Quickstart

cd projects/magi
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"          # or: make install
python -m pytest -q               # 233 tests

CLI Usage

# Ask a strategic question (full 6-layer pipeline)
python -m mgia ask "What are the implications of BRICS expansion?"

# Deployment mode / output formats
python -m mgia ask "Question?" --mode institutional
python -m mgia ask "Question?" -f json
python -m mgia ask "Question?" -f html -o report.html
python -m mgia ask "Question?" -f pdf  -o report.pdf

# Load a config file (live feeds, cache, source APIs, LLM provider)
python -m mgia --config examples/config.json ask "Question?"

# Reproducibility check (same input twice)
python -m mgia --config examples/config.json verify "Question?"

# System status / institutional memory / governance lint
python -m mgia status
python -m mgia memory
python -m mgia lint

# HTTP API (optional auth + rate limit); dashboard at /dashboard
python -m mgia --config examples/config.json serve --port 8080 \
    --token "$MGIA_API_TOKEN" --rate-limit 60

# Version
python -m mgia --version

Real LLM (DeepSeek / OpenAI-compatible): set MGIA_LLM_API_KEY (or DEEPSEEK_API_KEY) and use --config examples/config.deepseek.json.

Python API

from mgia.config import MGIAConfig, DeploymentMode
from mgia.orchestrator import MGIA

# Initialise with defaults
mgia = MGIA()

# Full pipeline
report, markdown = mgia.ask("What are the implications of BRICS expansion?")
print(report.confidence_summary.overall_confidence)
print(markdown[:200])

# System status
status = mgia.status()
print(status["layers"])

# Governance checks
lint = mgia.lint()
print(lint["all_passed"])

# Memory summary
mem = mgia.memory_status()
print(mem["learning_count"], "learnings stored")

Deployment Modes

Mode Red Team Scenario Killers Governance
calibration 50% aggressive relaxed
standard 35% normal relaxed
institutional 100% mandatory strict

Configuration

Via MGIAConfig (pydantic model, load from JSON, env vars, or defaults):

from mgia.config import MGIAConfig, DeploymentMode

config = MGIAConfig(
    mode=DeploymentMode.STANDARD,
    data_dir="examples",
    memory_path="memory/custom_memory.json",
    log_dir="reports/logs",
)

# Or from environment variables: MGIA_MODE, MGIA_DATA_DIR, etc.
config = MGIAConfig.from_env()

# Or from file:
config = MGIAConfig.from_file("config.json")

Project Structure

projects/magi/
  ARCHITECTURE.md            Technical reference
  IMPLEMENTATION_PLAN.md     Step-by-step build plan
  magi v4.txt                Source specification (frozen)
  README.md                  This file
  pyproject.toml             Package metadata + CLI entry point
  LICENSE                    Business Source License 1.1
  CHANGELOG.md               Release notes
  Makefile                   test / lint / typecheck / run / serve / build
  mgia/
    __init__.py              __version__
    config.py                MGIAConfig, DeploymentMode, LLMConfig
    orchestrator.py          MGIA — master orchestrator
    cli.py                   CLI: ask, status, memory, lint, verify, serve
    server.py                HTTP API (serve) + dashboard + auth/rate-limit
    report_export.py         Markdown/HTML/PDF export
    observability.py         ObservabilityEngine, MetricsCollector
    governance.py            GovernanceEngine, GovernancePolicy
    layer1_data/             Sources (file · RSS · JSON-API/NewsAPI · Reddit · GDELT · cache), collector
    layer2_trust/            Source trust, data quality, bias auditor
    layer3_causal/           Event graph engine, confidence, builder
    layer4_scenario/         Bayesian, adversarial, scenario killer, orchestrator
    layer5_memory/           Pattern store, learning loop, persistence
    layer6_strategic/        LLM interface (Mock + OpenAICompatBrain), report builder
  examples/                  config.json, config.deepseek.json, config.live.json, …
  tests/                     test suite

License

MGIA 4.0 is licensed under the Business Source License 1.1 (BUSL-1.1) — see LICENSE.

  • Source-available: you may copy, modify, and make non-production use freely.
  • Production use requires a commercial license from the Licensor (ooopalladiumsb) until the Change Date — Additional Use Grant: None.
  • On the Change Date (2030-07-08), each released version automatically converts to the Apache License 2.0.

For commercial-license inquiries, contact the Licensor.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mgia-0.2.1.tar.gz (97.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mgia-0.2.1-py3-none-any.whl (92.3 kB view details)

Uploaded Python 3

File details

Details for the file mgia-0.2.1.tar.gz.

File metadata

  • Download URL: mgia-0.2.1.tar.gz
  • Upload date:
  • Size: 97.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mgia-0.2.1.tar.gz
Algorithm Hash digest
SHA256 1ed1a6d5715c6f745b45f0f0c4ac9372d141f35531b6a39710425c1ad28dbd60
MD5 392c63c7d1ea1a88fc492298bfe0aa70
BLAKE2b-256 017544241d8747ab470df04869e81567ae9156031296e89332f0c3a27ff05508

See more details on using hashes here.

File details

Details for the file mgia-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: mgia-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 92.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mgia-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d880ba4df7ebae995b9254b01ea218d4d6b7ea67f96280cca5db3d2ffa668c21
MD5 78b79eb573688514490c09b599faf218
BLAKE2b-256 5ad6d07c5cc9f168472b8b0efd0af4868f9553939332b577b1922af3366cf2f0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page