diff --git a/docs/mvp/进度总账.md b/docs/mvp/进度总账.md index 50aad2c5..d5b444e0 100644 --- a/docs/mvp/进度总账.md +++ b/docs/mvp/进度总账.md @@ -189,7 +189,7 @@ - ✅ **2026-06-25(同日续):admin jobs 子域 e2e 转真连 + governance config 断层标注,admin governance e2e 全收口(commit 2d06ec5)**。剩 3 skip:jobs 2 个转真连(重试→后端校验 retryable 新插 operation_id=adminRetryJob queued 子 job、取消→muse_ai_job.status=cancelled、来源重试→新插 job_type=source_event_retry job;均纯 DB 状态机、活体 code:0),核心治理配置页(:456)保留 skip。关键坑:切片库后台 AI runtime worker ~3s 抢 queued→failed,取消锚点须用 running(queued 活体 cancel 真返 1040100014 不可取消)。global-setup 加 resetJobsFixture(幂等 seed 90001 failed/retryable + 90002 running muse_ai_job + 90003 needs_recheck muse_ai_source_event + 清派生)。真契约:retry 只接受 {commandId}、cancel/source 接受 {commandId,reason},删 museAdminPayloadsByPage。core config(:456)本轮先标 skip、随即续转真连(见下条;此处"缺表"前提经 psql 纠正为缺种子——原 agent 查 muse_function_chain 漏 meta_ 前缀误判无表)。**独立核实:连跑全量 account+market+jobs 6 passed/1 skipped + psql 复核 90002=cancelled/retry 派生=1/source_event_retry=1**。另查明 studio e2e 37 spec 本就 MSW-off 真连(playwright.config webServer VITE_API_MOCK=false 全局关 MSW + global-setup psql 复位)。待补后端:jobs/source 三写命令 P1r 真库 IT(现 Mockito 单测,本次 e2e 真连为首个端到端真验)。 - ✅ **2026-06-25(同日续):admin governance config 全页巡航转真连——拆 6 子系统+灌系统级种子,admin governance e2e 0 skip 全收口(commit 6bd9030)**。**前提纠正(承上条 jobs 的"缺表"误判)**:psql 实证真表名带 meta_ 前缀=muse_meta_function_chain/muse_meta_protection_node(V3 schema、都在 muse_slice_live、行数 0)——原 agent 查 muse_function_chain 漏 meta_ 前缀误判无表;真断层是切片库缺系统级公共治理对象种子、**非缺表非缺功能**(教训:断层标注前须按真实表名读 schema 验 to_regclass)。每锚点真表+真后端过滤契约(curl 实证):story.draft=muse_meta_schema、故事链路=muse_meta_function_chain(status=active、displayName 取 chain_snapshot)、事实校验=muse_meta_protection_node(status=active+policy_snapshot->>chainKey 绑定)、候选生成 Prompt=muse_prompt(非 muse_ai_prompt)、系统故事智能体=muse_agent(非 muse_ai_agent、agent_type=system)、系统世界观库=muse_knowledge_base(kb_type=global/owner=0)。global-setup 加 resetMetaGovernanceFixture(7 幂等 upsert)。原 1 skip 拆 6 条细粒度真连用例(元结构/功能编排/AI/全局知识/市场/New-API)+修 2 处 strict-mode 多命中。New-API 锚点契约纠正(mock user-e2e/usage-e2e 伪造值→真后端用户数字 id+聚合 recordId {userId}:{period})。**独立核实:连跑全量 e2e x2 各 12 passed/0 skipped + psql 复核 6 锚点种子真灌(function_chain/protection_node active、muse_prompt/muse_agent system/global KB 各 1 行)**。**至此 admin governance e2e 12 真连用例 0 skip 全转真后端**(account+market+jobs+meta governance、反假绿:真 token+代理+PG+契约+写 DB+读种子)。待补后端:jobs/source/market restore P1r 真库 IT;knowledge admin IT=0。 - ✅ **2026-06-25(同日续):studio e2e 全量健康核查 + 前端双 bug 修 + flaky 根治 + 揪出真后端 bug(commit 443a1f3/de5f4d0/ca0e04c)**。admin governance e2e 全收口后核查 studio e2e(36 spec/56 case、本就 MSW-off 真连)。4 轮全量:整体健康 **54/56 稳定绿、0 假绿候选**(抽查断言强度证非假绿)。**修复三类**:①**前端双 bug**(443a1f3):ChapterPanel 新建章节双提交(onKeyDown Enter+onBlur 双触发 submitCreate、isCreatingPending 异步滞后→重复 POST 第 2 个乐观锁 1041000002)加 useRef 同步守卫;WorkspacePage expectedWorkRevision 用 workRevision()??1 兜底掩盖 work 详情未加载→改传真实 revision(undefined 走 ChapterPanel ==null 早返)。实证单次新建 POST 2→1、chapter spec 修后 8 次全绿。②**环境 fixture 污染**(de5f4d0):asset1 被历史 delist→连带 7 spec 红、work1 多余槽位→agent-slot-bind 多命中;global-setup §17/§18 复位。③**测试间来源污染 flaky**(ca0e04c):source-attribution 期望 block1 user_original 但前序 accept-suggestion 写 ai_suggestion 漂移→改读 pristine block3+§3 复位(断言未放宽、强灌 ai_suggestion 免疫验证)。**最大价值=揪出真后端 bug(mock 永远发现不了)**:`MuseKnowledgeBindingMapper.updateStatusByKbId`(:38-46)无 binding_status 过滤、给该 KB 所有未删 binding 写同一 commandId,违反 uk_muse_knowledge_binding_command(tenant_id,command_id WHERE NOT NULL)唯一索引→DuplicateKeyException(disable POST HTTP 200 但 body code:500)→**任何用户把 KB 绑 ≥2 作品后无法停用该 KB**(生产影响)。mock 单测 mock 该 mapper 返行数掩盖、psql KB1 2 binding curl disable 500/1 binding code:0 坐实、代码 :43-45 铁证。用户批准委托修后端(传播写不覆盖 command_id/逐行派生+补真 PG IT+knowledge-disable-restore e2e 转绿,已修闭环 commit 0b152d9)。 -- ✅ **2026-06-25(同日续):AI 真生成 e2e 真红深诊——非 AI 外部、两层根因定位(环境已修 + SSE code bug 方案评审中)**。studio 全量末轮 54/56,2 红是 AI 真生成 spec(不 stub):ai-generation 真红、accept-suggestion flaky(隔离 2 次绿)。深诊定位**两层、均非 AI 外部**(New-API curl 真验在线 HTTP 200+/v1/chat/completions 15s 真文本、清代理非劫持误诊):①**环境/启动(已修)**:start-muse-server-infra.sh 漏 source p1r-external-acceptance.env(New-API 凭据)→server 无 MUSE_AI_NEW_API_*→RealNewApiMuseAiRuntimeClientCondition 装 UnavailableMuseAiRuntimeClient 兜底→AI job 秒失败 AI_NEW_API_UNAVAILABLE(runtime 10-21ms、HTTP 没发出);重启 source 两 env 真验 job completed+suggestion 落库(脚本待固化防复发);②**真 code bug(SSE 协议/时序)**:后端 MuseAiTaskStreamServiceImpl DEFAULT_TIMEOUT_MILLIS=30s 硬死线30s 后端空关+前端不重连→候选永丢 UI。accept flaky/ai-gen 真红是同一 bug 时延两侧(task70 15.3s 绿/task71 35.7s 红、server 日志 done 晚 8s 落库)。**反假绿:e2e 真红深诊分清环境/code/外部三层**(New-API 实在线、真红是 code bug、非急标 flaky/环境)。第二层属 SSE 协议/时序产品行为变更、用户选 A 委托出方案评审文档(后端 timeout↑/可配 vs 前端 AI 流重连对比、design-docs 临时件)review 后执行,本轮未改 code。 +- ✅ **2026-06-25(同日续):AI 真生成 e2e 真红深诊+修复闭环——非 AI 外部、两层根因(环境已修 + SSE code bug 已修 c77b006)**。studio 全量末轮 54/56,2 红是 AI 真生成 spec(不 stub):ai-generation 真红、accept-suggestion flaky(隔离 2 次绿)。深诊定位**两层、均非 AI 外部**(New-API curl 真验在线 HTTP 200+/v1/chat/completions 15s 真文本、清代理非劫持误诊):①**环境/启动(已修)**:start-muse-server-infra.sh 漏 source p1r-external-acceptance.env(New-API 凭据)→server 无 MUSE_AI_NEW_API_*→RealNewApiMuseAiRuntimeClientCondition 装 UnavailableMuseAiRuntimeClient 兜底→AI job 秒失败 AI_NEW_API_UNAVAILABLE(runtime 10-21ms、HTTP 没发出);重启 source 两 env 真验 job completed+suggestion 落库(脚本待固化防复发);②**真 code bug(SSE 协议/时序)**:后端 MuseAiTaskStreamServiceImpl DEFAULT_TIMEOUT_MILLIS=30s 硬死线30s 后端空关+前端不重连→候选永丢 UI。accept flaky/ai-gen 真红是同一 bug 时延两侧(task70 15.3s 绿/task71 35.7s 红、server 日志 done 晚 8s 落库)。**反假绿:e2e 真红深诊分清环境/code/外部三层**(New-API 实在线、真红是 code bug、非急标 flaky/环境)。第二层属 SSE 协议/时序产品行为变更、用户选 A 委托出方案评审文档(design-docs/临时-01、commit 09c35f5)→review 批准 A1+候选③→**已修 commit c77b006**:后端 DEFAULT_TIMEOUT_MILLIS 硬编码→@Value muse.ai.sse.task-timeout-millis 默认 240000(≥上游 TOTAL_TIMEOUT 180s+轮询/回放余量、连接死线:70+poll deadline:198 同引用);前端 connectAIStream 退避重连续 poll+按 SSE id 去重(后端不读 lastEventId、每次 seq0 全量回放→lastSeenSequenceNo 丢弃已见避免重复渲染候选)+done/error terminal 停+总超时 300s onError(SSE_TIMEOUT)不静默卡死(返回仍 AbortController、AIPanel 零改动);A1 start-muse-server-infra.sh 固化 source acceptance env。验证:后端单测 14/14+前端 107/107(含重连去重用例)、活体 e2e ai-generation+accept 连跑 3 轮 6/6 全绿、DB 落 6 行真 LLM suggestion、重连幂等方法 A 活体证。残留:本机 LLM 6.8-19s 未自然跨 30s、慢路径靠「240s 数学覆盖上游 180s+单测+方法 A 重连活体证」三重保证。通则沉淀 muse-module-ai/.agent。 ### D. gateway 接线(B4,**配置层已收口;运行态后置**) - ✅ **配置层收口(2026-06-19)**:`muse-gateway` 已新增 `/admin-api/muse/**`、`/app-api/muse/** → grayLb://muse-server`,删除当前聚合入口未启用的 bpm/pay/report/mp 死路由,Knife4j 聚合入口改为 `muse-server`。新增 `GatewayRouteConfigurationTest` 机械门禁,断言 Muse 路由存在、停用模块路由不回潮、Knife4j 不展示停用服务;本轮 `mvn -pl muse-gateway test -Dtest=GatewayRouteConfigurationTest` **3/3 绿**。 - ⏸ **运行态仍后置**:单体 P1R-7 仍以 `muse-server` 直服 48080 `/app-api` 为验收关键路径;`muse-server` 默认禁用 Nacos 注册,且 gateway 与 server 本地默认端口同为 48080,所以本轮不声称网关真实转发已完成。后续若启用网关部署,需补注册发现/端口方案并做 curl/e2e 首跑。 diff --git a/muse-cloud/muse-module-ai/.agent b/muse-cloud/muse-module-ai/.agent index ef58172c..eb1b431d 100644 --- a/muse-cloud/muse-module-ai/.agent +++ b/muse-cloud/muse-module-ai/.agent @@ -6,4 +6,4 @@ - **边界(不可违反)**:**只产 Shadow,绝不直写 Canonical**;只消费服务端签发的 Runtime Permission Envelope,不能自授权;runtime/任务执行侧不得直连 `ToolGrant` 写模型(`AiGrantRuntimeBoundaryArchTest` 最小门禁已守住);grant 与 runtime 完整物理包隔离仍后置;守 BC 边界不碰他域 `.dal`([bc-boundaries](../../.agents/rules/bc-boundaries.md);历史违例 `ContentMuseWorkOwnerFacade` **已整改消除**——改消费 content `MuseContentWorkOwnerApi`,门禁已收紧、无豁免)。 - **out-of-scope**:Accept Suggestion(归 content BC)、正文写入。 - **现状**:只读评估 72%;后端真实较高质量(无 stub),`RealNewApiMuseAiRuntimeClient` 真打 New-API,SSE 已脱占位;studio `/agents` 已补自建智能体写路活体证(2026-06-19:`agent-create.spec.ts` MSW-off 真单体 1/1,DB 证 `muse_agent` user/owner=1/active + command/audit)。 -- **关键风险 / TODO**:**AI runtime 生成 e2e 已端到端真验(2026-06-24)**——方案1(d647f0c 剥离 sourceSnapshotId 解授权死结)+ D(4dadc7b `DefaultDBFieldHandler` 无登录兜底 `system`,根治 scheduled worker 写 creator/updater null 违约 NOT NULL;BaseDO 带 jdbcType 强制入列致 insert/update 同病)+ agent_version config 补 modelKey=MiniMax-M2.5 + 启动 source `scripts/dev/p1r-external-acceptance.env`(New-API/RAGFlow 配置)→ task5 completed+suggestion+MiniMax-M2.5 真 LLM 生成(P-B envelope/approved、P-C contextAssembly 固化 ✓)。**P-A/P-B/P-C 完整 e2e 已端到端真验打通(2026-06-24,task7)**:P-A 检索命中根因=knowledge 模块 bug——`HttpRagFlowKnowledgeRuntimeClient.retrieveChunks` 把 `document_ids` 以 null 入 retrieval body,RAGFlow 要求其为 list 故拒(code 102 "documents should be a list")→检索 fail-closed→chunkCount=0(task3/4/5/6 全 0 即此 bug,非 RAGFlow 数据/凭据/timeout)。已修(commit 86c6dba:null 时不入 body + 回归测试)。task7 contextAssembly `chunkCount=1/retrievedKbIds=[2]/authorizationSnapshotIds=[authsnap-e2e-1]`,LLM(MiniMax-M2.5)基于 grounding 续写。**02D 槽位首次创建死锁已修+真验(2026-06-24,commit 9115d4f)**:根因=precheck/bind 都 `requireSlotBinding`(缺行抛 forbidden),而"替换"是设计中唯一创建入口("替换"=首次写入、无独立创建端点是设计有意,见后端-04 line748/产品-02D line507)→死锁,首次绑定永不可达(work4 seed binding 实为 E2E 绕此 bug 手插)。修:precheck 缺行放行 + bind 抽 `persistBinding` upsert(无行 insert revision=1/有行 updateById 沿用乐观锁)+ V29 `uk_muse_agent_slot_binding_active` partial unique index(同 work+slot 仅一条 active 并发兜底)+ 前端 mock protected 口径对齐 `protected:` 前缀。真验(muse_slice_live):work1 `writing.continuation` precheck(不再 forbidden)→bind 首次建 binding(slotRevision=1 active)→GET 槽位显示 agent1→AI task 用 `agentSlotKey`(非 agentOverrideRef)→agent1 解析 + runtime 授权过门 → completed + suggestion7(MiniMax-M2.5 真 LLM"星环大陆魔法体系"续写、finishReason stop)。**前端 MVP(df063cb)agentSlotKey 路径真后端端到端走通**;单测 `MuseAgentSlotServiceTest` 26/26 + Controller 4/4 + 前端 4/4;V29 由 Flyway 启动日志证 applied。**仍缺**:Override Slot Contract 主数据(方案 B:合法 slot 校验/系统默认 agent/listWorkAgentSlots 预设骨架未做,slotKey 暂自由字符串、listSlots 缺行仅返回已绑定);前端 agent "运行试用"等深链;grant/runtime 完整物理包拆分仍未做。SSE `event:` 解析漂移已修复并有 targeted Vitest 证据(2026-06-19:`sse.test.ts` + `AIPanel.contract.test.tsx` 17/17);`muse-module-ai-contract-server` 空壳孤儿 submodule 已清理(2026-06-19:从 AI reactor 移除并删除唯一 pom,`P1rAiRouteOwnershipTest` 加回潮门禁)。**2026-06-25:AI 生成候选采纳断层已修(ADR-020 方案 A,commit a16c596)**——`MuseAiRuntimeProjectionService` 此前用 `numericEnvelopeId(Long.parseLong)` 落 authz 快照,但真 runtime envelope 是字符串 `rpe-local-uuid`→解析失败落 null→suggestion 恒不可采纳(merge 1041001001);改直落字符串 envelope(删 numericEnvelopeId)、`MuseAiSuggestionDO.authorizationSnapshotId` 改 String、`AiSuggestionMergeProjectionFacade.getSuggestion` 校验改 hasText、V30 列 BIGINT→VARCHAR(128)。揭 `P1rContentMergeGeneratedSuggestionIT` 假绿(注入数值 9001、真 runtime 不产数值),改真字符串 envelope 转真绿。活体真验:真生成 suggestion authz=rpe-local 字符串→采纳 merge code=0+block revision 自增,生成→采纳→Canonical 全链通。详见总账 2026-06-25 / ADR-020 / memory muse-ai-accept-authz-snapshot-fix。**2026-06-25(同日续):槽位绑定授权快照孪生收口(C1,commit 854f18c)**——三路盘点发现 `muse_agent_slot_binding.authorization_snapshot_id` 是采纳断层唯一漏网 binding 表(列 BIGINT、DO Long,bind 时 parseLong 对字符串 envelope `rpe-local-` 返 null→授权快照静默丢失、绑定溯源链断);V31 两列(authz+source)BIGINT→VARCHAR(128)、DO Long→String、bind 两处(insert/updateById)直透传删 parseLong(`sameAuthorizationSnapshot` 的 parseLong 保留,字符串 envelope 走 fallback 字符串比较正确)。活体真验(muse_slice_live):真 envelope 经 precheck→bind,binding authz 列存非空 rpe-local(insert id=51+updateById id=50 两路径),列类型 varchar(128)、flyway V31 success;修前恒 null。**此前模块"仍缺"只列方案 B/深链/物理拆分,从未记此类型错配——盘点补上的盲区**。至此 ADR-020 全部 binding 表(knowledge V14 + suggestion/attribution V30 + slot V31)收口完成。 +- **关键风险 / TODO**:**AI runtime 生成 e2e 已端到端真验(2026-06-24)**——方案1(d647f0c 剥离 sourceSnapshotId 解授权死结)+ D(4dadc7b `DefaultDBFieldHandler` 无登录兜底 `system`,根治 scheduled worker 写 creator/updater null 违约 NOT NULL;BaseDO 带 jdbcType 强制入列致 insert/update 同病)+ agent_version config 补 modelKey=MiniMax-M2.5 + 启动 source `scripts/dev/p1r-external-acceptance.env`(New-API/RAGFlow 配置)→ task5 completed+suggestion+MiniMax-M2.5 真 LLM 生成(P-B envelope/approved、P-C contextAssembly 固化 ✓)。**P-A/P-B/P-C 完整 e2e 已端到端真验打通(2026-06-24,task7)**:P-A 检索命中根因=knowledge 模块 bug——`HttpRagFlowKnowledgeRuntimeClient.retrieveChunks` 把 `document_ids` 以 null 入 retrieval body,RAGFlow 要求其为 list 故拒(code 102 "documents should be a list")→检索 fail-closed→chunkCount=0(task3/4/5/6 全 0 即此 bug,非 RAGFlow 数据/凭据/timeout)。已修(commit 86c6dba:null 时不入 body + 回归测试)。task7 contextAssembly `chunkCount=1/retrievedKbIds=[2]/authorizationSnapshotIds=[authsnap-e2e-1]`,LLM(MiniMax-M2.5)基于 grounding 续写。**02D 槽位首次创建死锁已修+真验(2026-06-24,commit 9115d4f)**:根因=precheck/bind 都 `requireSlotBinding`(缺行抛 forbidden),而"替换"是设计中唯一创建入口("替换"=首次写入、无独立创建端点是设计有意,见后端-04 line748/产品-02D line507)→死锁,首次绑定永不可达(work4 seed binding 实为 E2E 绕此 bug 手插)。修:precheck 缺行放行 + bind 抽 `persistBinding` upsert(无行 insert revision=1/有行 updateById 沿用乐观锁)+ V29 `uk_muse_agent_slot_binding_active` partial unique index(同 work+slot 仅一条 active 并发兜底)+ 前端 mock protected 口径对齐 `protected:` 前缀。真验(muse_slice_live):work1 `writing.continuation` precheck(不再 forbidden)→bind 首次建 binding(slotRevision=1 active)→GET 槽位显示 agent1→AI task 用 `agentSlotKey`(非 agentOverrideRef)→agent1 解析 + runtime 授权过门 → completed + suggestion7(MiniMax-M2.5 真 LLM"星环大陆魔法体系"续写、finishReason stop)。**前端 MVP(df063cb)agentSlotKey 路径真后端端到端走通**;单测 `MuseAgentSlotServiceTest` 26/26 + Controller 4/4 + 前端 4/4;V29 由 Flyway 启动日志证 applied。**仍缺**:Override Slot Contract 主数据(方案 B:合法 slot 校验/系统默认 agent/listWorkAgentSlots 预设骨架未做,slotKey 暂自由字符串、listSlots 缺行仅返回已绑定);前端 agent "运行试用"等深链;grant/runtime 完整物理包拆分仍未做。SSE `event:` 解析漂移已修复并有 targeted Vitest 证据(2026-06-19:`sse.test.ts` + `AIPanel.contract.test.tsx` 17/17);`muse-module-ai-contract-server` 空壳孤儿 submodule 已清理(2026-06-19:从 AI reactor 移除并删除唯一 pom,`P1rAiRouteOwnershipTest` 加回潮门禁)。**2026-06-25:AI 生成候选采纳断层已修(ADR-020 方案 A,commit a16c596)**——`MuseAiRuntimeProjectionService` 此前用 `numericEnvelopeId(Long.parseLong)` 落 authz 快照,但真 runtime envelope 是字符串 `rpe-local-uuid`→解析失败落 null→suggestion 恒不可采纳(merge 1041001001);改直落字符串 envelope(删 numericEnvelopeId)、`MuseAiSuggestionDO.authorizationSnapshotId` 改 String、`AiSuggestionMergeProjectionFacade.getSuggestion` 校验改 hasText、V30 列 BIGINT→VARCHAR(128)。揭 `P1rContentMergeGeneratedSuggestionIT` 假绿(注入数值 9001、真 runtime 不产数值),改真字符串 envelope 转真绿。活体真验:真生成 suggestion authz=rpe-local 字符串→采纳 merge code=0+block revision 自增,生成→采纳→Canonical 全链通。详见总账 2026-06-25 / ADR-020 / memory muse-ai-accept-authz-snapshot-fix。**2026-06-25(同日续):槽位绑定授权快照孪生收口(C1,commit 854f18c)**——三路盘点发现 `muse_agent_slot_binding.authorization_snapshot_id` 是采纳断层唯一漏网 binding 表(列 BIGINT、DO Long,bind 时 parseLong 对字符串 envelope `rpe-local-` 返 null→授权快照静默丢失、绑定溯源链断);V31 两列(authz+source)BIGINT→VARCHAR(128)、DO Long→String、bind 两处(insert/updateById)直透传删 parseLong(`sameAuthorizationSnapshot` 的 parseLong 保留,字符串 envelope 走 fallback 字符串比较正确)。活体真验(muse_slice_live):真 envelope 经 precheck→bind,binding authz 列存非空 rpe-local(insert id=51+updateById id=50 两路径),列类型 varchar(128)、flyway V31 success;修前恒 null。**此前模块"仍缺"只列方案 B/深链/物理拆分,从未记此类型错配——盘点补上的盲区**。至此 ADR-020 全部 binding 表(knowledge V14 + suggestion/attribution V30 + slot V31)收口完成。 **2026-06-25(同日续):AI 流 SSE 长任务候选丢失已修(commit c77b006、A1+候选③、design-docs/临时-01 review 批准后执行)**——studio e2e ai-generation 真红根因=后端 `MuseAiTaskStreamServiceImpl` SSE 死线 30s 硬编码 < LLM 真时延(MiniMax 11-60s)、更 < 上游自己 `MUSE_AI_NEW_API_TOTAL_TIMEOUT_SECONDS=180`,poll 30s 后 `emitter.complete()` 静默关连接不补 done;前端 `connectAIStream` 一次性连接无重连(重连只在 connectEventStream)→LLM>30s 候选永丢(ai-gen 真红/accept flaky 是同 bug 时延两侧)。修:① 后端删 `DEFAULT_TIMEOUT_MILLIS` 常量→`@Value("${muse.ai.sse.task-timeout-millis:240000}")`(连接死线:70+poll deadline:198 同引用、application.yaml 配置项);② 前端退避重连续 poll + 按 SSE id 去重(后端不读 lastEventId、每次 seq0 全量回放→`lastSeenSequenceNo` 丢弃 id≤已见,避免重复渲染候选)+总超时 300s `onError(SSE_TIMEOUT)` 不静默卡死(返回仍 AbortController、AIPanel 零改动);③ A1 `scripts/dev/start-muse-server-infra.sh` 固化追加 source acceptance env(防漏 `MUSE_AI_NEW_API_*`→`UnavailableMuseAiRuntimeClient` 兜底秒失败 `AI_NEW_API_UNAVAILABLE`)。验证:后端 SSE 单测 14/14+前端 107/107(含重连去重用例)、活体 e2e ai-generation+accept 连跑 3 轮 6/6、重连幂等方法 A 活体证;残留=本机 LLM 6.8-19s 未自然>30s、慢路径靠「240s 数学覆盖上游 180s+单测+方法 A 重连活体证」三重保证。**通则(避免重踩"后端比上游先关门")**:SSE 长任务死线须 ≥ 上游 TOTAL_TIMEOUT;AI 流重连必须以 SSE id 幂等去重(后端 seq0 全量回放、无 lastEventId)。详见 memory muse-ai-generation-sse-timeout-bug。