fix(#84+#86): denial stream 用 compact chunk + 补丁 42 升级 plainConfig

#84: denialStream 之前打 type:text-chunks 带 .chunks 字段,
但宿主 firstRunMemberTime 认的是 .texts —— 字段错配继续炸。
改成逐 chunk 包成 { type:"chunk", time, chunk } 走单条路径。

#86: 补丁 42 register/commitLegacy 两个 validate 前漏 plainConfig,
cosmokit volatile 字段作为 live 对象引用灌进 validate,日志爆红。
两处 replace 加 plainConfig 包裹;markers 改成 #86 新串,
再加两条升级 pattern 匹配老用户已清洗、缺 plainConfig 的产物,
确保 skipIfMarked 短路后老用户也能走升级补齐。
This commit is contained in:
叫我小杨同学 committed 2026-10-09 15:47:04 +08:00
1 parent daa44d60cb
commit 92aafa0101
2 files changed
+34 -14

No files matched your search

+22 -3
View File
@@ -3817,7 +3817,7 @@ const NEW_TOOL_PATCHES = [
"\t\tthis.ensureLegacyDocument();\n" +
"\t\tconst stored = this.legacyDocument[ns];\n" +
"\t\tconst user = isPlainObject(stored) ? stored : void 0;\n" +
"\t\tconst resolved = schema(mergeLayers(options?.base, user));\n" +
"\t\tconst resolved = plainConfig(schema(mergeLayers(options?.base, user))); // [dsh-purge] #86 plainConfig before validate\n" +
"\t\toptions?.validate?.(resolved);\n" +
"\t\tconst registration = {\n" +
"\t\t\tns,\n" +
@@ -3891,7 +3891,7 @@ const NEW_TOOL_PATCHES = [
"\t\tif (registration === void 0) throw new Error(`settings namespace \"${ns}\" is not registered`);\n" +
"\t\tif (expectedRevision !== void 0 && registration.revision !== expectedRevision) throw new SettingsConflictError(ns, expectedRevision, registration.revision);\n" +
"\t\tconst user = change(registration.user);\n" +
"\t\tconst next = registration.schema(mergeLayers(registration.base, user));\n" +
"\t\tconst next = plainConfig(registration.schema(mergeLayers(registration.base, user))); // [dsh-purge] #86 plainConfig before validate\n" +
"\t\tregistration.validate?.(next);\n" +
"\t\tconst prev = registration.resolved;\n" +
"\t\tregistration.user = user;\n" +
@@ -3958,8 +3958,27 @@ const NEW_TOOL_PATCHES = [
'this.ownerContext.emit("settings/document-updated", previous.ns, revision);\n' +
'\t\t\tthis.ownerContext.emit("settings/updated", previous.ns);',
},
{
// #86 升级:老用户早期产物没过 plainConfig,volatile 字段漏进 validate。
pattern:
"\t\tconst resolved = schema(mergeLayers(options?.base, user));\n" +
"\t\toptions?.validate?.(resolved);",
replace:
"\t\tconst resolved = plainConfig(schema(mergeLayers(options?.base, user))); // [dsh-purge] #86 plainConfig before validate\n" +
"\t\toptions?.validate?.(resolved);",
},
{
// #86 升级:commitLegacy 同根问题。
pattern:
"\t\tconst next = registration.schema(mergeLayers(registration.base, user));\n" +
"\t\tregistration.validate?.(next);",
replace:
"\t\tconst next = plainConfig(registration.schema(mergeLayers(registration.base, user))); // [dsh-purge] #86 plainConfig before validate\n" +
"\t\tregistration.validate?.(next);",
},
],
markers: ["[dsh-purge] legacy settings api"],
// #86 换 marker:老用户已带 "legacy settings api",但缺 plainConfig —— 必须进 replacements 走升级。
markers: ["[dsh-purge] #86 plainConfig before validate"],
},
{
id: 45, name: "OFFICIAL_DESKTOP_UPDATE_HANDOFF", layer: "代码", layer_en: "Code",
+12 -11
View File
@@ -477,21 +477,22 @@ function denialChunks() {
}
/** 宿主持久化只要 Accumulator 紧致记录;裸 chunk 会让 firstRunMemberTime 读 undefined.length(#84)。
* 改为合并成一条 text-chunks 批记录,带 .length / .text,配合 firstRunMemberTime 的字段期望。 */
* 审查「4.1 才是正解」: 每个 chunk 包成 { type: "chunk", time, chunk },走 compact chunk
* 单条路径,避免批记录 (text-chunks 需要 .texts 字段而不是 .chunks) 字段名错配再次崩溃。 */
function denialStream(now = Date.now()) {
const time0 = Number.isSafeInteger(now) ? now : Date.now();
const chunks = denialChunks();
const record = {
type: "text-chunks",
time: time0,
chunks,
length: chunks.length,
text: DENIAL,
};
if (!COMPACT_STREAM_TYPES.has(record.type)) {
throw new TypeError(`denial stream must use compact Assistant records, got ${record.type}`);
const records = chunks.map((chunk, i) => ({
type: "chunk",
time: time0 + i,
chunk,
}));
for (const record of records) {
if (!COMPACT_STREAM_TYPES.has(record.type)) {
throw new TypeError(`denial stream must use compact Assistant records, got ${record.type}`);
}
}
return [record];
return records;
}
async function appendDenial(session, turn, step) {