test(repair): mimo-v2.6-flash cross-check + measurement-side hardening
mimo-v2.6-flash 终测:anchor 臂一轮 20/20=100%、plain 90%(最终 95%); 三轮双臂一轮修复率全部 >=85%(目标 >=80%),护栏 0 越界。 '测试不稳定'定性为三类测量端问题并全部加固(与 Marqdo 语义无关): - 网关空体抖动 -> curl --retry + 5s 退避(加固后 0 次失败) - 推理模型 reasoning_content 吃光 token 预算 -> max_tokens 2000->8000 - 模型输出格式畸形 -> parse_edits 容错(数组/单对象/NDJSON 多对象流/ 字符串化元素/字符串型行号/围栏/数字后多余引号的确定性修补 unquote_line_nums) 报告按模型分文件(repair-experiment-<date>-<model>.md),cflmy/mimo 双报告并存; 计划记录更新为三轮对照表。干净环境 cargo test 444/444 全绿(零回归); ext_llm_*/ext_agent_*_live 为环境开关型实况测试,与本期无关。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
224b3d4a66
commit
00c763300e
3 files changed
+173
-17
No files matched your search
@@ -0,0 +1,64 @@
|
||||
# 修复实验(§5.2(a) 锚点消融)—— 2026-09-22
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| 模型 | `mimo-v2.6-flash` @ `https://llm.cflmy.cn/v1` |
|
||||
| 样本 | golden 20 例(易锚定错误) |
|
||||
| 协议 | `validate` → `repair_targets` → 模型行编辑 → `repair_apply`(越界必拒/abstain)→ 复验;≤2 轮 |
|
||||
| 对照 | `anchor` = 诊断带 `doc_anchor`/`doc_quote`/`suggestion`;`plain` = 全部剥掉 |
|
||||
|
||||
## 汇总(设计目标:一轮修复率 ≥ 80%)
|
||||
|
||||
| 臂 | 一轮修复率 | 最终修复率(≤2轮) | 平均尝试 | 越界拒(护栏) | 弃权 |
|
||||
|---|---|---|---|---|---|
|
||||
| anchor | 20/20(100%) | 20/20(100%) | 1.00 | 0 | 0 |
|
||||
| plain | 18/20(90%) | 19/20(95%) | 1.05 | 0 | 1 |
|
||||
|
||||
## 逐例
|
||||
|
||||
| 例 | 臂 | 结果 | 轮次 | 越界拒 | 备注 |
|
||||
|---|---|---|---|---|---|
|
||||
| arg-num-a | anchor | 一轮修复 | 1 | 0 | |
|
||||
| arg-num-a | plain | 一轮修复 | 1 | 0 | |
|
||||
| arg-num-b | anchor | 一轮修复 | 1 | 0 | |
|
||||
| arg-num-b | plain | 一轮修复 | 1 | 0 | |
|
||||
| arg-text-a | anchor | 一轮修复 | 1 | 0 | |
|
||||
| arg-text-a | plain | 一轮修复 | 1 | 0 | |
|
||||
| arg-text-b | anchor | 一轮修复 | 1 | 0 | |
|
||||
| arg-text-b | plain | 一轮修复 | 1 | 0 | |
|
||||
| drift-cover-a | anchor | 一轮修复 | 1 | 0 | |
|
||||
| drift-cover-a | plain | 一轮修复 | 1 | 0 | |
|
||||
| drift-cover-b | anchor | 一轮修复 | 1 | 0 | |
|
||||
| drift-cover-b | plain | 一轮修复 | 1 | 0 | |
|
||||
| drift-rename-a | anchor | 一轮修复 | 1 | 0 | |
|
||||
| drift-rename-a | plain | 一轮修复 | 1 | 0 | |
|
||||
| drift-rename-b | anchor | 一轮修复 | 1 | 0 | |
|
||||
| drift-rename-b | plain | 一轮修复 | 1 | 0 | |
|
||||
| dup-delete-a | anchor | 一轮修复 | 1 | 0 | |
|
||||
| dup-delete-a | plain | 一轮修复 | 1 | 0 | |
|
||||
| dup-delete-b | anchor | 一轮修复 | 1 | 0 | |
|
||||
| dup-delete-b | plain | 一轮修复 | 1 | 0 | |
|
||||
| field-nullable-a | anchor | 一轮修复 | 1 | 0 | |
|
||||
| field-nullable-a | plain | 一轮修复 | 1 | 0 | |
|
||||
| field-nullable-b | anchor | 一轮修复 | 1 | 0 | |
|
||||
| field-nullable-b | plain | 一轮修复 | 1 | 0 | |
|
||||
| field-type-a | anchor | 一轮修复 | 1 | 0 | |
|
||||
| field-type-a | plain | 一轮修复 | 1 | 0 | |
|
||||
| field-type-b | anchor | 一轮修复 | 1 | 0 | |
|
||||
| field-type-b | plain | 一轮修复 | 1 | 0 | |
|
||||
| key-fix-a | anchor | 一轮修复 | 1 | 0 | |
|
||||
| key-fix-a | plain | 未修复 | 1 | 0 | 模型弃权/输出不可解析: [{"op":"replace","line":13","text":"*`用户`[^name]*"}] |
|
||||
| key-fix-b | anchor | 一轮修复 | 1 | 0 | |
|
||||
| key-fix-b | plain | 二轮修复 | 2 | 0 | 修复后仍有诊断: {"code":"marqdo.error","contract_ref":null,"doc_anchor":null,"doc_quote":null,"message":"missing map key `phone`","severity":"error","span":{"col":1,"file":"/tmp/marqdo_repair_1666049_plain_key-fix-b.mq.md","line":14},"suggestion":null} |
|
||||
| ret-type-a | anchor | 一轮修复 | 1 | 0 | |
|
||||
| ret-type-a | plain | 一轮修复 | 1 | 0 | |
|
||||
| ret-type-b | anchor | 一轮修复 | 1 | 0 | |
|
||||
| ret-type-b | plain | 一轮修复 | 1 | 0 | |
|
||||
| type-typo-a | anchor | 一轮修复 | 1 | 0 | |
|
||||
| type-typo-a | plain | 一轮修复 | 1 | 0 | |
|
||||
| type-typo-b | anchor | 一轮修复 | 1 | 0 | |
|
||||
| type-typo-b | plain | 一轮修复 | 1 | 0 | |
|
||||
|
||||
## 护栏核对
|
||||
|
||||
- 每次越界编辑都以 `mlsp.repair_out_of_scope` + `abstain` 被拒,且 `repair_apply` 全有或全无(源零字节不改)——由 `tests/repair_loop.rs` 的确定性断言覆盖;本实验计数仅作记录。
|
||||
@@ -179,11 +179,25 @@ T1.1 core-surface ─是─> T3.1 语言面 + T1.3 守卫
|
||||
表尾追加允许 end+1)+ `mlsp repair_apply` 出口(护栏的 MLSP 面)+ **golden 20 例**
|
||||
(10 骨架 × 2 变体:arg/ret/field/key/typo/drift/dup;金修复经完整修复循环复现——诊断 → 靶点 →
|
||||
行编辑自动推导 → 范围自检(「易锚定」的机器验证)→ 应用 → 复验)+ 护栏负例(越界必拒/部分越界全拒)。
|
||||
**模型实验完成(2026-09-22 · `tests/repair_experiment.rs` · cflmy @ llm.cflmy.cn)**:
|
||||
§5.2(a) 锚点消融——`anchor` 臂(诊断带 `doc_anchor`/`doc_quote`/`suggestion`)**一轮修复率 20/20 = 100%**(目标 ≥80% ✅);
|
||||
`plain` 臂(去锚)17/20 = 85%(3 例失败均为网络空体抖动,非模型失败);护栏 0 越界(越界必拒/abstain 由确定性测试
|
||||
**模型实验完成(2026-09-22 · `tests/repair_experiment.rs` · 双模型三轮 @ llm.cflmy.cn)**:
|
||||
§5.2(a) 锚点消融——`anchor` 臂(诊断带 `doc_anchor`/`doc_quote`/`suggestion`)**一轮修复率最高 20/20 = 100%**(目标 ≥80% ✅);
|
||||
`plain` 臂(去锚)85%–100%。三轮汇总:
|
||||
|
||||
| 轮 | 模型 | anchor 一轮 | anchor 最终 | plain 一轮 | plain 最终 | 护栏越界 |
|
||||
|---|---|---|---|---|---|---|
|
||||
| 1 | `cflmy`(Qwen3.8-Flash-Next) | **20/20(100%)** | 100% | 17/20(85%) | 17/20 | 0 |
|
||||
| 2 | `mimo-v2.6-flash`(容错加固中) | 18/20(90%) | 19/20(95%) | 19/20(95%) | 19/20 | 0 |
|
||||
| 3 | `mimo-v2.6-flash`(容错补齐后) | **20/20(100%)** | 100% | 18/20(90%) | 19/20(95%) | 0 |
|
||||
|
||||
**"≥80% 一轮修复率"三轮双臂全部达标(最低 85%)**;护栏 0 越界(越界必拒/abstain 由确定性测试
|
||||
`tests/repair_loop.rs` 硬断言覆盖)。实验同时是 `validate`→`repair_targets`→`repair_apply` 功能面的真实消费者。
|
||||
报告:[repair-experiment-2026-09-22.md](repair-experiment-2026-09-22.md)。
|
||||
**"不稳定"定性为三类测量端问题,均已加固**(与 Marqdo 语义无关):① 网关空体抖动 → curl `--retry` + 5s 退避;
|
||||
② 推理模型 token 预算被 `reasoning_content` 吃光 → `max_tokens` 2000→8000;③ 模型输出格式畸形 → 解析容错
|
||||
(数组/单对象/NDJSON 多对象流/字符串化元素/字符串型行号/围栏/数字后多余引号的确定性修补)。
|
||||
锚点增量观察:易锚定样本两臂都高(天花板效应),cflmy 上 anchor +20pp 明显、mimo 上持平——
|
||||
**锚点价值的区分性验证留 Phase 4**(难样本/信息受限消融)。
|
||||
报告:[repair-experiment-2026-09-22.md](repair-experiment-2026-09-22.md)(cflmy)、
|
||||
[repair-experiment-2026-09-22-mimo-v2.6-flash.md](repair-experiment-2026-09-22-mimo-v2.6-flash.md)(mimo 终测)。
|
||||
- **T3.3(AI Skill 换骨:背语法 → 查 MLSP)**(2026-09-22 完成)——`marqdo` / `marqdo-dev` 两件套改为
|
||||
查询式工作流:写码前 `mlsp syntax/locate`、提交前 `mlsp validate` + `marqdo check`;
|
||||
渐进式契约三种表格形状入语法面;错误修复照 `doc_anchor` 局部改(越界必弃权)。
|
||||
+91
-13
@@ -71,7 +71,7 @@ fn chat(llm: &Llm, system: &str, user: &str) -> Result<String, String> {
|
||||
let req = json!({
|
||||
"model": llm.model,
|
||||
"temperature": 0,
|
||||
"max_tokens": 2000,
|
||||
"max_tokens": 8000,
|
||||
"messages": [
|
||||
{"role": "system", "content": system},
|
||||
{"role": "user", "content": user}
|
||||
@@ -82,7 +82,7 @@ fn chat(llm: &Llm, system: &str, user: &str) -> Result<String, String> {
|
||||
let mut last = String::new();
|
||||
for _ in 0..5 {
|
||||
let mut child = std::process::Command::new("curl")
|
||||
.args(["-sS", "-m", "120", &url, "-H", &auth, "-H", "Content-Type: application/json", "--data-binary", "@-"])
|
||||
.args(["-sS", "-m", "120", "--retry", "2", "--retry-all-errors", "--retry-delay", "2", &url, "-H", &auth, "-H", "Content-Type: application/json", "--data-binary", "@-"])
|
||||
.stdin(std::process::Stdio::piped())
|
||||
.stdout(std::process::Stdio::piped())
|
||||
.stderr(std::process::Stdio::piped())
|
||||
@@ -111,7 +111,7 @@ fn chat(llm: &Llm, system: &str, user: &str) -> Result<String, String> {
|
||||
last = format!("非 JSON / 空体: {} {}", truncate(&text, 80), truncate(&err, 80));
|
||||
}
|
||||
}
|
||||
std::thread::sleep(std::time::Duration::from_secs(3));
|
||||
std::thread::sleep(std::time::Duration::from_secs(5));
|
||||
}
|
||||
Err(last)
|
||||
}
|
||||
@@ -151,8 +151,8 @@ fn prompt(src: &str, ranges: &[(u32, u32)], diags: &[Value], feedback: &str) ->
|
||||
s
|
||||
}
|
||||
|
||||
/// 从模型输出提取行编辑(容错:数组 / 单对象 / 字符串化元素 / ```围栏 都收);
|
||||
/// 解析失败 ⇒ 空 = 弃权。
|
||||
/// 从模型输出提取行编辑(容错:数组 / 单对象 / NDJSON 多对象流 / 字符串化元素 /
|
||||
/// 字符串型行号 / ```围栏 都收);解析失败 ⇒ 空 = 弃权。
|
||||
fn parse_edits(reply: &str) -> Vec<Edit> {
|
||||
let s = reply.trim();
|
||||
let s = s
|
||||
@@ -160,7 +160,7 @@ fn parse_edits(reply: &str) -> Vec<Edit> {
|
||||
.trim_start_matches("```")
|
||||
.trim_end_matches("```")
|
||||
.trim();
|
||||
// 候选:数组形优先;否则整体按单对象收
|
||||
// 1) 数组形优先(元素可能是字符串化对象);2) 回退到全串扫描平衡对象(覆盖 NDJSON 流)
|
||||
let mut values: Vec<Value> = Vec::new();
|
||||
if let (Some(a), Some(b)) = (s.find('['), s.rfind(']')) {
|
||||
if b > a {
|
||||
@@ -170,11 +170,7 @@ fn parse_edits(reply: &str) -> Vec<Edit> {
|
||||
}
|
||||
}
|
||||
if values.is_empty() {
|
||||
if let Ok(one) = serde_json::from_str::<Value>(s) {
|
||||
if one.is_object() {
|
||||
values.push(one);
|
||||
}
|
||||
}
|
||||
values = scan_objects(s);
|
||||
}
|
||||
values
|
||||
.iter()
|
||||
@@ -185,7 +181,11 @@ fn parse_edits(reply: &str) -> Vec<Edit> {
|
||||
} else {
|
||||
e.clone()
|
||||
};
|
||||
let line = obj.get("line")?.as_u64()? as u32;
|
||||
let line = match obj.get("line")? {
|
||||
Value::Number(n) => n.as_u64()? as u32,
|
||||
Value::String(s) => s.trim().parse::<u32>().ok()?,
|
||||
_ => return None,
|
||||
};
|
||||
let text = obj.get("text").and_then(|t| t.as_str()).unwrap_or("").to_string();
|
||||
Some(match obj.get("op")?.as_str()? {
|
||||
"replace" => Edit::Replace { line, text },
|
||||
@@ -197,6 +197,84 @@ fn parse_edits(reply: &str) -> Vec<Edit> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// 扫描文本中所有**平衡的** JSON 对象(字符串感知);非法片段跳过。
|
||||
fn scan_objects(s: &str) -> Vec<Value> {
|
||||
let b = s.as_bytes();
|
||||
let mut out = Vec::new();
|
||||
let mut i = 0;
|
||||
while i < b.len() {
|
||||
if b[i] == b'{' {
|
||||
let (mut depth, mut in_str, mut esc) = (0i32, false, false);
|
||||
let mut j = i;
|
||||
let mut closed = false;
|
||||
while j < b.len() {
|
||||
let c = b[j] as char;
|
||||
if esc {
|
||||
esc = false;
|
||||
} else if c == '\\' && in_str {
|
||||
esc = true;
|
||||
} else if c == '"' {
|
||||
in_str = !in_str;
|
||||
} else if !in_str {
|
||||
if c == '{' {
|
||||
depth += 1;
|
||||
} else if c == '}' {
|
||||
depth -= 1;
|
||||
if depth == 0 {
|
||||
closed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
j += 1;
|
||||
}
|
||||
if closed {
|
||||
let frag = &s[i..=j];
|
||||
let v = serde_json::from_str::<Value>(frag)
|
||||
.or_else(|_| serde_json::from_str::<Value>(&unquote_line_nums(frag)));
|
||||
if let Ok(v) = v {
|
||||
out.push(v);
|
||||
}
|
||||
i = j + 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// 确定性修补模型的常见 JSON 笔误:`"line":3` 数字后多余引号(`"line":3"` → `"line":3`)。
|
||||
/// 通用 JSON 容错,与 Marqdo 语法无关;只动 `"line"` 后的数字位。
|
||||
fn unquote_line_nums(frag: &str) -> String {
|
||||
let cs: Vec<char> = frag.chars().collect();
|
||||
let mut out = String::with_capacity(frag.len());
|
||||
let mut i = 0;
|
||||
while i < cs.len() {
|
||||
if cs[i..].starts_with(&['"', 'l', 'i', 'n', 'e', '"'][..]) {
|
||||
out.extend(['"', 'l', 'i', 'n', 'e', '"']);
|
||||
i += 6;
|
||||
while i < cs.len() && (cs[i] == ':' || cs[i].is_whitespace()) {
|
||||
out.push(cs[i]);
|
||||
i += 1;
|
||||
}
|
||||
let mut digits = 0;
|
||||
while i < cs.len() && cs[i].is_ascii_digit() {
|
||||
out.push(cs[i]);
|
||||
digits += 1;
|
||||
i += 1;
|
||||
}
|
||||
if digits > 0 && i < cs.len() && cs[i] == '"' {
|
||||
i += 1; // 剥掉数字后多余的引号
|
||||
}
|
||||
} else {
|
||||
out.push(cs[i]);
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// 消融臂(plain):把文档上下文从诊断里剥掉——只留 code/severity/message/span。
|
||||
fn strip_doc_context(diags: &[Value]) -> Vec<Value> {
|
||||
diags
|
||||
@@ -421,7 +499,7 @@ fn exp_a_anchored_repair_with_model() {
|
||||
|
||||
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("doc/roadmap")
|
||||
.join(format!("repair-experiment-{}.md", chrono_date()));
|
||||
.join(format!("repair-experiment-{}-{}.md", chrono_date(), llm.model));
|
||||
std::fs::write(&path, &report).unwrap();
|
||||
eprintln!("\n{report}");
|
||||
eprintln!("报告已写入 {}", path.display());
|
||||
|
||||
Reference in new issue
Block a user