Skip to content

feat(goal): integrate durable goals after permission policy review - #2141

Closed
new-Beginner wants to merge 8 commits into
vastsa:mainfrom
new-Beginner:feat/goal-runtime-clean-9ba23a
Closed

new-Beginner wants to merge 8 commits into
vastsa:mainfrom
new-Beginner:feat/goal-runtime-clean-9ba23a

Conversation

@new-Beginner

Copy link
Copy Markdown
Contributor

Summary / 概要

这是按 #1999 维护者意见 拆出的 B:完整 Goal 功能,依赖 https://github.com/vastsa/PI-Desktop/pull/2140;请先审阅并合入 A 的权限基础,不单独越过它合并 B。原 #1999 保持打开、head 不变,未强推或自动合并。

两份 PR 怎样看

两份都面向官方 main。由于 A 的分支位于 fork,B 的 GitHub 主 diff 仍包含 A 的提交,不伪称平台已自动隐藏它。

保留的功能与兼容性

从原 #1999 head 9b8dbd5f8aa938d157f6ee1a50a266bf8f342515 导入,并纳入最新 main。逐文件对照合成输入:全部 apps/packages 代码不变,六段数据库迁移不变。Rust 生产差异仅为三处 typed permission 接线与其测试。

  • 完整持久 Goal、owner-only 启动/恢复、CAS、轮次 claim、预算、用量、冻结 activeScope、完成审计和输入框附着式控制。
  • 保留 v27→28→29→30→31→32→33 的备份、事务及保守回填,不为缩小 PR 删除升级链。
  • 输入模式与执行授权独立;编辑下一 claim 生效,旧范围不能完成新目标;普通 FIFO 在当前 Host 对话结束后、Goal 续跑前处理。
  • Pause 立即持久化并限于窄收尾,最多三次后续 Agent 模型请求;Stop 撤权。保留已修复的 Pause 控制过期及旧内部历史读取兼容,显式 Resume 不重放旧交接指令。
  • 移除目标不是 Stop:仅合格的已有运行绑定可按 Agent 完成本次对话,不再启动自主下一轮;成功完整结算才增加完成轮数,内部工具/摘要请求不重复计轮。
  • 权限策略由既有 Host 执行模式/Goal 绑定校验后选择;Plan 仍 Contract,Goal 用 Agent 工具审批策略,但保持 Goal 执行身份、Computer/定时工具限制,以及 Ask/Auto、路径和插件边界。
  • 完成审计仍是当前模型自审,不是 Host 独立核验真实性;历史 Plan/Goal 审批不变为自主执行授权。

从新交付中移出的材料

新分支历史仅有 A + B 两个提交,不带入原大 PR 的旧提交历史。排除六个 Goal 过程目录的 **108 个文件(含 91 个二进制文件)**及 4 个一次性预览/流程图脚本。原 PR、历史分支和本地原件保留。

真实自动测试、产品文档、ADRs 和验收场景保留。保留的四个 UI runner 只改输出目录,改到唯一 PI_SCRATCH_DIR 子目录;断言、步骤、截止时间、容差和重试不变。没有新增图片、日志、数据库、构建产物或私有事故报告。没有新能力或无进展熔断器。

Verification / 实际验证

基线 main:078bc3061953a6f50eef0b4151e80207313c5e97;A:9320826b68462a500c3897c4ab4c6ff458b7d454;B:e66935f677d6e244cd75f5ef49edd39df9091032。
数量存在重叠,不相加。

检查 结果
Rust 权限 / Goal 过滤 / 数据库整组 / Computer fake-backend 27 / 103 / 49 / 30 通过
Runtime Goal + system transcript/journal + session context 83 通过
Desktop Goal 组件、服务、设置和提交路径 54 通过
相关 TS 包构建、Desktop typecheck 通过
Rust fmt/build/all-target Clippy 通过;5 条未改动主干告警
仓库规则 lint、架构、style、policy、语法和 diff 通过;lint 显式检查 145 个跟踪文件
文档结构 / 中英文配对 / 完整 VitePress 站点 618 页 / 89 对 / 构建通过,无死链

最终提交的真实隔离 Rust Host + Node sidecar + AgentHost 回环夹具均通过,无真实模型费用:

  • 权限入口:Agent/Goal Auto Write 成功、Plan 拒绝,caller mode 无法选择策略;零模型请求。
  • Pause / Resume / FIFO:11 请求;收尾 1/3 上限、显式恢复原生 Read、旧暂停段过期、替换和无假用户消息通过。
  • 独立输入:9 请求;切模式不暂停、编辑立即显示/下一轮生效、指导/FIFO、替换、Stop 及失败安全通过。
  • 移除/计轮:11 请求;当前对话可完成、Plan 冻结权限不变、无下一自主轮;两次真实摘要压缩及三次 Agent 请求只计一轮。
  • 自主完成代表路径:2 个 Host 轮、3 次模型请求、1 条用户消息,审计完成后不再续跑;重启暂停未完成目标、不重放。

没有运行完整 Rust/Desktop 全平台套件、完整工作区 build:js、Linux/macOS 本地验证、新一轮 Electron UI E2E、付费模型或发布安装;未运行 verify:ui:*。界面代码与原候选逐文件相同,并运行上述组件/服务回归,不把历史截图当本轮新验证。

额外的脚本未使用变量检查在原 render-goal-live-refinements.mjs 和新候选都报告同样 6 个未调用 helper;保留原测试,不删断言来掩盖提示。其余五个相关脚本补充 lint 通过。完整仓库规定 lint 已通过。新 PR 的 CI 以当前 head checks 为准。

UI reference / 界面参考

本拆分不改变原候选 UI;复用 #1999 的公开历史夹具供设计对照,不冒充当前 head 的新截图,不把图片放入本分支:

Requirement link / 需求关联

Refs #1995

Make Host tool membership an explicit internal policy so the Goal
authorization design can be reviewed independently of storage and UI.
Preserve the legacy Plan and Goal deny path until its Host producers
are supplied by the dependent feature.

Keep risk, approval, path and tool-specific execution guards unchanged;
cover the existing policy matrix and native Goal refusal.

Refs vastsa#1995
Keep the complete Goal lifecycle, migration chain and user controls from
the reviewed candidate while selecting the typed tool policy only after
Host execution validation. This separates authority review from storage
and interface implementation without changing the feature's behavior.

Exclude process reports, screenshots and one-off previews from the new
feature history. Retain executable acceptance fixtures and put generated
evidence in isolated scratch directories instead of the source tree.

Refs vastsa#1995
Keep the policy extraction behavior unchanged while retaining the newer\nsteering and background-job documentation. Point the existing compaction\ncontract test at the extracted allowlist instead of its former module.

Refs vastsa#1995
Preserve the existing Goal lifecycle and current main steering behavior.
Reconcile the independent v28 migration histories without discarding
backups or renumbering the six Goal upgrade steps.

Retain Pi 1.5 and its TypeBox entry point. Keep source-contract assertions
and refresh only the stale test path and steering fixture needed for the
combined implementation.

Refs vastsa#1995
Validate the existing policy boundary against the current remote base.
Keep the dependent Goal candidate on the current remote base and repaired
policy foundation without rewriting either published PR history.
Keep the pre-guidance tool interruption observable and reject any extra
errors. Compare complete guided Write arguments without accessing an
unknown value, preserving the stale-write regression and type safety.
@new-Beginner

Copy link
Copy Markdown
Contributor Author

Minimal CI/conflict repair

Head: 4021dfd71eef6aa8d6361774cec4f006132341e9. GitHub integration candidate: 21b67c692f9a5ab2a887cf2269165f944fadcd00; tree 1e2f5c0a8e604602406e1dce158579f34c793a8d.

Causes and exact changes

  1. Original CI job 127795192750 has the same sole stale source-contract failure as refactor(permissions): separate tool policy from approval decisions #2140. Update only the test's read path to permissions/tool_policy.rs, preserving all assertions.
  2. Keep main's Pi 1.5 upgrade. Two Goal modules now import Type from typebox, as required by the new export surface. No tool schema or behavior changes.
  3. Resolve the real schema-number collision: main's v28 is project-path alias repair; Goal's v28 begins Goal storage. Simply selecting v33 leaves main-v28 databases without Goal tables and skips alias repair for existing Goal-v33 data. Initialize the existing Goal base DDL inside the existing v28→29 transaction/backup, then run main's unchanged path repair at v33→34. Preserve all six original Goal upgrades and original backups. Add only three focused migration regressions (main v28 with owner/data preservation, backup failure without mutation, existing Goal v33 with aliases/Goal state/original backup preserved). Update corresponding English/Chinese storage documentation to v34.
  4. Preserve main's steering guard instead of bypassing it. Update the old Goal test fixture so a stale pre-guidance Write cannot run and a fresh guided Write does run. In the real independent-input fixture, require exactly the expected stale GetGoal interruption and its “new user input is waiting” result; any extra error still fails. No increased request cap, deadline, retries, or weakened permission check.

Conflict files (17 distinct files)

apps/desktop/electron/main/ipc/agent-ipc.ts
crates/host-core/src/db.rs
crates/host-core/src/db/tool_image_storage_migration.rs
crates/host-core/src/plugins/providers/tests.rs
docs/adr/README.md
docs/spec/03-runtime/02-agent-runtime.md
docs/spec/03-runtime/04-data-storage.md
docs/spec/03-runtime/06-host-rpc-protocol.md
docs/spec/06-delivery/04-e2e-test-plan.md
docs/zh-CN/spec/03-runtime/02-agent-runtime.md
docs/zh-CN/spec/03-runtime/03-tools-and-permissions.md
docs/zh-CN/spec/03-runtime/06-host-rpc-protocol.md
docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
packages/agent-runtime/src/runtime.test.ts
packages/agent-runtime/src/runtime.ts
packages/agent-runtime/src/system-transcript-journal.test.ts
pnpm-workspace.yaml

Import/catalog conflicts retain main's mention composition, background-job tools/steering and existing Goal tools/planning. Workspace configuration retains Pi 1.5 and the feature's existing exact Rollup exclusions; existing patches are unchanged. Tests retain isolated image migration and full-upgrade coverage. Documentation conflicts retain both sides' applicable entries/scenarios. Incorporating repaired A later conflicted only in the same ADR index and E2E document, not additional source files.

Additional directly necessary repair paths: context-compaction.test.mjs, db/goal_audit_migration.rs, db/repositories.rs, new db/goal_project_path_migration_tests.rs, goals/goal-planning.ts, goals/goal-turn.ts, goals/goal-runtime.test.ts, scripts/e2e-goal-independent.mjs, and the Chinese storage spec. No product UI components or production steering guard were altered by this repair.

Verification actually run

  • Context contract: 13/13. New migration regressions: reproduced red before compatibility fix, then 3/3 passing. Native permissions: 27 passed; Goal lifecycle unit module: 58 passed; complete local native run: 1300 passed, 6 baseline failures, 1 existing ignored test (details below).
  • Runtime full suite: 1902 passed, 1 existing skip; AgentHost: 109 passed; HostRuntime: 183 passed, 3 existing skips. Initial highly parallel runs hit image-bundle/file-index deadlines; rerunning with 2/1 workers passed without any deadline or test change.
  • Goal desktop component/service/bridge/submit tests: 53 passed. Isolated Electron Goal interaction: 1 passed, covering actual budget/save/edit/pause/resume/remove/retained TaskDock and narrow-screen keyboard paths. A policy-restricted local Chrome could not start remote debugging; the unchanged test passed with a checksum-verified scratch-only Electron 43.6 runtime instead.
  • All TS package builds and desktop typecheck; Electron production build; configured lint; architecture/style-token/agent-policy/Pi-patch/PR-base guards; Rustfmt and Clippy: passed. Clippy retains 5 old warnings.
  • Documentation structure: 621 pages; 89 locale pairs; full VitePress build: passed.
  • Final-commit real Host + sidecar / AgentHost loopback fixtures all passed:
    • e2e-goal-permission-policy.mjs --autonomous-goal-policy: no model; Agent/Goal Auto writes succeed, Plan denies, caller spoofing ineffective.
    • e2e-goal-pause-steering.mjs: 11 requests, FIFO ordering, immediate durable pause, 1/3-request closeout, Resume/native Read, replacement expiry.
    • e2e-goal-independent.mjs: 9 requests, 6 actual user messages, input-mode independence, frozen current scope, guidance/FIFO, explicit Stop/resume/replacement, provider failure fences.
    • e2e-goal-removal-rounds.mjs: 11 requests; 2 real compactions + 3 Agent requests still count as 1 completed Host conversation; eligible removal finishes without a new autonomous round.
    • e2e-autonomous-goal.mjs: 2 Host turns / 3 requests / 1 user, structured audit completion stops continuation; restart pauses.

Explicit local native limitation

The 6 local Windows failures also reproduce in the A/main-based candidate, in unchanged data_relocation (3), db::project_path_tests (1), and rpc::remote_tools (2) tests: path separator/extended-path fixture expectations and an extra permission request. They were not “fixed” by unrelated changes or by weakening assertions. The repaired-head Linux and Windows Rust CI checks have independently passed; the local full Rust result is still not described as green.

No refactor, new capability, permission relaxation, timeout/tolerance increase, assertion removal, dependency downgrade, force-push, or merge to main. Existing published heads remain ancestors. PR #1999 and the primary checkout were not modified. B still depends on A; the repaired A head is an ancestor of B.

Both candidates contain base fb4816bca4e9e01140f6b0b78faee6c7a9561910. GitHub merge-ref trees were fetched and verified equal to the locally tested candidate trees. Explicit test profiles, loopback model fixtures, task caches and evidence were directed to task scratch. No paid provider or daily application instance was used.

Current repaired-head CI (snapshot at posting)

  • Docs checks: success
  • JS build / typecheck / lint / architecture / test: failure
  • Rust host-core format / lint / test: success
  • Trusted extensions Electron E2E: success
  • Rust host-core Windows / transcript cache E2E: success
  • Head contains latest base: success

Pending checks are not claimed as passing. This comment does not request automatic merge.

The integrated prompt ingress reads the Host-authoritative turn mode.
Provide that boundary response in the existing mention fixture and assert
its exact binding, preserving every original mention assertion.
@new-Beginner

Copy link
Copy Markdown
Contributor Author

Final follow-up: all checks green

Final head: c150b817002df2a28d88d81043a8cf7fbcced8cc, containing main fb4816bca4e9e01140f6b0b78faee6c7a9561910 and repaired foundation #2140. The complete conflict inventory and compatibility explanation above remain applicable; this supersedes their earlier candidate head.

The first repaired-head JS run revealed four failures in apps/desktop/test/composer-agent-mention.test.mjs. Its Host stub omitted the session.getTurnMode call used by the existing Goal-integrated prompt ingress. The only follow-up source change is 4 added test-fixture lines: return the fixture's mode for that RPC and assert the exact session/turn binding. All original mention, Plan/Goal, file-precedence and Skill/template assertions remain. No production code changed. Reproduced locally: 4 failures before, 4 passing after.

At the final commit:

  • Combined context + agent-mention + all Goal desktop tests: 71 passed, 0 failed, 0 skipped, including isolated Electron interaction.
  • Re-ran all five real Host/sidecar permission, pause/FIFO/Resume, independent-input, removal/round-counting and audited-completion fixtures: all passed, with the original request caps and deadlines.
  • GitHub integration candidate 186ecbb8e32c37de92a753871a3d0e73536835ec has tree 86e2432644389e3cba93e822506ebf30f944e5d5, exactly matching the local candidate.
  • Final CI run: JS build/typecheck/lint/architecture/unit tests, Linux Rust, Windows Rust/transcript E2E and trusted-extensions Electron E2E all passed. Documentation and latest-base checks also passed: 6/6 checks green. refactor(permissions): separate tool policy from approval decisions #2140's final head 253af7c5fddb1187e9ca97ad0930cfe2a8e5428e is likewise 6/6 green.

The earlier disclosure of six local Windows native baseline failures remains unchanged; they were not hidden or patched, and both remote Rust gates passed. Both PRs are open/unmerged and conflict-free. No force-push, main merge, release/daily-app installation, PR #1999 change, or additional scope expansion.

@new-Beginner

Copy link
Copy Markdown
Contributor Author

@Tioit-Wang 回应你在 #1999 原始审阅意见 中提出的「六段数据库升级、新接口和权限变化混在一起,以及过程材料不应进入主干」问题:这份 B 是依赖 #2140 的 Goal 功能实现,不绕过 A 的设计审阅。

  1. 审阅入口:先看 refactor(permissions): separate tool policy from approval decisions #2140 的权限边界与 ADR,再看 A→B 功能对照。两份 PR 都面向官方 main,因此本 PR 的主 diff 仍包含 A,不能宣称平台已经自动将它排除。B 仍是完整功能 PR,并非一个小补丁。
  2. 存储与接口:保留六段 Goal 升级及其备份、事务和回填约束,没有为缩小差异删除用户升级路径。最新 main 的 v28 路径修复与 Goal v28 同号,现已增加到 v34 的必要兼容;新增三项回归验证主干 v28 升级、旧 Goal v33 数据保留,以及备份失败不改数据。当前实现不能再按最初正文中的 v33 理解,详见兼容修复说明。
  3. 权限行为变化仍需明确审阅:B 中实际选择 Goal 的 Agent 工具策略之前,保留 Host 的执行模式/绑定校验;执行身份仍为 Goal,不是赋予 Auto,也不取消 Computer、定时工具、路径、审批或插件边界。这是 B 中可见的启用点,不把 A 的通过视为对该变化的自动批准。
  4. 过程材料:已从新交付中移出六个 Goal 过程目录的 108 个文件(含 91 个二进制文件)和四个一次性预览/流程图脚本。原件保留在旧分支供历史对照;真实回归、产品文档和 ADR 保留,测试产物改写到 scratch,不再把这些过程图集带入本分支。

当前 head c150b8170 的六项 checks 全部通过;最终提交的 71 项桌面相关测试和五个真实 Host/sidecar 回环流程也通过,证据与复现方式 已列出。这里没有沿用 #1999 的旧绿色状态,也不把 CI 通过等同于你已经认可权限设计。仍按 A 先审、B 后审的顺序等待维护者决定。

@vastsa

vastsa commented Nov 8, 2026

Copy link
Copy Markdown
Owner

感谢 @new-Beginner 对持久 Goal、claim/CAS、预算及幂等结算机制的原创贡献。经维护者明确授权,本功能已提炼为可自定义的模式/分阶段工作流,并通过 #2194 合入 main(181d11e0cc254b91067ee6d17f7846ed1745dc73)。合入提交保留了你的 Co-authored-by 署名,移植模块和 ADR 也注明了来源;没有重写或强推你的分支。本 PR 由 #2194 替代,因此关闭,原讨论和贡献记录保留。

@vastsa vastsa closed this Nov 8, 2026
yg2224 pushed a commit to yg2224/PI-Desktop that referenced this pull request Nov 9, 2026
The staged-mode redesign (vastsa#2194) kept the durable Goal engine but dropped
several controls that vastsa#1999 / vastsa#2141 and issue vastsa#1995 asked for. This adds
them back on top of the mode run engine: edit the objective and budget of
an open run (modes.update, effective from the next claim), a per-run and
a settings default Goal budget (goalBudget), Remove as distinct from Stop,
a bounded closeout when a running turn is paused, and hiding the task dock
while a Goal run is open.

The closeout and Remove reach the running turn through a new sidecar
notice (agent.modeTurnNotice); both are system-side and never fake a user
message. A CompleteStage from a turn claimed for an edited objective is
refused with MODE_INPUT_CHANGED, and the next turn is told the objective
changed. All contract changes are additive.

Refs vastsa#1995
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.

2 participants