Skip to content

feat(coding): integrate Pi Coding SDK with durable execution - #4

Merged
syxc merged 214 commits into
masterfrom
dev/pi-durable
Nov 13, 2026
Merged

syxc merged 214 commits into
masterfrom
dev/pi-durable

Conversation

@syxc

@syxc syxc commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

直接用 durable 替换原 Coding 内核会丢失 Pi Coding 能力和插件契约。本 PR 将 Pi Coding SDK 保留为能力层,由 pi-durable 承担执行、事务、持久化及恢复,并接入 MkAgent 的会话、权限、MCP 和插件 UI。

本 PR 覆盖 master 的 8532525 至 dev/pi-durable 的 8e5d4fc,共 214 个提交。收尾提交分别收敛 SDK 依赖所有权,以及将包和物理目录统一为 @mkagent/coding-runtime、packages/coding-runtime。166cab2 修正 Linux 清理及 hoisted SDK 测试,22a3b15 进一步修复完整 CI 暴露的 bundle 资产定位、完整测试输出和运行时基线选择。8e5d4fc 修复名称严格回执完成后被排队的旧 watcher 元数据覆盖的问题,并保留真实外部改名与空名称。

  • 会话、资源、模型、插件加载、工具工厂、UI/HTML 和 MCP 优先委托 SDK,删除已覆盖的本地实现及生成规则。
  • durable 保留工具与请求任务、输入接纳、journal 原子提交、队列及旧任务恢复;必要宿主接点及退出条件有明确登记。
  • SDK 持有 Core/AI 及默认插件模块实例,避免同版本 peer 上下文形成不同类实例;生产依赖从 18 项减为 7 项。
  • 更新 workspace 锁、构建与类型检查脚本、跨包夹具、声明、许可路径和来源登记。

SDK 仍固定 Pi 1.5.0。仓内补丁提供必要协议出口与宿主接点,不能视为未修改发布包已经具备的 API。完整边界见 SDK 维护清单。

Verification

输入范围 已执行的验证
SDK 所有权修正,提交 7a59bca 对应快照 453 个不同测试通过,覆盖 SDK、产品与完整 worker bundle;独立复核通过
最终新目录,提交 79ea0f7 对应快照 95 项定向测试、695 个断言通过,包含完整 bundle-smoke 的全部 26 项
新 Task 正式安装 Bun 1.3.14,isolated、frozen lock、ignore-scripts;SDK 14/14、六个产品 workspace 62/62 声明节点通过,137/137 补丁输出匹配
声明闭包 标准源码与声明生成覆盖 117 个根、1,984 个文件,零诊断;116 份标准声明通过正式包入口严格消费,1,976 个文件零正例诊断、六个预期负例,无源码回落或额外声明增强
目录迁移 301 个受控文件迁移;299 个许可文件中 297 个字节不变,两份夹具仅改目录字串;受保护文件的 inode、模式及 blob 保持,内容未读取
锁及 SDK 生成 候选锁结构比较仅改变两处 workspace 路径及 Bun 排序,1785 条包记录和发布版本集合不变;packages/coding-runtime/scripts/patch-coding-sdk.ts <pristine-1.5.0> --check 核验 95 项输出
来源与文档 2,041 个许可 MkAgent 文件来源审计通过;13 份文档的 600 个本地链接、434 个锚点通过;独立路径复核通过

测试及安装在独立 Task HOME/TMP/cache 和确定性 provider 中执行。命令、输入与失败修正范围见 验证账本。上述结果复用已核对输入一致性的本地验收,GitHub CI 结果另行核验。

首轮 CI 43322969689 在全量测试中暴露两类测试可移植性问题,已由 166cab2 修复:6 处 fixture 清理使用共享 PATH helper,类型消费者解析实际 SDK 入口。两种正式 Bun 布局中六文件各 33 项通过;3 项隔离清理回归完成红绿,原始断言异常保持。hoisted 类型探针复现旧路径 TS2307,修复入口在两种布局严格消费零诊断,无新依赖、alias 或源码回落。当前来源审计覆盖 2,043 个许可文件,独立复核通过。完整 CI 以 Checks 中最新 head 的实际结果为准。

第二轮 CI 43328813751 的 47 个失败已按完整列表定位并由 22a3b15 修复:38 个 Buffer profile 基线、4 个清理调用、3 个大 receipt stdout,以及 Photon NODE_PATH 与 Jiti/Babel bundle 路径。两种正式布局分别通过 886 个截断、9 个 UI/loader、3 个 Photon、29 个 receipt 用例;真实 OS 慢管道完成 65,536 字节截断的红绿,全文、图片及单次副作用断言保留。SDK 正式静态 loader 开关及模块祖先内资源策略通过搬迁产物验证,真实生产构建 13 个资源已验;源码 117 入口/1,984 文件严格检查零诊断,八文件独立复核通过。依赖、lock 和 137 个 SDK 补丁产物保持。完整 CI 与三平台打包仍以最新 head 的 Checks 实际结果为准。

第三轮 CI 43335310617 的普通组已达到 6,993 pass / 0 fail(523 文件),随后隔离 fork 场景暴露已提交名称被旧 watcher header 在回合结束时覆盖。8e5d4fc 仅在真实名称变化且严格保存成功后更新排队 header 的名称,同名重复回执保持 no-op。双 store × 外部非空名/空名 4 用例完成原版红、收窄修复绿(120 断言);相关 10 文件 110 pass / 558 断言及 registration 9 pass / 48 断言通过,独立复核与真实 queue 外部改名控制均过。新测试使用内存 SDK 设置和真实 watcher handler,原 fork/worker/plugin 测试不变。本地过滤安装的 server-core 类型探针仍有与精确旧源码基线相同的 28 项诊断,不计作类型检查通过;最新完整环境的项目验证与原始隔离场景现已由 CI 通过。

最终提交 8e5d4fc 的 CI 43342529807 已全部成功:quality(安装、lint、来源、项目类型/定向验证、完整测试、WebUI/CLI、空白检查)与 mac-arm64、win-x64、linux-x64 三个平台打包。普通组 6,997 pass / 16 skip / 0 fail,共 7,013 项、524 文件;所有隔离组通过,原始双 store fork/worker/plugin 测试也已通过。

Boundaries and remaining checks

  • 新锁未重跑全 workspace 冷安装;此前全 workspace 冷安装的回执保留其旧输入范围。新目录已验证 SDK 与六产品 workspace 的正式安装。
  • 可选 archive 夹具因过滤树缺少 Root TypeScript 测试工具未运行;标准声明验收使用已有编译器工具,没有补依赖或手工 alias。
  • 既有四项浏览器输入导出/脱敏基线失败未计作本次已修复问题。真实付费模型、真实账户状态及本地跨平台验收未执行。
  • Electron 插件 UI 的行为与既有隔离 WebUI/桌面验收记录保留在账本;本次提交跟进没有重新截图。
  • 生成的 durable patch 有七处由 patch 上下文标记与原始 tab 组合产生的范围 whitespace 提示;137 项标准补丁输出及重放核验通过。

用户确定了目标、SDK 边界和合并指令;Agent 完成实现与自动复核,尚无已确认的人工逐行 diff 复核记录。

syxc and others added 30 commits November 4, 2026 05:37
Reuse independent Pi packages and reproduce native coding resources and
extension loading from pinned Pi v1.5.0 sources on the existing durable kernel.
Keep tool approval in the host and persist preparation and settlement decisions
with their next checkpoint, including stored-task migration to version 4.

Remove the historical type-only pi-agent-core production dependency. Preserve
finish markers and other fields when OpenAI SSE tool calls share a terminal
frame so the full headless CLI can complete an official hello tool round trip.

Record the implemented API groups and remaining compatibility limits. Validate
78 coding and bundle tests, 153 kernel tests, 27 SSE tests, the isolated CLI,
validate:ci, lint, source lineage, and a clean frozen install and server build.
Port the pinned Pi 1.5.0 public coding source closure with reproducible
provenance and independent package exports. Bind native sessions, tools,
queues, journals and lifecycle callbacks to the existing durable Harness.

Adopt supported legacy checkpoints atomically, preserve submission IDs,
and fail closed for uncertain request and extension effects. Persist tool
discovery and handoff controls across restart.

Ship native image modules, themes, export templates and license notices.
Validate isolated recovery on both storage backends, upstream behavior
parity, independent consumers and the standalone headless archive.
Bootstrap both extension transpilers without replacing Bun stack formatting,
including when the first imported extension was already cached.

Commit cache warming usage through an independent durable phase before
publishing entries or scheduling another request. Cancel and drain background
work when closing the host.

Rebuild native system prompts before before_agent_start so protocol prompts
received after session startup and subsequent replacements reach plugins and
model requests. Previous host tests set prompts before opening and missed the
production order. Add native and host-only regression cases and rebuild the
product subprocess in its fixture to avoid stale bundle results.

Full repository regression: 4978 pass, 11 skip, 0 fail.
validate:ci, lint, source generation and lineage checks pass.
Lint retains 106 warnings.
Move process I/O subscriptions into PiWorkerConnection and bind writes to a
product session and runtime generation. Preserve initial unscoped protocol
compatibility and reject ambiguous or stale messages after rebinding.

Keep existing startup, cancellation, stderr capture and shutdown behavior.
Check real-process foreground rebinding, lease isolation and scoped routing.

Pi client regression: 161 pass. Real conversation and Coding product tests:
5 pass. Shared typecheck, lint and source lineage audit pass.

Product adoption, retained background ownership and plugin session operations
remain in the documented D3 implementation sequence.
Scope worker commands and kernel events by product session and generation.
Keep retired source bindings limited to known background task completions
and matching stop replies, and release abandoned stop registrations.

Clear a queued compaction's exact controller when its scope is retired.
Otherwise the skipped handler never releases its ID and the target silently
loses a request reusing that ID. Cover both profiles with real worker
regressions, including the failing-before-fix admission sequence.
Route native dialogs and UI state through worker epochs, product owners and
client subscription leases. Preserve startup interaction, cancellation,
raw native input and host context until the matching prompt receipt.

Cancel pending composer writes on external replacements, including equal
empty values, and preserve Tab and Shift+Tab within dialog controls.

Validate with 5054 passing tests, 11 skips, CI checks and a packaged headless
probe. Add product factory assertions and retain documented UI boundaries.
Legacy saves swallowed write failures and removed the previous record
before replacement. Share one serial writer with strict receipts, retain
the committed record and metadata signature on failure, and roll back
product creation unless its final record is committed.

Keep cancellation effective for snapshots waiting behind an active write.
Cancelled strict receipts reject, while later admissions can still save.
Keep stable product input IDs separate from per-request prompt IDs so
retries cannot match stale receipts. Carry caller provenance through
queue replay without persisting client information.

Retire completed inputs and revoke retained leases even when Stop
follows source completion. Cover both missed boundaries with red-green
regressions and actual native worker integration.

This prepares D3.3 ownership handshakes; product session replacement
and targeted navigation remain pending.
Preserve the native command coroutine across source closure, target binding and durable publication receipts. Isolate callback listeners and retain each owner's worker leases, background tasks and completion boundary.

Require a target publication receipt on both normal and error cleanup paths. Keep fork and switch blocked until D3.4 provides stable native paths and exact anchors.

Verified with 5148 passing tests, CI validation, lint, real worker transfer chains and isolated WebUI panels.
Publish detached tree, leaf, name and native/durable/product identities only after storage receipts. Persist many-to-one product links in the same journal transaction and reject identity reassignment.

Initialize nested draft maps before writing through their stored property; mutating the object returned by nullish assignment loses the first link. Cover receipt gating, rejected writes, observer isolation and JSONL recovery.

Verified 180 package tests, package typecheck and public declaration build.
Write native JSONL and its identity manifest from journal receipts. Keep
product input IDs across queued native inputs and plugin replacement, and
strip host correlation from model context.

Projection faults still drain recovery jobs, run shutdown hooks, and retire
closed hosts. Cover those failures and input identity with deterministic
native host and real worker tests.
Route committed projection descriptors through the active worker lease and
wait for its native identity before registering a minimal product reference.

Serialize metadata snapshots behind strict receipts so projection and owner
writes preserve each other. Drain admitted writes during session flushes and
cover startup, handoff, failed persistence, and concurrent product updates.
Fork at a marker in the copied store to include document-only receipts
without changing source storage. Preserve the entire native tree and its
entry identities, map retained files, and select the requested leaf.

Keep committed trees unchanged during SDK bootstrap and reopen. Verify
SQLite and JSONL paths, inactive attachments, rejection cleanup, and cold
process SIGKILL recovery. The product fork/switch gate remains closed
until trusted path validation and owner activation are connected.
Preserve inactive product rows and stable native history metadata through
both writers, lazy loading and version 2 bundle transfers. Keep archived
source commands out of the input queue and hide internal metadata in DTOs.

Prefer precise product mappings and unique tool call/result pairs. Clear
temporary source ownership after consumption, and omit source display
caches from ordinary cutoff branches. Regression cases reproduce each
incorrect transition before its fix.

Product native fork and switch owner integration remains gated.
Require the final native source reference and check the copied journal before
path rewriting, inherited-task handling or Harness opening. Share projection
encoding and read committed state without journal initialization.

Reject conflicting target history so legacy resume cannot bypass native source
verification. Preserve legacy envelope data after consecutive path-remapped
forks and compare envelope identity fields instead.

Add SQLite and JSONL rejection, consecutive fork and read-only journal checks.
Verify prepared anchors, closed source references and complete bound target
trees before publishing native forks. Preserve archived product messages,
attachments and final names across repeated forks and restart.

Track each handled input's foreground actions. The preceding run's
settlement must not suppress completion, and a command's new model work
must finish before reporting the command complete.

Validate with CI, lint, Craft provenance and 93 targeted tests covering
572 assertions. Keep switch, parentSession and global name sync pending.
Persist summary responses and usage under pi-durable task ownership while
keeping original routing and credentials in the live request binding.
Fail closed after a native requester is lost instead of repeating its model
request. Merge caller and task signals so slow abort persistence cannot keep
the provider running after cancellation.

Cover SIGKILL admission, request and response boundaries, native compaction,
branch and bug-report summaries, owner identity and delayed abort commits.
Keep stable identity and original plugin content through durable input queues.
Materialize linked product rows and image files before assistant output, and
repair equal-revision transcripts when a cold worker opens the journal.

Serialize projection files through strict product receipts. Preserve committed
history on abort, and release a closed writer even when its projection failed.
Red-green product regressions cover missing rows, stop and release recovery;
path regressions prevent trailing separators from rejecting valid images.
Resolve native trust hooks and owned product UI before loading project
resources or either MCP configuration. Keep host precedence, headless
rejection, remembered decisions and missing-package skip behavior.

Keep prepared resources owned by the kernel and refresh them on reload.
Synchronize codemode registration with reloaded MCP exposure so trust
revocation cannot strand global tools. Pin both regressions with tests
that failed before the fixes, including the real product worker path.
Reuse pinned PKCE authorization through owner-scoped RPC commands and
retain authentication-required servers without automatic interaction.

Serialize login and logout with the native shared refresh lock. The
previous connection-local drain could not prevent another worker from
restoring a grant after logout. Allow cancellation before lock admission,
require secure OAuth resource URLs, and accept native auto registration.

Verify token rotation, actual subprocess coordination and product UI
cancellation using isolated local servers without model requests.
syxc added 29 commits November 12, 2026 02:17
Preserve complete tool results across failed hooks and cold cancellation, and release parallel delivery gates when a tool fails without an end event.

Record targeted recovery, type comparison and independent review results while keeping isolated worker and full acceptance gaps open.
Declare the MCP SDK required by GenAI declarations and limit Gaxios fetch compliance to its call signature.

Physical SDK declaration checks pass with default libraries. Record the remaining DOM diagnostics, failed isolated installations and limited review evidence.
Include standard DOM declarations required by GenAI, MCP and Photon in the Coding package. Retain Bun and Node types and leave the root compiler settings unchanged.

The physical SDK declaration check passes with the package configuration. Public package loading and full installation remain blocked.
Use SDK-owned Core and AI instances, plugin modules and model construction. Rename the package and remove unused or test-only production dependencies.

Validate frozen SDK and product installations, 453 distinct tests, strict emitted declarations and source lineage.
Move the workspace to packages/coding-runtime and update build, typecheck, fixture, documentation and provenance paths. Preserve protected file inodes and existing Git blobs.

Regenerate the lock with Bun, verify frozen SDK and product installs, run 95 targeted tests and consume all 116 emitted declarations strictly.
The full Linux CI suite failed because cleanup required a macOS-only trash path and the type fixture assumed a package-local SDK directory. Use PATH-based best-effort fixture cleanup and the actual public SDK entry. Keep functional assertions and dependency ownership unchanged.

The cleanup regression fails all three cases with the original expression and passes with the helper. Both official Bun layouts pass all 33 affected cases; strict SDK consumers pass in both layouts and reproduce the old hoisted TS2307. Source lineage and independent review pass.
Full CI exposed a platform-dependent truncation oracle, remaining cleanup errors, short worker stdout writes, and relocated Photon/Jiti asset resolution. Select the existing digest by Buffer behavior, reuse safe fixture cleanup, await the complete receipt write, constrain Photon package lookup, and select the SDK static Jiti bundle entry.

Both formal dependency layouts pass the affected SDK cases. Real slow pipes reproduce the original 65536-byte truncation and verify full receipt delivery. Relocated production bundles preserve unchanged plugin approval, strict source checks and lineage pass, and independent reviews pass. No dependency, lock, or SDK patch changes.
A watcher header queued before a strict native receipt could overwrite the recovered committed name during turn finalization. Synchronize only the pending name after a real name change is saved successfully. Keep duplicate receipts as no-ops so real external renames and explicit empty names survive.

The new SQLite/JSONL regression uses the real kernel, journal, product writer and watcher handler. Four cases and external-name controls pass independent review; related suites pass. Full environment type validation and the original fork subprocess scenario remain CI checks.
@syxc
syxc merged commit 903294c into master Nov 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant