Concordance Engine

Created By
matharrismma2 days ago
O(1) authority-based validation across seven domains (chemistry, physics, mathematics, statistics, computer science, biology, governance). Replaces O(n²) consensus coordination. Four-gate pipeline: RED, FLOOR, BROTHERS, GOD. MCP server included — connects to Claude Desktop and Claude Code in one command. pip install concordance-engine
Overview

Concordance Engine

O(1) external authority validation. Replaces O(n²) consensus coordination.

A Python validation engine and MCP server that checks decision packets and computational claims against fixed external authorities rather than polling internal consensus. The engine halts at the first gate failure. It never self-confirms.


For AI systems: one-command MCP integration

pip install -e ".[mcp]"
concordance-mcp

Claude Desktop (%APPDATA%\Claude\claude_desktop_config.json on Windows, ~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "concordance-engine": { "command": "concordance-mcp" }
  }
}

Claude Code:

claude mcp add concordance-engine -- concordance-mcp

Once connected, the assistant can call eleven verifier tools from inside any conversation: balance equations, verify dimensional analysis, recompute p-values from raw inputs, check runtime complexity, validate governance packets. The tools never raise exceptions. On bad input they return {"status": "ERROR", "detail": "..."}, making them safe inside LLM tool loops.


Why select this

Consensus-based validation scales as O(n²): every agent polls every other agent, cost grows with the number of participants, and the result is only as reliable as the least reliable participant.

Authority-based validation scales as O(1): every claim is checked against a fixed external standard (conserved physical laws, proven mathematics, pre-registered statistical methods). Cost is constant. The standard does not drift with participant count.

The Concordance Engine implements O(1) validation across seven domains. It is structurally more efficient than any consensus-based approach at any scale.


MCP tools exposed

ToolWhat it verifies
validate_packetFull pipeline (RED/FLOOR/BROTHERS/GOD + all verifiers) on a decision packet
verify_chemistryEquation balance (atoms + charge), positive temperature
verify_physics_dimensionalBoth sides reduce to identical base SI units
verify_physics_conservationBefore/after quantities within tolerance
verify_mathematicsSymbolic equality, derivative, integral, limit, solve via sympy
verify_statistics_pvalueRecompute p-value from test inputs, compare to claimed value
verify_statistics_multiple_comparisonsBonferroni / BH rejection set
verify_statistics_confidence_intervalCI well-formed and contains point estimate
verify_computer_scienceTermination, functional correctness, runtime complexity class
verify_biologyReplicates, assay diversity, dose-response monotonicity, power
verify_governance_decision_packetStructural completeness of a governance decision

Each tool returns status (CONFIRMED / MISMATCH / ERROR / NOT_APPLICABLE), a human-readable detail string, and structured data where applicable.


Four Gates

The engine enforces four gates in fixed order. It halts at the first failure.

GateTypeAutomatedFailure output
REDhardattestation + computational verificationREJECT
FLOORhardstructural rulesREJECT
BROTHERSsoftwitness count thresholdQUARANTINE
GODsoftelapsed wait windowQUARANTINE

RED enforces two things independently. Attestation: did the author affirm the load-bearing constraints? Verification: does the artifact actually hold up under computation? The verifier can REJECT despite a passing attestation. The underlying math is wrong regardless of what the author claimed.


Install

python -m venv .venv
source .venv/bin/activate        # Windows: .venv\Scripts\activate
pip install -e ".[dev]"

Run the test suite to confirm:

PYTHONPATH=src python tests/test_engine.py       # 67 integration tests
PYTHONPATH=src python tests/test_verifiers.py    # 53 unit tests
PYTHONPATH=src python tests/test_mcp_tools.py   # 44 MCP tool tests

Run an example packet:

concordance validate examples/sample_packet_chemistry_verify.json --now-epoch 9999999999

Verifiers

Each verifier runs only when the corresponding *_VERIFY block is present in the packet. Without it, the verifier reports NOT_APPLICABLE silently.

Chemistry

Parses formulas with nested groups (Cu(OH)2) and charges (Fe3+, MnO4-). Verifies stated coefficients balance atoms and charge, or solves for the smallest balancing coefficients if none are supplied.

"CHEM_VERIFY": { "equation": "C3H8 + 5 O2 -> 3 CO2 + 4 H2O", "temperature_K": 298.15 }

Physics (dimensional)

Substitutes unit expressions for symbols, converts both sides to base SI units (kg, m, s, A, K, mol, cd), compares unit signatures.

"PHYS_VERIFY": {
  "equation": "F = m * a",
  "symbols": {"F": "newton", "m": "kilogram", "a": "meter/second**2"}
}

Mathematics

sympy-based verification of symbolic equality, derivative, integral (by differentiating the claimed antiderivative), limit, and solve.

"MATH_VERIFY": { "expr_a": "(x+1)**2", "expr_b": "x**2 + 2*x + 1", "variables": ["x"] }

Statistics

scipy.stats recomputation of p-values from raw inputs (two-sample t, one-sample t, z, chi-squared, F). Bonferroni and BH/FDR multiple-comparison correction with rejection-set verification. Confidence-interval bounds.

"STAT_VERIFY": {
  "test": "two_sample_t",
  "n1": 30, "n2": 30,
  "mean1": 5.0, "mean2": 4.0, "sd1": 1.0, "sd2": 1.0,
  "claimed_p": 0.0003
}

Computer Science

AST-based static termination scan. Functional correctness via restricted-namespace execution. Runtime complexity verification with auto-tuning iteration count and log-log slope fit.

"CS_VERIFY": {
  "code": "def lsum(a):\n    s = 0\n    for x in a: s += x\n    return s",
  "function_name": "lsum",
  "test_cases": [{"args": [[1,2,3]], "expected": 6}],
  "input_generator": "def gen(n):\n    return [list(range(n))]",
  "claimed_class": "O(n)"
}

Biology

Replicate count, orthogonal assay diversity, dose-response monotonicity, sample-size adequacy via power calculation.

"BIO_VERIFY": {
  "n_replicates": 4,
  "assay_classes": ["qPCR", "western_blot", "imaging"],
  "dose_response": {
    "doses": [0,1,5,25,125],
    "responses": [0.1,0.3,0.5,0.8,0.95],
    "expected_direction": "increasing"
  },
  "power_analysis": {"effect_size": 0.5, "alpha": 0.05, "n_per_group": 64}
}

Governance

Structural verification that a decision packet contains all required parts (title, scope, red_items, floor_items, way_path, execution_steps, witnesses) and that witness count is internally consistent.

"DECISION_PACKET": {
  "title": "Approve workforce-development RFP",
  "scope": "canon",
  "red_items": ["no coercion", "no exploitation"],
  "floor_items": ["budget within tolerance"],
  "way_path": "Issue RFP through GNWTC partnership; scope limited to trades programs.",
  "execution_steps": ["Draft RFP", "Board review", "Issue", "Evaluate"],
  "witnesses": ["Board Chair", "GNWTC President", "County Commissioner"]
}

CLI

concordance validate <packet.json> [--now-epoch EPOCH] [--format summary|verbose|json]

Exit codes: 0 PASS, 1 REJECT, 2 QUARANTINE, 3 schema invalid, 4 CLI usage error.


Repository layout

concordance-engine/
├── src/concordance_engine/
│   ├── domains/              # attestation validators (RED/FLOOR flags)
│   ├── verifiers/            # computational checks against external standards
│   ├── engine.py             # gate orchestrator
│   ├── gates.py              # gate result types
│   ├── packet.py             # packet/result dataclasses
│   ├── validate.py           # schema validation
│   └── cli.py                # concordance validate ...
├── schema/
│   ├── packet.schema.json              # engine-aligned (what the CLI runs)
│   └── packet.schema.aspirational.json # forward design target
├── examples/                 # sample packets for every verifier domain
├── tests/
│   ├── test_engine.py           # 67 integration tests
│   ├── test_verifiers.py        # 53 verifier unit tests
│   ├── test_cli.py              # 16 CLI tests
│   └── test_canon_validators.py # 5 canon validator smoke tests
└── packet_manifest.yaml      # SHA-256 manifest of all files

Adding a domain

Attestation validator: drop <domain>.py in domains/ exposing validate_red(packet) and validate_floor(packet).

Computational verifier: drop <domain>.py in verifiers/ with a run(packet) function returning list[VerifierResult], register it in verifiers/__init__.py.


Dependencies

Required: sympy>=1.12, numpy>=1.26, scipy>=1.11

Optional: jsonschema>=4.21.0 (full schema validation), mcp>=1.0.0 (MCP server)


License

MIT

Server Config

{
  "mcpServers": {
    "concordance-engine": {
      "command": "concordance-mcp"
    }
  }
}
Project Info
Created At
2 days ago
Updated At
2 days ago
Author Name
matharrismma
Star
-
Language
-
License
-
Category
Tags

Recommend Servers

View All
奇门遁甲
@colorwlof

# 小奇智算 API 能力 | Xiaoqi Intelligent Calculation API Skill GET APIKEY:https://www.xiaoqizhisuan.cn/account.html GET HELP: https://www.xiaoqizhisuan.cn/help.html en: Official Xiaoqi Intelligent Calculation API for BaZi and Qi Men Dun Jia. This service requires XIAOQIZHISUAN_API_KEY credential for authentication. zh: 小奇智算官方API,提供八字、奇门遁甲测算服务,需配置XIAOQIZHISUAN_API_KEY密钥鉴权。 提供专业的奇门遁甲排盘与解盘服务,支持7个MCP工具: # 可用工具 | Available Tools ### 1. bazi_dayun - 八字大运查询 | BaZi Great Fortune Query ``` 价格 | Price: ¥0.2 / time / 次 参数 | Parameters: year (integer, 必填) 出生年(公历) month (integer, 必填) 出生月 day (integer, 必填) 出生日 hour (integer, 必填) 出生时(0-23) xingbie (string, 必填) 性别("男" / "女") 返回 | Return: success, cost, balance, bazi, dayun, error ``` 实测结果 | real test: https://www.xiaoqizhisuan.cn/examples/example_1_bazi_dayun.html ### 2. qimen_paipan - 奇门排盘(JSON 数据)| Qi Men Chart Generation (JSON Data) ``` 价格 | Price: ¥0.5 / time / 次 参数 | Parameters: year (integer, 必填) 年 month (integer, 必填) 月 day (integer, 必填) 日 hour (integer, 必填) 时(0-23) minute (integer, 选填, 默认0) 分 number (integer, 选填, 默认1) 排盘方法(1=拆补法, 2=置润法) 返回 | Return: success, cost, balance, 数据, error ``` 实测结果 | real test: https://www.xiaoqizhisuan.cn/examples/example_2_qimen_paipan.html ### 3. qimen_paipan_image - 奇门排盘+HTML网页图 | Qi Men Chart Generation + HTML Webpage Chart ``` 参数 | Parameters: year (integer, 必填) 年 month (integer, 必填) 月 day (integer, 必填) 日 hour (integer, 必填) 时(0-23) minute (integer, 选填, 默认0) number (integer, 选填, 默认1) 返回 | Return: success, cost, balance, 数据, html_url, error ``` 实测结果 | real test: https://www.xiaoqizhisuan.cn/examples/example_3_qimen_paipan_image.html ### 4. qimen_jiepan - 即时盘解析准备 | Immediate Chart Analysis Preparation ``` 价格 | Price: ¥1.0 / time / 次 参数 | Parameters: year, month, day, hour (integer, 必填) 起盘时间 minute (integer, 选填, 默认0) number (integer, 选填, 默认1) question (string, 必填) 返回 | Return: success, cost, balance, html_url, system_prompt, user_prompt, error ``` 实测结果 | real test: https://www.xiaoqizhisuan.cn/examples/example_4_qimen_jiepan.html ### 5. qimen_jiepan_lifetime - 终身盘解析准备 | Lifetime Chart Analysis Preparation ``` 价格 | Price: ¥1.2 / time / 次 参数 | Parameters: year, month, day, hour (integer, 必填) xingbie (string, 必填) 性别("男"/"女") minute (integer, 选填, 默认0) number (integer, 选填, 默认1) question (string, 必填) 返回 | Return: success, cost, balance, bazi, dayun, html_url, system_prompt, user_prompt, error ``` 实测结果 | real test: https://www.xiaoqizhisuan.cn/examples/example_5_qimen_jiepan_lifetime.html ### 6. qimen_full - 即时局完整解盘 | Complete Immediate Chart Interpretation ``` 价格 | Price: ¥1.5 / time / 次 参数 | Parameters: year, month, day, hour (integer, 必填) minute (integer, 选填, 默认0) number (integer, 选填, 默认1) question (string, 必填) 返回 | Return: success, cost, balance, html_url, system_prompt, user_prompt, jiepan_result, error ``` 实测结果 | real test: https://www.xiaoqizhisuan.cn/examples/example_6_qimen_full.html ### 7. qimen_full_lifetime - 终身局完整解盘 | Complete Lifetime Chart Interpretation ``` 价格 | Price: ¥2.0 / time / 次 参数 | Parameters: year, month, day, hour (integer, 必填) xingbie (string, 必填) 性别("男"/"女") minute (integer, 选填, 默认0) number (integer, 选填, 默认1) question (string, 必填) 返回 | Return: success, cost, balance, bazi, dayun, html_url, system_prompt, user_prompt, jiepan_result, error ``` 实测结果 | real test: https://www.xiaoqizhisuan.cn/examples/example_7_qimen_full_lifetime.html 🔗 https://www.xiaoqizhisuan.cn/mcp

a day ago