okstra 0.137.0 → 0.138.0

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.
@@ -194,31 +194,38 @@ def preview_worktree_decision(
194
194
  )
195
195
 
196
196
 
197
- def preview_stage_worktree_decision(
197
+ @dataclass
198
+ class StageWorktreeDecision:
199
+ """Side-effect-free decision for one concrete implementation stage."""
200
+
201
+ status: str
202
+ path: str
203
+ branch: str = ""
204
+ base_ref: str = ""
205
+
206
+
207
+ def resolve_stage_worktree_decision(
198
208
  *,
199
209
  project_id: str,
200
210
  task_group_segment: str,
201
211
  task_id_segment: str,
202
212
  work_category: str,
203
213
  stage_number: int,
204
- ) -> "WorktreeDecision":
205
- """Side-effect-free: what provision_stage_worktree WOULD do (reuse vs new).
206
-
207
- Mirrors provision_stage_worktree's registry-reuse branch exactly. A "new"
208
- decision carries no base_ref — the stage base commit is resolved later by
209
- the prepare flow from the stage's dependency anchors.
210
- """
214
+ ) -> StageWorktreeDecision:
215
+ """Resolve whether one concrete stage worktree is new or reusable."""
211
216
  safe_project = _safe_segment(project_id)
212
217
  safe_group = _safe_segment(task_group_segment)
213
218
  safe_task = _safe_segment(task_id_segment)
214
219
  existing = worktree_registry.lookup(
215
220
  safe_project, safe_group, safe_task, stage_number=stage_number)
216
221
  if existing is not None and existing.status == "active":
217
- return WorktreeDecision(
218
- status="reused", path=existing.worktree_path,
219
- branch=existing.branch, base_ref=existing.base_ref,
222
+ return StageWorktreeDecision(
223
+ status="reused",
224
+ path=existing.worktree_path,
225
+ branch=existing.branch,
226
+ base_ref=existing.base_ref,
220
227
  )
221
- return WorktreeDecision(
228
+ return StageWorktreeDecision(
222
229
  status="new",
223
230
  path=str(compute_worktree_path(
224
231
  project_id=safe_project, task_group_segment=safe_group,
@@ -923,31 +930,32 @@ def provision_stage_worktree(
923
930
  if not base_commit:
924
931
  raise RuntimeError("provision_stage_worktree requires a base_commit")
925
932
 
926
- safe_project = _safe_segment(project_id)
927
- safe_group = _safe_segment(task_group_segment)
928
- safe_task = _safe_segment(task_id_segment)
929
- worktree_path = compute_worktree_path(
930
- project_id=safe_project, task_group_segment=safe_group,
931
- task_id_segment=safe_task, stage_number=stage_number,
932
- )
933
- branch = compute_branch_name(
934
- work_category=work_category, task_id_segment=safe_task,
933
+ decision = resolve_stage_worktree_decision(
934
+ project_id=project_id,
935
+ task_group_segment=task_group_segment,
936
+ task_id_segment=task_id_segment,
937
+ work_category=work_category,
935
938
  stage_number=stage_number,
936
939
  )
937
-
938
- existing = worktree_registry.lookup(
939
- safe_project, safe_group, safe_task, stage_number=stage_number)
940
- if existing is not None and existing.status == "active":
940
+ if decision.status == "reused":
941
941
  return WorktreeProvision(
942
- status="reused", path=existing.worktree_path,
943
- branch=existing.branch, base_ref=existing.base_ref,
942
+ status="reused",
943
+ path=decision.path,
944
+ branch=decision.branch,
945
+ base_ref=decision.base_ref,
944
946
  note=(
945
947
  f"stage {stage_number} worktree reused at "
946
- f"{existing.worktree_path} on branch {existing.branch} "
947
- f"(base {existing.base_ref[:12]})"
948
+ f"{decision.path} on branch {decision.branch} "
949
+ f"(base {decision.base_ref[:12]})"
948
950
  ),
949
951
  )
950
952
 
953
+ safe_project = _safe_segment(project_id)
954
+ safe_group = _safe_segment(task_group_segment)
955
+ safe_task = _safe_segment(task_id_segment)
956
+ worktree_path = Path(decision.path)
957
+ branch = decision.branch
958
+
951
959
  if worktree_path.exists():
952
960
  raise RuntimeError(
953
961
  f"stage worktree path already exists but is not in the registry: "
@@ -137,6 +137,7 @@ prompt_path.write_text(
137
137
  f"**Errors sidecar path:** {project_root}/run/worker-results/"
138
138
  f"{target_worker_id}-errors.json",
139
139
  f"Assigned worker prompt history path: {prompt_relative}",
140
+ "**Prompt Delivery Mode:** eager-include",
140
141
  f"- Primary analysis packet: `{analysis_packet_path}`",
141
142
  "",
142
143
  "# Initial Analysis Prompt",
@@ -230,6 +231,7 @@ for worker in team_state.get("workers", []):
230
231
  f"**Errors sidecar path:** {project_root}/run/worker-results/"
231
232
  f"{worker_id}-errors.json",
232
233
  f"Assigned worker prompt history path: {prompt_relative}",
234
+ "**Prompt Delivery Mode:** eager-include",
233
235
  ]
234
236
  if worker_id != "report-writer":
235
237
  prompt_lines.append(