Phase1 skeleton: replace demo main.py with src.server contract

- Overlay ModelHub XC Phase1 (health/status, STRATEGY_ID gate, dry-run)
- Dockerfile CMD -> python -m src.server; FROM stays platform TCR base
- Remove demo main.py and requirements.txt (stdlib only)
- Add tests/, scripts/, docs/, Makefile, config/examples (no secrets)
This commit is contained in:
VC_noSugar
2026-10-16 15:47:10 +08:00
parent 26351cefee
commit 0d0f3b611a
31 changed files with 1436 additions and 106 deletions

View File

@@ -1,39 +1,74 @@
# Strategy Platform Demo Repo
# modelhub-agent-contrib
Minimal strategy repository for testing the platform Kaniko build and deployment flow.
ModelHub XC(信创模盒)**适配智能体** Phase1 本地骨架。
It satisfies the runtime contract from the parent README:
> **不代注册、不代提交。** 发布智能体本身 **不得分**。积分来自成功适配,数字一律 **待平台核实**。
> 冲突裁决:**适配 W1 优先**;本仓默认 dry-run,不抢验证队列。
- Root-level `Dockerfile`
- Listens on port `8080`
- Exposes `GET /health`
- Reads `EXTERNAL_SERVICE_TOKEN`
- Handles `SIGTERM` for graceful shutdown
## 契约要点
## Local Run
| 项 | 值 |
|----|-----|
| 端口 | 8080 |
| 健康检查 | `GET /health` → `{"status":"ok"}` |
| 启动 | **必须**有非空 `STRATEGY_ID`,否则 exit ≠0 |
| Live | `ALLOW_LIVE_SUBMIT=1` **且** `LIVE_CONFIRM=I_CONFIRM_LIVE_SUBMIT`;Phase1 仍无真实 `task/add` 客户端 |
| Base 镜像 | 平台 `xc_agent_platform/python:3.11-slim`(勿擅自改默认 FROM) |
闸门以 `src/gate.py` 实现为准:仅 `ALLOW_LIVE_SUBMIT=1` 与
`LIVE_CONFIRM=I_CONFIRM_LIVE_SUBMIT` 同时满足才开逻辑闸门。PRD 示例
`ALLOW_LIVE_SUBMIT=true` / `CONFIRM_LIVE=YES` 不受支持;本仓不读取确认文件。
即使开闸,无真实客户端仍返回 blocked;请保持默认关闭。
## 快速开始
```bash
python main.py
curl http://localhost:8080/health
curl http://localhost:8080/
cd /workspace/modelhub-agent-contrib
make test
make smoke-health # 自动起本地 server(需 STRATEGY_ID,脚本可注入测试值)
make dry-run # 写出 reports/dry-run-*.md
make build # 需 Docker + 可达平台 base;失败见 docs/build-notes.md
```
## Build Locally
本地起服务:
```bash
docker build -t strategy-demo:v1.0.0 .
docker run --rm -p 8080:8080 strategy-demo:v1.0.0
export STRATEGY_ID=local-dev
python3 -m src.server
# → http://127.0.0.1:8080/health
```
## Platform Test
## 目录
Push this directory to Gitea and keep the `v1.0.0` tag. Then create a strategy with:
```json
{
"name": "strategy-demo",
"repo_url": "https://<your-gitea-host>/<user>/strategy-demo",
"tag": "v1.0.0"
}
```text
Dockerfile Makefile README.md
src/ # server / health / strategy / gate
config/ # example.env, candidates.example.json
scripts/ # smoke_health.py, dry_run.py, tag_release.py
reports/ # dry-run 输出(gitignore)
docs/ # 契约 / runbook / kickoff / issues
tests/ # stdlib unittest
```
## Makefile 目标
- `test` / `build` / `smoke-health` / `dry-run`
- **没有** `register` / `submit` / `deploy` / `push`
## 文档
- [`docs/kickoff-for-victor.md`](docs/kickoff-for-victor.md) — 一页开工 + 验收勾选
- [`docs/platform-contract-agent.md`](docs/platform-contract-agent.md) — 契约表
- [`docs/register-runbook.md`](docs/register-runbook.md) — 仅人工注册
- [`docs/api-probe-design.md`](docs/api-probe-design.md) — 写接口禁止代调
- [`docs/diff-vs-demo.md`](docs/diff-vs-demo.md) — 对照官方 demo
- [`docs/issues.md`](docs/issues.md) — M0–M4 / Phase 清单
- [`docs/build-notes.md`](docs/build-notes.md) — 镜像构建说明
## 资源声明
按平台量级设计:约 **100m–1 CPU / 256–512Mi**。
## 许可与边界
本仓库用于 Victor 本地/Gitea 交付骨架;任何 ModelHub 写操作须 Victor 本人在控制台或显式批准后执行。