ww-agentic-workflows 1.0.0.dev7__py3-none-any.whl → 1.0.0.dev9__py3-none-any.whl

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.
Files changed (48) hide show
  1. ww/_bundled_extensions/ww/git/extension.py +49 -21
  2. ww/action_execution.py +42 -1
  3. ww/actions/contracts.py +16 -0
  4. ww/actions/extension.py +11 -0
  5. ww/artifacts.py +16 -3
  6. ww/assets/docs/features.md +155 -27
  7. ww/assets/docs/specification.md +8 -6
  8. ww/assets/ww-debug-report_skill.md +9 -3
  9. ww/assets/ww-rule_skill.md +13 -8
  10. ww/assets/ww_skill.md +4 -1
  11. ww/bootstrap.py +33 -7
  12. ww/child_coordination.py +22 -0
  13. ww/cli/audit.py +8 -0
  14. ww/cli/main.py +19 -7
  15. ww/cli/parser.py +32 -6
  16. ww/completion_artifacts.py +13 -12
  17. ww/completion_inputs.py +7 -2
  18. ww/config_writes.py +123 -31
  19. ww/execution_models/plan_codec.py +1 -0
  20. ww/execution_models/records.py +10 -1
  21. ww/extensions/api.py +9 -0
  22. ww/instructions/builder.py +86 -8
  23. ww/instructions/commands.py +5 -0
  24. ww/instructions/handoff.py +22 -1
  25. ww/instructions/models.py +19 -1
  26. ww/output_adapters/markdown.py +122 -9
  27. ww/output_adapters/rule_pages.py +24 -1
  28. ww/plan/__init__.py +2 -0
  29. ww/plan/actions.py +6 -1
  30. ww/plan/compiler.py +3 -12
  31. ww/plan/models.py +20 -0
  32. ww/results.py +2 -0
  33. ww/rule_verification.py +10 -3
  34. ww/rule_views.py +100 -4
  35. ww/rule_writes.py +132 -57
  36. ww/run_reports.py +206 -4
  37. ww/service.py +189 -7
  38. ww/storage.py +4 -0
  39. ww/task_ids.py +11 -0
  40. ww/transitions.py +27 -9
  41. ww/variables.py +11 -0
  42. ww/workflow_config.py +31 -2
  43. ww/workflow_validation.py +5 -22
  44. {ww_agentic_workflows-1.0.0.dev7.dist-info → ww_agentic_workflows-1.0.0.dev9.dist-info}/METADATA +1 -1
  45. {ww_agentic_workflows-1.0.0.dev7.dist-info → ww_agentic_workflows-1.0.0.dev9.dist-info}/RECORD +48 -48
  46. {ww_agentic_workflows-1.0.0.dev7.dist-info → ww_agentic_workflows-1.0.0.dev9.dist-info}/WHEEL +0 -0
  47. {ww_agentic_workflows-1.0.0.dev7.dist-info → ww_agentic_workflows-1.0.0.dev9.dist-info}/entry_points.txt +0 -0
  48. {ww_agentic_workflows-1.0.0.dev7.dist-info → ww_agentic_workflows-1.0.0.dev9.dist-info}/licenses/LICENSE +0 -0
@@ -400,18 +400,31 @@ def _status_paths(output: str) -> tuple[str, ...]:
400
400
  return tuple(paths)
401
401
 
402
402
 
403
- def _validate_commit_workspace(context: ExtensionContext) -> str | None:
403
+ def _workspace_status(
404
+ context: ExtensionContext,
405
+ ) -> tuple[tuple[str, ...], str | None]:
406
+ """The paths Git reports changed in the task workspace, or why it cannot."""
404
407
  root, error = _workspace_root(context)
405
408
  if error:
406
- return error
409
+ return (), error
407
410
  assert root is not None
408
411
  status = _git(context, "status", "--porcelain=v1", "-z", "--untracked-files=all")
409
412
  if status.returncode:
410
- return _failed(status, "git status failed")
413
+ return (), _failed(status, "git status failed")
411
414
  paths = _status_paths(status.stdout)
412
415
  if status.stdout and not paths:
413
- return "Git reported malformed status output"
414
- return _paths_inside(root, paths)
416
+ return (), "Git reported malformed status output"
417
+ return paths, _paths_inside(root, paths)
418
+
419
+
420
+ def _validate_commit_workspace(context: ExtensionContext) -> str | None:
421
+ return _workspace_status(context)[1]
422
+
423
+
424
+ def _needs_commit_message(context: ExtensionContext) -> bool:
425
+ """Whether the workspace has anything to commit; Git trouble asks as usual."""
426
+ paths, error = _workspace_status(context)
427
+ return bool(paths) or error is not None
415
428
 
416
429
 
417
430
  def _validate_staged_paths(context: ExtensionContext) -> str | None:
@@ -435,6 +448,23 @@ def _tokens(context: ExtensionContext) -> dict[str, str]:
435
448
  }
436
449
 
437
450
 
451
+ def _render_for_task(context: ExtensionContext, template: str) -> str:
452
+ """Render ``template`` for the task as one name without the ID's slash.
453
+
454
+ A child task (``parent/child``) renders the template with the parent ID
455
+ and appends ``-<child>``, so its name sits beside the parent's rather than
456
+ under it; a template that renders empty stays empty for the caller to
457
+ refuse.
458
+ """
459
+ tokens = _tokens(context)
460
+ task_id = context.task_id or ""
461
+ if "/" not in task_id:
462
+ return interpolate(template, tokens).strip()
463
+ parent_id, _, child_id = task_id.rpartition("/")
464
+ parent = interpolate(template, {**tokens, TASK_ID: parent_id}).strip()
465
+ return f"{parent}-{child_id}" if parent else ""
466
+
467
+
438
468
  def _now() -> str:
439
469
  return (
440
470
  datetime.now(timezone.utc)
@@ -489,14 +519,7 @@ def _worktree_name(context: ExtensionContext, settings: Settings) -> str:
489
519
  replaced by ``-``. Names a refusal must see (empty, ``.``, absolute) are
490
520
  returned unchanged for the caller to reject.
491
521
  """
492
- tokens = _tokens(context)
493
- name = interpolate(settings.worktree_name_format, tokens).strip()
494
- if _parent_branch(context) and context.task_id:
495
- parent_id, _, child_id = context.task_id.rpartition("/")
496
- parent = interpolate(
497
- settings.worktree_name_format, {**tokens, TASK_ID: parent_id}
498
- ).strip()
499
- name = f"{parent}-{child_id}"
522
+ name = _render_for_task(context, settings.worktree_name_format)
500
523
  if name and not Path(name).is_absolute() and "/" in name:
501
524
  name = name.replace("/", "-")
502
525
  return name
@@ -601,9 +624,11 @@ def _branch_name(
601
624
  """Render the task's branch from ``branch_format``: (branch, parent, error).
602
625
 
603
626
  A child task's branch is its parent's recorded branch plus the child ID,
604
- whatever the format says.
627
+ whatever the format says; without a recorded parent branch it is the
628
+ format rendered for the parent plus the child ID, so a child's slash
629
+ never nests its branch under the parent's name.
605
630
  """
606
- branch = interpolate(branch_format, _tokens(context)).strip()
631
+ branch = _render_for_task(context, branch_format)
607
632
  if not branch:
608
633
  return None, None, "branch name format rendered empty"
609
634
  parent_branch = _parent_branch(context)
@@ -787,12 +812,6 @@ def _commit_message_error(values: Mapping[str, str]) -> str | None:
787
812
 
788
813
  def _commit(context: ExtensionContext) -> ExtensionResult:
789
814
  settings = _task_settings(context)
790
- error = _commit_message_error(context.values)
791
- if error is not None:
792
- return ExtensionResult(False, error=error)
793
- subject = _subject(context, settings, context.values["commit_message"])
794
- if not subject:
795
- return ExtensionResult(False, error="commit_format rendered an empty message")
796
815
  # A retry may arrive after git committed but before ww recorded the
797
816
  # result. The operation trailer gives the checker a durable identity.
798
817
  if context.operation_id:
@@ -828,6 +847,14 @@ def _commit(context: ExtensionContext) -> ExtensionResult:
828
847
  False,
829
848
  error=_failed(has_staged_changes, "could not inspect staged changes"),
830
849
  )
850
+ # Only a commit needs its message: the precondition lets ww run this
851
+ # without asking for one when the workspace is clean.
852
+ error = _commit_message_error(context.values)
853
+ if error is not None:
854
+ return ExtensionResult(False, error=error)
855
+ subject = _subject(context, settings, context.values["commit_message"])
856
+ if not subject:
857
+ return ExtensionResult(False, error="commit_format rendered an empty message")
831
858
  commit_args = ["commit", "-m", subject]
832
859
  if context.operation_id:
833
860
  commit_args.extend(["-m", _operation_marker(context)])
@@ -1680,6 +1707,7 @@ EXTENSION = Extension(
1680
1707
  ),
1681
1708
  check=_check_commit,
1682
1709
  validate=_commit_message_error,
1710
+ needs_input=_needs_commit_message,
1683
1711
  ),
1684
1712
  ExtensionHandler(
1685
1713
  "merge-branch",
ww/action_execution.py CHANGED
@@ -28,6 +28,7 @@ from ww.actions import (
28
28
  RecoveryExtensionService,
29
29
  actions,
30
30
  )
31
+ from ww.assignments import completion_window_items
31
32
  from ww.errors import StateError
32
33
  from ww.execution_models import (
33
34
  CommandExecution,
@@ -49,6 +50,7 @@ from ww.metadata_publication import MetadataPublisher, validate_metadata_values
49
50
  from ww.plan import PlanItem, WorkflowPlan
50
51
  from ww.step_values import StepValues, no_step_values
51
52
  from ww.storage_adapters import CommandOutputAddress
53
+ from ww.transitions import release_provided_values
52
54
  from ww.variables import (
53
55
  PROJECT,
54
56
  item_context_error,
@@ -337,6 +339,13 @@ class _InputValidationContext:
337
339
  extensions: _HandlerLookup
338
340
 
339
341
 
342
+ @dataclass(frozen=True)
343
+ class _PreconditionContext:
344
+ """Handler access and the handler's own context; nothing is recorded."""
345
+
346
+ extensions: _ExtensionService
347
+
348
+
340
349
  class _PreflightExtensions:
341
350
  def __init__(self, executor: ActionExecutor) -> None:
342
351
  self._executor = executor
@@ -608,7 +617,22 @@ class ActionExecutor:
608
617
  result=bounded(result.output, STATE_OUTPUT_PREVIEW_LIMIT).strip() or None,
609
618
  output_values=tuple(result.values.items()),
610
619
  )
611
- values = {**dict(dispatch.state.workflow_values), **result.values}
620
+ values = dict(dispatch.state.workflow_values)
621
+ # The values the handler consumed are asked for afresh by their next
622
+ # consumer, unless a later item of the same completion window still
623
+ # needs them; the handler's own outputs are kept as usual.
624
+ release_provided_values(
625
+ values,
626
+ item,
627
+ keep={
628
+ value.name
629
+ for later in completion_window_items(
630
+ snapshot.plan, dispatch.state.cursor
631
+ )[1:]
632
+ for value in later.provide
633
+ },
634
+ )
635
+ values.update(result.values)
612
636
  completed = replace(
613
637
  dispatch.state,
614
638
  status="pending",
@@ -705,6 +729,23 @@ class ActionExecutor:
705
729
  _InputValidationContext(_HandlerLookup(self)),
706
730
  )
707
731
 
732
+ def needs_input(
733
+ self, state: ExecutionState, snapshot: PlanSnapshot, item: PlanItem
734
+ ) -> bool:
735
+ """Whether the current automatic item must get its inputs before it runs.
736
+
737
+ Asked while they are missing and before anything is recorded; an
738
+ action without a precondition always needs them.
739
+ """
740
+ implementation = actions.get(item.kind)
741
+ if not isinstance(implementation, AutomaticAction):
742
+ return True
743
+ dispatch = _Dispatch(self, state, snapshot, item)
744
+ return implementation.needs_input(
745
+ item.payload_as(implementation.planned_type),
746
+ _PreconditionContext(_ExtensionService(dispatch)),
747
+ )
748
+
708
749
  def check_recovery(
709
750
  self, state: ExecutionState, plan: WorkflowPlan, item: PlanItem
710
751
  ) -> RecoveryCheckResult | None:
ww/actions/contracts.py CHANGED
@@ -529,6 +529,13 @@ class InputValidationContext(Protocol):
529
529
  def extensions(self) -> ExtensionHandlerService: ...
530
530
 
531
531
 
532
+ class PreconditionContext(Protocol):
533
+ """What an action may consult to tell whether it needs its inputs."""
534
+
535
+ @property
536
+ def extensions(self) -> ExtensionService: ...
537
+
538
+
532
539
  class ExecutionContext(Protocol):
533
540
  """Read-only invocation information plus deliberately narrow effects."""
534
541
 
@@ -634,6 +641,15 @@ class AutomaticAction(Action[DefinitionT, PlannedT]):
634
641
  del planned, values, context
635
642
  return None
636
643
 
644
+ def needs_input(self, planned: PlannedT, context: PreconditionContext) -> bool:
645
+ """Whether the action needs its declared inputs this run.
646
+
647
+ Core asks while they are missing and nothing is recorded; ``False``
648
+ runs the action without requesting them.
649
+ """
650
+ del planned, context
651
+ return True
652
+
637
653
  def check_recovery(
638
654
  self, planned: PlannedT, context: RecoveryContext
639
655
  ) -> RecoveryCheckResult | None:
ww/actions/extension.py CHANGED
@@ -31,6 +31,7 @@ from .contracts import (
31
31
  InputValidationContext,
32
32
  InstructionContent,
33
33
  InstructionContext,
34
+ PreconditionContext,
34
35
  PreflightContext,
35
36
  RecoveryCheckResult,
36
37
  RecoveryContext,
@@ -70,6 +71,16 @@ class ExtensionAction(AutomaticAction[Extension, Extension]):
70
71
  return "extension validator returned an invalid result"
71
72
  return verdict.strip()
72
73
 
74
+ def needs_input(self, planned: Extension, context: PreconditionContext) -> bool:
75
+ """Ask the handler's precondition; one that fails needs the inputs."""
76
+ handler = context.extensions.handler(planned.reference)
77
+ if handler.needs_input is None:
78
+ return True
79
+ try:
80
+ return handler.needs_input(context.extensions.context(planned)) is not False
81
+ except Exception: # noqa: BLE001 - a failing precondition asks as usual
82
+ return True
83
+
73
84
  def execute(self, planned: Extension, context: ExecutionContext) -> ActionResult:
74
85
  handler = context.extensions.handler(planned.reference)
75
86
  try:
ww/artifacts.py CHANGED
@@ -44,13 +44,20 @@ def render_step_artifact(
44
44
  task_id: str,
45
45
  workflow: str,
46
46
  step: str,
47
- step_number: int,
47
+ step_number: str,
48
48
  step_total: int,
49
49
  skill: str,
50
50
  result: str,
51
51
  rules: RulesSummary | None = None,
52
+ previous_attempt: str | None = None,
52
53
  ) -> str:
53
- """Wrap an agent result in the built-in, stable Markdown artifact format."""
54
+ """Wrap an agent result in the built-in, stable Markdown artifact format.
55
+
56
+ ``step_number`` is the step's dotted declaration ordinals, ``2.1`` for the
57
+ first step nested in the second, as ``step_label`` renders them.
58
+ ``previous_attempt`` is the artifact of the completion ww rejected before
59
+ this one; it follows the result so the file keeps the step's history.
60
+ """
54
61
  body = _normalize_result(result).rstrip()
55
62
  return (
56
63
  f"# {task_id} — {step}\n\n"
@@ -59,7 +66,13 @@ def render_step_artifact(
59
66
  f"- Step: {step_number} of {step_total}\n"
60
67
  f"- Skill: {skill}\n\n"
61
68
  "## Result\n\n"
62
- f"{body}\n" + (_rules_section(rules) if rules is not None else "")
69
+ f"{body}\n"
70
+ + (_rules_section(rules) if rules is not None else "")
71
+ + (
72
+ f"\n## Previous attempt\n\n{_normalize_result(previous_attempt).rstrip()}\n"
73
+ if previous_attempt is not None
74
+ else ""
75
+ )
63
76
  )
64
77
 
65
78
 
@@ -1366,13 +1366,16 @@ Direct branches and `outcomes` cannot be combined; use `outcomes` for custom
1366
1366
  labels.
1367
1367
 
1368
1368
  The agent sees the choice before it answers: the assessment's page lists each
1369
- outcome and what it does, for example "`negative` — ends the workflow here".
1369
+ outcome and what it does, for example "`negative` — ends the workflow here",
1370
+ and says that once the step is complete the manager records the outcome with
1371
+ `next --outcome <label>`.
1370
1372
  Once the assessment is complete, the next page asks for the outcome and shows
1371
- one `next --outcome <label>` command per outcome, never a plain `next`, which
1372
- ww would refuse. An outcome made of an automatic command runs only after its
1373
- outcome is chosen; ww pauses at a pending assessment rather than running any
1374
- branch. A delegating manager chooses it itself; no worker preview is
1375
- shown until the outcome decides which work comes next.
1373
+ one `next --outcome <label>` command per outcome; a plain `next` runs nothing
1374
+ and shows that choice again. An outcome made of an automatic command runs only
1375
+ after its outcome is chosen; ww pauses at a pending assessment rather than
1376
+ running any branch. A delegating manager chooses it itself; no worker preview
1377
+ is shown until the outcome decides which work comes next, and the worker's
1378
+ handoff block ends with the same one command per outcome.
1376
1379
 
1377
1380
  `profile` may be a name or a mapping containing `name` and/or `description`.
1378
1381
  The mapping form supplies an inline description. ww resolves a named profile by
@@ -1537,7 +1540,16 @@ manager continues. `awaiting_operator` means a human must decide; see
1537
1540
  At handoff only the manager runs the displayed `next --role manager` command.
1538
1541
  In the `auto` runtime the manager's delegate page and the requested worker
1539
1542
  describe the step that drives selection, not whichever hook the cursor is on,
1540
- and both the manager and the worker are told every item the assignment covers.
1543
+ and both the manager and the worker are told every item the assignment covers,
1544
+ in plan order, the ones ww runs itself marked: `This assignment covers, in
1545
+ order: `develop`, `git-push` (run by `ww`), `update-workflow-summary`.` while
1546
+ nothing is done, then, once some of them are completed, `Already completed in
1547
+ this assignment: ... Remaining, in order: ...`, derived from the items'
1548
+ execution status rather than from the assignment's first item. The line is
1549
+ omitted when one item or none remains; while it is shown and ww is running an
1550
+ automatic item of the assignment, a commit hook or a push, it names it: `` `ww`
1551
+ is now running `git-push`. `` The previous manager page's "Upcoming
1552
+ assignment" preview lists the same items.
1541
1553
  A worker moving to a later item of the same assignment is told so explicitly,
1542
1554
  and the end of an assignment says to stop and return to the manager.
1543
1555
 
@@ -1548,9 +1560,11 @@ the `awaiting_input` instruction is addressed to the manager, its command
1548
1560
  carries `--role manager`, and the preview before it says that no worker is
1549
1561
  selected. Every pending-input page also lists, under "Work these values
1550
1562
  describe", the handovers of the steps completed since that handler last ran
1551
- in the run, so a commit message names this round's work rather than repeating
1552
- an earlier one. The first page of each session shows the requirements saved by
1553
- `init` in full under "Task requirements", so the user's wording reaches the worker
1563
+ in the run, through any of its placements, so a commit message names this
1564
+ round's work rather than repeating an earlier one; a run that found nothing to
1565
+ commit does not count as one. The first page of each session shows the
1566
+ requirements saved by `init` in full under "Task requirements", so the user's
1567
+ wording reaches the worker
1554
1568
  without the manager adding commentary: the manager's first page that asks for
1555
1569
  work, the first page of every delegated worker assignment (each is a fresh
1556
1570
  session; `pages.worker_requirements` in `ww.json` set to `pointer` swaps it for
@@ -1692,7 +1706,9 @@ Manager: continue with `./ww next TASK-7 --role manager`
1692
1706
  When the block ends a child task's run (the task ID has a `/` and no run of it
1693
1707
  is open any more), the last line names the parent instead: "Manager: continue
1694
1708
  with the parent task: `./ww next TASK-7 --role manager`". A child that is only
1695
- partway through its run keeps its own command.
1709
+ partway through its run keeps its own command. When the assignment ended with
1710
+ an assessment, the last line instead asks the manager to choose its outcome
1711
+ and lists one `next --outcome <label>` command per outcome.
1696
1712
 
1697
1713
  It lists every agent item the worker performed in the assignment with its
1698
1714
  outcome (`completed`, `loop break`, `loop continue`, `held for verification`,
@@ -2053,6 +2069,28 @@ without children, and a retried request that already bound its child simply
2053
2069
  reports the bound task. A child added with an explicit `--id` skips the request,
2054
2070
  as an explicit ID does for `start`.
2055
2071
 
2072
+ The identity page shows the child's text as its task requirements, and
2073
+ `requirements REQUEST-…` prints them while the request is open (a request has
2074
+ no run and no amendments). Wherever a request ID is accepted (`next`,
2075
+ `instruction`, `status`, `fail`, `complete`, `requirements`, `reset`), the
2076
+ parent-qualified name the parent's child record uses, `EPIC-1/REQUEST-…`,
2077
+ names the same request.
2078
+
2079
+ The identity step cannot be skipped, since there is no task without the
2080
+ external ID it obtains, so a failed request has two recoveries. `fail` shows
2081
+ them both:
2082
+
2083
+ ```console
2084
+ ww-agentic-workflows next REQUEST-20260923101500123456 --retry --yes --role manager
2085
+ ww-agentic-workflows reset REQUEST-20260923101500123456 --yes
2086
+ ```
2087
+
2088
+ `next --retry` reopens the failed request and dispatches the step again;
2089
+ `next --force` is refused for a request. `reset` removes the request and
2090
+ returns the parent's child record to pending, with its start operation kept,
2091
+ so `start-child EPIC-1 REQUEST-…` opens a fresh request for the same child. A
2092
+ request that has already bound its task is not reset; that task is.
2093
+
2056
2094
  A child can also be named by the parent at collection time: with the parent as
2057
2095
  an epic and its children as the epic's tasks, the agent creates each ticket,
2058
2096
  then records it with `add-child EPIC-1 --id TASK-7 --text ...`, making the
@@ -2157,8 +2195,11 @@ the completion is rejected: nothing is saved, the artifact is kept only as a
2157
2195
  draft, the step stays in progress with its worker, and `complete` exits
2158
2196
  non-zero. The response is the fix page, `## Fix required: 2 of 5 checks failed
2159
2197
  (attempt 1 of 3)`, with each failed check's rule text, command, and the last 40
2160
- lines it printed, then the same completion command; `fix_required` in JSON.
2161
- The worker fixes the causes and completes again with a revised artifact.
2198
+ lines it printed, the rejected artifact under `### Draft artifact`, then the
2199
+ same completion command; `fix_required` in JSON. The worker fixes the causes
2200
+ and completes again with the whole revised artifact, which replaces the draft
2201
+ entirely; the accepted artifact file keeps the rejected one under a
2202
+ **Previous attempt** heading.
2162
2203
 
2163
2204
  A failed check always goes back to the worker, never to the operator, until
2164
2205
  it has failed `max_fixes` times: the rule's own value, else `limits.fixes` in
@@ -2357,8 +2398,13 @@ the missing file.
2357
2398
  froze it: its full text, globs, rule file, command, and the steps that carry
2358
2399
  it, and for a rule without a command what the store knows about its wording.
2359
2400
  `ww rules` lists the project's declared groups, with their filters and each
2360
- rule's ID and first sentence, and each step's own rules; `--json` gives the
2361
- same for a program. `ww rules prune` deletes store entries no declared rule
2401
+ rule's ID and first sentence, each step's own rules, and then every
2402
+ workflow's steps as a `steps` filter can name them: one line per step with
2403
+ its path, which reaches exactly that step where a leaf name would match it
2404
+ everywhere (loop bodies and per-item stages included), the groups reaching
2405
+ it, or that it is not an agent step and takes no rules. `--json` gives the
2406
+ same for a program, the steps as `targets` with `workflow`, `step`, `path`,
2407
+ `agent_owned` and `groups`. `ww rules prune` deletes store entries no declared rule
2362
2408
  needs any more, after listing them and asking; `--yes` skips the question.
2363
2409
  `ww rules revoke <check>` rejects a converted or proposed check and its rules
2364
2410
  the same way.
@@ -2367,8 +2413,8 @@ the same way.
2367
2413
 
2368
2414
  Rules are easiest to add in conversation. Invoked as `/ww-rule`, or when you
2369
2415
  ask an agent to add or change a rule, the `ww-rule` skill carries the
2370
- judgment: it reads the groups (`ww rules --json`) and the real workflow and
2371
- step names (`ww discover`), splits what you said into atomic obligations,
2416
+ judgment: it reads the groups and the real workflow and step names from
2417
+ `ww rules --json`, splits what you said into atomic obligations,
2372
2418
  tells a new rule from an amendment of an existing one or a change of where a
2373
2419
  group applies, gives a rule globs only when it names a kind of file and
2374
2420
  counts what each matches, places it in a group whose filters fit, and
@@ -2405,6 +2451,13 @@ Reaches these steps (an agent step's page shows it):
2405
2451
  sentence unless `--id` names it, with `--paths` globs, `--contains` strings
2406
2452
  (it reports how many files hold each) and a check from `--check-shell` or
2407
2453
  `--check-argv` and `--assert empty|eq:<value>`. It never overwrites a file.
2454
+ A group that lists its rule files one by one instead of a directory gets
2455
+ the file beside its last one, or in `--dir <path>`, and the file's path
2456
+ appended to its `rules` list: `ww-rules.yaml` is rewritten whole; `ww.yaml`
2457
+ or another file of yours gains that one line, checked to change nothing
2458
+ else, and the command refuses with the line to add by hand when the list is
2459
+ written in a way it cannot extend (flow style, an anchor). A group that
2460
+ names only other groups needs `--dir`.
2408
2461
  - `rules add --group <name> --dir <path>` adds a root group, with optional
2409
2462
  `--workflows` and `--steps` filters. ww never rewrites
2410
2463
  `ww.yaml`: the group goes into `ww-rules.yaml` next to
@@ -2416,7 +2469,9 @@ Reaches these steps (an agent step's page shows it):
2416
2469
  and, when the old wording had an approved check, that `rules promote` keeps
2417
2470
  it.
2418
2471
  - `rules move <id> <group>` moves the file, unchanged, into another group's
2419
- directory; its wording, and so what the store knows about it, stays.
2472
+ directory, or beside the last file of a group that lists files and into its
2473
+ `rules` list as `rules add` does; its wording, and so what the store knows
2474
+ about it, stays.
2420
2475
  - `rules filter <group> --workflows ... --steps ...` changes where a group of
2421
2476
  `ww-rules.yaml` applies (`--workflows '*'` writes `"*"`; `--all-workflows` and
2422
2477
  `--all-steps` remove a filter, which also means all); a group declared
@@ -2485,7 +2540,10 @@ hook to declare a transition.
2485
2540
  Interpolations use `{{name}}`, with double braces everywhere. Every value ww
2486
2541
  provides lives under `ww.`, so a name without it is always a variable a step
2487
2542
  handed back: `{{ww.task.id}}` is the task's ID and `{{ww.task.workflows}}` the
2488
- ordered workflow-name list, joined by commas.
2543
+ ordered workflow-name list, joined by commas. `{{ww.task.slug}}` is the task ID
2544
+ as one path component, each `/` of a child task's `parent/child` ID replaced
2545
+ by `-` (`TASK-42/A` reads `TASK-42-A`), for file names, branch names and other
2546
+ places a slash would nest or split the ID.
2489
2547
  The core `{{ww.task.workspace_dir}}` variable is always the canonical directory for
2490
2548
  the task: the project root by default, the configured project directory when a
2491
2549
  task was started with `--project`, or the selected task checkout when an
@@ -2508,6 +2566,20 @@ the performer passes it with `complete --variable name=<value>`. A bare string,
2508
2566
  `- name`, is a value an automatic action returns itself. A step's values are
2509
2567
  available to its completion hooks and later plan items.
2510
2568
 
2569
+ A value an automatic handler asks for is consumed by it: once the handler has
2570
+ run with it, ww removes the value from the run again, unless a later hook of
2571
+ the same completion asks for it too, in which case it stays until that hook
2572
+ has run. The next handler that asks for the same name, a `git-commit` after a
2573
+ review loop or one that is a step of its own, therefore requests it afresh
2574
+ (`awaiting_input`) instead of running silently with the message an earlier
2575
+ step supplied. A failed handler releases its values the same way when it is
2576
+ retried, keeping them on its record so the request can show what it was given
2577
+ last time. A handler with a precondition asks only when it needs the value:
2578
+ `git-commit` needs no message while the task workspace has nothing to commit,
2579
+ so such a value is optional on the step's completion (the page says so), and
2580
+ when it is left out ww asks for it only if the workspace changed; a clean one
2581
+ commits nothing without a question.
2582
+
2511
2583
  When several automatic completion hooks request the same variable with the
2512
2584
  same description, ww asks for it once and gives that value to each hook.
2513
2585
  For example, project and workflow commit hooks share one `commit_message`.
@@ -2742,7 +2814,12 @@ holds the conversation, the manager in the `auto` runtime: it is a
2742
2814
  `role: manager` step, and the step's profile, agent, model, and reasoning
2743
2815
  are ignored. For a manual-testing workflow, put `interactive: true` on the
2744
2816
  per-item stage: the manager presents each test case, waits for the operator's
2745
- result, records it, ends the interaction, and completes the item.
2817
+ result, records it, ends the interaction, and completes the item. Running
2818
+ `next` again while such a step is open shows its page again, as it does for
2819
+ any open step in the `single` runtime; `complete` is not the way to leave an
2820
+ interactive step before the conversation ended. Only a worker's open item is
2821
+ refused, and the refusal names the ways out: `instruction` to see its page,
2822
+ `complete` to finish it, `next --reassign` to dispatch it again.
2746
2823
 
2747
2824
  A conversation is recorded once, when it ends. A session that ends in the
2748
2825
  middle of one has not recorded it, and ww does not recover it from the
@@ -2950,6 +3027,14 @@ steps/
2950
3027
  02-fix.md
2951
3028
  ```
2952
3029
 
3030
+ The `Step N of M` line in each step artifact's workflow context uses the same
3031
+ ordinals: `N` is the file's ordinal, dotted for a nested step (`02-fix.md`
3032
+ under `03-plan-and-fix/` reads `Step 3.2 of 3`), and `M` is the number of
3033
+ top-level steps the workflow declares, so a group counts once and the total
3034
+ does not change when items, children or a replan add plan items mid-run. The
3035
+ artifact of a step performed by an identity request (`REQUEST-…`) is
3036
+ numbered the same way once it is written into the bound task.
3037
+
2953
3038
  Loop bodies add an `iteration-NN` directory beneath each loop wrapper. Every
2954
3039
  round therefore keeps its own step and hook artifacts instead of overwriting
2955
3040
  the files from an earlier round:
@@ -3621,8 +3706,10 @@ An extension handler runs inside ww rather than as a shell command, so it can
3621
3706
  remember what it did. `ww/git`'s `git-commit` commits and then records the
3622
3707
  commit, and `commits` reads that back. It stages the task workspace first; when
3623
3708
  nothing is staged, for example after a review round that needed no fix, it
3624
- succeeds without a commit and without invoking project pre-commit hooks such as
3625
- Husky or lint-staged:
3709
+ succeeds without a commit, without a `commit_message`, and without invoking
3710
+ project pre-commit hooks such as Husky or lint-staged. Its precondition tells
3711
+ ww whether the workspace has anything to commit, so a clean one is committed
3712
+ without asking for a message at all:
3626
3713
 
3627
3714
  ```console
3628
3715
  ww-agentic-workflows extensions # what is installed, and what it provides
@@ -3727,8 +3814,12 @@ and return-to-base use one stable value. The record is trusted only while it
3727
3814
  names the branch being resolved and that branch exists; a record of another
3728
3815
  branch, or of a deleted one, is left behind by an earlier task under the same
3729
3816
  ID, and the configured base is resolved instead. A child task always uses its
3730
- recorded parent task branch instead. `reset` drops the task's branch and commit
3731
- records, and its children's.
3817
+ recorded parent task branch instead, and its branch is that branch plus
3818
+ `-<child id>`; without a recorded parent branch, the format is rendered for the
3819
+ parent ID and `-<child id>` appended, so `TASK-51/A` under
3820
+ `feature/{{ww.task.id}}` is `feature/task-51-a`, never a `feature/task-51/a`
3821
+ that Git would refuse beside `feature/task-51`. `reset` drops the task's branch
3822
+ and commit records, and its children's.
3732
3823
 
3733
3824
  `branch_name_formats` names the available branch naming strategies. Without an
3734
3825
  override, `start-task-branch` first looks for a strategy matching the workflow
@@ -3932,6 +4023,16 @@ workspace, and no effects, and it does not replace the check the handler makes
3932
4023
  when it runs: `ww/git` declares one for `commit_message` and still checks the
3933
4024
  same rule in `git-commit`.
3934
4025
 
4026
+ Such a handler may also declare `needs_input`, a precondition: whether the
4027
+ handler needs its declared inputs this run; `False` lets ww run it without
4028
+ asking. ww consults it, with the handler's ordinary context, when the inputs
4029
+ are missing: the values of a handler with a precondition are optional on the
4030
+ agent's completion, and when they are left out ww asks for them only if the
4031
+ precondition says they are needed (a precondition that raises counts as
4032
+ needing them). The handler must then accept running without them: `ww/git`'s
4033
+ `git-commit` needs its message only while the task workspace has something
4034
+ to commit, and commits nothing without one otherwise.
4035
+
3935
4036
  ```python
3936
4037
  def _subject_error(values):
3937
4038
  if "\n" in values.get("commit_message", ""):
@@ -3939,11 +4040,16 @@ def _subject_error(values):
3939
4040
  return None
3940
4041
 
3941
4042
 
4043
+ def _needs_commit_message(context):
4044
+ return bool(_git(context, "status", "--porcelain").stdout)
4045
+
4046
+
3942
4047
  ExtensionHandler(
3943
4048
  "git-commit",
3944
4049
  _commit,
3945
4050
  provide=(ProvidedVariable("commit_message"),),
3946
4051
  validate=_subject_error,
4052
+ needs_input=_needs_commit_message,
3947
4053
  )
3948
4054
  ```
3949
4055
 
@@ -4120,7 +4226,9 @@ anything is saved, ww hands each value to the handler that will consume it:
4120
4226
  a handler that declares a validator, such as `ww/git`'s `git-commit` for
4121
4227
  `commit_message`, refuses a value it would fail on, and the completion fails
4122
4228
  with the handler's own message and records nothing, so the agent corrects the
4123
- value and completes again. `ww` then
4229
+ value and completes again. A value whose handler has a precondition is
4230
+ optional, and the screen says so: left out, it is requested later only when
4231
+ the handler needs it, as `git-commit` does only with something to commit. `ww` then
4124
4232
  executes those handlers itself before it activates the next worker item or
4125
4233
  returns control to the manager. If an automatic command fails, the worker stops
4126
4234
  and reports the failure to the manager. The response reports
@@ -4722,23 +4830,43 @@ ww writes the record: the workflow's name, the time, the task and run IDs, the
4722
4830
  agent, runtime and modes, the ww version with the plan and task-state schema
4723
4831
  versions, the workflow's definition as written in `ww.yaml` (not the compiled
4724
4832
  plan), and the two arrays. The record's ID is the task and run, such as
4725
- `TASK-42--01-task`; a child task's slash becomes a plus.
4833
+ `TASK-42--01-task`; a child task's slash becomes a dash, as in
4834
+ `{{ww.task.slug}}` (`TASK-42-A--01-task`).
4726
4835
 
4727
4836
  The agent is told about the collection exactly once: the first page of a run
4728
4837
  asks it to say that ww collects debug info or feedback at the end of the run,
4729
4838
  that it stays on this machine, and where. The collection itself is silent
4730
4839
  until the summary step. Nothing is ever sent by itself.
4731
4840
 
4841
+ A debug record also carries an `events` array, apart from the agent's two
4842
+ arrays, with what ww itself observed while `debug.collect` was on: a `fail`
4843
+ (on a task or on an identity request, with the error), a `next --force` with
4844
+ what it forced and the operator's reason, a `dispute`, and every stop for the
4845
+ operator (the `operator_reason` and the error, once per stop, not on every
4846
+ reading of the page). Each event has `at`, `source` (`ww`, or `operator` for
4847
+ a note) and `summary`, plus `detail`. Events wait under
4848
+ `.ww/debug/pending/` until the run completes, when the record takes them
4849
+ over; the events of an identity request go to the record of the task the
4850
+ request bound.
4851
+
4732
4852
  ```console
4733
4853
  ./ww debug list
4734
4854
  ./ww debug show TASK-42--01-task
4855
+ ./ww debug note TASK-42 --summary "The fix page named the wrong step" --detail "..."
4735
4856
  ./ww workflow-feedback list
4736
4857
  ./ww workflow-feedback show TASK-42--01-task --json
4737
4858
  ```
4738
4859
 
4739
4860
  `list` names every record with its counts and whether it was reported;
4740
4861
  `show` prints one as Markdown, exactly what a report would send; `--json`
4741
- gives the records themselves.
4862
+ gives the records themselves. `note` keeps the operator's own observation of
4863
+ ww's behaviour: given a record ID, or a task whose run completed, the note is
4864
+ added to that record's events; given a task still running or an identity
4865
+ request, it waits with the pending events for the run's record and is also
4866
+ written as a standalone record (`TASK-42--notes`, empty agent arrays), which
4867
+ the run's own record replaces once it completes, so a note on a run that
4868
+ never completes is still kept. The note is written whether or not
4869
+ `debug.collect` is on.
4742
4870
 
4743
4871
  ### Reporting debug records
4744
4872