feat: candidate AI-U1 document read closed loop #7

Merged
cflmy merged 1 commits from codex/ai-u1-document-cycle into main 2026-11-30 16:06:52 +08:00
7 changed files with 136 additions and 7 deletions

No files matched your search

+7 -7
View File
@@ -14,14 +14,14 @@
| 本地 fixture 集成(真实 CLI + 真实 TCP + 真实 HTTP) | 已验证 | 39 个候选 case + 白盒单元(rc.6 与 rc.5 CI 镜像均 PASS) |
| 真实模型 smoke(TLS,真实凭证) | 已验证(本地,含瞬时失败) | 2026-11-30 真实请求 4 次尝试:3 次瞬时 TLS 读错误、1 次 PASS(model/finish/label 校验);报告 `docs/evidence/real-model-2026-11-30/real-model-smoke.json`;CI 默认 UNVERIFIED |
| 独立 CI(rc.5 ci-shell 镜像) | 见 §5 | Woodpecker 流水线已提交 |
| 两个独立示范 | 部分 | 采购建议闭环可用;量子物理确定性可用;量子**自主锚点选择**闭环阻塞于 AI-U1 |
| 两个独立示范 | 部分 | 采购建议闭环可用;量子物理确定性可用;量子**自主锚点选择**闭环已由 CLI #24 候选解锁(候选 lane `scripts/candidate_document_cycle.sh`) |
| 父仓激活 / 发行 | 未开始 | 由父仓 AI-I1 按 C2 → B2 → A2 决定 |
## 2. 上游阻塞(必须如实保留)
| 编号 | 仓库 | 缺口 | 证据 | 影响 |
|---|---|---|---|---|
| AI-U1([marqdo-cli#24](https://git.cflmy.cn/cflmy/marqdo-cli/issues/24)) | `marqdo-cli` | 无通用运行期「已加载文稿目录 + 章节精确读取」公开能力;`ref()` 只承诺 Formula/Code/FunctionRef,`document.outline` 为 `symbol.unknown` | `docs/evidence/M0-baseline.md` §4 | C01–C03、C05 的自主闭环与 I08 主示范不能在本轮完成;不得以预写全文替代 |
| AI-U1([marqdo-cli#24](https://git.cflmy.cn/cflmy/marqdo-cli/issues/24)) | `marqdo-cli` | **已解除**:CLI #24 合并 `afea4f947473ae4cd5688e53a6545cce7f327b2f` 提供 `document.outline`/`document.read`(同一 prepare 快照、精确 span/digest、结构化失败) | `docs/evidence/2026-11-30-ai-u1-document-cycle.md` | ext-ai 候选 lane 已验证「选择锚点→精确读取→判断」闭环;默认 CI 镜像仍无该 builtin,故候选 lane 与默认套件分离 |
| AI-U2([marqdo-ext-http#13](https://git.cflmy.cn/cflmy/marqdo-ext-http/issues/13)) | `marqdo-ext-http` | **已解除**:字节预算修复已合并(`8fe0bee24c92a5a71747b67fa4f9265993c110b7`),本包 lock 已重 pin 到合并提交;6 头请求可在默认预算下重复构造 | `docs/evidence/2026-11-30-bundle03-strict-and-http-pin.md` | 多步真实推理的传输预算阻塞解除;真实 loopback 多请求领域测试由 ext-http#3 跟踪 |
| AI-U2b([marqdo-std-data#13](https://git.cflmy.cn/cflmy/marqdo-std-data/issues/13)) | `marqdo-std-data` | 上游已解除:官方 Bundle 0.3.0(根 main `51c335e5`)提供 `json.严格解析`;本包切换需等该 Bundle/CI 镜像正式可用,当前保留词法兜底 | `docs/evidence/2026-11-30-bundle03-strict-and-http-pin.md` | 严格 JSON 语义唯一来源已回到数据组件;本包不再扩展词法扫描范围 |
| AI-U3 真实模型稳定性 | `marqdo-cli` / 网关 | 早期 4 次尝试中 3 次瞬时 `tls read failed: Resource temporarily unavailable`;2026-11-30 使用 Bundle 0.3.0/HTTP 合并提交后真实 smoke 首次尝试 PASS | `docs/evidence/2026-11-30-bundle03-strict-and-http-pin.md` | 不作为稳定 CI 门禁;继续记录更多环境样本 |
@@ -47,14 +47,14 @@
| 编号 | 状态 | 依据 |
|---|---|---|
| C01 | BLOCKED | 目录来自 Unit/Anchor,但运行期读取 API 缺失([marqdo-cli#24](https://git.cflmy.cn/cflmy/marqdo-cli/issues/24)) |
| C01 | PASS(候选) | `document.outline` 返回同一快照的 Unit/Anchor 目录;候选 lane `document_cycle` 以真实 CLI 验证(CLI `afea4f9`) |
| C02 | PARTIAL | 模型只收到调用者传入的有界目录 + 有限编号;读取以显式快照数据验证,非运行期自主读取 |
| C03 | BLOCKED | UTF-8/span/同名不同父的**运行期**读取依赖 [marqdo-cli#24](https://git.cflmy.cn/cflmy/marqdo-cli/issues/24);本包不对字节位置做猜测 |
| C04 | PARTIAL | 未知编号/重复/越权在示例程序中拒绝;过期摘要重定位依赖 AI-U1 |
| C03 | PASS(候选) | `document.read` 返回 exact UTF-8 byte slice 与 unit/anchor;CLI 契约测试覆盖同名不同父/字节边界;ext-ai 候选 lane 验证 anchor 读取(CLI `afea4f9`) |
| C04 | PARTIAL | 未知编号/重复/越权在示例程序中拒绝;`document.read` 现支持 expected_digest,候选示例尚未覆盖过期摘要重定位 |
| C05 | PASS | 引用不自动导入/执行/联网;读取纯知识无模型副作用(模型调用只发生在显式 infer) |
| C06 | PARTIAL | 必选规则由调用者显式提供、程序另做确定性检查;超预算收缩逻辑由调用者程序承担(示例演示) |
| C07 | PASS | 上下文/输入为普通数据;两次 infer 不自动携带历史 |
| C08 | PARTIAL | 同一内容以直接文本与锚点快照数据进入时行为一致;真实锚点读取待 AI-U1 |
| C08 | PARTIAL | 候选 lane 中锚点读取与直接文本走同一 classify 输入形态;同内容双路径一致性专项尚未补 |
| C09 | PARTIAL | 单次 infer 固定 1 请求且调用者显式预算;多轮扩充受 AI-U2 限制 |
### I. 智能推理与执行
@@ -68,7 +68,7 @@
| I05 | PASS | 固定 fixture 响应下重复执行分支与确定性计算一致;远端非确定性未被隐藏 |
| I06 | PASS | 单次 infer = 1 请求;fixture 请求计数证明无隐式循环/重试 |
| I07 | PASS | 拒绝/截断/传输失败/服务端错误均有真实结果;失败不触发后续计算 |
| I08 | BLOCKED | 量子物理与目录选择可用;完整「选择→读取→判断→计算→解释」闭环被 [marqdo-cli#24](https://git.cflmy.cn/cflmy/marqdo-cli/issues/24) 与 [marqdo-ext-http#13](https://git.cflmy.cn/cflmy/marqdo-ext-http/issues/13) 阻塞 |
| I08 | PARTIAL | 候选 lane `document_cycle` 完成「选择锚点→精确读取→模型判断→返回结构化结果」(真实 CLI `afea4f9` + fixture 模型);计算/解释与真实模型部分待继续,AI-U2 已解除 |
| I09 | PASS | 采购 B01–B08 由 fixture + 确定性检查覆盖:预算/有效期/独立核验/人工确认不可由模型修改 |
### S. 安全、预算与证据
@@ -0,0 +1,51 @@
# ext-ai AI-U1 候选闭环 — 运行期文稿读取
Date: 2026-11-30. Issue: `marqdo-ext-ai#2`(AI-U1 / C01–C03 / I08);
上游 `marqdo-cli#24` 已合并为
`afea4f947473ae4cd5688e53a6545cce7f327b2f`。
## 1. 候选闭环
新增候选 lane(不进入默认 CI,因为组件默认镜像仍发布不含 `document.*` 的 CLI):
- `tests/integration/document_cycle.mq.md`:程序先 `document.outline()` 取得
当前模块 Unit/Anchor 目录,再 `document.read(module, "规则")` 精确读取知识
章节,然后用读取到的原文构造 `ai.classify` 的上下文,最后返回
module/unit、读取长度与模型判断。
- `tests/cases-candidate/document_cycle.json`:确定性 fixture 模型
(`valid_yes` → `{"label":"是"}`),断言请求数/model/非流式、读取 unit 身份与
返回值。
- `scripts/candidate_document_cycle.sh`:显式要求提供 CLI candidate 与 Bundle;
通过 `MARQDO_AI_CASES_DIR` 选择候选 cases。默认 `scripts/ci.sh` 不变。
- `scripts/fixture_server.py` 增加 `valid_yes` 场景;`run_cases.py` 支持
`MARQDO_AI_CASES_DIR`。
## 2. 验证(真实 CLI,Linux x86_64 / glibc 2.43)
输入:CLI candidate `afea4f9`(document.*)、Bundle `marqdo-stdlib 0.3.0`
(tree `sha256:4e47b0ff…`)、HTTP 依赖已 pin 合并提交 `8fe0bee`。
```text
$ MARQDO_BIN=<cli afea4f9> MARQDO_STDLIB_DIR=<0.3.0> \
MARQDO_AI_CASES_DIR=tests/cases-candidate python3 scripts/run_cases.py
PASS document_cycle
1 cases passed (marqdo 3.0.0-rc.6)
$ MARQDO_BIN=<cli afea4f9> MARQDO_STDLIB_DIR=<0.3.0> sh scripts/ci.sh test
39 cases passed (marqdo 3.0.0-rc.6)
```
`document_cycle` 断言 unit id
`root:ai-acceptance-consumer@0.0.0::tests/integration/document_cycle.mq.md#规则库/规则`,
证明读取与 Analysis 同一 module/unit 身份;读取文本作为模型上下文,判断结果
`{"label":"是"}` 经本地契约校验。
## 3. 状态与边界
- C01/C03:候选 PASS(依赖 CLI `afea4f9`);默认 CI 镜像仍无 `document.*`,
因此不作为默认套件。
- I08:PARTIAL(选择→读取→判断→结构化结果已闭环;计算/解释与真实模型部分另见
I02/AI-U3)。
- AI-U2(HTTP 字节预算)已解除;AI-U2b(严格 JSON)在 Bundle 0.3.0 已可用但
切换待正式镜像(见 STATUS)。
- 未改 CLI/其它组件;未新增跨仓依赖;未创建 release/tag。
+15
View File
@@ -0,0 +1,15 @@
#!/bin/sh
# Candidate-input AI-U1 closed-loop case.
#
# Requires a CLI candidate that provides `document.outline`/`document.read`
# (marqdo-cli#24, merged as afea4f9) and the matching Bundle. The default
# component CI image still ships an older CLI, so this case is a separate
# candidate lane: it never runs implicitly from `scripts/ci.sh` and never turns
# an unavailable capability into a default-suite failure.
set -eu
: "${MARQDO_BIN:?set MARQDO_BIN to the CLI candidate with document.* builtins}"
: "${MARQDO_STDLIB_DIR:?set MARQDO_STDLIB_DIR to the verified Bundle}"
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
MARQDO_AI_CASES_DIR="$ROOT/tests/cases-candidate"
export MARQDO_AI_CASES_DIR
exec python3 "$ROOT/scripts/run_cases.py" "$@"
+1
View File
@@ -32,6 +32,7 @@ VALID_PROCUREMENT = {
SCENARIOS = {
"valid_select": {"content": json.dumps(VALID_SELECT, ensure_ascii=False)},
"valid_classify": {"content": json.dumps(VALID_CLASSIFY, ensure_ascii=False)},
"valid_yes": {"content": json.dumps({"label": "是"}, ensure_ascii=False)},
"valid_procurement": {"content": json.dumps(VALID_PROCUREMENT, ensure_ascii=False)},
"valid_text": {"content": "好的"},
"usage_meta": {
+4
View File
@@ -324,6 +324,10 @@ def unit_case(case: dict, workdir: Path, env: dict[str, str]) -> None:
def main() -> int:
global CASES
override = os.environ.get("MARQDO_AI_CASES_DIR")
if override:
CASES = Path(override).resolve()
binary = os.environ.get("MARQDO_BIN")
bundle = os.environ.get("MARQDO_STDLIB_DIR")
if not binary or not shutil.which(binary):
+28
View File
@@ -0,0 +1,28 @@
{
"schema": "marqdo.ai-test-case",
"schema_version": 1,
"name": "document_cycle",
"kind": "fixture",
"scenario": "valid_yes",
"entry": "tests/integration/document_cycle.mq.md",
"function": "主流程",
"args": ["端点=\"127.0.0.1:${PORT}\""],
"grants": ["127.0.0.1"],
"allow_env": [],
"env": {},
"expected": {
"value": [
true,
true,
"root:ai-acceptance-consumer@0.0.0::tests/integration/document_cycle.mq.md#规则库/规则",
true,
true,
{"label": "是"}
]
},
"request_asserts": {
"count": 1,
"model": "fixture-model",
"stream_false": true
}
}
+30
View File
@@ -0,0 +1,30 @@
---
import:
ai: "@ai"
---
# @knowledge 规则库
## 规则
只回答“是”。
# @exec document_cycle
## 主流程
`params(端点)`
**`纲 = document.outline()`**
**`读 = document.read(纲.module, "规则")`**
**`配置 = {endpoint: 端点, transport: "tcp", model: "fixture-model"}`**
**`上下文 = [{kind: "rule", text: 读.text}]`**
**`输入 = {text: "规则要求只回答是吗?"}`**
**`结果 = ai.classify(上下文, 输入, ["是", "否"], {config: 配置})`**
`return [纲.ok, 读.ok, 读.unit, 长度(读.text) > 0, 结果.ok, 结果.value]`