Repository navigation
feat(workbench): one-click loop starters, read-only loop discovery and bounded schedules - #10153
Conversation
Add asynchronous read-only loop discovery with four isolated sources, deterministic candidates, scoped cache reuse, persisted dismissals, and optional summary-only refinement. Keep local authenticated discovery routes available without LoopX Core. Add compatible SQLite endAt/maxRuns/runCount fields. Count committed turn starts transactionally and disable schedules at the inclusive deadline or run limit, preserving manual-run compatibility, recovery, and failed-start rollback. Validation: daemon typecheck and build pass; discovery, expiry, and schedule tests pass 42/42. Full daemon suite: 1527 passed, 5 failed, 22 skipped out of 1554 tests. The same five cases also fail on baseline a37e245 with matching errors; leave unrelated assertions unchanged. Semantic advisory was unavailable because uv was not found. Final necessity check was static, not full dynamic ablation. Signed-off-by: maxliux5 <5958865+maxliux5@users.noreply.github.com> Co-Authored-By: Claude Code <noreply@anthropic.com>
Prefill the shared Goal confirmation from templates and API candidates, with cancellable discovery and explicit bounded schedule opt-in. Add translated copy and contract coverage. Signed-off-by: maxliux5 <5958865+maxliux5@users.noreply.github.com> Co-Authored-By: Claude Code <noreply@anthropic.com>
POST /api/loopx/goal-draft takes the static draft of a starter template or a discovery candidate (title, objective, completion, boundary), its suggested cadence and its source, and asks the agent configured in the loopDiscovery hub setting to make the texts concrete for the workspace: it names the project folder and the head of the README, carries the one evidence line of a candidate, and may confirm or correct the cadence. Nothing is stored: the question is asked through askOnce without recording the prompt, and the answer is returned, not persisted. When no agent is configured, the model fails, times out or overreaches (cron not on whole minutes, more than 100 runs, no stop condition), the static draft comes back unchanged with generatedBy: 'rules', so the caller can always create. The title is never rewritten, so discovery keeps matching existing Goals by topic. Signed-off-by: maxliux5 <5958865+maxliux5@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google · self_reported
动机 / Motivation
Workbench 中打开“新 loop”空状态页、希望快速发起可持续推进任务(Goal)或按周期自动跟进的个人用户与运维操作者。
修改前,“新 loop”空状态页只显示标题与当前目录副标题,用户必须凭空想出完整目标并手工填写创建表单,且创建后无法在同一确认流里为新 Goal 绑定有界限的定时推进;修改后,首屏提供 3 个可直接预填的启动模板(监控产品线上反馈、持续迭代产品 UI、跟踪线上需求效果)和只读的“帮我发现可跑的 loop”面板,同时创建确认框新增默认关闭的“开启自动定时推进”开关与次数/到期时间上限。实际在 macOS 真实路径下复测时,已创建 Goal 的去重在符号链接目录上会漏滤,导致重复推荐。
用户在“新 loop”空状态页点击模板或只读发现候选后,会预填统一的 Goal 确认弹窗,可显式勾选并配置带 cron、maxRuns 与 endAt 的有界定时任务,且原始发现信号不落盘(仅持久化忽略 id);但在当前 head 上,当 Goal 绑定工作区经过符号链接时,已绑定 Goal 的去重失效(macOS 下实测 2 条 daemon 单元测试失败)。
本 PR 不修改 LoopX Core 协议、不持久化飞书/会话/Git 原始信号正文、不默认开启任何自动定时运行或模型润色、也不改造独立定时任务管理页(SchedulesPage)的上限展示。
不做这项改动会让“新 loop”首屏停留在冷启动空白页,用户既难以从已有日历、会话、Git 与消息活动中识别值得持续推进的工作,也无法在创建 Goal 时一次性建立带安全停止条件(次数上限与到期时间)的定时推进。整体切片方向完整且紧扣 #10072 之后的真实用户路径,但当前 exact head (8e15b301e8b23678d891a11a0f9db080dff81dab) 存在一个可在 macOS 及符号链接工作区稳定复现的去重回归(2 条 PR 自带 daemon 单测失败),需修复后再合入。
改动思路 / Approach
本 PR 沿现有 Workbench daemon + Web 分层组织两条链路,复用已有认证中间件、工作区白名单 isWithinWorkdirs、只读飞书传输 executeLark、ThreadManager.startTurn 的事务前置钩子 beforeStart 以及统一的 GoalConfirm 弹窗:
- 只读 Loop 发现(Read-only Loop Discovery):在
http.ts的 bearer/link token 鉴权之后、LoopX Core 代理之前挂载GET/POST /api/loopx/discover与POST /api/loopx/discover/dismiss,由ThreadManager持有的LoopDiscovery负责 4 个独立数据源(lark-calendar、loochat-threads、git-activity、lark-messages)的并发只读采集。每个源通过bounded()独立限时与取消,单源缺失/未登录/超时只标记为skipped/failed而不拖垮其余源;原始信号与候选仅保存在内存缓存(30 分钟 TTL、最多保留 20 个已完成扫描),落盘的只有去重后的最近 200 个忽略 id(hubSetting('loopDiscoveryDismissed'))。可选模型润色默认关闭(loopDiscovery.agent为空时走纯规则rules),开启时也仅允许覆写summary字段且recordPrompt: false。 - 显式有界定时推进(Opt-in Bounded Schedules):
Store在事务中向schedules表幂等迁移end_at、max_runs、run_count三列;Scheduler禁止外部写入runCount,校验严格 ISO 时间戳(含日历合法性校验)与正整数maxRuns,并在fireReady()传入startTurn(..., beforeStart)事务回调:在turn.started提交的同一 SQLite 事务内复检到期/停用/并发运行并原子递增runCount(达到maxRuns时同步置enabled = false)。前端GoalConfirm默认关闭定时选项(scheduled = false);仅当用户显式勾选后,createConfirmedGoal()才在applyGoal成功后读取新线程真实agent/cwd/permissionMode,先以enabled: false创建日程并逐项回读核对绑定线程、权限与上下限,确认未被旧版 daemon 静默丢弃后才调用updateSchedule(..., { enabled: true })并再次核对回读状态。
- 架构评估与当前 PR 边界:将发现读模型独立为 daemon 侧 LoopDiscovery(本地鉴权且脱离 LoopX Core 可用),并把有界定时上限(endAt/maxRuns/runCount)下沉到 Scheduler 事务性 startTurn 回调中,职责边界清晰、默认隔离合理;当前仅需修复 LoopDiscovery.view 的路径规范化缺陷即可合入,无需重构架构。当前 PR 边界限定在 Workbench daemon(LoopDiscovery、Scheduler 有界执行、Store 迁移、/api/loopx/discover 路由)与 Web 首屏/创建确认流(LoopStarters、GoalConfirm、createConfirmedGoal、zh/en/ja 文案);不扩展到 LoopX Core 或独立日程管理页编辑能力。
具体改动 / Changes
- 无成文外部规格文档:本 PR 无独立 RFC/Issue 规格文档(
spec_basis: no_spec),以 PR 描述中的 5 项交付标准为核对基准(基于 #10072):- “新 loop”空状态 3 个启动模板预填 Goal 弹窗 → implemented(
starter-templates.ts、LoopStarters.tsx、goal-creation.ts)。 - 4 源只读发现、原始依据与单源独立降级 → not_met(去重缺陷)(
loop-discovery.ts:164已有 Goal 去重在符号链接工作区失效,其余源隔离/降级正常)。 - 不持久化原始信号、忽略 id 跨重启保留 → implemented(
loop-discovery.ts、store.ts)。 - 显式有界定时任务(
cron/maxRuns/endAt、服务端runCount、权限继承、回读启用) → implemented(scheduler.ts、store.ts、LoopxGoal.tsx、goal-creation.ts)。 zh/en/ja翻译覆盖新增前端文案 → implemented(含 1 处非阻塞文案润色项)(静态模板与控件文案齐全,LoopStarters.tsx:43,45直接渲染 daemon 返回的原始英文下划线错误码step.reason与status.error)。
- “新 loop”空状态 3 个启动模板预填 Goal 弹窗 → implemented(
关键代码讲解
apps/workbench/packages/daemon/src/loop-discovery.ts—LoopDiscovery.normalizeCwd/start/view/collect/refine:核心发现读模型。normalizeCwd用realpathSync(resolve(...))规范目录并校验isWithinWorkdirs;collect用Promise.all+bounded并行读取四源并隔离故障;view按忽略集合、工作区白名单和已有 Goal 绑定过滤候选,但第 164 行对binding.workspace仅调用resolve(loop.cwd)未做realpathSync,导致符号链接工作区(含 macOS/var/folders->/private/var/folders)去重失效。apps/workbench/packages/daemon/src/scheduler.ts—Scheduler.fire/fireReady/expired/create/update:新增进程内firing互斥集防并发建线程,把到期/上限/停用复检与runCount自增放进startTurn的 SQLite 事务回调,失败提交时回滚计数并清理未启动线程,到期后在tick、recover、list、fireReady统一持久化enabled: false。apps/workbench/packages/web/src/loopx/goal-creation.ts—createConfirmedGoal:先执行applyGoal;当schedule为null(默认关闭)时零日程请求直接返回;开启时读取新建线程真实权限,先enabled: false创建再严格回读比对threadId、mode、permissionMode、maxRuns、endAt,通过后才启用并再次核对enabled === true,任何失败都不回滚已建 Goal 并向界面回传scheduleError。apps/workbench/packages/web/src/components/LoopxGoal.tsx—GoalConfirm:支持预填标题、目标、验收、边界、权限与目录,将原生<select>替换为符合仓库规范的Popover,新增默认关闭的定时推进开关与前端输入校验,并用creatingRef+<fieldset disabled={creating}>防止重复提交。apps/workbench/packages/web/src/loopx/discovery-session.ts&LoopStarters.tsx—LoopDiscoverySession:负责挂载时只读GET、点击后异步POST、800ms 轮询直至收敛、目录切换/卸载时AbortController取消请求与定时器,以及乐观忽略与失败回滚。
对主干的风险 / Risks
阻塞项(P1 / Blocking)
- Problem:
LoopDiscovery.view()在比对已有 Goal 绑定工作区时未做符号链接规范化,导致 macOS 与任意符号链接工作区下已有 Goal 去重失效。- Evidence:
apps/workbench/packages/daemon/src/loop-discovery.ts:104在normalizeCwd()中通过realpathSync(resolve(input))生成candidate.cwd,但同文件第 164 行在view()中仅用resolve(loop.cwd) === candidate.cwd比对binding.workspace。在当前 exact head8e15b301e8b23678d891a11a0f9db080dff81dab的 macOS 环境中运行node --import tsx --test packages/daemon/test/loop-discovery.test.ts,16 条用例中稳定失败 2 条(loop-discovery.test.ts:203期望 0 实际 1;loop-discovery.test.ts:288期望 1 实际 2),因os.tmpdir()返回/var/folders/...而realpathSync为/private/var/folders/...。 - Impact:在 macOS 或任何经由符号链接打开的工作区里,用户已创建并绑定的 Goal 无法被发现视图过滤,刷新或重新打开“发现可跑的 loop”会持续重复推荐已存在的 loop,同时破坏跨平台单测稳定性。
- Fix:在
LoopDiscovery中抽一个路径规范化辅助方法(try { return realpathSync(resolve(dir)); } catch { return resolve(dir); })用于view()里的loop.cwd;并在packages/daemon/test/loop-discovery.test.ts补充显式将binding.workspace设为符号链接别名(如alias)的回归用例,使该问题在 Linux 与 macOS 上均被锁定。修复后重跑node --import tsx --test packages/daemon/test/loop-discovery.test.ts应达到 16/16 PASS。
- Evidence:
非阻塞建议(P2 / Non-blocking)
- 原始机器错误码直接暴露到前端文案(UX / i18n):
apps/workbench/packages/web/src/components/LoopStarters.tsx:43,45直接渲染step.reason(cli_missing、lark_not_logged_in、no_allowed_project、source_timeout、source_unavailable)和view.status?.error(discovery_unavailable),未通过zh.ts/en.ts/ja.ts映射为人类可读说明;同时loop-discovery.ts内的规则候选与step.line固定为中文。建议在本次修复一并为已知 reason/error code 增加多语言映射与兜底文案。 - PR 描述首行仍保留过期 Draft 提示:当前 PR 已为 Ready for Review(
isDraft: false),但正文首行仍写着> **Draft** — ... A second increment is in progress on this branch,建议同步清理以免造成合入范围误解。 - 边界说明:
SchedulesPage.tsx尚未展示maxRuns/endAt/runCount或解释到期后开关自动回弹原因(daemon 仍强制阻止越界运行,不构成安全缺陷),作为后续增强可接受。
验证与门禁实测(exact head 8e15b301e8b23678d891a11a0f9db080dff81dab)
npm run typecheck(apps/workbench全部 6 个 workspace):PASSnpm run build(@loopx/loochat、@loopx/loochat-web、@calli/ext-loopx):PASSnpm test -w @loopx/loochat-web:PASS(745/745,含test/loop-discovery.test.ts)node --import tsx --test packages/daemon/test/schedule-expiry.test.ts packages/daemon/test/schedules.test.ts:PASS(26/26)node --import tsx --test packages/daemon/test/loop-discovery.test.ts:FAIL(14/16 通过,2/16 因上述符号链接路径去重缺陷失败)uv run --extra test loopx canary premerge --from-git-diff --git-diff-base origin/main:PASS(direct checks 4/4,catalog canaries 6/6,含semantic-vocabulary-drift-smoke.py与check_rfc_bilingual.py)uv run --extra test loopx check --scan-path ...(14 个改动源码与 locale 文件):PASS(errors=0,仅 3 条既有http.ts非字面量 credential 提示)- 默认隔离与权限语义核查:普通会话空状态、普通发送流、
GoalConfirm默认关闭定时(scheduled=false)、loopDiscovery.agent默认关闭模型润色均验证与改动前行为一致;新路由均位于http.ts鉴权之后且强制isWithinWorkdirs,未声明超出实现的控制面或协作权限。
我的整体评价 / Verdict
- 长程效果(long_horizon):
improved— 事务性runCount计数、包含边界的endAt停机、maxRuns自动停用与重启不补跑过期任务,防止无人值守循环失控;同时发现层与定时层默认关闭、无隐式后台写副作用。 - 用户体验(user_experience):
regression(因上述可复现去重缺陷暂不可合入)— 首屏模板、只读渐进发现与弹窗回读启用设计本身清晰克制,但在 macOS/符号链接工作区下已有 Goal 去重失效会导致重复推荐,且原始错误码直出影响可读性。 - 视觉核验(visual_review):
not_yet_proven— PR 正文提供了修订 8e15b30 本地打包构建的 9 张合成数据截图(覆盖 1440×1000 桌面端与 390×844 手机端、亮暗主题的默认/展开/确认弹窗状态),本轮复核验证了打包构建、CSS 响应式规则与 745 条前端单测,但未在真实浏览器中独立打开截图或渲染页面进行人工视觉核验。 未核验范围:未在本轮独立进行浏览器实景视觉检查,且真实飞书账号、真实 LoopX Core 与已安装桌面端外壳均未实测。 - 可观察语义与代码体量:
Scheduler对无endAt/maxRuns的既有定时任务保持完全兼容,新增 SQLite 字段幂等迁移且不改写历史;代码体量与改动面与功能目标匹配,无重复控制面实现。语义词表属于 Workbench 本地局部类型(local_only),semantic-vocabulary-drift-smoke实测通过,无需修改共享词表或 RFC。 - 残余风险与复审要求:请修复
LoopDiscovery.view()的符号链接路径规范化并补齐显式符号链接去重回归测试(建议顺手补齐step.reason/status.error的 i18n 映射与清理 PR 顶部过期的 Draft 提示);重推新 head 后我们将基于精确新 head 复核并重跑loop-discovery.test.ts。
英文简短结论
English verdict: REQUEST_CHANGES at head 8e15b30. Blocking P1 defect: LoopDiscovery.view() compares resolve(loop.cwd) against realpathSync-normalized candidate.cwd, breaking existing-Goal deduplication on macOS and symlinked workspaces (reproduced: 2/16 failures in packages/daemon/test/loop-discovery.test.ts at lines 203 and 288); schedule-expiry/schedules (26/26), web tests (745/745), typecheck, build, and canary premerge (direct 4/4, canaries 6/6) all passed.
Creating a loop asked for a title, objective, completion, boundary,
cadence and a stop before anything happened, which kept people from
starting one at all. The new-loop page now prefills everything and
creates on one click; every field stays editable afterwards in the
Goal thread.
- Starter cards and discovery candidates create the Goal directly from
the static draft with a bounded schedule (maxRuns is added when the
suggested cadence has no stop). Each card shows its title with a
readable cadence, and a disabled state keeps a second click from
creating twice.
- Before creating, the web asks the new read-only
POST /api/loopx/goal-draft endpoint, which uses the agent configured
for loop discovery and the workspace context to write the objective,
completion, boundary and cadence. When no model is configured or the
call fails, the static draft is used unchanged and creation still
succeeds.
- Cadence defaults follow the nature of the template: online feedback
is checked on weekdays at 10:00 for up to 20 runs, UI iteration runs
on Mondays at 10:00 for up to 8, requirement tracking on weekdays at
10:00 for up to 20. Candidates use their own suggested cadence.
- A quiet "customize" entry per card ("adjust first" for candidates)
opens the existing dialog with everything prefilled, for people who
want to change something before creating.
- After creation a notice names the Goal and its cadence, with an
"adjust" link into the Goal thread. A failed creation shows the
reason and leaves nothing half-made; when the Goal exists but the
schedule could not be enabled, the notice says so and links to the
schedules page.
- zh, en and ja copy; styles reuse the existing loopx.css classes and
design tokens only.
Signed-off-by: maxliux5 <5958865+maxliux5@users.noreply.github.com>
…aces LoopDiscovery.view() compared each existing Goal's workspace with path.resolve() against a candidate cwd that normalizeCwd() had put through realpathSync(), so a Goal registered through a symlinked path (macOS /var -> /private/var, a person's own link) was proposed again. Both sides are now resolved with the workdirs helper (realpath; the plain path when the directory is gone), locked by a regression test with a nested link. The page also words why a source was skipped or a scan failed itself: the daemon sends a candidate count instead of a Chinese line, and the reason and error codes are mapped to zh/en/ja, with an unknown code still named rather than hidden. Signed-off-by: maxliux5 <5958865+maxliux5@users.noreply.github.com>
|
Addressed the review of
Re-verified at @loopx-agent please re-review the new head. |
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-astra · OpenAI · runtime_reported · high
Request changes conclusion
[P2] 周会候选卡显示最多 8 次,一键创建后实际启用了 20 次。 不配置草稿模型即可复现。问题位于 apps/workbench/packages/web/src/loopx/goal-draft.ts:24。
动机 / Motivation
从周会候选直接建立循环的用户,依赖卡片上的运行次数决定是否创建。基线没有周会发现卡或一键创建链路。本次新增的界面根据每周频率补上八次上限,守护进程另有自己的默认值。
卡片与 SQLite 分别为 20/20、8/8,两条计划都已启用。周会候选卡显示最多 8 次,一键创建后实际启用了 20 次。Core 的预览与应用回执使用夹具,未运行模型或让真实任务触发。
改动思路 / Approach
我给日历读取器一条合成的周五 14:00 周会,让 LoopDiscovery 生成周四 18:00 的候选,然后走卡片计算与一键创建,读取守护进程 SQLite 中已启用的计划。在相同环境下保留工作日和显式周上限两组对照,以区分解析错误和前后端默认值差异。
具体改动 / Changes
关键代码讲解
LoopStarters 用 boundedSchedule 计算卡片次数,goalDraftInput 却把原候选缺失的 maxRuns 作为 null 发送。守护进程的静态回退将其补为 20,随后一键创建把 20 写入计划,并以该值校验创建回执后启用。 本次检查对应提交 0c7a4ed40dcf9e103880ab2c7f2b2f6d6f182b51 和验收项 weekly-discovery-cap。PR 说明
| 检查 | 独立观察 |
|---|---|
| 仓库相关回归与构建 | Workbench 构建成功,发现、草稿、一键创建与调度六个测试文件共 69 项通过。 |
| 工作日默认与显式周上限 | 卡片与 SQLite 分别为 20/20、8/8,两条计划都已启用。 |
| 未带显式上限的每周候选 | 卡片 8,数据库 20,enabled=true,runCount=0,草稿来源为 rules。 |
对主干的风险 / Risks
计划在一键创建时已经启用。用户按照卡片预期在第八次停止,实际计划仍允许再运行十二次。现有前端用例检查静态计算,守护进程用例检查各自回退,两边独立通过仍会漏掉这条组合路径。测试连接了实际的草稿、线程、调度和 SQLite 存储。Core 的预览与应用回执使用夹具,未运行模型或让真实任务触发。
我的整体评价 / Verdict
请让草稿请求携带卡片已显示的停止条件,并增加一条不配置模型的每周候选测试,把展示上限与启用后 SQLite 读回的值直接比对。本轮观察的是卡片所用的次数值和持久化状态。本轮未独立检查桌面和窄屏布局。
English verdict: REQUEST_CHANGES on 0c7a4ed. A weekly candidate displayed with an eight-run cap is enabled for twenty runs on the model-free path.
A weekly candidate arrives without a stop condition and its card shows it bounded to 8 runs, but the draft request sent the cadence as it arrived. With no draft model configured the daemon's static fallback granted its own default of 20, so one click enabled 20. - web: the draft request carries the cadence the card already shows (boundedSchedule), so the daemon's fallback has nothing left to bound. - daemon: a model proposal without any stop condition inherits the one that was sent, the cap the page showed, instead of the daemon default; a proposal with a stop condition stays the model's. - tests: web unit (weekly candidate on a rules stub: request 8, created 8, row wording = card wording; fails without the fix), daemon (an explicit cap is kept on the rules path; an unbounded model proposal inherits the sent cap), and a browser check that one-clicks the weekly candidate with no model configured and compares the cap parsed from the card with the schedule read back from SQLite. Signed-off-by: maxliux5 <5958865+maxliux5@users.noreply.github.com>
|
第二轮审阅意见(周会候选卡片显示 8 次、无模型时实际启用 20 次)已在 7941528 修复,线程内已回复细节:草稿请求现在携带卡片已显示的停止条件;模型提案不带停止条件时继承发送的那一个。新增不配置模型的每周候选浏览器检查,把卡片上的上限与启用后 SQLite 读回的 |
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google · self_reported
动机 / Motivation
本 PR 服务于在 Workbench 中打开「新 loop」空状态页、希望快速创建可持久化推进 Goal 并配套有界定时推进的个人用户与运维操作者。改动前,「新 loop」页面仅展示标题与工作区路径副标题,用户必须从零构思目标文本并手动填写全部表单字段,且确认弹窗不支持直接创建带终止边界的定时计划;改动后,首屏提供 3 个预设启动模板与 1 个按需只读发现入口,卡片直接显示真实生效的周期与运行上限,支持一键调用只读模型润色并创建 Goal 与有界定时任务。此前两轮审阅指出的符号链接工作区去重失效、原始错误码直出、以及周会候选卡片展示 8 次却落库启用 20 次的问题均已在本精确 head 修复并回归验证。一键点击模板或发现候选后请求 POST /api/loopx/goal-draft 润色目标与周期(无配置或失败时自动回退静态模板),先预览并应用创建 Goal,再先禁用创建有界定时任务、读回校验线程绑定与权限和次数上限一致后启用,最后在页顶展示一致的周期提示与「调整」入口。本 PR 不修改 LoopX Core 控制面状态机或跨运行时共享词表,不在守护进程侧生成多语言规则候选文本(留作后续),也不由发现或草稿流程自动对外发消息、修改日历或发布代码。
改动思路 / Approach
| 路径/机制 | 职责分类 | 归属边界与默认/失败语义 |
|---|---|---|
LoopStarters + createLoopOneClick + LoopGoalDraft |
投影与只读草稿策略 | UI 按需触发;POST /api/loopx/goal-draft 无写入且模型不可用/超时/越界时静默回退 rules |
LoopDiscovery(4 源只读扫描 + 内存缓存) |
Provider IO 与本地读模型 | 默认关闭,点击才扫描;单源失败/未登录独立降级,仅 loopDiscoveryDismissed 落盘 |
Scheduler + Store(endAt/maxRuns/runCount) |
核心执行不变量 | 守护进程 SQLite 唯一拥有 runCount,在 startTurn 事务内校验上限与截止时间并自动停用 |
createConfirmedGoal(先禁用创建→读回校验→启用) |
安全启用契约 | 先校验绑定的 threadId、permissionMode 与上限一致再启用;失败保留 Goal 并显式报错 |
架构取舍上,把无副作用的候选发现与草稿润色留在 Workbench 本地只读路径,不向 Hub 事件流写入草稿提示词;将工作区白名单、定时配额 runCount 原子扣减以及先禁用后读回校验再启用收敛在守护进程与事务回调中,避免重做 LoopX Core 协议同时确保失败可隔离、改动可逆。当前 PR 边界为:Workbench 空状态启动页、本地只读发现与草稿端点、以及守护进程 SQLite 定时任务截止时间与运行次数上限。
具体改动 / Changes
- 规范依据(
no_spec):本仓库针对该 Workbench 空状态与一键创建流程无独立事先验收 RFC 或书面 Issue 规范,本次依据本 PR 描述的交付目标与前两轮审阅线程记录逐项核验当前 head 实现。 - 前序审阅修复复核:
- R1 P1(符号链接工作区去重):
apps/workbench/packages/daemon/src/loop-discovery.ts中view()已改为调用共享辅助函数realPath(loop.cwd)(导出自apps/workbench/packages/daemon/src/workdirs.ts),与normalizeCwd()的realpathSync结果对齐,macOS/var->/private/var及多层符号链接不再漏滤已创建的 Goal(loop-discovery.test.ts17/17 通过)。 - R1 P2(原始错误码多语言化):
apps/workbench/packages/web/src/components/LoopStarters.tsx与apps/workbench/packages/web/src/loopx/discovery.ts将step.count、step.reason(stepReasonText)及status.error(discoveryErrorText)统一接入zh/en/ja词典,未知错误码保留在本地化包装文案中输出。 - R2 P2(周会候选展示上限与落库不一致):
apps/workbench/packages/web/src/loopx/goal-draft.ts的goalDraftInput()先经boundedSchedule(row.schedule)补齐卡片展示的运行上限(周会0 18 * * 4携带maxRuns: 8)再请求草稿接口;apps/workbench/packages/daemon/src/loop-goal-draft.ts在rules()与refined()中当模型未给出停止条件时继承请求携带的上限,不再覆盖为守护进程默认 20。
- R1 P1(符号链接工作区去重):
关键代码讲解
LoopDiscovery.view(apps/workbench/packages/daemon/src/loop-discovery.ts:157-169):每次读取扫描状态时动态合并未归档与已归档线程的loopx.binding,按proposalId或(realPath(loop.cwd) === candidate.cwd && topic(loop.title) === topic(candidate.title))过滤已建 Goal 与已忽略候选,确保符号链接目录与后续新建 Goal 都能即时隐藏。LoopGoalDraft.draft与refined(apps/workbench/packages/daemon/src/loop-goal-draft.ts:107-207):校验输入cron、endAt(含2027-02-30日历溢出校验)、maxRuns与允许目录isWithinWorkdirs后,仅在配置了loopDiscovery.agent时通过askOnce(..., { recordPrompt: false })请求一次;模型输出保持原标题不变、限定整分钟cron且不超过100次,若无停止条件则继承请求携带的上限,任意失败均无损回退generatedBy: 'rules'。goalDraftInput与createLoopOneClick(apps/workbench/packages/web/src/loopx/goal-draft.ts:20-30、apps/workbench/packages/web/src/loopx/one-click.ts:42-77):一键点击先以卡片显示的boundedSchedule组装只读草稿请求,依次调用api.goalDraft、previewGoal与createConfirmedGoal,并用读回的实际定时记录渲染结果提示,确保卡片展示值、请求载荷与 SQLite 启用态一致。Scheduler.fireReady与expired(apps/workbench/packages/daemon/src/scheduler.ts:359-428, 577-582):在firing内存去重集合之后进入manager.startTurn的数据库事务回调,重新读取最新计划记录并校验截止时间now >= endAt、运行上限runCount >= maxRuns及禁用状态,原子递增runCount并在达到上限时置enabled = false;若启动事务回滚则释放未提交的新建对话并持久化过期停用标记。
对主干的风险 / Risks
- 正向与负向路径:正向路径覆盖四源只读发现、模型润色、一键创建与有界调度按次停用;负向路径验证了工作区逃逸/非法日期/非法
runCount拒绝(400/403)、lark-cli缺失或源超时独立降级、并发触发不超额扣减以及旧版守护进程忽略maxRuns时前端拒绝启用的回读保护。 - 阻塞项判断:当前精确 head
7a9df571c1d2ba13fef424440d2a1b529a42a60d未发现阻塞性缺陷(No blocking finding)。 - 非阻塞残余风险:
LoopGoalDraft.normalizeCwd未像LoopDiscovery.normalizeCwd那样先显式要求isAbsolute(input),虽仍受realpathSync+isWithinWorkdirs兜底,但建议后续统一复用workdirs.ts绝对路径校验。- 规则引擎生成的候选标题、证据与目标文本目前仍为中文,非中文界面下需后续由守护进程按请求语言生成。
- 完整
loochat守护进程全量测试与浏览器实时 E2E(含真实飞书 CLI 与真实模型调用)未在本轮复审会话中重跑,是当前最强的未直接覆盖边界。
我的整体评价 / Verdict
- 长程与用户体验影响:长程维度
improved(守护进程事务级拥有runCount、防并发重入与重启补跑过期拦截,避免无人值守任务无限执行或失败扣次);用户体验维度improved(空状态一键发起将配置门槛降至单次点击,并保留「自定义 / 先调整」与失败可恢复提示)。 - 视觉检查说明(
visual_review):基于同一 Workbench 源码快照(到精确 head 之间前端零改动)已实图核验桌面浅色启动页、桌面浅色展开候选列表、390px 手机窄屏启动页与手机窄屏展开候选一键创建结果,桌面与窄屏层次清晰、无横向溢出、卡片上限与提示一致。 未覆盖范围(unverified_scope):本轮复审未在本地启动真实浏览器执行实时交互点击或暗色模式截图重拍。 - 语义与架构边界:本 PR 属于 Workbench 本地 UI/守护进程功能扩展(
local_only),未新增或修改跨运行时控制面共享词表,代码体量与兼容边界(禁止客户端伪造runCount、兼容旧库迁移列、默认关闭按需触发)均必要且与改动收益匹配。 - 本地验证结果(
7a9df571c1d2ba13fef424440d2a1b529a42a60d,wait_for_ci: false):npm run typecheck(Workbench 6 个工作区):PASSnpm run build(daemon / web / ext-loopx):PASSnpm test -w @loopx/loochat-web:PASS(755/755)- 守护进程定向测试(
loop-discovery17、loop-goal-draft5、schedule-expiry10、schedules16、main-conversations6):PASS(54/54) uv run --extra test loopx canary premerge --from-git-diff --git-diff-base origin/main:PASS(merge_gate_passed: true,含双语 RFC 与语义词表漂移检查 6/6 通过)- 全量
loochat守护进程剩余无关测试与实时 Playwright E2E:UNVERIFIED(本轮未重跑)
英文简短结论
English verdict: APPROVE — exact head 7a9df571c1d2ba13fef424440d2a1b529a42a60d resolves all prior review findings (symlink Goal deduplication via realPath, localized discovery step/error codes, and consistent 8-run weekly schedule cap from card to SQLite readback) with no blocking regressions; local Workbench typecheck/build, 755 web tests, 54 targeted daemon tests, and loopx canary premerge all PASS (wait_for_ci=false; full daemon suite and live Playwright E2E not re-run in this session).
|
This pull request has merge conflicts with Choose the remote for the base repository, not an out-of-date fork. git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEADFor a same-repository clone whose Keep the DCO |
…ialog's cadence note follows its fields; the README read stays inside the allowed workdirs - one click: a confirmation whose reply was lost keeps the proposal the core reviewed. The next click on the card confirms that one (the daemon confirms a proposal at most once and answers the Goal's thread again) instead of drafting and reviewing another, so a lost reply does not become a second Goal without a schedule. A kept proposal the daemon no longer knows is reviewed once more from the same texts; a refusal ends the attempt, and the next click starts anew. - customize dialog: the cadence note is the wording of the schedule object the create button creates, so after the run cap and the end time are cleared it says 「不自动停止」 (en "no automatic stop", ja 「自動停止なし」) instead of the prefilled 「最多 8 次」. An unbounded schedule stays allowed, as before. - goal draft: the workspace README is read through its real path and only when that lies inside the allowed workdirs; a README symlinked to a file outside is neither read nor handed to the model. Reviewed-in-code by the Workbench review conversation; unit tests in web/test/loop-one-click.test.ts and daemon/test/loop-goal-draft.test.ts, a browser check in the feature E2E (lost reply: one thread, one schedule, one question to the model; the note after clearing the cap). Signed-off-by: maxliux5 <5958865+maxliux5@users.noreply.github.com>
One conflict, in the daemon's route table (apps/workbench/packages/daemon/src/http.ts): this branch adds the read-only discovery and goal-draft routes where main added the report preview routes; both kept, this branch's first. Signed-off-by: maxliux5 <5958865+maxliux5@users.noreply.github.com>
|
Round 3 — the three supplementary items from the Workbench review, fixed in
Verified on @loopx-agent ready for another look. |
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google · self_reported
动机 / Motivation
受影响方与触发场景:Workbench 用户在「新 loop」空白页需要从零填写目标、完成标准、边界和 cron 调度表达式,许多用户因此放弃启动持续循环。
改进前后对比(Before / After):改动前空白页仅显示标题与副标题,改动后首屏直接给出 3 个一键启动模板和按需展开的只读发现面板,支持可选模型润色与一键创建,并保留自定义与先调整入口。
可观察成果与边界(Non-goals):在最新提交 b7d8bf5 上,一键重试可复用同一 proposalId 避免重复建 Goal、弹窗调整清空停止条件后实时切换为不自动停止、README 读取校验 allowedWorkdirs 边界、http.ts 冲突合并保留双方路由;但新增的 README symlink 单测在 macOS APFS 上稳定失败(54/55 通过、1 失败)。 本次改动不修改 LoopX Core,发现源原始文本仅驻留内存、仅持久化忽略 id,不自动修改日程、代码或外发消息。
改动思路 / Approach
本轮复审重点核验自 R2(7a9df571c)以来的两项变更:R3 修复提交 a1f5ce388 与合并 main 的冲突解决 a3dfb72a2ff6d(以及最新主干合并 b7d8bf57aa152)。发现与草稿逻辑保持在 Workbench daemon 本地只读边界内,复用了既有 launch/preview、launch/apply、workdirs 守卫与 SQLite schedules 调度器。 仅限 Workbench daemon 与 web 表面,不涉及 LoopX Core 改造;规则候选文案多语言化与定时任务页上限展示留作后续改进。
flowchart LR
Card["Starter / Candidate Card"] -->|"点击一键创建 (无保留提案)"| Draft["POST /api/loopx/goal-draft (realPath README 守卫, 失败回退静态草稿)"]
Draft --> Preview["POST /api/loopx/launch/preview 生成 proposalId"]
Preview --> Apply["createConfirmedGoal: launch/apply -> createSchedule(disabled) -> enable"]
Card -->|"网络/5xx 断链重试 (保留 attempt)"| Apply
Apply -->|"409 preview_expired (daemon 重启)"| RePreview["用同一 launch 复审一次"] --> Apply
图注(基于 exact head b7d8bf57aa152 源码推导,说明控制流与重试边界):createLoopOneClick 与 LoopStarters 保留未确认提案以防止断链重试产生第二个 Goal。
- R3 修复(
a1f5ce388):- 一键重试幂等:
apps/workbench/packages/web/src/loopx/one-click.ts引入OneClickAttempt与OneClickError,在LoopStarters.tsx中按卡片key保存 Core 已审核但确认回复丢失的proposalId(仅当!(error instanceof LoopxError && error.status < 500)时保留;若 daemon 返回409 preview_expired,用同一launch最多重审一次)。 - 弹窗文案与表单字段一致:
apps/workbench/packages/web/src/components/LoopxGoal.tsx增加scheduleNow()动态读取当前cron/maxRuns/endAt,配合cadenceLabel()新增的loopStarter.cadence.unbounded(不自动停止/no automatic stop/自動停止なし),清空上限后立即准确显示,不再残留预填的「最多 8 次」。 - README 路径逃逸守卫:
apps/workbench/packages/daemon/src/loop-goal-draft.ts在readme()中先调用realPath解析 symlink 再校验isWithinWorkdirs,防止项目内指向允许目录之外的README.md软链被读取并送入模型。
- 一键重试幂等:
- 合并冲突解决(
b7d8bf57aa152):apps/workbench/packages/daemon/src/http.ts同时保留了本分支的/api/loopx/discover、/api/loopx/discover/dismiss、/api/loopx/goal-draft与主干的/api/loopx/report-preview-link、/api/loopx/report-preview/...路由,鉴权、方法校验与corePath转发顺序完整无回退。
具体改动 / Changes
本次 PR 共涉及 origin/main...HEAD 28 个文件(+3384 / -115),无书面规范(no written specification;以 PR 需求为准)。核心功能与冲突合并已在 exact head b7d8bf57aa152 核验到位,但在 loop-goal-draft.test.ts 新增的跨平台 symlink 回归测试存在阻塞缺陷。
关键代码讲解
LoopGoalDraft.readme(apps/workbench/packages/daemon/src/loop-goal-draft.ts:155-173)
按['README.md', 'readme.md', 'README', 'Readme.md']顺序读取项目前 4096 字节 / 40 行 README 供模型生成具体目标。a1f5ce388新增realPath与isWithinWorkdirs(path, this.manager.allowedWorkdirs)校验,确保逃逸工作区软链不会被打开;但配套测试apps/workbench/packages/daemon/test/loop-goal-draft.test.ts:158-159同时使用README.md(外链)与readme.md(回退文件),在 macOS APFS 上二者指向同一目录项,导致测试把回退内容直接写入外链目标并使测试断言失败。createLoopOneClick(apps/workbench/packages/web/src/loopx/one-click.ts:61-127)
首次点击经goalDraftInput -> api.goalDraft (失败回退 rules) -> previewGoal生成OneClickAttempt,再调用createConfirmedGoal。若launch/apply因>=500或网络中断抛出错误,unconfirmed()将attempt附在OneClickError上交由LoopStarters.tsx的attemptsMap 缓存;下次点击跳过goalDraft与重复preview,直接确认同一proposalId(仅在409 preview_expired时重审一次)。需注意one-click.ts:77仅比对agent与permission未比对cwd,若用户在同一组件内切换工作区后重试同名模板会复用旧cwd提案(非阻塞建议)。GoalConfirm(apps/workbench/packages/web/src/components/LoopxGoal.tsx:120-165)与cadenceLabel(starter-templates.ts:87-91)
GoalConfirm通过scheduleNow()将表单实时值构造为与创建按钮完全一致的LoopSuggestedSchedule传入cadenceLabel();当maxRuns与endAt均为空时返回loopStarter.cadence.unbounded,解决调整弹窗清空上限后提示文字与实际创建无上限任务不一致的问题。createHttpServer路由表合并(apps/workbench/packages/daemon/src/http.ts:386-486)
b7d8bf57aa152正确合并了主干的report-preview-link/report-preview与本分支的/api/loopx/discover、/api/loopx/discover/dismiss、/api/loopx/goal-draft,二者均位于 bearer 鉴权之后、通用corePath代理之前,互不遮蔽。LoopDiscovery.view(apps/workbench/packages/daemon/src/loop-discovery.ts:157-169)
R2 已验证的realPath(loop.cwd) === candidate.cwd与多语言错误/跳过码映射在冲突合并后保持完整。
对主干的风险 / Risks
阻塞问题(Blocking)
- [Blocking]
loop-goal-draft.test.ts新增的 symlink 测试在大小写不敏感文件系统(macOS APFS)上稳定失败- Problem:
apps/workbench/packages/daemon/test/loop-goal-draft.test.ts:158-159先创建外链symlinkSync(join(f.outside, 'secret.txt'), join(f.cwd, 'README.md')),紧接着写入writeFileSync(join(f.cwd, 'readme.md'), ...),并在第 166 行执行rmSync(join(f.cwd, 'readme.md'))、第 169 行执行rmSync(join(f.cwd, 'README.md'))。 - Evidence:在 exact head
b7d8bf57aa152的隔离 worktree 内执行tsx --import ./test/home-env.mjs --test test/loop-discovery.test.ts test/loop-goal-draft.test.ts test/schedule-expiry.test.ts test/schedules.test.ts test/main-conversations.test.ts,55 项测试通过 54 项、test/loop-goal-draft.test.ts:165失败(实际 prompt 中"readme":null,未匹配/The project's own readme\./)。根因是 macOS 默认 APFS 大小写不敏感,README.md与readme.md为同一目录项,writeFileSync穿透软链覆盖了outside/secret.txt且入口仍是外链软链,导致LoopGoalDraft.readme()跳过所有.md变体。 - Impact:Workbench 本地 macOS 开发与发布验证的 daemon 测试门禁必败;即使通过第 165 行,第 166 行的
rmSync('readme.md')也会删掉README.md,导致第 169 行抛出ENOENT。 - Fix:将第 159 行和第 166 行的
'readme.md'改为'README'(同样在LoopGoalDraft.readme()候选列表['README.md', 'readme.md', 'README', 'Readme.md']中,且在大小写敏感与不敏感文件系统上均与'README.md'为不同文件名),并重跑上述 5 个 daemon 测试文件确认 55/55 通过。
- Problem:
非阻塞建议(Non-blocking)
LoopStarters切换工作区时的重试提案隔离(apps/workbench/packages/web/src/loopx/one-click.ts:77、apps/workbench/packages/web/src/components/LoopStarters.tsx:37):one-click.ts:77仅校验input.retry?.launch.agent === input.agent && input.retry.launch.permission === input.permission,未校验input.retry.launch.cwd === input.source.cwd,且LoopStarters切换cwd时未清空attemptsMap。若同一挂载周期内点击卡片出现 5xx 失败、随后切换工作区再点击同 id 模板,会沿用旧工作区cwd的提案。建议在one-click.ts:77增加&& input.retry.launch.cwd === input.source.cwd(或在LoopStarters.tsx的useEffect([api, cwd])中清空attempts.current)。
验证与范围核对(Exact Head b7d8bf57aa152)
npm run typecheck(Workbench 全 6 个 workspace):PASSnpm run build(@loopx/loochat、@loopx/loochat-web、@calli/ext-loopx):PASSnpm test -w @loopx/loochat-web:PASS(767/767 通过,0 失败)- 定向 daemon 测试(
loop-discovery.test.ts、loop-goal-draft.test.ts、schedule-expiry.test.ts、schedules.test.ts、main-conversations.test.ts):FAIL(54/55 通过,1 失败即上述loop-goal-draft.test.ts:165) loopx check --scan-path apps/workbench/packages/daemon/src --scan-path apps/workbench/packages/web/src:PASS(errors=0,warnings=72非字面量 credential 提示)loopx canary premerge --from-git-diff --git-diff-base origin/main:PASS(tier=standard,direct_checks4/4 通过,6/6 catalog canaries 通过)- DCO 核对:全部功能提交与
b7d8bf57aa152均包含Signed-off-by(7a9df571c为 GitHub Web 端双亲合并提交,按CONTRIBUTING.md豁免)。
我的整体评价 / Verdict
从**长程效果(long_horizon = improved)与用户体验(user_experience = improved)**看,PR #10153 在 R3 修复与 main 冲突合并后进一步补齐了断链幂等重试、弹窗动态停止提示和 README symlink 越界防护,生产代码与合并结果本身架构清晰、默认开关与权限边界守卫严密。
在呈现与可见性方面(visual_review = inspected):本轮已在 exact head b7d8bf5 完成全部前端构建与 767/767 Web 单元测试,并核对了 PR 正文附带的桌面端与移动端亮暗色截图说明及组件样式源码。 未验证范围:本次复审未在本地实时浏览器中重新执行 Playwright 截图渲染。
本次代码新增局部前端与 daemon 契约词汇,未改动 LoopX Core 共享语义表(semantic_alignment = not_applicable);code_volume = necessary、change_proportionality = proportionate、default_off_isolation = isolated、authority_semantics = aligned。但因 R3 新提交 a1f5ce388 引入的 loop-goal-draft.test.ts:165 在 macOS 大小写不敏感文件系统上稳定失败(54/55),按 exact-head 验证原则必须给出 REQUEST_CHANGES;仅需将测试里的回退文件名 'readme.md' 改为 'README' 并重跑上述 daemon 测试即可重新送审。
英文简短结论
English verdict: REQUEST_CHANGES at exact head b7d8bf57aa1525f2488b3cde6400732511634de2. While the R3 production fixes (one-click.ts retry idempotency, LoopxGoal.tsx dynamic scheduleNow() unbounded cadence label, loop-goal-draft.ts realPath README guard) and the http.ts merge resolution are solid and Workbench typecheck, build, 767/767 web tests, and 6/6 premerge canaries pass, the newly added test in apps/workbench/packages/daemon/test/loop-goal-draft.test.ts:154-169 fails on macOS case-insensitive APFS (54/55 targeted daemon tests; line 165 fails because readme.md collides with the README.md symlink). Replace 'readme.md' with 'README' in that test and re-run the targeted daemon suite.
… scope a kept proposal to its workspace Review round 4 on #10153. - daemon/test/loop-goal-draft.test.ts wrote its fallback as `readme.md`. On a case-insensitive filesystem (macOS) that is the same directory entry as the `README.md` link to the file outside the allowed workdirs, so the write went through the link and nothing was left to read. The fallback is `README` now, a different entry on both filesystem kinds; the guard itself is unchanged. - web/src/loopx/one-click.ts confirmed a kept proposal for a click in another workspace when the agent and the permission were unchanged. The workspace is part of what the proposal was reviewed for: a click in another workspace drafts and reviews again (unit test with a starter). Signed-off-by: maxliux5 <5958865+maxliux5@users.noreply.github.com>
…iscovery Signed-off-by: maxliux5 <5958865+maxliux5@users.noreply.github.com>
|
Round 4 — |
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google · self_reported
动机 / Motivation
受影响方与触发场景:Workbench 用户在「新 loop」空白页启动持续循环时,过去只能面对标题、副标题和需要手填目标、完成标准、边界以及 cron 表达式的表单,许多用户因此直接放弃创建。
改进前后对比(Before / After):改动前「新 loop」页缺少现成起点;改动后首屏提供 3 个一键启动模板和按需展开的只读发现面板,自动结合工作区信息或发现源生成有界调度计划(bounded schedule),同时保留「自定义 / 先调整」弹窗与断链重试幂等保护。
可观察成果与边界(Non-goals):在最新提交 ca2b812(含 R4 修复 c3644b3)上,R3 遗留的 macOS 大小写不敏感文件系统(APFS)测试碰撞问题以及「工作区切换后沿用旧提案」的非阻塞隐患均已修复,Workbench 全栈类型检查、构建、775/775 Web 单测、55/55 定向 Daemon 单测与 6/6 Premerge Canary 全部通过。 本次改动仅限 Workbench daemon 与 web 表面,不修改 LoopX Core,发现源原始文本仅驻留内存、仅持久化忽略 id,不自动外发消息或修改日程与代码。 规则候选文案多语言化与定时任务页上限展示留作后续改进。
改动思路 / Approach
本轮复审(R4)在 exact head ca2b812c8122 核验了 R3 提交 b7d8bf57aa15 之后的唯一增量提交 c3644b3d2006 及与 origin/main 的合并状态。发现、草稿润色与一键确认链路保持在 Workbench 本地只读边界内,复用了既有 launch/preview、launch/apply、workdirs 路径守卫与 SQLite schedules 调度器,未引入额外控制面状态或独立审批模型。 仅改动 Workbench daemon 与 web 表面,不修改 LoopX Core 协议,在架构复杂度与当前 PR 边界内交付首屏一键启动、只读发现与有界调度。
flowchart LR
Click["点击 Starter / Candidate"] -->|"校验 agent + permission + cwd"| Keep{"命中保留 attempt?"}
Keep -->|"否 (首次或工作区/配置已变)"| Draft["POST /api/loopx/goal-draft (realPath README 守卫)"]
Draft --> Preview["POST /api/loopx/launch/preview 生成 proposalId"]
Keep -->|"是 (同工作区断链重试)"| Apply["createConfirmedGoal: apply -> createSchedule -> enable"]
Preview --> Apply
Apply -->|"409 preview_expired"| RePreview["同 launch 重审一次"] --> Apply
图注(基于 exact head ca2b812c8122 源码推导的说明性流程):c3644b3d2006 将 draft.cwd 纳入保留提案的匹配键,切换工作区后自动重新草拟与预览,不再复用旧工作区提案。
- R4 阻塞项修复(
apps/workbench/packages/daemon/test/loop-goal-draft.test.ts:154-177):R3 遗留问题为测试同时在工作区写入外链README.md与回退文件readme.md,在 macOS 默认 APFS 大小写不敏感文件系统上两者指向同一目录项导致覆盖外链并稳定失败。c3644b3d2006将回退文件改为与README.md在大小写敏感与不敏感文件系统上均互不冲突的'README'(仍在LoopGoalDraft.readme候选列表内),生产侧realPath+isWithinWorkdirs守卫保持不变。 - R3 非阻塞建议顺手闭环(
apps/workbench/packages/web/src/loopx/one-click.ts:76-80):createLoopOneClick先计算draft = goalDraftInput(...)并校验draft.cwd,随后将input.retry.launch.cwd === draft.cwd加入attempt复用条件,并在loop-one-click.test.ts:310-324新增跨工作区不复用旧proposalId的单元测试。
具体改动 / Changes
本次 PR 相对 origin/main 共涉及 Workbench 28 个文件,无书面规范(no written specification;以 PR 需求为准)。R4 仅在 b7d8bf57aa15 基础上新增 c3644b3d2006 及其合并提交 ca2b812c8122,所有前序实现与 http.ts 路由合并在当前 head 保持完整一致。
关键代码讲解
createLoopOneClick(apps/workbench/packages/web/src/loopx/one-click.ts:64-127)
一键创建主入口。先通过goalDraftInput解析当前cwd,仅当agent、permission与cwd三者均与保留的retry.launch一致时才跳过草稿与previewGoal直接重确认;遇到LoopxError且status < 500时放弃保留提案,网络/5xx 断链保留attempt并在409 preview_expired时最多重审一次。LoopGoalDraft.readme(apps/workbench/packages/daemon/src/loop-goal-draft.ts:155-173)与回归测试(loop-goal-draft.test.ts:154-177)
按['README.md', 'readme.md', 'README', 'Readme.md']顺序先调用realPath解析软链接再检查isWithinWorkdirs(path, this.manager.allowedWorkdirs),越界软链被直接跳过。测试使用README.md(指向外部secret.txt)与README(工作区内回退文本)验证跨平台行为,在 macOS APFS 上实测通过。GoalConfirm(apps/workbench/packages/web/src/components/LoopxGoal.tsx:69-181)与LoopStarters(apps/workbench/packages/web/src/components/LoopStarters.tsx:27-116)
LoopStarters维护按卡片key索引的attemptsMap 与单飞锁busyRef;GoalConfirm通过scheduleNow()实时由表单字段计算cadenceLabel,在用户清空maxRuns与endAt后立即展示「不自动停止」。createHttpServer(apps/workbench/packages/daemon/src/http.ts:386-412)与Scheduler(apps/workbench/packages/daemon/src/scheduler.ts)
/api/loopx/discover、/api/loopx/discover/dismiss与/api/loopx/goal-draft保持只读边界与 bearer token 鉴权,并与主干新增的/api/loopx/report-preview-link路由并存无冲突;Scheduler服务端持有runCount、maxRuns与endAt到期控制。
对主干的风险 / Risks
- R3 阻塞缺陷与非阻塞项已闭环:此前在 macOS APFS 稳定失败的
loop-goal-draft.test.ts:165已通过改为'README'彻底修复;跨工作区点击卡片误用旧提案的问题亦已在one-click.ts:79修复并通过单测锁定。 - 默认关闭与权限边界(
default_off_isolation = isolated、authority_semantics = aligned):未启用一键点击或未展开发现面板时,既有的空白页/手写创建与普通对话完全不受影响;goal-draft与discover均为本地只读,不隐式创建 Goal 或扩展 Actor 权限。 - 验证基线与未覆盖范围说明:Workbench 全 6 个 workspace
typecheck、生产构建、775/775@loopx/loochat-web单测、55/55 定向 Daemon 套件(loop-discovery.test.ts、loop-goal-draft.test.ts、schedule-expiry.test.ts、schedules.test.ts、main-conversations.test.ts)、8 个 PR 改动文件loopx check(errors=0)以及loopx canary premerge(tier=standard,4/4 direct checks、6/6 catalog canaries)均在 exact headca2b812c8122实测 PASS。另注:顺带加跑api.test.ts时,其中 5 项既有outputs用例在 macOS 因系统临时目录符号链接解析差异失败(与 PR 改动无关的基线环境现象)。
我的整体评价 / Verdict
从**长程效果(long_horizon = improved)与用户体验(user_experience = improved)**看,PR #10153 在 R4 修复后补齐了跨平台测试健壮性与跨工作区提案隔离,一键启动、只读发现、断链幂等与有界调度端到端闭环完整,未给主干引入回归或过度设计。
在呈现与可见性方面(visual_review = inspected):已核对 PR 描述中提供的 1440x1000 桌面端与 390x844 移动端亮暗色多状态截图说明,并在 exact head ca2b812 完成 Vite 生产构建、6 个 workspace 类型检查与 775/775 Web 单测,首屏模板网格、渐进式发现面板与自定义弹窗层级清晰、无重复说明文案且状态可达。 未验证范围:本轮未在本地启动真实浏览器重新执行 Playwright E2E 实拍。
本次新增类型与状态字段均属 Workbench 局部前端与 daemon 契约词汇,未改动 LoopX Core 共享语义表(semantic_alignment = not_applicable);code_volume = necessary、change_proportionality = proportionate、default_off_isolation = isolated、authority_semantics = aligned、observable_semantics = intentional_change_validated、repository_reuse = reused。全部阻塞与非阻塞项已验证解决,可以批准合入(由维护者按合入授权处理)。
英文简短结论
English verdict: APPROVE at exact head ca2b812c81227a16ddba2976efd89910043c2a27. R4 (c3644b3d2006) resolves the macOS case-insensitive APFS failure in apps/workbench/packages/daemon/test/loop-goal-draft.test.ts (using README instead of readme.md alongside the README.md symlink) and also scopes retained one-click retry proposals to the current workspace (cwd) in apps/workbench/packages/web/src/loopx/one-click.ts. Verified cleanly on this head: Workbench typecheck (6 workspaces), build, 775/775 web unit tests, 55/55 targeted daemon tests on macOS APFS, loopx check (errors=0 on PR files), and loopx canary premerge (4/4 direct checks, 6/6 catalog canaries).
|
This pull request has merge conflicts with Choose the remote for the base repository, not an out-of-date fork. git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEADFor a same-repository clone whose Keep the DCO |
…iscovery One conflict, in App.tsx: main wrapped the conversation in ControllerConversation (#10114) and this branch gives the empty state its "empty-loop-start" class and the starters; both are kept — the new closing tag with this branch's empty-state div. Signed-off-by: maxliux5 <5958865+maxliux5@users.noreply.github.com>
…iscovery No conflicts: main's change (#10173) touches only the Antigravity and Lark Python packages. Signed-off-by: maxliux5 <5958865+maxliux5@users.noreply.github.com>

Goal And Delivered Outcome
POST /api/loopx/goal-draftasks the agent configured for loop discovery (loopDiscoverysetting) to make the objective, completion and boundary concrete for the workspace (project name, README head, the candidate's one evidence line) and to confirm or correct the cadence. When no agent is configured, or the model fails, times out or answers unusably, the static draft is created as it was (generatedBy: 'rules'). The prompt is not recorded in hub history and the answer is returned, not stored.GET/POST /api/loopx/discover— reads four sources read-only (calendar agenda, conversation titles and recent human text, git activity, recent Lark messages per chat) and proposes recurring, launch, UI and feedback candidates, each with a raw evidence line and a suggested cadence. Sources degrade independently and say why. Raw signals stay in memory; only dismissal ids persist. A cached scan is shared across tabs and rescans are asynchronous.runCount, validates the cron, normalizesendAt, maps the permission per adapter, and creates the schedule disabled → reads it back → enables it, so a failed enable is reported, never silent. A one-click Goal uses the template's suggested permission (read_onlyfor monitoring,workspace_autofor the UI rounds) when the agent offers it.real_entrypointandunitrows below.main.Author Declaration
Implemented against
apps/workbench/packages/web/src/loopx/one-click.ts,src/components/LoopStarters.tsx,src/App.tsxapps/workbench/packages/web/test/loop-one-click.test.ts;real_entrypointrowapps/workbench/packages/daemon/src/loop-goal-draft.ts(POST /api/loopx/goal-draft),web/src/loopx/goal-draft.tsdaemon/test/loop-goal-draft.test.ts;real_entrypointrow (draft failing / unconfigured / answering)web/src/loopx/starter-templates.ts(boundedSchedule,defaultMaxRuns,cronLabel,cadenceLabel)web/test/loop-one-click.test.tsweb/src/components/LoopxGoal.tsxreal_entrypointrowweb/src/App.tsx(createdLoop),web/src/loopx/goal-creation.tsweb/test/loop-one-click.test.ts;real_entrypointrowapps/workbench/packages/daemon/src/loop-discovery.ts,src/http.ts,web/src/loopx/discovery.ts,src/loopx/discovery-session.tsdaemon/test/loop-discovery.test.tsloop-discovery.ts(view()),src/store.ts(loopDiscoveryDismissed, last 200 ids)real_entrypointmaxRuns,endAt, server-ownedrunCount, permission per adapter, enable readbackapps/workbench/packages/daemon/src/scheduler.ts,src/threads.ts,web/src/loopx/goal-creation.tsdaemon/test/schedule-expiry.test.ts,daemon/test/schedules.test.ts; schedule readback inreal_entrypoint/var→/private/var, a personal link)apps/workbench/packages/daemon/src/loop-discovery.ts(view(), both sides resolved throughrealPathinsrc/workdirs.ts)daemon/test/loop-discovery.test.ts: “a Goal registered through a symlinked workspace path still hides its candidate” (fails without the fix)apps/workbench/packages/web/src/loopx/goal-draft.ts(goalDraftInputsends the cadence the card shows),apps/workbench/packages/daemon/src/loop-goal-draft.ts(a model proposal without a stop condition inherits the sent one)web/test/loop-one-click.test.ts(weekly candidate on a rules stub: request 8, created 8, row = card; fails without the fix);daemon/test/loop-goal-draft.test.ts; browser check below (card text vs SQLite readback, no model configured)web/src/loopx/discovery.ts(stepReasonText,discoveryErrorText),src/components/LoopStarters.tsx,web/src/i18n/locales/{zh,en,ja}.tsweb/test/loop-discovery.test.ts(three languages, unknown-code fallback)apps/workbench/packages/web/src/loopx/one-click.ts(OneClickAttempt,OneClickError),web/src/components/LoopStarters.tsx(kept per card)web/test/loop-one-click.test.ts(a lost reply → the sameproposalIdis confirmed; a proposal the daemon no longer knows is reviewed once more from the same texts; a refusal ends the attempt; a changed composer starts anew); browser check in thereal_entrypointrow (the same check fails without the fix: a second Goal thread)web/src/components/LoopxGoal.tsx(the note and the create button sharescheduleNow),web/src/loopx/starter-templates.ts(cadenceLabel),web/src/i18n/locales/{zh,en,ja}.ts(loopStarter.cadence.unbounded)web/test/loop-one-click.test.ts(zh / en / ja); browser check in thereal_entrypointrow (the note follows the field, create stays enabled)apps/workbench/packages/daemon/src/loop-goal-draft.ts(readme()resolves the real path and checksisWithinWorkdirsfromsrc/workdirs.ts)daemon/test/loop-goal-draft.test.ts(a link outside skipped and the next README name read, a link inside the workdir read; fails without the fix)web/src/i18n/locales/{zh,en,ja}.tsweb/test/i18n.test.ts;web/test/loop-discovery.test.tslark-cliexecutable and a route-level Core stub.Scope And Continuation
0c7a4ed40with a regression test, and the per-source skip / failure codes and the scan error are now worded in zh / en / ja. Review round 2: a weekly candidate's card showed “最多 8 次” while one click without a draft model enabled 20 (the request sent the cadence unbounded and the daemon's static fallback granted its own default) — fixed in7941528ee: the draft request carries the cadence the card shows, a model proposal without a stop condition inherits the sent one, with unit tests and a browser check that compares the card's cap with the SQLite readback. Review round 3 (three supplementary items from the Workbench review conversation, fixed ina1f5ce388): a retried one click reviewed a new proposal and so made a second Goal without a schedule — the proposal of a confirmation that did not finish is kept per card and confirmed again (the daemon is idempotent per proposal); the “自定义” dialog's cadence note kept the prefilled “最多 8 次” after the run cap was cleared — it is now the wording of the schedule object the create button creates and says “不自动停止” when nothing stops the loop; the goal-draft README read followed a symlink out of the allowed workdirs — it resolves the real path and reads only inside them. Review round 4 (fixc3644b3d2): the README link test wrote its fallback asreadme.md, which on a case-insensitive filesystem (macOS) is the same entry as theREADME.mdlink to the file outside the allowed workdirs — the fallback isREADMEnow, the guard unchanged; and a kept proposal is confirmed only for the workspace it was reviewed for — a starter clicked in another workspace drafts and reviews again. Known limits: the goal-draft prompt is not recorded in hub history but stays in the adapter's own session store, same as the discovery refinement; at phone width the created row truncates the title (“调整” stays visible); the daemon's schedulelabelis Chinese, so the web words cadences itself for the other languages; the candidates the daemon's rules produce (title, evidence, objective) are Chinese and the optional model refinement follows the model — wording the rules per language needs a daemon-side locale decision and is a follow-up, as is showingmaxRuns/endAt/runCounton the Schedules page (the daemon enforces the limits regardless).Validation
eded3f2c480efdd1e17e0b91ae992c5f01124790(GitHub update-merge ofmain56afaef2397499739a9ecc58d01976bc8809d8a2on top of9b482d152eee270d7f20acc4f7e18001347c7d6d, two merges ofmaininto8dc1de28f…; the first, ofa11d83a75…, had one conflict, inApp.tsx—mainwrapped the conversation inControllerConversation(Attach Workbench to the original C1 Controller Turn #10114) and this branch gives the empty state itsempty-loop-startclass and the starters, both kept;8dc1de28f…is the GitHub update-merge onca2b812c81227a16ddba2976efd89910043c2a27, the merge ofmain8786693af…on top of the review-round-4 fixc3644b3d2006de378730a44d00efe862aa40b648, which sits ona3dfb72a2…— the merge ofmain4d190e2c7on top of the review-round-3 fixa1f5ce388…). The suites, the pre-merge gate and the browser run were re-run onb3d242bbc…(the merge ofa11d83a75; the later commits bring onlymain's Python changes — fix(antigravity,lark): harden transient continuations, detached tasks, and busy-cascade topic lanes #10173 and Keep dual-mentioned Lark group requests on one worker and reply in place #10054 — and nothing underapps/workbenchdiffers), the focused browser specs and the pre-merge gate again on the final revision, with the counts below; the captures below were taken ona3dfb72a2(the later commits change a test's file name, a retry condition and merges ofmain).staticpassednpm --prefix apps/workbench run typecheck(all workspaces) andnpm --prefix apps/workbench run build;git diff --check origin/main...HEADclean. ruff / mypy / pytestnot_applicable: no Python changes.unitpassed@loopx/loochat-web806/806 incl. the newtest/loop-one-click.test.ts(static fallback on reject / 503 / malformed, no request without a workspace, cadence wording and bounds in each language, the draft request carrying the card's cap and the weekly candidate enabled with 8 on a rules stub, a retried click confirming the same proposal and a kept one left behind when the agent, permission or workspace changed, the cadence note without a stop condition in zh / en / ja) andtest/loop-discovery.test.ts;@calli/ext-board43/43;@calli/ext-loopx4/4; e2e runner 30/30.unitfailed@loopx/loochatfull daemon suite: 1584 tests, 1559 pass, 22 skipped, 3 fail (two auto-join discovery tests, git traversal rejection) — environment-dependent failures that also fail on base07a41a872without this change (five fail there; the other two pass on this head, which carries the latestmain), none in the touched files; the discovery, goal-draft and schedule suites pass (the five files of the automated review's targeted run: 55/55).integrationpasseddaemon/test/loop-goal-draft.test.ts(6): malformed bodies refused before any model is asked; no configured agent → the static draft, bounded; the configured agent rewrites the texts and corrects the cadence with the workspace and evidence in the prompt; a model that fails, times out or overreaches (minute-step cron, more than 100 runs) hands back the static draft; an explicit cap is kept on the rules path and a model proposal without a stop condition inherits the cap that was sent; served POST-only behind the hub token with the prompt not recorded; a README that is a symlink to a file outside the allowed workdirs is neither read nor handed to the model (the next README name in the folder is read instead), one that links inside the workdir is.daemon/test/loop-discovery.test.ts: the real read-only subprocess + JSON transport against a syntheticlark-cliexecutable, a real git subprocess on a temporary repo, independent degradation (missing CLI, not logged in, workspace guard, source timeout), dismissal persisted across SQLite reopen, optional model refinement with fallback, an existing Goal registered through a one- and two-level symlink deduplicated (and not over-matched for a vanished directory).real_entrypointpassedlark-cliand LoopX Core stubbed at the browser route layer; the daemon's/api/loopx/discoverand/api/loopx/goal-draftroutes are real: 39/39 checks over desktop 1440×1000 and phone 390×844 in light and dark — starters without horizontal overflow, each with its cadence and “自定义”; one click on a template → schedule read back bound to the new thread (mode: same, cron0 10 * * 1-5,maxRuns20,enabled,runCount0) when goal-draft answers 500 (static draft), when no agent is configured, and with the model (0 9 * * 1-5,maxRuns5); one click on the weekly meeting candidate (0 18 * * 4): with goal-draft down (static draft) and with no agent configured (rules draft) the cap is parsed from the card text (“最多 8 次”), the draft request is checked to carry it, and the schedule read back from the daemon's SQLite hasmaxRuns8 — the same check fails on the previous head with 20; with the model, its cadence (0 9 * * 1-5, 5 runs); the created candidate leaves the list; “调整” opens the Goal thread; “自定义” / “先调整” open the prefilled dialog; “忽略” and cancel create nothing; with the run cap cleared the “自定义” dialog's note reads “每周一 10:00 · 不自动停止” and its create button stays enabled; a one click whose apply reply is dropped after the daemon applied it shows the failure on the card and leaves one Goal thread and one schedule, and the next click confirms the same proposal (reused: true) — no second thread, no second schedule — the same check fails on the previous head in all four viewports with a second Goal thread; 0 page errors; no goal-draft prompt in hub events; a scan of the daemon data dir (45 files) found no raw signal bodies, calendar or chat ids, or commit titles.regression_paritypassed07a41a872vs head: the daemon suite's failing names are three of base's five (the other two were fixed onmainsince). The repository's focused browser specs (goal-board,goal-confirm,loopx,main-conversations,native-goals,schedule-edit-cron,schedules): 13/17 in the full run on this head (14/17 onca2b812c8), 14/17 on base4d190e2c7. Three fail on both (legacy Goal deep links, steward reader reload, Goal-confirm cancel draft — the last since base removed the composer's LoopX toggle in67a73a177without updating that spec). A fourth,goal-board"eight Core Goals with no Workbench bindings keep their reader and hide the board shortcut", counts the sidebar's rows in the same tick the steward overview appears (0 !== 5when they have not rendered yet): on this machine it passed 2 of 7 runs ona3dfb72a2, 3 of 4 on the previously approved head7a9df571c, 6 of 6 on base, 2 of 8 onca2b812c8; in the full runs it failed on this head and passed onca2b812c8, and it passes whenever one more round trip precedes the count — the same five rows are listed. Timing-sensitive, no difference in what is rendered; the spec is outside this PR's bounds.manualpassedreal_backendnot_runlark-cliexecutable and a route-level Core stub; installed deployment and live paid LLM providers not exercised.python3 -m loopx.cli canary premerge --from-git-diff --git-diff-base origin/main→status: passed,merge_gate_passed: true(direct checks 4/4, catalog canaries 6/6). The vocabulary drift canary needs the repository npm dev dependencies installed once (npm ci --ignore-scripts).Frontend / Visual Evidence
07a41a872— v1-01 desktop light, beforea3dfb72a2— v2-01 desktop light, starters with cadence · v2-02 phone light, starters · v2-03 desktop dark, starters · v2-04 desktop light, created after one click · v2-05 desktop light, candidates with one-click controls · v2-06 desktop light, created from a candidate · v2-07 phone dark, created from a candidate · v2-08 desktop light, “自定义” dialog · v2-09 desktop light, “先调整” dialog · v2-10 phone light, created from the weekly candidate with no draft model · v2-11 desktop light, “自定义” dialog with the run cap cleared · v2-12 desktop light, a reply lost on create · v2-13 desktop light, created by the click after the lost replya3dfb72a2, packaged local Workbench build (apps/workbench/packages/web/dist+packages/daemon/dist) from this branch, synthetic workspace and fixtures; no preview link (not deployed).--loop-pill-mist-*,--loopx-blue,--loopx-blue-soft,--loop-kbd-focus,--danger); no new raw hex.Type of Change
LoopX Area
Technical Direction
Shared-authority RFC fixture impact
N/A — no TypeScript control-plane migration or shared Goal Authority change.
Boundary Checklist
.loopx/,.codex/goals/, and liveACTIVE_GOAL_STATE.md).python3 scripts/check_rfc_bilingual.py --base origin/main --head HEADpasses, or no paired RFC changed.none.Signed-off-bytrailer (git commit -s).