diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/00-audit.md b/docs/dev-loop-runs/2026-12-01-tool-system/00-audit.md new file mode 100644 index 00000000..96090df3 --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/00-audit.md @@ -0,0 +1,297 @@ +# M1 Tool 系统逐项复核 + +日期:2026-12-01(Asia/Shanghai)。基线:`a91f6435c5811d970d3cecdc316b5bfb8f434d31`,已从用户指定的 `LofiSu/LofiBot` 拉取 `origin/main` 核对。本文是修复前的审计,不是修复完成报告。 + +## 结论 + +问题不只是代码组织松散。已实际复现跨 Worker 修改 job、取消后继续执行、重复 call ID 执行两次、参数错误进入执行器、未发现 MCP 工具被调用、MCP 文本资源绕过落盘脱敏,以及 trace 掩盖失败和丢失工具目录。 + +另有明确的产品语义问题:`start_job` 和 `spawn_team` 不执行输入任务,到时直接标记成功;`create_worker` 只记日志。现有测试把计时器完成作为成功标准,不能证明这些工具完成了真实工作。这是设计契约缺陷,不应伪称为某次变更引入的回归。 + +用户附件中的结论不能全部照收。Runtime 已拒绝非法 follow-up 日期;PR/fill 已有精确且一次性的审批绑定;LocalEnv 已拦截测试中的 `../` 与 symlink 文件读取。Browser SSRF 尚未证明可利用;MCP SDK 也不是永不取消、无限接收单包。 + +没有证据证明远程任意代码执行、任意文件读取、真实付款/邮件重复发生或 PR/fill 审批被绕过。因此不使用附件的“五项 P0”作为已证实严重度。 + +## 方法与边界 + +- 主审计加三个独立的只读专项审计:工具调用与 MCP、job/队列/模型协议、执行与审批边界。 +- 使用真实 TypeScript 实现、临时 SQLite、脚本模型、fetch stub、本地 stdio MCP fixture、真实锁定版本 OpenTelemetry SDK 和内存 exporter。 +- MCP 副作用仅为 fixture 的本地时间戳记录;未联系实际外部 MCP、真实模型、真实浏览器 driver,未发送邮件/发布 PR/操作生产数据。 +- 已安装工作区锁文件依赖:`pnpm install --frozen-lockfile --ignore-scripts`,exit 0,版本未修改。 +- 证据脚本的 exit 0 表示“审计断言和复现成功”,不表示产品正确或问题已修复。 +- 本文不宣称完整测试套件、coverage 或生产验收通过。 + +## 现有调用链 + +```text +Runtime.create + └─ ToolRegistry(deps) + ├─ 内置 tools.ts: ToolSpec + roles + run + ├─ memory/tools.ts: 单独拼接和分发 + └─ MCP: 单独拼接和按名字前缀分发 + +runTurn + ├─ specsFor(role, sessionId):每 turn 一次 + ├─ model.complete(messages, tools) + │ ├─ HttpOpenAI:转换 function tools;JSON.parse 参数后直接断言类型 + │ └─ HttpAnthropic:已有 input object 检查和响应内 call ID 去重 + ├─ 对模型参数脱敏 + ├─ tool.invoke trace(仅位于 loop) + ├─ ToolRegistry.invoke + │ ├─ restricted 当前权限检查 + │ ├─ memory / MCP 快速分支 + │ └─ 内置角色检查 → handler → EnvPort / role ports + └─ 结果或 {error: string} → journal → 下一个模型步骤 +``` + +参考:`src/runtime.ts:2007`;`src/harness/tools.ts:121,152,189`;`src/harness/loop.ts:1179,1203,1259`;`src/harness/model.ts:368,393,578,618`。 + +当前有 35 个内置名字定义在 tools.ts,另有 memory、memory_transcript,共 37 个。MCP 另外增加。角色、配置、session 和 restricted 权限决定可见集合;源码名字总数不等于某一运行进程的可用工具数。 + +## 已复现的优先问题 + +### B01 — 未验证 schema,错误参数进入执行器(P1) + +位置:`src/harness/tools.ts:107,189,639,654`。 + +`bash({command:{oops:true}})` 被 `String()` 转为 `[object Object]` 后传给 EnvPort;`write_file({path:'existing.txt'})` 把缺失 body 转为空字符串传给写入层。后者可能清空已存在文件,不只是错误信息不好看。复现使用可计数 stub executor,没有触碰真实文件。 + +通用 schema 没有 required,允许额外字段;执行入口没有验证类型、必填、嵌套结构。MCP inputSchema 也只做类型断言。具体 handler 的 ACL、路径、审批检查仍然有价值,但不能代替输入验证。 + +证据:`artifacts/main-repro.txt`。修复要求:在任何 handler/I/O 运行前验证,禁止隐式类型转换;错误只返回字段路径和受控码,不回显参数值。 + +### B02 — OpenAI 接纳非对象 args;重复 ID 可执行两次(P1) + +位置:`src/harness/model.ts:393–397`;`src/harness/loop.ts:1217–1282`。 + +实际 HttpOpenAI.complete 接纳 JSON `null`、`[]`、字符串和数字作为 ToolCall.args;重复 `id:'same'` 的两条调用也都保留。实际 runTurn 对重复 ID 调用计数 executor 两次:`sideEffectCount=2`,journal 中两条 resultEntries 都是 same。 + +这证明同一次响应没有调用身份完整性防护;不表示给任意 shell 自动加一个 ID 就能实现外部 exactly-once。Anthropic 同一响应的这些输入已经受防护,不能泛称所有 provider 都有同样 parser 缺陷。 + +证据:`artifacts/main-repro.txt`、`artifacts/jobs-output.json`。 + +### B03 — stop_job 跨 session/ticket 修改状态(P1) + +位置:`src/harness/tools.ts:928–935`;`src/store/sqlite.ts:1384–1388`。 + +worker_attacker 调用 stop_job,实际把 worker_foreign/ticket_foreign 的 job_1 改为 stopped。handler 没有 ctx,也不检查 owner。不存在的 job 也返回 stopped。 + +不能靠 job ID 难猜保证权限;当前 ID 还是递增格式。需要 session/ticket 双重所有权检查,存在性、状态和真实取消结果必须一致。 + +证据:`artifacts/main-repro.txt`。 + +### B04 — stop/complete 后,排队或恢复的 continuation 仍执行(P1) + +位置:`src/harness/loop.ts:854,875–887`;`src/harness/tools.ts:932–935`。 + +占住同 session 的队列,等待 timer 写 job_completion,再 stop_job,最后释放队列:工具返回 stopped,但 DB 仍 succeeded,JOB_DONE 仍执行。原因之一是 timer 已标记 succeeded,而 completeJob 只更新 running;另一个是已排队闭包没有在执行前重查取消。 + +另外两个复现:stopped row 加持久 job_completion 后 scheduleJob 仍执行;complete_team 发生在成员 completion 已排队后,也无法阻止 TEAM_MEMBER_DONE。 + +timer 触发前、没有 pending 的停止已有保护。修复不能简单删除 pending 恢复逻辑,否则会破坏正常 succeeded-but-undelivered 的恢复。 + +证据:`artifacts/jobs-output.json` 中 queuedStop、persistedStoppedPending、queuedCompleteTeam。 + +### B05 — Team 与 Job 两份终态互相矛盾(P1) + +位置:`src/harness/team.ts:145–177`;`src/harness/tools.ts:928–935`。 + +stop_job 停止成员后:job=stopped,member=running;再 completeTeam 后:job=stopped,member=succeeded。两个状态源分别更新,没有同一事务和一致的状态机。 + +应由真实执行记录决定终态;team 是其聚合。complete_team 不能通过改缓存制造成功。 + +证据:`artifacts/jobs-output.json` 的 teamStopMismatch。 + +### B06 — 工具“成功”与真实能力脱节(P1 产品正确性 / P2 可用性) + +位置:`src/harness/tools.ts:335–342,484,854–884,1328–1338`;`src/harness/loop.ts:843–899`;`src/harness/team.ts:161`。 + +- create_worker:只记日志,返回 engine-assigns。名字应退出模型表面,真实派工用 dispatch_work。 +- start_job:只收 name,不收任务/命令;计时器直接把 job 标记 succeeded。 +- spawn_team:成员 job 都挂父 session;计时器写固定 report='member done',没有独立成员工作执行。 +- complete_team:可把未完成成员直接标成功,这是当前实现语义而非任务执行证据。 +- 不配置 teams/publisher 时,仍公开 spawn_team/team_status/complete_team/publish_feature_pr,调用才失败。 +- nudge callback 缺失仍返回 nudged;dispatch_work 可在 launchWork 缺失时返回派工结果。默认 Runtime.create 始终注入这两个 callback(runtime.ts:2053,2061);缺 callback 是自定义 ToolRegistry 配置缺口,不是默认生产 Runtime 必现。dispatch_work 缺 callback 未单独构造完整派工复现。 + +现有 team-harness 测试明确断言固定 member done,job 测试明确断言到点成功。测试是绿的,产品承诺却没有被验证。 + +证据:源码、`artifacts/main-repro.txt`、现有 `test/job.test.ts`、`test/team-harness.test.ts`。 + +### B07 — MCP 未发现工具照样到达 server(P1) + +位置:`src/harness/tools.ts:214–218`;`src/harness/mcp.ts:145–160`。 + +真实 fixture 的两次 specs 都为空,invoke(mcp__fixture__unlisted_delete,{}) 仍到达 handler。fixture 仅回显名字,没有执行 delete。入口只检查 role/server 前缀,不检查 discovered set。 + +配置 server 不应隐式等于允许尝试 server 的任意方法。目录刷新和调用再授权需要共用同一份允许集合。 + +证据:`artifacts/mcp-results.json` 的 discovery-cache-and-unlisted;对应原始协议日志。 + +### B08 — MCP host 超时后,实际副作用仍可能发生(P1,取决于启用工具) + +位置:`src/harness/mcp.ts:102,159–172`。 + +timeoutMs=60:host 约 61–62ms 返回普通超时错误,返回时无 cancellation。250ms fixture 在 252ms 记下副作用;1300ms fixture 在约 1061ms 收到 SDK cancellation,忽略通知后 1301ms 仍记下副作用。 + +SDK 确实会在其 timeoutMs+1000 的期限发送取消,不应说“完全不会取消”。问题是 host 截止时间没有同步取消、结果没有 unknown 语义。停止等待、发送取消、杀本地进程、撤销外部操作是四种不同保证。不能把超时当作可安全重试的普通失败。 + +证据:`artifacts/mcp-results.json` 的 timeout-250/1300,`artifacts/mcp-case-1/server.jsonl`、`mcp-case-2/server.jsonl`。 + +### B09 — MCP 部分发现永久缓存;list_changed 后 schema 陈旧(P2) + +位置:`src/harness/mcp.ts:140–142,219–240`。 + +首次 tools/list 超时后,等 server 恢复,第二次 specs 仍为空,协议只有一次 list。另一个 fixture 更新 value:string 到 value:number 并发送 tools/list_changed,第二次 specs 仍旧,旧参数继续被发送。 + +已证明缓存陈旧和通知不生效;没有验证 server 重启后的自动重连。仅加本地 hash 不能强迫外部 server 在调用时使用旧语义,需要刷新、撤销规则及 server 配合的版本协议。 + +证据:`artifacts/mcp-results.json` 的 discovery-cache-and-unlisted、schema-snapshot-and-name。 + +### B10 — MCP 文本 resource 原文落盘,返回值脱敏为时已晚(P1) + +位置:`src/harness/mcp.ts:272–275,289–294`。 + +配置将 TOKEN_AUDIT_SENTINEL 替换为 [redacted] 的 redact,resource.text 文件仍保存原文。ToolRegistry 只脱敏返回对象,不会反向修改文件。umask022 时文件0644、目录0755;是否其他用户可读还取决于父目录权限,未证明跨用户泄露。 + +文本应按存储策略先脱敏后写;二进制不能盲目字符串替换,应使用私有存储和明确访问策略。 + +证据:`artifacts/mcp-results.json` 的 resource-redaction-and-permissions。 + +### B11 — MCP 资源配额与存储约束不足(P2;带前置条件的边界问题) + +位置:`src/harness/mcp.ts:265–275,289–294`。 + +三次合法响应各写 7MiB,共22,020,096字节,无累计配额/生命周期;ASCII A 字节可声明 image/png 并写成 png。预置 workspace/fixture 指向 outside 的 symlink 后,UUID文件写到了 workspace 之外。 + +symlink 前置条件是本地同用户有目录控制;stdio server 本来已有 owner OS 权限。这不是“纯远程任意路径覆盖”的证明。MIME 不匹配也未证明文件执行/XSS。 + +附件的“单包无限”不成立:锁定 SDK 默认10MiB消息缓冲上限,11MiB decoded payload 在实验中被 Connection closed 拒绝。adapter 仍应增加更小的 artifact 限制、累计配额、私有权限和 symlink 防护。 + +证据:`artifacts/mcp-results.json` 的 binary-size-and-type、symlink-artifact-escape、sdk-oversize-message。 + +### B12 — LocalEnv 输出字节契约与 UTF‑8 解码错误(P2) + +位置:`src/env/local-env.ts:205–209`。 + +maxOutputBytes=10 时中文输出实际42字节:内容30字节、标记12字节。实现按 UTF‑16 length 截断,不是 UTF‑8 bytes。它仍有有限上界,不能夸大成无限内存泄漏。 + +将“你”的三字节拆成两个 stdout chunk,实际得到三个替换字符。每 chunk String(buffer) 导致解码丢失。stdout/stderr 都需要独立 decoder、字节预算和截断语义。 + +证据:`artifacts/boundaries-output.jsonl`。 + +### B13 — Trace 把模型失败与 shell 失败显示为 OK(P2 调试正确性) + +位置:`src/harness/loop.ts:1207–1213,1269–1271`;`src/harness/tracing.ts:127–140`。 + +真实 SDK 与 InMemorySpanExporter 复现:model.complete 抛错时 child status=ERROR(2),agent.turn=OK(1) 且没有 model_failed outcome。bash 返回 code1 时 tool.invoke=OK,只有打开 output 才知道失败。达到 maxSteps 也没有结构化终态。 + +SDK span OK 可以仅表示函数正常返回,但当前没有额外业务 outcome,UI 很容易把它解释成任务成功。应保留 transport/handler/business/turn/task 的区别,而不是把所有错误都粗暴抛出。 + +证据:`artifacts/main-trace-repro.txt`。 + +### B14 — Trace 的输入预算会挤掉工具列表(P2) + +位置:`src/harness/tracing.ts:18–57`;`src/harness/loop.ts:1203`。 + +整个请求共享256次访问和16KiB预算,messages 在 tools 前。使用原始 capture 代码与64条短消息、20个工具,实际只保留12个名字;消息各500字符时20个全部不见,只剩 preview。保留数量取决于输入结构,不是固定阈值。 + +这只影响 trace,不说明模型实际没有拿到 tools。修复应单列有效 tool 名单、计数、schema digest;历史内容用独立预算,明确截断。 + +证据:`artifacts/main-trace-repro.txt`。 + +### B15 — 调试事实不完整,不能用局部 trace 解释整个任务(P2 缺口) + +位置:`src/runtime.ts:3568`;`src/harness/loop.ts:1266`;`src/harness/tracing.ts:76–88,136–151`。 + +- deferred publish 直接 tools.invoke,绕过只放在 loop 中的工具埋点。源码已确认缺口,未执行真实发布来验收。 +- 全部 span 叫 tool.invoke,真实名字在属性;没有 turn/step/trigger 的完整因果数据。 +- 原始异常不导出是正确的保密策略,但连受控错误码/阶段也没有,只有 ERROR 难以诊断。 +- tracing 请求启用但配置/依赖失败可静默返回 undefined。根工作区曾缺 SDK;隔离工作区按 lock 安装后初始化正常。依赖未安装不是必然产品 bug,静默无诊断是产品缺口。 +- intake、后台 memory、visible stream、Outbox、外部 driver 不在当前 trace 范围;docs/PHOENIX.md 已声明,不能当作这些功能从未运行的证据。 +- desktop timeline 并非 Phoenix viewer;只修 exporter 不会自动补桌面的 tool-start/result 展示。 + +## 对用户附件全部事项的裁定 + +“确认”含代码证实和动态证实;具体证据强度见上文。P0/P1 等左列编号沿用附件,右列结论不沿用其严重度。 + +| 附件项目 | 裁定 | 说明 | +|---|---|---| +| P0-01 统一 schema validation | 确认缺陷 | B01;不能由此直接推导路径穿越 | +| P0-02 timeout/cancel | 部分成立、已复现 | B08;SDK会延迟取消,外部结果仍未知 | +| P0-03 MCP文件资源安全 | 部分成立、已复现 | B11;有SDK单包上限,缺累计预算/类型/路径防护 | +| P0-04 Browser SSRF | 未证实利用 | 页面网络在owner driver;host allowlist不是网络防火墙 | +| P0-05 Approval绑定 | 泛化结论不成立 | 通用card只hold;PR/fill已有exact binding/one-use | +| P1-01 stop_job ownership | 确认缺陷 | B03 | +| P1-02 stop_job cancellation | 确认缺陷 | B04,精确到pending/dequeue窗口 | +| P1-03 follow-up日期 | 生产路径已有防护 | runtime.ts3316–3327拒绝NaN/过去/太近;工具边界可改善 | +| P1-04 MCP discovered set | 确认缺陷 | B07 | +| P1-05 resource文本脱敏 | 确认缺陷 | B10 | +| P1-06 discovery不重试 | 确认缺陷 | B09 | +| P1-07 schema snapshot | 确认陈旧缓存 | B09;不能仅加hash就保证远端语义不变 | +| P1-08 输出bytes | 确认缺陷 | B12;附带UTF8乱码 | +| P2-01 required | 确认契约缺失 | B01 | +| P2-02 execution policy | 设计建议 | 可统一元数据,不能取代各执行器实际边界 | +| P2-03 全串行 | 设计选择 | 无并行本身不是bug;应先保证副作用和审批顺序 | +| P2-04 通用幂等 | 设计边界 | 不可为任意shell/外部服务承诺exactly-once | +| P2-05 artifact生命周期 | 确认设计缺口 | B10/B11;现有文件可读性与引用还需兼容 | +| P2-06 turn快照固定 | 稳定性选择 | invoke有再次权限检查;不是单凭旧spec就可越权 | +| P2-07 结构化错误 | 确认设计缺口 | B08/B13/B15,unknown不能表现成可重试失败 | +| P3-01 tools.ts太集中 | 维护性建议 | 拆文件不能替代修正执行契约 | +| P3-02 stderr忽略 | 确认诊断缺口 | mcp.ts194–202;必须bounded/redacted再记录 | +| P3-03 description注入 | 信任风险、未复现利用 | 描述直传;系统prompt已有外部内容不可信规则 | +| P3-04 sync I/O | 资源/响应性风险 | readFile无尺寸上限;未跑大文件压测,不声称已发生OOM | +| P3-05 metrics | 观测设计建议 | 当前没有统一工具维度统计 | +| 额外1 array.find | 优化建议 | 当前几十项不是主要性能瓶颈,Map有利于冲突检测 | +| 额外2 provider工具名 | 确认兼容性缺口 | 113字符带点名字原样暴露;未验证live provider拒绝 | +| 额外3 context budget | 设计风险 | 单结果和条数限制不等于全turn token预算;与PR274协调 | + +### 已有保护的实测反证 + +- follow-up:NaN、过去、未来1秒均被 Runtime 拒绝;未来2分钟可调度。 +- Anthropic:null/array/string tool input 拒绝;同响应重复ID只保留一条。 +- LocalEnv:`../outside` 与 symlink 文件读取拒绝;不能把MCP artifact写路径问题套到LocalEnv。 +- PR/fill:已有精确绑定、一次性消费和unknown拒绝重放;相关30项现有测试通过(另有7项LocalEnv symlink测试),未发现绕过。这不是对任意攻击的形式证明。 +- restricted:invoke会重新检查持久权限,现有定向测试覆盖并通过;保留这一点。 + +## 已运行检查 + +新增安全契约复现命令: + +```sh +node --import tsx docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-contracts.mjs "$PWD" +``` + +实跑 exit 1:5项契约全部失败,包含非法bash参数、缺body写入、跨worker停止、未知MCP执行和无依赖仍公开工具;stub执行器实际被调用2次,MCP stub被调用1次。`artifacts/main-contracts.txt` 保存红灯结果。这是预期在修复前失败、修复后通过的反馈环,不是把漏洞复现exit0误当成回归通过。 + +```sh +pnpm run test test/mcp-config.test.ts test/mcp-registry.test.ts \ + test/mcp-invoke.test.ts test/mcp-source.test.ts test/mcp-runtime.test.ts \ + test/restricted-tool-permissions.test.ts test/fill-tools.test.ts \ + test/publish-feature-pr-tool.test.ts test/tool-spec-schema.test.ts \ + test/job.test.ts test/team-harness.test.ts test/phoenix-tracing.test.ts \ + test/phoenix-harness.test.ts --no-file-parallelism +``` + +结果:13 files passed,89 tests passed,11.80s。完整输出:`artifacts/main-existing-tests.txt`。 + +独立边界检查:fill、publish、local-env-symlink,3 files / 37 tests passed(其中fill/publish与89项有重叠,不相加)。输出:`artifacts/boundaries-tests.txt`。 + +首次 `pnpm test ... --no-file-parallelism` 被 pnpm 自己的参数解析拒绝,未执行测试;改为上述 pnpm run test 后才通过。未将失败命令算为通过。 + +原有测试通过与复现出缺陷并不矛盾:测试缺少未知MCP调用、重复call ID、非法参数执行前拒绝、pending后的取消窗口和真实成员执行断言。 + +## 复现材料 + +原始运行目录:`/private/tmp/lofibot-tool-audit/`。本目录 artifacts 保存脚本、结果和MCP原始协议快照,避免临时目录清理后丢证据。脚本中的固定工作区/临时目录是本次审计上下文,详见 `artifacts/README.md`。 + +不提交真实凭据、实际用户数据或生产副作用。所有 sentinel 均为人工测试字符串。 + +## 修复顺序与退出条件 + +1. M1 调用边界:schema/envelope/重复ID/统一catalog和invoke授权;stop_job owner检查。先写能在本基线上失败的回归测试。 +2. M1 Job/Team:真实执行与completion状态分离,取消覆盖timer前、pending后、dequeue前、运行中、重启;移除假成功。 +3. M1 MCP/M2 存储:发现刷新、未知结果、取消、私有与受控artifact;保留已有审批/ACL边界。 +4. M1 Trace:在executor边界记录真实执行,安全错误码、outcome、工具目录独立预算;通过真实runTurn与deferred执行测试。 +5. M9 输出:字节预算、StringDecoder、文件读取上限。 + +每一项都需要实现证据、回归测试、独立审查、PR状态和集成验证。当前仅完成审计;没有修复代码、没有声称全套门禁或集成完成。 diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/01-design.md b/docs/dev-loop-runs/2026-12-01-tool-system/01-design.md new file mode 100644 index 00000000..29130ff2 --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/01-design.md @@ -0,0 +1,184 @@ +# M1 工具系统重新设计(待 owner 审阅) + +日期:2026-12-01。依据:同目录 `00-audit.md`,main a91f643。范围:M1 Harness 工具契约、M9 Env 执行/输出、M2 Store 执行记录,以及它们与 M3 Engine/M6 Memory/M8 Channels 的既有边界。 + +本文是可审阅方案;尚未实现,也没有宣称部署/合并。目标不是把所有能力搬进一个万能对象,而是让“模型看到的工具、调用时允许的工具、实际执行和审计事实”一致。 + +## 方案选择 + +| 方案 | 收益 | 代价/问题 | +|---|---|---| +| 原文件补丁 | 最快挡stop_job和坏参数 | 分支式memory/MCP、假job、trace遗漏仍会反复漂移 | +| 统一契约与执行入口,保留领域执行器(推荐) | 一份目录生成spec/诊断;一个入口负责验证/授权/记录;保留已证明的ACL和审批 | 需要分阶段迁移和回归测试,尤其job与恢复 | +| 全新插件/远程执行平台 | 可彻底替换旧实现 | 迁移过大,新增网络与进程边界,无法靠当前证据合理化 | + +选第二种。以小PR逐项交付,不混入 UI 重写、连接器功能或上下文工程PR274的重构。 + +## 必须达到的行为 + +1. `lofibot tools --role worker --json` 能回答该进程有哪些工具、何时不可用、为什么受限、属于哪个模块/来源;不是静态名字清单。不探测服务时显式说明discovery未运行;显式发现模式才启动owner配置的MCP子进程。 +2. 给模型的目录与调用允许集合来自相同catalog;执行时再检查当前权限和依赖,旧spec不能授权新调用。 +3. 所有provider、memory和内置工具接受同样的输入边界;非法schema/未知名字/重复call身份在副作用前拒绝。 +4. 无依赖不公开可执行工具;没有真实执行不能标任务成功;不存在的job不能返回已停止。 +5. 停止覆盖排队、执行和恢复;无法证明停止的外部动作明确为unknown/cancel_requested。 +6. trace显示真实tool、step、结果、错误码和因果ID;打开trace能判断是在等审批、工具失败、达到预算还是完成。它不能凭span OK宣称领域任务成功。 +7. 保留现有memory ACL、speculation隔离、精确PR/fill审批与restricted持久防降级检查。 + +## 分层与调用路径 + +```text +ToolProvider(builtins / memory / MCP) + ↓ definitions + availability +ToolCatalog → snapshot/version → provider spec / CLI diagnostics + ↓ resolve +ToolExecutor + envelope/identity → current authorization → validate input + → claim execution → handler → normalize outcome → durable receipt + → journal / trace(同一份执行事实) + ↓ +RolePorts / EnvPort / Memory ACL / MCP adapter + ↓ +Engine / OS / owner-configured external server +``` + +`src/harness/tools.ts` 保留兼容facade,现有import逐步迁移。新实现位于 `src/harness/tools/`: + +- `types.ts`:定义、调用身份、结果、错误码和安全元数据。 +- `catalog.ts`:合并provider、重名检测、availability和snapshot。只发现与解释,不执行。 +- `validation.ts`:schema编译/缓存和安全错误转换;不做类型强转/default注入。 +- `executor.ts`:所有模型调用和host deferred调用的唯一入口。 +- `builtin/{router,worker,watchdog,approval,vault,browser,delegation}.ts`:按领域拆handler;不复制Engine逻辑。 +- `memory-provider.ts` / `mcp-provider.ts`:将原有快速分支纳入相同契约。 +- `audit.ts`:把执行事实映射到trace/journal,collector故障不阻止业务。 + +M9仍拥有shell/文件/浏览器适配;M3是领域状态唯一写者;M2负责事务/执行receipt;M6仍拥有记忆授权与数据模型。此改造不扩大模型权限。 + +## 唯一工具定义与目录 + +每个定义包含:`id/name`、module、source、description、roles、inputSchema、effect类别、`availability(context)`、handler以及实现支持的执行能力。执行能力声明例如supportsAbort、idempotencySupport,不能把仅有timeout配置冒充可取消。 + +effect为只读、本地写、领域变更、外部副作用或unknown;MCP默认unknown,server annotations只是提示,不能作为可信授权。策略显式决定是否允许,默认不因annotation而自动重试或并行。 + +目录区分 available、disabled、unconfigured、restricted、discovery_failed,并给受控原因码。给模型只投影available;CLI可看其余原因但不暴露命令环境、token或敏感路径。角色/scope/当前ticket可影响availability,业务handler仍有最终检查。 + +Map按内部ID索引;注册阶段拒绝冲突。MCP保留server原名,provider-facing名称规范化为供应商可接受的稳定别名,超长名字用hash后缀并检测碰撞,反向映射只允许来自本次snapshot的别名,不能猜前缀分派。 + +MCP发现按server保存状态,失败可重试,显式刷新与tools/list_changed更新版本。刷新中的失败不能静默把已撤销工具继续当作可用。调用绑定本地schema digest/version;变化后要求新spec,不悄悄用新schema执行旧请求。不能承诺不配合的server保持远端语义原子性。 + +## 输入验证与调用身份 + +使用直接声明且锁定版本的JSON Schema validator(例如Ajv),不是依赖MCP的传递依赖。内置schema有明确required、additionalProperties:false、enum/范围和嵌套结构。兼容旧members字符串只放在明确的旧版解析入口;新spawn_team使用对象数组,不隐式接受任意格式。 + +MCP支持明确的schema方言;拒绝/标不可用不支持的方言或远程ref,不能静默忽略安全约束。不联网加载schema。限制schema大小/深度和验证资源;不启用任意format代码或不受控regex。编译失败只影响该工具,并在diagnostics可见。 + +所有模型适配器在解析后统一检查非空id/name和plain object args。每次completion的重复call ID整批拒绝,避免执行首个后才发现冲突。executor再次防御,host调用也不能绕过。 + +调用身份是runtime生成的turn/step/execution ID加原始call ID,不是只信任模型字符串。单turn重复身份拒绝;持久执行receipt匹配同一身份与args digest。新turn里同一个短call ID本身不等于重放;deferred审批引用原始执行关系,另有执行attempt ID。 + +外部副作用提交前写running receipt,返回后写结果;崩溃留下unknown。只读或有可靠幂等协议的调用才能按策略重试。不能自动重放unknown shell/MCP动作,也不承诺任意系统exactly-once。 + +## 结果与错误 + +统一内部 `ToolOutcome`:status、data/artifact refs、errorCode、retryable、executionId、duration和有限summary。状态区分 succeeded、failed、blocked、cancel_requested、cancelled、unknown。shell非0是execution_failed并保留exitCode;失败不必抛掉可诊断stdout/stderr。 + +框架拒绝码例如 INVALID_ARGUMENTS、NOT_AVAILABLE、PERMISSION_DENIED、DUPLICATE_CALL、STALE_CATALOG;业务错误码例如 APPROVAL_REQUIRED、EXECUTION_FAILED、OUTCOME_UNKNOWN。错误描述受控且不包含原始参数/exception;模型允许收到的业务解释与trace导出策略分离。 + +迁移期间保留原工具结果payload,旁挂受控状态,避免一次性改坏memory images、Anthropic tool_result.is_error、审批续接与旧journal。版本化新journal事件;旧journal只读兼容。 + +工具执行成功、子Agent结束、领域ticket完成是三个事实;由Engine决定ticket终态,executor不擅自把ticket标成功。 + +## Job/Team:用真实工作替换计时器成功 + +`create_worker` 从模型目录移除;router使用真实dispatch_work。回放历史中的旧tool消息仍可读取,新的create_worker调用返回迁移错误,不返回假成功。 + +`start_job` 必须携带明确task,启动受预算约束的子Worker执行,返回jobId/executionId。子执行拥有独立session、自己的模型循环和journal;继承父ticket授权范围与workspace隔离规则。不得借子session提升到router权限;子执行禁止无限递归start_job/spawn_team。默认串行副作用,有限并发只作用于已定义的独立成员。 + +`spawn_team` 必须给每个成员name/task/role说明;role说明不是运行时权限。每个成员是真实子执行,其工具集合是父范围的子集。运行产生的summary/artifacts可追溯;无执行器时目录不可用,不退回定时假成功。 + +子执行的授权与数据交接作如下明确限制: + +- child session使用host生成的独立ID,禁止复用/伪装父workerSessionId。调用上下文包含host登记的parentExecution关系,由Store查验,模型不能自行填写。 +- 当前memory工具只认可规范父session。此次不通过放宽该检查给child继承所有记忆:child目录不含memory/memory_transcript/read_object。父worker在自身ACL下读取后,仅把任务相关、已脱敏且有来源的片段作为child输入。child结果中的候选记忆由父审核后写入;这是一项明确能力限制,不宣传child已拥有完整记忆。 +- M9为child创建独立WorkspaceLease。父通过有尺寸/数量预算的输入manifest给定文件,由host检查父可读权限、路径和symlink后复制到child;不复制credentials、runtime state、.git或整个owner HOME。不同child不共享可写目录,命令运行受与父相同或更窄的真实sandbox约束。 +- child产出先登记为ticket+execution拥有的artifact,父通过受控读取/显式apply才能写入父workspace;不自动promotion,不接受模型返回的任意绝对路径。不把子目录可写性等同于OS级隔离;缺少所需sandbox时不得宣称其已隔离。 +- speculative父ticket本次不开放start_job/spawn_team,返回受控NOT_AVAILABLE;避免现有仅settle父session的逻辑遗留child scratch。将来开放需另行设计整个workspace lease树的promotion/discard,不能在本次隐式开启。 +- 父结束/停止先原子撤销child lease与新工具调用权限,再传播取消,收集结果后清理临时workspace;子进程未退出不删除仍在用的目录并不返回已停止。进程重启后接管登记的lease清理与unknown记录,不自动重放可能已产生副作用的任务。 + +父ticket级动作(report_to_router、request_approval、订阅、发布)由父worker处理;成员通过执行结果向父返回,不可用共享ticket直接冒充父发报告/授权发布。确需审批时,成员blocked结果由父创建绑定于实际操作的请求。 + +Job持久记录区分ownerSession、executorSession、ticket、task、attempt/lease、执行终态与completion delivery状态。利用M2事务实现CAS:running→succeeded/failed/cancelled/unknown;completion pending→claimed→delivered/cancelled/unknown。claim记录owner进程;回调dequeue时重查lease、取消和ticket状态。若进程在claimed后、delivered前终止,无法证明父turn未产生副作用:保留子任务结果,将delivery标记unknown,并在父session的持久journal中一次性登记带jobId的恢复提示。启动恢复扫描unknown记录,将其作为持久待处理事件投到父任务的状态流,令空闲父任务也能在现有会话中观察并通过read_job_result核实;事件投递与确认须幂等,不能启动新模型turn或重放父turn/完成回调。宿主进程自身在投递前再次退出时,下一次启动继续投递。即使尚无工具回执,也不能把“未观察到副作用”当成安全重试证明。 + +stop_job只允许owner或明确授权父控制自己的成员。queued/pending原子取消并清除待投递;running传播AbortSignal。只有合作执行器确认停止才能返回cancelled,否则cancel_requested/unknown。停止不能把已经成功的结果改写为从未发生;返回already_terminal及真实状态。 + +Team状态从job真实结果聚合;complete_team仅在全部terminal时完成聚合,成员仍运行就返回unfinished,不能制造成功。取消团队显式走成员取消,保留失败与unknown。 + +升级恢复:新版本不把旧timer-only running job恢复成成功;标为legacy execution unavailable并停止自动续跑,要求新任务。旧已succeeded记录保留历史且注明无真实执行证据,不追认成功、不删除审计。迁移以新的schema版本和回归用例实现。 + +## 审批与副作用边界 + +保留PR/fill原有exact binding、durable一次性claim、unknown不重放,逐步将其receipt关联到executor。审批digest必须由host对规范化结构生成,不能信任模型提供digest。 + +通用request_approval明确是协作hold,不宣传为任意bash命令的授权防火墙。需要机器强制授权的操作走有明确执行器的结构化plan;只给shell命令加hash并不能阻止命令借网络、文件或子进程扩大行为。 + +restricted持久策略与执行时检查保留。若希望把默认bash也改为每次审批,这是权限产品行为变更,不能在本次bug修复中暗中引入。 + +## MCP与Artifact + +host deadline与SDK signal使用同一取消控制器,向server发送取消;将已发出且无可靠完成证据的副作用超时标unknown。绝不从“abort已发”推导“外部动作已撤销”。unknown需要核验/owner处理;提供可信幂等key和服务回执时才能重试。 + +MCP结果在解码前限制base64编码长度,解码后限制单artifact尺寸、单call和server累计字节。SDK的10MiB消息上限只作为额外边界,不能代替存储配额。失败清理未引用临时文件;有引用资源不因TTL被删。 + +文本先按策略脱敏再保存;目录0700、文件0600,写入前校验路径与目录身份,不跟随symlink。MIME是声明信息,识别不到真实类型就标unverified,不用后缀当安全证明;不自动执行/渲染活动内容。 + +逐步统一受控ArtifactStore,记录owner ticket/session、大小、声明/检测MIME、hash、引用和保留状态。模型得到artifact ID和有限preview;读取/导出重新检查ACL。保留已有spill的授权,不把本地裸路径当能力。二进制用私有存储,不能为“脱敏”破坏原始格式。 + +MCP stderr使用bounded/redacted尾部buffer,仅用于诊断,不注入模型指令。描述和结果明确为外部不可信元数据,长度受限,权限由owner策略决定。 + +Browser的网络防护仍由实际driver落实;诊断说明owner host allowlist不是firewall。不在未验证driver前声称已经防DNS rebinding,也不无条件禁止owner明确允许的localhost。 + +## Trace与调试 + +executor统一产生tool执行事件,模型循环和host deferred publish都经过同入口,恰好记录一份执行事实。span名用已验证工具名,如tool.bash;拒绝未知模型名时用固定tool.rejected而不创建任意高基数名称。 + +属性至少包含role/session/ticket/assignment/turn/step/call/execution ID、catalog digest、受控outcome、errorCode、exitCode、artifact refs和因果parent/link。tool根据发起它的model step关联,不只是靠列表顺序猜。 + +Turn返回结构化outcome:completed、model_failed、paused、approval_wait、budget_exhausted、cancelled。completed仅表示模型循环正常结束,不等于task成功。错误可恢复时保留attempt failed及最终turn outcome,不能丢失中间失败。 + +有效tool名字/数量/schema digest单独捕获,不与history共用裁剪预算;messages独立预算,优先当前输入、最近步骤、明确截断计数。继续过滤已知秘密、二进制与原始异常。safe errorCode不走全字段error脱敏而消失。 + +tracing状态显示disabled/requested/initialized/export_failed及受控原因;collector不可用不影响工具执行,也不伪称collector已收到。跨进程重启以持久执行ID和因果记录连接,不把JSON载荷里的任意trace parent当可信输入。 + +CLI diagnostics先落地;桌面工具时间线通过现有协议添加版本化start/result/hold事件,与PR276共享前后端工作协调。Phoenix测试与桌面UI验收分开,不能相互替代。 + +## M9输出与资源 + +stdout/stderr分别使用StringDecoder,按实际接受字节预算截断;不把半个UTF8字符flush成误导性内容,截断标记的预算另行明示。保留进程组timeout终止与现有路径/descriptor检查。 + +文件读取先fstat并限额,必要时分段返回/受控artifact,不同步加载任意大文件。不要为了异步化丢失symlink/TOCTOU防护。全turn context预算与PR274对齐,工具只提供可信长度/引用/截断信息,避免两套独立context重写。 + +## 实施分块与验收 + +分块是交付顺序,不是允许只做一半后称完成: + +1. **调用契约与授权**:schema/envelope/duplicate ID、catalog与可用性、stop_job scope,工具诊断CLI。先写漏洞回归再迁移定义。 +2. **Job/Team真实执行**:子session、预算、执行/投递状态机、取消/恢复/旧数据迁移;更新不真实的成功测试与prompt。 +3. **MCP与Artifact/M9**:发现刷新/别名、同deadline取消与unknown、落盘脱敏/配额/路径/模式、UTF8和read cap。 +4. **统一审计与trace/展示**:executor事实、outcome、step因果、独立预算、初始化诊断,CLI及必要的桌面协议联调。 + +四块是工作流,不是四个大PR。每个小PR一个concern,使用独立worktree/分支:调用envelope与身份、内置schema、目录与诊断、job ownership、job执行/恢复、team真实执行、MCP发现/别名、MCP取消/unknown、artifact存储、M9输出、trace事实、桌面协议分别按依赖串行交付。共享文件在前一PR集成后交接所有权;只有同时运行的agent不得重叠文件。现有PR274/276不自动引入或合并。安全边界改动必须独立security review;遵守仓库高风险owner merge gate。 + +关键回归矩阵: + +- 每个role×config×restricted×session的catalog/spec/invoke一致;被拒绝时handler计数为0。 +- 每个内置schema缺字段/错类型/额外字段/边界值;memory/Anthropic兼容。 +- 各provider非法envelope、重复ID、混合合法非法batch;未知tool和deferred host调用。 +- job stop在timer前、pending后、dequeue前、运行中、terminal后、restart;team状态与job一致。 +- 至少两个成员真实执行不同task且输出不同artifact;失败/超限/取消成员不能标成功。 +- MCP迟到响应、忽略取消、动态撤销、发现恢复、schema变更、长名碰撞、超大/重复binary、文本secret、symlink和private mode。 +- 真实runTurn的模型失败、shell非0、审批hold、maxSteps、恢复后的publish;所有路径有唯一executor记录、正确outcome和敏感数据反例。 +- 长history下完整tool manifest仍可见;trace collector失败不影响业务,桌面事件另做验收。 +- UTF8每种字节边界、stdout/stderr合约、read cap与原有路径隔离不回归。 + +PR前本地必须有 `pnpm typecheck`、`pnpm lint`、`pnpm run test --no-file-parallelism` 的真实输出;受影响包构建/coverage与专项检查按仓库CI执行。CI通过和独立review后再按风险进行owner批准/集成;合并后重跑受影响检查。 + +真实外部服务的幂等与取消不能用offline fixture替代证明;完成报告必须分别列出offline、live和未验证边界。本文没有把任意第三方工具的安全性当作本次可保证结果。 diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/02-review.md b/docs/dev-loop-runs/2026-12-01-tool-system/02-review.md new file mode 100644 index 00000000..db9733e9 --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/02-review.md @@ -0,0 +1,37 @@ +# 审计与设计复核记录 + +2026-12-01,main a91f643。仅审计与设计,不是实现验收。 + +## 审计独立复核 + +Reviewer: audit_review,code-reviewer,结论 APPROVE。 + +独立重跑 main-repro.mjs 与 main-trace-repro.mjs,均 exit0,核对核心结论与保存输出一致,37工具计数正确。修正入口引用为tools.ts107/152/189;补明默认Runtime注入launchWork/nudge,缺callback属于自定义Registry配置缺口;补齐artifact重跑README。 + +新增main-contracts.mjs由主审计运行:5项正确行为契约均失败,exit1。原始脚本和失败输出已保存。复现脚本exit0与安全契约exit1不可混为产品通过。 + +## 架构审查 + +Reviewer: design_review,architect。 + +第一轮 REQUEST_CHANGES: + +1. 模块归属错误:M2=Store、M9=Env,不能写成M2=Env/M5=Store。 +2. 子session不能隐式继承父memory与speculative工作区;需要明确授权、输入/产出交接和父终止清理。 +3. 四个工作流不应合成四个过大PR,应逐concern交付,共享文件串行交接。 + +修订:模块归属已更正;child使用独立host身份,memory/read_object不开放,父按ACL提供任务片段;WorkspaceLease与受控manifest/artifact交接;speculative父禁止spawn;父终止撤销lease、传播取消、按真实进程状态清理;重启保留unknown不自动重放。四工作流拆为小PR并按依赖串行集成。 + +第二轮 APPROVE,无新的必须修正项。审查明确:接口与方案本身不能证明实际取消、ACL或sandbox实现正确,后续需要具体回归测试和实现审查。 + +## 本地验证与未完成范围 + +- pnpm typecheck:exit0。 +- 13个定向测试文件:89 passed,exit0。 +- 独立边界3文件:37 passed,与89项部分重叠。 +- pnpm lint首次因sandbox禁止tsx IPC pipe失败;等价执行 `NODE_NO_WARNINGS=1 node --import tsx scripts/lint.ts`,lint ok。最终提交前再次检查新增tracked文件。 +- git diff --check:通过。 +- 未执行完整离线套件、coverage、live模型、真实浏览器driver或生产副作用。 +- 尚未修改运行时源码;无实现PR、无集成验证,所有已复现bug仍存在于基线。 + +下一步为owner审阅01-design.md,随后按技能流程编写实施计划、先锁定失败回归,再逐项实现和独立审查。 diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/03-implementation-plan.md b/docs/dev-loop-runs/2026-12-01-tool-system/03-implementation-plan.md new file mode 100644 index 00000000..21732105 --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/03-implementation-plan.md @@ -0,0 +1,76 @@ +# M1 Tool System Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use subagent-driven-development or executing-plans to implement task-by-task, with TDD and independent review. + +**Goal:** Implement owner-approved 01-design.md and close audit B01–B15 with executable evidence. +**Architecture:** Catalog is the sole discovery/authorization source; executor validates, claims and observes calls. Domain handlers retain ACL/approval checks. Real bounded child executions replace timer-only success. +**Tech Stack:** Node22, TypeScript, pnpm, Vitest, MCP SDK, OpenTelemetry, SQLite. + +## Global constraints + +Owner approved design on 2026-12-02. Implementation base origin/main 49aad78c9f09816be71e1f161790d9f025410d00; audit remains historical a91f643. One concern per PR, no main commits/force pushes/protection bypass. Runtime policies, memory ACL, PR/fill approvals remain enforced. No production restart or external sending. Only root updates state/master plans. Existing PR274/276/278/279 are independent; trace changes must preserve compatible APIs. Every behavior change starts with a failing real-path test. No hidden scope reduction: all tasks remain required until acceptance. + +## File ownership and task order + +### Task A — Tool-call protocol (parallel independent slice) +Files: src/harness/model.ts, src/harness/loop.ts, new src/harness/tool-calls.ts, test/tool-call-protocol.test.ts. Owner protocol implementer in .worktrees/tool-call-protocol. +Interfaces: validateToolCalls(value: unknown): ToolCall[]; throws safe protocol error for malformed/duplicate IDs. Both adapters and runTurn consume it; reject the entire malformed batch before execution. A turn must not execute a repeated call ID on a later step. No global dedup across turns. Preserve valid images/replay and provider conversion. +- [ ] Write fetch-stub HttpOpenAI/Anthropic tests for null/arrays/scalars/empty names/IDs, duplicate IDs, mixed batches; real runTurn fixture counts executor calls and verifies zero side effects for invalid batches. +- [ ] Run pnpm run test test/tool-call-protocol.test.ts and save expected failures under /private/tmp/lofibot-tool-implementation/protocol-red.txt. +- [ ] Implement shared parser/batch validation, apply before journal/tool dispatch, add structured safe error code without raw args. +- [ ] Run focused model, memory/approval replay, Phoenix suites; typecheck/lint/full offline test before PR. +- [ ] Commit scoped implementation and report SHA/evidence; independent review before PR integration. + +### Task B — M9 bounded UTF8 output (parallel independent slice) +Files: src/env/local-env.ts, new src/env/bounded-output.ts if justified, test/local-env-output.test.ts. Owner env implementer in .worktrees/tool-env-output. No approval or file-path behavior changes. +Interfaces: shell return code/stdout/stderr preserved; maxOutputBytes bounds each returned stream including marker, UTF8 remains valid at chunk/truncation boundaries. +- [ ] Write subprocess tests split UTF8 across chunks, CJK byte caps, stdout/stderr independent limits, exact cap/zero output, timeout existing semantics. +- [ ] Run focused test and preserve RED output. +- [ ] Implement byte-bound per-stream decoder; preserve process-group cleanup and redaction. +- [ ] Run LocalEnv/symlink/hardening tests and all required gates before PR; commit only owned files. + +### Task C — MCP discovery/cancellation (parallel independent slice) +Files: src/harness/mcp.ts, test/mcp-source.test.ts, test/mcp-invoke.test.ts, new test/fixtures MCP protocol fixtures. Owner MCP implementer .worktrees/tool-mcp-runtime. Artifact security is separate subsequent commit/PR; do not mix. +Interfaces: existing McpToolSourceLike compatible, optional refresh/diagnostics only if needed. Invoke requires a discovered exact name; failed discoveries retry; list_changed invalidates catalog. Deadline propagates AbortSignal and timeout is controlled OUTCOME_UNKNOWN, retryable false after request sent. No claim that server cancellation undoes effects. +- [ ] Write stdio fixture tests undiscovered name zero calls, discovery recovery/change invalidation, on-deadline cancellation and ignored-cancel late result classification. +- [ ] Run and preserve RED tests. +- [ ] Implement discovery state/allowlist and cancellation without duplicate requests or automatic retries of unknown work. Keep schema names stable for integration; aliases handled later in catalog. +- [ ] Run MCP config/source/runtime/invoke suites and required gates, scoped commits separating discovery and cancellation; report evidence. + +### Task D — Catalog/schema/executor foundation (after A, can prepare while A–C run) +Files: src/harness/tools.ts facade; new src/harness/tools/{types,catalog,validation,executor}.ts; package.json/pnpm-lock.yaml; builtin extraction files; test/tool-catalog.test.ts and test/tool-validation.test.ts. Root coordinates implementer. +Interfaces: ToolCatalog snapshots definitions/status/reasons; ToolExecutor resolve→current permission→schema→handler, compatibility invoke returns original payload. One direct locked validator, no remote refs/defaults/coercion. Memory/MCP pass same boundary. Execution context is host-built, not model args. +- [ ] Convert audit main-contracts into Vitest failures: wrong command/missing body, unknown MCP, unavailable teams/publisher, stopped foreign jobs; assert handler I/O remains zero. +- [ ] Implement strict per-tool required/optional schemas; nested approval schemas, memory schemas and members array/legacy replay compatibility; controlled errors. +- [ ] Extract handlers by domain preserving ACL/approval logic; remove create_worker from new model surface; false capabilities unavailable with diagnostics. +- [ ] Add CLI tools --role/--json with no-discovery default and explicit discovery mode, no model/network runs by default. +- [ ] Run matrix role/config/restriction/sessions, validation error secret tests, full gates and independent code/security review. + +### Task E — Job/Team real execution and cancellation +Files: src/harness/jobs.ts (new), team.ts, loop.ts, tools/builtin/worker.ts, src/shared/{types,ports}.ts, src/store/{schema,sqlite}.ts, runtime.ts, env workspace lease adapter, job/team/regression tests. Serial ownership after protocol and catalog integration. +Interfaces: durable Job execution identity/task/owner/executor, lifecycle outcome distinct from completion delivery; bounded child session uses host authorization. Child cannot parent-report/approve/publish/subscribe/delegate recursively or access memory/read_object; explicit input manifests/artifact handoff. Speculative spawn disabled. +- [ ] Port jobs-audit queue barriers to deterministic Vitest (wait for pending condition, no fixed sleep as proof); foreign stop, pending stop, restarted stopped pending, team/job mismatch all RED. +- [ ] Implement cancellation/receipt CAS and dequeue checks; preserve normal succeeded pending recovery. Stop returns actual terminal or cancel_requested status. +- [ ] Add schema migration for real child attempts; legacy timer-only running records become unavailable, never auto-success; preserve historical rows. +- [ ] Implement bounded child model turn task with own session/workspace; at least two tasks produce distinct real outputs. Parent termination revokes leases and cancels. On restart, interrupted child turns are unknown unless an explicit durable checkpoint proves safe continuation; the current text-only executor has no such checkpoint, so it must not replay them. The parent can inspect the retained result/unknown state before starting a new task. +- [ ] Team aggregates job facts; complete_team refuses running members. Add failure/budget/cancel/sandbox/artifact/memory denial tests. +- [ ] Run full gates, independent code/security/QA; small PRs for ownership, state machine, child execution, team aggregation. + +### Task F — Artifact security and provider names +Files: new src/harness/artifacts.ts or M9 artifact adapter, src/harness/mcp.ts, catalog integration, M2 metadata storage/tests. Serial ownership after C. +- [ ] RED fixture tests unredacted resource text, symlink directory escape, unsafe modes, per-call and cumulative limits, MIME mismatch classification, long-name mapping/collisions. +- [ ] Implement predecode bounds, private no-follow storage, quota and ACL artifact metadata, retention references and cleanup; no automatic deletion of referenced artifacts. Maintain spill/image compatibility. +- [ ] Normalize provider names to stable bounded aliases with collision checks; schema snapshots reject stale calls rather than silently adapting. +- [ ] Add LocalEnv read-size cap without weakening descriptor checks. Run all artifact/MCP/memory/path suites and full gates; independent security review. + +### Task G — Executor facts, trace and diagnostics +Files: tools/executor.ts, tools/audit.ts, harness/tracing.ts, loop.ts, runtime.ts, cli diagnostics, versioned desktop tool events if compatible with PR276, docs/PHOENIX.md; tracing/transport tests. +- [ ] RED real runTurn tests model_failed/exit1/approval_wait/budget_exhausted and complete manifest under long history; host deferred call must have exactly one tool execution span. +- [ ] Add host turn/step/execution IDs and durable receipts; trace registered tool name, safe error/outcome, separate catalog/history budgets. No raw exception/secret export. +- [ ] Expose requested/initialized/export_failed diagnostics without requiring collector success for execution. Preserve approved PR278/279 APIs when integrated separately. +- [ ] Verify CLI diagnostics and desktop start/result/hold events independently from Phoenix; no invented historic payloads. +- [ ] Full offline tests/typecheck/lint/build/coverage as required CI, independent code/security/QA review. Record live limitations, PR URLs/CI and postmerge verification. + +## Review and delivery + +Each small concern gets RED/GREEN evidence, scoped commit, independent spec/code review (security for untrusted input/I/O). Required local typecheck/lint/test before opening PR; observe exact-head CI before ordinary merge, retain owner merge gate for high-risk changes. Do not present a partial slice as entire redesign complete. Final acceptance maps each B01–B15 to code/test/review/PR/integration evidence. diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/README.md b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/README.md new file mode 100644 index 00000000..17a34605 --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/README.md @@ -0,0 +1,31 @@ +# 修复前复现证据 + +基线 a91f6435c5811d970d3cecdc316b5bfb8f434d31,2026-12-01。 + +这些脚本为了审计有意断言当前错误行为。exit 0 证明复现成立,不证明修复通过。实现时必须将相应预期反转,形成真正的失败→通过回归测试。 + +例外是 `main-contracts.mjs`:它断言应有的安全契约,修复前实跑 exit 1、5项失败,日志为 `main-contracts.txt`。此脚本可直接作为红灯反馈环。 + +原始运行输出按执行时内容保留。复现脚本的源码导入现指向运行脚本所在的checkout;历史输出仍绑定审计时的基线SHA。 + +从仓库根目录运行(Node.js 22.15.0+,已执行 `pnpm install --frozen-lockfile`): + +```sh +node --import tsx docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-repro.mjs "$PWD" +node --import tsx docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-contracts.mjs "$PWD" +node --import tsx docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-trace-repro.mjs "$PWD" +node --import tsx docs/dev-loop-runs/2026-12-01-tool-system/artifacts/jobs-audit.mjs +node --import tsx docs/dev-loop-runs/2026-12-01-tool-system/artifacts/boundaries.mjs +node --import tsx docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-audit.mjs +``` + +`jobs-audit.mjs` 和 `mcp-audit.mjs` 在系统临时目录创建各自的运行目录;MCP服务脚本使用本目录提交的 `server.mjs`。MCP脚本会清理并重建自己命名的mcp-case-*子目录,然后写入临时二进制资源和协议日志;不要指向用户数据目录。jobs脚本用20ms等待fixture timer,再以同session队列barrier控制竞争窗口,输出必须检查pending确实存在,不能只看exit状态。历史复现脚本面向审计基线;当前修复版可能产生不同结果,应以对应SHA和测试断言解释差异。 + +- `main-repro.*`:真实 registry 分发、stub executor、副作用计数和OpenAI解析。 +- `main-trace-repro.*`:真实 SDK、内存exporter、runTurn和原始capture函数。 +- `jobs-*`:实际Runtime、队列屏障、持久completion、取消和provider反例。 +- `mcp-*`、`server.mjs`:真实stdio协议;取消、发现、版本、落盘、限额。case-*的server.jsonl为原始运行快照。 +- `boundaries.*`、`boundaries-output.jsonl`:本地shell的中文输出和临时文件边界。 +- `main-existing-tests.txt`:13文件89项通过。`boundaries-tests.txt`:3文件37项通过,与前者部分重叠。 + +所有凭据样式和 TOKEN_AUDIT_SENTINEL 都是合成字符串,未连接真实模型/外部服务。大二进制fixture未复制入Git;长度和原始协议证据保留在结果文件。 diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/boundaries-output.jsonl b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/boundaries-output.jsonl new file mode 100644 index 00000000..fecf1093 --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/boundaries-output.jsonl @@ -0,0 +1,7 @@ +{"case":"utf8_byte_limit","configured":10,"actualBytes":42,"text":"你你你你你你你你你你\n[truncated]"} +{"case":"split_utf8","expected":"你","actual":"���"} +{"case":"explicit_private_allowed","input":"http://127.0.0.1:99/path","result":"http://127.0.0.1:99/path"} +{"case":"explicit_private_allowed","input":"http://169.254.169.254/latest/meta-data","result":"http://169.254.169.254/latest/meta-data"} +{"case":"explicit_private_allowed","input":"http://2130706433/path","result":"http://127.0.0.1/path"} +{"case":"file_boundary","p":"../outside","error":"path escapes workspace"} +{"case":"file_boundary","p":"link","error":"path escapes workspace: symlinks are not allowed"} diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/boundaries-tests.txt b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/boundaries-tests.txt new file mode 100644 index 00000000..245a8985 --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/boundaries-tests.txt @@ -0,0 +1,239 @@ + + RUN v3.2.7 /Users/sulin/deepseek-super-agent/.worktrees/tool-system-redesign + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > is unavailable without publisher +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > is unavailable without publisher +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > refuses publishing without an owner approval before publisher or gh calls +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > refuses publishing without an owner approval before publisher or gh calls +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > does not publish while the bound owner approval is pending +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-approval approvalId=appr_1 actionId=act_6e49b7f1e6fcb57b action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > does not publish while the bound owner approval is pending +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > records exact host-computed publish metadata in the pending owner approval +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > records exact host-computed publish metadata in the pending owner approval +[approval] requested ticketId=ticket-approval approvalId=appr_1 actionId=act_e92d10e671e641c3 action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} | (commit summary unavailable) + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > records exact host-computed publish metadata in the pending owner approval +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > shows a bounded commit summary in the owner approval action text +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > shows a bounded commit summary in the owner approval action text +[approval] requested ticketId=ticket-summary approvalId=appr_1 actionId=act_8cb3ddd2c5e3567f action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} | 3 files changed, 12 insertions(+) README.md | 2 ++ notes.txt | 10 ++++++++++ + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > shows a bounded commit summary in the owner approval action text +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > refuses an approved publish after its ticket has ended +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-ended approvalId=appr_1 actionId=act_6e49b7f1e6fcb57b action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} +[approval] approved ticketId=ticket-ended approvalId=appr_1 by=human + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > refuses an approved publish after its ticket has ended +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > rechecks ticket lifecycle after asynchronous approval preparation +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-ending-during-prepare approvalId=appr_1 actionId=act_6e49b7f1e6fcb57b action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} +[approval] approved ticketId=ticket-ending-during-prepare approvalId=appr_1 by=human + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > rechecks ticket lifecycle after asynchronous approval preparation +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > consumes one approved publish request after its first publication +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-single-use approvalId=appr_1 actionId=act_6e49b7f1e6fcb57b action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} +[approval] approved ticketId=ticket-single-use approvalId=appr_1 by=human + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > consumes one approved publish request after its first publication +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > admits only one of two overlapping calls on separate SQLite connections +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-overlapping approvalId=appr_1 actionId=act_6e49b7f1e6fcb57b action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} +[approval] approved ticketId=ticket-overlapping approvalId=appr_1 by=human + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > admits only one of two overlapping calls on separate SQLite connections +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > does not replay approval after local push succeeds but confirmation fails +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-uncertain approvalId=appr_1 actionId=act_e6ef6db19e7b2398 action=publish_feature_pr {"repo":"o/r","head":"08209f8c728f57c3ef0b9573406355eca6d8a8e0","branch":"peanut/uncertain","base":"main","title":"Approved title","body":"Approved body"} +[approval] approved ticketId=ticket-uncertain approvalId=appr_1 by=human + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > does not replay approval after local push succeeds but confirmation fails +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > keeps admission consumed when the process stops before publisher entry +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-stopped-before-publisher approvalId=appr_1 actionId=act_6e49b7f1e6fcb57b action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} +[approval] approved ticketId=ticket-stopped-before-publisher approvalId=appr_1 by=human + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > keeps admission consumed when the process stops before publisher entry +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > resumes only the matching deferred publish in default mode +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-deferred-admitted approvalId=appr_1 actionId=act_6e49b7f1e6fcb57b action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} +[approval] approved ticketId=ticket-deferred-admitted approvalId=appr_1 by=human + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > resumes only the matching deferred publish in default mode +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > resumes only the matching deferred publish in restricted mode +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-deferred-admitted approvalId=appr_1 actionId=act_6e49b7f1e6fcb57b action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} +[approval] approved ticketId=ticket-deferred-admitted approvalId=appr_1 by=human + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > resumes only the matching deferred publish in restricted mode +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > leaves an unconfirmed publisher boundary when result persistence fails +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-confirmation-write-fails approvalId=appr_1 actionId=act_6e49b7f1e6fcb57b action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} +[approval] approved ticketId=ticket-confirmation-write-fails approvalId=appr_1 by=human + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > leaves an unconfirmed publisher boundary when result persistence fails +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > refuses an approved request bound to different metadata +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-approval approvalId=appr_1 actionId=act_6e49b7f1e6fcb57b action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} +[approval] approved ticketId=ticket-approval approvalId=appr_1 by=human + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > refuses an approved request bound to different metadata +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > is not exposed to router or watchdog +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > is not exposed to router or watchdog +[daemon] stop + + ✓ test/publish-feature-pr-tool.test.ts (16 tests) 612ms +stdout | test/fill-tools.test.ts > fill vault tools > loads an owner-only vault file into the Runtime and never logs a value +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=ScriptedModel +[fill] vault=entries=1 target=browser:checkout.example +[ingress] slow-path mode=rules timeoutMs=3000 + + ✓ test/fill-tools.test.ts (14 tests) 100ms + ✓ test/local-env-symlink.test.ts (7 tests) 13ms + + Test Files 3 passed (3) + Tests 37 passed (37) + Start at 07:02:03 + Duration 1.97s (transform 445ms, setup 0ms, collect 903ms, tests 725ms, environment 0ms, prepare 105ms) diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/boundaries.mjs b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/boundaries.mjs new file mode 100644 index 00000000..35d82b36 --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/boundaries.mjs @@ -0,0 +1,20 @@ +import fs from 'node:fs'; +import os from 'node:os'; +import path from 'node:path'; +import { LocalEnv } from '../../../../src/env/local-env.ts'; +import { assertAllowedUrl } from '../../../../src/env/browser-errands.ts'; +const root=fs.mkdtempSync(path.join(os.tmpdir(),'lofibot-boundary-')); +const env = new LocalEnv(root,{maxOutputBytes:10,timeoutMs:3000,sandbox:{enabled:false},env:{PATH:process.env.PATH}}); +const cmd = code => `${JSON.stringify(process.execPath)} -e '${code.replace(/'/g,"'\\''")}'`; +const output=await env.bash('worker_bytes',cmd('process.stdout.write("你".repeat(20))')); +console.log(JSON.stringify({case:'utf8_byte_limit',configured:10,actualBytes:Buffer.byteLength(output.stdout),text:output.stdout})); +const env2 = new LocalEnv(root,{maxOutputBytes:100,timeoutMs:3000,sandbox:{enabled:false},env:{PATH:process.env.PATH}}); +const split=await env2.bash('worker_split',cmd('process.stdout.write(Buffer.from([0xe4]));setTimeout(()=>process.stdout.write(Buffer.from([0xbd,0xa0])),100)')); +console.log(JSON.stringify({case:'split_utf8',expected:'你',actual:split.stdout})); +for(const raw of ['http://127.0.0.1:99/path','http://169.254.169.254/latest/meta-data','http://2130706433/path']) { + try { console.log(JSON.stringify({case:'explicit_private_allowed',input:raw,result:assertAllowedUrl(raw,['127.0.0.1','169.254.169.254']).href})); }catch(error){console.log(JSON.stringify({case:'explicit_private_allowed',input:raw,error:error.message}));} +} +const outside=path.join(root,'outside');fs.writeFileSync(outside,'sentinel'); +const workspace=env2.workspace('worker_safe');fs.symlinkSync(outside,path.join(workspace,'link')); +for(const p of ['../outside','link']){try{console.log({case:'file_boundary',p,result:await env2.readFile('worker_safe',p)})}catch(error){console.log(JSON.stringify({case:'file_boundary',p,error:error.message}))}} +fs.rmSync(root,{recursive:true,force:true}); diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/jobs-audit.mjs b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/jobs-audit.mjs new file mode 100644 index 00000000..ebd29120 --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/jobs-audit.mjs @@ -0,0 +1,36 @@ +import {mkdtempSync,rmSync} from 'node:fs'; +import {tmpdir} from 'node:os';import {join} from 'node:path'; +const root=new URL('../../../../',import.meta.url); +const {Runtime}=await import(new URL('src/runtime.ts',root).href); +const {HttpOpenAI,HttpAnthropic}=await import(new URL('src/harness/model.ts',root).href); +const {runTurn}=await import(new URL('src/harness/loop.ts',root).href); +const results={}; +const originalLog=console.log; console.log=()=>{}; +const delay=ms=>new Promise(r=>setTimeout(r,ms)); +function make(){const home=mkdtempSync(join(tmpdir(),'lofibot-job-audit-')); const seen=[]; const model={name:'audit',classify:()=>({hit:true,reason:'audit'}),complete:async req=>{seen.push(req.messages.filter(m=>m.role==='user').at(-1)?.content);return {text:'done'}}};const runtime=Runtime.create({home,model,jobDelayMs:0,env:{}});const ticketId='audit-ticket',sessionId=`worker_${ticketId}`;runtime.store.putDoc('ticket',ticketId,{id:ticketId,title:'Audit',brief:'Audit',mandate:{strength:'explicit',policyVersion:'policy-v1',scope:'audit',actor:'you',basis:'addressed'},threadKeys:['cli:local'],channels:[{source:'cli',thread:'local'}],inputs:[],assignments:[{id:'asg-audit',state:'running',speculative:false,startedAt:new Date().toISOString()}],speculative:false,originTriggerId:'original',createdAt:new Date().toISOString()});return {runtime,home,seen,ticketId,sessionId,ctx:{role:'worker',sessionId,ticketId}};} +async function close(f){await f.runtime.jobsSettled();await f.runtime.finish();rmSync(f.home,{recursive:true,force:true});} +{ + const f=make(),{runtime:r,sessionId,ticketId,ctx}=f;let release;const barrier=new Promise(x=>release=x); r.harness.enqueue(sessionId,()=>barrier); const job=r.store.createJob({sessionId,ticketId,name:'queued'});r.harness.scheduleJob(job);await delay(20);const before={job:r.store.getJob(job.id),pending:!!r.store.getDoc('job_completion',job.id)};const stopped=await r.tools.invoke({id:'stop',name:'stop_job',args:{jobId:job.id}},ctx);release();await r.jobsSettled();results.queuedStop={before,toolResult:stopped,after:r.store.getJob(job.id),callbackExecuted:f.seen.some(p=>p.startsWith('JOB_DONE'))};await close(f); +} +{ + const f=make(),{runtime:r,sessionId,ticketId,ctx}=f;const job=r.store.createJob({sessionId,ticketId,name:'pending-stopped'});r.store.putDoc('job_completion',job.id,{prompt:'JOB_DONE\nrestored-stopped'});r.store.completeJob(job.id,'stopped');r.harness.scheduleJob(job);await r.jobsSettled();results.persistedStoppedPending={rowStatus:r.store.getJob(job.id).status,callbackExecuted:f.seen.some(p=>p.includes('restored-stopped'))};await close(f); +} +{ + const f=make(),{runtime:r,sessionId,ticketId,ctx}=f;const team=r.teams.spawnTeam({parentSessionId:sessionId,ticketId,members:[{name:'alpha'}]});const jobId=team.members[0].jobId;await r.tools.invoke({id:'stop',name:'stop_job',args:{jobId}},ctx);const before={job:r.store.getJob(jobId).status,member:r.teams.getTeam(team.id).members[0].status};r.teams.completeTeam(team.id);results.teamStopMismatch={before,after:{job:r.store.getJob(jobId).status,member:r.teams.getTeam(team.id).members[0].status}};await close(f); +} +{ + const f=make(),{runtime:r,ticketId}=f;r.inboxEnabled=true;results.followup={};for(const [label,value] of [['nan',NaN],['past',Date.now()-1000],['tooSoon',Date.now()+1000],['valid',Date.now()+120000]]){try{results.followup[label]=r.scheduleFollowUp(ticketId,value,'audit');}catch(e){results.followup[label]={rejected:e.message};}}await close(f); +} +{ + const original=globalThis.fetch;results.openai={};try{for(const [label,args] of [['null','null'],['array','[]'],['string','"x"'],['duplicate','{}']]){globalThis.fetch=async()=>new Response(JSON.stringify({choices:[{message:{content:null,tool_calls:(label==='duplicate'?[1,2]:[1]).map(()=>({id:'same',function:{name:'bash',arguments:args}}))}}]}),{headers:{'content-type':'application/json'}});const out=await new HttpOpenAI('http://localhost/v1','fixture','fixture',1000).complete({role:'worker',messages:[],tools:[]});results.openai[label]=out.toolCalls;}}finally{globalThis.fetch=original;} +} +{ + const entries=[];let calls=0,steps=0;await runTurn({model:{name:'audit',complete:async()=>++steps===1?{toolCalls:[{id:'same',name:'probe',args:{}},{id:'same',name:'probe',args:{}}]}:{text:'done'}},tools:{memoryIndex:()=>undefined,spillContext:content=>({content}),specsFor:async()=>[{name:'probe',description:'audit',parameters:{type:'object'}}],invoke:async()=>{calls++;return {ok:true}}},journal:{history:()=>[],append:(_s,e)=>entries.push(e)},log:()=>{},metrics:{increment:()=>{},observeModelLatency:()=>{}},redact:s=>s,session:{id:'worker-audit',role:'worker'},prompt:'audit'});results.duplicateLoop={sideEffectCount:calls,resultEntries:entries.filter(e=>e.role==='tool').map(e=>e.toolCallId)}; +} +{ + const f=make(),{runtime:r,sessionId,ticketId,ctx}=f;let release;const barrier=new Promise(x=>release=x); r.harness.enqueue(sessionId,()=>barrier); const team=r.teams.spawnTeam({parentSessionId:sessionId,ticketId,members:[{name:'alpha'}]});r.harness.scheduleJob({id:team.members[0].jobId,sessionId,ticketId});await delay(20);const pending=!!r.store.getDoc('job_completion',team.members[0].jobId);r.teams.completeTeam(team.id);release();await r.jobsSettled();results.queuedCompleteTeam={pendingBeforeComplete:pending,callbackExecuted:f.seen.some(p=>p.startsWith('TEAM_MEMBER_DONE'))};await close(f); +} +{ + const original=globalThis.fetch;results.anthropic={};try{for(const [label,input] of [['null',null],['array',[]],['string','x'],['duplicate',{}]]){globalThis.fetch=async()=>new Response(JSON.stringify({content:(label==='duplicate'?[1,2]:[1]).map(()=>({type:'tool_use',id:'same',name:'bash',input}))}),{headers:{'content-type':'application/json'}});const out=await new HttpAnthropic('http://localhost/v1','fixture','fixture',1000).complete({role:'worker',messages:[],tools:[]});results.anthropic[label]=out.toolCalls;}}finally{globalThis.fetch=original;} +} +originalLog(JSON.stringify(results,null,2)); diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/jobs-output.json b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/jobs-output.json new file mode 100644 index 00000000..13b96c9a --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/jobs-output.json @@ -0,0 +1,117 @@ +{ + "queuedStop": { + "before": { + "job": { + "id": "job_1", + "sessionId": "worker_audit-ticket", + "ticketId": "audit-ticket", + "name": "queued", + "status": "succeeded", + "createdAt": "2026-11-30T23:01:10.392Z", + "finishedAt": "2026-11-30T23:01:10.393Z" + }, + "pending": true + }, + "toolResult": { + "status": "stopped", + "jobId": "job_1" + }, + "after": { + "id": "job_1", + "sessionId": "worker_audit-ticket", + "ticketId": "audit-ticket", + "name": "queued", + "status": "succeeded", + "createdAt": "2026-11-30T23:01:10.392Z", + "finishedAt": "2026-11-30T23:01:10.393Z" + }, + "callbackExecuted": true + }, + "persistedStoppedPending": { + "rowStatus": "stopped", + "callbackExecuted": true + }, + "teamStopMismatch": { + "before": { + "job": "stopped", + "member": "running" + }, + "after": { + "job": "stopped", + "member": "succeeded" + } + }, + "followup": { + "nan": { + "rejected": "follow-up must be scheduled between one minute and 30 days ahead" + }, + "past": { + "rejected": "follow-up must be scheduled between one minute and 30 days ahead" + }, + "tooSoon": { + "rejected": "follow-up must be scheduled between one minute and 30 days ahead" + }, + "valid": { + "id": "b80f754f0c8121c11550ff353b436a5ad71d9888f751f7f514215b92a69e274a", + "scheduled": true + } + }, + "openai": { + "null": [ + { + "id": "same", + "name": "bash", + "args": null + } + ], + "array": [ + { + "id": "same", + "name": "bash", + "args": [] + } + ], + "string": [ + { + "id": "same", + "name": "bash", + "args": "x" + } + ], + "duplicate": [ + { + "id": "same", + "name": "bash", + "args": {} + }, + { + "id": "same", + "name": "bash", + "args": {} + } + ] + }, + "duplicateLoop": { + "sideEffectCount": 2, + "resultEntries": [ + "same", + "same" + ] + }, + "queuedCompleteTeam": { + "pendingBeforeComplete": true, + "callbackExecuted": true + }, + "anthropic": { + "null": [], + "array": [], + "string": [], + "duplicate": [ + { + "id": "same", + "name": "bash", + "args": {} + } + ] + } +} diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-contracts.mjs b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-contracts.mjs new file mode 100644 index 00000000..f170e161 --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-contracts.mjs @@ -0,0 +1,21 @@ +import assert from 'node:assert/strict' +import fs from 'node:fs' +import path from 'node:path' +import os from 'node:os' +import {pathToFileURL} from 'node:url' +const repo=process.argv[2],mod=p=>import(pathToFileURL(path.join(repo,p)).href) +const {ToolRegistry}=await mod('src/harness/tools.ts'),{Store}=await mod('src/store/sqlite.ts') +const home=fs.mkdtempSync(path.join(os.tmpdir(),'lofibot-contracts-')),store=new Store(home) +let sideEffects=0,mcpCalls=0,failures=0 +const tools=new ToolRegistry({store,ports:{router:{},worker:{},watchdog:{}},env:{bash:async()=>{sideEffects++;return{code:0,stdout:'',stderr:''}},writeFile:async()=>{sideEffects++;return'fixture'}},metrics:{increment(){}},redact:x=>x,log:()=>{},scheduleJob:()=>{},routerTurn:async()=>{},mcp:{specs:async()=>[],invoke:async()=>{mcpCalls++;return{}},close:async()=>{}}}) +const ctx={role:'worker',sessionId:'worker_a',ticketId:'ticket_a'},call=(name,args)=>tools.invoke({id:'contract-'+name,name,args},ctx) +const check=async(name,fn)=>{try{await fn();console.log('PASS',name)}catch(e){failures++;console.log('FAIL',name,':',e.message.split('\n')[0])}} +try{ + await check('invalid bash args rejected before executor',async()=>{const before=sideEffects;await assert.rejects(call('bash',{command:{bad:true}}));assert.equal(sideEffects,before)}) + await check('missing write body rejected before executor',async()=>{const before=sideEffects;await assert.rejects(call('write_file',{path:'existing.txt'}));assert.equal(sideEffects,before)}) + await check('foreign job cannot be stopped',async()=>{const job=store.createJob({sessionId:'worker_b',ticketId:'ticket_b',name:'foreign'});await assert.rejects(call('stop_job',{jobId:job.id}));assert.equal(store.getJob(job.id).status,'running')}) + await check('undiscovered MCP cannot reach server',async()=>{await assert.rejects(call('mcp__fixture__hidden',{}));assert.equal(mcpCalls,0)}) + await check('unconfigured team/publisher tools not advertised',async()=>{const names=(await tools.specsFor('worker')).map(t=>t.name);for(const name of ['spawn_team','team_status','complete_team','publish_feature_pr'])assert.ok(!names.includes(name),name+' advertised')}) + console.log(JSON.stringify({contracts:5,failed:failures,fixtureExecutorCalls:sideEffects,fixtureMcpCalls:mcpCalls})) + process.exitCode=failures?1:0 +}finally{store.close();fs.rmSync(home,{recursive:true,force:true})} diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-contracts.txt b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-contracts.txt new file mode 100644 index 00000000..26cf79f4 --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-contracts.txt @@ -0,0 +1,8 @@ +FAIL invalid bash args rejected before executor : Missing expected rejection. +FAIL missing write body rejected before executor : Missing expected rejection. +FAIL foreign job cannot be stopped : Missing expected rejection. +FAIL undiscovered MCP cannot reach server : Missing expected rejection. +FAIL unconfigured team/publisher tools not advertised : spawn_team advertised +{"contracts":5,"failed":5,"fixtureExecutorCalls":2,"fixtureMcpCalls":1} +(node:4376) ExperimentalWarning: SQLite is an experimental feature and might change at any time +(Use `node --trace-warnings ...` to show where the warning was created) diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-existing-tests.txt b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-existing-tests.txt new file mode 100644 index 00000000..0e8cc74d --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-existing-tests.txt @@ -0,0 +1,753 @@ + +> lofibot@0.1.0 test /Users/sulin/deepseek-super-agent/.worktrees/tool-system-redesign +> LOFIBOT_ALLOW_MOCK_FIXTURE=1 NODE_NO_WARNINGS=1 vitest run test/mcp-config.test.ts test/mcp-registry.test.ts test/mcp-invoke.test.ts test/mcp-source.test.ts test/mcp-runtime.test.ts test/restricted-tool-permissions.test.ts test/fill-tools.test.ts test/publish-feature-pr-tool.test.ts test/tool-spec-schema.test.ts test/job.test.ts test/team-harness.test.ts test/phoenix-tracing.test.ts test/phoenix-harness.test.ts --no-file-parallelism + + + RUN v3.2.7 /Users/sulin/deepseek-super-agent/.worktrees/tool-system-redesign + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > is unavailable without publisher +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > is unavailable without publisher +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > refuses publishing without an owner approval before publisher or gh calls +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > refuses publishing without an owner approval before publisher or gh calls +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > does not publish while the bound owner approval is pending +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-approval approvalId=appr_1 actionId=act_6e49b7f1e6fcb57b action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > does not publish while the bound owner approval is pending +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > records exact host-computed publish metadata in the pending owner approval +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > records exact host-computed publish metadata in the pending owner approval +[approval] requested ticketId=ticket-approval approvalId=appr_1 actionId=act_e92d10e671e641c3 action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} | (commit summary unavailable) + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > records exact host-computed publish metadata in the pending owner approval +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > shows a bounded commit summary in the owner approval action text +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > shows a bounded commit summary in the owner approval action text +[approval] requested ticketId=ticket-summary approvalId=appr_1 actionId=act_8cb3ddd2c5e3567f action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} | 3 files changed, 12 insertions(+) README.md | 2 ++ notes.txt | 10 ++++++++++ + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > shows a bounded commit summary in the owner approval action text +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > refuses an approved publish after its ticket has ended +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-ended approvalId=appr_1 actionId=act_6e49b7f1e6fcb57b action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} +[approval] approved ticketId=ticket-ended approvalId=appr_1 by=human + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > refuses an approved publish after its ticket has ended +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > rechecks ticket lifecycle after asynchronous approval preparation +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-ending-during-prepare approvalId=appr_1 actionId=act_6e49b7f1e6fcb57b action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} +[approval] approved ticketId=ticket-ending-during-prepare approvalId=appr_1 by=human + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > rechecks ticket lifecycle after asynchronous approval preparation +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > consumes one approved publish request after its first publication +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-single-use approvalId=appr_1 actionId=act_6e49b7f1e6fcb57b action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} +[approval] approved ticketId=ticket-single-use approvalId=appr_1 by=human + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > consumes one approved publish request after its first publication +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > admits only one of two overlapping calls on separate SQLite connections +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-overlapping approvalId=appr_1 actionId=act_6e49b7f1e6fcb57b action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} +[approval] approved ticketId=ticket-overlapping approvalId=appr_1 by=human + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > admits only one of two overlapping calls on separate SQLite connections +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > does not replay approval after local push succeeds but confirmation fails +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-uncertain approvalId=appr_1 actionId=act_ba84277b4734876a action=publish_feature_pr {"repo":"o/r","head":"436680ea47140c0dcab84babec25f6697838bb86","branch":"peanut/uncertain","base":"main","title":"Approved title","body":"Approved body"} +[approval] approved ticketId=ticket-uncertain approvalId=appr_1 by=human + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > does not replay approval after local push succeeds but confirmation fails +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > keeps admission consumed when the process stops before publisher entry +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-stopped-before-publisher approvalId=appr_1 actionId=act_6e49b7f1e6fcb57b action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} +[approval] approved ticketId=ticket-stopped-before-publisher approvalId=appr_1 by=human + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > keeps admission consumed when the process stops before publisher entry +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > resumes only the matching deferred publish in default mode +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-deferred-admitted approvalId=appr_1 actionId=act_6e49b7f1e6fcb57b action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} +[approval] approved ticketId=ticket-deferred-admitted approvalId=appr_1 by=human + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > resumes only the matching deferred publish in default mode +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > resumes only the matching deferred publish in restricted mode +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-deferred-admitted approvalId=appr_1 actionId=act_6e49b7f1e6fcb57b action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} +[approval] approved ticketId=ticket-deferred-admitted approvalId=appr_1 by=human + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > resumes only the matching deferred publish in restricted mode +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > leaves an unconfirmed publisher boundary when result persistence fails +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-confirmation-write-fails approvalId=appr_1 actionId=act_6e49b7f1e6fcb57b action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} +[approval] approved ticketId=ticket-confirmation-write-fails approvalId=appr_1 by=human + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > leaves an unconfirmed publisher boundary when result persistence fails +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > refuses an approved request bound to different metadata +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[approval] requested ticketId=ticket-approval approvalId=appr_1 actionId=act_6e49b7f1e6fcb57b action=publish_feature_pr {"repo":"o/r","head":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","branch":"peanut/feature","base":"main","title":"Approved title","body":"Approved body"} +[approval] approved ticketId=ticket-approval approvalId=appr_1 by=human + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > refuses an approved request bound to different metadata +[daemon] stop + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > is not exposed to router or watchdog +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/publish-feature-pr-tool.test.ts > publish_feature_pr tool > is not exposed to router or watchdog +[daemon] stop + + ✓ test/publish-feature-pr-tool.test.ts (16 tests) 638ms +stdout | test/fill-tools.test.ts > fill vault tools > loads an owner-only vault file into the Runtime and never logs a value +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=ScriptedModel +[fill] vault=entries=1 target=browser:checkout.example +[ingress] slow-path mode=rules timeoutMs=3000 + + ✓ test/fill-tools.test.ts (14 tests) 116ms + ✓ test/phoenix-tracing.test.ts (12 tests) 1176ms + ✓ bounds shutdown with an exporter that never completes 1001ms +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > filters the advertised tools and rejects direct credentials, Bash, and sends +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=ScriptedModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > filters the advertised tools and rejects direct credentials, Bash, and sends +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=ScriptedModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > filters the advertised tools and rejects direct credentials, Bash, and sends +[daemon] stop +[daemon] stop + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > filters the advertised tools and rejects direct credentials, Bash, and sends +[daemon] stop +[daemon] stop + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > enforces the memory and MCP fast paths before dispatch +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=ScriptedModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > enforces the memory and MCP fast paths before dispatch +[daemon] stop + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > enforces the memory and MCP fast paths before dispatch +[daemon] stop + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > refuses remote configuration before opening state and rejects late registration +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=ScriptedModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > refuses remote configuration before opening state and rejects late registration +[daemon] stop + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > refuses remote configuration before opening state and rejects late registration +[daemon] stop + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > refuses resident messaging before channel adapters open +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=ScriptedModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > refuses resident messaging before channel adapters open +[daemon] stop + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > refuses resident messaging before channel adapters open +[daemon] stop + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > persists the restriction for a separate process without the opt-in environment +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=ScriptedModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[daemon] stop + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > persists the restriction for a separate process without the opt-in environment +[daemon] stop + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > persists the restriction for a separate process without the opt-in environment +[daemon] stop + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > persists the restriction for a separate process without the opt-in environment +[daemon] stop + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > stops an already-open default registry after another Runtime enables the restriction +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=ScriptedModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=ScriptedModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > stops an already-open default registry after another Runtime enables the restriction +[daemon] stop +[daemon] stop + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > stops an already-open default registry after another Runtime enables the restriction +[daemon] stop +[daemon] stop + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > keeps a pre-existing Outbox from claiming external sends after restrictions are saved +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=ScriptedModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=ScriptedModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > keeps a pre-existing Outbox from claiming external sends after restrictions are saved +[daemon] stop +[daemon] stop + +stdout | test/restricted-tool-permissions.test.ts > restricted tool permissions > keeps a pre-existing Outbox from claiming external sends after restrictions are saved +[daemon] stop +[daemon] stop + + ✓ test/restricted-tool-permissions.test.ts (8 tests) 972ms + ✓ restricted tool permissions > persists the restriction for a separate process without the opt-in environment 728ms +stdout | test/team-harness.test.ts > T14 Team harness integration > spawn_team path: member jobs settle into a completed team without Router events +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=TeamHarnessScript +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[ingress] two-level fast=pass:mention-or-direct semantic=pass:explicit model=TeamHarnessScript action=pass layer=semantic +[routing] shards=default triggerId=team_harness_trigger +[ingress] batch-hook thread=cli:local triggerId=team_harness_trigger pending=1 +[engine] Intake.receive id=team_harness_trigger result=stored +[engine] Evals.batch thread=cli:local size=1 triggerIds=team_harness_trigger +[engine] subscribe ticketId=ticket_1 thread=cli:local +[engine] Tickets.create ticketId=ticket_1 title=please investigate the login timeout speculative=false +[engine] Evals.accept thread=cli:local ticketId=ticket_1 strength=explicit +[channel] norm=cli ticketId=ticket_1 purpose=acknowledgement local-sent +[reply] purpose=acknowledgement ticketId=ticket_1 channel=cli thread=local text=Acknowledged “please investigate the login timeout”. Working on it. +[harness] session journal jsonl dir=/var/folders/hb/d5qrt86d36s3jlpw46lr9zj40000gn/T/lofibot-nRFWH8/sessions +[harness] MainSession start session=router role=router resident=true +[harness] dual-layer routers=router ExecutorSession=worker_ticket_1 ticketId=ticket_1 + +stdout | test/team-harness.test.ts > T14 Team harness integration > spawn_team path: member jobs settle into a completed team without Router events +[harness] MainSession turn session=router + +stdout | test/team-harness.test.ts > T14 Team harness integration > spawn_team path: member jobs settle into a completed team without Router events +[harness] async-react step=0 session=router role=router + +stdout | test/team-harness.test.ts > T14 Team harness integration > spawn_team path: member jobs settle into a completed team without Router events +[mesh] place ticketId=ticket_1 node=local +[harness] ExecutorSession start session=worker_ticket_1 ticketId=ticket_1 role=worker +[engine] Assignments.start ticketId=ticket_1 assignmentId=asg_1 session=worker_ticket_1 +[engine] Assignments.placed ticketId=ticket_1 assignmentId=asg_1 node=local + +stdout | test/team-harness.test.ts > T14 Team harness integration > spawn_team path: member jobs settle into a completed team without Router events +[harness] ExecutorSession turn session=worker_ticket_1 + +stdout | test/team-harness.test.ts > T14 Team harness integration > spawn_team path: member jobs settle into a completed team without Router events +[harness] async-react step=0 session=worker_ticket_1 role=worker + +stdout | test/team-harness.test.ts > T14 Team harness integration > spawn_team path: member jobs settle into a completed team without Router events +[team] member done teamId=team_mx3vlb5m_6h5fm6 jobId=job_1 +[job] completion trigger session=worker_ticket_1 jobId=job_1 + +stdout | test/team-harness.test.ts > T14 Team harness integration > spawn_team path: member jobs settle into a completed team without Router events +[harness] ExecutorSession turn session=worker_ticket_1 + +stdout | test/team-harness.test.ts > T14 Team harness integration > spawn_team path: member jobs settle into a completed team without Router events +[harness] async-react step=0 session=worker_ticket_1 role=worker + +stdout | test/team-harness.test.ts > T14 Team harness integration > spawn_team path: member jobs settle into a completed team without Router events +[team] member done teamId=team_mx3vlb5m_6h5fm6 jobId=job_2 +[job] completion trigger session=worker_ticket_1 jobId=job_2 + +stdout | test/team-harness.test.ts > T14 Team harness integration > spawn_team path: member jobs settle into a completed team without Router events +[harness] ExecutorSession turn session=worker_ticket_1 + +stdout | test/team-harness.test.ts > T14 Team harness integration > spawn_team path: member jobs settle into a completed team without Router events +[harness] async-react step=0 session=worker_ticket_1 role=worker + +stdout | test/team-harness.test.ts > T14 Team harness integration > spawn_team path: member jobs settle into a completed team without Router events +[daemon] stop + +stdout | test/team-harness.test.ts > T14 Team harness integration > complete_team path finishes a team without waiting for member jobs +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=TeamHarnessScript +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/team-harness.test.ts > T14 Team harness integration > complete_team path finishes a team without waiting for member jobs +[daemon] stop + +stdout | test/team-harness.test.ts > T14 Team harness integration > complete_team after scheduling member jobs suppresses late member turns +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=TeamHarnessScript +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[ingress] two-level fast=pass:mention-or-direct semantic=pass:explicit model=TeamHarnessScript action=pass layer=semantic +[routing] shards=default triggerId=team_complete_scheduled +[ingress] batch-hook thread=cli:local triggerId=team_complete_scheduled pending=1 +[engine] Intake.receive id=team_complete_scheduled result=stored +[engine] Evals.batch thread=cli:local size=1 triggerIds=team_complete_scheduled +[engine] subscribe ticketId=ticket_1 thread=cli:local +[engine] Tickets.create ticketId=ticket_1 title=please investigate the login timeout speculative=false +[engine] Evals.accept thread=cli:local ticketId=ticket_1 strength=explicit +[channel] norm=cli ticketId=ticket_1 purpose=acknowledgement local-sent +[reply] purpose=acknowledgement ticketId=ticket_1 channel=cli thread=local text=Acknowledged “please investigate the login timeout”. Working on it. +[harness] session journal jsonl dir=/var/folders/hb/d5qrt86d36s3jlpw46lr9zj40000gn/T/lofibot-T2GLz7/sessions +[harness] MainSession start session=router role=router resident=true +[harness] dual-layer routers=router ExecutorSession=worker_ticket_1 ticketId=ticket_1 + +stdout | test/team-harness.test.ts > T14 Team harness integration > complete_team after scheduling member jobs suppresses late member turns +[harness] MainSession turn session=router + +stdout | test/team-harness.test.ts > T14 Team harness integration > complete_team after scheduling member jobs suppresses late member turns +[harness] async-react step=0 session=router role=router + +stdout | test/team-harness.test.ts > T14 Team harness integration > complete_team after scheduling member jobs suppresses late member turns +[mesh] place ticketId=ticket_1 node=local +[harness] ExecutorSession start session=worker_ticket_1 ticketId=ticket_1 role=worker +[engine] Assignments.start ticketId=ticket_1 assignmentId=asg_1 session=worker_ticket_1 +[engine] Assignments.placed ticketId=ticket_1 assignmentId=asg_1 node=local + +stdout | test/team-harness.test.ts > T14 Team harness integration > complete_team after scheduling member jobs suppresses late member turns +[harness] ExecutorSession turn session=worker_ticket_1 + +stdout | test/team-harness.test.ts > T14 Team harness integration > complete_team after scheduling member jobs suppresses late member turns +[harness] async-react step=0 session=worker_ticket_1 role=worker + +stdout | test/team-harness.test.ts > T14 Team harness integration > complete_team after scheduling member jobs suppresses late member turns +[job] async job skipped jobId=job_1 status=succeeded + +stdout | test/team-harness.test.ts > T14 Team harness integration > complete_team after scheduling member jobs suppresses late member turns +[job] async job skipped jobId=job_2 status=succeeded + +stdout | test/team-harness.test.ts > T14 Team harness integration > complete_team after scheduling member jobs suppresses late member turns +[daemon] stop + +stdout | test/team-harness.test.ts > T14 Team harness integration > spawn_team rejects malformed member payloads with clear errors +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=TeamHarnessScript +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/team-harness.test.ts > T14 Team harness integration > spawn_team rejects malformed member payloads with clear errors +[daemon] stop + +stdout | test/team-harness.test.ts > T14 Team harness integration > scopes team_status and complete_team to the owning worker session +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=TeamHarnessScript +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/team-harness.test.ts > T14 Team harness integration > scopes team_status and complete_team to the owning worker session +[daemon] stop + + ✓ test/team-harness.test.ts (5 tests) 142ms + ✓ test/phoenix-harness.test.ts (5 tests) 80ms + ✓ test/mcp-source.test.ts (6 tests) 2876ms + ✓ McpToolSource > omits a server that never finishes initialize without stalling the listing 2505ms +stdout | test/job.test.ts > async job > returns started immediately and later marks the job succeeded +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=ScriptedModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[ingress] two-level fast=pass:mention-or-direct semantic=pass:explicit model=ScriptedModel action=pass layer=semantic +[routing] shards=default triggerId=trg_login +[ingress] batch-hook thread=im:topic/bug-login triggerId=trg_login pending=1 +[engine] Intake.receive id=trg_login result=stored +[engine] Evals.batch thread=im:topic/bug-login size=1 triggerIds=trg_login +[engine] subscribe ticketId=ticket_1 thread=im:topic/bug-login +[engine] Tickets.create ticketId=ticket_1 title=@lofibot please fix the login timeout on checkout speculative=false +[engine] Evals.accept thread=im:topic/bug-login ticketId=ticket_1 strength=explicit +[reply] ack-suppressed ticketId=ticket_1 channel=im reason=conversational +[harness] session journal jsonl dir=/var/folders/hb/d5qrt86d36s3jlpw46lr9zj40000gn/T/lofibot-Z8ZJNc/sessions +[harness] MainSession start session=router role=router resident=true +[harness] dual-layer routers=router ExecutorSession=worker_ticket_1 ticketId=ticket_1 + +stdout | test/job.test.ts > async job > returns started immediately and later marks the job succeeded +[harness] MainSession turn session=router + +stdout | test/job.test.ts > async job > returns started immediately and later marks the job succeeded +[harness] async-react step=0 session=router role=router + +stdout | test/job.test.ts > async job > returns started immediately and later marks the job succeeded +[mesh] place ticketId=ticket_1 node=local +[harness] ExecutorSession start session=worker_ticket_1 ticketId=ticket_1 role=worker +[engine] Assignments.start ticketId=ticket_1 assignmentId=asg_1 session=worker_ticket_1 +[engine] Assignments.placed ticketId=ticket_1 assignmentId=asg_1 node=local + +stdout | test/job.test.ts > async job > returns started immediately and later marks the job succeeded +[harness] ExecutorSession turn session=worker_ticket_1 + +stdout | test/job.test.ts > async job > returns started immediately and later marks the job succeeded +[harness] async-react step=0 session=worker_ticket_1 role=worker + +stdout | test/job.test.ts > async job > returns started immediately and later marks the job succeeded +[job] async job started jobId=job_1 status=started + +stdout | test/job.test.ts > async job > returns started immediately and later marks the job succeeded +[harness] async-react step=1 session=worker_ticket_1 role=worker + +stdout | test/job.test.ts > async job > returns started immediately and later marks the job succeeded +[job] async job finished jobId=job_1 status=succeeded +[job] completion trigger session=worker_ticket_1 jobId=job_1 + +stdout | test/job.test.ts > async job > returns started immediately and later marks the job succeeded +[harness] ExecutorSession turn session=worker_ticket_1 + +stdout | test/job.test.ts > async job > returns started immediately and later marks the job succeeded +[harness] async-react step=0 session=worker_ticket_1 role=worker + +stdout | test/job.test.ts > async job > returns started immediately and later marks the job succeeded +[daemon] stop + +stdout | test/job.test.ts > async job > does not throw if the store closes before the worker turn runs +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[ingress] two-level fast=pass:mention-or-direct semantic=pass:explicit model=MockModel action=pass layer=semantic +[routing] shards=default triggerId=trg_login +[ingress] batch-hook thread=im:topic/bug-login triggerId=trg_login pending=1 +[engine] Intake.receive id=trg_login result=stored +[engine] Evals.batch thread=im:topic/bug-login size=1 triggerIds=trg_login +[engine] subscribe ticketId=ticket_1 thread=im:topic/bug-login +[engine] Tickets.create ticketId=ticket_1 title=@lofibot please fix the login timeout on checkout speculative=false +[engine] Evals.accept thread=im:topic/bug-login ticketId=ticket_1 strength=explicit +[reply] ack-suppressed ticketId=ticket_1 channel=im reason=conversational +[harness] session journal jsonl dir=/var/folders/hb/d5qrt86d36s3jlpw46lr9zj40000gn/T/lofibot-PuOrI3/sessions +[harness] MainSession start session=router role=router resident=true +[harness] dual-layer routers=router ExecutorSession=worker_ticket_1 ticketId=ticket_1 +[daemon] stop + +stdout | test/job.test.ts > async job > does not throw if the store closes before the worker turn runs +[harness] worker skipped ticketId=ticket_1 ticket-missing + + ✓ test/job.test.ts (3 tests) 320ms + ✓ test/mcp-invoke.test.ts (6 tests) 610ms +stdout | test/mcp-registry.test.ts > ToolRegistry with an MCP source > exposes namespaced MCP tools to workers only and routes their calls +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/mcp-registry.test.ts > ToolRegistry with an MCP source > exposes namespaced MCP tools to workers only and routes their calls +[daemon] stop + +stdout | test/mcp-registry.test.ts > ToolRegistry with an MCP source > refuses MCP tool calls from the router role +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/mcp-registry.test.ts > ToolRegistry with an MCP source > refuses MCP tool calls from the router role +[daemon] stop + + ✓ test/mcp-registry.test.ts (2 tests) 53ms + ✓ test/mcp-config.test.ts (9 tests) 3ms +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 +[ingress] two-level fast=pass:mention-or-direct semantic=pass:explicit model=MockModel action=pass layer=semantic +[routing] shards=default triggerId=trg_secret +[ingress] batch-hook thread=im:topic/secret triggerId=trg_secret pending=1 +[engine] Intake.receive id=trg_secret result=stored +[engine] Evals.batch thread=im:topic/secret size=1 triggerIds=trg_secret +[engine] subscribe ticketId=ticket_1 thread=im:topic/secret +[engine] Tickets.create ticketId=ticket_1 title=leaked [redacted] here speculative=false +[engine] Evals.accept thread=im:topic/secret ticketId=ticket_1 strength=explicit +[reply] ack-suppressed ticketId=ticket_1 channel=im reason=conversational +[harness] session journal jsonl dir=/var/folders/hb/d5qrt86d36s3jlpw46lr9zj40000gn/T/lofibot-87WyYC/sessions +[harness] MainSession start session=router role=router resident=true +[harness] dual-layer routers=router ExecutorSession=worker_ticket_1 ticketId=ticket_1 + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[harness] MainSession turn session=router + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[harness] async-react step=0 session=router role=router + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[daemon] stop +[harness] async-react step=1 session=router role=router + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[mesh] place ticketId=ticket_1 node=local +[harness] ExecutorSession start session=worker_ticket_1 ticketId=ticket_1 role=worker +[engine] Assignments.start ticketId=ticket_1 assignmentId=asg_1 session=worker_ticket_1 +[engine] Assignments.placed ticketId=ticket_1 assignmentId=asg_1 node=local + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[harness] ExecutorSession turn session=worker_ticket_1 + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[mcp] connect failed server=krene error=spawn /definitely/not/krene-mcp ENOENT + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[mcp] skipping server=krene reason=not-connected + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[harness] async-react step=0 session=worker_ticket_1 role=worker + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[env] bash session=worker_ticket_1 isolated=false code=71 + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[harness] async-react step=1 session=worker_ticket_1 role=worker + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[env] write_file session=worker_ticket_1 isolated=false path=notes.txt + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[harness] async-react step=2 session=worker_ticket_1 role=worker + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[job] async job started jobId=job_1 status=started + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[harness] async-react step=3 session=worker_ticket_1 role=worker + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +deliver=true ticketId=ticket_1 + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[harness] MainSession turn session=router + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[harness] async-react step=0 session=router role=router + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[channel] norm=im ticketId=ticket_1 purpose=result +[reply] purpose=result ticketId=ticket_1 channel=im thread=topic/secret text=ready: investigation recorded +[outbox] enqueue outboxId=outbox_1 replyId=reply_1 channel=im thread=topic/secret ticketId=ticket_1 + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[harness] async-react step=1 session=router role=router + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[collab] turn paused session=worker_ticket_1 role=worker ticketId=ticket_1 step=4 reason=ticket ended + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > redacts credentials supplied through an MCP server env +[job] async job skipped jobId=job_1 ticket=ended + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > starts when the MCP configuration is unreadable +[mcp] LOFIBOT_MCP_SERVERS ignored: Unexpected token 'o', "not json" is not valid JSON +[connector] enabled=false services=calendar,gmail,drive,docs,sheets,slides,tasks pollIntervalMinutes=15 indexMaxRecords=5000 indexMaxAgeDays=180 +[connector] wake enabled=false services=gmail,calendar target=cli:local minIntervalMinutes=120 maxPerDay=3 +[proactive] enabled=false intervalMinutes=30 tz=Asia/Shanghai quiet=23:00-08:00 minIntervalMinutes=180 maxPerDay=2 +[runtime] instance=local meshCapacity=4 meshQueue=100 shards=1 +[runtime] model=MockModel +[fill] vault=missing target=none +[ingress] slow-path mode=rules timeoutMs=3000 + +stdout | test/mcp-runtime.test.ts > Runtime MCP configuration > starts when the MCP configuration is unreadable +[daemon] stop + + ✓ test/mcp-runtime.test.ts (2 tests) 1523ms + ✓ Runtime MCP configuration > redacts credentials supplied through an MCP server env 1481ms + ✓ test/tool-spec-schema.test.ts (1 test) 1ms + + Test Files 13 passed (13) + Tests 89 passed (89) + Start at 07:04:43 + Duration 11.80s (transform 481ms, setup 0ms, collect 1.87s, tests 8.51s, environment 1ms, prepare 418ms) diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-repro.mjs b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-repro.mjs new file mode 100644 index 00000000..cf998b60 --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-repro.mjs @@ -0,0 +1,49 @@ +import assert from 'node:assert/strict' +import fs from 'node:fs' +import path from 'node:path' +import os from 'node:os' +import { pathToFileURL } from 'node:url' +const repo = process.argv[2] +const mod = p => import(pathToFileURL(path.join(repo, p)).href) +const { ToolRegistry } = await mod('src/harness/tools.ts') +const { Store } = await mod('src/store/sqlite.ts') +const { HttpOpenAI } = await mod('src/harness/model.ts') +const home = fs.mkdtempSync(path.join(os.tmpdir(), 'lofibot-audit-main-')) +const store = new Store(home) +const actual = [] +const registry = new ToolRegistry({ + store, ports: {router:{},worker:{},watchdog:{}}, + env:{ bash:async (...args)=> {actual.push(args);return {code:0,stdout:'',stderr:''}}, writeFile:async(...args)=>{actual.push(args);return 'fixture'} }, + metrics:{increment(){}},redact:x=>x,log:()=>{},scheduleJob:()=>{},routerTurn:async()=>{}, + mcp:{ specs:async()=>[],invoke:async name=>({executed:name}),close:async()=>{} } +}) +const session={role:'worker',sessionId:'worker_attacker',ticketId:'ticket_attacker'} +const call=(name,args)=>registry.invoke({id:'call-'+name,name,args},session) +try { + const visible=(await registry.specsFor('worker')).map(t=>t.name) + const missing=['spawn_team','team_status','complete_team','publish_feature_pr'].filter(t=>visible.includes(t)) + assert.equal(missing.length,4); console.log('BUG unavailable tools advertised:',JSON.stringify(missing)) + await call('bash',{command:{oops:true}}) + assert.equal(actual.at(-1)[1],'[object Object]');console.log('BUG wrong bash argument reached executor:',JSON.stringify(actual.at(-1))) + await call('write_file',{path:'existing.txt'}) + assert.equal(actual.at(-1)[2],'');console.log('BUG missing write body reaches executor as empty string:',JSON.stringify(actual.at(-1))) + const job=store.createJob({sessionId:'worker_foreign',ticketId:'ticket_foreign',name:'foreign'}) + console.log('BUG foreign job stop:',JSON.stringify(await call('stop_job',{jobId:job.id})),store.getJob(job.id).status) + assert.equal(store.getJob(job.id).status,'stopped') + const absent=await call('stop_job',{jobId:'missing-job'});assert.equal(absent.status,'stopped');console.log('BUG nonexistent job stop reports:',JSON.stringify(absent)) + const hidden=await call('mcp__fake__not_listed',{});assert.equal(hidden.executed,'mcp__fake__not_listed');console.log('BUG undiscovered MCP forwarded:',JSON.stringify(hidden)) + console.log('BUG create_worker no launch:',JSON.stringify(await registry.invoke({id:'create',name:'create_worker',args:{title:'work'}},{role:'router',sessionId:'router'}))) + console.log('BUG absent nudge callback reports:',JSON.stringify(await registry.invoke({id:'nudge',name:'nudge_worker',args:{ticketId:'missing'}},{role:'watchdog',sessionId:'watchdog'}))) + const fetchBefore=globalThis.fetch + const model=new HttpOpenAI('http://fixture.invalid','fixture-key','fixture-model') + try { + for(const value of ['null','[]','"text"','42']){ + globalThis.fetch=async()=>new Response(JSON.stringify({choices:[{message:{tool_calls:[{id:'id',function:{name:'bash',arguments:value}}]}}]}),{headers:{'content-type':'application/json'}}) + const out=await model.complete({role:'worker',messages:[],tools:[]}) + assert.equal(out.toolCalls.length,1); console.log('BUG OpenAI accepts non-object args:',value,JSON.stringify(out.toolCalls)) + } + globalThis.fetch=async()=>new Response(JSON.stringify({choices:[{message:{tool_calls:[{id:'same',function:{name:'bash',arguments:'{}'}},{id:'same',function:{name:'bash',arguments:'{}'}}]}}]})) + const out=await model.complete({role:'worker',messages:[],tools:[]});assert.equal(out.toolCalls.length,2);console.log('BUG OpenAI accepts duplicate call IDs:',JSON.stringify(out.toolCalls)) + } finally {globalThis.fetch=fetchBefore} + console.log('Audit assertions verified; no production shell/model/MCP/network operation performed.') +}finally{store.close();fs.rmSync(home,{recursive:true,force:true})} diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-repro.txt b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-repro.txt new file mode 100644 index 00000000..5b327a9d --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-repro.txt @@ -0,0 +1,16 @@ +BUG unavailable tools advertised: ["spawn_team","team_status","complete_team","publish_feature_pr"] +BUG wrong bash argument reached executor: ["worker_attacker","[object Object]",{"isolated":false}] +BUG missing write body reaches executor as empty string: ["worker_attacker","existing.txt","",{"isolated":false}] +BUG foreign job stop: {"status":"stopped","jobId":"job_1"} stopped +BUG nonexistent job stop reports: {"status":"stopped","jobId":"missing-job"} +BUG undiscovered MCP forwarded: {"executed":"mcp__fake__not_listed"} +BUG create_worker no launch: {"status":"engine-assigns"} +BUG absent nudge callback reports: {"nudged":"missing"} +BUG OpenAI accepts non-object args: null [{"id":"id","name":"bash","args":null}] +BUG OpenAI accepts non-object args: [] [{"id":"id","name":"bash","args":[]}] +BUG OpenAI accepts non-object args: "text" [{"id":"id","name":"bash","args":"text"}] +BUG OpenAI accepts non-object args: 42 [{"id":"id","name":"bash","args":42}] +BUG OpenAI accepts duplicate call IDs: [{"id":"same","name":"bash","args":{}},{"id":"same","name":"bash","args":{}}] +Audit assertions verified; no production shell/model/MCP/network operation performed. +(node:46369) ExperimentalWarning: SQLite is an experimental feature and might change at any time +(Use `node --trace-warnings ...` to show where the warning was created) diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-trace-repro.mjs b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-trace-repro.mjs new file mode 100644 index 00000000..a2118d68 --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-trace-repro.mjs @@ -0,0 +1,47 @@ +import assert from 'node:assert/strict' +import fs from 'node:fs' +import path from 'node:path' +import os from 'node:os' +import { createRequire } from 'node:module' +import { pathToFileURL } from 'node:url' +const repo=process.argv[2], require=createRequire(path.join(repo,'package.json')) +const mod=p=>import(pathToFileURL(path.join(repo,p)).href) +const {InMemorySpanExporter}=await import(pathToFileURL(require.resolve('@opentelemetry/sdk-trace')).href) +const {createAgentTracing}=await mod('src/harness/tracing.ts') +const {runTurn}=await mod('src/harness/loop.ts') +const {ToolRegistry}=await mod('src/harness/tools.ts') +const {SessionJournal}=await mod('src/harness/session.ts') +const {Store}=await mod('src/store/sqlite.ts') +const {Metrics}=await mod('src/metrics/metrics.ts') +const home=fs.mkdtempSync(path.join(os.tmpdir(),'lofibot-audit-trace-')),store=new Store(home),metrics=new Metrics(home) +const exporter=new InMemorySpanExporter(),tracing=createAgentTracing({LOFIBOT_TRACE_ENABLED:'1'},x=>x,exporter) +assert.ok(tracing,'locked SDK must initialize') +const tools=new ToolRegistry({store,metrics,ports:{router:{},worker:{},watchdog:{}},env:{bash:async()=>({code:1,stdout:'',stderr:'fixture failed'})},redact:x=>x,log:()=>{},scheduleJob:()=>{},routerTurn:async()=>{}}) +const journal=new SessionJournal(path.join(home,'sessions'),store,()=>{}) +const run=async(id,complete,maxSteps)=>runTurn({model:{name:'fixture',classify:()=>({pass:true,strength:'explicit',reason:'fixture'}),complete},tools,tracing,journal,metrics,redact:x=>x,log:()=>{},session:{role:'worker',id},prompt:'fixture',maxSteps}) +try{ + await run('model_failed',async()=>{throw new Error('fixture model failure')}) + await tracing.flush() + let spans=exporter.getFinishedSpans(),root=spans.find(s=>s.name==='agent.turn') + assert.equal(root.status.code,1);assert.equal(spans.find(s=>s.name==='model.complete').status.code,2) + console.log('BUG model throws: model ERROR=2, agent.turn OK=1, root output/outcome:',JSON.stringify(root.attributes)) + exporter.reset();let n=0 + await run('shell_failed',async()=>n++===0?{toolCalls:[{id:'shell',name:'bash',args:{command:'exit 1'}}]}:{text:'done'}) + await tracing.flush();spans=exporter.getFinishedSpans() + const shell=spans.find(s=>s.name==='tool.invoke');assert.equal(shell.status.code,1);assert.equal(JSON.parse(shell.attributes['output.value']).code,1) + console.log('BUG shell code1: tool span OK=1, output:',shell.attributes['output.value']) + exporter.reset() + await run('limit',async()=>({toolCalls:[{id:'list',name:'read_file',args:{path:'fixture'}}]}),1) + await tracing.flush();root=exporter.getFinishedSpans().find(s=>s.name==='agent.turn') + console.log('GAP maxSteps reached: root OK with no explicit outcome:',JSON.stringify(root.attributes)) + const ts=await import(pathToFileURL(require.resolve('typescript')).href) + const source=fs.readFileSync(path.join(repo,'src/harness/tracing.ts'),'utf8')+'\nexport { capture };' + const js=ts.transpileModule(source,{compilerOptions:{module:ts.ModuleKind.ESNext,target:ts.ScriptTarget.ES2022}}).outputText + const {capture}=await import('data:text/javascript;base64,'+Buffer.from(js).toString('base64')) + for(const size of [4,500]){ + const input={role:'worker',messages:Array.from({length:64},()=>({role:'user',content:'x'.repeat(size)})),tools:Array.from({length:20},(_,i)=>({name:'tool_'+i,description:'fixture',parameters:{type:'object'}}))} + const out=capture(input,x=>x),kept=input.tools.filter(t=>out.includes('"'+t.name+'"')).length + assert.ok(kept<20);console.log('BUG trace capture tool names retained:',JSON.stringify({messageChars:size,retained:kept,total:20,wholeObjectPreview:!!JSON.parse(out).preview})) + } + console.log('Real locked OpenTelemetry SDK + InMemorySpanExporter used. No external collector/model/shell required.') +}finally{await tracing.shutdown();store.close();fs.rmSync(home,{recursive:true,force:true})} diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-trace-repro.txt b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-trace-repro.txt new file mode 100644 index 00000000..68963727 --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/main-trace-repro.txt @@ -0,0 +1,8 @@ +(node:53602) ExperimentalWarning: SQLite is an experimental feature and might change at any time +(Use `node --trace-warnings ...` to show where the warning was created) +BUG model throws: model ERROR=2, agent.turn OK=1, root output/outcome: {"openinference.span.kind":"CHAIN","session.id":"model_failed","lofibot.role":"worker"} +BUG shell code1: tool span OK=1, output: {"code":1,"stdout":"","stderr":"fixture failed"} +GAP maxSteps reached: root OK with no explicit outcome: {"openinference.span.kind":"CHAIN","session.id":"limit","lofibot.role":"worker"} +BUG trace capture tool names retained: {"messageChars":4,"retained":12,"total":20,"wholeObjectPreview":false} +BUG trace capture tool names retained: {"messageChars":500,"retained":0,"total":20,"wholeObjectPreview":true} +Real locked OpenTelemetry SDK + InMemorySpanExporter used. No external collector/model/shell required. diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-audit.mjs b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-audit.mjs new file mode 100644 index 00000000..b3b951ff --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-audit.mjs @@ -0,0 +1,11 @@ +import fs from 'node:fs';import path from 'node:path';import os from 'node:os';import {fileURLToPath} from 'node:url';import {setTimeout as delay} from 'node:timers/promises'; +import {McpToolSource} from '../../../../src/harness/mcp.ts'; +const root=fs.mkdtempSync(path.join(os.tmpdir(),'lofibot-mcp-audit-'));const server=fileURLToPath(new URL('./server.mjs',import.meta.url));const results=[];let count=0;const record=(name,data)=>{results.push({name,...data});console.log(JSON.stringify(results.at(-1)));}; +async function source(scenario,opts={}){const dir=path.join(root,'mcp-case-'+(++count));fs.rmSync(dir,{recursive:true,force:true});fs.mkdirSync(dir,{recursive:true});const logfile=path.join(dir,'server.jsonl'),workspace=path.join(dir,'workspace'),logs=[];fs.mkdirSync(workspace);const client=new McpToolSource([{name:'fixture',command:process.execPath,args:[server,scenario,logfile],env:{},timeoutMs:opts.timeoutMs??2000}],{log:l=>logs.push(l),metrics:{increment(){}},redact:s=>s.replaceAll('TOKEN_AUDIT_SENTINEL','[redacted]'),spill:{put:()=> 'spill'},workspaceDir:workspace,listTimeoutMs:opts.listTimeoutMs??1000});return {client,dir,workspace,logs,events:()=>fs.existsSync(logfile)?fs.readFileSync(logfile,'utf8').trim().split('\n').map(JSON.parse):[]};} +for(const wait of [250,1300]){const s=await source('normal',{timeoutMs:60});await s.client.specs();const started=Date.now();let error;try{await s.client.invoke('mcp__fixture__delayed',{delay:wait});}catch(e){error=e.message;}const returned=Date.now();const immediate=s.events().filter(e=>e.message?.method==='notifications/cancelled');await delay(wait+150);record('timeout-'+wait,{error,returnedAfterMs:returned-started,cancelAtReturn:immediate.length,timeline:s.events().filter(e=>e.event==='side-effect'||e.message?.method==='notifications/cancelled').map(e=>({event:e.event,method:e.message?.method,afterMs:e.at-started}))});await s.client.close();} +{const s=await source('slow-list',{listTimeoutMs:60});const a=await s.client.specs();await delay(300);const b=await s.client.specs();record('discovery-cache-and-unlisted',{first:a.length,second:b.length,listRequests:s.events().filter(e=>e.event==='list').length,hidden:await s.client.invoke('mcp__fixture__unlisted_delete',{}),logs:s.logs});await s.client.close();} +{const s=await source('normal');const a=await s.client.specs();await s.client.invoke('mcp__fixture__change',{});await delay(100);const b=await s.client.specs();record('schema-snapshot-and-name',{first:a[0].parameters,second:b[0].parameters,call:await s.client.invoke('mcp__fixture__echo',{value:'old-string'}),names:b.map(x=>({name:x.name,length:x.name.length})),listRequests:s.events().filter(e=>e.event==='list').length});await s.client.close();} +{const s=await source('normal');await s.client.specs();const mask=process.umask(0o022);const r=await s.client.invoke('mcp__fixture__resource',{});process.umask(mask);record('resource-redaction-and-permissions',{body:fs.readFileSync(r.paths[0],'utf8'),fileMode:(fs.statSync(r.paths[0]).mode&0o777).toString(8),dirMode:(fs.statSync(path.dirname(r.paths[0])).mode&0o777).toString(8)});const paths=[];for(let i=0;i<3;i++){const b=await s.client.invoke('mcp__fixture__binary',{megabytes:7});paths.push(b.paths[0]);}record('binary-size-and-type',{sizes:paths.map(p=>fs.statSync(p).size),totalBytes:paths.reduce((n,p)=>n+fs.statSync(p).size,0),firstBytes:fs.readFileSync(paths[0]).subarray(0,8).toString(),files:fs.readdirSync(path.dirname(paths[0])).length});await s.client.close();} +{const s=await source('normal');await s.client.specs();const outside=path.join(s.dir,'outside');fs.mkdirSync(outside);fs.symlinkSync(outside,path.join(s.workspace,'fixture'),'dir');const r=await s.client.invoke('mcp__fixture__resource',{});record('symlink-artifact-escape',{returnedPath:r.paths[0],realPath:fs.realpathSync(r.paths[0]),outsideFiles:fs.readdirSync(outside)});await s.client.close();} +{const s=await source('normal');await s.client.specs();let error;try{await s.client.invoke('mcp__fixture__binary',{megabytes:11});}catch(e){error=e.message;}record('sdk-oversize-message',{decodedMegabytes:11,error});await s.client.close();} +fs.writeFileSync(path.join(root,'mcp-results.json'),JSON.stringify({baseline:'a91f6435c5811d970d3cecdc316b5bfb8f434d31',results},null,2)); diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-1/server.jsonl b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-1/server.jsonl new file mode 100644 index 00000000..d0158cf8 --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-1/server.jsonl @@ -0,0 +1,6 @@ +{"at":1796079613463,"event":"received","message":{"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"lofibot-fixture","version":"0.1.0"}},"jsonrpc":"2.0","id":0}} +{"at":1796079613466,"event":"received","message":{"method":"notifications/initialized","jsonrpc":"2.0"}} +{"at":1796079613466,"event":"received","message":{"method":"tools/list","jsonrpc":"2.0","id":1}} +{"at":1796079613466,"event":"list","version":1} +{"at":1796079613469,"event":"received","message":{"method":"tools/call","params":{"name":"delayed","arguments":{"delay":250}},"jsonrpc":"2.0","id":2}} +{"at":1796079613720,"event":"side-effect","name":"delayed"} diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-2/server.jsonl b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-2/server.jsonl new file mode 100644 index 00000000..0493fe37 --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-2/server.jsonl @@ -0,0 +1,7 @@ +{"at":1796079613966,"event":"received","message":{"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"lofibot-fixture","version":"0.1.0"}},"jsonrpc":"2.0","id":0}} +{"at":1796079613967,"event":"received","message":{"method":"notifications/initialized","jsonrpc":"2.0"}} +{"at":1796079613967,"event":"received","message":{"method":"tools/list","jsonrpc":"2.0","id":1}} +{"at":1796079613967,"event":"list","version":1} +{"at":1796079613969,"event":"received","message":{"method":"tools/call","params":{"name":"delayed","arguments":{"delay":1300}},"jsonrpc":"2.0","id":2}} +{"at":1796079615030,"event":"received","message":{"jsonrpc":"2.0","method":"notifications/cancelled","params":{"requestId":2,"reason":"McpError: MCP error -32001: Request timed out"}}} +{"at":1796079615270,"event":"side-effect","name":"delayed"} diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-3/server.jsonl b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-3/server.jsonl new file mode 100644 index 00000000..5e96e9cb --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-3/server.jsonl @@ -0,0 +1,5 @@ +{"at":1796079615513,"event":"received","message":{"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"lofibot-fixture","version":"0.1.0"}},"jsonrpc":"2.0","id":0}} +{"at":1796079615513,"event":"received","message":{"method":"notifications/initialized","jsonrpc":"2.0"}} +{"at":1796079615514,"event":"received","message":{"method":"tools/list","jsonrpc":"2.0","id":1}} +{"at":1796079615514,"event":"list","version":1} +{"at":1796079615848,"event":"received","message":{"method":"tools/call","params":{"name":"unlisted_delete","arguments":{}},"jsonrpc":"2.0","id":2}} diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-4/server.jsonl b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-4/server.jsonl new file mode 100644 index 00000000..31d7c23c --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-4/server.jsonl @@ -0,0 +1,6 @@ +{"at":1796079615876,"event":"received","message":{"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"lofibot-fixture","version":"0.1.0"}},"jsonrpc":"2.0","id":0}} +{"at":1796079615876,"event":"received","message":{"method":"notifications/initialized","jsonrpc":"2.0"}} +{"at":1796079615877,"event":"received","message":{"method":"tools/list","jsonrpc":"2.0","id":1}} +{"at":1796079615877,"event":"list","version":1} +{"at":1796079615877,"event":"received","message":{"method":"tools/call","params":{"name":"change","arguments":{}},"jsonrpc":"2.0","id":2}} +{"at":1796079615980,"event":"received","message":{"method":"tools/call","params":{"name":"echo","arguments":{"value":"old-string"}},"jsonrpc":"2.0","id":3}} diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-5/server.jsonl b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-5/server.jsonl new file mode 100644 index 00000000..36d52564 --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-5/server.jsonl @@ -0,0 +1,8 @@ +{"at":1796079616008,"event":"received","message":{"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"lofibot-fixture","version":"0.1.0"}},"jsonrpc":"2.0","id":0}} +{"at":1796079616009,"event":"received","message":{"method":"notifications/initialized","jsonrpc":"2.0"}} +{"at":1796079616009,"event":"received","message":{"method":"tools/list","jsonrpc":"2.0","id":1}} +{"at":1796079616009,"event":"list","version":1} +{"at":1796079616012,"event":"received","message":{"method":"tools/call","params":{"name":"resource","arguments":{}},"jsonrpc":"2.0","id":2}} +{"at":1796079616014,"event":"received","message":{"method":"tools/call","params":{"name":"binary","arguments":{"megabytes":7}},"jsonrpc":"2.0","id":3}} +{"at":1796079616236,"event":"received","message":{"method":"tools/call","params":{"name":"binary","arguments":{"megabytes":7}},"jsonrpc":"2.0","id":4}} +{"at":1796079616445,"event":"received","message":{"method":"tools/call","params":{"name":"binary","arguments":{"megabytes":7}},"jsonrpc":"2.0","id":5}} diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-6/server.jsonl b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-6/server.jsonl new file mode 100644 index 00000000..b09b7b63 --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-6/server.jsonl @@ -0,0 +1,5 @@ +{"at":1796079616620,"event":"received","message":{"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"lofibot-fixture","version":"0.1.0"}},"jsonrpc":"2.0","id":0}} +{"at":1796079616622,"event":"received","message":{"method":"notifications/initialized","jsonrpc":"2.0"}} +{"at":1796079616622,"event":"received","message":{"method":"tools/list","jsonrpc":"2.0","id":1}} +{"at":1796079616622,"event":"list","version":1} +{"at":1796079616625,"event":"received","message":{"method":"tools/call","params":{"name":"resource","arguments":{}},"jsonrpc":"2.0","id":2}} diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-7/server.jsonl b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-7/server.jsonl new file mode 100644 index 00000000..f14f4138 --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-case-7/server.jsonl @@ -0,0 +1,5 @@ +{"at":1796079616665,"event":"received","message":{"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"lofibot-fixture","version":"0.1.0"}},"jsonrpc":"2.0","id":0}} +{"at":1796079616666,"event":"received","message":{"method":"notifications/initialized","jsonrpc":"2.0"}} +{"at":1796079616666,"event":"received","message":{"method":"tools/list","jsonrpc":"2.0","id":1}} +{"at":1796079616666,"event":"list","version":1} +{"at":1796079616668,"event":"received","message":{"method":"tools/call","params":{"name":"binary","arguments":{"megabytes":11}},"jsonrpc":"2.0","id":2}} diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-output.jsonl b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-output.jsonl new file mode 100644 index 00000000..c6ce9a65 --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-output.jsonl @@ -0,0 +1,8 @@ +{"name":"timeout-250","error":"mcp tool mcp__fixture__delayed timed out after 60ms","returnedAfterMs":62,"cancelAtReturn":0,"timeline":[{"event":"side-effect","afterMs":252}]} +{"name":"timeout-1300","error":"mcp tool mcp__fixture__delayed timed out after 60ms","returnedAfterMs":61,"cancelAtReturn":0,"timeline":[{"event":"received","method":"notifications/cancelled","afterMs":1061},{"event":"side-effect","afterMs":1301}]} +{"name":"discovery-cache-and-unlisted","first":0,"second":0,"listRequests":1,"hidden":"{\"name\":\"unlisted_delete\",\"args\":{},\"version\":1}","logs":["[mcp] connected server=fixture","[mcp] skipping server=fixture reason=list-timeout"]} +{"name":"schema-snapshot-and-name","first":{"type":"object","properties":{"value":{"type":"string"}}},"second":{"type":"object","properties":{"value":{"type":"string"}}},"call":"{\"name\":\"echo\",\"args\":{\"value\":\"old-string\"},\"version\":2}","names":[{"name":"mcp__fixture__echo","length":18},{"name":"mcp__fixture__bad.name.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","length":113}],"listRequests":1} +{"name":"resource-redaction-and-permissions","body":"TOKEN_AUDIT_SENTINEL","fileMode":"644","dirMode":"755"} +{"name":"binary-size-and-type","sizes":[7340032,7340032,7340032],"totalBytes":22020096,"firstBytes":"AAAAAAAA","files":4} +{"name":"symlink-artifact-escape","returnedPath":"/private/tmp/lofibot-tool-audit/mcp-case-6/workspace/fixture/30d041c0-f63b-418a-a98f-c5d561376189.txt","realPath":"/private/tmp/lofibot-tool-audit/mcp-case-6/outside/30d041c0-f63b-418a-a98f-c5d561376189.txt","outsideFiles":["30d041c0-f63b-418a-a98f-c5d561376189.txt"]} +{"name":"sdk-oversize-message","decodedMegabytes":11,"error":"mcp tool mcp__fixture__binary failed: MCP error -32000: Connection closed"} diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-results.json b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-results.json new file mode 100644 index 00000000..9544faee --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/mcp-results.json @@ -0,0 +1,106 @@ +{ + "baseline": "a91f6435c5811d970d3cecdc316b5bfb8f434d31", + "results": [ + { + "name": "timeout-250", + "error": "mcp tool mcp__fixture__delayed timed out after 60ms", + "returnedAfterMs": 62, + "cancelAtReturn": 0, + "timeline": [ + { + "event": "side-effect", + "afterMs": 252 + } + ] + }, + { + "name": "timeout-1300", + "error": "mcp tool mcp__fixture__delayed timed out after 60ms", + "returnedAfterMs": 61, + "cancelAtReturn": 0, + "timeline": [ + { + "event": "received", + "method": "notifications/cancelled", + "afterMs": 1061 + }, + { + "event": "side-effect", + "afterMs": 1301 + } + ] + }, + { + "name": "discovery-cache-and-unlisted", + "first": 0, + "second": 0, + "listRequests": 1, + "hidden": "{\"name\":\"unlisted_delete\",\"args\":{},\"version\":1}", + "logs": [ + "[mcp] connected server=fixture", + "[mcp] skipping server=fixture reason=list-timeout" + ] + }, + { + "name": "schema-snapshot-and-name", + "first": { + "type": "object", + "properties": { + "value": { + "type": "string" + } + } + }, + "second": { + "type": "object", + "properties": { + "value": { + "type": "string" + } + } + }, + "call": "{\"name\":\"echo\",\"args\":{\"value\":\"old-string\"},\"version\":2}", + "names": [ + { + "name": "mcp__fixture__echo", + "length": 18 + }, + { + "name": "mcp__fixture__bad.name.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + "length": 113 + } + ], + "listRequests": 1 + }, + { + "name": "resource-redaction-and-permissions", + "body": "TOKEN_AUDIT_SENTINEL", + "fileMode": "644", + "dirMode": "755" + }, + { + "name": "binary-size-and-type", + "sizes": [ + 7340032, + 7340032, + 7340032 + ], + "totalBytes": 22020096, + "firstBytes": "AAAAAAAA", + "files": 4 + }, + { + "name": "symlink-artifact-escape", + "returnedPath": "/private/tmp/lofibot-tool-audit/mcp-case-6/workspace/fixture/30d041c0-f63b-418a-a98f-c5d561376189.txt", + "realPath": "/private/tmp/lofibot-tool-audit/mcp-case-6/outside/30d041c0-f63b-418a-a98f-c5d561376189.txt", + "outsideFiles": [ + "30d041c0-f63b-418a-a98f-c5d561376189.txt" + ] + }, + { + "name": "sdk-oversize-message", + "decodedMegabytes": 11, + "error": "mcp tool mcp__fixture__binary failed: MCP error -32000: Connection closed" + } + ] +} \ No newline at end of file diff --git a/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/server.mjs b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/server.mjs new file mode 100644 index 00000000..ed15803e --- /dev/null +++ b/docs/dev-loop-runs/2026-12-01-tool-system/artifacts/server.mjs @@ -0,0 +1,17 @@ +import fs from 'node:fs'; +import readline from 'node:readline'; +const [scenario, logFile] = process.argv.slice(2); let version=1; +const log=(event,data={})=>fs.appendFileSync(logFile,JSON.stringify({at:Date.now(),event,...data})+'\n'); +const send=(id,result)=>process.stdout.write(JSON.stringify({jsonrpc:'2.0',id,result})+'\n'); +const listed=()=>[{name:'echo',description:'echo-v'+version,inputSchema:{type:'object',properties:{value:{type:version===1?'string':'number'}}}},{name:'bad.name.'+'x'.repeat(90),description:'long-invalid-provider-name',inputSchema:{type:'object'}}]; +readline.createInterface({input:process.stdin}).on('line',line=>{const m=JSON.parse(line);log('received',{message:m}); +if(m.method==='initialize')return send(m.id,{protocolVersion:'2025-03-26',capabilities:{tools:{listChanged:true}},serverInfo:{name:'audit-fixture',version:'1'}}); +if(m.method==='tools/list'){log('list',{version});return setTimeout(()=>send(m.id,{tools:listed()}),scenario==='slow-list'?180:0);} +if(m.method!=='tools/call')return; +const name=m.params.name; +if(name==='delayed'){const ms=m.params.arguments.delay;return setTimeout(()=>{log('side-effect',{name});send(m.id,{content:[{type:'text',text:'effect-completed'}]});},ms);} +if(name==='resource')return send(m.id,{content:[{type:'resource',resource:{uri:'audit://text',mimeType:'text/plain',text:'TOKEN_AUDIT_SENTINEL'}}]}); +if(name==='binary')return send(m.id,{content:[{type:'image',mimeType:'image/png',data:Buffer.alloc((m.params.arguments.megabytes??7)*1024*1024,65).toString('base64')}]}); +if(name==='change'){version=2;process.stdout.write(JSON.stringify({jsonrpc:'2.0',method:'notifications/tools/list_changed'})+'\n');} +send(m.id,{content:[{type:'text',text:JSON.stringify({name,args:m.params.arguments,version})}]}); +});