@pennixrv/trellis 0.7.2-beta.0 → 0.7.2-beta.11
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/README.md +14 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +94 -96
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/teamwork/adapters/acp.d.ts.map +1 -1
- package/dist/commands/teamwork/adapters/acp.js +3 -0
- package/dist/commands/teamwork/adapters/acp.js.map +1 -1
- package/dist/commands/teamwork/adapters/index.d.ts +1 -1
- package/dist/commands/teamwork/adapters/index.d.ts.map +1 -1
- package/dist/commands/teamwork/artifact.d.ts +9 -4
- package/dist/commands/teamwork/artifact.d.ts.map +1 -1
- package/dist/commands/teamwork/artifact.js +8 -37
- package/dist/commands/teamwork/artifact.js.map +1 -1
- package/dist/commands/teamwork/batch.d.ts +1 -0
- package/dist/commands/teamwork/batch.d.ts.map +1 -1
- package/dist/commands/teamwork/batch.js +24 -3
- package/dist/commands/teamwork/batch.js.map +1 -1
- package/dist/commands/teamwork/coordinator.d.ts +16 -3
- package/dist/commands/teamwork/coordinator.d.ts.map +1 -1
- package/dist/commands/teamwork/coordinator.js +209 -86
- package/dist/commands/teamwork/coordinator.js.map +1 -1
- package/dist/commands/teamwork/guard.js +2 -2
- package/dist/commands/teamwork/guard.js.map +1 -1
- package/dist/commands/teamwork/index.d.ts.map +1 -1
- package/dist/commands/teamwork/index.js +26 -2
- package/dist/commands/teamwork/index.js.map +1 -1
- package/dist/commands/teamwork/result.d.ts +2 -1
- package/dist/commands/teamwork/result.d.ts.map +1 -1
- package/dist/commands/teamwork/result.js.map +1 -1
- package/dist/commands/teamwork/runtime.d.ts +2 -2
- package/dist/commands/teamwork/runtime.d.ts.map +1 -1
- package/dist/commands/teamwork/runtime.js +60 -30
- package/dist/commands/teamwork/runtime.js.map +1 -1
- package/dist/commands/teamwork/spawn.d.ts.map +1 -1
- package/dist/commands/teamwork/spawn.js +2 -0
- package/dist/commands/teamwork/spawn.js.map +1 -1
- package/dist/commands/teamwork/supervisor.d.ts +1 -1
- package/dist/commands/teamwork/supervisor.d.ts.map +1 -1
- package/dist/commands/teamwork/teammate-adapters.d.ts +3 -0
- package/dist/commands/teamwork/teammate-adapters.d.ts.map +1 -1
- package/dist/commands/teamwork/teammate-adapters.js +14 -5
- package/dist/commands/teamwork/teammate-adapters.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +34 -44
- package/dist/commands/update.js.map +1 -1
- package/dist/configurators/workflow.d.ts.map +1 -1
- package/dist/configurators/workflow.js +15 -52
- package/dist/configurators/workflow.js.map +1 -1
- package/dist/migrations/manifests/0.7.2-beta.1.json +11 -0
- package/dist/migrations/manifests/0.7.2-beta.10.json +9 -0
- package/dist/migrations/manifests/0.7.2-beta.2.json +11 -0
- package/dist/migrations/manifests/0.7.2-beta.3.json +9 -0
- package/dist/migrations/manifests/0.7.2-beta.4.json +9 -0
- package/dist/migrations/manifests/0.7.2-beta.5.json +9 -0
- package/dist/migrations/manifests/0.7.2-beta.6.json +9 -0
- package/dist/migrations/manifests/0.7.2-beta.7.json +9 -0
- package/dist/migrations/manifests/0.7.2-beta.8.json +9 -0
- package/dist/migrations/manifests/0.7.2-beta.9.json +9 -0
- package/dist/templates/claude/agents/trellis-implement.md +1 -1
- package/dist/templates/codebuddy/agents/trellis-implement.md +1 -1
- package/dist/templates/codex/hooks/session-start.py +24 -29
- package/dist/templates/common/bundled-skills/trellis-decision-space-construction-and-merging/SKILL.md +2 -0
- package/dist/templates/common/bundled-skills/trellis-decision-space-construction-and-merging/workflow.md +7 -3
- package/dist/templates/common/bundled-skills/trellis-delivery-review-and-closeout/SKILL.md +2 -0
- package/dist/templates/common/bundled-skills/trellis-goal-exploration-and-requirements/SKILL.md +2 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/multi-agent-teamwork.md +6 -0
- package/dist/templates/common/bundled-skills/trellis-solution-design-and-convergence/SKILL.md +2 -0
- package/dist/templates/common/bundled-skills/trellis-solution-design-and-convergence/workflow.md +14 -5
- package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/references/spec-writing.md +6 -0
- package/dist/templates/common/bundled-skills/trellis-task-implementation/SKILL.md +2 -0
- package/dist/templates/common/bundled-skills/trellis-task-implementation/workflow.md +1 -1
- package/dist/templates/common/bundled-skills/trellis-teamwork/SKILL.md +7 -0
- package/dist/templates/common/bundled-skills/trellis-teamwork/references/teamwork-plan-construction.md +6 -2
- package/dist/templates/common/bundled-skills/trellis-worktree-delegation/SKILL.md +14 -0
- package/dist/templates/common/bundled-skills/trellis-worktree-delegation/workflow.md +17 -0
- package/dist/templates/common/commands/continue.md +8 -0
- package/dist/templates/common/commands/start.md +2 -0
- package/dist/templates/common/skills/before-dev.md +3 -1
- package/dist/templates/common/skills/check.md +3 -1
- package/dist/templates/common/skills/request-intake.md +5 -3
- package/dist/templates/copilot/hooks/session-start.py +10 -29
- package/dist/templates/cursor/agents/trellis-implement.md +1 -1
- package/dist/templates/droid/droids/trellis-implement.md +1 -1
- package/dist/templates/dsh/agents/trellis-implement.md +1 -1
- package/dist/templates/gemini/agents/trellis-implement.md +1 -1
- package/dist/templates/grok/agents/trellis-implement.md +1 -1
- package/dist/templates/kimi/agents/trellis-implement.md +1 -1
- package/dist/templates/kiro/agents/trellis-implement.json +1 -1
- package/dist/templates/kiro/agents/trellis.json +1 -1
- package/dist/templates/markdown/agents.md +9 -0
- package/dist/templates/markdown/index.d.ts +1 -0
- package/dist/templates/markdown/index.d.ts.map +1 -1
- package/dist/templates/markdown/index.js +1 -0
- package/dist/templates/markdown/index.js.map +1 -1
- package/dist/templates/markdown/spec/index.md.txt +19 -0
- package/dist/templates/opencode/agents/trellis-implement.md +1 -1
- package/dist/templates/opencode/lib/session-utils.js +17 -5
- package/dist/templates/qoder/agents/trellis-implement.md +1 -1
- package/dist/templates/shared-hooks/guard-teamwork-wait.py +5 -0
- package/dist/templates/shared-hooks/inject-workflow-state.py +15 -0
- package/dist/templates/shared-hooks/session-start.py +7 -5
- package/dist/templates/snow/agents/trellis-implement.md +1 -1
- package/dist/templates/trae/agents/trellis-implement.md +1 -1
- package/dist/templates/trellis/agents/delegated-worktree-primary-agent.md +20 -22
- package/dist/templates/trellis/agents/teammate.md +4 -2
- 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/config.py +5 -0
- package/dist/templates/trellis/scripts/common/git_context.py +10 -0
- package/dist/templates/trellis/scripts/common/io.py +2 -2
- package/dist/templates/trellis/scripts/common/packages_context.py +29 -1
- package/dist/templates/trellis/scripts/common/task_continuity.py +73 -0
- package/dist/templates/trellis/scripts/common/task_move.py +2 -2
- package/dist/templates/trellis/scripts/common/task_store.py +23 -1
- package/dist/templates/trellis/scripts/common/task_workflow.py +63 -6
- package/dist/templates/trellis/scripts/common/worktree_delegation.py +561 -0
- package/dist/templates/trellis/scripts/task.py +39 -1
- package/dist/templates/trellis/workflow.md +20 -3
- package/dist/templates/zcode/agents/trellis-implement.md +1 -1
- package/dist/utils/asset-backup.d.ts.map +1 -1
- package/dist/utils/asset-backup.js +40 -26
- package/dist/utils/asset-backup.js.map +1 -1
- package/dist/utils/file-writer.d.ts +2 -0
- package/dist/utils/file-writer.d.ts.map +1 -1
- package/dist/utils/file-writer.js +1 -1
- package/dist/utils/file-writer.js.map +1 -1
- package/dist/utils/managed-markdown.d.ts +5 -0
- package/dist/utils/managed-markdown.d.ts.map +1 -0
- package/dist/utils/managed-markdown.js +64 -0
- package/dist/utils/managed-markdown.js.map +1 -0
- package/dist/utils/managed-removal.d.ts +2 -0
- package/dist/utils/managed-removal.d.ts.map +1 -1
- package/dist/utils/managed-removal.js +26 -2
- package/dist/utils/managed-removal.js.map +1 -1
- package/dist/utils/manifest-prune.d.ts.map +1 -1
- package/dist/utils/manifest-prune.js +5 -12
- package/dist/utils/manifest-prune.js.map +1 -1
- package/dist/utils/uninstall-scrubbers.d.ts.map +1 -1
- package/dist/utils/uninstall-scrubbers.js +5 -11
- package/dist/utils/uninstall-scrubbers.js.map +1 -1
- package/package.json +2 -2
|
@@ -97,6 +97,65 @@ def _task(root: Path, task_path: str | None = None) -> tuple[Path, dict, str, st
|
|
|
97
97
|
return directory, data, task_id, active.context_key
|
|
98
98
|
|
|
99
99
|
|
|
100
|
+
def _submodule_facts(root: Path) -> list[dict]:
|
|
101
|
+
rc, output, _ = run_git(["submodule", "status", "--recursive"], cwd=root, timeout=20)
|
|
102
|
+
if rc:
|
|
103
|
+
raise ContinuityError("TASK_CONTINUITY_WITHHELD", "Git submodule status is unavailable")
|
|
104
|
+
facts = []
|
|
105
|
+
for line in output.splitlines():
|
|
106
|
+
if len(line) < 43:
|
|
107
|
+
raise ContinuityError("TASK_CONTINUITY_WITHHELD", "Git submodule status is malformed")
|
|
108
|
+
state, revision, relative_text = line[0], line[1:41], line[42:]
|
|
109
|
+
if " (" in relative_text:
|
|
110
|
+
relative_text = relative_text.rsplit(" (", 1)[0]
|
|
111
|
+
relative = Path(relative_text)
|
|
112
|
+
candidate = root / relative
|
|
113
|
+
try:
|
|
114
|
+
candidate.resolve(strict=True).relative_to(root.resolve())
|
|
115
|
+
except (OSError, ValueError) as error:
|
|
116
|
+
if state == "-" and not candidate.exists():
|
|
117
|
+
facts.append({"path": relative.as_posix(), "revision": revision, "state": "uninitialized"})
|
|
118
|
+
continue
|
|
119
|
+
raise ContinuityError("TASK_CONTINUITY_WITHHELD", f"submodule path is unavailable or unsafe: {relative}") from error
|
|
120
|
+
if state == "-":
|
|
121
|
+
facts.append({"path": relative.as_posix(), "revision": revision, "state": "uninitialized"})
|
|
122
|
+
continue
|
|
123
|
+
if not candidate.is_dir():
|
|
124
|
+
raise ContinuityError("TASK_CONTINUITY_WITHHELD", f"submodule path is not a directory: {relative}")
|
|
125
|
+
rc, head, _ = run_git(["rev-parse", "HEAD"], cwd=candidate, timeout=5)
|
|
126
|
+
rc_status, status, _ = run_git(["status", "--porcelain=v1", "--untracked-files=all"], cwd=candidate, timeout=10)
|
|
127
|
+
rc_diff, diff, _ = run_git(["diff", "--binary", "HEAD", "--", "."], cwd=candidate, timeout=20)
|
|
128
|
+
rc_untracked, untracked, _ = run_git(["ls-files", "--others", "--exclude-standard", "-z"], cwd=candidate, timeout=10)
|
|
129
|
+
if any((rc, rc_status, rc_diff, rc_untracked)):
|
|
130
|
+
raise ContinuityError("TASK_CONTINUITY_WITHHELD", f"submodule worktree is unavailable: {relative}")
|
|
131
|
+
digest = hashlib.sha256(diff.encode("utf-8", errors="surrogateescape"))
|
|
132
|
+
for raw_path in sorted(os.fsencode(path) for path in untracked.split("\0") if path):
|
|
133
|
+
path = candidate / Path(os.fsdecode(raw_path))
|
|
134
|
+
try:
|
|
135
|
+
path.resolve(strict=True).relative_to(candidate.resolve())
|
|
136
|
+
if path.is_symlink():
|
|
137
|
+
content = os.fsencode(os.readlink(path))
|
|
138
|
+
elif path.is_file():
|
|
139
|
+
content = path.read_bytes()
|
|
140
|
+
else:
|
|
141
|
+
raise OSError("not a regular file or symbolic link")
|
|
142
|
+
except (OSError, ValueError) as error:
|
|
143
|
+
raise ContinuityError("TASK_CONTINUITY_WITHHELD", f"submodule untracked path is unavailable or unsafe: {relative / path.name}") from error
|
|
144
|
+
digest.update(raw_path)
|
|
145
|
+
digest.update(b"\0")
|
|
146
|
+
digest.update(content)
|
|
147
|
+
digest.update(b"\0")
|
|
148
|
+
facts.append({
|
|
149
|
+
"path": relative.as_posix(),
|
|
150
|
+
"revision": revision,
|
|
151
|
+
"head": head.strip(),
|
|
152
|
+
"state": state,
|
|
153
|
+
"status_digest": hashlib.sha256(status.encode("utf-8")).hexdigest(),
|
|
154
|
+
"content_digest": digest.hexdigest(),
|
|
155
|
+
})
|
|
156
|
+
return facts
|
|
157
|
+
|
|
158
|
+
|
|
100
159
|
def _projection(root: Path, directory: Path, data: dict, task_id: str) -> dict:
|
|
101
160
|
meta = data.get("meta")
|
|
102
161
|
if not isinstance(meta, dict):
|
|
@@ -178,11 +237,21 @@ def _projection(root: Path, directory: Path, data: dict, task_id: str) -> dict:
|
|
|
178
237
|
worktree.update(b"\0")
|
|
179
238
|
worktree.update(content)
|
|
180
239
|
worktree.update(b"\0")
|
|
240
|
+
submodules = _submodule_facts(root)
|
|
241
|
+
worktree.update(json.dumps(submodules, ensure_ascii=False, sort_keys=True, separators=(",", ":")).encode("utf-8"))
|
|
181
242
|
evidence_digest = hashlib.sha256(
|
|
182
243
|
json.dumps(sorted(evidence), ensure_ascii=False, separators=(",", ":")).encode("utf-8")
|
|
183
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")}
|
|
184
252
|
return {
|
|
185
253
|
"task": {"id": task_id, "path": directory.relative_to(root).as_posix(), "status": data.get("status")},
|
|
254
|
+
"delegations": delegations,
|
|
186
255
|
"phase": {"current_phase_id": current_phase, "task_route_revision": route_revision, "input_revision": input_revision, "phases": phases},
|
|
187
256
|
"evidence_digest": evidence_digest,
|
|
188
257
|
"git": {
|
|
@@ -191,6 +260,7 @@ def _projection(root: Path, directory: Path, data: dict, task_id: str) -> dict:
|
|
|
191
260
|
"clean": not status,
|
|
192
261
|
"status_digest": hashlib.sha256(status.encode("utf-8")).hexdigest(),
|
|
193
262
|
"content_digest": worktree.hexdigest(),
|
|
263
|
+
"submodules": submodules,
|
|
194
264
|
},
|
|
195
265
|
}
|
|
196
266
|
|
|
@@ -608,6 +678,9 @@ def assert_task_identity_change_allowed(repo_root: Path, task_dir: Path, data: d
|
|
|
608
678
|
@contextlib.contextmanager
|
|
609
679
|
def task_mutation_guard(repo_root: Path, task_dir: Path, data: dict):
|
|
610
680
|
"""Hold the ownership lock across a single task mutation."""
|
|
681
|
+
if os.environ.get("TRELLIS_DELEGATION_CONTEXT"):
|
|
682
|
+
yield False
|
|
683
|
+
return
|
|
611
684
|
from .task_move import layout_lock, require_settled_layout
|
|
612
685
|
|
|
613
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)
|
|
@@ -55,6 +55,15 @@ from .task_utils import (
|
|
|
55
55
|
)
|
|
56
56
|
from .workflow_selection import DIR_WORKFLOWS, WORKFLOW_ID_RE
|
|
57
57
|
|
|
58
|
+
RESERVED_META_KEYS = {
|
|
59
|
+
"task_workflow",
|
|
60
|
+
"delegation_authorizations",
|
|
61
|
+
"delegated_worktree_execution_history",
|
|
62
|
+
"delegated_worktree_execution_record",
|
|
63
|
+
"task_cancellation",
|
|
64
|
+
"task_lifecycle_recoveries",
|
|
65
|
+
}
|
|
66
|
+
|
|
58
67
|
|
|
59
68
|
# =============================================================================
|
|
60
69
|
# Helper Functions
|
|
@@ -248,6 +257,9 @@ def _parse_meta_pairs(pairs: list[str] | None) -> dict[str, str] | None:
|
|
|
248
257
|
file=sys.stderr,
|
|
249
258
|
)
|
|
250
259
|
return None
|
|
260
|
+
if key in RESERVED_META_KEYS:
|
|
261
|
+
print(colored(f"Error: metadata key is managed by Trellis: {key}", Colors.RED), file=sys.stderr)
|
|
262
|
+
return None
|
|
251
263
|
meta[key] = value
|
|
252
264
|
return meta
|
|
253
265
|
|
|
@@ -1007,6 +1019,11 @@ def cmd_rename(args: argparse.Namespace) -> int:
|
|
|
1007
1019
|
print(colored(f"Error: Task not found: {args.name}", Colors.RED), file=sys.stderr)
|
|
1008
1020
|
return 1
|
|
1009
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
|
+
|
|
1010
1027
|
# Restrict renames to the prescribed status directory levels.
|
|
1011
1028
|
if not is_within_tasks_dir(task_dir, repo_root):
|
|
1012
1029
|
print(
|
|
@@ -1247,7 +1264,8 @@ def cmd_remove_subtask(args: argparse.Namespace) -> int:
|
|
|
1247
1264
|
|
|
1248
1265
|
if parent_data.get("status") != "cancelled":
|
|
1249
1266
|
from .task_workflow import _assert_delegated_record_closed
|
|
1250
|
-
|
|
1267
|
+
from .worktree_delegation import resolve_record
|
|
1268
|
+
_assert_delegated_record_closed(child_dir.name, resolve_record(repo_root, child_dir, child_data))
|
|
1251
1269
|
original_parent = json.loads(json.dumps(parent_data))
|
|
1252
1270
|
# Remove child from parent's children list
|
|
1253
1271
|
parent_children = _ensure_children_list(parent_data)
|
|
@@ -1427,6 +1445,10 @@ def cmd_set_meta(args: argparse.Namespace) -> int:
|
|
|
1427
1445
|
key = args.key
|
|
1428
1446
|
value = args.value
|
|
1429
1447
|
|
|
1448
|
+
if key in RESERVED_META_KEYS:
|
|
1449
|
+
print(colored(f"Error: metadata key is managed by Trellis: {key}", Colors.RED), file=sys.stderr)
|
|
1450
|
+
return 1
|
|
1451
|
+
|
|
1430
1452
|
if not key:
|
|
1431
1453
|
print(colored("Error: Missing arguments", Colors.RED))
|
|
1432
1454
|
print("Usage: python3 task.py set-meta <task-dir> <key> <value>")
|
|
@@ -110,6 +110,28 @@ def _state(meta: dict) -> dict:
|
|
|
110
110
|
raise TaskWorkflowError("TASK_PHASE_TASK_INVALID", "route dependency admission has an invalid shape")
|
|
111
111
|
if state.get("current_phase_id") is not None and state["current_phase_id"] not in state["phase_ids"]:
|
|
112
112
|
raise TaskWorkflowError("TASK_PHASE_TASK_INVALID", "current phase is not in the task route")
|
|
113
|
+
skip_records = state.get("skip_records")
|
|
114
|
+
if not isinstance(skip_records, dict):
|
|
115
|
+
raise TaskWorkflowError("TASK_PHASE_TASK_INVALID", "task phase skip records have an invalid shape")
|
|
116
|
+
for phase_id, skip in skip_records.items():
|
|
117
|
+
if (
|
|
118
|
+
phase_id not in PHASE_ID_SET
|
|
119
|
+
or not isinstance(skip, dict)
|
|
120
|
+
or not isinstance(skip.get("reason"), str)
|
|
121
|
+
or not skip["reason"].strip()
|
|
122
|
+
or not isinstance(skip.get("evidence_refs"), list)
|
|
123
|
+
or not skip["evidence_refs"]
|
|
124
|
+
or any(not isinstance(value, str) or not value.strip() for value in skip["evidence_refs"])
|
|
125
|
+
or skip.get("task_route_revision") != state["task_route_revision"]
|
|
126
|
+
or not ROUTE_REVISION.fullmatch(str(skip.get("input_revision", "")))
|
|
127
|
+
or not isinstance(skip.get("artifact_revision"), str)
|
|
128
|
+
or not re.fullmatch(r"[a-f0-9]{64}", skip["artifact_revision"])
|
|
129
|
+
or (
|
|
130
|
+
phase_id in state["phases"]
|
|
131
|
+
and skip["artifact_revision"] != state["phases"][phase_id].get("artifact_revision")
|
|
132
|
+
)
|
|
133
|
+
):
|
|
134
|
+
raise TaskWorkflowError("TASK_PHASE_TASK_INVALID", f"task phase skip record is invalid: {phase_id}")
|
|
113
135
|
for phase_id in state["phase_ids"]:
|
|
114
136
|
record = state["phases"].get(phase_id)
|
|
115
137
|
if not isinstance(record, dict) or record.get("status") not in {"not_started", "active", "waiting_user", "blocked", "accepted", "skipped"}:
|
|
@@ -254,6 +276,7 @@ def _is_withdrawal_route(state: dict) -> bool:
|
|
|
254
276
|
and isinstance(withdrawal.get("from"), str)
|
|
255
277
|
and withdrawal["from"] in PHASE_ID_SET
|
|
256
278
|
and withdrawal.get("to") == PHASE_IDS[4]
|
|
279
|
+
and withdrawal.get("return_kind") == "withdrawal"
|
|
257
280
|
and withdrawal.get("task_route_revision") == state.get("task_route_revision")
|
|
258
281
|
and isinstance(withdrawal.get("evidence_refs"), list)
|
|
259
282
|
and bool(withdrawal["evidence_refs"])
|
|
@@ -389,6 +412,8 @@ def _validate_classification(task_kind: str | None, complexity: str | None, proj
|
|
|
389
412
|
raise TaskWorkflowError("TASK_PHASE_INVALID_INPUT", "--project-context must be new or existing")
|
|
390
413
|
if task_kind == "analysis" and PHASE_IDS[3] in phases:
|
|
391
414
|
raise TaskWorkflowError("TASK_PHASE_INVALID_ROUTE", "analysis tasks cannot include the Task Implementation and Test Verification Phase")
|
|
415
|
+
if task_kind in {"implementation", "combined"} and PHASE_IDS[3] not in phases:
|
|
416
|
+
raise TaskWorkflowError("TASK_PHASE_INVALID_ROUTE", "implementation and combined tasks must include the Task Implementation and Test Verification Phase")
|
|
392
417
|
|
|
393
418
|
|
|
394
419
|
def _increment(value: str, allow_zero: bool = False) -> str:
|
|
@@ -441,7 +466,13 @@ def _init(args: argparse.Namespace, task_dir: Path, data: dict, meta: dict) -> i
|
|
|
441
466
|
"implementation_authorization": None,
|
|
442
467
|
"closeout_disposition": None,
|
|
443
468
|
"skip_records": {
|
|
444
|
-
phase: {
|
|
469
|
+
phase: {
|
|
470
|
+
"reason": route_reason,
|
|
471
|
+
"evidence_refs": route_evidence,
|
|
472
|
+
"task_route_revision": "1",
|
|
473
|
+
"input_revision": input_revision,
|
|
474
|
+
"artifact_revision": _phase_record(input_revision)["artifact_revision"],
|
|
475
|
+
}
|
|
445
476
|
for phase in omitted
|
|
446
477
|
},
|
|
447
478
|
"return_record": None,
|
|
@@ -549,7 +580,13 @@ def _update(args: argparse.Namespace, task_dir: Path, data: dict, state: dict) -
|
|
|
549
580
|
if current == PHASE_IDS[0]:
|
|
550
581
|
raise TaskWorkflowError("TASK_PHASE_INVALID_TRANSITION", "The Goal Exploration and Requirements Confirmation Phase must reach minimum alignment and acceptance and cannot be skipped")
|
|
551
582
|
record.update({"status": "skipped", "reason": reason, "evidence_refs": evidence})
|
|
552
|
-
state["skip_records"][current] = {
|
|
583
|
+
state["skip_records"][current] = {
|
|
584
|
+
"reason": reason,
|
|
585
|
+
"evidence_refs": evidence,
|
|
586
|
+
"task_route_revision": state["task_route_revision"],
|
|
587
|
+
"input_revision": state["input_revision"],
|
|
588
|
+
"artifact_revision": record["artifact_revision"],
|
|
589
|
+
}
|
|
553
590
|
_advance(state, current)
|
|
554
591
|
elif action == "accept":
|
|
555
592
|
_require_current_accepted_artifacts(task_dir, state)
|
|
@@ -660,6 +697,7 @@ def _update(args: argparse.Namespace, task_dir: Path, data: dict, state: dict) -
|
|
|
660
697
|
target == PHASE_IDS[4]
|
|
661
698
|
and phases == [PHASE_IDS[0], PHASE_IDS[4]]
|
|
662
699
|
and bool(evidence)
|
|
700
|
+
and args.return_kind == "withdrawal"
|
|
663
701
|
)
|
|
664
702
|
if not changed and not classification_changed and target == current and not reviewed_delivery:
|
|
665
703
|
raise TaskWorkflowError("TASK_PHASE_INVALID_ROUTE", "the updated route and target are unchanged")
|
|
@@ -702,12 +740,24 @@ def _update(args: argparse.Namespace, task_dir: Path, data: dict, state: dict) -
|
|
|
702
740
|
if phase_id not in old_phases:
|
|
703
741
|
phase_record["input_revision"] = state["input_revision"]
|
|
704
742
|
state["skip_records"] = {
|
|
705
|
-
phase_id: {
|
|
743
|
+
phase_id: {
|
|
744
|
+
**skip,
|
|
745
|
+
"task_route_revision": state["task_route_revision"],
|
|
746
|
+
"input_revision": state["input_revision"],
|
|
747
|
+
"artifact_revision": state["phases"][phase_id]["artifact_revision"],
|
|
748
|
+
}
|
|
706
749
|
for phase_id, skip in state["skip_records"].items()
|
|
707
750
|
if phase_id in phases and state["phases"][phase_id].get("status") == "skipped"
|
|
708
751
|
}
|
|
709
752
|
for phase_id in omitted:
|
|
710
|
-
state["
|
|
753
|
+
phase_record = state["phases"].get(phase_id, old_phases.get(phase_id, _phase_record(state["input_revision"])))
|
|
754
|
+
state["skip_records"][phase_id] = {
|
|
755
|
+
"reason": reason,
|
|
756
|
+
"evidence_refs": evidence,
|
|
757
|
+
"task_route_revision": state["task_route_revision"],
|
|
758
|
+
"input_revision": state["input_revision"],
|
|
759
|
+
"artifact_revision": phase_record["artifact_revision"],
|
|
760
|
+
}
|
|
711
761
|
if withdrawal_route and state["phases"][PHASE_IDS[0]].get("status") != "accepted":
|
|
712
762
|
state["phases"][PHASE_IDS[0]].update({
|
|
713
763
|
"status": "skipped",
|
|
@@ -721,6 +771,8 @@ def _update(args: argparse.Namespace, task_dir: Path, data: dict, state: dict) -
|
|
|
721
771
|
"reason": reason,
|
|
722
772
|
"evidence_refs": evidence,
|
|
723
773
|
"task_route_revision": state["task_route_revision"],
|
|
774
|
+
"input_revision": state["input_revision"],
|
|
775
|
+
"artifact_revision": state["phases"][PHASE_IDS[0]]["artifact_revision"],
|
|
724
776
|
}
|
|
725
777
|
state["implementation_authorization"] = None
|
|
726
778
|
state["closeout_disposition"] = None
|
|
@@ -728,6 +780,7 @@ def _update(args: argparse.Namespace, task_dir: Path, data: dict, state: dict) -
|
|
|
728
780
|
state["return_record"] = {
|
|
729
781
|
"from": current,
|
|
730
782
|
"to": target,
|
|
783
|
+
**({"return_kind": "withdrawal"} if withdrawal_route else {}),
|
|
731
784
|
"reason": reason,
|
|
732
785
|
"evidence_refs": evidence,
|
|
733
786
|
"task_route_revision": state["task_route_revision"],
|
|
@@ -1324,8 +1377,10 @@ def _assert_delegated_resources_closed(task_dir: Path, data: dict) -> None:
|
|
|
1324
1377
|
if not isinstance(children, list):
|
|
1325
1378
|
raise TaskWorkflowError("TASK_PHASE_RESOURCE_ACTIVE", "linked child task list is malformed")
|
|
1326
1379
|
for task_id in [task_dir.name, *children]:
|
|
1327
|
-
|
|
1328
|
-
|
|
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))
|
|
1329
1384
|
|
|
1330
1385
|
|
|
1331
1386
|
def _assert_delegated_record_closed(task_id: str, record) -> None:
|
|
@@ -1333,6 +1388,8 @@ def _assert_delegated_record_closed(task_id: str, record) -> None:
|
|
|
1333
1388
|
return
|
|
1334
1389
|
if isinstance(record, dict) and record.get("status") == "retired" and isinstance(record.get("closure_evidence"), dict):
|
|
1335
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")
|
|
1336
1393
|
agent_id = record.get("agent_id") if isinstance(record, dict) else None
|
|
1337
1394
|
if not isinstance(agent_id, str) or not agent_id.strip():
|
|
1338
1395
|
raise TaskWorkflowError("TASK_PHASE_RESOURCE_ACTIVE", f"delegated execution status is unknown for {task_id}; preserve the current state")
|