diff --git a/lib/core.js b/lib/core.js index c9d7461..2d0b02d 100644 --- a/lib/core.js +++ b/lib/core.js @@ -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", diff --git a/lib/net-scope.js b/lib/net-scope.js index 900df0e..ade9a77 100644 --- a/lib/net-scope.js +++ b/lib/net-scope.js @@ -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) {