Metadata-Version: 2.4
Name: acps-math-multisolver
Version: 1.0.0
Summary: An acps-sdk 2.1.0 multi-agent workspace for exploring one mathematics problem through complementary paths. Algebra and Geometry agents solve in parallel; a Socratic agent turns both traces into progressive questions rather than premature answers. For Zhongkao/Gaokao finale problems, olympiad exploration and university proof seminars, it builds divergent thinking and auditable solution comparison. Includes a deterministic quadratic-function capstone and a local ACP mesh requiring no LLM API key.
Author: ACPs Math MultiSolver Engineering
License-Expression: MIT
Project-URL: Homepage, https://pypi.org/project/acps-math-multisolver/
Keywords: acps-sdk,multi-agent,mathematics,multiple-solutions,socratic-tutoring,divergent-thinking,exam-preparation
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Education
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: acps-sdk==2.1.0
Requires-Dist: fastapi>=0.100.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: uvicorn>=0.27.0
Provides-Extra: dev
Requires-Dist: build>=1.0.0; extra == "dev"
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: ruff>=0.6.0; extra == "dev"
Requires-Dist: twine>=5.0.0; extra == "dev"

# acps-math-multisolver

**数学一题多解启发多智能体协作工具**：基于 `acps-sdk 2.1.0`，让 Algebra Agent 与 Geometry Agent 并行构造独立解法，再由 Socratic Agent 读取双路径产物，生成“共同表征 → 分岔探索 → 双路径贯通”的连续追问。每次求解都保留 ADP 发现、AIP 任务和结构化产物记录。

## 命名与定位

**MultiSolver = Multiple + Solver**：不是把同一提示词复制给多个模型，而是用不同数学表征解决同一问题。`acps-` 表示任务分发、能力发现与通信均基于 ACPs SDK；`math` 表明面向数学学习。

面向中高考压轴题、竞赛题研讨与大学证明题课堂，它把“看懂标准答案”改造成“比较多种路径、解释路径为何等价、在追问中自己重建关键一步”。苏格拉底导师只给问题与按需支架，不在问题链中直接报最终答案。

## 协作机制

```text
                         ┌─ AIP task → Algebra Agent ─┐
Leader → ADP 能力发现 ───┤                            ├─ typed products → Socratic Agent
                         └─ AIP task → Geometry Agent ┘         │
                                                                 └─ 七轮问题链 → Leader fan-in
```

1. 三个 Agent 各自运行在独立的 loopback FastAPI/AIP v2 JSON-RPC 服务中，拥有合法 AIC 与 ACS 能力描述。
2. Leader 通过 `DiscoveryRequest` 和 `skills.tags` 过滤发现端点，使用 `AipRpcClient.start_task()` 并行派发给代数与几何 Agent。
3. 两个 `StructuredDataItem` 解法产品经 Pydantic 校验后，一起进入 Socratic Agent；结论不一致时导师拒绝生成启发，避免把错误路径教给学生。
4. 最终报告包含双解、启发记录、task ID、完成状态、耗时和在线 Agent，可审计而非单体函数伪装协作。

## 安装与一键演示

要求 Python 3.10+。在 PowerShell 中：

```powershell
cd acps-math-multisolver
python -m venv .venv
.\.venv\Scripts\python -m pip install -e ".[dev]"
.\.venv\Scripts\python run_demo.py
```

也可使用安装产生的命令：

```powershell
math-multisolver demo
math-multisolver demo --json       # 完整 typed product，便于接入学习系统
math-multisolver tutor             # 真人逐轮作答；:hint 支架，:quit 退出
math-multisolver --version         # 1.0.0
```

`run_demo.py` 自动模拟一名学生的七轮回答，但底层三个 Agent、ADP 发现、AIP 请求和结果回传均真实执行；无需 LLM API Key，也不需要外部服务。

### 自定义输入

```powershell
math-multisolver solve --problem "已知抛物线 y = -x² + 2x + 3 与 x 轴交于 A、B 两点（A 在 B 左侧），与 y 轴交于点 C。点 P 是抛物线弧 BC 上一动点（不与 B、C 重合）。(1) 求 A、B、C 的坐标；(2) 求 △PBC 面积的最大值及此时 P 的坐标。"
```

v1.0.0 内置经过验证的二次函数动点面积策略，用于可复现演示与协议集成；它不是伪装成通用数学 AI 的提示词包装器。未注册题型会明确报错，不会编造答案。新增题型时可扩展 `engine`，复用现有 ACP 编排与 typed contracts。

## 演示题与预期输出摘要

输入题：抛物线 `y=-x²+2x+3` 与 x 轴交于 A、B，与 y 轴交于 C；P 在弧 BC 上运动，求三个定点坐标以及 `△PBC` 面积最大值和对应 P。

```text
[acps-math-multisolver] 正在启动二次函数压轴题多解演示 ...
[acps-math-multisolver] 在线 Agent：Algebra Agent、Geometry Agent、Socratic Agent
========================================================================================
ACPs Math MultiSolver v1.0.0 | session=multisolve-...
SDK=acps-sdk 2.1.0 | 端到端耗时 ... ms | report=report-...
========================================================================================
[1/4] Algebra Agent · 代数路径：面积函数与配方
核心洞察：以动点横坐标为单变量，把面积转化为区间上的二次函数最值。
  1. ... A(−1,0)、B(3,0)；... C(0,3)。
  2. 设 P(t,−t²+2t+3)，其中 0<t<3。直线 BC 为 x+y−3=0。
  4. S(t)=...=−3/2(t−3/2)²+27/8。
结论：最大面积为 27/8，此时 P(3/2,15/4)。

[2/4] Geometry Agent · 几何路径：平行线平移与相切
核心洞察：固定底边后，面积最大等价于高最大；最远平行线的临界状态是相切。
  3. 作 l∥BC，设 l:x+y=k。... 临界位置是与抛物线相切，切点即所求 P。
  4. ... 相切要求 Δ=...=21−4k=0，故 k=21/4。
结论：最大面积为 27/8，此时 P(3/2,15/4)。

[3/4] Socratic Agent · 连续追问启发
导师 1：在 P 移动时，BC 的长度会改变吗？若把 BC 作为底，真正变化的量是什么？
学生 1：BC 的长度不变；面积变化来自 P 到 BC 的高。
导师 5：如果作一条与 BC 平行的直线并向抛物线外侧平移，何时达到‘仍有公共点’的最后位置？
学生 5：平行线向外平移，即将离开抛物线时的临界位置是相切。
导师 7：代数面积函数的顶点与几何路径的切点重合，是巧合吗？它们共同刻画了什么事实？
学生 7：不是巧合；... 都在刻画同一个‘到 BC 的距离最大’。

[4/4] AIP v2 协作审计
Algebra Agent | algebra-solution | completed | ... ms | task=task-...
Geometry Agent | geometry-solution | completed | ... ms | task=task-...
Socratic Agent | socratic-guidance | completed | ... ms | task=task-...
调度拓扑：(Algebra Agent ∥ Geometry Agent) → Socratic Agent → Leader
```

## 测试

```powershell
.\.venv\Scripts\python -m pytest
.\.venv\Scripts\python -m ruff check .
```

测试覆盖数学结果、区间条件、七轮启发不泄露最终答案、双路径一致性保护、不支持题型的失败行为，以及三个真实 AIP 任务的端到端往返。

## 构建 wheel 与上传 PyPI

```powershell
# 在开发虚拟环境中执行；构建 wheel 与 sdist 到 dist/
.\.venv\Scripts\python -m build

# 检查 METADATA、README 渲染与包描述
.\.venv\Scripts\python -m twine check dist/*

# 可选：先上传 TestPyPI 验证发布流程；密码提示中粘贴 TestPyPI API Token
.\.venv\Scripts\python -m twine upload --repository testpypi -u __token__ dist/*

# 正式发布；密码提示中粘贴 PyPI API Token
.\.venv\Scripts\python -m twine upload -u __token__ dist/*
```

不要把 API Token 写入代码、README 或命令历史。PyPI 不允许覆盖同版本文件；再次发布前必须提升 `pyproject.toml` 与 `identity.py` 中的版本号。上传是显式发布操作，本地构建和校验不会自动上传。

## 项目结构

```text
acps-math-multisolver/
├── pyproject.toml               # 1.0.0、acps-sdk==2.1.0、CLI、构建与质量工具
├── README.md                    # 安装、交互、演示、测试和 PyPI 发布说明
├── run_demo.py                  # 源码目录一键演示
├── src/math_multisolver/
│   ├── __init__.py              # 公共 API 与 __version__
│   ├── __main__.py              # python -m math_multisolver
│   ├── cli.py                   # demo / solve / tutor
│   ├── models.py                # AIP typed request/product/report
│   ├── identity.py              # AIC、ACS 与项目版本
│   ├── registry.py              # 基于 ADP 模型的能力注册与过滤发现
│   ├── runtime.py               # AIP v2 服务、任务生命周期与产品编解码
│   ├── mesh.py                  # 三个独立 Agent 服务生命周期
│   ├── orchestrator.py          # ADP 发现、并行 AIP 分发与 fan-in
│   ├── demo.py                  # 模拟对话、真人 tutor 与一键演示
│   ├── report.py                # 双解、启发记录与审计渲染
│   ├── py.typed                 # PEP 561 类型标记
│   ├── agents/
│   │   ├── base.py              # AIP handler 基类
│   │   ├── algebra.py           # Algebra Agent
│   │   ├── geometry.py          # Geometry Agent
│   │   └── socratic.py          # Socratic Agent
│   └── engine/
│       ├── quadratic.py         # 已验证双解与苏格拉底问题链
│       └── __init__.py
└── tests/test_workflow.py       # 单元与真实 AIP 集成测试
```

## License

MIT
