Add the candidate-input closed loop unlocked by marqdo-cli#24 (CLI afea4f9): the program selects the unit/anchor outline with document.outline, reads the exact knowledge section with document.read, feeds that exact source text to ai.classify and returns the structured identity/result. The default component CI image still ships a CLI without document.*, so this is a separate candidate lane (scripts/candidate_document_cycle.sh + MARQDO_AI_CASES_DIR); the default scripts/ci.sh and 39-case suite are unchanged and stay green. Fixture server gains a deterministic valid_yes scenario. STATUS updates AI-U1 resolved, C01/C03 candidate PASS, I08 PARTIAL (select->read->classify->structured result closed; compute/explain and real model continue). Evidence: docs/evidence/2026-11-30-ai-u1-document-cycle.md. No release, no new cross-repo dependency, no CLI/other component change.
marqdo-ext-ai
Marqdo AI 扩展库:为普通 .mq.md 程序提供受控的模型推理原语。它负责模型协议数据与推理编排;传输入、通用数据、权限与执行语义由现行 CLI/依赖组件提供。
当前阶段:首个可安装用例已实现并通过离线门禁;仍有两项上游能力阻塞完整首版(运行期文档读取、受控 HTTP 依赖的字节预算),详见 docs/STATUS.md。根 catalog 中本组件仍为 planned,激活由父仓按 C2 → B2 → A2 流程决定。
职责
- 公开
ai.infer、ai.classify、ai.select:输入/输出契约校验、一次逻辑模型请求、严格解析、可恢复错误族。 - 单一模型协议:OpenAI-compatible Chat Completions 最小文本请求(非流式)。
- 上文/任务数据由调用者显式构造;本包不读取文档、不检索、不执行工具、不维护会话。
- 复用
marqdo-ext-http(报文编解码)与默认 Bundle(JSON/UTF-8);TLS/TCP 使用 CLI 通用resource.open能力。
安装与最小运行
消费者在 marqdo.yaml 声明显式依赖:
dependencies:
ai:
git: https://git.cflmy.cn/cflmy/marqdo-ext-ai
rev: <精确提交>
---
import:
ai: "@ai"
---
# @exec 示例
## main
`params()`
**配置 = {endpoint: "llm.example.test:443", transport: "tls", model: "configured-model", credential_env: "EXAMPLE_API_KEY"}**
**选项 = {config: 配置}**
**上下文 = [{kind: "rule", text: "只根据给定资料判断。"}]**
**输入 = {text: "任务输入"}**
**契约 = {type: "object", properties: {label: {type: "string", enum: ["a", "b"]}}, required: ["label"], additionalProperties: false}**
`return ai.infer(上下文, 输入, 契约, 选项)`
真实调用还需要宿主显式授权(缺一即 fail-closed):
marqdo call index.mq.md main --mode project \
--allow-net llm.example.test \
--allow-env EXAMPLE_API_KEY \
--output json
凭证只按 credential_env 名称读取宿主已授权的环境变量;不写入文稿、锁、fixture、日志或模型消息。完整契约见 docs/API.md。
目录
| 路径 | 内容 |
|---|---|
index.mq.md |
唯一公开入口:infer、classify、select |
lib/ |
分层实现:字节、严格 JSON、契约、上下文、协议、传输、编排、便捷函数 |
examples/ |
量子态确定性计算与知识选择、采购建议两个可运行示例(消费者工程内运行) |
tests/ |
白盒单元用例、fixture 集成入口、候选 case 清单 |
scripts/ |
独立验收入口 ci.sh、run_cases.py、fixture_server.py、真实模型 smoke |
docs/ |
API、架构、状态、ADR 与证据 |
独立验收
MARQDO_BIN=/path/to/verified/marqdo \
MARQDO_STDLIB_DIR=/path/to/installed/bundle \
sh scripts/ci.sh
scripts/ci.sh 只接受显式输入,不读取父仓或兄弟仓工作树;它把本仓复制进临时消费者工程,按真实 marqdo lock 锁定固定 HTTP 依赖,启动 127.0.0.1 确定性 fixture,实际调用 CLI 并断言 Observation 值与请求内容。真实模型 smoke 是独立可选入口,见 docs/STATUS.md。
支持平台
Linux x86_64(与冻结 CLI 发行物一致)。其它平台未验证,不声明支持。
边界
不提供 Agent/Workflow/Graph/Node/ContextManager/MemoryManager/RAG/向量库、独立 Markdown parser、索引器或知识图谱;不新增语言标记;不隐式联网、不自动执行工具、不提供 shell/eval;不依赖 Knowledge/View/Prove/Lint/MQDH。详见 docs/ARCHITECTURE.md 与 docs/API.md。
上下文边界
调用方负责选择锚点、构造上下文、读取正文与控制流程;ext-ai 只处理显式输入,不读文件/不检索/不递归链接。边界契约见 docs/CONTEXT-BOUNDARY.md。