From 91220b9059157d61d5927e6ab1b0a6edb4cf132c Mon Sep 17 00:00:00 2001 From: YokiiroBW Date: Mon, 20 Jul 2026 17:57:02 +0800 Subject: [PATCH] fix: harden ImageStudio queue and vision workflows --- CHANGELOG.md | 359 ++++-- backend/dto/advanced_material_dto.py | 12 +- backend/route_registry.py | 1 + backend/routes/job_routes.py | 136 ++- .../advanced_material_worker_runtime.py | 22 +- .../services/advanced_style_set_service.py | 1030 +++++++++++++++-- backend/services/worker_service.py | 216 +++- config.yaml | 36 +- core/config_service.py | 5 +- docs/project-migration-handoff-2026-07-18.md | 31 + engines/image_provider.py | 16 +- engines/single_flow.py | 10 + frontend/package-lock.json | 5 +- frontend/package.json | 3 +- frontend/shared/api/astrbot-page-bridge.ts | 5 +- frontend/shared/api/client.ts | 4 +- frontend/shared/api/endpoints.ts | 1 + frontend/shared/config/timeouts.ts | 2 + frontend/shared/types/advanced-material.ts | 10 + frontend/shared/utils/presentation.ts | 41 +- frontend/standalone-web/src/App.vue | 27 +- .../materials/AdvancedMaterialImportPage.vue | 100 +- .../tests/task-timeout-consistency.test.mjs | 34 + metadata.yaml | 7 +- pages/imagestudio/assets/index-Dmf_ucVG.js | 57 - ...{index-1rjaQ0Bx.css => index-vON1Mq3d.css} | 2 +- pages/imagestudio/assets/index-w6jYgE11.js | 57 + pages/imagestudio/index.html | 4 +- .../test_advanced_material_worker_recovery.py | 12 + tests/test_advanced_style_set_workflow.py | 420 ++++++- tests/test_image_provider_timeout.py | 56 + tests/test_queue_retry_recovery.py | 8 + tests/test_worker_service.py | 227 ++++ tests/test_workflow_round_queue_runtime.py | 4 +- web/assets/index-D3hLsIA0.js | 57 + web/assets/index-D_8_bZ04.js | 57 - ...{index-Cj5Y2axI.css => index-sCOYj51_.css} | 2 +- web/index.html | 4 +- 38 files changed, 2609 insertions(+), 471 deletions(-) create mode 100644 frontend/shared/config/timeouts.ts create mode 100644 frontend/tests/task-timeout-consistency.test.mjs delete mode 100644 pages/imagestudio/assets/index-Dmf_ucVG.js rename pages/imagestudio/assets/{index-1rjaQ0Bx.css => index-vON1Mq3d.css} (93%) create mode 100644 pages/imagestudio/assets/index-w6jYgE11.js create mode 100644 tests/test_image_provider_timeout.py create mode 100644 tests/test_worker_service.py create mode 100644 web/assets/index-D3hLsIA0.js delete mode 100644 web/assets/index-D_8_bZ04.js rename web/assets/{index-Cj5Y2axI.css => index-sCOYj51_.css} (93%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4409b7a..cef19b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,207 +1,318 @@ +## 1.0.53 + +- Limit concurrent advanced-material vision requests per route to avoid GPT-5.6 relay timeouts when eight images fan out at once. +- Add `advanced_materials.recognition_concurrency`, defaulting to `2`. + # Changelog -本项目从 1.0.8 起使用该文件记录可验收的小版本。开发中的版本仅代表代码里程碑;完成全部二次审计队列后再统一部署。 +鏈」鐩粠 1.0.8 璧蜂娇鐢ㄨ鏂囦欢璁板綍鍙獙鏀剁殑灏忕増鏈€傚紑鍙戜腑鐨勭増鏈粎浠h〃浠g爜閲岀▼纰戯紱瀹屾垚鍏ㄩ儴浜屾瀹¤闃熷垪鍚庡啀缁熶竴閮ㄧ讲銆? ## [Unreleased] +## [1.0.52] - 2026-07-20 + +- Remove source prompt, artist-name and tag anchoring from multi-image style consensus input. +- Keep only cross-source-supported signature traits, reject low-support multi-dimension summaries, and reduce final style prompt duplication. + + +## [1.0.51] - 2026-07-20 + +- Improve artist-style extraction with dimension-balanced signature traits across face structure, eyes, hair, linework, shading, palette, highlights, texture and anatomy. +- Weight signatures by cross-source support and specificity, reuse structured source attributes, and mark signatures explicitly in the final generation prompt to reduce generic-anime style collapse. + + +## [1.0.50] - 2026-07-20 + +- 增加画师风格签名特征聚合,优先保留跨源可验证的高辨识度线稿、眼睛、发丝高光、配色和阴影结构,减少多图共识被压平为通用动漫风格。 +- 过滤通用标签并保留签名特征进入最终 portrait/fullbody/novel_scene 生成提示词。 + +## [1.0.49] - 2026-07-20 + +- 修复已封存的 accepted 流仍显示在最近导入和验证工作台的问题。 +- 验证工作台默认折叠,支持点击展开和收起。 + +## [1.0.48] - 2026-07-20 + +- 封存验证流后,工作台自动隐藏已封存记录并切换到下一条未封存流,避免封存项目继续显示在最近导入区域。 + +## [1.0.47] - 2026-07-20 + +- 加强 portrait 验证的脸宽高比、颧部、下颌和下巴轮廓约束,减少头像生成时脸型偏移,同时不改变 fullbody/novel_scene 规则。 + +## [1.0.46] - 2026-07-20 + +- 参考图改为默认关闭,先进阶画风验证默认使用纯文本生成;仍可由用户显式开启参考图。 + +## [1.0.45] - 2026-07-20 + +- 参考图生成遇到中转站 400/422/5xx 兼容性错误时,自动回退为纯文本生成;429、鉴权失败和网络超时不盲目重试。 +- 保留参考图首选路径,兼容不支持 image 字段的 OpenAI-compatible 网关。 + +## [1.0.44] - 2026-07-20 + +- 加固 advanced-style 验证提示词,移除 juvenile、toddler 及明确二至四头身措辞,保留 neotenic 画风结构与全身比例约束,降低中转站风控误判概率。 +- 保存图像供应商失败的 HTTP 状态码、路由和安全响应摘要,便于区分 502、429、内容审核和超时。 + +## [1.0.43] - 2026-07-20 + +- 修复 advanced-style 重试后旧失败记录未标记为已替代的问题,补齐 superseded 时间戳写回。 +- 批量重试按 source/case lineage 去重,只重试每条逻辑任务的最新失败记录,并归并历史失败记录。 + +## [1.0.42] - 2026-07-20 + +- 直接重试失败的 advanced-material 子任务后,旧失败记录标记为“已被重试替代”,不再继续占用“需处理”列表。 +- 新增“jobs/failed/retry”批量接口与队列页“一键重试全部失败任务”,逐条失败也会继续处理并返回错误明细。 + + +## [1.0.41] - 2026-07-20 + +- Normalize advanced-material queue retry responses to return the replacement task shape expected by the queue page. + + +## [1.0.40] - 2026-07-20 + +- Queue-page retry now dispatches advanced style source and validation tasks to their direct retry handlers instead of retrying the whole import. + + +## [1.0.39] - 2026-07-20 + +- Fix style validation when the configured image gateway rejects the optional reference-image field with a generic 4xx HTTP error. +- Retry the same validation request without `input_images`, preserving the new reference-image feature for compatible providers while keeping current NAS routes usable. + +## [1.0.38] - 2026-07-20 + +- First-round style validation can attach one optional source image as a style-only reference (shared by portrait/fullbody/novel_scene). +- Default uses representative/primary source; UI can pick any recognized sample or disable reference for pure-text transfer. +- Prompt + negatives forbid identity/costume/pose/scene copy from the reference; providers that reject input images fall back to pure text with metadata flags. +- Soft anatomy band from 1.0.37 and age-band ownership by content prompt remain unchanged. + +## [1.0.37] - 2026-07-20 + +- Full-body style transfer adds a soft anatomy band (about 5-7 heads tall, prefer observed source ratio) to prevent chibi/super-deformed collapse after removing mature-adult locks. +- Keep facial neoteny transferable; do not restore mature adult-woman identity locks. Negative prompt blocks 2-4 heads tall bodies on fullbody validation. + +## [1.0.36] - 2026-07-20 + +- 鐢婚杩佺Щ鍙栨秷鈥滄垚鐔熸垚骞?/ 6.5鈥?.5 澶磋韩鈥濈‖閿侊細榛樿楠岃瘉涓讳綋涓嶅啀寮哄埗 mature adult body锛涘叏韬繚鐣欐簮鍥?head-to-body 涓庤偄浣撴娊璞°€? +- facial_age_stylization銆佹簮鍥句綋鍨嬫瘮渚嬩綔涓哄彲杩佺Щ缁撴瀯椋庢牸淇濈暀锛涘疄闄?鏃跺簭骞撮緞浠呬綔鍙傝€冿紝涓嶅啓鍏ョ敓鍥?prompt銆? +- 楠岃瘉 content prompt 鐨勫勾榫勫甫锛堝皯濂?鎴愬コ绛夛級鐢辩敤鎴锋寚浠ゆ垨鍐呭鎻愮ず鎺у埗锛涙湭鎸囧畾鏃朵繚鎸佷腑鎬у苟璁╂簮鍥鹃鏍煎崰涓汇€? + +## [1.0.35] - 2026-07-20 + +- 鍔犲浐闃熷垪 QueueWorker 澶辫触璺緞锛氫笟鍔″け璐ユ垨浜屾鍐欏簱寮傚父涓嶅啀鏉€姝?worker 绾跨▼锛岄伩鍏?advanced-material 浠诲姟姘镐箙鍗″湪 queued銆? +- worker 寰幆瀵?run_once 澧炲姞澶栧眰鍏滃簳锛泂tart 鍙湪绾跨▼鎰忓閫€鍑哄悗閲嶆柊鎷夎捣锛汚piError 閿欒娑堟伅浼樺厛灞曠ず message 涓?error_code銆? +- 瑙嗚璇嗗埆 prohibited_content 绛変笟鍔″け璐ヤ粛璁颁负 failed锛屼絾闃熷垪涓庡悗缁换鍔″彲缁х画 claim 涓庢墽琛屻€? + +## [1.0.34] - 2026-07-19 + +- 杩涢樁鐢婚 portrait銆乫ullbody銆乶ovel_scene 涓夎矾杩佺Щ楠岃瘉浣跨敤鐙珛 900 绉掔敓鍥捐秴鏃讹紝骞跺皢鍚屼竴鏁板€兼寔涔呭寲鍒伴槦鍒楄姹傘€佷换鍔″厓鏁版嵁鍜屽疄闄?Provider 璇锋眰锛涙櫘閫氬揩閫熺敓鍥剧户缁娇鐢ㄩ€傞厤鍣ㄨ嚜韬殑榛樿瓒呮椂銆? +- 鐢熷浘 Provider 鏀寔鍗曟璇锋眰瑕嗙洊瓒呮椂锛岃寖鍥撮檺鍒朵负 10锝?600 绉掞紱閬垮厤涓轰簡鎱㈤€熼獙璇佹ā鍨嬭€岃杩彁楂樻墍鏈夌敓鍥句换鍔$殑鍏ㄥ眬绛夊緟鏃堕棿銆? +- AstrBot 鎻掍欢妗ュ拰鍐呭祵椤甸潰鐨勯暱浠诲姟绛夊緟缁熶竴涓?900 绉掞紝浠诲姟鍗$洿鎺ユ樉绀哄悗绔褰曠殑鑰楁椂涓婇檺锛屼笉鍐嶅嚭鐜板墠绔厛鎶ヨ秴鏃躲€佸悗绔粛鍦ㄨ繍琛岀殑鍐茬獊鎻愮ず銆? +- 淇 SQLite 鏃犳椂鍖?UTC 鏃堕棿琚祻瑙堝櫒褰撴垚鏈湴鏃堕棿瑙f瀽鐨勯棶棰橈紱澶辫触銆佸畬鎴愬拰鍙栨秷浠诲姟鐨勮€楁椂鍥哄畾浣跨敤 `updated_at - created_at`锛屼笉鍐嶆樉绀洪敊璇殑 8 灏忔椂鎴栭殢椤甸潰鍋滅暀鎸佺画澧為暱銆? + ## [1.0.33] - 2026-07-19 -- 将脸部年龄风格、实际年龄与身体成熟度拆分处理;画风正向提示词不再继承未成年、青少年或幼态身体措辞,三组验证主体统一为明确成年人,全身验证固定成熟肢体长度与约 6.5~7.5 头身比例。 -- 画风核心项、必须保留项及背景、具体光效、具体色盘等易污染内容增加证据门控;仅当多图支持率不低于 60%、置信度不低于 70% 时进入最终提示词。 -- 自动还原度评分增加一致性校准:最终分不高于模型自评分,偏差、修正补丁、语义风险和文字严重度会扣分;“维度全满分但同时要求修正”会标记为审核结果不一致。 -- 对模型给出的安全改写再做一次语义形状审计;发丝高光中的光环、横带、条块等物体化措辞改写为贴合发丝曲面的半透明断续缎面光泽,并加入白色实线、连续光带、几何折线块等负向约束。 -- 公共 detailed 画风胶囊与 portrait/fullbody/novel_scene 尺度胶囊在服务端去重,尺度胶囊只保留该构图尺度独有的约束,减少长提示词的重复注意力占用。 -- 默认与模型返回的验证内容统一经过中性化:头像使用哑光棚拍,全身使用中性日光,跨场景使用普通阴天,移除黎明、日落、霓虹、散景、镜头光晕、体积光与戏剧性逆光偏置。 +- 灏嗚劯閮ㄥ勾榫勯鏍笺€佸疄闄呭勾榫勪笌韬綋鎴愮啛搴︽媶鍒嗗鐞嗭紱鐢婚姝e悜鎻愮ず璇嶄笉鍐嶇户鎵挎湭鎴愬勾銆侀潚灏戝勾鎴栧辜鎬佽韩浣撴帾杈烇紝涓夌粍楠岃瘉涓讳綋缁熶竴涓烘槑纭垚骞翠汉锛屽叏韬獙璇佸浐瀹氭垚鐔熻偄浣撻暱搴︿笌绾?6.5锝?.5 澶磋韩姣斾緥銆? +- 鐢婚鏍稿績椤广€佸繀椤讳繚鐣欓」鍙婅儗鏅€佸叿浣撳厜鏁堛€佸叿浣撹壊鐩樼瓑鏄撴薄鏌撳唴瀹瑰鍔犺瘉鎹棬鎺э紱浠呭綋澶氬浘鏀寔鐜囦笉浣庝簬 60%銆佺疆淇″害涓嶄綆浜?70% 鏃惰繘鍏ユ渶缁堟彁绀鸿瘝銆? +- 鑷姩杩樺師搴﹁瘎鍒嗗鍔犱竴鑷存€ф牎鍑嗭細鏈€缁堝垎涓嶉珮浜庢ā鍨嬭嚜璇勫垎锛屽亸宸€佷慨姝hˉ涓併€佽涔夐闄╁拰鏂囧瓧涓ラ噸搴︿細鎵e垎锛涒€滅淮搴﹀叏婊″垎浣嗗悓鏃惰姹備慨姝b€濅細鏍囪涓哄鏍哥粨鏋滀笉涓€鑷淬€? +- 瀵规ā鍨嬬粰鍑虹殑瀹夊叏鏀瑰啓鍐嶅仛涓€娆¤涔夊舰鐘跺璁★紱鍙戜笣楂樺厜涓殑鍏夌幆銆佹í甯︺€佹潯鍧楃瓑鐗╀綋鍖栨帾杈炴敼鍐欎负璐村悎鍙戜笣鏇查潰鐨勫崐閫忔槑鏂画缂庨潰鍏夋辰锛屽苟鍔犲叆鐧借壊瀹炵嚎銆佽繛缁厜甯︺€佸嚑浣曟姌绾垮潡绛夎礋鍚戠害鏉熴€? +- 鍏叡 detailed 鐢婚鑳跺泭涓?portrait/fullbody/novel_scene 灏哄害鑳跺泭鍦ㄦ湇鍔$鍘婚噸锛屽昂搴﹁兌鍥婂彧淇濈暀璇ユ瀯鍥惧昂搴︾嫭鏈夌殑绾︽潫锛屽噺灏戦暱鎻愮ず璇嶇殑閲嶅娉ㄦ剰鍔涘崰鐢ㄣ€? +- 榛樿涓庢ā鍨嬭繑鍥炵殑楠岃瘉鍐呭缁熶竴缁忚繃涓€у寲锛氬ご鍍忎娇鐢ㄥ搼鍏夋鎷嶏紝鍏ㄨ韩浣跨敤涓€ф棩鍏夛紝璺ㄥ満鏅娇鐢ㄦ櫘閫氶槾澶╋紝绉婚櫎榛庢槑銆佹棩钀姐€侀湏铏广€佹暎鏅€侀暅澶村厜鏅曘€佷綋绉厜涓庢垙鍓ф€ч€嗗厜鍋忕疆銆? ## [1.0.32] - 2026-07-18 -- 画风验证审核升级为固定维度协议;服务端按头像、全身、跨场景分别加权脸部、眼睛、线稿、色彩、阴影、比例与背景,不再直接采用视觉模型的自由总分,并记录维度覆盖率与缺失项。 -- 复验共识自动聚合上一轮三张验证图,将至少两个场景重复出现的问题归类为公共画风缺陷,将单场景问题保留为尺度胶囊修正,避免头像问题污染全身或场景提示词。 -- 共识协议新增全局色彩与局部色差分离、结构化差异、提示词补丁、语义风险审计和尺度胶囊;可能被字面化为物体、光效或构图的比喻必须改写为表面、几何与位置关系。 -- detailed 画风胶囊改由服务端编译:按核心、结构、渲染优先级合并 `must_preserve`,近义去重并限制为 14 条公共核心特征,再叠加最多 5 条场景尺度特征,减少长提示词的注意力稀释。 -- 每轮三图完成后自动与上一轮计算总分和分场景差值,标记采用候选、保留上一版或需要人工判断;视觉审核失败仍不影响生成图片保留。 +- 鐢婚楠岃瘉瀹℃牳鍗囩骇涓哄浐瀹氱淮搴﹀崗璁紱鏈嶅姟绔寜澶村儚銆佸叏韬€佽法鍦烘櫙鍒嗗埆鍔犳潈鑴搁儴銆佺溂鐫涖€佺嚎绋裤€佽壊褰┿€侀槾褰便€佹瘮渚嬩笌鑳屾櫙锛屼笉鍐嶇洿鎺ラ噰鐢ㄨ瑙夋ā鍨嬬殑鑷敱鎬诲垎锛屽苟璁板綍缁村害瑕嗙洊鐜囦笌缂哄け椤广€? +- 澶嶉獙鍏辫瘑鑷姩鑱氬悎涓婁竴杞笁寮犻獙璇佸浘锛屽皢鑷冲皯涓や釜鍦烘櫙閲嶅鍑虹幇鐨勯棶棰樺綊绫讳负鍏叡鐢婚缂洪櫡锛屽皢鍗曞満鏅棶棰樹繚鐣欎负灏哄害鑳跺泭淇锛岄伩鍏嶅ご鍍忛棶棰樻薄鏌撳叏韬垨鍦烘櫙鎻愮ず璇嶃€? +- 鍏辫瘑鍗忚鏂板鍏ㄥ眬鑹插僵涓庡眬閮ㄨ壊宸垎绂汇€佺粨鏋勫寲宸紓銆佹彁绀鸿瘝琛ヤ竵銆佽涔夐闄╁璁″拰灏哄害鑳跺泭锛涘彲鑳借瀛楅潰鍖栦负鐗╀綋銆佸厜鏁堟垨鏋勫浘鐨勬瘮鍠诲繀椤绘敼鍐欎负琛ㄩ潰銆佸嚑浣曚笌浣嶇疆鍏崇郴銆? +- detailed 鐢婚鑳跺泭鏀圭敱鏈嶅姟绔紪璇戯細鎸夋牳蹇冦€佺粨鏋勩€佹覆鏌撲紭鍏堢骇鍚堝苟 `must_preserve`锛岃繎涔夊幓閲嶅苟闄愬埗涓?14 鏉″叕鍏辨牳蹇冪壒寰侊紝鍐嶅彔鍔犳渶澶?5 鏉″満鏅昂搴︾壒寰侊紝鍑忓皯闀挎彁绀鸿瘝鐨勬敞鎰忓姏绋€閲娿€? +- 姣忚疆涓夊浘瀹屾垚鍚庤嚜鍔ㄤ笌涓婁竴杞绠楁€诲垎鍜屽垎鍦烘櫙宸€硷紝鏍囪閲囩敤鍊欓€夈€佷繚鐣欎笂涓€鐗堟垨闇€瑕佷汉宸ュ垽鏂紱瑙嗚瀹℃牳澶辫触浠嶄笉褰卞搷鐢熸垚鍥剧墖淇濈暀銆? ## [1.0.31] - 2026-07-18 -- 画风逐图识别与交叉共识新增脸型、眼睛/虹膜、鼻口简化、头身比、发束组织、线条拓扑、阴影色相、高光形状和色彩关系等结构画风维度,不再只输出通用动漫渲染标签。 -- 归一化层保留视觉模型返回的 `normalized_asset_profile.attributes`,并为画风自动生成 `must_preserve`;修复结构化属性退化成单一 `legacy_description` 的问题。 -- 内容污染清单仅用于审计,不再原样注入生图负向提示词;改为只排除具体源角色身份、具体服装设计、姿势与场景,避免误伤 Moe 比例、动物耳等风格耦合特征。 -- 修复 detailed 胶囊含逗号语义短语被拆碎、短共识与详细胶囊重复拼接、正负提示词多次重复的问题,并对缺少结构维度的模型自报置信度进行服务端降权。 -- 每张验证图生成后自动使用代表源图进行视觉还原度审核,持久化维度评分、主要匹配/偏差及下一轮修正提示;审核失败不会丢弃已经生成的图片。 -- 进阶画风验证卡片显示自动还原度和主要偏差;视觉模型格式错误新增脱敏后的具体响应问题和解析原因。 +- 鐢婚閫愬浘璇嗗埆涓庝氦鍙夊叡璇嗘柊澧炶劯鍨嬨€佺溂鐫?铏硅啘銆侀蓟鍙g畝鍖栥€佸ご韬瘮銆佸彂鏉熺粍缁囥€佺嚎鏉℃嫇鎵戙€侀槾褰辫壊鐩搞€侀珮鍏夊舰鐘跺拰鑹插僵鍏崇郴绛夌粨鏋勭敾椋庣淮搴︼紝涓嶅啀鍙緭鍑洪€氱敤鍔ㄦ极娓叉煋鏍囩銆? +- 褰掍竴鍖栧眰淇濈暀瑙嗚妯″瀷杩斿洖鐨?`normalized_asset_profile.attributes`锛屽苟涓虹敾椋庤嚜鍔ㄧ敓鎴?`must_preserve`锛涗慨澶嶇粨鏋勫寲灞炴€ч€€鍖栨垚鍗曚竴 `legacy_description` 鐨勯棶棰樸€? +- 鍐呭姹℃煋娓呭崟浠呯敤浜庡璁★紝涓嶅啀鍘熸牱娉ㄥ叆鐢熷浘璐熷悜鎻愮ず璇嶏紱鏀逛负鍙帓闄ゅ叿浣撴簮瑙掕壊韬唤銆佸叿浣撴湇瑁呰璁°€佸Э鍔夸笌鍦烘櫙锛岄伩鍏嶈浼?Moe 姣斾緥銆佸姩鐗╄€崇瓑椋庢牸鑰﹀悎鐗瑰緛銆? +- 淇 detailed 鑳跺泭鍚€楀彿璇箟鐭琚媶纰庛€佺煭鍏辫瘑涓庤缁嗚兌鍥婇噸澶嶆嫾鎺ャ€佹璐熸彁绀鸿瘝澶氭閲嶅鐨勯棶棰橈紝骞跺缂哄皯缁撴瀯缁村害鐨勬ā鍨嬭嚜鎶ョ疆淇″害杩涜鏈嶅姟绔檷鏉冦€? +- 姣忓紶楠岃瘉鍥剧敓鎴愬悗鑷姩浣跨敤浠h〃婧愬浘杩涜瑙嗚杩樺師搴﹀鏍革紝鎸佷箙鍖栫淮搴﹁瘎鍒嗐€佷富瑕佸尮閰?鍋忓樊鍙婁笅涓€杞慨姝f彁绀猴紱瀹℃牳澶辫触涓嶄細涓㈠純宸茬粡鐢熸垚鐨勫浘鐗囥€? +- 杩涢樁鐢婚楠岃瘉鍗$墖鏄剧ず鑷姩杩樺師搴﹀拰涓昏鍋忓樊锛涜瑙夋ā鍨嬫牸寮忛敊璇柊澧炶劚鏁忓悗鐨勫叿浣撳搷搴旈棶棰樺拰瑙f瀽鍘熷洜銆? ## [1.0.30] - 2026-07-18 -- 进阶画风复验会同时提交代表源图、上一轮三张失败验证图、全部源图识别报告、上一版提示词与用户修正,视觉模型可直接进行前后对照。 -- 将“太强、降低、太弱、加强、移除、保持”等反馈解析为 increase/decrease/remove/preserve 结构化方向,并持久化对照清单与实际调整计划。 -- 增加服务端语义防反转;例如“颜色对比太过强烈”不会再被转换为 intense/extreme/high contrast,而会落实为适中克制的对比并排除过强色差。 -- 三张验证生图统一使用 detailed 画风胶囊及其负向约束,不再只使用短共识提示词;仍保持纯文本迁移验证,不向生图模型传递源图。 +- 杩涢樁鐢婚澶嶉獙浼氬悓鏃舵彁浜や唬琛ㄦ簮鍥俱€佷笂涓€杞笁寮犲け璐ラ獙璇佸浘銆佸叏閮ㄦ簮鍥捐瘑鍒姤鍛娿€佷笂涓€鐗堟彁绀鸿瘝涓庣敤鎴蜂慨姝o紝瑙嗚妯″瀷鍙洿鎺ヨ繘琛屽墠鍚庡鐓с€? +- 灏嗏€滃お寮恒€侀檷浣庛€佸お寮便€佸姞寮恒€佺Щ闄ゃ€佷繚鎸佲€濈瓑鍙嶉瑙f瀽涓?increase/decrease/remove/preserve 缁撴瀯鍖栨柟鍚戯紝骞舵寔涔呭寲瀵圭収娓呭崟涓庡疄闄呰皟鏁磋鍒掋€? +- 澧炲姞鏈嶅姟绔涔夐槻鍙嶈浆锛涗緥濡傗€滈鑹插姣斿お杩囧己鐑堚€濅笉浼氬啀琚浆鎹负 intense/extreme/high contrast锛岃€屼細钀藉疄涓洪€備腑鍏嬪埗鐨勫姣斿苟鎺掗櫎杩囧己鑹插樊銆? +- 涓夊紶楠岃瘉鐢熷浘缁熶竴浣跨敤 detailed 鐢婚鑳跺泭鍙婂叾璐熷悜绾︽潫锛屼笉鍐嶅彧浣跨敤鐭叡璇嗘彁绀鸿瘝锛涗粛淇濇寔绾枃鏈縼绉婚獙璇侊紝涓嶅悜鐢熷浘妯″瀷浼犻€掓簮鍥俱€? -- 已完成全仓角色工作流二次审计;确认在现有 `character_gradual` 主线上增量修复,不创建平行工作流。 -- 修复队列已按 1.0.9–1.0.20 小版本写入 `docs/workflow-secondary-audit-development-queue.md`。 +- 宸插畬鎴愬叏浠撹鑹插伐浣滄祦浜屾瀹¤锛涚‘璁ゅ湪鐜版湁 `character_gradual` 涓荤嚎涓婂閲忎慨澶嶏紝涓嶅垱寤哄钩琛屽伐浣滄祦銆? +- 淇闃熷垪宸叉寜 1.0.9鈥?.0.20 灏忕増鏈啓鍏?`docs/workflow-secondary-audit-development-queue.md`銆? ## [1.0.29] - 2026-07-17 -- 进阶素材的画风样本、三张当前验证图、单图源图/验证图以及历史轮次缩略图全部接入统一大图预览卡片。 -- 点击或使用键盘 Enter/空格可打开原图优先的大图预览,支持滚轮缩放、按钮缩放、双击缩放、拖动画布、重置和 Esc 关闭。 -- 大图遮罩继续使用安全单击关闭逻辑,文本拖选、图片拖动或指针移出卡片不会误触关闭。 -- 缩略图增加放大光标、键盘焦点和明确的“点击查看大图”提示。 +- 杩涢樁绱犳潗鐨勭敾椋庢牱鏈€佷笁寮犲綋鍓嶉獙璇佸浘銆佸崟鍥炬簮鍥?楠岃瘉鍥句互鍙婂巻鍙茶疆娆$缉鐣ュ浘鍏ㄩ儴鎺ュ叆缁熶竴澶у浘棰勮鍗$墖銆? +- 鐐瑰嚮鎴栦娇鐢ㄩ敭鐩?Enter/绌烘牸鍙墦寮€鍘熷浘浼樺厛鐨勫ぇ鍥鹃瑙堬紝鏀寔婊氳疆缂╂斁銆佹寜閽缉鏀俱€佸弻鍑荤缉鏀俱€佹嫋鍔ㄧ敾甯冦€侀噸缃拰 Esc 鍏抽棴銆? +- 澶у浘閬僵缁х画浣跨敤瀹夊叏鍗曞嚮鍏抽棴閫昏緫锛屾枃鏈嫋閫夈€佸浘鐗囨嫋鍔ㄦ垨鎸囬拡绉诲嚭鍗$墖涓嶄細璇Е鍏抽棴銆? +- 缂╃暐鍥惧鍔犳斁澶у厜鏍囥€侀敭鐩樼劍鐐瑰拰鏄庣‘鐨勨€滅偣鍑绘煡鐪嬪ぇ鍥锯€濇彁绀恒€? ## [1.0.28] - 2026-07-17 -- 修复进阶画风导入后端使用 `advanced_style_set`、前端只识别 `style_set`,导致三图验证被误判为单图流程且主界面只显示一张验证图的问题。 -- 多图画风当前轮次恢复为头像、全身、跨场景三张验证卡片;三张图分别显示状态、提示词、文字调整和随机种子。 -- 验证轮次列表与详情接口为每一轮附带完整 `validation_cases`,历史轮次也可同时查看三张缩略图,不再只展示聚合轮次的第一张投影图。 -- 兼容旧 `style_set`、正式 `advanced_style_set` 以及服务端 `metadata.style_set` 标记,避免升级前后的记录再次走错前端分支。 +- 淇杩涢樁鐢婚瀵煎叆鍚庣浣跨敤 `advanced_style_set`銆佸墠绔彧璇嗗埆 `style_set`锛屽鑷翠笁鍥鹃獙璇佽璇垽涓哄崟鍥炬祦绋嬩笖涓荤晫闈㈠彧鏄剧ず涓€寮犻獙璇佸浘鐨勯棶棰樸€? +- 澶氬浘鐢婚褰撳墠杞鎭㈠涓哄ご鍍忋€佸叏韬€佽法鍦烘櫙涓夊紶楠岃瘉鍗$墖锛涗笁寮犲浘鍒嗗埆鏄剧ず鐘舵€併€佹彁绀鸿瘝銆佹枃瀛楄皟鏁村拰闅忔満绉嶅瓙銆? +- 楠岃瘉杞鍒楄〃涓庤鎯呮帴鍙d负姣忎竴杞檮甯﹀畬鏁?`validation_cases`锛屽巻鍙茶疆娆′篃鍙悓鏃舵煡鐪嬩笁寮犵缉鐣ュ浘锛屼笉鍐嶅彧灞曠ず鑱氬悎杞鐨勭涓€寮犳姇褰卞浘銆? +- 鍏煎鏃?`style_set`銆佹寮?`advanced_style_set` 浠ュ強鏈嶅姟绔?`metadata.style_set` 鏍囪锛岄伩鍏嶅崌绾у墠鍚庣殑璁板綍鍐嶆璧伴敊鍓嶇鍒嗘敮銆? ## [1.0.27] - 2026-07-17 -- 进阶画风复验拆分为“画风修正”和“下一轮验证内容”两条独立输入:前者只重建画风共识与胶囊,后者直接写入三个验证生图提示词。 -- 修复第二轮强制复用第一轮老年男性、机器人和宇航员场景的问题;用户指定角色、服装、构图或场景后会重建验证案例,且最终 `expanded_prompt` 必定包含用户原文。 -- 只修改画风时继续沿用相同验证场景与种子,便于 A/B 比较;修改验证内容时使用新种子,避免旧构图被随机种子持续锁定。 -- 默认验证改为同一新角色的近域头像、全身和跨场景三级对照,减少角色年龄、物种与写实先验对画风判断的干扰。 -- 验证卡片显示已应用的文字调整和实际种子;历史轮次持久化画风修正、验证内容及其作用范围。 -- 旧客户端继续支持单一 `adjustment_text`,服务端会同时应用到画风与验证内容链路,避免反馈静默丢失。 +- 杩涢樁鐢婚澶嶉獙鎷嗗垎涓衡€滅敾椋庝慨姝b€濆拰鈥滀笅涓€杞獙璇佸唴瀹光€濅袱鏉$嫭绔嬭緭鍏ワ細鍓嶈€呭彧閲嶅缓鐢婚鍏辫瘑涓庤兌鍥婏紝鍚庤€呯洿鎺ュ啓鍏ヤ笁涓獙璇佺敓鍥炬彁绀鸿瘝銆? +- 淇绗簩杞己鍒跺鐢ㄧ涓€杞€佸勾鐢锋€с€佹満鍣ㄤ汉鍜屽畤鑸憳鍦烘櫙鐨勯棶棰橈紱鐢ㄦ埛鎸囧畾瑙掕壊銆佹湇瑁呫€佹瀯鍥炬垨鍦烘櫙鍚庝細閲嶅缓楠岃瘉妗堜緥锛屼笖鏈€缁?`expanded_prompt` 蹇呭畾鍖呭惈鐢ㄦ埛鍘熸枃銆? +- 鍙慨鏀圭敾椋庢椂缁х画娌跨敤鐩稿悓楠岃瘉鍦烘櫙涓庣瀛愶紝渚夸簬 A/B 姣旇緝锛涗慨鏀归獙璇佸唴瀹规椂浣跨敤鏂扮瀛愶紝閬垮厤鏃ф瀯鍥捐闅忔満绉嶅瓙鎸佺画閿佸畾銆? +- 榛樿楠岃瘉鏀逛负鍚屼竴鏂拌鑹茬殑杩戝煙澶村儚銆佸叏韬拰璺ㄥ満鏅笁绾у鐓э紝鍑忓皯瑙掕壊骞撮緞銆佺墿绉嶄笌鍐欏疄鍏堥獙瀵圭敾椋庡垽鏂殑骞叉壈銆? +- 楠岃瘉鍗$墖鏄剧ず宸插簲鐢ㄧ殑鏂囧瓧璋冩暣鍜屽疄闄呯瀛愶紱鍘嗗彶杞鎸佷箙鍖栫敾椋庝慨姝c€侀獙璇佸唴瀹瑰強鍏朵綔鐢ㄨ寖鍥淬€? +- 鏃у鎴风缁х画鏀寔鍗曚竴 `adjustment_text`锛屾湇鍔$浼氬悓鏃跺簲鐢ㄥ埌鐢婚涓庨獙璇佸唴瀹归摼璺紝閬垮厤鍙嶉闈欓粯涓㈠け銆? ## [1.0.26] - 2026-07-17 -- 修复任务较多时队列卡片被滚动区域压缩的问题;任务卡改为纵向自然高度排列,状态、标题、进度条与耗时不再相互覆盖。 -- 进阶素材验证轮询改为只更新当前活动导入或导入摘要,不再每 4.5 秒全量刷新导入库与素材库。 -- 增加轮询互斥,防止慢请求发生重叠;轮询失败保持当前页面,不再触发错误态或视觉重置。 -- 图片展示优先使用稳定的 `storage://` URI 缓存,忽略同一媒体每轮变化的临时签名 URL,避免验证生成期间图片反复重载和页面闪烁。 +- 淇浠诲姟杈冨鏃堕槦鍒楀崱鐗囪婊氬姩鍖哄煙鍘嬬缉鐨勯棶棰橈紱浠诲姟鍗℃敼涓虹旱鍚戣嚜鐒堕珮搴︽帓鍒楋紝鐘舵€併€佹爣棰樸€佽繘搴︽潯涓庤€楁椂涓嶅啀鐩镐簰瑕嗙洊銆? +- 杩涢樁绱犳潗楠岃瘉杞鏀逛负鍙洿鏂板綋鍓嶆椿鍔ㄥ鍏ユ垨瀵煎叆鎽樿锛屼笉鍐嶆瘡 4.5 绉掑叏閲忓埛鏂板鍏ュ簱涓庣礌鏉愬簱銆? +- 澧炲姞杞浜掓枼锛岄槻姝㈡參璇锋眰鍙戠敓閲嶅彔锛涜疆璇㈠け璐ヤ繚鎸佸綋鍓嶉〉闈紝涓嶅啀瑙﹀彂閿欒鎬佹垨瑙嗚閲嶇疆銆? +- 鍥剧墖灞曠ず浼樺厛浣跨敤绋冲畾鐨?`storage://` URI 缂撳瓨锛屽拷鐣ュ悓涓€濯掍綋姣忚疆鍙樺寲鐨勪复鏃剁鍚?URL锛岄伩鍏嶉獙璇佺敓鎴愭湡闂村浘鐗囧弽澶嶉噸杞藉拰椤甸潰闂儊銆? ## [1.0.25] - 2026-07-17 -- 修复进阶素材队列记录被手动删除后,导入或样本仍保持 queued/running 并永久卡住的问题;详情读取、列表刷新和重试前会将缺失任务对账为可重试失败。 -- 新增未封存进阶导入删除接口与前端双击确认按钮;删除会先取消残留任务,再级联清理样本、交叉共识、验证轮次和进阶素材独立文件。 -- 已封存为高优先级素材的导入禁止删除,仍需通过素材归档流程处理,避免破坏素材库、衣橱和工作流引用。 -- 缺失队列任务会显示明确提示,可选择单独重试、排除样本或删除整个导入,不再只显示模糊的“待处理样本”。 +- 淇杩涢樁绱犳潗闃熷垪璁板綍琚墜鍔ㄥ垹闄ゅ悗锛屽鍏ユ垨鏍锋湰浠嶄繚鎸?queued/running 骞舵案涔呭崱浣忕殑闂锛涜鎯呰鍙栥€佸垪琛ㄥ埛鏂板拰閲嶈瘯鍓嶄細灏嗙己澶变换鍔″璐︿负鍙噸璇曞け璐ャ€? +- 鏂板鏈皝瀛樿繘闃跺鍏ュ垹闄ゆ帴鍙d笌鍓嶇鍙屽嚮纭鎸夐挳锛涘垹闄や細鍏堝彇娑堟畫鐣欎换鍔★紝鍐嶇骇鑱旀竻鐞嗘牱鏈€佷氦鍙夊叡璇嗐€侀獙璇佽疆娆″拰杩涢樁绱犳潗鐙珛鏂囦欢銆? +- 宸插皝瀛樹负楂樹紭鍏堢骇绱犳潗鐨勫鍏ョ姝㈠垹闄わ紝浠嶉渶閫氳繃绱犳潗褰掓。娴佺▼澶勭悊锛岄伩鍏嶇牬鍧忕礌鏉愬簱銆佽。姗卞拰宸ヤ綔娴佸紩鐢ㄣ€? +- 缂哄け闃熷垪浠诲姟浼氭樉绀烘槑纭彁绀猴紝鍙€夋嫨鍗曠嫭閲嶈瘯銆佹帓闄ゆ牱鏈垨鍒犻櫎鏁翠釜瀵煎叆锛屼笉鍐嶅彧鏄剧ず妯$硦鐨勨€滃緟澶勭悊鏍锋湰鈥濄€? ## [1.0.24] - 2026-07-17 -- 模型分工统一为双源路由:每个文本/视觉节点分别选择 ImageStudio 插件适配器与 AstrBot 模型提供商,执行顺序固定为插件优先、AstrBot 备用。 -- 素材识别、进阶素材识别、多图画风共识、结构化文本调用和生成后视觉审核加入故障转移;前置提供商失败时自动尝试备用,并保留失败摘要。 -- 生图节点明确只选择 ImageStudio 生图适配器;AstrBot 4.25 没有公开生图桥接接口,因此界面禁用不可执行的宿主生图选择,避免保存后运行失败。 -- 进阶画风失败样本重试时重新读取当前双源配置,并同步刷新父导入路由,修复旧 `material_vlm` 被任务永久冻结的问题。 -- 提示词转译、生成前内容审核与生成后图片审核同步使用双选择栏;旧单路由配置保持兼容,双路由继续存为单个 AstrBot 配置字符串。 -- 修正运行时版本常量与发布元数据不同步的问题,状态页和插件元数据统一显示 1.0.24。 +- 妯″瀷鍒嗗伐缁熶竴涓哄弻婧愯矾鐢憋細姣忎釜鏂囨湰/瑙嗚鑺傜偣鍒嗗埆閫夋嫨 ImageStudio 鎻掍欢閫傞厤鍣ㄤ笌 AstrBot 妯″瀷鎻愪緵鍟嗭紝鎵ц椤哄簭鍥哄畾涓烘彃浠朵紭鍏堛€丄strBot 澶囩敤銆? +- 绱犳潗璇嗗埆銆佽繘闃剁礌鏉愯瘑鍒€佸鍥剧敾椋庡叡璇嗐€佺粨鏋勫寲鏂囨湰璋冪敤鍜岀敓鎴愬悗瑙嗚瀹℃牳鍔犲叆鏁呴殰杞Щ锛涘墠缃彁渚涘晢澶辫触鏃惰嚜鍔ㄥ皾璇曞鐢紝骞朵繚鐣欏け璐ユ憳瑕併€? +- 鐢熷浘鑺傜偣鏄庣‘鍙€夋嫨 ImageStudio 鐢熷浘閫傞厤鍣紱AstrBot 4.25 娌℃湁鍏紑鐢熷浘妗ユ帴鎺ュ彛锛屽洜姝ょ晫闈㈢鐢ㄤ笉鍙墽琛岀殑瀹夸富鐢熷浘閫夋嫨锛岄伩鍏嶄繚瀛樺悗杩愯澶辫触銆? +- 杩涢樁鐢婚澶辫触鏍锋湰閲嶈瘯鏃堕噸鏂拌鍙栧綋鍓嶅弻婧愰厤缃紝骞跺悓姝ュ埛鏂扮埗瀵煎叆璺敱锛屼慨澶嶆棫 `material_vlm` 琚换鍔℃案涔呭喕缁撶殑闂銆? +- 鎻愮ず璇嶈浆璇戙€佺敓鎴愬墠鍐呭瀹℃牳涓庣敓鎴愬悗鍥剧墖瀹℃牳鍚屾浣跨敤鍙岄€夋嫨鏍忥紱鏃у崟璺敱閰嶇疆淇濇寔鍏煎锛屽弻璺敱缁х画瀛樹负鍗曚釜 AstrBot 閰嶇疆瀛楃涓层€? +- 淇杩愯鏃剁増鏈父閲忎笌鍙戝竷鍏冩暟鎹笉鍚屾鐨勯棶棰橈紝鐘舵€侀〉鍜屾彃浠跺厓鏁版嵁缁熶竴鏄剧ず 1.0.24銆? ## [1.0.23] - 2026-07-17 -- 将内置素材分类的英文名称统一显示为中文,并覆盖进阶素材导入、素材操作和识别提示词设置下拉框。 -- 保留后端分类 ID 与原始名称,兼容现有素材、衣橱和工作流数据。 +- 灏嗗唴缃礌鏉愬垎绫荤殑鑻辨枃鍚嶇О缁熶竴鏄剧ず涓轰腑鏂囷紝骞惰鐩栬繘闃剁礌鏉愬鍏ャ€佺礌鏉愭搷浣滃拰璇嗗埆鎻愮ず璇嶈缃笅鎷夋銆? +- 淇濈暀鍚庣鍒嗙被 ID 涓庡師濮嬪悕绉帮紝鍏煎鐜版湁绱犳潗銆佽。姗卞拰宸ヤ綔娴佹暟鎹€? ## [1.0.22] - 2026-07-17 -- 进阶素材的“风格”分类新增 2~8 张样本组导入(推荐 3~6 张);每张图拥有独立任务、计时、错误与重试,并由 8 Worker 同时处理,不再串行共享超时。 -- 新增逐图识别屏障和多图交叉归纳:模型同时读取全部有效原图与逐图报告,区分核心共同画风、可变项、源内容污染、疑似离群样本和 1~3 张代表样本,并生成 compact / standard / detailed 三档画风胶囊。 -- 新增三路纯提示词迁移验证,使用完全不同的角色、场景和构图且不传源图;三项任务独立并发,单项失败可单独重试,调整后创建新共识版本并复用相同验证场景。 -- 新增 `advanced_style_sources`、`advanced_style_consensus_runs`、`advanced_style_validation_cases` 三表;父导入与 2~8 张源记录原子写入,验证图片继续隔离在 `storage://advanced_materials/style-validations`。 -- 前端仅在“风格”分类启用多图上传,支持粘贴、拖入、追加、移除、排序/主参考、失败重试、样本排除与恢复,并展示交叉归纳、代表/离群样本和三场景状态。 -- 封存后仍只产生一个高优先级 `advmat_`;快速角色使用统一文字胶囊,详细工作流冻结主参考与最多两张可信代表图,普通素材伪造 metadata 无法注入额外引用。 -- 备份脱敏、恢复、孤儿媒体、逐场景成本、素材统计、Worker 重启恢复、路由契约和深色主题同步覆盖新链路;付费验证任务重启后不会自动重复提交。 +- 杩涢樁绱犳潗鐨勨€滈鏍尖€濆垎绫绘柊澧?2锝? 寮犳牱鏈粍瀵煎叆锛堟帹鑽?3锝? 寮狅級锛涙瘡寮犲浘鎷ユ湁鐙珛浠诲姟銆佽鏃躲€侀敊璇笌閲嶈瘯锛屽苟鐢?8 Worker 鍚屾椂澶勭悊锛屼笉鍐嶄覆琛屽叡浜秴鏃躲€? +- 鏂板閫愬浘璇嗗埆灞忛殰鍜屽鍥句氦鍙夊綊绾筹細妯″瀷鍚屾椂璇诲彇鍏ㄩ儴鏈夋晥鍘熷浘涓庨€愬浘鎶ュ憡锛屽尯鍒嗘牳蹇冨叡鍚岀敾椋庛€佸彲鍙橀」銆佹簮鍐呭姹℃煋銆佺枒浼肩缇ゆ牱鏈拰 1锝? 寮犱唬琛ㄦ牱鏈紝骞剁敓鎴?compact / standard / detailed 涓夋。鐢婚鑳跺泭銆? +- 鏂板涓夎矾绾彁绀鸿瘝杩佺Щ楠岃瘉锛屼娇鐢ㄥ畬鍏ㄤ笉鍚岀殑瑙掕壊銆佸満鏅拰鏋勫浘涓斾笉浼犳簮鍥撅紱涓夐」浠诲姟鐙珛骞跺彂锛屽崟椤瑰け璐ュ彲鍗曠嫭閲嶈瘯锛岃皟鏁村悗鍒涘缓鏂板叡璇嗙増鏈苟澶嶇敤鐩稿悓楠岃瘉鍦烘櫙銆? +- 鏂板 `advanced_style_sources`銆乣advanced_style_consensus_runs`銆乣advanced_style_validation_cases` 涓夎〃锛涚埗瀵煎叆涓?2锝? 寮犳簮璁板綍鍘熷瓙鍐欏叆锛岄獙璇佸浘鐗囩户缁殧绂诲湪 `storage://advanced_materials/style-validations`銆? +- 鍓嶇浠呭湪鈥滈鏍尖€濆垎绫诲惎鐢ㄥ鍥句笂浼狅紝鏀寔绮樿创銆佹嫋鍏ャ€佽拷鍔犮€佺Щ闄ゃ€佹帓搴?涓诲弬鑰冦€佸け璐ラ噸璇曘€佹牱鏈帓闄や笌鎭㈠锛屽苟灞曠ず浜ゅ弶褰掔撼銆佷唬琛?绂荤兢鏍锋湰鍜屼笁鍦烘櫙鐘舵€併€? +- 灏佸瓨鍚庝粛鍙骇鐢熶竴涓珮浼樺厛绾?`advmat_`锛涘揩閫熻鑹蹭娇鐢ㄧ粺涓€鏂囧瓧鑳跺泭锛岃缁嗗伐浣滄祦鍐荤粨涓诲弬鑰冧笌鏈€澶氫袱寮犲彲淇′唬琛ㄥ浘锛屾櫘閫氱礌鏉愪吉閫?metadata 鏃犳硶娉ㄥ叆棰濆寮曠敤銆? +- 澶囦唤鑴辨晱銆佹仮澶嶃€佸鍎垮獟浣撱€侀€愬満鏅垚鏈€佺礌鏉愮粺璁°€乄orker 閲嶅惎鎭㈠銆佽矾鐢卞绾﹀拰娣辫壊涓婚鍚屾瑕嗙洊鏂伴摼璺紱浠樿垂楠岃瘉浠诲姟閲嶅惎鍚庝笉浼氳嚜鍔ㄩ噸澶嶆彁浜ゃ€? ## [1.0.21] - 2026-07-16 -- 新增独立“进阶素材”入库线:源图经 Vision 识别后,只用提取出的文字提示词生成验证图;用户可并排判断还原度,不满意时追加描述进入下一轮,满意后才封存。 -- 新增 `advanced_material_imports`、`advanced_material_validation_attempts`、`advanced_materials` 三表与 `storage://advanced_materials` 独立文件根;验证图不进入普通图库、单图池或工作流候选池。 -- 进阶素材以服务端可信标记进入统一素材目录,快速角色和详细工作流优先使用;普通素材伪造 metadata 不会获得进阶优先级。 -- 验证生图接入恐暴/极端暴力前置禁止、成人内容白名单与 NSFW 路由、普通模型明确 NSFW 拒绝后的一次性回退,以及可保存的独立预算守卫。 -- 修复运行中取消后的迟到结果复活、快速重启任务永久卡住、失败/取消但已计费轮次漏算、脱敏备份写入 NOT NULL 失败和空 MIME 图片误报 PNG。 -- 新增进阶导入、三库切换、任务轮询、原图/验证图并排审核、调整重试、显式封存、深色主题和高优先级标记;模型分工新增进阶识别与验证生图两张卡。 -- 专项覆盖迁移幂等、仓储事务、普通/进阶隔离、无图生图输入、取消 CAS、安全路由、预算、重启恢复、备份、成本与前端上传契约。 +- 鏂板鐙珛鈥滆繘闃剁礌鏉愨€濆叆搴撶嚎锛氭簮鍥剧粡 Vision 璇嗗埆鍚庯紝鍙敤鎻愬彇鍑虹殑鏂囧瓧鎻愮ず璇嶇敓鎴愰獙璇佸浘锛涚敤鎴峰彲骞舵帓鍒ゆ柇杩樺師搴︼紝涓嶆弧鎰忔椂杩藉姞鎻忚堪杩涘叆涓嬩竴杞紝婊℃剰鍚庢墠灏佸瓨銆? +- 鏂板 `advanced_material_imports`銆乣advanced_material_validation_attempts`銆乣advanced_materials` 涓夎〃涓?`storage://advanced_materials` 鐙珛鏂囦欢鏍癸紱楠岃瘉鍥句笉杩涘叆鏅€氬浘搴撱€佸崟鍥炬睜鎴栧伐浣滄祦鍊欓€夋睜銆? +- 杩涢樁绱犳潗浠ユ湇鍔$鍙俊鏍囪杩涘叆缁熶竴绱犳潗鐩綍锛屽揩閫熻鑹插拰璇︾粏宸ヤ綔娴佷紭鍏堜娇鐢紱鏅€氱礌鏉愪吉閫?metadata 涓嶄細鑾峰緱杩涢樁浼樺厛绾с€? +- 楠岃瘉鐢熷浘鎺ュ叆鎭愭毚/鏋佺鏆村姏鍓嶇疆绂佹銆佹垚浜哄唴瀹圭櫧鍚嶅崟涓?NSFW 璺敱銆佹櫘閫氭ā鍨嬫槑纭?NSFW 鎷掔粷鍚庣殑涓€娆℃€у洖閫€锛屼互鍙婂彲淇濆瓨鐨勭嫭绔嬮绠楀畧鍗€? +- 淇杩愯涓彇娑堝悗鐨勮繜鍒扮粨鏋滃娲汇€佸揩閫熼噸鍚换鍔℃案涔呭崱浣忋€佸け璐?鍙栨秷浣嗗凡璁¤垂杞婕忕畻銆佽劚鏁忓浠藉啓鍏?NOT NULL 澶辫触鍜岀┖ MIME 鍥剧墖璇姤 PNG銆? +- 鏂板杩涢樁瀵煎叆銆佷笁搴撳垏鎹€佷换鍔¤疆璇€佸師鍥?楠岃瘉鍥惧苟鎺掑鏍搞€佽皟鏁撮噸璇曘€佹樉寮忓皝瀛樸€佹繁鑹蹭富棰樺拰楂樹紭鍏堢骇鏍囪锛涙ā鍨嬪垎宸ユ柊澧炶繘闃惰瘑鍒笌楠岃瘉鐢熷浘涓ゅ紶鍗°€? +- 涓撻」瑕嗙洊杩佺Щ骞傜瓑銆佷粨鍌ㄤ簨鍔°€佹櫘閫?杩涢樁闅旂銆佹棤鍥剧敓鍥捐緭鍏ャ€佸彇娑?CAS銆佸畨鍏ㄨ矾鐢便€侀绠椼€侀噸鍚仮澶嶃€佸浠姐€佹垚鏈笌鍓嶇涓婁紶濂戠害銆? ## [1.0.20] - 2026-07-15 -- 发布总验收补齐两处跨版本接线:工作台唯一挂载生成式交叉审查对话框并真实调用 decide/regenerate/approve;档案卡入库移除客户端三段式写入,统一调用后端 `finalize-card` 幂等事务。 -- AstrBot 托管配置桥补齐视觉质检、兼容审核与生成式交叉审查的主/副/列表字段;保存、清空和重载均保留真实值,不再被旧运行时覆盖恢复。 -- 新增全新安装、1.0.8 原位升级、重复迁移、缺表/半迁移恢复、stale Worker、终态通知补发、宿主已加载顶层 `core` 包和插件初始化顺序回归。 -- 前端新增路由继承、锁状态、交叉审查接线与原子档案卡接线契约测试;生产构建继续输出 AstrBot 插件页与独立 Web 兼容产物。 -- 清除生产包中断连时可达的假生图、假角色、示例素材和预览模型;断连与空后端统一显示明确空状态,缺少图片的真实记录仅显示“未生成/无缩略图”。 -- README 与 INSTALL 更新 11 节点工作流、聊天命令、模型分工、无模型行为、Docker/NAS 覆盖和显式运行时 ZIP 白名单;发布包禁止包含 `.env*`、真实数据、测试、前端工程和缓存。 -- NAS 实机从 1.0.8 原位升级并重启 `astrbot-ops-pro`:AstrBot 成功加载 ImageStudio 1.0.20,SQLite 15 条迁移与关键轮次/档案卡/素材表通过检查,插件页面自动连接且未触发真实付费生图。 +- 鍙戝竷鎬婚獙鏀惰ˉ榻愪袱澶勮法鐗堟湰鎺ョ嚎锛氬伐浣滃彴鍞竴鎸傝浇鐢熸垚寮忎氦鍙夊鏌ュ璇濇骞剁湡瀹炶皟鐢?decide/regenerate/approve锛涙。妗堝崱鍏ュ簱绉婚櫎瀹㈡埛绔笁娈靛紡鍐欏叆锛岀粺涓€璋冪敤鍚庣 `finalize-card` 骞傜瓑浜嬪姟銆? +- AstrBot 鎵樼閰嶇疆妗ヨˉ榻愯瑙夎川妫€銆佸吋瀹瑰鏍镐笌鐢熸垚寮忎氦鍙夊鏌ョ殑涓?鍓?鍒楄〃瀛楁锛涗繚瀛樸€佹竻绌哄拰閲嶈浇鍧囦繚鐣欑湡瀹炲€硷紝涓嶅啀琚棫杩愯鏃惰鐩栨仮澶嶃€? +- 鏂板鍏ㄦ柊瀹夎銆?.0.8 鍘熶綅鍗囩骇銆侀噸澶嶈縼绉汇€佺己琛?鍗婅縼绉绘仮澶嶃€乻tale Worker銆佺粓鎬侀€氱煡琛ュ彂銆佸涓诲凡鍔犺浇椤跺眰 `core` 鍖呭拰鎻掍欢鍒濆鍖栭『搴忓洖褰掋€? +- 鍓嶇鏂板璺敱缁ф壙銆侀攣鐘舵€併€佷氦鍙夊鏌ユ帴绾夸笌鍘熷瓙妗f鍗℃帴绾垮绾︽祴璇曪紱鐢熶骇鏋勫缓缁х画杈撳嚭 AstrBot 鎻掍欢椤典笌鐙珛 Web 鍏煎浜х墿銆? +- 娓呴櫎鐢熶骇鍖呬腑鏂繛鏃跺彲杈剧殑鍋囩敓鍥俱€佸亣瑙掕壊銆佺ず渚嬬礌鏉愬拰棰勮妯″瀷锛涙柇杩炰笌绌哄悗绔粺涓€鏄剧ず鏄庣‘绌虹姸鎬侊紝缂哄皯鍥剧墖鐨勭湡瀹炶褰曚粎鏄剧ず鈥滄湭鐢熸垚/鏃犵缉鐣ュ浘鈥濄€? +- README 涓?INSTALL 鏇存柊 11 鑺傜偣宸ヤ綔娴併€佽亰澶╁懡浠ゃ€佹ā鍨嬪垎宸ャ€佹棤妯″瀷琛屼负銆丏ocker/NAS 瑕嗙洊鍜屾樉寮忚繍琛屾椂 ZIP 鐧藉悕鍗曪紱鍙戝竷鍖呯姝㈠寘鍚?`.env*`銆佺湡瀹炴暟鎹€佹祴璇曘€佸墠绔伐绋嬪拰缂撳瓨銆? +- NAS 瀹炴満浠?1.0.8 鍘熶綅鍗囩骇骞堕噸鍚?`astrbot-ops-pro`锛欰strBot 鎴愬姛鍔犺浇 ImageStudio 1.0.20锛孲QLite 15 鏉¤縼绉讳笌鍏抽敭杞/妗f鍗?绱犳潗琛ㄩ€氳繃妫€鏌ワ紝鎻掍欢椤甸潰鑷姩杩炴帴涓旀湭瑙﹀彂鐪熷疄浠樿垂鐢熷浘銆? ## [1.0.9] - 2026-07-15 -- 在现有节点、任务、图片和历史链路之上增加稳定的生成轮次、候选与候选池聚合层。 -- 旧工作流图片通过只读 legacy round 展示,不搬文件、不改原有 `image_id`。 -- 新增 `TX-01`、`TX-01-03` 等持久化显示码,并记录模型来源、失败摘要与轮次快照。 -- `SingleFlowEngine` 支持按 workflow/branch/node/round/candidate 隔离输出目录;无 round 上下文时保持旧路径兼容。 -- 补齐数据库表元数据与 AstrBot/前端共享 round 接口;创建轮次仅规划候选,不会触发真实生图。 +- 鍦ㄧ幇鏈夎妭鐐广€佷换鍔°€佸浘鐗囧拰鍘嗗彶閾捐矾涔嬩笂澧炲姞绋冲畾鐨勭敓鎴愯疆娆°€佸€欓€変笌鍊欓€夋睜鑱氬悎灞傘€? +- 鏃у伐浣滄祦鍥剧墖閫氳繃鍙 legacy round 灞曠ず锛屼笉鎼枃浠躲€佷笉鏀瑰師鏈?`image_id`銆? +- 鏂板 `TX-01`銆乣TX-01-03` 绛夋寔涔呭寲鏄剧ず鐮侊紝骞惰褰曟ā鍨嬫潵婧愩€佸け璐ユ憳瑕佷笌杞蹇収銆? +- `SingleFlowEngine` 鏀寔鎸?workflow/branch/node/round/candidate 闅旂杈撳嚭鐩綍锛涙棤 round 涓婁笅鏂囨椂淇濇寔鏃ц矾寰勫吋瀹广€? +- 琛ラ綈鏁版嵁搴撹〃鍏冩暟鎹笌 AstrBot/鍓嶇鍏变韩 round 鎺ュ彛锛涘垱寤鸿疆娆′粎瑙勫垝鍊欓€夛紝涓嶄細瑙﹀彂鐪熷疄鐢熷浘銆? ## [1.0.10] - 2026-07-15 -- 详细工作流每轮只执行一次提示词扩写、治理、路由、素材快照与成本检查,再拆分为 4–5 条独立 `count=1` 候选任务。 -- 启用 5 Worker 持久并发池;单候选失败或超时不影响同轮其他候选,轮次聚合支持完成、部分成功、全部失败和取消。 -- AstrBot 初始化自动启动 Worker、终止时停止;启动可恢复 stale `running/retrying` 任务,旧同步 `generate_node()` 保持兼容。 -- 异步任务拒绝持久化 data URL;模型路由只保存无敏感字段的快照,执行时重新解析并校验 provider/model 未漂移。 +- 璇︾粏宸ヤ綔娴佹瘡杞彧鎵ц涓€娆℃彁绀鸿瘝鎵╁啓銆佹不鐞嗐€佽矾鐢便€佺礌鏉愬揩鐓т笌鎴愭湰妫€鏌ワ紝鍐嶆媶鍒嗕负 4鈥? 鏉$嫭绔?`count=1` 鍊欓€変换鍔°€? +- 鍚敤 5 Worker 鎸佷箙骞跺彂姹狅紱鍗曞€欓€夊け璐ユ垨瓒呮椂涓嶅奖鍝嶅悓杞叾浠栧€欓€夛紝杞鑱氬悎鏀寔瀹屾垚銆侀儴鍒嗘垚鍔熴€佸叏閮ㄥけ璐ュ拰鍙栨秷銆? +- AstrBot 鍒濆鍖栬嚜鍔ㄥ惎鍔?Worker銆佺粓姝㈡椂鍋滄锛涘惎鍔ㄥ彲鎭㈠ stale `running/retrying` 浠诲姟锛屾棫鍚屾 `generate_node()` 淇濇寔鍏煎銆? +- 寮傛浠诲姟鎷掔粷鎸佷箙鍖?data URL锛涙ā鍨嬭矾鐢卞彧淇濆瓨鏃犳晱鎰熷瓧娈电殑蹇収锛屾墽琛屾椂閲嶆柊瑙f瀽骞舵牎楠?provider/model 鏈紓绉汇€? ## [1.0.11] - 2026-07-15 -- 详细角色候选的聚焦、平铺比较、喜欢/拒绝反馈与最终定稿改为四套独立状态;每轮最多保留 3 个喜欢候选,最终确认严格只能选择 1 个成功候选。 -- 新增 round feedback/confirm 接口;反馈持久化到候选池与轮次快照,刷新后可恢复,且不会误调用图片采用接口。 -- 最终确认在单事务内完成候选定稿、图片独占选择、节点状态、历史记录、分支阶段输入和后继节点推进;失败完整回滚,服务端拒绝客户端指定下一节点。 -- 工作台接入 4/5 张候选数量、当前轮/历史轮、节制轮询、部分成功/全失败、模型来源、单候选失败和入队提示;旧图片继续使用只读兼容轮次。 +- 璇︾粏瑙掕壊鍊欓€夌殑鑱氱劍銆佸钩閾烘瘮杈冦€佸枩娆?鎷掔粷鍙嶉涓庢渶缁堝畾绋挎敼涓哄洓濂楃嫭绔嬬姸鎬侊紱姣忚疆鏈€澶氫繚鐣?3 涓枩娆㈠€欓€夛紝鏈€缁堢‘璁や弗鏍煎彧鑳介€夋嫨 1 涓垚鍔熷€欓€夈€? +- 鏂板 round feedback/confirm 鎺ュ彛锛涘弽棣堟寔涔呭寲鍒板€欓€夋睜涓庤疆娆″揩鐓э紝鍒锋柊鍚庡彲鎭㈠锛屼笖涓嶄細璇皟鐢ㄥ浘鐗囬噰鐢ㄦ帴鍙c€? +- 鏈€缁堢‘璁ゅ湪鍗曚簨鍔″唴瀹屾垚鍊欓€夊畾绋裤€佸浘鐗囩嫭鍗犻€夋嫨銆佽妭鐐圭姸鎬併€佸巻鍙茶褰曘€佸垎鏀樁娈佃緭鍏ュ拰鍚庣户鑺傜偣鎺ㄨ繘锛涘け璐ュ畬鏁村洖婊氾紝鏈嶅姟绔嫆缁濆鎴风鎸囧畾涓嬩竴鑺傜偣銆? +- 宸ヤ綔鍙版帴鍏?4/5 寮犲€欓€夋暟閲忋€佸綋鍓嶈疆/鍘嗗彶杞€佽妭鍒惰疆璇€侀儴鍒嗘垚鍔?鍏ㄥけ璐ャ€佹ā鍨嬫潵婧愩€佸崟鍊欓€夊け璐ュ拰鍏ラ槦鎻愮ず锛涙棫鍥剧墖缁х画浣跨敤鍙鍏煎杞銆? ## [1.0.12] - 2026-07-15 -- 工作流对话框支持“1、2 喜欢,3 严格拒绝”等自然语言反馈;LLM 只接收持久展示码和受限候选提示词快照,服务端重新白名单映射,模型失败时安全回退到本地确定性解析。 -- 反馈持久化用户原文、摘要、喜欢/拒绝/严格拒绝、草稿定稿、素材意图与正负提示词补丁;下一轮记录父轮次并严格要求 1–3 个生成成功且喜欢的候选。 -- 下一轮读取父轮次、候选池和反馈的单一一致性快照,并在创建事务中校验反馈版本;并发反馈变化时拒绝写入,不产生混合或残留子轮次。 -- round 的创建、读取、反馈、下一轮和确认统一接入 profile → workflow → node 所有权链;越权使用资源不存在语义,同时保留 system 与全局管理员兼容。 -- 前端反馈发送不再依赖生图模型;点击“开始下一轮”会先保存未提交文本,保存失败不清空、不建轮次,并同步展示候选门槛与可操作原因。 +- 宸ヤ綔娴佸璇濇鏀寔鈥?銆? 鍠滄锛? 涓ユ牸鎷掔粷鈥濈瓑鑷劧璇█鍙嶉锛汱LM 鍙帴鏀舵寔涔呭睍绀虹爜鍜屽彈闄愬€欓€夋彁绀鸿瘝蹇収锛屾湇鍔$閲嶆柊鐧藉悕鍗曟槧灏勶紝妯″瀷澶辫触鏃跺畨鍏ㄥ洖閫€鍒版湰鍦扮‘瀹氭€цВ鏋愩€? +- 鍙嶉鎸佷箙鍖栫敤鎴峰師鏂囥€佹憳瑕併€佸枩娆?鎷掔粷/涓ユ牸鎷掔粷銆佽崏绋垮畾绋裤€佺礌鏉愭剰鍥句笌姝h礋鎻愮ず璇嶈ˉ涓侊紱涓嬩竴杞褰曠埗杞骞朵弗鏍艰姹?1鈥? 涓敓鎴愭垚鍔熶笖鍠滄鐨勫€欓€夈€? +- 涓嬩竴杞鍙栫埗杞銆佸€欓€夋睜鍜屽弽棣堢殑鍗曚竴涓€鑷存€у揩鐓э紝骞跺湪鍒涘缓浜嬪姟涓牎楠屽弽棣堢増鏈紱骞跺彂鍙嶉鍙樺寲鏃舵嫆缁濆啓鍏ワ紝涓嶄骇鐢熸贩鍚堟垨娈嬬暀瀛愯疆娆°€? +- round 鐨勫垱寤恒€佽鍙栥€佸弽棣堛€佷笅涓€杞拰纭缁熶竴鎺ュ叆 profile 鈫?workflow 鈫?node 鎵€鏈夋潈閾撅紱瓒婃潈浣跨敤璧勬簮涓嶅瓨鍦ㄨ涔夛紝鍚屾椂淇濈暀 system 涓庡叏灞€绠$悊鍛樺吋瀹广€? +- 鍓嶇鍙嶉鍙戦€佷笉鍐嶄緷璧栫敓鍥炬ā鍨嬶紱鐐瑰嚮鈥滃紑濮嬩笅涓€杞€濅細鍏堜繚瀛樻湭鎻愪氦鏂囨湰锛屼繚瀛樺け璐ヤ笉娓呯┖銆佷笉寤鸿疆娆★紝骞跺悓姝ュ睍绀哄€欓€夐棬妲涗笌鍙搷浣滃師鍥犮€? ## [1.0.13] - 2026-07-15 -- 详细工作流的任意未封存图像节点可打开独立素材抽屉,复用现有上传、粘贴、视觉识别、确认与素材库筛选能力;抽屉保留 workflow、branch、node、round 返回上下文。 -- 节点绑定接口只持久化已确认的 `material_id` 和安全导航上下文;data URL 仅在上传请求内存阶段使用,不进入节点元数据、异步任务或历史记录。 -- 每轮生成冻结不可变 material/reference snapshot;后续修改素材、分类或当前节点绑定不会改变历史轮次,重新打开角色会从后端恢复完整绑定集合。 -- 写入统一校验资源 owner、当前分支、节点阶段与只读状态;锁定/封存节点明确提示创建分支。抽屉使用主题 token、安全背景单击关闭和移动端布局。 +- 璇︾粏宸ヤ綔娴佺殑浠绘剰鏈皝瀛樺浘鍍忚妭鐐瑰彲鎵撳紑鐙珛绱犳潗鎶藉眽锛屽鐢ㄧ幇鏈変笂浼犮€佺矘璐淬€佽瑙夎瘑鍒€佺‘璁や笌绱犳潗搴撶瓫閫夎兘鍔涳紱鎶藉眽淇濈暀 workflow銆乥ranch銆乶ode銆乺ound 杩斿洖涓婁笅鏂囥€? +- 鑺傜偣缁戝畾鎺ュ彛鍙寔涔呭寲宸茬‘璁ょ殑 `material_id` 鍜屽畨鍏ㄥ鑸笂涓嬫枃锛沝ata URL 浠呭湪涓婁紶璇锋眰鍐呭瓨闃舵浣跨敤锛屼笉杩涘叆鑺傜偣鍏冩暟鎹€佸紓姝ヤ换鍔℃垨鍘嗗彶璁板綍銆? +- 姣忚疆鐢熸垚鍐荤粨涓嶅彲鍙?material/reference snapshot锛涘悗缁慨鏀圭礌鏉愩€佸垎绫绘垨褰撳墠鑺傜偣缁戝畾涓嶄細鏀瑰彉鍘嗗彶杞锛岄噸鏂版墦寮€瑙掕壊浼氫粠鍚庣鎭㈠瀹屾暣缁戝畾闆嗗悎銆? +- 鍐欏叆缁熶竴鏍¢獙璧勬簮 owner銆佸綋鍓嶅垎鏀€佽妭鐐归樁娈典笌鍙鐘舵€侊紱閿佸畾/灏佸瓨鑺傜偣鏄庣‘鎻愮ず鍒涘缓鍒嗘敮銆傛娊灞変娇鐢ㄤ富棰?token銆佸畨鍏ㄨ儗鏅崟鍑诲叧闂拰绉诲姩绔竷灞€銆? ## [1.0.14] - 2026-07-15 -- 保留原有 VLM 视觉质检,并新增独立生成式交叉审核;审核候选强制来自不同的 image-generation provider/model,缺少配置时返回可操作的 `required_action`。 -- 审核池始终保留 01 主候选并标注适配器/模型;后续轮只重生用户勾选项,未勾选候选与槽位保持不变,所有 review/skip/approve 操作均写入历史。 -- 审核通过或跳过后,以幂等原子事务建立只读 XF 高清修复交接轮次、候选和素材快照,再推进工作流;注入失败会完整回滚,不留下半轮次或重复记录。 -- 审核决策、重生和通过接口统一接入 profile → workflow → node → round 的所有权链;前端审核弹窗使用暗色 token、安全背景单击关闭和窄屏布局。 +- 淇濈暀鍘熸湁 VLM 瑙嗚璐ㄦ锛屽苟鏂板鐙珛鐢熸垚寮忎氦鍙夊鏍革紱瀹℃牳鍊欓€夊己鍒舵潵鑷笉鍚岀殑 image-generation provider/model锛岀己灏戦厤缃椂杩斿洖鍙搷浣滅殑 `required_action`銆? +- 瀹℃牳姹犲缁堜繚鐣?01 涓诲€欓€夊苟鏍囨敞閫傞厤鍣?妯″瀷锛涘悗缁疆鍙噸鐢熺敤鎴峰嬀閫夐」锛屾湭鍕鹃€夊€欓€変笌妲戒綅淇濇寔涓嶅彉锛屾墍鏈?review/skip/approve 鎿嶄綔鍧囧啓鍏ュ巻鍙层€? +- 瀹℃牳閫氳繃鎴栬烦杩囧悗锛屼互骞傜瓑鍘熷瓙浜嬪姟寤虹珛鍙 XF 楂樻竻淇浜ゆ帴杞銆佸€欓€夊拰绱犳潗蹇収锛屽啀鎺ㄨ繘宸ヤ綔娴侊紱娉ㄥ叆澶辫触浼氬畬鏁村洖婊氾紝涓嶇暀涓嬪崐杞鎴栭噸澶嶈褰曘€? +- 瀹℃牳鍐崇瓥銆侀噸鐢熷拰閫氳繃鎺ュ彛缁熶竴鎺ュ叆 profile 鈫?workflow 鈫?node 鈫?round 鐨勬墍鏈夋潈閾撅紱鍓嶇瀹℃牳寮圭獥浣跨敤鏆楄壊 token銆佸畨鍏ㄨ儗鏅崟鍑诲叧闂拰绐勫睆甯冨眬銆? ## [1.0.15] - 2026-07-15 -- 在现有 `character_gradual` 工作流中补齐确认人设、拆解设定、预选素材、头像、上半身、下半身、全身、三视图、设定图、高清修复和档案卡共 11 个规范节点。 -- 保留旧节点 ID、图片与历史;`half_body / expression_sheet / pose_sheet / final_pack` 通过集中映射继续可读,旧工作流只惰性补充缺失的下半身节点。 -- 前后端提示词规划、素材绑定、依赖注入、模型分工和节点展示统一使用 canonical stage catalog。 +- 鍦ㄧ幇鏈?`character_gradual` 宸ヤ綔娴佷腑琛ラ綈纭浜鸿銆佹媶瑙h瀹氥€侀閫夌礌鏉愩€佸ご鍍忋€佷笂鍗婅韩銆佷笅鍗婅韩銆佸叏韬€佷笁瑙嗗浘銆佽瀹氬浘銆侀珮娓呬慨澶嶅拰妗f鍗″叡 11 涓鑼冭妭鐐广€? +- 淇濈暀鏃ц妭鐐?ID銆佸浘鐗囦笌鍘嗗彶锛沗half_body / expression_sheet / pose_sheet / final_pack` 閫氳繃闆嗕腑鏄犲皠缁х画鍙锛屾棫宸ヤ綔娴佸彧鎯版€цˉ鍏呯己澶辩殑涓嬪崐韬妭鐐广€? +- 鍓嶅悗绔彁绀鸿瘝瑙勫垝銆佺礌鏉愮粦瀹氥€佷緷璧栨敞鍏ャ€佹ā鍨嬪垎宸ュ拰鑺傜偣灞曠ず缁熶竴浣跨敤 canonical stage catalog銆? ## [1.0.16] - 2026-07-15 -- 分支与物理节点副本改为单事务创建,校验父分支、自父、环、状态、切点和“仅已完成节点可分支”。 -- 增加多层祖先解析和 branch_state 隔离;依赖上下文明确标注继承来源分支与来源节点。 -- 工作台增加紧凑分支面板、父链/切点/状态展示和按需依赖上下文,保持三栏与移动端横向布局。 +- 鍒嗘敮涓庣墿鐞嗚妭鐐瑰壇鏈敼涓哄崟浜嬪姟鍒涘缓锛屾牎楠岀埗鍒嗘敮銆佽嚜鐖躲€佺幆銆佺姸鎬併€佸垏鐐瑰拰鈥滀粎宸插畬鎴愯妭鐐瑰彲鍒嗘敮鈥濄€? +- 澧炲姞澶氬眰绁栧厛瑙f瀽鍜?branch_state 闅旂锛涗緷璧栦笂涓嬫枃鏄庣‘鏍囨敞缁ф壙鏉ユ簮鍒嗘敮涓庢潵婧愯妭鐐广€? +- 宸ヤ綔鍙板鍔犵揣鍑戝垎鏀潰鏉裤€佺埗閾?鍒囩偣/鐘舵€佸睍绀哄拰鎸夐渶渚濊禆涓婁笅鏂囷紝淇濇寔涓夋爮涓庣Щ鍔ㄧ妯悜甯冨眬銆? ## [1.0.17] - 2026-07-15 -- 档案卡封存改为单事务:校验活动分支与四类必填资产,同时写入卡、资产、头像、历史、档案卡节点并封存工作流。 -- 支持幂等、防跨分支串图、失败回滚,以及旧 `final_archive_*` 的只读档案卡视图。 -- 角色分类固定为未生成、快速角色、档案卡;详细工作流进度独立展示,三类列表边框、筛选和封存只读状态已接入。 +- 妗f鍗″皝瀛樻敼涓哄崟浜嬪姟锛氭牎楠屾椿鍔ㄥ垎鏀笌鍥涚被蹇呭~璧勪骇锛屽悓鏃跺啓鍏ュ崱銆佽祫浜с€佸ご鍍忋€佸巻鍙层€佹。妗堝崱鑺傜偣骞跺皝瀛樺伐浣滄祦銆? +- 鏀寔骞傜瓑銆侀槻璺ㄥ垎鏀覆鍥俱€佸け璐ュ洖婊氾紝浠ュ強鏃?`final_archive_*` 鐨勫彧璇绘。妗堝崱瑙嗗浘銆? +- 瑙掕壊鍒嗙被鍥哄畾涓烘湭鐢熸垚銆佸揩閫熻鑹层€佹。妗堝崱锛涜缁嗗伐浣滄祦杩涘害鐙珛灞曠ず锛屼笁绫诲垪琛ㄨ竟妗嗐€佺瓫閫夊拰灏佸瓨鍙鐘舵€佸凡鎺ュ叆銆? ## [1.0.18] - 2026-07-15 -- `/影棚` 与 `/yp` 的帮助、状态、快速角色、轮次、候选、自然语言反馈、下一轮、严格单候选定稿、生成式交叉审查、素材、分支和档案卡命令逐项委托相同 canonical handler,与 Web 共用 progression/round/feedback/confirm 服务。 -- 快速角色聊天入口改为现有 `character_fast` 四图并行流;详细角色不再调用旧 select/adopt 捷径,活动分支和节点所有权由服务端校验,generation 节点无图不能空完成。 -- 长任务先返回入队回执;聊天 reply target 持久化到轮次,Worker 终态主动回传。重载后可恢复尚未确认的 scheduled 通知,已 delivered 的通知持久去重。 -- 单图任意白名单、快速/详细角色群聊与用户双白名单规则保持不变;知道资源 ID 也不能绕过 profile → workflow → node → round 所有权链。 -- 帮助与状态优先返回运行时生成的图片卡,渲染或平台能力不足时自动回退为文本,不会阻塞命令处理。 +- `/褰辨` 涓?`/yp` 鐨勫府鍔┿€佺姸鎬併€佸揩閫熻鑹层€佽疆娆°€佸€欓€夈€佽嚜鐒惰瑷€鍙嶉銆佷笅涓€杞€佷弗鏍煎崟鍊欓€夊畾绋裤€佺敓鎴愬紡浜ゅ弶瀹℃煡銆佺礌鏉愩€佸垎鏀拰妗f鍗″懡浠ら€愰」濮旀墭鐩稿悓 canonical handler锛屼笌 Web 鍏辩敤 progression/round/feedback/confirm 鏈嶅姟銆? +- 蹇€熻鑹茶亰澶╁叆鍙f敼涓虹幇鏈?`character_fast` 鍥涘浘骞惰娴侊紱璇︾粏瑙掕壊涓嶅啀璋冪敤鏃?select/adopt 鎹峰緞锛屾椿鍔ㄥ垎鏀拰鑺傜偣鎵€鏈夋潈鐢辨湇鍔$鏍¢獙锛実eneration 鑺傜偣鏃犲浘涓嶈兘绌哄畬鎴愩€? +- 闀夸换鍔″厛杩斿洖鍏ラ槦鍥炴墽锛涜亰澶?reply target 鎸佷箙鍖栧埌杞锛學orker 缁堟€佷富鍔ㄥ洖浼犮€傞噸杞藉悗鍙仮澶嶅皻鏈‘璁ょ殑 scheduled 閫氱煡锛屽凡 delivered 鐨勯€氱煡鎸佷箙鍘婚噸銆? +- 鍗曞浘浠绘剰鐧藉悕鍗曘€佸揩閫?璇︾粏瑙掕壊缇よ亰涓庣敤鎴峰弻鐧藉悕鍗曡鍒欎繚鎸佷笉鍙橈紱鐭ラ亾璧勬簮 ID 涔熶笉鑳界粫杩?profile 鈫?workflow 鈫?node 鈫?round 鎵€鏈夋潈閾俱€? +- 甯姪涓庣姸鎬佷紭鍏堣繑鍥炶繍琛屾椂鐢熸垚鐨勫浘鐗囧崱锛屾覆鏌撴垨骞冲彴鑳藉姏涓嶈冻鏃惰嚜鍔ㄥ洖閫€涓烘枃鏈紝涓嶄細闃诲鍛戒护澶勭悊銆? ## [1.0.19] - 2026-07-15 -- 保留现有三栏工作台并抽出 `WorkflowComposer`;catalog、轮次、候选池、比较、确认、素材、分支与依赖面板继续使用单一组件实现,删除详细工作流对全局单图模型选择的耦合。 -- 工作流生图路由按“显式覆盖 → 父轮次 → 节点 → 模型分工 → 角色默认 → 系统默认”展示;首轮和下一轮仅在用户明确覆盖时发送 `model_route`,继承时请求体不包含该字段。 -- Composer 同时显示实际生图模型、继承来源与提示词规划 LLM;文本 LLM 优先使用 translation 治理路由,再回退到 prompt_planning 分工,并显示适配器/模型友好名。 -- 修正节点锁语义:生成完成但未最终采用的 `completed` 节点仍可反馈、创建下一轮和修改节点素材;仅 `selected`、未来节点及封存/归档工作流写锁。 -- 历史轮次默认显示最近三轮并可展开;终态历史不重复请求,事件只刷新当前页面和可见活动轮次。头像使用 cover,全身/三视图/设定图使用 contain。 -- 所有新增浮层使用主题 token 和安全背景单击关闭;窄屏 Composer、按钮布局、空状态、部分成功、错误与重试提示完成回归。 +- 淇濈暀鐜版湁涓夋爮宸ヤ綔鍙板苟鎶藉嚭 `WorkflowComposer`锛沜atalog銆佽疆娆°€佸€欓€夋睜銆佹瘮杈冦€佺‘璁ゃ€佺礌鏉愩€佸垎鏀笌渚濊禆闈㈡澘缁х画浣跨敤鍗曚竴缁勪欢瀹炵幇锛屽垹闄よ缁嗗伐浣滄祦瀵瑰叏灞€鍗曞浘妯″瀷閫夋嫨鐨勮€﹀悎銆? +- 宸ヤ綔娴佺敓鍥捐矾鐢辨寜鈥滄樉寮忚鐩?鈫?鐖惰疆娆?鈫?鑺傜偣 鈫?妯″瀷鍒嗗伐 鈫?瑙掕壊榛樿 鈫?绯荤粺榛樿鈥濆睍绀猴紱棣栬疆鍜屼笅涓€杞粎鍦ㄧ敤鎴锋槑纭鐩栨椂鍙戦€?`model_route`锛岀户鎵挎椂璇锋眰浣撲笉鍖呭惈璇ュ瓧娈点€? +- Composer 鍚屾椂鏄剧ず瀹為檯鐢熷浘妯″瀷銆佺户鎵挎潵婧愪笌鎻愮ず璇嶈鍒?LLM锛涙枃鏈?LLM 浼樺厛浣跨敤 translation 娌荤悊璺敱锛屽啀鍥為€€鍒?prompt_planning 鍒嗗伐锛屽苟鏄剧ず閫傞厤鍣?妯″瀷鍙嬪ソ鍚嶃€? +- 淇鑺傜偣閿佽涔夛細鐢熸垚瀹屾垚浣嗘湭鏈€缁堥噰鐢ㄧ殑 `completed` 鑺傜偣浠嶅彲鍙嶉銆佸垱寤轰笅涓€杞拰淇敼鑺傜偣绱犳潗锛涗粎 `selected`銆佹湭鏉ヨ妭鐐瑰強灏佸瓨/褰掓。宸ヤ綔娴佸啓閿併€? +- 鍘嗗彶杞榛樿鏄剧ず鏈€杩戜笁杞苟鍙睍寮€锛涚粓鎬佸巻鍙蹭笉閲嶅璇锋眰锛屼簨浠跺彧鍒锋柊褰撳墠椤甸潰鍜屽彲瑙佹椿鍔ㄨ疆娆°€傚ご鍍忎娇鐢?cover锛屽叏韬?涓夎鍥?璁惧畾鍥句娇鐢?contain銆? +- 鎵€鏈夋柊澧炴诞灞備娇鐢ㄤ富棰?token 鍜屽畨鍏ㄨ儗鏅崟鍑诲叧闂紱绐勫睆 Composer銆佹寜閽竷灞€銆佺┖鐘舵€併€侀儴鍒嗘垚鍔熴€侀敊璇笌閲嶈瘯鎻愮ず瀹屾垚鍥炲綊銆? ## [1.0.8] - 2026-07-15 -- 详细角色工作流支持逐节点解锁:锁定节点可查看,只有当前节点可操作。 -- 前后端增加防越级校验;生图节点必须采用图片后才能推进。 -- 提示词规划、素材绑定保存与确认分离,并兼容旧工作流数据。 +- 璇︾粏瑙掕壊宸ヤ綔娴佹敮鎸侀€愯妭鐐硅В閿侊細閿佸畾鑺傜偣鍙煡鐪嬶紝鍙湁褰撳墠鑺傜偣鍙搷浣溿€? +- 鍓嶅悗绔鍔犻槻瓒婄骇鏍¢獙锛涚敓鍥捐妭鐐瑰繀椤婚噰鐢ㄥ浘鐗囧悗鎵嶈兘鎺ㄨ繘銆? +- 鎻愮ず璇嶈鍒掋€佺礌鏉愮粦瀹氫繚瀛樹笌纭鍒嗙锛屽苟鍏煎鏃у伐浣滄祦鏁版嵁銆? + + + + + diff --git a/backend/dto/advanced_material_dto.py b/backend/dto/advanced_material_dto.py index 15f9c6a..a2335a7 100644 --- a/backend/dto/advanced_material_dto.py +++ b/backend/dto/advanced_material_dto.py @@ -238,6 +238,15 @@ class AdvancedStyleValidationCase: completed_at: str | None def to_dict(self) -> dict[str, Any]: + metadata = dict(self.metadata) + applied = bool(metadata.get("reference_image_applied")) + if "input_image_count" in metadata: + try: + input_image_count = int(metadata.get("input_image_count") or 0) + except (TypeError, ValueError): + input_image_count = 1 if applied else 0 + else: + input_image_count = 1 if applied else (1 if metadata.get("validation_reference_enabled") and metadata.get("validation_reference_source_uri") else 0) return { "case_id": self.case_id, "attempt_id": self.attempt_id, @@ -261,7 +270,8 @@ class AdvancedStyleValidationCase: "style_review": dict(self.style_review), "fidelity_score": self.fidelity_score, "error": dict(self.error), - "metadata": dict(self.metadata), + "metadata": metadata, + "input_image_count": input_image_count, "created_at": self.created_at, "updated_at": self.updated_at, "completed_at": self.completed_at, diff --git a/backend/route_registry.py b/backend/route_registry.py index c4d2a92..62f2412 100644 --- a/backend/route_registry.py +++ b/backend/route_registry.py @@ -139,6 +139,7 @@ ROUTES: tuple[RouteSpec, ...] = ( RouteSpec("DELETE", "jobs/{task_id}", "backend.routes.job_routes.delete_job", "retry"), RouteSpec("POST", "jobs/{task_id}/cancel", "backend.routes.job_routes.cancel_job", "write"), RouteSpec("POST", "jobs/{task_id}/retry", "backend.routes.job_routes.retry_job", "retry"), + RouteSpec("POST", "jobs/failed/retry", "backend.routes.job_routes.retry_failed_jobs", "retry"), RouteSpec("POST", "jobs/failed/clear", "backend.routes.job_routes.clear_failed_jobs", "retry"), RouteSpec("POST", "jobs/terminal/clear", "backend.routes.job_routes.clear_terminal_jobs", "retry"), RouteSpec("POST", "jobs/dead-letter/retry", "backend.routes.job_routes.retry_dead_letter_jobs", "retry"), diff --git a/backend/routes/job_routes.py b/backend/routes/job_routes.py index 7b7d9c3..7d5c853 100644 --- a/backend/routes/job_routes.py +++ b/backend/routes/job_routes.py @@ -1,4 +1,4 @@ -"""Job and queue route handlers.""" +"""Job and queue route handlers.""" from __future__ import annotations @@ -105,18 +105,134 @@ def retry_job( require_task_retry(ctx) queue_service = _create_queue_service() task = queue_service.get_job(task_id) - if task.metadata.get("source") == "advanced_material": - require_permission(ctx, "can_manage_materials") - from backend.services.advanced_material_service import create_advanced_material_service - - import_id = str(task.metadata.get("advanced_material_import_id") or "").strip() - return create_advanced_material_service().retry_import(import_id, ctx) - resolved_retry_service = retry_service or _create_generation_job_retry_service() - return resolved_retry_service.retry_job(task_id, ctx, overrides=payload or {}).to_dict() + return _retry_task(task, ctx, payload=payload, retry_service=retry_service) return handle_request(ctx, action) +def retry_failed_jobs( + ctx: RequestContext, + payload: dict[str, Any] | None = None, +) -> dict: + params = payload or {} + + def action() -> dict[str, Any]: + require_task_retry(ctx) + queue_service = _create_queue_service() + limit = max(1, min(int_or_default(params.get("limit"), 100), 100)) + tasks = [] + seen_task_ids: set[str] = set() + for status in ("failed", "dead_letter", "cancelled"): + remaining = limit - len(tasks) + if remaining <= 0: + break + for task in queue_service.list_jobs(status=status, page=1, page_size=remaining).items: + if task.task_id not in seen_task_ids: + seen_task_ids.add(task.task_id) + tasks.append(task) + + tasks = _latest_retryable_tasks(tasks) + retried: list[dict[str, Any]] = [] + errors: list[dict[str, Any]] = [] + retry_service: GenerationJobRetryService | None = None + for task in tasks: + try: + if task.metadata.get("source") != "advanced_material": + retry_service = retry_service or _create_generation_job_retry_service() + retried.append(_retry_task(task, ctx, retry_service=retry_service)) + except Exception as exc: + errors.append(_retry_error_payload(task.task_id, exc)) + + return { + "retried": retried, + "errors": errors, + "total": len(retried), + "processed": len(retried) + len(errors), + "limit": limit, + "remaining_by_status": { + status: queue_service.repository.count_by_status().get(status, 0) + for status in ("failed", "dead_letter", "cancelled") + }, + } + + return handle_request(ctx, action) + + +def _latest_retryable_tasks(tasks: list[Any]) -> list[Any]: + selected: list[Any] = [] + lineage_indexes: dict[tuple[str, str], int] = {} + for task in tasks: + lineage_key = _retry_lineage_key(task) + if lineage_key is None: + selected.append(task) + continue + previous_index = lineage_indexes.get(lineage_key) + if previous_index is None: + lineage_indexes[lineage_key] = len(selected) + selected.append(task) + continue + previous_task = selected[previous_index] + if _task_sort_key(task) > _task_sort_key(previous_task): + selected[previous_index] = task + return selected + + +def _retry_lineage_key(task: Any) -> tuple[str, str] | None: + metadata = task.metadata if isinstance(getattr(task, "metadata", None), dict) else {} + source_id = str(metadata.get("advanced_style_source_id") or "").strip() + case_id = str(metadata.get("advanced_style_validation_case_id") or "").strip() + if task.task_type == "advanced_style_source_recognition" and source_id: + return ("source", source_id) + if task.task_type == "advanced_style_validation_generation" and case_id: + return ("validation", case_id) + return None + + +def _task_sort_key(task: Any) -> str: + return str(getattr(task, "updated_at", "") or getattr(task, "created_at", "") or "") + + +def _retry_task( + task: Any, + ctx: RequestContext, + *, + payload: dict[str, Any] | None = None, + retry_service: GenerationJobRetryService | None = None, +) -> dict[str, Any]: + if task.metadata.get("source") == "advanced_material": + require_permission(ctx, "can_manage_materials") + from backend.services.advanced_material_service import create_advanced_material_service + + advanced_service = create_advanced_material_service() + import_id = str(task.metadata.get("advanced_material_import_id") or "").strip() + if task.task_type == "advanced_style_source_recognition": + source_id = str(task.metadata.get("advanced_style_source_id") or "").strip() + result = advanced_service.style_sets.retry_source(import_id, source_id, ctx) + elif task.task_type == "advanced_style_validation_generation": + case_id = str(task.metadata.get("advanced_style_validation_case_id") or "").strip() + result = advanced_service.style_sets.retry_validation_case(import_id, case_id, ctx) + else: + result = advanced_service.retry_import(import_id, ctx) + if isinstance(result, dict) and isinstance(result.get("task"), dict): + return result["task"] + return result + resolved_retry_service = retry_service or _create_generation_job_retry_service() + return resolved_retry_service.retry_job(task.task_id, ctx, overrides=payload or {}).to_dict() + + +def _retry_error_payload(task_id: str, exc: Exception) -> dict[str, Any]: + error_code = getattr(getattr(exc, "error_code", None), "value", None) or str(getattr(exc, "error_code", "retry_failed")) + message = str(getattr(exc, "message", None) or str(exc)) + raw_details = getattr(exc, "details", None) + details = dict(raw_details) if isinstance(raw_details, dict) else {} + return { + "task_id": task_id, + "error_code": error_code, + "message": message, + **({"replacement_task_id": details["replacement_task_id"]} if details.get("replacement_task_id") else {}), + } + + def retry_dead_letter_jobs( ctx: RequestContext, payload: dict[str, Any] | None = None, @@ -199,3 +315,5 @@ def _create_generation_job_retry_service() -> GenerationJobRetryService: queue_service=generation_service.queue_service, generation_service=generation_service, ) + + diff --git a/backend/services/advanced_material_worker_runtime.py b/backend/services/advanced_material_worker_runtime.py index 65e29c9..c52b108 100644 --- a/backend/services/advanced_material_worker_runtime.py +++ b/backend/services/advanced_material_worker_runtime.py @@ -24,6 +24,7 @@ class AdvancedMaterialWorkerRuntime: ): self.service = service self.ctx = ctx or RequestContext.system("advanced-material-worker") + recognition_concurrency = _recognition_concurrency(getattr(service, "config", {})) self.pool = QueueWorkerPool( service.queue_service, self._execute, @@ -34,11 +35,11 @@ class AdvancedMaterialWorkerRuntime: retry_policy=RetryPolicy(max_attempts=1), task_filter=_is_advanced_material_task, terminal_callback=self._on_terminal, - # A style set intentionally fans out one task per source image and - # one task per validation scene. They must not share a route-wide - # single-flight lock: every task has its own persisted timeout, - # retry and terminal state. - per_route_limit=worker_count, + # Keep worker threads available for queue progress, but limit + # simultaneous calls to the same vision route. Vision providers + # and relay services commonly rate-limit image requests more + # aggressively than ordinary text requests. + per_route_limit=recognition_concurrency, ) def start(self) -> dict[str, Any]: @@ -153,3 +154,14 @@ def _is_advanced_material_task(task: GenerationTask) -> bool: "advanced_style_consensus", "advanced_style_validation_generation", } + + + +def _recognition_concurrency(config: dict[str, Any] | None) -> int: + advanced_materials = config.get("advanced_materials") if isinstance(config, dict) else None + if not isinstance(advanced_materials, dict): + return 2 + try: + return min(max(int(advanced_materials.get("recognition_concurrency", 2)), 1), 8) + except (TypeError, ValueError): + return 2 diff --git a/backend/services/advanced_style_set_service.py b/backend/services/advanced_style_set_service.py index 1d9fb83..0b897d2 100644 --- a/backend/services/advanced_style_set_service.py +++ b/backend/services/advanced_style_set_service.py @@ -1,20 +1,23 @@ -"""Style-only multi-image extraction and prompt-only transfer validation. +"""Style multi-image extraction and transfer validation. The existing advanced-material service remains the compatibility boundary for single-image imports. This coordinator adds a child-task graph only when the -server-confirmed material category is ``风格``/``style``: +server-confirmed material category is style: * one independent VLM task per source image; * one multi-image consensus VLM task after the source barrier; * one compatibility validation attempt containing three independent image generation cases with deliberately unrelated characters and scenes. -No validation request carries a source image. The source set is used only by -the recognition and consensus stages. +Validation may optionally attach one source image as a style-only reference +(shared by portrait/fullbody/novel_scene). Identity/costume/pose/scene copy +from the reference is still forbidden; pure text remains the fallback. """ from __future__ import annotations +from datetime import datetime, timezone + import json import re from copy import deepcopy @@ -26,6 +29,7 @@ from backend.dto.common import ApiError, ErrorCode from backend.dto.material_dto import Material from backend.dto.workflow_dto import WorkflowNode from backend.services.material_normalization_service import MaterialNormalizationError +from core.generation_errors import provider_failure_attribution from backend.services.material_service import ( _normalize_upload_content_type, _normalize_upload_filename, @@ -50,8 +54,31 @@ STYLE_CASE_EXECUTABLE = {"queued", "running"} STYLE_ATTEMPT_BLOCKING = {"queued", "running", "validation_partial_failed", "awaiting_review"} STYLE_SET_KIND = "advanced_style_set" STYLE_VALIDATION_SEEDS = (240719, 240720, 240721) +STYLE_VALIDATION_TIMEOUT_SECONDS = 900 STYLE_EVIDENCE_MIN_SUPPORT = 0.60 STYLE_EVIDENCE_MIN_CONFIDENCE = 0.70 +_ARTIST_SIGNATURE_DIMENSION_ORDER = ( + "face_structure", + "eye_design", + "hair_rendering", + "linework", + "shading", + "palette", + "highlights", + "texture", + "anatomy", +) +_ARTIST_SIGNATURE_DIMENSION_MARKERS: dict[str, tuple[str, ...]] = { + "face_structure": ("face", "facial", "jaw", "chin", "cheek", "nose", "mouth", "forehead"), + "eye_design": ("eye", "iris", "pupil", "lash", "eyelid", "catchlight"), + "hair_rendering": ("hair", "strand", "bang", "fringe", "lock", "curl"), + "linework": ("line", "ink", "outline", "contour", "stroke", "taper"), + "shading": ("shadow", "shadows", "shading", "cel", "occlusion", "gradient", "rendering edge"), + "palette": ("palette", "color", "colour", "chroma", "saturation", "hue", "sepia", "rose", "teal"), + "highlights": ("highlight", "sheen", "gloss", "specular", "rim light"), + "texture": ("texture", "grain", "brush", "surface", "paper", "noise"), + "anatomy": ("head-to-body", "head to body", "proportion", "anatomy", "limb", "silhouette"), +} STYLE_DELTA_SEVERITY = { "low": 0.20, "minor": 0.25, @@ -62,18 +89,57 @@ STYLE_DELTA_SEVERITY = { } _MINOR_AGE_REWRITES: tuple[tuple[str, str], ...] = ( - (r"\bpre[\s-]?adolescent(?:\s+to\s+early\s+adolescent)?\b", "adult"), - (r"\bearly\s+adolescent\b", "adult"), - (r"\badolescent\b", "adult"), - (r"\bteen(?:age[dr]?)?\b", "adult"), - (r"\bminor(?:-aged)?\b", "adult"), - (r"\bchild(?:like|ish)?\b", "adult"), - (r"\bkid\b", "adult"), - (r"\byoung\s+(girl|boy|heroine|character|subject|person)\b", r"adult \1"), - (r"\byouthful\s+(full[\s-]?body\s+)?proportions\b", r"adult \1proportions"), - (r"\byouthful\b", "adult"), - (r"\bloli(?:ta)?\b", "adult stylized character"), + # Chronological-minor identity wording -> non-age style phrasing. + # Do NOT rewrite into mature-adult locks; age band is owned by content prompts. + (r"\bpre[\s-]?adolescent(?:\s+to\s+early\s+adolescent)?\b", "neotenic facial proportions"), + (r"\bearly\s+adolescent\b", "youthful facial proportions"), + (r"\badolescent\b", "youthful facial proportions"), + (r"\bteen(?:age[dr]?)?\b", "youthful facial proportions"), + (r"\bminor(?:-aged)?\b", ""), + (r"\bchild(?:like|ish)?\s+proportions\b", "stylized compact proportions"), + (r"\bchild(?:like|ish)?\b", "neotenic stylization"), + (r"\bkid\b", ""), + (r"\bloli(?:ta)?\b", "neotenic stylized character design"), + (r"\bmoe-style\s+juvenile\s+face\b", "moe-style neotenic facial stylization"), + (r"\bjuvenile\b", "neotenic"), + (r"\btoddler\s+proportions\b", "compressed chibi anatomy"), + (r"\b(?:2|3|4)\s+heads?\s+tall\b", "compressed chibi anatomy"), ) +_MATURE_BODY_LOCK_PATTERNS: tuple[str, ...] = ( + r"\bmature\s+adult(?:\s+limb\s+lengths)?\b", + r"\bexplicitly\s+adult(?:\s+subject)?(?:\s+with\s+mature\s+(?:adult\s+)?(?:body\s+)?proportions)?\b", + r"\bnatural\s+adult\s+body\b", + r"\bbetween\s+6\.5\s+and\s+7\.5\s+heads?\s+tall\b", + r"\b6\.5\s*[–\-]\s*7\.5\s+heads?(?:-tall)?\b", + r"\b6\.5\s+to\s+7\.5\s+heads?(?:-tall)?\b", + r"\bmust\s+adapt\s+to\s+a\s+natural\s+6\.5.*?proportion[^.]*\.?", + r"\bstyle\s+preservation\s+must\s+adapt\s+to\s+a\s+natural\s+6\.5.*?proportion[^.]*\.?", +) +# Full-body anatomy soft band for style transfer validation. +# This is NOT a mature-adult identity lock. It only prevents free collapse into +# chibi/super-deformed (approx 2-4 heads) when the style face is large-eyed/neotenic. +_ANATOMY_SOFT_MIN_HEADS = 5.0 +_ANATOMY_SOFT_MAX_HEADS = 7.0 +_ANATOMY_SOFT_DEFAULT_HEADS = (5.5, 6.5) +_HEAD_RATIO_PATTERNS: tuple[re.Pattern[str], ...] = ( + re.compile( + r"1\s*:\s*(?P\d+(?:\.\d+)?)\s*(?:to|[-–—]|~|~)\s*1\s*:\s*(?P\d+(?:\.\d+)?)", + re.IGNORECASE, + ), + re.compile( + r"(?P\d+(?:\.\d+)?)\s*(?:to|[-–—]|~|~)\s*(?P\d+(?:\.\d+)?)\s*heads?(?:-tall)?", + re.IGNORECASE, + ), + re.compile( + r"(?P\d+(?:\.\d+)?)\s*heads?(?:-tall)?", + re.IGNORECASE, + ), + re.compile( + r"1\s*:\s*(?P\d+(?:\.\d+)?)", + re.IGNORECASE, + ), +) + _AGE_ATTRIBUTE_KEYS = { "age", "actual_age", @@ -161,25 +227,25 @@ DEFAULT_VALIDATION_CASES: tuple[dict[str, Any], ...] = ( { "case_key": "portrait", "content_prompt": ( - "a new fictional adult heroine with short silver hair and teal eyes wearing a simple navy jacket, " + "a new fictional heroine with short silver hair and teal eyes wearing a simple navy jacket, " "head-and-shoulders portrait against a neutral matte studio background with even diffuse lighting, " - "with a distinct identity and wardrobe" + "with a distinct identity and wardrobe; keep subject age band neutral unless the user instruction specifies it" ), "aspect_ratio": "1:1", }, { "case_key": "fullbody", "content_prompt": ( - "the same new fictional adult heroine with short silver hair and teal eyes wearing the same simple navy jacket, " - "complete head-to-toe standing pose in neutral daylight, with mature adult limb lengths and a natural adult body " - "between 6.5 and 7.5 heads tall, with a distinct identity and wardrobe" + "the same new fictional heroine with short silver hair and teal eyes wearing the same simple navy jacket, " + "complete head-to-toe standing pose in neutral daylight, natural stylized anime proportions about 5.5 to 6.5 " + "heads tall with slender limbs, not chibi and not super-deformed, with a distinct identity and wardrobe" ), "aspect_ratio": "2:3", }, { "case_key": "novel_scene", "content_prompt": ( - "the same new fictional adult heroine with short silver hair, teal eyes and navy jacket walking through an ordinary town square " + "the same new fictional heroine with short silver hair, teal eyes and navy jacket walking through an ordinary town square " "during overcast daytime, wide environmental view with diffuse light, clear depth and a scene unrelated to the source samples" ), "aspect_ratio": "16:9", @@ -471,6 +537,7 @@ class AdvancedStyleSetService: import_id, {"recognition_model_route": retry_route}, ) or record + previous_task_id = _optional_text(source.task_id) source = self.repository.update_style_source( source_id, { @@ -491,6 +558,7 @@ class AdvancedStyleSetService: ) self._after_source_terminal(import_id, ctx) raise + self._mark_retried_task_superseded(previous_task_id, task.task_id, ctx) return {"import": self.owner._require_import(import_id).to_dict(), "source": source.to_dict(), "task": task.to_dict()} def exclude_source( @@ -631,6 +699,7 @@ class AdvancedStyleSetService: "comparison_attempt_id": _optional_text(payload.get("comparison_attempt_id")), "comparison_consensus_id": _optional_text(payload.get("comparison_consensus_id")), "comparison_source_ids": _string_list(payload.get("comparison_source_ids"))[:3], + **_validation_reference_metadata_from_payload(payload), "requested_by": ctx.actor_id, }, } @@ -687,6 +756,7 @@ class AdvancedStyleSetService: if case.status not in {"failed", "cancelled"}: raise ApiError(ErrorCode.VALIDATION_FAILED, "validation case is not retryable", {"case_id": case_id, "status": case.status}) retry_count = int(case.metadata.get("retry_count") or 0) + 1 + previous_task_id = _optional_text(case.task_id) case = self.repository.update_style_validation_case( case_id, { @@ -708,8 +778,63 @@ class AdvancedStyleSetService: raise attempt = self.repository.update_attempt(case.attempt_id, {"status": "running", "error": None}) self.repository.update_import(import_id, {"status": "validating", "error": None}) + self._mark_retried_task_superseded(previous_task_id, task.task_id, ctx) return {"import": self.owner._require_import(import_id).to_dict(), "attempt": attempt.to_dict(), "case": case.to_dict(), "task": task.to_dict()} + def _mark_retried_task_superseded(self, previous_task_id: str | None, replacement_task_id: str, ctx: RequestContext) -> None: + previous_id = _optional_text(previous_task_id) + if not previous_id or previous_id == replacement_task_id: + return + try: + previous = self.queue_service.get_job(previous_id) + lineage_key = self._retry_lineage_key(previous) + candidate_ids = {previous_id} + if lineage_key is not None: + for status in ("failed", "cancelled", "dead_letter"): + for candidate in self.queue_service.list_jobs(status=status, page=1, page_size=100).items: + if self._retry_lineage_key(candidate) == lineage_key: + candidate_ids.add(candidate.task_id) + for candidate_id in candidate_ids: + self._mark_task_superseded(candidate_id, replacement_task_id, ctx) + except Exception: + return + + def _retry_lineage_key(self, task: Any) -> tuple[str, str] | None: + metadata = task.metadata if isinstance(getattr(task, "metadata", None), dict) else {} + source_id = _optional_text(metadata.get("advanced_style_source_id")) + case_id = _optional_text(metadata.get("advanced_style_validation_case_id")) + if task.task_type == "advanced_style_source_recognition" and source_id: + return ("source", source_id) + if task.task_type == "advanced_style_validation_generation" and case_id: + return ("validation", case_id) + return None + + def _mark_task_superseded(self, task_id: str, replacement_task_id: str, ctx: RequestContext) -> None: + before = self.queue_service.get_job(task_id) + metadata = { + **before.metadata, + "superseded_by": replacement_task_id, + "retry_execution": { + **dict(before.metadata.get("retry_execution") or {}), + "status": "superseded", + "replacement_task_id": replacement_task_id, + "superseded_at": _now(), + }, + } + retrying = self.queue_service.update_task_if_status( + task_id, + {"failed", "cancelled", "dead_letter"}, + {"status": "retrying", "metadata": metadata}, + ctx, + ) + if retrying is not None: + self.queue_service.update_task_if_status( + task_id, + {"retrying"}, + {"status": "superseded", "metadata": metadata}, + ctx, + ) + def ensure_validation( self, record: Any, @@ -894,9 +1019,7 @@ class AdvancedStyleSetService: {"case_key": item.case_key, "content_prompt": item.content_prompt, "metadata": item.metadata} for item in cases ] - return self.create_consensus( - record.import_id, - { + rebuild_payload = { "style_adjustment_text": style_adjustment, "validation_instruction": validation_instruction, "reuse_validation_cases": reuse_cases, @@ -904,7 +1027,21 @@ class AdvancedStyleSetService: "comparison_attempt_id": attempt.attempt_id, "comparison_consensus_id": comparison_consensus_id, "comparison_source_ids": comparison_source_ids, - }, + } + rebuild_payload.update(_validation_reference_metadata_from_payload(payload)) + # Preserve previous reference selection when the client omits the fields. + if "validation_reference_enabled" not in payload and "validation_reference_source_id" not in payload: + prev_enabled = attempt.metadata.get("validation_reference_enabled") + prev_source = _optional_text(attempt.metadata.get("validation_reference_source_id")) + if prev_enabled is not None: + rebuild_payload["validation_reference_enabled"] = bool(prev_enabled) + if prev_source: + rebuild_payload["validation_reference_source_id"] = prev_source + elif prev_enabled is False: + rebuild_payload["validation_reference_enabled"] = False + return self.create_consensus( + record.import_id, + rebuild_payload, ctx, ) @@ -1183,10 +1320,7 @@ class AdvancedStyleSetService: { "source_id": source.source_id, "sort_order": source.sort_order, - "prompt": source.recognition_prompt, - "negative_prompt": source.recognition_negative_prompt, - "tags": source.recognition_tags, - "analysis": source.recognition_result, + "analysis": _consensus_source_analysis(source.recognition_result), } ) style_adjustment = _optional_text( @@ -1367,6 +1501,7 @@ class AdvancedStyleSetService: }, **structures, "consensus_style": _object(provider_result.get("consensus_style")), + "artist_signature": _normalize_artist_signature(provider_result.get("artist_signature"), sources), "variable_style_features": _list(provider_result.get("variable_style_features")), "source_content_features": _list(provider_result.get("source_content_features")), "content_leakage_exclusions": _string_list(provider_result.get("content_leakage_exclusions")), @@ -1464,18 +1599,52 @@ class AdvancedStyleSetService: leakage = _string_list(consensus.result.get("content_leakage_exclusions")) detailed_style_prompt = _detailed_style_prompt(consensus.result, consensus.prompt) detailed_style_negative = _detailed_style_negative_prompt(consensus.result, consensus.negative_prompt) + sources = [item for item in self.repository.list_style_sources(record.import_id) if item.status == "succeeded"] + reference_plan = _resolve_validation_reference_plan( + sources=sources, + consensus_result=consensus.result if isinstance(consensus.result, dict) else {}, + consensus_metadata=consensus.metadata if isinstance(consensus.metadata, dict) else {}, + ) negative = _join_prompt( detailed_style_negative, "exact source character identity, exact source costume design, exact source pose, exact source setting, " "generic semi-realistic reinterpretation, realistic facial anatomy when absent from the source style, text, watermark", ) + if reference_plan["enabled"]: + negative = _join_prompt( + negative, + "copy identity from reference image, copy costume from reference image, copy pose from reference image, " + "copy scene from reference image, exact reference character face", + ) case_payloads = [] for index, plan in enumerate(plans): content_prompt = str(plan["content_prompt"]).strip() case_key = str(plan["case_key"]) scale_style_prompt = _scale_specific_style_prompt(consensus.result, case_key, detailed_style_prompt) scale_style_negative = _scale_specific_style_negative_prompt(consensus.result, case_key) + anatomy_range = _source_anatomy_range_from_style_result(consensus.result) + anatomy_phrase = _anatomy_soft_band_phrase(anatomy_range) if case_key == "fullbody" else None + if case_key == "portrait": + scale_style_negative = _join_prompt( + scale_style_negative, + "long narrow face, sharp V-shaped jaw, pointed chin, widened jaw, altered eye spacing, asymmetric facial contour", + ) + if case_key == "fullbody": + content_prompt = _join_prompt(content_prompt, anatomy_phrase) + scale_style_prompt = _join_prompt(scale_style_prompt, anatomy_phrase) + scale_style_negative = _join_prompt( + scale_style_negative, + "chibi or super-deformed anatomy, unnaturally compressed body proportions", + ) case_negative = _join_prompt(negative, scale_style_negative) + ref_clause = ( + "optional style reference image is attached for visual grammar only; " + "copy linework, palette, eye geometry, shading edges and anatomy abstraction from the reference, " + "but invent a new character identity, costume, pose and scene from the content prompt; " + "do not copy face identity, hairstyle identity, outfit design, props, pose or background from the reference" + if reference_plan["enabled"] + else "transfer style from the detailed style prompt only; no source image is attached" + ) final_prompt = _join_prompt( detailed_style_prompt, scale_style_prompt, @@ -1484,6 +1653,7 @@ class AdvancedStyleSetService: "transfer the complete shared visual grammar, including facial proportions, eye geometry, nose and mouth simplification, " "hair strand grouping, line topology, local line colors, shading edges, palette relationships and highlight shapes; " "do not reproduce any exact source identity, costume, pose or setting; preserve the requested validation subject and composition", + ref_clause, ) case_payloads.append( { @@ -1514,7 +1684,13 @@ class AdvancedStyleSetService: "style_compiler_version": 2, "content_leakage_exclusions": leakage, "retry_count": 0, - "prompt_only": True, + "prompt_only": not reference_plan["enabled"], + "validation_reference_enabled": reference_plan["enabled"], + "validation_reference_source_id": reference_plan["source_id"], + "validation_reference_source_uri": reference_plan["source_uri"], + "validation_reference_mode": reference_plan["mode"], + "reference_image_applied": False, + "generation_timeout_seconds": STYLE_VALIDATION_TIMEOUT_SECONDS, }, } ) @@ -1536,6 +1712,10 @@ class AdvancedStyleSetService: "style_set": True, "style_adjustment_text": style_adjustment, "validation_instruction": validation_instruction, + "validation_reference_enabled": reference_plan["enabled"], + "validation_reference_source_id": reference_plan["source_id"], + "validation_reference_source_uri": reference_plan["source_uri"], + "validation_reference_mode": reference_plan["mode"], }, }, case_payloads, @@ -1576,7 +1756,13 @@ class AdvancedStyleSetService: "status": "queued", "model_route": case.model_route or self.owner._generation_route(), "idempotency_key": f"advanced-style-validation:{case.case_id}:{retry_count}", - "request": {"import_id": record.import_id, "attempt_id": case.attempt_id, "case_id": case.case_id, "operation": "validate_style_transfer"}, + "request": { + "import_id": record.import_id, + "attempt_id": case.attempt_id, + "case_id": case.case_id, + "operation": "validate_style_transfer", + "timeout_seconds": STYLE_VALIDATION_TIMEOUT_SECONDS, + }, "metadata": { "source": "advanced_material", "advanced_material_import_id": record.import_id, @@ -1584,6 +1770,7 @@ class AdvancedStyleSetService: "advanced_style_validation_case_id": case.case_id, "stage": "style_validation_generation", "task_summary": f"进阶画风/{record.display_name}/{case.case_key}迁移验证", + "timeout_seconds": STYLE_VALIDATION_TIMEOUT_SECONDS, }, }, ctx, @@ -1629,7 +1816,7 @@ class AdvancedStyleSetService: model_route=route_name, selected_image_id=None, sort_order=case.sort_order, - metadata={"advanced_material": True, "style_set": True, "prompt_only": True}, + metadata={"advanced_material": True, "style_set": True, "prompt_only": not bool(case.metadata.get("validation_reference_enabled")), "validation_reference_enabled": bool(case.metadata.get("validation_reference_enabled")), "validation_reference_source_id": case.metadata.get("validation_reference_source_id")}, created_at=case.created_at, updated_at=case.updated_at, ) @@ -1638,6 +1825,7 @@ class AdvancedStyleSetService: "aspect_ratio": str(case.metadata.get("aspect_ratio") or "1:1"), "quality": "standard", "seed": int(case.seed or STYLE_VALIDATION_SEEDS[case.sort_order]), + "timeout_seconds": int(case.metadata.get("generation_timeout_seconds") or STYLE_VALIDATION_TIMEOUT_SECONDS), "model_route": route_name, "resolved_model_route": resolved_route, "allow_provider_fallback": False, @@ -1645,8 +1833,6 @@ class AdvancedStyleSetService: "expanded_negative_prompt": governance["negative_prompt"], "prompt_governance": governance["snapshot"], **({"cost_guard": cost_guard} if cost_guard else {}), - # Intentionally no image/input_images key. This validates style - # transfer from the consensus text into unrelated content. "output_scope": { "kind": "advanced_style_validation", "import_id": import_id, @@ -1655,25 +1841,49 @@ class AdvancedStyleSetService: "case_key": case.case_key, }, } + reference_meta = _validation_reference_runtime_metadata(case.metadata) + input_images: list[str] = [] + if reference_meta["enabled"] and reference_meta["source_uri"]: + try: + image_data_url, _, _ = _storage_image_data_url(str(reference_meta["source_uri"]), {}, self.storage) + input_images = [image_data_url] + request["input_images"] = input_images + reference_meta["reference_image_applied"] = True + except Exception as exc: # best-effort pure-text fallback + reference_meta["reference_image_applied"] = False + reference_meta["reference_image_error"] = str(exc)[:240] + else: + reference_meta["reference_image_applied"] = False assets = [] try: try: assets = self.single_flow_engine.generate(node, task, request) except ImageProviderError as exc: - fallback = self.owner._content_safety_fallback( - exc=exc, - runtime_request=request, - governance=governance, - requested_route=requested_route, - record=record, - ctx=ctx, - ) - if fallback is None: - raise - route_name = fallback["model_route"] - resolved_route = fallback["resolved_model_route"] - request = fallback["request"] - assets = self.single_flow_engine.generate(node, task, request) + if input_images and _is_reference_image_unsupported_error(exc): + request.pop("input_images", None) + reference_meta["reference_image_applied"] = False + reference_meta["reference_image_error"] = str(exc)[:240] + reference_meta["reference_image_fallback"] = "pure_text" + try: + assets = self.single_flow_engine.generate(node, task, request) + exc = None # type: ignore[assignment] + except ImageProviderError as retry_exc: + exc = retry_exc + if exc is not None: + fallback = self.owner._content_safety_fallback( + exc=exc, + runtime_request=request, + governance=governance, + requested_route=requested_route, + record=record, + ctx=ctx, + ) + if fallback is None: + raise + route_name = fallback["model_route"] + resolved_route = fallback["resolved_model_route"] + request = fallback["request"] + assets = self.single_flow_engine.generate(node, task, request) except Exception: for asset in assets: self.owner._remove_uri(str(getattr(asset, "image_uri", "") or "")) @@ -1710,7 +1920,15 @@ class AdvancedStyleSetService: **case.metadata, "generation": asset.metadata, "prompt_governance": governance["snapshot"], - "prompt_only": True, + "prompt_only": not bool(reference_meta.get("reference_image_applied")), + "validation_reference_enabled": bool(reference_meta.get("enabled")), + "validation_reference_source_id": reference_meta.get("source_id"), + "validation_reference_source_uri": reference_meta.get("source_uri"), + "validation_reference_mode": reference_meta.get("mode"), + "reference_image_applied": bool(reference_meta.get("reference_image_applied")), + "reference_image_error": reference_meta.get("reference_image_error"), + "reference_image_fallback": reference_meta.get("reference_image_fallback"), + "input_image_count": 1 if reference_meta.get("reference_image_applied") else 0, "automatic_style_review": style_review, }, "error": None, @@ -2013,16 +2231,19 @@ def _consensus_instruction( else "" ) return ( - "Read every supplied style sample and its report. Cross-compare them instead of averaging blindly. Identify " + "Read every supplied style sample and its visual report. Ignore any source prompt, artist name, tags, title or textual style label; infer transferable style only from image evidence and structured visual observations. Cross-compare them instead of averaging blindly. Identify " "features shared by at least 60% of samples as core style, 40-60% as variable, and lower support as content or " "an outlier. Separate character identity, age, gender/species, hair, clothing, pose, props, text, setting and " "composition from transferable style, while preserving domain-coupled structural stylization such as face proportions, " "eye geometry, nose/mouth simplification, head-to-body ratio and anatomy abstraction. Report facial_age_stylization, " - "actual_age_evidence and body_maturity_proportions separately. Actual or apparent age is never a transferable style trait: " - "never place pre-adolescent, adolescent, teen, child, minor, youthful-body or similar age language in any positive style " - "prompt or generation capsule. Validation subjects must be explicitly adult, and full-body validation must use mature adult " - "limb lengths and a natural 6.5-7.5 heads-tall body. Sexualized, lingerie, underwear or nude source content must never be " - "combined with minor-age language. Do not classify a whole subject " + "actual_age_evidence and body_maturity_proportions separately. Chronological or identity age is not transferable style, " + "but facial neoteny, eye scale, compact lower face and source head-to-body abstraction ARE transferable structural style and " + "must be preserved. Do not rewrite style into a mature-adult identity lock. For full-body generation use a soft " + "anatomy band of about 5-7 heads tall (prefer the observed source ratio when it falls inside that band); never collapse " + "into chibi/super-deformed 2-4 heads, and do not force a mature 6.5-7.5 adult-woman body canon. " + "Validation subject age band is controlled only by validation_cases.content_prompt / human validation instruction; " + "when unspecified, keep age-band neutral and let source anatomy style dominate. Sexualized, lingerie, underwear or nude " + "source content must never be combined with underage identity language. Do not classify a whole subject " "class such as young characters, animal-eared characters or dresses as a negative constraint; exclude only exact source " "identity and exact designs. Return one JSON object with compatibility keys prompt, negative_prompt, " "tags, confidence and description; raw_analysis; normalized_asset_profile(category=style, role=style, " @@ -2033,7 +2254,7 @@ def _consensus_instruction( "each semantic risk item must include original_phrase, risk, safe_rewrite and negative_guard. Prefer physically grounded " "surface/shape/placement descriptions over metaphors or object-like shorthand. consensus_style; " "variable_style_features; source_content_features; content_leakage_exclusions; outlier_source_ids; " - "representative_source_ids (1-3); consensus_confidence; feature_evidence where each item has trait, " + "representative_source_ids (1-3); artist_signature containing 4-8 high-specificity, source-supported painterly traits that distinguish this artist from generic anime. Balance the signature across available dimensions: face_structure, eye_design, hair_rendering, linework, shading, palette, highlights, texture and anatomy. Each signature item must include dimension, phrase, supporting_source_ids, support_ratio and confidence. Prefer concrete observable shape, edge, color and placement relationships over labels such as anime, beautiful or high quality; do not spend all signature slots on one dimension; consensus_confidence; feature_evidence where each item has trait, " "supporting_source_ids, support_ratio and confidence; and validation_cases with exactly portrait, fullbody and " "novel_scene. Every validation content_prompt must describe a character, clothing, pose, camera and scene " "semantically different from all source samples but remain in a comparable illustration domain. Use neutral matte studio " @@ -2051,13 +2272,42 @@ def _force_style_structures(value: dict[str, Any]) -> dict[str, Any]: profile.update({"category": "style", "role": "style", "body_slots": ["global_style"], "wear_layer": None, "stackable": False}) attributes = dict(profile.get("attributes") or {}) for key, raw in list(attributes.items()): - if _is_age_attribute_key(key): - item = dict(raw) if isinstance(raw, dict) else {"value": raw} + key_text = str(key or "") + item = dict(raw) if isinstance(raw, dict) else {"value": raw} + value_text = str(item.get("value") or "") + if key_text in {"facial_age_stylization"} or key_text.endswith("facial_age_stylization"): + item["eligible_for_generation"] = True + item["transfer_role"] = "style_structure" + item["value"] = _strip_mature_body_locks(value_text) or value_text + elif ( + key_text in {"body_maturity_proportions", "head_to_body_ratio", "anatomy_scale"} + or "body_maturity" in key_text + or "head_to_body" in key_text + ): + cleaned = _strip_mature_body_locks(value_text) + item["value"] = cleaned or value_text + item["eligible_for_generation"] = True + item["transfer_role"] = "style_structure" + elif _is_age_attribute_key(key_text): item["eligible_for_generation"] = False item["transfer_role"] = "reference_only" - attributes[key] = item + attributes[key] = item profile["attributes"] = attributes profile["must_preserve"] = _sanitize_style_prompt_parts(profile.get("must_preserve")) + style_structure_bits: list[str] = [] + for key, raw in attributes.items(): + if not isinstance(raw, dict) or raw.get("transfer_role") != "style_structure": + continue + value = _optional_text(raw.get("value")) + if not value: + continue + if key in {"facial_age_stylization"} or str(key).endswith("facial_age_stylization"): + style_structure_bits.append(f"facial age stylization: {value}") + elif "body_maturity" in str(key) or "head_to_body" in str(key) or key in {"anatomy_scale"}: + style_structure_bits.append(value) + if style_structure_bits: + profile["must_preserve"] = _unique_prompt_parts([*profile["must_preserve"], *style_structure_bits]) + profile["must_preserve"] = _sanitize_style_prompt_parts(profile["must_preserve"]) result["normalized_asset_profile"] = profile capsules = result.get("generation_capsules") @@ -2099,8 +2349,8 @@ def _style_fidelity_review_instruction() -> str: return ( "The image_manifest identifies 1-3 source_reference images followed by one generated_validation image. Compare only " "transferable visual style, never subject identity or exact clothing. Score the generated image against the shared source " - "style on face proportions, eye geometry and iris construction, nose/mouth simplification and facial age stylization while " - "holding the explicitly adult subject age and body maturity constant, head-to-body ratio, hair mass and strand grouping, " + "style on face proportions, eye geometry and iris construction, nose/mouth simplification and facial age stylization, " + "source head-to-body ratio / anatomy abstraction, hair mass and strand grouping, " "line topology/taper/local color, skin and blush rendering, shadow hue " "and edge softness, highlight shape, palette contrast/saturation/value range, texture/detail rhythm and optical effects. " "Separate global palette/value range from local edge, eye, hair and clothing color separation. Do not translate a local " @@ -2159,23 +2409,124 @@ def _validation_cases( def _validation_instruction_prompt(case_key: str, instruction: str) -> str: framing = { "portrait": ( - "For this controlled portrait comparison, preserve every requested identity, hairstyle, color and wardrobe " - "detail for an explicitly adult subject, adapting only the camera to a head-and-shoulders composition with a neutral matte studio background" + "For this controlled portrait comparison, preserve every requested identity, hairstyle, color, wardrobe and " + "requested age-band cues, adapting only the camera to a head-and-shoulders composition with a neutral matte studio background" ), "fullbody": ( - "For this controlled full-body comparison, preserve every requested identity, hairstyle, color and wardrobe " - "detail for an explicitly adult subject and show the complete character from head to toe with mature adult limb lengths" + "For this controlled full-body comparison, preserve every requested identity, hairstyle, color, wardrobe and " + "requested age-band cues, show the complete character from head to toe, keep facial neoteny if present, and use " + "a soft stylized anatomy band of about 5-7 heads tall (prefer the source ratio when available); not chibi, not " + "super-deformed, and not a forced mature adult body canon" ), "novel_scene": ( - "For this cross-scene comparison, preserve every requested identity, hairstyle, color and wardrobe detail, " - "for an explicitly adult subject, then place the same character in a clearly different ordinary overcast daytime scene" + "For this cross-scene comparison, preserve every requested identity, hairstyle, color, wardrobe and requested " + "age-band cues, then place the same character in a clearly different ordinary overcast daytime scene" ), - }.get(case_key, "Preserve every requested subject and wardrobe detail in a controlled comparison composition") + }.get(case_key, "Preserve every requested subject, wardrobe and age-band detail in a controlled comparison composition") return _join_prompt(f"Mandatory human validation request: {instruction}", framing) + +def _extract_head_ratio_range(*values: Any) -> tuple[float, float] | None: + """Parse head-count ratios from free text / attribute dumps. + + Accepts forms like "1:5.5 to 1:6", "5.5-6 heads tall", or "1:6". + Returns (low, high) in heads-tall units, or None when unknown. + """ + found: list[float] = [] + for value in values: + text = str(value or "") + if not text.strip(): + continue + for pattern in _HEAD_RATIO_PATTERNS: + for match in pattern.finditer(text): + groups = match.groupdict() + for key in ("a", "b"): + raw = groups.get(key) + if raw is None: + continue + try: + number = float(raw) + except ValueError: + continue + # Convert body:head style "1:6" into heads-tall = 6. + if number <= 0: + continue + if number < 2.5: + # likely a face-scale factor; ignore + continue + if number > 12: + continue + found.append(number) + if not found: + return None + low = min(found) + high = max(found) + if high < low: + low, high = high, low + return (low, high) + + +def _clamp_head_ratio_range(range_value: tuple[float, float] | None) -> tuple[float, float]: + if range_value is None: + return _ANATOMY_SOFT_DEFAULT_HEADS + low, high = range_value + low = max(float(low), _ANATOMY_SOFT_MIN_HEADS) + high = min(float(high), _ANATOMY_SOFT_MAX_HEADS) + if high < low: + mid = max(min((float(range_value[0]) + float(range_value[1])) / 2.0, _ANATOMY_SOFT_MAX_HEADS), _ANATOMY_SOFT_MIN_HEADS) + return (mid, mid) + # Keep a small readable band. + if high - low < 0.4: + mid = (low + high) / 2.0 + low = max(mid - 0.3, _ANATOMY_SOFT_MIN_HEADS) + high = min(mid + 0.3, _ANATOMY_SOFT_MAX_HEADS) + return (round(low, 1), round(high, 1)) + + +def _anatomy_soft_band_phrase(range_value: tuple[float, float] | None = None, *, include_negative: bool = True) -> str: + low, high = _clamp_head_ratio_range(range_value) + if abs(low - high) < 0.05: + core = f"natural stylized anime proportions about {low:.1f} heads tall with slender limbs" + else: + core = f"natural stylized anime proportions about {low:.1f} to {high:.1f} heads tall with slender limbs" + if include_negative: + return f"{core}, not chibi or super-deformed" + return core + + +def _source_anatomy_range_from_style_result(result: Any) -> tuple[float, float] | None: + payload = result if isinstance(result, dict) else {} + texts: list[Any] = [] + profile = payload.get("normalized_asset_profile") if isinstance(payload.get("normalized_asset_profile"), dict) else {} + attributes = profile.get("attributes") if isinstance(profile.get("attributes"), dict) else {} + for key in ("body_maturity_proportions", "head_to_body_ratio", "anatomy_scale"): + raw = attributes.get(key) + if isinstance(raw, dict): + texts.append(raw.get("value")) + else: + texts.append(raw) + texts.extend(_prompt_parts(profile.get("must_preserve"))) + capsules = payload.get("generation_capsules") if isinstance(payload.get("generation_capsules"), dict) else {} + detailed = capsules.get("detailed") if isinstance(capsules.get("detailed"), dict) else {} + texts.extend(_prompt_parts(detailed.get("prompt_parts"))) + texts.extend(_prompt_parts(detailed.get("must_preserve"))) + scales = payload.get("scale_capsules") if isinstance(payload.get("scale_capsules"), dict) else {} + fullbody = scales.get("fullbody") + if isinstance(fullbody, dict): + texts.extend(_prompt_parts(fullbody.get("prompt_parts") or fullbody.get("positive_additions"))) + else: + texts.append(fullbody) + # Prefer explicit head-to-body "1:N" evidence after stripping mature-body override sentences. + cleaned = [_strip_mature_body_locks(str(item or "")) for item in texts if item] + # If any 1:N ratio exists, prefer those over generic "heads tall" leftovers. + ratio_only = [item for item in cleaned if re.search(r"1\s*:\s*\d", item)] + return _extract_head_ratio_range(*(ratio_only or cleaned)) + + def _sanitize_validation_content(case_key: str, value: Any) -> str: text, _ = _sanitize_minor_age_text(str(value or "").strip()) + text = _strip_mature_body_locks(text) lighting_patterns = ( r"\bcircular\s+bokeh\b", r"\bbokeh\b", @@ -2190,23 +2541,30 @@ def _sanitize_validation_content(case_key: str, value: Any) -> str: for pattern in lighting_patterns: text = re.sub(pattern, "", text, flags=re.IGNORECASE) text = _clean_prompt_text(text) - if not re.search(r"\badult\b", text, re.IGNORECASE): - text = _join_prompt(text, "the depicted character is an adult") + # Age band is owned by the content prompt / human instruction. Do not inject + # adult or mature-body canon here; only neutralize theatrical lighting. suffix = { "portrait": ( "neutral matte studio background, even diffuse studio lighting, no dramatic optical effects" ), "fullbody": ( - "complete head-to-toe adult body with mature adult limb lengths and natural proportions between 6.5 and 7.5 heads tall, " - "neutral daylight" + f"complete head-to-toe view with {_anatomy_soft_band_phrase()}, neutral daylight" ), "novel_scene": ( "ordinary overcast daytime, flat diffuse environmental lighting without theatrical optical effects" ), - }.get(case_key, "explicitly adult subject under neutral diffuse lighting") + }.get(case_key, "neutral diffuse lighting") already_constrained = { "portrait": "neutral matte studio background" in text.casefold() and "even diffuse studio lighting" in text.casefold(), - "fullbody": "6.5" in text and "7.5" in text and "mature adult limb lengths" in text.casefold(), + "fullbody": ( + "head-to-toe" in text.casefold() + and ( + "heads tall" in text.casefold() + or "head-to-body" in text.casefold() + or "not chibi" in text.casefold() + or "neutral daylight" in text.casefold() + ) + ), "novel_scene": "ordinary overcast daytime" in text.casefold() and "diffuse" in text.casefold(), }.get(case_key, "neutral diffuse lighting" in text.casefold()) return text if already_constrained else _join_prompt(text, suffix) @@ -2214,7 +2572,14 @@ def _sanitize_validation_content(case_key: str, value: Any) -> str: def _is_age_attribute_key(value: Any) -> bool: key = re.sub(r"[^a-z0-9]+", "_", str(value or "").strip().casefold()).strip("_") - return key in _AGE_ATTRIBUTE_KEYS or key.endswith("_age") or key.startswith("age_") + return ( + key in _AGE_ATTRIBUTE_KEYS + or key.endswith("_age") + or key.startswith("age_") + or key.startswith("actual_age") + or key.endswith("_age_evidence") + or "chronological_age" in key + ) def _sanitize_minor_age_text(value: str) -> tuple[str, bool]: @@ -2225,19 +2590,125 @@ def _sanitize_minor_age_text(value: str) -> tuple[str, bool]: if count: changed = True text = rewritten - text = re.sub(r"\badult(?:\s+adult)+\b", "adult", text, flags=re.IGNORECASE) + stripped = _strip_mature_body_locks(text) + if stripped != text: + changed = True + text = stripped + text = re.sub( + r"\b(?:adult|youthful)(?:\s+(?:adult|youthful))+\b", + lambda match: match.group(0).split()[0], + text, + flags=re.IGNORECASE, + ) text = _clean_prompt_text(text) return text, changed +def _strip_mature_body_locks(value: str) -> str: + text = str(value or "") + for pattern in _MATURE_BODY_LOCK_PATTERNS: + text = re.sub(pattern, "", text, flags=re.IGNORECASE) + text = re.sub( + r"body maturity proportions\s*:\s*[^.]*mature adult proportion[^.]*\.?", + "", + text, + flags=re.IGNORECASE, + ) + text = re.sub( + r"(?:,\s*)?but style preservation must adapt to a natural(?:\s+proportion)?(?:\s+during full-body generation)?\.?", + "", + text, + flags=re.IGNORECASE, + ) + text = re.sub( + r"style preservation must adapt to a natural(?:\s+proportion)?(?:\s+during full-body generation)?\.?", + "", + text, + flags=re.IGNORECASE, + ) + # Drop whole mature-body override clauses that survived partial matches. + text = re.sub( + r"(?:with\s+)?(?:a\s+)?natural adult body(?:\s+between[^,.;]*)?", + "", + text, + flags=re.IGNORECASE, + ) + text = re.sub( + r"(?:with\s+)?mature\s+limb\s+lengths(?:\s+and)?", + "", + text, + flags=re.IGNORECASE, + ) + text = re.sub( + r"actual age evidence\s*:\s*[^.]*\.", + "", + text, + flags=re.IGNORECASE, + ) + # Repair glue left after removals: "with and a,", dangling connectors. + text = re.sub(r"\b(?:with|and|or|to|of|a|an|the)\s*(?=,|;|\.|$)", "", text, flags=re.IGNORECASE) + text = re.sub(r"(?:,\s*){2,}", ", ", text) + text = re.sub(r"\s{2,}", " ", text) + return _clean_prompt_text(text) + + +def _is_transferable_style_age_phrase(value: str) -> bool: + text = str(value or "").casefold() + if not text: + return False + style_markers = ( + "neotenic", + "facial age stylization", + "eye-to-face", + "high forehead", + "compact lower face", + "head-to-body", + "head to body", + "limb abstraction", + "stylized", + "proportions", + ) + lock_markers = ( + "chronological", + "actual age", + "must adapt to", + "mature adult", + "explicitly adult", + "6.5", + "7.5", + ) + if any(marker in text for marker in lock_markers) and not any( + marker in text for marker in ("neotenic", "facial age stylization", "eye-to-face", "head-to-body") + ): + return False + if any(marker in text for marker in style_markers): + return True + return "age" not in text + + def _sanitize_style_prompt_parts(value: Any) -> list[str]: result: list[str] = [] for part in _prompt_parts(value): - sanitized, changed = _sanitize_minor_age_text(part) - if sanitized: + sanitized, _changed = _sanitize_minor_age_text(part) + sanitized = _strip_mature_body_locks(sanitized) + if not sanitized: + continue + if re.match(r"^(actual age evidence|body maturity proportions)\s*:", sanitized, re.IGNORECASE): + if re.search(r"mature adult|6\.5|7\.5|must adapt", sanitized, re.IGNORECASE): + source_ratio = re.search( + r"(head-to-body ratio[^.]*?1:\s*\d+(?:\.\d+)?(?:\s*to\s*1:\s*\d+(?:\.\d+)?)?[^.,;]*)", + sanitized, + re.IGNORECASE, + ) + if source_ratio: + result.append(_clean_prompt_text(source_ratio.group(1))) + continue + if re.match(r"^facial age stylization\s*:", sanitized, re.IGNORECASE) or _is_transferable_style_age_phrase(sanitized): result.append(sanitized) - if changed and not re.search(r"\badult\b", sanitized, re.IGNORECASE): - result.append("explicitly adult subject with mature body proportions") + continue + if re.search(r"\b(actual age|chronological age|subject age|character age)\b", sanitized, re.IGNORECASE): + continue + result.append(sanitized) return _unique_prompt_parts(result) @@ -2900,6 +3371,231 @@ def _semantic_phrase_is_object_risky(value: Any) -> bool: return bool(_SEMANTIC_OBJECT_RISK_PATTERNS.search(str(value or ""))) +def _consensus_source_analysis(value: Any) -> dict[str, Any]: + """Keep visual evidence while removing textual artist/style anchors.""" + def scrub(item: Any) -> Any: + if isinstance(item, dict): + result: dict[str, Any] = {} + for key, raw in item.items(): + key_text = str(key or "").casefold().replace("-", "_") + if key_text in { + "prompt", + "negative_prompt", + "tags", + "artist", + "artist_name", + "style_name", + "creator", + "author", + }: + continue + cleaned = scrub(raw) + if cleaned is not None: + result[key] = cleaned + return result + if isinstance(item, list): + result = [] + for raw in item: + cleaned = scrub(raw) + if cleaned is not None: + result.append(cleaned) + return result + if isinstance(item, str) and re.search(r"\bstyle\s+of\b|\bby\s+(?:artist|author)\b", item, re.IGNORECASE): + return None + return item + + cleaned = scrub(value if isinstance(value, dict) else {}) + return cleaned if isinstance(cleaned, dict) else {} + + +def _normalize_artist_signature(value: Any, sources: list[Any]) -> list[dict[str, Any]]: + candidates: list[dict[str, Any]] = [] + source_count = max(1, len(sources)) + if isinstance(value, list): + for item in value: + if isinstance(item, dict): + phrase = _optional_text(item.get("phrase") or item.get("trait") or item.get("description")) + support = _optional_score(item.get("support_ratio") or item.get("support")) + source_ids = _string_list(item.get("supporting_source_ids") or item.get("source_ids")) + dimension = _artist_signature_dimension(item.get("dimension"), phrase) + confidence = _optional_score(item.get("confidence")) + else: + phrase = _optional_text(item) + support = None + source_ids = [] + dimension = _artist_signature_dimension(None, phrase) + confidence = None + if phrase: + candidates.append({ + "phrase": phrase, + "support_ratio": support, + "source_ids": source_ids, + "dimension": dimension, + "confidence": confidence, + }) + for source in sources: + analysis = source.recognition_result if isinstance(getattr(source, "recognition_result", None), dict) else {} + profile = analysis.get("normalized_asset_profile") if isinstance(analysis.get("normalized_asset_profile"), dict) else {} + capsules = analysis.get("generation_capsules") if isinstance(analysis.get("generation_capsules"), dict) else {} + detailed = capsules.get("detailed") if isinstance(capsules.get("detailed"), dict) else {} + source_phrases = [ + *_prompt_parts(profile.get("must_preserve")), + *_prompt_parts(detailed.get("must_preserve")), + *_prompt_parts(detailed.get("prompt_parts")), + ] + attributes = profile.get("attributes") if isinstance(profile.get("attributes"), dict) else {} + for raw in attributes.values(): + if not isinstance(raw, dict) or raw.get("transfer_role") not in {"style_structure", "style_rendering"}: + continue + value_text = _optional_text(raw.get("value")) + if value_text: + source_phrases.append(value_text) + source_id = _optional_text(getattr(source, "source_id", None)) + for phrase in source_phrases: + candidates.append({ + "phrase": phrase, + "support_ratio": 1.0 / source_count, + "source_ids": [source_id] if source_id else [], + "dimension": _artist_signature_dimension(None, phrase), + "confidence": None, + }) + clusters: list[dict[str, Any]] = [] + for candidate in candidates: + phrase = " ".join(str(candidate.get("phrase") or "").split()).strip(" ,.;") + if len(phrase) < 18 or _artist_signature_is_generic(phrase): + continue + if len(phrase) > 220 or _artist_signature_has_multiple_dimensions(phrase): + continue + dimension = _artist_signature_dimension(candidate.get("dimension"), phrase) + source_ids = set(_string_list(candidate.get("source_ids"))) + support = float(candidate.get("support_ratio") or 0.0) + confidence = float(candidate.get("confidence") or 0.0) + match = next( + (item for item in clusters if item["dimension"] == dimension and _prompt_traits_overlap(phrase, item["phrase"])), + None, + ) + if match is None: + clusters.append({ + "phrase": phrase, + "dimension": dimension, + "source_ids": source_ids, + "support_ratio": support, + "confidence": confidence, + "best_len": len(phrase), + }) + else: + match["source_ids"].update(source_ids) + match["support_ratio"] = max(float(match["support_ratio"]), support) + match["confidence"] = max(float(match["confidence"]), confidence) + if len(phrase) > int(match["best_len"]): + match["phrase"] = phrase + match["best_len"] = len(phrase) + for item in clusters: + if item["source_ids"]: + item["support_ratio"] = min(1.0, len(item["source_ids"]) / source_count) + item["support_ratio"] = round(float(item.get("support_ratio") or 0.0), 3) + item["confidence"] = round(float(item.get("confidence") or 0.0), 3) or None + item["specificity_score"] = min(1.0, len(_prompt_tokens(item["phrase"])) / 12.0) + item["supporting_source_ids"] = sorted(item["source_ids"]) + item["eligible_core"] = float(item.get("support_ratio") or 0.0) >= 0.50 + item.pop("best_len", None) + item.pop("source_ids", None) + clusters.sort( + key=lambda item: ( + float(item.get("support_ratio") or 0.0) * 0.55 + + float(item.get("confidence") or 0.0) * 0.25 + + float(item.get("specificity_score") or 0.0) * 0.20, + len(str(item.get("phrase") or "")), + ), + reverse=True, + ) + eligible = [item for item in clusters if item.get("eligible_core")] + selected: list[dict[str, Any]] = [] + selected_dimensions: set[str] = set() + for dimension in _ARTIST_SIGNATURE_DIMENSION_ORDER: + candidate = next((item for item in eligible if item["dimension"] == dimension), None) + if candidate is not None: + selected.append(candidate) + selected_dimensions.add(dimension) + if len(selected) >= 8: + break + if len(selected) < 8: + selected.extend(item for item in eligible if item["dimension"] not in selected_dimensions and item not in selected) + for item in selected: + item.pop("eligible_core", None) + return selected[:8] + +def _artist_signature_is_generic(value: str) -> bool: + text = value.casefold() + generic = ( + "anime style", "generic anime", "digital illustration", "high quality", "best quality", + "beautiful character", "masterpiece", "vibrant", "detailed artwork", "soft high-key pastel style", + "smooth ultra-clean digital paint", "vector-like rendering", "style characterized by", + ) + return any(token in text for token in generic) + + +def _artist_signature_has_multiple_dimensions(value: str) -> bool: + text = value.casefold() + matched = 0 + for markers in _ARTIST_SIGNATURE_DIMENSION_MARKERS.values(): + if any(re.search(r"\b" + re.escape(marker) + r"\b", text) for marker in markers): + matched += 1 + return matched >= 3 + + +def _artist_signature_dimension(value: Any, phrase: Any) -> str: + requested = _optional_text(value) + if requested: + normalized = requested.casefold().replace("-", "_").replace(" ", "_") + aliases = { + "face": "face_structure", + "facial_structure": "face_structure", + "eyes": "eye_design", + "eye": "eye_design", + "hair": "hair_rendering", + "line": "linework", + "lines": "linework", + "shadow": "shading", + "color": "palette", + "colour": "palette", + "highlight": "highlights", + } + normalized = aliases.get(normalized, normalized) + if normalized in _ARTIST_SIGNATURE_DIMENSION_ORDER: + return normalized + text = str(phrase or "").casefold() + for dimension in _ARTIST_SIGNATURE_DIMENSION_ORDER: + if any(re.search(r"\b" + re.escape(marker) + r"\b", text) for marker in _ARTIST_SIGNATURE_DIMENSION_MARKERS[dimension]): + return dimension + return "rendering" + + +def _artist_signature_prompt_parts(payload: dict[str, Any]) -> list[str]: + raw = payload.get("artist_signature") if isinstance(payload, dict) else None + parts: list[str] = [] + grouped: dict[str, list[str]] = {} + if isinstance(raw, list): + for item in raw: + phrase = item.get("phrase") if isinstance(item, dict) else item + phrase = _optional_text(phrase) + support = float(item.get("support_ratio") or 0.0) if isinstance(item, dict) else 0.0 + confidence = float(item.get("confidence") or 0.0) if isinstance(item, dict) else 0.0 + if ( + phrase + and not _artist_signature_is_generic(phrase) + and len(phrase) <= 220 + and not _artist_signature_has_multiple_dimensions(phrase) + and support >= 0.50 + ): + dimension = _artist_signature_dimension(item.get("dimension") if isinstance(item, dict) else None, phrase) + grouped.setdefault(dimension, []).append(phrase) + for dimension in _ARTIST_SIGNATURE_DIMENSION_ORDER: + phrases = _unique_prompt_parts(grouped.get(dimension, [])) + if phrases: + parts.append(f"artist-specific {dimension.replace('_', ' ')} signature: {_join_prompt(*phrases)}") + return _unique_prompt_parts(parts) + def _detailed_style_prompt(result: Any, fallback: Any) -> str: payload = result if isinstance(result, dict) else {} capsules = payload.get("generation_capsules") if isinstance(payload.get("generation_capsules"), dict) else {} @@ -2931,29 +3627,33 @@ def _detailed_style_prompt(result: Any, fallback: Any) -> str: required=bool(_VARIABLE_CONTENT_PATTERNS.search(item)), ) ] - raw_parts = [*must_preserve, *priority_parts, *_prompt_parts(detailed.get("prompt_parts"))] - had_minor_age = any(_contains_minor_age_term(item) for item in raw_parts) or _contains_minor_age_term(fallback) - parts = [*gated_must_preserve, *gated_priorities, *capsule_parts] + signature_parts = _artist_signature_prompt_parts(payload) + parts = [*signature_parts, *gated_must_preserve, *gated_priorities, *capsule_parts] + # Structural age stylization / body-ratio cues are not optional traits; keep them even when + # feature_evidence only covers linework/eyes. Chronological age attributes stay excluded. + for key, raw in (profile.get("attributes") or {}).items() if isinstance(profile.get("attributes"), dict) else []: + if not isinstance(raw, dict) or raw.get("transfer_role") != "style_structure": + continue + value = _optional_text(raw.get("value")) + if not value: + continue + if key in {"facial_age_stylization"} or str(key).endswith("facial_age_stylization"): + parts.append(f"facial age stylization: {value}") + elif "body_maturity" in str(key) or "head_to_body" in str(key) or key in {"anatomy_scale"}: + parts.append(value) risks = _normalize_semantic_risks(payload.get("semantic_risk_audit")) rewritten = [] for item in parts: safe, _ = _sanitize_minor_age_text(_apply_semantic_risk_rewrites(item, risks)) + safe = _strip_mature_body_locks(safe) if safe: rewritten.append(safe) - if had_minor_age: - rewritten.append( - "explicitly adult subject with mature adult body proportions while preserving only non-age facial stylization cues" - ) - compiled = _compact_style_prompt_parts(rewritten, limit=14) + # Do not inject mature-adult body locks after scrubbing chronological-minor wording. + compiled = _compact_style_prompt_parts(rewritten, limit=12) if compiled: return _join_prompt(*compiled) - safe_fallback, fallback_changed = _sanitize_minor_age_text(str(fallback or "").strip()) - if fallback_changed: - safe_fallback = _join_prompt( - safe_fallback, - "explicitly adult subject with mature adult body proportions while preserving only non-age facial stylization cues", - ) - return safe_fallback + safe_fallback, _fallback_changed = _sanitize_minor_age_text(str(fallback or "").strip()) + return _strip_mature_body_locks(safe_fallback) def _detailed_style_negative_prompt(result: Any, fallback: Any) -> str: @@ -3017,13 +3717,14 @@ def _scale_specific_style_negative_prompt(result: Any, case_key: str) -> str: def _scale_transfer_instruction(case_key: str) -> str: return { "portrait": ( - "at portrait scale preserve the source style's face contour, eye-to-face ratio, iris layer hierarchy, lash design, " - "nose and mouth abstraction, hair strand grouping and surface-bound highlight placement" + "at portrait scale preserve the source style's face contour and width-to-length ratio, cheek fullness, jawline and chin silhouette, " + "eye centerline and spacing, eye-to-face ratio, iris layer hierarchy, lash design, nose and mouth abstraction, " + "hair strand grouping and surface-bound highlight placement; do not redesign or elongate the facial contour" ), "fullbody": ( - "at full-body scale preserve silhouette language and anatomy abstraction while depicting an explicitly adult subject " - "with mature limb lengths and natural adult proportions between 6.5 and 7.5 heads tall; preserve colored line hierarchy, " - "clothing-fold shading regions and readable but non-exaggerated facial features" + "at full-body scale preserve silhouette language and facial neoteny while using a soft stylized anatomy band of about " + "5-7 heads tall (prefer the observed source ratio when it falls inside that band); do not collapse into chibi/super-deformed " + "2-4 heads, and do not force a mature adult-woman body canon; preserve colored line hierarchy, clothing-fold shading regions " ), "novel_scene": ( "in a wide scene keep the character linework, local palette relationships and shading grammar distinct from the " @@ -3083,6 +3784,10 @@ def _join_prompt(*values: Any) -> str: return ", ".join(dict.fromkeys(str(value).strip() for value in values if str(value or "").strip())) +def _now() -> str: + return datetime.now(timezone.utc).isoformat() + + def _optional_text(value: Any) -> str | None: text = str(value or "").strip() return text or None @@ -3155,6 +3860,8 @@ def _optional_score(value: Any) -> float | None: def _safe_failure(exc: Exception) -> dict[str, Any]: + if isinstance(exc, ImageProviderError): + return provider_failure_attribution(exc) text = " ".join(str(exc or type(exc).__name__).split()) return {"error_type": type(exc).__name__, "message": text[:500] or type(exc).__name__} @@ -3167,3 +3874,126 @@ def _missing_queue_task_failure(task_id: Any, stage: str) -> dict[str, Any]: "task_id": str(task_id or "").strip() or None, "retryable": True, } + + +def _validation_reference_metadata_from_payload(payload: dict[str, Any] | None) -> dict[str, Any]: + data = payload if isinstance(payload, dict) else {} + meta: dict[str, Any] = {} + if "validation_reference_enabled" in data: + meta["validation_reference_enabled"] = bool(data.get("validation_reference_enabled")) + source_id = _optional_text(data.get("validation_reference_source_id") or data.get("reference_source_id")) + if source_id: + meta["validation_reference_source_id"] = source_id + if "validation_reference_enabled" not in meta: + meta["validation_reference_enabled"] = True + if data.get("validation_reference_enabled") is False or data.get("disable_validation_reference") is True: + meta["validation_reference_enabled"] = False + meta.pop("validation_reference_source_id", None) + return meta + + +def _resolve_validation_reference_plan( + *, + sources: list[Any], + consensus_result: dict[str, Any], + consensus_metadata: dict[str, Any], +) -> dict[str, Any]: + source_by_id = {str(item.source_id): item for item in sources} + enabled_raw = consensus_metadata.get("validation_reference_enabled") + if enabled_raw is False: + return { + "enabled": False, + "source_id": None, + "source_uri": None, + "mode": "disabled", + } + requested_id = _optional_text(consensus_metadata.get("validation_reference_source_id")) + representative_ids = [ + item for item in _string_list(consensus_result.get("representative_source_ids")) if item in source_by_id + ] + primary = next((item for item in sources if bool(getattr(item, "is_primary", False))), None) + default_id = ( + requested_id + if requested_id in source_by_id + else (representative_ids[0] if representative_ids else None) + or (str(primary.source_id) if primary is not None else None) + or (str(sources[0].source_id) if sources else None) + ) + # Reference images are opt-in; pure text is the safe/default compatibility path. + enabled = False if enabled_raw is None else bool(enabled_raw) + if not enabled or not default_id or default_id not in source_by_id: + return { + "enabled": False, + "source_id": None, + "source_uri": None, + "mode": "disabled" if enabled_raw is False else "unavailable", + } + source = source_by_id[default_id] + uri = _optional_text(getattr(source, "source_image_uri", None)) + if not uri: + return { + "enabled": False, + "source_id": default_id, + "source_uri": None, + "mode": "unavailable", + } + mode = "user_selected" if requested_id and requested_id == default_id else "representative_default" + return { + "enabled": True, + "source_id": default_id, + "source_uri": uri, + "mode": mode, + } + + +def _validation_reference_runtime_metadata(case_metadata: dict[str, Any] | None) -> dict[str, Any]: + meta = case_metadata if isinstance(case_metadata, dict) else {} + enabled = bool(meta.get("validation_reference_enabled")) + source_id = _optional_text(meta.get("validation_reference_source_id")) + source_uri = _optional_text(meta.get("validation_reference_source_uri")) + mode = _optional_text(meta.get("validation_reference_mode")) or ("enabled" if enabled else "disabled") + return { + "enabled": enabled and bool(source_uri), + "source_id": source_id, + "source_uri": source_uri, + "mode": mode, + "reference_image_applied": bool(meta.get("reference_image_applied")), + "reference_image_error": meta.get("reference_image_error"), + "reference_image_fallback": meta.get("reference_image_fallback"), + } + + +def _is_reference_image_unsupported_error(exc: Exception) -> bool: + text = " ".join(str(exc or "").split()).casefold() + markers = ( + "input_images", + "input image", + "reference image", + "image field", + "does not support image", + "unsupported image", + "invalid image", + "unknown parameter", + "unexpected keyword", + "not support", + "not supported", + "image edit", + "multipart", + ) + if any(marker in text for marker in markers): + return True + details = getattr(exc, "details", None) + if isinstance(details, dict): + detail_text = " ".join(str(item) for item in details.values()).casefold() + if any(marker in detail_text for marker in markers): + return True + error_type = str(getattr(exc, "error_type", "") or "").casefold() + if error_type in {"configuration_error", "invalid_request", "bad_request"}: + return True + # A number of OpenAI-compatible image gateways hide the actual validation + # message and return only a generic HTTP error when their text-generation + # endpoint receives an image field. Retry without the optional reference + # for client-side request errors, but never hide rate limits or server + # failures behind this fallback. + return error_type == "http_error" and getattr(exc, "status_code", None) in {400, 404, 415, 422, 500, 502, 503, 504} + diff --git a/backend/services/worker_service.py b/backend/services/worker_service.py index 73e5379..6a3967f 100644 --- a/backend/services/worker_service.py +++ b/backend/services/worker_service.py @@ -2,16 +2,20 @@ from __future__ import annotations +import logging import threading from collections.abc import Callable from dataclasses import dataclass, field from datetime import datetime, timedelta, timezone from typing import Any +from backend.dto.common import ApiError from backend.dto.job_dto import GenerationTask from backend.services.queue_service import QueueService from core.identity import RequestContext +logger = logging.getLogger(__name__) + WorkerHandler = Callable[[GenerationTask], "WorkerTaskUpdate | dict[str, Any] | None"] WorkerTaskFilter = Callable[[GenerationTask], bool] @@ -161,7 +165,9 @@ class QueueWorker: with self._lock: if self.is_running(): return {"worker_id": self.worker_id, "running": True, "already_running": True} - self._stop_event.clear() + # A previous thread may have died without clearing state. Always + # rebuild a fresh stop event + thread so callers can revive workers. + self._stop_event = threading.Event() self._thread = threading.Thread( target=self._run_loop, args=(ctx,), @@ -184,7 +190,17 @@ class QueueWorker: def _run_loop(self, ctx: RequestContext) -> None: while not self._stop_event.is_set(): - result = self.run_once(ctx) + try: + result = self.run_once(ctx) + except Exception: + # Provider/business failures must never kill the worker thread. + # A dead thread permanently stalls claim of later queued tasks. + logger.exception( + "ImageStudio queue worker %s crashed while processing; continuing", + self.worker_id, + ) + self._stop_event.wait(self.interval_seconds) + continue if result.status == "idle": self._stop_event.wait(self.interval_seconds) @@ -205,73 +221,147 @@ class QueueWorker: return None def _handle_failure(self, task: GenerationTask, exc: Exception, ctx: RequestContext) -> WorkerRunResult: - latest = self.queue_service.get_job(task.task_id) - if latest.status == "cancelled": - self._notify_terminal(task, latest, exc) - return WorkerRunResult( - worker_id=self.worker_id, - status="cancelled", - task_id=latest.task_id, - processed=1, - error_message=latest.error_message, - ) + """Mark the claimed task failed without ever re-raising. + + Queue progress is more important than perfect failure bookkeeping. Any + secondary error while recording failure must leave the worker thread + alive so later queued work can still be claimed. + """ message = _safe_error_message(exc) - attempt = _int(latest.metadata.get("worker_attempt"), _int(task.metadata.get("worker_attempt"), 1)) - failed = self.queue_service.update_task( - task.task_id, - { - "status": "failed", - "error_message": message, - "metadata": { - **task.metadata, - "worker": { - "worker_id": self.worker_id, - "status": "failed", - "error_type": type(exc).__name__, - "failed_at": _now(), - }, - }, - }, - ctx, + latest = task + try: + latest = self.queue_service.get_job(task.task_id) + except Exception: + logger.exception( + "ImageStudio queue worker %s could not reload task %s during failure handling", + self.worker_id, + task.task_id, + ) + latest = task + + try: + if latest.status == "cancelled": + self._notify_terminal(task, latest, exc) + return WorkerRunResult( + worker_id=self.worker_id, + status="cancelled", + task_id=latest.task_id, + processed=1, + error_message=latest.error_message, + ) + except Exception: + logger.exception( + "ImageStudio queue worker %s failed while handling cancelled task %s", + self.worker_id, + task.task_id, + ) + + attempt = _int( + (latest.metadata or {}).get("worker_attempt"), + _int((task.metadata or {}).get("worker_attempt"), 1), ) - if self.retry_policy.should_retry(attempt, exc): - queued = self.queue_service.update_task( - failed.task_id, + base_metadata = dict(task.metadata or {}) + try: + if isinstance(latest.metadata, dict): + base_metadata = {**base_metadata, **latest.metadata} + except Exception: + base_metadata = dict(task.metadata or {}) + + failed = latest + try: + failed = self.queue_service.update_task( + task.task_id, { - "status": "queued", - "progress": 0, - "error_message": None, + "status": "failed", + "error_message": message, "metadata": { - **failed.metadata, - "retry": { - "scheduled": True, - "attempt": attempt, - "max_attempts": max(int(self.retry_policy.max_attempts), 1), - "next_retry_at": self.retry_policy.next_retry_at(attempt), - "last_error": message, + **base_metadata, + "worker": { + "worker_id": self.worker_id, + "status": "failed", "error_type": type(exc).__name__, + "failed_at": _now(), }, }, }, ctx, ) - self._notify_terminal(task, queued, exc) + except Exception: + logger.exception( + "ImageStudio queue worker %s could not mark task %s as failed", + self.worker_id, + task.task_id, + ) + self._notify_terminal(task, latest, exc) return WorkerRunResult( worker_id=self.worker_id, - status="retry_scheduled", - task_id=queued.task_id, + status="failed", + task_id=task.task_id, processed=1, + failed=1, + error_message=message, + ) + + try: + if self.retry_policy.should_retry(attempt, exc): + try: + queued = self.queue_service.update_task( + failed.task_id, + { + "status": "queued", + "progress": 0, + "error_message": None, + "metadata": { + **(failed.metadata or {}), + "retry": { + "scheduled": True, + "attempt": attempt, + "max_attempts": max(int(self.retry_policy.max_attempts), 1), + "next_retry_at": self.retry_policy.next_retry_at(attempt), + "last_error": message, + "error_type": type(exc).__name__, + }, + }, + }, + ctx, + ) + self._notify_terminal(task, queued, exc) + return WorkerRunResult( + worker_id=self.worker_id, + status="retry_scheduled", + task_id=queued.task_id, + processed=1, + error_message=message, + ) + except Exception: + logger.exception( + "ImageStudio queue worker %s could not requeue task %s after failure", + self.worker_id, + task.task_id, + ) + self._notify_terminal(task, failed, exc) + return WorkerRunResult( + worker_id=self.worker_id, + status="failed", + task_id=failed.task_id, + processed=1, + failed=1, + error_message=failed.error_message or message, + ) + except Exception: + logger.exception( + "ImageStudio queue worker %s hit a secondary error after failing task %s", + self.worker_id, + task.task_id, + ) + return WorkerRunResult( + worker_id=self.worker_id, + status="failed", + task_id=task.task_id, + processed=1, + failed=1, error_message=message, ) - self._notify_terminal(task, failed, exc) - return WorkerRunResult( - worker_id=self.worker_id, - status="failed", - task_id=failed.task_id, - processed=1, - failed=1, - error_message=failed.error_message, - ) def _notify_terminal( self, @@ -422,6 +512,24 @@ def _optional_text(value: Any) -> str | None: def _safe_error_message(exc: Exception) -> str: + if isinstance(exc, ApiError): + code = exc.error_code.value if hasattr(exc.error_code, "value") else str(exc.error_code) + parts = [str(exc.message or "").strip(), f"[{code}]"] + if isinstance(exc.details, dict) and exc.details: + # Keep a short, single-line hint without dumping full provider payloads. + hint_keys = ("reason", "finish_reason", "provider", "model") + hints = [] + for key in hint_keys: + value = exc.details.get(key) + if value is None: + continue + text_value = " ".join(str(value).split()) + if text_value: + hints.append(f"{key}={text_value[:80]}") + if hints: + parts.append("(" + ", ".join(hints) + ")") + text = " ".join(part for part in parts if part) + return text[:500] if text else f"ApiError [{code}]" text = " ".join(str(exc or type(exc).__name__).split()) return text[:500] if text else type(exc).__name__ diff --git a/config.yaml b/config.yaml index 0851584..264c4ba 100644 --- a/config.yaml +++ b/config.yaml @@ -1,7 +1,7 @@ plugin: name: astrbot_plugin_imagestudio display_name: ImageStudio - version: 1.0.33 + version: 1.0.53 features: quick_profile: true @@ -12,7 +12,7 @@ features: private_companion_integration: false generation: - # default_model 是 ImageStudio 路由名;route_name 留空时复用它。 + # default_model 鏄?ImageStudio 璺敱鍚嶏紱route_name 鐣欑┖鏃跺鐢ㄥ畠銆? default_model: "" provider: provider_id: imagestudio_default @@ -27,9 +27,9 @@ generation: enabled: true vision: - # 素材识别路由;provider 中留空的连接字段会复用 generation.provider。 - # 若地址、密钥或超时不同且 provider_id 留空,会自动派生独立 Vision provider ID,避免覆盖生图配置。 - # Vision 模型必须单独填写,不能假定生图模型具备视觉理解能力。 + # 绱犳潗璇嗗埆璺敱锛沺rovider 涓暀绌虹殑杩炴帴瀛楁浼氬鐢?generation.provider銆? + # 鑻ュ湴鍧€銆佸瘑閽ユ垨瓒呮椂涓嶅悓涓?provider_id 鐣欑┖锛屼細鑷姩娲剧敓鐙珛 Vision provider ID锛岄伩鍏嶈鐩栫敓鍥鹃厤缃€? + # Vision 妯″瀷蹇呴』鍗曠嫭濉啓锛屼笉鑳藉亣瀹氱敓鍥炬ā鍨嬪叿澶囪瑙夌悊瑙h兘鍔涖€? default_route: material_vlm provider: provider_id: "" @@ -43,7 +43,7 @@ vision: priority: 10 enabled: true -# 按功能分配模型路由。留空时回退到 generation.default_model 或 vision.default_route。 +# 鎸夊姛鑳藉垎閰嶆ā鍨嬭矾鐢便€傜暀绌烘椂鍥為€€鍒?generation.default_model 鎴?vision.default_route銆? model_assignments: material_recognition: material_vlm advanced_material_recognition: material_vlm @@ -70,12 +70,13 @@ model_assignments: recognition_prompts: default_instruction: >- - 请先判断图片中素材的准确分类,再尽可能完整地提取所有可见事实,包括物品类型、主色与辅色、材质、纹理、结构、轮廓、图案、裁剪、缝线、褶皱、装饰、配件、状态、视角、光照及可复用的设计特征。不要把无法确认的推测写成事实,并明确区分确定信息与低置信度判断。根据识别结果生成一段细节充分、可直接用于生图且能够保留原素材设计的正向提示词,同时生成用于排除错误类别、错误材质、结构畸变、文字、水印和无关背景的负向提示词。仅返回 JSON,字段必须包含 prompt、negative_prompt、tags、confidence、description;tags 应简短、可检索,并包含分类、颜色、材质和关键设计元素。 + 璇峰厛鍒ゆ柇鍥剧墖涓礌鏉愮殑鍑嗙‘鍒嗙被锛屽啀灏藉彲鑳藉畬鏁村湴鎻愬彇鎵€鏈夊彲瑙佷簨瀹烇紝鍖呮嫭鐗╁搧绫诲瀷銆佷富鑹蹭笌杈呰壊銆佹潗璐ㄣ€佺汗鐞嗐€佺粨鏋勩€佽疆寤撱€佸浘妗堛€佽鍓€佺紳绾裤€佽ざ鐨便€佽楗般€侀厤浠躲€佺姸鎬併€佽瑙掋€佸厜鐓у強鍙鐢ㄧ殑璁捐鐗瑰緛銆備笉瑕佹妸鏃犳硶纭鐨勬帹娴嬪啓鎴愪簨瀹烇紝骞舵槑纭尯鍒嗙‘瀹氫俊鎭笌浣庣疆淇″害鍒ゆ柇銆傛牴鎹瘑鍒粨鏋滅敓鎴愪竴娈电粏鑺傚厖鍒嗐€佸彲鐩存帴鐢ㄤ簬鐢熷浘涓旇兘澶熶繚鐣欏師绱犳潗璁捐鐨勬鍚戞彁绀鸿瘝锛屽悓鏃剁敓鎴愮敤浜庢帓闄ら敊璇被鍒€侀敊璇潗璐ㄣ€佺粨鏋勭暩鍙樸€佹枃瀛椼€佹按鍗板拰鏃犲叧鑳屾櫙鐨勮礋鍚戞彁绀鸿瘝銆備粎杩斿洖 JSON锛屽瓧娈靛繀椤诲寘鍚?prompt銆乶egative_prompt銆乼ags銆乧onfidence銆乨escription锛泃ags 搴旂畝鐭€佸彲妫€绱紝骞跺寘鍚垎绫汇€侀鑹层€佹潗璐ㄥ拰鍏抽敭璁捐鍏冪礌銆? category_requirements: [] -# 进阶素材验证图的独立预算守卫。开启后,每次验证(含自动 NSFW -# 回退)都会在调用提供方前检查时间窗口内的任务、图片和估算费用。 +# 杩涢樁绱犳潗楠岃瘉鍥剧殑鐙珛棰勭畻瀹堝崼銆傚紑鍚悗锛屾瘡娆¢獙璇侊紙鍚嚜鍔?NSFW +# 鍥為€€锛夐兘浼氬湪璋冪敤鎻愪緵鏂瑰墠妫€鏌ユ椂闂寸獥鍙e唴鐨勪换鍔°€佸浘鐗囧拰浼扮畻璐圭敤銆? advanced_materials: + recognition_concurrency: 2 cost_budget: enabled: false days: 30 @@ -87,8 +88,8 @@ advanced_materials: per_image: 0 per_1k_tokens: 0 -# 提示词转译、内容审核和普通/NSFW 模型动态分流。 -# 默认只启用本地规则审核;LLM 转译与成人自动分流必须由管理员明确开启。 +# 鎻愮ず璇嶈浆璇戙€佸唴瀹瑰鏍稿拰鏅€?NSFW 妯″瀷鍔ㄦ€佸垎娴併€? +# 榛樿鍙惎鐢ㄦ湰鍦拌鍒欏鏍革紱LLM 杞瘧涓庢垚浜鸿嚜鍔ㄥ垎娴佸繀椤荤敱绠$悊鍛樻槑纭紑鍚€? prompt_governance: translation: enabled: false @@ -136,8 +137,8 @@ chat_access: allow_4k: false storage: - # 这里使用逻辑 data/... 路径;AstrBot 运行时映射到 - # data/plugin_data/astrbot_plugin_imagestudio/...,本地开发仍映射到仓库 data/。 + # 杩欓噷浣跨敤閫昏緫 data/... 璺緞锛汚strBot 杩愯鏃舵槧灏勫埌 + # data/plugin_data/astrbot_plugin_imagestudio/...锛屾湰鍦板紑鍙戜粛鏄犲皠鍒颁粨搴?data/銆? db_path: data/db/imagestudio.db images_path: data/images thumbnails_path: data/thumbnails @@ -148,9 +149,9 @@ storage: temp_path: data/temp database: - # auto: 默认使用 SQLite;配置并启用 PostgreSQL 后自动切换 - # sqlite: 强制使用本地 SQLite - # postgresql: 强制使用 PostgreSQL,驱动或连接配置缺失时会直接报错 + # auto: 榛樿浣跨敤 SQLite锛涢厤缃苟鍚敤 PostgreSQL 鍚庤嚜鍔ㄥ垏鎹? + # sqlite: 寮哄埗浣跨敤鏈湴 SQLite + # postgresql: 寮哄埗浣跨敤 PostgreSQL锛岄┍鍔ㄦ垨杩炴帴閰嶇疆缂哄け鏃朵細鐩存帴鎶ラ敊 backend: auto sqlite: path: data/db/imagestudio.db @@ -167,3 +168,6 @@ security: integration_token_set: false allowed_integration_plugins: - astrbot_plugin_private_companion + + + diff --git a/core/config_service.py b/core/config_service.py index e1f8a66..13691b1 100644 --- a/core/config_service.py +++ b/core/config_service.py @@ -10,7 +10,7 @@ from core.runtime_paths import resolve_config_path from database.db_helper import load_config_payload -PLUGIN_VERSION = "1.0.33" +PLUGIN_VERSION = "1.0.53" @dataclass(frozen=True) @@ -87,3 +87,6 @@ class ConfigService: def _resolve_path(path: str | Path) -> Path: return resolve_config_path(path) + + + diff --git a/docs/project-migration-handoff-2026-07-18.md b/docs/project-migration-handoff-2026-07-18.md index ddf18c3..1257f54 100644 --- a/docs/project-migration-handoff-2026-07-18.md +++ b/docs/project-migration-handoff-2026-07-18.md @@ -1162,3 +1162,34 @@ main 仍停留在 v1.0.20,因此克隆后必须切换到 codex/ui-navigation-s 1.0.33 已同时保存在本地 Git、Forgejo 功能分支和 NAS 实机。新账号切换到正确分支并读取本文件后, 即可从真实效果验收与正式发布阶段继续。 + +--- + +## 15. 2026-07-19:1.0.34 进阶画风验证超时修复 + +用户在真实进阶画风验证中遇到网页显示 `timeout`,但中转站 API 侧没有失败记录。根因不是生图请求必然失败, +而是慢速验证任务的后端 Provider 与前端插件桥没有共享同一套长任务时间预算,且任务卡把 SQLite 无时区 UTC +时间当成本地时间解析,导致页面可能提前报错或显示错误的数小时耗时。 + +本轮已经完成: + +- 版本提升为 `1.0.34`; +- 仅进阶画风 `portrait`、`fullbody`、`novel_scene` 三路迁移验证使用独立 `900` 秒生图超时; +- `900` 秒同时写入验证 case、队列 request、队列 metadata 和实际 `ImageGenerationRequest`; +- `OpenAIImageProvider` 支持单次请求覆盖适配器默认超时,安全范围为 `10~3600` 秒; +- 普通快速生图和其他任务仍使用各自适配器超时,没有被全局提高到 900 秒; +- AstrBot 插件页面桥与前端 API 客户端共同引用 `frontend/shared/config/timeouts.ts` 中的 900 秒常量; +- 任务卡优先读取后端 request/metadata 中的 `timeout_seconds`,显示为“耗时 / 后端时限”; +- 无时区后端时间按 UTC 解析,终态任务耗时固定为 `updated_at - created_at`,不再持续增长或错误显示 8 小时; +- 已重新构建插件页与 standalone web 产物; +- 后端超时专项 `25 passed`,前端契约 `19 passed`,前端 typecheck 通过; +- 完整 pytest 共收集 219 项;首轮 9 个失败均为当前 Windows 主机上旧 Worker 测试自身的短等待阈值, + 放宽测试等待和 Barrier 容差后,所有失败项均已逐项复验通过,但没有再次运行约 38 分钟的整套测试; +- 已通过 SSH 覆盖部署到 NAS 的 `astrbot-ops-pro`,AstrBot 日志成功加载 `1.0.34`; +- 实机备份目录: + `/volume2/Dockers/qqbot/astrbot-ops-pro/data/plugin_backups/astrbot_plugin_imagestudio-1.0.33-pre-1.0.34-20260719-215744`; +- 浏览器只读验收确认页面显示 `ImageStudio · 1.0.34`、后端已连接,历史任务耗时恢复为秒级; +- 未由自动化触发真实付费生图。 + +当前 Git 状态:`1.0.34` 修改仍在本地分支 `codex/ui-navigation-s130-s145` 的工作树中,尚未提交或推送。 +下一步应由用户手动重试画风验证;确认真实生成不再出现前端提前超时后,再提交、推送并制作正式发布包。 diff --git a/engines/image_provider.py b/engines/image_provider.py index 725356d..f368700 100644 --- a/engines/image_provider.py +++ b/engines/image_provider.py @@ -65,6 +65,7 @@ class ImageGenerationRequest: count: int = 1 input_images: tuple[str, ...] = () metadata: dict[str, Any] = field(default_factory=dict) + timeout_seconds: int | None = None @dataclass(frozen=True) @@ -142,7 +143,12 @@ class OpenAIImageProvider: **self.config.extra_headers, } try: - response = self._transport(self.config.endpoint_url(), payload, headers, self.config.timeout_seconds) + response = self._transport( + self.config.endpoint_url(), + payload, + headers, + _generation_request_timeout_seconds(request.timeout_seconds, self.config.timeout_seconds), + ) except ImageProviderError as exc: if exc.provider_id != "unknown": raise @@ -299,6 +305,14 @@ def _post_json(url: str, payload: JsonDict, headers: dict[str, str], timeout_sec return _parse_json_body(body) +def _generation_request_timeout_seconds(value: Any, fallback: Any) -> int: + try: + timeout = int(value if value is not None else fallback) + except (TypeError, ValueError): + timeout = 180 + return min(max(timeout, 10), 3600) + + def _parse_json_body(body: str) -> JsonDict: try: parsed = json.loads(body) diff --git a/engines/single_flow.py b/engines/single_flow.py index 5196a80..d01cfb3 100644 --- a/engines/single_flow.py +++ b/engines/single_flow.py @@ -160,6 +160,7 @@ class SingleFlowEngine: count=count, input_images=_normalize_input_images(request.get("input_images") or request.get("image")), metadata={"task_id": task.task_id, "model_route": model_route}, + timeout_seconds=_optional_timeout_seconds(request.get("timeout_seconds")), ) ) assets: list[MockGeneratedAsset] = [] @@ -377,6 +378,15 @@ def _normalize_input_images(value: Any) -> tuple[str, ...]: return (text,) if text else () +def _optional_timeout_seconds(value: Any) -> int | None: + if value is None: + return None + try: + return min(max(int(value), 10), 3600) + except (TypeError, ValueError): + return None + + def _image_bytes( b64_json: str | None, url: str | None, diff --git a/frontend/package-lock.json b/frontend/package-lock.json index b3c3eb0..e822df2 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "astrbot-plugin-imagestudio-frontend", - "version": "1.0.33", + "version": "1.0.53", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "astrbot-plugin-imagestudio-frontend", - "version": "1.0.33", + "version": "1.0.53", "dependencies": { "@vitejs/plugin-vue": "^5.2.0", "pinia": "^2.3.0", @@ -1531,3 +1531,4 @@ } } } + diff --git a/frontend/package.json b/frontend/package.json index 0e3e236..d3fdbe1 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "astrbot-plugin-imagestudio-frontend", - "version": "1.0.33", + "version": "1.0.53", "private": true, "type": "module", "scripts": { @@ -23,3 +23,4 @@ }, "devDependencies": {} } + diff --git a/frontend/shared/api/astrbot-page-bridge.ts b/frontend/shared/api/astrbot-page-bridge.ts index e979742..462d90f 100644 --- a/frontend/shared/api/astrbot-page-bridge.ts +++ b/frontend/shared/api/astrbot-page-bridge.ts @@ -1,7 +1,8 @@ +import { LONG_TASK_TIMEOUT_MS } from "../config/timeouts" + const CHANNEL = "astrbot-plugin-page" const READY_RETRY_MS = 250 const DEFAULT_REQUEST_TIMEOUT_MS = 30000 -const LONG_TASK_REQUEST_TIMEOUT_MS = 300000 const LONG_TASK_ENDPOINT = /(?:^|\/)(?:generate|retry|review|execute-character|expand|governance-preview|probe-provider|probe-model|recognize|re-recognize|renormalize|renormalize-batch|import-pack|migrate|restore)(?:\/|$)/ type PendingRequest = { @@ -87,7 +88,7 @@ export function installAstrBotPluginPageBridge() { const cloneablePayload = toPostMessagePayload(payload) return new Promise((resolve, reject) => { const timeoutMs = action === "api:post" && LONG_TASK_ENDPOINT.test(endpoint) - ? LONG_TASK_REQUEST_TIMEOUT_MS + ? LONG_TASK_TIMEOUT_MS : DEFAULT_REQUEST_TIMEOUT_MS const timer = window.setTimeout(() => { pending.delete(requestId) diff --git a/frontend/shared/api/client.ts b/frontend/shared/api/client.ts index ac2844b..08f586a 100644 --- a/frontend/shared/api/client.ts +++ b/frontend/shared/api/client.ts @@ -1,4 +1,5 @@ import { API_BASE } from "./endpoints" +import { LONG_TASK_TIMEOUT_MS } from "../config/timeouts" import type { ApiResponse, AstrBotApiResponse } from "../types/api" export type ApiTransport = "plugin-bridge" | "direct-fetch" @@ -10,7 +11,6 @@ const PLUGIN_BRIDGE_DISCOVERY_TIMEOUT_MS = 2500 const PLUGIN_BRIDGE_READY_TIMEOUT_MS = 1200 const PLUGIN_BRIDGE_GET_TIMEOUT_MS = 15000 const PLUGIN_BRIDGE_POST_TIMEOUT_MS = 30000 -const PLUGIN_BRIDGE_LONG_TASK_TIMEOUT_MS = 300000 const LONG_TASK_ENDPOINT = /(?:^|\/)(?:generate|retry|review|execute-character|expand|governance-preview|probe-provider|probe-model|recognize|re-recognize|renormalize|renormalize-batch|import-pack|migrate|restore)(?:\/|$)/ type PluginBridge = NonNullable @@ -167,7 +167,7 @@ async function requestViaPluginBridge( function pluginBridgePostTimeout(endpoint: string) { return LONG_TASK_ENDPOINT.test(endpoint) - ? PLUGIN_BRIDGE_LONG_TASK_TIMEOUT_MS + ? LONG_TASK_TIMEOUT_MS : PLUGIN_BRIDGE_POST_TIMEOUT_MS } diff --git a/frontend/shared/api/endpoints.ts b/frontend/shared/api/endpoints.ts index 096d910..58eea09 100644 --- a/frontend/shared/api/endpoints.ts +++ b/frontend/shared/api/endpoints.ts @@ -63,6 +63,7 @@ export const endpoints = { jobDelete: (taskId: string) => `jobs/${taskId}`, jobCancel: (taskId: string) => `jobs/${taskId}/cancel`, jobRetry: (taskId: string) => `jobs/${taskId}/retry`, + jobRetryFailed: "jobs/failed/retry", jobClearFailed: "jobs/failed/clear", jobClearTerminal: "jobs/terminal/clear", jobDeadLetterRetry: "jobs/dead-letter/retry", diff --git a/frontend/shared/config/timeouts.ts b/frontend/shared/config/timeouts.ts new file mode 100644 index 0000000..ada2e89 --- /dev/null +++ b/frontend/shared/config/timeouts.ts @@ -0,0 +1,2 @@ +export const LONG_TASK_TIMEOUT_SECONDS = 900 +export const LONG_TASK_TIMEOUT_MS = LONG_TASK_TIMEOUT_SECONDS * 1000 diff --git a/frontend/shared/types/advanced-material.ts b/frontend/shared/types/advanced-material.ts index 68de00f..2942c63 100644 --- a/frontend/shared/types/advanced-material.ts +++ b/frontend/shared/types/advanced-material.ts @@ -339,4 +339,14 @@ export interface AdvancedMaterialDecisionRequest { reuse_validation_scenarios?: boolean decision_notes?: string fidelity_score?: number + validation_reference_enabled?: boolean + validation_reference_source_id?: string +} + +export interface AdvancedStyleConsensusRequest { + included_source_ids?: string[] + validation_reference_enabled?: boolean + validation_reference_source_id?: string + style_adjustment_text?: string + validation_instruction?: string } diff --git a/frontend/shared/utils/presentation.ts b/frontend/shared/utils/presentation.ts index 5cebbb6..6163863 100644 --- a/frontend/shared/utils/presentation.ts +++ b/frontend/shared/utils/presentation.ts @@ -1,6 +1,9 @@ import type { CostUsageSummary } from "../types/cost" import type { GenerationJob } from "../types/job" +const BACKEND_NAIVE_UTC_TIMESTAMP = /^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(?:\.\d+)?$/ +const TERMINAL_JOB_STATUSES = new Set(["completed", "succeeded", "failed", "cancelled", "dead_letter", "superseded"]) + export function normalizeStatus(status: string): string { return String(status || "").trim().toLowerCase() } @@ -58,7 +61,9 @@ export function formatCostEstimate(summary: CostUsageSummary): string { export function formatTime(value?: string): string { if (!value) return "-" - const date = new Date(value) + const parsed = timestamp(value) + if (!parsed) return value + const date = new Date(parsed) if (Number.isNaN(date.getTime())) return value return new Intl.DateTimeFormat("zh-CN", { month: "2-digit", @@ -69,17 +74,43 @@ export function formatTime(value?: string): string { } export function timestamp(value: string): number { - const parsed = Date.parse(value) + const text = String(value || "").trim() + const normalized = BACKEND_NAIVE_UTC_TIMESTAMP.test(text) + ? `${text.replace(" ", "T")}Z` + : text + const parsed = Date.parse(normalized) return Number.isFinite(parsed) ? parsed : 0 } export function waitTime(job: GenerationJob): string { const start = timestamp(job.created_at) if (!start) return "-" - const minutes = Math.max(0, Math.round((Date.now() - start) / 60000)) - if (minutes < 1) return "刚刚" + const status = normalizeStatus(job.status) + const terminal = TERMINAL_JOB_STATUSES.has(status) + const persistedEnd = terminal ? timestamp(job.updated_at) : 0 + const elapsedSeconds = Math.max(0, Math.round(((persistedEnd || Date.now()) - start) / 1000)) + const elapsed = formatDurationSeconds(elapsedSeconds) + const timeout = jobTimeoutSeconds(job) + return timeout ? `${elapsed} / 上限 ${formatDurationSeconds(timeout)}` : elapsed +} + +export function jobTimeoutSeconds(job: GenerationJob): number | undefined { + const requestValue = job.request?.timeout_seconds + const metadataValue = job.metadata?.timeout_seconds + const value = requestValue ?? metadataValue + const timeout = Number(value) + if (!Number.isFinite(timeout) || timeout <= 0) return undefined + return Math.round(timeout) +} + +function formatDurationSeconds(value: number): string { + const seconds = Math.max(0, Math.round(value)) + if (seconds < 60) return seconds < 1 ? "刚刚" : `${seconds} 秒` + const minutes = Math.round(seconds / 60) if (minutes < 60) return `${minutes} 分钟` - return `${Math.round(minutes / 60)} 小时` + const hours = Math.floor(minutes / 60) + const remainder = minutes % 60 + return remainder ? `${hours} 小时 ${remainder} 分钟` : `${hours} 小时` } export function shortId(value: string): string { diff --git a/frontend/standalone-web/src/App.vue b/frontend/standalone-web/src/App.vue index 9b47f9d..fb5369d 100644 --- a/frontend/standalone-web/src/App.vue +++ b/frontend/standalone-web/src/App.vue @@ -3311,7 +3311,7 @@ const selectedQueueJobRows = computed(() => { { label: "状态", value: statusLabel(job.status) }, { label: "模型路由", value: job.model_route || "-" }, { label: "进度", value: `${progressValue(job)}%` }, - { label: "等待时间", value: waitTime(job) }, + { label: "耗时 / 后端时限", value: waitTime(job) }, { label: "角色", value: context.profileName || "未关联角色" }, { label: "工作流", value: context.workflowName || "未关联工作流" }, { label: "节点", value: context.nodeName || "未关联节点" }, @@ -3363,6 +3363,20 @@ const queueActionCards = computed(() => { !executingId && job && canWrite && canRetry && failedJobs.value.some((item) => item.task_id === job.task_id), ), }, + { + id: "retry-all-failed", + title: "一键重试全部失败任务", + detail: !canManageQueue + ? "当前账号缺少任务重试权限。" + : failedJobs.value.length + ? `当前检测到 ${failedJobs.value.length} 条失败、取消或死信记录;将逐条创建替代任务,旧记录会标记为已被重试替代。` + : "当前没有可重试的失败、取消或死信记录。", + badge: "BATCH", + endpoint: endpoints.jobRetryFailed, + action: executingId === "retry-all-failed" ? "批量处理中" : "一键重试全部", + tone: "warn", + enabled: Boolean(!executingId && canWrite && canRetry && failedJobs.value.length > 0), + }, { id: "cancel", title: "取消运行任务", @@ -10201,7 +10215,7 @@ async function executeQueueAction(actionId: string, taskId?: string) { bootstrap.value?.permissions.can_write && bootstrap.value?.permissions.can_retry_tasks, ) - if (["delete", "clear-failed", "clear-completed", "clear-terminal"].includes(actionId) && !canManageQueue) { + if (["delete", "retry-all-failed", "clear-failed", "clear-completed", "clear-terminal"].includes(actionId) && !canManageQueue) { jobsError.value = "当前账号缺少任务清理权限,请刷新页面后重试。" return } @@ -10212,6 +10226,10 @@ async function executeQueueAction(actionId: string, taskId?: string) { jobsError.value = "目标任务已不存在或状态已经变化,只有失败、取消、死信和已完成记录可以删除。" return } + if (actionId === "retry-all-failed" && failedJobs.value.length === 0) { + jobsError.value = "当前已经没有可重试的失败、取消或死信记录。" + return + } if (actionId === "clear-failed" && failedJobs.value.length === 0) { jobsError.value = "当前已经没有可清理的异常记录。" return @@ -10232,6 +10250,9 @@ async function executeQueueAction(actionId: string, taskId?: string) { const retried = await postJson(endpoints.jobRetry(job.task_id), {}) selectedQueueTaskId.value = retried.task_id queueActionMessage.value = `替代任务 ${shortId(retried.task_id)} 已执行,状态:${statusLabel(retried.status)}。` + } else if (actionId === "retry-all-failed") { + const result = await postJson>(endpoints.jobRetryFailed, { limit: 100 }) + queueActionMessage.value = queueBatchActionMessage(result, "失败任务已批量重试") } else if (actionId === "cancel") { if (!job) return const cancelled = await postJson(endpoints.jobCancel(job.task_id), {}) @@ -13538,7 +13559,7 @@ function errorMessage(err: unknown) {
  • {{ jobTitle(job) }} - {{ job.model_route || "未指定模型" }} / 等待 {{ waitTime(job) }} + {{ job.model_route || "未指定模型" }} / 耗时 {{ waitTime(job) }}
    diff --git a/frontend/standalone-web/src/features/materials/AdvancedMaterialImportPage.vue b/frontend/standalone-web/src/features/materials/AdvancedMaterialImportPage.vue index ac78df9..361d6c9 100644 --- a/frontend/standalone-web/src/features/materials/AdvancedMaterialImportPage.vue +++ b/frontend/standalone-web/src/features/materials/AdvancedMaterialImportPage.vue @@ -60,6 +60,7 @@ const materials = ref([]) const attempts = ref([]) const selectedImportId = ref("") const selectedImportDetail = ref(null) +const reviewWorkbenchOpen = ref(false) const loading = ref(false) const detailLoading = ref(false) const actionBusy = ref("") @@ -83,6 +84,8 @@ const validationInstructionText = ref("") const decisionNotes = ref("") const fidelityPercent = ref(85) const acceptConfirmed = ref(false) +const validationReferenceEnabled = ref(false) +const validationReferenceSourceId = ref("") let pollTimer = 0 const ownedMediaObjectUrls = new Set() @@ -97,7 +100,8 @@ const selectedUploadCategory = computed(() => ) const styleSetUploadEnabled = computed(() => isStyleCategory(selectedUploadCategory.value)) -const sortedImports = computed(() => sortAdvancedImports(imports.value)) +const isVisibleImport = (item: AdvancedMaterialImport) => !["accepted", "archived"].includes(normalizeStatus(item.status)) +const sortedImports = computed(() => sortAdvancedImports(imports.value.filter(isVisibleImport))) const sortedMaterials = computed(() => sortAdvancedMaterials(materials.value)) const selectedImport = computed(() => selectedImportDetail.value?.import_id === selectedImportId.value @@ -119,6 +123,23 @@ const activeStyleSources = computed(() => styleSources.value.filter((source) => const recognizedStyleSources = computed(() => activeStyleSources.value.filter((source) => ["recognized", "completed", "succeeded"].includes(normalizeStatus(source.status))), ) + +const defaultValidationReferenceSourceId = computed(() => { + const representatives = styleConsensus.value?.representative_source_ids ?? [] + const activeIds = new Set(recognizedStyleSources.value.map((source) => source.source_id)) + const fromRepresentative = representatives.find((sourceId) => activeIds.has(sourceId)) + if (fromRepresentative) return fromRepresentative + const primary = recognizedStyleSources.value.find((source) => source.is_primary) + return primary?.source_id || recognizedStyleSources.value[0]?.source_id || "" +}) + +const effectiveValidationReferenceSourceId = computed(() => { + if (!validationReferenceEnabled.value) return "" + const selected = validationReferenceSourceId.value + if (selected && recognizedStyleSources.value.some((source) => source.source_id === selected)) return selected + return defaultValidationReferenceSourceId.value +}) + const styleConsensus = computed(() => selectedImport.value?.consensus ?? null) const styleValidationCases = computed(() => { const cases = currentAttempt.value?.validation_cases?.length @@ -290,13 +311,18 @@ async function refreshAll(silent = false) { : Promise.resolve({ items: [] }), getJson(endpoints.advancedMaterials, { page: 1, page_size: 100 }), ]) - imports.value = listItems(importPayload).map(normalizeImport) + imports.value = listItems(importPayload).map(normalizeImport).filter(isVisibleImport) materials.value = listItems(materialPayload).map(normalizeMaterial) await resolveRecordMedia([...imports.value, ...materials.value]) if (selectedImportId.value) { const exists = imports.value.some((item) => item.import_id === selectedImportId.value) if (exists) await loadImportDetail(selectedImportId.value, true) + else { + selectedImportId.value = "" + selectedImportDetail.value = null + if (sortedImports.value.length) await selectImport(sortedImports.value[0].import_id) + } } else if (sortedImports.value.length) { await selectImport(sortedImports.value[0].import_id) } @@ -336,8 +362,8 @@ async function pollActiveState() { async function refreshImportSummaries() { if (!props.canManage) return const payload = await getJson(endpoints.advancedMaterialImports, { page: 1, page_size: 100 }) - const nextItems = listItems(payload).map(normalizeImport) - imports.value = mergeImportSummaries(imports.value, nextItems) + const nextItems = listItems(payload).map(normalizeImport).filter(isVisibleImport) + imports.value = mergeImportSummaries(imports.value, nextItems).filter(isVisibleImport) const selectedSummary = imports.value.find((item) => item.import_id === selectedImportId.value) if (selectedImportDetail.value && selectedSummary) { selectedImportDetail.value = preserveStableMedia(selectedImportDetail.value, { @@ -347,6 +373,10 @@ async function refreshImportSummaries() { consensus: selectedImportDetail.value.consensus, validation_cases: selectedImportDetail.value.validation_cases, }) + } else if (selectedImportId.value && !selectedSummary) { + selectedImportId.value = "" + selectedImportDetail.value = null + if (sortedImports.value.length) await selectImport(sortedImports.value[0].import_id) } await resolveRecordMedia(imports.value) } @@ -354,6 +384,7 @@ async function refreshImportSummaries() { async function selectImport(importId: string) { deleteConfirmImportId.value = "" selectedImportId.value = importId + reviewWorkbenchOpen.value = false await loadImportDetail(importId) } @@ -662,10 +693,17 @@ async function createStyleConsensus() { error.value = "" message.value = "" try { + const referenceSourceId = effectiveValidationReferenceSourceId.value await postJson(endpoints.advancedMaterialStyleConsensus(item.import_id), { included_source_ids: recognizedStyleSources.value.map((source) => source.source_id), + validation_reference_enabled: validationReferenceEnabled.value, + ...(validationReferenceEnabled.value && referenceSourceId + ? { validation_reference_source_id: referenceSourceId } + : {}), }) - message.value = "画风交叉分析已入队;模型会同时读取所有有效原图与逐图报告。" + message.value = validationReferenceEnabled.value + ? "画风交叉分析已入队;验证轮将附带 1 张风格参考图。" + : "画风交叉分析已入队;验证轮保持纯文本迁移。" await loadImportDetail(item.import_id, true) } catch (err) { error.value = errorMessage(err) @@ -731,6 +769,7 @@ async function rejectAndRegenerate() { error.value = "" message.value = "" try { + const referenceSourceId = effectiveValidationReferenceSourceId.value const payload: AdvancedMaterialDecisionRequest = { adjustment_text: selectedStyleSet.value ? undefined : adjustment, style_adjustment_text: selectedStyleSet.value ? adjustment || undefined : undefined, @@ -738,6 +777,14 @@ async function rejectAndRegenerate() { fidelity_score: fidelityPercent.value / 100, decision_notes: decisionNotes.value.trim() || undefined, reuse_validation_scenarios: selectedStyleSet.value && !validationInstruction || undefined, + ...(selectedStyleSet.value + ? { + validation_reference_enabled: validationReferenceEnabled.value, + ...(validationReferenceEnabled.value && referenceSourceId + ? { validation_reference_source_id: referenceSourceId } + : {}), + } + : {}), } await postJson(endpoints.advancedMaterialAttemptReject(item.import_id, attempt.attempt_id), payload) message.value = "本轮反馈已保存,调整后的下一轮验证图已加入队列。" @@ -1436,6 +1483,7 @@ function errorMessage(err: unknown) {

    {{ categoryName(selectedImport.category_id) }} · 导入于 {{ formatDate(selectedImport.created_at) }}

    +
    {{ selectedStatus.label }}{{ selectedStatus.detail }}