feat: add task artifact validation for code runs
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
- P6.15 H5 Code-run Validation Metadata: 已完成,H5 code-run 自动声明 `.memind/agent-runs/<requestId>.json` receipt 校验,生产已恢复 `MEMIND_AGENT_CODE_RUNS_REQUIRE_VALIDATION=1` 并通过普通测试用户真实路径。
|
||||
- P6.17 Controlled Worker Concurrency Canary: 已完成,external worker 短窗口提升到并发 2,两条真实 code-run 同时 running 并全部通过 receipt validation。
|
||||
- P6.18 Concurrency Rollout Policy: 已完成,生产 worker 和 Portal runtime/status 已对齐到并发 2,worker KeepAlive 保持开启,保留回滚备份。
|
||||
- P6.19 Task-level Artifact Validation: 已完成第一步,H5 code-run 会在 receipt 之外追加可推断的 `public/*.html` 目标文件校验,页面编辑 code-run 会追加 page-edit task receipt,生产真实 canary 三项 expectedFiles 全部通过。
|
||||
- P8.1 Queue Lease / Stuck Run Recovery: 已完成第一步,worker dispatch 前自动回收超时 running run,新增 `--recover-stale` dry-run/apply 运维入口,生产 synthetic stale run 验证通过。
|
||||
- P8.2 Portal DB/Auth Transient Error Hardening: 已完成第一步,session attach、`/auth/status` 和 API auth middleware 已捕获 DB/auth 瞬时错误,生产部署后 live health、auth/status、runtime/status、guard 和 SLO 验证通过。
|
||||
- P5.15 Active Stream TTL Reconcile: 已按用户要求跳过,暂不做报表/定时 reconcile。
|
||||
@@ -2863,6 +2864,71 @@ runtime/status:
|
||||
- `ok=true`
|
||||
- `failures=[]`
|
||||
|
||||
### 2026-07-02 P6.19 Task-level Artifact Validation
|
||||
|
||||
目标:
|
||||
|
||||
- receipt validation 继续作为所有 code-run 的兜底。
|
||||
- 对能从用户指令或 MindSpace 上下文稳定推断的具体产物追加 task-level validation。
|
||||
- 页面编辑类任务即使通过 API/patch 修改页面,也需要生成带 `pageId` 的 task receipt,证明执行器处理的是目标页面。
|
||||
|
||||
改动:
|
||||
|
||||
- `src/utils/agentRunMode.ts`:
|
||||
- 新增 `extractAgentRunPublicHtmlPaths()`,可从用户输入、`MindSpace/.../public/*.html` 和公开链接中提取 workspace-relative `public/*.html`。
|
||||
- 新增 `buildAgentRunTaskValidation()`。
|
||||
- `resolveAgentRunOptions()` 现在会合并:
|
||||
- 默认 `.memind/agent-runs/<requestId>.json` receipt。
|
||||
- 推断出的 `public/*.html` expectedFiles。
|
||||
- `page_edit_code_task` 的 `.memind/agent-runs/<requestId>-page-edit.json`,内容必须包含 `pageId`。
|
||||
- `src/hooks/useTKMindChat.ts`:
|
||||
- 普通 H5 code-run 调用 `resolveAgentRunOptions()` 时传入 MindSpace context。
|
||||
- `src/hooks/usePageEditSubChat.ts`:
|
||||
- 页面编辑子聊天传入 MindSpace context、`pageId` 和 `pageTitle`。
|
||||
|
||||
测试:
|
||||
|
||||
- `npm run build` 通过。
|
||||
- `node --test agent-run-gateway.test.mjs agent-run-routes.test.mjs` 通过,29 tests pass。
|
||||
- `npx tsc --noEmit` 仍被既有历史 TS 问题阻断,本次相关 `waitForAgentRun()` 返回类型已收紧;最终以 Vite build 和 agent-run route/gateway tests 为准。
|
||||
|
||||
生产部署:
|
||||
|
||||
- 使用灰度 env 重建 H5:
|
||||
- `VITE_AGENT_CODE_RUNS_ENABLED=1`
|
||||
- `VITE_AGENT_CODE_RUNS_AUTODETECT=1`
|
||||
- `VITE_AGENT_CODE_RUNS_USER_IDS=`
|
||||
- 备份:
|
||||
- `/Users/john/Project/memind_backups/20260702-122737-p619-task-artifact-validation`
|
||||
- 已同步:
|
||||
- `/Users/john/Project/Memind/dist`
|
||||
|
||||
生产验证:
|
||||
|
||||
- `https://mm.tkmind.cn/` 已加载新 bundle:
|
||||
- `/assets/index-jYf9W5vk.js`
|
||||
- `/api/runtime/status`:
|
||||
- `ok=true`
|
||||
- `codeRunsEnabled=true`
|
||||
- `requireValidation=true`
|
||||
- `maxConcurrentRuns=2`
|
||||
- `statusCounts={}`
|
||||
- guard dry-run:
|
||||
- `ok=true`
|
||||
- `shouldPause=false`
|
||||
- `failedRecentCount=0`
|
||||
- real canary:
|
||||
- user `916f1fe6-e9c8-44b5-9faa-2fc1bf146ab9`
|
||||
- run `60067d2f-d2af-40d1-bf35-7976309bd8da`
|
||||
- request `p619-task-validation-20260702042911`
|
||||
- status `succeeded`
|
||||
- attempts `1`
|
||||
- event chain includes `tool_gateway_validation`
|
||||
- validated expectedFiles:
|
||||
- `.memind/agent-runs/p619-task-validation-20260702042911.json`
|
||||
- `public/p619-task-validation-20260702042911.html`
|
||||
- `.memind/agent-runs/p619-task-validation-20260702042911-page-edit.json`
|
||||
|
||||
## 回滚策略
|
||||
|
||||
- P0: 修改前保留 `server.mjs` 备份;如启动失败,恢复备份并 `launchctl kickstart` Portal。
|
||||
|
||||
Reference in New Issue
Block a user