@pennixrv/trellis 0.7.2-beta.4 → 0.7.2-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/migrations/manifests/0.7.2-beta.5.json +9 -0
- package/dist/templates/codex/hooks/session-start.py +14 -0
- package/dist/templates/common/bundled-skills/trellis-task-implementation/workflow.md +1 -1
- package/dist/templates/common/bundled-skills/trellis-worktree-delegation/SKILL.md +12 -0
- package/dist/templates/common/bundled-skills/trellis-worktree-delegation/workflow.md +14 -0
- package/dist/templates/shared-hooks/inject-workflow-state.py +15 -0
- package/dist/templates/trellis/agents/delegated-worktree-primary-agent.md +20 -22
- package/dist/templates/trellis/agents/worktree-delegation-node.md +24 -0
- package/dist/templates/trellis/index.d.ts.map +1 -1
- package/dist/templates/trellis/index.js +1 -0
- package/dist/templates/trellis/index.js.map +1 -1
- package/dist/templates/trellis/scripts/common/git_context.py +10 -0
- package/dist/templates/trellis/scripts/common/task_continuity.py +11 -0
- package/dist/templates/trellis/scripts/common/task_move.py +2 -2
- package/dist/templates/trellis/scripts/common/task_store.py +7 -1
- package/dist/templates/trellis/scripts/common/task_workflow.py +6 -2
- package/dist/templates/trellis/scripts/common/worktree_delegation.py +476 -0
- package/dist/templates/trellis/scripts/task.py +30 -0
- package/package.json +2 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.7.2-beta.5",
|
|
3
|
+
"description": "同机 Paseo 工作树委派与公开 SDK 可选适配",
|
|
4
|
+
"breaking": true,
|
|
5
|
+
"recommendMigrate": false,
|
|
6
|
+
"changelog": "引入显式目标和能力绑定、准备/实施两步许可、固定角色与按次投影、未知创建/发送恢复,以及目标 owner 集成后核销。新增独立 Node >=22 适配包,基础 CLI/core 仍支持 Node >=18.17。",
|
|
7
|
+
"migrations": [],
|
|
8
|
+
"notes": "通过原生 trellis update 更新角色、脚本、Hook 和协作 Skill。旧运行记录先沿原生 reconciliation 保全闭合;新启动必须传入目标、设置和能力要求,不能退回旧的一步启动。"
|
|
9
|
+
}
|
|
@@ -495,6 +495,20 @@ def _build_workflow_toc(workflow_path: Path) -> str:
|
|
|
495
495
|
|
|
496
496
|
|
|
497
497
|
def main() -> None:
|
|
498
|
+
if os.environ.get("TRELLIS_DELEGATION_CONTEXT"):
|
|
499
|
+
try:
|
|
500
|
+
locator = Path(os.environ["TRELLIS_DELEGATION_CONTEXT"])
|
|
501
|
+
if locator.is_symlink() or locator.stat().st_size > 256 * 1024:
|
|
502
|
+
raise ValueError("invalid delegation context")
|
|
503
|
+
context = json.loads(locator.read_text(encoding="utf8"))
|
|
504
|
+
result = subprocess.run([sys.executable, str(Path(context["control_root"]) / ".trellis/scripts/get_context.py")], capture_output=True, text=True, timeout=15)
|
|
505
|
+
message = result.stdout.strip() if result.returncode == 0 else "Delegated node blocked: invalid/stale context; preserve resources and report to controller."
|
|
506
|
+
if len(message.encode()) > 256 * 1024:
|
|
507
|
+
raise ValueError("oversized delegation context")
|
|
508
|
+
except (OSError, ValueError, KeyError, subprocess.TimeoutExpired):
|
|
509
|
+
message = "Delegated node blocked: missing/invalid execution context; do not enter controller workflow."
|
|
510
|
+
print(json.dumps({"hookSpecificOutput": {"hookEventName": "SessionStart", "additionalContext": message}}))
|
|
511
|
+
return
|
|
498
512
|
if should_skip_injection():
|
|
499
513
|
sys.exit(0)
|
|
500
514
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
实施阶段为 `blocked` 或 `waiting_user` 时,先解决阻塞并经原生 `phase resume` 恢复,再重新核验准入。`delegate-start` 核验父任务已有的 ownership 围栏和子任务状态;存在未消费交接、当前会话不符合已有 ownership 记录,或子任务已完成、取消时,不启动或复用委派执行。没有 ownership 记录的任务不具备默认会话独占保护。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
父授权有效且本轮允许委派写入时,先加载 `trellis-worktree-delegation`,通过其原生新协议入口冻结明确目标、设置与能力要求,再准备、核验 ready、执行和观察。委派节点沿 `TRELLIS_DELEGATION_CONTEXT` 与共享节点方法执行本包,不进入主控阶段或新建任务。输入漂移先保全并核对授权;未知创建或发送只做原生 inspect 和显式 recover,不覆盖映射或重放。结果由 owner 审查并在目标分支 merge/FF,验证 ancestry 后再显式核销;idle/cancel 不替代 writer 停止证据。
|
|
8
8
|
|
|
9
9
|
按合同的依赖和优先级选取当前工作包,实施满足目标的最小变更,并运行与风险和影响相称的局部验证。主工作树主代理核对来源、revision、Git 基线、差异和结果后接受工作包。多包任务按合同集成;单一交付不人为拆分。Trellis Teamwork 仅用于冻结计划下的只读比较或评议,不能改写任务状态或接受实施结果。实际写入委派依父任务规定使用 Trellis 受控入口与 Paseo;各组件源码仍在 owner 仓库内修改。
|
|
10
10
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: trellis-worktree-delegation
|
|
3
|
+
description: 在 Trellis 已授权实施阶段,把完整结果包交由同机 Paseo 独立工作树执行,管理绑定、准备、返工、恢复及 owner 集成;不用于 Teamwork 只读审查或普通研究。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 委派工作树协作
|
|
7
|
+
|
|
8
|
+
先读取 [操作合同](workflow.md)。此入口只编排已批准的完整工作包;任务阶段、授权和接受由主控 Trellis 维护,workspace、agent 和 provider thread 由 Paseo 维护。Teamwork 用于有界只读研究或审查,不获得源码实施权。
|
|
9
|
+
|
|
10
|
+
主控按依赖与包大小选择可同时推进的结果包;不为每个普通实现步骤另建委派。目标可为独立仓库、submodule 或 linked worktree,可没有 Trellis。不要复制全局 AGENTS、安装目录或主控整个上下文。必要方法通过明确只读引用提供;没有目标项目资产不构成自动初始化许可。
|
|
11
|
+
|
|
12
|
+
原生 `task.py delegate-*` 负责校验绑定与当前父授权;可选 `trellis-paseo-adapter` 只通过公开 SDK 操作同机 daemon。缺包、版本、身份或必需能力不符时停止相应动作,沿 Lifecycle 修复;不调用旧 start、不换 host/provider、不把弱角色提示词当兼容模式。创建/发送结果不明时 inspect 并核验原生资源,使用显式 recover 接回,不能重放未知操作。
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# 主控操作合同
|
|
2
|
+
|
|
3
|
+
使用项目原生 `python3 .trellis/scripts/task.py <command> --help` 核对参数。先核对父任务有效实施合同、父子链接、owner、当前路线的 Lifecycle/Paseo/Git 准入及证据。一个 controller task 是控制权威;节点不创建第二套阶段状态。
|
|
4
|
+
|
|
5
|
+
1. 读取 adapter 的 capability(有界 stdin JSON `version=1, operation=capability, daemon_selector={}, payload={cwd:目标绝对路径}`),从实际可用 Codex 模型解析默认值并固定显式 model/effort。使用 mode `full-access`,sandbox/approval/reviewer/context 保留 `native_default`。固定角色为 `.trellis/agents/delegated-worktree-primary-agent.md`,节点方法为 `.trellis/agents/worktree-delegation-node.md`;两包共用同版正文。
|
|
6
|
+
2. 在子任务记录 PRD、`settings.json`、`requirements.json`,通过原生 `task.py set-branch` 设置不存在的执行分支。settings 含 version=1、provider=codex、model、effort、mode=full-access;可指定同机 daemon_home。requirements 含 version=1、非空 allowed_paths、forbidden_paths、required_rules/required_skills/required_tools/checks/resources 字符串数组、可选 setup_ref、teamwork_permission(none/read_only)。声明准确来源、工具真实探测、测试端口/数据库等资源;setup_ref 指向已授权的原生准备动作。禁止副作用隐藏在 setup 中。
|
|
7
|
+
3. `delegate-bind <child> --target-repo <确切 checkout> --integration-branch <owner 分支> --settings-ref settings.json --requirements-ref requirements.json` 冻结 PRD/角色/设置/能力哈希、base、目标 Git 身份及父授权。target 与 controller 可不同;integration 是该目标 owner 分支。主控在启动前检查项目原生 workspace setup/teardown,不允许未经批准的脚本;原生 autoArchiveAfterMerge 必须为 false。CLI 不修改 daemon 配置。
|
|
8
|
+
4. `delegate-start <child>` 先持久化创建 intent,再创建 workspace 和 prepare agent。只授予准备许可;观察 native resources 与 bounded ready,核对当前源码 HEAD、完整必需能力、实际模型/effort/mode;不能只凭节点自报或 idle 就接受。主控检查 `delegate-inspect` 后,`delegate-execute` 发送实施指令。有并行包时分别准备、执行,按真实依赖集成后再派下游。
|
|
9
|
+
5. `delegate-wait <child> --timeout-ms 3600000` 使用原生等待;主控还有独立工作就先推进。没有其他工作时持续原生等待,timeout 不是完成或批准。observe/inspect 不改结果接受;`delegate-followup --instructions-ref <子任务内文件>` 返工前重核当前绑定与实际设置。interrupt 仅请求取消,不证明 writer 已停止。
|
|
10
|
+
6. 压缩/新主控恢复先 inspect,沿当前 task/binding/attempt/native ID 续接。未知创建使用 `delegate-reconcile --recover --workspace-id <完整ID> [--agent-id <完整ID>]` 预览,核验准确原生 workspace、cwd、Git common/branch/base、agent 标签后,显式 `--execute --reason ... --approval-ref ...` 接回。未知发送/取消还需要 `--delivery-evidence-ref`,引用主控实际检查的原生 timeline/turn 证据;不得把 idle 当交付证明。workspace 已映射而尚未发起 agent 时,恢复后 `delegate-start` 仅创建尚未发起的 agent。未知 agent 创建必须先找到准确 ID,不能再创建一个。
|
|
11
|
+
7. owner 审查 result 的真实 commits/diff/checks、范围和控制面未被改动,依赖结果只能在集成后作为当前树事实。通过目标 owner 原生 merge/FF 集成,验证 accepted HEAD 是目标 integration branch 的祖先;禁止默认 cherry-pick。根侧 gitlink 集成单独记录。
|
|
12
|
+
8. `delegate-reconcile --disposition integrated` 预览;确认原生 agent 无 active turn、结果和接受证据、源码保全、后台 writer 与测试服务已停后,使用 `--execute --reason ... --approval-ref ... --writer-evidence-ref <子任务内证据>` 核销。取消可用 retained,保留实际 checkout/HEAD/status 和候选;没有结果时也必须保留源码,不销毁未知 writer。核销仅结束控制记录,不自动 archive/delete。资源删除由原生 owner 另按已批准处置执行。
|
|
13
|
+
|
|
14
|
+
新协议记录在 ignored `.trellis/.runtime/delegation/<child>/`;任务 PRD 和实施/接受证据仍在原生任务中。不要手写 record、映射或许可。旧 meta 记录只供旧 reconciliation/闭合,不能作为新协议启动成功证据。完成、取消、转移、解绑、移动及重命名前应核销活动委派;遇未知状态保留资源并报告。
|
|
@@ -44,6 +44,7 @@ import re
|
|
|
44
44
|
import sys
|
|
45
45
|
import queue
|
|
46
46
|
import threading
|
|
47
|
+
import subprocess
|
|
47
48
|
from pathlib import Path
|
|
48
49
|
|
|
49
50
|
# Force UTF-8 on stdin/stdout/stderr on Windows. Default codepage there is
|
|
@@ -466,6 +467,20 @@ def _load_hook_input() -> dict:
|
|
|
466
467
|
|
|
467
468
|
|
|
468
469
|
def main() -> int:
|
|
470
|
+
if os.environ.get("TRELLIS_DELEGATION_CONTEXT"):
|
|
471
|
+
try:
|
|
472
|
+
locator = Path(os.environ["TRELLIS_DELEGATION_CONTEXT"])
|
|
473
|
+
if locator.is_symlink() or locator.stat().st_size > 256 * 1024:
|
|
474
|
+
raise ValueError("invalid delegation context")
|
|
475
|
+
context = json.loads(locator.read_text(encoding="utf8"))
|
|
476
|
+
result = subprocess.run([sys.executable, str(Path(context["control_root"]) / ".trellis/scripts/get_context.py")], capture_output=True, text=True, timeout=15)
|
|
477
|
+
message = result.stdout.strip() if result.returncode == 0 else "Delegated node blocked: invalid/stale context; preserve resources and report to controller."
|
|
478
|
+
if len(message.encode()) > 256 * 1024:
|
|
479
|
+
raise ValueError("oversized delegation context")
|
|
480
|
+
except (OSError, ValueError, KeyError, subprocess.TimeoutExpired):
|
|
481
|
+
message = "Delegated node blocked: missing/invalid execution context; do not enter controller workflow."
|
|
482
|
+
print(json.dumps({"hookSpecificOutput": {"hookEventName": "UserPromptSubmit", "additionalContext": message}}))
|
|
483
|
+
return 0
|
|
469
484
|
if os.environ.get("TRELLIS_HOOKS") == "0" or os.environ.get("TRELLIS_DISABLE_HOOKS") == "1":
|
|
470
485
|
return 0
|
|
471
486
|
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: delegated-worktree-primary-agent
|
|
3
|
-
description: Executes an authorized
|
|
3
|
+
description: Executes an authorized result package in its own Paseo worktree.
|
|
4
4
|
labels: [trellis, delegated-worktree]
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
parent contract permits it. Those teammates must not implement code or delegate
|
|
27
|
-
again. These are role obligations, not a sandbox guarantee.
|
|
7
|
+
你是独立执行工作树中的委派实施 Agent,负责完成主控交付的一个完整结果包。
|
|
8
|
+
|
|
9
|
+
遵守当前宿主指令、原生加载的用户及项目 AGENTS、目录规范和组件接口。有效父合同与已有授权覆盖的动作直接推进;主控派发消息本身不构成新增授权。
|
|
10
|
+
|
|
11
|
+
先读取 TRELLIS_DELEGATION_CONTEXT 指向的执行上下文,按其引用读取当前合同、必需能力和节点协作方法。环境变量只定位资料,不授予权限;实际 cwd、源码工作树、绑定及原生资源身份必须与当前上下文一致。缺失、冲突或陈旧时报告阻断,不退回普通主控流程。
|
|
12
|
+
|
|
13
|
+
准备期间只做合同允许的准备与就绪报告,不修改业务源码。主控核验并明确下发当前绑定的实施指令后,在本包范围连续完成修改、验证和源码提交;不为普通实现步骤另建委派。
|
|
14
|
+
|
|
15
|
+
只修改合同允许的源码及指定候选报告。任务阶段、授权、接受、主控运行记录和其他包资源由主控或对应 owner 写入。不得接受自己的成果,不得擅自初始化项目、安装共享组件、改变信任、发布或销毁工作树。
|
|
16
|
+
|
|
17
|
+
源码检索以当前执行树为准。只使用准入已通过的工具和绑定;其他树或未集成兄弟包的查询结果只能作为注明来源的参考,不能当作本树事实。CodeGraph 不可用时按当前能力合同处理,不借另一树索引或忽略现行使用规则。
|
|
18
|
+
|
|
19
|
+
直接完成本包,不发起嵌套写入委派。仅在合同允许时使用有界只读研究或审查,Teamwork teammate 不获得源码实施、父任务接受或资源处置权。
|
|
20
|
+
|
|
21
|
+
重要新选择、合同冲突、身份失配、必需能力失败或范围外副作用通过指定 blocked 候选回报主控,停止受影响动作。意外原生审批或问答保留真实请求,不替用户答复,不自动放行。
|
|
22
|
+
|
|
23
|
+
按合同运行检查并提交源码,报告实际提交、差异、检查结果、未运行项、剩余事项和工作树状态。报告进入指定候选入口,不提交运行资料,不把 turn 结束或自报完成当作主控接受。
|
|
24
|
+
|
|
25
|
+
返工、压缩和恢复后重新读取当前执行上下文,核对绑定、许可及源码状态;未确认仍可实施时不继续写入。保全成果,等待 owner 审查、集成与资源收尾。
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: worktree-delegation-node
|
|
3
|
+
description: Shared preparation, execution and recovery method for delegated nodes.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 委派工作树节点方法
|
|
7
|
+
|
|
8
|
+
这是明确引用的协作资料,不代表目标仓库安装了 Trellis 或新增全局规则。全局及项目 AGENTS 继续由宿主原生加载,不从主控规则复制派生。需求与接受标准以 `contract_ref` 为准,执行同时受当前有效绑定、许可和所引用的能力合同约束。
|
|
9
|
+
|
|
10
|
+
每次 prepare、execute、followup 和恢复后,重读 `TRELLIS_DELEGATION_CONTEXT` 指向的文件、其 `record_ref`、`contract_ref`、要求的规则及 Skills;核对原生 `PASEO_AGENT_ID`、workspace、实际 Git checkout、branch、base、attempt、binding、模型和 effort。投影与记录不一致时停止受影响动作。主控持有的资料可只读,不修改控制仓库的任务、接受、运行记录或其他包。
|
|
11
|
+
|
|
12
|
+
准备许可只允许合同明确的准备和候选报告。`requirements.setup_ref` 有值时,先读取控制任务目录下该文件,只运行其中已批准的原生准备动作。不存在时不能初始化 Trellis、安装依赖、索引或修改共享配置。检查实际 cwd、用户和目录规则、必需 Skill 的准确来源和可读性、工具连接及真实能力。必需 CodeGraph 只能使用本树原生 bound MCP 和本树索引;查询须看到本树 provenance,不能借祖先或兄弟索引。记录观察和缺项,不要求底层权限或上下文窗口默认值的完整回执。
|
|
13
|
+
|
|
14
|
+
候选目录为本树 `.trellis-delegation/<attempt_id>/`,只允许 `ready.json`、`result.json`、`blocked.json` 三个普通 JSON 文件,每个不超过 256 KiB,不含链接。不要提交这些运行资料,也不要创建其他报告文件。每个候选的公共字段为:
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{"version":1,"kind":"ready","attempt_id":"来自投影","binding_revision":"来自投影","base_commit":"来自 binding","head_commit":"本树 git rev-parse HEAD","workspace_id":"来自投影","agent_id":"来自投影","observations":{},"limitations":[]}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
ready 增加 `missing` 数组;只有实际满足全部必需项时才为空。observations 记录规则/Skills 来源、必需工具的实际探测、Git 和设置摘要;不保存凭据、完整配置或历史。身份映射尚未完整时只报告阻断,等待主控核验后恢复准备。
|
|
21
|
+
|
|
22
|
+
收到 execute 时,重新读取投影,仅在 `execution_permission=implementation`、当前 attempt/绑定仍有效时完成整个包:按允许路径改源码、运行合同检查、提交源码。不得发起实施子代理或嵌套委派。result 在公共字段之外包含 `changed_paths`、`source_commits`、`checks`、`remaining` 数组,分别记录相对 base 的真实文件、全部真实提交、已运行/未运行及结果、未结事项。准备时的 ready 也保留;result 的 HEAD 必须是当前源码 HEAD。源码之外只保留指定候选报告,不接受自己的成果。
|
|
23
|
+
|
|
24
|
+
blocked 使用公共字段并在 observations 说明阻断、真实错误、已保全成果和所需 owner 动作;只停止依赖动作。原生权限/问答不替用户答复,不自动批准、不降级模型或工具。返工重新核对当前投影和 owner 指示,不把历史许可当新增授权。完成后保全工作树、源码提交和候选,等待 owner 审查、集成及资源处置;turn 结束、idle 或 cancel 均不证明后台 writer 已停止。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/trellis/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAcH,eAAO,MAAM,WAAW,QAAsC,CAAC;AAG/D,eAAO,MAAM,UAAU,QAA6C,CAAC;AACrE,eAAO,MAAM,WA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|
scripts.set("common/task_store.py", commonTaskStore);
|
|
103
103
|
scripts.set("common/task_workflow.py", commonTaskWorkflow);
|
|
104
104
|
scripts.set("common/task_continuity.py", commonTaskContinuity);
|
|
105
|
+
scripts.set("common/worktree_delegation.py", readTemplate("scripts/common/worktree_delegation.py"));
|
|
105
106
|
scripts.set("common/session_context.py", commonSessionContext);
|
|
106
107
|
scripts.set("common/packages_context.py", commonPackagesContext);
|
|
107
108
|
scripts.set("common/workflow_phase.py", commonWorkflowPhase);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/trellis/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,SAAS,YAAY,CAAC,YAAoB;IACxC,OAAO,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC;AAED,gCAAgC;AAChC,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC,qBAAqB,CAAC,CAAC;AAE/D,0BAA0B;AAC1B,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC,4BAA4B,CAAC,CAAC;AACrE,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC,yBAAyB,CAAC,CAAC;AACnE,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAC,6BAA6B,CAAC,CAAC;AAC3E,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,C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SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YAC7C,IAAI,KAAK,CAAC,WAAW,EAAE;gBAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;iBACtC,IAAI,KAAK,CAAC,MAAM,EAAE;gBACrB,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;;gBAC1D,MAAM,IAAI,KAAK,CAAC,+BAA+B,QAAQ,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IACD,OAAO,CAAC,EAAE,CAAC,CAAC;IACZ,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -49,6 +49,16 @@ def main() -> None:
|
|
|
49
49
|
"""CLI entry point."""
|
|
50
50
|
import argparse
|
|
51
51
|
|
|
52
|
+
from .worktree_delegation import node_context
|
|
53
|
+
from .task_workflow import TaskWorkflowError
|
|
54
|
+
try:
|
|
55
|
+
delegated = node_context()
|
|
56
|
+
except (ValueError, OSError, KeyError, TaskWorkflowError) as error:
|
|
57
|
+
raise SystemExit(f"Delegated node blocked: {error}") from error
|
|
58
|
+
if delegated is not None:
|
|
59
|
+
print(json.dumps({"delegated_node": delegated, "instruction": "Read node_method_ref and current contract. Do not enter controller phases, task intake, or nested implementation delegation."}, ensure_ascii=False))
|
|
60
|
+
return
|
|
61
|
+
|
|
52
62
|
parser = argparse.ArgumentParser(description="Get Session Context for AI Agent")
|
|
53
63
|
parser.add_argument(
|
|
54
64
|
"--json",
|
|
@@ -242,8 +242,16 @@ def _projection(root: Path, directory: Path, data: dict, task_id: str) -> dict:
|
|
|
242
242
|
evidence_digest = hashlib.sha256(
|
|
243
243
|
json.dumps(sorted(evidence), ensure_ascii=False, separators=(",", ":")).encode("utf-8")
|
|
244
244
|
).hexdigest()
|
|
245
|
+
from .worktree_delegation import runtime_path, read as read_delegation
|
|
246
|
+
delegations = {}
|
|
247
|
+
for task_name in [directory.name, *data.get("children", [])]:
|
|
248
|
+
path = runtime_path(root, task_name)
|
|
249
|
+
if path.exists():
|
|
250
|
+
record = read_delegation(path)
|
|
251
|
+
delegations[task_name] = {"record_digest": _digest(record), "attempt_id": record.get("attempt_id"), "status": record.get("status"), "intent": record.get("intent")}
|
|
245
252
|
return {
|
|
246
253
|
"task": {"id": task_id, "path": directory.relative_to(root).as_posix(), "status": data.get("status")},
|
|
254
|
+
"delegations": delegations,
|
|
247
255
|
"phase": {"current_phase_id": current_phase, "task_route_revision": route_revision, "input_revision": input_revision, "phases": phases},
|
|
248
256
|
"evidence_digest": evidence_digest,
|
|
249
257
|
"git": {
|
|
@@ -670,6 +678,9 @@ def assert_task_identity_change_allowed(repo_root: Path, task_dir: Path, data: d
|
|
|
670
678
|
@contextlib.contextmanager
|
|
671
679
|
def task_mutation_guard(repo_root: Path, task_dir: Path, data: dict):
|
|
672
680
|
"""Hold the ownership lock across a single task mutation."""
|
|
681
|
+
if os.environ.get("TRELLIS_DELEGATION_CONTEXT"):
|
|
682
|
+
yield False
|
|
683
|
+
return
|
|
673
684
|
from .task_move import layout_lock, require_settled_layout
|
|
674
685
|
|
|
675
686
|
with layout_lock(repo_root):
|
|
@@ -107,8 +107,8 @@ def _plan(root: Path, moves: list[tuple[Path, Path]], updates: dict[Path, dict])
|
|
|
107
107
|
elif not path.is_dir():
|
|
108
108
|
raise ValueError(f"Unsupported task content: {path}")
|
|
109
109
|
data = _read(source / "task.json")
|
|
110
|
-
|
|
111
|
-
delegated =
|
|
110
|
+
from .worktree_delegation import resolve_record
|
|
111
|
+
delegated = resolve_record(root, source, data)
|
|
112
112
|
if delegated is not None:
|
|
113
113
|
from .task_workflow import _assert_delegated_record_closed
|
|
114
114
|
_assert_delegated_record_closed(source.name, delegated)
|
|
@@ -1019,6 +1019,11 @@ def cmd_rename(args: argparse.Namespace) -> int:
|
|
|
1019
1019
|
print(colored(f"Error: Task not found: {args.name}", Colors.RED), file=sys.stderr)
|
|
1020
1020
|
return 1
|
|
1021
1021
|
|
|
1022
|
+
from .worktree_delegation import runtime_path
|
|
1023
|
+
if runtime_path(repo_root, task_dir.name).exists():
|
|
1024
|
+
print("Error: preserve delegation identity; a task with delegation runtime cannot be renamed", file=sys.stderr)
|
|
1025
|
+
return 1
|
|
1026
|
+
|
|
1022
1027
|
# Restrict renames to the prescribed status directory levels.
|
|
1023
1028
|
if not is_within_tasks_dir(task_dir, repo_root):
|
|
1024
1029
|
print(
|
|
@@ -1259,7 +1264,8 @@ def cmd_remove_subtask(args: argparse.Namespace) -> int:
|
|
|
1259
1264
|
|
|
1260
1265
|
if parent_data.get("status") != "cancelled":
|
|
1261
1266
|
from .task_workflow import _assert_delegated_record_closed
|
|
1262
|
-
|
|
1267
|
+
from .worktree_delegation import resolve_record
|
|
1268
|
+
_assert_delegated_record_closed(child_dir.name, resolve_record(repo_root, child_dir, child_data))
|
|
1263
1269
|
original_parent = json.loads(json.dumps(parent_data))
|
|
1264
1270
|
# Remove child from parent's children list
|
|
1265
1271
|
parent_children = _ensure_children_list(parent_data)
|
|
@@ -1377,8 +1377,10 @@ def _assert_delegated_resources_closed(task_dir: Path, data: dict) -> None:
|
|
|
1377
1377
|
if not isinstance(children, list):
|
|
1378
1378
|
raise TaskWorkflowError("TASK_PHASE_RESOURCE_ACTIVE", "linked child task list is malformed")
|
|
1379
1379
|
for task_id in [task_dir.name, *children]:
|
|
1380
|
-
|
|
1381
|
-
|
|
1380
|
+
child_dir = _task_dir(task_id)
|
|
1381
|
+
child_data, _ = _load(child_dir)
|
|
1382
|
+
from .worktree_delegation import resolve_record
|
|
1383
|
+
_assert_delegated_record_closed(task_id, resolve_record(get_repo_root(), child_dir, child_data))
|
|
1382
1384
|
|
|
1383
1385
|
|
|
1384
1386
|
def _assert_delegated_record_closed(task_id: str, record) -> None:
|
|
@@ -1386,6 +1388,8 @@ def _assert_delegated_record_closed(task_id: str, record) -> None:
|
|
|
1386
1388
|
return
|
|
1387
1389
|
if isinstance(record, dict) and record.get("status") == "retired" and isinstance(record.get("closure_evidence"), dict):
|
|
1388
1390
|
return
|
|
1391
|
+
if isinstance(record, dict) and "binding" in record:
|
|
1392
|
+
raise TaskWorkflowError("TASK_PHASE_RESOURCE_ACTIVE", f"protocol v1 delegation for {task_id} must be explicitly reconciled before closing or moving")
|
|
1389
1393
|
agent_id = record.get("agent_id") if isinstance(record, dict) else None
|
|
1390
1394
|
if not isinstance(agent_id, str) or not agent_id.strip():
|
|
1391
1395
|
raise TaskWorkflowError("TASK_PHASE_RESOURCE_ACTIVE", f"delegated execution status is unknown for {task_id}; preserve the current state")
|
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
"""Versioned controller-only worktree delegation; Paseo owns native resources."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import hashlib
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
import re
|
|
9
|
+
import subprocess
|
|
10
|
+
import uuid
|
|
11
|
+
from typing import NoReturn
|
|
12
|
+
|
|
13
|
+
from .io import read_json_checked, write_json
|
|
14
|
+
from .paths import get_repo_root
|
|
15
|
+
|
|
16
|
+
MAX_BYTES = 256 * 1024
|
|
17
|
+
SAFE_ID = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def fail(message: str) -> NoReturn:
|
|
21
|
+
from .task_workflow import TaskWorkflowError
|
|
22
|
+
raise TaskWorkflowError("TASK_DELEGATE_WITHHELD", message)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def digest(value) -> str:
|
|
26
|
+
data = value if isinstance(value, bytes) else json.dumps(value, sort_keys=True, separators=(",", ":"), ensure_ascii=False).encode()
|
|
27
|
+
return hashlib.sha256(data).hexdigest()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def read(path: Path) -> dict:
|
|
31
|
+
if path.is_symlink() or not path.is_file() or path.stat().st_size > MAX_BYTES:
|
|
32
|
+
fail(f"invalid bounded regular JSON file: {path}")
|
|
33
|
+
value, reason = read_json_checked(path)
|
|
34
|
+
if value is None:
|
|
35
|
+
fail(f"cannot read {path}: {reason}")
|
|
36
|
+
return value
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def save(path: Path, value: dict):
|
|
40
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
41
|
+
if path.is_symlink() or not write_json(path, value):
|
|
42
|
+
fail(f"could not atomically save {path}; preserve current state")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def runtime_path(root: Path, task_id: str) -> Path:
|
|
46
|
+
if not SAFE_ID.fullmatch(task_id):
|
|
47
|
+
fail("unsafe task identity")
|
|
48
|
+
path = root / ".trellis/.runtime/delegation" / task_id / "record.json"
|
|
49
|
+
if path.resolve() != path.absolute():
|
|
50
|
+
fail("redirected delegation runtime")
|
|
51
|
+
return path
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def resolve_record(root: Path, task_dir: Path, data: dict):
|
|
55
|
+
"""One resolver for current runtime and historical task-meta consumers."""
|
|
56
|
+
path = runtime_path(root, task_dir.name)
|
|
57
|
+
return read(path) if path.exists() else data.get("meta", {}).get("delegated_worktree_execution_record")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def git(root: Path, *args: str) -> str:
|
|
61
|
+
result = subprocess.run(["git", *args], cwd=root, capture_output=True, text=True, encoding="utf8", timeout=30)
|
|
62
|
+
if result.returncode:
|
|
63
|
+
fail(f"Git identity/check failed: {args[0]}")
|
|
64
|
+
return result.stdout.strip()
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def identity(root: Path) -> dict:
|
|
68
|
+
root = root.resolve(strict=True)
|
|
69
|
+
if Path(git(root, "rev-parse", "--show-toplevel")).resolve() != root:
|
|
70
|
+
fail("target must be the exact checkout root")
|
|
71
|
+
return {"checkout": str(root), "common_dir": str(Path(git(root, "rev-parse", "--path-format=absolute", "--git-common-dir")).resolve())}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def task_inputs(child_dir: Path):
|
|
75
|
+
from .task_workflow import _load, _task_dir, _state, implementation_start_ready, TaskWorkflowError
|
|
76
|
+
from .task_continuity import assert_task_mutation_allowed
|
|
77
|
+
child, _ = _load(child_dir)
|
|
78
|
+
if not child.get("parent"):
|
|
79
|
+
fail("child must be linked to an authorized controller task")
|
|
80
|
+
parent_dir = _task_dir(child["parent"])
|
|
81
|
+
parent, meta = _load(parent_dir)
|
|
82
|
+
if child.get("status") not in {"planning", "in_progress"}:
|
|
83
|
+
raise TaskWorkflowError("TASK_DELEGATE_CHILD_TERMINAL", "child task is terminal")
|
|
84
|
+
if child_dir.name not in parent.get("children", []):
|
|
85
|
+
fail("child links or lifecycle are invalid")
|
|
86
|
+
assert_task_mutation_allowed(get_repo_root(), parent_dir, parent)
|
|
87
|
+
assert_task_mutation_allowed(get_repo_root(), child_dir, child)
|
|
88
|
+
if parent.get("status") != "in_progress" or not implementation_start_ready(parent, parent_dir):
|
|
89
|
+
raise TaskWorkflowError("TASK_DELEGATE_IMPLEMENTATION_NOT_AUTHORIZED", "current parent implementation authorization required")
|
|
90
|
+
return child, parent, _state(meta), parent_dir
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def file_ref(task_dir: Path, ref: str) -> Path:
|
|
94
|
+
path = task_dir / ref
|
|
95
|
+
try:
|
|
96
|
+
path.resolve(strict=True).relative_to(task_dir.resolve())
|
|
97
|
+
except (ValueError, OSError):
|
|
98
|
+
fail("metadata reference must stay in the child task")
|
|
99
|
+
if path.is_symlink() or not path.is_file() or path.stat().st_size > MAX_BYTES:
|
|
100
|
+
fail("metadata reference must be a bounded regular file")
|
|
101
|
+
return path
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def freeze(root: Path, child_dir: Path, target: Path, branch: str | None, integration: str, settings_ref: str, requirements_ref: str, base_commit: str | None = None) -> dict:
|
|
105
|
+
child, parent, state, _ = task_inputs(child_dir)
|
|
106
|
+
target_identity = identity(target)
|
|
107
|
+
settings_path, requirements_path = file_ref(child_dir, settings_ref), file_ref(child_dir, requirements_ref)
|
|
108
|
+
settings, requirements = read(settings_path), read(requirements_path)
|
|
109
|
+
if settings.get("version") != 1 or settings.get("provider") != "codex" or settings.get("mode") != "full-access" or not settings.get("model") or not settings.get("effort"):
|
|
110
|
+
fail("settings v1 require explicit codex/model/effort/full-access; resolve defaults through capability first")
|
|
111
|
+
if set(settings) - {"version", "provider", "model", "effort", "mode", "daemon_home", "sandbox", "approval", "reviewer", "context"}:
|
|
112
|
+
fail("unknown settings field")
|
|
113
|
+
if any(settings.get(k, "native_default") != "native_default" for k in ["sandbox", "approval", "reviewer", "context"]):
|
|
114
|
+
fail("bottom-level permissions and context must retain native defaults")
|
|
115
|
+
fields = {"version", "required_rules", "required_skills", "required_tools", "checks", "resources", "allowed_paths", "forbidden_paths", "setup_ref", "teamwork_permission"}
|
|
116
|
+
if requirements.get("version") != 1 or set(requirements) - fields or not isinstance(requirements.get("allowed_paths"), list) or not requirements["allowed_paths"]:
|
|
117
|
+
fail("requirements v1 and nonempty allowed_paths required")
|
|
118
|
+
for key in fields - {"version", "setup_ref", "teamwork_permission"}:
|
|
119
|
+
if key in requirements and (not isinstance(requirements[key], list) or any(not isinstance(item, str) or not item or "\0" in item for item in requirements[key])):
|
|
120
|
+
fail(f"requirements {key} must contain nonempty strings")
|
|
121
|
+
if requirements.get("teamwork_permission", "none") not in {"none", "read_only"}:
|
|
122
|
+
fail("Teamwork may only be absent or read_only")
|
|
123
|
+
if requirements.get("setup_ref"):
|
|
124
|
+
file_ref(child_dir, requirements["setup_ref"])
|
|
125
|
+
if not isinstance(branch, str) or not branch:
|
|
126
|
+
fail("child execution branch must be set through the native task interface")
|
|
127
|
+
for ref in [settings_ref, requirements_ref, "prd.md"]:
|
|
128
|
+
file_ref(child_dir, ref)
|
|
129
|
+
git(target, "check-ref-format", "--branch", branch)
|
|
130
|
+
git(target, "check-ref-format", "--branch", integration)
|
|
131
|
+
if branch == integration:
|
|
132
|
+
fail("execution branch must differ from integration branch")
|
|
133
|
+
base = base_commit or git(target, "rev-parse", "--verify", "--end-of-options", f"{integration}^{{commit}}")
|
|
134
|
+
git(target, "merge-base", "--is-ancestor", base, integration)
|
|
135
|
+
role = root / ".trellis/agents/delegated-worktree-primary-agent.md"
|
|
136
|
+
if not role.is_file() or role.is_symlink() or role.stat().st_size > MAX_BYTES:
|
|
137
|
+
fail("current bundled stable role is missing; update project assets")
|
|
138
|
+
authorization = state["implementation_authorization"]
|
|
139
|
+
binding = {"format_version": 1, "parent_task_id": parent["id"], "child_task_id": child["id"], "parent_route_revision": state["task_route_revision"], "parent_contract_revision": authorization["contract_revision"], "approval_ref": authorization["approval_ref"], "target_locator": str(target), "integration_branch": integration, "execution_branch": branch, "base_commit": base, "contract_sha256": digest(file_ref(child_dir, "prd.md").read_bytes()), "role_sha256": digest(role.read_bytes()), "settings_sha256": digest(settings_path.read_bytes()), "requirements_sha256": digest(requirements_path.read_bytes()), "settings_ref": settings_ref, "requirements_ref": requirements_ref}
|
|
140
|
+
binding["binding_revision"] = digest(binding)
|
|
141
|
+
return {"binding": binding, "target_identity": target_identity, "settings": settings, "requirements": requirements}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def adapter(record: dict, operation: str, payload: dict):
|
|
145
|
+
request = {"version": 1, "operation": operation, "attempt_id": record.get("attempt_id"), "binding_revision": record.get("binding", {}).get("binding_revision"), "daemon_selector": {"home": record["settings"].get("daemon_home")} if record["settings"].get("daemon_home") else {}, "payload": payload}
|
|
146
|
+
if record.get("daemon_identity"):
|
|
147
|
+
request["daemon_selector"]["server_id"] = record["daemon_identity"]["server_id"]
|
|
148
|
+
try:
|
|
149
|
+
# A regular temp file bounds what the controller reads even if a broken
|
|
150
|
+
# adapter emits excessive output. Never execute candidate-report commands.
|
|
151
|
+
import tempfile
|
|
152
|
+
with tempfile.TemporaryFile() as output, tempfile.TemporaryFile() as errors:
|
|
153
|
+
result = subprocess.run(["trellis-paseo-adapter"], input=json.dumps(request).encode(), stdout=output, stderr=errors, timeout=3700 if operation == "wait" else 120)
|
|
154
|
+
output.seek(0)
|
|
155
|
+
raw = output.read(MAX_BYTES + 1)
|
|
156
|
+
value = json.loads(raw) if len(raw) <= MAX_BYTES else None
|
|
157
|
+
except (OSError, subprocess.TimeoutExpired, ValueError):
|
|
158
|
+
fail("adapter unavailable or outcome unknown; preserve intent and reconcile; install/check trellis-paseo-adapter through Lifecycle")
|
|
159
|
+
if not isinstance(value, dict) or value.get("version") != 1 or value.get("operation") != operation or value.get("attempt_id") != request["attempt_id"] or value.get("binding_revision") != request["binding_revision"]:
|
|
160
|
+
fail("adapter response identity/shape unknown; preserve intent and reconcile")
|
|
161
|
+
if result.returncode or value.get("ok") is not True or not isinstance(value.get("observations"), dict):
|
|
162
|
+
fail(f"adapter {value.get('error', {}).get('category', 'outcome_unknown')}; inspect native resources before retry")
|
|
163
|
+
observed = value["observations"]
|
|
164
|
+
if record.get("daemon_identity") and observed.get("identity") != record["daemon_identity"]:
|
|
165
|
+
fail("daemon identity changed; reconcile before continuing")
|
|
166
|
+
return observed
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def current(root: Path, child_dir: Path) -> tuple[dict, Path]:
|
|
170
|
+
path = runtime_path(root, child_dir.name)
|
|
171
|
+
record = read(path)
|
|
172
|
+
b = record["binding"]
|
|
173
|
+
frozen = freeze(root, child_dir, Path(b["target_locator"]), b["execution_branch"], b["integration_branch"], b["settings_ref"], b["requirements_ref"], b["base_commit"])
|
|
174
|
+
if frozen != {k: record[k] for k in frozen}:
|
|
175
|
+
fail("frozen input or target identity changed; preserve current attempt and rebind only after closure")
|
|
176
|
+
return record, path
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def assert_worktree(record: dict):
|
|
180
|
+
tree = Path(record["worktree_path"])
|
|
181
|
+
actual = identity(tree)
|
|
182
|
+
if actual["common_dir"] != record["target_identity"]["common_dir"] or git(tree, "branch", "--show-current") != record["binding"]["execution_branch"]:
|
|
183
|
+
fail("native worktree identity does not match current binding")
|
|
184
|
+
git(tree, "merge-base", "--is-ancestor", record["binding"]["base_commit"], "HEAD")
|
|
185
|
+
return tree
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def projection(root: Path, child_dir: Path, record: dict, path: Path):
|
|
189
|
+
b = record["binding"]
|
|
190
|
+
context = {"version": 1, "control_root": str(root), "control_task": str(child_dir), "record_ref": str(path), "attempt_id": record["attempt_id"], "binding_revision": b["binding_revision"], "binding": b, "workspace_id": record.get("workspace_id"), "agent_id": record.get("agent_id"), "target": record.get("worktree_path"), "execution_permission": record.get("execution_permission", "preparation"), "role_ref": str(root / ".trellis/agents/delegated-worktree-primary-agent.md"), "contract_ref": str(child_dir / "prd.md"), "requirements": record["requirements"], "settings": record["settings"], "node_method_ref": str(root / ".trellis/agents/worktree-delegation-node.md"), "ready_path": str(Path(record["worktree_path"]) / ".trellis-delegation" / record["attempt_id"] / "ready.json"), "result_path": str(Path(record["worktree_path"]) / ".trellis-delegation" / record["attempt_id"] / "result.json")}
|
|
191
|
+
save(path.with_name("context.json"), context)
|
|
192
|
+
return path.with_name("context.json")
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def candidate(record: dict, name: str, *, current_head=True):
|
|
196
|
+
tree = assert_worktree(record)
|
|
197
|
+
directory = tree / ".trellis-delegation" / record["attempt_id"]
|
|
198
|
+
path = directory / f"{name}.json"
|
|
199
|
+
if directory.resolve() != directory or (tree / ".trellis-delegation").is_symlink():
|
|
200
|
+
fail("redirected candidate directory")
|
|
201
|
+
if directory.exists() and any(p.name not in {"ready.json", "result.json", "blocked.json"} or p.is_symlink() or not p.is_file() or p.stat().st_size > MAX_BYTES for p in directory.iterdir()):
|
|
202
|
+
fail("candidate directory contains unexpected data; preserve it")
|
|
203
|
+
if not path.exists():
|
|
204
|
+
return None
|
|
205
|
+
value = read(path)
|
|
206
|
+
b = record["binding"]
|
|
207
|
+
expected = {"version": 1, "kind": name, "attempt_id": record["attempt_id"], "binding_revision": b["binding_revision"], "base_commit": b["base_commit"], "workspace_id": record["workspace_id"], "agent_id": record["agent_id"]}
|
|
208
|
+
if any(value.get(k) != v for k, v in expected.items()) or (current_head and value.get("head_commit") != git(tree, "rev-parse", "HEAD")) or "acceptance" in value:
|
|
209
|
+
fail("candidate identity/head/authority does not match the current attempt")
|
|
210
|
+
if not isinstance(value.get("observations"), dict) or not isinstance(value.get("limitations"), list):
|
|
211
|
+
fail("candidate observations/limitations are malformed")
|
|
212
|
+
return value
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def clean_result(record: dict, result: dict):
|
|
216
|
+
tree = assert_worktree(record)
|
|
217
|
+
base, head = record["binding"]["base_commit"], result["head_commit"]
|
|
218
|
+
changed = git(tree, "diff", "--name-only", base, head).splitlines()
|
|
219
|
+
commits = git(tree, "rev-list", f"{base}..{head}").splitlines()
|
|
220
|
+
if set(changed) != set(result.get("changed_paths", [])) or set(commits) != set(result.get("source_commits", [])):
|
|
221
|
+
fail("result commits/paths do not match native Git")
|
|
222
|
+
import fnmatch
|
|
223
|
+
req = record["requirements"]
|
|
224
|
+
if any(p.startswith((".trellis-delegation/", ".trellis/tasks/", ".trellis/.runtime/")) or not any(fnmatch.fnmatchcase(p, a) for a in req["allowed_paths"]) or any(fnmatch.fnmatchcase(p, f) for f in req.get("forbidden_paths", [])) for p in changed):
|
|
225
|
+
fail("source changes exceed the authorized paths")
|
|
226
|
+
# No hidden committed runtime files, even if a later commit deletes them.
|
|
227
|
+
for commit in commits:
|
|
228
|
+
if git(tree, "diff-tree", "--no-commit-id", "--name-only", "-r", "-m", commit, "--", ".trellis-delegation", ".trellis/tasks", ".trellis/.runtime"):
|
|
229
|
+
fail("source history modifies protected controller/runtime facts")
|
|
230
|
+
dirty = git(tree, "status", "--porcelain", "--untracked-files=all").splitlines()
|
|
231
|
+
allowed = {f"?? .trellis-delegation/{record['attempt_id']}/{name}.json" for name in ["ready", "result", "blocked"]}
|
|
232
|
+
if any(line not in allowed for line in dirty):
|
|
233
|
+
fail("source worktree has unpreserved changes")
|
|
234
|
+
if not isinstance(result.get("checks"), list) or not isinstance(result.get("remaining"), list):
|
|
235
|
+
fail("result checks/remaining required")
|
|
236
|
+
return changed
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def prepare_agent(root: Path, child_dir: Path, record: dict, path: Path):
|
|
240
|
+
context = projection(root, child_dir, record, path)
|
|
241
|
+
role = (root / ".trellis/agents/delegated-worktree-primary-agent.md").read_text(encoding="utf8")
|
|
242
|
+
if role.startswith("---\n"):
|
|
243
|
+
role = role.split("\n---\n", 1)[1].lstrip("\n")
|
|
244
|
+
record["intent"] = "prepare-agent"
|
|
245
|
+
save(path, record)
|
|
246
|
+
agent = adapter(record, "prepare-agent", {"workspace_id": record["workspace_id"], "cwd": record["worktree_path"], "model": record["settings"]["model"], "effort": record["settings"]["effort"], "role": role, "context": str(context), "prompt": f"prepare:读取 {context},只准备并提交 ready.json;当前 agent_id 映射由主控落盘,身份不完整时只报告阻断。", "codegraph": "codegraph" in record["requirements"].get("required_tools", []), "labels": {"trellis.control": record["control_project_id"], "trellis.child": record["binding"]["child_task_id"], "trellis.attempt": record["attempt_id"]}})["agent"]
|
|
247
|
+
if not agent or not agent.get("id") or agent.get("workspaceId") != record["workspace_id"]:
|
|
248
|
+
fail("agent creation outcome unknown; preserve intent")
|
|
249
|
+
record.update({"agent_id": agent["id"], "status": "running", "intent": None})
|
|
250
|
+
save(path, record)
|
|
251
|
+
projection(root, child_dir, record, path)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def recover(root: Path, child_dir: Path, record: dict, path: Path, args):
|
|
255
|
+
if not record.get("attempt_id") or not record.get("intent"):
|
|
256
|
+
fail("recovery requires an unresolved attempt intent")
|
|
257
|
+
workspace_id = args.workspace_id or record.get("workspace_id")
|
|
258
|
+
if not workspace_id:
|
|
259
|
+
fail("explicit native workspace-id required; inspect native resources first")
|
|
260
|
+
observed = adapter(record, "inspect", {"target": record["binding"]["target_locator"], "workspace_id": workspace_id})
|
|
261
|
+
spaces = observed.get("workspaces", [])
|
|
262
|
+
if len(spaces) != 1 or spaces[0].get("id") != workspace_id or not spaces[0].get("workspaceDirectory"):
|
|
263
|
+
fail("native workspace identity is unverified")
|
|
264
|
+
adopted = {**record, "workspace_id": workspace_id, "worktree_path": str(Path(spaces[0]["workspaceDirectory"]).resolve())}
|
|
265
|
+
assert_worktree(adopted)
|
|
266
|
+
if record.get("workspace_id") and (record["workspace_id"] != workspace_id or record["worktree_path"] != adopted["worktree_path"]):
|
|
267
|
+
fail("recovery cannot switch existing workspace mappings")
|
|
268
|
+
agent_id = args.agent_id or record.get("agent_id")
|
|
269
|
+
if agent_id:
|
|
270
|
+
agents = [a for a in observed.get("agents", []) if a and a.get("id") == agent_id]
|
|
271
|
+
if len(agents) != 1:
|
|
272
|
+
fail("exact native agent-id not found; no fuzzy or prefix adoption")
|
|
273
|
+
agent = agents[0]
|
|
274
|
+
if agent.get("workspaceId") != workspace_id or Path(agent.get("cwd", "")).resolve() != Path(adopted["worktree_path"]) or agent.get("labels", {}).get("trellis.attempt") != record["attempt_id"] or agent.get("labels", {}).get("trellis.control") != record["control_project_id"]:
|
|
275
|
+
fail("native agent labels/workspace/cwd do not match the pending attempt")
|
|
276
|
+
if record.get("agent_id") and record["agent_id"] != agent_id:
|
|
277
|
+
fail("recovery cannot replace an existing agent")
|
|
278
|
+
adopted.update({"agent_id": agent_id, "status": "running"})
|
|
279
|
+
elif record["intent"] != "prepare-workspace":
|
|
280
|
+
fail("unknown agent creation must be mapped before any new agent is created")
|
|
281
|
+
else:
|
|
282
|
+
adopted["status"] = "workspace_created"
|
|
283
|
+
evidence = {"observation": observed, "intent": record["intent"]}
|
|
284
|
+
if record["intent"] in {"send_pending", "interrupt_pending"}:
|
|
285
|
+
if not args.delivery_evidence_ref:
|
|
286
|
+
fail("controller-owned native delivery/interrupt evidence required; idle alone cannot resolve unknown delivery")
|
|
287
|
+
evidence["delivery_evidence"] = file_ref(child_dir, args.delivery_evidence_ref).read_text(encoding="utf8")
|
|
288
|
+
if not args.execute:
|
|
289
|
+
return {"status": "ready", "recovery": evidence, "adopted": adopted}
|
|
290
|
+
if not args.reason or not args.approval_ref:
|
|
291
|
+
fail("explicit recovery reason and existing approval reference required")
|
|
292
|
+
adopted.setdefault("recovery_receipts", []).append({**evidence, "reason": args.reason, "approval_ref": args.approval_ref})
|
|
293
|
+
adopted["intent"] = None
|
|
294
|
+
save(path, adopted)
|
|
295
|
+
projection(root, child_dir, adopted, path)
|
|
296
|
+
return adopted
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
def run(args):
|
|
300
|
+
from .task_workflow import _task_dir, _task_lock
|
|
301
|
+
root = get_repo_root().resolve()
|
|
302
|
+
child_dir = _task_dir(args.child_task)
|
|
303
|
+
with _task_lock(child_dir):
|
|
304
|
+
path = runtime_path(root, child_dir.name)
|
|
305
|
+
operation = args.command.removeprefix("delegate-")
|
|
306
|
+
if operation == "bind":
|
|
307
|
+
if getattr(args, "result_path", None):
|
|
308
|
+
fail("legacy --result-path cannot start protocol v1; reconcile old attempts first")
|
|
309
|
+
child, _, _, _ = task_inputs(child_dir)
|
|
310
|
+
previous = resolve_record(root, child_dir, child)
|
|
311
|
+
if previous and previous.get("status") != "retired":
|
|
312
|
+
fail("an existing attempt is not retired; inspect/reconcile instead of rebinding")
|
|
313
|
+
if not args.target_repo or not args.integration_branch or not args.settings_ref or not args.requirements_ref:
|
|
314
|
+
fail("explicit --target-repo, --integration-branch, --settings-ref and --requirements-ref required")
|
|
315
|
+
record = freeze(root, child_dir, Path(args.target_repo).resolve(), child.get("branch"), args.integration_branch, args.settings_ref, args.requirements_ref)
|
|
316
|
+
record.update({"status": "bound", "control_project_id": digest(str(root).encode()), "execution_permission": "preparation"})
|
|
317
|
+
if previous:
|
|
318
|
+
save(path.with_name(f"retired-{previous['attempt_id']}.json"), previous)
|
|
319
|
+
save(path, record)
|
|
320
|
+
else:
|
|
321
|
+
_, _, state, _ = task_inputs(child_dir)
|
|
322
|
+
if operation == "start":
|
|
323
|
+
admission = state.get("route_dependency_admission") or {}
|
|
324
|
+
if admission.get("admission_state") != "ready":
|
|
325
|
+
from .task_workflow import TaskWorkflowError
|
|
326
|
+
raise TaskWorkflowError("TASK_DELEGATE_ADMISSION_REQUIRED", "current route dependency admission is not ready")
|
|
327
|
+
record, path = current(root, child_dir)
|
|
328
|
+
b = record["binding"]
|
|
329
|
+
if operation == "start":
|
|
330
|
+
if record["status"] == "workspace_created" and not record.get("intent"):
|
|
331
|
+
assert_worktree(record)
|
|
332
|
+
prepare_agent(root, child_dir, record, path)
|
|
333
|
+
print(json.dumps(record, ensure_ascii=False))
|
|
334
|
+
return 0
|
|
335
|
+
if record["status"] != "bound":
|
|
336
|
+
fail("attempt already exists; use inspect/observe/reconcile without creating another writer")
|
|
337
|
+
_, _, state, _ = task_inputs(child_dir)
|
|
338
|
+
admission = state.get("route_dependency_admission") or {}
|
|
339
|
+
if admission.get("admission_state") != "ready" or admission.get("task_route_revision") != state["task_route_revision"] or not admission.get("evidence_refs") or not {"pennix-lifecycle", "paseo", "git"}.issubset(admission.get("dependencies", [])):
|
|
340
|
+
fail("current evidenced Lifecycle/Paseo/Git admission is required")
|
|
341
|
+
observed = adapter(record, "capability", {"cwd": b["target_locator"]})
|
|
342
|
+
record["daemon_identity"] = observed["identity"]
|
|
343
|
+
models = observed.get("models", [])
|
|
344
|
+
modes = observed.get("modes", [])
|
|
345
|
+
if isinstance(models, dict):
|
|
346
|
+
models = models.get("models", [])
|
|
347
|
+
if isinstance(modes, dict):
|
|
348
|
+
modes = modes.get("modes", [])
|
|
349
|
+
selected = next((m for m in models if m.get("id") == record["settings"]["model"]), None)
|
|
350
|
+
if not selected or not any(m.get("id") == "full-access" for m in modes):
|
|
351
|
+
fail("requested Codex model/full-access mode is not available")
|
|
352
|
+
options = selected.get("thinkingOptions", [])
|
|
353
|
+
if not any(o.get("id") == record["settings"]["effort"] for o in options):
|
|
354
|
+
fail("requested effort is not supported by the selected model")
|
|
355
|
+
existing = adapter(record, "inspect", {"target": b["target_locator"]})
|
|
356
|
+
if existing.get("lifecycle", {}).get("autoArchiveAfterMerge") is not False:
|
|
357
|
+
fail("native autoArchiveAfterMerge must be explicitly disabled before delegation; preserve worktrees until owner closeout")
|
|
358
|
+
for agent in existing.get("agents", []):
|
|
359
|
+
if agent and agent.get("status") not in {"closed", "idle"} and agent.get("cwd") and Path(agent["cwd"]).exists() and identity(Path(agent["cwd"]))["common_dir"] == record["target_identity"]["common_dir"] and git(Path(agent["cwd"]), "branch", "--show-current") == b["execution_branch"]:
|
|
360
|
+
fail("another target writer is active; reconcile before starting")
|
|
361
|
+
if subprocess.run(["git", "show-ref", "--verify", "--quiet", f"refs/heads/{b['execution_branch']}"], cwd=b["target_locator"]).returncode != 1:
|
|
362
|
+
fail("execution branch already exists; do not create or reset it")
|
|
363
|
+
for other in (root / ".trellis/.runtime/delegation").glob("*/record.json"):
|
|
364
|
+
if other != path:
|
|
365
|
+
item = read(other)
|
|
366
|
+
if item.get("target_identity") == record["target_identity"] and item.get("binding", {}).get("execution_branch") == b["execution_branch"] and item.get("status") not in {"bound", "retired"}:
|
|
367
|
+
fail("another controller record owns this target branch")
|
|
368
|
+
record.update({"attempt_id": uuid.uuid4().hex, "status": "starting", "intent": "prepare-workspace"})
|
|
369
|
+
save(path, record)
|
|
370
|
+
workspace = adapter(record, "prepare-workspace", {"target": b["target_locator"], "branch": b["execution_branch"], "base_commit": b["base_commit"], "title": f"trellis-{record['attempt_id']}"})["workspace"]
|
|
371
|
+
if not isinstance(workspace, dict) or not workspace.get("id") or not workspace.get("workspaceDirectory"):
|
|
372
|
+
fail("workspace creation outcome unknown; preserve intent")
|
|
373
|
+
record.update({"workspace_id": workspace["id"], "worktree_path": str(Path(workspace["workspaceDirectory"]).resolve()), "status": "workspace_created"})
|
|
374
|
+
save(path, record)
|
|
375
|
+
assert_worktree(record)
|
|
376
|
+
prepare_agent(root, child_dir, record, path)
|
|
377
|
+
elif operation in {"inspect", "observe", "wait", "interrupt"}:
|
|
378
|
+
if operation == "interrupt":
|
|
379
|
+
if record.get("intent"):
|
|
380
|
+
fail("resolve prior intent before interrupt; native emergency cancellation remains available")
|
|
381
|
+
record["intent"] = "interrupt_pending"
|
|
382
|
+
save(path, record)
|
|
383
|
+
observations = adapter(record, "wait" if operation == "wait" else "interrupt" if operation == "interrupt" else "observe" if record.get("agent_id") else "inspect", {"agent_id": record["agent_id"], "cwd": record["worktree_path"], **({"timeout_ms": args.timeout_ms} if operation == "wait" else {})} if record.get("agent_id") else {"target": b["target_locator"], **({"workspace_id": record["workspace_id"]} if record.get("workspace_id") else {})})
|
|
384
|
+
if operation == "interrupt":
|
|
385
|
+
record.setdefault("interrupt_receipts", []).append(observations)
|
|
386
|
+
record["intent"] = None
|
|
387
|
+
save(path, record)
|
|
388
|
+
reports = {name: candidate(record, name, current_head=False) for name in ["ready", "result", "blocked"]} if record.get("worktree_path") else {}
|
|
389
|
+
print(json.dumps({"record": record, "observations": observations, "candidates": reports}, ensure_ascii=False))
|
|
390
|
+
return 0
|
|
391
|
+
elif operation in {"execute", "followup"}:
|
|
392
|
+
if record.get("intent"):
|
|
393
|
+
fail("prior creation/send outcome unresolved; inspect and reconcile first")
|
|
394
|
+
observed = adapter(record, "observe", {"agent_id": record["agent_id"], "cwd": record["worktree_path"]})["agent"]
|
|
395
|
+
runtime = observed.get("runtimeInfo") or {}
|
|
396
|
+
if observed.get("activeTurn") or observed.get("status") != "idle" or runtime.get("modeId") != "full-access" or runtime.get("model") != record["settings"]["model"] or runtime.get("thinkingOptionId") != record["settings"]["effort"]:
|
|
397
|
+
fail("agent is active or settings are unverified/drifted")
|
|
398
|
+
ready = candidate(record, "ready", current_head=operation == "execute")
|
|
399
|
+
if not ready or ready.get("missing") != []:
|
|
400
|
+
fail("current ready candidate with no missing requirements required")
|
|
401
|
+
record["ready_evidence"] = ready
|
|
402
|
+
record["execution_permission"] = "implementation"
|
|
403
|
+
context = projection(root, child_dir, record, path)
|
|
404
|
+
message = f"{operation}:重新读取 {context},按当前绑定与许可完成本包并提交 result.json。"
|
|
405
|
+
if operation == "followup":
|
|
406
|
+
message += file_ref(child_dir, args.instructions_ref).read_text(encoding="utf8")
|
|
407
|
+
record["intent"] = "send_pending"
|
|
408
|
+
record["send_pending"] = {"client_message_id": str(uuid.uuid4()), "sha256": digest(message.encode())}
|
|
409
|
+
save(path, record)
|
|
410
|
+
receipt = adapter(record, operation, {"agent_id": record["agent_id"], "cwd": record["worktree_path"], "prompt": message, "client_message_id": record["send_pending"]["client_message_id"]})
|
|
411
|
+
record.setdefault("followup_receipts", []).append({**record.pop("send_pending"), **receipt})
|
|
412
|
+
record["intent"] = None
|
|
413
|
+
save(path, record)
|
|
414
|
+
elif operation == "reconcile":
|
|
415
|
+
if args.recover:
|
|
416
|
+
print(json.dumps(recover(root, child_dir, record, path, args), ensure_ascii=False))
|
|
417
|
+
return 0
|
|
418
|
+
if record.get("status") == "retired":
|
|
419
|
+
print(json.dumps(record, ensure_ascii=False)); return 0
|
|
420
|
+
if not record.get("agent_id"):
|
|
421
|
+
fail("partial creation requires explicit native resource mapping before retirement; preserve intent")
|
|
422
|
+
observation = adapter(record, "observe", {"agent_id": record["agent_id"], "cwd": record["worktree_path"]})
|
|
423
|
+
agent = observation["agent"]
|
|
424
|
+
if not agent or agent.get("activeTurn") or agent.get("status") not in {"idle", "closed"}:
|
|
425
|
+
fail("native writer is active or unknown")
|
|
426
|
+
result = candidate(record, "result")
|
|
427
|
+
if not result and args.disposition != "retained":
|
|
428
|
+
fail("bounded result and preserved source evidence required before retirement")
|
|
429
|
+
if result:
|
|
430
|
+
clean_result(record, result)
|
|
431
|
+
if args.disposition == "integrated":
|
|
432
|
+
if result is None:
|
|
433
|
+
fail("integrated closure requires a result")
|
|
434
|
+
git(Path(b["target_locator"]), "merge-base", "--is-ancestor", result["head_commit"], b["integration_branch"])
|
|
435
|
+
tree = assert_worktree(record)
|
|
436
|
+
evidence = {"result": result, "observation": observation, "disposition": args.disposition, "preserved_worktree": str(tree), "head_commit": git(tree, "rev-parse", "HEAD"), "git_status": git(tree, "status", "--porcelain", "--untracked-files=all")}
|
|
437
|
+
if not args.execute:
|
|
438
|
+
print(json.dumps({"status": "ready", "evidence": evidence}, ensure_ascii=False)); return 0
|
|
439
|
+
if not args.reason or not args.approval_ref or not args.writer_evidence_ref:
|
|
440
|
+
fail("reason, approval-ref and controller-owned writer-evidence-ref required; idle/cancel alone do not prove background writers stopped")
|
|
441
|
+
evidence["writer_evidence"] = file_ref(child_dir, args.writer_evidence_ref).read_text(encoding="utf8")
|
|
442
|
+
record.update({"status": "retired", "intent": None, "result_evidence": result, "closure_evidence": {**evidence, "reason": args.reason, "approval_ref": args.approval_ref}})
|
|
443
|
+
save(path, record)
|
|
444
|
+
else:
|
|
445
|
+
fail("unsupported delegation operation")
|
|
446
|
+
print(json.dumps(record, ensure_ascii=False))
|
|
447
|
+
return 0
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
def node_context() -> dict | None:
|
|
451
|
+
raw = os.environ.get("TRELLIS_DELEGATION_CONTEXT")
|
|
452
|
+
if not raw:
|
|
453
|
+
return None
|
|
454
|
+
context = read(Path(raw))
|
|
455
|
+
record = read(Path(context["record_ref"]))
|
|
456
|
+
if context.get("version") != 1 or record.get("status") == "retired" or context.get("attempt_id") != record.get("attempt_id") or context.get("binding_revision") != record.get("binding", {}).get("binding_revision") or context.get("agent_id") != os.environ.get("PASEO_AGENT_ID") or not context.get("agent_id") or git(Path.cwd(), "rev-parse", "--show-toplevel") != str(Path(context.get("target", "")).resolve()):
|
|
457
|
+
fail("delegated context/resource/cwd is missing, stale or mismatched; do not enter ordinary controller workflow")
|
|
458
|
+
assert_worktree(record)
|
|
459
|
+
if context.get("execution_permission") != record.get("execution_permission") or context.get("binding") != record.get("binding") or context.get("target") != record.get("worktree_path"):
|
|
460
|
+
fail("delegated execution projection is stale")
|
|
461
|
+
control = Path(context["control_task"])
|
|
462
|
+
child = read(control / "task.json")
|
|
463
|
+
from .task_utils import resolve_task_dir
|
|
464
|
+
parent_dir = resolve_task_dir(child["parent"], Path(context["control_root"]))
|
|
465
|
+
if parent_dir is None:
|
|
466
|
+
fail("current parent task is missing")
|
|
467
|
+
parent = read(parent_dir / "task.json")
|
|
468
|
+
state = parent.get("meta", {}).get("task_workflow", {})
|
|
469
|
+
b = record["binding"]
|
|
470
|
+
auth = state.get("implementation_authorization") or {}
|
|
471
|
+
if parent.get("status") != "in_progress" or state.get("current_phase_id") != "task_implementation" or state.get("task_route_revision") != b["parent_route_revision"] or auth.get("contract_revision") != b["parent_contract_revision"]:
|
|
472
|
+
fail("parent authorization changed; stop delegated implementation")
|
|
473
|
+
for ref, key in [("prd.md", "contract_sha256"), (b["settings_ref"], "settings_sha256"), (b["requirements_ref"], "requirements_sha256")]:
|
|
474
|
+
if digest(file_ref(control, ref).read_bytes()) != b[key]:
|
|
475
|
+
fail("delegated input changed; wait for controller revalidation")
|
|
476
|
+
return context
|
|
@@ -30,6 +30,7 @@ from __future__ import annotations
|
|
|
30
30
|
|
|
31
31
|
import argparse
|
|
32
32
|
import json
|
|
33
|
+
import os
|
|
33
34
|
import sys
|
|
34
35
|
from pathlib import Path
|
|
35
36
|
|
|
@@ -807,11 +808,28 @@ def main() -> int:
|
|
|
807
808
|
p_delegate_bind = subparsers.add_parser("delegate-bind", help="Freeze a linked child contract within current parent authorization")
|
|
808
809
|
p_delegate_bind.add_argument("child_task")
|
|
809
810
|
p_delegate_bind.add_argument("--result-path", help="Assigned artifact under .trellis/delegated-results/")
|
|
811
|
+
p_delegate_bind.add_argument("--target-repo")
|
|
812
|
+
p_delegate_bind.add_argument("--integration-branch")
|
|
813
|
+
p_delegate_bind.add_argument("--settings-ref")
|
|
814
|
+
p_delegate_bind.add_argument("--requirements-ref")
|
|
810
815
|
p_delegate_reconcile = subparsers.add_parser("delegate-reconcile", help="Inspect or explicitly retire a verified delegated execution")
|
|
811
816
|
p_delegate_reconcile.add_argument("child_task")
|
|
812
817
|
p_delegate_reconcile.add_argument("--execute", action="store_true")
|
|
813
818
|
p_delegate_reconcile.add_argument("--reason")
|
|
814
819
|
p_delegate_reconcile.add_argument("--approval-ref")
|
|
820
|
+
p_delegate_reconcile.add_argument("--disposition", choices=("integrated", "retained"), default="integrated")
|
|
821
|
+
p_delegate_reconcile.add_argument("--writer-evidence-ref")
|
|
822
|
+
p_delegate_reconcile.add_argument("--recover", action="store_true", help="Adopt verified existing resources; never replay an unknown create/send")
|
|
823
|
+
p_delegate_reconcile.add_argument("--workspace-id")
|
|
824
|
+
p_delegate_reconcile.add_argument("--agent-id")
|
|
825
|
+
p_delegate_reconcile.add_argument("--delivery-evidence-ref")
|
|
826
|
+
for operation in ("inspect", "execute", "followup", "observe", "wait", "interrupt"):
|
|
827
|
+
command = subparsers.add_parser(f"delegate-{operation}", help="Protocol v1 controller operation; see trellis-worktree-delegation")
|
|
828
|
+
command.add_argument("child_task")
|
|
829
|
+
if operation == "followup":
|
|
830
|
+
command.add_argument("--instructions-ref", required=True)
|
|
831
|
+
if operation == "wait":
|
|
832
|
+
command.add_argument("--timeout-ms", type=int, default=3600000)
|
|
815
833
|
|
|
816
834
|
add_continuity_commands(subparsers)
|
|
817
835
|
|
|
@@ -884,6 +902,10 @@ def main() -> int:
|
|
|
884
902
|
|
|
885
903
|
args = parser.parse_args()
|
|
886
904
|
|
|
905
|
+
if os.environ.get("TRELLIS_DELEGATION_CONTEXT") and args.command not in {"current", "list", "list-context", "validate"}:
|
|
906
|
+
print("TASK_DELEGATE_NODE_READ_ONLY: delegated nodes cannot mutate controller tasks; use the assigned candidate files", file=sys.stderr)
|
|
907
|
+
return 1
|
|
908
|
+
|
|
887
909
|
if not args.command:
|
|
888
910
|
show_usage()
|
|
889
911
|
return 1
|
|
@@ -926,7 +948,15 @@ def main() -> int:
|
|
|
926
948
|
if args.command == "transfer":
|
|
927
949
|
return transfer_task_ownership(args)
|
|
928
950
|
if args.command in commands:
|
|
951
|
+
if args.command.startswith("delegate-"):
|
|
952
|
+
from common.worktree_delegation import run, runtime_path
|
|
953
|
+
child = resolve_task_dir(args.child_task, get_repo_root())
|
|
954
|
+
if args.command != "delegate-reconcile" or (child and runtime_path(get_repo_root(), child.name).exists()):
|
|
955
|
+
return run(args)
|
|
929
956
|
return commands[args.command](args)
|
|
957
|
+
if args.command.startswith("delegate-"):
|
|
958
|
+
from common.worktree_delegation import run
|
|
959
|
+
return run(args)
|
|
930
960
|
show_usage()
|
|
931
961
|
return 1
|
|
932
962
|
except TaskWorkflowError as error:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pennixrv/trellis",
|
|
3
|
-
"version": "0.7.2-beta.
|
|
3
|
+
"version": "0.7.2-beta.5",
|
|
4
4
|
"description": "AI capabilities grow like ivy — Trellis provides the structure to guide them along a disciplined path",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"inquirer": "^9.3.7",
|
|
36
36
|
"undici": "^6.21.0",
|
|
37
37
|
"zod": "^4.4.2",
|
|
38
|
-
"@pennixrv/trellis-core": "0.7.2-beta.
|
|
38
|
+
"@pennixrv/trellis-core": "0.7.2-beta.5"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@eslint/js": "^9.18.0",
|