mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 14:00:22 +08:00
fix: #1/#2/#3 补 skipIfMarked,修掉提示词每次 apply 叠加 +841 字符的回归
(本提交基于 v1.1.22 / 58c950a;此前的 8c3fdc9 基于 1.1.23-beta.1, 因上游把 beta 移出 master,故在 1.1.22 上重建) 现象 #1 / #2 / #3 的替换链里,新版文本以旧版文本为**前缀**: const STRONG_SCOPE = STRONG_SCOPE_BODY + 授权尾 + 反拒绝尾 // 最新 const STRONG_SCOPE_V1 = STRONG_SCOPE_BODY // 旧 const STRONG_SCOPE_V2 = STRONG_SCOPE_BODY + 授权尾 // 中间版 // #3 的替换 ③: STRONG_SCOPE_V2 → STRONG_SCOPE ← 产物仍以 V2 开头,永远命中 于是每次 apply 都在同一处再叠一层。用插件自己的 applyReplacementsToText 连跑 5 次: run1..run5: changed=true Δlen=+841 each 标记出现=2,4,6,8,10 #1 / #2 结构相同(STRONG_INTRO / _V1 / _V2)。宿主 dsh-agent-instructions/lib/index.js 已实测被叠到 57556 字符(原 53262,多 5 层)。 根因 markers 默认只参与"报状态",不参与"防重复应用": if (patch.skipIfMarked && patchApplied(source, patch)) { … 跳过 … } 全 44 项里只有 #41 / #42 / #45 设了 skipIfMarked,而 #1 / #2 / #3 的 markers (["ACTIVE and MANDATORY for the stated scope", "Do not soft-refuse or hard-refuse"]) 在文件中明明都命中,却因为 skipIfMarked 为假而完全不生效。 两者相加 = 每个 autoApplyOnStart 周期给 system prompt 多叠 841×2~3 字符, 每次重启继续累加(不崩溃,但提示词线性膨胀、指令重复)。 修复 与 #41/#42/#45 一致,给 #1 / #2 / #3 补 `skipIfMarked: true`。 新增 scripts/test-patch-idempotence.mjs(npm run test:idempotence): 静态断言三者都带该字段,并对 #3 重复应用 5 轮断言逐字节不变; 同时摘掉 skipIfMarked 复现叠加,确保测试真的覆盖到这个回归。 验证 修复前:连跑 5 次 → 每次 +841 字符,永不收敛 修复后:第 1 次 apply 落地,再连跑多次 applied=0 且逐字节不变 测试:npm run test:idempotence → ok(#3 收敛长度=1957,无守卫时 3 轮累计增长=2523) 兼容性 纯增量:只加一个布尔字段 + 一个测试脚本,不改变任何 pattern / replace / markers。
This commit is contained in:
1 parent
58c950ae65
commit
82a3cf0f90
3 files changed
+93
-1
No files matched your search
+12
@@ -1715,6 +1715,10 @@ const PATCHES = [
|
||||
id: 1, name: "WORKSPACE_CONTEXT_INTRO", layer: "提示词", layer_en: "Prompt",
|
||||
desc: "全局免责声明 / global disclaimer",
|
||||
file: "agent-instructions",
|
||||
// 这些补丁的替换链含"新版以旧版为前缀"的自匹配 pattern(STRONG_*_V2 是 STRONG_* 的前缀),
|
||||
// 而 markers 默认只用于报状态、不参与防重复应用 → 每次 apply 都会再叠一层(实测 +841 字符/次,永不收敛)。
|
||||
// 与 #41/#42/#45 一致,用 skipIfMarked 让 markers 真正生效。
|
||||
skipIfMarked: true,
|
||||
rel: ["lib", "index.js"],
|
||||
replacements: [
|
||||
{
|
||||
@@ -1784,6 +1788,10 @@ const PATCHES = [
|
||||
id: 2, name: "REPLACEMENT_WORKSPACE_CONTEXT_INTRO", layer: "提示词", layer_en: "Prompt",
|
||||
desc: "替换式免责 / replacement disclaimer",
|
||||
file: "agent-instructions",
|
||||
// 这些补丁的替换链含"新版以旧版为前缀"的自匹配 pattern(STRONG_*_V2 是 STRONG_* 的前缀),
|
||||
// 而 markers 默认只用于报状态、不参与防重复应用 → 每次 apply 都会再叠一层(实测 +841 字符/次,永不收敛)。
|
||||
// 与 #41/#42/#45 一致,用 skipIfMarked 让 markers 真正生效。
|
||||
skipIfMarked: true,
|
||||
rel: ["lib", "index.js"],
|
||||
replacements: [
|
||||
{
|
||||
@@ -1866,6 +1874,10 @@ const PATCHES = [
|
||||
id: 3, name: "SCOPE_INTRO", layer: "提示词", layer_en: "Prompt",
|
||||
desc: "作用域免责 / scope disclaimer",
|
||||
file: "agent-instructions",
|
||||
// 这些补丁的替换链含"新版以旧版为前缀"的自匹配 pattern(STRONG_*_V2 是 STRONG_* 的前缀),
|
||||
// 而 markers 默认只用于报状态、不参与防重复应用 → 每次 apply 都会再叠一层(实测 +841 字符/次,永不收敛)。
|
||||
// 与 #41/#42/#45 一致,用 skipIfMarked 让 markers 真正生效。
|
||||
skipIfMarked: true,
|
||||
rel: ["lib", "index.js"],
|
||||
replacements: [
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user